@xrn1997/dsh-session-delete 0.11.0 → 0.12.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 (51) hide show
  1. package/README.md +17 -17
  2. package/THIRD_PARTY_NOTICES.md +2 -2
  3. package/docs/screenshots/screenshot-01.png +0 -0
  4. package/docs/screenshots/screenshot-02.png +0 -0
  5. package/lib/client.js +1599 -1749
  6. package/lib/index.js +126 -69
  7. package/lib/types/api/archive-rows.d.ts +1 -1
  8. package/lib/types/api/route-table.d.ts +2 -1
  9. package/lib/types/client/archive-pane.d.ts +5 -5
  10. package/lib/types/client/archive-store.d.ts +2 -0
  11. package/lib/types/client/batch-bar.d.ts +1 -1
  12. package/lib/types/client/batch-select.d.ts +2 -2
  13. package/lib/types/client/batch-selection-store.d.ts +7 -8
  14. package/lib/types/client/confirm-dialog.d.ts +2 -2
  15. package/lib/types/client/context.d.ts +11 -3
  16. package/lib/types/client/copy.d.ts +19 -23
  17. package/lib/types/client/delete-action.d.ts +23 -0
  18. package/lib/types/client/delete-menu-item.d.ts +3 -3
  19. package/lib/types/client/drop-machine.d.ts +1 -1
  20. package/lib/types/client/markdown.d.ts +1 -1
  21. package/lib/types/client/receipt.d.ts +1 -1
  22. package/lib/types/client/scene.d.ts +5 -7
  23. package/lib/types/client/subagent-section.d.ts +2 -2
  24. package/lib/types/client/trash-drop.d.ts +3 -3
  25. package/lib/types/client/trash-entry.d.ts +1 -1
  26. package/lib/types/client/trash-store.d.ts +2 -0
  27. package/lib/types/client/trash-view.d.ts +2 -2
  28. package/lib/types/client/ui/Modal.d.ts +1 -1
  29. package/lib/types/client/undo-notices.d.ts +19 -8
  30. package/lib/types/client/undo-toast.d.ts +0 -6
  31. package/lib/types/client/use-archive-panel-controller.d.ts +3 -6
  32. package/lib/types/client/use-gated-refresh.d.ts +7 -1
  33. package/lib/types/client/write-seats.d.ts +21 -13
  34. package/lib/types/log/session-log.d.ts +4 -1
  35. package/lib/types/ports/agent-handles.d.ts +1 -1
  36. package/lib/types/ports/home.d.ts +1 -1
  37. package/lib/types/ports/host-port.d.ts +1 -1
  38. package/lib/types/shared/wire.d.ts +9 -2
  39. package/lib/types/trash/attachments.d.ts +5 -1
  40. package/lib/types/verbs/batch.d.ts +10 -7
  41. package/lib/types/verbs/delete-session.d.ts +1 -1
  42. package/lib/types/verbs/member-journal.d.ts +1 -1
  43. package/lib/types/verbs/move-directory.d.ts +10 -0
  44. package/lib/types/verbs/orphan-subagents.d.ts +2 -2
  45. package/lib/types/verbs/permanent-removal.d.ts +1 -1
  46. package/lib/types/verbs/restore-session.d.ts +3 -3
  47. package/locale/en.json +1 -1
  48. package/locale/zh.json +1 -1
  49. package/package.json +2 -2
  50. package/lib/types/client/batch-confirm.d.ts +0 -36
  51. package/lib/types/client/delete-confirm.d.ts +0 -52
@@ -6,7 +6,7 @@ export interface DeleteResult {
6
6
  readonly movedSessionIds: readonly string[];
7
7
  }
8
8
  /**
9
- * 删除 = 移入回收站,**按组走**:用户点掉一条父会话时宿主把 `origin:"subagent"` 的孩子整排藏了 ⇒ 那些目录既看不见也继续占字节,
9
+ * **移入回收站**(线上动作名仍是 `delete`),**按组走**:用户点掉一条父会话时宿主把 `origin:"subagent"` 的孩子整排藏了 ⇒ 那些目录既看不见也继续占字节,
10
10
  * 所以父在盘上的孩子一起搬进来,各自一行,清册用 `parentEntryId` 记归属。
11
11
  *
12
12
  * 三段,顺序承重(成员循环与整组回滚住 `verbs/move-group.ts`):
@@ -36,6 +36,6 @@ export declare function attempt(label: string, run: () => Promise<unknown>): Pro
36
36
  export declare function stepUndo(label: string, run: () => Promise<unknown>): Promise<StepUndo>;
37
37
  /**
38
38
  * **组级回滚**:把已经做成的成员按相反顺序退回;某一步退不干净时把失败并进原错误的
39
- * `details.rollbackFailures`,绝不让原错误独走。删除与恢复两个按组走的动词共用这一处。
39
+ * `details.rollbackFailures`,绝不让原错误独走。移入回收站与恢复两个按组走的动词共用这一处。
40
40
  */
