@xrn1997/dsh-session-delete 0.7.0 → 0.9.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 (106) hide show
  1. package/README.md +133 -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 +5276 -2159
  9. package/lib/index.js +1594 -489
  10. package/lib/types/api/archive-rows.d.ts +20 -0
  11. package/lib/types/api/attachment.d.ts +2 -2
  12. package/lib/types/api/connection-route.d.ts +1 -1
  13. package/lib/types/api/route-table.d.ts +100 -11
  14. package/lib/types/client/archive-detail.d.ts +27 -0
  15. package/lib/types/client/archive-pane.d.ts +60 -0
  16. package/lib/types/client/archive-store.d.ts +6 -0
  17. package/lib/types/client/attachment-view.d.ts +0 -7
  18. package/lib/types/client/batch-bar.d.ts +5 -6
  19. package/lib/types/client/batch-confirm.d.ts +19 -11
  20. package/lib/types/client/batch-menu-item.d.ts +1 -1
  21. package/lib/types/client/batch-pick.d.ts +2 -1
  22. package/lib/types/client/busy-gate.d.ts +12 -5
  23. package/lib/types/client/config-settings.d.ts +2 -2
  24. package/lib/types/client/confirm-dialog.d.ts +23 -0
  25. package/lib/types/client/context-menu-actions.d.ts +11 -5
  26. package/lib/types/client/copy.d.ts +66 -14
  27. package/lib/types/client/delete-confirm.d.ts +2 -2
  28. package/lib/types/client/delete-menu-item.d.ts +2 -2
  29. package/lib/types/client/detail-ledger.d.ts +23 -0
  30. package/lib/types/client/detail-pane.d.ts +33 -0
  31. package/lib/types/client/host-archive-watch.d.ts +22 -0
  32. package/lib/types/client/host-rows.d.ts +7 -0
  33. package/lib/types/client/maintenance-parts.d.ts +4 -3
  34. package/lib/types/client/maintenance-settings.d.ts +4 -3
  35. package/lib/types/client/notice.d.ts +16 -0
  36. package/lib/types/client/orphan-maintenance.d.ts +1 -1
  37. package/lib/types/client/plugin.d.ts +6 -0
  38. package/lib/types/client/prompt-rail.d.ts +22 -0
  39. package/lib/types/client/receipt.d.ts +4 -1
  40. package/lib/types/client/remote.d.ts +82 -98
  41. package/lib/types/client/reset-client-state.d.ts +1 -0
  42. package/lib/types/client/session-detail.d.ts +94 -0
  43. package/lib/types/client/session-list.d.ts +112 -0
  44. package/lib/types/client/session-live.d.ts +31 -0
  45. package/lib/types/client/settings-cards.d.ts +1 -1
  46. package/lib/types/client/subagent-section.d.ts +45 -0
  47. package/lib/types/client/trash-confirm.d.ts +2 -1
  48. package/lib/types/client/trash-detail.d.ts +9 -50
  49. package/lib/types/client/trash-nav.d.ts +8 -7
  50. package/lib/types/client/trash-panel.d.ts +1 -1
  51. package/lib/types/client/trash-snapshot.d.ts +38 -0
  52. package/lib/types/client/trash-view.d.ts +41 -10
  53. package/lib/types/client/ui/ErrorBoundary.d.ts +32 -0
  54. package/lib/types/client/ui/icons.d.ts +10 -4
  55. package/lib/types/client/undo-notices.d.ts +27 -7
  56. package/lib/types/client/undo-toast.d.ts +5 -3
  57. package/lib/types/client/use-archive-detail-reader.d.ts +28 -0
  58. package/lib/types/client/use-archive-panel-controller.d.ts +73 -0
  59. package/lib/types/client/use-archive-query.d.ts +29 -0
  60. package/lib/types/client/use-detail-pager.d.ts +7 -3
  61. package/lib/types/client/use-detail-rail.d.ts +48 -0
  62. package/lib/types/client/use-detail-reader.d.ts +71 -0
  63. package/lib/types/client/use-gated-refresh.d.ts +27 -0
  64. package/lib/types/client/{use-trash-selection.d.ts → use-list-selection.d.ts} +16 -14
  65. package/lib/types/client/use-maintenance-section.d.ts +29 -18
  66. package/lib/types/client/use-maintenance.d.ts +21 -8
  67. package/lib/types/client/use-panel-selection.d.ts +38 -0
  68. package/lib/types/client/use-prefetch.d.ts +14 -0
  69. package/lib/types/client/use-prompt-rail.d.ts +60 -0
  70. package/lib/types/client/use-trash-detail-reader.d.ts +27 -0
  71. package/lib/types/client/use-trash-panel-controller.d.ts +23 -9
  72. package/lib/types/client/use-trash-query.d.ts +14 -7
  73. package/lib/types/client/write-seats.d.ts +95 -23
  74. package/lib/types/deps.d.ts +9 -6
  75. package/lib/types/{verbs/errors.d.ts → errors.d.ts} +1 -1
  76. package/lib/types/index.d.ts +1 -1
  77. package/lib/types/log/session-log.d.ts +24 -2
  78. package/lib/types/log/zstd-frames.d.ts +8 -1
  79. package/lib/types/ports/fs-port.d.ts +35 -2
  80. package/lib/types/ports/host-port.d.ts +107 -15
  81. package/lib/types/shared/project-key.d.ts +28 -0
  82. package/lib/types/shared/session-path.d.ts +35 -0
  83. package/lib/types/shared/wire.d.ts +250 -36
  84. package/lib/types/trash/archive-detail.d.ts +27 -0
  85. package/lib/types/trash/attachments.d.ts +7 -4
  86. package/lib/types/trash/detail.d.ts +28 -3
  87. package/lib/types/trash/display-name.d.ts +16 -0
  88. package/lib/types/trash/entry.d.ts +27 -10
  89. package/lib/types/trash/groups.d.ts +1 -0
  90. package/lib/types/trash/ledger.d.ts +4 -2
  91. package/lib/types/trash/projection-cache.d.ts +24 -0
  92. package/lib/types/trash/reconcile.d.ts +5 -3
  93. package/lib/types/trash/session-rows.d.ts +83 -0
  94. package/lib/types/trash/shrinking-view.d.ts +30 -0
  95. package/lib/types/verbs/batch-carried.d.ts +4 -2
  96. package/lib/types/verbs/live-admission.d.ts +7 -2
  97. package/lib/types/verbs/member-journal.d.ts +1 -1
  98. package/lib/types/verbs/permanent-removal.d.ts +15 -5
  99. package/lib/types/verbs/restore-session.d.ts +6 -4
  100. package/lib/types/verbs/trash-scope.d.ts +14 -13
  101. package/locale/en.json +7 -6
  102. package/locale/zh.json +2 -1
  103. package/package.json +10 -4
  104. package/lib/types/client/confirm-close.d.ts +0 -14
  105. package/lib/types/client/write-settlement.d.ts +0 -66
  106. package/lib/types/client/write.d.ts +0 -64
