dsh-code-server-app 0.3.25 → 0.3.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -58,8 +58,10 @@ let pollTimer = null;
58
58
  let lastPollAt = 0;
59
59
  /** 「问 DSH」面板:null = 没开。`{panel, state, mode}`(状态模型见 lib/ask-panel.js)。 */
60
60
  let askPanel = null;
61
- /** 宿主是否支持 DSH 页面里的悬浮对话框(0.2.5;/sync 的 askDialog 字段)。 */
61
+ /** 宿主是否支持 DSH 页面里的悬浮对话框(0.2.5 探测;0.3.26 起不再自动启用)。 */
62
62
  let askDialogSupported = false;
63
+ /** 上一份对话流快照(host 只在变化时回传,这里兜住"没变化"的那些轮询)。 */
64
+ let lastThreadSnapshot;
63
65
  /** 扩展根目录(activate 时记下;面板要按它取 webview 产物 URI)。 */
64
66
  let extensionRoot = null;
65
67
  /** 是否已经确认过 host 端点可达(避免把"IDE 刚起、扩展先加载"误判为断线)。 */
@@ -393,11 +395,19 @@ async function pollOnce() {
393
395
  // 能力探测:宿主支持悬浮对话框(0.3.24)⇒ 右键提问不再开编辑器面板。
394
396
  if (result.askDialog === true && !askDialogSupported) {
395
397
  askDialogSupported = true;
396
- log('宿主支持 DSH 页面里的对话对话框:右键提问将浮在 DSH 界面上(不再开编辑器面板)');
398
+ log('宿主支持 DSH 页面里的对话对话框(本版仍用编辑器面板,见 0.3.26 回退)');
397
399
  }
398
400
  // 对话流 + 授权待决:host 每趟把被观看会话的**新内容**与待决授权一起回来
399
401
  // (见 host 侧 lib/bridge-thread.mjs / lib/bridge-approval.mjs),面板有变化才重画。
400
- if (askPanel !== null && applySync(askPanel.state, result)) refreshAskPanel();
402
+ // 0.3.27 起 host **没变化就不带 thread**(省掉每 600ms 一份 ~1MB 的快照,那会把 /sync 拖成超时,
403
+ // 于是 approvals 也一起丢掉、卡片永远不出现)⇒ 这里沿用上一份快照。
404
+ if (askPanel !== null) {
405
+ const thread = result.thread !== undefined
406
+ ? result.thread
407
+ : (result.threadRev !== undefined ? lastThreadSnapshot : undefined);
408
+ if (result.thread !== undefined) lastThreadSnapshot = result.thread;
409
+ if (applySync(askPanel.state, { ...result, thread })) refreshAskPanel();
410
+ }
401
411
  }
402
412
 
403
413
  function startPolling(context) {
@@ -615,19 +625,12 @@ async function openAskPanelFor(mode) {
615
625
  vscode.window.showInformationMessage('没有活动的编辑器:请先打开一个文件。');
616
626
  return;
617
627
  }
618
- // 0.2.5 起优先用 **DSH 页面里的悬浮对话框**(用户要的"对话框形式":浮在 DSH 界面上,不占编辑器版面)。
619
- // 宿主能力由 /sync 的 askDialog 字段探测;老宿主(探测不到)才退回编辑器里的 webview 面板。
628
+ // 0.3.26 回退:提问**始终**开编辑器里的 webview 面板。
629
+ // 0.2.5/0.2.6 试过"浮在 DSH 页面上的对话框",但实测在编辑器侧看不到授权卡片,而面板这条路是
630
+ // 验证过的(0.3.22/0.3.23 实测卡片就在面板里)。功能优先:先把能看、能批授权的 UI 还给用户;
631
+ // 对话框那套(client 半部 + /api/code-server/ask/*)留着但**不再自动启用**。
620
632
  if (askDialogSupported) {
621
- try {
622
- const result = await client.askOpen(mode);
623
- if (result !== null && result.ok === true) {
624
- log(`已请宿主打开对话对话框(mode=${mode}${typeof result.contextText === 'string' ? `,${result.contextText}` : ''})`);
625
- return;
626
- }
627
- log(`宿主没有打开对话框(${result !== null && result.error ? result.error : '未知原因'})→ 退回编辑器面板`);
628
- } catch (error) {
629
- log(`ask-open 失败(${error && error.message ? error.message : error}) → 退回编辑器面板`);
630
- }
633
+ log('宿主声明支持 DSH 页面对话框;本版仍用编辑器面板(0.3.26 回退,对话框待验证后再启用)');
631
634
  }
632
635
  openAskPanel(mode);
633
636
  }
