dsh-vscode-mode 0.23.2 → 0.23.4

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.
package/README.md CHANGED
@@ -533,13 +533,13 @@ profile 请替换为实际目标,不要把示例目录当成当前运行 profi
533
533
 
534
534
  ```bash
535
535
  # ① Git 安装(clone + prepare 构建;推荐打固定 tag)
536
- dsh plugin --profile web add github:Lenonss/DSH_VsCodeMode#v0.23.1
536
+ dsh plugin --profile web add github:Lenonss/DSH_VsCodeMode#v0.23.4
537
537
 
538
538
  # ② npm 注册表(发布到 npm 后)
539
- dsh plugin --profile web add dsh-vscode-mode@0.23.1
539
+ dsh plugin --profile web add dsh-vscode-mode@0.23.4
540
540
 
541
541
  # ③ GitHub Release tgz 直装(Release asset 可用后)
542
- dsh plugin --profile web add https://github.com/Lenonss/DSH_VsCodeMode/releases/download/v0.23.1/dsh-vscode-mode-0.23.1.tgz
542
+ dsh plugin --profile web add https://github.com/Lenonss/DSH_VsCodeMode/releases/download/v0.23.4/dsh-vscode-mode-0.23.4.tgz
543
543
  ```
544
544
 
545
545
  > **DSH 版本政策(0.17.0 起)**:六项 DSH peer 仍统一声明为 `*`,另以