@@ -0,0 +1,20 @@
1
+ /**
2
+ * `GET /archive-list` 那一行的装配:registry 归档集 ∩ 会话语料 → `ArchiveListWire`。
3
+ *
4
+ * 与 `api/trash-rows.ts` 同层同责(「一行里放什么」),但两档各写各的口径:归档行念
5
+ * `sessionPersistence.sizeBytes`(宿主持久化日志工件字节)与「最后活动」,回收站行念清册
6
+ * 的目录实测与删除时间——**两个 sizeBytes 不是一个数**(ADR-0060 决定第 3 条)。
7
+ *
8
+ * 四路读面(标题 / 活动 / 大小 / label)的缺席口径住 `src/trash/session-rows.ts`,这一层只管
9
+ * 「哪一批 id、哪些格要过线」:
10
+ * - `sessionQuery` 缺席 ⇒ `{ available: false }`(显式的「语料不可见」,不是空列表);
11
+ * - 大小读面抛错 ⇒ 整档 `io`(`sizeFailure: 'throw'`,不拿 0 冒充没有大小);
12
+ * - label 那格只随**子会话行**过线(普通行的 `labelOf` 念的是标题那一路,不是 descriptor label)。
13
+ *
14
+ * 交集按 **id 原样**(与 `isArchived` 的精确判据一致):ghost id(归档集里有、语料已无记录)
15
+ * 宁可少显示也不显示死行——删除不改 `archivedSessionIds`(ADR-0008),回收站里那条也靠这道
16
+ * 交集自动消失。
17
+ */
18
+ import type { CoreDeps } from '../deps.js';
19
+ import type { ArchiveListWire } from '../shared/wire.js';
20
+ export declare function assembleArchiveRows(deps: CoreDeps): Promise<ArchiveListWire>;
@@ -19,13 +19,13 @@
19
19
  *
20
20
  * 请求本身不对(id/kind 形状)⇒ 400;对象不在 / 超限 / 读失败 ⇒ 200 + 信封(与其余段同一条错误面)。
21
21
  */
22
- import type { FsPort } from '../ports/fs-port.js';
22
+ import type { FsAttachmentPort } from '../ports/fs-port.js';
23
23
  import type { SessionDeleteConfig } from '../config.js';
24
24
  import type { AttachmentsPort } from '../ports/attachments-port.js';
25
25
  import type { BinaryResponse } from './route-table.js';
26
26
  /** 读附件只需要 stat + read、宿主 `attachments` 读面与响应上限;执行面(removeDir/removeFile)不给。 */
27
27
  export interface AttachmentReadPorts {
28
- fs: Pick<FsPort, 'statFile' | 'readFile'>;
28
+ fs: FsAttachmentPort;
29
29
  home: string;
30
30
  attachments: AttachmentsPort;
31
31
  config: Pick<SessionDeleteConfig, 'maxAttachmentBytes'>;
@@ -15,7 +15,7 @@ export interface ConnectionFetchServiceLike {
15
15
  };
16
16
  }
17
17
  /**
18
- * 注册十段 exact Fetch 路由。返回一个组合 disposer;调用方把它挂在自己的 effect 上。
18
+ * 注册全部段名 exact Fetch 路由。返回一个组合 disposer;调用方把它挂在自己的 effect 上。
19
19
  * `connection` 是插件的硬依赖(web UI / 桌面端都装 `client-connection`);`fetch.register`
20
20
  * 缺席属于宿主形状漂移,直接抛——静默返回空 disposer 会让插件「在但没有入口」。
21
21
  * `dispatch` 与分发器同源。
@@ -8,15 +8,21 @@
8
8
  * - 切片声明宽了 ⇒ 危险能力(删目录 / 时钟)漏进读段的 run;窄了 ⇒ 写段的处理编译不过。
9
9
  *
10
10
  * 这张表不放 shared/wire.ts:处理函数会 import 动词与 node:fs,而浏览器半要 import wire.ts。
11
- * 段名、方法与动作仍住 wire.ts(`ROUTES` 每项 `{ path, method }`,本表的 method 只投影、不写第二份字面量);
12
- * 这张表只回答“怎么处理”。
11
+ * 段名、方法、请求体形状与字段组描述住 wire.ts(`ROUTES` 每项 `{ path, method, body }`,本表的 method /
12
+ * body 由 `defineRoute` 从段名表那一格派生、不写第二份字面量;字段组描述 `BODY_GROUPS` 由本表的
13
+ * 通用解析手消费);这张表只回答“怎么处理”。
13
14
  */
14
- import { type ApplyAction, type RouteName } from '../shared/wire.js';
15
+ import { ROUTES, type ApplyAction, type RouteBody, type RouteName } from '../shared/wire.js';
15
16
  import type { ConfigEditorLike, CoreDeps, DeleteDeps, RemovalDeps } from '../deps.js';