@@ -32,7 +32,9 @@ const BRIDGE_FILENAME = 'bridge.json';
32
32
  const BRIDGE_BASE = '/code-server-bridge';
33
33
  const TOKEN_HEADER = 'x-dshcs-bridge-token';
34
34
  const STATE_FILENAME = 'extension-state.json';
35
- const REQUEST_TIMEOUT_MS = 3000;
35
+ // 请求超时(0.2.8 起 8s):3s 在实测里太紧 —— 对话流快照一大,宿主序列化就要几秒,
36
+ // 超时会让扩展**丢整份响应**(包括 approvals),表现就是"授权卡片一直不出现"。
37
+ const REQUEST_TIMEOUT_MS = 8000;
36
38
  /** 轮询间隔:host 侧事件只是"去看一眼这个文件"的提示,600ms 足够且几乎无开销。 */
37
39
  const POLL_INTERVAL_MS = 600;
38
40
  /** 宿主配置重读间隔(端点/令牌轮换后最多这么久恢复)。 */
@@ -2,7 +2,7 @@
2
2
  "name": "dshcs-editor-bridge",
3
3
  "displayName": "DSH Editor Bridge",
4
4
  "description": "只读地把编辑器状态(未保存缓冲区、诊断、活动选区)提供给 DSH;右键提问打开 DSH 页面里的悬浮对话对话框(0.2.5;老宿主退回编辑器面板),正文/思考/上下文都用 DSH 官方渲染器,并可就地回答授权请求。由 dsh-code-server-app 插件安装,可禁用。",
5
- "version": "0.2.6",
5
+ "version": "0.2.8",
6
6
  "publisher": "dsh-code-server-app",
7
7
  "license": "MIT",
8
8
  "private": true,
@@ -11,7 +11,7 @@
11
11
  | react | 18.3.1 | MIT |
12
12
  | react-dom | 18.3.1 | MIT |
13
13
 
14
- 生成时间:2026-09-13T09:25:29.333Z
14
+ 生成时间:2026-09-13T09:43:23.819Z
15
15
  渲染器:@deepseek-ai/dsh-client-ui-primitives@0.1.5-rc.2(DSH 部署的界面版本:0.1.5-rc.2)
16
16
  设计令牌:@deepseek-ai/dsh-client-ui-theme@0.1.5-rc.2(11 段)
17
17
  KaTeX:已打包(公式排版与 DSH 界面一致)
