dsh-code-server-app 0.3.29 → 0.3.31

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.
@@ -376,6 +376,10 @@ async function pollOnce() {
376
376
  // 声明"本扩展懂对话流修订号"(0.2.9):host 才会在没变化时省略 thread 省流量。
377
377
  // 不声明(旧扩展)时 host 照旧发整份快照 —— 否则旧扩展会误报"宿主没有对话流能力"。
378
378
  threadRev: lastThreadRev,
379
+ // 声明"我这边能把授权卡片画出来"(0.3.30):面板开着 **且** 对话流正常(不是那条"宿主没有对话流能力"
380
+ // 的坏状态)。宿主只在它为 true 时才敢抢答授权 —— 否则"抢过来却没人看得见"就是用户遇到的
381
+ // "没弹出授权"(官方卡片被我们吞了,面板又不画)。
382
+ approvalsUi: askPanel !== null && askPanel.state.available === true,
379
383
  };
380
384
  const result = await client.sync(payload);
381
385
  if (result.ok !== true) {
@@ -641,8 +645,19 @@ async function openAskPanelFor(mode) {
641
645
  // 0.2.5/0.2.6 试过"浮在 DSH 页面上的对话框",但实测在编辑器侧看不到授权卡片,而面板这条路是
642
646
  // 验证过的(0.3.22/0.3.23 实测卡片就在面板里)。功能优先:先把能看、能批授权的 UI 还给用户;
643
647
  // 对话框那套(client 半部 + /api/code-server/ask/*)留着但**不再自动启用**。
648
+ // 0.3.30:把悬浮对话框还回来(用户要的形态),但只在宿主证明客户端半部在轮询时才用
649
+ // (askDialogSupported 现在等于 askDialogLive());否则安静退回编辑器面板 —— 两条路都能看能批授权。
644
650
  if (askDialogSupported) {
645
- log('宿主声明支持 DSH 页面对话框;本版仍用编辑器面板(0.3.26 回退,对话框待验证后再启用)');
651
+ try {
652
+ const result = await client.askOpen(mode);
653
+ if (result !== null && result.ok === true) {
654
+ log('已请宿主打开悬浮对话框(mode=' + mode + ')');
655
+ return;
656
+ }
657
+ log('宿主没有打开对话框(' + (result !== null && result.error ? result.error : '未知原因') + ')→ 退回编辑器面板');
658
+ } catch (error) {
659
+ log('ask-open 失败(' + (error && error.message ? error.message : error) + ') → 退回编辑器面板');
660
+ }
646
661
  }
647
662
  openAskPanel(mode);
648
663
  }
@@ -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.10",
5
+ "version": "0.2.12",
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-13T10:00:36.531Z
14
+ 生成时间:2026-09-13T11:54:47.758Z
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
@@ -753,6 +753,34 @@ export async function apply(ctx, config) {
753
753
  const bridgeWatch = { ids: [], dialogIds: [], at: 0 };
754
754
  /** 上次回给扩展的对话流修订号(0.3.27:没变化就不重传整份快照)。 */
755
755
  let bridgeThreadRevSent = -1;
756
+ /** 上次记录过的"有没有人在看"(0.3.30:状态翻转才写诊断日志)。 */
757
+ let bridgeWatchLogged = false;
758
+ /** 首帧是否已写过诊断(0.3.31:"一直没人看"也要留下证据)。 */
759
+ let bridgeWatchWroteFirst = false;
760
+ /** 客户端(self-declared)是否能把授权卡片画出来(0.3.30)。 */
761
+ let bridgeApprovalsUi = false;
762
+ let bridgeApprovalsUiLogged = false;
763
+
764
+ /**
765
+ * 授权/看护状态的**诊断日志**(0.3.30):写到 <home>/.dsh/code-server/bridge-approval.log。
766
+ * "卡片为什么不出现"只有三个问题:有没有人在看 / 请求到没到 / 谁答的 —— 三件事都在宿主进程里,
767
+ * 用户看不到、我也读不到;落成有界文件后一次复现就能定论。
768
+ */
769
+ function bridgeDiag(message) {
770
+ try {
771
+ const dir = path.join(os.homedir(), '.dsh', 'code-server');
772
+ fs.mkdirSync(dir, { recursive: true });
773
+ const file2 = path.join(dir, 'bridge-approval.log');
774
+ try {
775
+ if (fs.statSync(file2).size > 256 * 1024) fs.writeFileSync(file2, '');
776
+ } catch {
777
+ // 首次写入:文件不存在
778
+ }
779
+ fs.appendFileSync(file2, new Date().toISOString() + ' ' + message + '\n');
780
+ } catch {
781
+ // 诊断失败绝不影响主流程
782
+ }
783
+ }
756
784
 
757
785
  /** 当前所有"在看"的会话(去重)。 */
758
786
  function watchedSessions() {
@@ -761,14 +789,27 @@ export async function apply(ctx, config) {
761
789
  }
762
790
  /** 现在有没有人在看(授权拦截的唯一判据)。 */
763
791
  function hasWatcher() {
764
- return watchedSessions().length > 0 && Date.now() - bridgeWatch.at < 5000;
792
+ const sessions = watchedSessions();
793
+ if (sessions.length === 0) return false;
794
+ // **对话框是宿主侧状态**(只在 /ask/close 时消失):不拿轮询新鲜度去判它 ——
795
+ // 浏览器把后台标签的定时器节流到分钟级时,900ms 的心跳一断、5 秒窗口就过期,
796
+ // 我们会误判"没人看"而放弃拦截(用户实测:授权卡片因此跑到 DSH 界面)。
797
+ if (bridgeWatch.dialogIds.length > 0) return true;
798
+ // 编辑器面板靠 /sync 的 600ms 心跳;窗口放宽到 60 秒(正常心跳远小于它)。
799
+ return Date.now() - bridgeWatch.at < 60000;
765
800
  }
766
801
 
767
802
  const bridgeApproval = createApprovalInterceptor({
768
803
  board: bridgeApprovalBoard,
769
804
  holdMs: DEFAULT_HOLD_MS,
770
- hasPanel: hasWatcher,
771
- log: (message) => console.warn(`[code-server] 编辑器桥授权:${message}`),
805
+ // **只在客户端能画卡片时才抢答**(0.3.30):面板/对话框在看 **且** 它自己声明 approvalsUi。
806
+ // 反例(用户实测):面板处于"宿主没有对话流能力"的坏状态时我们仍然抢答 ⇒ 官方卡片不出现、
807
+ // 面板也不画 ⇒ 用户看到的是"没弹出授权",请求在宿主里干等 5 分钟。
808
+ hasPanel: () => hasWatcher() && bridgeApprovalsUi,
809
+ log: (message) => {
810
+ console.warn(`[code-server] 编辑器桥授权:${message}`);
811
+ bridgeDiag(`approval: ${message}`);
812
+ },
772
813
  });
773
814
 
774
815
  /**
@@ -1891,8 +1932,23 @@ export async function apply(ctx, config) {
1891
1932
  // (授权拦截只在面板看着的时候才抢答,否则一律交给官方链路)。
1892
1933
  const watch = Array.isArray(body.watch) ? body.watch.filter((id) => typeof id === 'string' && id !== '') : [];
1893
1934
  bridgeWatch.ids = watch.slice(0, 4);
1935
+ bridgeApprovalsUi = body.approvalsUi === true;
1936
+ if (bridgeApprovalsUi !== bridgeApprovalsUiLogged) {
1937
+ bridgeApprovalsUiLogged = bridgeApprovalsUi;
1938
+ bridgeDiag('approvalsUi → ' + bridgeApprovalsUi + '(客户端可否显示授权卡片)');
1939
+ }
1894
1940
  bridgeWatch.at = Date.now();
1895
1941
  bridgeThread.sync(watchedSessions());
1942
+ // 看护状态变化就写一行;并且**首帧必写**(0.3.31:只记"翻转"会让"一直没人看"这种情况在日志里
1943
+ // 完全空白,事后无从判断 —— 上一轮就是这样被拖了一整轮)。
1944
+ const watchingNow = hasWatcher();
1945
+ if (watchingNow !== bridgeWatchLogged || bridgeWatchWroteFirst !== true) {
1946
+ bridgeWatchLogged = watchingNow;
1947
+ bridgeWatchWroteFirst = true;
1948
+ bridgeDiag('hasWatcher → ' + watchingNow
1949
+ + ' (面板=[' + bridgeWatch.ids.join(',') + '] 对话框=[' + bridgeWatch.dialogIds.join(',') + ']'
1950
+ + ' approvalsUi=' + bridgeApprovalsUi + ')');
1951
+ }
1896
1952
  // 请求过对话框、客户端半部却从没来问过 → 说清楚原因(多半是浏览器还缓存着旧的客户端 bundle)。
1897
1953
  if (askDialog.open && !askDialogLive() && askDialog.warned !== true) {
1898
1954
  askDialog.warned = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-code-server-app",
3
- "version": "0.3.29",
3
+ "version": "0.3.31",
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-13T10:00:35.533Z",
6
+ "preparedAt": "2026-09-13T11:54:46.662Z",
7
7
  "source": "registry",
8
8
  "node": "v24.21.0",
9
9
  "platform": "win32",