@xrn1997/dsh-session-delete 0.8.0 → 0.10.0

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.
Files changed (155) hide show
  1. package/README.md +134 -173
  2. package/THIRD_PARTY_NOTICES.md +4 -2
  3. package/docs/DETAIL.md +1 -0
  4. package/docs/DETAIL.zh.md +1 -0
  5. package/docs/preview.svg +119 -0
  6. package/docs/preview.zh.svg +117 -0
  7. package/docs/screenshots/screenshot-01.png +0 -0
  8. package/lib/client.js +28630 -26493
  9. package/lib/index.js +2913 -1620
  10. package/lib/types/api/archive-rows.d.ts +7 -0
  11. package/lib/types/api/attachment-orphans.d.ts +3 -9
  12. package/lib/types/api/attachment.d.ts +4 -18
  13. package/lib/types/api/connection-route.d.ts +2 -6
  14. package/lib/types/api/route-table.d.ts +79 -31
  15. package/lib/types/api/trash-rows.d.ts +6 -22
  16. package/lib/types/client/api-base.d.ts +5 -12
  17. package/lib/types/client/archive-detail.d.ts +19 -0
  18. package/lib/types/client/archive-pane.d.ts +63 -0
  19. package/lib/types/client/archive-store.d.ts +10 -0
  20. package/lib/types/client/attachment-view.d.ts +3 -17
  21. package/lib/types/client/batch-bar.d.ts +4 -14
  22. package/lib/types/client/batch-confirm.d.ts +21 -17
  23. package/lib/types/client/batch-menu-item.d.ts +2 -10
  24. package/lib/types/client/batch-pick.d.ts +6 -13
  25. package/lib/types/client/batch-select.d.ts +10 -25
  26. package/lib/types/client/batch-selection-store.d.ts +21 -9
  27. package/lib/types/client/busy-gate.d.ts +2 -4
  28. package/lib/types/client/config-settings.d.ts +2 -3
  29. package/lib/types/client/confirm-dialog.d.ts +5 -8
  30. package/lib/types/client/context-menu-actions.d.ts +2 -8
  31. package/lib/types/client/context.d.ts +6 -15
  32. package/lib/types/client/copy.d.ts +86 -57
  33. package/lib/types/client/delete-confirm.d.ts +25 -13
  34. package/lib/types/client/delete-menu-item.d.ts +5 -9
  35. package/lib/types/client/detail-blocks.d.ts +5 -6
  36. package/lib/types/client/detail-ledger.d.ts +19 -0
  37. package/lib/types/client/detail-pane.d.ts +28 -0
  38. package/lib/types/client/host-archive-watch.d.ts +9 -0
  39. package/lib/types/client/host-rows.d.ts +32 -36
  40. package/lib/types/client/index.d.ts +5 -19
  41. package/lib/types/client/main-view.d.ts +25 -34
  42. package/lib/types/client/maintenance-parts.d.ts +2 -4
  43. package/lib/types/client/maintenance-settings.d.ts +3 -12
  44. package/lib/types/client/markdown.d.ts +4 -9
  45. package/lib/types/client/notice.d.ts +13 -0
  46. package/lib/types/client/orphan-maintenance.d.ts +8 -20
  47. package/lib/types/client/panel-tab.d.ts +39 -0
  48. package/lib/types/client/pending-open.d.ts +0 -1
  49. package/lib/types/client/plugin.d.ts +2 -4
  50. package/lib/types/client/prompt-rail.d.ts +1 -2
  51. package/lib/types/client/receipt.d.ts +14 -41
  52. package/lib/types/client/remote.d.ts +53 -88
  53. package/lib/types/client/scene.d.ts +41 -0
  54. package/lib/types/client/session-detail.d.ts +64 -0
  55. package/lib/types/client/session-list.d.ts +78 -0
  56. package/lib/types/client/session-live.d.ts +3 -13
  57. package/lib/types/client/settings-cards.d.ts +3 -6
  58. package/lib/types/client/settings-view.d.ts +1 -7
  59. package/lib/types/client/store.d.ts +6 -25
  60. package/lib/types/client/subagent-section.d.ts +36 -0
  61. package/lib/types/client/trash-confirm.d.ts +8 -9
  62. package/lib/types/client/trash-detail.d.ts +12 -66
  63. package/lib/types/client/trash-entry.d.ts +1 -1
  64. package/lib/types/client/trash-nav.d.ts +12 -18
  65. package/lib/types/client/trash-panel.d.ts +4 -6
  66. package/lib/types/client/trash-snapshot.d.ts +33 -41
  67. package/lib/types/client/trash-store.d.ts +12 -4
  68. package/lib/types/client/trash-tab.d.ts +22 -0
  69. package/lib/types/client/trash-view.d.ts +50 -50
  70. package/lib/types/client/ui/ErrorBoundary.d.ts +33 -0
  71. package/lib/types/client/ui/Modal.d.ts +3 -1
  72. package/lib/types/client/ui/Toast.d.ts +6 -3
  73. package/lib/types/client/ui/icons.d.ts +10 -4
  74. package/lib/types/client/undo-notices.d.ts +51 -20
  75. package/lib/types/client/undo-toast.d.ts +6 -9
  76. package/lib/types/client/use-archive-detail-reader.d.ts +27 -0
  77. package/lib/types/client/use-archive-panel-controller.d.ts +44 -0
  78. package/lib/types/client/use-archive-query.d.ts +31 -0
  79. package/lib/types/client/use-column-resize.d.ts +4 -11
  80. package/lib/types/client/use-detail-frame.d.ts +50 -0
  81. package/lib/types/client/use-detail-pager.d.ts +5 -13
  82. package/lib/types/client/use-detail-rail.d.ts +39 -0
  83. package/lib/types/client/use-detail-reader.d.ts +60 -0
  84. package/lib/types/client/use-gated-refresh.d.ts +27 -0
  85. package/lib/types/client/{use-trash-selection.d.ts → use-list-selection.d.ts} +16 -15
  86. package/lib/types/client/use-maintenance-section.d.ts +7 -12
  87. package/lib/types/client/use-maintenance.d.ts +11 -13
  88. package/lib/types/client/use-panel-child-view.d.ts +20 -0
  89. package/lib/types/client/use-panel-list-read.d.ts +51 -0
  90. package/lib/types/client/use-panel-selection.d.ts +36 -0
  91. package/lib/types/client/use-panel-tab.d.ts +134 -0
  92. package/lib/types/client/use-panel-width.d.ts +3 -11
  93. package/lib/types/client/use-prompt-rail.d.ts +8 -28
  94. package/lib/types/client/use-trash-detail-reader.d.ts +10 -23
  95. package/lib/types/client/use-trash-panel-controller.d.ts +17 -37
  96. package/lib/types/client/use-trash-query.d.ts +9 -25
  97. package/lib/types/client/use-write-progress.d.ts +26 -0
  98. package/lib/types/client/write-progress.d.ts +18 -0
  99. package/lib/types/client/write-seats.d.ts +64 -34
  100. package/lib/types/config.d.ts +8 -25
  101. package/lib/types/deps.d.ts +8 -10
  102. package/lib/types/domain/closure.d.ts +11 -30
  103. package/lib/types/errors.d.ts +21 -0
  104. package/lib/types/index.d.ts +9 -32
  105. package/lib/types/log/session-log.d.ts +42 -14
  106. package/lib/types/log/zstd-frames.d.ts +10 -25
  107. package/lib/types/ports/agent-handles.d.ts +10 -19
  108. package/lib/types/ports/attachments-port.d.ts +2 -6
  109. package/lib/types/ports/fs-port.d.ts +22 -24
  110. package/lib/types/ports/home.d.ts +7 -15
  111. package/lib/types/ports/host-port.d.ts +96 -59
  112. package/lib/types/ports/presence-port.d.ts +5 -12
  113. package/lib/types/remote/map-error.d.ts +4 -17
  114. package/lib/types/shared/apply-actions.d.ts +36 -0
  115. package/lib/types/shared/apply-values.d.ts +163 -0
  116. package/lib/types/shared/project-key.d.ts +5 -23
  117. package/lib/types/shared/session-path.d.ts +10 -0
  118. package/lib/types/shared/value-schema.d.ts +54 -0
  119. package/lib/types/shared/wire.d.ts +243 -197
  120. package/lib/types/trash/archive-detail.d.ts +16 -0
  121. package/lib/types/trash/attachments.d.ts +60 -43
  122. package/lib/types/trash/detail.d.ts +30 -26
  123. package/lib/types/trash/display-name.d.ts +2 -5
  124. package/lib/types/trash/entry.d.ts +22 -32
  125. package/lib/types/trash/groups.d.ts +17 -25
  126. package/lib/types/trash/ledger.d.ts +5 -9
  127. package/lib/types/trash/manifest.d.ts +4 -6
  128. package/lib/types/trash/projection-cache.d.ts +18 -0
  129. package/lib/types/trash/reconcile.d.ts +13 -23
  130. package/lib/types/trash/session-rows.d.ts +63 -0
  131. package/lib/types/trash/shrinking-view.d.ts +29 -0
  132. package/lib/types/trash/storage-manifest.d.ts +4 -7
  133. package/lib/types/trash/subagent-summary.d.ts +35 -0
  134. package/lib/types/verbs/batch-carried.d.ts +22 -2
  135. package/lib/types/verbs/batch.d.ts +39 -2
  136. package/lib/types/verbs/config.d.ts +3 -11
  137. package/lib/types/verbs/delete-session.d.ts +8 -13
  138. package/lib/types/verbs/empty-batch.d.ts +18 -0
  139. package/lib/types/verbs/live-admission.d.ts +3 -5
  140. package/lib/types/verbs/member-journal.d.ts +3 -7
  141. package/lib/types/verbs/member-presence.d.ts +7 -18
  142. package/lib/types/verbs/move-group.d.ts +2 -6
  143. package/lib/types/verbs/orphan-subagents.d.ts +23 -36
  144. package/lib/types/verbs/permanent-removal.d.ts +98 -81
  145. package/lib/types/verbs/restore-session.d.ts +10 -24
  146. package/lib/types/verbs/trash-scope.d.ts +21 -29
  147. package/lib/types/verbs/write-progress.d.ts +37 -0
  148. package/locale/en.json +7 -6
  149. package/locale/zh.json +2 -1
  150. package/package.json +135 -128
  151. package/lib/types/client/confirm-close.d.ts +0 -14
  152. package/lib/types/client/reset-client-state.d.ts +0 -1
  153. package/lib/types/client/write-settlement.d.ts +0 -66
  154. package/lib/types/client/write.d.ts +0 -66
  155. package/lib/types/verbs/errors.d.ts +0 -27
