Skip to content

Commit

Permalink
Upgrade Theia (except arm/v7) to v1.56.0 including yarn.lock
Browse files Browse the repository at this point in the history
Include new modules:
@theia/ai-chat
@theia/ai-chat-ui
@theia/ai-code-completion
@theia/ai-core
@theia/ai-history
@theia/ai-huggingface
@theia/ai-llamafile
@theia/ai-ollama
@theia/ai-openai
@theia/ai-terminal
@theia/ai-workspace-agent
@theia/plugin-ext-headless
@theia/remote
  • Loading branch information
struanb committed Dec 10, 2024
1 parent 4b7017a commit a0f3bec
Show file tree
Hide file tree
Showing 9 changed files with 9,383 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ ENV BASH_ENV=/tmp/theia-bash-env
# obtain wstunnel binaries from the Dockside Google Cloud Storage bucket. wstunnel is published
# under https://github.com/erebe/wstunnel/blob/master/LICENSE.
RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \
THEIA_VERSION=1.53.2; \
THEIA_VERSION=1.56.0; \
WSTUNNEL_BINARY="https://storage.googleapis.com/dockside/wstunnel/v6.0/wstunnel-v6.0-linux-x64"; \
elif [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
THEIA_VERSION=1.53.2; \
THEIA_VERSION=1.56.0; \
WSTUNNEL_BINARY="https://storage.googleapis.com/dockside/wstunnel/v6.0/wstunnel-v6.0-linux-arm64"; \
elif [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then \
THEIA_VERSION=1.35.0; \
Expand Down
22 changes: 22 additions & 0 deletions ide/theia/1.56.0/bin/dummysh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

# Read the shell from /etc/passwd, using the root shell as a default.
SHELL=$(getent passwd "${USER:-root}" | cut -d: -f7)

# Failover, in case SHELL is parsed incorrectly.
[ -x "$SHELL" ] || SHELL="/bin/sh"

# Restore our original PATH from _PATH and delete _PATH
[ -n "$_PATH" ] && PATH="$_PATH" && unset _PATH

# Delete other env vars set only to override default paths
unset XDG_CACHE_HOME XDG_CONFIG_HOME npm_config_cache THEIA_WEBVIEW_EXTERNAL_ENDPOINT THEIA_MINI_BROWSER_HOST_PATTERN VSCODE_NLS_CONFIG

# Make shell env clean
unset SHLVL OLDPWD

[ -n "$_HOME" ] && HOME="$_HOME" && unset _HOME

cd "$HOME"

exec $SHELL -l "$@"
65 changes: 65 additions & 0 deletions ide/theia/1.56.0/bin/launch-ide.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/opt/dockside/theia/bin/sh -l

# Expects:
# - IDE_PATH
#

log() {
local PID="$$"
local S=$(printf "%s|%15s|%5d|" "$(date +%Y-%m-%d.%H:%M:%S)" "theia" "$PID")
echo "$S$1" >&2
}

which() {
local cmd="$1"
for p in $(echo $PATH | tr ':' '\012'); do [ -x "$p/$cmd" ] && echo "$p/$cmd" && break; done
}

LOG=/tmp/dockside/theia.log

log "Creating logfile '$LOG' ..."
touch $LOG && chmod 666 $LOG

exec 1>>$LOG
exec 2>>$LOG

log "Evaling arguments $@ ..."
eval "$@"

log "Launching IDE from IDE_PATH='$IDE_PATH' ..."

log "Backing up and overriding PATH=$PATH ..."
export _PATH="$PATH"
export PATH="$IDE_PATH/bin:$PATH"

# Run ssh-agent if available, but not already running.
log "Checking for ssh-agent ..."
if [ -x $(which ssh-agent) ] && ! pgrep ssh-agent >/dev/null; then
log "Found ssh-agent binary but no running agent, so launching it ..."
eval $($(which ssh-agent))
fi

# See https://github.com/eclipse-theia/theia/blob/master/CHANGELOG.md under v0.13.0
#
# Webview origin pattern can be configured with THEIA_WEBVIEW_EXTERNAL_ENDPOINT env variable.
# The default value is {{uuid}}.webview.{{hostname}}.
# Here {{uuid}} and {{hostname}} are placeholders which get replaced at runtime with proper webview uuid and hostname correspondingly.
#
# To switch to un-secure mode as before configure THEIA_WEBVIEW_EXTERNAL_ENDPOINT with {{hostname}} as a value.
# You can also drop {{uuid}}. prefix, in this case, webviews still will be able to access each other but not the main window.
#export THEIA_WEBVIEW_EXTERNAL_ENDPOINT='{{uuid}}-webview-{{hostname}}'
#export THEIA_MINI_BROWSER_HOST_PATTERN='{{uuid}}-minibrowser-{{hostname}}'
export THEIA_WEBVIEW_EXTERNAL_ENDPOINT='{{uuid}}-wv-{{hostname}}'
export THEIA_MINI_BROWSER_HOST_PATTERN='{{uuid}}-mb-{{hostname}}'
export SHELL="$IDE_PATH/bin/dummysh"

THEIA_PATH=$IDE_PATH
log "Launching IDE using: $THEIA_PATH/bin/node $THEIA_PATH/theia/src-gen/backend/main.js $HOME --hostname 0.0.0.0 --port 3131 ..."

unset IDE_PATH
cd $THEIA_PATH/theia || exit 1

log "Listing launch environment variables ..."
env | sed -r 's/^/ /' >&2

exec $THEIA_PATH/bin/node $THEIA_PATH/theia/src-gen/backend/main.js $HOME --hostname 0.0.0.0 --port 3131 --plugins=local-dir:$HOME/theia-plugins
109 changes: 109 additions & 0 deletions ide/theia/1.56.0/build/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"private": true,
"name": "@theia/Dockside",
"version": "1.56.0",
"license": "EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0",
"theia": {
"frontend": {
"config": {
"applicationName": "Theia for Dockside from NewsNow Labs",
"warnOnPotentiallyInsecureHostPattern": false,
"preferences": {
"files.enableTrash": false,
"security.workspace.trust.enabled": false
},
"reloadOnReconnect": true
}
},
"backend": {
"config": {
"resolveSystemPlugins": false,
"frontendConnectionTimeout": 3000
}
}
},
"dependencies": {
"@theia/ai-chat": "1.56.0",
"@theia/ai-chat-ui": "1.56.0",
"@theia/ai-code-completion": "1.56.0",
"@theia/ai-core": "1.56.0",
"@theia/ai-history": "1.56.0",
"@theia/ai-huggingface": "1.56.0",
"@theia/ai-llamafile": "1.56.0",
"@theia/ai-ollama": "1.56.0",
"@theia/ai-openai": "1.56.0",
"@theia/ai-terminal": "1.56.0",
"@theia/ai-workspace-agent": "1.56.0",
"@theia/bulk-edit": "1.56.0",
"@theia/callhierarchy": "1.56.0",
"@theia/collaboration": "1.56.0",
"@theia/console": "1.56.0",
"@theia/core": "1.56.0",
"@theia/debug": "1.56.0",
"@theia/editor": "1.56.0",
"@theia/editor-preview": "1.56.0",
"@theia/file-search": "1.56.0",
"@theia/filesystem": "1.56.0",
"@theia/getting-started": "1.56.0",
"@theia/git": "1.56.0",
"@theia/keymaps": "1.56.0",
"@theia/markers": "1.56.0",
"@theia/messages": "1.56.0",
"@theia/metrics": "1.56.0",
"@theia/mini-browser": "1.56.0",
"@theia/monaco": "1.56.0",
"@theia/navigator": "1.56.0",
"@theia/notebook": "1.56.0",
"@theia/outline-view": "1.56.0",
"@theia/output": "1.56.0",
"@theia/plugin-dev": "1.56.0",
"@theia/plugin-ext": "1.56.0",
"@theia/plugin-ext-headless": "1.56.0",
"@theia/plugin-ext-vscode": "1.56.0",
"@theia/plugin-metrics": "1.56.0",
"@theia/preferences": "1.56.0",
"@theia/preview": "1.56.0",
"@theia/process": "1.56.0",
"@theia/property-view": "1.56.0",
"@theia/remote": "1.56.0",
"@theia/scm": "1.56.0",
"@theia/scm-extra": "1.56.0",
"@theia/search-in-workspace": "1.56.0",
"@theia/secondary-window": "1.56.0",
"@theia/task": "1.56.0",
"@theia/terminal": "1.56.0",
"@theia/timeline": "1.56.0",
"@theia/toolbar": "1.56.0",
"@theia/typehierarchy": "1.56.0",
"@theia/userstorage": "1.56.0",
"@theia/variable-resolver": "1.56.0",
"@theia/vsx-registry": "1.56.0",
"@theia/workspace": "1.56.0"
},
"scripts": {
"clean": "theia clean",
"build": "yarn compile && yarn bundle",
"bundle": "theia build --mode development",
"compile": "tsc -b",
"coverage": "yarn test --test-coverage && yarn coverage:report",
"coverage:clean": "rimraf .nyc_output && rimraf coverage",
"coverage:report": "nyc report --reporter=html",
"rebuild": "theia rebuild:browser --cacheRoot ../..",
"prepare": "yarn run clean && yarn production",
"production": "theia build --mode production",
"start": "yarn rebuild && theia start --plugins=local-dir:../../plugins",
"start:debug": "yarn start --log-level=debug",
"start:watch": "concurrently --kill-others -n tsc,bundle,run -c red,yellow,green \"tsc -b -w --preserveWatchOutput\" \"yarn watch:bundle\" \"yarn start\"",
"test": "yarn rebuild && theia test . --plugins=local-dir:../../plugins --test-spec=../api-tests/**/*.spec.js",
"test:debug": "yarn test --test-inspect",
"watch": "concurrently --kill-others -n tsc,bundle -c red,yellow \"tsc -b -w --preserveWatchOutput\" \"yarn watch:bundle\"",
"watch:bundle": "theia build --watch --mode development",
"watch:compile": "tsc -b -w",
"postinstall": "patch-package --error-on-fail"
},
"devDependencies": {
"@theia/cli": "1.56.0",
"patch-package": "^6.2.2",
"postinstall-postinstall": "^2.1.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff --git a/node_modules/@theia/application-manager/lib/generator/frontend-generator.js b/node_modules/@theia/application-manager/lib/generator/frontend-generator.js
index 042b37f..879dfb2 100644
--- a/node_modules/@theia/application-manager/lib/generator/frontend-generator.js
+++ b/node_modules/@theia/application-manager/lib/generator/frontend-generator.js
@@ -75,7 +75,13 @@ require('setimmediate');
const { Container } = require('inversify');
const { FrontendApplicationConfigProvider } = require('@theia/core/lib/browser/frontend-application-config-provider');

-FrontendApplicationConfigProvider.set(${this.prettyStringify(this.pck.props.frontend.config)});
+// Determine Dockside devtainer name from document href hostname,
+// and write the value to the in-memory frontend config
+// (technically, package.json's theia.frontend.config.devtainerName)
+// It will be read by our patched window-title-service.js
+let config = ${this.prettyStringify(this.pck.props.frontend.config)};
+try { config.devtainerName=document.location.href.split('/')[2].split('.')[0].split('--')[0].split('-').slice(1).join('-'); } catch {};
+FrontendApplicationConfigProvider.set(config);

${this.ifMonaco(() => `
self.MonacoEnvironment = {
30 changes: 30 additions & 0 deletions ide/theia/1.56.0/build/patches/@theia+core+1.56.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff --git a/node_modules/@theia/core/lib/browser/core-preferences.js b/node_modules/@theia/core/lib/browser/core-preferences.js
index 23b07eb..526d133 100644
--- a/node_modules/@theia/core/lib/browser/core-preferences.js
+++ b/node_modules/@theia/core/lib/browser/core-preferences.js
@@ -95,7 +95,7 @@ exports.corePreferenceSchema = {
'window.title': {
type: 'string',
default: os_1.isOSX
- ? '${activeEditorShort}${separator}${rootName}'
+ ? '${activeEditorShort}${separator}${rootName}${separator}${appName}'
: '${dirty} ${activeEditorShort}${separator}${rootName}${separator}${appName}',
scope: 'application',
markdownDescription: windowTitleDescription
diff --git a/node_modules/@theia/core/lib/browser/window/window-title-service.js b/node_modules/@theia/core/lib/browser/window/window-title-service.js
index 11cc54c..49dbb8d 100644
--- a/node_modules/@theia/core/lib/browser/window/window-title-service.js
+++ b/node_modules/@theia/core/lib/browser/window/window-title-service.js
@@ -44,7 +44,11 @@ exports.InitialWindowTitleParts = {
appName: frontend_application_config_provider_1.FrontendApplicationConfigProvider.get().applicationName,
remoteName: undefined,
dirty: undefined,
- developmentHost: undefined
+ // Obtain this value from the in-memory frontend config
+ // (technically, package.json's theia.frontend.config.devtainerName, which is set
+ // not in our package.json file, but dynamically during app load by our patched
+ // frontend-generator.js)
+ developmentHost: frontend_application_config_provider_1.FrontendApplicationConfigProvider.get().devtainerName || '[devtainer]'
};
let WindowTitleService = class WindowTitleService {
constructor() {
18 changes: 18 additions & 0 deletions ide/theia/1.56.0/build/patches/@theia+plugin-ext+1.56.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/node_modules/@theia/plugin-ext/lib/main/browser/webview/webview-environment.js b/node_modules/@theia/plugin-ext/lib/main/browser/webview/webview-environment.js
index 7c58dce..3aa490b 100644
--- a/node_modules/@theia/plugin-ext/lib/main/browser/webview/webview-environment.js
+++ b/node_modules/@theia/plugin-ext/lib/main/browser/webview/webview-environment.js
@@ -68,7 +68,12 @@ let WebviewEnvironment = class WebviewEnvironment {
return (await this.externalEndpointUrl()).resolve('theia-resource/{{scheme}}//{{authority}}/{{path}}').toString(true);
}
async cspSource() {
- return (await this.externalEndpointUrl()).withPath('').withQuery('').withFragment('').toString(true).replace('{{uuid}}', '*');
+ // In Dockside, webviews deployed by VSX extensions are launched on variant subdomains
+ // of the devtainer's IDE FQDN, as specified by the values of
+ // THEIA_WEBVIEW_EXTERNAL_ENDPOINT and THEIA_MINI_BROWSER_HOST_PATTERN in launch-ide.sh.
+ // The value of cspSource() must be adjusted accordingly.
+ // See: https://github.com/eclipse-theia/theia/issues/8857
+ return (await this.externalEndpointUrl()).withPath('').withQuery('').withFragment('').toString(true).replace('{{uuid}}\.', '*.');
}
async getHostPattern() {
return environment_1.environment.electron.is()
7 changes: 7 additions & 0 deletions ide/theia/1.56.0/build/patches/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Patch to fix invalid cspSource:
- @theia+plugin-ext+<version>.patch
- https://github.com/eclipse-theia/theia/issues/8857

Patches to modify browser title to incorporate devtainer name:
- @theia+application-manager+<version>.patch
- @theia+core+<version>.patch
Loading

0 comments on commit a0f3bec

Please sign in to comment.