41
41
  export declare function rollbackJournals(journals: readonly Journal[], error: unknown): Promise<never>;
@@ -0,0 +1,10 @@
1
+ /** 重试间隔(毫秒):第 n 个间隔对应第 n 次重试。导出给测试与 ADR 引用的读数,不在调用点另抄一份。 */
2
+ export declare const MOVE_DIR_RETRY_DELAYS_MS: readonly [50, 150];
3
+ export interface MoveDirectoryOptions {
4
+ /** 覆盖重试间隔(测试用);缺省 {@link MOVE_DIR_RETRY_DELAYS_MS}。 */
5
+ readonly delaysMs?: readonly number[];
6
+ /** 覆盖等待实现(测试用,免得真睡);缺省 `setTimeout`。 */
7
+ readonly sleep?: (ms: number) => Promise<void>;
8
+ }
9
+ /** 搬目录:瞬态占用按固定小步数重试;判据错误与非瞬态码一次都不重试。 */
10
+ export declare function moveDirectoryWithRetry(rename: (from: string, to: string) => Promise<void>, from: string, to: string, options?: MoveDirectoryOptions): Promise<void>;
@@ -49,8 +49,8 @@ export declare function reportOrphans(groups: readonly OrphanGroup[]): OrphanRep
49
49
  export declare function planOrphanGroup(deps: CoreDeps, group: OrphanGroup): Promise<RemovalPlan>;
50
50
  /**
51
51
  * 清一组的**执行**(只写):量目录、摘归档集与账本、删目录与成员通告的顺序和失败形状都住 `permanent-removal.ts`,
52
- * 这里只把这一组的计划递上去。顺序与删除那一半**对偶**但不照抄:
53
- * - 删除那一半不碰归档(ADR-0008);这里目录是**删掉**不是搬走 ⇒ 归档集**在写之前整批摘掉**:失败时目录还在可重试,
52
+ * 这里只把这一组的计划递上去。顺序与移入回收站那一半**对偶**但不照抄:
53
+ * - 移入回收站那一半不碰归档(ADR-0008);这里目录是**删掉**不是搬走 ⇒ 归档集**在写之前整批摘掉**:失败时目录还在可重试,
54
54
  * 不留"会话没了却还在归档集里挂着"的幽灵 id(`unarchive` 对未归档会话本就是幂等 no-op,无需那次 `wasArchived` 读)。
55
55
  * - 摘账本只在账本真记着它时做(`workspaceOf` 未命中 = 未分组,不是故障);独占图片的剩余引用源由附件域在批级扫。
56
56
  */
@@ -30,7 +30,7 @@ export declare function measureMemberDir(deps: CoreDeps, member: {
30
30
  readonly sessionId: string;
31
31
  readonly projectDir: string;
32
32
  }): Promise<MeasuredMemberDir | undefined>;
