@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,17 +1,14 @@
1
1
  /**
2
- * 撤销提示(docs/ui-spec.md 状态 ③):删除成功后一条可撤销的横幅。
3
- *
4
- * 现场与发布住在 `undo-notices.ts`;本文件只做组件:画通知台已有的事实,「撤销」整趟按下交给
5
- * `write-seats.ts` 的 `restoreFromUndo`(编排归恢复座位,见 ADR-0018 的边界)。
6
- * 为什么组件要独立:宿主的菜单行随菜单**一起卸载**(真产物 Menu 的注释原文
7
- * "the rows unmount with the list"),而提示要在菜单关掉之后还活着。宿主的官方配方同形——
8
- * 会话行的动作把请求写进一个模块级 store,`shell.overlay` 里的 `workspace.row-toast` 读它。
2
+ * 撤销提示(`docs/ui-spec.md` §2 ③):删除成功后一条可撤销的横幅。现场与发布住 `undo-notices.ts`,
3
+ * 本文件只做组件;「撤销」整趟交给 `write-seats.ts` 的 `restoreFromUndo`。组件必须独立于菜单行:
4
+ * 宿主的菜单行随菜单一起卸载,而提示要在菜单关掉之后还活着(宿主官方配方同形:模块级 store +
5
+ * `shell.overlay` 里的 toast 读它)。
9
6
  */
10
7
  import { type Translate } from './copy.js';
11
8
  import type { OneShotDeps } from './remote.js';
12
9
  /**
13
- * 常驻的撤销提示宿主。挂 `shell.overlay`(框架级浮层;槽位说明原文 "a toast stack or a status
14
- * pill all belong here"):没有待撤销的事时什么都不渲染。
10
+ * 常驻的撤销提示宿主,挂 `shell.overlay`。两种来源共用:**当前横幅**优先;不在时顶上一条待显示的
11
+ * 撤销失败(在飞期间横幅被覆盖/熄灭,失败原文不能跟着消失)。
15
12
  */