16
17
  import type { AttachmentsPort } from '../ports/attachments-port.js';
17
18
  import type { TrashEntry } from '../trash/entry.js';
18
19
  /** 请求体:`json` 才读下来(GET 一律不读;读两遍会把流消费掉)。 */
19
20
  export type BodyKind = 'none' | 'json';
21
+ /** 读的是 wire 那一格(`ROUTES.x.body`),本表不写第二份:无字段与查询串段不读;
22
+ * 带 JSON 字段的段(config / entry / apply / sessionId)读一次。`defineRoute` 据此填行的 `body`。 */
23
+ export declare function bodyOf(route: {
24
+ readonly body: RouteBody;
25
+ }): BodyKind;
20
26
  /** 到达序:`pure` 不进链;`chained` 进链;函数形式给 `/apply` 用(`count` 是纯读)。 */
21
27
  export type Purity = 'pure' | 'chained' | ((body: JsonBody) => 'pure' | 'chained');
22
28
  /** 清册读面:`none` = 不读;`list` = 真相读(先对账);`raw` = 索引快照(不对账)。
@@ -34,8 +40,8 @@ export interface BinaryResponse {
34
40
  export interface RouteRead {
35
41
  rows(): Promise<readonly TrashEntry[]>;
36
42
  }
37
- /** deps 切片(ADR-0032):每一段只声明自己要的那一面。读与探测五段拿基础面,`attachment` 段另多一条
38
- * 宿主 `attachments` 读面,两个删盘段多删除能力,`/apply` 是唯一拿全量面的行,`/config` 只多
43
+ /** deps 切片(ADR-0032):每一段只声明自己要的那一面。读与探测各段拿基础面,`attachment` 段另多一条
44
+ * 宿主 `attachments` 读面,三个写段多删除能力(`/empty`、`/attachment-clean`、`/projection-clean`),`/apply` 是唯一拿全量面的行,`/config` 只多
39
45
  * configEditor + entry 两件(段的 run 里长出超面调用就是编译错;dispatch 也只按这一格注入,
40
46
  * 运行期收窄住 `src/api/dispatch.ts` 的 `slicesOf`)。 */
41
47
  export type RouteSlice = 'core' | 'removal' | 'full' | 'attachment' | 'config';
@@ -58,33 +64,116 @@ interface BaseRouteSpec<S extends RouteSlice> {
58
64
  readonly method: 'GET' | 'POST';
59
65
  readonly body: BodyKind;
60
66
  readonly purity: Purity;
61
- readonly read: ReadKind;
62
67
  /** 同源取数闸(ADR-0033):只有能被别的页面渲染消费的段需要;判据住 `src/api/connection-route.ts`。
63
68
  * 缺省不设闸——JSON 响应跨源读不到(没有 CORS),不需要它。 */
64
69
  readonly fetchGate?: 'same-origin';
65
70
  }
