@linxiraos/pi-tui 1.4.6 → 1.4.9
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 +162 -244
- package/README.md +41 -35
- 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/charts/table-data.d.ts +4 -2
- package/dist/types/chat/assistant-message.d.ts +15 -3
- package/dist/types/chat/bash-execution.d.ts +6 -1
- package/dist/types/chat/display-preferences.d.ts +2 -0
- package/dist/types/chat/eval-execution.d.ts +2 -0
- package/dist/types/chat/execution-shared.d.ts +14 -8
- package/dist/types/chat/extension-types.d.ts +31 -0
- package/dist/types/chat/figure-markdown.d.ts +2 -0
- package/dist/types/chat/reply-write.d.ts +48 -0
- package/dist/types/chat/svg-figure.d.ts +5 -0
- package/dist/types/chat/table-chart.d.ts +6 -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 +13 -3
- package/dist/types/chrome/dynamic-border.d.ts +6 -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 +21 -9
- package/dist/types/components/editor.d.ts +23 -6
- package/dist/types/components/image.d.ts +6 -0
- package/dist/types/components/loader.d.ts +2 -0
- package/dist/types/components/markdown.d.ts +7 -0
- package/dist/types/keybinding-matchers.d.ts +7 -0
- package/dist/types/native/blobs.d.ts +2 -1
- package/dist/types/native/describe.d.ts +4 -2
- package/dist/types/native/node.d.ts +2 -3
- package/dist/types/native/overlay.d.ts +42 -2
- package/dist/types/native/picker.d.ts +4 -4
- package/dist/types/native/state.d.ts +4 -0
- package/dist/types/overlays/annotation-overlay.d.ts +7 -1
- package/dist/types/overlays/annotation-types.d.ts +28 -0
- package/dist/types/overlays/btw-history-panel.d.ts +15 -0
- package/dist/types/overlays/btw-history.d.ts +24 -0
- package/dist/types/overlays/btw-inject.d.ts +22 -0
- package/dist/types/overlays/btw-panel.d.ts +7 -0
- package/dist/types/overlays/hook-editor.d.ts +2 -0
- package/dist/types/overlays/jobs-panel.d.ts +4 -0
- package/dist/types/overlays/login-dialog.d.ts +5 -1
- package/dist/types/overlays/model-browser.d.ts +11 -2
- package/dist/types/overlays/oauth-selector.d.ts +23 -0
- 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/session-selector.d.ts +33 -4
- package/dist/types/prompt/composer.d.ts +56 -5
- package/dist/types/prompt/interactive-context-helpers.d.ts +10 -3
- package/dist/types/render/extension-links.d.ts +65 -0
- package/dist/types/render/hyperlink.d.ts +25 -7
- package/dist/types/render/index.d.ts +1 -0
- package/dist/types/render/render-utils.d.ts +23 -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 +1 -1
- package/dist/types/status-line/context-usage.d.ts +28 -6
- package/dist/types/status-line/host.d.ts +6 -2
- package/dist/types/status-line/startup.d.ts +0 -15
- package/dist/types/terminal-capabilities.d.ts +1 -1
- package/dist/types/theme/symbols.d.ts +3 -1
- package/dist/types/theme/theme-class.d.ts +1 -0
- package/dist/types/theme/theme.d.ts +1 -24
- package/dist/types/theme/tui-adapters.d.ts +2 -0
- package/dist/types/thinking.d.ts +8 -6
- package/dist/types/tools/ast-grep.d.ts +2 -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/eval.d.ts +2 -0
- package/dist/types/tools/find.d.ts +1 -1
- package/dist/types/tools/grouped-file-output.d.ts +100 -19
- package/dist/types/tools/hashline-format.d.ts +5 -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 +6 -5
- package/dist/types/tools/native-view.d.ts +3 -1
- package/dist/types/tools/output-meta.d.ts +27 -0
- package/dist/types/tools/read.d.ts +14 -4
- 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 +13 -4
- package/dist/types/tools/url-scheme-host.d.ts +17 -0
- package/dist/types/tools/wait.d.ts +2 -0
- package/dist/types/tools/yield.d.ts +1 -1
- package/dist/types/tui.d.ts +19 -2
- package/dist/types/utils.d.ts +4 -0
- package/package.json +10 -14
- package/src/app-keybindings.d.ts +20 -0
- package/src/app-keybindings.ts +20 -0
- package/src/apps/git/git-tui.ts +10 -17
- package/src/apps/git/sidebar.ts +21 -35
- package/src/apps/ps-top.ts +4 -12
- package/src/apps/session-picker.ts +7 -0
- package/src/charts/chart-plan.d.ts +9 -7
- package/src/charts/chart-plan.ts +20 -79
- package/src/charts/table-data.d.ts +4 -2
- package/src/charts/table-data.ts +55 -6
- 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 +6 -1
- package/src/chat/bash-execution.ts +26 -9
- package/src/chat/chat-transcript-builder.ts +63 -30
- 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/eval-execution.d.ts +2 -0
- package/src/chat/eval-execution.ts +14 -7
- package/src/chat/execution-shared.d.ts +14 -8
- package/src/chat/execution-shared.ts +39 -18
- package/src/chat/extension-types.d.ts +31 -0
- package/src/chat/extension-types.ts +34 -0
- package/src/chat/figure-markdown.d.ts +2 -0
- package/src/chat/figure-markdown.ts +6 -4
- package/src/chat/read-tool-group.ts +56 -36
- package/src/chat/reply-write.d.ts +48 -0
- package/src/chat/reply-write.ts +127 -0
- package/src/chat/svg-figure.d.ts +5 -0
- package/src/chat/svg-figure.ts +55 -16
- package/src/chat/table-chart.d.ts +6 -3
- package/src/chat/table-chart.ts +29 -6
- 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 +13 -3
- package/src/chat/transcript-render-helpers.ts +134 -44
- package/src/chrome/dynamic-border.d.ts +6 -0
- package/src/chrome/dynamic-border.ts +28 -2
- package/src/chrome/index.ts +1 -0
- package/src/chrome/transcript-notice.d.ts +35 -0
- package/src/chrome/transcript-notice.ts +83 -0
- package/src/chrome/transcript-status.d.ts +21 -9
- package/src/chrome/transcript-status.ts +32 -30
- package/src/components/editor.d.ts +23 -6
- package/src/components/editor.ts +133 -25
- package/src/components/image.d.ts +6 -0
- package/src/components/image.ts +13 -0
- package/src/components/key-value-list.ts +9 -9
- package/src/components/loader.d.ts +2 -0
- package/src/components/loader.ts +7 -0
- package/src/components/markdown.d.ts +7 -0
- package/src/components/markdown.ts +116 -6
- package/src/components/section.ts +1 -9
- package/src/components/table.ts +1 -9
- package/src/hotkeys-markdown.ts +1 -0
- package/src/keybinding-matchers.d.ts +7 -0
- package/src/keybinding-matchers.ts +13 -0
- package/src/native/backend.ts +10 -67
- package/src/native/blobs.d.ts +2 -1
- package/src/native/blobs.ts +3 -2
- package/src/native/describe.d.ts +4 -2
- package/src/native/describe.ts +9 -4
- package/src/native/node.d.ts +2 -3
- package/src/native/node.ts +2 -3
- package/src/native/overlay.d.ts +42 -2
- package/src/native/overlay.ts +124 -16
- package/src/native/picker.d.ts +4 -4
- package/src/native/picker.ts +4 -4
- package/src/native/state.d.ts +4 -0
- package/src/native/state.ts +25 -5
- package/src/overlays/advisor-config.ts +1 -10
- package/src/overlays/annotation-overlay.ts +125 -37
- package/src/overlays/annotation-types.ts +24 -0
- package/src/overlays/btw-history-panel.ts +106 -14
- package/src/overlays/btw-history.ts +65 -0
- package/src/overlays/btw-inject.ts +91 -0
- package/src/overlays/btw-panel.ts +53 -12
- package/src/overlays/extensions/extension-dashboard.ts +7 -8
- package/src/overlays/hook-editor.ts +6 -0
- package/src/overlays/hook-selector.ts +2 -2
- package/src/overlays/jobs-panel.ts +82 -22
- package/src/overlays/login-dialog.ts +39 -31
- package/src/overlays/mcp-add-wizard.ts +1 -1
- package/src/overlays/model-browser.ts +106 -10
- 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/plan-review-overlay.ts +13 -2
- package/src/overlays/rewind-selector.ts +29 -12
- package/src/overlays/session-selector.ts +338 -47
- package/src/overlays/settings-defs.ts +2 -2
- package/src/overlays/tree-selector.ts +83 -27
- package/src/overlays/usage-dashboard.ts +9 -18
- package/src/prompt/composer.ts +233 -6
- 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/render/code-cell.ts +1 -1
- package/src/render/extension-links.d.ts +65 -0
- package/src/render/extension-links.ts +214 -0
- package/src/render/file-list.ts +4 -7
- package/src/render/hyperlink.d.ts +25 -7
- package/src/render/hyperlink.ts +65 -9
- package/src/render/index.d.ts +1 -0
- package/src/render/index.ts +1 -0
- package/src/render/render-utils.d.ts +23 -1
- package/src/render/render-utils.ts +38 -6
- package/src/setup/scenes/composer.ts +2 -0
- package/src/setup/scenes/glyph.ts +4 -2
- package/src/setup/scenes/model.ts +192 -29
- package/src/setup/scenes/outro.ts +33 -15
- package/src/setup/scenes/sign-in.ts +196 -400
- 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 +4 -10
- package/src/status-line/context-usage.ts +72 -21
- package/src/status-line/host.ts +6 -2
- package/src/status-line/startup.ts +36 -70
- package/src/terminal-capabilities.d.ts +1 -1
- package/src/terminal-capabilities.ts +5 -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 +3 -1
- package/src/theme/symbols.ts +16 -9
- package/src/theme/theme-class.d.ts +1 -0
- package/src/theme/theme-class.ts +15 -3
- package/src/theme/theme.d.ts +1 -24
- package/src/theme/theme.ts +3 -75
- package/src/theme/tui-adapters.d.ts +2 -0
- package/src/theme/tui-adapters.ts +8 -3
- package/src/thinking.d.ts +8 -6
- package/src/thinking.ts +17 -11
- package/src/tmux.ts +1 -0
- package/src/tools/agent-tree.ts +13 -11
- package/src/tools/ask.ts +24 -37
- package/src/tools/ast-edit.ts +48 -93
- package/src/tools/ast-grep.d.ts +2 -0
- package/src/tools/ast-grep.ts +31 -67
- 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 +9 -0
- package/src/tools/default-renderer.d.ts +6 -4
- package/src/tools/default-renderer.ts +10 -7
- package/src/tools/edit.ts +50 -43
- package/src/tools/eval.d.ts +2 -0
- package/src/tools/eval.ts +16 -4
- package/src/tools/fetch.ts +2 -1
- package/src/tools/find.d.ts +1 -1
- package/src/tools/find.ts +13 -5
- package/src/tools/github.ts +14 -46
- package/src/tools/glob.ts +2 -1
- package/src/tools/grep.ts +47 -277
- package/src/tools/grouped-file-output.d.ts +100 -19
- package/src/tools/grouped-file-output.ts +414 -103
- package/src/tools/hashline-format.d.ts +5 -0
- package/src/tools/hashline-format.ts +5 -0
- 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 -46
- package/src/tools/lsp.d.ts +2 -0
- package/src/tools/lsp.ts +246 -47
- package/src/tools/mcp.d.ts +6 -5
- package/src/tools/mcp.ts +20 -12
- package/src/tools/native-view.d.ts +3 -1
- package/src/tools/native-view.ts +12 -6
- package/src/tools/output-meta.d.ts +27 -0
- package/src/tools/output-meta.ts +68 -4
- package/src/tools/proc-render.ts +3 -3
- package/src/tools/read.d.ts +14 -4
- package/src/tools/read.ts +20 -5
- 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 +13 -4
- package/src/tools/task.ts +100 -97
- package/src/tools/url-scheme-host.d.ts +17 -0
- package/src/tools/url-scheme-host.ts +21 -0
- package/src/tools/vibe.ts +4 -4
- package/src/tools/wait.d.ts +2 -0
- package/src/tools/wait.ts +8 -5
- package/src/tools/write.ts +17 -27
- package/src/tools/yield.d.ts +1 -1
- package/src/tools/yield.ts +19 -10
- package/src/tui.d.ts +19 -2
- package/src/tui.ts +134 -24
- package/src/utils.d.ts +4 -0
- package/src/utils.ts +10 -0
- 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
|
@@ -18,6 +18,7 @@ import { formatBytes, getProjectDir } from "@linxiraos/pi-utils";
|
|
|
18
18
|
import type { TspPickerGroup, TspPickerItem, TspSpan, TspText, TspTone } from "@linxiraos/pi-wire";
|
|
19
19
|
import { compact, kv, md, node, span } from "../native/describe";
|
|
20
20
|
import {
|
|
21
|
+
bindingKeys,
|
|
21
22
|
picker,
|
|
22
23
|
pickerAction,
|
|
23
24
|
pickerAge,
|
|
@@ -27,7 +28,7 @@ import {
|
|
|
27
28
|
pickerHits,
|
|
28
29
|
} from "../native/picker";
|
|
29
30
|
import type { DescribeContext, NativeChild, NativeNode, NativeUiEvent } from "../native/node";
|
|
30
|
-
import { hintsRow, type NativeHint, overlayCard } from "../native/overlay";
|
|
31
|
+
import { actionHint, hintsRow, type NativeHint, overlayCard } from "../native/overlay";
|
|
31
32
|
import { plainText } from "../native/spans";
|
|
32
33
|
import { tuiText, tuiTextFmt } from "../i18n";
|
|
33
34
|
import {
|
|
@@ -45,6 +46,7 @@ import {
|
|
|
45
46
|
import { theme } from "../theme/theme";
|
|
46
47
|
import { contentRowWidth } from "../chrome/selector-helpers";
|
|
47
48
|
import { matchesAppInterrupt, matchesSelectDown, matchesSelectUp } from "../keybinding-matchers";
|
|
49
|
+
import { getKeybindings } from "../keybindings";
|
|
48
50
|
/** Session lifecycle status presented by the picker. */
|
|
49
51
|
export type SessionSelectorStatus = "complete" | "interrupted" | "aborted" | "error" | "pending" | "unknown";
|
|
50
52
|
|
|
@@ -64,6 +66,7 @@ export interface SessionSelectorEntry {
|
|
|
64
66
|
parentSessionPath?: string;
|
|
65
67
|
}
|
|
66
68
|
import { shortenPath } from "../render/render-utils";
|
|
69
|
+
import { formTheme } from "../chrome/form-theme";
|
|
67
70
|
import { HookSelectorComponent } from "./hook-selector";
|
|
68
71
|
import { ResumeTreeComponent, type ResumeTreeSource } from "./resume-tree";
|
|
69
72
|
|
|
@@ -80,6 +83,7 @@ export type {
|
|
|
80
83
|
ResumeWorkspaceLike,
|
|
81
84
|
} from "./resume-picker";
|
|
82
85
|
import { bottomBorder, OverlayPanel, row, topBorder } from "../chrome/overlay-box";
|
|
86
|
+
import { TextFormField } from "../components/form";
|
|
83
87
|
import { MenuSelection, getMenuWindow } from "../components/menu-selection";
|
|
84
88
|
import { formatKeyHint, formatKeyHints } from "../app-keybindings";
|
|
85
89
|
import { boundKeys, interruptKey } from "../chrome/keybinding-hints";
|
|
@@ -545,6 +549,8 @@ class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
545
549
|
readonly #getTerminalRows: () => number;
|
|
546
550
|
|
|
547
551
|
onDeleteRequest?: (session: T) => void;
|
|
552
|
+
onRenameRequest?: (session: T) => void;
|
|
553
|
+
onPinRequest?: (session: T, pinned: boolean) => void;
|
|
548
554
|
|
|
549
555
|
#allSessions: T[];
|
|
550
556
|
#showCwd: boolean;
|
|
@@ -618,7 +624,7 @@ class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
618
624
|
this.#getCurrentSessionPath =
|
|
619
625
|
typeof currentSessionPath === "function" ? currentSessionPath : () => currentSessionPath;
|
|
620
626
|
this.#historyMatcher = historyMatcher;
|
|
621
|
-
this.#menu = new MenuSelection<T>(sessions, {
|
|
627
|
+
this.#menu = new MenuSelection<T>(this.#pinnedFirst(sessions), {
|
|
622
628
|
getKey: session => session.path,
|
|
623
629
|
getSearchText: sessionSearchText,
|
|
624
630
|
});
|
|
@@ -714,8 +720,9 @@ class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
714
720
|
this.#hadFilterQuery = tokens.length > 0;
|
|
715
721
|
this.#lastFilterQuery = query;
|
|
716
722
|
if (tokens.length === 0) {
|
|
717
|
-
const
|
|
718
|
-
this.#menu.
|
|
723
|
+
const items = this.#pinnedFirst(this.#allSessions);
|
|
724
|
+
const keepIndex = Math.min(this.#menu.selectedIndex, Math.max(0, items.length - 1));
|
|
725
|
+
this.#menu.setItems(items, keepIndex >= 0 ? items[keepIndex]?.path : undefined);
|
|
719
726
|
if (hadQuery) this.#selectCurrentSession();
|
|
720
727
|
this.#scheduleHistoryMerge(query);
|
|
721
728
|
return;
|
|
@@ -789,8 +796,9 @@ class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
789
796
|
}
|
|
790
797
|
|
|
791
798
|
/**
|
|
792
|
-
* Rebuild the menu's visible list with
|
|
793
|
-
* prompt-history hits, literal matches (recency), and
|
|
799
|
+
* Rebuild the menu's visible list with pinned sessions first, then title
|
|
800
|
+
* matches, other prompt-history hits, literal matches (recency), and
|
|
801
|
+
* fuzzy-only hits (score).
|
|
794
802
|
*/
|
|
795
803
|
#composeFiltered(): void {
|
|
796
804
|
this.#itemsVersion++;
|
|
@@ -798,17 +806,31 @@ class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
798
806
|
const base: T[] = [];
|
|
799
807
|
for (const match of this.#literalRanked) base.push(match.session);
|
|
800
808
|
for (const match of this.#fuzzyRanked) base.push(match.session);
|
|
801
|
-
const composed =
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
809
|
+
const composed = this.#pinnedFirst(
|
|
810
|
+
prioritizeTitleMatches(
|
|
811
|
+
this.#historyIds.length > 0 ? mergeSessionRanking(this.#allSessions, base, this.#historyIds) : base,
|
|
812
|
+
tokenizeSessionQuery(this.#searchInput.getValue()),
|
|
813
|
+
this.#literalRanked,
|
|
814
|
+
),
|
|
805
815
|
);
|
|
806
|
-
//
|
|
807
|
-
// selection
|
|
816
|
+
// A late pinned or history match can land above the cursor: a moved
|
|
817
|
+
// selection follows its session, an untouched one keeps the top rank.
|
|
818
|
+
// The query path resets explicitly.
|
|
819
|
+
if (this.#selectionMoved) {
|
|
820
|
+
this.#menu.setItems(composed);
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
808
823
|
const keepIndex = Math.min(this.#menu.selectedIndex, Math.max(0, composed.length - 1));
|
|
809
824
|
this.#menu.setItems(composed, keepIndex >= 0 ? composed[keepIndex]?.path : undefined);
|
|
810
825
|
}
|
|
811
826
|
|
|
827
|
+
/** Stable partition: pinned sessions first, each group in its incoming order. */
|
|
828
|
+
#pinnedFirst(sessions: readonly T[]): readonly T[] {
|
|
829
|
+
const pins = this.#pinnedIds;
|
|
830
|
+
const pinned = pins.size > 0 ? sessions.filter(session => pins.has(session.id)) : [];
|
|
831
|
+
return pinned.length > 0 ? [...pinned, ...sessions.filter(session => !pins.has(session.id))] : sessions;
|
|
832
|
+
}
|
|
833
|
+
|
|
812
834
|
/**
|
|
813
835
|
* Augment ranked results with prompt-history matches without replacing them.
|
|
814
836
|
* The session-list corpus only sees the first 4KB of each session, so a prompt
|
|
@@ -870,6 +892,22 @@ class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
870
892
|
}
|
|
871
893
|
}
|
|
872
894
|
|
|
895
|
+
/** Update a session's title in place and refresh the visible list, keeping the selection. */
|
|
896
|
+
renameSessionTitle(sessionPath: string, title: string): void {
|
|
897
|
+
const entry = this.#allSessions.find(s => s.path === sessionPath);
|
|
898
|
+
if (!entry) return;
|
|
899
|
+
this.#datasetVersion++;
|
|
900
|
+
entry.title = title;
|
|
901
|
+
// The cached native item embeds the old title, and the search haystack
|
|
902
|
+
// caches it too: drop both so the next describe rebuilds the row and
|
|
903
|
+
// the literal/fuzzy search paths match the new title. Selection is
|
|
904
|
+
// path-keyed, so the same-query refilter keeps the cursor on the
|
|
905
|
+
// renamed session.
|
|
906
|
+
delete (entry as NativeSessionInfo)[kNativeItem];
|
|
907
|
+
delete (entry as SearchableSessionInfo)[kSearchTextLower];
|
|
908
|
+
this.#filterSessions(this.#searchInput.getValue());
|
|
909
|
+
}
|
|
910
|
+
|
|
873
911
|
/** Resolve a list-local rendered-line index to a filtered-session index. */
|
|
874
912
|
hitTestSession(line: number): number | undefined {
|
|
875
913
|
return this.#hitRows[line];
|
|
@@ -913,6 +951,43 @@ class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
913
951
|
if (selected) this.onDeleteRequest?.(selected);
|
|
914
952
|
}
|
|
915
953
|
|
|
954
|
+
/** F2: ask the parent to rename the selected session. */
|
|
955
|
+
requestRename(): void {
|
|
956
|
+
const selected = this.#menu.selectedItem;
|
|
957
|
+
if (selected) this.onRenameRequest?.(selected);
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
/** Pin keys: ask the parent to pin or unpin the selected session (default: flip it); no-op when already there. */
|
|
961
|
+
requestPin(pinned?: boolean): void {
|
|
962
|
+
const selected = this.#menu.selectedItem;
|
|
963
|
+
if (!selected) return;
|
|
964
|
+
const isPinned = this.#pinnedIds.has(selected.id);
|
|
965
|
+
if (pinned !== isPinned) this.onPinRequest?.(selected, !isPinned);
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
/** Apply a persisted pin change; the list re-partitions and the cursor follows the session. */
|
|
969
|
+
setPinned(sessionId: string, pinned: boolean): void {
|
|
970
|
+
const pinnedIds = new Set(this.#pinnedIds);
|
|
971
|
+
if (pinned) pinnedIds.add(sessionId);
|
|
972
|
+
else pinnedIds.delete(sessionId);
|
|
973
|
+
this.#pinnedIds = pinnedIds;
|
|
974
|
+
// Counts as moving the selection: it keeps the cursor on this session
|
|
975
|
+
// and a pending history merge from reordering under it.
|
|
976
|
+
this.#selectionMoved = true;
|
|
977
|
+
if (this.#hadFilterQuery) {
|
|
978
|
+
this.#composeFiltered();
|
|
979
|
+
} else {
|
|
980
|
+
this.#itemsVersion++;
|
|
981
|
+
this.#menu.setItems(this.#pinnedFirst(this.#allSessions));
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
/** Whether the selected session is pinned (picks the pin action's direction). */
|
|
986
|
+
get selectedPinned(): boolean {
|
|
987
|
+
const selected = this.#menu.selectedItem;
|
|
988
|
+
return selected !== undefined && this.#pinnedIds.has(selected.id);
|
|
989
|
+
}
|
|
990
|
+
|
|
916
991
|
/** Empty the search query (the empty state's "Clear search"). */
|
|
917
992
|
clearSearch(): void {
|
|
918
993
|
this.#searchInput.setValue("");
|
|
@@ -966,7 +1041,7 @@ class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
966
1041
|
if (tokens.length === 0) {
|
|
967
1042
|
const now = new Date();
|
|
968
1043
|
const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();
|
|
969
|
-
// Pins lead the listing (`
|
|
1044
|
+
// Pins lead the listing (`#pinnedFirst`), so they get their own group ahead of the days.
|
|
970
1045
|
const groups = visible.map(session =>
|
|
971
1046
|
this.#pinnedIds.has(session.id) ? PINNED_GROUP : sessionDayGroup(session.modified, startOfToday),
|
|
972
1047
|
);
|
|
@@ -1331,6 +1406,21 @@ class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
1331
1406
|
this.requestDelete();
|
|
1332
1407
|
return;
|
|
1333
1408
|
}
|
|
1409
|
+
// F2 renames the selected session; as a non-printable key it never
|
|
1410
|
+
// collides with the search input.
|
|
1411
|
+
if (matchesKey(keyData, "f2")) {
|
|
1412
|
+
this.requestRename();
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
const keybindings = getKeybindings();
|
|
1416
|
+
if (keybindings.matches(keyData, "app.session.pin")) {
|
|
1417
|
+
this.requestPin(true);
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
if (keybindings.matches(keyData, "app.session.unpin")) {
|
|
1421
|
+
this.requestPin(false);
|
|
1422
|
+
return;
|
|
1423
|
+
}
|
|
1334
1424
|
// Up arrow
|
|
1335
1425
|
if (matchesSelectUp(keyData)) {
|
|
1336
1426
|
this.#selectionMoved = true;
|
|
@@ -1386,11 +1476,24 @@ class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
1386
1476
|
|
|
1387
1477
|
export interface SessionSelectorOptions<T extends SessionSelectorEntry = SessionSelectorEntry> {
|
|
1388
1478
|
onDelete?: (session: T) => Promise<boolean>;
|
|
1479
|
+
/**
|
|
1480
|
+
* Rename the selected session to a user-supplied title; resolve with the
|
|
1481
|
+
* title as stored (the session canonicalizes it) or null when the rename
|
|
1482
|
+
* did not happen.
|
|
1483
|
+
*/
|
|
1484
|
+
onRename?: (session: T, title: string) => Promise<string | null>;
|
|
1485
|
+
/** Persist the selected session's pin state (pin keys / the picker's Pin action). */
|
|
1486
|
+
onSetPinned?: (session: T, pinned: boolean) => Promise<void>;
|
|
1389
1487
|
historyMatcher?: SessionHistoryMatcher;
|
|
1488
|
+
/**
|
|
1489
|
+
* Complete folder listing when the constructor's `sessions` are a preliminary
|
|
1490
|
+
* subset; replaces them once it settles.
|
|
1491
|
+
*/
|
|
1492
|
+
completeSessions?: Promise<T[]>;
|
|
1390
1493
|
/** Loads sessions across all projects for the all-projects scope toggle (Tab). */
|
|
1391
|
-
loadAllSessions?: () => Promise<T[]>;
|
|
1494
|
+
loadAllSessions?: () => Promise<T[] | { sessions: T[] }>;
|
|
1392
1495
|
/** Preloaded all-projects list; cached so the first Tab toggle is instant. */
|
|
1393
|
-
allSessions?: T[];
|
|
1496
|
+
allSessions?: T[] | { sessions: T[] };
|
|
1394
1497
|
/**
|
|
1395
1498
|
* The host's resume model (project → workspace → conversation) and its
|
|
1396
1499
|
* pure view builder. When set, the native `picker` describes the resume
|
|
@@ -1487,17 +1590,23 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1487
1590
|
#nativePicker = false;
|
|
1488
1591
|
readonly #getTerminalRowsOption: (() => number) | undefined;
|
|
1489
1592
|
#confirmationDialog: HookSelectorComponent | null = null;
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1593
|
+
/** Open rename dialog: an OverlayPanel hosting the rename TextFormField. */
|
|
1594
|
+
#renameDialog: OverlayPanel | null = null;
|
|
1595
|
+
/** The rename dialog's input; keystrokes route here while the dialog is open. */
|
|
1596
|
+
#renameField: TextFormField | null = null;
|
|
1597
|
+
// Hosts whichever of `#sessionList` / `#confirmationDialog` / `#renameDialog`
|
|
1598
|
+
// is live this frame. The delete dialog REPLACES the list in this slot rather
|
|
1599
|
+
// than being appended below the picker chrome, so the picker is always
|
|
1493
1600
|
// `chrome + max(list, dialog) + chrome` and never overflows the viewport
|
|
1494
1601
|
// (issue #3283: an overflowing dialog frame committed the header into
|
|
1495
1602
|
// scrollback, stranding it above the viewport once the dialog closed).
|
|
1496
1603
|
#contentSlot: Container;
|
|
1497
1604
|
#messageContainer: Container;
|
|
1498
1605
|
#onDelete?: (session: T) => Promise<boolean>;
|
|
1606
|
+
#onRename?: (session: T, title: string) => Promise<string | null>;
|
|
1607
|
+
#onSetPinned?: (session: T, pinned: boolean) => Promise<void>;
|
|
1499
1608
|
#onRequestRender?: () => void;
|
|
1500
|
-
readonly #loadAllSessions?: () => Promise<T[]>;
|
|
1609
|
+
readonly #loadAllSessions?: () => Promise<T[] | { sessions: T[] }>;
|
|
1501
1610
|
#folderSessions: T[];
|
|
1502
1611
|
readonly #folderShowCwd: boolean;
|
|
1503
1612
|
#globalSessions: T[] | null = null;
|
|
@@ -1577,6 +1686,7 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1577
1686
|
message: SessionPickerMessage | undefined;
|
|
1578
1687
|
errorOpen: boolean;
|
|
1579
1688
|
choice: DeleteChoice<T> | null;
|
|
1689
|
+
rename: OverlayPanel | null;
|
|
1580
1690
|
node: NativeNode;
|
|
1581
1691
|
}
|
|
1582
1692
|
| undefined;
|
|
@@ -1585,7 +1695,7 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1585
1695
|
title: string;
|
|
1586
1696
|
scope: "folder" | "all";
|
|
1587
1697
|
message: SessionPickerMessage | undefined;
|
|
1588
|
-
dialog: HookSelectorComponent | null;
|
|
1698
|
+
dialog: HookSelectorComponent | OverlayPanel | null;
|
|
1589
1699
|
list: NativeNode;
|
|
1590
1700
|
node: NativeNode;
|
|
1591
1701
|
}
|
|
@@ -1602,18 +1712,34 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1602
1712
|
|
|
1603
1713
|
this.#messageContainer = new Container();
|
|
1604
1714
|
this.#onDelete = options.onDelete;
|
|
1715
|
+
this.#onRename = options.onRename;
|
|
1716
|
+
this.#onSetPinned = options.onSetPinned;
|
|
1605
1717
|
this.#loadAllSessions = options.loadAllSessions;
|
|
1606
1718
|
this.#folderSessions = sessions;
|
|
1607
1719
|
// Storage directory, not recorded cwd: one folder's sessions may record
|
|
1608
1720
|
// symlink aliases of the same path, which must not turn the column on.
|
|
1609
1721
|
this.#folderShowCwd = options.showCwd ?? new Set(sessions.map(session => path.dirname(session.path))).size > 1;
|
|
1610
|
-
this.#globalSessions = options.allSessions
|
|
1722
|
+
this.#globalSessions = Array.isArray(options.allSessions)
|
|
1723
|
+
? options.allSessions
|
|
1724
|
+
: (options.allSessions?.sessions ?? null);
|
|
1611
1725
|
this.#getTerminalRows = options.getTerminalRows ?? (() => 24);
|
|
1612
1726
|
this.#fillHeight = options.fillHeight ?? false;
|
|
1613
1727
|
this.#title = options.title ?? tuiText("ssTitleResume", "Resume Session");
|
|
1614
1728
|
this.#actionLabel = options.actionLabel ?? "Resume";
|
|
1615
1729
|
this.#pickerTitle = options.title;
|
|
1616
1730
|
this.#standalone = options.standalone ?? false;
|
|
1731
|
+
if (options.completeSessions) {
|
|
1732
|
+
void options.completeSessions.then(rows => {
|
|
1733
|
+
const next = rows.filter(row => !this.#resumeHidden.has(row.path));
|
|
1734
|
+
const selected = this.#sessionList.selectedSession?.path;
|
|
1735
|
+
this.#folderSessions = next;
|
|
1736
|
+
if (this.#scope === "folder") {
|
|
1737
|
+
this.#sessionList.setSessions(next, this.#folderShowCwd);
|
|
1738
|
+
if (selected) this.#sessionList.selectSession(selected);
|
|
1739
|
+
}
|
|
1740
|
+
this.#onRequestRender?.();
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1617
1743
|
this.#resumeSource = options.resumeSource;
|
|
1618
1744
|
this.#resumeScope = options.resumeSource?.initialScope ?? "workspace";
|
|
1619
1745
|
this.#deleteMode = options.deleteMode ?? options.resumeSource?.deleteMode ?? "permanent";
|
|
@@ -1657,6 +1783,16 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1657
1783
|
this.#showDeleteConfirmation(session);
|
|
1658
1784
|
};
|
|
1659
1785
|
}
|
|
1786
|
+
if (this.#onRename) {
|
|
1787
|
+
this.#sessionList.onRenameRequest = (session: T) => {
|
|
1788
|
+
this.#showRenameDialog(session);
|
|
1789
|
+
};
|
|
1790
|
+
}
|
|
1791
|
+
if (this.#onSetPinned) {
|
|
1792
|
+
this.#sessionList.onPinRequest = (session: T, pinned: boolean) => {
|
|
1793
|
+
void this.#setPinned(session, pinned);
|
|
1794
|
+
};
|
|
1795
|
+
}
|
|
1660
1796
|
if (this.#loadAllSessions || this.#globalSessions) {
|
|
1661
1797
|
this.#sessionList.onToggleScope = () => {
|
|
1662
1798
|
void this.#toggleScope();
|
|
@@ -1723,7 +1859,7 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1723
1859
|
* never pays for the cross-project scan.
|
|
1724
1860
|
*/
|
|
1725
1861
|
async #toggleScope(): Promise<void> {
|
|
1726
|
-
if (this.#toggling || this.#confirmationDialog) return;
|
|
1862
|
+
if (this.#toggling || this.#confirmationDialog || this.#renameDialog) return;
|
|
1727
1863
|
if (this.#scope === "folder") {
|
|
1728
1864
|
let global = this.#globalSessions;
|
|
1729
1865
|
if (!global) {
|
|
@@ -1735,7 +1871,8 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1735
1871
|
this.#message = { kind: "loading", text: loading };
|
|
1736
1872
|
this.#onRequestRender?.();
|
|
1737
1873
|
try {
|
|
1738
|
-
|
|
1874
|
+
const loaded = await this.#loadAllSessions();
|
|
1875
|
+
global = Array.isArray(loaded) ? loaded : loaded.sessions;
|
|
1739
1876
|
} catch (err) {
|
|
1740
1877
|
this.#showError(err instanceof Error ? err.message : String(err));
|
|
1741
1878
|
this.#toggling = false;
|
|
@@ -1865,6 +2002,107 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1865
2002
|
this.#onRequestRender?.();
|
|
1866
2003
|
}
|
|
1867
2004
|
|
|
2005
|
+
/**
|
|
2006
|
+
* Mirror a renamed title into the scope caches. The visible list holds
|
|
2007
|
+
* one entry per session, but the folder and all-projects caches can hold
|
|
2008
|
+
* their own copies of the same session, so a rename has to reach all of
|
|
2009
|
+
* them or a scope switch shows the old title again.
|
|
2010
|
+
*/
|
|
2011
|
+
#syncScopeTitles(sessionPath: string, title: string): void {
|
|
2012
|
+
for (const cache of [this.#folderSessions, this.#globalSessions]) {
|
|
2013
|
+
if (!cache) continue;
|
|
2014
|
+
const entry = cache.find(s => s.path === sessionPath);
|
|
2015
|
+
if (!entry) continue;
|
|
2016
|
+
entry.title = title;
|
|
2017
|
+
delete (entry as NativeSessionInfo)[kNativeItem];
|
|
2018
|
+
delete (entry as SearchableSessionInfo)[kSearchTextLower];
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
/** Close the rename dialog without changes, restoring the session list. */
|
|
2023
|
+
#closeRenameDialog(): void {
|
|
2024
|
+
if (!this.#renameDialog) return;
|
|
2025
|
+
this.#renameDialog = null;
|
|
2026
|
+
this.#renameField = null;
|
|
2027
|
+
// Restore the SessionList into the content slot so the picker is back
|
|
2028
|
+
// to its normal layout on the very next render — the same frame the
|
|
2029
|
+
// dialog disappears.
|
|
2030
|
+
this.#contentSlot.clear();
|
|
2031
|
+
this.#contentSlot.addChild(this.#sessionList);
|
|
2032
|
+
this.#onRequestRender?.();
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
#showRenameDialog(session: T): void {
|
|
2036
|
+
if (!this.#onRename || this.#confirmationDialog || this.#renameDialog || this.#toggling) return;
|
|
2037
|
+
// One submit at a time: a second Enter while the rename is still
|
|
2038
|
+
// awaiting disk I/O would queue a second write for the same session.
|
|
2039
|
+
let pending = false;
|
|
2040
|
+
// This editor's own identity: a submit that settles after the user
|
|
2041
|
+
// opened another editor must not close it.
|
|
2042
|
+
const owner = new OverlayPanel("Rename Session");
|
|
2043
|
+
const submit = async (value: string) => {
|
|
2044
|
+
if (pending) return;
|
|
2045
|
+
const title = value.trim();
|
|
2046
|
+
// Empty treated as cancel: Esc and a blank submit both leave the title.
|
|
2047
|
+
if (title.length === 0) {
|
|
2048
|
+
this.#closeRenameDialog();
|
|
2049
|
+
return;
|
|
2050
|
+
}
|
|
2051
|
+
const rename = this.#onRename;
|
|
2052
|
+
if (!rename) {
|
|
2053
|
+
this.#closeRenameDialog();
|
|
2054
|
+
return;
|
|
2055
|
+
}
|
|
2056
|
+
this.#clearError();
|
|
2057
|
+
pending = true;
|
|
2058
|
+
try {
|
|
2059
|
+
const stored = await rename(session, title);
|
|
2060
|
+
if (stored) {
|
|
2061
|
+
// The stored title is the canonical one (the session may
|
|
2062
|
+
// collapse whitespace), so the row and the search index
|
|
2063
|
+
// match what is on disk.
|
|
2064
|
+
this.#sessionList.renameSessionTitle(session.path, stored);
|
|
2065
|
+
this.#syncScopeTitles(session.path, stored);
|
|
2066
|
+
if (this.#preview?.session === session) this.#preview = undefined;
|
|
2067
|
+
} else {
|
|
2068
|
+
this.#showError("Failed to rename session.");
|
|
2069
|
+
}
|
|
2070
|
+
} catch (err) {
|
|
2071
|
+
this.#showError(err instanceof Error ? err.message : String(err));
|
|
2072
|
+
} finally {
|
|
2073
|
+
pending = false;
|
|
2074
|
+
}
|
|
2075
|
+
if (this.#renameDialog === owner) this.#closeRenameDialog();
|
|
2076
|
+
};
|
|
2077
|
+
const field = new TextFormField({
|
|
2078
|
+
theme: formTheme,
|
|
2079
|
+
label: "Rename session",
|
|
2080
|
+
initialValue: session.title ?? "",
|
|
2081
|
+
empty: "cancel",
|
|
2082
|
+
onSubmit: value => {
|
|
2083
|
+
void submit(value);
|
|
2084
|
+
},
|
|
2085
|
+
onCancel: () => {
|
|
2086
|
+
// A cancel while the rename is still in flight must not tear
|
|
2087
|
+
// the editor down underneath it; the submit closes it.
|
|
2088
|
+
if (pending) return;
|
|
2089
|
+
this.#closeRenameDialog();
|
|
2090
|
+
},
|
|
2091
|
+
});
|
|
2092
|
+
field.focused = true;
|
|
2093
|
+
owner.addChild(field);
|
|
2094
|
+
this.#renameDialog = owner;
|
|
2095
|
+
this.#renameField = field;
|
|
2096
|
+
// Swap the SessionList out of the content slot and mount the dialog in its
|
|
2097
|
+
// place: the dialog competes only with the SessionList's rendered budget,
|
|
2098
|
+
// never the SessionList AND the picker chrome, so the picker frame stays
|
|
2099
|
+
// inside the terminal viewport and the TUI never commits the header into
|
|
2100
|
+
// scrollback (issue #3283).
|
|
2101
|
+
this.#contentSlot.clear();
|
|
2102
|
+
this.#contentSlot.addChild(owner);
|
|
2103
|
+
this.#onRequestRender?.();
|
|
2104
|
+
}
|
|
2105
|
+
|
|
1868
2106
|
/**
|
|
1869
2107
|
* Render the panel directly so fill-height mode can keep its footer pinned
|
|
1870
2108
|
* while sharing OverlayPanel's exact rounded-box chrome. Children receive
|
|
@@ -1889,9 +2127,34 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1889
2127
|
return lines;
|
|
1890
2128
|
}
|
|
1891
2129
|
|
|
2130
|
+
/** Persist a pin change, then reorder the list; a failure shows the error and leaves the list as it was. */
|
|
2131
|
+
async #setPinned(session: T, pinned: boolean): Promise<void> {
|
|
2132
|
+
if (!this.#onSetPinned) return;
|
|
2133
|
+
this.#clearError();
|
|
2134
|
+
try {
|
|
2135
|
+
await this.#onSetPinned(session, pinned);
|
|
2136
|
+
this.#sessionList.setPinned(session.id, pinned);
|
|
2137
|
+
} catch (err) {
|
|
2138
|
+
this.#showError(err instanceof Error ? err.message : String(err));
|
|
2139
|
+
}
|
|
2140
|
+
this.#onRequestRender?.();
|
|
2141
|
+
}
|
|
2142
|
+
|
|
2143
|
+
/** The pin action that applies to the selected session: unpin when it is pinned, else pin. */
|
|
2144
|
+
#pinAction(): { binding: "app.session.pin" | "app.session.unpin"; label: string } | undefined {
|
|
2145
|
+
if (!this.#onSetPinned) return undefined;
|
|
2146
|
+
return this.#sessionList.selectedPinned
|
|
2147
|
+
? { binding: "app.session.unpin", label: "unpin" }
|
|
2148
|
+
: { binding: "app.session.pin", label: "pin" };
|
|
2149
|
+
}
|
|
2150
|
+
|
|
1892
2151
|
/** Blank · keybinding hint · bottom border. Rendered by {@link render}. */
|
|
1893
2152
|
#footerLines(width: number): string[] {
|
|
1894
2153
|
const cancel = interruptKey();
|
|
2154
|
+
const scopeHint = this.#scope === "all" ? "current folder" : "all projects";
|
|
2155
|
+
// Keys mirror SessionList#handleInput; cancel is `app.interrupt` (raw Escape when unbound).
|
|
2156
|
+
const pin = this.#pinAction();
|
|
2157
|
+
const pinKey = pin && getKeybindings().getKeys(pin.binding)[0];
|
|
1895
2158
|
const hint = this.#resumeTree
|
|
1896
2159
|
? composeFooter(
|
|
1897
2160
|
width,
|
|
@@ -1918,7 +2181,7 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1918
2181
|
)
|
|
1919
2182
|
: theme.fg(
|
|
1920
2183
|
"muted",
|
|
1921
|
-
`[${this.#onDelete ? `${formatKeyHints(["delete", "backspace"])} delete · ` : ""}${formatKeyHint("
|
|
2184
|
+
`[${this.#onDelete ? `${formatKeyHints(["delete", "backspace"])} delete · ` : ""}${this.#onRename ? `${formatKeyHint("f2")} rename · ` : ""}${pinKey ? `${formatKeyHint(pinKey)} ${pin.label} · ` : ""}${formatKeyHint("enter")} select · ${formatKeyHint("tab")} ${scopeHint} · ${cancel} cancel]`,
|
|
1922
2185
|
);
|
|
1923
2186
|
return [row("", width), row(hint, width), row("", width), bottomBorder(width)];
|
|
1924
2187
|
}
|
|
@@ -1930,31 +2193,41 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1930
2193
|
|
|
1931
2194
|
/** Over the transcript the picker is its own sheet (`layer`); the standalone app fills the screen surface. */
|
|
1932
2195
|
nativeSheet(cx: DescribeContext): boolean {
|
|
2196
|
+
// A rename editor is a card with a text field, not a picker sheet: it
|
|
2197
|
+
// renders in place, like the generic composition does.
|
|
2198
|
+
if (this.#renameDialog) return false;
|
|
1933
2199
|
return cx.supports("picker") && !this.#standalone;
|
|
1934
2200
|
}
|
|
1935
2201
|
|
|
1936
2202
|
/**
|
|
1937
2203
|
* With the `picker` kind: the data-first session picker (§4.7). Otherwise
|
|
1938
2204
|
* scope `tabs`, loading/error message, then the search `input` and session
|
|
1939
|
-
* `list` — or the delete-confirmation dialog in their place, as on
|
|
1940
|
-
* path — and the key-hint footer.
|
|
2205
|
+
* `list` — or the delete-confirmation / rename dialog in their place, as on
|
|
2206
|
+
* the ANSI path — and the key-hint footer.
|
|
1941
2207
|
*/
|
|
1942
2208
|
override describe(cx: DescribeContext): NativeNode {
|
|
1943
|
-
|
|
2209
|
+
// The picker kind has no text-input affordance, so a rename would
|
|
2210
|
+
// capture every keystroke into an invisible field. While the rename
|
|
2211
|
+
// editor is open, describe the card path instead (the same fallback
|
|
2212
|
+
// the hook selector uses for its slider and countdown).
|
|
2213
|
+
if (cx.supports("picker") && !this.#renameDialog) {
|
|
1944
2214
|
// The native picker owns its own event model; raw keys must keep going
|
|
1945
2215
|
// to the list even though the ANSI tree is constructed.
|
|
1946
2216
|
this.#nativePicker = true;
|
|
1947
2217
|
return this.#describePicker();
|
|
1948
2218
|
}
|
|
1949
2219
|
this.#nativePicker = false;
|
|
1950
|
-
|
|
2220
|
+
// The rename card is an in-place fallback on picker terminals; only a
|
|
2221
|
+
// terminal without the kind swaps the flat list for the ANSI tree.
|
|
2222
|
+
if (!cx.supports("picker")) this.#mountResumeTree();
|
|
1951
2223
|
const list = this.#sessionList.describeList();
|
|
2224
|
+
const dialog = this.#confirmationDialog ?? this.#renameDialog;
|
|
1952
2225
|
const memo = this.#nativeMemo;
|
|
1953
2226
|
if (
|
|
1954
2227
|
memo?.title === this.title &&
|
|
1955
2228
|
memo.scope === this.#scope &&
|
|
1956
2229
|
memo.message === this.#message &&
|
|
1957
|
-
memo.dialog ===
|
|
2230
|
+
memo.dialog === dialog &&
|
|
1958
2231
|
memo.list === list
|
|
1959
2232
|
) {
|
|
1960
2233
|
return memo.node;
|
|
@@ -1968,13 +2241,16 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1968
2241
|
} else if (message) {
|
|
1969
2242
|
children.push(node("text", { spans: [span(message.text, "error")] }, undefined, "message"));
|
|
1970
2243
|
}
|
|
1971
|
-
if (
|
|
1972
|
-
children.push(
|
|
2244
|
+
if (dialog) {
|
|
2245
|
+
children.push(dialog);
|
|
1973
2246
|
} else {
|
|
1974
2247
|
children.push(this.#sessionList.searchInput, list);
|
|
1975
2248
|
}
|
|
1976
2249
|
const hints: (NativeHint | undefined)[] = [];
|
|
1977
2250
|
if (this.#onDelete) hints.push({ keys: ["delete", "backspace"], label: "delete" });
|
|
2251
|
+
if (this.#onRename) hints.push({ keys: ["f2"], label: "rename" });
|
|
2252
|
+
const pin = this.#pinAction();
|
|
2253
|
+
if (pin) hints.push(actionHint(pin.binding, pin.label));
|
|
1978
2254
|
hints.push({ keys: ["enter"], label: "select" });
|
|
1979
2255
|
if (this.#sessionList.onToggleScope) {
|
|
1980
2256
|
hints.push({ keys: ["tab"], label: this.#scope === "all" ? "current folder" : "all projects" });
|
|
@@ -1988,7 +2264,7 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
1988
2264
|
title: this.title,
|
|
1989
2265
|
scope: this.#scope,
|
|
1990
2266
|
message,
|
|
1991
|
-
dialog
|
|
2267
|
+
dialog,
|
|
1992
2268
|
list,
|
|
1993
2269
|
node: result,
|
|
1994
2270
|
};
|
|
@@ -2276,8 +2552,9 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
2276
2552
|
* `lg` cards sheet (`screen` for the standalone app): sessions grouped by
|
|
2277
2553
|
* day (ranked flat while searching), the selected session's preview, the
|
|
2278
2554
|
* delete confirm strip, and the actions of the keys Enter, Delete/Backspace,
|
|
2279
|
-
*
|
|
2280
|
-
*
|
|
2555
|
+
* F2 (rename), the pin keys (Pin / Unpin, whichever applies to the selected
|
|
2556
|
+
* session), Tab (the scope toggle, labelled with the scope it switches
|
|
2557
|
+
* to) and Esc. Untitled unless the caller named it; the placeholder says the scope.
|
|
2281
2558
|
*/
|
|
2282
2559
|
#describePicker(): NativeNode {
|
|
2283
2560
|
if (this.#resumeSource) return this.#describeResumePicker();
|
|
@@ -2287,6 +2564,7 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
2287
2564
|
const message = this.#message;
|
|
2288
2565
|
const errorOpen = this.#pickerErrorOpen && message?.kind === "error";
|
|
2289
2566
|
const choice = this.#deleteChoice;
|
|
2567
|
+
const rename = this.#renameDialog;
|
|
2290
2568
|
const memo = this.#pickerMemo;
|
|
2291
2569
|
if (
|
|
2292
2570
|
memo?.view === view &&
|
|
@@ -2294,7 +2572,8 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
2294
2572
|
memo.scope === this.#scope &&
|
|
2295
2573
|
memo.message === message &&
|
|
2296
2574
|
memo.errorOpen === errorOpen &&
|
|
2297
|
-
memo.choice === choice
|
|
2575
|
+
memo.choice === choice &&
|
|
2576
|
+
memo.rename === rename
|
|
2298
2577
|
) {
|
|
2299
2578
|
return memo.node;
|
|
2300
2579
|
}
|
|
@@ -2302,6 +2581,9 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
2302
2581
|
const toggle = list.onToggleScope !== undefined;
|
|
2303
2582
|
const actions = [pickerAction("resume", this.#actionLabel, "enter", { primary: true })];
|
|
2304
2583
|
if (this.#onDelete) actions.push(pickerAction("delete", "Delete", "backspace"));
|
|
2584
|
+
if (this.#onRename) actions.push(pickerAction("rename", "Rename", "f2"));
|
|
2585
|
+
const pin = this.#pinAction();
|
|
2586
|
+
if (pin) actions.push(pickerAction("pin", pin.label === "pin" ? "Pin" : "Unpin", bindingKeys(pin.binding)));
|
|
2305
2587
|
if (toggle) {
|
|
2306
2588
|
actions.push(pickerAction("scope", this.#scope === "all" ? "This folder" : "All projects", "tab"));
|
|
2307
2589
|
}
|
|
@@ -2352,7 +2634,7 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
2352
2634
|
},
|
|
2353
2635
|
preview,
|
|
2354
2636
|
);
|
|
2355
|
-
this.#pickerMemo = { view, preview, scope: this.#scope, message, errorOpen, choice, node: result };
|
|
2637
|
+
this.#pickerMemo = { view, preview, scope: this.#scope, message, errorOpen, choice, rename, node: result };
|
|
2356
2638
|
return result;
|
|
2357
2639
|
}
|
|
2358
2640
|
|
|
@@ -2390,31 +2672,37 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
2390
2672
|
|
|
2391
2673
|
/**
|
|
2392
2674
|
* Picker pointer events run the keys' paths: a row click selects (arrows),
|
|
2393
|
-
* a second click or `Resume` resumes (Enter), `Delete` asks (Delete),
|
|
2394
|
-
* tab or `All projects` toggles scope (Tab),
|
|
2395
|
-
* the confirm strip answers the delete dialog (Yes / Esc).
|
|
2675
|
+
* a second click or `Resume` resumes (Enter), `Delete` asks (Delete),
|
|
2676
|
+
* `Rename` renames (F2), `Pin` / `Unpin` flips the pin, the tab or `All projects` toggles scope (Tab),
|
|
2677
|
+
* `Close` cancels (Esc), and the confirm strip answers the delete dialog (Yes / Esc).
|
|
2396
2678
|
*/
|
|
2397
2679
|
#handlePickerEvent(ev: PickerEvent): void {
|
|
2398
2680
|
const list = this.#sessionList;
|
|
2399
2681
|
const choice = this.#deleteChoice;
|
|
2400
2682
|
if (ev.kind !== "action") {
|
|
2401
|
-
if (choice) return;
|
|
2683
|
+
if (choice || this.#renameDialog) return;
|
|
2402
2684
|
if (ev.kind === "select") list.selectSession(ev.item);
|
|
2403
2685
|
else list.confirmSession(ev.item);
|
|
2404
2686
|
return;
|
|
2405
2687
|
}
|
|
2406
2688
|
if (ev.act === "delete-confirm") choice?.confirm();
|
|
2407
|
-
else if (ev.act === "cancel")
|
|
2408
|
-
|
|
2689
|
+
else if (ev.act === "cancel") {
|
|
2690
|
+
if (choice) choice.cancel();
|
|
2691
|
+
else this.#closeRenameDialog();
|
|
2692
|
+
} else if (ev.act === "tab") {
|
|
2409
2693
|
if (this.#resumeSource && ev.value) this.#setResumeScope(ev.value as ResumeScopeKindLike);
|
|
2410
2694
|
} else if (ev.act === "close") {
|
|
2411
2695
|
if (choice) choice.cancel();
|
|
2696
|
+
else if (this.#renameDialog) this.#closeRenameDialog();
|
|
2412
2697
|
else list.onCancel?.();
|
|
2413
|
-
} else if (choice) return;
|
|
2698
|
+
} else if (choice || this.#renameDialog) return;
|
|
2414
2699
|
else if (ev.act === "resume") list.resumeSelected();
|
|
2415
2700
|
else if (ev.act === "delete") list.requestDelete();
|
|
2416
|
-
else if (ev.act === "
|
|
2417
|
-
else if (ev.act === "
|
|
2701
|
+
else if (ev.act === "rename") list.requestRename();
|
|
2702
|
+
else if (ev.act === "pin") {
|
|
2703
|
+
if (this.#resumeSource) this.#toggleResumePin();
|
|
2704
|
+
else list.requestPin();
|
|
2705
|
+
} else if (ev.act === "refresh") this.#refreshResume();
|
|
2418
2706
|
else if (ev.act === "scope") {
|
|
2419
2707
|
list.onToggleScope?.();
|
|
2420
2708
|
} else if (ev.act === "clear") list.clearSearch();
|
|
@@ -2434,7 +2722,8 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
2434
2722
|
if (event.type === "select" && event.item !== this.#scope) void this.#toggleScope();
|
|
2435
2723
|
return;
|
|
2436
2724
|
}
|
|
2437
|
-
if (event.key === "list" && !this.#confirmationDialog
|
|
2725
|
+
if (event.key === "list" && !this.#confirmationDialog && !this.#renameDialog)
|
|
2726
|
+
this.#sessionList.confirmSession(event.item);
|
|
2438
2727
|
}
|
|
2439
2728
|
|
|
2440
2729
|
handleInput(keyData: string): void {
|
|
@@ -2446,6 +2735,8 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
2446
2735
|
}
|
|
2447
2736
|
if (this.#confirmationDialog) {
|
|
2448
2737
|
this.#confirmationDialog.handleInput(keyData);
|
|
2738
|
+
} else if (this.#renameDialog) {
|
|
2739
|
+
this.#renameField?.handleInput(keyData);
|
|
2449
2740
|
} else if (this.#resumeTree && !this.#nativePicker) {
|
|
2450
2741
|
this.#resumeTree.handleInput(keyData);
|
|
2451
2742
|
} else {
|
|
@@ -2460,7 +2751,7 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
|
|
|
2460
2751
|
* pointer. Mouse is inert while the delete-confirmation dialog is open.
|
|
2461
2752
|
*/
|
|
2462
2753
|
#handleMouse(data: string): void {
|
|
2463
|
-
if (this.#confirmationDialog) return;
|
|
2754
|
+
if (this.#confirmationDialog || this.#renameDialog) return;
|
|
2464
2755
|
if (this.#resumeTree) {
|
|
2465
2756
|
// The panel paints the tree inside `│ ` … ` │`; rows start at
|
|
2466
2757
|
// #listLineOffset and the first content column is 2.
|