@@ -880,6 +880,8 @@ Keep All / Undo All 却是亮的。修复:单文件 Keep / Undo 覆盖冲突
880
880
  完整变更见 [GitHub Releases](https://github.com/Lenonss/DSH_VsCodeMode/releases)。
881
881
  近期关键版本:
882
882
 
883
+ - **v0.23.4**:修复桌面端点计划卡「查看全文」会先闪开一页官方计划预览、随即自动关闭。根因:官方卡片走 `ctx.sidebarRight.openResource(planAddress(callId))`,而本插件以 extension 优先级认领了 `dsh-resource://plan/**` 与 `dsh-resource://plan-review/**`,于是侧栏先按本插件类型建出一个页签(正文「正在打开计划预览…」),挂载后才把计划转进「文件编辑」、再把这个页签关掉——用户看到的就是这次建而即关。现由新增 `src/client/planDirect.ts` 在装配期包装 `sidebarRight.openResource`:只接管「2 段计划地址 + 会话为在屏会话」,正文依次取回顾卡片的 `params.planReview`、插件侧地址→正文缓存、可选 `resources.source()` 资源流(上限 1.5s),拿到正文后经 `requestOpen(..., { preview: true })` 直通本插件编辑器的只读计划页签,不再创建侧栏页签;非计划地址、跨会话与 subagent 5 段地址、正文不可得、编辑器 5s 未回执、以及服务对象只读导致包装赋值失败,一律回落原生 `openResource`,原「认领 + 挂载后转移」链路保留为后备。`openReceipt` 新增可选 `timeoutMs`,`planState` 新增有界(64 条)地址→正文缓存并由 live `exit_plan_mode` 写入。验证:typecheck 0 error;`tests/planDirect.test.ts`(新增 9 例)、`tests/planBridge.test.ts`(13)、`tests/planState.test.ts`(10)、`tests/openReceipt.test.ts`(9)四套 41/41;`npm run build` 双 bundle 通过(含客户端产物完整性校验);浏览器确认新 bundle 已加载且 Console 无「计划直通装配失败」;GUI 点按由用户在本机 Web 端手动复验后发布。见 [发布说明](docs/release-0.23.4.md)。
884
+ - **v0.23.3**:修复 issue #13(已删除文件的差异条目把人卡死)与 #12(重启后成串「采集不完整」)。①文件在磁盘上被删掉时,客户端申请整文件删除预览被「已有官方审查记录」拒绝,而拒绝只是一条普通 `Error`,于是落到通用加载失败分支——「文件加载失败:…」+ 进度钉在 0%、重试同错、标签页关不掉;`edrv.review.detail` 还把 Undo 不可用解释成「缺少可验证的原始字节」,而真实原因是文件已不在。现缺失文件预览的可预期拒绝带稳定码(`official-covered` / `official-decided` / `no-records` / `no-evidence` / `too-large`),客户端据此显示「文件已在磁盘删除(· 有官方待审改动)」终态:标题 + 原因 + 重试 / 关闭标签页,不再画 0% 进度条;官方待审记录在磁盘已删除时给出「Keep 按删除结案、Undo 需要读写该文件」的准确原因(Keep 语义不变,仍只写共享审查库),记录都已结案时提示可直接关闭;`!review` 的磁盘状态抖动改为最多重读 2 次后给终态,消除缺失↔重现的无限递归。v0.22.0 起 `hasOfficial()` 已用 `typeof path !== 'string'` 守卫堵掉把不透明 FsTarget 绑进 SQL 导致的 `Unknown named parameter 'targetKey'`,本版不再复现。②官方 `workspace/changes` 的 summary 只存在宿主内存里,插件启动补采原先无条件把历史事件全部入队,重启后每一轮都必然抛「summary 已失效或尚不可用」并写成不可修复的 `gap`(面板成串「轮次 N 采集不完整」);现补采先 `summary()` 探测再入队,失效事件只记一条汇总日志。验证:typecheck 与基线同为 37 个既有错误(`fflate/browser` 依赖缺失)、零新增;定向单测 111/111(含新增 `tests/deletedFileReview.test.ts` 5 例与 `tests/officialBackfill.test.ts` 2 例)、EditorView 相关 82/82;`npm run build` 四个 bundle 通过。见 [发布说明](docs/release-0.23.3.md)。
883
885
  - **v0.23.2**:修复 Keep 在非活跃端(桌面端)点了没反应,两处成因。①`edrv.review.decide` 原先一律要求本端活跃会话,而能力位只按审查库推导,会话在另一实例时按钮亮着、点击后抛错被兜底成 HTTP 500。现按写入副作用区分:官方记录 Keep 只写共享审查库(`BEGIN IMMEDIATE` + 幂等键 + 版本 CAS),冷端放行;官方 Undo(校验证据并写回源文件)与待审投影条目(本机 JSON 无跨进程锁)仍限活跃端,返回可读跨端原因而非 500;详情新增 `capability.live`,冷端禁用 Undo 并说明、Keep 提示补「写入共享审查库,仍可执行」。②已结算待审投影的 `capability.keep` 恒为假,却因排在 `items[0]`、同路径官方待审行被历史过滤,把官方记录挤出差异栏(表现为「待审 0」+Keep 禁用+点击无反应);现 `pendingPageOf()` 剔除已结算投影,官方记录重新成为审查目标。另详情未加载时点 Keep 不再静默失败;打开文件时若某条官方记录的改动已全部不在当前文件中(无可定位差异且缓冲区干净),自动按 Keep 结案(只标记不写盘),差异栏不再显示「本记录 N 处改动均已不在当前文件中」;官方元数据首次载入期间差异栏显示 `—` 而非按历史记录报数,重启瞬间不再闪出几十条假待审。验证:typecheck 0 error、目标单测 57/57、build 通过、真实审查库探针确认首条回到官方记录且 `capability={keep:true,undo:true,live:true}`;桌面端 GUI 点按验收因重启后恢复的是另一个会话未完成,缺口保留。发布不自动部署,升级后重启 DSH 并刷新页面。见 [发布说明](docs/release-0.23.2.md)。
884
886
  - **v0.23.1**:修复 Keep All / Undo All 在待审超过一页时必定中止——批量按钮原先复用分页接口并把每页的展示用计数当全量总数校验,官方待审 150 条时先报「待审记录在分页期间变化」或最终报「待审记录数量不完整」,实际 0 项被决策。现改为一次性完整快照(`edrv.review.list` 新增 `all: true`,服务端循环取全并与历史改动投影去重,`nextCursor: null`、`pending` 为真实总数),客户端单次取快照、校验唯一且仍待审后逐项决策;超过 2000 条明确拒绝并提示分批,途中变化仍整批中止不部分写入。差异栏浏览仍走原分页接口。本版未在重启后的 GUI 点按验证,缺口保留;发布不自动部署,升级后重启 DSH 并刷新页面。见 [发布说明](docs/release-0.23.1.md)。
885
887
  - **v0.23.0**:新增快捷菜单——可拖动悬浮按钮 + 自定义菜单树(组/按钮,最多 5 层),按钮携带提示词并「直接发送给 AI」或「只填入输入框」;配置存 `<DSH_HOME>/dsh-vscode-mode/data/quick-menu.json`,带 `revision` 乐观锁、冲突重拉不覆盖、损坏降级。节点可限定工作区(默认全部、子节点继承),按钮可绑定技能与规则,发送时按会话可见性校验后只拼装通过的绑定(规则支持引用/内联)。新增 `skills.list` 只读 RPC 枚举全局技能 + 当前工作区技能;配置界面工作区改下拉弹层、技能/规则改分组多选下拉并移除手输技能名,菜单设置重排四段、统一按钮盒模型并修掉「导入 JSON」下移不居中。本版 GUI 未真机验收(pnpm store 损坏、插件未部署),缺口已获用户接受;发布不自动部署,升级后重启 DSH 并刷新页面。见 [发布说明](docs/release-0.23.0.md)。
package/lib/client.js CHANGED
@@ -2613,7 +2613,7 @@ window.__ModuleLoader__.load({
2613
2613
  * @param line Optional target line.
2614
2614
  * @param column Optional target column.
2615
2615
  * @param sessionId Owning session, required for routing.
2616
- * @param options Explicit preview, read-only plan document and optional cancellation signal.
2616
+ * @param options Explicit preview, read-only plan document, cancellation signal and receipt deadline.
2617
2617
  * @returns Actual completion; timeout and disposal are false.
2618
2618
  */
2619
2619
  function requestOpen(path, line, column, sessionId = "", options = {}) {
@@ -2647,7 +2647,7 @@ window.__ModuleLoader__.load({
2647
2647
  request,
2648
2648
  finish
2649
2649
  });
2650
- timer = setTimeout(() => finish(false), 2e4);
2650
+ timer = setTimeout(() => finish(false), options.timeoutMs ?? 2e4);
2651
2651
  openEditorView(null);
2652
2652
  window.dispatchEvent(new CustomEvent("edrv:open-request", { detail: request }));
2653
2653
  });
@@ -376030,6 +376030,8 @@ td.UniverTableCell, th.UniverTableCell{mso-padding-alt:0cm 5.4pt 0cm 5.4pt;}
376030
376030
  //#endregion
376031
376031
  //#region src/client/planState.ts
376032
376032
  const associated = /* @__PURE__ */ new Map();
376033
+ /** 地址 → 已解析计划正文(只留内存,供后续点击省掉一次资源解析)。 */
376034
+ const documents = /* @__PURE__ */ new Map();
376033
376035
  /** @private @author ddj 2026年10月08号 @param value JSON candidate. @returns Object or empty record. */
376034
376036
  function record(value) {
376035
376037
  return value !== null && typeof value === "object" ? value : {};
@@ -376096,9 +376098,25 @@ td.UniverTableCell, th.UniverTableCell{mso-padding-alt:0cm 5.4pt 0cm 5.4pt;}
376096
376098
  associated.set(sessionId, paths);
376097
376099
  if (associated.size > 32) associated.delete(associated.keys().next().value);
376098
376100
  }
376101
+ /** @public @author ddj 2026年10月31号
376102
+ * 记住一份已解析计划,供「查看全文」时免去资源解析。
376103
+ * @param plan 已解析计划。
376104
+ * @returns 无;只缓存合法地址与正文,超过上限按插入序淘汰。
376105
+ */
376106
+ function rememberPlan(plan) {
376107
+ const valid = planDocument(plan.address, plan);
376108
+ if (valid === void 0) return;
376109
+ documents.set(valid.address, valid);
376110
+ if (documents.size > 64) documents.delete(documents.keys().next().value);
376111
+ }
376112
+ /** @public @author ddj 2026年10月31号 @param address 官方资源地址。 @returns 已缓存的计划正文。 */
376113
+ function cachedPlan(address) {
376114
+ return documents.get(address);
376115
+ }
376099
376116
  /** @public @author ddj 2026年10月08号 Clear associations when the plugin unloads. */
376100
376117
  function clearPlanState() {
376101
376118
  associated.clear();
376119
+ documents.clear();
376102
376120
  }
376103
376121
  /** @public @author ddj 2026年10月08号
376104
376122
  * Reduce only live append deltas; hydration, pagination, reconnect and duplicate sequences never open plans.
@@ -376134,6 +376152,7 @@ td.UniverTableCell, th.UniverTableCell{mso-padding-alt:0cm 5.4pt 0cm 5.4pt;}
376134
376152
  if (event.type === "tool/result") return void 0;
376135
376153
  const plan = planDocument("dsh-resource://plan/" + encodeURIComponent(sessionId) + "/" + encodeURIComponent(id), { markdown: call.args.plan });
376136
376154
  if (plan) {
376155
+ rememberPlan(plan);
376137
376156
  remember(id);
376138
376157
  return { plan };
376139
376158
  }
@@ -377892,6 +377911,25 @@ td.UniverTableCell, th.UniverTableCell{mso-padding-alt:0cm 5.4pt 0cm 5.4pt;}
377892
377911
  }
377893
377912
  //#endregion
377894
377913
  //#region src/client/missingReview.ts
377914
+ /**
377915
+ * @public
377916
+ * @author ddj 2026年10月31号
377917
+ * @description: 把 missingReview 的失败归并成「文件已删除」终态。只有确认删除的拒绝码才是终态;
377918
+ * 会话缺失、权限、文件重新出现等失败返回 null,调用方继续走通用加载失败(可重试、保留跨端提示)。
377919
+ * @param failure RPC 失败结果(error 必填,code 可选)
377920
+ * @returns 终态信息或 null
377921
+ */
377922
+ function goneStateOf(failure) {
377923
+ const code = failure?.code;
377924
+ const official = code === "official-covered";
377925
+ if (!official && code !== "official-decided" && code !== "no-records" && code !== "no-evidence" && code !== "too-large") return null;
377926
+ const message = String(failure?.error ?? "文件已在磁盘删除").replace(/^Error:\s*/, "");
377927
+ return {
377928
+ title: official ? "文件已在磁盘删除 · 有官方待审改动" : "文件已在磁盘删除",
377929
+ message,
377930
+ official
377931
+ };
377932
+ }
377895
377933
  /** @public @author ddj 2026年10月28号 @param review Frozen complete snapshot. @returns One whole-file deletion, including empty files; no invented current lines. */
377896
377934
  function missingRegion(review) {
377897
377935
  return {
@@ -393573,6 +393611,9 @@ td.UniverTableCell, th.UniverTableCell{mso-padding-alt:0cm 5.4pt 0cm 5.4pt;}
393573
393611
  const aiStatusTimer = react$1.default.useRef(null);
393574
393612
  const [error, setError] = react$1.default.useState(null);
393575
393613
  const [loadError, setLoadError] = react$1.default.useState(null);
393614
+ const [goneFile, setGoneFile] = react$1.default.useState(null);
393615
+ const missingReadRef = react$1.default.useRef(/* @__PURE__ */ new Map());
393616
+ const goneNow = goneFile && goneFile.path === active && goneFile.sessionId === sessionId ? goneFile : null;
393576
393617
  const [largeCandidate, setLargeCandidate] = react$1.default.useState(null);
393577
393618
  const [pagedFile, setPagedFile] = react$1.default.useState(null);
393578
393619
  const [pageChanged, setPageChanged] = react$1.default.useState(null);
@@ -394459,7 +394500,38 @@ td.UniverTableCell, th.UniverTableCell{mso-padding-alt:0cm 5.4pt 0cm 5.4pt;}
394459
394500
  * @param force 强制走 RPC(reloadFile 用,跳过 model 复用)
394460
394501
  * @param version 已知磁盘版本(缺省走 RPC 返回值)
394461
394502
  */
394462
- /** @private @author ddj 2026年10月28号 @param path Missing text file. @param sid Owning session. @param seq Loader generation. @sideEffects Loads deletion evidence without creating or saving the file. */
394503
+ /**
394504
+ * 把「文件已在磁盘删除」记成终态面板:不占进度条、不反复重试,并允许直接关闭页签。
394505
+ * 只有确认删除的原因才走终态;会话/权限类失败仍回退通用加载失败,保留跨端提示。
394506
+ * @private @author ddj 2026年10月31号
394507
+ * @param path 目标文件
394508
+ * @param sid 会话 id
394509
+ * @param seq 加载序号(过期响应丢弃)
394510
+ * @param failure 宿主拒绝原因(可带稳定 code)
394511
+ */
394512
+ function settleGone(path, sid, seq, failure) {
394513
+ if (!loadCurrent(path, seq)) return;
394514
+ const error = failure && typeof failure === "object" ? failure : { error: failure };
394515
+ const gone = goneStateOf(error) ?? (error.deleted === true ? {
394516
+ title: "文件已在磁盘删除",
394517
+ official: false,
394518
+ message: String(error.error ?? "")
394519
+ } : null);
394520
+ if (!gone) {
394521
+ failLoad(path, sid, seq, String(error.error ?? error));
394522
+ return;
394523
+ }
394524
+ stampLoad(path, sid, seq, gone.message);
394525
+ setLoadError(null);
394526
+ setError(null);
394527
+ setGoneFile({
394528
+ ...gone,
394529
+ path,
394530
+ sessionId: sid
394531
+ });
394532
+ setStatus(gone.official ? "文件已删除 · 差异栏可 Keep 结案" : "文件已删除");
394533
+ }
394534
+ /** @private @author ddj 2026年10月28号 / 2026年10月31号 @param path Missing text file. @param sid Owning session. @param seq Loader generation. @sideEffects Loads deletion evidence without creating or saving the file. */
394463
394535
  async function loadMissing(path, sid, seq) {
394464
394536
  try {
394465
394537
  const result = await rpc("edrv.missingReview", {
@@ -394468,13 +394540,23 @@ td.UniverTableCell, th.UniverTableCell{mso-padding-alt:0cm 5.4pt 0cm 5.4pt;}
394468
394540
  });
394469
394541
  if (!loadCurrent(path, seq)) return;
394470
394542
  if (!result.ok) {
394471
- failLoad(path, sid, seq, result.error);
394543
+ settleGone(path, sid, seq, result);
394472
394544
  return;
394473
394545
  }
394474
394546
  if (!result.review) {
394475
- loadContent(path, sid, true);
394547
+ const attempts = (missingReadRef.current.get(path) ?? 0) + 1;
394548
+ missingReadRef.current.set(path, attempts);
394549
+ if (attempts <= 2) {
394550
+ loadContent(path, sid, true);
394551
+ return;
394552
+ }
394553
+ settleGone(path, sid, seq, {
394554
+ deleted: true,
394555
+ error: "文件状态在磁盘上反复变化,请稍后重试,或关闭该标签页"
394556
+ });
394476
394557
  return;
394477
394558
  }
394559
+ missingReadRef.current.delete(path);
394478
394560
  if (dirtyRef.current[path] || savingRef.current.has(path)) {
394479
394561
  failLoad(path, sid, seq, "文件已删除,但有未保存编辑;请先处理本地缓冲");
394480
394562
  return;
@@ -394487,6 +394569,7 @@ td.UniverTableCell, th.UniverTableCell{mso-padding-alt:0cm 5.4pt 0cm 5.4pt;}
394487
394569
  };
394488
394570
  missingRef.current.set(path, preview);
394489
394571
  setMissingPreview(preview);
394572
+ setGoneFile(null);
394490
394573
  setContent("");
394491
394574
  setContentPath(path);
394492
394575
  setLoadError(null);
@@ -394511,6 +394594,7 @@ td.UniverTableCell, th.UniverTableCell{mso-padding-alt:0cm 5.4pt 0cm 5.4pt;}
394511
394594
  status: "loading"
394512
394595
  });
394513
394596
  setLoadError(null);
394597
+ setGoneFile(null);
394514
394598
  setLargeCandidate(null);
394515
394599
  setPagedFile(null);
394516
394600
  setPageChanged(null);
@@ -398542,6 +398626,37 @@ td.UniverTableCell, th.UniverTableCell{mso-padding-alt:0cm 5.4pt 0cm 5.4pt;}
398542
398626
  className: "edrv-pill edrv-pill-ghost",
398543
398627
  onClick: retry
398544
398628
  }, "重试") : null);
398629
+ /**
398630
+ * 渲染缺失文件终态面板:说明 + 重试 + 关闭页签(不显示进度条,避免卡在 0%)。
398631
+ * @private @author ddj 2026年10月31号
398632
+ * @param gone 终态信息
398633
+ * @param retry 重新读取回调
398634
+ * @param close 关闭该标签页回调
398635
+ * @returns 终态面板 React 元素
398636
+ */
398637
+ const goneBody = (gone, retry, close) => react$1.default.createElement("div", {
398638
+ className: "edrv-empty edrv-loading",
398639
+ "aria-live": "polite",
398640
+ role: "status"
398641
+ }, react$1.default.createElement("div", { className: "edrv-loading-title" }, gone.title), react$1.default.createElement("div", { style: {
398642
+ fontSize: 12,
398643
+ maxWidth: 460,
398644
+ lineHeight: 1.6
398645
+ } }, gone.message), gone.official ? react$1.default.createElement("div", { style: {
398646
+ fontSize: 12,
398647
+ maxWidth: 460,
398648
+ lineHeight: 1.6,
398649
+ opacity: .8
398650
+ } }, "待审改动在差异栏:Keep 保留删除结果并结案;Undo 需要该文件的原始内容,磁盘已删除时不可用。") : null, react$1.default.createElement("div", { style: {
398651
+ display: "flex",
398652
+ gap: 8
398653
+ } }, react$1.default.createElement("button", {
398654
+ className: "edrv-pill edrv-pill-ghost",
398655
+ onClick: retry
398656
+ }, "重试"), react$1.default.createElement("button", {
398657
+ className: "edrv-pill edrv-pill-ghost",
398658
+ onClick: close
398659
+ }, "关闭标签页")));
398545
398660
  let body;
398546
398661
  if (activePlan) {
398547
398662
  const labels = PLAN_MD_LABELS;
@@ -398582,6 +398697,12 @@ td.UniverTableCell, th.UniverTableCell{mso-padding-alt:0cm 5.4pt 0cm 5.4pt;}
398582
398697
  }
398583
398698
  }, "重试"));
