Skip to content

Commit 08468ae

Browse files
committed
Move websocket constants and security tokens from shared to editor package with legacy support
- move `packages/shared/src/constants/websocket.ts` to `apps/editor/src/constants` - we recently changed name of the tool to 'code web chat', should update security tokens in a backward compatible way (with a comment the old tokens should be removed after at least Dec 2026) └── apps └── editor ├── package.json └── src ├── constants │ ├── agents.ts │ ├── edit-format-instructions.ts │ ├── ignored-lock-files.ts │ ├── instructions.ts │ ├── providers.ts │ ├── secret-storage-keys.ts │ ├── state-keys.ts │ ├── values.ts │ └── websocket.ts ├── i18n │ └── translations │ └── utils │ └── agentic-cli-invocation.ts ├── services │ ├── websocket-manager.ts │ └── websocket-server-process.ts └── utils └── agentic-cli-invocation ├── agents │ ├── antigravity.ts │ ├── claude.ts │ ├── codex.ts │ ├── cursor.ts │ ├── grok.ts │ ├── index.ts │ ├── muse.ts │ └── opencode.ts ├── invoke-agentic-cli.ts └── utils └── check-command-exists.ts
1 parent 008f1dd commit 08468ae

5 files changed

Lines changed: 20 additions & 16 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export const DEFAULT_PORT = 55155
2+
export const SECURITY_TOKENS = {
3+
BROWSER: 'code-web-chat-browser',
4+
EDITOR: 'code-web-chat-editor',
5+
// TODO: Remove legacy tokens after at least Dec 2026
6+
LEGACY_BROWSER: 'gemini-coder',
7+
LEGACY_EDITOR: 'gemini-coder-vscode'
8+
}

‎apps/editor/src/services/websocket-manager.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
WebSocketMessage
1212
} from '@shared/types/websocket-message'
1313
import { CHATBOTS } from '@shared/constants/chatbots'
14-
import { DEFAULT_PORT, SECURITY_TOKENS } from '@shared/constants/websocket'
14+
import { DEFAULT_PORT, SECURITY_TOKENS } from '@/constants/websocket'
1515
import { Logger } from '@shared/utils/logger'
1616
import { WebConfiguration } from '@shared/types/web-configuration'
1717
import { ConfigWebConfigurationFormat } from '@/utils/web-configuration-format-converters'
@@ -26,7 +26,7 @@ import { t } from '@/i18n'
2626
export class WebSocketManager {
2727
private extension_context: vscode.ExtensionContext
2828
private port: number = DEFAULT_PORT
29-
private security_token: string = SECURITY_TOKENS.VSCODE
29+
private security_token: string = SECURITY_TOKENS.EDITOR
3030
private client: WebSocket.WebSocket | null = null
3131
private _on_connection_status_change: vscode.EventEmitter<boolean> =
3232
new vscode.EventEmitter<boolean>()

‎apps/editor/src/services/websocket-server-process.ts‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as process from 'process'
33
// eslint-disable-next-line @typescript-eslint/no-var-requires
44
const WebSocket = require('ws')
55

6-
import { DEFAULT_PORT, SECURITY_TOKENS } from '@shared/constants/websocket'
6+
import { DEFAULT_PORT, SECURITY_TOKENS } from '../constants/websocket'
77

88
interface BrowserClient {
99
ws: WebSocket
@@ -76,12 +76,19 @@ class WebSocketServer {
7676
const url = new URL(request.url || '', `http://localhost:${DEFAULT_PORT}`)
7777
const token = url.searchParams.get('token')
7878

79-
if (token != SECURITY_TOKENS.BROWSERS && token != SECURITY_TOKENS.VSCODE) {
79+
if (
80+
token != SECURITY_TOKENS.BROWSER &&
81+
token != SECURITY_TOKENS.EDITOR &&
82+
token != SECURITY_TOKENS.LEGACY_BROWSER &&
83+
token != SECURITY_TOKENS.LEGACY_EDITOR
84+
) {
8085
ws.close(1008, 'Invalid security token')
8186
return
8287
}
8388

84-
const is_browser_client = token == SECURITY_TOKENS.BROWSERS
89+
const is_browser_client =
90+
token == SECURITY_TOKENS.BROWSER ||
91+
token == SECURITY_TOKENS.LEGACY_BROWSER
8592

8693
if (is_browser_client) {
8794
this._handle_browser_connection(ws, url)

‎packages/shared/src/constants/api-tools.ts‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎packages/shared/src/constants/websocket.ts‎

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)