@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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Component } from "../tui";
|
|
2
|
+
import { truncateToWidth, visibleWidth } from "../utils";
|
|
2
3
|
import { fgOrPlain, theme } from "../theme/index";
|
|
3
4
|
import type { NativeNode } from "../native/node";
|
|
4
5
|
import { EMPTY_NODE } from "../native/describe";
|
|
@@ -13,7 +14,9 @@ import { EMPTY_NODE } from "../native/describe";
|
|
|
13
14
|
*/
|
|
14
15
|
export class DynamicBorder implements Component {
|
|
15
16
|
#color: (str: string) => string;
|
|
17
|
+
#label: string | (() => string) | undefined;
|
|
16
18
|
#cachedWidth = -1;
|
|
19
|
+
#cachedLabel: string | undefined;
|
|
17
20
|
#cachedLines: string[] | undefined;
|
|
18
21
|
|
|
19
22
|
constructor(color: (str: string) => string = str => fgOrPlain("border", str)) {
|
|
@@ -25,19 +28,42 @@ export class DynamicBorder implements Component {
|
|
|
25
28
|
this.#cachedLines = undefined;
|
|
26
29
|
}
|
|
27
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Pre-styled text set into the rule after a short lead (`─── label ────`);
|
|
33
|
+
* undefined draws a plain rule. A function label is re-read every render,
|
|
34
|
+
* for live text such as a spinner.
|
|
35
|
+
*/
|
|
36
|
+
setLabel(label: string | (() => string) | undefined): void {
|
|
37
|
+
if (label === this.#label) return;
|
|
38
|
+
this.#label = label;
|
|
39
|
+
this.invalidate();
|
|
40
|
+
}
|
|
41
|
+
|
|
28
42
|
/** Native terminals draw their own chrome; a border rule describes nothing. */
|
|
29
43
|
describe(): NativeNode {
|
|
30
44
|
return EMPTY_NODE;
|
|
31
45
|
}
|
|
32
46
|
|
|
33
47
|
render(width: number): readonly string[] {
|
|
34
|
-
|
|
48
|
+
const label = typeof this.#label === "function" ? this.#label() : this.#label;
|
|
49
|
+
if (this.#cachedLines && this.#cachedWidth === width && this.#cachedLabel === label) {
|
|
35
50
|
return this.#cachedLines;
|
|
36
51
|
}
|
|
37
52
|
const horizontal = typeof theme === "undefined" ? "─" : theme.boxRound.horizontal;
|
|
38
|
-
const lines = [this.#
|
|
53
|
+
const lines = [this.#rule(horizontal, Math.max(1, width), label)];
|
|
39
54
|
this.#cachedWidth = width;
|
|
55
|
+
this.#cachedLabel = label;
|
|
40
56
|
this.#cachedLines = lines;
|
|
41
57
|
return lines;
|
|
42
58
|
}
|
|
59
|
+
|
|
60
|
+
#rule(horizontal: string, width: number, label: string | undefined): string {
|
|
61
|
+
const lead = horizontal.repeat(3);
|
|
62
|
+
// The label sits between single spaces and leaves at least one rule cell after it.
|
|
63
|
+
const labelRoom = width - visibleWidth(lead) - 3;
|
|
64
|
+
if (!label || labelRoom < 1) return this.#color(horizontal.repeat(width));
|
|
65
|
+
const fitted = ` ${truncateToWidth(label, labelRoom)} `;
|
|
66
|
+
const rest = width - visibleWidth(lead) - visibleWidth(fitted);
|
|
67
|
+
return `${this.#color(lead)}${fitted}${this.#color(horizontal.repeat(rest))}`;
|
|
68
|
+
}
|
|
43
69
|
}
|
package/src/chrome/index.ts
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { TspText } from "@linxiraos/pi-wire";
|
|
2
|
+
import type { NativeNode } from "../native/node";
|
|
3
|
+
import type { Component } from "../tui";
|
|
4
|
+
import { TranscriptBlock } from "./transcript-container";
|
|
5
|
+
/** How loud an inline transcript notice is; a native terminal styles it as `zeta.notice.<tone>`. */
|
|
6
|
+
export type NoticeTone = "info" | "success" | "warning" | "error";
|
|
7
|
+
/** Optional parts of a {@link noticeRow}. */
|
|
8
|
+
export interface NoticeRowOptions {
|
|
9
|
+
/** Icon name in place of the tone's own (`read` for a file read, `download` for an update). */
|
|
10
|
+
readonly icon?: string;
|
|
11
|
+
readonly key?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* One inline transcript notice for a native terminal (`zeta.notice.<tone>`): a
|
|
15
|
+
* leading icon beside the wrapped message. Warnings, errors, background-job
|
|
16
|
+
* completions and prompt file reads all draw as this row, so they read alike.
|
|
17
|
+
* The tone colors the icon (an info notice keeps it quiet); the message spans
|
|
18
|
+
* carry emphasis only (`path`, `mono`, `dim`), never the tone itself.
|
|
19
|
+
*/
|
|
20
|
+
export declare function noticeRow(tone: NoticeTone, message: TspText, options?: NoticeRowOptions): NativeNode;
|
|
21
|
+
/**
|
|
22
|
+
* A transcript block that a native terminal draws as one {@link noticeRow}
|
|
23
|
+
* while a text terminal draws `ansi`.
|
|
24
|
+
*/
|
|
25
|
+
export declare class TranscriptNotice extends TranscriptBlock {
|
|
26
|
+
#private;
|
|
27
|
+
constructor(native: NativeNode, ansi: readonly Component[]);
|
|
28
|
+
/**
|
|
29
|
+
* `showWarning` / `showError`: a blank row and the `Warning: …` / `Error: …`
|
|
30
|
+
* line in its color in a text terminal; natively the tone's icon and the
|
|
31
|
+
* message, the label left to the icon.
|
|
32
|
+
*/
|
|
33
|
+
static line(tone: "warning" | "error", message: string): TranscriptNotice;
|
|
34
|
+
describe(): NativeNode;
|
|
35
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { TspText } from "@linxiraos/pi-wire";
|
|
2
|
+
import { Spacer } from "../components/spacer";
|
|
3
|
+
import { Text } from "../components/text";
|
|
4
|
+
import { node, text } from "../native/describe";
|
|
5
|
+
import type { NativeNode } from "../native/node";
|
|
6
|
+
import { styledSpans } from "../native/spans";
|
|
7
|
+
import { theme } from "../theme";
|
|
8
|
+
import type { Component } from "../tui";
|
|
9
|
+
import { TranscriptBlock } from "./transcript-container";
|
|
10
|
+
|
|
11
|
+
/** How loud an inline transcript notice is; a native terminal styles it as `zeta.notice.<tone>`. */
|
|
12
|
+
export type NoticeTone = "info" | "success" | "warning" | "error";
|
|
13
|
+
|
|
14
|
+
/** Each tone's default icon. */
|
|
15
|
+
const ICONS: Readonly<Record<NoticeTone, string>> = {
|
|
16
|
+
info: "info",
|
|
17
|
+
success: "success",
|
|
18
|
+
warning: "warning",
|
|
19
|
+
error: "error",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The word a warning or error leads with: a text terminal writes it
|
|
24
|
+
* (`Warning: …`); a native row leaves it to the icon, whose name it becomes
|
|
25
|
+
* for screen readers.
|
|
26
|
+
*/
|
|
27
|
+
const LABELS = { warning: "Warning", error: "Error" } as const;
|
|
28
|
+
|
|
29
|
+
/** Optional parts of a {@link noticeRow}. */
|
|
30
|
+
export interface NoticeRowOptions {
|
|
31
|
+
/** Icon name in place of the tone's own (`read` for a file read, `download` for an update). */
|
|
32
|
+
readonly icon?: string;
|
|
33
|
+
readonly key?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* One inline transcript notice for a native terminal (`zeta.notice.<tone>`): a
|
|
38
|
+
* leading icon beside the wrapped message. Warnings, errors, background-job
|
|
39
|
+
* completions and prompt file reads all draw as this row, so they read alike.
|
|
40
|
+
* The tone colors the icon (an info notice keeps it quiet); the message spans
|
|
41
|
+
* carry emphasis only (`path`, `mono`, `dim`), never the tone itself.
|
|
42
|
+
*/
|
|
43
|
+
export function noticeRow(tone: NoticeTone, message: TspText, options: NoticeRowOptions = {}): NativeNode {
|
|
44
|
+
const icon = node("icon", {
|
|
45
|
+
name: options.icon ?? ICONS[tone],
|
|
46
|
+
tone: tone === "info" ? undefined : tone,
|
|
47
|
+
aria: tone === "warning" || tone === "error" ? LABELS[tone] : undefined,
|
|
48
|
+
});
|
|
49
|
+
return node(
|
|
50
|
+
"row",
|
|
51
|
+
{ role: `zeta.notice.${tone}`, tone, gap: "sm", align: "start" },
|
|
52
|
+
[icon, text(message, { wrap: "word", grow: 1, shrink: 1 })],
|
|
53
|
+
options.key,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* A transcript block that a native terminal draws as one {@link noticeRow}
|
|
59
|
+
* while a text terminal draws `ansi`.
|
|
60
|
+
*/
|
|
61
|
+
export class TranscriptNotice extends TranscriptBlock {
|
|
62
|
+
readonly #native: NativeNode;
|
|
63
|
+
|
|
64
|
+
constructor(native: NativeNode, ansi: readonly Component[]) {
|
|
65
|
+
super();
|
|
66
|
+
for (const child of ansi) this.addChild(child);
|
|
67
|
+
this.#native = native;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* `showWarning` / `showError`: a blank row and the `Warning: …` / `Error: …`
|
|
72
|
+
* line in its color in a text terminal; natively the tone's icon and the
|
|
73
|
+
* message, the label left to the icon.
|
|
74
|
+
*/
|
|
75
|
+
static line(tone: "warning" | "error", message: string): TranscriptNotice {
|
|
76
|
+
const line = new Text(`${LABELS[tone]}: ${message}`, 1, 0).setStyleFn(t => theme.fg(tone, t));
|
|
77
|
+
return new TranscriptNotice(noticeRow(tone, styledSpans(message)), [new Spacer(1), line]);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
override describe(): NativeNode {
|
|
81
|
+
return this.#native;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -1,24 +1,36 @@
|
|
|
1
|
+
import type { TspSpan } from "@linxiraos/pi-wire";
|
|
1
2
|
import type { NativeNode } from "../native/node";
|
|
2
3
|
import { type ThemeColor } from "../theme";
|
|
3
4
|
import { TranscriptBlock } from "./transcript-container";
|
|
4
|
-
|
|
5
|
+
import { type NoticeTone } from "./transcript-notice";
|
|
6
|
+
/** One run of a status row's terminal line, in `color` unless the text is already styled. */
|
|
5
7
|
export interface TranscriptStatusPart {
|
|
6
8
|
readonly text: string;
|
|
7
|
-
readonly color
|
|
8
|
-
/** Glyph art (tree connectors) drawn only in rows; native terminals draw their own structure. */
|
|
9
|
-
readonly rowsOnly?: boolean;
|
|
9
|
+
readonly color?: ThemeColor;
|
|
10
10
|
}
|
|
11
|
-
/**
|
|
11
|
+
/** A status row in a native terminal: its {@link noticeRow}'s tone, icon and message. */
|
|
12
|
+
export interface TranscriptStatusNative {
|
|
13
|
+
readonly tone: NoticeTone;
|
|
14
|
+
/** Icon name in place of the tone's own. */
|
|
15
|
+
readonly icon?: string;
|
|
16
|
+
readonly message: readonly TspSpan[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* One compact transcript status row: the terminal line's themed parts (joined
|
|
20
|
+
* by single spaces, glyphs and brackets included) and the same row natively.
|
|
21
|
+
*/
|
|
12
22
|
export interface TranscriptStatusRow {
|
|
13
23
|
readonly parts: readonly (TranscriptStatusPart | undefined)[];
|
|
14
24
|
readonly indent?: number;
|
|
25
|
+
readonly native: TranscriptStatusNative;
|
|
15
26
|
}
|
|
16
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Shared compact status block for background activity and prompt file reads:
|
|
29
|
+
* one themed line per row in a text terminal, one notice row per row natively
|
|
30
|
+
* (`zeta.status-block`).
|
|
31
|
+
*/
|
|
17
32
|
export declare class TranscriptStatusBlock extends TranscriptBlock {
|
|
18
33
|
#private;
|
|
19
34
|
constructor(rows: readonly TranscriptStatusRow[]);
|
|
20
|
-
/** Append a supplemental line such as an artifact warning. */
|
|
21
|
-
addLine(parts: readonly (TranscriptStatusPart | undefined)[], indent?: number): void;
|
|
22
|
-
/** One wrapped text line per status row. */
|
|
23
35
|
describe(): NativeNode;
|
|
24
36
|
}
|
|
@@ -1,56 +1,58 @@
|
|
|
1
1
|
import type { TspSpan } from "@linxiraos/pi-wire";
|
|
2
2
|
import { Text } from "../components/text";
|
|
3
|
-
import { col
|
|
3
|
+
import { col } from "../native/describe";
|
|
4
4
|
import type { NativeNode } from "../native/node";
|
|
5
5
|
import { type ThemeColor, theme } from "../theme";
|
|
6
6
|
import { TranscriptBlock } from "./transcript-container";
|
|
7
|
+
import { type NoticeTone, noticeRow } from "./transcript-notice";
|
|
7
8
|
|
|
8
|
-
/** One
|
|
9
|
+
/** One run of a status row's terminal line, in `color` unless the text is already styled. */
|
|
9
10
|
export interface TranscriptStatusPart {
|
|
10
11
|
readonly text: string;
|
|
11
|
-
readonly color
|
|
12
|
-
/** Glyph art (tree connectors) drawn only in rows; native terminals draw their own structure. */
|
|
13
|
-
readonly rowsOnly?: boolean;
|
|
12
|
+
readonly color?: ThemeColor;
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
/**
|
|
15
|
+
/** A status row in a native terminal: its {@link noticeRow}'s tone, icon and message. */
|
|
16
|
+
export interface TranscriptStatusNative {
|
|
17
|
+
readonly tone: NoticeTone;
|
|
18
|
+
/** Icon name in place of the tone's own. */
|
|
19
|
+
readonly icon?: string;
|
|
20
|
+
readonly message: readonly TspSpan[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* One compact transcript status row: the terminal line's themed parts (joined
|
|
25
|
+
* by single spaces, glyphs and brackets included) and the same row natively.
|
|
26
|
+
*/
|
|
17
27
|
export interface TranscriptStatusRow {
|
|
18
28
|
readonly parts: readonly (TranscriptStatusPart | undefined)[];
|
|
19
29
|
readonly indent?: number;
|
|
30
|
+
readonly native: TranscriptStatusNative;
|
|
20
31
|
}
|
|
21
32
|
|
|
22
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Shared compact status block for background activity and prompt file reads:
|
|
35
|
+
* one themed line per row in a text terminal, one notice row per row natively
|
|
36
|
+
* (`zeta.status-block`).
|
|
37
|
+
*/
|
|
23
38
|
export class TranscriptStatusBlock extends TranscriptBlock {
|
|
24
|
-
readonly #
|
|
25
|
-
#native: NativeNode | undefined;
|
|
39
|
+
readonly #native: NativeNode;
|
|
26
40
|
|
|
27
41
|
constructor(rows: readonly TranscriptStatusRow[]) {
|
|
28
42
|
super();
|
|
29
|
-
for (const row of rows)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const styled: string[] = [];
|
|
35
|
-
const spans: TspSpan[] = [];
|
|
36
|
-
for (const part of parts) {
|
|
37
|
-
if (!part) continue;
|
|
38
|
-
styled.push(theme.fg(part.color, part.text));
|
|
39
|
-
if (part.rowsOnly) continue;
|
|
40
|
-
if (spans.length > 0) spans.push(span(" "));
|
|
41
|
-
spans.push(span(part.text, part.color));
|
|
43
|
+
for (const row of rows) {
|
|
44
|
+
const styled = row.parts.flatMap(part =>
|
|
45
|
+
part ? [part.color ? theme.fg(part.color, part.text) : part.text] : [],
|
|
46
|
+
);
|
|
47
|
+
this.addChild(new Text(styled.join(" "), row.indent ?? 1, 0));
|
|
42
48
|
}
|
|
43
|
-
this
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
this.#native = col(
|
|
50
|
+
rows.map(({ native }) => noticeRow(native.tone, native.message, { icon: native.icon })),
|
|
51
|
+
{ role: "zeta.status-block" },
|
|
52
|
+
);
|
|
46
53
|
}
|
|
47
54
|
|
|
48
|
-
/** One wrapped text line per status row. */
|
|
49
55
|
override describe(): NativeNode {
|
|
50
|
-
this.#native ??= col(
|
|
51
|
-
this.#rows.map(spans => text(spans, { wrap: "word" })),
|
|
52
|
-
{ role: "zeta.status-block" },
|
|
53
|
-
);
|
|
54
56
|
return this.#native;
|
|
55
57
|
}
|
|
56
58
|
}
|
|
@@ -98,6 +98,14 @@ export declare class Editor implements Component, Focusable {
|
|
|
98
98
|
describeDecorations: ((lines: readonly string[]) => readonly TspEditorDecoration[]) | undefined;
|
|
99
99
|
/** TSP code language of the buffer (`python`, `bash`): the terminal highlights it in the mono face. */
|
|
100
100
|
describeLanguage: (() => string | undefined) | undefined;
|
|
101
|
+
/** Label the TSP field to disable host-side editing while another input owner handles raw keys. */
|
|
102
|
+
nativeKeyPassthrough: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Ask the TSP terminal to keep what is typed into this field and draw it at
|
|
105
|
+
* the caret until this clears, then send it: set while startup cannot read
|
|
106
|
+
* input yet (the prompt composer's deferred-input start).
|
|
107
|
+
*/
|
|
108
|
+
nativeTypeahead: boolean;
|
|
101
109
|
/**
|
|
102
110
|
* TSP chrome around the `editor` node (the prompt composer's chips, mode
|
|
103
111
|
* chip, send/stop): the root role, the children with `input` placed where
|
|
@@ -149,12 +157,21 @@ export declare class Editor implements Component, Focusable {
|
|
|
149
157
|
* cursor. The host styles it (ANSI allowed). Re-evaluated on every render, so hosts can derive
|
|
150
158
|
* it from live state. */
|
|
151
159
|
placeholder?: () => string | undefined;
|
|
152
|
-
/** Whole-message
|
|
153
|
-
*
|
|
154
|
-
* autocomplete is open. A shown prediction replaces the {@link placeholder}; Tab or
|
|
155
|
-
* the rest without submitting.
|
|
156
|
-
*
|
|
157
|
-
|
|
160
|
+
/** Whole-message predictions for the next prompt, most likely first. The first one the single-line
|
|
161
|
+
* buffer is a strict prefix of is painted as ghost text after the cursor while the cursor sits at
|
|
162
|
+
* its end and no autocomplete is open. A shown prediction replaces the {@link placeholder}; Tab or
|
|
163
|
+
* Right inserts the rest without submitting. A buffer the user typed keeps the ghost even when it
|
|
164
|
+
* equals a shorter prediction; once Tab, Right, or the list has inserted one of two or more
|
|
165
|
+
* predictions, no ghost extends it to a longer one, and Tab instead opens a list of all of them
|
|
166
|
+
* that swaps the whole line, also without submitting. Each must be a single line. Re-evaluated on
|
|
167
|
+
* every render, so hosts can derive them from live state. */
|
|
168
|
+
predictions?: () => readonly string[] | undefined;
|
|
169
|
+
/** Called with the prediction's index in {@link predictions} after Tab or Right inserts the rest of
|
|
170
|
+
* a shown prediction, or the alternatives list swaps a different one into the buffer. */
|
|
171
|
+
onPredictionAccepted?: (index: number) => void;
|
|
172
|
+
/** Called for each frame that paints a prediction as ghost text: a terminal frame that draws at
|
|
173
|
+
* least one cell of it, or a native frame that carries it as the editor's ghost. */
|
|
174
|
+
onPredictionShown?: () => void;
|
|
158
175
|
constructor(theme: EditorTheme);
|
|
159
176
|
/** Return bounded editor content, cursor, and transient child state for debug inspection. */
|
|
160
177
|
debugState(): Record<string, unknown>;
|