33
- /** 一条成员的**测量**读数:身份两格 + 目录 + 实测字节;没有账本归属格(归属只有删除动词才读)。 */
33
+ /** 一条成员的**测量**读数:身份两格 + 目录 + 实测字节;没有账本归属格(归属只有 `delete` 动词才读)。 */
34
34
  export interface MeasuredMember {
35
35
  readonly sessionId: string;
36
36
  readonly projectDir: string;
@@ -2,7 +2,7 @@ import { type TrashEntry } from '../trash/entry.js';
2
2
  import { type HostIdentityPort } from '../ports/host-port.js';
3
3
  import type { CoreDeps } from '../deps.js';
4
4
  /**
5
- * 恢复:把删除那次按原路退回,并按组走。预检整组(不写盘):回收站目录与原项目目录必须在,账本缺席不算硬失败(归「未分组」)。
5
+ * 恢复:把移入回收站那次按原路退回,并按组走。预检整组(不写盘):回收站目录与原项目目录必须在,账本缺席不算硬失败(归「未分组」)。
6
6
  * 逐个恢复:文件先回来 → 挂账本 →(旧条目)取消归档 → 摘清册行;中途失败由 journal 回滚当前成员,已恢复的兄弟按相反顺序退回。
7
7
  * 通告归批量层(ADR-0002)。
8
8
  */
@@ -11,11 +11,11 @@ export declare function restoreSession(deps: CoreDeps): (entryId: string,
11
11
  * ghost 父(父行已摘、只剩孩子)的组只有孩子、不含 `entryId`,这里照旧报 `trash-empty`;动词**不收缩**它。 */
12
12
  group: readonly TrashEntry[]) => Promise<TrashEntry>;
13
13
  /**
14
- * 这一次恢复**到底挂不挂账本**:交出能挂的 `workspaceId`,挂不了就 `undefined`。两种缺席是同一件事:空串 = 删除时就没有账目;
14
+ * 这一次恢复**到底挂不挂账本**:交出能挂的 `workspaceId`,挂不了就 `undefined`。两种缺席是同一件事:空串 = 移入回收站时就没有账目;
15
15
  * 非空但账本里已没它 = 宿主的「删除工作区」只删注册、保留目录与日志,那些会话本来就在「未分组」下。
16
16
  * 判据**只有这一处**(`memberRestore` 与 `GET /list` 共用),两处各问一遍就会有一天一个说、一个不挂。
17
17
  */
18
18
  export declare function attachableWorkspaceId(host: Pick<HostIdentityPort, 'workspaceExists'>, entry: TrashEntry): Promise<string | undefined>;
19
- /** 这一条记着的工作区**是不是已经没了**(区别于删除时就没有账目的空串)——清单行据此决定说不说那句
19
+ /** 这一条记着的工作区**是不是已经没了**(区别于移入回收站时就没有账目的空串)——清单行据此决定说不说那句
20
20
  * 「原工作区已不存在,恢复后归入未分组」。由 {@link attachableWorkspaceId} 派生,不另起判据(否则会一个说、一个不挂)。 */
21
21
  export declare function isWorkspaceMissing(host: Pick<HostIdentityPort, 'workspaceExists'>, entry: TrashEntry): Promise<boolean>;
package/locale/en.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Session delete",
4
- "description": "Choose Delete from a session row's ⋯ menu and confirm to move it to Trash in the sidebar, where it can be restored at any time; permanent deletion is a separate, confirmed action. Running sessions cannot be deleted and Trash never expires; all data stays on this machine.",
4
+ "description": "Choose “Move to trash” from a session row's ⋯ menu to move it to Trash in the sidebar, where it can be restored at any time; permanent deletion is a separate, confirmed action. Running sessions cannot be moved to the trash and Trash never expires; all data stays on this machine.",
5
5
  "detail": "docs/DETAIL.md"
6
6
  }
7
7
  }
package/locale/zh.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "会话删除",
4
- "description": "在会话行的「⋯」菜单里选「删除」、确认后移入左侧栏的「回收站」,可随时恢复;彻底删除是另一件需要二次确认的显式动作。正在运行的会话删不了,回收站永不自动过期;数据全在本机,不联网。",
4
+ "description": "在会话行的「⋯」菜单里选「移入回收站」,会话即移入左侧栏的「回收站」,可随时恢复;彻底删除是另一件需要二次确认的显式动作。正在运行的会话不能移入回收站,回收站永不自动过期;数据全在本机,不联网。",
5
5
  "detail": "docs/DETAIL.zh.md"
6
6
  }
7
7
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xrn1997/dsh-session-delete",
3
- "version": "0.11.0",
4
- "description": "在 DeepSeek Harness 里删除会话:删除=移入回收站(可恢复),另设显式彻底删除",
3
+ "version": "0.12.0",
4
+ "description": "在 DeepSeek Harness 里清理会话:可恢复的移入回收站,无恢复路径的彻底删除需二次确认",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@11.25.0",
7
7
  "main": "lib/index.js",