66
- /** JSON 段:处理函数拿请求体与读面;`query` 不在这里(十行里只有二进制段需要查询串)。 */
67
- export interface JsonRouteSpec<S extends RouteSlice = RouteSlice> extends BaseRouteSpec<S> {
71
+ /** `read: 'none'` 的 JSON 段:处理函数只拿请求体——没有读面可交,签名里也就不摆 `RouteRead`
72
+ * (none 行想看读面是编译错,不是运行期才炸的拒约)。 */
73
+ export interface NoReadJsonRouteSpec<S extends RouteSlice = RouteSlice> extends BaseRouteSpec<S> {
74
+ readonly read: 'none';
75
+ readonly response: 'json';
76
+ /** 声明成函数属性而不是方法:方法签名是双变的,显式标注更宽的 deps 能绕过切片闸;属性按逆变校验。 */
77
+ readonly run: (deps: SliceDeps[S], body: JsonBody) => Promise<unknown>;
78
+ }
79
+ /** `read: 'list' | 'raw'` 的 JSON 段:处理函数拿请求体与读面;`query` 不在这里(段名表里只有二进制段需要查询串)。 */
80
+ export interface ReadJsonRouteSpec<S extends RouteSlice = RouteSlice> extends BaseRouteSpec<S> {
81
+ readonly read: 'list' | 'raw';
68
82
  readonly response: 'json';
69
83
  /** 声明成函数属性而不是方法:方法签名是双变的,显式标注更宽的 deps 能绕过切片闸;属性按逆变校验。 */
70
84
  readonly run: (deps: SliceDeps[S], body: JsonBody, read: RouteRead) => Promise<unknown>;
71
85
  }
86
+ /** JSON 段(两种读面的并集):`response` 是 `json` 的行都归它;按 `read` 再分成拿不拿读面两形。 */
87
+ export type JsonRouteSpec<S extends RouteSlice = RouteSlice> = NoReadJsonRouteSpec<S> | ReadJsonRouteSpec<S>;
72
88
  /** 二进制段:只有 `/attachment`;处理函数直接拿查询串,交回字节与安全头。 */
73
89
  export interface BinaryRouteSpec<S extends RouteSlice = RouteSlice> extends BaseRouteSpec<S> {
90
+ readonly read: 'none';
74
91
  readonly response: 'binary';
75
92
  readonly run: (deps: SliceDeps[S], query: URLSearchParams) => Promise<BinaryResponse>;
76
93
  }
77
94
  export type RouteSpec<S extends RouteSlice = RouteSlice> = JsonRouteSpec<S> | BinaryRouteSpec<S>;
78
- /** 十行的并集(表的值类型):每行由自己的 `slice` 与 `response` 字面量定型,`run` 的 deps 面随之收窄。 */
95
+ /** 各行的并集(表的值类型):每行由自己的 `slice` 与 `response` 字面量定型,`run` 的 deps 面随之收窄。 */
79
96
  export type AnyRouteSpec = {
80
97
  [S in RouteSlice]: RouteSpec<S>;
81
98
  }[RouteSlice];
99
+ /** 行的决定半(`defineRoute` 三个重载的入参):只写 `slice` / 纯度 / 读面 / 处理——`name` 是段名,
100
+ * `method` 与 `body` 由 `defineRoute` 按 `name` 从段名表取,行里写不进第二份(写了就是编译错的
101
+ * 多余属性)。none 行的 `run` 允许少写形参(探测段没有可读的入参,`/ping` 连请求体都不消费)。 */
102
+ interface NoneJsonDecision<S extends RouteSlice> {
103
+ readonly slice: S;
104
+ readonly purity: Purity;
105
+ readonly read: 'none';
106
+ readonly response?: 'json';
107
+ readonly fetchGate?: 'same-origin';
108
+ readonly run: (deps: SliceDeps[S], body: JsonBody) => Promise<unknown>;
109
+ }
110
+ /** 读行的决定半。`run` 的形参数量**恰好**三参:TS 的函数赋值默认放行少参,而读行声明了读面、
111
+ * `run` 却少接一个形参就是「带读面声明却拿不到读面」的死接线——按 `R` 数形参,少一个、多一个
112
+ * 都把 `run` 判成 `never`(编译错)。`R` 只从 `run` 推断,形参的上下文类型取 `R` 的约束
113
+ * (标准三参形),行体照常按它写。 */
114
+ type ReadJsonDecision<S extends RouteSlice, R extends (deps: SliceDeps[S], body: JsonBody, read: RouteRead) => Promise<unknown>> = {
115
+ readonly slice: S;
116
+ readonly purity: Purity;
117
+ readonly read: 'list' | 'raw';
118
+ readonly response?: 'json';
119
+ readonly fetchGate?: 'same-origin';
120
+ readonly run: R;
121
+ } & (Parameters<R>['length'] extends 3 ? unknown : {
122
+ readonly run: never;
123
+ });
124
+ /** 二进制行的决定半:同一条数参判据,`run` 恰好两参——`query` 是它的寻址入参,
125
+ * 少接一个就只剩一个不会寻址的处理器。 */
126
+ type BinaryDecision<S extends RouteSlice, R extends (deps: SliceDeps[S], query: URLSearchParams) => Promise<BinaryResponse>> = {
127
+ readonly slice: S;
128
+ readonly purity: Purity;
129
+ readonly read: 'none';
130
+ readonly response: 'binary';
131
+ readonly fetchGate?: 'same-origin';
132
+ readonly run: R;
133
+ } & (Parameters<R>['length'] extends 2 ? unknown : {
134
+ readonly run: never;
135
+ });
136
+ /** 段名表的键(`list` / `ping` / …):与 `RouteName`(每项的 `path`)是两个域——行文按键写、
137
+ * 线上段名是它的 `path`,`defineRoute` 拿键去段名表取那一格。 */
138
+ type RouteKey = keyof typeof ROUTES;
139
+ /** 段名键 → 行的条目:`name` 是这条目自己的段名键,组装器按它派生键——键与段名同一个字面量,错不开。 */
140
+ type RouteEntry<N extends RouteKey> = {
141
+ readonly name: N;
142
+ readonly spec: AnyRouteSpec;
143
+ };
144
+ /**
145
+ * 一行路由 = 段名 + 决定半:`method` / `body` 从 `ROUTES[name]` 派生(投影只这一处,行里写不进第二份),
146
+ * 纯度 / 读面 / 切片 / 处理由调用方给。三个重载按 `read` 与 `response` 分派 `run` 的形:
147
+ * none 的 JSON 行只拿请求体(拿不到 `RouteRead`),`list` / `raw` 行多拿读面(恰好三参),
148
+ * 二进制行拿查询串(恰好两参)——`read` 与 `response` 的组合三选一,坏组合没有重载收。
149
+ * 交回条目(段名 + 行)而不是裸行:`createRouteTable` 按 `name` 派生键,行文里没有第二个可写错的段名。
150
+ */
151
+ export declare function defineRoute<N extends RouteKey, S extends RouteSlice>(name: N, decision: NoneJsonDecision<S>): RouteEntry<N>;
152
+ export declare function defineRoute<N extends RouteKey, S extends RouteSlice, R extends (deps: SliceDeps[S], body: JsonBody, read: RouteRead) => Promise<unknown>>(name: N, decision: ReadJsonDecision<S, R>): RouteEntry<N>;
153
+ export declare function defineRoute<N extends RouteKey, S extends RouteSlice, R extends (deps: SliceDeps[S], query: URLSearchParams) => Promise<BinaryResponse>>(name: N, decision: BinaryDecision<S, R>): RouteEntry<N>;
154
+ /**
155
+ * `/apply` 的六个动作与各自的**静态纯度**。一张表三个用途:动作名单由键派生,纯度从同一格读,
156
+ * 唯一识别器(`actionOf`)也只认这些键——新增动作必须同时给出纯度,漏了编译不过;
157
+ * 新加一个纯读动作也不会再静默落进 `chained`。
158
+ */
159
+ export declare const APPLY_ACTION_TABLE: {
160
+ delete: "chained";
161
+ restore: "chained";
162
+ purge: "chained";
163
+ count: "pure";
164
+ 'orphan-clean': "chained";
165
+ unarchive: "chained";
166
+ };
82
167
  export declare const APPLY_ACTIONS: readonly ApplyAction[];
83
168
  /**
84
- * 十个段名各一行。`Record<段名, AnyRouteSpec>` 是闸:`wire.ts` 加了段名而这里没加,编译不过;
169
+ * 段名表逐行:键是段名(`createRouteTable` 按条目的段名派生成 `ROUTES[name].path`,行文里不手写键),
170
+ * 值经 `defineRoute` 构造。`Record<段名, AnyRouteSpec>` 是闸:`wire.ts` 加了段名而这里没加,编译不过;
85
171
  * 每行的 `slice` 又把该行的 `run` 钉在自己那一格 deps 上(ADR-0032)。
86
172
  */
87
173
  export declare const ROUTE_TABLE: Record<RouteName, AnyRouteSpec>;
88
- /** 段名 → 那一行;不认识的段名回 `undefined`(调用方抛 404,并带出原路径)。 */
174
+ /** 段名 → 那一行;不认识的段名回 `undefined`(调用方抛 404,并带出原路径)。
175
+ * **必须问 `Object.hasOwn`**:段名来自线上路径,`constructor` / `toString` 这类原型属性名会从
176
+ * `Record` 的索引读里"查到"一个函数,把未知路径判成已知路由(随后以 405 / 处理期炸开的形态出现)。
177
+ * 这里只认表自身的键——表是 `Object.fromEntries` 建出来的,自有键恰好就是段名。 */
89
178
  export declare function routeOf(rest: string): RouteSpec | undefined;
90
179
  export {};
@@ -0,0 +1,27 @@
1
+ /**
2
+ * 归档详情投影(`session-detail.tsx` 的归档档入口):信息表**恰五行**
3
+ * (项目 / 日志末条 / 会话 id / 大小 / 状态),无「回收站目录」「原本归档」;
4
+ * 子会话段与回收站共用同一套呈现(数据来自宿主闭包,见 `src/trash/archive-detail.ts`)。
5
+ *
6
+ * 标题与大小与**选中行**配对:显示名走 `displayNameOf`(label 优先),大小只摆信息表那一行
7
+ * (行的 `sizeBytes`,缺席显式「—」;计量行不重复)——详情只给正文与日志读数,不重算这两格。
8
+ * 状态行认**主体自己的归档态**(不认导航道):已归档主体(清单行、以及清单不可见时被打开的
9
+ * 已归档孩子)说「已归档」;未归档孩子说「随归档父会话查看」。
10
+ */
11
+ import type { Translate } from './copy.js';
12
+ import type { ArchiveDetailLike } from './remote.js';
13
+ import type { DetailState } from './use-detail-reader.js';
14
+ import type { ArchiveDetailSubject } from './use-archive-detail-reader.js';
15
+ import { type DetailNav, type DetailPager } from './session-detail.js';
16
+ export interface ArchiveDetailProps {
17
+ state: DetailState<ArchiveDetailSubject, ArchiveDetailLike>;
18
+ busy: boolean;
19
+ wide: boolean;
20
+ /** 与回收站档同一面导航(按会话 id 交接,`DetailNav`);孩子视图由 `parentContext` 在场判定。 */
21
+ detailNav: DetailNav;
22
+ onRetry: () => void;
23
+ onBack: () => void;
24
+ pager: DetailPager;
25
+ t: Translate;
26
+ }
27
+ export declare function ArchiveDetail({ state, busy, wide, detailNav, onRetry, onBack, pager, t, }: ArchiveDetailProps): import("react").JSX.Element;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * 归档档的三个纯视图件(清单列 / 工具行 / 页脚):状态面来自 `useArchiveQuery`(四态),
3
+ * 动作面来自 `useArchivePanelController`,勾选面来自 `useListSelection`(归档自己的那一台)。
4
+ *
5
+ * 清单的 DOM 不在这里拼——grid、组头、行壳与那三张状态卡都由 `src/client/session-list.tsx` 的
6
+ * `SessionList` 交出,这一档只交**行读数**与**那一排动作**。
7
+ *
8
+ * 行语义(docs/ui-spec.md §3.1):显示名(`displayNameOf`,label 优先)+ 最后活动/创建于 + 大小
9
+ * (缺席显式「—」)+ 行右两枚图标按钮(解除归档 / 删除,均带 `aria-label`、不写 emoji);行点击 =
10
+ * 选中看详情(不做原生打开);孤儿子会话照常显示并带「子代理」标签。
11
+ *
12
+ * 「最后活动」与「创建于」是归档档自己的口径(`updatedAtSource`),与回收站的「删除于」不是同一句;
13
+ * 数据标签按档不同,界面语言按档相同(ADR-0060 边界)。
14
+ */
15
+ import type { RefObject } from 'react';
16
+ import { type Translate } from './copy.js';
17
+ import type { ArchiveRowWire } from '../shared/wire.js';
18
+ import { type ProjectGroup } from './trash-view.js';
19
+ import { type ListDom } from './session-list.js';
20
+ import type { ArchiveQuery } from './use-archive-query.js';
21
+ import type { ListSelection } from './use-list-selection.js';
22
+ import type { ArchivePanelController } from './use-archive-panel-controller.js';
23
+ import type { TrashNav } from './trash-nav.js';
24
+ /** 这一档进 DOM 的身份:行身份是会话 id(回收站那边是条目 id)。 */
25
+ export declare const ARCHIVE_LIST_DOM: ListDom;
26
+ /** 行身份:模块级稳定引用(面板把导航接在这里)。 */
27
+ export declare const archiveRowIdOf: (row: ArchiveRowWire) => string;
28
+ export interface ArchiveListProps {
29
+ query: ArchiveQuery;
30
+ selection: ListSelection<ArchiveRowWire>;
31
+ groups: readonly ProjectGroup<ArchiveRowWire>[];
32
+ controller: Pick<ArchivePanelController, 'selectRow' | 'prefetch' | 'unarchive' | 'requestDeleteOne' | 'actionFailure' | 'busy'>;
33
+ /** 清单的 grid 节点:面板的 `useRowFocus` 按 `ARCHIVE_LIST_DOM.idAttr` 查询它。 */
34
+ listRef: RefObject<HTMLDivElement>;
35
+ /** 键盘契约(导航状态住面板,窄档下钻时清单卸载也不丢 Esc 与焦点交还)。 */
36
+ nav: TrashNav;
37
+ /** 当前活动行(选中行优先,回落光标):说「详情正画着这一条」,也只在非多选态参与 `aria-selected`。
38
+ * 光标与活动行都住控制器(`activeId` / `selectRow`),清单不再自己回报光标。 */
39
+ activeId: string | null;
40
+ onRetry: () => void;
41
+ t: Translate;
42
+ }
43
+ /** 清单列:四态里非「有行」的三档各交一块普通内容;有行时只交读数与动作给 `SessionList`。 */
44
+ export declare function ArchiveList({ query, selection, groups, controller, listRef, nav, activeId, onRetry, t }: ArchiveListProps): import("react").JSX.Element;
45
+ export interface ArchiveToolbarProps {
46
+ selection: ListSelection<ArchiveRowWire>;
47
+ groups: readonly ProjectGroup<ArchiveRowWire>[];
48
+ t: Translate;
49
+ }
50
+ /** 工具行随档位:全部折叠 / 多选(归档档自己的选择面)。 */
51
+ export declare function ArchiveToolbar({ selection, groups, t }: ArchiveToolbarProps): import("react").JSX.Element;
52
+ export interface ArchiveFooterProps {
53
+ selection: ListSelection<ArchiveRowWire>;
54
+ controller: Pick<ArchivePanelController, 'unarchive' | 'requestDeleteMany' | 'busy'>;
55
+ t: Translate;
56
+ }
57
+ /** 页脚随档位:多选态 = 「解除所选」(无确认框)/「删除所选」(实心红,确认框语义同批量删除)。
58
+ * 危险那颗仍是这一排的最后一个(「整页唯一一块实心红」的位置契约)。
59
+ * 勾中的行读选择面那一份派生(`checkedRows`,含折叠组),不在这里从 groups 重算。 */
60
+ export declare function ArchiveFooter({ selection, controller, t }: ArchiveFooterProps): import("react").JSX.Element | null;
@@ -0,0 +1,6 @@
1
+ /** 通告一次"归档可见性变过了"(旁路观察、解除归档自救)。 */
2
+ export declare function invalidateArchive(): void;
3
+ /** 供归档查询订阅。 */
4
+ export declare function useArchiveRevision(): number;
5
+ /** 测试专用:修订号归零(订阅者随组件卸载自行退订)。 */
6
+ export declare function resetArchiveStore(): void;
@@ -18,10 +18,3 @@ export declare function AttachmentStrip({ attachments, t, align, }: {
18
18
  /** `end`(默认)= 靠右,用户气泡那一侧;`start` = 靠左,助手正文那一侧。 */
19
19
  align?: 'start' | 'end';
20
20
  }): import("react").JSX.Element | null;
21
- /**
22
- * 附件清理回执那一行提示(「N 个附件未能清理」/「附件未清理:原因」)。表现层只收一句已经拼好的话;
23
- * 什么时候该有这句话、失败与跳过怎么拼,归接线的那一侧(判据住 `receipt.ts` 与 `use-trash-query.ts`)。
24
- */
25
- export declare function AttachmentNotice({ message }: {
26
- message: string | null;
27
- }): import("react").JSX.Element | null;
@@ -11,15 +11,14 @@
11
11
  *
12
12
  * 那个 K 是**勾选变化后防抖 300ms 的一次批量 count**(`/apply` 的 `action:'count'`,一组 id 一次),
13
13
  * 并且带**最新票守卫**:在飞的旧响应不许盖掉新名单的读数(compare-and-set 住 `createLatestWins`,
14
- * 防抖本身仍在下面这个 effect 里)。
15
- * 读不到就整句不说——K 是合计,缺一条就是假数(「不许拿 0 冒充没有」)。
14
+ * 防抖本身仍在下面这个 effect 里)。**读数与它对应的那份名单绑在一起存**:名单对不上(刚勾了一条、
15
+ * 新读还在窗口里)就整句不说——拿旧读数求新名单的和,会把新增那条按 0 算出一个偏小的假数。
16
+ * 读不到也整句不说——K 是合计,缺一条就是假数(「不许拿 0 冒充没有」)。
16
17
  */