@@ -1,43 +1,14 @@
1
- /**
2
- * 浏览器半的取数通道:同源 fetch 宿主 `connection.fetch` 的 exact Fetch 路由(`/api` + 插件前缀)。
3
- * **一次调用只有一种落地面**:`RemoteOutcome<T>`(成功带值 / 失败带 `RemoteFailure`)。信封解析、
4
- * 401/403 原文、非信封诊断与网络失败归一都在这里一次完成——没有 raw 层、没有 make-it-throw 的适配层、
5
- * 也没有调用点各自的 try/catch。
6
- *
7
- * - 每段的**路径与方法**从 `src/shared/wire.ts` 的 `ROUTES` 投影(`{ path, method, body }`);本文件不写
8
- * 段名或方法的第二份字面量,请求字段只由上面 interface 的签名决定(`body` 那一格是给 Node 半决定
9
- * 「要不要预读 JSON」的,见 `src/api/route-table.ts`)。取数地址(官方 `/api` 前缀 + 文档挂载点)归
10
- * `src/client/api-base.ts`(根部署下与旧版逐字相同)。
11
- * - 十段注册在宿主 `connection.fetch.register` 上,鉴权归宿主 `/api` bridge(ADR-0033);
12
- * 没有旧前缀 fallback——支持面是 web UI 与桌面端,二者的标准组合都装 `client-connection`。
13
- * 官方 remote.<namespace> 仍不可用(第三方拿不到 Typert 描述符的动态发现挂载点)。
14
- * - 写动作统一走 apply;`attachment` 是唯一二进制段,由 `src/client/attachment-view.tsx` 经同一投影
15
- * 拼地址,不经过本文件的 JSON 通道;`attachment-orphans`(纯读)与 `attachment-clean`(聚合写)是
16
- * 孤儿附件的两段。
17
- * - 失败在线上是 {code,message,details?} 普通对象;本通道把它原样当数据交回,既不补标记位也不抛
18
- * (标记位判别 isDSHRemoteError 的家在 src/shared/wire.ts,读它的是 Node 半),这里不 import 任何宿主客户端包。
19
- */
20
- import { type ApplyAction, type ApplyOutcome, type ApplyValueByAction, type AttachmentCleanupWire, type AttachmentOrphanReportWire, type OrphanReportWire, type PurgeStatsWire, type RemoteFailure, type SessionDeleteConfigWire, type TrashDetailWire, type TrashRowWire } from '../shared/wire.js';
21
- /**
22
- * 回收站条目(`/list` 那一行)。**形状的家在 `shared/wire.ts`**(ADR-0003):这里只是别名,
23
- * 所以浏览器半不再自己抄一遍字段;下面几处"只读面"的镜像同理。
24
- */
1
+ import { type ApplyAction, type ApplyOutcome, type ApplyValueByAction, type ArchiveDetailWire, type ArchiveListWire, type AttachmentCleanupWire, type AttachmentOrphanReportWire, type OrphanReportWire, type ProjectionCacheCleanupWire, type ProjectionCacheOrphanReportWire, type PurgeStatsWire, type RemoteFailure, type SessionDeleteConfigWire, type TrashDetailWire, type TrashRowWire, type WriteProgressWire } from '../shared/wire.js';
2
+ /** 下面这些只读面都是 `shared/wire.ts` 的别名:形状的家只在那边(ADR-0003)。 */
25
3
  export type TrashEntryLike = TrashRowWire;
26
- /** 彻底删除的回执(`PurgeStatsWire`)。 */
27
4
  export type PurgeResultLike = PurgeStatsWire;
