@linxiraos/pi-tui 1.4.4 → 1.4.7
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/CHANGELOG.md +208 -207
- package/README.md +34 -34
- package/dist/types/app-keybindings.d.ts +20 -0
- package/dist/types/apps/session-picker.d.ts +5 -0
- package/dist/types/charts/chart-plan.d.ts +9 -7
- package/dist/types/chat/assistant-message.d.ts +15 -3
- package/dist/types/chat/bash-execution.d.ts +2 -0
- package/dist/types/chat/display-preferences.d.ts +2 -0
- package/dist/types/chat/extension-types.d.ts +31 -0
- package/dist/types/chat/reply-write.d.ts +48 -0
- package/dist/types/chat/table-chart.d.ts +4 -3
- package/dist/types/chat/tool-execution.d.ts +1 -2
- package/dist/types/chat/transcript-outline.d.ts +7 -0
- package/dist/types/chat/transcript-render-helpers.d.ts +2 -0
- package/dist/types/chrome/context-map.d.ts +15 -0
- package/dist/types/chrome/context-presentation.d.ts +48 -0
- package/dist/types/chrome/context-view-model.d.ts +77 -0
- package/dist/types/chrome/index.d.ts +1 -0
- package/dist/types/chrome/transcript-notice.d.ts +35 -0
- package/dist/types/chrome/transcript-status.d.ts +20 -8
- package/dist/types/components/editor.d.ts +8 -0
- package/dist/types/components/image.d.ts +20 -0
- package/dist/types/components/loader.d.ts +1 -1
- package/dist/types/components/markdown.d.ts +7 -0
- package/dist/types/native/blobs.d.ts +11 -1
- package/dist/types/native/picker.d.ts +4 -4
- package/dist/types/overlays/advisor-config.d.ts +6 -0
- package/dist/types/overlays/agent-hub-projection.d.ts +3 -1
- package/dist/types/overlays/annotation-overlay.d.ts +7 -1
- package/dist/types/overlays/annotation-types.d.ts +28 -0
- package/dist/types/overlays/ask-dialog.d.ts +12 -3
- package/dist/types/overlays/btw-history-panel.d.ts +16 -2
- package/dist/types/overlays/btw-history.d.ts +7 -0
- package/dist/types/overlays/btw-panel.d.ts +2 -0
- package/dist/types/overlays/context-viewer-format.d.ts +42 -0
- package/dist/types/overlays/context-viewer-overview.d.ts +70 -0
- package/dist/types/overlays/context-viewer.d.ts +25 -0
- package/dist/types/overlays/hook-input.d.ts +1 -0
- package/dist/types/overlays/login-dialog.d.ts +5 -1
- package/dist/types/overlays/mcp-add-wizard.d.ts +2 -0
- package/dist/types/overlays/model-browser.d.ts +10 -1
- package/dist/types/overlays/oauth-selector.d.ts +23 -0
- package/dist/types/overlays/pause-screen.d.ts +13 -3
- package/dist/types/overlays/plan-review-overlay.d.ts +2 -0
- package/dist/types/overlays/rewind-selector.d.ts +1 -1
- package/dist/types/overlays/running-subagent-badge.d.ts +7 -1
- package/dist/types/overlays/session-selector.d.ts +22 -2
- package/dist/types/prompt/composer.d.ts +43 -0
- package/dist/types/prompt/interactive-context-helpers.d.ts +10 -3
- package/dist/types/prompt/macos-spelling.d.ts +2 -2
- package/dist/types/render/extension-links.d.ts +65 -0
- package/dist/types/render/hyperlink.d.ts +38 -7
- package/dist/types/render/index.d.ts +1 -0
- package/dist/types/render/output-pane.d.ts +1 -1
- package/dist/types/render/render-utils.d.ts +7 -1
- package/dist/types/setup/scenes/glyph.d.ts +1 -1
- package/dist/types/setup/scenes/model.d.ts +1 -1
- package/dist/types/setup/scenes/outro.d.ts +5 -4
- package/dist/types/setup/scenes/sign-in.d.ts +13 -8
- package/dist/types/setup/scenes/types.d.ts +16 -1
- package/dist/types/setup/startup-splash.d.ts +1 -1
- package/dist/types/setup/wizard-overlay.d.ts +11 -7
- package/dist/types/setup/wizard.d.ts +5 -1
- package/dist/types/status-line/component.d.ts +3 -3
- package/dist/types/status-line/context-usage.d.ts +42 -35
- package/dist/types/status-line/host.d.ts +6 -2
- package/dist/types/terminal-capabilities.d.ts +7 -0
- package/dist/types/theme/symbols.d.ts +1 -1
- package/dist/types/theme/theme.d.ts +0 -23
- package/dist/types/tools/ask.d.ts +4 -0
- package/dist/types/tools/bash-interactive.d.ts +6 -0
- package/dist/types/tools/bash.d.ts +2 -0
- package/dist/types/tools/default-renderer.d.ts +6 -4
- package/dist/types/tools/edit.d.ts +3 -1
- package/dist/types/tools/fetch.d.ts +1 -0
- package/dist/types/tools/github.d.ts +3 -0
- package/dist/types/tools/grouped-file-output.d.ts +2 -0
- package/dist/types/tools/irc.d.ts +6 -0
- package/dist/types/tools/json-tree.d.ts +23 -4
- package/dist/types/tools/lsp.d.ts +2 -0
- package/dist/types/tools/mcp.d.ts +7 -6
- package/dist/types/tools/native-view.d.ts +1 -1
- package/dist/types/tools/read.d.ts +3 -0
- package/dist/types/tools/renderer.d.ts +2 -0
- package/dist/types/tools/streaming-output.d.ts +11 -0
- package/dist/types/tools/task.d.ts +9 -1
- package/dist/types/tools/url-scheme-host.d.ts +17 -0
- package/dist/types/tools/wait.d.ts +16 -2
- package/dist/types/tools/yield.d.ts +1 -1
- package/dist/types/tui.d.ts +9 -2
- package/dist/types/vim.d.ts +39 -0
- package/package.json +10 -14
- package/src/app-keybindings.d.ts +20 -0
- package/src/app-keybindings.ts +20 -0
- package/src/apps/session-picker.ts +7 -0
- package/src/charts/chart-plan.d.ts +9 -7
- package/src/charts/chart-plan.ts +20 -50
- package/src/chat/advisor-message.ts +2 -0
- package/src/chat/assistant-message.d.ts +15 -3
- package/src/chat/assistant-message.ts +137 -19
- package/src/chat/background-tan-message.ts +4 -0
- package/src/chat/bash-execution.d.ts +2 -0
- package/src/chat/bash-execution.ts +13 -1
- package/src/chat/chat-transcript-builder.ts +58 -28
- package/src/chat/compaction-summary-message.ts +2 -1
- package/src/chat/display-preferences.d.ts +2 -0
- package/src/chat/display-preferences.ts +3 -0
- package/src/chat/extension-types.d.ts +31 -0
- package/src/chat/extension-types.ts +34 -0
- package/src/chat/read-tool-group.ts +1 -2
- package/src/chat/reply-write.d.ts +48 -0
- package/src/chat/reply-write.ts +127 -0
- package/src/chat/skill-message.ts +2 -6
- package/src/chat/table-chart.d.ts +4 -3
- package/src/chat/table-chart.ts +10 -4
- package/src/chat/tool-execution.d.ts +1 -2
- package/src/chat/tool-execution.ts +20 -13
- package/src/chat/transcript-outline.d.ts +7 -0
- package/src/chat/transcript-outline.ts +27 -0
- package/src/chat/transcript-render-helpers.d.ts +2 -0
- package/src/chat/transcript-render-helpers.ts +66 -24
- package/src/chrome/context-map.ts +62 -0
- package/src/chrome/context-presentation.ts +26 -0
- package/src/chrome/context-view-model.ts +73 -0
- package/src/chrome/index.ts +1 -0
- package/src/chrome/transcript-container.ts +89 -59
- package/src/chrome/transcript-notice.d.ts +35 -0
- package/src/chrome/transcript-notice.ts +83 -0
- package/src/chrome/transcript-status.d.ts +20 -8
- package/src/chrome/transcript-status.ts +29 -29
- package/src/components/editor.d.ts +8 -0
- package/src/components/editor.ts +465 -14
- package/src/components/image.d.ts +20 -0
- package/src/components/image.ts +83 -18
- package/src/components/loader.d.ts +1 -1
- package/src/components/loader.ts +1 -1
- package/src/components/markdown.d.ts +7 -0
- package/src/components/markdown.ts +225 -13
- package/src/hotkeys-markdown.ts +2 -0
- package/src/native/backend.ts +5 -66
- package/src/native/blobs.d.ts +11 -1
- package/src/native/blobs.ts +5 -3
- package/src/native/picker.d.ts +4 -4
- package/src/native/picker.ts +4 -4
- package/src/overlays/advisor-config.ts +10 -12
- package/src/overlays/agent-hub-projection.d.ts +3 -1
- package/src/overlays/agent-hub-projection.ts +6 -5
- package/src/overlays/agent-hub.ts +51 -42
- package/src/overlays/annotation-overlay.ts +125 -37
- package/src/overlays/annotation-types.ts +24 -0
- package/src/overlays/ask-dialog.ts +125 -35
- package/src/overlays/btw-history-panel.ts +124 -12
- package/src/overlays/btw-history.ts +11 -0
- package/src/overlays/btw-panel.ts +8 -4
- package/src/overlays/context-viewer-format.ts +145 -0
- package/src/overlays/context-viewer-overview.ts +381 -0
- package/src/overlays/context-viewer.ts +728 -0
- package/src/overlays/hook-input.ts +2 -0
- package/src/overlays/hook-selector.ts +2 -2
- package/src/overlays/login-dialog.ts +31 -5
- package/src/overlays/mcp-add-wizard.ts +6 -1
- package/src/overlays/model-browser.ts +37 -0
- package/src/overlays/model-hub.ts +1 -7
- package/src/overlays/model-picker.ts +1 -10
- package/src/overlays/oauth-selector.ts +44 -6
- package/src/overlays/pause-screen.ts +166 -33
- package/src/overlays/plan-review-overlay.ts +13 -2
- package/src/overlays/rewind-selector.ts +29 -12
- package/src/overlays/running-subagent-badge.ts +12 -1
- package/src/overlays/session-selector.ts +313 -42
- package/src/overlays/settings-defs.ts +1 -0
- package/src/overlays/usage-dashboard.ts +20 -14
- package/src/prompt/composer.ts +216 -1
- package/src/prompt/custom-editor.ts +6 -1
- package/src/prompt/emoji-autocomplete.ts +0 -2
- package/src/prompt/interactive-context-helpers.ts +29 -4
- package/src/prompt/macos-spelling.ts +24 -15
- package/src/render/extension-links.d.ts +65 -0
- package/src/render/extension-links.ts +214 -0
- package/src/render/hyperlink.d.ts +38 -7
- package/src/render/hyperlink.ts +102 -23
- package/src/render/index.d.ts +1 -0
- package/src/render/index.ts +1 -0
- package/src/render/output-pane.d.ts +1 -1
- package/src/render/output-pane.ts +60 -17
- package/src/render/render-utils.d.ts +7 -1
- package/src/render/render-utils.ts +11 -2
- package/src/setup/scenes/composer.ts +2 -0
- package/src/setup/scenes/glyph.ts +3 -1
- package/src/setup/scenes/model.ts +192 -29
- package/src/setup/scenes/outro.ts +33 -15
- package/src/setup/scenes/sign-in.ts +194 -392
- package/src/setup/scenes/theme.ts +2 -0
- package/src/setup/scenes/types.ts +18 -1
- package/src/setup/startup-splash.ts +8 -7
- package/src/setup/wizard-overlay.ts +164 -35
- package/src/setup/wizard.ts +11 -2
- package/src/status-line/component.ts +10 -14
- package/src/status-line/context-usage.ts +122 -597
- package/src/status-line/host.ts +6 -2
- package/src/terminal-capabilities.d.ts +7 -0
- package/src/terminal-capabilities.ts +10 -0
- package/src/terminal.ts +24 -2
- package/src/theme/defaults.json +1 -0
- package/src/theme/loader.ts +1 -1
- package/src/theme/symbols.d.ts +1 -1
- package/src/theme/symbols.ts +16 -0
- package/src/theme/theme.d.ts +0 -23
- package/src/theme/theme.ts +2 -75
- package/src/tools/ask.d.ts +4 -0
- package/src/tools/ask.ts +4 -0
- package/src/tools/ast-grep.ts +3 -2
- package/src/tools/bash-interactive.d.ts +49 -0
- package/src/tools/bash-interactive.ts +6 -1
- package/src/tools/bash.d.ts +2 -0
- package/src/tools/bash.ts +7 -23
- package/src/tools/default-renderer.d.ts +6 -4
- package/src/tools/default-renderer.ts +9 -6
- package/src/tools/edit.d.ts +3 -1
- package/src/tools/edit.ts +8 -4
- package/src/tools/eval.ts +14 -4
- package/src/tools/fetch.d.ts +1 -0
- package/src/tools/fetch.ts +1 -0
- package/src/tools/find.ts +3 -10
- package/src/tools/github.d.ts +3 -0
- package/src/tools/github.ts +23 -3
- package/src/tools/glob.ts +4 -3
- package/src/tools/grep.ts +3 -4
- package/src/tools/grouped-file-output.d.ts +2 -0
- package/src/tools/grouped-file-output.ts +8 -2
- package/src/tools/irc.d.ts +6 -0
- package/src/tools/irc.ts +6 -0
- package/src/tools/job-widget.ts +13 -1
- package/src/tools/json-tree.d.ts +23 -4
- package/src/tools/json-tree.ts +132 -42
- package/src/tools/lsp.d.ts +2 -0
- package/src/tools/lsp.ts +36 -15
- package/src/tools/mcp.d.ts +7 -6
- package/src/tools/mcp.ts +41 -15
- package/src/tools/native-view.d.ts +1 -1
- package/src/tools/native-view.ts +3 -3
- package/src/tools/read.d.ts +3 -0
- package/src/tools/read.ts +3 -1
- package/src/tools/renderer.d.ts +2 -0
- package/src/tools/renderer.ts +2 -0
- package/src/tools/streaming-output.d.ts +11 -0
- package/src/tools/streaming-output.ts +41 -0
- package/src/tools/task.d.ts +9 -1
- package/src/tools/task.ts +59 -16
- package/src/tools/url-scheme-host.d.ts +17 -0
- package/src/tools/url-scheme-host.ts +21 -0
- package/src/tools/vibe.ts +14 -3
- package/src/tools/wait.d.ts +16 -2
- package/src/tools/wait.ts +16 -2
- package/src/tools/yield.d.ts +1 -1
- package/src/tools/yield.ts +18 -9
- package/src/tui.d.ts +9 -2
- package/src/tui.ts +102 -34
- package/src/vim.d.ts +39 -0
- package/src/vim.ts +313 -22
- package/dist/types/theme/defaults/index.d.ts +0 -10289
- package/src/theme/defaults/alabaster.json +0 -103
- package/src/theme/defaults/amethyst.json +0 -106
- package/src/theme/defaults/anthracite.json +0 -103
- package/src/theme/defaults/basalt.json +0 -101
- package/src/theme/defaults/birch.json +0 -105
- package/src/theme/defaults/dark-abyss.json +0 -101
- package/src/theme/defaults/dark-arctic.json +0 -114
- package/src/theme/defaults/dark-aurora.json +0 -105
- package/src/theme/defaults/dark-catppuccin.json +0 -117
- package/src/theme/defaults/dark-cavern.json +0 -101
- package/src/theme/defaults/dark-celestial.json +0 -116
- package/src/theme/defaults/dark-copper.json +0 -105
- package/src/theme/defaults/dark-cosmos.json +0 -100
- package/src/theme/defaults/dark-cyberpunk.json +0 -112
- package/src/theme/defaults/dark-dracula.json +0 -108
- package/src/theme/defaults/dark-eclipse.json +0 -101
- package/src/theme/defaults/dark-ember.json +0 -105
- package/src/theme/defaults/dark-equinox.json +0 -100
- package/src/theme/defaults/dark-forest.json +0 -106
- package/src/theme/defaults/dark-github.json +0 -115
- package/src/theme/defaults/dark-gruvbox.json +0 -122
- package/src/theme/defaults/dark-lavender.json +0 -105
- package/src/theme/defaults/dark-lunar.json +0 -99
- package/src/theme/defaults/dark-midnight.json +0 -105
- package/src/theme/defaults/dark-monochrome.json +0 -104
- package/src/theme/defaults/dark-monokai.json +0 -108
- package/src/theme/defaults/dark-nebula.json +0 -100
- package/src/theme/defaults/dark-neon-noir.json +0 -110
- package/src/theme/defaults/dark-nord.json +0 -108
- package/src/theme/defaults/dark-ocean.json +0 -111
- package/src/theme/defaults/dark-one.json +0 -110
- package/src/theme/defaults/dark-poimandres.json +0 -125
- package/src/theme/defaults/dark-rainforest.json +0 -101
- package/src/theme/defaults/dark-reef.json +0 -101
- package/src/theme/defaults/dark-retro.json +0 -102
- package/src/theme/defaults/dark-rose-pine.json +0 -106
- package/src/theme/defaults/dark-sakura.json +0 -105
- package/src/theme/defaults/dark-slate.json +0 -105
- package/src/theme/defaults/dark-solarized.json +0 -107
- package/src/theme/defaults/dark-solstice.json +0 -100
- package/src/theme/defaults/dark-starfall.json +0 -101
- package/src/theme/defaults/dark-sunset.json +0 -109
- package/src/theme/defaults/dark-swamp.json +0 -100
- package/src/theme/defaults/dark-synthwave.json +0 -113
- package/src/theme/defaults/dark-taiga.json +0 -101
- package/src/theme/defaults/dark-terminal.json +0 -105
- package/src/theme/defaults/dark-tokyo-night.json +0 -111
- package/src/theme/defaults/dark-tundra.json +0 -101
- package/src/theme/defaults/dark-twilight.json +0 -101
- package/src/theme/defaults/dark-volcanic.json +0 -101
- package/src/theme/defaults/graphite.json +0 -102
- package/src/theme/defaults/index.d.ts +0 -10289
- package/src/theme/defaults/index.ts +0 -203
- package/src/theme/defaults/light-arctic.json +0 -117
- package/src/theme/defaults/light-aurora-day.json +0 -101
- package/src/theme/defaults/light-canyon.json +0 -101
- package/src/theme/defaults/light-catppuccin.json +0 -116
- package/src/theme/defaults/light-cirrus.json +0 -100
- package/src/theme/defaults/light-coral.json +0 -105
- package/src/theme/defaults/light-cyberpunk.json +0 -106
- package/src/theme/defaults/light-dawn.json +0 -100
- package/src/theme/defaults/light-dunes.json +0 -101
- package/src/theme/defaults/light-eucalyptus.json +0 -105
- package/src/theme/defaults/light-forest.json +0 -110
- package/src/theme/defaults/light-frost.json +0 -105
- package/src/theme/defaults/light-github.json +0 -125
- package/src/theme/defaults/light-glacier.json +0 -101
- package/src/theme/defaults/light-gruvbox.json +0 -118
- package/src/theme/defaults/light-haze.json +0 -100
- package/src/theme/defaults/light-honeycomb.json +0 -105
- package/src/theme/defaults/light-lagoon.json +0 -101
- package/src/theme/defaults/light-lavender.json +0 -105
- package/src/theme/defaults/light-meadow.json +0 -101
- package/src/theme/defaults/light-mint.json +0 -105
- package/src/theme/defaults/light-monochrome.json +0 -111
- package/src/theme/defaults/light-ocean.json +0 -109
- package/src/theme/defaults/light-one.json +0 -109
- package/src/theme/defaults/light-opal.json +0 -101
- package/src/theme/defaults/light-orchard.json +0 -101
- package/src/theme/defaults/light-paper.json +0 -105
- package/src/theme/defaults/light-poimandres.json +0 -125
- package/src/theme/defaults/light-prism.json +0 -100
- package/src/theme/defaults/light-retro.json +0 -108
- package/src/theme/defaults/light-sand.json +0 -105
- package/src/theme/defaults/light-savanna.json +0 -101
- package/src/theme/defaults/light-solarized.json +0 -112
- package/src/theme/defaults/light-soleil.json +0 -100
- package/src/theme/defaults/light-sunset.json +0 -109
- package/src/theme/defaults/light-synthwave.json +0 -108
- package/src/theme/defaults/light-tokyo-night.json +0 -121
- package/src/theme/defaults/light-wetland.json +0 -101
- package/src/theme/defaults/light-zenith.json +0 -99
- package/src/theme/defaults/limestone.json +0 -104
- package/src/theme/defaults/mahogany.json +0 -107
- package/src/theme/defaults/marble.json +0 -103
- package/src/theme/defaults/obsidian.json +0 -101
- package/src/theme/defaults/onyx.json +0 -101
- package/src/theme/defaults/pearl.json +0 -103
- package/src/theme/defaults/porcelain.json +0 -101
- package/src/theme/defaults/quartz.json +0 -106
- package/src/theme/defaults/sandstone.json +0 -105
- package/src/theme/defaults/titanium.json +0 -100
package/src/native/picker.d.ts
CHANGED
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
* the item id and `action` with an action id (plus `value` for
|
|
17
17
|
* `scope`/`tab`/`strip`). {@link pickerEvent} folds them into one shape.
|
|
18
18
|
*/
|
|
19
|
-
import type { TspPickerAction, TspPickerItem, TspPickerProps } from "@linxiraos/pi-wire";
|
|
19
|
+
import type { TspPickerAction, TspPickerItem, TspPickerProps, TspProps } from "@linxiraos/pi-wire";
|
|
20
20
|
import type { KeyName } from "../key-hint-format";
|
|
21
21
|
import { type Keybinding } from "../keybindings";
|
|
22
22
|
import type { Input } from "../components/input";
|
|
23
23
|
import type { SelectItem, SelectList } from "../components/select-list";
|
|
24
24
|
import type { NativeChild, NativeNode, NativeUiEvent } from "./node";
|
|
25
25
|
/** The picker sheet; `preview` children fill its preview pane. */
|
|
26
|
-
export declare function picker(p:
|
|
26
|
+
export declare function picker(p: TspProps<"picker">, preview?: readonly NativeChild[]): NativeNode;
|
|
27
27
|
/**
|
|
28
28
|
* A picker's search field from the {@link Input} that edits it: the text and
|
|
29
29
|
* its caret. `null` hides the field. Memoized pickers MUST key on the caret
|
|
@@ -37,7 +37,7 @@ export declare const PICKER_KEY = "picker";
|
|
|
37
37
|
* the picker as child {@link PICKER_KEY}, which the reconciler hoists into
|
|
38
38
|
* `layer`. Route its events with `pickerEvent(event, PICKER_KEY)`.
|
|
39
39
|
*/
|
|
40
|
-
export declare function dockedPicker(p:
|
|
40
|
+
export declare function dockedPicker(p: TspProps<"picker">, preview?: readonly NativeChild[]): NativeNode;
|
|
41
41
|
/** Keycap names for one key id (`"alt+enter"` → `["alt", "enter"]`, `"escape"` → `["esc"]`). */
|
|
42
42
|
export declare function pickerKeys(key: KeyName | string): string[];
|
|
43
43
|
/** The keycaps of a keybinding's primary key, empty when unbound. */
|
|
@@ -83,7 +83,7 @@ export interface SelectPickerOptions {
|
|
|
83
83
|
readonly subtitle?: string;
|
|
84
84
|
readonly icon?: string;
|
|
85
85
|
readonly noun?: string;
|
|
86
|
-
/** Show
|
|
86
|
+
/** Show Zeta's filter text as the search field (lists that filter as you type). */
|
|
87
87
|
readonly searchable?: boolean;
|
|
88
88
|
/** Per-item extras (a thinking-level dot, a swatch mark, a budget fact). */
|
|
89
89
|
readonly decorate?: (item: SelectItem) => Partial<Omit<TspPickerItem, "id">> | undefined;
|
package/src/native/picker.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* the item id and `action` with an action id (plus `value` for
|
|
17
17
|
* `scope`/`tab`/`strip`). {@link pickerEvent} folds them into one shape.
|
|
18
18
|
*/
|
|
19
|
-
import type { TspPickerAction, TspPickerItem, TspPickerProps } from "@linxiraos/pi-wire";
|
|
19
|
+
import type { TspPickerAction, TspPickerItem, TspPickerProps, TspProps } from "@linxiraos/pi-wire";
|
|
20
20
|
import type { KeyName } from "../key-hint-format";
|
|
21
21
|
import { getKeybindings, type Keybinding } from "../keybindings";
|
|
22
22
|
import type { Input } from "../components/input";
|
|
@@ -25,7 +25,7 @@ import { col, node } from "./describe";
|
|
|
25
25
|
import type { NativeChild, NativeNode, NativeUiEvent } from "./node";
|
|
26
26
|
|
|
27
27
|
/** The picker sheet; `preview` children fill its preview pane. */
|
|
28
|
-
export function picker(p:
|
|
28
|
+
export function picker(p: TspProps<"picker">, preview?: readonly NativeChild[]): NativeNode {
|
|
29
29
|
return node("picker", p, preview);
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -46,7 +46,7 @@ export const PICKER_KEY = "picker";
|
|
|
46
46
|
* the picker as child {@link PICKER_KEY}, which the reconciler hoists into
|
|
47
47
|
* `layer`. Route its events with `pickerEvent(event, PICKER_KEY)`.
|
|
48
48
|
*/
|
|
49
|
-
export function dockedPicker(p:
|
|
49
|
+
export function dockedPicker(p: TspProps<"picker">, preview?: readonly NativeChild[]): NativeNode {
|
|
50
50
|
return col([node("picker", p, preview, PICKER_KEY)]);
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -193,7 +193,7 @@ export interface SelectPickerOptions {
|
|
|
193
193
|
readonly subtitle?: string;
|
|
194
194
|
readonly icon?: string;
|
|
195
195
|
readonly noun?: string;
|
|
196
|
-
/** Show
|
|
196
|
+
/** Show Zeta's filter text as the search field (lists that filter as you type). */
|
|
197
197
|
readonly searchable?: boolean;
|
|
198
198
|
/** Per-item extras (a thinking-level dot, a swatch mark, a budget fact). */
|
|
199
199
|
readonly decorate?: (item: SelectItem) => Partial<Omit<TspPickerItem, "id">> | undefined;
|
|
@@ -36,7 +36,6 @@ import { editorKey, editorKeys } from "../chrome/keybinding-hints";
|
|
|
36
36
|
import { HookEditorComponent } from "./hook-editor";
|
|
37
37
|
import {
|
|
38
38
|
buildBrowserItems,
|
|
39
|
-
MODEL_PICKER_COLUMNS,
|
|
40
39
|
ModelBrowser,
|
|
41
40
|
type ModelBrowserItem,
|
|
42
41
|
type ModelBrowserSource,
|
|
@@ -64,10 +63,11 @@ import { getThinkingLevelMetadata, parseThinkingLevel } from "../thinking";
|
|
|
64
63
|
|
|
65
64
|
export const ADVISOR_REVIEW_MODES = ["turn", "agent-end"] as const;
|
|
66
65
|
export const ADVISOR_SYNC_BACKLOG_MODES = ["off", "1", "3", "5", "strict"] as const;
|
|
66
|
+
export const ADVISOR_SESSION_SCOPES = ["main", "subagent", "all"] as const;
|
|
67
67
|
|
|
68
68
|
export type AdvisorReviewMode = (typeof ADVISOR_REVIEW_MODES)[number];
|
|
69
69
|
export type AdvisorSyncBacklog = (typeof ADVISOR_SYNC_BACKLOG_MODES)[number];
|
|
70
|
-
|
|
70
|
+
export type AdvisorSessionScope = (typeof ADVISOR_SESSION_SCOPES)[number];
|
|
71
71
|
/** One advisor declared in `WATCHDOG.yml`; its instructions specialize the shared baseline. */
|
|
72
72
|
export interface AdvisorConfig {
|
|
73
73
|
name: string;
|
|
@@ -83,6 +83,10 @@ export interface AdvisorConfig {
|
|
|
83
83
|
reviewMode?: AdvisorReviewMode;
|
|
84
84
|
reviewInterval?: number;
|
|
85
85
|
syncBacklog?: AdvisorSyncBacklog;
|
|
86
|
+
/** Which session kinds this advisor attaches to (`main`, `subagent`, or `all`; defaults to `all`). */
|
|
87
|
+
scope?: AdvisorSessionScope;
|
|
88
|
+
/** Whether primary assistant thinking blocks are included in updates sent to this advisor (defaults to `true`). */
|
|
89
|
+
includeReasoning?: boolean;
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
/** Which level a `WATCHDOG.yml` lives at: the project root or the user agent dir. */
|
|
@@ -744,16 +748,8 @@ export class AdvisorConfigOverlayComponent implements Component {
|
|
|
744
748
|
size: "md",
|
|
745
749
|
layout: "rows",
|
|
746
750
|
preview: "below",
|
|
747
|
-
query: browser.query,
|
|
748
|
-
cursor: browser.cursor,
|
|
749
751
|
placeholder: "Search models…",
|
|
750
|
-
|
|
751
|
-
...catalogue,
|
|
752
|
-
order: order.order,
|
|
753
|
-
...(order.hits ? { hits: order.hits } : {}),
|
|
754
|
-
selected: browser.pickerSelected,
|
|
755
|
-
...(this.#modelCurrent ? { current: [this.#modelCurrent] } : {}),
|
|
756
|
-
total: browser.baseCount,
|
|
752
|
+
...browser.pickerRows(catalogue, order, this.#modelCurrent),
|
|
757
753
|
empty: "No models available",
|
|
758
754
|
actions: [
|
|
759
755
|
pickerAction("use", "Use for advisor", "enter", { primary: true }),
|
|
@@ -1202,7 +1198,9 @@ export class AdvisorConfigOverlayComponent implements Component {
|
|
|
1202
1198
|
advisor.syncBacklog === undefined &&
|
|
1203
1199
|
!advisor.instructions?.trim() &&
|
|
1204
1200
|
advisor.enabled !== false &&
|
|
1205
|
-
advisor.maxNotesPerUpdate === undefined
|
|
1201
|
+
advisor.maxNotesPerUpdate === undefined &&
|
|
1202
|
+
advisor.scope === undefined &&
|
|
1203
|
+
advisor.includeReasoning === undefined
|
|
1206
1204
|
);
|
|
1207
1205
|
}
|
|
1208
1206
|
|
|
@@ -44,5 +44,7 @@ export declare function aggregateMetrics<TRecord extends AgentRecordLike>(args:
|
|
|
44
44
|
hasFallbackLiveSessions: boolean;
|
|
45
45
|
};
|
|
46
46
|
/** Parent-before-child projection preserving initial subtree rank and prepending new siblings. */
|
|
47
|
-
export declare function projectAgentTree<TRecord extends AgentRecordLike>(refs: readonly TRecord[],
|
|
47
|
+
export declare function projectAgentTree<TRecord extends AgentRecordLike>(refs: readonly TRecord[],
|
|
48
|
+
/** Rows spawned while the hub is open; such a child never lifts its parent's group. */
|
|
49
|
+
spawnedWhileOpen?: (ref: TRecord) => boolean): AgentTreeProjection<TRecord>;
|
|
48
50
|
export {};
|
|
@@ -342,7 +342,8 @@ export function aggregateMetrics<TRecord extends AgentRecordLike>(args: {
|
|
|
342
342
|
/** Parent-before-child projection preserving initial subtree rank and prepending new siblings. */
|
|
343
343
|
export function projectAgentTree<TRecord extends AgentRecordLike>(
|
|
344
344
|
refs: readonly TRecord[],
|
|
345
|
-
|
|
345
|
+
/** Rows spawned while the hub is open; such a child never lifts its parent's group. */
|
|
346
|
+
spawnedWhileOpen?: (ref: TRecord) => boolean,
|
|
346
347
|
): AgentTreeProjection<TRecord> {
|
|
347
348
|
const ids = new Set<string>();
|
|
348
349
|
const operationalIndex = new Map<string, number>();
|
|
@@ -374,13 +375,13 @@ export function projectAgentTree<TRecord extends AgentRecordLike>(
|
|
|
374
375
|
const current = stack.pop();
|
|
375
376
|
if (!current) continue;
|
|
376
377
|
if (current.expanded) {
|
|
377
|
-
|
|
378
|
-
|
|
378
|
+
const own = operationalIndex.get(current.ref.id) ?? Number.MAX_SAFE_INTEGER;
|
|
379
|
+
let order = own;
|
|
379
380
|
for (const child of children.get(current.ref.id) ?? []) {
|
|
380
|
-
const childRank = rosterRank?.get(child);
|
|
381
381
|
// A child spawned later cannot move an existing parent's group.
|
|
382
|
-
if (
|
|
382
|
+
if (spawnedWhileOpen?.(child) && (operationalIndex.get(child.id) ?? Number.MAX_SAFE_INTEGER) < own) {
|
|
383
383
|
continue;
|
|
384
|
+
}
|
|
384
385
|
order = Math.min(order, subtreeOrder.get(child.id) ?? Number.MAX_SAFE_INTEGER);
|
|
385
386
|
}
|
|
386
387
|
subtreeOrder.set(current.ref.id, order);
|
|
@@ -200,9 +200,18 @@ const DATA_CHANGE_RENDER_COALESCE_MS = 100;
|
|
|
200
200
|
/** Double-tap window for the table's left-left "close hub" gesture. */
|
|
201
201
|
const LEFT_TAP_WINDOW_MS = 500;
|
|
202
202
|
|
|
203
|
-
|
|
203
|
+
/** A row's rank, frozen when the hub first saw its generation: the batch it came in, and its status and recency then. */
|
|
204
|
+
interface FrozenRank extends Pick<AgentRecordLike, "id" | "status" | "lastActivity"> {
|
|
205
|
+
/** 0 for the agents the hub opened with or the saved-agent scan found; each later batch of new generations is one lower. */
|
|
206
|
+
batch: number;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function compareFrozenRanks(a: FrozenRank, b: FrozenRank): number {
|
|
204
210
|
return (
|
|
205
|
-
|
|
211
|
+
a.batch - b.batch ||
|
|
212
|
+
STATUS_ORDER[a.status] - STATUS_ORDER[b.status] ||
|
|
213
|
+
b.lastActivity - a.lastActivity ||
|
|
214
|
+
a.id.localeCompare(b.id)
|
|
206
215
|
);
|
|
207
216
|
}
|
|
208
217
|
|
|
@@ -364,10 +373,17 @@ export class AgentHubOverlayComponent<TRecord extends AgentRecordLike = AgentRec
|
|
|
364
373
|
#rows: TRecord[] = [];
|
|
365
374
|
#statusCounts: Record<AgentStatus, number> = { running: 0, idle: 0, parked: 0, aborted: 0 };
|
|
366
375
|
#selectedRow = 0;
|
|
367
|
-
/**
|
|
368
|
-
*
|
|
369
|
-
|
|
370
|
-
|
|
376
|
+
/**
|
|
377
|
+
* Each row keeps the rank it got when the hub first saw its generation, so
|
|
378
|
+
* heartbeats and status changes do not move rows. An agent the saved-agent
|
|
379
|
+
* scan finds takes its place in the status/recency order; every other new
|
|
380
|
+
* generation goes on top.
|
|
381
|
+
*/
|
|
382
|
+
#frozenRank = new Map<TRecord, FrozenRank>();
|
|
383
|
+
/** Every id ranked so far: a new object under a known id is a new generation, not a saved agent. */
|
|
384
|
+
#seenIds = new Set<string>();
|
|
385
|
+
#opened = false;
|
|
386
|
+
#spawnBatches = 0;
|
|
371
387
|
#hoveredRow: number | null = null;
|
|
372
388
|
/** Per-render screen-line to agent-row map, shared by click and hover routing. */
|
|
373
389
|
#hitRows: Array<number | undefined> = [];
|
|
@@ -519,13 +535,11 @@ export class AgentHubOverlayComponent<TRecord extends AgentRecordLike = AgentRec
|
|
|
519
535
|
logger.warn("Failed to register persisted subagents", { error });
|
|
520
536
|
})
|
|
521
537
|
.finally(() => {
|
|
522
|
-
|
|
523
|
-
//
|
|
538
|
+
if (this.#disposed) return;
|
|
539
|
+
// Rank what the scan found before its end turns later arrivals into spawns.
|
|
540
|
+
this.#refreshRows();
|
|
524
541
|
this.#loadingPersistedSubagents = false;
|
|
525
|
-
|
|
526
|
-
this.#refreshRows();
|
|
527
|
-
this.#requestRender();
|
|
528
|
-
}
|
|
542
|
+
this.#requestRender();
|
|
529
543
|
});
|
|
530
544
|
this.#refreshRows();
|
|
531
545
|
}
|
|
@@ -1532,41 +1546,36 @@ export class AgentHubOverlayComponent<TRecord extends AgentRecordLike = AgentRec
|
|
|
1532
1546
|
this.#requestRender();
|
|
1533
1547
|
}
|
|
1534
1548
|
|
|
1549
|
+
/** A parked or killed agent with no live session and an unknown id, seen while the saved-agent scan runs, is one the scan found. */
|
|
1550
|
+
#foundOnDisk(ref: TRecord): boolean {
|
|
1551
|
+
return (
|
|
1552
|
+
this.#loadingPersistedSubagents &&
|
|
1553
|
+
ref.session === null &&
|
|
1554
|
+
(ref.status === "parked" || ref.status === "aborted") &&
|
|
1555
|
+
!this.#seenIds.has(ref.id)
|
|
1556
|
+
);
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1535
1559
|
#refreshRows(): void {
|
|
1536
1560
|
const selectedId = this.#rows[this.#selectedRow]?.id;
|
|
1537
1561
|
const refs = this.#registry.list().filter(ref => ref.id !== MAIN_AGENT_ID);
|
|
1538
1562
|
this.#observedById = new Map();
|
|
1539
1563
|
for (const session of this.#observers.getSessions()) this.#observedById.set(session.id, session);
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
const
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
} else {
|
|
1553
|
-
for (const rankedRef of rowOrder.keys()) {
|
|
1554
|
-
if (!refs.includes(rankedRef)) rowOrder.delete(rankedRef);
|
|
1555
|
-
}
|
|
1556
|
-
// Each batch of newly appearing generations uses the initial sort,
|
|
1557
|
-
// then takes ranks above every agent already on screen.
|
|
1558
|
-
let newcomers: TRecord[] | undefined;
|
|
1559
|
-
for (const ref of refs) {
|
|
1560
|
-
if (!rowOrder.has(ref)) (newcomers ??= []).push(ref);
|
|
1561
|
-
}
|
|
1562
|
-
if (newcomers) {
|
|
1563
|
-
newcomers.sort(compareRosterAgents);
|
|
1564
|
-
for (let i = newcomers.length - 1; i >= 0; i--) {
|
|
1565
|
-
rowOrder.set(newcomers[i]!, --this.#nextNewRowOrder);
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
ordered = refs.sort((a, b) => rowOrder.get(a)! - rowOrder.get(b)!);
|
|
1564
|
+
const live = new Set(refs);
|
|
1565
|
+
for (const ref of this.#frozenRank.keys()) if (!live.has(ref)) this.#frozenRank.delete(ref);
|
|
1566
|
+
let spawnBatch: number | undefined;
|
|
1567
|
+
for (const ref of refs) {
|
|
1568
|
+
if (this.#frozenRank.has(ref)) continue;
|
|
1569
|
+
this.#frozenRank.set(ref, {
|
|
1570
|
+
batch: this.#opened && !this.#foundOnDisk(ref) ? (spawnBatch ??= --this.#spawnBatches) : 0,
|
|
1571
|
+
id: ref.id,
|
|
1572
|
+
status: ref.status,
|
|
1573
|
+
lastActivity: ref.lastActivity,
|
|
1574
|
+
});
|
|
1575
|
+
this.#seenIds.add(ref.id);
|
|
1569
1576
|
}
|
|
1577
|
+
this.#opened = true;
|
|
1578
|
+
const ordered = refs.sort((a, b) => compareFrozenRanks(this.#frozenRank.get(a)!, this.#frozenRank.get(b)!));
|
|
1570
1579
|
const query = this.#agentFilter.getValue().trim();
|
|
1571
1580
|
const rosterRows =
|
|
1572
1581
|
query.length > 0
|
|
@@ -1574,7 +1583,7 @@ export class AgentHubOverlayComponent<TRecord extends AgentRecordLike = AgentRec
|
|
|
1574
1583
|
: ordered;
|
|
1575
1584
|
|
|
1576
1585
|
if (this.#viewMode === "tree") {
|
|
1577
|
-
const tree = projectAgentTree(rosterRows,
|
|
1586
|
+
const tree = projectAgentTree(rosterRows, ref => this.#frozenRank.get(ref)!.batch < 0);
|
|
1578
1587
|
this.#rows = tree.rows;
|
|
1579
1588
|
this.#treeDepthById = tree.depthById;
|
|
1580
1589
|
this.#treeParentById = tree.parentById;
|
|
@@ -19,6 +19,7 @@ import type { Keybinding } from "../keybindings";
|
|
|
19
19
|
import { sanitizeText } from "@linxiraos/pi-utils";
|
|
20
20
|
import { type Theme } from "../theme/theme";
|
|
21
21
|
import type {
|
|
22
|
+
AnnotationOverlayDraft,
|
|
22
23
|
CodeReviewAnnotation,
|
|
23
24
|
CodeReviewOverlayResult,
|
|
24
25
|
ReviewDiffFile,
|
|
@@ -125,8 +126,14 @@ const MIN_BODY_ROWS = 3;
|
|
|
125
126
|
const SIDEBAR_MIN_TOTAL_WIDTH = 64;
|
|
126
127
|
const SIDEBAR_MIN_BODY_WIDTH = 40;
|
|
127
128
|
const MAX_ANNOTATION_EDITOR_ROWS = 6;
|
|
128
|
-
|
|
129
|
-
const
|
|
129
|
+
/** Clears every note and closes; the host then has nothing to keep. Needs a second confirm. */
|
|
130
|
+
export const DISCARD_ANNOTATIONS_ACTION = "Discard notes and close";
|
|
131
|
+
const CODE_REVIEW_ACTIONS = [
|
|
132
|
+
CONTINUE_CODE_REVIEW_ACTION,
|
|
133
|
+
PASTE_CODE_REVIEW_ACTION,
|
|
134
|
+
DISCARD_ANNOTATIONS_ACTION,
|
|
135
|
+
] as const;
|
|
136
|
+
const TEXT_REVIEW_ACTIONS = [PASTE_CODE_REVIEW_ACTION, DISCARD_ANNOTATIONS_ACTION] as const;
|
|
130
137
|
|
|
131
138
|
function isSourceRow(row: ReviewDiffRow): row is ReviewSourceRow {
|
|
132
139
|
return row.kind === "context" || row.kind === "added" || row.kind === "removed";
|
|
@@ -229,6 +236,8 @@ export class AnnotationOverlay implements Focusable {
|
|
|
229
236
|
/** Set once {@link replaceTextSource} runs; the paste result then carries the edited text. */
|
|
230
237
|
#textSourceEdited = false;
|
|
231
238
|
#finished = false;
|
|
239
|
+
/** Discard was chosen once; choosing it again discards, any other input disarms it. */
|
|
240
|
+
#discardArmed = false;
|
|
232
241
|
#annotations: CommittedAnnotation[] = [];
|
|
233
242
|
#textAnnotations: CommittedTextAnnotation[] = [];
|
|
234
243
|
/** Annotation lists before each create/edit/delete, restored by `u`. */
|
|
@@ -295,6 +304,8 @@ export class AnnotationOverlay implements Focusable {
|
|
|
295
304
|
this.#files = filesOrSource;
|
|
296
305
|
this.#mode = modeOrCallbacks as string;
|
|
297
306
|
this.#callbacks = maybeCallbacks!;
|
|
307
|
+
// Start on Paste, not the LLM review: a stray Enter must not submit (it does nothing until a note exists).
|
|
308
|
+
this.#actionIndex = 1;
|
|
298
309
|
}
|
|
299
310
|
const symbols = {
|
|
300
311
|
cursor: theme.nav.cursor,
|
|
@@ -357,6 +368,60 @@ export class AnnotationOverlay implements Focusable {
|
|
|
357
368
|
this.#finished = true;
|
|
358
369
|
}
|
|
359
370
|
|
|
371
|
+
/** Notes, the unfinished note, and any source edit, in the form {@link restoreDraft} replays. */
|
|
372
|
+
getDraft(): AnnotationOverlayDraft {
|
|
373
|
+
const editing =
|
|
374
|
+
this.#editingAnnotationIndex === undefined ? {} : { editingAnnotationIndex: this.#editingAnnotationIndex };
|
|
375
|
+
const text = this.#editor.getExpandedText();
|
|
376
|
+
if (this.#textSource) {
|
|
377
|
+
const scope = this.#annotationScope === "text" ? "text" : "line";
|
|
378
|
+
const sourceIndex = scope === "text" ? -1 : this.#sourceIndex;
|
|
379
|
+
return {
|
|
380
|
+
kind: "text",
|
|
381
|
+
annotations: this.#textAnnotations.map(entry => ({ ...entry, annotation: { ...entry.annotation } })),
|
|
382
|
+
...(this.#textSourceEdited ? { editedText: this.#textSource.text } : {}),
|
|
383
|
+
...(this.#annotating ? { editor: { sourceIndex, scope, ...editing, text } } : {}),
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
const scope = this.#annotationScope === "file" ? "file" : "line";
|
|
387
|
+
const editor = { fileIndex: this.#fileIndex, sourceIndex: this.#sourceIndex, scope, ...editing, text } as const;
|
|
388
|
+
return {
|
|
389
|
+
kind: "diff",
|
|
390
|
+
annotations: this.#annotations.map(entry => ({ ...entry, annotation: { ...entry.annotation } })),
|
|
391
|
+
...(this.#annotating ? { editor } : {}),
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/** Replay a draft taken from this same source; anything anchored outside it is dropped. */
|
|
396
|
+
restoreDraft(draft: AnnotationOverlayDraft): void {
|
|
397
|
+
const rows = (fileIndex: number) =>
|
|
398
|
+
this.#textSource ? this.#textLines.length : (this.#files[fileIndex]?.rows.filter(isSourceRow).length ?? -1);
|
|
399
|
+
const fits = (fileIndex: number, sourceIndex: number, whole: boolean) =>
|
|
400
|
+
rows(fileIndex) >= 0 && (whole ? sourceIndex === -1 : sourceIndex >= 0 && sourceIndex < rows(fileIndex));
|
|
401
|
+
if (draft.kind === "text" && this.#textSource) {
|
|
402
|
+
if (draft.editedText !== undefined) this.replaceTextSource(draft.editedText);
|
|
403
|
+
this.#textAnnotations = draft.annotations.filter(e => fits(0, e.sourceIndex, e.annotation.scope === "text"));
|
|
404
|
+
} else if (draft.kind === "diff" && !this.#textSource) {
|
|
405
|
+
this.#annotations = draft.annotations.filter(e =>
|
|
406
|
+
fits(e.fileIndex, e.sourceIndex, e.annotation.scope === "file"),
|
|
407
|
+
);
|
|
408
|
+
} else return;
|
|
409
|
+
const editor = draft.editor;
|
|
410
|
+
const fileIndex = editor && "fileIndex" in editor ? editor.fileIndex : 0;
|
|
411
|
+
if (editor && fits(fileIndex, editor.sourceIndex, editor.scope === "text" || editor.scope === "file")) {
|
|
412
|
+
this.#fileIndex = fileIndex;
|
|
413
|
+
if (editor.sourceIndex >= 0) this.#sourceIndex = editor.sourceIndex;
|
|
414
|
+
this.#annotationScope = editor.scope;
|
|
415
|
+
const count = this.#textSource ? this.#textAnnotations.length : this.#annotations.length;
|
|
416
|
+
this.#editingAnnotationIndex =
|
|
417
|
+
(editor.editingAnnotationIndex ?? count) < count ? editor.editingAnnotationIndex : undefined;
|
|
418
|
+
this.#annotating = true;
|
|
419
|
+
this.#editor.setText(editor.text);
|
|
420
|
+
}
|
|
421
|
+
this.#annotationRev++;
|
|
422
|
+
this.#nativeBody = undefined;
|
|
423
|
+
}
|
|
424
|
+
|
|
360
425
|
getAnnotations(): CodeReviewAnnotation[] {
|
|
361
426
|
return this.#annotations.map(entry => ({ ...entry.annotation }));
|
|
362
427
|
}
|
|
@@ -422,6 +487,8 @@ export class AnnotationOverlay implements Focusable {
|
|
|
422
487
|
|
|
423
488
|
handleInput(data: string): void {
|
|
424
489
|
if (this.#finished || this.#externalOperation) return;
|
|
490
|
+
const discardArmed = this.#discardArmed;
|
|
491
|
+
this.#discardArmed = false;
|
|
425
492
|
if (this.#annotationChooser) {
|
|
426
493
|
this.#handleAnnotationChooser(data);
|
|
427
494
|
return;
|
|
@@ -431,8 +498,9 @@ export class AnnotationOverlay implements Focusable {
|
|
|
431
498
|
void this.#openAnnotationEditor();
|
|
432
499
|
return;
|
|
433
500
|
}
|
|
501
|
+
// Close, keeping the unfinished note in the draft so it reopens in the editor.
|
|
434
502
|
if (this.#keybindings.matches(data, "tui.select.cancel")) {
|
|
435
|
-
this.#
|
|
503
|
+
this.#finish(undefined);
|
|
436
504
|
return;
|
|
437
505
|
}
|
|
438
506
|
this.#editor.handleInput(data);
|
|
@@ -476,7 +544,7 @@ export class AnnotationOverlay implements Focusable {
|
|
|
476
544
|
}
|
|
477
545
|
if (this.#focus === "files") this.#handleFiles(data);
|
|
478
546
|
else if (this.#focus === "diff") this.#handleDiff(data);
|
|
479
|
-
else this.#handleActions(data);
|
|
547
|
+
else this.#handleActions(data, discardArmed);
|
|
480
548
|
}
|
|
481
549
|
|
|
482
550
|
/** Primary key bound to `action` in this overlay's keybindings, formatted for footer hints. */
|
|
@@ -495,10 +563,9 @@ export class AnnotationOverlay implements Focusable {
|
|
|
495
563
|
}
|
|
496
564
|
}
|
|
497
565
|
|
|
498
|
-
/** Esc, by state: leave the note chooser,
|
|
566
|
+
/** Esc, by state: leave the note chooser, else close the review; the host keeps the draft. */
|
|
499
567
|
#escape(): void {
|
|
500
568
|
if (this.#annotationChooser) this.#annotationChooser = undefined;
|
|
501
|
-
else if (this.#annotating) this.#cancelAnnotation();
|
|
502
569
|
else this.#finish(undefined);
|
|
503
570
|
}
|
|
504
571
|
|
|
@@ -602,33 +669,41 @@ export class AnnotationOverlay implements Focusable {
|
|
|
602
669
|
}
|
|
603
670
|
}
|
|
604
671
|
|
|
605
|
-
#handleActions(data: string): void {
|
|
606
|
-
const
|
|
607
|
-
if (
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
if (this.#keybindings.matches(data, "tui.select.down") || matchesKey(data, "j")) {
|
|
614
|
-
if (this.#textSource) {
|
|
615
|
-
this.#actionIndex = (this.#actionIndex + 1) % actionCount;
|
|
616
|
-
} else if (hasAnnotations) {
|
|
617
|
-
this.#actionIndex = Math.min(actionCount - 1, this.#actionIndex + 1);
|
|
672
|
+
#handleActions(data: string, discardArmed: boolean): void {
|
|
673
|
+
const up = this.#keybindings.matches(data, "tui.select.up") || matchesKey(data, "k");
|
|
674
|
+
if (up || this.#keybindings.matches(data, "tui.select.down") || matchesKey(data, "j")) {
|
|
675
|
+
const step = up ? -1 : 1;
|
|
676
|
+
for (let index = this.#actionIndex + step; index >= 0 && index < this.#actions.length; index += step) {
|
|
677
|
+
if (this.#actionDisabled(index)) continue;
|
|
678
|
+
this.#actionIndex = index;
|
|
679
|
+
break;
|
|
618
680
|
}
|
|
619
681
|
return;
|
|
620
682
|
}
|
|
621
|
-
if (this.#keybindings.matches(data, "tui.select.confirm")) this.#confirmAction();
|
|
683
|
+
if (this.#keybindings.matches(data, "tui.select.confirm")) this.#confirmAction(discardArmed);
|
|
622
684
|
}
|
|
623
685
|
|
|
624
686
|
#actionDisabled(index: number): boolean {
|
|
687
|
+
if (this.#actions[index] === DISCARD_ANNOTATIONS_ACTION) return false;
|
|
625
688
|
const hasAnnotations = this.#textSource ? this.#textAnnotations.length > 0 : this.#annotations.length > 0;
|
|
626
689
|
return this.#textSource ? !hasAnnotations : index === 1 && !hasAnnotations;
|
|
627
690
|
}
|
|
628
691
|
|
|
629
|
-
#confirmAction(): void {
|
|
692
|
+
#confirmAction(discardArmed = false): void {
|
|
630
693
|
if (this.#actionDisabled(this.#actionIndex)) return;
|
|
631
|
-
if (this.#
|
|
694
|
+
if (this.#actions[this.#actionIndex] === DISCARD_ANNOTATIONS_ACTION) {
|
|
695
|
+
if (!discardArmed) {
|
|
696
|
+
this.#discardArmed = true;
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
this.#annotations = [];
|
|
700
|
+
this.#textAnnotations = [];
|
|
701
|
+
this.#textSourceEdited = false;
|
|
702
|
+
this.#annotating = false;
|
|
703
|
+
this.#editingAnnotationIndex = undefined;
|
|
704
|
+
this.#editor.setText("");
|
|
705
|
+
this.#finish(undefined);
|
|
706
|
+
} else if (this.#textSource) {
|
|
632
707
|
this.#finish({
|
|
633
708
|
action: "paste",
|
|
634
709
|
annotations: this.getTextAnnotations(),
|
|
@@ -721,12 +796,6 @@ export class AnnotationOverlay implements Focusable {
|
|
|
721
796
|
this.#editor.setText(existing?.annotation.note ?? "");
|
|
722
797
|
}
|
|
723
798
|
|
|
724
|
-
#cancelAnnotation(): void {
|
|
725
|
-
this.#annotating = false;
|
|
726
|
-
this.#editingAnnotationIndex = undefined;
|
|
727
|
-
this.#editor.setText("");
|
|
728
|
-
}
|
|
729
|
-
|
|
730
799
|
#commitAnnotation(value: string): void {
|
|
731
800
|
if (this.#textSource) {
|
|
732
801
|
this.#commitTextAnnotation(value);
|
|
@@ -925,7 +994,6 @@ export class AnnotationOverlay implements Focusable {
|
|
|
925
994
|
this.#annotationRev++;
|
|
926
995
|
this.#annotations = snapshot.annotations;
|
|
927
996
|
this.#textAnnotations = snapshot.textAnnotations;
|
|
928
|
-
if (this.#annotations.length === 0 && this.#actionIndex === 1) this.#actionIndex = 0;
|
|
929
997
|
}
|
|
930
998
|
|
|
931
999
|
async #openAnnotationEditor(): Promise<void> {
|
|
@@ -1146,9 +1214,10 @@ export class AnnotationOverlay implements Focusable {
|
|
|
1146
1214
|
}
|
|
1147
1215
|
|
|
1148
1216
|
#renderActions(): string[] {
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1217
|
+
return this.#actions.map((action, index) => {
|
|
1218
|
+
const label =
|
|
1219
|
+
action === DISCARD_ANNOTATIONS_ACTION && this.#discardArmed ? "Confirm: discard all notes" : action;
|
|
1220
|
+
const disabled = this.#actionDisabled(index);
|
|
1152
1221
|
const selected = index === this.#actionIndex;
|
|
1153
1222
|
const cursor = selected ? `${this.#theme.nav.cursor} ` : " ";
|
|
1154
1223
|
const text = disabled
|
|
@@ -1224,7 +1293,7 @@ export class AnnotationOverlay implements Focusable {
|
|
|
1224
1293
|
const hints = [
|
|
1225
1294
|
`${editorKey("tui.input.submit")} save`,
|
|
1226
1295
|
`${editorKey("tui.input.newLine")} newline`,
|
|
1227
|
-
`${this.#key("tui.select.cancel")}
|
|
1296
|
+
`${this.#key("tui.select.cancel")} close, keep note`,
|
|
1228
1297
|
];
|
|
1229
1298
|
hints.push(`${formatKeyHint(appExternalEditorKey())} editor`);
|
|
1230
1299
|
return [caption, ...this.#editor.render(width), this.#theme.fg("dim", hints.join(" · "))];
|
|
@@ -1428,6 +1497,7 @@ export class AnnotationOverlay implements Focusable {
|
|
|
1428
1497
|
this.#bodyHeight,
|
|
1429
1498
|
this.#annotating ? `annotating:${this.#annotationScope}:${this.#editingAnnotationIndex}` : "",
|
|
1430
1499
|
chooser ? `chooser:${chooser.selected}:${chooser.entries.join()}` : "",
|
|
1500
|
+
this.#discardArmed ? "discard-armed" : "",
|
|
1431
1501
|
].join("|");
|
|
1432
1502
|
if (this.#nativeRoot && sig === this.#nativeSig && body === this.#nativeRootBody) return this.#nativeRoot;
|
|
1433
1503
|
|
|
@@ -1462,6 +1532,8 @@ export class AnnotationOverlay implements Focusable {
|
|
|
1462
1532
|
|
|
1463
1533
|
handleNativeEvent(event: NativeUiEvent): void {
|
|
1464
1534
|
if (this.#finished || this.#externalOperation) return;
|
|
1535
|
+
const discardArmed = this.#discardArmed;
|
|
1536
|
+
this.#discardArmed = false;
|
|
1465
1537
|
if (event.type === "action") {
|
|
1466
1538
|
if (event.act === "close") {
|
|
1467
1539
|
this.#escape();
|
|
@@ -1470,10 +1542,18 @@ export class AnnotationOverlay implements Focusable {
|
|
|
1470
1542
|
// A draft or the note chooser is open: finish or leave it first.
|
|
1471
1543
|
if (this.#annotating || this.#annotationChooser) return;
|
|
1472
1544
|
const index =
|
|
1473
|
-
event.act === "
|
|
1545
|
+
event.act === "discard"
|
|
1546
|
+
? this.#actions.indexOf(DISCARD_ANNOTATIONS_ACTION)
|
|
1547
|
+
: event.act === "review" && !this.#textSource
|
|
1548
|
+
? 0
|
|
1549
|
+
: event.act === "paste"
|
|
1550
|
+
? this.#textSource
|
|
1551
|
+
? 0
|
|
1552
|
+
: 1
|
|
1553
|
+
: -1;
|
|
1474
1554
|
if (index < 0 || this.#actionDisabled(index)) return;
|
|
1475
1555
|
this.#actionIndex = index;
|
|
1476
|
-
this.#confirmAction();
|
|
1556
|
+
this.#confirmAction(discardArmed);
|
|
1477
1557
|
return;
|
|
1478
1558
|
}
|
|
1479
1559
|
if (event.type !== "select" && event.type !== "activate") return;
|
|
@@ -1826,7 +1906,15 @@ export class AnnotationOverlay implements Focusable {
|
|
|
1826
1906
|
mark ? ({ ...button, p: { ...button.p, mark } } as NativeNode) : button;
|
|
1827
1907
|
const hasNotes = this.#textSource ? this.#textAnnotations.length > 0 : this.#annotations.length > 0;
|
|
1828
1908
|
const pasteTitle = hasNotes ? PASTE_CODE_REVIEW_ACTION : "Add a note to paste it into the prompt";
|
|
1829
|
-
const buttons: NativeNode[] = [
|
|
1909
|
+
const buttons: NativeNode[] = [
|
|
1910
|
+
actionButton("Cancel", "close", { keys: "escape" }),
|
|
1911
|
+
marked(
|
|
1912
|
+
actionButton(this.#discardArmed ? "Confirm discard" : "Discard", "discard", {
|
|
1913
|
+
title: DISCARD_ANNOTATIONS_ACTION,
|
|
1914
|
+
}),
|
|
1915
|
+
pick(this.#actions.indexOf(DISCARD_ANNOTATIONS_ACTION)),
|
|
1916
|
+
),
|
|
1917
|
+
];
|
|
1830
1918
|
if (this.#textSource) {
|
|
1831
1919
|
buttons.push(
|
|
1832
1920
|
marked(actionButton("Paste into prompt", "paste", { tone: "accent", title: pasteTitle }), pick(0)),
|
|
@@ -1862,7 +1950,7 @@ export class AnnotationOverlay implements Focusable {
|
|
|
1862
1950
|
return [
|
|
1863
1951
|
this.#hint("tui.input.submit", "save"),
|
|
1864
1952
|
this.#hint("tui.input.newLine", "new line"),
|
|
1865
|
-
this.#hint("tui.select.cancel", "
|
|
1953
|
+
this.#hint("tui.select.cancel", "close, keep note"),
|
|
1866
1954
|
this.#callbacks.onAnnotationExternalEditor ? key(appExternalEditorKey(), "editor") : undefined,
|
|
1867
1955
|
];
|
|
1868
1956
|
}
|
|
@@ -78,3 +78,27 @@ export interface TextReviewOverlayResult {
|
|
|
78
78
|
/** Source text after an external-editor edit; absent when the source was not edited. */
|
|
79
79
|
editedText?: string;
|
|
80
80
|
}
|
|
81
|
+
|
|
82
|
+
export type AnnotationOverlayDraft =
|
|
83
|
+
| {
|
|
84
|
+
kind: "diff";
|
|
85
|
+
annotations: { fileIndex: number; sourceIndex: number; annotation: CodeReviewAnnotation }[];
|
|
86
|
+
editor?: {
|
|
87
|
+
fileIndex: number;
|
|
88
|
+
sourceIndex: number;
|
|
89
|
+
scope: "file" | "line";
|
|
90
|
+
editingAnnotationIndex?: number;
|
|
91
|
+
text: string;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
| {
|
|
95
|
+
kind: "text";
|
|
96
|
+
annotations: { sourceIndex: number; annotation: TextReviewAnnotation }[];
|
|
97
|
+
editedText?: string;
|
|
98
|
+
editor?: {
|
|
99
|
+
sourceIndex: number;
|
|
100
|
+
scope: "text" | "line";
|
|
101
|
+
editingAnnotationIndex?: number;
|
|
102
|
+
text: string;
|
|
103
|
+
};
|
|
104
|
+
};
|