16
13
  export declare function UndoToast({ deps, t }: {
17
14
  deps: OneShotDeps;
@@ -0,0 +1,27 @@
1
+ import type { ArchiveSubagentWire } from '../shared/wire.js';
2
+ import type { ArchiveDetailLike, SessionDeleteRemote } from './remote.js';
3
+ import { type DetailReader } from './use-detail-reader.js';
4
+ /** 归档详情主体:清单里的已归档行,或父详情子会话段里那条孩子(后者可缺时间读数)。 */
5
+ export interface ArchiveDetailSubject {
6
+ readonly sessionId: string;
7
+ readonly projectDir: string;
8
+ readonly title: string;
9
+ readonly label?: string;
10
+ readonly updatedAt?: number;
11
+ readonly updatedAtSource?: 'prompt' | 'created';
12
+ readonly sizeBytes?: number;
13
+ }
14
+ /** 孩子视图的主体:只带详情投影消费的格,时间读数缺席不造 0。归档态不在主体上——
15
+ * 状态行只认这一读的 `ArchiveDetailWire.archived`(ADR-0061 决定 4)。 */
16
+ export declare function childSubjectOf(child: ArchiveSubagentWire): ArchiveDetailSubject;
17
+ export declare function useArchiveDetailReader(input: {
18
+ deps: Pick<SessionDeleteRemote, 'archiveDetail'>;
19
+ /** 归档档是否在眼前:不活动时控制器交 `subject: null`(没有读需求),这里只负责订失效。 */
20
+ active: boolean;
21
+ subject: ArchiveDetailSubject | null;
22
+ present: (sessionId: string) => boolean;
23
+ /** 主体是清单里的顶层行:孩子视图不保持上一条(与回收站同一条)。 */
24
+ topLevel: boolean;
25
+ /** 清单行(自己已归档)回 `undefined`;离清单的 id(含孩子视图尚未打开时的意图预取)带上清单选中行作只读根。 */
26
+ rootOf: (sessionId: string) => string | undefined;
27
+ }): DetailReader<ArchiveDetailSubject, ArchiveDetailLike>;
@@ -0,0 +1,44 @@
1
+ import type { ArchiveRowWire, ArchiveSubagentWire } from '../shared/wire.js';
2
+ import type { BusyGate } from './busy-gate.js';
3
+ import type { Translate } from './copy.js';
4
+ import type { ArchiveDetailLike, SessionDeleteRemote } from './remote.js';
5
+ import type { ArchiveDetailSubject } from './use-archive-detail-reader.js';
6
+ import { type ArchiveQuery } from './use-archive-query.js';
7
+ import { type PanelTabController } from './use-panel-tab.js';
8
+ /** 归档档离清单的孩子视图:父仍是清单选中那条已归档行,看的却是它的一个子会话。 */
9
+ export interface ArchiveChildView {
10
+ readonly parentSessionId: string;
11
+ readonly child: ArchiveSubagentWire;
12
+ }
13
+ export interface ArchivePanelController extends PanelTabController<ArchiveRowWire, ArchiveDetailSubject, ArchiveDetailLike> {
14
+ /** 当前活动行:选中行优先;没有选中时回落到光标,光标行被收走就落空(不拿旧行冒充)。 */
15
+ readonly activeId: string | null;
16
+ /** 正在看哪个孩子(离清单的详情导航态;null = 看清单选中那条)。单级是设计。 */
17
+ readonly childView: ArchiveChildView | null;
18
+ select: (row: ArchiveRowWire) => Promise<void>;
19
+ selectRow: (row: ArchiveRowWire, options?: {
20
+ drill?: boolean;
21
+ }) => Promise<void>;
22
+ prefetch: (sessionId: string) => void;
23
+ /** 单条/批量解除归档:`/apply` 的 `unarchive`,无确认框(幂等)、无撤销座位。 */
24
+ unarchive: (ids: readonly string[]) => Promise<void>;
25
+ /** 单删:`requestDelete({ sessionId, title: 显示名 })` → `DeleteConfirmHost`。 */
26
+ requestDeleteOne: (row: ArchiveRowWire) => void;
27
+ requestDeleteMany: (items: readonly {
28
+ sessionId: string;
29
+ title: string;
30
+ }[]) => void;
31
+ }
32
+ export declare function useArchivePanelController(input: {
33
+ /** `progress` 不在这里读:slice 按「自己读或向下转发的」收——座位吃 `OneShotDeps`(含认领轮询那一格)。 */
34
+ deps: Pick<SessionDeleteRemote, 'archiveDetail' | 'applyOutcomes' | 'progress'>;
35
+ gate: BusyGate;
36
+ query: ArchiveQuery;
37
+ ordered: readonly ArchiveRowWire[];
38
+ /** 归档档是否在眼前:不活动时详情主体落空(没有读需求,生命周期只订失效不读)。 */
39
+ active: boolean;
40
+ /** 分栏态:`selectRow` 的「drill 或分栏才真正选中」要它。归档档没有独立 `drilled` 位(选中即窄档
41
+ * 下钻),所以布局事实必须进控制器——两台孪生控制器的 `select` 契约因此不同。 */
42
+ split: boolean;
43
+ t: Translate;
44
+ }): ArchivePanelController;
@@ -0,0 +1,31 @@
1
+ import type { ArchiveRowWire } from '../shared/wire.js';
2
+ import type { SessionDeleteRemote } from './remote.js';
3
+ export type ArchiveListState = {
4
+ readonly status: 'loading';
5
+ } | {
6
+ readonly status: 'ready';
7
+ readonly rows: readonly ArchiveRowWire[];
8
+ readonly totalBytes: number;
9
+ readonly missingSizeCount: number;
10
+ } | {
11
+ readonly status: 'failure';
12
+ readonly message: string;
13
+ } | {
14
+ readonly status: 'corpus-missing';
15
+ };
16
+ /** 归档清单状态对视图行的唯一解读:只有 `ready` 交出行;缺席与失败都不折成空清单。 */
17
+ export declare function archiveRowsOf(list: ArchiveListState): readonly ArchiveRowWire[] | null;
18
+ export interface ArchiveQuery {
19
+ readonly list: ArchiveListState;
20
+ /** 清单已有行、重读还在飞;只给 `aria-busy` 用,**不是第五态**。 */
21
+ readonly refreshing: boolean;
22
+ /** M 的惰性读数:首次成功读取前是 `null`(不摆假 0),之后随每次成功读数更新。 */
23
+ readonly count: number | null;
24
+ /** 唯一重读入口:挂载/切档、两台修订、自救动作、显式重试全走这一条。 */
25
+ reload: () => Promise<void>;
26
+ }
27
+ export declare function useArchiveQuery({ deps, active, }: {
28
+ deps: Pick<SessionDeleteRemote, 'archiveList'>;
29
+ /** 归档档活动(面板挂载且档位在归档):不活动只置脏不读。 */
30
+ active: boolean;
31
+ }): ArchiveQuery;
@@ -1,15 +1,8 @@
1
1
  /**
2
- * 清单列与详情列之间那根可拖的宽度把手(docs/ui-spec.md 的「面板与清单」)。
3
- *
4
- * 三件事住在这里:
5
- * ① 宽度夹在两个界之间:下限由调用方给,上限 = 面板宽 − reserve。
6
- * reserve 的数值与来历住在调用方(DETAIL_RESERVE),这一层不复制算式。
7
- * ② 夹在“读”的时候也做一次:窗口变窄不触发写入,listWidth 每次渲染按当前 panelWidth 重算。
8
- * ③ 按下才算在拖:指针捕获挂在把手元素上;拖动途中把手可能卸载,所以 window 上另兜一层
9
- * pointerup/pointercancel 复用 stop;move 仍只认把手。
10
- *
11
- * 键盘:role=separator、←→ 各一格、Home 回默认、End 到上限;焦点态可见性由 ui.css 的
12
- * .sd-width-handle:focus-visible::after 负责。
2
+ * 清单列与详情列之间那根可拖的宽度把手。
3
+ * ① 宽度夹在 [min, panelWidth − reserve],reserve 的算式住调用方;② 夹在读的时候也做一次(窗口变窄
4
+ * 不触发写入);③ 按下才算在拖:指针捕获挂把手,window 上另兜 pointerup/pointercancel——拖动途中把手
5
+ * 可能卸载,它自己的 pointerup 永远不来。
13
6
  */
14
7
  import { type KeyboardEvent, type PointerEvent } from 'react';
15
8
  export interface ColumnResizeArgs {
@@ -0,0 +1,50 @@
1
+ /**
2
+ * 详情这一帧的接线 module:把「一台详情读路 + 分页读面 + 提问轨」收成一个对象。面板一档调一次,
3
+ * 交出 `state` / `pager` / `rail`;两档投影只做行投影,帧原样转交。判据都没搬:轨的三条仍在
4
+ * `use-detail-rail.ts`,分页两笔账仍在 `use-detail-pager.ts`——这里只拥有「谁接给谁」,两档读路
5
+ * 来源只是结构相同,不是同一个状态机。
6
+ */
7
+ import { type RefObject } from 'react';
8
+ import type { DetailBody, DetailState } from './use-detail-reader.js';
9
+ import { type DetailPagerHandle } from './use-detail-pager.js';
10
+ import { type DetailRail, type RailDetailLike } from './use-detail-rail.js';
11
+ /** 分页这一块(在飞/失败 + 滚动容器):四样东西是分页读面的四个格子,打包走一个名字。 */
12
+ export interface DetailPager {
13
+ /** 更早一页正在读。 */
14
+ loadingOlder: boolean;
15
+ /** 更早一页读失败的原文;正文本身仍是 ready。 */
16
+ olderFailure: string | null;
17
+ onLoadOlder: () => void;
18
+ /** 详情栏的滚动容器;prepend 更早一页后按高度差补偿滚动位置。 */
19
+ scrollRef?: RefObject<HTMLDivElement | null>;
20
+ }
21
+ /** 帧的读路来源:两档面板控制器各交一台实例的同名五格(与 `DetailReader` 同名同义,帧不重新定义)。 */
22
+ export interface DetailFrameSource<S, D extends RailDetailLike> {
23
+ readonly detail: DetailState<S, D>;
24
+ /** 「保持期拒绝导航/跳转」判据(`use-detail-reader` 的唯一出口):原样交给轨与投影。 */
25
+ readonly canNavigate: boolean;
26
+ readonly loadingOlder: boolean;
27
+ readonly olderFailure: string | null;
28
+ readonly loadOlder: () => Promise<void>;
29
+ }
30
+ /** 帧的宿主事实:详情栏这一刻在不在 DOM 里、滚动容器是谁——只有面板知道(ADR-0057 的挂载判据)。 */
31
+ export interface DetailFrameHost {
32
+ /** 详情栏的滚动容器:分页补偿与提问轨落位共用这一个 ref。 */
33
+ readonly scrollRef: RefObject<HTMLDivElement | null>;
34
+ readonly paneMounted: boolean;
35
+ }
36
+ /** 详情这一帧:壳的两格(`state` / `pager`)与栏外壳的搭档(`rail`);同一件事只有一份名字。 */
37
+ export interface DetailFrame<S, D extends RailDetailLike> {
38
+ readonly state: DetailState<S, D>;
39
+ readonly pager: DetailPager;
40
+ readonly rail: DetailRail;
41
+ }
42
+ export declare function useDetailFrame<S, D extends RailDetailLike>(source: DetailFrameSource<S, D>, host: DetailFrameHost): DetailFrame<S, D>;
43
+ /** 壳要的那两格(`rail` 归栏外壳;`canNavigate` 归控制器与轨,不进帧)。投影口只读 `state`。 */
44
+ export type DetailFrameView<S, D extends RailDetailLike> = Pick<DetailFrame<S, D>, 'state' | 'pager'>;
45
+ /**
46
+ * 正文块的翻页入口:`useDetailPager` 的接线只住这里——帧给分页读面,壳只交正文与档位。
47
+ */
48
+ export declare function useDetailFramePager(frame: {
49
+ readonly pager: DetailPager;
50
+ }, detail: DetailBody, compact: boolean): DetailPagerHandle;
@@ -1,21 +1,13 @@
1
1
  /**
2
2
  * 详情分页的读侧编排:手动补页、简洁档自动连翻、prepend 后的滚动锚点。
3
- * 组件只画;分页的两笔账(连翻预算与滚动位置)都住这里。
4
- *
5
- * 取数只由**显式动作**发起:工具栏那颗「加载更早」、切进简洁档时的联动、提问轨上点某一格。
6
- * 滚动只管阅读,不挂 scroll 监听——「滚到顶就补一页」会让新页一页页顶在读者头上,顶端持续
7
- * 后退,想往回拖滚动条找位置反而越拉越远(ADR-0057)。
3
+ * 取数只由**显式动作**发起(工具栏按钮、切进简洁档、提问轨点格);滚动只管阅读,不挂 scroll 监听——
4
+ * 「滚到顶就补一页」会让新页一页页顶在读者头上(ADR-0057)。
8
5
  */
9
6
  import { type RefObject } from 'react';
10
7
  import type { TrashDetailBlockWire } from '../shared/wire.js';
11
- /**
12
- * 简洁档里一次补页最多自动连翻多少页(补回来的一整页可能全是被藏起来的过程块)。
13
- *
14
- * 服务端按**块**翻页;简洁档把过程块整段藏起来,一页可能全是过程块 ⇒ 点一下什么都不出现,
15
- * 看着像没反应。所以简洁档下自动继续往前翻,直到这一批里出现对话块、翻完、或到上限。
16
- * 切进简洁档时当前页若全是过程块,也按同一份预算自动连翻——否则用户看到的仍是一页空白。
17
- * 上限防的是"一条几乎全是工具调用的巨型会话"把一次点击变成几十个串行请求。
18
- */
8
+ /** 简洁档一次补页最多自动连翻多少页:服务端按块翻页,一页可能全是藏起来的过程块 ⇒ 点一下什么都不
9
+ * 出现。自动往前翻直到出现对话块、翻完或到上限——上限防"几乎全是工具调用的巨型会话"把一次点击
10
+ * 变成几十个串行请求。 */
19
11
  export declare const AUTO_OLDER_PAGE_LIMIT = 10;
20
12
  interface DetailPagerOptions {
21
13
  blocks: readonly TrashDetailBlockWire[];
@@ -0,0 +1,39 @@
1
+ /**
2
+ * 详情栏的提问轨接线(两档共用):从一台详情读路算出轨要画的三份读数加上 `usePromptRail` 那一面。
3
+ * 三条判据:**没有正文就没有轨**(读数中/失败那一帧不画指向不存在正文的刻度);**保持期顶住**
4
+ * (跳转会把别人的游标补进这一页,禁用判据问 `canNavigate`,ADR-0049);**挂载判据要显式传**
5
+ * (窄档下钻后 ref 才补上,只靠 ref 会漏挂滚动监听,ADR-0057)。
6
+ */
7
+ import { type RefObject } from 'react';
8
+ import type { TrashDetailBlockWire, TrashDetailPromptWire } from '../shared/wire.js';
9
+ import type { DetailState } from './use-detail-reader.js';
10
+ import { type PromptRailHandle } from './use-prompt-rail.js';
11
+ /** 轨要的三格:`SessionDetailWire` 与它的两档投影都够(两半的详情线上都带这三样)。 */
12
+ export interface RailDetailLike {
13
+ readonly prompts?: readonly TrashDetailPromptWire[];
14
+ readonly blocks?: readonly TrashDetailBlockWire[];
15
+ readonly olderCursor?: number | null;
16
+ }
17
+ export interface DetailRailInput<S, D extends RailDetailLike> {
18
+ /** 这一档的详情读路状态(回收站档与归档档各一台实例)。 */
19
+ readonly state: DetailState<S, D>;
20
+ /** 「保持期拒绝导航/跳转」判据(`use-detail-reader` 的唯一出口):`disabled` 直接取反,不在这里重推保持。 */
21
+ readonly canNavigate: boolean;
22
+ readonly loadingOlder: boolean;
23
+ readonly olderFailure: string | null;
24
+ loadOlder: () => Promise<void>;
25
+ readonly scrollRef: RefObject<HTMLDivElement | null>;
26
+ /** 详情栏这一刻在不在 DOM 里。 */
27
+ readonly paneMounted: boolean;
28
+ }
29
+ export interface DetailRail {
30
+ /** 整条会话的提问索引;没有正文时是空表 ⇒ `hasRail` false。 */
31
+ readonly prompts: readonly TrashDetailPromptWire[];
32
+ /** 已加载块的 id:轨上未加载的刻度更短更淡,预览卡里也明说「会先补页」。 */
33
+ readonly loadedIds: ReadonlySet<string>;
34
+ readonly hasRail: boolean;
35
+ /** 保持期:轨仍画上一条的刻度,但整条顶住——跳转会把别人的游标补进这一页(ADR-0049)。 */
36
+ readonly disabled: boolean;
37
+ readonly handle: PromptRailHandle;
38
+ }
39
+ export declare function useDetailRail<S, D extends RailDetailLike>({ state, canNavigate, loadingOlder, olderFailure, loadOlder, scrollRef, paneMounted, }: DetailRailInput<S, D>): DetailRail;
@@ -0,0 +1,60 @@
1
+ import type { TrashDetailBlockWire } from '../shared/wire.js';
2
+ import type { DetailLedger } from './detail-ledger.js';
3
+ import type { RemoteOutcome } from './remote.js';
4
+ /** 详情值的最小面:分页合并只认这两格。 */
5
+ export interface DetailBody {
6
+ readonly blocks: readonly TrashDetailBlockWire[];
7
+ readonly olderCursor: number | null;
8
+ }
9
+ /** 一台详情读路的状态(主体键名 `subject`:回收站实例对外映射成 `entry`,键名语义归各自视图)。 */
10
+ export type DetailState<S, D> = {
11
+ kind: 'idle';
12
+ } | {
13
+ kind: 'loading';
14
+ subject: S;
15
+ } | {
16
+ kind: 'failed';
17
+ subject: S;
18
+ message: string;
19
+ } | {
20
+ kind: 'holding';
21
+ subject: S;
22
+ detail: D;
23
+ } | {
24
+ kind: 'ready';
25
+ subject: S;
26
+ detail: D;
27
+ };
28
+ export interface DetailReaderInput<S, D extends DetailBody> {
29
+ readonly fetch: (id: string, before?: number) => Promise<RemoteOutcome<D>>;
30
+ readonly ledger: DetailLedger<D>;
31
+ readonly subject: S | null;
32
+ /** 主体的身份(回收站 = 条目 id;归档 = 会话 id)。 */
33
+ readonly idOf: (subject: S) => string;
34
+ /** 主体是清单里的顶层行:孩子视图不保持上一条(它的返回键语义在孩子视图上,会串)。 */
35
+ readonly topLevel: boolean;
36
+ /** 上一条已就绪的详情是否仍在清单里:被清单换版收走就不再顶住画面。 */
37
+ readonly present: (id: string) => boolean;
38
+ /** 主体换成「还没读过」的那一条时要不要自动补读(兜底那一支)。窄档方向键只移选中、详情栏不在眼前:
39
+ * 那里给 false,别为每次按键打一条 `/detail`;显式 `ensure` 一律照常读。 */
40
+ readonly autoRead?: boolean;
41
+ }
42
+ export interface DetailReader<S, D extends DetailBody> {
43
+ readonly detail: DetailState<S, D>;
44
+ /** 「保持期拒绝导航/跳转」的唯一出口:holding ⇒ false,其余 true。两个控制器的守卫与
45
+ * `use-detail-rail` 的 `disabled` 都只问它,不再各自重推保持。 */
46
+ readonly canNavigate: boolean;
47
+ readonly loadingOlder: boolean;
48
+ readonly olderFailure: string | null;
49
+ readonly ensure: (id: string) => Promise<void>;
50
+ readonly prefetch: (id: string) => void;
51
+ readonly loadOlder: () => Promise<void>;
52
+ readonly retry: () => void;
53
+ /** 只收分页的旧失败(切主体 / 回父时);在飞登记不动。 */
54
+ readonly clearOlderFailure: () => void;
55
+ readonly reset: (id: string) => void;
56
+ readonly forget: (id: string) => void;
57
+ /** 整本作废:丢缓存、在飞、保持与失败,回到首次读数(归档集变更时用)。 */
58
+ readonly clearAll: () => void;
59
+ }
60
+ export declare function useDetailReader<S, D extends DetailBody>(input: DetailReaderInput<S, D>): DetailReader<S, D>;
@@ -0,0 +1,27 @@
1
+ /** 详情类消费者的合并窗默认值:够把一批写后通告收成一趟读,又短到用户察觉不到。 */
2
+ export declare const DEFAULT_REFRESH_COALESCE_MS = 120;
3
+ export interface GatedRefreshPolicy {
4
+ /** 挂载时先置脏(清单类:挂载就读);默认 false(详情类:subject 出现才读)。 */
5
+ readonly initialDirty?: boolean;
6
+ /** 每次 active false→true 都强制 refresh(归档清单的既有语义);默认 false。 */
7
+ readonly refreshOnActivate?: boolean;
8
+ /** 合并窗(毫秒):同一窗口内多次失效合并为一次读;0 = 仅微任务合并。默认 0。 */
9
+ readonly coalesceMs?: number;
10
+ }
11
+ export declare function useGatedRefresh(input: {
12
+ /** 面板/档位是否活动:不活动只置脏不读。 */
13
+ readonly active: boolean;
14
+ /** 读需求(reader 传 `subject !== null`);默认 true。 */
15
+ readonly demand?: boolean;
16
+ /** 订阅的修订号集合:任一变化即一次失效。 */
17
+ readonly revisions: readonly number[];
18
+ /**
19
+ * 便宜、同步、每次修订都跑的现场作废——唯一不过两道门的回调,所以「档位关着也要立刻丢」的现场只能
20
+ * 落这里。整本账本作废不属于这一类(当场丢会让兜底首读绕过合并窗与单飞,归档 reader 放进自己的
21
+ * refresh,ADR-0063 决定第 5 条)。
22
+ */
23
+ readonly onInvalidate?: () => void;
24
+ /** 实际的读;latest-wins 与失败面由它自持。 */
25
+ readonly refresh: () => Promise<void>;
26
+ readonly policy?: GatedRefreshPolicy;
27
+ }): void;
@@ -1,35 +1,36 @@
1
- import type { TrashEntryLike } from './remote.js';
2
1
  import type { ProjectGroup } from './trash-view.js';
3
- export interface TrashSelection {
2
+ export interface ListSelection<R> {
4
3
  /** 多选模式:入口在工具排(「多选」/「退出多选」),模式内点行说的是"勾/取消"。 */
5
4
  readonly selectMode: boolean;
6
5
  readonly checked: ReadonlySet<string>;
6
+ /** 勾中的**行本身**,按清单从上往下排(页脚要标题时用这一份,别再从 groups 重算一遍)。 */
7
+ readonly checkedRows: readonly R[];
7
8
  /** 按**清单从上往下**排好的勾选 id(页脚两颗与批量执行都读这一份)。 */
8
9
  readonly checkedIds: readonly string[];
9
10
  /** 键盘 ↑↓ 与下钻走这个顺序:**只含展开的组**(折叠的行不在 DOM 里,方向键别停过去)。 */
10
- readonly ordered: readonly TrashEntryLike[];
11
+ readonly ordered: readonly R[];
11
12
  readonly allCollapsed: boolean;
12
- /** 方法一律写成**属性声明**:面板会把它们摘下来传给导航/行组件,实现体也都不读 `this`。
13
- * 方法简写带来的隐式 `this: TrashSelection` 会让 `unbound-method` 误报,且会诱导调用点
14
- * 为了消警报去包箭头函数——那会让 `TrashSelection` 每次渲染换新身份(见 ADR 外的回归教训)。 */
13
+ /** 方法一律写成**属性声明**:面板会把它们摘下来传给导航/行组件,实现体也都不读 `this`——方法简写会被
14
+ * `unbound-method` 误报。 */
15
15
  isCollapsed: (projectDir: string) => boolean;
16
16
  enterSelect: () => void;
17
17
  exitSelect: () => void;
18
18
  toggleGroup: (projectDir: string) => void;
19
19
  toggleAllGroups: () => void;
20
- toggleCheck: (entryId: string) => void;
21
- /** 组头那颗:说的是"这个项目的全部会话",折叠起来的条目也算。勾满再点 = 整组取消。 */
20
+ toggleCheck: (id: string) => void;
21
+ /** 组头那颗:说的是"这个项目的全部会话",折叠起来的行也算。勾满再点 = 整组取消。 */
22
22
  toggleGroupCheck: (group: {
23
- entries: readonly TrashEntryLike[];
23
+ rows: readonly R[];
24
24
  }) => void;
25
25
  groupFullyChecked: (group: {
26
- entries: readonly TrashEntryLike[];
26
+ rows: readonly R[];
27
27
  }) => boolean;
28
28
  groupPartiallyChecked: (group: {
29
- entries: readonly TrashEntryLike[];
29
+ rows: readonly R[];
30
30
  }) => boolean;
31
31
  }
32
- export declare function useTrashSelection({ entries, groups, }: {
33
- entries: readonly TrashEntryLike[] | null;
34
- groups: readonly ProjectGroup[];
35
- }): TrashSelection;
32
+ export declare function useListSelection<R>({ rows, groups, idOf, }: {
33
+ rows: readonly R[] | null;
34
+ groups: readonly ProjectGroup<R>[];
35
+ idOf: (row: R) => string;
36
+ }): ListSelection<R>;
@@ -1,8 +1,7 @@
1
1
  import type { RemoteOutcome } from './remote.js';
2
2
  /** 一段在飞的动作:检查只读,清理会写。状态行靠它分开说「检查中…」与「清理中…」;`null` = 空闲。 */
3
3
  export type MaintenancePhase = 'scanning' | 'cleaning';
4
- /** 检查的落地面:失败句由各段自己拼(`text`)——机器只负责在赢票之后把它摆上屏。
5
- * 这样「检查失败怎么说」归 glue,而「什么时候说」仍归机器。 */
4
+ /** 检查的落地面:失败句由各段自己拼(`text`),机器只负责在赢票之后把它摆上屏。 */
6
5
  export type MaintenanceScanOutcome<R> = {
7
6
  readonly ok: true;
8
7
  readonly value: R;
@@ -10,8 +9,7 @@ export type MaintenanceScanOutcome<R> = {
10
9
  readonly ok: false;
11
10
  readonly text: string;
12
11
  };
13
- /** 一段维护交给界面的全部:四份读数(报告 / 失败 / 中性提示 / 第二回执)、
14
- * 一个确认框、一档忙碌,加四个动作。 */
12
+ /** 一段维护交给界面的全部:四份读数、一个确认框、一档忙碌,加四个动作。 */
15
13
  export interface MaintenanceSectionView<R> {
16
14
  /** `null` = 还没检查(或上一次检查失败——失败在 `failure` 单独一格,不折成零条)。 */
17
15
  readonly report: R | null;
@@ -49,15 +47,12 @@ export interface MaintenanceAfterClean<R> {
49
47
  export interface MaintenanceSectionConfig<R, C> {
50
48
  /** 手动检查(也是失败块的重试)。交回的已是落地面——通道直接给 `RemoteOutcome`,不会抛。 */
51
49
  scan(): Promise<MaintenanceScanOutcome<R>>;
52
- /** 清理写动作;入参是点击那一刻的报告(清理输入由各段自己从里面点名)。报告没活可干时
53
- * 同步回 `null`:不发请求、只收确认框——"没活"的判据各段不同,是各段的业务。
54
- * 同样交回落地面、不抛。`C` 是这一段的回执形状:状态机不认识它,只把它原样递给
55
- * `afterClean`,段那边就不必把 `outcome.value` 擦回 `unknown` 再 `as` 一次。 */
50
+ /** 清理写动作;入参是点击那一刻的报告(清理输入由各段自己点名)。报告没活可干时同步回 `null`:
51
+ * 不发请求、只收确认框——"没活"的判据各段不同。交回落地面、不抛;`C` 是这一段的回执形状。 */
56
52
  clean(report: R): Promise<RemoteOutcome<C>> | null;
57
- /** 清理落地后的**一次**判读:`preset` 交给必发重查前的读数位,`plan` 等重查赢了再摆。
58
- * `report` 是**这一趟**点击那一刻的报告:回执要按请求名单逐条判读,名单只能随这一趟交下来;
59
- * 段自己存一份"最近一次清理的名单"会在两趟交错时把上一趟的回执按后一趟的名单判读。
60
- * 本回调必须无副作用(只算、不 set):输赢未定时它已经被调用,副作用会落到输家身上。 */
53
+ /** 清理落地后的**一次**判读:`preset` 交给必发重查前的读数位,`plan` 等重查赢了再摆。`report` 是这一趟
54
+ * 点击那一刻的报告——回执要按请求名单逐条判读,段自己存名单会在两趟交错时判错。本回调必须无副作用
55
+ * (只算、不 set):输赢未定时它已经被调用,副作用会落到输家身上。 */
61
56
  afterClean(outcome: RemoteOutcome<C>, report: R): MaintenanceAfterClean<R>;
62
57
  }
63
58
  export declare function useMaintenanceSection<R, C>(config: MaintenanceSectionConfig<R, C>): MaintenanceSectionView<R>;
@@ -1,24 +1,22 @@
1
1
  /**
2
- * 插件设置页「维护」卡的手动编排:孤儿会话 + 孤儿附件两段。
3
- *
4
- * 状态机本身(报告 / 失败 / 中性提示 / 确认框 / 在飞档位 / 最新票 / 清完必重查)收在
5
- * `src/client/use-maintenance-section.ts` 的泛型段 module 里,两段各实例化一次;这一层只剩薄 glue:
6
- * 各段自己的远程调用、"没活可干"的判据与回执拼句。三条承重规矩(没有自动扫描 / 挂载只交初始态 /
7
- * 没有定时器)由段 module 保证,这一层同样不挂 effect。
8
- *
9
- * 写动作走既有的两段:孤儿会话是 `/apply` 的 `orphan-clean`(回执判读复用 `receipt.ts` 的读法),
10
- * 孤儿附件是聚合的 `POST /attachment-clean`(回执就是 `AttachmentCleanupWire` 本身)。
11
- * 面板的 `useTrashQuery` 与本 hook 互不引用:维护卡是手动面,面板是挂载即读的清单面。
2
+ * 插件设置页「维护」卡的手动编排:孤儿会话 + 孤儿附件 + 投影缓存三段。状态机收在
3
+ * `use-maintenance-section.ts` 的泛型段 module 里,三段各实例化一次;这一层只剩薄 glue:各段自己的
4
+ * 远程调用、"没活可干"的判据与回执拼句,同样不挂 effect。写动作走 `/apply` 的 `orphan-clean` 与
5
+ * 两个聚合清理段;面板的 `useTrashQuery` 与本 hook 互不引用。
12
6
  */
13
7
  import type { Translate } from './copy.js';
14
- import { type AttachmentOrphanReportWire, type OrphanReportWire, type SessionDeleteRemote } from './remote.js';
8
+ import type { AttachmentOrphanReportWire, OrphanReportWire } from '../shared/wire.js';
9
+ import { type SessionDeleteRemote } from './remote.js';
10
+ import type { ProjectionCacheOrphanReportWire } from '../shared/wire.js';
15
11
  import { type MaintenanceSectionView } from './use-maintenance-section.js';
16
- /** 维护卡只需要这四段:两份报告 + 孤儿会话的批量写 + 孤儿附件的聚合写。 */
17
- export type MaintenanceDeps = Pick<SessionDeleteRemote, 'scanOrphans' | 'applyOutcomes' | 'scanAttachmentOrphans' | 'cleanAttachmentOrphans'>;
12
+ /** 维护卡只需要这七段:三份报告 + 孤儿会话的批量写 + 孤儿附件/投影缓存的聚合写,加进度认领那一读
13
+ * (确认框里的进度行轮询 `/progress`,不在 /progress 覆盖面的两段只拿它当兜底文案不管)。 */
14
+ export type MaintenanceDeps = Pick<SessionDeleteRemote, 'scanOrphans' | 'applyOutcomes' | 'scanAttachmentOrphans' | 'cleanAttachmentOrphans' | 'scanProjectionCacheOrphans' | 'cleanProjectionCacheOrphans' | 'progress'>;
18
15
  export interface Maintenance {
19
16
  /** 孤儿会话段:清理顺带清掉的附件读数在这台状态机的 `secondaryNotice` 上(第二回执)。 */
20
17
  readonly orphans: MaintenanceSectionView<OrphanReportWire>;
21
18
  readonly attachments: MaintenanceSectionView<AttachmentOrphanReportWire>;
19
+ readonly projection: MaintenanceSectionView<ProjectionCacheOrphanReportWire>;
22
20
  }
23
21
  export declare function useMaintenance({ deps, t }: {
24
22
  deps: MaintenanceDeps;
@@ -0,0 +1,20 @@
1
+ import type { DetailNav } from './session-detail.js';
2
+ export interface PanelChildViewInput<C, R> {
3
+ readonly childView: C | null;
4
+ readonly setChildView: (next: C | null) => void;
5
+ readonly selected: R | null;
6
+ readonly parentTitle: (row: R) => string;
7
+ readonly openChild: (childId: string) => void | Promise<void>;
8
+ readonly prefetchChild: (childId: string) => void;
9
+ /** 收孩子视图时要作的废:回收站丢分页失败,归档丢孩子账本。 */
10
+ readonly onClose?: (child: C) => void;
11
+ /** 窄档退下钻(回收站清 drilled;归档交选中面 drop)。 */
12
+ readonly backWithoutChild: () => void;
13
+ }
14
+ export interface PanelChildView {
15
+ /** 收孩子视图并跑本档收尾(分页/账本作废)。属性声明:调用点会把它摘下来转交。 */
16
+ readonly closeChild: () => void;
17
+ readonly back: () => void;
18
+ readonly detailNav: DetailNav;
19
+ }
20
+ export declare function usePanelChildView<C, R>(input: PanelChildViewInput<C, R>): PanelChildView;
@@ -0,0 +1,51 @@
1
+ /** 一次读的归一路面:adapter 把各自信封折成三支;本 hook 只认这三支。 */
2
+ export type PanelReadOutcome<R, M> = {
3
+ readonly kind: 'rows';
4
+ readonly rows: readonly R[];
5
+ readonly meta: M;
6
+ }
7
+ /** 显式缺席(归档档的 `{available:false}` / 语料不可见)。它不是空清单、也不是失败。 */
8
+ | {
9
+ readonly kind: 'absent';
10
+ } | {
11
+ readonly kind: 'failure';
12
+ readonly message: string;
13
+ };
14
+ /** 读数的三态 + 缺席态:两档的渲染侧各自从这一份派生自己的旧形状(见两个 query 包装)。 */
15
+ export type PanelListState<R, M> = {
16
+ readonly status: 'loading';
17
+ } | {
18
+ readonly status: 'ready';
19
+ readonly rows: readonly R[];
20
+ readonly meta: M;
21
+ } | {
22
+ readonly status: 'absent';
23
+ } | {
24
+ readonly status: 'failure';
25
+ readonly message: string;
26
+ };
27
+ export interface PanelListReadSpec<R, M> {
28
+ /** 首帧初值(回收站首帧快照):挂载只调一次;null = 从 loading 起画。 */
29
+ readonly initial?: () => {
30
+ readonly rows: readonly R[];
31
+ readonly meta: M;
32
+ } | null;
33
+ /** 发一趟读并折成三支。`read` 经 `useLatest` 读取,逐渲染换新引用不会让回调换身份。 */
34
+ readonly read: () => Promise<PanelReadOutcome<R, M>>;
35
+ /** 成功落点(回收站写回首帧快照;归档无)。 */
36
+ readonly onSuccess?: (rows: readonly R[], meta: M) => void;
37
+ /** 失败落点(回收站整份丢快照;归档无)。 */
38
+ readonly onFailure?: (message: string) => void;
39
+ /** 同一拍多次 `reload` 共享一个微任务(归档档);缺省 false = 每次调用各自发一趟。 */
40
+ readonly coalesceMicrotask?: boolean;
41
+ }
42
+ export interface PanelListRead<R, M> {
43
+ readonly state: PanelListState<R, M>;
44
+ /** 读数已有行、重读还在飞;只给 `aria-busy`,不是第五态。 */
45
+ readonly refreshing: boolean;
46
+ /** 唯一重读入口:挂载、显式重试、写后、失效通告都走这一条;属性声明是因为会被摘下来交给 `useGatedRefresh`。 */
47
+ readonly reload: () => Promise<void>;
48
+ /** 聚合写失败等「读数之外」的失败落面:作废在飞读、跑 `onFailure`、把清单打成 failure。 */
49
+ readonly fail: (message: string) => void;
50
+ }
51
+ export declare function usePanelListRead<R, M>(spec: PanelListReadSpec<R, M>): PanelListRead<R, M>;
@@ -0,0 +1,36 @@
1
+ export interface PanelSelection<R> {
2
+ readonly selectedId: string | null;
3
+ /** 选中那一行本身(从**全量行**里找,不从 `ordered` 找:折叠组只收掉清单那一列)。 */
4
+ readonly selected: R | null;
5
+ /** 动作失败原文按行存(键 = 行身份):切走再回来还在,别行的成败不串台。 */
6
+ readonly actionFailure: Readonly<Record<string, string>>;
7
+ /** 把选中落到这一行并把读路交回 `onPick`;`options.read` 决定要不要真读详情(窄档方向键交 false)。 */
8
+ pick: (row: R, options?: {
9
+ read?: boolean;
10
+ }) => Promise<void>;
11
+ /** 收起选中(窄档返回:详情槽交还给清单)。 */
12
+ drop: () => void;
13
+ /** 一次动作进入时清掉这些行的旧失败。 */
14
+ clearRowFailures: (ids: readonly string[]) => void;
15
+ /** 把这一趟的逐条失败铺回各行。 */
16
+ setRowFailures: (failures: ReadonlyMap<string, string>) => void;
17
+ }
18
+ export interface PanelSelectionInput<R> {
19
+ /** 当前清单的行;`null` = 这一拍不知道,不算「行没了」。 */
20
+ rows: readonly R[] | null;
21
+ /** 行身份(回收站 = 条目 id,归档 = 会话 id)。允许调用方内联传箭头。 */
22
+ idOf: (row: R) => string;
23
+ /** 屏幕上的可见顺序(只含展开的组):自动选中第一条走这一份。 */
24
+ ordered: readonly R[];
25
+ /** 这一档要不要自动选中:面板按布局给,这里不认断点。 */
26
+ canAutoSelect: boolean;
27
+ /** 挂载续位的选中 id(首帧快照);没有就留空。 */
28
+ initialId?: string | null;
29
+ /** 选中落定后要跑的读路。`options.read = false` = 只移选中、不读详情(窄档方向键)。 */
30
+ onPick: (row: R, options: {
31
+ read: boolean;
32
+ }) => void | Promise<void>;
33
+ /** 那一行被清单收走时调用方自己的清场(丢账本、作废在飞读数、收附属导航态)。 */
34
+ onGone?: (id: string) => void;
35
+ }
36
+ export declare function usePanelSelection<R>({ rows, idOf, ordered, canAutoSelect, initialId, onPick, onGone, }: PanelSelectionInput<R>): PanelSelection<R>;