@linxiraos/pi-tui 1.4.11 → 1.4.13
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 +30 -233
- package/README.md +4 -1
- package/THIRD-PARTY-NOTICES.txt +4 -5
- package/dist/types/apps/shell-visualizer.d.ts +24 -0
- package/dist/types/autocomplete.d.ts +20 -0
- package/dist/types/chat/cache-invalidation-marker.d.ts +15 -7
- package/dist/types/chat/chat-transcript-builder.d.ts +5 -3
- package/dist/types/chat/display-preferences.d.ts +2 -0
- package/dist/types/chat/extension-types.d.ts +72 -1
- package/dist/types/chat/image-loading.d.ts +2 -2
- package/dist/types/chat/messages.d.ts +2 -3
- package/dist/types/chat/read-tool-group.d.ts +15 -2
- package/dist/types/chat/skill-message.d.ts +1 -0
- package/dist/types/chat/spotlight.d.ts +203 -0
- package/dist/types/chat/tool-execution.d.ts +26 -5
- package/dist/types/chat/transcript-actions.d.ts +11 -0
- package/dist/types/chat/transcript-browser.d.ts +9 -0
- package/dist/types/chat/transcript-presentation.d.ts +164 -0
- package/dist/types/chat/ttsr-notification.d.ts +2 -0
- package/dist/types/chrome/message-frame.d.ts +2 -0
- package/dist/types/chrome/transcript-container.d.ts +27 -6
- package/dist/types/components/loader.d.ts +0 -2
- package/dist/types/components/markdown.d.ts +11 -1
- package/dist/types/components/settings-list.d.ts +12 -2
- package/dist/types/frame-rate.d.ts +18 -0
- package/dist/types/hotkeys-markdown.d.ts +2 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/keybinding-matchers.d.ts +4 -1
- package/dist/types/kitty-graphics.d.ts +1 -1
- package/dist/types/motion-effects.d.ts +10 -0
- package/dist/types/native/encode.d.ts +2 -0
- package/dist/types/native/measure.d.ts +10 -0
- package/dist/types/native/overlay.d.ts +1 -1
- package/dist/types/native/quiet.d.ts +5 -0
- package/dist/types/native/reconcile.d.ts +6 -1
- package/dist/types/native/spans.d.ts +6 -0
- package/dist/types/native/state.d.ts +4 -0
- package/dist/types/overlays/agent-hub.d.ts +6 -0
- package/dist/types/overlays/link-browser.d.ts +55 -0
- package/dist/types/overlays/running-subagent-badge.d.ts +1 -4
- package/dist/types/overlays/spotlight-sheet.d.ts +36 -0
- package/dist/types/prompt/composer-attachments.d.ts +5 -2
- package/dist/types/prompt/composer-cache.d.ts +7 -2
- package/dist/types/prompt/composer.d.ts +6 -11
- package/dist/types/prompt/custom-editor.d.ts +8 -2
- package/dist/types/prompt/gradient-highlight.d.ts +2 -2
- package/dist/types/prompt/magic-keywords.d.ts +2 -0
- package/dist/types/prompt/model-mention-autocomplete.d.ts +9 -7
- package/dist/types/prompt/model-mention-syntax.d.ts +6 -0
- package/dist/types/prompt/prompt-action-autocomplete.d.ts +2 -1
- package/dist/types/prompt/welcome.d.ts +19 -0
- package/dist/types/render/extension-links.d.ts +0 -6
- package/dist/types/render/index.d.ts +1 -0
- package/dist/types/render/link-hints.d.ts +78 -0
- package/dist/types/render/render-utils.d.ts +0 -2
- package/dist/types/setup/scenes/types.d.ts +8 -0
- package/dist/types/setup/scenes/updates.d.ts +6 -0
- package/dist/types/setup/wizard.d.ts +7 -2
- package/dist/types/spinner-clock.d.ts +34 -0
- package/dist/types/status-line/component.d.ts +8 -4
- package/dist/types/status-line/host.d.ts +62 -0
- package/dist/types/status-line/index.d.ts +1 -0
- package/dist/types/status-line/prompt-cache.d.ts +14 -0
- package/dist/types/status-line/schema.d.ts +1 -1
- package/dist/types/status-line/startup.d.ts +6 -0
- package/dist/types/status-line/types.d.ts +8 -21
- package/dist/types/theme/schema.d.ts +28 -1
- package/dist/types/theme/symbols.d.ts +1 -1
- package/dist/types/theme/theme-class.d.ts +12 -2
- package/dist/types/theme/theme.d.ts +1 -1
- package/dist/types/theme/tui-adapters.d.ts +7 -0
- package/dist/types/thinking.d.ts +12 -0
- package/dist/types/tools/ask.d.ts +1 -1
- package/dist/types/tools/bash.d.ts +21 -0
- package/dist/types/tools/find.d.ts +9 -1
- package/dist/types/tools/grep.d.ts +2 -1
- package/dist/types/tools/grouped-file-output.d.ts +17 -0
- package/dist/types/tools/job-widget.d.ts +2 -2
- package/dist/types/tools/lsp.d.ts +4 -2
- package/dist/types/tools/native-view.d.ts +4 -0
- package/dist/types/tools/renderer.d.ts +9 -1
- package/dist/types/tools/shell-trace.d.ts +10 -0
- package/dist/types/tools/shell-viz-render.d.ts +6 -0
- package/dist/types/tools/shell-viz.d.ts +16 -0
- package/dist/types/tools/wait.d.ts +2 -2
- package/dist/types/tools/web-search-types.d.ts +1 -0
- package/dist/types/tools/write.d.ts +2 -0
- package/dist/types/tui.d.ts +15 -1
- package/package.json +15 -11
- package/src/apps/shell-visualizer.d.ts +24 -0
- package/src/apps/shell-visualizer.ts +167 -0
- package/src/autocomplete.d.ts +20 -0
- package/src/autocomplete.ts +14 -0
- package/src/chat/assistant-message.ts +11 -6
- package/src/chat/cache-invalidation-marker.d.ts +15 -7
- package/src/chat/cache-invalidation-marker.ts +18 -9
- package/src/chat/chat-transcript-builder.d.ts +5 -3
- package/src/chat/chat-transcript-builder.ts +16 -12
- package/src/chat/display-preferences.d.ts +2 -0
- package/src/chat/display-preferences.ts +3 -0
- package/src/chat/extension-types.d.ts +72 -1
- package/src/chat/extension-types.ts +74 -1
- package/src/chat/image-loading.d.ts +2 -2
- package/src/chat/image-loading.ts +2 -2
- package/src/chat/messages.d.ts +2 -3
- package/src/chat/messages.ts +3 -8
- package/src/chat/read-tool-group.d.ts +15 -2
- package/src/chat/read-tool-group.ts +201 -41
- package/src/chat/skill-message.d.ts +1 -0
- package/src/chat/skill-message.ts +4 -0
- package/src/chat/spotlight.d.ts +203 -0
- package/src/chat/spotlight.ts +460 -0
- package/src/chat/tool-execution.d.ts +26 -5
- package/src/chat/tool-execution.ts +360 -38
- package/src/chat/transcript-actions.d.ts +11 -0
- package/src/chat/transcript-actions.ts +13 -1
- package/src/chat/transcript-browser.d.ts +9 -0
- package/src/chat/transcript-browser.ts +18 -0
- package/src/chat/transcript-presentation.d.ts +164 -0
- package/src/chat/transcript-presentation.ts +642 -0
- package/src/chat/ttsr-notification.d.ts +25 -0
- package/src/chat/ttsr-notification.ts +5 -0
- package/src/chrome/message-frame.d.ts +2 -0
- package/src/chrome/message-frame.ts +7 -0
- package/src/chrome/message-notice.d.ts +58 -0
- package/src/chrome/transcript-container.d.ts +27 -6
- package/src/chrome/transcript-container.ts +317 -66
- package/src/components/editor.ts +25 -1
- package/src/components/loader.d.ts +0 -2
- package/src/components/loader.ts +30 -18
- package/src/components/markdown.d.ts +11 -1
- package/src/components/markdown.ts +41 -16
- package/src/components/settings-list.d.ts +12 -2
- package/src/components/settings-list.ts +29 -13
- package/src/frame-rate.d.ts +18 -0
- package/src/frame-rate.ts +36 -0
- package/src/hotkeys-markdown.ts +9 -2
- package/src/index.d.ts +3 -0
- package/src/index.ts +3 -0
- package/src/keybinding-matchers.d.ts +4 -1
- package/src/keybinding-matchers.ts +13 -12
- package/src/kitty-graphics.d.ts +1 -1
- package/src/kitty-graphics.ts +3 -2
- package/src/motion-effects.d.ts +10 -0
- package/src/motion-effects.ts +27 -0
- package/src/native/backend.ts +66 -7
- package/src/native/encode.d.ts +2 -0
- package/src/native/encode.ts +2 -0
- package/src/native/measure.d.ts +10 -0
- package/src/native/measure.ts +185 -0
- package/src/native/overlay.d.ts +1 -1
- package/src/native/overlay.ts +1 -1
- package/src/native/quiet.d.ts +5 -0
- package/src/native/quiet.ts +105 -0
- package/src/native/reconcile.d.ts +6 -1
- package/src/native/reconcile.ts +16 -10
- package/src/native/spans.d.ts +6 -0
- package/src/native/spans.ts +40 -0
- package/src/native/state.d.ts +4 -0
- package/src/native/state.ts +18 -0
- package/src/overlays/agent-hub.ts +15 -2
- package/src/overlays/ask-dialog.ts +1 -0
- package/src/overlays/btw-history-panel.ts +73 -6
- package/src/overlays/link-browser.ts +295 -0
- package/src/overlays/running-subagent-badge.ts +2 -9
- package/src/overlays/settings-defs.ts +1 -1
- package/src/overlays/settings-selector.ts +17 -3
- package/src/overlays/spotlight-sheet.ts +478 -0
- package/src/overlays/usage-dashboard.ts +6 -5
- package/src/prompt/composer-attachments.d.ts +5 -2
- package/src/prompt/composer-attachments.ts +6 -6
- package/src/prompt/composer-cache.ts +17 -16
- package/src/prompt/composer.ts +30 -123
- package/src/prompt/custom-editor.ts +17 -13
- package/src/prompt/gradient-highlight.d.ts +2 -2
- package/src/prompt/gradient-highlight.ts +5 -4
- package/src/prompt/magic-keywords.d.ts +2 -0
- package/src/prompt/magic-keywords.ts +4 -1
- package/src/prompt/model-mention-autocomplete.ts +73 -20
- package/src/prompt/model-mention-syntax.d.ts +6 -0
- package/src/prompt/model-mention-syntax.ts +9 -0
- package/src/prompt/prompt-action-autocomplete.ts +49 -33
- package/src/prompt/tips.txt +1 -0
- package/src/prompt/welcome.ts +104 -2
- package/src/render/extension-links.d.ts +0 -6
- package/src/render/extension-links.ts +0 -20
- package/src/render/index.d.ts +1 -0
- package/src/render/index.ts +1 -0
- package/src/render/link-hints.d.ts +78 -0
- package/src/render/link-hints.ts +299 -0
- package/src/render/render-utils.d.ts +0 -2
- package/src/render/render-utils.ts +0 -5
- package/src/setup/scenes/glyph.ts +1 -1
- package/src/setup/scenes/types.ts +8 -0
- package/src/setup/scenes/updates.ts +116 -0
- package/src/setup/wizard.ts +19 -8
- package/src/spinner-clock.d.ts +34 -0
- package/src/spinner-clock.ts +79 -0
- package/src/status-line/component.ts +145 -53
- package/src/status-line/host.ts +51 -0
- package/src/status-line/index.ts +1 -0
- package/src/status-line/presets.ts +3 -1
- package/src/status-line/prompt-cache.ts +154 -0
- package/src/status-line/schema.ts +1 -1
- package/src/status-line/segments.ts +33 -22
- package/src/status-line/startup.ts +22 -4
- package/src/status-line/types.ts +8 -22
- package/src/stdin-buffer.ts +89 -46
- package/src/terminal-capabilities.ts +3 -3
- package/src/terminal.ts +1 -8
- package/src/theme/loader.ts +3 -2
- package/src/theme/schema.d.ts +28 -1
- package/src/theme/schema.ts +30 -1
- package/src/theme/symbols.d.ts +1 -1
- package/src/theme/symbols.ts +15 -3
- package/src/theme/theme-class.d.ts +12 -2
- package/src/theme/theme-class.ts +23 -0
- package/src/theme/theme-schema.json +1 -1
- package/src/theme/theme.d.ts +1 -1
- package/src/theme/theme.ts +3 -7
- package/src/theme/tui-adapters.d.ts +7 -0
- package/src/theme/tui-adapters.ts +33 -1
- package/src/thinking.d.ts +12 -0
- package/src/thinking.ts +31 -0
- package/src/tools/ask.d.ts +1 -1
- package/src/tools/ask.ts +99 -38
- package/src/tools/ast-edit.ts +51 -32
- package/src/tools/ast-grep.ts +31 -19
- package/src/tools/bash.d.ts +21 -0
- package/src/tools/bash.ts +166 -24
- package/src/tools/find.d.ts +9 -1
- package/src/tools/find.ts +23 -2
- package/src/tools/grep.d.ts +2 -1
- package/src/tools/grep.ts +52 -36
- package/src/tools/grouped-file-output.d.ts +17 -0
- package/src/tools/grouped-file-output.ts +20 -2
- package/src/tools/job-widget.d.ts +2 -2
- package/src/tools/job-widget.ts +2 -2
- package/src/tools/lsp.d.ts +4 -2
- package/src/tools/lsp.ts +537 -642
- package/src/tools/native-view.d.ts +4 -0
- package/src/tools/native-view.ts +8 -2
- package/src/tools/renderer.d.ts +9 -1
- package/src/tools/renderer.ts +9 -1
- package/src/tools/shell-trace.d.ts +10 -0
- package/src/tools/shell-trace.ts +80 -0
- package/src/tools/shell-viz-render.d.ts +6 -0
- package/src/tools/shell-viz-render.ts +156 -0
- package/src/tools/shell-viz.d.ts +16 -0
- package/src/tools/shell-viz.ts +181 -0
- package/src/tools/streaming-output.ts +18 -8
- package/src/tools/wait.d.ts +2 -2
- package/src/tools/wait.ts +39 -34
- package/src/tools/web-search-types.d.ts +1 -0
- package/src/tools/web-search-types.ts +1 -0
- package/src/tools/write.d.ts +2 -0
- package/src/tools/write.ts +2 -0
- package/src/tui.d.ts +15 -1
- package/src/tui.ts +63 -6
- package/src/windows-input-mode.ts +7 -1
- package/dist/types/chat/collab-prompt-message.d.ts +0 -14
- package/dist/types/chrome/collab-qrcode.d.ts +0 -35
- package/src/chat/collab-prompt-message.d.ts +0 -14
- package/src/chat/collab-prompt-message.ts +0 -46
- package/src/chrome/collab-qrcode.ts +0 -99
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
CombinedAutocompleteProvider,
|
|
5
5
|
findLeadingSlashCommandStart,
|
|
6
6
|
getKeybindings,
|
|
7
|
+
type ModelMentionCompletion,
|
|
7
8
|
type SlashCommand,
|
|
8
9
|
} from "../index";
|
|
9
10
|
import { formatKeyHints, type KeybindingsManager } from "../app-keybindings";
|
|
@@ -139,36 +140,28 @@ export class PromptActionAutocompleteProvider implements AutocompleteProvider {
|
|
|
139
140
|
onPartial?: (suggestions: { items: AutocompleteItem[]; prefix: string }) => void,
|
|
140
141
|
): Promise<{ items: AutocompleteItem[]; prefix: string } | null> {
|
|
141
142
|
if (signal?.aborted) return null;
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if (modelMentionSuggestions) return modelMentionSuggestions;
|
|
165
|
-
// No slash-argument completion for this input: preserve numeric
|
|
166
|
-
// GitHub references and internal URLs while keeping prompt-action
|
|
167
|
-
// tokens such as `#copy` literal.
|
|
168
|
-
const githubRefSuggestions = getGithubRefSuggestions(textBeforeCursor);
|
|
169
|
-
if (githubRefSuggestions) return githubRefSuggestions;
|
|
170
|
-
return getInternalUrlSuggestions(textBeforeCursor, undefined, signal, this.#internalUrlCaller);
|
|
171
|
-
}
|
|
143
|
+
const textBeforeCursor = (lines[cursorLine] || "").slice(0, cursorCol);
|
|
144
|
+
if (!this.#outranksModelMention(lines, cursorLine, textBeforeCursor)) {
|
|
145
|
+
const modelMention = getModelMentionSuggestions(textBeforeCursor, this.#modelMentions);
|
|
146
|
+
if (modelMention.kind === "matched") return modelMention.suggestions;
|
|
147
|
+
}
|
|
148
|
+
if (this.#isInSlashCommandArguments(lines, cursorLine, textBeforeCursor)) {
|
|
149
|
+
const argumentSuggestions = await this.#baseProvider.getSuggestions(
|
|
150
|
+
lines,
|
|
151
|
+
cursorLine,
|
|
152
|
+
cursorCol,
|
|
153
|
+
signal,
|
|
154
|
+
onPartial,
|
|
155
|
+
);
|
|
156
|
+
if (argumentSuggestions) return argumentSuggestions;
|
|
157
|
+
const modelMention = getModelMentionSuggestions(textBeforeCursor, this.#modelMentions);
|
|
158
|
+
if (modelMention.kind === "matched") return modelMention.suggestions;
|
|
159
|
+
// No slash-argument completion for this input: preserve numeric
|
|
160
|
+
// GitHub references and internal URLs while keeping prompt-action
|
|
161
|
+
// tokens such as `#copy` literal.
|
|
162
|
+
const githubRefSuggestions = getGithubRefSuggestions(textBeforeCursor);
|
|
163
|
+
if (githubRefSuggestions) return githubRefSuggestions;
|
|
164
|
+
return getInternalUrlSuggestions(textBeforeCursor, undefined, signal, this.#internalUrlCaller);
|
|
172
165
|
}
|
|
173
166
|
|
|
174
167
|
const githubRefSuggestions = getGithubRefSuggestions(textBeforeCursor);
|
|
@@ -197,9 +190,6 @@ export class PromptActionAutocompleteProvider implements AutocompleteProvider {
|
|
|
197
190
|
}
|
|
198
191
|
}
|
|
199
192
|
|
|
200
|
-
const modelMentionSuggestions = getModelMentionSuggestions(textBeforeCursor, this.#modelMentions);
|
|
201
|
-
if (modelMentionSuggestions) return modelMentionSuggestions;
|
|
202
|
-
|
|
203
193
|
const urlSuggestions = await getInternalUrlSuggestions(
|
|
204
194
|
textBeforeCursor,
|
|
205
195
|
undefined,
|
|
@@ -216,6 +206,27 @@ export class PromptActionAutocompleteProvider implements AutocompleteProvider {
|
|
|
216
206
|
return this.#baseProvider.getSuggestions(lines, cursorLine, cursorCol, signal, onPartial);
|
|
217
207
|
}
|
|
218
208
|
|
|
209
|
+
#isInSlashCommandArguments(lines: string[], cursorLine: number, textBeforeCursor: string): boolean {
|
|
210
|
+
const leadingSlashStart = findLeadingSlashCommandStart(textBeforeCursor);
|
|
211
|
+
if (leadingSlashStart === null || lines.slice(0, cursorLine).some(line => (line || "").trim() !== "")) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
const commandText = textBeforeCursor.slice(leadingSlashStart);
|
|
215
|
+
const spaceIndex = commandText.indexOf(" ");
|
|
216
|
+
if (spaceIndex === -1) return false;
|
|
217
|
+
const commandName = commandText.slice(1, spaceIndex);
|
|
218
|
+
const command = this.#commands.find(cmd => cmd.name === commandName || cmd.aliases?.includes(commandName));
|
|
219
|
+
return command !== undefined && (!("allowArgs" in command) || command.allowArgs !== false);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
#outranksModelMention(lines: string[], cursorLine: number, textBeforeCursor: string): boolean {
|
|
223
|
+
return (
|
|
224
|
+
this.#isInSlashCommandArguments(lines, cursorLine, textBeforeCursor) ||
|
|
225
|
+
getGithubRefContext(textBeforeCursor) !== null ||
|
|
226
|
+
getPromptActionPrefix(textBeforeCursor) !== null
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
219
230
|
applyCompletion(
|
|
220
231
|
lines: string[],
|
|
221
232
|
cursorLine: number,
|
|
@@ -272,6 +283,11 @@ export class PromptActionAutocompleteProvider implements AutocompleteProvider {
|
|
|
272
283
|
trySyncSlashCompletion(textBeforeCursor: string): { items: AutocompleteItem[]; prefix: string } | null {
|
|
273
284
|
return this.#baseProvider.trySyncSlashCompletion?.(textBeforeCursor) ?? null;
|
|
274
285
|
}
|
|
286
|
+
trySyncModelMentionCompletion(lines: string[], cursorLine: number, cursorCol: number): ModelMentionCompletion {
|
|
287
|
+
const textBeforeCursor = (lines[cursorLine] || "").slice(0, cursorCol);
|
|
288
|
+
if (this.#outranksModelMention(lines, cursorLine, textBeforeCursor)) return { kind: "unhandled" };
|
|
289
|
+
return getModelMentionSuggestions(textBeforeCursor, this.#modelMentions);
|
|
290
|
+
}
|
|
275
291
|
trySyncInlineReplace(textBeforeCursor: string): { replaceLen: number; insert: string } | null {
|
|
276
292
|
if (!emojiAutocompleteEnabled) return null;
|
|
277
293
|
return tryEmojiInlineReplace(textBeforeCursor);
|
package/src/prompt/tips.txt
CHANGED
|
@@ -12,6 +12,7 @@ Need a cheap nested model call? Use `completion(x...)`
|
|
|
12
12
|
Spaghetti code? Try complaining with /omfg
|
|
13
13
|
Did you know? Each kitty/tmux/cmux/zellij/wezterm split keeps its own session — `zetacode -c` resumes the right one
|
|
14
14
|
Drop the word `ultrathink` in your message for harder multi-step reasoning — watch it glow rainbow as you type
|
|
15
|
+
Agent overthinking? Say `chillax` — on models with per-message effort, thinking drops to the lowest level, even mid-turn — watch it glow as you type
|
|
15
16
|
Say `orchestrate` in your message to drive a multi-phase task with parallel subagents — watch it glow as you type
|
|
16
17
|
Say `workflowz` in your message to drive the task with parallel subagents in eval — watch it glow as you type
|
|
17
18
|
Bulk data to classify or triage? Say `jevify` in your message — the eval kernel's `judge()` processes the batch and you read only what it flags — watch it glow as you type
|
package/src/prompt/welcome.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { card, col, keyed, node, row, span, text } from "../native/describe";
|
|
|
8
8
|
import type { DescribeContext, NativeChild, NativeNode } from "../native/node";
|
|
9
9
|
import { compactText, plainText } from "../native/spans";
|
|
10
10
|
import { isNativeRendering } from "../native/state";
|
|
11
|
+
import { renderProgressBar } from "../components/progress-bar";
|
|
11
12
|
import { isHyperlinkEnabled, urlHyperlink, urlLinkSpan } from "../render/hyperlink";
|
|
12
13
|
import { TERMINAL } from "../terminal-capabilities";
|
|
13
14
|
import { theme } from "../theme/theme";
|
|
@@ -259,6 +260,17 @@ export function renderWelcomeTip(tip: string, width: number, phase = 0, isNew =
|
|
|
259
260
|
return lines;
|
|
260
261
|
}
|
|
261
262
|
|
|
263
|
+
/**
|
|
264
|
+
* Background self-update activity shown after the welcome banner's version
|
|
265
|
+
* label: `updating` while a newer `version` downloads (`fraction` once bytes
|
|
266
|
+
* are counted) or installs, `ready` once the next launch starts it, `failed`
|
|
267
|
+
* when the attempt stopped.
|
|
268
|
+
*/
|
|
269
|
+
export type VersionUpdate =
|
|
270
|
+
| { phase: "updating"; version: string; fraction?: number }
|
|
271
|
+
| { phase: "ready"; version: string }
|
|
272
|
+
| { phase: "failed"; version: string };
|
|
273
|
+
|
|
262
274
|
/**
|
|
263
275
|
* The session's welcome banner. In a terminal: the gradient mark beside the
|
|
264
276
|
* `Zeta` wordmark, with the version under the wordmark and the `Linxira-Zeta`
|
|
@@ -268,6 +280,7 @@ export function renderWelcomeTip(tip: string, width: number, phase = 0, isNew =
|
|
|
268
280
|
* ({@link WelcomeComponent.describe}).
|
|
269
281
|
*/
|
|
270
282
|
export class WelcomeComponent implements Component {
|
|
283
|
+
#versionUpdate: VersionUpdate | null = null;
|
|
271
284
|
#animStart: number | null = null;
|
|
272
285
|
#animTimer: Timer | null = null;
|
|
273
286
|
#requestRender: (() => void) | null = null;
|
|
@@ -336,7 +349,13 @@ export class WelcomeComponent implements Component {
|
|
|
336
349
|
col(
|
|
337
350
|
[
|
|
338
351
|
art([span("Zeta", "strong")], "zeta.welcome.wordmark"),
|
|
339
|
-
art(
|
|
352
|
+
art(
|
|
353
|
+
[
|
|
354
|
+
span(`v${this.version}`, "dim mono"),
|
|
355
|
+
...(this.#versionUpdate ? versionUpdateSpans(this.#versionUpdate) : []),
|
|
356
|
+
],
|
|
357
|
+
"zeta.welcome.version",
|
|
358
|
+
),
|
|
340
359
|
art([span("Linxira-Zeta", "dim")], "zeta.welcome.subline"),
|
|
341
360
|
],
|
|
342
361
|
{ role: "zeta.welcome.mark" },
|
|
@@ -432,6 +451,12 @@ export class WelcomeComponent implements Component {
|
|
|
432
451
|
this.invalidate();
|
|
433
452
|
}
|
|
434
453
|
|
|
454
|
+
/** Show (or with `null`, clear) background self-update activity after the version label. */
|
|
455
|
+
setVersionUpdate(update: VersionUpdate | null): void {
|
|
456
|
+
this.#versionUpdate = update;
|
|
457
|
+
this.invalidate();
|
|
458
|
+
}
|
|
459
|
+
|
|
435
460
|
render(termWidth: number): readonly string[] {
|
|
436
461
|
const animating = this.#animStart != null;
|
|
437
462
|
const lang = tuiText("welcomeBack", "Welcome back!");
|
|
@@ -457,8 +482,12 @@ export class WelcomeComponent implements Component {
|
|
|
457
482
|
const logo = this.#currentLogoFrame();
|
|
458
483
|
const version = theme.fg("dim", `v${this.version}`);
|
|
459
484
|
const lockupWidth = LOGO_WIDTH + LOCKUP_GAP + Math.max(WORDMARK_WIDTH, visibleWidth(version));
|
|
460
|
-
const
|
|
485
|
+
const hasLockup = room >= lockupWidth;
|
|
486
|
+
const art = hasLockup ? lockup(logo, version) : room >= LOGO_WIDTH ? logo : [];
|
|
487
|
+
// Centered without the update indicator, which then trails the version: the
|
|
488
|
+
// lockup stays put as the indicator appears, grows, and changes form.
|
|
461
489
|
const lines = centerBlock(art, termWidth);
|
|
490
|
+
if (hasLockup && this.#versionUpdate) appendVersionUpdate(lines, this.#versionUpdate, termWidth);
|
|
462
491
|
const tip = termWidth >= TIP_MIN_COLUMNS ? this.#renderTip(room) : [];
|
|
463
492
|
if (tip.length > 0) lines.push("", ...tip.flatMap(line => centerBlock([line], termWidth)));
|
|
464
493
|
return lines;
|
|
@@ -526,12 +555,85 @@ const WORDMARK_WIDTH = Math.max(...ZETA_WORDMARK.map(row => visibleWidth(row)));
|
|
|
526
555
|
/** Columns between the logo and the wordmark. */
|
|
527
556
|
const LOCKUP_GAP = 4;
|
|
528
557
|
|
|
558
|
+
/** Lockup row holding the version: directly below the wordmark rows. */
|
|
559
|
+
const VERSION_ROW = ZETA_WORDMARK.length;
|
|
560
|
+
|
|
561
|
+
/** Cells of the download bar in a {@link VersionUpdate} indicator. */
|
|
562
|
+
const UPDATE_BAR_WIDTH = 10;
|
|
563
|
+
|
|
529
564
|
/** Widest a welcome tip wraps, so a long one stays a centered paragraph. */
|
|
530
565
|
const TIP_MEASURE = 72;
|
|
531
566
|
|
|
532
567
|
/** Narrowest terminal that still shows the tip; below it the banner is the logo alone. */
|
|
533
568
|
const TIP_MIN_COLUMNS = 50;
|
|
534
569
|
|
|
570
|
+
/** Download percent, floored so 100% means every byte arrived. */
|
|
571
|
+
function updatePercent(fraction: number): string {
|
|
572
|
+
return `${Math.floor(Math.min(1, Math.max(0, fraction)) * 100)}%`;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/** Theme tone of a {@link VersionUpdate}: accent while running, success when ready, warning when failed. */
|
|
576
|
+
function updateTone(update: VersionUpdate): "accent" | "success" | "warning" {
|
|
577
|
+
return update.phase === "ready" ? "success" : update.phase === "failed" ? "warning" : "accent";
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Terminal forms of a {@link VersionUpdate} indicator, widest first: `→ v<new>`
|
|
582
|
+
* with a progress bar and percent while downloading (`updating…` before bytes
|
|
583
|
+
* are counted), `✔ next launch` once ready, `⚠ update failed` when stopped;
|
|
584
|
+
* then the arrow and version with the bare percent.
|
|
585
|
+
*/
|
|
586
|
+
function versionUpdateLabels(update: VersionUpdate): string[] {
|
|
587
|
+
const head = theme.fg(updateTone(update), `→ v${update.version}`);
|
|
588
|
+
let detail: string;
|
|
589
|
+
let compact = head;
|
|
590
|
+
if (update.phase === "updating") {
|
|
591
|
+
if (update.fraction === undefined) {
|
|
592
|
+
detail = theme.fg("muted", "updating…");
|
|
593
|
+
} else {
|
|
594
|
+
const percent = theme.fg("accent", updatePercent(update.fraction));
|
|
595
|
+
const bar = renderProgressBar(update.fraction, UPDATE_BAR_WIDTH, {
|
|
596
|
+
style: {
|
|
597
|
+
filled: theme.progress.filled,
|
|
598
|
+
empty: theme.progress.empty,
|
|
599
|
+
styleFilled: cells => theme.fg("accent", cells),
|
|
600
|
+
styleEmpty: cells => theme.fg("dim", cells),
|
|
601
|
+
},
|
|
602
|
+
});
|
|
603
|
+
detail = `${bar} ${percent}`;
|
|
604
|
+
compact = `${head} ${percent}`;
|
|
605
|
+
}
|
|
606
|
+
} else if (update.phase === "ready") {
|
|
607
|
+
detail = theme.fg("success", `${theme.status.success} next launch`);
|
|
608
|
+
} else {
|
|
609
|
+
detail = theme.fg("warning", `${theme.status.warning} update failed`);
|
|
610
|
+
}
|
|
611
|
+
return [`${head} ${detail}`, compact];
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Append the widest {@link versionUpdateLabels} form that fits after the
|
|
616
|
+
* lockup's version label in `lines`, keeping the right margin column clear;
|
|
617
|
+
* nothing when none fits.
|
|
618
|
+
*/
|
|
619
|
+
function appendVersionUpdate(lines: string[], update: VersionUpdate, termWidth: number): void {
|
|
620
|
+
const base = lines[VERSION_ROW];
|
|
621
|
+
if (base === undefined) return;
|
|
622
|
+
const room = termWidth - 2 - visibleWidth(base);
|
|
623
|
+
const label = versionUpdateLabels(update).find(form => visibleWidth(form) <= room);
|
|
624
|
+
if (label) lines[VERSION_ROW] = `${base} ${label}`;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/** Native spans of a {@link VersionUpdate} indicator, following the version label. */
|
|
628
|
+
function versionUpdateSpans(update: VersionUpdate): TspSpan[] {
|
|
629
|
+
const tone = updateTone(update);
|
|
630
|
+
const head = span(` → v${update.version}`, `${tone} mono`);
|
|
631
|
+
if (update.phase === "ready") return [head, span(" next launch", tone)];
|
|
632
|
+
if (update.phase === "failed") return [head, span(" update failed", tone)];
|
|
633
|
+
if (update.fraction === undefined) return [head, span(" updating…", "muted")];
|
|
634
|
+
return [head, span(` ${updatePercent(update.fraction)}`, `${tone} mono`)];
|
|
635
|
+
}
|
|
636
|
+
|
|
535
637
|
/**
|
|
536
638
|
* The lockup block: the mark beside the wordmark, `version` (styled) under the
|
|
537
639
|
* wordmark, and the `Linxira-Zeta` subline centered under the pair.
|
|
@@ -31,12 +31,6 @@ export declare function extensionLinkScheme(href: string): string | undefined;
|
|
|
31
31
|
* not change between renders of the same text, or rows rendered twice stop matching.
|
|
32
32
|
*/
|
|
33
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
34
|
/**
|
|
41
35
|
* `line` without omp's extension-link markers (the OSC 8 open and close around each label), for
|
|
42
36
|
* terminal output. Every other hyperlink is kept as is.
|
|
@@ -121,26 +121,6 @@ export function formatExtensionLink(label: string, href: string, key: string): s
|
|
|
121
121
|
return `${MARKER_OPEN}-${id};${safe}\x07${UNDERLINE.on}${body}${UNDERLINE.off}\x1b]8;;\x07`;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
/** Hint tag letters, home row first. */
|
|
125
|
-
const LINK_HINT_ALPHABET = "asdfghjklqwertyuiopzxcvbnm";
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Tags for `count` links in keyboard link-hint mode: single letters while they suffice, otherwise
|
|
129
|
-
* two letters each, so no tag is a prefix of another. At most the alphabet squared (676) are made;
|
|
130
|
-
* links past that stay untagged.
|
|
131
|
-
*/
|
|
132
|
-
export function linkHintTags(count: number): string[] {
|
|
133
|
-
if (count <= LINK_HINT_ALPHABET.length) return LINK_HINT_ALPHABET.slice(0, Math.max(0, count)).split("");
|
|
134
|
-
const tags: string[] = [];
|
|
135
|
-
for (const first of LINK_HINT_ALPHABET) {
|
|
136
|
-
for (const second of LINK_HINT_ALPHABET) {
|
|
137
|
-
if (tags.length === count) return tags;
|
|
138
|
-
tags.push(`${first}${second}`);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return tags;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
124
|
/**
|
|
145
125
|
* `line` without omp's extension-link markers (the OSC 8 open and close around each label), for
|
|
146
126
|
* terminal output. Every other hyperlink is kept as is.
|
package/src/render/index.d.ts
CHANGED
package/src/render/index.ts
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** An extension link label drawn on a shown row: what a click or hint tag lands on. */
|
|
2
|
+
export interface ViewportLink {
|
|
3
|
+
readonly url: string;
|
|
4
|
+
/** Shown row the label is drawn on (its first row, for a label wrapped across rows). */
|
|
5
|
+
readonly row: number;
|
|
6
|
+
/** First cell of the label's part on that row. */
|
|
7
|
+
readonly start: number;
|
|
8
|
+
}
|
|
9
|
+
/** A label {@link viewportLinkTargets} found: where it is drawn, its marker id and its text. */
|
|
10
|
+
export interface ViewportLinkTarget extends ViewportLink {
|
|
11
|
+
/** The label's marker id ({@link ExtensionLinkLabel.id}). */
|
|
12
|
+
readonly id: string;
|
|
13
|
+
/** The label's text, across every shown row it wraps to; its tag prefers these letters. */
|
|
14
|
+
readonly text: string;
|
|
15
|
+
/** Where each shown row's part of the label starts, top to bottom; the first is `row`/`start`. */
|
|
16
|
+
readonly parts: readonly {
|
|
17
|
+
readonly row: number;
|
|
18
|
+
readonly start: number;
|
|
19
|
+
}[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The extension link labels drawn on `rows`, top to bottom, a wrapped label once at its first row:
|
|
23
|
+
* a row's first label continues the previous row's last label when that has the same marker id
|
|
24
|
+
* and ends its row.
|
|
25
|
+
*/
|
|
26
|
+
export declare function viewportLinkTargets(rows: readonly string[]): ViewportLinkTarget[];
|
|
27
|
+
/**
|
|
28
|
+
* The tags of one hint session and the letters typed so far. A tag is drawn over the first cell of
|
|
29
|
+
* its label, so it prefers the letters it covers: the label's first letter, then its others, then
|
|
30
|
+
* the home row. Tags never prefix one another.
|
|
31
|
+
*/
|
|
32
|
+
export declare class LinkHints {
|
|
33
|
+
#private;
|
|
34
|
+
/** Whether labels have been tagged since construction. */
|
|
35
|
+
get tagged(): boolean;
|
|
36
|
+
/** Tag every label `rows` draw afresh and forget the letters typed; returns how many were tagged. */
|
|
37
|
+
assign(rows: readonly string[]): number;
|
|
38
|
+
/**
|
|
39
|
+
* Keep the tags while `rows` still draw the tagged labels first, in the same order and columns
|
|
40
|
+
* (they may sit on other rows, and links may be added after them), following them to the rows
|
|
41
|
+
* they are on now. Returns false, keeping nothing to pick, when they no longer are.
|
|
42
|
+
*/
|
|
43
|
+
follow(rows: readonly string[]): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Tag what `rows` draw now, keeping each label's tag while it stays in view: tags of labels no
|
|
46
|
+
* longer drawn are dropped and only newly drawn labels get one, top to bottom. A label is the
|
|
47
|
+
* same across repaints when one of its row parts is: that part's row (shown row plus `origin`,
|
|
48
|
+
* so a scrolling surface passes the row its first shown row has in the whole content), first
|
|
49
|
+
* cell, marker id and URL; marker ids alone repeat across replies. Matching any part keeps a
|
|
50
|
+
* wrapped label's tag while only some of its rows stay in view.
|
|
51
|
+
*
|
|
52
|
+
* The one time existing tags change: a new label finds no tag that keeps the set prefix-free
|
|
53
|
+
* (every letter is already a single-letter tag, say a 27th label joins 26). Then every label is
|
|
54
|
+
* tagged afresh with two letters, and the letters typed are forgotten.
|
|
55
|
+
*/
|
|
56
|
+
update(rows: readonly string[], origin?: number): void;
|
|
57
|
+
/**
|
|
58
|
+
* The content moved under the tags, as when a reply above some labels is redrawn taller or
|
|
59
|
+
* shorter: `move` maps the row a label was last drawn on in the whole content to the row it is
|
|
60
|
+
* on now, so the next {@link update} finds it there with its tag.
|
|
61
|
+
*/
|
|
62
|
+
moveRows(move: (row: number) => number): void;
|
|
63
|
+
/** Whether some row holds more tag cells than `width`, so its tags could not all be read side by side. */
|
|
64
|
+
crowded(width: number): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Type one letter of a tag. Returns the link whose whole tag is now typed, `true` while the
|
|
67
|
+
* letters still lead to several tags, and `false` when none starts with them. A pick or a miss
|
|
68
|
+
* forgets the letters typed.
|
|
69
|
+
*/
|
|
70
|
+
type(letter: string): ViewportLink | boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Draw every tag the typed letters still lead to over the start of its label, within the first
|
|
73
|
+
* `width` cells of each row (cells past it, such as a scrollbar, are kept). Tags on one row never
|
|
74
|
+
* overlap: one that would land on an earlier tag moves right, and tags that would run past
|
|
75
|
+
* `width` move left, so each stays readable as long as the row has room for them all.
|
|
76
|
+
*/
|
|
77
|
+
paint(rows: readonly string[], width: number): string[];
|
|
78
|
+
}
|