package/lib/index.js CHANGED
@@ -751,6 +751,8 @@ export async function apply(ctx, config) {
751
751
  * - `at`:最近一次声明的时间(超过 5s 视为没人看)。
752
752
  */
753
753
  const bridgeWatch = { ids: [], dialogIds: [], at: 0 };
754
+ /** 上次回给扩展的对话流修订号(0.3.27:没变化就不重传整份快照)。 */
755
+ let bridgeThreadRevSent = -1;
754
756
 
755
757
  /** 当前所有"在看"的会话(去重)。 */
756
758
  function watchedSessions() {
@@ -1898,14 +1900,23 @@ export async function apply(ctx, config) {
1898
1900
  + '浏览器可能还在用旧的客户端 bundle(硬刷新 / 清 Code Cache)。'
1899
1901
  + '此期间提问会退回编辑器面板,授权也在面板里批。');
1900
1902
  }
1903
+ // **对话流只在变化时回传**(0.3.27):以前每趟 /sync 都塞整份快照(≤120 条 × ≤8KB,可达 ~1MB / 600ms),
1904
+ // 实测把 /sync 拖成 3 秒超时 —— 扩展收不到响应 ⇒ 面板看不到 approvals ⇒ 授权卡片永远不出现
1905
+ // (卡片在宿主里干等到窗口结束才交给 DSH 界面)。现在给修订号,没变化就不重传。
1906
+ const threadRev = bridgeThread.rev(watchedSessions());
1907
+ const snapshot = bridgeThread.supported()
1908
+ ? bridgeThread.snapshot(watchedSessions())
1909
+ : { available: false, sessionId: null, cursor: null, rev: 0, entries: [], error: '宿主没有 sessionController.follow(DSH 版本过旧)' };
1910
+ const threadChanged = threadRev !== bridgeThreadRevSent || snapshot.available === false;
1911
+ bridgeThreadRevSent = threadRev;
1901
1912
  // 对话流走独立字段:每个会话给有界条目(见 lib/bridge-thread.mjs),
1902
1913
  // 授权待决列表也一并回去(面板显示卡片)。
1903
1914
  return jsonResponse({
1904
1915
  ok: true,
1905
1916
  events,
1906
- thread: bridgeThread.supported()
1907
- ? bridgeThread.snapshot(watchedSessions())
1908
- : { available: false, sessionId: null, cursor: null, entries: [], error: '宿主没有 sessionController.follow(DSH 版本过旧)' },
1917
+ // thread 缺省 = 没变化(扩展沿用上一份);threadRev 用来区分"没变化"与"旧宿主没有这个字段"。
1918
+ threadRev,
1919
+ thread: threadChanged ? snapshot : undefined,
1909
1920
  approvals: bridgeApprovalBoard.snapshot(),
1910
1921
  // 授权卡片要在面板上倒计时,窗口长度由 host 给(面板不猜)。
1911
1922
  approvalHoldMs: DEFAULT_HOLD_MS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-code-server-app",
3
- "version": "0.3.25",
3
+ "version": "0.3.27",
4
4
  "description": "VS Code (from a code-server release) inside DSH: a right-sidebar tab driven by the plugin's own launcher over the in-process VS Code server (lib/launcher.mjs). Since 0.3.0 the bundle also ships an editor bridge (assets/extensions/dshcs-editor-bridge): a read-only channel between the in-tree VS Code extension host and DSH, giving the agent what only the editor knows (unsaved buffers, language-server diagnostics, the active selection) and letting editor gestures drive the session. Since 0.3.22 the ask panel renders that session's new content with DSH's own Markdown renderer (pinned to the deployed DSH UI version); since 0.3.23 it is a full-width dialog with collapsible thinking rows and can answer approval requests in place — the bridge's only non-read-only route (POST /approve, constrained to pending in-process requests and the outcomes allowed-once/rejected; panel-first for 5 minutes, handed back to the official card the moment the panel closes). The tab claims DSH file addresses (dsh-resource://file/**) by file type (setting claimExtensions), so the product's own produced-file chips, delivered-file previews and inline prose mentions open in the workbench. The IDE is a resident surface moved with Element.moveBefore instead of being remounted, so switching sidebar tabs no longer reloads it. Opening the tab switches the right sidebar to fullscreen by default (setting fullscreenOnOpen). Following a workspace switch is lightweight: the workbench re-navigates with the new ?folder= and the IDE process is not restarted (since 0.2.12). Requires a DSH with the right-sidebar services (sidebarRightTabs/sidebarRight, >= 0.1.5-alpha.1); older DSH versions get a single upgrade notice on the settings page and no other UI. Two serving modes: loopback port (default) or same-origin mount on DSH's own webServer (/code-server, protected by ctx.connection.requestRejection). No code-server Node layer, no argon2, no C++ toolchain.",
5
5
  "homepage": "https://github.com/jinsiyu/dsh-code-server-app",
6
6
  "repository": {
@@ -3,7 +3,7 @@
3
3
  "vscodeVersion": "1.137.0",
4
4
  "productPath": "stable-b11dabdaca0d3369986975be285db92c8795cea5",
5
5
  "layout": "vscode-only",
6
- "preparedAt": "2026-09-13T09:25:27.979Z",
6
+ "preparedAt": "2026-09-13T09:43:22.825Z",
7
7
  "source": "registry",
8
8
  "node": "v24.21.0",
9
9
  "platform": "win32",