398584
398699
  else if (!active) body = react$1.default.createElement("div", { className: "edrv-empty" }, react$1.default.createElement("div", null, "暂无打开的文件"), react$1.default.createElement("div", { style: { fontSize: 12 } }, "使用右上搜索框 (" + (chordOf("edrv.quickOpen") ?? "Ctrl+P") + ") 打开工作区文件;" + (chordOf("edrv.showCommands") ?? "Ctrl+Shift+P") + " 打开命令栏;agent 修改文件后顶部会出现差异角标"));
398700
+ else if (goneNow) body = goneBody(goneNow, () => {
398701
+ missingReadRef.current.delete(goneNow.path);
398702
+ loadContent(active, sessionId, true);
398703
+ }, () => {
398704
+ closeTab(goneNow.path);
398705
+ });
398585
398706
  else if (content === null && loadError && isSessionMissingError(loadError)) body = react$1.default.createElement("div", {
398586
398707
  className: "edrv-empty edrv-loading",
398587
398708
  "aria-live": "polite"
@@ -412255,19 +412376,269 @@ td.UniverTableCell, th.UniverTableCell{mso-padding-alt:0cm 5.4pt 0cm 5.4pt;}
412255
412376
  return directTranslate();
412256
412377
  }
412257
412378
  //#endregion
412258
- //#region src/client/planBridge.ts
412259
- /** Optional DSH plan integration; no provider or approval UI replacement. @author ddj 2026年10月08号 */
412260
- const CLAIM_ID = "dsh-vscode-mode/plan";
412261
- const CLAIM_KIND = "edrvPlan";
412262
- const EMPTY_RESOURCE = { status: "none" };
412263
- /** @private @author ddj 2026年10月08号 @param ctx Optional context. @param name Service name. @returns Service or undefined without gating plugin activation. */
412264
- function optional(ctx, name) {
412379
+ //#region src/client/planDirect.ts
412380
+ /**
412381
+ * dsh-vscode-mode client — 计划地址直通。
412382
+ *
412383
+ * 背景:官方计划卡片「查看全文」调 `ctx.sidebarRight.openResource(planAddress)`,
412384
+ * 侧栏会先创建计划页签、再由本插件认领并立刻关闭,桌面端表现为「快速打开又迅速关闭」。
412385
+ * 本模块在装配时包装该服务方法:能直接拿到计划正文时改为把只读计划送进「文件编辑」,
412386
+ * 不再创建侧栏页签;地址不属于在屏会话、正文暂不可得、编辑器未回执或包装未生效时
412387
+ * 一律回落原方法,官方页签与原认领转交链路继续作为后备。
412388
+ * 作者 ddj 2026年10月31号
412389
+ */
412390
+ /** 正文解析上限:超过即回落官方页签,避免点击后长时间无反馈。 */
412391
+ const RESOLVE_MS = 1500;
412392
+ /** 编辑器回执上限:超过即回落官方页签。 */
412393
+ const ROUTE_MS = 5e3;
412394
+ /** @public @author ddj 2026年10月31号
412395
+ * 可选探测客户端服务,缺失或抛错时返回 undefined。
412396
+ * @param ctx 客户端上下文(只需 get)。
412397
+ * @param name 服务名。
412398
+ * @returns 服务实例,或 undefined(不阻断装配)。
412399
+ */
412400
+ function optionalService(ctx, name) {
412265
412401
  try {
412266
412402
  return ctx.get(name);
412267
412403
  } catch {
412268
412404
  return;
412269
412405
  }
412270
412406
  }
412407
+ /** @public @author ddj 2026年10月31号
412408
+ * 包装官方 openResource,把本会话的计划地址改为直通插件编辑器。
412409
+ * @param ctx 客户端上下文(可选服务一律 ctx.get 探测)。
412410
+ * @param service 官方 sidebarRight 服务;仅在赋值生效时留下包装。
412411
+ * @returns 供路由回退使用的原方法,以及卸载时中止在途并还原的清理函数。
412412
+ */
412413
+ function installPlanDirect(ctx, service) {
412414
+ const original = service.openResource;
412415
+ const pending = /* @__PURE__ */ new Map();
412416
+ let closed = false;
412417
+ let installed = false;
412418
+ /** @private @author ddj 2026年10月31号
412419
+ * 解码地址段(畸形编码一律视为不可接管)。
412420
+ * @param address 官方资源地址。
412421
+ * @returns 去掉协议前缀后的解码段。
412422
+ */
412423
+ function decode(address) {
412424
+ try {
412425
+ return address.split("/").slice(3).map(decodeURIComponent);
412426
+ } catch {
412427
+ return;
412428
+ }
412429
+ }
412430
+ /** @private @author ddj 2026年10月31号
412431
+ * 判断该地址是否由本插件接管:只认两段式计划地址,且归属当前在屏会话。
412432
+ * @param address 官方资源地址。
412433
+ * @returns 可接管的会话 id,其他情况 undefined(回落原方法)。
412434
+ */
412435
+ function take(address) {
412436
+ if (closed || !isPlanAddress(address)) return void 0;
412437
+ const segments = decode(address);
412438
+ if (segments?.length !== 2) return void 0;
412439
+ const current = readSessionScope(ctx).sessionId ?? "";
412440
+ return current !== "" && segments[0] === current ? current : void 0;
412441
+ }
412442
+ /** @private @author ddj 2026年10月31号
412443
+ * 读官方参数里随页签携带的计划正文(临时回顾页签走这里)。
412444
+ * @param address 官方资源地址。
412445
+ * @param options 官方 openResource 参数。
412446
+ * @returns 计划正文,或不带正文时 undefined。
412447
+ */
412448
+ function inline(address, options) {
412449
+ const params = options?.params;
412450
+ if (params === null || typeof params !== "object") return void 0;
412451
+ return planDocument(address, params.planReview);
412452
+ }
412453
+ /** @private @author ddj 2026年10月31号
412454
+ * 打开计划资源流。
412455
+ * @param services resources 服务。
412456
+ * @param address 官方资源地址。
412457
+ * @returns 资源流;服务缺失或抛错时 undefined。
412458
+ */
412459
+ function streamOf(services, address) {
412460
+ try {
412461
+ return services?.source?.(address);
412462
+ } catch {
412463
+ return;
412464
+ }
412465
+ }
412466
+ /** @private @author ddj 2026年10月31号
412467
+ * 从资源快照读已就绪的计划正文。
412468
+ * @param address 官方资源地址。
412469
+ * @param stream 计划资源流。
412470
+ * @returns 计划正文;未就绪、失败或内容不完整时 undefined。
412471
+ */
412472
+ function planOf(address, stream) {
412473
+ let snapshot;
412474
+ try {
412475
+ snapshot = stream.getSnapshot?.();
412476
+ } catch {
412477
+ return;
412478
+ }
412479
+ const state = snapshot !== null && typeof snapshot === "object" ? snapshot : {};
412480
+ return state.status === "live" ? planDocument(address, state.value) : void 0;
412481
+ }
412482
+ /** @private @author ddj 2026年10月31号
412483
+ * 订阅资源快照变化。
412484
+ * @param stream 计划资源流。
412485
+ * @param listener 变更监听。
412486
+ * @returns 退订函数;订阅面缺失或抛错时为 no-op。
412487
+ */
412488
+ function watchStream(stream, listener) {
412489
+ try {
412490
+ const off = stream.subscribe?.(listener);
412491
+ return typeof off === "function" ? off : () => void 0;
412492
+ } catch {
412493
+ return () => void 0;
412494
+ }
412495
+ }
412496
+ /** @private @author ddj 2026年10月31号
412497
+ * 回落官方方法(包装外的原入口)。
412498
+ * @param address 官方资源地址。
412499
+ * @param options 官方参数。
412500
+ * @returns 无;失败只记日志,不影响点击链路。
412501
+ */
412502
+ function native(address, options) {
412503
+ if (typeof original !== "function") return;
412504
+ try {
412505
+ original.call(service, address, options);
412506
+ } catch (error) {
412507
+ log$2.warn("官方计划页签回退失败:" + String(error));
412508
+ }
412509
+ }
412510
+ /** @private @author ddj 2026年10月31号
412511
+ * 把已解析的计划送进插件编辑器;地址级在途合并,重复点击不叠开。
412512
+ * @param plan 计划正文。
412513
+ * @param session 归属会话。
412514
+ * @param address 官方资源地址。
412515
+ * @param options 官方参数(回落时原样透传)。
412516
+ * @returns 无;未就绪或失败时回落官方页签,但不劫持已切换的会话。
412517
+ */
412518
+ function direct(plan, session, address, options) {
412519
+ if (closed || pending.has(address)) return;
412520
+ const controller = new AbortController();
412521
+ pending.set(address, () => {
412522
+ pending.delete(address);
412523
+ controller.abort();
412524
+ });
412525
+ rememberPlan(plan);
412526
+ /** @private @author ddj 2026年10月31号 @param ok 编辑器是否就绪。 @returns 无;失败时回落官方页签。 */
412527
+ function settle(ok) {
412528
+ pending.delete(address);
412529
+ if (ok || closed || readSessionScope(ctx).sessionId !== session) return;
412530
+ native(address, options);
412531
+ }
412532
+ requestOpen(null, void 0, void 0, session, {
412533
+ preview: true,
412534
+ plan,
412535
+ signal: controller.signal,
412536
+ timeoutMs: ROUTE_MS
412537
+ }).then(settle, (error) => {
412538
+ log$2.warn("计划直通失败:" + String(error));
412539
+ settle(false);
412540
+ });
412541
+ }
412542
+ /** @private @author ddj 2026年10月31号
412543
+ * 从计划资源异步解析正文,就绪后直通;超时或无法解析回落官方页签。
412544
+ * @param address 官方资源地址。
412545
+ * @param session 归属会话。
412546
+ * @param options 官方参数。
412547
+ * @returns 无。
412548
+ */
412549
+ function lookup(address, session, options) {
412550
+ const stream = streamOf(optionalService(ctx, "resources"), address);
412551
+ if (stream === void 0) {
412552
+ native(address, options);
412553
+ return;
412554
+ }
412555
+ const early = planOf(address, stream);
412556
+ if (early !== void 0) {
412557
+ direct(early, session, address, options);
412558
+ return;
412559
+ }
412560
+ if (closed || pending.has(address)) return;
412561
+ let timer;
412562
+ let stop;
412563
+ let done = false;
412564
+ /** @private @author ddj 2026年10月31号 @param ok 是否已拿到正文。 @returns 无;幂等收尾,清定时器、退订、释放地址。 */
412565
+ function finish(ok) {
412566
+ if (done) return;
412567
+ done = true;
412568
+ if (timer !== void 0) clearTimeout(timer);
412569
+ stop?.();
412570
+ pending.delete(address);
412571
+ if (!ok && !closed) native(address, options);
412572
+ }
412573
+ pending.set(address, () => finish(false));
412574
+ timer = setTimeout(() => finish(false), RESOLVE_MS);
412575
+ stop = watchStream(stream, () => {
412576
+ const plan = planOf(address, stream);
412577
+ if (plan === void 0) return;
412578
+ finish(true);
412579
+ direct(plan, session, address, options);
412580
+ });
412581
+ }
412582
+ /** @private @author ddj 2026年10月31号 @param address 官方资源地址。 @param options 官方参数。 @returns 无;包装后的 openResource 入口。 */
412583
+ function open(address, options) {
412584
+ const session = take(address);
412585
+ if (session === void 0) {
412586
+ native(address, options);
412587
+ return;
412588
+ }
412589
+ const known = inline(address, options) ?? cachedPlan(address);
412590
+ if (known !== void 0) {
412591
+ direct(known, session, address, options);
412592
+ return;
412593
+ }
412594
+ lookup(address, session, options);
412595
+ }
412596
+ /** @private @author ddj 2026年10月31号 @returns 无;赋值后校验,未生效即降级为原认领转交链路。 */
412597
+ function mount() {
412598
+ if (typeof original !== "function") return;
412599
+ try {
412600
+ service.openResource = open;
412601
+ } catch (error) {
412602
+ log$2.warn("计划直通装配失败:" + String(error));
412603
+ }
412604
+ installed = service.openResource === open;
412605
+ if (installed) return;
412606
+ try {
412607
+ service.openResource = original;
412608
+ } catch {}
412609
+ }
412610
+ /** @private @author ddj 2026年10月31号 @returns 无;仅在包装仍是自己时还原(HMR 安全)。 */
412611
+ function unmount() {
412612
+ if (!installed || service.openResource !== open) return;
412613
+ try {
412614
+ service.openResource = original;
412615
+ } catch (error) {
412616
+ log$2.warn("计划直通还原失败:" + String(error));
412617
+ }
412618
+ installed = false;
412619
+ }
412620
+ /** @private @author ddj 2026年10月31号 @returns 无;卸载时先标记关闭,再中止在途并还原官方方法。 */
412621
+ function dispose() {
412622
+ if (closed) return;
412623
+ closed = true;
412624
+ for (const cancel of [...pending.values()]) try {
412625
+ cancel();
412626
+ } catch {}
412627
+ pending.clear();
412628
+ unmount();
412629
+ }
412630
+ mount();
412631
+ return {
412632
+ dispose,
412633
+ native
412634
+ };
412635
+ }
412636
+ //#endregion
412637
+ //#region src/client/planBridge.ts
412638
+ /** Optional DSH plan integration; no provider or approval UI replacement. @author ddj 2026年10月08号 */
412639
+ const CLAIM_ID = "dsh-vscode-mode/plan";
412640
+ const CLAIM_KIND = "edrvPlan";
412641
+ const EMPTY_RESOURCE = { status: "none" };
412271
412642
  /** @private @author ddj 2026年10月08号 @param tab Current tab. @returns Native plan fallback options, preserving transient review parameters. */
412272
412643
  function nativeOptions(tab) {
412273
412644
  return {
@@ -412275,8 +412646,8 @@ td.UniverTableCell, th.UniverTableCell{mso-padding-alt:0cm 5.4pt 0cm 5.4pt;}
412275
412646
  params: tab?.navigation?.params
412276
412647
  };
412277
412648
  }
412278
- /** @private @author ddj 2026年10月08号 @param ctx Optional context. @param official Sidebar services. @returns Transfer component with native fallback and cancellable receipts. */
412279
- function planRouter(ctx, official) {
412649
+ /** @private @author ddj 2026年10月08号 @param ctx Optional context. @param official Sidebar services. @param native Official openResource bypass. @returns Transfer component with native fallback and cancellable receipts. */
412650
+ function planRouter(ctx, official, native) {
412280
412651
  const transfers = /* @__PURE__ */ new Map();
412281
412652
  /** @private @author ddj 2026年10月08号 @param all Plugin disposal. Cancel scope-stale transfers, not transfers merely hidden by the editor mount. */
412282
412653
  function cancel(all = false) {
@@ -412306,7 +412677,7 @@ td.UniverTableCell, th.UniverTableCell{mso-padding-alt:0cm 5.4pt 0cm 5.4pt;}
412306
412677
  function openNative() {
412307
412678
  if (typeof official.service.openResource !== "function") return;
412308
412679
  try {
412309
- official.service.openResource(address, nativeOptions(tab));
412680
+ native(address, nativeOptions(tab));
412310
412681
  tab?.actions?.close?.();
412311
412682
  } catch (error) {
412312
412683
  log$2.warn("计划官方查看器回退失败:" + String(error));
@@ -412373,18 +412744,21 @@ td.UniverTableCell, th.UniverTableCell{mso-padding-alt:0cm 5.4pt 0cm 5.4pt;}
412373
412744
  canOpen: isPlanAddress,
412374
412745
  title: () => "计划预览"
412375
412746
  });
412376
- const router = planRouter(ctx, official);
412747
+ const direct = installPlanDirect(ctx, official.service);
412748
+ const router = planRouter(ctx, official, direct.native);
412377
412749
  try {
412378
412750
  const offBody = ctx.slots.inject(OFFICIAL_SLOT_NAME, () => ctx.slots.register({
412379
412751
  name: OFFICIAL_SLOT_NAME,
412380
412752
  key: CLAIM_ID
412381
412753
  }, router.body));
412382
412754
  return () => {
412755
+ direct.dispose();
412383
412756
  router.dispose();
412384
412757
  if (typeof offBody === "function") offBody();
412385
412758
  offType();
412386
412759
  };
412387
412760
  } catch (error) {
412761
+ direct.dispose();
412388
412762
  router.dispose();
412389
412763
  offType();
412390
412764
  throw error;
@@ -412400,7 +412774,7 @@ td.UniverTableCell, th.UniverTableCell{mso-padding-alt:0cm 5.4pt 0cm 5.4pt;}
412400
412774
  /** @private @author ddj 2026年10月08号 @param id Owning session. @returns Valid borrowed feed, or undefined on older/incompatible services. */
412401
412775
  function sourceOf(id) {
412402
412776
  try {
412403
- const sessions = optional(ctx, "sessions");
412777
+ const sessions = optionalService(ctx, "sessions");
412404
412778
  if (!id || typeof sessions?.binding !== "function") return void 0;
412405
412779
  const feed = sessions.binding(id)?.eventSource;
412406
412780
  return typeof feed?.getSnapshot === "function" && typeof feed.subscribe === "function" ? feed : void 0;
package/lib/client.js.map CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/lib/client.js.map
3
- size: 35670356 bytes
4
- sha256: 4a298d4c08a69a99f2aa5a4626c9aa23ff928609a2af4f4cb9328d3ba4b25114
3
+ size: 35694036 bytes
4
+ sha256: 5a0053a6aa5733ebef51b077a624f0fc5bcf1a9c555232c357762a7eb8bdf2ef