28
- /**
29
- * 回收站单条详情(`TrashDetailWire`)。
30
- *
31
- * **线上只有"日志里读出来的那几件"**:`deletedAt` / `sizeBytes` / `wasArchived` / 清册 `title` 这些
32
- * 清册已有的字段一律不过线——组件按 `entryId` 与自己手上那份清单配对,这样"清单里的大小"和
33
- * "详情里的大小"永远是同一个数,不会因为两次读数不同而各说各话。
34
- * 例外只有一格:`subagents`(孩子摘要)。孩子不在客户端清单里、无从配对,
35
- * 它们的清册事实只能随详情过线(issue #7;单级判据现由 ADR-0055 的「沿用」节承接)。
36
- */
5
+ /** 回收站单条详情:线上只有日志里读出来的那几件,清册已有字段不过线(组件按 `entryId` 与手上清单配对);
6
+ * 例外是 `subagents`——孩子不在客户端清单里,只能随详情过线(ADR-0055「沿用」)。 */
37
7
  export type TrashDetailLike = TrashDetailWire;
38
- /** 一次远程调用的落地面:要么值,要么失败——所有操作都交这一种形状,调用方只做状态检查。
39
- * 失败**不抛**:抛出来的失败面会让每个调用点再学一套 try/catch,也会让「返回的失败」与
40
- * 「抛出的失败」变成两种落地。 */
8
+ export type ArchiveListLike = ArchiveListWire;
9
+ /** 归档单条详情:基座 + sessionId,无 `entryId`;子会话段是只读投影,来源与回收站不同。 */
10
+ export type ArchiveDetailLike = ArchiveDetailWire;
11
+ /** 信封与失败形状的家在 `shared/wire.js`:浏览器半不补标记位、不抛失败(异常 → 失败面是 Node 半的活)。 */
41
12
  export type RemoteOutcome<T> = {
42
13
  ok: true;
43
14
  value: T;
@@ -45,87 +16,81 @@ export type RemoteOutcome<T> = {
45
16
  ok: false;
46
17
  failure: RemoteFailure;
47
18
  };
48
- /**
49
- * 浏览器半的**唯一取数 interface**:每个操作交回同一种落地面 `RemoteOutcome<T>`。
50
- *
51
- * 两个 adapter 是真的:生产是同源 fetch({@link createHttpRemote}),测试是内存假件
52
- * (`tests/client/support/fake-remote.ts`)。没有第二条「raw 信封」interface,也没有把信封
53
- * 再展开成 throw 的中间层——失败形状从三种收成一种。
54
- */
19
+ /** 唯一取数 interface:生产是同源 fetch({@link createHttpRemote}),测试是内存假件;没有第二条 raw 信封面。 */
55
20
  export interface SessionDeleteRemote {
56
- /** 通道的"在不在":一次零成本的 GET(探测专用,见 `src/api/dispatch.ts` 的 `ping` 支)。
57
- * `signal` 由探测方给:半开连接不能把 `activate` 永远吊在这里。 */
21
+ /** 探测专用零成本 GET;`signal` 由探测方给——半开连接不能把 `activate` 吊住。 */
58
22
  ping(signal?: AbortSignal): Promise<RemoteOutcome<string>>;
59
23
  list(): Promise<RemoteOutcome<TrashEntryLike[]>>;
60
- /** 三只可调项的当前值:空体 POST(与 `/detail` 的“POST 表达读”同法)。 */
61
24
  config(): Promise<RemoteOutcome<SessionDeleteConfigWire>>;
62
25
  /** 写回三只可调项:走宿主 `configEditor.edit`,这一行会重启;失败以 `io` 落地。 */
63
26
  saveConfig(config: SessionDeleteConfigWire): Promise<RemoteOutcome<SessionDeleteConfigWire>>;
64
- /** 纯读:回收站之外的无主子会话扫描。它**不清理**——清理是 `apply` 的 `orphan-clean` 动作。
65
- * 读不到是失败,调用方不许把它折成"零条残留"。 */
27
+ /** 纯读:扫描无主子会话;不清理(清理是 `apply` 的 `orphan-clean`),读不到是失败,不折成「零条残留」。 */
66
28
  scanOrphans(): Promise<RemoteOutcome<OrphanReportWire>>;
67
29
  /** 纯读:`.dsh` 内无引用图片对象的数量、字节与预览清单(引用源读不出是失败,不折成 0)。 */
68
30
  scanAttachmentOrphans(): Promise<RemoteOutcome<AttachmentOrphanReportWire>>;
69
31
  /** 聚合写:只删上一条报告那一刻无引用的图片对象,回 `AttachmentCleanupWire`。 */
70
32
  cleanAttachmentOrphans(): Promise<RemoteOutcome<AttachmentCleanupWire>>;
33
+ /** 纯读:`session_projcache` 里找不到会话痕迹的记录条数(判据住 `src/trash/projection-cache.ts`);读不出是失败。 */
34
+ scanProjectionCacheOrphans(): Promise<RemoteOutcome<ProjectionCacheOrphanReportWire>>;
35
+ /** 聚合写:现扫一遍,只删这一刻仍找不到会话痕迹的投影缓存记录,回 `ProjectionCacheCleanupWire`。 */
36
+ cleanProjectionCacheOrphans(): Promise<RemoteOutcome<ProjectionCacheCleanupWire>>;
71
37
  detail(entryId: string, before?: number): Promise<RemoteOutcome<TrashDetailLike>>;
72
- /** 一组 id 上的同一个动作。顶层 `ok:false` 只表示**整次调用**没办成(路由自检、栅栏之外);
73
- * 单条动作的成败住在 `ApplyOutcome` 里——这是批量接口的判据,别在信封层找它。 */
38
+ /** 纯读:归档清单。`{ available: false }` 是成功信封里的显式「语料不可见」,不是失败。 */
39
+ archiveList(): Promise<RemoteOutcome<ArchiveListLike>>;
40
+ /** 纯读:归档单条详情(subagent 闭包成员也行;寻址红线:只传 id)。 */
41
+ archiveDetail(sessionId: string, before?: number, rootSessionId?: string): Promise<RemoteOutcome<ArchiveDetailLike>>;
42
+ /** 一组 id 上的同一动作:顶层 `ok:false` 只表示整次调用没办成,单条成败住在 `ApplyOutcome` 里。 */
74
43
  applyOutcomes(action: ApplyAction, ids: readonly string[]): Promise<RemoteOutcome<ApplyOutcome[]>>;
75
- /** 清空回收站:聚合回执,不按条回。 */
76
44
  emptyTrash(): Promise<RemoteOutcome<PurgeResultLike>>;
45
+ /** 纯读:在飞写入的进度快照(`idle` = 没写在飞,是成功值不是失败)。进度是小读,走独立短上限。 */
46
+ progress(signal?: AbortSignal): Promise<RemoteOutcome<WriteProgressWire>>;
77
47
  }
78
48
  /** 插件设置页「可调项」卡只要这两件。 */
79
49
  export type ConfigDeps = Pick<SessionDeleteRemote, 'config' | 'saveConfig'>;
80
- /** 需要那一段 `/apply` 的组件只要这一段 deps(单条非写调用见 {@link applyOne},写动作走 `./write.js` 的 `runWrite`)。 */
81
- export type OneShotDeps = Pick<SessionDeleteRemote, 'applyOutcomes'>;
50
+ /** 只做写身份认领轮询的组件只要这一格(窄切片的口径同 {@link ConfigDeps}):它自己不发起写。 */
51
+ export type ProgressDeps = Pick<SessionDeleteRemote, 'progress'>;
52
+ /** 需要那一段 `/apply` 的组件只要这一段 deps(单条非写调用见 {@link applyOne},写动作走 `./write-seats.ts` 的六个座位);
53
+ * `progress` 随身是因为写身份认领轮询(`./use-write-progress.ts`)跟写动作同一批组件进出,共用一份 deps。 */
54
+ export type OneShotDeps = Pick<SessionDeleteRemote, 'applyOutcomes' | 'progress'>;
55
+ /** 一次普通请求的时长上限(探针另有更短的 5s 上限,见 {@link PROBE_TIMEOUT_MS})。 */
56
+ export declare const REQUEST_TIMEOUT_MS = 30000;
57
+ /** 聚合读 / 批量写 / 清空的上限:工作量随盘上全量数据线性变长,共用 30s 会把「宿主还在干活」误判成超时。 */
58
+ export declare const SLOW_REQUEST_TIMEOUT_MS = 120000;
59
+ /** 进度是 300ms 轮询的遥测小读:半开连接最多冻结两秒,不能占满普通请求的 30 秒。 */
60
+ export declare const PROGRESS_TIMEOUT_MS = 2000;
61
+ /** 超时的固定中文原文:通道诊断是协议原文,不随 locale(见 `docs/architecture.md` §3)。 */
62
+ export declare const REQUEST_TIMEOUT_MESSAGE = "\u53D6\u6570\u901A\u9053\u8D85\u65F6\uFF1A\u5BBF\u4E3B\u6CA1\u6709\u5728\u65F6\u9650\u5185\u56DE\u5E94";
63
+ /** 调用方自己中止这一趟(探测的 5s 上限)时的原文:与宿主超时分开,诊断才能指对人。 */
64
+ export declare const CALLER_ABORT_MESSAGE = "\u53D6\u6570\u901A\u9053\u6253\u4E0D\u901A\uFF1A\u8BF7\u6C42\u5DF2\u88AB\u8C03\u7528\u65B9\u4E2D\u6B62";
65
+ /** 成功信封里的值形状不对时的固定中文原文(判形住 `src/shared/wire.ts` 的 `WIRE_VALUE_GUARDS`)。 */
66
+ export declare const CHANNEL_SHAPE_MESSAGE = "\u53D6\u6570\u901A\u9053\u56DE\u7684\u503C\u5F62\u72B6\u4E0D\u5BF9";
67
+ /** `createHttpRemote` 的可选覆盖:**生产不传**(按段用两档上限)。存在只为让超时支在测试里真的跑到,不必等 30/120 秒。 */
68
+ export interface HttpRemoteOptions {
69
+ readonly timeoutMs?: number;
70
+ }
82
71
  /**
83
- * 唯一生产 adapter:同源 fetch。**同源、带挂载点前缀**:不拼 host、不认 origin——页面本身就是从
84
- * 宿主页面加载的,同源是这条通道的全部前提;路径只由 `api-base.ts` 从 `document.baseURI` 的目录
85
- * 与官方 `/api` 前缀拼出(根部署下与旧版逐字相同,反代到 `/dsh/` 时得到 `/dsh/api/...`)。
86
- * 鉴权归宿主 `/api` bridge(ADR-0033)。所以这条通道**只对**宿主页面打开过、带宿主身份的客户端
87
- * 成立(凭据是那次访问换来的 cookie,不是插件自己的秘密)。
72
+ * 唯一生产 adapter:同源 fetch,不拼 host、不认 origin——页面本身从宿主加载,同源是这条通道的全部前提;
73
+ * 路径由 `api-base.ts` 从 `document.baseURI` 目录与 `/api` 前缀拼出(反代到 `/dsh/` 时得到 `/dsh/api/...`)。
74
+ * 鉴权归宿主 `/api` bridge(ADR-0033),凭据是宿主页面访问换来的 cookie,不是插件自己的秘密。
88
75
  */
89
- export declare function createHttpRemote(): SessionDeleteRemote;
76
+ export declare function createHttpRemote(options?: HttpRemoteOptions): SessionDeleteRemote;
90
77
  /** 探测默认上限:5s。超时经 `AbortController` 打断 fetch,`activate` 不会永远吊在一条半开连接上。 */
91
78
  export declare const PROBE_TIMEOUT_MS = 5000;
92
- /**
93
- * 探测的可选覆盖。**生产调用方不传**:注册路径只用 {@link PROBE_TIMEOUT_MS}。
94
- * 这一格存在是为了让「超时算探测不过」这条支能在测试里真的跑到——不然它要等 5 秒墙上时间。
95
- */
79
+ /** 探测的可选覆盖:**生产不传**(只用 {@link PROBE_TIMEOUT_MS});存在只为让「超时算探测不过」在测试里跑到。 */
96
80
  export interface ProbeOptions {
97
- /** 单次往返的上限;超时经 `AbortController` 打断 fetch。 */
98
81
  readonly timeoutMs?: number;
99
82
  }
100
83
  /**
101
- * 探测唯一通道:一次 `GET /ping` 回成功信封(`pong`)才注册入口。
102
- *
103
- * - 401/403 是宿主 `/api` 的纯文本身份/归属失败:入口不出现,不装禁用态。
104
- * - 失败信封 / 404 / 非信封同样按不可用处理:`/api` 网关对未知路径也可能回错误形状,
105
- * 不能据此把入口摆出来让每个动作都失败。
106
- * - **往返有 5s 上限**:半开连接或宿主没起来时 `activate` 不悬着;超时与网络失败同样是
107
- * 「这一代不可用」,不自动重试(一次探测一个结论,刷新页面才会再探)。三种失败都在
108
- * console 留下原因——入口不出现是有意的,但"为什么没出现"不能只活在脑子里。
84
+ * 探测唯一通道:一次 `GET /ping` 回成功信封(`pong`)才注册入口;401/403 与任何失败都不装禁用态。
85
+ * 往返有 5s 上限,超时与网络失败同样是「这一代不可用」,不自动重试(刷新才会再探);失败在 console 留原因。
109
86
  */
110
87
  export declare function probeChannel(deps: SessionDeleteRemote, options?: ProbeOptions): Promise<boolean>;
111
- /** `shared/wire.ts` 的 `ApplyOutcome`、扫描报告与附件回执从这里转出去——浏览器半只认 `remote.js` 这一扇门。 */
112
- export type { ApplyAction, ApplyOutcome, AttachmentCleanupWire, AttachmentOrphanReportWire, OrphanReportWire, } from '../shared/wire.js';
113
- /**
114
- * N=1 的成功支:`null` 已被 `receipt.ts` 的单条读法折成协议错,所以 `value` 必然非空。
115
- * 不再需要条件类型把 `delete` / `restore` 的 null 抠掉——那份判据只住回执读法一处。
116
- * 成败判别只住外层 `RemoteOutcome.ok`(ADR-0053 唯一落地面),这里不再叠第二枚 ok。
117
- */
88
+ /** N=1 的成功支:`value` 必然非空(null 已由 `readSingleReceipt` 折成协议错);成败只认 `RemoteOutcome.ok`(ADR-0053)。 */
118
89
  export type OneShotSuccess<A extends ApplyAction> = {
119
90
  readonly id: string;
120
91
  readonly action: A;
121
92
  readonly value: Exclude<ApplyValueByAction[A], null>;
122
93
  };
123
- /**
124
- * **N=1 的 `apply`**:一个动作 + 一个 id → 那一条的成功支(`value` 必然非空)。
125
- *
126
- * 三件事各归一个家:
127
- * - **按发出去的那个 id** 取结果(取"第一条"会把别条的成败安在这条头上);
128
- * - 成/败/幂等/缺失与「单条 null 是协议错」的判读只走 {@link readSingleReceipt};
129
- * - 这里只把 verdict 折成同一落地面(拿到值 / 失败),不抛——与通道的其余操作同一条契约。
130
- */
94
+ /** **N=1 的 `apply`**:按发出去的那个 id 取结果(取「第一条」会把别条成败安在这条头上),
95
+ * 判读只走 {@link readSingleReceipt};这里只把 verdict 折成同一落地面,不抛。 */
131
96
  export declare function applyOne<A extends ApplyAction>(deps: OneShotDeps, action: A, id: string): Promise<RemoteOutcome<OneShotSuccess<A>>>;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * 浏览器半的**场景 seam**:九份跨槽位现场聚成一个实例。进程场景必须由注册面安装(未装即接线错,不懒建第二份账);
3
+ * 测试每例换新;各槽位经 `ClientSceneProvider` 读同一实例(宿主槽位是互不相邻的 React 树)。
4
+ *
5
+ * **环内模块顶层只许字面量初始化**:本文件与九个现场模块互相 import,顶层读环内导出会踩 TDZ / `undefined`。
6
+ */
7
+ import { type ReactElement, type ReactNode } from 'react';
8
+ import { type ArchiveRevisionScene } from './archive-store.js';
9
+ import { type BatchConfirmScene } from './batch-confirm.js';
10
+ import { type BatchSelectionScene } from './batch-selection-store.js';
11
+ import { type DeleteRequestScene } from './delete-confirm.js';
12
+ import { type HostRowsScene } from './host-rows.js';
13
+ import { type MainViewScene } from './main-view.js';
14
+ import { type TrashRevisionScene } from './trash-store.js';
15
+ import { type TrashSnapshotScene } from './trash-snapshot.js';
16
+ import { type UndoNoticeScene } from './undo-notices.js';
17
+ export interface ClientScene {
18
+ readonly trashRevisions: TrashRevisionScene;
19
+ readonly archiveRevisions: ArchiveRevisionScene;
20
+ readonly snapshot: TrashSnapshotScene;
21
+ readonly undo: UndoNoticeScene;
22
+ readonly mainView: MainViewScene;
23
+ readonly hostRows: HostRowsScene;
24
+ readonly batchSelection: BatchSelectionScene;
25
+ readonly deleteRequest: DeleteRequestScene;
26
+ readonly batchConfirm: BatchConfirmScene;
27
+ /** 场景收场:九份现场一起回初值(测试收场只调这一条)。 */
28
+ reset(): void;
29
+ }
30
+ export declare function createClientScene(): ClientScene;
31
+ export declare function getDefaultClientScene(): ClientScene;
32
+ /** 已有就沿用(HMR 二次激活不换现场);省略候选时只在未安装时现造一份;`replace` 只给测试。返回 Provider 要用的那一份。 */
33
+ export declare function installClientScene(candidate?: ClientScene, options?: {
34
+ readonly replace?: boolean;
35
+ }): ClientScene;
36
+ export declare function useClientScene(): ClientScene;
37
+ /** 宿主各槽位是互不相邻的 React 树:每个贡献各包一次,拿到的是同一实例(ADR-0048 无共同父级)。 */
38
+ export declare function ClientSceneProvider({ scene, children }: {
39
+ readonly scene: ClientScene;
40
+ readonly children?: ReactNode;
41
+ }): ReactElement;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * 会话详情的通用视图(只画状态,不取数):状态壳、信息表、计量行、工作步骤、提问轨、附件与分页。
3
+ *
4
+ * 档差只在三个投影口里:`head`(与选中行配对)、`infoRows`(两档各自的行集)、`subagents`(子会话段)。
5
+ * 两档共用的接线(读路状态 + 分页读面 + 提问轨)由 `use-detail-frame.ts` 拼成详情帧,这里只消费 `state` / `pager`。
6
+ *
7
+ * 两档同守:动作留在清单行;正文是块(用户/助手常显,其余默认折叠;注入也铺进正文——对宿主 Chat 的有意偏离,删之前看全);助手/思考走 Markdown,提问保持原话。
8
+ */
9
+ import { type CSSProperties, type ReactNode } from 'react';
10
+ import { type Translate } from './copy.js';
11
+ import type { SessionDetailWire } from '../shared/wire.js';
12
+ import { type DetailFrameView } from './use-detail-frame.js';
13
+ /** 详情的导航面(孩子视图的开与回):类型定义在这里(控制器 `import type` 避免环);孩子一律按 id 交接(ADR-0055)。 */
14
+ export interface DetailNav {
15
+ /** 只在主体是清单选中那条时交出(ADR-0055 沿用的单级判据,唯一实现)。 */
16
+ readonly onOpenChild?: (childId: string) => void;
17
+ /** 与 `onOpenChild` 同进同出的意图预取:hover/focus 子会话行时先把它的详情读进来。 */
18
+ readonly onPrefetchChild?: (childId: string) => void;
19
+ /** 孩子视图的返回目标;title 是原文(未命名兜底由视图按 t 处理)。 */
20
+ readonly parentContext?: {
21
+ readonly title: string;
22
+ readonly onBack: () => void;
23
+ };
24
+ }
25
+ /** 信息表的一行:标签 + 值(`title` 只在原文值得展开时给,不给就没有悬停提示;`code` 走等宽样式)。 */
26
+ export interface DetailInfoRow {
27
+ readonly label: string;
28
+ readonly value: string;
29
+ readonly title?: string;
30
+ readonly code?: boolean;
31
+ }
32
+ export interface SubagentSectionProps {
33
+ readonly badge: ReactNode;
34
+ readonly body: ReactNode;
35
+ }
36
+ export interface SessionDetailProps<S, D extends SessionDetailWire> {
37
+ /** 详情帧:壳只消费读路状态与分页读面;`rail` / `canNavigate` / 行投影不归壳。 */
38
+ frame: DetailFrameView<S, D>;
39
+ /** 主体身份(换条复位滚动、body 重挂载的 key、保持提示的判据都按它)。 */
40
+ subjectId: string;
41
+ /** 标题与大小与**选中行**配对:列表行给 display name 与大小,详情不重算。 */
42
+ head: {
43
+ readonly displayName: string;
44
+ readonly sizeText: string | null;
45
+ };
46
+ infoRows: readonly DetailInfoRow[];
47
+ subagents?: SubagentSectionProps;
48
+ busy: boolean;
49
+ wide: boolean;
50
+ onRetry: () => void;
51
+ onBack: () => void;
52
+ detailNav: DetailNav;
53
+ t: Translate;
54
+ }
55
+ /** 返回键排在标题之后;标题排按紧凑按钮预留高度(父子切换不跳 6px)。`position: sticky`:长会话中段返回键仍在(触屏没有 Esc)。 */
56
+ export declare const HEAD_MIN_HEIGHT = 28;
57
+ export declare const HEAD_PAD_BOTTOM = 6;
58
+ export declare const BLOCK_META: CSSProperties;
59
+ export declare const SECTION_LABEL: CSSProperties;
60
+ /** 日志里那两个时间戳缺省时的降级(`src/trash/detail.ts` 把初值写成 0,读不到就是 0)。 */
61
+ export declare function timeText(ms: number): string;
62
+ /** 空串不是名字:wire 用缺席表示没读到,清册字段仍可能是空串;行名与标题排共用这一条。 */
63
+ export declare function present(value: string | undefined): value is string;
64
+ export declare function SessionDetail<S, D extends SessionDetailWire>({ frame, subjectId, head, infoRows, subagents, busy, wide, onRetry, onBack, detailNav, t, }: SessionDetailProps<S, D>): import("react").JSX.Element;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * 清单的分组列(回收站/归档共用,各交一份行视图):grid 容器与 ARIA、组头、行壳与三格、非就绪的三张卡。
3
+ *
4
+ * 只有真有行才挂 grid 与它的 aria(ADR-0028):失败/加载/空是一块普通内容;`aria-busy` 在容器上(刷新不是第四态,ADR-0048)。
5
+ * 底色(详情正画这一条)与 `aria-selected`(勾选集)是两套判据,互不冒充;行 id 在这侧编码,原始身份留 `dom.idAttr`。
6
+ */
7
+ import { type ReactNode, type RefObject } from 'react';
8
+ import { type ProjectGroup } from './trash-view.js';
9
+ import type { ListSelection } from './use-list-selection.js';
10
+ import type { TrashNav } from './trash-nav.js';
11
+ import type { DelayedPrefetch } from './use-prefetch.js';
12
+ import type { Translate } from './copy.js';
13
+ /** 一档清单进 DOM 的身份:档位名与行身份属性成对出现(`useRowFocus` 也读它)。 */
14
+ export interface ListDom {
15
+ /** 档位名前缀:拼容器/行/组头的 `data-dsh-session-delete` 与 DOM id(`sd-trash-` / `sd-archive-`)。 */
16
+ readonly kind: 'trash' | 'archive';
17
+ /** 行原始身份写进哪个属性(条目 id / 会话 id 本是两种东西,不混名)。 */
18
+ readonly idAttr: string;
19
+ }
20
+ /** 把焦点交还清单某一行:按属性值自己比,不把行 id 拼进选择器——宿主目录名带引号时选择器直接抛。 */
21
+ export declare function useRowFocus(listRef: RefObject<HTMLDivElement | null>, idAttr: string): (rowId: string) => void;
22
+ /** 一行的可见读数;勾选 / 活动行 / tab 落点是清单态,由本模块自己算。 */
23
+ export interface SessionRowView {
24
+ /** 行的原始身份(回收站 = 条目 id,归档 = 会话 id):DOM 属性、`aria-selected` 判定都走它。 */
25
+ readonly id: string;
26
+ readonly title: string;
27
+ /** 标题悬停的全文;`null` ⇒ 不挂 `title`(未命名行没有可展开的原文)。 */
28
+ readonly titleTip: string | null;
29
+ readonly meta: string;
30
+ readonly metaTip: string;
31
+ readonly checkLabel: string;
32
+ readonly failure: string | null;
33
+ readonly actions: ReactNode;
34
+ /** 点行 = 选中看详情;多选态由本模块先拦成「勾 / 取消这一条」。 */
35
+ readonly onSelect: () => void;
36
+ }
37
+ export interface SessionListProps<R> {
38
+ listRef: RefObject<HTMLDivElement>;
39
+ dom: ListDom;
40
+ gridLabel: string;
41
+ /** 重读在飞 ⇒ 容器 `aria-busy`(不是第四态,ADR-0048)。 */
42
+ refreshing: boolean;
43
+ /** 非「有行」那一档的整块内容(加载 / 失败 / 语料缺席 / 空态):在场就不挂 grid。 */
44
+ notice: ReactNode;
45
+ groups: readonly ProjectGroup<R>[];
46
+ selection: ListSelection<R>;
47
+ nav: TrashNav;
48
+ /** hover / focus 的延时预取:四件事的接线只在这一处。 */
49
+ prefetch: DelayedPrefetch<R>;
50
+ /** 当前活动行(选中行,或窄档方向键的光标):底色与 `aria-activedescendant` 读它。 */
51
+ activeId: string | null;
52
+ rowOf: (row: R) => SessionRowView;
53
+ t: Translate;
54
+ }
55
+ /** 分组列本体:`notice` 在场时容器仍渲染(焦点与滚动要它),但 grid 的 role 与 aria 不挂。 */
56
+ export declare function SessionList<R>({ listRef, dom, gridLabel, refreshing, notice, groups, selection, nav, prefetch, activeId, rowOf, t, }: SessionListProps<R>): import("react").JSX.Element;
57
+ /** 加载那一拍:一句轻读数,不画骨架(清单还不知道有几条)。 */
58
+ export declare function ListLoading({ label }: {
59
+ label: string;
60
+ }): import("react").JSX.Element;
61
+ export interface ListNoticeProps {
62
+ title: string;
63
+ /** 标题下面那句:失败原文或语料缺席的提示。 */
64
+ detail: string;
65
+ /** 读数是失败来的 ⇒ 红色警告图标;只是「看不见」⇒ 低调灰(看不见 ≠ 没有,ADR-0019)。 */
66
+ tone: 'error' | 'muted';
67
+ onRetry: () => void;
68
+ retryLabel: string;
69
+ }
70
+ /** 打断块:图标 + 标题 + 原文/提示 + 重试;`CARD` 那一族带底色边框,与清单行不是一套长相。 */
71
+ export declare function ListNotice({ title, detail, tone, onRetry, retryLabel }: ListNoticeProps): import("react").JSX.Element;
72
+ export interface ListEmptyProps {
73
+ icon: ReactNode;
74
+ title: string;
75
+ hint: string;
76
+ }
77
+ /** 空态:居中一块,图标 + 标题 + 一句提示。空清单是读数,不是失败。 */
78
+ export declare function ListEmpty({ icon, title, hint }: ListEmptyProps): import("react").JSX.Element;
@@ -1,11 +1,6 @@
1
1
  /**
2
- * 会话行的 live 读法:菜单行与两枚勾选框行共用这一支。
3
- *
4
- * 从 `context-menu-actions.tsx` 分出:那个文件的例外只覆盖**菜单注册**(双轨协商与两个 icon key),
5
- * 不把勾选行的读法也绑进菜单模块;否则菜单模块会因两类无关原因而变(Divergent Change)。
6
- *
7
- * root hook 缺席时走恒等兜底:`running` 判 false、`title` 取空串,hook 顺序不变。
8
- * 读到 false 不等于「没在跑」;Node 半仍会拒绝 live 删除。
2
+ * 会话行的 live 读法(菜单行与两枚勾选框行共用):root hook 缺席时走恒等兜底,`running` 判 false、`title` 取空串,hook 顺序不变。
3
+ * 读到 false 不等于「没在跑」——Node 半仍会拒绝 live 删除。
9
4
  */
10
5
  /** 宿主 root hook 交回的会话 state(只窄镜像本插件用到的两格)。 */
11
6
  export interface SessionRowState {
@@ -14,18 +9,13 @@ export interface SessionRowState {
14
9
  title?: string;
15
10
  } | undefined>;
16
11
  }
17
- /** `ui-session` 通过 `ctx.slots.provideRoot({ hooks: { sessions: ctx.sessions.list } })` 提供的根
18
- * hook(asar @22967283 原文)。 */
12
+ /** `ui-session` 通过 `ctx.slots.provideRoot({ hooks: { sessions: ctx.sessions.list } })` 提供的根 hook(asar @22967283 原文)。 */
19
13
  export type UseSessions = <T>(select: (state: SessionRowState | undefined) => T) => T;
20
- /** 菜单贡献的订阅面只读 `running`;与 `SessionRowState` 同源、窄一格。 */
21
14
  export interface SessionsStateLike {
22
15
  byId?: Record<string, {
23
16
  running?: boolean;
24
17
  } | undefined>;
25
18
  }
26
- /** 会话是否在跑:state / 条目缺席都按「不知道」判 false(Node 半仍会拒绝 live 删除)。 */
27
19
  export declare function runningOf(state: SessionsStateLike | undefined, sessionId: string): boolean;
28
- /** 根 hook 缺失时的兜底:对空 state 求值。恒等身份,hook 顺序不变。 */
29
20
  export declare const NEVER_SESSIONS: UseSessions;
30
- /** 槽位行的 live 读法:root hook 缺席走 NEVER_SESSIONS 兜底;菜单行与两枚勾选框行共用这一支。 */
31
21
  export declare function useSessionLive(useSessions: UseSessions | undefined, sessionId: string): boolean;
@@ -1,17 +1,14 @@
1
1
  /**
2
- * `plugins.bundle.config` 的槽位占用者:上「可调项」、下「维护」(ADR-0043 决定 4)。
3
- *
4
- * 本文件只有两件事:按槽位契约守住视图(`summary` 不渲染,理由见 ADR-0021),以及排两张卡的先后。
5
- * 各自的呈现、状态机与读数仍归 `config-settings.tsx` 与 `maintenance-settings.tsx`。
2
+ * `plugins.bundle.config` 槽位占用者:上「可调项」、下「维护」(ADR-0043 决定 4),只排两张卡的先后;
3
+ * 呈现与状态机归 `config-settings.tsx` / `maintenance-settings.tsx`。
6
4
  */
7
5
  import type { ReactElement } from 'react';
8
6
  import { type Translate } from './copy.js';
9
7
  import type { ConfigDeps } from './remote.js';
10
8
  import type { MaintenanceDeps } from './use-maintenance.js';
11
9
  export interface SettingsCardsProps {
12
- /** 维护四件 + 可调项两件;只造维护四件的测试替身会让「可调项」卡整体缺席。 */
10
+ /** 维护七件 + 可调项两件;只造维护七件的测试替身会让「可调项」卡整体缺席。 */
13
11
  deps: MaintenanceDeps & Partial<ConfigDeps>;
14
- /** 文案(缺省 = 内置 zh;宿主 locale 服务缺席时也是它,见 `copy.ts`)。 */
15
12
  t?: Translate;
16
13
  /** 宿主 `plugins.bundle.config` 的视图:`summary` 是插件行的一行摘要,两张卡都只属于详情页。 */
17
14
  view?: 'summary' | 'page';
@@ -1,9 +1,3 @@
1
- /**
2
- * 插件设置页两张卡共用的**视图词汇**:卡片外壳配方。
3
- *
4
- * 与 `trash-view.ts` 同一个理由:两张卡共用宽度、内距与底色,只有内容节奏(`gap`)不同——各写一份
5
- * 就会一张改了另一张没改。按内容高、铺满宿主给的宽度,不假设自己住在中央面板里(没有 `height:100%`)。
6
- */
1
+ /** 设置页两张卡共用的卡片外壳:宽度、内距与底色同源,只有内容节奏(`gap`)各自给;不假设住在中央面板。 */
7
2
  import type { CSSProperties } from 'react';
8
- /** 设置页卡片外壳:`gap` 是这一张卡自己的内容节奏,其余两张贴一样。 */
9
3
  export declare const settingsCardShell: (gap: number) => CSSProperties;
@@ -1,53 +1,34 @@
1
1
  export interface ClientStore<T> {
2
2
  get(): T;
3
3
  set(next: T): void;
4
- /** 回调回同一引用 ⇒ `false`(不发通告);新值 ⇒ `true`。 */
5
4
  update(next: (current: T) => T): boolean;
6
- /**
7
- * 以本次递增的 seq(从 1 起)造新值并通告,值没变也通告。
8
- * **`make` 回的值必须把 seq 带上**(放进快照字段,如 `{ seq, items }`):订阅方拿它当 React key
9
- * 才会在"同一段文案连续出现两次"时重挂载;丢了 seq,重挂载语义会静默消失。
10
- */
5
+ /** 以本次递增的 seq 造新值并通告(值没变也通告);`make` 回的值**必须把 seq 带上**,订阅方靠它重挂载。 */
11
6
  publish(make: (seq: number) => T): void;
12
7
  subscribe(listener: () => void): () => void;
13
8
  use(): T;
14
- /** 测试专用:回初值并清零 seq。 */
15
9
  reset(): void;
16
10
  }
17
11
  export declare function createStore<T>(initial: T): ClientStore<T>;
18
12
  /** 懒读快照:`get()` 只在脏了时调用 `read()`,干净时回同一个引用(React snapshot 契约)。 */
19
13
  export interface LazyStore<T> {
20
- /** 属性声明:`get` / `subscribe` 会被摘下来直接交给 `useSyncExternalStore`(宿主行快照),
21
- * 实现不读 `this`。方法简写会给它隐式 `this: LazyStore<T>`,触发 `unbound-method` 误报。 */
14
+ /** 属性声明:`get` / `subscribe` 会被摘下来直接交给 `useSyncExternalStore`;方法简写会给隐式 `this`,触发 `unbound-method` 误报。 */
22
15
  get: () => T;
23
- /** 标脏并通告;下一次 `get()` 重读。 */
24
16
  invalidate: () => void;
25
17
  subscribe: (listener: () => void) => () => void;
26
18
  }
27
19
  export declare function createLazyStore<T>(initial: T, read: () => T): LazyStore<T>;
28
- /**
29
- * 最新票句柄:每张票记着签发时的序号,只有序号仍等于当前的那张才 `current`。
30
- * 调用方在发起异步读时 `issue()` 一张票,落地前问 `ticket.current`——旧读因此不会盖掉新状态。
31
- *
32
- * 组件里要拿到**同一枚**句柄时用 `useState(createLatestWins)`,不要用 `useMemo`:React 允许丢 memo
33
- * 缓存,丢了就是两张各自记数的票台,守卫静默失效。模块级现场(`main-view.ts`)直接建一颗,没这个问题。
34
- */
20
+ /** 最新票句柄:异步读落地前问 `ticket.current`,旧读不会盖掉新状态;只拥有 compare-and-set,防抖/轮询/焦点策略仍归调用方。
21
+ * 组件里取同一枚句柄用 `useState(createLatestWins)`,不要 `useMemo`:React 允许丢缓存,丢了就是两张各自记数的票台。 */
35
22
  export interface LatestWinsTicket {
36
23
  readonly current: boolean;
37
24
  }
38
25
  export interface LatestWins {
39
- /** 签发一张新票;之前的票立刻作废。 */
40
26
  issue(): LatestWinsTicket;
41
- /** 只作废当前票,不签发新票(用于"这一拍整体作废")。 */
42
27
  invalidate(): void;
43
28
  }
44
29
  export declare function createLatestWins(): LatestWins;
45
- /**
46
- * 引用归一:输入允许调用方逐渲染换新对象,回调只经这份 ref 读**最新**那一份,于是依赖它的回调
47
- * 身份恒稳、调用方的 effect 可以放心把它们当依赖——「输入必须是稳定引用」的隐式契约就此不存在
48
- * (issue #8 第 3 条)。写回在 effect 里(提交后),与 React 的渲染期只读约定一致。
49
- * 这一形状的唯一实现:别在调用方再手写一份「useRef + 每渲染写回」。
50
- */
30
+ /** 引用归一:回调只经这份 ref 读最新值,身份恒稳、可进 effect 依赖(写回在 effect 里,与渲染期只读约定一致)。
31
+ * 别在调用方再手写「useRef + 每渲染写回」(issue #8 第 3 条)。 */
51
32
  export declare function useLatest<T>(value: T): {
52
33
  readonly current: T;
53
34
  };
@@ -0,0 +1,36 @@
1
+ import { type Translate } from './copy.js';
2
+ import { type SubagentSectionProps } from './session-detail.js';
3
+ /** 子会话行与摘要条共用的显示名:次序走 `preferredNameOf`(ADR-0058),空串走未命名兜底。 */
4
+ export declare function rowName(row: {
5
+ readonly label?: string;
6
+ readonly title: string;
7
+ }, t: Translate): string;
8
+ /** 一个孩子的原始事实:显示名两档各按名次序算好交进来,其余三样由这一段念成话。 */
9
+ export interface SubagentChild {
10
+ readonly id: string;
11
+ readonly name: string;
12
+ /** 已知字节数;`undefined` ⇒ 摆 `sizeAbsentText` 给的那句(不给就摆「—」)。 */
13
+ readonly sizeBytes: number | undefined;
14
+ /** 时间读数(回收站 = 删除时间,归档 = 最后活动);`undefined` ⇒ 这一格不画。 */
15
+ readonly at: number | undefined;
16
+ /** 有可打开的详情才可点;归档里未归档的孩子只读。 */
17
+ readonly navigable: boolean;
18
+ }
19
+ export interface SubagentSectionInput {
20
+ readonly subjectId: string;
21
+ /** 已列出来的孩子(被条数闸截断时就是前 N 条)。空表 ⇒ 整段不画。 */
22
+ readonly children: readonly SubagentChild[];
23
+ /** 孩子总数,只在被截断时给(`undefined` = 已列的就是全部);徽标与「已列 N / 共 M」都读它。 */
24
+ readonly total: number | undefined;
25
+ /** **全部**孩子的已知大小合计(家在 Node 半,不拿已列前 N 条求和——那是少报);`undefined` ⇒ 不摆这一格。 */
26
+ readonly totalSizeBytes: number | undefined;
27
+ /** 单行大小缺席时念什么(归档交自己键上的那句,与它的清单行同一个字符);不给 ⇒ 「—」。 */
28
+ readonly sizeAbsentText?: string;
29
+ /** 展开体里那句「它们跟谁走」;两档各自给(回收站=随组恢复/删除,归档=按自己的归档状态)。 */
30
+ readonly note: string;
31
+ readonly onOpenChild?: (id: string) => void;
32
+ readonly onPrefetchChild?: (id: string) => void;
33
+ readonly t: Translate;
34
+ }
35
+ /** 子会话段的两个槽:徽标(标题排)与段体(计量行之后);没有孩子时缺席。 */
36
+ export declare function useSubagentSection(input: SubagentSectionInput): SubagentSectionProps | undefined;
@@ -1,13 +1,11 @@
1
1
  import { type Translate } from './copy.js';
2
- import type { OrphanReportWire, TrashEntryLike } from './remote.js';
2
+ import type { OrphanReportWire } from '../shared/wire.js';
3
+ import type { OneShotDeps, TrashEntryLike } from './remote.js';
3
4
  import type { PendingAction } from './use-trash-panel-controller.js';
4
- /**
5
- * 两种批量动作共用这一个确认框壳:`purge`(不可恢复)与 `restore`(加法,但一批条目多、去向是
6
- * 各自的旧项目目录,点之前也要过一道)。标题、正文、确认键的措辞各处一套;批量恢复把选中条目
7
- * 列成卡片(标题 + 项目名——恢复的去向是**每条各自的**旧项目目录,逐条列出来是这句话的正文);
8
- * 批量彻底删除只给条数——那批的"去哪"没有可说的,而"不可恢复"那句警告才是要读的。
9
- */
10
- export declare function TrashConfirm({ pending, restoreEntries, busy, t, onCancel, onConfirmPurge, onConfirmRestore, }: {
5
+ /** 两种批量动作共用确认框壳:批量恢复把条目列成卡片(去向是每条各自的旧项目目录);批量彻底删除
6
+ * 只给条数——"不可恢复"那句警告才是要读的。 */
7
+ export declare function TrashConfirm({ deps, pending, restoreEntries, busy, t, onCancel, onConfirmPurge, onConfirmRestore, }: {
8
+ deps: OneShotDeps;
11
9
  pending: PendingAction;
12
10
  restoreEntries: readonly TrashEntryLike[];
13
11
  busy: boolean;
@@ -17,7 +15,8 @@ export declare function TrashConfirm({ pending, restoreEntries, busy, t, onCance
17
15
  onConfirmRestore: (ids: readonly string[]) => void;
18
16
  }): import("react").JSX.Element;
19
17
  /** 无主子会话的清理确认框。载荷是刚扫出来的那份报告,界面不重算。 */
20
- export declare function OrphanConfirm({ report, busy, t, onCancel, onConfirm, }: {
18
+ export declare function OrphanConfirm({ deps, report, busy, t, onCancel, onConfirm, }: {
19
+ deps: OneShotDeps;
21
20
  report: OrphanReportWire;
22
21
  busy: boolean;
23
22
  t: Translate;