17
18
  import { type ReactElement } from 'react';
18
19
  import { type Translate } from './copy.js';
19
- import type { SessionDeleteRemote } from './remote.js';
20
- /** 浮条只需要那一个批量口(计数);执行归确认框。 */
21
- export type BatchBarDeps = Pick<SessionDeleteRemote, 'applyOutcomes'>;
20
+ import type { OneShotDeps } from './remote.js';
22
21
  export declare function BatchBar({ deps, t, }: {
23
- deps: BatchBarDeps;
22
+ deps: OneShotDeps;
24
23
  t?: Translate;
25
24
  }): ReactElement | null;
@@ -1,33 +1,41 @@
1
1
  /**
2
2
  * 批量删除的确认框——挂在 `shell.overlay` 上的宿主,加它读的那个模块级现场。
3
3
  *
4
- * 为什么又开一个文件而不是把 `delete-confirm.tsx` 撑大:单删那张框是**已交付的面**(docs/ui-spec.md 状态 ②,
5
- * 用例钉着),批量形与它只有三件不同——标题随条数、目标卡逐条列、执行是一次批量 `apply`。共用一个壳
6
- * 意味着单删的 `busy` / 失败面要跟着学批量形,那是拿已交付的行为去换省一个文件。卡片样式(`TARGET_CARD`)
7
- * 与 hint、子会话那两句**复用**单删的,一句不造第二个键。
4
+ * 与单删那张框的关系:**页脚与关框规则共壳**(`confirm-dialog.tsx`,裁决见 ADR-0052),业务面
5
+ * 仍然各是各的——批量形的标题随条数、目标卡逐条列、执行是一次批量 `apply`、失败面按行回;
6
+ * 单删的 `busy` / 失败面没有被拖进来。卡片样式(`TARGET_CARD`)与 hint、子会话那两句**复用**单删的,
7
+ * 一句不造第二个键。
8
8
  *
9
9
  * 现场是模块级的(同 `delete-confirm.tsx` / `undo-notices.ts`):请求从浮条那颗按钮发来,确认框住在
10
10
  * `shell.overlay` 上——它必须活在行开关那棵子树之外(槽位行随宿主重排而卸载,见 `delete-confirm.tsx` 头注)。
11
+ *
12
+ * 这张框不认识任何一方的选中集:宿主浮条与回收站面板的归档档都发请求进来,**执行后怎么收缩自己的
13
+ * 勾选由发请求那一面交钩子**(`shrinkSelection`)。框自己只收缩请求现场(重试轮只发失败 id)。
11
14
  */
