@av-pi-studio/workbench 0.0.0-stage → 0.0.117
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/README.md +157 -2
- package/dist/chunks/BinaryFallbackViewer-BN-9Yvel.js +19 -0
- package/dist/chunks/ChatPanel-CjPUJMEs.js +2493 -0
- package/dist/chunks/CodeView-6kJms_MF.js +143 -0
- package/dist/chunks/DiffView-BqDuT3CF.js +48 -0
- package/dist/chunks/FilePanel-B8IXG2bj.js +92 -0
- package/dist/chunks/HtmlViewer-DpuVFaDo.js +490 -0
- package/dist/chunks/ImageViewer-BBfyA5QN.js +27 -0
- package/dist/chunks/MarkdownFileViewer-DPFPDS7G.js +88 -0
- package/dist/chunks/ModelProvidersPanel-Dsezq7Ss.js +95 -0
- package/dist/chunks/MoleculeViewerPanel-DEEU6Zkx.js +191 -0
- package/dist/chunks/PdfViewer-BdacmAu_.js +300 -0
- package/dist/chunks/SaveFileButton-2rOu02Xx.js +33 -0
- package/dist/chunks/SettingsDialog-DO1tDhMW.js +471 -0
- package/dist/chunks/SkillsPanel-DZDia4Pw.js +833 -0
- package/dist/chunks/TerminalPanel-bphwCSyW.js +242 -0
- package/dist/chunks/TextViewer-CVGqN6yy.js +63 -0
- package/dist/chunks/VideoViewer-BkB9BoOr.js +20 -0
- package/dist/chunks/ViewersPanel-C2E9FLf7.js +50 -0
- package/dist/chunks/href-resolution-jv3tpRcp.js +25 -0
- package/dist/chunks/index-Dlz8mEKZ.js +6258 -0
- package/dist/chunks/markdown-B2OXhZ-_.js +353 -0
- package/dist/chunks/provider-auth-store-C1GaLTlw.js +34 -0
- package/dist/chunks/use-file-download-CogCqTvU.js +31 -0
- package/dist/chunks/use-file-watch-Bb_Xzbr-.js +55 -0
- package/dist/chunks/use-provider-auth-list-DTjIZycd.js +16 -0
- package/dist/features/agent-ui/AskCard.d.ts +62 -0
- package/dist/features/agent-ui/agent-ui-store.d.ts +84 -0
- package/dist/features/agent-ui/announce.d.ts +51 -0
- package/dist/features/agent-ui/ask-list.d.ts +53 -0
- package/dist/features/agent-ui/ask-placement.d.ts +47 -0
- package/dist/features/agent-ui/deadline.d.ts +27 -0
- package/dist/features/agent-ui/keyboard.d.ts +37 -0
- package/dist/features/agent-ui/notify-effect.d.ts +41 -0
- package/dist/features/agent-ui/option-layout.d.ts +24 -0
- package/dist/features/agent-ui/outcome-line.d.ts +38 -0
- package/dist/features/agent-ui/prompt-text.d.ts +24 -0
- package/dist/features/chat/Attachments.d.ts +20 -0
- package/dist/features/chat/ChatPanel.d.ts +12 -0
- package/dist/features/chat/CommandMenu.d.ts +41 -0
- package/dist/features/chat/Composer.d.ts +58 -0
- package/dist/features/chat/ForkDialog.d.ts +24 -0
- package/dist/features/chat/ModelMenu.d.ts +54 -0
- package/dist/features/chat/ThinkingMenu.d.ts +39 -0
- package/dist/features/chat/Timeline.d.ts +30 -0
- package/dist/features/chat/TurnProgressBar.d.ts +14 -0
- package/dist/features/chat/composer-busy.d.ts +22 -0
- package/dist/features/chat/composer-gate.d.ts +37 -0
- package/dist/features/chat/composer-path-drop.d.ts +75 -0
- package/dist/features/chat/fork-correlation.d.ts +39 -0
- package/dist/features/chat/fork-gate.d.ts +27 -0
- package/dist/features/chat/fork-picker-nav.d.ts +14 -0
- package/dist/features/chat/fork-result.d.ts +43 -0
- package/dist/features/chat/model-menu-sort.d.ts +30 -0
- package/dist/features/chat/onboarding-nudge.d.ts +18 -0
- package/dist/features/chat/rows/AssistantRow.d.ts +24 -0
- package/dist/features/chat/rows/CompactionRow.d.ts +16 -0
- package/dist/features/chat/rows/ErrorRow.d.ts +13 -0
- package/dist/features/chat/rows/ReasoningRow.d.ts +16 -0
- package/dist/features/chat/rows/RowShell.d.ts +37 -0
- package/dist/features/chat/rows/SystemRow.d.ts +11 -0
- package/dist/features/chat/rows/ToolCard.d.ts +30 -0
- package/dist/features/chat/rows/UserRow.d.ts +43 -0
- package/dist/features/chat/slash-commands.d.ts +81 -0
- package/dist/features/chat/thinking-level-source.d.ts +29 -0
- package/dist/features/chat/todos/TodoPanel.d.ts +11 -0
- package/dist/features/chat/todos/agent-todos-store.d.ts +35 -0
- package/dist/features/chat/todos/todo-collapse-codec.d.ts +12 -0
- package/dist/features/chat/todos/todo-panel-model.d.ts +37 -0
- package/dist/features/chat/use-bottom-anchor.d.ts +33 -0
- package/dist/features/chat/use-fork-action.d.ts +32 -0
- package/dist/features/connection/ConnectionBar.d.ts +18 -0
- package/dist/features/connection/connection-presentation.d.ts +70 -0
- package/dist/features/files/BinaryFallbackViewer.d.ts +9 -0
- package/dist/features/files/CodeView.d.ts +15 -0
- package/dist/features/files/DiffView.d.ts +18 -0
- package/dist/features/files/FileContextMenu.d.ts +13 -0
- package/dist/features/files/FileExplorer.d.ts +24 -0
- package/dist/features/files/FilePanel.d.ts +26 -0
- package/dist/features/files/HtmlViewer.d.ts +22 -0
- package/dist/features/files/ImageViewer.d.ts +8 -0
- package/dist/features/files/MarkdownFileViewer.d.ts +14 -0
- package/dist/features/files/MoleculeViewer.d.ts +60 -0
- package/dist/features/files/MoleculeViewerPanel.d.ts +9 -0
- package/dist/features/files/PdfViewer.d.ts +14 -0
- package/dist/features/files/RightSidebar.d.ts +9 -0
- package/dist/features/files/SaveFileButton.d.ts +9 -0
- package/dist/features/files/TextViewer.d.ts +23 -0
- package/dist/features/files/TreeDraftRow.d.ts +15 -0
- package/dist/features/files/TreeNode.d.ts +42 -0
- package/dist/features/files/TreeRenameRow.d.ts +19 -0
- package/dist/features/files/VideoViewer.d.ts +8 -0
- package/dist/features/files/create-entry.d.ts +23 -0
- package/dist/features/files/delete-entry.d.ts +17 -0
- package/dist/features/files/file-tree.d.ts +92 -0
- package/dist/features/files/git-status-index.d.ts +37 -0
- package/dist/features/files/html-asset-loader.d.ts +43 -0
- package/dist/features/files/html-assets.d.ts +97 -0
- package/dist/features/files/html-sandbox.d.ts +62 -0
- package/dist/features/files/molecule-reload.d.ts +20 -0
- package/dist/features/files/molecule-source.d.ts +10 -0
- package/dist/features/files/molecule-theme.d.ts +31 -0
- package/dist/features/files/move-entry.d.ts +10 -0
- package/dist/features/files/move-status.d.ts +10 -0
- package/dist/features/files/move-target.d.ts +31 -0
- package/dist/features/files/open-file-tab.d.ts +32 -0
- package/dist/features/files/pdf-layout.d.ts +28 -0
- package/dist/features/files/pdfjs-runtime.d.ts +30 -0
- package/dist/features/files/polymer-file.d.ts +33 -0
- package/dist/features/files/text-viewer-state.d.ts +53 -0
- package/dist/features/files/upload-sources.d.ts +20 -0
- package/dist/features/files/viewer-registry.d.ts +81 -0
- package/dist/features/files/write-file.d.ts +12 -0
- package/dist/features/git/ChangesPanel.d.ts +13 -0
- package/dist/features/provider-auth/LoginDialog.d.ts +21 -0
- package/dist/features/provider-auth/ModelProvidersPanel.d.ts +12 -0
- package/dist/features/provider-auth/QrCode.d.ts +26 -0
- package/dist/features/provider-auth/login-flow.d.ts +55 -0
- package/dist/features/provider-auth/provider-auth-presentation.d.ts +31 -0
- package/dist/features/provider-auth/provider-auth-store.d.ts +42 -0
- package/dist/features/sessions/SessionContextMenu.d.ts +11 -0
- package/dist/features/sessions/SessionItem.d.ts +22 -0
- package/dist/features/sessions/SessionList.d.ts +9 -0
- package/dist/features/sessions/WorkspaceContextMenu.d.ts +9 -0
- package/dist/features/sessions/WorkspaceGroupHeader.d.ts +26 -0
- package/dist/features/sessions/apply-agent-deep-link.d.ts +7 -0
- package/dist/features/sessions/open-chat-tab.d.ts +14 -0
- package/dist/features/sessions/open-workspace.d.ts +20 -0
- package/dist/features/sessions/session-actions.d.ts +18 -0
- package/dist/features/sessions/session-presentation.d.ts +47 -0
- package/dist/features/sessions/status-map.d.ts +10 -0
- package/dist/features/sessions/workspace-grouping.d.ts +30 -0
- package/dist/features/settings/SettingsDialog.d.ts +22 -0
- package/dist/features/settings/ViewersPanel.d.ts +18 -0
- package/dist/features/settings/settings-categories.d.ts +32 -0
- package/dist/features/skills/InstallSkillDialog.d.ts +21 -0
- package/dist/features/skills/SkillsPanel.d.ts +32 -0
- package/dist/features/skills/skills-presentation.d.ts +159 -0
- package/dist/features/skills/use-skills.d.ts +215 -0
- package/dist/features/terminal/TerminalPanel.d.ts +37 -0
- package/dist/features/terminal/terminal-font.d.ts +44 -0
- package/dist/features/terminal/terminal-size.d.ts +52 -0
- package/dist/features/workspace/ContextMeter.d.ts +15 -0
- package/dist/features/workspace/ContextMeterPopover.d.ts +16 -0
- package/dist/features/workspace/DropPreview.d.ts +23 -0
- package/dist/features/workspace/PaneDividers.d.ts +30 -0
- package/dist/features/workspace/StatusBar.d.ts +16 -0
- package/dist/features/workspace/TabContextMenu.d.ts +15 -0
- package/dist/features/workspace/TabPanelHost.d.ts +30 -0
- package/dist/features/workspace/TabStrip.d.ts +36 -0
- package/dist/features/workspace/compact-action.d.ts +21 -0
- package/dist/features/workspace/context-meter.d.ts +26 -0
- package/dist/features/workspace/external-drag.d.ts +99 -0
- package/dist/features/workspace/pane-dnd.d.ts +70 -0
- package/dist/features/workspace/pane-layout-view.d.ts +73 -0
- package/dist/features/workspace/pane-tree.d.ts +141 -0
- package/dist/features/workspace/panel-registry.d.ts +13 -0
- package/dist/features/workspace/reopen-client-tabs.d.ts +44 -0
- package/dist/features/workspace/restore-active-workspace.d.ts +30 -0
- package/dist/features/workspace/status-bar-format.d.ts +20 -0
- package/dist/features/workspace/tab-attention.d.ts +35 -0
- package/dist/features/workspace-picker/OpenWorkspaceDialog.d.ts +11 -0
- package/dist/fonts/CascadiaMono.woff2 +0 -0
- package/dist/fonts/CascadiaMonoNF.woff2 +0 -0
- package/dist/fonts/LICENSE-Cascadia.txt +97 -0
- package/dist/fonts.css +60 -0
- package/dist/hooks/agent-stream-events.d.ts +20 -0
- package/dist/hooks/file-text-state.d.ts +31 -0
- package/dist/hooks/file-transfer-instance.d.ts +10 -0
- package/dist/hooks/use-agent-commands.d.ts +18 -0
- package/dist/hooks/use-agent-deep-link-boot.d.ts +9 -0
- package/dist/hooks/use-agent-stream.d.ts +15 -0
- package/dist/hooks/use-agent-todos.d.ts +10 -0
- package/dist/hooks/use-checkout-status.d.ts +13 -0
- package/dist/hooks/use-connection.d.ts +27 -0
- package/dist/hooks/use-explorer-tree.d.ts +20 -0
- package/dist/hooks/use-explorer-watch.d.ts +39 -0
- package/dist/hooks/use-explorer.d.ts +21 -0
- package/dist/hooks/use-external-pane-drop.d.ts +47 -0
- package/dist/hooks/use-file-diff.d.ts +9 -0
- package/dist/hooks/use-file-download.d.ts +18 -0
- package/dist/hooks/use-file-live-refresh.d.ts +31 -0
- package/dist/hooks/use-file-read.d.ts +31 -0
- package/dist/hooks/use-file-source.d.ts +16 -0
- package/dist/hooks/use-file-text.d.ts +21 -0
- package/dist/hooks/use-file-transfer.d.ts +18 -0
- package/dist/hooks/use-file-watch.d.ts +36 -0
- package/dist/hooks/use-home-dir.d.ts +14 -0
- package/dist/hooks/use-inline-image.d.ts +37 -0
- package/dist/hooks/use-is-compacting.d.ts +9 -0
- package/dist/hooks/use-pane-drag.d.ts +40 -0
- package/dist/hooks/use-pane-layout.d.ts +40 -0
- package/dist/hooks/use-provider-auth-list.d.ts +19 -0
- package/dist/hooks/use-provider-models.d.ts +14 -0
- package/dist/hooks/use-session-restore.d.ts +44 -0
- package/dist/hooks/use-session-stats.d.ts +40 -0
- package/dist/hooks/use-shortcuts.d.ts +6 -0
- package/dist/hooks/use-terminal-exit-watch.d.ts +47 -0
- package/dist/hooks/use-terminal-restore.d.ts +38 -0
- package/dist/hooks/use-thinking-levels.d.ts +13 -0
- package/dist/hooks/use-timeline-reset-watch.d.ts +43 -0
- package/dist/hooks/use-viewer-settings.d.ts +17 -0
- package/dist/host/browser-clipboard.d.ts +9 -0
- package/dist/host/browser-connection.d.ts +13 -0
- package/dist/host/browser-files.d.ts +9 -0
- package/dist/host/browser-host.d.ts +14 -0
- package/dist/host/browser-launch.d.ts +19 -0
- package/dist/host/browser-worker-timers.d.ts +29 -0
- package/dist/host/external-link.d.ts +14 -0
- package/dist/host/index.d.ts +4 -0
- package/dist/host/install.d.ts +21 -0
- package/dist/host/types.d.ts +168 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +18 -0
- package/dist/lib/agent-deep-link.d.ts +29 -0
- package/dist/lib/connection/connection-store.d.ts +49 -0
- package/dist/lib/connection/files-changed.d.ts +41 -0
- package/dist/lib/connection/live-file-transfer.d.ts +8 -0
- package/dist/lib/connection/normalize-url.d.ts +16 -0
- package/dist/lib/connection/query-client.d.ts +3 -0
- package/dist/lib/connection/resolve-connect-target.d.ts +10 -0
- package/dist/lib/connection/resume-action.d.ts +33 -0
- package/dist/lib/connection/resume-handler.d.ts +6 -0
- package/dist/lib/connection/rpc-keys.d.ts +39 -0
- package/dist/lib/drag-guard.d.ts +39 -0
- package/dist/lib/inline-image-cache.d.ts +34 -0
- package/dist/lib/pane-layout-persistence.d.ts +74 -0
- package/dist/lib/paths.d.ts +33 -0
- package/dist/lib/protocol/events.d.ts +19 -0
- package/dist/lib/protocol/timeline-paging.d.ts +29 -0
- package/dist/lib/random-id.d.ts +16 -0
- package/dist/shell/Workbench.d.ts +6 -0
- package/dist/shell/WorkbenchBoot.d.ts +4 -0
- package/dist/shell/WorkbenchProvider.d.ts +10 -0
- package/dist/shell/WorkspaceShell.d.ts +12 -0
- package/dist/shell/context.d.ts +8 -0
- package/dist/shell/hooks.d.ts +32 -0
- package/dist/shell/regions.d.ts +17 -0
- package/dist/stores/compaction-store.d.ts +45 -0
- package/dist/stores/deep-link-store.d.ts +15 -0
- package/dist/stores/draft-store.d.ts +45 -0
- package/dist/stores/explorer-store.d.ts +63 -0
- package/dist/stores/fork-store.d.ts +69 -0
- package/dist/stores/git-store.d.ts +59 -0
- package/dist/stores/layout-store.d.ts +137 -0
- package/dist/stores/materialize.d.ts +47 -0
- package/dist/stores/session-store.d.ts +76 -0
- package/dist/stores/stats-store.d.ts +48 -0
- package/dist/stores/tab-store.d.ts +145 -0
- package/dist/stores/ui-store.d.ts +85 -0
- package/dist/styles.css +1 -0
- package/dist/timeline/FileLink.d.ts +22 -0
- package/dist/timeline/InlineImage.d.ts +16 -0
- package/dist/timeline/bottom-anchor.d.ts +77 -0
- package/dist/timeline/compaction.d.ts +12 -0
- package/dist/timeline/file-link-src.d.ts +34 -0
- package/dist/timeline/file-open-target.d.ts +19 -0
- package/dist/timeline/format-meta-time.d.ts +10 -0
- package/dist/timeline/highlight.d.ts +9 -0
- package/dist/timeline/href-resolution.d.ts +34 -0
- package/dist/timeline/image-src.d.ts +32 -0
- package/dist/timeline/inline-image-view.d.ts +34 -0
- package/dist/timeline/live-tail.d.ts +5 -0
- package/dist/timeline/markdown.d.ts +35 -0
- package/dist/timeline/mermaid-theme.d.ts +23 -0
- package/dist/timeline/reducer.d.ts +38 -0
- package/dist/timeline/row-model.d.ts +154 -0
- package/dist/timeline/streaming-split.d.ts +42 -0
- package/dist/timeline/tool-mapping.d.ts +60 -0
- package/dist/viewer-plugins/viewer-settings-store.d.ts +55 -0
- package/dist/vite/index.d.ts +36 -0
- package/dist/vite/index.js +39 -0
- package/package.json +81 -4
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Explorer store — the right-sidebar Files tab's tree-expansion state (POC `currentFilePath`
|
|
3
|
+
* global, superseded by a tree view: POC_TO_APP_PLAN_UI.md §4.7 / §3 `stores/explorer-store.ts`).
|
|
4
|
+
* File listing data itself is TanStack Query cache (see `hooks/use-explorer.ts`), NOT store
|
|
5
|
+
* state — this store only tracks *which directories are expanded*, not their contents.
|
|
6
|
+
*
|
|
7
|
+
* `expandedByRoot` remembers each workspace's expanded-path set across workspace-tab switches,
|
|
8
|
+
* keyed by that workspace's resolved root path — restored when `setRoot` is called again with the
|
|
9
|
+
* same root (in-memory only, for the lifetime of the session; not persisted to disk).
|
|
10
|
+
*/
|
|
11
|
+
interface ExplorerStoreState {
|
|
12
|
+
/** The active workspace's resolved cwd — the tree root. Rendered as the tree's own first row,
|
|
13
|
+
* a collapsible directory row with its children at depth 1 (`file-tree.ts`'s `flattenTree`);
|
|
14
|
+
* there is nothing above it to show, since the explorer is workspace-scoped, not a general
|
|
15
|
+
* filesystem browser. */
|
|
16
|
+
rootPath: string;
|
|
17
|
+
/** Absolute paths of directories currently expanded in the tree. Contains `rootPath` unless
|
|
18
|
+
* the user has collapsed the root row itself. */
|
|
19
|
+
expanded: Set<string>;
|
|
20
|
+
/** Session memory of each workspace's `expanded` set, keyed by its resolved root path. Keys
|
|
21
|
+
* are inserted dynamically as workspaces are visited this session, so a `Map` (not `Record`)
|
|
22
|
+
* is the right fit here. */
|
|
23
|
+
expandedByRoot: Map<string, Set<string>>;
|
|
24
|
+
/** Switch the tree root — called when the active workspace changes. Saves the outgoing root's
|
|
25
|
+
* `expanded` set into `expandedByRoot` and restores the incoming root's remembered set. A root
|
|
26
|
+
* never visited this session is seeded expanded; a *remembered* set is restored verbatim, so a
|
|
27
|
+
* deliberately collapsed root stays collapsed across workspace switches. */
|
|
28
|
+
setRoot(path: string): void;
|
|
29
|
+
toggle(path: string): void;
|
|
30
|
+
/** In-progress inline "new file"/"new folder" row in the tree: the directory it will be
|
|
31
|
+
* created in, and which kind. Only one draft at a time. */
|
|
32
|
+
draft: {
|
|
33
|
+
parentPath: string;
|
|
34
|
+
kind: "file" | "directory";
|
|
35
|
+
} | null;
|
|
36
|
+
/** Begin an inline draft under `parentPath`, expanding it so the draft row is visible. */
|
|
37
|
+
startDraft(parentPath: string, kind: "file" | "directory"): void;
|
|
38
|
+
cancelDraft(): void;
|
|
39
|
+
/** Absolute path of the row currently being renamed in place, or null. Only one inline editor
|
|
40
|
+
* exists at a time, so this and `draft` are never both set. */
|
|
41
|
+
renaming: string | null;
|
|
42
|
+
/** Begin renaming `path`; discards any in-progress create draft. */
|
|
43
|
+
startRename(path: string): void;
|
|
44
|
+
cancelRename(): void;
|
|
45
|
+
/** Last-clicked row (directory or file) — where "New File"/"New Folder" (header toolbar and
|
|
46
|
+
* the empty-space context menu) create their new entry: the selected directory itself, or the
|
|
47
|
+
* selected file's parent directory. `null` (nothing selected yet) falls back to `rootPath`. */
|
|
48
|
+
selected: {
|
|
49
|
+
path: string;
|
|
50
|
+
isDirectory: boolean;
|
|
51
|
+
} | null;
|
|
52
|
+
setSelected(selected: {
|
|
53
|
+
path: string;
|
|
54
|
+
isDirectory: boolean;
|
|
55
|
+
} | null): void;
|
|
56
|
+
/** Rewrite tree state after a move: any expanded path equal to `from` or nested under it
|
|
57
|
+
* becomes the same path under `to`, and `selected` follows the same rewrite. Also expands
|
|
58
|
+
* `toParent` so the moved item is visible where it landed. */
|
|
59
|
+
repathAfterMove(from: string, to: string, toParent: string): void;
|
|
60
|
+
}
|
|
61
|
+
export declare const useExplorerStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ExplorerStoreState>>;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=explorer-store.d.ts.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fork dialog state (sprint-072) — one dialog, two steps (visual spec § 07's "open question 5"
|
|
3
|
+
* decision), shared globally across every open chat pane since a fork can be triggered from any
|
|
4
|
+
* of them but only one fork dialog is ever open at a time. A dedicated store rather than folding
|
|
5
|
+
* into `ui-store.ts` (despite both holding ephemeral overlay state): this carries richer
|
|
6
|
+
* fork-domain state than `ui-store.ts`'s `{ id, x, y }` menu-target shape — the same reasoning
|
|
7
|
+
* that keeps `agent-ui-store.ts` a separate file from `ui-store.ts`.
|
|
8
|
+
*
|
|
9
|
+
* Entry points (task-002/task-003):
|
|
10
|
+
* - Row affordance, correlation matched -> `openConfirm` directly, `backTo: null` (no picker to
|
|
11
|
+
* return to — visual spec § 07: "Entry point A opens the same dialog already on step 2, with no
|
|
12
|
+
* Back control").
|
|
13
|
+
* - Row affordance, correlation failed -> `openPicker`.
|
|
14
|
+
* - Session "⋮" menu ("Fork from…") -> `openPicker` directly.
|
|
15
|
+
* - Picker row selected -> `selectFromPicker`, which swaps to the confirm step carrying
|
|
16
|
+
* `backTo: messages` so `‹ Back` (rendered only when `backTo` is non-null) returns to the exact
|
|
17
|
+
* same list without a second `forkMessages()` call.
|
|
18
|
+
*
|
|
19
|
+
* `triggerElement` (sprint-072/task-005, visual spec § 11) — the control that opened this whole
|
|
20
|
+
* flow, captured by the CALLER synchronously at click-time (never re-derived from
|
|
21
|
+
* `document.activeElement` inside this store, since `openConfirm`/`openPicker` fire from inside
|
|
22
|
+
* an async `forkMessages()` callback, by which point focus could in principle have moved).
|
|
23
|
+
* Carried unchanged through `selectFromPicker`/`backToPicker` — the picker step's own rows are
|
|
24
|
+
* destroyed the moment the dialog closes, so restoring focus to one would be meaningless; the
|
|
25
|
+
* ORIGINAL row button / "⋮" menu item is what `ForkDialog`'s `onCloseAutoFocus` restores focus to
|
|
26
|
+
* on close, falling back to that session's composer when the row no longer exists (a successful
|
|
27
|
+
* fork's own timeline reset routinely removes it before the dialog even finishes closing).
|
|
28
|
+
*/
|
|
29
|
+
import type { ForkTarget } from "../features/chat/fork-correlation.js";
|
|
30
|
+
export type ForkDialogState = {
|
|
31
|
+
status: "closed";
|
|
32
|
+
} | {
|
|
33
|
+
status: "confirm";
|
|
34
|
+
agentId: string;
|
|
35
|
+
target: ForkTarget;
|
|
36
|
+
/** True while `fork(entryId)` is in flight — both footer buttons disabled, spinner shown,
|
|
37
|
+
* outside-click/Esc inert (visual spec § 06 "in-flight"). */
|
|
38
|
+
pending: boolean;
|
|
39
|
+
/** The picker's message list to return to via `‹ Back`, or `null` when this step was
|
|
40
|
+
* reached directly (row affordance, correlation matched) and there is nothing to go back
|
|
41
|
+
* to. */
|
|
42
|
+
backTo: ForkTarget[] | null;
|
|
43
|
+
triggerElement: HTMLElement | null;
|
|
44
|
+
} | {
|
|
45
|
+
status: "picker";
|
|
46
|
+
agentId: string;
|
|
47
|
+
messages: ForkTarget[];
|
|
48
|
+
triggerElement: HTMLElement | null;
|
|
49
|
+
};
|
|
50
|
+
interface ForkStoreState {
|
|
51
|
+
dialog: ForkDialogState;
|
|
52
|
+
/** Verified single-target match — opens the confirm step directly, no `‹ Back` control.
|
|
53
|
+
* `triggerElement` is the control to restore focus to on close (captured by the caller). */
|
|
54
|
+
openConfirm(agentId: string, target: ForkTarget, triggerElement: HTMLElement | null): void;
|
|
55
|
+
/** Ordinal out of range, text mismatch, or the "Fork from…" menu item — opens the picker,
|
|
56
|
+
* never forking an unverified entry. */
|
|
57
|
+
openPicker(agentId: string, messages: ForkTarget[], triggerElement: HTMLElement | null): void;
|
|
58
|
+
/** A picker row was selected — swap to the confirm step for it, remembering the list for Back.
|
|
59
|
+
* No-op if the dialog isn't currently showing the picker. */
|
|
60
|
+
selectFromPicker(target: ForkTarget): void;
|
|
61
|
+
/** `‹ Back` from the confirm step — no-op if there's nothing to go back to (or not confirming). */
|
|
62
|
+
backToPicker(): void;
|
|
63
|
+
/** Flip the confirm step's in-flight flag. No-op outside the confirm step. */
|
|
64
|
+
setPending(pending: boolean): void;
|
|
65
|
+
close(): void;
|
|
66
|
+
}
|
|
67
|
+
export declare const useForkStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ForkStoreState>>;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=fork-store.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git store — the right-sidebar Changes tab's checkout-status projection (POC `changeList`
|
|
3
|
+
* global + `handleCheckoutStatusUpdate`, POC_TO_APP_PLAN_UI.md §4.7). `applyProjection` ports the
|
|
4
|
+
* POC mapping verbatim: staged entries key off `indexStatus`, unstaged entries key off
|
|
5
|
+
* `worktreeStatus`, untracked paths are always "added"/unstaged.
|
|
6
|
+
*
|
|
7
|
+
* Also retains the projection's branch metadata (branch/ahead/behind/detached/upstream/conflict
|
|
8
|
+
* count/availability) for the workspace status bar's git segment (sprint-042) — previously
|
|
9
|
+
* discarded here even though `use-checkout-status.ts` already receives the full projection.
|
|
10
|
+
*/
|
|
11
|
+
export interface CheckoutFileEntry {
|
|
12
|
+
path: string;
|
|
13
|
+
indexStatus: string;
|
|
14
|
+
worktreeStatus: string;
|
|
15
|
+
}
|
|
16
|
+
export interface CheckoutStatusProjection {
|
|
17
|
+
available: boolean;
|
|
18
|
+
branch: string | null;
|
|
19
|
+
upstream: string | null;
|
|
20
|
+
ahead: number;
|
|
21
|
+
behind: number;
|
|
22
|
+
detached: boolean;
|
|
23
|
+
staged: CheckoutFileEntry[];
|
|
24
|
+
unstaged: CheckoutFileEntry[];
|
|
25
|
+
untracked: string[];
|
|
26
|
+
/** Gitignored paths (server's `--ignored=traditional` `!` lines). Optional — a daemon older
|
|
27
|
+
* than this field simply omits it. Deliberately NOT folded into `changes`, which drive the
|
|
28
|
+
* Changes tab and the status bar's dirty count; only the Files tree reads this, to ghost
|
|
29
|
+
* ignored rows (`git-status-index.ts`). */
|
|
30
|
+
ignored?: string[];
|
|
31
|
+
conflicted: string[];
|
|
32
|
+
hasConflicts: boolean;
|
|
33
|
+
unavailableReason?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ChangeEntry {
|
|
36
|
+
path: string;
|
|
37
|
+
status: "added" | "deleted" | "modified";
|
|
38
|
+
staged: boolean;
|
|
39
|
+
}
|
|
40
|
+
interface GitStoreState {
|
|
41
|
+
subscribedCwd: string | null;
|
|
42
|
+
changes: ChangeEntry[];
|
|
43
|
+
available: boolean;
|
|
44
|
+
branch: string | null;
|
|
45
|
+
upstream: string | null;
|
|
46
|
+
ahead: number;
|
|
47
|
+
behind: number;
|
|
48
|
+
detached: boolean;
|
|
49
|
+
conflictCount: number;
|
|
50
|
+
/** Workspace-relative gitignored paths; a wholly ignored directory arrives as one `dir/` entry. */
|
|
51
|
+
ignored: string[];
|
|
52
|
+
setSubscribedCwd(cwd: string | null): void;
|
|
53
|
+
/** Map a `checkout_status_update` projection into flat change rows (POC `handleCheckoutStatusUpdate`)
|
|
54
|
+
* plus the branch metadata above. */
|
|
55
|
+
applyProjection(projection: CheckoutStatusProjection | null | undefined): void;
|
|
56
|
+
}
|
|
57
|
+
export declare const useGitStore: import("zustand").UseBoundStore<import("zustand").StoreApi<GitStoreState>>;
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=git-store.d.ts.map
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout store — pane structure per workspace: the pane tree, which pane holds each tab, each
|
|
3
|
+
* pane's active tab, and which pane is focused.
|
|
4
|
+
*
|
|
5
|
+
* **Division of labour with `tab-store`.** The spec requires one owner for the tab↔pane invariant,
|
|
6
|
+
* never two mutable directions that can drift:
|
|
7
|
+
*
|
|
8
|
+
* - `tab-store` remains the single owner of tab identity and *global* tab order. A pane's tab order
|
|
9
|
+
* is **derived** — the global order filtered by pane membership — so reordering within a pane
|
|
10
|
+
* stays `tab-store.reorder` and there is no second order to fall out of sync.
|
|
11
|
+
* - this store owns pane structure: `tree`, `placement` (tab id → pane id), `activeByPane`, and
|
|
12
|
+
* `focusedPaneId`, keyed by normalized workspace cwd.
|
|
13
|
+
* - the workspace-active tab is **derived** (`activeTabOf` = `activeByPane[focusedPaneId]`), never
|
|
14
|
+
* stored — a stored duplicate can drift and point at an invisible tab.
|
|
15
|
+
*
|
|
16
|
+
* Because per-pane order lives in `tab-store`, the operations that must pick a fallback active tab
|
|
17
|
+
* accept an optional `order` argument: the workspace's tab ids in global order. Callers that have it
|
|
18
|
+
* (sprint-049's `tab-store` wiring) pass it so the fallback matches the strip the user sees; without
|
|
19
|
+
* it the store falls back to `placement` insertion order, which is deterministic but not necessarily
|
|
20
|
+
* the visible order.
|
|
21
|
+
*
|
|
22
|
+
* **Restore is claim-driven.** Tabs are not persisted — they are rebuilt from daemon state on
|
|
23
|
+
* connect by two independent one-shot hooks, in no guaranteed order. So `installPersistedLayouts`
|
|
24
|
+
* installs geometry immediately and holds the persisted `placement`/`activeByPane` as *pending
|
|
25
|
+
* claims*, which `claimPaneFor` consumes as each tab arrives.
|
|
26
|
+
*
|
|
27
|
+
* The settle point (`markHydrationSource`) does more than cleanup, though: while it is still
|
|
28
|
+
* pending, `claimPaneFor` refuses to let an UNCLAIMED arrival (an orphaned terminal the daemon
|
|
29
|
+
* still has, a chat nothing persisted claimed) steal an already-occupied pane's active slot —
|
|
30
|
+
* only a claim, or a genuinely empty pane, may take one. Without that guard, two independent
|
|
31
|
+
* restore hooks racing in undefined order meant a terminal-restore arrival could silently replace
|
|
32
|
+
* a chat a claim had *just* placed a moment earlier in the same pass — restore noise overwriting a
|
|
33
|
+
* deliberate arrangement. After the settle point this restriction lifts: a live "+"/Ctrl+T open
|
|
34
|
+
* into the focused pane taking it over immediately is the correct, expected behaviour.
|
|
35
|
+
*
|
|
36
|
+
* swe/features/workspace-split-panes.md § Tab ↔ pane assignment, § Splitting,
|
|
37
|
+
* § Programmatic splits, § Moving a tab between panes, § Removing a pane / collapsing,
|
|
38
|
+
* § Restoring a persisted layout
|
|
39
|
+
*/
|
|
40
|
+
import { type PaneNode, type SplitPath, type SplitRegion } from "../features/workspace/pane-tree.js";
|
|
41
|
+
import type { ValidatedWorkspaceLayout } from "../lib/pane-layout-persistence.js";
|
|
42
|
+
export interface WorkspacePaneLayout {
|
|
43
|
+
tree: PaneNode;
|
|
44
|
+
/** tab id → pane id. The single owner of the tab↔pane invariant. */
|
|
45
|
+
placement: Record<string, string>;
|
|
46
|
+
/** pane id → that pane's active tab id. Every value is placed in its own pane. */
|
|
47
|
+
activeByPane: Record<string, string>;
|
|
48
|
+
/** Always a leaf id present in `tree`. */
|
|
49
|
+
focusedPaneId: string;
|
|
50
|
+
/** Unconsumed persisted claims: tab identity → pane id. Emptied at the settle point. */
|
|
51
|
+
pendingPlacement: Record<string, string>;
|
|
52
|
+
/** Which identity each pane wants as its active tab. Held until the settle point. */
|
|
53
|
+
pendingActive: Record<string, string>;
|
|
54
|
+
/** Panes whose active tab the user chose directly — a claim must never displace it. */
|
|
55
|
+
userActedPanes: ReadonlySet<string>;
|
|
56
|
+
}
|
|
57
|
+
/** The connect-time inventories whose arrival together means initial hydration is complete. */
|
|
58
|
+
export type HydrationSource = "sessions" | "terminals";
|
|
59
|
+
export interface LayoutStoreState {
|
|
60
|
+
/** Keyed by normalized workspace cwd (`workspace-grouping.ts#normalizeCwd`). */
|
|
61
|
+
layouts: Record<string, WorkspacePaneLayout>;
|
|
62
|
+
/** Which restore sources have reported. Hydration is complete once every one is `true`. */
|
|
63
|
+
hydrationSources: Readonly<Record<HydrationSource, boolean>>;
|
|
64
|
+
/** Whether a restore cycle is in flight — `true` from `installPersistedLayouts` until hydration
|
|
65
|
+
* settles. Distinct from `!every(hydrationSources)`, which is also true before any restore cycle
|
|
66
|
+
* has ever started (e.g. every unit test that never calls `installPersistedLayouts`); this field
|
|
67
|
+
* exists so `claimPaneFor`'s restore-time guard only restricts unclaimed arrivals during an actual
|
|
68
|
+
* restore, never ordinary live use. */
|
|
69
|
+
restoring: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* The workspace that was in view when the record was written, captured at boot and held until the
|
|
72
|
+
* settle point — `null` when nothing was persisted.
|
|
73
|
+
*
|
|
74
|
+
* Captured rather than re-read on demand: `writePaneLayout` persists `activeWorkspaceCwd` from the
|
|
75
|
+
* *current* tab-store value and writes fire throughout the restore window, so a mid-restore write
|
|
76
|
+
* can clobber the stored target before a later reader gets to it. Consumers that must agree on
|
|
77
|
+
* which workspace restore is heading for (`use-session-restore.ts`'s sidebar/explorer seeding, and
|
|
78
|
+
* `restore-active-workspace.ts`'s view switch) read this one captured value instead of racing
|
|
79
|
+
* localStorage.
|
|
80
|
+
*/
|
|
81
|
+
pendingActiveWorkspace: string | null;
|
|
82
|
+
/** Create the single-leaf default on first touch; idempotent. */
|
|
83
|
+
ensureWorkspace(cwd: string): void;
|
|
84
|
+
/**
|
|
85
|
+
* Place a tab: the explicit pane when it exists, else the focused pane, else the first leaf.
|
|
86
|
+
* Makes it that pane's active tab and focuses the pane unless `background`.
|
|
87
|
+
*/
|
|
88
|
+
assignTab(cwd: string, tabId: string, paneId?: string, background?: boolean, order?: readonly string[]): void;
|
|
89
|
+
/**
|
|
90
|
+
* Move a tab into another pane: activate it there, focus that pane, fall the source pane's active
|
|
91
|
+
* tab back to its nearest remaining sibling, and remove the source pane if it is now empty.
|
|
92
|
+
* A move into the pane the tab already occupies is a no-op — cross-pane reorder is `tab-store`'s.
|
|
93
|
+
*/
|
|
94
|
+
moveTab(cwd: string, tabId: string, targetPaneId: string, order?: readonly string[]): void;
|
|
95
|
+
/**
|
|
96
|
+
* Split `targetPaneId` and move `tabId` into the new pane. No-op when the split is illegal or the
|
|
97
|
+
* tab is the target pane's only tab — the new pane would immediately collapse, so nothing should
|
|
98
|
+
* visibly happen.
|
|
99
|
+
*/
|
|
100
|
+
splitWithTab(cwd: string, tabId: string, targetPaneId: string, region: SplitRegion, order?: readonly string[]): void;
|
|
101
|
+
/**
|
|
102
|
+
* Split only, returning the new (focused, empty) pane id, or `null` when refused. The caller opens
|
|
103
|
+
* a tab into it immediately — an empty pane cannot exist at rest.
|
|
104
|
+
*/
|
|
105
|
+
splitEmpty(cwd: string, targetPaneId: string, region: SplitRegion): string | null;
|
|
106
|
+
/** Drop a closed tab; an emptied pane collapses, except the last one or one still under claim. */
|
|
107
|
+
removeTab(cwd: string, tabId: string, order?: readonly string[]): void;
|
|
108
|
+
/** Set a pane's active tab *without* focusing it — restore needs to do exactly that. */
|
|
109
|
+
setActiveTab(cwd: string, paneId: string, tabId: string): void;
|
|
110
|
+
focusPane(cwd: string, paneId: string): void;
|
|
111
|
+
resizeDivider(cwd: string, splitPath: SplitPath, boundaryIndex: number, deltaFraction: number): void;
|
|
112
|
+
/** Install persisted geometry up front and hold its placement as pending claims, plus the
|
|
113
|
+
* workspace that was in view, as `pendingActiveWorkspace`. */
|
|
114
|
+
installPersistedLayouts(loaded: ReadonlyMap<string, ValidatedWorkspaceLayout>, activeWorkspaceCwd?: string | null): void;
|
|
115
|
+
/**
|
|
116
|
+
* Resolve the pane an arriving tab belongs in, consuming a matching claim. The single entry point
|
|
117
|
+
* for every tab open, restored or user-initiated.
|
|
118
|
+
*/
|
|
119
|
+
claimPaneFor(cwd: string, tabId: string, identity: string | null, paneId?: string): void;
|
|
120
|
+
/**
|
|
121
|
+
* Report that one restore source has finished. Once every source has, unconsumed claims are
|
|
122
|
+
* discarded and unclaimed panes are pruned from the stored tree.
|
|
123
|
+
*/
|
|
124
|
+
markHydrationSource(source: HydrationSource): void;
|
|
125
|
+
paneOfTab(cwd: string, tabId: string): string | null;
|
|
126
|
+
/** The workspace's active tab, derived from the focused pane. */
|
|
127
|
+
activeTabOf(cwd: string): string | null;
|
|
128
|
+
}
|
|
129
|
+
export declare function createPaneLayout(): WorkspacePaneLayout;
|
|
130
|
+
/**
|
|
131
|
+
* Whether `tabId` is its own pane's active tab — the per-pane visibility test panels apply, as
|
|
132
|
+
* opposed to `tab-store.activeTabId`, which names one tab per *workspace*. Pure, so it is testable
|
|
133
|
+
* without a DOM; `tab-store.useIsTabVisible` is the subscribing wrapper.
|
|
134
|
+
*/
|
|
135
|
+
export declare function isPaneActiveTab(layout: WorkspacePaneLayout | undefined, tabId: string): boolean;
|
|
136
|
+
export declare const useLayoutStore: import("zustand").UseBoundStore<import("zustand").StoreApi<LayoutStoreState>>;
|
|
137
|
+
//# sourceMappingURL=layout-store.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deferred-draft materialization + preselected default model — the client-side half of the
|
|
3
|
+
* server's deferred-spawn draft creation (`agent-service.ts` `handleCreate`/
|
|
4
|
+
* `spawnOrResumeSession`). Opening a "New chat" tab creates only a client-only `SessionEntry`
|
|
5
|
+
* (`session-store.ts` `createSession`, `agentId: null`) — nothing is persisted or spawned
|
|
6
|
+
* server-side until `tab-store.ts` `openNewChat` eagerly calls `ensureMaterialized` the moment the
|
|
7
|
+
* tab is created, which commits it into a real, restorable `AgentRecord` without spawning a `pi`
|
|
8
|
+
* process (that stays deferred to the first send). `ensureMaterialized` also resolves the default
|
|
9
|
+
* model itself when the entry doesn't have one yet, so callers never need a separate display-only
|
|
10
|
+
* lookup before materializing.
|
|
11
|
+
*/
|
|
12
|
+
import type { PiStudioClient } from "@av-pi-studio/client";
|
|
13
|
+
export interface DefaultModel {
|
|
14
|
+
model?: string;
|
|
15
|
+
modelProvider?: string;
|
|
16
|
+
/** The fresh default thinking level Pi would start a new session at (sprint-070/task-003),
|
|
17
|
+
* when the provider reports one — seeded onto the draft so a brand-new chat shows the real
|
|
18
|
+
* default, not a placeholder. */
|
|
19
|
+
thinkingLevel?: string;
|
|
20
|
+
}
|
|
21
|
+
/** Resolve the model a brand-new chat would run on with no override — settings' configured
|
|
22
|
+
* default, else the provider's built-in default — WITHOUT spawning anything. Called by
|
|
23
|
+
* `ensureMaterialized` itself when an entry has no model yet; exported separately only because
|
|
24
|
+
* cache scope (per `PiStudioClient` instance) is useful to assert on directly in tests. */
|
|
25
|
+
export declare function resolveDefaultModel(client: PiStudioClient, provider?: string): Promise<DefaultModel>;
|
|
26
|
+
/**
|
|
27
|
+
* Ensure `sessionId` has a bound `agentId`, materializing a deferred draft if it doesn't yet.
|
|
28
|
+
* Materializing means `createAgent` with NO `initialPrompt` — the server persists the record but
|
|
29
|
+
* does not spawn a provider process (`agent-service.ts` `handleCreate`'s deferred-draft branch) —
|
|
30
|
+
* carrying whatever model is CURRENTLY on the session entry (the preselected default from
|
|
31
|
+
* `resolveDefaultModel`, or an explicit `/model` pick; either way, `config.model`/
|
|
32
|
+
* `config.modelProvider` is what the server replays on first spawn, unconditionally, since
|
|
33
|
+
* neither `createSession` nor `resumeSession` consult it themselves).
|
|
34
|
+
*
|
|
35
|
+
* Idempotent: returns the already-bound `agentId` immediately, or the same in-flight promise if
|
|
36
|
+
* a materialize is already running for this session.
|
|
37
|
+
*/
|
|
38
|
+
export declare function ensureMaterialized(client: PiStudioClient, sessionId: string): Promise<string>;
|
|
39
|
+
/** Discard a chat whose conversation never started: closing its tab throws it away instead of
|
|
40
|
+
* leaving an empty persisted record behind forever. A record that's never closed persists
|
|
41
|
+
* indefinitely by design (`use-session-restore.ts` hydrates every known agent unconditionally,
|
|
42
|
+
* including an untouched draft) — this is the ONLY path that removes one short of an explicit
|
|
43
|
+
* delete. A chat with any timeline row is kept (closing the tab keeps the session, as before).
|
|
44
|
+
* Returns whether the session was removed, purely for tests — callers (`tab-store.ts`
|
|
45
|
+
* `closeTab`) treat this as fire-and-forget. */
|
|
46
|
+
export declare function discardIfEmpty(client: PiStudioClient | null, sessionId: string): Promise<boolean>;
|
|
47
|
+
//# sourceMappingURL=materialize.d.ts.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session store — replaces the POC's `sessions[]`/`activeSessionId` globals
|
|
3
|
+
* (POC_TO_APP_PLAN_UI.md §4.3). Kills the POC's `expectingAgent` race: a session only subscribes
|
|
4
|
+
* to `agent(id).timeline.subscribe` once `agentId` is bound (from the `createAgent` response),
|
|
5
|
+
* so no event can arrive before the session that owns it is known — no guessing required.
|
|
6
|
+
*/
|
|
7
|
+
import type { AgentStatus } from "@av-pi-studio/protocol";
|
|
8
|
+
import type { TimelineState } from "../timeline/reducer.js";
|
|
9
|
+
import type { AgentStreamEvent } from "@av-pi-studio/protocol";
|
|
10
|
+
export interface SessionEntry {
|
|
11
|
+
id: string;
|
|
12
|
+
agentId: string | null;
|
|
13
|
+
title: string;
|
|
14
|
+
status: AgentStatus | "idle";
|
|
15
|
+
cwd: string;
|
|
16
|
+
timeline: TimelineState;
|
|
17
|
+
/** User-turn count, for the sidebar meta line (POC: `messages.filter(role==='user').length`). */
|
|
18
|
+
userMessageCount: number;
|
|
19
|
+
/** Current model id, shown by the workspace status bar's model segment (sprint-042). Seeded
|
|
20
|
+
* from the preselected default (`materialize.ts` `resolveDefaultModel`) or create-agent config
|
|
21
|
+
* / a restored `list_agents` entry, updated live by an `agent_update({model})` broadcast, and
|
|
22
|
+
* reconciled by the periodic session-stats poll. */
|
|
23
|
+
model?: string;
|
|
24
|
+
/** The current model's own underlying LLM provider (e.g. `"anthropic"`) — travels alongside
|
|
25
|
+
* `model` so a materialized draft can pin `config.modelProvider` for first-spawn replay
|
|
26
|
+
* (`agent-service.ts` `spawnOrResumeSession`) without a second round trip to re-derive it. */
|
|
27
|
+
modelProvider?: string;
|
|
28
|
+
/** Effective thinking level (sprint-070): seeded from `list_agents`' `thinkingLevel` on
|
|
29
|
+
* restore, updated optimistically on pick and authoritatively by `agent_update`
|
|
30
|
+
* (`thinkingLevel`) broadcasts — live-wins-over-pinned, same discipline as `model`. */
|
|
31
|
+
thinkingLevel?: string;
|
|
32
|
+
}
|
|
33
|
+
interface SessionStoreState {
|
|
34
|
+
sessions: Record<string, SessionEntry>;
|
|
35
|
+
order: string[];
|
|
36
|
+
activeSessionId: string | null;
|
|
37
|
+
createSession(cwd: string): string;
|
|
38
|
+
bindAgent(sessionId: string, agentId: string): void;
|
|
39
|
+
setStatus(sessionId: string, status: AgentStatus | "idle"): void;
|
|
40
|
+
setStatusByAgentId(agentId: string, status: AgentStatus | "idle"): void;
|
|
41
|
+
setModel(sessionId: string, model: string | undefined, modelProvider?: string): void;
|
|
42
|
+
setModelByAgentId(agentId: string, model: string | undefined, modelProvider?: string): void;
|
|
43
|
+
setThinkingLevel(sessionId: string, level: string | undefined): void;
|
|
44
|
+
setThinkingLevelByAgentId(agentId: string, level: string | undefined): void;
|
|
45
|
+
setTitle(sessionId: string, title: string): void;
|
|
46
|
+
/** Applies a daemon-authoritative title broadcast (`agent_update({title})` —
|
|
47
|
+
* `use-session-restore.ts`'s listener). Supersedes the pre-sprint client-side heuristic that
|
|
48
|
+
* used to guess a title from the first assistant reply on `turn_completed`: that guess was
|
|
49
|
+
* per-client (never persisted, never seen by a second window) and often landed before the
|
|
50
|
+
* daemon's own title, producing two different labels across tabs. The daemon now always wins. */
|
|
51
|
+
setTitleByAgentId(agentId: string, title: string): void;
|
|
52
|
+
setCwd(sessionId: string, cwd: string): void;
|
|
53
|
+
applyStreamEvent(sessionId: string, event: AgentStreamEvent, timestamp?: string): void;
|
|
54
|
+
addOptimisticUserMessage(sessionId: string, clientMessageId: string, text: string, images?: Array<{
|
|
55
|
+
mimeType?: string;
|
|
56
|
+
data?: string;
|
|
57
|
+
}>, queued?: boolean): void;
|
|
58
|
+
markUserMessageFailed(sessionId: string, clientMessageId: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* Unconditionally replace a session's timeline wholesale — the fork-resync counterpart to
|
|
61
|
+
* `applyStreamEvent`'s incremental updates (sprint-072/task-001). Recomputes `userMessageCount`
|
|
62
|
+
* from the replacement rows and drops every optimistic row as a side effect of the full
|
|
63
|
+
* replace: an optimistic `UserRow` only ever exists client-side, so a fresh authoritative
|
|
64
|
+
* refetch can never reproduce one.
|
|
65
|
+
*/
|
|
66
|
+
setTimeline(sessionId: string, timeline: TimelineState): void;
|
|
67
|
+
setTimelineByAgentId(agentId: string, timeline: TimelineState): void;
|
|
68
|
+
activate(sessionId: string): void;
|
|
69
|
+
remove(sessionId: string): void;
|
|
70
|
+
/** Register a restored session (session restore on connect, §4.3 "Session restore"). */
|
|
71
|
+
hydrate(entry: SessionEntry): void;
|
|
72
|
+
findByAgentId(agentId: string): SessionEntry | undefined;
|
|
73
|
+
}
|
|
74
|
+
export declare const useSessionStore: import("zustand").UseBoundStore<import("zustand").StoreApi<SessionStoreState>>;
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=session-store.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stats store — per-session context/token/cost usage + poll-reconciled model, for the workspace
|
|
3
|
+
* status bar (sprint-042). Sourced from `agent_session_stats_request` (SDK
|
|
4
|
+
* `client.agent(id).sessionStats()`), which is pull-only: no stream event carries this data (see
|
|
5
|
+
* `use-session-stats.ts`, which polls it). Keyed by **sessionId**, not `agentId` — a fresh session
|
|
6
|
+
* has no `agentId` yet, and keying by sessionId lets switching back to a previously-visited
|
|
7
|
+
* session show its last-known stats instantly instead of a blank flash while a fresh poll runs.
|
|
8
|
+
*/
|
|
9
|
+
export interface SessionStats {
|
|
10
|
+
contextTokens?: number;
|
|
11
|
+
contextWindow?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Context usage as a **0–100** percentage — Pi's own scale (`(tokens / contextWindow) * 100`),
|
|
14
|
+
* passed through the wire's `agentContextUsageSchema.percent` untouched. Never a 0–1 fraction:
|
|
15
|
+
* `context-meter.ts` divides by 100 to get one.
|
|
16
|
+
*/
|
|
17
|
+
contextPercent?: number;
|
|
18
|
+
/**
|
|
19
|
+
* True when `contextTokens`/`contextPercent` came from a compaction's `estimatedTokensAfter`
|
|
20
|
+
* rather than a stats poll (Pi reports null usage after a compaction until the next LLM reply).
|
|
21
|
+
* Cleared by the first poll that carries real tokens.
|
|
22
|
+
*/
|
|
23
|
+
contextEstimated?: boolean;
|
|
24
|
+
totalTokens?: number;
|
|
25
|
+
inputTokens?: number;
|
|
26
|
+
outputTokens?: number;
|
|
27
|
+
cost?: number;
|
|
28
|
+
/** Poll-reconciled model id — see `agent_session_stats_response.payload.model` (sprint-042). */
|
|
29
|
+
model?: string;
|
|
30
|
+
}
|
|
31
|
+
interface StatsStoreState {
|
|
32
|
+
bySession: Record<string, SessionStats>;
|
|
33
|
+
/** Shallow-merge a partial update into one session's stats (missing keys are left untouched). */
|
|
34
|
+
setStats(sessionId: string, partial: Partial<SessionStats>): void;
|
|
35
|
+
clear(sessionId: string): void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Seed a session's context numbers from a compaction's `estimatedTokensAfter`. Pi reports null
|
|
39
|
+
* context usage after a compaction until the next LLM reply, so the estimate is the only fresh
|
|
40
|
+
* number there is; the next poll that carries real tokens replaces it (`contextEstimated: false`).
|
|
41
|
+
* Shared by the live `compaction` stream event and the compact RPC response (the fallback for
|
|
42
|
+
* daemons without `compactionEvents`) so the two can never disagree about the scale: the percent
|
|
43
|
+
* is Pi's 0–100, multiplied before dividing so round inputs stay exact.
|
|
44
|
+
*/
|
|
45
|
+
export declare function applyCompactionEstimate(sessionId: string, estimatedTokensAfter: number): void;
|
|
46
|
+
export declare const useStatsStore: import("zustand").UseBoundStore<import("zustand").StoreApi<StatsStoreState>>;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=stats-store.d.ts.map
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tab store — replaces the POC's `tabs[]`/`activeTabId` globals + `addTab`/`closeTab`/
|
|
3
|
+
* `activateTab` (POC_TO_APP_PLAN_UI.md §4.2). `TabPanelHost` keeps inactive panels mounted but
|
|
4
|
+
* hidden, so this store only tracks identity/order/label — not panel content.
|
|
5
|
+
*
|
|
6
|
+
* Tabs are scoped by workspace (§4.3/§4.7 follow-up: workspace-scoped tabs): every `Tab` carries
|
|
7
|
+
* the (already `normalizeCwd`-normalized) workspace cwd it belongs to, and `activeWorkspaceCwd`
|
|
8
|
+
* names which workspace's tabs `TabStrip`/`TabPanelHost` currently render. All tabs stay mounted
|
|
9
|
+
* regardless of workspace — same "hidden but alive" model that already preserves terminal/scroll
|
|
10
|
+
* state across in-workspace tab switches — only the visible SUBSET changes on a workspace switch.
|
|
11
|
+
*
|
|
12
|
+
* **`activeTabId` is derived, not owned.** Since sprint-049 every lifecycle mutation here goes
|
|
13
|
+
* through `layout-store`, which owns pane structure: which pane holds each tab, each pane's active
|
|
14
|
+
* tab, and which pane is focused. The workspace-active tab is that focused pane's active tab, and
|
|
15
|
+
* this store's `activeTabId` field is a cached projection of it written by `syncActiveFromLayout`
|
|
16
|
+
* alone — the dozens of `activeTabId` consumers keep working, without a second mutable truth that
|
|
17
|
+
* can drift. A per-workspace "last active tab" map used to live here; the layout store's focused
|
|
18
|
+
* pane + per-pane actives are the same information, now persisted across reloads, so it is gone.
|
|
19
|
+
*
|
|
20
|
+
* With splits, "active" and "visible" part company: a pane's active tab is visible even when
|
|
21
|
+
* another pane is focused. Panels therefore ask `useIsTabVisible`, not `=== activeTabId`.
|
|
22
|
+
*/
|
|
23
|
+
export type TabKind = "chat" | "file" | "diff" | "terminal" | "molecule";
|
|
24
|
+
export interface FileTabData {
|
|
25
|
+
path: string;
|
|
26
|
+
}
|
|
27
|
+
export interface DiffTabData {
|
|
28
|
+
path: string;
|
|
29
|
+
staged: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface ChatTabData {
|
|
32
|
+
sessionId: string;
|
|
33
|
+
}
|
|
34
|
+
export interface TerminalTabData {
|
|
35
|
+
slot: number | null;
|
|
36
|
+
/** Cwd captured at shortcut-fire time — the terminal launches here regardless of which
|
|
37
|
+
* session/workspace becomes active before its `create_terminal_request` resolves. */
|
|
38
|
+
cwd: string;
|
|
39
|
+
/** Set once a `terminals_update` broadcast shows this slot is no longer live (sprint-053/
|
|
40
|
+
* task-003, `use-terminal-exit-watch.ts`). Sticky — never cleared; there is no "restart
|
|
41
|
+
* terminal" affordance. Absent/`undefined` means still alive. */
|
|
42
|
+
exited?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** `path: null` is the empty ("+"-menu) molecule tab — molviewer's own drag-drop empty state. */
|
|
45
|
+
export interface MoleculeTabData {
|
|
46
|
+
path: string | null;
|
|
47
|
+
}
|
|
48
|
+
export type TabData = ChatTabData | FileTabData | DiffTabData | TerminalTabData | MoleculeTabData;
|
|
49
|
+
export interface Tab {
|
|
50
|
+
id: string;
|
|
51
|
+
kind: TabKind;
|
|
52
|
+
label: string;
|
|
53
|
+
closable: boolean;
|
|
54
|
+
data: TabData;
|
|
55
|
+
/** Normalized workspace cwd this tab belongs to (see `workspace-grouping.ts#normalizeCwd`) —
|
|
56
|
+
* fixed at creation time, never re-derived live from whatever session happens to be active. */
|
|
57
|
+
workspaceCwd: string;
|
|
58
|
+
}
|
|
59
|
+
interface TabStoreState {
|
|
60
|
+
tabs: Tab[];
|
|
61
|
+
/** The focused pane's active tab, projected from `layout-store` — see the module header. */
|
|
62
|
+
activeTabId: string | null;
|
|
63
|
+
/** Which workspace's tabs are currently visible in the strip/panel host. */
|
|
64
|
+
activeWorkspaceCwd: string | null;
|
|
65
|
+
/** Open a tab, or activate it if a tab with the same `id` already exists (POC `addTab`).
|
|
66
|
+
* Always brings the tab's workspace into view. `targetPaneId` places it in a specific pane
|
|
67
|
+
* (a pane's own "+" menu, or the pane a Split right/down just created); the default is the
|
|
68
|
+
* focused pane. */
|
|
69
|
+
open(tab: Tab, targetPaneId?: string): void;
|
|
70
|
+
close(id: string): void;
|
|
71
|
+
/** Activate a tab by id, bringing its workspace into view too. */
|
|
72
|
+
activate(id: string): void;
|
|
73
|
+
/** Switch the visible workspace, restoring its focused pane's active tab (or none). */
|
|
74
|
+
switchWorkspace(cwd: string): void;
|
|
75
|
+
reorder(fromId: string, toId: string): void;
|
|
76
|
+
updateLabel(id: string, label: string): void;
|
|
77
|
+
updateData(id: string, data: Partial<TabData>): void;
|
|
78
|
+
/** Close every file/diff/molecule tab whose path is `prefix` or nested under it (e.g. a
|
|
79
|
+
* directory delete closing every open tab underneath — `FileContextMenu.tsx`'s `remove()`).
|
|
80
|
+
* No-op for chat/terminal tabs, which have no filesystem path. */
|
|
81
|
+
closeByPathPrefix(prefix: string): void;
|
|
82
|
+
}
|
|
83
|
+
export declare const useTabStore: import("zustand").UseBoundStore<import("zustand").StoreApi<TabStoreState>>;
|
|
84
|
+
/**
|
|
85
|
+
* A tab's stable cross-session identity, or `null` when it has none yet. Identity — not tab id — is
|
|
86
|
+
* what `pane-layout-persistence` keys a pane assignment on, because ids are not stable across a
|
|
87
|
+
* reconnect: `openNewTerminal` mints `term-new-<n>` while `use-terminal-restore` reopens the same
|
|
88
|
+
* terminal as `term-<slot>`. Keys are kind-prefixed, so a `file` and a `molecule` tab on the same
|
|
89
|
+
* absolute path cannot collide. Identity-less tabs (a terminal awaiting its daemon slot, an empty
|
|
90
|
+
* molecule tab) are simply omitted from the record — there is nothing to restore them against.
|
|
91
|
+
*
|
|
92
|
+
* Lives here rather than in `pane-layout-persistence` because `tab-store` must call it on every
|
|
93
|
+
* open, and that module already depends on this one.
|
|
94
|
+
*/
|
|
95
|
+
export declare function tabIdentity(tab: Tab): string | null;
|
|
96
|
+
/**
|
|
97
|
+
* Whether a tab is on screen: its workspace is in view **and** it is its own pane's active tab.
|
|
98
|
+
*
|
|
99
|
+
* Not `=== activeTabId`. With splits every pane shows a tab simultaneously, so a pane's active tab
|
|
100
|
+
* is visible even while another pane is focused — panels that measure themselves or refit a terminal
|
|
101
|
+
* grid must react to this, not to workspace-wide activeness.
|
|
102
|
+
*/
|
|
103
|
+
export declare function useIsTabVisible(tabId: string): boolean;
|
|
104
|
+
/** Non-hook counterpart of `useIsTabVisible`, same visibility rule, for callers outside React
|
|
105
|
+
* (`agent-ui-store.ts`'s effect routing needs a point-in-time answer when a `set_editor_text`
|
|
106
|
+
* effect arrives — sprint-069/task-007). */
|
|
107
|
+
export declare function isTabVisible(tabId: string): boolean;
|
|
108
|
+
export declare const tabIds: {
|
|
109
|
+
chat: (sessionId: string) => string;
|
|
110
|
+
file: (path: string) => string;
|
|
111
|
+
diff: (path: string, staged: boolean) => string;
|
|
112
|
+
terminal: (slotOrToken: number | string) => string;
|
|
113
|
+
molecule: (key: string | number) => string;
|
|
114
|
+
};
|
|
115
|
+
/** Open a brand-new terminal tab against a workspace cwd (no slot yet — `TerminalPanel` creates
|
|
116
|
+
* one on mount). Shared by the `Ctrl/Cmd+T` shortcut (`use-shortcuts.ts`) and the TabStrip's "+"
|
|
117
|
+
* button so both paths mint tab ids/labels identically.
|
|
118
|
+
*
|
|
119
|
+
* `targetPaneId` places the tab in a named pane; omitted (the shortcut's case) it lands in the
|
|
120
|
+
* focused pane. Same contract on `openNewMolecule`/`openNewChat` below. */
|
|
121
|
+
export declare function openNewTerminal(workspaceCwd: string, targetPaneId?: string): void;
|
|
122
|
+
/** Open a brand-new empty molecule tab (no path — molviewer's own drag-drop empty state). Shared
|
|
123
|
+
* by the "+" menu so it mints tab ids/labels identically wherever a future shortcut adds another
|
|
124
|
+
* entry point. */
|
|
125
|
+
export declare function openNewMolecule(workspaceCwd: string, targetPaneId?: string): void;
|
|
126
|
+
/** Open a brand-new chat: creates a session against a workspace cwd and opens/focuses its chat
|
|
127
|
+
* tab. Shared by the sidebar's "+ New session" affordances (workspace context-menu item and
|
|
128
|
+
* each workspace group's trailing row), `open-workspace.ts`'s create-new path, and the
|
|
129
|
+
* TabStrip's "+" button — so every caller mints identical tab ids/labels (mirrors
|
|
130
|
+
* `openNewTerminal` above). `workspaceCwd` MUST already be normalized by the caller (same
|
|
131
|
+
* contract as `openNewTerminal`).
|
|
132
|
+
*
|
|
133
|
+
* Materializes eagerly: the tab and sidebar row appear synchronously from `createSession`/`open`
|
|
134
|
+
* above, then `ensureMaterialized` (`materialize.ts`) commits a real, persisted `AgentRecord` in
|
|
135
|
+
* the background — no spawn yet, just the record (`agent-service.ts` `handleCreate`'s
|
|
136
|
+
* deferred-draft branch) — so every "New chat" has a bound `agentId` before the user does
|
|
137
|
+
* anything. Best-effort: a failure here (or opening while disconnected, guarded by `if (client)`)
|
|
138
|
+
* is retried by `Composer.submit`'s own `ensureMaterialized` call on the first send. */
|
|
139
|
+
export declare function openNewChat(workspaceCwd: string, targetPaneId?: string): void;
|
|
140
|
+
/** Close a tab, discarding a never-used chat's draft record with it (`materialize.ts`
|
|
141
|
+
* `discardIfEmpty`). Every UI close path MUST go through this, not `useTabStore.close` directly.
|
|
142
|
+
*/
|
|
143
|
+
export declare function closeTab(tabId: string): void;
|
|
144
|
+
export {};
|
|
145
|
+
//# sourceMappingURL=tab-store.d.ts.map
|