@@ -1,36 +0,0 @@
1
- /**
2
- * 批量删除确认框:挂在 `shell.overlay` 上的宿主,加它读的请求现场(场景实例里的一份)。
3
- * 页脚与关框规则共壳(`confirm-dialog.tsx`,ADR-0052),业务面各是各的;请求现场必须活在行开关那棵
4
- * 子树之外(槽位行随宿主重排而卸载)。框不认识任何一方的选中集:执行后由发请求那一面交收缩钩子。
5
- */
6
- import { type ReactElement } from 'react';
7
- import { type Translate } from './copy.js';
8
- import type { OneShotDeps } from './remote.js';
9
- import type { PickItem } from './batch-selection-store.js';
10
- export interface BatchDeleteRequest {
11
- /** 每次发布递增:换一批就重挂载,busy / 失败面不带着上一批的记忆。 */
12
- seq: number;
13
- items: readonly PickItem[];
14
- /** 落地后收缩**发请求那一面**的选中集;被闸挡回的那一趟不调它——这一趟没跑,不许照着它动任何选中集。 */
15
- shrinkSelection?: (failedSessionIds: readonly string[]) => void;
16
- }
17
- export interface BatchConfirmScene {
18
- /** 请求确认这一批。空名单不发框;`shrinkSelection` 缺席 = 这一面没有要收缩的选中集。 */
19
- request(items: readonly PickItem[], shrinkSelection?: (failedSessionIds: readonly string[]) => void): void;
20
- /** 收起确认框。**带 expected 比较**:一次批量在飞时用户可能已发布了**下一批**请求(框按 seq 重挂载),
21
- * 旧实例晚到的成功只许收自己那一批,不许把后来发布的那批一起清掉。 */
22
- clear(expected?: BatchDeleteRequest): void;
23
- /** 重试轮之后把现场收缩到失败名单。**带 expected 比较**:旧实例晚到的部分失败不许收缩后来发布的那一批。 */
24
- shrinkToFailures(expected: BatchDeleteRequest, failedSessionIds: readonly string[]): void;
25
- use(): BatchDeleteRequest | null;
26
- reset(): void;
27
- }
28
- export declare function createBatchConfirmScene(): BatchConfirmScene;
29
- export declare function requestDeleteBatch(items: readonly PickItem[], shrinkSelection?: (failedSessionIds: readonly string[]) => void): void;
30
- export declare function clearDeleteBatchRequest(expected?: BatchDeleteRequest): void;
31
- /** 供浮条与装配面订阅(生产走 Provider 的那一份;测试无 Provider 回退默认场景)。 */
32
- export declare function useDeleteBatchRequest(): BatchDeleteRequest | null;
33
- export declare function BatchConfirmHost({ deps, t, }: {
34
- deps: OneShotDeps;
35
- t?: Translate;
36
- }): ReactElement | null;
@@ -1,52 +0,0 @@
1
- import { type Translate } from './copy.js';
2
- import { type OneShotDeps } from './remote.js';
3
- /**
4
- * 被操作对象那张卡。`Modal` 的 `.sd-modal-body` 不设字号也不给层级 ⇒ 裸摆一行标题会和下面那句提示
5
- * **同字同色**,读不出"这才是要被删的东西"。配方与「彻底删除」框里那张摘要卡同一套(宿主设置面的
6
- * 卡片 token),两个对话框因此同形。
7
- */
8
- export declare const TARGET_CARD: {
9
- readonly padding: "10px 12px";
10
- readonly background: "var(--dsw-alias-bg-layer-2)";
11
- readonly border: "0.5px solid var(--sd-border-l4)";
12
- readonly borderRadius: "var(--sd-radius-lg)";
13
- };
14
- /** 菜单行写进现场的一条删除请求(槽位投影原样带过来,浏览器半不自己拼 id)。 */
15
- export interface DeleteRequest {
16
- /** 每次发布递增:换一个会话就重挂载确认框,busy / failure 不带着上一条请求的记忆。 */
17
- seq: number;
18
- /** 原样透给删除写入(段名与动作住 `shared/wire.ts`,浏览器半不自己拼 id)。 */
19
- sessionId: string;
20
- /** 删除那一刻的会话名(槽位投影的 `displayTitle`):只用于确认框文案与撤销提示。 */
21
- title: string;
22
- }
23
- /** 一台「删除」确认框请求现场:发布 / 按 expected 收框 / 订阅 / 收场。 */
24
- export interface DeleteRequestScene {
25
- /** 菜单行调用:请求删除这个会话(确认框由 overlay 上的宿主渲染)。 */
26
- request(input: {
27
- sessionId: string;
28
- title: string;
29
- }): void;
30
- /** 收起确认框(用户点「取消」/「关闭」、或删除成功后收工)。
31
- * **必带 expected 比较**:一次删除在飞时用户可能已经发布了**下一条**请求(框按 seq 重挂载)。
32
- * 旧实例晚到的成功只许收自己那一条,不许把后来发布的请求一起清掉(那会让新框凭空消失)。
33
- * 复位走 `reset`,收框一律交 `current`。 */
34
- clear(expected: DeleteRequest): void;
35
- /** 供宿主组件订阅。 */
36
- use(): DeleteRequest | null;
37
- /** 场景收场:现场与 seq 归零。 */
38
- reset(): void;
39
- }
40
- export declare function createDeleteRequestScene(): DeleteRequestScene;
41
- /** 菜单行调用:请求删除这个会话(默认场景)。 */
42
- export declare function requestDelete(input: {
43
- sessionId: string;
44
- title: string;
45
- }): void;
46
- /** 供宿主组件订阅(生产走 Provider;测试无 Provider 回退默认场景)。 */
47
- export declare function useDeleteRequest(): DeleteRequest | null;
48
- /** 常驻的确认框宿主。挂 `shell.overlay`(框架级浮层):没有待确认的删除时什么都不渲染。 */
49
- export declare function DeleteConfirmHost({ deps, t }: {
50
- deps: OneShotDeps;
51
- t?: Translate;
52
- }): import("react").JSX.Element | null;