12
15
  import { type ReactElement } from 'react';
13
16
  import { type Translate } from './copy.js';
14
- import type { SessionDeleteRemote } from './remote.js';
15
- import { type PickItem } from './batch-selection-store.js';
17
+ import type { OneShotDeps } from './remote.js';
18
+ import type { PickItem } from './batch-selection-store.js';
16
19
  export interface BatchDeleteRequest {
17
20
  /** 每次发布递增:换一批就重挂载,busy / 失败面不带着上一批的记忆。 */
18
21
  seq: number;
19
22
  items: readonly PickItem[];
23
+ /** 落地后收缩**发请求那一面**的选中集(宿主浮条交 picks 的收缩;归档档不交,勾选面归面板自己)。
24
+ * 被闸挡回的那一趟不调它——这一趟没跑,不许照着它动任何选中集。 */
25
+ shrinkSelection?: (failedSessionIds: readonly string[]) => void;
20
26
  }
21
- /** 浮条那颗按钮调用:请求确认这一批(缺省 = 当前选中集)。空名单不发框。 */
22
- export declare function requestDeleteBatch(items?: readonly PickItem[]): void;
23
- export declare function clearDeleteBatchRequest(): void;
27
+ /** 请求确认这一批。空名单不发框。`shrinkSelection` 是调用方自己的选中集收尾,缺席 = 这一面没有要收缩的选中集。 */
28
+ export declare function requestDeleteBatch(items: readonly PickItem[], shrinkSelection?: (failedSessionIds: readonly string[]) => void): void;
29
+ /** 收起确认框(用户点「取消」/「关闭」、或整批成功后收工)。
30
+ * **带 expected 比较**:一次批量在飞时用户可能已经发布了**下一批**请求(框按 seq 重挂载)。
31
+ * 旧实例晚到的成功只许收自己那一批,不许把后来发布的那批一起清掉。 */
32
+ export declare function clearDeleteBatchRequest(expected?: BatchDeleteRequest): void;
24
33
  /** 供浮条与装配面订阅。 */
