From aa6e7848f95f2c99a2fe4566c6452c8c490fb011 Mon Sep 17 00:00:00 2001 From: QQ Date: Wed, 18 Nov 2026 08:19:46 +0800 Subject: [PATCH] Import patches/0002-fork-fast-mode-lite-projection-force-relay-and-clien.patch --- ...ite-projection-force-relay-and-clien.patch | 173 +++++++++++++++--- 1 file changed, 149 insertions(+), 24 deletions(-) diff --git a/patches/0002-fork-fast-mode-lite-projection-force-relay-and-clien.patch b/patches/0002-fork-fast-mode-lite-projection-force-relay-and-clien.patch index 332ee71..acc4e62 100644 --- a/patches/0002-fork-fast-mode-lite-projection-force-relay-and-clien.patch +++ b/patches/0002-fork-fast-mode-lite-projection-force-relay-and-clien.patch @@ -1,19 +1,21 @@ -From 53a3789330f8ab99cf0295b5b5aafa7d6f44be21 Mon Sep 17 00:00:00 2001 +From a98fb3c8a80450b30fb26e0389fd884ab959524c Mon Sep 17 00:00:00 2001 From: rainow Date: Fri, 13 Nov 2026 11:45:58 +0800 -Subject: [PATCH 2/3] fork: fast mode (lite projection + force relay) and +Subject: [PATCH 2/4] fork: fast mode (lite projection + force relay) and client extras --- + packages/plugin/package.json | 3 +- + packages/plugin/scripts/verify-bundles.mjs | 44 +++++ packages/plugin/src/client-connection.ts | 13 +- - packages/plugin/src/client-locale.ts | 16 ++ + packages/plugin/src/client-locale.ts | 20 ++ packages/plugin/src/client-runtime.ts | 3 +- packages/plugin/src/client.ts | 8 +- - .../plugin/src/client/fast-mode-switches.ts | 92 +++++++++ - packages/plugin/src/client/shell.ts | 3 + + .../plugin/src/client/fast-mode-switches.ts | 94 ++++++++++ + packages/plugin/src/client/shell.ts | 4 + packages/plugin/src/client/types.ts | 1 + packages/plugin/src/client/workspaces.ts | 5 +- - packages/plugin/src/compact-history.ts | 21 ++- + packages/plugin/src/compact-history.ts | 25 ++- packages/plugin/src/config.ts | 10 + packages/plugin/src/control-runtime.ts | 94 ++++++++-- packages/plugin/src/harness-remote-bridge.ts | 46 ++++- @@ -24,19 +26,91 @@ Subject: [PATCH 2/3] fork: fast mode (lite projection + force relay) and packages/plugin/src/server-connection.ts | 24 ++- packages/plugin/src/service.ts | 4 + packages/plugin/tests/client-runtime.test.ts | 1 + + packages/plugin/tests/compact-history.test.ts | 27 +++ packages/plugin/tests/control-runtime.test.ts | 29 +++ .../tests/host-websocket-origin.test.ts | 1 + packages/plugin/tests/lite-mode.test.ts | 91 +++++++++ .../plugin/tests/multi-client-runtime.test.ts | 1 + .../plugin/tests/relay-preference.test.ts | 40 ++++ .../plugin/tests/server-connection.test.ts | 1 + - 25 files changed, 722 insertions(+), 41 deletions(-) + 28 files changed, 806 insertions(+), 42 deletions(-) + create mode 100644 packages/plugin/scripts/verify-bundles.mjs create mode 100644 packages/plugin/src/client/fast-mode-switches.ts create mode 100644 packages/plugin/src/lite-mode.ts create mode 100644 packages/plugin/src/relay-preference.ts create mode 100644 packages/plugin/tests/lite-mode.test.ts create mode 100644 packages/plugin/tests/relay-preference.test.ts +diff --git a/packages/plugin/package.json b/packages/plugin/package.json +index d2b6ab3d..a5c3b058 100644 +--- a/packages/plugin/package.json ++++ b/packages/plugin/package.json +@@ -1,6 +1,6 @@ + { + "name": "ds-harness-remote-fast", +- "version": "0.6.5-fast.2", ++ "version": "0.6.5-fast.3", + "description": "P2P-based, end-to-end encrypted remote access to DeepSeek Harness, CodeX, Claude Code, Pi, and other workspaces from web and mobile clients.", + "keywords": [ + "deepseek", +@@ -78,6 +78,7 @@ + }, + "scripts": { + "build": "node scripts/verify-version-sync.mjs && tsc -p tsconfig.json && node scripts/build-bundles.mjs", ++ "prepack": "node scripts/build-bundles.mjs && node scripts/verify-bundles.mjs", + "check": "node scripts/verify-version-sync.mjs && tsc -p tsconfig.test.json", + "test": "node scripts/verify-version-sync.mjs && vitest run" + }, +diff --git a/packages/plugin/scripts/verify-bundles.mjs b/packages/plugin/scripts/verify-bundles.mjs +new file mode 100644 +index 00000000..1d0e49dc +--- /dev/null ++++ b/packages/plugin/scripts/verify-bundles.mjs +@@ -0,0 +1,44 @@ ++#!/usr/bin/env node ++// Guards `npm publish`: the tarball must ship the esbuild bundles, never the ++// raw `tsc` output. `tsc -p tsconfig.json` writes dist/client.js as an ESM ++// module (starts with `import`), and if that runs after build-bundles the ++// client entry silently stops being importable in the browser. ++// ++// Wired to `prepack`, so `npm pack` / `npm publish` fail loudly instead of ++// shipping a broken package (this happened for 0.6.5-fast.2). ++import { readFile, stat } from 'node:fs/promises' ++import { dirname, join } from 'node:path' ++import { fileURLToPath } from 'node:url' ++ ++const root = join(dirname(fileURLToPath(import.meta.url)), '..') ++const MIN_BUNDLE_BYTES = 300_000 ++ ++const failures = [] ++ ++async function check(file, { minBytes, forbidHead }) { ++ const path = join(root, 'dist', file) ++ let size ++ try { ++ size = (await stat(path)).size ++ } catch { ++ failures.push(`${file}: missing (run the build first)`) ++ return ++ } ++ if (size < minBytes) failures.push(`${file}: ${size} bytes < ${minBytes} — looks like raw tsc output`) ++ if (forbidHead) { ++ const head = (await readFile(path, 'utf8')).slice(0, 200) ++ if (forbidHead.test(head)) failures.push(`${file}: starts with ${JSON.stringify(head.slice(0, 40))} — tsc output, not the bundle`) ++ } ++} ++ ++await check('index.js', { minBytes: 1_000_000 }) ++await check('client.js', { minBytes: MIN_BUNDLE_BYTES, forbidHead: /^\s*(import\s|export\s)/ }) ++await check('client.github.js', { minBytes: MIN_BUNDLE_BYTES, forbidHead: /^\s*(import\s|export\s)/ }) ++ ++if (failures.length > 0) { ++ console.error('Refusing to pack: committed bundles are not esbuild output') ++ for (const line of failures) console.error(` - ${line}`) ++ process.exit(1) ++} ++ ++console.log('Bundle check ok: dist/index.js + client bundles are esbuild output') diff --git a/packages/plugin/src/client-connection.ts b/packages/plugin/src/client-connection.ts index c592d3ac..1f778314 100644 --- a/packages/plugin/src/client-connection.ts @@ -92,13 +166,14 @@ index c592d3ac..1f778314 100644 for (const attempt of attempts) { webRtcFallback = false diff --git a/packages/plugin/src/client-locale.ts b/packages/plugin/src/client-locale.ts -index 4c65bb8e..a08080df 100644 +index 4c65bb8e..cd82f404 100644 --- a/packages/plugin/src/client-locale.ts +++ b/packages/plugin/src/client-locale.ts -@@ -330,6 +330,10 @@ export const en = { +@@ -330,6 +330,11 @@ export const en = { startSignIn: 'Start sign-in', allowControlCurrentDevice: 'Allow control of this device', allowControlDevice: 'Allow control of this device', ++ fastModeGroupTitle: 'Data saver & speed', + liteMode: 'Fast mode', + forceRelay: 'Force relay', + forceRelayHint: 'Skip LAN, internet-direct and TURN probing and connect straight through the encrypted relay. Faster first connection and reconnects, but all traffic goes through the server.', @@ -106,10 +181,11 @@ index 4c65bb8e..a08080df 100644 connectedClientCount: '{count} connected', checkAcp: 'Check backend', checkingAcp: 'Checking ACP…', -@@ -714,6 +718,10 @@ export const zh: Record = { +@@ -714,6 +719,11 @@ export const zh: Record = { startSignIn: '开始登录', allowControlCurrentDevice: '允许控制本机', allowControlDevice: '允许控制本机', ++ fastModeGroupTitle: '省流提速设置', + liteMode: '极速模式', + forceRelay: '强制中继', + forceRelayHint: '跳过局域网、互联网直连和 TURN 探测,直接走加密中继。首次连接与断线重连更快,但流量会经过服务器。', @@ -117,10 +193,11 @@ index 4c65bb8e..a08080df 100644 connectedClientCount: '{count} 台已连接', checkAcp: '检测后端', checkingAcp: '正在检测 ACP…', -@@ -770,6 +778,10 @@ export const zh: Record = { +@@ -770,6 +780,11 @@ export const zh: Record = { } export const ru: Record = { ++ fastModeGroupTitle: 'Экономия трафика и скорость', + liteMode: 'Быстрый режим', + forceRelay: 'Только через ретранслятор', + forceRelayHint: 'Пропускать проверку LAN, прямого соединения и TURN и подключаться сразу через шифрованный ретранслятор. Первое подключение и переподключение быстрее, но весь трафик идёт через сервер.', @@ -128,10 +205,11 @@ index 4c65bb8e..a08080df 100644 serverSavedLive: 'Адрес сервера сохранён и применён.', saveServerBeforeLogin: 'Сохраните адрес сервера, прежде чем продолжить вход или сопряжение.', pairingLoginTab: 'DSH Go', -@@ -1154,6 +1166,10 @@ export const ru: Record = { +@@ -1154,6 +1169,11 @@ export const ru: Record = { } export const uk: Record = { ++ fastModeGroupTitle: 'Економія трафіку та швидкість', + liteMode: 'Швидкий режим', + forceRelay: 'Лише через ретранслятор', + forceRelayHint: 'Пропускати перевірку LAN, прямого зʼєднання й TURN і підключатися одразу через зашифрований ретранслятор. Перше підключення та перепідключення швидші, але весь трафік іде через сервер.', @@ -202,10 +280,10 @@ index 05a27cd6..17447db0 100644 control, diff --git a/packages/plugin/src/client/fast-mode-switches.ts b/packages/plugin/src/client/fast-mode-switches.ts new file mode 100644 -index 00000000..ab0b6b34 +index 00000000..5bdfd281 --- /dev/null +++ b/packages/plugin/src/client/fast-mode-switches.ts -@@ -0,0 +1,92 @@ +@@ -0,0 +1,94 @@ +import type { Translate } from '../client-locale.js' +import type { ClientReact, PluginSettingsView } from './types.js' + @@ -290,25 +368,28 @@ index 00000000..ab0b6b34 + }) { + return React.createElement('div', { + className: props.className ?? 'dshRemoteFastModeSwitches', -+ }, TOGGLE_ORDER.map(key => React.createElement(RemoteToggleSwitch, { -+ key, -+ control: props.control, -+ t: props.t, -+ configKey: key, -+ }))) ++ }, ++ React.createElement('span', { className: 'dshRemoteFastModeGroupTitle' }, props.t('fastModeGroupTitle')), ++ TOGGLE_ORDER.map(key => React.createElement(RemoteToggleSwitch, { ++ key, ++ control: props.control, ++ t: props.t, ++ configKey: key, ++ }))) + } +} diff --git a/packages/plugin/src/client/shell.ts b/packages/plugin/src/client/shell.ts -index 4436301c..e855c955 100644 +index 4436301c..f691348f 100644 --- a/packages/plugin/src/client/shell.ts +++ b/packages/plugin/src/client/shell.ts -@@ -67,6 +67,9 @@ export function installStyle(clientModuleId: string): () => void { +@@ -67,6 +67,10 @@ export function installStyle(clientModuleId: string): () => void { '.dshRemoteSidebarEntry.isWide.hasUpdate .dshRemoteModeButton{border:1px solid color-mix(in srgb,var(--dsw-alias-brand-primary-new-colorprimary-new-color,var(--dsw-alias-brand-primary)) 20%,transparent);background:color-mix(in srgb,var(--dsw-alias-brand-primary-new-colorprimary-new-color,var(--dsw-alias-brand-primary)) 8%,transparent);color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,var(--dsw-alias-brand-primary));font-weight:500}.dshRemoteSidebarEntry .dshRemoteModeButton,.dshRemoteAccountEntry .dshRemoteAccountEntryButton{position:relative}.dshRemoteUpdateSuffix{flex:0 0 auto;margin-left:auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;line-height:18px;font-weight:500}.dshRemoteUpdateDot{position:absolute;inset-inline-end:2px;top:2px;width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-brand-primary-new-colorprimary-new-color,var(--dsw-alias-brand-primary))}', '.dshRemoteSectionHeading{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:10px}.dshRemoteSectionTitle{min-width:0;display:flex;align-items:center;gap:10px}.dshRemoteSectionTitle>strong{font-size:14px}.dshRemoteManageHosts{color:var(--dsw-alias-label-secondary);font-size:12px;text-decoration:none;white-space:nowrap}.dshRemoteManageHosts:hover{color:var(--dsw-alias-label-primary);text-decoration:underline}.dshRemoteSectionActions{display:flex;align-items:center;gap:14px}.dshRemoteSectionActions>button{border:0;background:transparent;color:var(--dsw-alias-label-secondary);cursor:pointer;padding:5px 0;font-size:12px}.dshRemoteSectionActions>button:hover:not(:disabled){color:var(--dsw-alias-label-primary);text-decoration:underline}', '.dshRemoteSectionTitle{flex:1}.dshRemoteSectionTitle>.dshRemoteConnectedMenu{margin-left:auto}', + // The fork's fast-mode row: its own line under the host section heading so + // upstream edits to `.dshRemoteSectionTitle` never move it. + '.dshRemoteFastModeSwitches{display:flex;flex-wrap:wrap;align-items:center;gap:16px;margin:0 0 12px}', ++ '.dshRemoteFastModeGroupTitle{font-size:12px;opacity:.62;white-space:nowrap;margin-right:4px}', '.dshRemoteAcpSetting{display:block!important;width:100%;padding:0}.dshRemoteAcpSetting>summary{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;cursor:pointer;list-style:none}.dshRemoteAcpSetting>summary::-webkit-details-marker{display:none}.dshRemoteAcpSetting>summary::after{content:"⌄";color:var(--dsw-alias-label-secondary);transition:transform .18s ease-out}.dshRemoteAcpSetting[open]>summary::after{transform:rotate(180deg)}.dshRemoteAcpSummaryText{min-width:0}.dshRemoteAcpSummaryText strong{display:block}.dshRemoteAcpSummaryText p{margin:4px 0 0;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1.4}.dshRemoteAcpCheckLink{grid-column:2;grid-row:1;color:var(--dsw-alias-brand-primary);font-size:12px;text-decoration:underline;text-underline-offset:3px}.dshRemoteAcpCheckLink:hover{color:var(--dsw-alias-label-primary)}.dshRemoteAcpCheckResult{grid-column:3;grid-row:1;font-size:11px;line-height:1.4;white-space:nowrap}.dshRemoteAcpCheckResult.isPassed{color:var(--dsw-alias-state-success-primary)}.dshRemoteAcpCheckResult.isFailed{color:var(--dsw-alias-state-danger-primary)}.dshRemoteAcpList{display:flex;flex-direction:column;gap:0;margin-top:12px;padding-top:0;border-top:0}.dshRemoteAcpList>.dshRemoteAuthorizationSetting{display:grid;width:100%;grid-template-columns:minmax(0,1fr) auto auto auto auto;align-items:center;column-gap:18px;line-height:1.4}.dshRemoteAcpList>.dshRemoteAuthorizationSetting>span:first-child{min-width:0;line-height:1.4}.dshRemoteAcpList>.dshRemoteAuthorizationSetting>input{grid-column:4;grid-row:1}', '.dshRemoteAcpAddLink{align-self:flex-start;margin-top:12px;color:var(--dsw-alias-brand-primary);font-size:12px;text-decoration:underline;text-underline-offset:3px}.dshRemoteAcpAddForm{display:grid;grid-template-columns:minmax(100px,.8fr) minmax(140px,1fr) minmax(100px,1fr) auto;gap:8px;margin-top:12px}.dshRemoteAcpAddForm input{min-width:0;height:34px;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;background:var(--dsw-alias-bg-layer-2);color:inherit;padding:0 10px}.dshRemoteAcpAddForm button{border:1px solid var(--dsw-alias-border-l2);border-radius:8px;background:transparent;color:var(--dsw-alias-label-primary);padding:0 12px;cursor:pointer;font:inherit;font-size:12px}.dshRemoteAcpAddForm button:hover{background:var(--dsw-alias-interactive-bg-hover)}.dshRemoteAcpRemoveLink{grid-column:3;grid-row:1;color:var(--dsw-alias-label-secondary);font-size:12px;text-decoration:underline;text-underline-offset:3px}.dshRemoteAcpRemoveLink:hover{color:var(--dsw-alias-state-danger-primary)}', '.dshRemoteAcpCheckResult.isPassed,.dshRemoteAcpCheckResult.isFailed{color:var(--dsw-alias-label-secondary)}', @@ -362,7 +443,7 @@ index ec17b423..6506cb2b 100644 className: `dshRemoteHostList${connectingHost === undefined ? '' : ' isCollapsed'}`, 'aria-busy': connectingHost === undefined ? undefined : true, diff --git a/packages/plugin/src/compact-history.ts b/packages/plugin/src/compact-history.ts -index 8bc8fc26..56592cfc 100644 +index 8bc8fc26..017091c7 100644 --- a/packages/plugin/src/compact-history.ts +++ b/packages/plugin/src/compact-history.ts @@ -9,6 +9,9 @@ const MARKER = '\n[Compact history: output omitted]' @@ -375,7 +456,7 @@ index 8bc8fc26..56592cfc 100644 const object = (value: unknown): value is Record => value !== null && typeof value === 'object' && !Array.isArray(value) type Budget = { remaining: number } -@@ -28,13 +31,23 @@ function summary(value: unknown, budget: Budget): string { +@@ -28,18 +31,32 @@ function summary(value: unknown, budget: Budget): string { return preservedRound(text, budget) ?? text.slice(0, LIMIT) + MARKER } @@ -403,6 +484,15 @@ index 8bc8fc26..56592cfc 100644 } else if (key === 'content' && Array.isArray(child)) { let previews = 0 const blocks = child.flatMap(block => { + // Keep every tool correlation block, even when several share a message. + if (object(block) && (block.type === 'tool-call' || block.type === 'tool-result')) return [toolValue(block, budget)] ++ // An image/file block carries only an attachment reference: flattening it ++ // to `{ summary }` text both loses the image and leaks a truncated JSON ++ // blob into the transcript, so keep the block intact. ++ if (object(block) && ['image', 'file', 'audio', 'video'].includes(String(block.type))) return [block] + const preview = object(block) ? block.text ?? block : block + // A recognised group round is conversation content: keep it even when it + // would fall outside the two-preview budget. Earlier previews already go diff --git a/packages/plugin/src/config.ts b/packages/plugin/src/config.ts index 56e459f1..20c1d2f1 100644 --- a/packages/plugin/src/config.ts @@ -1111,6 +1201,41 @@ index cc1edaf6..cf361eb5 100644 reconnect: { enabled: true, initialDelayMs: 100, maxDelayMs: 1_000, jitter: 0 }, codex: { enabled: false, binary: 'codex' }, cursor: { enabled: false, binary: 'agent' }, +diff --git a/packages/plugin/tests/compact-history.test.ts b/packages/plugin/tests/compact-history.test.ts +index 534c4d59..194723d9 100644 +--- a/packages/plugin/tests/compact-history.test.ts ++++ b/packages/plugin/tests/compact-history.test.ts +@@ -193,3 +193,30 @@ describe('compact group round preservation', () => { + expect(messageText(result.records[0])).toBe(empty) + }) + }) ++ ++describe('compact history attachment blocks', () => { ++ const attachment = { attachmentId: `sha256:${'a'.repeat(64)}`, mediaType: 'image/png', bytes: 101954, width: 860, height: 220, name: 'shot.png' } ++ it('keeps image blocks intact so remote clients can still resolve the attachment', () => { ++ const record = { ++ type: 'event', ++ event: { ++ type: 'tool/result', seq: 12, ++ data: { ++ callId: 'tool-img', turn: 1, ++ message: { source: { callId: 'tool-img' }, content: [ ++ { type: 'tool-result', toolCallId: 'tool-img', content: [ ++ { type: 'text', text: 'ok\n' }, ++ { type: 'image', attachment }, ++ ] }, ++ ] }, ++ }, ++ }, ++ view: { for: 'result', view: { title: 'browser_screenshot' } }, ++ } ++ const result = compactHistory({ cursor: 12, throughSeq: 12, hasMore: false, records: [record] }) ++ const content = (result.records[0] as typeof record).event.data.message.content as unknown as { type: string; content: unknown[] }[] ++ const blocks = content[0]!.content as { type: string; attachment?: unknown }[] ++ expect(blocks.some(block => block.type === 'image')).toBe(true) ++ expect(blocks.find(block => block.type === 'image')!.attachment).toEqual(attachment) ++ }) ++}) diff --git a/packages/plugin/tests/control-runtime.test.ts b/packages/plugin/tests/control-runtime.test.ts index b53566f2..15219611 100644 --- a/packages/plugin/tests/control-runtime.test.ts