@linxiraos/pi-tui 1.4.4 → 1.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +208 -207
- package/README.md +34 -34
- package/dist/types/app-keybindings.d.ts +20 -0
- package/dist/types/apps/session-picker.d.ts +5 -0
- package/dist/types/charts/chart-plan.d.ts +9 -7
- package/dist/types/chat/assistant-message.d.ts +15 -3
- package/dist/types/chat/bash-execution.d.ts +2 -0
- package/dist/types/chat/display-preferences.d.ts +2 -0
- package/dist/types/chat/extension-types.d.ts +31 -0
- package/dist/types/chat/reply-write.d.ts +48 -0
- package/dist/types/chat/table-chart.d.ts +4 -3
- package/dist/types/chat/tool-execution.d.ts +1 -2
- package/dist/types/chat/transcript-outline.d.ts +7 -0
- package/dist/types/chat/transcript-render-helpers.d.ts +2 -0
- package/dist/types/chrome/context-map.d.ts +15 -0
- package/dist/types/chrome/context-presentation.d.ts +48 -0
- package/dist/types/chrome/context-view-model.d.ts +77 -0
- package/dist/types/chrome/index.d.ts +1 -0
- package/dist/types/chrome/transcript-notice.d.ts +35 -0
- package/dist/types/chrome/transcript-status.d.ts +20 -8
- package/dist/types/components/editor.d.ts +8 -0
- package/dist/types/components/image.d.ts +20 -0
- package/dist/types/components/loader.d.ts +1 -1
- package/dist/types/components/markdown.d.ts +7 -0
- package/dist/types/native/blobs.d.ts +11 -1
- package/dist/types/native/picker.d.ts +4 -4
- package/dist/types/overlays/advisor-config.d.ts +6 -0
- package/dist/types/overlays/agent-hub-projection.d.ts +3 -1
- package/dist/types/overlays/annotation-overlay.d.ts +7 -1
- package/dist/types/overlays/annotation-types.d.ts +28 -0
- package/dist/types/overlays/ask-dialog.d.ts +12 -3
- package/dist/types/overlays/btw-history-panel.d.ts +16 -2
- package/dist/types/overlays/btw-history.d.ts +7 -0
- package/dist/types/overlays/btw-panel.d.ts +2 -0
- package/dist/types/overlays/context-viewer-format.d.ts +42 -0
- package/dist/types/overlays/context-viewer-overview.d.ts +70 -0
- package/dist/types/overlays/context-viewer.d.ts +25 -0
- package/dist/types/overlays/hook-input.d.ts +1 -0
- package/dist/types/overlays/login-dialog.d.ts +5 -1
- package/dist/types/overlays/mcp-add-wizard.d.ts +2 -0
- package/dist/types/overlays/model-browser.d.ts +10 -1
- package/dist/types/overlays/oauth-selector.d.ts +23 -0
- package/dist/types/overlays/pause-screen.d.ts +13 -3
- package/dist/types/overlays/plan-review-overlay.d.ts +2 -0
- package/dist/types/overlays/rewind-selector.d.ts +1 -1
- package/dist/types/overlays/running-subagent-badge.d.ts +7 -1
- package/dist/types/overlays/session-selector.d.ts +22 -2
- package/dist/types/prompt/composer.d.ts +43 -0
- package/dist/types/prompt/interactive-context-helpers.d.ts +10 -3
- package/dist/types/prompt/macos-spelling.d.ts +2 -2
- package/dist/types/render/extension-links.d.ts +65 -0
- package/dist/types/render/hyperlink.d.ts +38 -7
- package/dist/types/render/index.d.ts +1 -0
- package/dist/types/render/output-pane.d.ts +1 -1
- package/dist/types/render/render-utils.d.ts +7 -1
- package/dist/types/setup/scenes/glyph.d.ts +1 -1
- package/dist/types/setup/scenes/model.d.ts +1 -1
- package/dist/types/setup/scenes/outro.d.ts +5 -4
- package/dist/types/setup/scenes/sign-in.d.ts +13 -8
- package/dist/types/setup/scenes/types.d.ts +16 -1
- package/dist/types/setup/startup-splash.d.ts +1 -1
- package/dist/types/setup/wizard-overlay.d.ts +11 -7
- package/dist/types/setup/wizard.d.ts +5 -1
- package/dist/types/status-line/component.d.ts +3 -3
- package/dist/types/status-line/context-usage.d.ts +42 -35
- package/dist/types/status-line/host.d.ts +6 -2
- package/dist/types/terminal-capabilities.d.ts +7 -0
- package/dist/types/theme/symbols.d.ts +1 -1
- package/dist/types/theme/theme.d.ts +0 -23
- package/dist/types/tools/ask.d.ts +4 -0
- package/dist/types/tools/bash-interactive.d.ts +6 -0
- package/dist/types/tools/bash.d.ts +2 -0
- package/dist/types/tools/default-renderer.d.ts +6 -4
- package/dist/types/tools/edit.d.ts +3 -1
- package/dist/types/tools/fetch.d.ts +1 -0
- package/dist/types/tools/github.d.ts +3 -0
- package/dist/types/tools/grouped-file-output.d.ts +2 -0
- package/dist/types/tools/irc.d.ts +6 -0
- package/dist/types/tools/json-tree.d.ts +23 -4
- package/dist/types/tools/lsp.d.ts +2 -0
- package/dist/types/tools/mcp.d.ts +7 -6
- package/dist/types/tools/native-view.d.ts +1 -1
- package/dist/types/tools/read.d.ts +3 -0
- package/dist/types/tools/renderer.d.ts +2 -0
- package/dist/types/tools/streaming-output.d.ts +11 -0
- package/dist/types/tools/task.d.ts +9 -1
- package/dist/types/tools/url-scheme-host.d.ts +17 -0
- package/dist/types/tools/wait.d.ts +16 -2
- package/dist/types/tools/yield.d.ts +1 -1
- package/dist/types/tui.d.ts +9 -2
- package/dist/types/vim.d.ts +39 -0
- package/package.json +10 -14
- package/src/app-keybindings.d.ts +20 -0
- package/src/app-keybindings.ts +20 -0
- package/src/apps/session-picker.ts +7 -0
- package/src/charts/chart-plan.d.ts +9 -7
- package/src/charts/chart-plan.ts +20 -50
- package/src/chat/advisor-message.ts +2 -0
- package/src/chat/assistant-message.d.ts +15 -3
- package/src/chat/assistant-message.ts +137 -19
- package/src/chat/background-tan-message.ts +4 -0
- package/src/chat/bash-execution.d.ts +2 -0
- package/src/chat/bash-execution.ts +13 -1
- package/src/chat/chat-transcript-builder.ts +58 -28
- package/src/chat/compaction-summary-message.ts +2 -1
- package/src/chat/display-preferences.d.ts +2 -0
- package/src/chat/display-preferences.ts +3 -0
- package/src/chat/extension-types.d.ts +31 -0
- package/src/chat/extension-types.ts +34 -0
- package/src/chat/read-tool-group.ts +1 -2
- package/src/chat/reply-write.d.ts +48 -0
- package/src/chat/reply-write.ts +127 -0
- package/src/chat/skill-message.ts +2 -6
- package/src/chat/table-chart.d.ts +4 -3
- package/src/chat/table-chart.ts +10 -4
- package/src/chat/tool-execution.d.ts +1 -2
- package/src/chat/tool-execution.ts +20 -13
- package/src/chat/transcript-outline.d.ts +7 -0
- package/src/chat/transcript-outline.ts +27 -0
- package/src/chat/transcript-render-helpers.d.ts +2 -0
- package/src/chat/transcript-render-helpers.ts +66 -24
- package/src/chrome/context-map.ts +62 -0
- package/src/chrome/context-presentation.ts +26 -0
- package/src/chrome/context-view-model.ts +73 -0
- package/src/chrome/index.ts +1 -0
- package/src/chrome/transcript-container.ts +89 -59
- package/src/chrome/transcript-notice.d.ts +35 -0
- package/src/chrome/transcript-notice.ts +83 -0
- package/src/chrome/transcript-status.d.ts +20 -8
- package/src/chrome/transcript-status.ts +29 -29
- package/src/components/editor.d.ts +8 -0
- package/src/components/editor.ts +465 -14
- package/src/components/image.d.ts +20 -0
- package/src/components/image.ts +83 -18
- package/src/components/loader.d.ts +1 -1
- package/src/components/loader.ts +1 -1
- package/src/components/markdown.d.ts +7 -0
- package/src/components/markdown.ts +225 -13
- package/src/hotkeys-markdown.ts +2 -0
- package/src/native/backend.ts +5 -66
- package/src/native/blobs.d.ts +11 -1
- package/src/native/blobs.ts +5 -3
- package/src/native/picker.d.ts +4 -4
- package/src/native/picker.ts +4 -4
- package/src/overlays/advisor-config.ts +10 -12
- package/src/overlays/agent-hub-projection.d.ts +3 -1
- package/src/overlays/agent-hub-projection.ts +6 -5
- package/src/overlays/agent-hub.ts +51 -42
- package/src/overlays/annotation-overlay.ts +125 -37
- package/src/overlays/annotation-types.ts +24 -0
- package/src/overlays/ask-dialog.ts +125 -35
- package/src/overlays/btw-history-panel.ts +124 -12
- package/src/overlays/btw-history.ts +11 -0
- package/src/overlays/btw-panel.ts +8 -4
- package/src/overlays/context-viewer-format.ts +145 -0
- package/src/overlays/context-viewer-overview.ts +381 -0
- package/src/overlays/context-viewer.ts +728 -0
- package/src/overlays/hook-input.ts +2 -0
- package/src/overlays/hook-selector.ts +2 -2
- package/src/overlays/login-dialog.ts +31 -5
- package/src/overlays/mcp-add-wizard.ts +6 -1
- package/src/overlays/model-browser.ts +37 -0
- package/src/overlays/model-hub.ts +1 -7
- package/src/overlays/model-picker.ts +1 -10
- package/src/overlays/oauth-selector.ts +44 -6
- package/src/overlays/pause-screen.ts +166 -33
- package/src/overlays/plan-review-overlay.ts +13 -2
- package/src/overlays/rewind-selector.ts +29 -12
- package/src/overlays/running-subagent-badge.ts +12 -1
- package/src/overlays/session-selector.ts +313 -42
- package/src/overlays/settings-defs.ts +1 -0
- package/src/overlays/usage-dashboard.ts +20 -14
- package/src/prompt/composer.ts +216 -1
- package/src/prompt/custom-editor.ts +6 -1
- package/src/prompt/emoji-autocomplete.ts +0 -2
- package/src/prompt/interactive-context-helpers.ts +29 -4
- package/src/prompt/macos-spelling.ts +24 -15
- package/src/render/extension-links.d.ts +65 -0
- package/src/render/extension-links.ts +214 -0
- package/src/render/hyperlink.d.ts +38 -7
- package/src/render/hyperlink.ts +102 -23
- package/src/render/index.d.ts +1 -0
- package/src/render/index.ts +1 -0
- package/src/render/output-pane.d.ts +1 -1
- package/src/render/output-pane.ts +60 -17
- package/src/render/render-utils.d.ts +7 -1
- package/src/render/render-utils.ts +11 -2
- package/src/setup/scenes/composer.ts +2 -0
- package/src/setup/scenes/glyph.ts +3 -1
- package/src/setup/scenes/model.ts +192 -29
- package/src/setup/scenes/outro.ts +33 -15
- package/src/setup/scenes/sign-in.ts +194 -392
- package/src/setup/scenes/theme.ts +2 -0
- package/src/setup/scenes/types.ts +18 -1
- package/src/setup/startup-splash.ts +8 -7
- package/src/setup/wizard-overlay.ts +164 -35
- package/src/setup/wizard.ts +11 -2
- package/src/status-line/component.ts +10 -14
- package/src/status-line/context-usage.ts +122 -597
- package/src/status-line/host.ts +6 -2
- package/src/terminal-capabilities.d.ts +7 -0
- package/src/terminal-capabilities.ts +10 -0
- package/src/terminal.ts +24 -2
- package/src/theme/defaults.json +1 -0
- package/src/theme/loader.ts +1 -1
- package/src/theme/symbols.d.ts +1 -1
- package/src/theme/symbols.ts +16 -0
- package/src/theme/theme.d.ts +0 -23
- package/src/theme/theme.ts +2 -75
- package/src/tools/ask.d.ts +4 -0
- package/src/tools/ask.ts +4 -0
- package/src/tools/ast-grep.ts +3 -2
- package/src/tools/bash-interactive.d.ts +49 -0
- package/src/tools/bash-interactive.ts +6 -1
- package/src/tools/bash.d.ts +2 -0
- package/src/tools/bash.ts +7 -23
- package/src/tools/default-renderer.d.ts +6 -4
- package/src/tools/default-renderer.ts +9 -6
- package/src/tools/edit.d.ts +3 -1
- package/src/tools/edit.ts +8 -4
- package/src/tools/eval.ts +14 -4
- package/src/tools/fetch.d.ts +1 -0
- package/src/tools/fetch.ts +1 -0
- package/src/tools/find.ts +3 -10
- package/src/tools/github.d.ts +3 -0
- package/src/tools/github.ts +23 -3
- package/src/tools/glob.ts +4 -3
- package/src/tools/grep.ts +3 -4
- package/src/tools/grouped-file-output.d.ts +2 -0
- package/src/tools/grouped-file-output.ts +8 -2
- package/src/tools/irc.d.ts +6 -0
- package/src/tools/irc.ts +6 -0
- package/src/tools/job-widget.ts +13 -1
- package/src/tools/json-tree.d.ts +23 -4
- package/src/tools/json-tree.ts +132 -42
- package/src/tools/lsp.d.ts +2 -0
- package/src/tools/lsp.ts +36 -15
- package/src/tools/mcp.d.ts +7 -6
- package/src/tools/mcp.ts +41 -15
- package/src/tools/native-view.d.ts +1 -1
- package/src/tools/native-view.ts +3 -3
- package/src/tools/read.d.ts +3 -0
- package/src/tools/read.ts +3 -1
- package/src/tools/renderer.d.ts +2 -0
- package/src/tools/renderer.ts +2 -0
- package/src/tools/streaming-output.d.ts +11 -0
- package/src/tools/streaming-output.ts +41 -0
- package/src/tools/task.d.ts +9 -1
- package/src/tools/task.ts +59 -16
- package/src/tools/url-scheme-host.d.ts +17 -0
- package/src/tools/url-scheme-host.ts +21 -0
- package/src/tools/vibe.ts +14 -3
- package/src/tools/wait.d.ts +16 -2
- package/src/tools/wait.ts +16 -2
- package/src/tools/yield.d.ts +1 -1
- package/src/tools/yield.ts +18 -9
- package/src/tui.d.ts +9 -2
- package/src/tui.ts +102 -34
- package/src/vim.d.ts +39 -0
- package/src/vim.ts +313 -22
- package/dist/types/theme/defaults/index.d.ts +0 -10289
- package/src/theme/defaults/alabaster.json +0 -103
- package/src/theme/defaults/amethyst.json +0 -106
- package/src/theme/defaults/anthracite.json +0 -103
- package/src/theme/defaults/basalt.json +0 -101
- package/src/theme/defaults/birch.json +0 -105
- package/src/theme/defaults/dark-abyss.json +0 -101
- package/src/theme/defaults/dark-arctic.json +0 -114
- package/src/theme/defaults/dark-aurora.json +0 -105
- package/src/theme/defaults/dark-catppuccin.json +0 -117
- package/src/theme/defaults/dark-cavern.json +0 -101
- package/src/theme/defaults/dark-celestial.json +0 -116
- package/src/theme/defaults/dark-copper.json +0 -105
- package/src/theme/defaults/dark-cosmos.json +0 -100
- package/src/theme/defaults/dark-cyberpunk.json +0 -112
- package/src/theme/defaults/dark-dracula.json +0 -108
- package/src/theme/defaults/dark-eclipse.json +0 -101
- package/src/theme/defaults/dark-ember.json +0 -105
- package/src/theme/defaults/dark-equinox.json +0 -100
- package/src/theme/defaults/dark-forest.json +0 -106
- package/src/theme/defaults/dark-github.json +0 -115
- package/src/theme/defaults/dark-gruvbox.json +0 -122
- package/src/theme/defaults/dark-lavender.json +0 -105
- package/src/theme/defaults/dark-lunar.json +0 -99
- package/src/theme/defaults/dark-midnight.json +0 -105
- package/src/theme/defaults/dark-monochrome.json +0 -104
- package/src/theme/defaults/dark-monokai.json +0 -108
- package/src/theme/defaults/dark-nebula.json +0 -100
- package/src/theme/defaults/dark-neon-noir.json +0 -110
- package/src/theme/defaults/dark-nord.json +0 -108
- package/src/theme/defaults/dark-ocean.json +0 -111
- package/src/theme/defaults/dark-one.json +0 -110
- package/src/theme/defaults/dark-poimandres.json +0 -125
- package/src/theme/defaults/dark-rainforest.json +0 -101
- package/src/theme/defaults/dark-reef.json +0 -101
- package/src/theme/defaults/dark-retro.json +0 -102
- package/src/theme/defaults/dark-rose-pine.json +0 -106
- package/src/theme/defaults/dark-sakura.json +0 -105
- package/src/theme/defaults/dark-slate.json +0 -105
- package/src/theme/defaults/dark-solarized.json +0 -107
- package/src/theme/defaults/dark-solstice.json +0 -100
- package/src/theme/defaults/dark-starfall.json +0 -101
- package/src/theme/defaults/dark-sunset.json +0 -109
- package/src/theme/defaults/dark-swamp.json +0 -100
- package/src/theme/defaults/dark-synthwave.json +0 -113
- package/src/theme/defaults/dark-taiga.json +0 -101
- package/src/theme/defaults/dark-terminal.json +0 -105
- package/src/theme/defaults/dark-tokyo-night.json +0 -111
- package/src/theme/defaults/dark-tundra.json +0 -101
- package/src/theme/defaults/dark-twilight.json +0 -101
- package/src/theme/defaults/dark-volcanic.json +0 -101
- package/src/theme/defaults/graphite.json +0 -102
- package/src/theme/defaults/index.d.ts +0 -10289
- package/src/theme/defaults/index.ts +0 -203
- package/src/theme/defaults/light-arctic.json +0 -117
- package/src/theme/defaults/light-aurora-day.json +0 -101
- package/src/theme/defaults/light-canyon.json +0 -101
- package/src/theme/defaults/light-catppuccin.json +0 -116
- package/src/theme/defaults/light-cirrus.json +0 -100
- package/src/theme/defaults/light-coral.json +0 -105
- package/src/theme/defaults/light-cyberpunk.json +0 -106
- package/src/theme/defaults/light-dawn.json +0 -100
- package/src/theme/defaults/light-dunes.json +0 -101
- package/src/theme/defaults/light-eucalyptus.json +0 -105
- package/src/theme/defaults/light-forest.json +0 -110
- package/src/theme/defaults/light-frost.json +0 -105
- package/src/theme/defaults/light-github.json +0 -125
- package/src/theme/defaults/light-glacier.json +0 -101
- package/src/theme/defaults/light-gruvbox.json +0 -118
- package/src/theme/defaults/light-haze.json +0 -100
- package/src/theme/defaults/light-honeycomb.json +0 -105
- package/src/theme/defaults/light-lagoon.json +0 -101
- package/src/theme/defaults/light-lavender.json +0 -105
- package/src/theme/defaults/light-meadow.json +0 -101
- package/src/theme/defaults/light-mint.json +0 -105
- package/src/theme/defaults/light-monochrome.json +0 -111
- package/src/theme/defaults/light-ocean.json +0 -109
- package/src/theme/defaults/light-one.json +0 -109
- package/src/theme/defaults/light-opal.json +0 -101
- package/src/theme/defaults/light-orchard.json +0 -101
- package/src/theme/defaults/light-paper.json +0 -105
- package/src/theme/defaults/light-poimandres.json +0 -125
- package/src/theme/defaults/light-prism.json +0 -100
- package/src/theme/defaults/light-retro.json +0 -108
- package/src/theme/defaults/light-sand.json +0 -105
- package/src/theme/defaults/light-savanna.json +0 -101
- package/src/theme/defaults/light-solarized.json +0 -112
- package/src/theme/defaults/light-soleil.json +0 -100
- package/src/theme/defaults/light-sunset.json +0 -109
- package/src/theme/defaults/light-synthwave.json +0 -108
- package/src/theme/defaults/light-tokyo-night.json +0 -121
- package/src/theme/defaults/light-wetland.json +0 -101
- package/src/theme/defaults/light-zenith.json +0 -99
- package/src/theme/defaults/limestone.json +0 -104
- package/src/theme/defaults/mahogany.json +0 -107
- package/src/theme/defaults/marble.json +0 -103
- package/src/theme/defaults/obsidian.json +0 -101
- package/src/theme/defaults/onyx.json +0 -101
- package/src/theme/defaults/pearl.json +0 -103
- package/src/theme/defaults/porcelain.json +0 -101
- package/src/theme/defaults/quartz.json +0 -106
- package/src/theme/defaults/sandstone.json +0 -105
- package/src/theme/defaults/titanium.json +0 -100
|
@@ -178,7 +178,16 @@ export function buildProviderCards(
|
|
|
178
178
|
for (const report of providerReports) {
|
|
179
179
|
for (const limit of report.limits) {
|
|
180
180
|
const label = formatLimitTitle(limit);
|
|
181
|
-
|
|
181
|
+
// Distinct buckets can share a label and window (Antigravity's Gemini
|
|
182
|
+
// vs Gemini (Argon) weekly) and must not average into one row, so the
|
|
183
|
+
// id joins the key. The label and window stay in it too: some
|
|
184
|
+
// providers build ids positionally or per plan (kimi's `${index}`,
|
|
185
|
+
// copilot's allowance), where ids differ across accounts for the
|
|
186
|
+
// same quota, so an id-only key would split those accounts apart.
|
|
187
|
+
// `sharedGroup` already names the routing copies of one shared bucket.
|
|
188
|
+
const key =
|
|
189
|
+
limit.scope.sharedGroup ??
|
|
190
|
+
`${label}|${limit.window?.id ?? limit.scope.windowId ?? "default"}|${limit.id}`;
|
|
182
191
|
const entry = buckets.get(key) ?? { label, limits: [] };
|
|
183
192
|
entry.limits.push(limit);
|
|
184
193
|
buckets.set(key, entry);
|
|
@@ -426,22 +435,15 @@ function clockTime(date: Date): string {
|
|
|
426
435
|
}
|
|
427
436
|
|
|
428
437
|
/**
|
|
429
|
-
* When a window resets,
|
|
430
|
-
*
|
|
431
|
-
*
|
|
438
|
+
* When a window resets, `resetMs` from `nowMs`: the countdown (`resets in
|
|
439
|
+
* 2h30m`), which reads the same in every time zone; the title carries the
|
|
440
|
+
* local date and time.
|
|
432
441
|
*/
|
|
433
442
|
function resetLabel(nowMs: number, resetMs: number): { text: string; title: string } {
|
|
434
443
|
const at = new Date(nowMs + resetMs);
|
|
435
|
-
const now = new Date(nowMs);
|
|
436
|
-
const sameDay = at.toDateString() === now.toDateString();
|
|
437
|
-
const text = sameDay
|
|
438
|
-
? `resets ${clockTime(at)}`
|
|
439
|
-
: resetMs < 6 * 86_400_000
|
|
440
|
-
? `resets ${WEEKDAY_NAMES[at.getDay()]} ${clockTime(at)}`
|
|
441
|
-
: `resets ${at.getDate()} ${MONTH_NAMES[at.getMonth()]}`;
|
|
442
444
|
return {
|
|
443
|
-
text
|
|
444
|
-
title: `Resets ${shortDate(at)} ${at.getFullYear()}, ${clockTime(at)}
|
|
445
|
+
text: `resets in ${formatDuration(resetMs)}`,
|
|
446
|
+
title: `Resets ${shortDate(at)} ${at.getFullYear()}, ${clockTime(at)}`,
|
|
445
447
|
};
|
|
446
448
|
}
|
|
447
449
|
|
|
@@ -1680,7 +1682,11 @@ export class UsageDashboardComponent implements Component {
|
|
|
1680
1682
|
for (const [index, report] of reports.entries()) {
|
|
1681
1683
|
for (const limit of report.limits) {
|
|
1682
1684
|
const label = sanitizeDisplayLine(formatLimitTitle(limit));
|
|
1683
|
-
|
|
1685
|
+
// Same hybrid key as the cards: distinct buckets that share a
|
|
1686
|
+
// label and window (Gemini vs Gemini (Argon) weekly) stay separate.
|
|
1687
|
+
const key =
|
|
1688
|
+
limit.scope.sharedGroup ??
|
|
1689
|
+
`${label}|${limit.window?.id ?? limit.scope.windowId ?? "default"}|${limit.id}`;
|
|
1684
1690
|
let bucket = buckets.get(key);
|
|
1685
1691
|
if (!bucket) {
|
|
1686
1692
|
bucket = { label, window: detailWindowLabel(label, limit), rows: [] };
|
package/src/prompt/composer.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { getComposerStyle } from "../components/composer/registry";
|
|
2
2
|
import { Spacer } from "../components/spacer";
|
|
3
3
|
import type { StatusLineComponent } from "../status-line/component";
|
|
4
|
+
import { compositeLineAt } from "../render/composite";
|
|
5
|
+
import { type ExtensionLinkLabel, extensionLinkLabels, linkHintTags } from "../render/extension-links";
|
|
4
6
|
import type { StatusLineSession } from "../status-line/host";
|
|
5
7
|
import { createStartupStatusLine, type StatusLineStartupData } from "../status-line/startup";
|
|
6
8
|
import { isInsideTerminalMultiplexer } from "../terminal-multiplexer";
|
|
@@ -177,6 +179,46 @@ export function routeViewportClick(spans: readonly ViewportClickSpan[], index: n
|
|
|
177
179
|
return [];
|
|
178
180
|
}
|
|
179
181
|
|
|
182
|
+
/** An extension link label drawn on a mutable-viewport line: what a click or hint tag lands on. */
|
|
183
|
+
export interface ViewportLink {
|
|
184
|
+
readonly url: string;
|
|
185
|
+
/** Mutable-viewport line the label is drawn on. */
|
|
186
|
+
readonly row: number;
|
|
187
|
+
/** First cell of the label's part on that line. */
|
|
188
|
+
readonly start: number;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** An extension link label tagged for picking by keyboard in link-hint mode. */
|
|
192
|
+
interface ViewportLinkHint {
|
|
193
|
+
readonly tag: string;
|
|
194
|
+
readonly link: ViewportLink;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Called once when link-hint mode ends; `reason` is `"crowded"` when a row held more links than
|
|
199
|
+
* their tags could fit side by side, so no tags were drawn.
|
|
200
|
+
*/
|
|
201
|
+
export type LinkHintsEnd = (reason?: "crowded") => void;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* The extension link labels drawn on `rows`, top to bottom, a wrapped label once at its first row:
|
|
205
|
+
* a row's first label continues the previous row's last label when that has the same marker id
|
|
206
|
+
* and ends its row.
|
|
207
|
+
*/
|
|
208
|
+
function viewportLinkTargets(rows: readonly string[]): ViewportLink[] {
|
|
209
|
+
const targets: ViewportLink[] = [];
|
|
210
|
+
let previous: ExtensionLinkLabel | undefined;
|
|
211
|
+
for (let row = 0; row < rows.length; row++) {
|
|
212
|
+
const labels = extensionLinkLabels(rows[row]!);
|
|
213
|
+
for (const [index, label] of labels.entries()) {
|
|
214
|
+
if (index === 0 && previous?.endsRow && previous.id === label.id) continue;
|
|
215
|
+
targets.push({ url: label.url, row, start: label.start });
|
|
216
|
+
}
|
|
217
|
+
previous = labels.at(-1);
|
|
218
|
+
}
|
|
219
|
+
return targets;
|
|
220
|
+
}
|
|
221
|
+
|
|
180
222
|
/**
|
|
181
223
|
* Reserved click-candidate id for the pinned HUD expander row. Checked before
|
|
182
224
|
* any registry lookup: its `@…:…` charset cannot collide with generated agent
|
|
@@ -260,8 +302,18 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
|
|
|
260
302
|
#retiredHeaderRows: readonly string[] | undefined;
|
|
261
303
|
/** Click spans of the last `renderFrame` viewport, in viewport coordinates. */
|
|
262
304
|
#lastClickSpans: ViewportClickSpan[] = [];
|
|
305
|
+
/** Rows of the last `renderFrame` viewport, before the hover band; read to hit-test extension links. */
|
|
306
|
+
#lastViewportRows: readonly string[] = [];
|
|
263
307
|
/** Click-candidate id under the pointer, painted with the hover band. Id-anchored so it follows streaming rows. */
|
|
264
308
|
#hoveredClickId: string | undefined;
|
|
309
|
+
/**
|
|
310
|
+
* Keyboard link-hint mode: the tags drawn over the extension links on screen (`undefined` until
|
|
311
|
+
* the first frame after `startLinkHints` assigns them), the letters typed so far, and what to run
|
|
312
|
+
* when the mode ends for any reason.
|
|
313
|
+
*/
|
|
314
|
+
#linkHints: { hints: ViewportLinkHint[] | undefined; typed: string; onEnd: LinkHintsEnd } | undefined;
|
|
315
|
+
/** Width of the last painted viewport, which `#lastViewportRows` was laid out for. */
|
|
316
|
+
#lastViewportWidth = 0;
|
|
265
317
|
// Hard-row prefix currently above the native viewport. The first resize
|
|
266
318
|
// frame may pull part of it down before the normal buffer is borrowed.
|
|
267
319
|
#retiredHeaderStart = 0;
|
|
@@ -403,6 +455,8 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
|
|
|
403
455
|
const transcriptIndex = roots.findIndex(root => root instanceof TranscriptContainer);
|
|
404
456
|
if (transcriptIndex < 0) {
|
|
405
457
|
this.#lastClickSpans = [];
|
|
458
|
+
this.#lastViewportRows = [];
|
|
459
|
+
this.#syncLinkHints([], 0);
|
|
406
460
|
const viewport: string[] = [];
|
|
407
461
|
for (const root of roots) {
|
|
408
462
|
const rendered = root.render(width);
|
|
@@ -512,11 +566,95 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
|
|
|
512
566
|
for (const span of activeSpans) shift(span, before.length - drop);
|
|
513
567
|
for (const span of afterSpans) shift(span, slack + before.length + active.length - drop);
|
|
514
568
|
this.#lastClickSpans = spans;
|
|
569
|
+
this.#lastViewportRows = mutable;
|
|
570
|
+
this.#lastViewportWidth = width;
|
|
571
|
+
this.#syncLinkHints(mutable, width);
|
|
515
572
|
if (history !== undefined && this.#offeredHistory?.source === "header") {
|
|
516
573
|
const visibleHeaderRows = Math.max(0, rows - (mutable.length + drop));
|
|
517
574
|
this.#retiredHeaderStart = Math.max(0, history.rows.length - visibleHeaderRows);
|
|
518
575
|
}
|
|
519
|
-
return { history, viewport: this.#paintHoverBand(mutable, spans) };
|
|
576
|
+
return { history, viewport: this.#paintLinkHints(this.#paintHoverBand(mutable, spans), width) };
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Keep link-hint tags on what `rows` show. The first frame after `startLinkHints` tags its
|
|
581
|
+
* labels; later frames keep the tags while the tagged labels are still drawn first, in the same
|
|
582
|
+
* order and columns (rows may scroll, links may be added below), and otherwise end the mode, so a
|
|
583
|
+
* tag never picks a label no longer drawn under it. Every frame ends the mode as `"crowded"` when
|
|
584
|
+
* some row has more tag cells than `width` (a resize can narrow it), since tags drawn side by
|
|
585
|
+
* side could not all be read.
|
|
586
|
+
*/
|
|
587
|
+
#syncLinkHints(rows: readonly string[], width: number): void {
|
|
588
|
+
const state = this.#linkHints;
|
|
589
|
+
if (state === undefined) return;
|
|
590
|
+
const targets = viewportLinkTargets(rows);
|
|
591
|
+
const hints = state.hints;
|
|
592
|
+
if (hints === undefined) {
|
|
593
|
+
state.hints = linkHintTags(targets.length).map((tag, index) => ({ tag, link: targets[index]! }));
|
|
594
|
+
if (state.hints.length === 0) {
|
|
595
|
+
this.#endLinkHints();
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
} else {
|
|
599
|
+
const unchanged =
|
|
600
|
+
targets.length >= hints.length &&
|
|
601
|
+
hints.every(({ link }, index) => link.url === targets[index]!.url && link.start === targets[index]!.start);
|
|
602
|
+
if (!unchanged) {
|
|
603
|
+
this.#endLinkHints();
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
state.hints = hints.map(({ tag }, index) => ({ tag, link: targets[index]! }));
|
|
607
|
+
}
|
|
608
|
+
const cells = new Map<number, number>();
|
|
609
|
+
for (const { tag, link } of state.hints) cells.set(link.row, (cells.get(link.row) ?? 0) + tag.length);
|
|
610
|
+
if ([...cells.values()].some(count => count > width)) this.#endLinkHints("crowded");
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
#endLinkHints(reason?: "crowded"): void {
|
|
614
|
+
const state = this.#linkHints;
|
|
615
|
+
if (state === undefined) return;
|
|
616
|
+
this.#linkHints = undefined;
|
|
617
|
+
state.onEnd(reason);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Draw every tag the typed letters still lead to over the start of its label. Tags on one row
|
|
622
|
+
* never overlap: one that would land on an earlier tag moves right, and tags that would run past
|
|
623
|
+
* the right edge move left, so each stays readable as long as the row has room for them all.
|
|
624
|
+
*/
|
|
625
|
+
#paintLinkHints(viewport: string[], width: number): string[] {
|
|
626
|
+
const state = this.#linkHints;
|
|
627
|
+
if (state?.hints === undefined) return viewport;
|
|
628
|
+
const rows = new Map<number, { tag: string; col: number }[]>();
|
|
629
|
+
for (const { tag, link } of state.hints) {
|
|
630
|
+
if (viewport[link.row] === undefined || !tag.startsWith(state.typed)) continue;
|
|
631
|
+
let row = rows.get(link.row);
|
|
632
|
+
if (!row) rows.set(link.row, (row = []));
|
|
633
|
+
row.push({ tag, col: link.start });
|
|
634
|
+
}
|
|
635
|
+
const painted = [...viewport];
|
|
636
|
+
for (const [index, tags] of rows) {
|
|
637
|
+
tags.sort((a, b) => a.col - b.col);
|
|
638
|
+
let free = 0;
|
|
639
|
+
for (const placed of tags) {
|
|
640
|
+
placed.col = Math.max(placed.col, free);
|
|
641
|
+
free = placed.col + placed.tag.length;
|
|
642
|
+
}
|
|
643
|
+
let limit = width;
|
|
644
|
+
for (let i = tags.length - 1; i >= 0; i--) {
|
|
645
|
+
const placed = tags[i]!;
|
|
646
|
+
placed.col = Math.max(0, Math.min(placed.col, limit - placed.tag.length));
|
|
647
|
+
limit = placed.col;
|
|
648
|
+
}
|
|
649
|
+
let line = painted[index]!;
|
|
650
|
+
for (const { tag, col } of tags) {
|
|
651
|
+
// Raw SGR like the hover highlight: chalk's inverse/bold drop out when it detects no color.
|
|
652
|
+
const styled = `\x1b[1;7m${theme.fg("accent", tag)}\x1b[22;27m`;
|
|
653
|
+
line = compositeLineAt(line, styled, col, tag.length, width);
|
|
654
|
+
}
|
|
655
|
+
painted[index] = line;
|
|
656
|
+
}
|
|
657
|
+
return painted;
|
|
520
658
|
}
|
|
521
659
|
|
|
522
660
|
/**
|
|
@@ -635,6 +773,17 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
|
|
|
635
773
|
return routeViewportClick(this.#lastClickSpans, index);
|
|
636
774
|
}
|
|
637
775
|
|
|
776
|
+
/**
|
|
777
|
+
* The extension-owned link label drawn at cell `col` of a mutable-viewport line, or `undefined`.
|
|
778
|
+
* Only links whose scheme an extension registered match; see `extensionLinkLabels`.
|
|
779
|
+
*/
|
|
780
|
+
viewportLinkAt(index: number, col: number): ViewportLink | undefined {
|
|
781
|
+
const line = this.#lastViewportRows[index];
|
|
782
|
+
if (line === undefined || col < 0) return undefined;
|
|
783
|
+
const label = extensionLinkLabels(line).find(label => col >= label.start && col < label.end);
|
|
784
|
+
return label && { url: label.url, row: index, start: label.start };
|
|
785
|
+
}
|
|
786
|
+
|
|
638
787
|
/**
|
|
639
788
|
* Point the hover band at a click-candidate id (or clear it). Takes effect
|
|
640
789
|
* on the next frame; callers repaint only when the target actually changes.
|
|
@@ -643,6 +792,55 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
|
|
|
643
792
|
this.#hoveredClickId = id;
|
|
644
793
|
}
|
|
645
794
|
|
|
795
|
+
/** How many extension link labels the last frame drew; a label wrapped across rows counts once. */
|
|
796
|
+
viewportLinkCount(): number {
|
|
797
|
+
return viewportLinkTargets(this.#lastViewportRows).length;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* Enter keyboard link-hint mode: the next frame draws a tag over each extension link label it
|
|
802
|
+
* shows. `onEnd` runs once when the mode ends: a pick, a cancel, a key no tag starts with, a
|
|
803
|
+
* repaint that no longer draws the tagged labels where they were, or (`"crowded"`) a row with
|
|
804
|
+
* too many links for their tags to fit side by side.
|
|
805
|
+
*/
|
|
806
|
+
startLinkHints(onEnd: LinkHintsEnd): void {
|
|
807
|
+
this.#endLinkHints();
|
|
808
|
+
this.#linkHints = { hints: undefined, typed: "", onEnd };
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/** Whether link-hint mode is on. */
|
|
812
|
+
get linkHintsActive(): boolean {
|
|
813
|
+
return this.#linkHints !== undefined;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* Type one letter of a tag. Returns the link whose whole tag is now typed, `true` while the
|
|
818
|
+
* letters still lead to several tags, and `false` when none starts with them. The mode ends on
|
|
819
|
+
* a pick or a miss.
|
|
820
|
+
*/
|
|
821
|
+
typeLinkHint(letter: string): ViewportLink | boolean {
|
|
822
|
+
const state = this.#linkHints;
|
|
823
|
+
if (state === undefined) return false;
|
|
824
|
+
// A key typed before the tags were first painted picks among the labels last drawn.
|
|
825
|
+
if (state.hints === undefined) this.#syncLinkHints(this.#lastViewportRows, this.#lastViewportWidth);
|
|
826
|
+
const hints = this.#linkHints?.hints;
|
|
827
|
+
if (hints === undefined) return false;
|
|
828
|
+
const typed = state.typed + letter.toLowerCase();
|
|
829
|
+
const matching = hints.filter(hint => hint.tag.startsWith(typed));
|
|
830
|
+
const picked = matching.length === 1 && matching[0]!.tag === typed ? matching[0]!.link : undefined;
|
|
831
|
+
if (matching.length === 0 || picked !== undefined) {
|
|
832
|
+
this.#endLinkHints();
|
|
833
|
+
return picked ?? false;
|
|
834
|
+
}
|
|
835
|
+
state.typed = typed;
|
|
836
|
+
return true;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
/** Leave link-hint mode without picking a link. */
|
|
840
|
+
cancelLinkHints(): void {
|
|
841
|
+
this.#endLinkHints();
|
|
842
|
+
}
|
|
843
|
+
|
|
646
844
|
/** Acknowledges one accepted header, replay, or transcript batch. */
|
|
647
845
|
acknowledgeHistory(id: number): void {
|
|
648
846
|
const offered = this.#offeredHistory;
|
|
@@ -940,6 +1138,9 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
|
|
|
940
1138
|
start(options: ComposerStartOptions = {}): void {
|
|
941
1139
|
if (this.#started || this.#stopped) return;
|
|
942
1140
|
this.#started = true;
|
|
1141
|
+
// A TSP terminal keeps (and draws) what is typed until startup releases
|
|
1142
|
+
// the held input, standing in for the kernel echo other terminals give.
|
|
1143
|
+
this.#editor.nativeTypeahead = options.deferInput === true;
|
|
943
1144
|
this.ui.start({ clearScrollback: options.clearScrollback === true, deferInput: options.deferInput === true });
|
|
944
1145
|
if (options.playWelcomeIntro !== false) this.playWelcomeIntro();
|
|
945
1146
|
// Deferred input identifies the CLI prepaint handoff. Flush the queued
|
|
@@ -1023,9 +1224,23 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
|
|
|
1023
1224
|
/** Update the canonical editor reference after InteractiveMode remounts a custom editor. */
|
|
1024
1225
|
setEditor(editor: CustomEditor): void {
|
|
1025
1226
|
this.ui.replaceHeldFocus(this.#editor, editor);
|
|
1227
|
+
editor.nativeTypeahead = this.#editor.nativeTypeahead;
|
|
1026
1228
|
this.#editor = editor;
|
|
1027
1229
|
}
|
|
1028
1230
|
|
|
1231
|
+
/**
|
|
1232
|
+
* End the startup input hold once the app's handlers are wired: the TSP
|
|
1233
|
+
* terminal sends the typing it kept, and the keys the TUI held replay
|
|
1234
|
+
* ({@link TUI.releaseHeldInput}). Idempotent.
|
|
1235
|
+
*/
|
|
1236
|
+
releaseHeldInput(): void {
|
|
1237
|
+
if (this.#editor.nativeTypeahead) {
|
|
1238
|
+
this.#editor.nativeTypeahead = false;
|
|
1239
|
+
this.ui.requestRender();
|
|
1240
|
+
}
|
|
1241
|
+
this.ui.releaseHeldInput();
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1029
1244
|
/**
|
|
1030
1245
|
* Mount the session-aware status component into the slot below the editor,
|
|
1031
1246
|
* retiring the startup status line; the caller installs the real top-border
|
|
@@ -1063,7 +1063,12 @@ export class CustomEditor extends Editor {
|
|
|
1063
1063
|
/** Editing is available during bootstrap; atomic sends wait until submission is wired and enabled
|
|
1064
1064
|
* and no dictation is still writing into the draft. */
|
|
1065
1065
|
protected override get nativeSendable(): boolean {
|
|
1066
|
-
return
|
|
1066
|
+
return (
|
|
1067
|
+
!this.nativeKeyPassthrough &&
|
|
1068
|
+
this.onSubmit !== undefined &&
|
|
1069
|
+
!this.disableSubmit &&
|
|
1070
|
+
!dictationHoldsDraft(this.composerState().dictation)
|
|
1071
|
+
);
|
|
1067
1072
|
}
|
|
1068
1073
|
/** The quoted-title placeholder, kept while the title stands so the editor node stays reused. */
|
|
1069
1074
|
#titlePlaceholder: { title: string; text: TspText } | undefined;
|
|
@@ -3,12 +3,17 @@ import type { AssistantMessage, Model, TextContent } from "@linxiraos/pi-ai";
|
|
|
3
3
|
import { getMarkdownLinkUrls } from "../index";
|
|
4
4
|
import { EMPTY_LINK_TARGETS } from "../render/render-utils";
|
|
5
5
|
import type { ImageBudget } from "../components/image";
|
|
6
|
-
import type { AssistantThinkingRenderer } from "../chat/extension-types";
|
|
6
|
+
import type { AssistantTextRenderer, AssistantThinkingRenderer } from "../chat/extension-types";
|
|
7
7
|
import { AssistantMessageComponent } from "../chat/assistant-message";
|
|
8
|
+
import { ReplyWriteComponent } from "../chat/reply-write";
|
|
8
9
|
/** Session display capabilities supplied unchanged by the interactive host. */
|
|
9
10
|
export interface AssistantMessageSession {
|
|
10
11
|
readonly model?: Model;
|
|
11
|
-
readonly extensionRunner?: {
|
|
12
|
+
readonly extensionRunner?: {
|
|
13
|
+
getAssistantThinkingRenderers(): readonly AssistantThinkingRenderer[];
|
|
14
|
+
/** Empty while the setting that enables them is off; hosts predating it may omit it. */
|
|
15
|
+
getAssistantTextRenderers?(): readonly AssistantTextRenderer[];
|
|
16
|
+
};
|
|
12
17
|
}
|
|
13
18
|
|
|
14
19
|
/** Host state required to construct and refresh assistant transcript segments. */
|
|
@@ -109,12 +114,15 @@ export function assistantMessageLinkTargets(
|
|
|
109
114
|
/**
|
|
110
115
|
* Construct an {@link AssistantMessageComponent} wired to the live context's
|
|
111
116
|
* thinking/image settings. `message` is omitted for the streaming placeholder
|
|
112
|
-
* component and supplied when rendering a persisted turn.
|
|
117
|
+
* component and supplied when rendering a persisted turn. `contentOffset` is
|
|
118
|
+
* the index in the full reply of the first block of a segment drawn after a
|
|
119
|
+
* tool call, so extension text renderers see the reply's own block indexes.
|
|
113
120
|
*/
|
|
114
121
|
export function createAssistantMessageComponent(
|
|
115
122
|
ctx: AssistantMessageHost,
|
|
116
123
|
message?: AssistantMessage,
|
|
117
124
|
linkTargets: ReadonlyMap<string, string> = getAssistantMessageLinkTargets(ctx),
|
|
125
|
+
contentOffset = 0,
|
|
118
126
|
): AssistantMessageComponent {
|
|
119
127
|
const component = new AssistantMessageComponent(
|
|
120
128
|
message,
|
|
@@ -125,7 +133,25 @@ export function createAssistantMessageComponent(
|
|
|
125
133
|
ctx.proseOnlyThinking,
|
|
126
134
|
linkTargets,
|
|
127
135
|
ctx.expandThinkingBlocks,
|
|
136
|
+
{ renderers: ctx.viewSession.extensionRunner?.getAssistantTextRenderers?.() ?? [], contentOffset },
|
|
128
137
|
);
|
|
138
|
+
applyHostDisplay(ctx, component);
|
|
139
|
+
return component;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Construct a {@link ReplyWriteComponent} (an `out://` write) drawn like the context's assistant prose. */
|
|
143
|
+
export function createReplyWriteComponent(ctx: AssistantMessageHost): ReplyWriteComponent {
|
|
144
|
+
const component = new ReplyWriteComponent({
|
|
145
|
+
requestRender: () => ctx.ui.requestRender(),
|
|
146
|
+
imageBudget: ctx.ui.imageBudget,
|
|
147
|
+
linkTargets: getAssistantMessageLinkTargets(ctx),
|
|
148
|
+
});
|
|
149
|
+
applyHostDisplay(ctx, component);
|
|
150
|
+
return component;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Apply the context's image, chart, expansion, and scrollback-publication display state. */
|
|
154
|
+
function applyHostDisplay(ctx: AssistantMessageHost, component: AssistantMessageComponent): void {
|
|
129
155
|
component.setImagesVisible(ctx.assistantImagesVisible);
|
|
130
156
|
component.setTableChartsVisible(ctx.tableChartsVisible);
|
|
131
157
|
component.setToolResultImagesVisible(!ctx.hideToolActivity);
|
|
@@ -136,5 +162,4 @@ export function createAssistantMessageComponent(
|
|
|
136
162
|
const compat = ctx.viewSession.model?.compat;
|
|
137
163
|
const wireRevisable = compat !== undefined && "streamRevision" in compat && compat.streamRevision === "possible";
|
|
138
164
|
component.setMidStreamPublication(!wireRevisable);
|
|
139
|
-
return component;
|
|
140
165
|
}
|
|
@@ -62,7 +62,7 @@ export class MacOSSpellingProvider implements EditorTextAssistProvider {
|
|
|
62
62
|
#availabilityChecked = false;
|
|
63
63
|
#cacheGeneration = 0;
|
|
64
64
|
#typoCache = new Map<string, readonly native.SpellingRange[]>();
|
|
65
|
-
/** {@link #projectTypoRanges} answers for the current {@link #typoCache}; segments re-ask every frame. */
|
|
65
|
+
/** {@link #projectTypoRanges} answers for the current {@link #typoCache}; render segments re-ask every frame. */
|
|
66
66
|
#projectionMemo = new Map<string, readonly native.SpellingRange[] | undefined>();
|
|
67
67
|
#typoInFlight = new Map<string, Promise<readonly native.SpellingRange[]>>();
|
|
68
68
|
#automaticTypoActive = false;
|
|
@@ -120,39 +120,48 @@ export class MacOSSpellingProvider implements EditorTextAssistProvider {
|
|
|
120
120
|
/**
|
|
121
121
|
* Misspelled prose ranges in `text` (offsets into it), in order and
|
|
122
122
|
* non-overlapping, except ones touching `context.typing` (the word still
|
|
123
|
-
* being typed).
|
|
124
|
-
*
|
|
123
|
+
* being typed). Checks the full logical line so rendering cuts cannot
|
|
124
|
+
* change spelling or prose boundaries. Uncached lines arrive through {@link onUpdate}.
|
|
125
125
|
*/
|
|
126
126
|
typoRanges(text: string, context: SpellingDecorationContext): readonly native.SpellingRange[] {
|
|
127
127
|
if (!this.#available || !this.#features.typoDetection || text.length === 0) return [];
|
|
128
|
-
|
|
129
|
-
const
|
|
130
|
-
|
|
128
|
+
const line = context.lines[context.line];
|
|
129
|
+
const segmentEnd = context.startCol + text.length;
|
|
130
|
+
if (
|
|
131
|
+
line === undefined ||
|
|
132
|
+
context.startCol < 0 ||
|
|
133
|
+
segmentEnd > line.length ||
|
|
134
|
+
!line.startsWith(text, context.startCol)
|
|
135
|
+
)
|
|
136
|
+
return [];
|
|
137
|
+
if (!this.#prose.isProse(context, context.startCol, segmentEnd)) return [];
|
|
138
|
+
const lane = `${context.line}:0`;
|
|
139
|
+
const cached = this.#typoCache.get(line);
|
|
131
140
|
// A cache hit obsoletes any older text queued for this lane. A miss must
|
|
132
141
|
// keep its just-scheduled entry alive: deleting it here used to cancel the
|
|
133
142
|
// verification check whenever a stale projection painted ranges while
|
|
134
143
|
// another check was in flight, freezing the projected undercurl (e.g. the
|
|
135
144
|
// "eac" of a fast-typed "each") until an unrelated repaint rescheduled it.
|
|
136
|
-
if (cached === undefined) this.#scheduleTypoRanges(
|
|
145
|
+
if (cached === undefined) this.#scheduleTypoRanges(line, lane);
|
|
137
146
|
else this.#automaticTypoQueue.delete(lane);
|
|
138
|
-
const ranges = cached ?? this.#projectTypoRanges(
|
|
147
|
+
const ranges = cached ?? this.#projectTypoRanges(line);
|
|
139
148
|
if (!ranges || ranges.length === 0) return [];
|
|
140
149
|
const kept: native.SpellingRange[] = [];
|
|
141
150
|
const typing = context.typing?.line === context.line ? context.typing : undefined;
|
|
142
151
|
let cursor = 0;
|
|
143
152
|
for (const range of ranges) {
|
|
144
153
|
const end = range.start + range.length;
|
|
145
|
-
if (typing &&
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
154
|
+
if (typing && range.start <= typing.end && typing.start <= end) continue;
|
|
148
155
|
// Overlapping or out-of-bounds ranges (stale native data, edit projection)
|
|
149
156
|
// must never re-emit already-rendered text: that doubles it on screen and
|
|
150
157
|
// desyncs the rendered width from the measured width (cursor drift).
|
|
151
|
-
if (range.start < cursor || end >
|
|
152
|
-
if (!this.#prose.isProse(context,
|
|
153
|
-
|
|
158
|
+
if (range.start < cursor || end > line.length) continue;
|
|
159
|
+
if (!this.#prose.isProse(context, range.start, end)) continue;
|
|
160
|
+
const start = Math.max(range.start, context.startCol);
|
|
161
|
+
const clippedEnd = Math.min(end, segmentEnd);
|
|
162
|
+
if (start < clippedEnd) {
|
|
163
|
+
kept.push({ start: start - context.startCol, length: clippedEnd - start });
|
|
154
164
|
}
|
|
155
|
-
kept.push(range);
|
|
156
165
|
cursor = end;
|
|
157
166
|
}
|
|
158
167
|
return kept;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set the registered schemes (lowercase, without `:`). Bumps {@link extensionLinksVersion} on any
|
|
3
|
+
* change so cached markdown renders are redrawn.
|
|
4
|
+
*/
|
|
5
|
+
export declare function setExtensionLinks(next: Iterable<string>): void;
|
|
6
|
+
/** Changes whenever the scheme set changes; part of the markdown render cache key. */
|
|
7
|
+
export declare function extensionLinksVersion(): number;
|
|
8
|
+
/**
|
|
9
|
+
* Whether activating a registered-scheme link (a click or a hint tag) reaches its extension: a
|
|
10
|
+
* scheme is registered and the terminal is plain.
|
|
11
|
+
*/
|
|
12
|
+
export declare function extensionLinksRouted(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Set by the interactive product: whether the user has a way to pick a link drawn now (a bound
|
|
15
|
+
* hint key, mouse clicks). `undefined` when nothing in this process can pick one.
|
|
16
|
+
*/
|
|
17
|
+
export declare function setExtensionLinkPicking(provider: (() => boolean) | undefined): void;
|
|
18
|
+
/**
|
|
19
|
+
* Whether a registered-scheme link drawn now can be activated: links are routed and the product
|
|
20
|
+
* offers a way to pick them. Process-wide, so a UI-less extension runner (a subagent's, whose
|
|
21
|
+
* transcript the user may focus) answers like the interactive one.
|
|
22
|
+
*/
|
|
23
|
+
export declare function extensionLinkClicksAvailable(): boolean;
|
|
24
|
+
/** The registered scheme `href` uses, or `undefined` for every other link. */
|
|
25
|
+
export declare function extensionLinkScheme(href: string): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Draw an extension link's label: dotted-underlined (plain underline where the terminal has no
|
|
28
|
+
* styled underlines, re-applied after any style reset inside it) and wrapped in the OSC 8 marker
|
|
29
|
+
* {@link extensionLinkLabels} reads back in a plain terminal; as given in Tern's native view. Never
|
|
30
|
+
* followed by a ` (url)` suffix. `key` tells apart links of one URL drawn near each other; it must
|
|
31
|
+
* not change between renders of the same text, or rows rendered twice stop matching.
|
|
32
|
+
*/
|
|
33
|
+
export declare function formatExtensionLink(label: string, href: string, key: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Tags for `count` links in keyboard link-hint mode: single letters while they suffice, otherwise
|
|
36
|
+
* two letters each, so no tag is a prefix of another. At most the alphabet squared (676) are made;
|
|
37
|
+
* links past that stay untagged.
|
|
38
|
+
*/
|
|
39
|
+
export declare function linkHintTags(count: number): string[];
|
|
40
|
+
/**
|
|
41
|
+
* `line` without omp's extension-link markers (the OSC 8 open and close around each label), for
|
|
42
|
+
* terminal output. Every other hyperlink is kept as is.
|
|
43
|
+
*/
|
|
44
|
+
export declare function stripExtensionLinkMarkers(line: string): string;
|
|
45
|
+
/** One extension link label drawn on a rendered row (before {@link stripExtensionLinkMarkers}). */
|
|
46
|
+
export interface ExtensionLinkLabel {
|
|
47
|
+
readonly url: string;
|
|
48
|
+
/**
|
|
49
|
+
* The marker's params, unique to each drawn link and repeated on every row a wrapped label
|
|
50
|
+
* spans, so a row's parts of one label can be told from an adjacent label of the same URL.
|
|
51
|
+
*/
|
|
52
|
+
readonly id: string;
|
|
53
|
+
/** First 0-based cell the label covers. */
|
|
54
|
+
readonly start: number;
|
|
55
|
+
/** Cell just past the label. */
|
|
56
|
+
readonly end: number;
|
|
57
|
+
/** Whether only blank cells follow the label on its row, so a wrapped label may go on below. */
|
|
58
|
+
readonly endsRow: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The extension link labels drawn on a rendered row, left to right. Only omp's own markers with a
|
|
62
|
+
* registered scheme match, so ordinary hyperlinks (even of a registered scheme) and rows drawn for
|
|
63
|
+
* a scheme that is no longer registered never do.
|
|
64
|
+
*/
|
|
65
|
+
export declare function extensionLinkLabels(line: string): ExtensionLinkLabel[];
|