25
34
  export declare function useDeleteBatchRequest(): BatchDeleteRequest | null;
26
35
  /** 测试专用:现场与 seq 归零,用例之间互不串味。 */
27
36
  export declare function resetBatchConfirm(): void;
28
- export type BatchConfirmDeps = Pick<SessionDeleteRemote, 'applyOutcomes'>;
29
37
  /** 常驻的批量确认框宿主。没有待确认的批量删除时什么都不渲染。 */
30
38
  export declare function BatchConfirmHost({ deps, t, }: {
31
- deps: BatchConfirmDeps;
39
+ deps: OneShotDeps;
32
40
  t?: Translate;
33
41
  }): ReactElement | null;
@@ -5,7 +5,7 @@
5
5
  * 模式内才渲染勾选框、才把整行点击变成"勾/取消"(守卫在 `host-rows.ts`)。
6
6
  * 菜单的开关归 owner(与 `delete-menu-item.tsx` 同一条契约):按下后先切模式、再收菜单。
7
7
  *
8
- * 文案复用回收站工具栏那两句(`trash.toolbar.select` / `selectExit`)——同一个"多选/退出多选"
8
+ * 文案复用清单那两句(`list.select.enter` / `list.select.exit`)——同一个"多选/退出多选"
9
9
  * 不造第二个键。
10
10
  */
11
11
  import type { ReactElement } from 'react';
