dsh-coding-sidebar 1.0.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.
- package/LICENSE +21 -0
- package/README.md +524 -0
- package/cordis.patch.yml +49 -0
- package/lib/client-editor.js +48229 -0
- package/lib/client-mermaid.js +200745 -0
- package/lib/client-registry.js +21867 -0
- package/lib/client-terminal.js +9361 -0
- package/lib/client.js +21867 -0
- package/lib/index.js +4556 -0
- package/lib/invariant.js +22 -0
- package/lib/types/agent-opens.d.ts +65 -0
- package/lib/types/agent-pty.d.ts +226 -0
- package/lib/types/browser-probe.d.ts +15 -0
- package/lib/types/bundle-route.d.ts +12 -0
- package/lib/types/client/BrowserView.d.ts +39 -0
- package/lib/types/client/DiffTab.d.ts +6 -0
- package/lib/types/client/DiffView.d.ts +51 -0
- package/lib/types/client/EditorHost.d.ts +13 -0
- package/lib/types/client/FileTree.d.ts +38 -0
- package/lib/types/client/FreeWindow.d.ts +29 -0
- package/lib/types/client/GitView.d.ts +10 -0
- package/lib/types/client/MarkdownHtml.d.ts +32 -0
- package/lib/types/client/OrphanedTab.d.ts +11 -0
- package/lib/types/client/PdfView.d.ts +6 -0
- package/lib/types/client/RenderBoundary.d.ts +32 -0
- package/lib/types/client/SandboxStatusBar.d.ts +10 -0
- package/lib/types/client/SideCardSection.d.ts +74 -0
- package/lib/types/client/SideChatView.d.ts +16 -0
- package/lib/types/client/Sidebar.d.ts +6 -0
- package/lib/types/client/SubagentView.d.ts +16 -0
- package/lib/types/client/TabBar.d.ts +54 -0
- package/lib/types/client/TerminalView.d.ts +24 -0
- package/lib/types/client/TextEditor.d.ts +10 -0
- package/lib/types/client/TreePanel.d.ts +24 -0
- package/lib/types/client/UploadOverlay.d.ts +20 -0
- package/lib/types/client/add-plugin-modal.d.ts +15 -0
- package/lib/types/client/api.d.ts +275 -0
- package/lib/types/client/binary-download.d.ts +12 -0
- package/lib/types/client/breakpoints.d.ts +17 -0
- package/lib/types/client/browser.d.ts +60 -0
- package/lib/types/client/builtins/index.d.ts +18 -0
- package/lib/types/client/builtins/tabs.d.ts +11 -0
- package/lib/types/client/builtins/viewers.d.ts +3 -0
- package/lib/types/client/chunk-loader.d.ts +131 -0
- package/lib/types/client/chunks/editor.d.ts +9 -0
- package/lib/types/client/chunks/mermaid.d.ts +10 -0
- package/lib/types/client/chunks/terminal.d.ts +9 -0
- package/lib/types/client/cm-themes.d.ts +24 -0
- package/lib/types/client/conversation-draft.d.ts +14 -0
- package/lib/types/client/desktop-env.d.ts +35 -0
- package/lib/types/client/editor-load.d.ts +66 -0
- package/lib/types/client/frame-batcher.d.ts +24 -0
- package/lib/types/client/icons.d.ts +59 -0
- package/lib/types/client/image-types.d.ts +3 -0
- package/lib/types/client/ime-guard.d.ts +36 -0
- package/lib/types/client/index.d.ts +25 -0
- package/lib/types/client/intercept.d.ts +46 -0
- package/lib/types/client/lang.d.ts +14 -0
- package/lib/types/client/layout-push.d.ts +15 -0
- package/lib/types/client/lazy-chunk.d.ts +25 -0
- package/lib/types/client/link-intercept.d.ts +42 -0
- package/lib/types/client/locales-ar.d.ts +18 -0
- package/lib/types/client/locales-de.d.ts +4 -0
- package/lib/types/client/locales-fr.d.ts +10 -0
- package/lib/types/client/locales-hi.d.ts +17 -0
- package/lib/types/client/locales-id.d.ts +15 -0
- package/lib/types/client/locales-it.d.ts +8 -0
- package/lib/types/client/locales-ja.d.ts +17 -0
- package/lib/types/client/locales-ko.d.ts +9 -0
- package/lib/types/client/locales-nl.d.ts +16 -0
- package/lib/types/client/locales-pl.d.ts +19 -0
- package/lib/types/client/locales-pt.d.ts +1 -0
- package/lib/types/client/locales-ru.d.ts +13 -0
- package/lib/types/client/locales-sv.d.ts +1 -0
- package/lib/types/client/locales-th.d.ts +17 -0
- package/lib/types/client/locales-tr.d.ts +17 -0
- package/lib/types/client/locales-vi.d.ts +17 -0
- package/lib/types/client/locales-zh-HK.d.ts +32 -0
- package/lib/types/client/locales-zh-MO.d.ts +32 -0
- package/lib/types/client/locales-zh-TW.d.ts +32 -0
- package/lib/types/client/locales.d.ts +452 -0
- package/lib/types/client/markdown-html.d.ts +96 -0
- package/lib/types/client/markdown-images.d.ts +45 -0
- package/lib/types/client/markdown-labels.d.ts +38 -0
- package/lib/types/client/md-toc.d.ts +4 -0
- package/lib/types/client/mermaid-blocks.d.ts +47 -0
- package/lib/types/client/mermaid-sanitize.d.ts +2 -0
- package/lib/types/client/mermaid.d.ts +12 -0
- package/lib/types/client/open-when-sized.d.ts +20 -0
- package/lib/types/client/open-with-settings.d.ts +4 -0
- package/lib/types/client/open-with.d.ts +87 -0
- package/lib/types/client/openpath-intercept.d.ts +85 -0
- package/lib/types/client/paths.d.ts +43 -0
- package/lib/types/client/pdf-types.d.ts +2 -0
- package/lib/types/client/pinned.d.ts +86 -0
- package/lib/types/client/plugin-settings.d.ts +8 -0
- package/lib/types/client/plugins-shared.d.ts +27 -0
- package/lib/types/client/plugins-tabs.d.ts +3 -0
- package/lib/types/client/plugins-viewers.d.ts +3 -0
- package/lib/types/client/prefs.d.ts +41 -0
- package/lib/types/client/produced-files.d.ts +29 -0
- package/lib/types/client/selection-payload.d.ts +27 -0
- package/lib/types/client/service.d.ts +439 -0
- package/lib/types/client/settings-nav-icon.d.ts +19 -0
- package/lib/types/client/shell-presets.d.ts +48 -0
- package/lib/types/client/sidechat-transcript.d.ts +103 -0
- package/lib/types/client/split-pane.d.ts +36 -0
- package/lib/types/client/state.d.ts +432 -0
- package/lib/types/client/subagent-detect.d.ts +54 -0
- package/lib/types/client/subagent-jobs.d.ts +63 -0
- package/lib/types/client/tab-content-memo.d.ts +40 -0
- package/lib/types/client/terminal-font.d.ts +78 -0
- package/lib/types/client/terminal-links.d.ts +119 -0
- package/lib/types/client/theme.d.ts +45 -0
- package/lib/types/client/titlebar-strip.d.ts +23 -0
- package/lib/types/client/upload.d.ts +69 -0
- package/lib/types/client/wco.d.ts +47 -0
- package/lib/types/config.d.ts +64 -0
- package/lib/types/context-types.d.ts +605 -0
- package/lib/types/fs-operations.d.ts +28 -0
- package/lib/types/fs-search.d.ts +24 -0
- package/lib/types/fs-tree.d.ts +51 -0
- package/lib/types/git.d.ts +124 -0
- package/lib/types/html-route.d.ts +59 -0
- package/lib/types/index.d.ts +47 -0
- package/lib/types/invariant.d.ts +15 -0
- package/lib/types/jobs-routes.d.ts +45 -0
- package/lib/types/open-external.d.ts +24 -0
- package/lib/types/path-security.d.ts +20 -0
- package/lib/types/prefs-shared.d.ts +236 -0
- package/lib/types/pty-deps.d.ts +78 -0
- package/lib/types/pty-manager.d.ts +168 -0
- package/lib/types/sidechat-core.d.ts +172 -0
- package/lib/types/sidechat-routes.d.ts +30 -0
- package/lib/types/subagent-activity.d.ts +44 -0
- package/lib/types/subagent-live-route.d.ts +44 -0
- package/lib/types/tools.d.ts +34 -0
- package/lib/types/trust-fence.d.ts +24 -0
- package/lib/types/wire.d.ts +38 -0
- package/package.json +172 -0
- package/scripts/install.ps1 +306 -0
- package/scripts/install.sh +287 -0
- package/src/agent-opens.ts +265 -0
- package/src/agent-pty.ts +527 -0
- package/src/browser-probe.ts +26 -0
- package/src/bundle-route.ts +129 -0
- package/src/client/BrowserView.tsx +289 -0
- package/src/client/DiffTab.tsx +114 -0
- package/src/client/DiffView.tsx +305 -0
- package/src/client/EditorHost.tsx +558 -0
- package/src/client/FileTree.tsx +669 -0
- package/src/client/FreeWindow.tsx +337 -0
- package/src/client/GitView.tsx +717 -0
- package/src/client/MarkdownHtml.tsx +296 -0
- package/src/client/OrphanedTab.tsx +27 -0
- package/src/client/PdfView.tsx +110 -0
- package/src/client/RenderBoundary.tsx +49 -0
- package/src/client/SandboxStatusBar.tsx +60 -0
- package/src/client/SideCardSection.module.css +960 -0
- package/src/client/SideCardSection.tsx +1163 -0
- package/src/client/SideChatView.module.css +437 -0
- package/src/client/SideChatView.tsx +645 -0
- package/src/client/Sidebar.tsx +1370 -0
- package/src/client/SubagentView.module.css +547 -0
- package/src/client/SubagentView.tsx +883 -0
- package/src/client/TabBar.tsx +365 -0
- package/src/client/TerminalView.tsx +424 -0
- package/src/client/TextEditor.tsx +468 -0
- package/src/client/TreePanel.tsx +275 -0
- package/src/client/UploadOverlay.tsx +62 -0
- package/src/client/add-plugin-modal.tsx +199 -0
- package/src/client/api.ts +357 -0
- package/src/client/binary-download.tsx +23 -0
- package/src/client/breakpoints.ts +61 -0
- package/src/client/browser.ts +167 -0
- package/src/client/builtins/index.ts +37 -0
- package/src/client/builtins/tabs.tsx +340 -0
- package/src/client/builtins/viewers.tsx +125 -0
- package/src/client/chunk-loader.ts +358 -0
- package/src/client/chunks/editor.tsx +9 -0
- package/src/client/chunks/mermaid.tsx +10 -0
- package/src/client/chunks/terminal.tsx +9 -0
- package/src/client/cm-themes.ts +129 -0
- package/src/client/conversation-draft.ts +29 -0
- package/src/client/css-modules.d.ts +5 -0
- package/src/client/desktop-env.ts +72 -0
- package/src/client/editor-load.ts +92 -0
- package/src/client/frame-batcher.ts +56 -0
- package/src/client/icons.tsx +152 -0
- package/src/client/image-types.ts +8 -0
- package/src/client/ime-guard.ts +47 -0
- package/src/client/index.tsx +427 -0
- package/src/client/intercept.tsx +188 -0
- package/src/client/lang.ts +225 -0
- package/src/client/layout-push.ts +24 -0
- package/src/client/layout.css +90 -0
- package/src/client/lazy-chunk.tsx +89 -0
- package/src/client/link-intercept.ts +73 -0
- package/src/client/locales-ar.ts +368 -0
- package/src/client/locales-de.ts +353 -0
- package/src/client/locales-fr.ts +360 -0
- package/src/client/locales-hi.ts +367 -0
- package/src/client/locales-id.ts +365 -0
- package/src/client/locales-it.ts +358 -0
- package/src/client/locales-ja.ts +367 -0
- package/src/client/locales-ko.ts +359 -0
- package/src/client/locales-nl.ts +365 -0
- package/src/client/locales-pl.ts +369 -0
- package/src/client/locales-pt.ts +350 -0
- package/src/client/locales-ru.ts +365 -0
- package/src/client/locales-sv.ts +350 -0
- package/src/client/locales-th.ts +367 -0
- package/src/client/locales-tr.ts +367 -0
- package/src/client/locales-vi.ts +367 -0
- package/src/client/locales-zh-HK.ts +382 -0
- package/src/client/locales-zh-MO.ts +382 -0
- package/src/client/locales-zh-TW.ts +382 -0
- package/src/client/locales.ts +894 -0
- package/src/client/markdown-html.ts +331 -0
- package/src/client/markdown-images.ts +137 -0
- package/src/client/markdown-labels.tsx +52 -0
- package/src/client/md-toc.tsx +127 -0
- package/src/client/mermaid-blocks.ts +110 -0
- package/src/client/mermaid-sanitize.ts +93 -0
- package/src/client/mermaid.tsx +406 -0
- package/src/client/open-when-sized.ts +43 -0
- package/src/client/open-with-settings.tsx +135 -0
- package/src/client/open-with.ts +221 -0
- package/src/client/openpath-intercept.ts +143 -0
- package/src/client/paths.ts +63 -0
- package/src/client/pdf-types.ts +4 -0
- package/src/client/pinned.ts +183 -0
- package/src/client/plugin-settings.ts +43 -0
- package/src/client/plugins-shared.ts +29 -0
- package/src/client/plugins-tabs.ts +96 -0
- package/src/client/plugins-viewers.ts +30 -0
- package/src/client/prefs.ts +210 -0
- package/src/client/produced-files.ts +120 -0
- package/src/client/selection-payload.ts +86 -0
- package/src/client/service.ts +859 -0
- package/src/client/settings-nav-icon.ts +45 -0
- package/src/client/shell-presets.ts +83 -0
- package/src/client/sidebar.module.css +2788 -0
- package/src/client/sidechat-transcript.ts +321 -0
- package/src/client/split-pane.tsx +331 -0
- package/src/client/state.ts +1497 -0
- package/src/client/subagent-detect.ts +137 -0
- package/src/client/subagent-jobs.ts +161 -0
- package/src/client/tab-content-memo.ts +55 -0
- package/src/client/terminal-font.ts +224 -0
- package/src/client/terminal-links.ts +194 -0
- package/src/client/theme.ts +110 -0
- package/src/client/titlebar-strip.ts +37 -0
- package/src/client/upload.ts +187 -0
- package/src/client/wco.ts +120 -0
- package/src/config.ts +154 -0
- package/src/context-types.ts +611 -0
- package/src/fs-operations.ts +95 -0
- package/src/fs-search.ts +113 -0
- package/src/fs-tree.ts +158 -0
- package/src/git.ts +446 -0
- package/src/html-route.ts +106 -0
- package/src/index.ts +1291 -0
- package/src/invariant.ts +32 -0
- package/src/jobs-routes.ts +257 -0
- package/src/open-external.ts +90 -0
- package/src/path-security.ts +75 -0
- package/src/prefs-shared.ts +280 -0
- package/src/pty-deps.ts +240 -0
- package/src/pty-manager.ts +376 -0
- package/src/sidechat-core.ts +468 -0
- package/src/sidechat-routes.ts +344 -0
- package/src/subagent-activity.ts +91 -0
- package/src/subagent-live-route.ts +93 -0
- package/src/tools.ts +482 -0
- package/src/trust-fence.ts +84 -0
- package/src/wire.ts +100 -0
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-session sidebar state: the panel geometry, the split-pane workbench
|
|
3
|
+
* tree, open tabs, and the explorer expansion set. One state instance per
|
|
4
|
+
* conversation id, persisted to localStorage under `dsh-sidebar:v1:<id>` so
|
|
5
|
+
* a reload restores the exact layout of the session it belongs to — switching
|
|
6
|
+
* conversations swaps the whole state (memory + isolation).
|
|
7
|
+
*
|
|
8
|
+
* The split tree is a recursive structure: a leaf holds a tab group, a split
|
|
9
|
+
* divides the space row- or column-wise with fractional sizes. All tree
|
|
10
|
+
* operations are pure functions over the node, unit-tested in tests/state.spec.ts.
|
|
11
|
+
*/
|
|
12
|
+
import { type SidebarPrefs } from '../prefs-shared.ts';
|
|
13
|
+
/**
|
|
14
|
+
* Tab type identifier. Builtins register their ids (editor / git / terminal
|
|
15
|
+
* / subagent / browser / diff) through the sidebar service; external
|
|
16
|
+
* plugins register their own (e.g. `'my-plugin:db'`). Kept as `string` so
|
|
17
|
+
* the registry stays open.
|
|
18
|
+
*/
|
|
19
|
+
export type TabType = string;
|
|
20
|
+
/** What a diff tab shows: a worktree/index change of one path, or one commit's full patch. */
|
|
21
|
+
export type SidebarDiffRef = {
|
|
22
|
+
kind: 'worktree';
|
|
23
|
+
path: string;
|
|
24
|
+
staged: boolean;
|
|
25
|
+
untracked?: boolean;
|
|
26
|
+
worktree?: string;
|
|
27
|
+
repoRoot?: string;
|
|
28
|
+
} | {
|
|
29
|
+
kind: 'commit';
|
|
30
|
+
hash: string;
|
|
31
|
+
hashFull: string;
|
|
32
|
+
subject: string;
|
|
33
|
+
worktree?: string;
|
|
34
|
+
repoRoot?: string;
|
|
35
|
+
};
|
|
36
|
+
/** One open tab. `path` carries the file (editor) or is absent (git/terminal);
|
|
37
|
+
* `diff` carries the change a diff tab shows; `meta` (v0.12.0+) carries
|
|
38
|
+
* plugin-owned JSON-serializable state, preserved across reloads. */
|
|
39
|
+
export interface SidebarTab {
|
|
40
|
+
id: string;
|
|
41
|
+
type: TabType;
|
|
42
|
+
title: string;
|
|
43
|
+
path?: string;
|
|
44
|
+
diff?: SidebarDiffRef;
|
|
45
|
+
/** Plugin-owned state (v0.12.0+): MUST be JSON-serializable — it is
|
|
46
|
+
* persisted with the layout and restored verbatim on reload. */
|
|
47
|
+
meta?: unknown;
|
|
48
|
+
/** Pinned-terminal marker (v0.17.0+): a pinned terminal tab survives a
|
|
49
|
+
* session switch in its home session's state and surfaces in the
|
|
50
|
+
* PinnedRail of every session the scope allows. `homeCwd` is the cwd
|
|
51
|
+
* snapshot at pin time — a `workspace`-scoped pin is only visible to
|
|
52
|
+
* sessions whose cwd matches it. Absent = unpinned (legacy states). */
|
|
53
|
+
pin?: {
|
|
54
|
+
scope: 'workspace' | 'global';
|
|
55
|
+
homeCwd?: string;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** A tab group. */
|
|
59
|
+
export interface SidebarLeaf {
|
|
60
|
+
kind: 'leaf';
|
|
61
|
+
id: string;
|
|
62
|
+
tabs: SidebarTab[];
|
|
63
|
+
active: string | null;
|
|
64
|
+
}
|
|
65
|
+
/** A recursive split between child panes (fractional sizes summing to 1). */
|
|
66
|
+
export interface SidebarSplit {
|
|
67
|
+
kind: 'split';
|
|
68
|
+
id: string;
|
|
69
|
+
dir: 'row' | 'col';
|
|
70
|
+
sizes: number[];
|
|
71
|
+
children: SplitNode[];
|
|
72
|
+
}
|
|
73
|
+
export type SplitNode = SidebarLeaf | SidebarSplit;
|
|
74
|
+
/**
|
|
75
|
+
* One free window: a tab dragged out of the workbench onto the conversation
|
|
76
|
+
* area floats in the panel host at viewport coordinates. The tab is OWNED by
|
|
77
|
+
* the window exactly like a pane owns its tabs (moved, not copied); geometry
|
|
78
|
+
* persists with the session so a reload restores the window in place.
|
|
79
|
+
* Stacking order is the array order (last = topmost).
|
|
80
|
+
*/
|
|
81
|
+
export interface FloatWindow {
|
|
82
|
+
id: string;
|
|
83
|
+
tab: SidebarTab;
|
|
84
|
+
/** Viewport coordinates of the window's top-left corner. */
|
|
85
|
+
x: number;
|
|
86
|
+
y: number;
|
|
87
|
+
w: number;
|
|
88
|
+
h: number;
|
|
89
|
+
}
|
|
90
|
+
/** The full per-session state. */
|
|
91
|
+
export interface SidebarState {
|
|
92
|
+
panelOpen: boolean;
|
|
93
|
+
width: number;
|
|
94
|
+
/** The pane receiving newly opened tabs (last pane the user touched).
|
|
95
|
+
* Referenced by id so a re-id survives sanitize — see {@link treeOf}. */
|
|
96
|
+
activePane: string | null;
|
|
97
|
+
/** Monotonic terminal tab counter (ids survive reloads). */
|
|
98
|
+
nextTerminal: number;
|
|
99
|
+
/** Monotonic browser tab counter (ids survive reloads; mirrors nextTerminal). */
|
|
100
|
+
nextBrowser: number;
|
|
101
|
+
/** Explorer expansion set (absolute directory paths). */
|
|
102
|
+
expanded: string[];
|
|
103
|
+
/**
|
|
104
|
+
* Explorer rows highlighted by a "Show in folder" reveal (absolute paths).
|
|
105
|
+
* Transient by design: sanitizeState never restores it, so a reload starts
|
|
106
|
+
* unhighlighted.
|
|
107
|
+
*/
|
|
108
|
+
revealed: string[];
|
|
109
|
+
/** The right sidebar's split tree (the original workbench). */
|
|
110
|
+
splits: SplitNode;
|
|
111
|
+
/** Free windows (tabs dragged out onto the conversation area). */
|
|
112
|
+
floats: FloatWindow[];
|
|
113
|
+
}
|
|
114
|
+
export declare const PANEL_MIN = 280;
|
|
115
|
+
export declare const PANEL_MAX = 640;
|
|
116
|
+
export declare const PANEL_DEFAULT = 400;
|
|
117
|
+
export declare const TAB_MAX_WIDTH = 160;
|
|
118
|
+
/** Free-window geometry contract: the floor keeps the window usable (a
|
|
119
|
+
* header plus some content), the ceiling is the viewport. */
|
|
120
|
+
export declare const FLOAT_MIN_W = 320;
|
|
121
|
+
export declare const FLOAT_MIN_H = 200;
|
|
122
|
+
/** Geometry a fresh free window starts with: a phone-like portrait ratio
|
|
123
|
+
* (390×780 ≈ 1:2). The creation path additionally caps the size to the
|
|
124
|
+
* viewport (minus a 24px margin), so a short viewport gets a shorter —
|
|
125
|
+
* not overflowing — window instead of an exact ratio. */
|
|
126
|
+
export declare const FLOAT_DEFAULT_W = 390;
|
|
127
|
+
export declare const FLOAT_DEFAULT_H = 780;
|
|
128
|
+
/** Mint a fresh uid-based tab id. The `'editor:' + path` convention only
|
|
129
|
+
* covers openSidebarFile opens (per-path dedupe); opens that must not
|
|
130
|
+
* dedupe (the tree's "open to the side") mint through here. */
|
|
131
|
+
export declare function mintTabId(): string;
|
|
132
|
+
/** The default tab a fresh session seeds. */
|
|
133
|
+
export type DefaultSeed = 'editor-home' | 'none';
|
|
134
|
+
/** A fresh default state: one seeded tab in one pane, open per the caller's
|
|
135
|
+
* preference. `width` is the caller's preferred panel width (default
|
|
136
|
+
* PANEL_DEFAULT) and `panelOpen` whether the panel starts expanded (default
|
|
137
|
+
* true); the store seeds new sessions from the user's side card prefs.
|
|
138
|
+
* `seed` picks the seeded tab: 'editor-home' places the EMPTY files window
|
|
139
|
+
* (an editor tab with no path whose tree panel starts open,
|
|
140
|
+
* `meta.treeOpen: true`) — in BOTH editorExplorer modes that window is the
|
|
141
|
+
* file explorer page — and 'none' starts with an empty pane (the store
|
|
142
|
+
* passes it when the user disabled the editor tab type in settings). */
|
|
143
|
+
export declare function makeDefaultState(width?: number, panelOpen?: boolean, seed?: DefaultSeed): SidebarState;
|
|
144
|
+
/** Which tree owns a pane/split id. The bottom panel was removed in v1.0.0 —
|
|
145
|
+
* only the right tree remains; kept as a function so call sites stay
|
|
146
|
+
* written against the (formerly two-tree) resolution seam. */
|
|
147
|
+
export declare function treeOf(_state: SidebarState, _id: string): 'splits';
|
|
148
|
+
/** Walk the tree and apply `visit` to the leaf with the given id. */
|
|
149
|
+
export declare function mapLeaf(node: SplitNode, paneId: string, visit: (leaf: SidebarLeaf) => void): SplitNode;
|
|
150
|
+
/** The first leaf of the tree (fallback pane when activePane is gone). */
|
|
151
|
+
export declare function firstLeaf(node: SplitNode): SidebarLeaf;
|
|
152
|
+
/** Find the leaf containing a tab id, if any. */
|
|
153
|
+
export declare function leafWithTab(node: SplitNode, tabId: string): SidebarLeaf | undefined;
|
|
154
|
+
/** All leaves of the tree, depth-first. */
|
|
155
|
+
export declare function allLeaves(node: SplitNode): SidebarLeaf[];
|
|
156
|
+
/** Whether a tab exists anywhere in a state (any pane, or any free window —
|
|
157
|
+
* a floating tab is as open as a docked one). */
|
|
158
|
+
export declare function tabOpenIn(state: SidebarState, tabId: string): boolean;
|
|
159
|
+
/** The free window holding a tab id, if any. */
|
|
160
|
+
export declare function floatWithTab(state: SidebarState, tabId: string): FloatWindow | undefined;
|
|
161
|
+
/** The free window with the given window id, if any. */
|
|
162
|
+
export declare function floatById(state: SidebarState, floatId: string): FloatWindow | undefined;
|
|
163
|
+
/** Replace a leaf with a split of it plus a fresh empty leaf. */
|
|
164
|
+
export declare function splitLeafAt(node: SplitNode, paneId: string, dir: 'row' | 'col'): SplitNode;
|
|
165
|
+
/**
|
|
166
|
+
* Split a leaf by inserting a fresh leaf holding `tab` beside it — the
|
|
167
|
+
* VSCode drag-to-edge gesture. `dir` is the split direction ('row' for
|
|
168
|
+
* left/right, 'col' for up/down); `front` places the new leaf first (left/
|
|
169
|
+
* up) or second (right/down).
|
|
170
|
+
* @returns the new tree plus the fresh leaf's id (the drop's active pane).
|
|
171
|
+
*/
|
|
172
|
+
export declare function insertLeafAt(node: SplitNode, paneId: string, dir: 'row' | 'col', tab: SidebarTab, front: boolean): {
|
|
173
|
+
node: SplitNode;
|
|
174
|
+
leafId: string;
|
|
175
|
+
};
|
|
176
|
+
/** Where a tab drop lands on a pane: an edge creates a split, center merges. */
|
|
177
|
+
export type DropZone = 'left' | 'right' | 'up' | 'down' | 'center';
|
|
178
|
+
/**
|
|
179
|
+
* The VSCode drag gesture: move a tab out of its pane and either merge it
|
|
180
|
+
* into the target pane (center) or split the target pane with the tab in a
|
|
181
|
+
* fresh leaf (edge). The source pane collapses when it empties.
|
|
182
|
+
*/
|
|
183
|
+
export declare function moveTabToEdge(state: SidebarState, fromPane: string, tabId: string, toPane: string, zone: DropZone): SidebarState;
|
|
184
|
+
/**
|
|
185
|
+
* Remove a leaf from the tree. A split left with one child promotes that
|
|
186
|
+
* child; removing the last leaf yields an empty leaf.
|
|
187
|
+
*/
|
|
188
|
+
export declare function removeLeafAt(node: SplitNode, paneId: string): SplitNode;
|
|
189
|
+
/** Close a tab; an emptied leaf is removed (unless it is the only pane). */
|
|
190
|
+
export declare function closeTab(state: SidebarState, paneId: string, tabId: string): SidebarState;
|
|
191
|
+
/** Activate a tab in its pane (the pane's own tree). */
|
|
192
|
+
export declare function activateTab(state: SidebarState, paneId: string, tabId: string): SidebarState;
|
|
193
|
+
/** Update the display fields of one open tab (title / path / meta) without
|
|
194
|
+
* re-opening it. The browser tab persists its current URL and hostname
|
|
195
|
+
* title through this reducer so a reload restores the visited page. A
|
|
196
|
+
* missing tab id is a no-op. The tab may live in any pane or a free
|
|
197
|
+
* window. */
|
|
198
|
+
export declare function patchTab(state: SidebarState, tabId: string, patch: {
|
|
199
|
+
title?: string;
|
|
200
|
+
path?: string;
|
|
201
|
+
meta?: unknown;
|
|
202
|
+
}): SidebarState;
|
|
203
|
+
/**
|
|
204
|
+
* Set or clear the pin marker on one open tab (v0.17.0+). A pin marker is
|
|
205
|
+
* structural metadata (NOT display fields like title/path), so it walks
|
|
206
|
+
* the split tree AND the free windows exactly like {@link patchTab} —
|
|
207
|
+
* the tab may live in a pane or float. Passing `null` clears the pin
|
|
208
|
+
* (the tab stays open in its home session); passing a `{ scope, homeCwd }`
|
|
209
|
+
* object sets it. An unknown tab id is a strict no-op (same reference
|
|
210
|
+
* returned) so a stale pin request never churns the state or rewrites
|
|
211
|
+
* localStorage.
|
|
212
|
+
* @param state - the current per-session sidebar state.
|
|
213
|
+
* @param tabId - the tab to pin/unpin.
|
|
214
|
+
* @param pin - the pin marker to set, or null to clear.
|
|
215
|
+
* @returns the next state (or the same reference when the tab is missing
|
|
216
|
+
* or the pin marker is already the requested value).
|
|
217
|
+
*/
|
|
218
|
+
export declare function setTabPin(state: SidebarState, tabId: string, pin: {
|
|
219
|
+
scope: 'workspace' | 'global';
|
|
220
|
+
homeCwd?: string;
|
|
221
|
+
} | null): SidebarState;
|
|
222
|
+
/**
|
|
223
|
+
* Land a tab in the active pane (or focus its existing instance by id).
|
|
224
|
+
* Dedup strategies (single-instance, per-path, per-change) are owned by the
|
|
225
|
+
* tab descriptor through {@link BetterSidebarService.openTab} / `dedupeKey`;
|
|
226
|
+
* this reducer only handles the id-based safety net (reconcile and
|
|
227
|
+
* openDiffTab already check existence before calling) and the landing
|
|
228
|
+
* itself — the service's dedupe path delegates here after its dedupeKey
|
|
229
|
+
* check misses.
|
|
230
|
+
*
|
|
231
|
+
* A stale activePane id (its pane was closed since) falls back to the
|
|
232
|
+
* right tree's first pane instead of swallowing the open.
|
|
233
|
+
*/
|
|
234
|
+
export declare function openTabInActivePane(state: SidebarState, tab: SidebarTab): SidebarState;
|
|
235
|
+
/** Move a tab from one pane to another (insert at index; -1 appends). */
|
|
236
|
+
export declare function moveTab(state: SidebarState, fromPane: string, tabId: string, toPane: string, index?: number): SidebarState;
|
|
237
|
+
/** Split the active pane (or the pane containing the active tab). */
|
|
238
|
+
export declare function splitPane(state: SidebarState, dir: 'row' | 'col'): SidebarState;
|
|
239
|
+
/**
|
|
240
|
+
* Open a diff tab the VSCode way: an existing instance of the same change is
|
|
241
|
+
* focused wherever it lives; otherwise the tab joins the first pane that
|
|
242
|
+
* already holds diff tabs (diff panes are sticky — repeated clicks stack
|
|
243
|
+
* there); on the FIRST diff of a layout the source pane splits vertically so
|
|
244
|
+
* the diff lands in a fresh pane below it ("默认在下半栏新增一个").
|
|
245
|
+
*
|
|
246
|
+
* This is split-tree placement surgery, not registry dispatch: the diff tab
|
|
247
|
+
* descriptor's `dedupeKey` is `(tab) => tab.id`, and the existing-instance
|
|
248
|
+
* check below is exactly that rule — the two agree by construction (asserted
|
|
249
|
+
* in tests). Diff tabs minted by the Git view carry change-derived ids, so
|
|
250
|
+
* the id check is the per-change dedupe.
|
|
251
|
+
* @returns the new state, with the diff pane active.
|
|
252
|
+
*/
|
|
253
|
+
export declare function openDiffTab(state: SidebarState, sourcePaneId: string, tab: SidebarTab): SidebarState;
|
|
254
|
+
/** Toggle the panel open/closed (opening restores the previous layout). */
|
|
255
|
+
export declare function togglePanel(state: SidebarState): SidebarState;
|
|
256
|
+
/** Set the panel width (clamped to the contract range; the upper bound is
|
|
257
|
+
* the viewport so the fullscreen expansion can fill the window). */
|
|
258
|
+
export declare function setWidth(state: SidebarState, width: number): SidebarState;
|
|
259
|
+
/** Toggle a directory in the explorer expansion set. */
|
|
260
|
+
export declare function toggleExpanded(state: SidebarState, path: string): SidebarState;
|
|
261
|
+
/**
|
|
262
|
+
* Reveal files in the explorer: expand every ancestor directory between the
|
|
263
|
+
* explorer root and each file (so the lazy tree actually shows the row) and
|
|
264
|
+
* record the paths for highlighting. The reveal set is transient —
|
|
265
|
+
* sanitizeState never restores it, so a reload starts unhighlighted.
|
|
266
|
+
* @param state - current sidebar state.
|
|
267
|
+
* @param cwd - the explorer's root (session working directory).
|
|
268
|
+
* @param files - absolute paths to highlight (parent dirs are expanded).
|
|
269
|
+
* @returns the next state, or the same reference when nothing is revealed.
|
|
270
|
+
*/
|
|
271
|
+
export declare function revealPaths(state: SidebarState, cwd: string | undefined, files: readonly string[]): SidebarState;
|
|
272
|
+
/** Adjust one split divider: `i` is the left/top child index, delta in fractions. */
|
|
273
|
+
export declare function resizeSplit(node: SplitNode, splitId: string, index: number, delta: number): SplitNode;
|
|
274
|
+
/** State-level {@link resizeSplit} route: the divider may live in either
|
|
275
|
+
* tree (split ids are globally unique). */
|
|
276
|
+
export declare function resizeSplitIn(state: SidebarState, splitId: string, index: number, delta: number): SidebarState;
|
|
277
|
+
/** Clamp free-window geometry: sizes respect the floor and the viewport, and
|
|
278
|
+
* the position keeps the whole window inside the viewport. Without a window
|
|
279
|
+
* (unit tests) only the floor applies — the caller's values pass through. */
|
|
280
|
+
export declare function clampFloatGeometry(x: number, y: number, w: number, h: number): Pick<FloatWindow, 'x' | 'y' | 'w' | 'h'>;
|
|
281
|
+
/**
|
|
282
|
+
* Float a docked tab: remove it from its pane (an emptied pane collapses
|
|
283
|
+
* like any move) and append a free window centered on the drop
|
|
284
|
+
* point, with the default size clamped to the viewport. The stacking order
|
|
285
|
+
* is the array order, so a fresh window is born topmost. An unknown tab id
|
|
286
|
+
* (or one already floating) is a strict no-op.
|
|
287
|
+
*/
|
|
288
|
+
export declare function floatTab(state: SidebarState, tabId: string, x: number, y: number): SidebarState;
|
|
289
|
+
/** Move a free window (clamped to the viewport); unknown ids are a no-op. */
|
|
290
|
+
export declare function moveFloat(state: SidebarState, floatId: string, x: number, y: number): SidebarState;
|
|
291
|
+
/** Resize a free window from its SE corner: the top-left corner stays
|
|
292
|
+
* anchored, sizes clamp to the floor and to the viewport's remaining room. */
|
|
293
|
+
export declare function resizeFloat(state: SidebarState, floatId: string, w: number, h: number): SidebarState;
|
|
294
|
+
/** Bring a free window to the top (the array's end). Already topmost (or the
|
|
295
|
+
* only window) returns the same reference — no persist churn on every click. */
|
|
296
|
+
export declare function raiseFloat(state: SidebarState, floatId: string): SidebarState;
|
|
297
|
+
/** Dock a free window back into a pane (center merge): the tab joins the
|
|
298
|
+
* target pane and activates. `toPane` defaults to the active pane with the
|
|
299
|
+
* right tree's first leaf as the stale-id fallback (mirrors
|
|
300
|
+
* {@link openTabInActivePane}). Unknown window ids are a no-op. */
|
|
301
|
+
export declare function dockFloat(state: SidebarState, floatId: string, toPane?: string): SidebarState;
|
|
302
|
+
/** Close the free window holding a tab (the tab closes WITH the window —
|
|
303
|
+
* the caller fires the descriptor's onClose lifecycle). */
|
|
304
|
+
export declare function closeFloatByTab(state: SidebarState, tabId: string): SidebarState;
|
|
305
|
+
/** Prefix marking a tab id as an agent-owned terminal (suffix is the uuid). */
|
|
306
|
+
export declare const AGENT_TAB_PREFIX = "agent:";
|
|
307
|
+
/** Whether a tab id refers to an agent-owned terminal. */
|
|
308
|
+
export declare function isAgentTabId(tabId: string): boolean;
|
|
309
|
+
/** Extract the agent terminal uuid from an `agent:<uuid>` tab id. */
|
|
310
|
+
export declare function agentUuidOf(tabId: string): string;
|
|
311
|
+
/** Build the sidebar tab id for one agent terminal uuid. */
|
|
312
|
+
export declare function agentTabId(uuid: string): string;
|
|
313
|
+
/**
|
|
314
|
+
* Reconcile the sidebar's agent-terminal tabs with the host's live list.
|
|
315
|
+
* The host pushes the current list of agent terminals (created by the model
|
|
316
|
+
* through the `terminal_create` tool) over a dedicated WebSocket; this
|
|
317
|
+
* reducer mirrors that list into tabs: new uuids get a tab, vanished uuids
|
|
318
|
+
* lose theirs. The agent owns the lifetime — the user closing a tab sends a
|
|
319
|
+
* WS close frame that kills the pty, which fires a change, which converges
|
|
320
|
+
* the view. Idempotent: a no-op when the lists already match.
|
|
321
|
+
* @param state - the current per-session sidebar state.
|
|
322
|
+
* @param agentTerminals - the live agent terminal snapshots from the host.
|
|
323
|
+
* @returns the next state (or the same reference if no change was needed).
|
|
324
|
+
*/
|
|
325
|
+
export declare function reconcileAgentTerminals(state: SidebarState, agentTerminals: ReadonlyArray<{
|
|
326
|
+
uuid: string;
|
|
327
|
+
title: string;
|
|
328
|
+
}>): SidebarState;
|
|
329
|
+
/** Immutable snapshot handed to React (replaced only on real changes). */
|
|
330
|
+
export interface SidebarSnapshot {
|
|
331
|
+
sessionId: string | undefined;
|
|
332
|
+
state: SidebarState | undefined;
|
|
333
|
+
/**
|
|
334
|
+
* The current side card prefs. Carried IN the snapshot (not a separate
|
|
335
|
+
* subscription) so prefs changes re-render the consumers that gate on
|
|
336
|
+
* them — the + menu hides a tab type the moment its switch flips.
|
|
337
|
+
*/
|
|
338
|
+
prefs: SidebarPrefs;
|
|
339
|
+
}
|
|
340
|
+
/** Default panel width for one viewport: the prefs percent of the window,
|
|
341
|
+
* clamped to the panel floor (a tiny percent must stay usable) and to the
|
|
342
|
+
* viewport (a large one must never cover the whole window). */
|
|
343
|
+
export declare function defaultWidthFor(viewport: number, percent: number): number;
|
|
344
|
+
/**
|
|
345
|
+
* Structural validation of one persisted state. A malformed or stale shape
|
|
346
|
+
* (older layouts, hand-edited storage) must fall back to the default instead
|
|
347
|
+
* of crashing the panel on every reload; the restored width is also clamped
|
|
348
|
+
* to the current viewport so a stale fullscreen width can never crush the
|
|
349
|
+
* app shell (margin-right larger than the window) or cover the whole screen.
|
|
350
|
+
* @returns a clean state, or undefined to fall back to the default.
|
|
351
|
+
*/
|
|
352
|
+
export declare function sanitizeState(parsed: unknown): SidebarState | undefined;
|
|
353
|
+
/** The session-scoped store: one state per conversation, localStorage-backed. */
|
|
354
|
+
export declare class SidebarStore {
|
|
355
|
+
private readonly bySession;
|
|
356
|
+
private snapshot;
|
|
357
|
+
private readonly listeners;
|
|
358
|
+
/** Per-session persist debounce timers (v0.12.0+: one per session, so a
|
|
359
|
+
* targeted open never cancels another session's pending write). */
|
|
360
|
+
private readonly persistTimers;
|
|
361
|
+
/** User-facing side card prefs seeding brand-new session states (defaults until the settings RPC resolves). */
|
|
362
|
+
private prefs;
|
|
363
|
+
/**
|
|
364
|
+
* External disable (the dsh-web-ui family's aionui-panel provider choice):
|
|
365
|
+
* while true the sidebar must not mount at all. Not part of the snapshot —
|
|
366
|
+
* nothing renders on it; the mount gate and the intercept predicates read
|
|
367
|
+
* it directly.
|
|
368
|
+
*/
|
|
369
|
+
private suspended;
|
|
370
|
+
/**
|
|
371
|
+
* Set the external-disable flag (from the settings route) and remember it
|
|
372
|
+
* for the mount gate and the intercept predicates.
|
|
373
|
+
*/
|
|
374
|
+
setSuspended(suspended: boolean): void;
|
|
375
|
+
/** Whether the sidebar is externally disabled (aionui-panel chosen). */
|
|
376
|
+
getSuspended(): boolean;
|
|
377
|
+
/**
|
|
378
|
+
* Replace the side card prefs (the settings RPC result / settings page
|
|
379
|
+
* write). Notifies like any store change: the snapshot carries the prefs,
|
|
380
|
+
* so consumers that gate on enable switches (the + menu, derived flows)
|
|
381
|
+
* re-render with the new values immediately.
|
|
382
|
+
*/
|
|
383
|
+
setPrefs(prefs: SidebarPrefs): void;
|
|
384
|
+
/** The current side card prefs (seeds new sessions; persisted states win). */
|
|
385
|
+
getPrefs(): SidebarPrefs;
|
|
386
|
+
/** Select a session (or none); loads its persisted state. */
|
|
387
|
+
setSession(sessionId: string | undefined): void;
|
|
388
|
+
subscribe(listener: () => void): () => void;
|
|
389
|
+
getSnapshot(): SidebarSnapshot;
|
|
390
|
+
/** Mutate the current session's state (no-op without a session). */
|
|
391
|
+
update(mutator: (draft: SidebarState) => void): void;
|
|
392
|
+
/**
|
|
393
|
+
* Whether a tab still exists in its session's state. Views use this on
|
|
394
|
+
* unmount to tell "the tab was closed" (release the terminal now) from
|
|
395
|
+
* "the tree re-rendered / the conversation switched" (the tab is still
|
|
396
|
+
* open — keep the terminal alive through the host's reconnect grace).
|
|
397
|
+
* Checks the session's own map entry (the current snapshot may already
|
|
398
|
+
* point at another session when a conversation switch unmounts the old
|
|
399
|
+
* one's tabs).
|
|
400
|
+
*/
|
|
401
|
+
tabOpen(sessionId: string, tabId: string): boolean;
|
|
402
|
+
/**
|
|
403
|
+
* Read-only view of EVERY cached session's state (v0.17.0+). The
|
|
404
|
+
* PinnedRail uses this to collect pinned terminals across sessions
|
|
405
|
+
* without each render reading private fields. The map is the live
|
|
406
|
+
* `bySession` reference — callers MUST treat it as read-only (mutations
|
|
407
|
+
* go through {@link reduce} / {@link reduceFor}). A session that has
|
|
408
|
+
* never been visited in this run is absent (its pinned tabs are not
|
|
409
|
+
* visible until first load — accepted as YAGNI by the design).
|
|
410
|
+
*/
|
|
411
|
+
getSessionStates(): ReadonlyMap<string, SidebarState>;
|
|
412
|
+
/** Apply a pure reducer (returns the next state). */
|
|
413
|
+
reduce(reducer: (state: SidebarState) => SidebarState): void;
|
|
414
|
+
/**
|
|
415
|
+
* Apply a pure reducer to a TARGET session's state (not the active one),
|
|
416
|
+
* loading it on demand and persisting the result — WITHOUT switching the
|
|
417
|
+
* active snapshot or notifying (the UI must not follow along). Used by the
|
|
418
|
+
* service's targeted `openTab(seed, scope)`: the open lands in the target
|
|
419
|
+
* session's layout and is visible whenever the user switches to it.
|
|
420
|
+
*/
|
|
421
|
+
reduceFor(sessionId: string, reducer: (state: SidebarState) => SidebarState): void;
|
|
422
|
+
private schedulePersist;
|
|
423
|
+
private notify;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Create one sidebar store instance. Production code calls this only from
|
|
427
|
+
* the client plugin's `apply` (the instance is handed to components as a
|
|
428
|
+
* prop); tests call it directly. No module-level singleton: the store's
|
|
429
|
+
* lifetime belongs to the plugin activation, exactly like the official
|
|
430
|
+
* `createXXXStore()` factory rule.
|
|
431
|
+
*/
|
|
432
|
+
export declare function createSidebarStore(): SidebarStore;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure subagent-membership helpers over the sessions list feed (structural
|
|
3
|
+
* mirror world — no runtime imports). Used by the sidebar's auto-activation
|
|
4
|
+
* effect and the Subagent page:
|
|
5
|
+
*
|
|
6
|
+
* - {@link directSubagentCount}: direct durable children of one session,
|
|
7
|
+
* - {@link detectNewDirectSubagent}: the 0 → N transition that means "a new
|
|
8
|
+
* subagent just spawned under the current session" (the auto-open trigger),
|
|
9
|
+
* - {@link countSubagentDescendants}: uninterrupted subagent-origin lineage
|
|
10
|
+
* totals (mirror of the official `indexSubagentDescendants` over the
|
|
11
|
+
* plugin's own summary rows).
|
|
12
|
+
*/
|
|
13
|
+
import type { SidebarSessionList, SidebarSessionSummary, SidebarSubagentCatalog } from '../context-types.ts';
|
|
14
|
+
/**
|
|
15
|
+
* Side Chat threads ride the subagent origin (main-list hiding + the RPC
|
|
16
|
+
* ownership fence) but they are NOT subagent topology: they carry the
|
|
17
|
+
* durable 'Side: ' label and live as sidebar tabs. Excluding them here
|
|
18
|
+
* keeps the auto-open trigger and the Subagent page counts clean.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isSideThreadSummary(summary: SidebarSessionSummary): boolean;
|
|
21
|
+
/** Count the direct subagent children of one session (durable `origin` rows). */
|
|
22
|
+
export declare function directSubagentCount(byId: SidebarSessionList['byId'], sessionId: string): number;
|
|
23
|
+
/**
|
|
24
|
+
* The main agent of the current session's tree: walk the durable parent
|
|
25
|
+
* chain upward until the first non-subagent session. The Subagent page shows
|
|
26
|
+
* THIS root's full topology regardless of how deep the current selection is
|
|
27
|
+
* (a session whose row is still hydrating, or a broken chain, degrades to
|
|
28
|
+
* the session itself).
|
|
29
|
+
*/
|
|
30
|
+
export declare function rootAncestor(byId: SidebarSessionList['byId'], sessionId: string | undefined): string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Collect every catalog branch (an entry with `hasChildren`) reachable from
|
|
33
|
+
* the root — the set of catalogs the always-expanded topology consumes.
|
|
34
|
+
* Cycles fail soft.
|
|
35
|
+
*/
|
|
36
|
+
export declare function collectBranchIds(catalogs: Readonly<Record<string, SidebarSubagentCatalog>>, rootId: string | undefined): string[];
|
|
37
|
+
/**
|
|
38
|
+
* Whether a new direct subagent appeared under `sessionId` between two
|
|
39
|
+
* consecutive list snapshots (the count crossed 0 → >0). Switching to a
|
|
40
|
+
* session that already has subagents yields `false` (its baseline starts at
|
|
41
|
+
* the current count), so the auto-open never fights an existing layout.
|
|
42
|
+
*/
|
|
43
|
+
export declare function detectNewDirectSubagent(prev: SidebarSessionList, next: SidebarSessionList, sessionId: string): boolean;
|
|
44
|
+
/** Descendant totals of one session through an uninterrupted subagent-origin chain. */
|
|
45
|
+
export interface SubagentDescendantTotals {
|
|
46
|
+
count: number;
|
|
47
|
+
runningCount: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Index every subagent descendant under each ancestor it reaches through an
|
|
51
|
+
* uninterrupted subagent-origin chain (same semantics as the official
|
|
52
|
+
* `indexSubagentDescendants`; cycles fail soft).
|
|
53
|
+
*/
|
|
54
|
+
export declare function countSubagentDescendants(byId: SidebarSessionList['byId'], sessionId: string): SubagentDescendantTotals;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure derivations for the Subagent page's background-job section. Kept
|
|
3
|
+
* framework-free so the node test environment can unit-test them: the job
|
|
4
|
+
* rows arrive through the harness `session/jobs` push mirror
|
|
5
|
+
* (`jobsBySession` in the sessions list feed) — nothing here issues
|
|
6
|
+
* requests, and the row ordering / status mapping mirror the official
|
|
7
|
+
* ui-jobs header list.
|
|
8
|
+
*/
|
|
9
|
+
import type { SidebarSessionList, SidebarJobStatus, SidebarJobView } from '../context-types.ts';
|
|
10
|
+
import type { CopyKey } from './locales.ts';
|
|
11
|
+
/** One row of the jobs section: the job plus its owning session's title. */
|
|
12
|
+
export interface TreeJob {
|
|
13
|
+
ownerSessionId: string;
|
|
14
|
+
ownerTitle: string;
|
|
15
|
+
job: SidebarJobView;
|
|
16
|
+
}
|
|
17
|
+
/** Whether the registry still holds the job open (its duration ticks). */
|
|
18
|
+
export declare function isJobLive(job: SidebarJobView): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Every session id of the topology tree rooted at `rootId` (the root plus
|
|
21
|
+
* each session whose uninterrupted subagent-origin chain reaches it — same
|
|
22
|
+
* lineage semantics as {@link countSubagentDescendants}; cycles fail soft).
|
|
23
|
+
* Sessions outside the tree (orphans, other trees) are excluded, so the
|
|
24
|
+
* jobs section never shows foreign work.
|
|
25
|
+
*/
|
|
26
|
+
export declare function treeSessionIds(byId: SidebarSessionList['byId'], rootId: string | undefined): Set<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Whether a NEW background job appeared for one session between two
|
|
29
|
+
* consecutive list snapshots (a job id the previous snapshot lacked).
|
|
30
|
+
* Unlike the subagent auto-open (0 → N only), ANY new job id triggers: the
|
|
31
|
+
* agent may start several jobs over a session, and each new one should
|
|
32
|
+
* surface the Jobs page (a fresh page load never triggers — its baseline
|
|
33
|
+
* starts at the current snapshot).
|
|
34
|
+
*/
|
|
35
|
+
export declare function detectNewJob(prev: SidebarSessionList, next: SidebarSessionList, sessionId: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Collect the background jobs of the whole current tree, owner-labeled.
|
|
38
|
+
* Sessions without a mirror entry contribute nothing; an absent mirror
|
|
39
|
+
* (runtime older than the jobs feed) yields an empty list.
|
|
40
|
+
*/
|
|
41
|
+
export declare function collectTreeJobs(byId: SidebarSessionList['byId'], jobsBySession: Readonly<Record<string, readonly SidebarJobView[]>> | undefined, rootId: string | undefined): TreeJob[];
|
|
42
|
+
/**
|
|
43
|
+
* Live rows first in start order, then settled rows newest-first (mirror of
|
|
44
|
+
* the official ui-jobs ordering); a tie falls back to start order so the
|
|
45
|
+
* sort never depends on the host's map iteration.
|
|
46
|
+
*/
|
|
47
|
+
export declare function orderJobs(rows: readonly TreeJob[]): TreeJob[];
|
|
48
|
+
/** The sidebar's StateDot states for the five wire statuses. */
|
|
49
|
+
export type JobDotState = 'ongoing' | 'warning' | 'done' | 'error';
|
|
50
|
+
/**
|
|
51
|
+
* Status marker semantics. `stopping` and `killed` share the attention
|
|
52
|
+
* color: both mean the work ended (or is ending) on request rather than on
|
|
53
|
+
* its own.
|
|
54
|
+
*/
|
|
55
|
+
export declare function jobDotState(status: SidebarJobStatus): JobDotState;
|
|
56
|
+
/** Human status word of one wire status (localized through the passed translator). */
|
|
57
|
+
export declare function jobStatusLabel(status: SidebarJobStatus, t: (key: CopyKey, params?: Record<string, string | number>) => string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Elapsed time in at most two adjacent units (mirror of the official
|
|
60
|
+
* ui-jobs duration wording). A background job that outlives an hour is
|
|
61
|
+
* already exceptional, so hours is the widest unit.
|
|
62
|
+
*/
|
|
63
|
+
export declare function formatJobDuration(elapsedMs: number, t: (key: CopyKey, params?: Record<string, string | number>) => string): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The memo comparator for one tab's content cell (TabContent in Sidebar.tsx).
|
|
3
|
+
*
|
|
4
|
+
* Kept as a pure module so the "what re-renders a tab cell" contract is unit
|
|
5
|
+
* testable: geometry/store re-renders of the Sidebar shell must NOT reconcile
|
|
6
|
+
* every mounted tab (xterm/CodeMirror/FileTree subtrees — issue #315), while
|
|
7
|
+
* locale switches (localeRevision), tab-registry updates (tabsVersion), and
|
|
8
|
+
* a tab MOVING BETWEEN PANES (paneId — onOpenDiff closes over the pane id,
|
|
9
|
+
* and moveTab reuses the SAME tab object, so only the pane id identifies the
|
|
10
|
+
* move) must re-render the cell.
|
|
11
|
+
*/
|
|
12
|
+
import type { SidebarTab } from './state.ts';
|
|
13
|
+
/** The fields whose change invalidates a tab cell's memo. Anything a cell's
|
|
14
|
+
* render (or its callbacks) depends on must be listed here. */
|
|
15
|
+
export interface TabContentMemoKey {
|
|
16
|
+
tab: SidebarTab;
|
|
17
|
+
/** The pane this tab currently lives in. onOpenDiff closes over it, and
|
|
18
|
+
* moveTab reuses the same tab object when the tab moves panes — without
|
|
19
|
+
* comparing paneId the cell would keep the source pane's callback. */
|
|
20
|
+
paneId: string;
|
|
21
|
+
sessionId: string;
|
|
22
|
+
cwd: string | undefined;
|
|
23
|
+
visible: boolean;
|
|
24
|
+
expanded: string[];
|
|
25
|
+
/** Files highlighted in the file tree (the "Show in folder" reveal). */
|
|
26
|
+
revealed: string[];
|
|
27
|
+
localeRevision: string;
|
|
28
|
+
tabsVersion: number;
|
|
29
|
+
/** When the tab is a pinned virtual tab (injected from another session),
|
|
30
|
+
* this overrides `tab.id` passed to the tab descriptor's component so
|
|
31
|
+
* TerminalView connects to the home session's PTY by the original id.
|
|
32
|
+
* Undefined for regular tabs (no override). */
|
|
33
|
+
effectiveTabId: string | undefined;
|
|
34
|
+
}
|
|
35
|
+
/** True when the cell may skip a re-render (all render-affecting fields
|
|
36
|
+
* unchanged). Callback/context identities are deliberately ignored: their
|
|
37
|
+
* captured dependencies are stable or covered by the compared fields
|
|
38
|
+
* (onReferenceFile → sessionId/cwd, onSubagentJump/onToggleDir → stable
|
|
39
|
+
* refs/closures, onOpenDiff → paneId). */
|
|
40
|
+
export declare function tabContentCompare(prev: TabContentMemoKey, next: TabContentMemoKey): boolean;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal font resolution: the user's custom font prefs (SidebarPrefs,
|
|
3
|
+
* configured under the terminal card's secondary settings) turned into the
|
|
4
|
+
* xterm options. Kept as a pure module (no DOM, no xterm) so the fallback
|
|
5
|
+
* chain and clamping are unit-testable without mounting a terminal.
|
|
6
|
+
*/
|
|
7
|
+
import { type SidebarPrefs } from '../prefs-shared.ts';
|
|
8
|
+
/** The built-in fallback stack when neither the user nor the theme sets one. */
|
|
9
|
+
export declare const DEFAULT_TERMINAL_FONT_FAMILY = "\"SF Mono\", Menlo, Consolas, \"Liberation Mono\", monospace";
|
|
10
|
+
/**
|
|
11
|
+
* Icon fonts appended to whichever base stack wins, so shell prompts that
|
|
12
|
+
* draw glyphs from the Nerd Font Private Use Areas resolve to a real glyph
|
|
13
|
+
* instead of the missing-glyph box (aka tofu).
|
|
14
|
+
*
|
|
15
|
+
* Why this is needed even though the OS "should" fall back automatically:
|
|
16
|
+
* prompt frameworks (starship, powerlevel10k, oh-my-posh) take their icons
|
|
17
|
+
* from the PUA. Chromium's implicit system fallback reliably covers the
|
|
18
|
+
* *BMP* PUA (U+E000–U+F8FF — e.g. the U+E0B0 powerline separator) but NOT
|
|
19
|
+
* the *supplementary-plane* PUA-B (U+F0000+) where Nerd Fonts v3 relocated
|
|
20
|
+
* the Material Design icon set. Naming the families explicitly makes the
|
|
21
|
+
* browser consult them per character, which covers both planes.
|
|
22
|
+
*
|
|
23
|
+
* Deliberately NOT listed: color-emoji families. Chromium routes genuine
|
|
24
|
+
* emoji code points through a dedicated emoji fallback path (which is why
|
|
25
|
+
* emoji already render), so naming them buys nothing here — while placing a
|
|
26
|
+
* color font ahead of the generic family risks capturing BMP symbols the
|
|
27
|
+
* prompt expects in monospace (U+26A0 ⚠, U+2714 ✔ …) and rendering them as
|
|
28
|
+
* wide color glyphs that break the cell grid.
|
|
29
|
+
*
|
|
30
|
+
* Ordering rationale: the symbols-only patches ship glyphs without Latin,
|
|
31
|
+
* so they can never hijack ASCII metrics — the safest first hop. The
|
|
32
|
+
* fully-patched distributions follow for users who installed one of those
|
|
33
|
+
* instead. Both the `… Mono` and proportional family names are listed
|
|
34
|
+
* because the Nerd Fonts installers register them as distinct families.
|
|
35
|
+
*
|
|
36
|
+
* These are strictly *appended*, never prepended: xterm derives its cell
|
|
37
|
+
* metrics from the first entry, so the base font must stay in front or the
|
|
38
|
+
* whole grid would be re-measured against an icon font.
|
|
39
|
+
*/
|
|
40
|
+
export declare const ICON_FONT_FALLBACKS: readonly string[];
|
|
41
|
+
/**
|
|
42
|
+
* Append {@link ICON_FONT_FALLBACKS} to a CSS font-family stack, keeping
|
|
43
|
+
* the caller's own entries and order intact.
|
|
44
|
+
*
|
|
45
|
+
* - Families already named in `stack` are not duplicated (quote-, case- and
|
|
46
|
+
* whitespace-insensitive), so a user who already lists their Nerd Font
|
|
47
|
+
* keeps their exact priority.
|
|
48
|
+
* - The icon fonts are spliced in ahead of the *first* generic family
|
|
49
|
+
* (`monospace` etc.), because a generic always resolves: anything after it
|
|
50
|
+
* would never be consulted. A stack that OPENS with a generic is the one
|
|
51
|
+
* exception: only the symbols-only patches (no Latin) may precede it — a
|
|
52
|
+
* fully-patched Nerd Font there would become xterm's measuring base font
|
|
53
|
+
* and override the user/theme family precedence, so it is placed after the
|
|
54
|
+
* generic instead.
|
|
55
|
+
* - Idempotent — re-applying to an already-topped-up stack is a no-op, which
|
|
56
|
+
* matters because `TerminalView` diffs the resolved value against the live
|
|
57
|
+
* `term.options.fontFamily` before reflowing.
|
|
58
|
+
*
|
|
59
|
+
* @param stack - a CSS font-family stack (base font first).
|
|
60
|
+
* @returns the stack with icon fallbacks merged in.
|
|
61
|
+
*/
|
|
62
|
+
export declare function withIconFontFallbacks(stack: string): string;
|
|
63
|
+
/**
|
|
64
|
+
* Resolve the xterm font options for the given prefs.
|
|
65
|
+
*
|
|
66
|
+
* The base family keeps its existing precedence — user pref > theme code
|
|
67
|
+
* font > built-in stack — and then {@link withIconFontFallbacks} tops it up
|
|
68
|
+
* so prompt icons resolve regardless of which base won.
|
|
69
|
+
*
|
|
70
|
+
* @param prefs - the current side card preferences.
|
|
71
|
+
* @param themeFontFamily - the app's theme code font (`--ds-font-family-code`
|
|
72
|
+
* token value, read live by the caller); undefined when the token is absent.
|
|
73
|
+
* @returns the `fontFamily` / `fontSize` xterm options.
|
|
74
|
+
*/
|
|
75
|
+
export declare function resolveTerminalFont(prefs: SidebarPrefs, themeFontFamily: string | undefined): {
|
|
76
|
+
fontFamily: string;
|
|
77
|
+
fontSize: number;
|
|
78
|
+
};
|