@@ -14,6 +14,7 @@ export declare function areAllVisibleRowsSelected(rows: readonly PickItem[], pic
14
14
  * 边界:行里的按钮 / 链接 / 输入 / 菜单项一律放行(否则 ⋯ 菜单、归档、置顶、单删都点不动);
15
15
  * 双击的第二下与 dblclick 不翻转(第一下已经选中,第二下不能又反掉,也不能打开宿主的重命名)。
16
16
  * 认行靠 `data-row-key="session:…"`——**这是本文件唯一一处 DOM 读**(ADR-0034):宿主将来改掉这个
17
- * 属性,最差是模式内点行不生效,勾选框本身仍在。模式外不挂监听:这时点行必须还是宿主的"打开会话"。
17
+ * 属性,最差是模式内点行不生效,勾选框本身仍在。**先查登记再吞事件**:没登记的行(别的列表 / 本插件
18
+ * 没接管的会话行)一个默认行为都不改。模式外不挂监听:这时点行必须还是宿主的"打开会话"。
18
19
  */
19
20
  export declare function useSelectionRowClickGuard(): void;
@@ -1,10 +1,17 @@
1
+ /** 一次过闸的落地面:**没跑**与**跑了**在类型面就是两支,不靠 `undefined` 兼职。 */
2
+ export type GateRun<T> = {
3
+ readonly kind: 'blocked';
4
+ } | {
5
+ readonly kind: 'ran';
6
+ readonly value: T;
7
+ };
1
8
  export interface BusyGate {
2
9
  readonly busy: boolean;
3
10
  /** 把一次任务整个包进「这一趟还算忙」;落地与抛错都放回 false。
4
- * 同一枚闸已有任务在飞时这一次**不执行**(同步判重),立即回 `undefined`。类型里带上 `undefined`
5
- * 不是将就,是判据:挡回的那一趟什么都没跑,把它伪装成一枚 `T` 就是把「没跑」当成「跑完且结果是
6
- * 那个值」——消费返回值的调用方(写入座位、清空)会照着编出失败原文或宣布成功。怎么收尾由调用方
7
- * 定:这一趟的界面后果归在飞的那一趟,挡回来的那一份什么都不该改。 */
8
- around: <T>(task: () => Promise<T>) => Promise<T | undefined>;
11
+ * 同一枚闸已有任务在飞时这一次**不执行**(同步判重),立即回 `{ kind: 'blocked' }`。
12
+ * 挡回的那一趟什么都没跑——把它伪装成一枚 `T` 就是把「没跑」当成「跑完且结果是那个值」,
13
+ * 消费返回值的调用方(写入座位、清空)会照着编出失败原文或宣布成功。挡回来那一份的界面后果
14
+ * 归在飞的那一趟,调用方按 `kind` 分派,写不出「拿没跑当跑完」。 */
15
+ around: <T>(task: () => Promise<T>) => Promise<GateRun<T>>;
9
16
  }
10
17
  export declare function useBusyGate(): BusyGate;
@@ -2,12 +2,12 @@ import type { ReactElement } from 'react';
2
2
  import { type Translate } from './copy.js';
3
3
  import type { ConfigDeps } from './remote.js';
4
4
  export interface ConfigSettingsProps {
5
- /** 整套 remote 的切片;测试可以只给维护那四件(缺这两件时本卡不渲染)。 */
5
+ /** 整套 remote 的切片;测试可以只给维护那六件(缺这两件时本卡不渲染)。 */
6
6
  readonly deps: Partial<ConfigDeps>;
7
7
  readonly t?: Translate;
8
8
  }
9
9
  /**
10
- * 卡片入口:两个方法都在才渲染。`useMaintenance` 与 `MaintenanceSettings` 的测试替身只造维护四件,
10
+ * 卡片入口:两个方法都在才渲染。`useMaintenance` 与 `MaintenanceSettings` 的测试替身只造维护六件,
11
11
  * 所以在那些用例里本卡整体缺席——不让"没给配置 deps"变成一次假渲染。
12
12
  */
13
13
  export declare function ConfigSettings({ deps, t }: ConfigSettingsProps): ReactElement | null;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 六个确认框共用的**一个壳**:`Modal` + 标题 + 关闭钮 + 「取消(描边) / 确认(主按钮)」页脚。
3
+ *
4
+ * 共用的只有**页脚与关框规则**(在飞时取消与关闭都按住),不共用业务:每个框的
5
+ * 标题、正文、列什么、确认键文案与危险层级都由调用方交,各框自己的状态机与失败面一行业没少。
6
+ * 曾经在 `batch-confirm.tsx` 的头注里否过一次共壳——那时否的是把单删的 `busy` / 失败面拖进批量形;
7
+ * 这里共的是页脚这一层,裁决见 ADR-0052。
8
+ */
9
+ import { type ReactNode } from 'react';
10
+ export interface ConfirmDialogProps {
11
+ readonly title: string;
12
+ readonly closeLabel: string;
13
+ readonly cancelLabel: string;
14
+ readonly confirmLabel: string;
15
+ /** 在飞:取消 / 关闭与确认键一起按住。 */
16
+ readonly busy: boolean;
17
+ readonly onCancel: () => void;
18
+ readonly onConfirm: () => void;
19
+ /** 危险层级:实心红主按钮;缺省是普通 primary(与「移入回收站」同款)。 */
20
+ readonly danger?: boolean;
21
+ readonly children?: ReactNode;
22
+ }
23
+ export declare function ConfirmDialog({ title, closeLabel, cancelLabel, confirmLabel, busy, onCancel, onConfirm, danger, children, }: ConfirmDialogProps): ReactNode;
@@ -1,4 +1,8 @@
1
+ import type { ClientContextLike } from './context.js';
1
2
  import type { Translate } from './copy.js';
3
+ import { type SessionsStateLike } from './session-live.js';
4
+ /** legacy 菜单槽:只在 contextMenus 不可用时注册(0.2.2+ 的内置动作已迁到数据动作)。 */
5
+ export declare const SESSION_MENU_SLOT = "sidebar.workspaces.session.menu.item";
2
6
  interface MenuTarget {
3
7
  readonly sessionId: string;
4
8
  readonly displayTitle: string;
@@ -19,11 +23,6 @@ export interface ObservableSnapshotLike<T> {
19
23
  getSnapshot(): T;
20
24
  subscribe(listener: () => void): () => void;
21
25
  }
22
- interface SessionsStateLike {
23
- byId?: Record<string, {
24
- running?: boolean;
25
- } | undefined>;
26
- }
27
26
  export interface SessionsServiceLike {
28
27
  list?: ObservableSnapshotLike<SessionsStateLike>;
29
28
  }
@@ -44,4 +43,11 @@ export declare const ICON_DELETE = "xrn1997.session-delete.delete";
44
43
  * 所以它们与 Archive 一起排掉 legacy 组件行,恢复「归档在多选/删除之前」。
45
44
  */
46
45
  export declare function createSessionMenuContribution(t: Translate, sessionList?: ObservableSnapshotLike<SessionsStateLike>): MenuContributionLike;
46
+ /** 菜单槽注入的 `useMenuOpenState`:官方 `menuOpenStateFactory` 交回一对开合状态(asar @46195835)。 */
47
+ export type UseMenuOpenState = () => readonly [boolean, (open: boolean) => void];
48
+ /**
49
+ * 注册菜单两行:数据动作可用就走数据动作(+ 两个 icon key),否则注册 legacy 槽位行并等
50
+ * `contextMenus` 迟到。`index.tsx` 的贡献表只留一行调用。
51
+ */
52
+ export declare function installSessionMenus(client: ClientContextLike, t: Translate): void;
47
53
  export {};