@oh-my-pi/pi-tui 18.2.3 → 18.2.5
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 +29 -0
- package/README.md +43 -0
- package/dist/types/app-keybindings.d.ts +395 -0
- package/dist/types/apps/autoresearch-dashboard.d.ts +43 -0
- package/dist/types/apps/autoresearch-data.d.ts +15 -0
- package/dist/types/apps/cleanse-board.d.ts +66 -0
- package/dist/types/apps/cleanse-picker.d.ts +23 -0
- package/dist/types/apps/debug/log-formatting.d.ts +6 -0
- package/dist/types/apps/debug/log-viewer.d.ts +81 -0
- package/dist/types/apps/debug/protocol-probe.d.ts +42 -0
- package/dist/types/apps/debug/raw-sse-buffer.d.ts +58 -0
- package/dist/types/apps/debug/raw-sse.d.ts +26 -0
- package/dist/types/apps/debug/terminal-info.d.ts +34 -0
- package/dist/types/apps/debug/viewer-frame.d.ts +52 -0
- package/dist/types/apps/git/avatar.d.ts +9 -0
- package/dist/types/apps/git/colors.d.ts +49 -0
- package/dist/types/apps/git/diff-pane.d.ts +188 -0
- package/dist/types/apps/git/git-tui.d.ts +66 -0
- package/dist/types/apps/git/sidebar.d.ts +149 -0
- package/dist/types/apps/git/state.d.ts +117 -0
- package/dist/types/apps/if-bench-board.d.ts +75 -0
- package/dist/types/apps/live-visualizer.d.ts +33 -0
- package/dist/types/apps/ps-data.d.ts +51 -0
- package/dist/types/apps/ps-top.d.ts +33 -0
- package/dist/types/apps/session-picker.d.ts +26 -0
- package/dist/types/apps/setup-model-picker.d.ts +13 -0
- package/dist/types/apps/standalone-picker.d.ts +42 -0
- package/dist/types/autocomplete.d.ts +4 -0
- package/dist/types/chat/advisor-message.d.ts +11 -0
- package/dist/types/chat/assistant-message.d.ts +106 -0
- package/dist/types/chat/background-tan-message.d.ts +9 -0
- package/dist/types/chat/bash-execution.d.ts +47 -0
- package/dist/types/chat/cache-invalidation-marker.d.ts +50 -0
- package/dist/types/chat/chat-transcript-builder.d.ts +50 -0
- package/dist/types/chat/collab-prompt-message.d.ts +10 -0
- package/dist/types/chat/compaction-summary-message.d.ts +54 -0
- package/dist/types/chat/custom-message.d.ts +10 -0
- package/dist/types/chat/display-preferences.d.ts +13 -0
- package/dist/types/chat/eval-execution.d.ts +29 -0
- package/dist/types/chat/execution-shared.d.ts +51 -0
- package/dist/types/chat/extension-types.d.ts +28 -0
- package/dist/types/chat/hook-message.d.ts +10 -0
- package/dist/types/chat/image-loading.d.ts +46 -0
- package/dist/types/chat/late-diagnostics-message.d.ts +21 -0
- package/dist/types/chat/messages.d.ts +189 -0
- package/dist/types/chat/reaction.d.ts +30 -0
- package/dist/types/chat/read-target.d.ts +4 -0
- package/dist/types/chat/read-tool-group.d.ts +67 -0
- package/dist/types/chat/served-model-marker.d.ts +47 -0
- package/dist/types/chat/skill-message.d.ts +33 -0
- package/dist/types/chat/skill-title-input.d.ts +14 -0
- package/dist/types/chat/stripped-tool-calls-placeholder.d.ts +12 -0
- package/dist/types/chat/thinking-display.d.ts +12 -0
- package/dist/types/chat/todo-reminder.d.ts +13 -0
- package/dist/types/chat/tool-execution.d.ts +138 -0
- package/dist/types/chat/transcript-browser.d.ts +93 -0
- package/dist/types/chat/transcript-entry.d.ts +45 -0
- package/dist/types/chat/transcript-outline.d.ts +86 -0
- package/dist/types/chat/transcript-render-helpers.d.ts +92 -0
- package/dist/types/chat/ttsr-notification.d.ts +23 -0
- package/dist/types/chat/user-message.d.ts +52 -0
- package/dist/types/chrome/chat-block.d.ts +64 -0
- package/dist/types/chrome/collab-qrcode.d.ts +28 -0
- package/dist/types/chrome/context-thresholds.d.ts +10 -0
- package/dist/types/chrome/countdown-timer.d.ts +14 -0
- package/dist/types/chrome/diff.d.ts +14 -0
- package/dist/types/chrome/dynamic-border.d.ts +16 -0
- package/dist/types/chrome/error-block.d.ts +17 -0
- package/dist/types/chrome/form-theme.d.ts +3 -0
- package/dist/types/chrome/format.d.ts +12 -0
- package/dist/types/chrome/index.d.ts +20 -0
- package/dist/types/chrome/keybinding-hints.d.ts +40 -0
- package/dist/types/chrome/live-board.d.ts +23 -0
- package/dist/types/chrome/local-date.d.ts +4 -0
- package/dist/types/chrome/message-divider.d.ts +22 -0
- package/dist/types/chrome/message-frame.d.ts +52 -0
- package/dist/types/chrome/message-notice.d.ts +35 -0
- package/dist/types/chrome/overlay-box.d.ts +74 -0
- package/dist/types/chrome/qrcode.d.ts +48 -0
- package/dist/types/chrome/segment-track.d.ts +27 -0
- package/dist/types/chrome/select-list-mouse-routing.d.ts +4 -0
- package/dist/types/chrome/selector-helpers.d.ts +52 -0
- package/dist/types/chrome/shared.d.ts +5 -0
- package/dist/types/chrome/streaming-panel.d.ts +19 -0
- package/dist/types/chrome/tool-activity.d.ts +17 -0
- package/dist/types/chrome/transcript-container.d.ts +129 -0
- package/dist/types/chrome/transcript-status.d.ts +12 -0
- package/dist/types/chrome/visual-truncate.d.ts +19 -0
- package/dist/types/components/disclosure.d.ts +42 -0
- package/dist/types/components/form.d.ts +130 -0
- package/dist/types/components/image.d.ts +18 -16
- package/dist/types/components/key-value-list.d.ts +24 -0
- package/dist/types/components/layout/geometry.d.ts +73 -0
- package/dist/types/components/layout/row.d.ts +55 -0
- package/dist/types/components/layout/split-pane.d.ts +80 -0
- package/dist/types/components/layout/stack.d.ts +50 -0
- package/dist/types/components/menu-selection.d.ts +71 -0
- package/dist/types/components/metric.d.ts +44 -0
- package/dist/types/components/progress-bar.d.ts +36 -0
- package/dist/types/components/scroll-view.d.ts +53 -19
- package/dist/types/components/scroll-viewport.d.ts +46 -0
- package/dist/types/components/section.d.ts +19 -0
- package/dist/types/components/select-list.d.ts +46 -2
- package/dist/types/components/settings-list.d.ts +20 -0
- package/dist/types/components/table.d.ts +32 -0
- package/dist/types/components/tree-view.d.ts +130 -0
- package/dist/types/components/wizard-step.d.ts +60 -0
- package/dist/types/hotkeys-markdown.d.ts +7 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/keybinding-matchers.d.ts +35 -0
- package/dist/types/keys.d.ts +2 -2
- package/dist/types/lang-from-path.d.ts +9 -0
- package/dist/types/overlays/advisor-config.d.ts +114 -0
- package/dist/types/overlays/agent-activity.d.ts +41 -0
- package/dist/types/overlays/agent-hub-projection.d.ts +33 -0
- package/dist/types/overlays/agent-hub-renderer.d.ts +53 -0
- package/dist/types/overlays/agent-hub-types.d.ts +99 -0
- package/dist/types/overlays/agent-hub.d.ts +126 -0
- package/dist/types/overlays/agent-transcript-viewer.d.ts +71 -0
- package/dist/types/overlays/agents-hub.d.ts +72 -0
- package/dist/types/overlays/ask-dialog.d.ts +88 -0
- package/dist/types/overlays/bordered-loader.d.ts +11 -0
- package/dist/types/overlays/btw-history-panel.d.ts +29 -0
- package/dist/types/overlays/btw-history.d.ts +17 -0
- package/dist/types/overlays/btw-panel.d.ts +26 -0
- package/dist/types/overlays/cleanse-panel.d.ts +36 -0
- package/dist/types/overlays/codex-reset-fireworks.d.ts +52 -0
- package/dist/types/overlays/composer-shape-preview.d.ts +47 -0
- package/dist/types/overlays/composer-shape-registry.d.ts +50 -0
- package/dist/types/overlays/copy-selector.d.ts +48 -0
- package/dist/types/overlays/copy-targets.d.ts +63 -0
- package/dist/types/overlays/error-banner.d.ts +13 -0
- package/dist/types/overlays/extensions/display-text.d.ts +10 -0
- package/dist/types/overlays/extensions/extension-dashboard.d.ts +63 -0
- package/dist/types/overlays/extensions/extension-list.d.ts +54 -0
- package/dist/types/overlays/extensions/inspector-model.d.ts +109 -0
- package/dist/types/overlays/extensions/inspector-panel.d.ts +17 -0
- package/dist/types/overlays/extensions/live-tool-session.d.ts +28 -0
- package/dist/types/overlays/extensions/mcp-runtime.d.ts +107 -0
- package/dist/types/overlays/extensions/state-manager.d.ts +42 -0
- package/dist/types/overlays/extensions/types.d.ts +165 -0
- package/dist/types/overlays/history-search.d.ts +16 -0
- package/dist/types/overlays/hook-editor.d.ts +44 -0
- package/dist/types/overlays/hook-input.d.ts +20 -0
- package/dist/types/overlays/hook-selector.d.ts +71 -0
- package/dist/types/overlays/hub-frame.d.ts +77 -0
- package/dist/types/overlays/login-dialog.d.ts +43 -0
- package/dist/types/overlays/logout-account-selector.d.ts +15 -0
- package/dist/types/overlays/mcp-add-wizard.d.ts +87 -0
- package/dist/types/overlays/model-browser.d.ts +213 -0
- package/dist/types/overlays/model-hub.d.ts +72 -0
- package/dist/types/overlays/model-picker.d.ts +74 -0
- package/dist/types/overlays/model-selector.d.ts +52 -0
- package/dist/types/overlays/move-overlay.d.ts +39 -0
- package/dist/types/overlays/oauth-selector.d.ts +41 -0
- package/dist/types/overlays/omfg-panel.d.ts +20 -0
- package/dist/types/overlays/pause-screen.d.ts +43 -0
- package/dist/types/overlays/plan-review-overlay.d.ts +89 -0
- package/dist/types/overlays/plan-save-overlay.d.ts +19 -0
- package/dist/types/overlays/plan-toc.d.ts +41 -0
- package/dist/types/overlays/plugin-selector.d.ts +28 -0
- package/dist/types/overlays/plugin-settings.d.ts +180 -0
- package/dist/types/overlays/queue-mode-selector.d.ts +11 -0
- package/dist/types/overlays/reset-usage-selector.d.ts +23 -0
- package/dist/types/overlays/rewind-selector.d.ts +61 -0
- package/dist/types/overlays/running-subagent-badge.d.ts +6 -0
- package/dist/types/overlays/session-account-selector.d.ts +24 -0
- package/dist/types/overlays/session-info-overlay.d.ts +17 -0
- package/dist/types/overlays/session-observer-registry.d.ts +77 -0
- package/dist/types/overlays/session-selector.d.ts +131 -0
- package/dist/types/overlays/settings-defs.d.ts +119 -0
- package/dist/types/overlays/settings-selector.d.ts +73 -0
- package/dist/types/overlays/show-images-selector.d.ts +11 -0
- package/dist/types/overlays/snapcompact-shape-preview.d.ts +31 -0
- package/dist/types/overlays/theme-selector.d.ts +12 -0
- package/dist/types/overlays/thinking-selector.d.ts +12 -0
- package/dist/types/overlays/tiny-title-download-progress.d.ts +21 -0
- package/dist/types/overlays/tree-selector.d.ts +92 -0
- package/dist/types/overlays/usage-dashboard.d.ts +94 -0
- package/dist/types/overlays/usage-display.d.ts +5 -0
- package/dist/types/overlays/usage-row.d.ts +17 -0
- package/dist/types/prompt/attachment-chips.d.ts +19 -0
- package/dist/types/prompt/composer-attachments.d.ts +71 -0
- package/dist/types/prompt/composer-cache.d.ts +37 -0
- package/dist/types/prompt/composer.d.ts +159 -0
- package/dist/types/prompt/custom-editor.d.ts +261 -0
- package/dist/types/prompt/editor-top-gap.d.ts +18 -0
- package/dist/types/prompt/emoji-autocomplete.d.ts +16 -0
- package/dist/types/prompt/github-ref-autocomplete.d.ts +35 -0
- package/dist/types/prompt/gradient-highlight.d.ts +32 -0
- package/dist/types/prompt/image-format.d.ts +4 -0
- package/dist/types/prompt/image-references.d.ts +26 -0
- package/dist/types/prompt/interactive-context-helpers.d.ts +43 -0
- package/dist/types/prompt/internal-url-autocomplete.d.ts +56 -0
- package/dist/types/prompt/macos-spelling.d.ts +44 -0
- package/dist/types/prompt/magic-keyword-boundary.d.ts +9 -0
- package/dist/types/prompt/magic-keywords.d.ts +26 -0
- package/dist/types/prompt/markdown-prose.d.ts +15 -0
- package/dist/types/prompt/model-mention-autocomplete.d.ts +25 -0
- package/dist/types/prompt/model-mention-syntax.d.ts +24 -0
- package/dist/types/prompt/orchestrate.d.ts +13 -0
- package/dist/types/prompt/prompt-action-autocomplete.d.ts +56 -0
- package/dist/types/prompt/queue-input.d.ts +8 -0
- package/dist/types/prompt/skill-tokens.d.ts +13 -0
- package/dist/types/prompt/tools-markdown.d.ts +12 -0
- package/dist/types/prompt/ultrathink.d.ts +13 -0
- package/dist/types/prompt/usage-amounts.d.ts +26 -0
- package/dist/types/prompt/video.d.ts +18 -0
- package/dist/types/prompt/welcome.d.ts +83 -0
- package/dist/types/prompt/workflow.d.ts +13 -0
- package/dist/types/render/code-cell.d.ts +51 -0
- package/dist/types/render/file-list.d.ts +22 -0
- package/dist/types/render/hyperlink.d.ts +80 -0
- package/dist/types/render/index.d.ts +16 -0
- package/dist/types/render/output-block.d.ts +54 -0
- package/dist/types/render/output-pane.d.ts +80 -0
- package/dist/types/render/render-utils.d.ts +312 -0
- package/dist/types/render/sixel.d.ts +21 -0
- package/dist/types/render/status-line.d.ts +23 -0
- package/dist/types/render/tool-card.d.ts +71 -0
- package/dist/types/render/tree-list.d.ts +29 -0
- package/dist/types/render/types.d.ts +17 -0
- package/dist/types/render/utils.d.ts +43 -0
- package/dist/types/render/width-aware-text.d.ts +23 -0
- package/dist/types/setup/lazy.d.ts +3 -0
- package/dist/types/setup/scenes/composer.d.ts +3 -0
- package/dist/types/setup/scenes/glyph.d.ts +3 -0
- package/dist/types/setup/scenes/model.d.ts +3 -0
- package/dist/types/setup/scenes/outro.d.ts +2 -0
- package/dist/types/setup/scenes/providers.d.ts +3 -0
- package/dist/types/setup/scenes/sign-in.d.ts +21 -0
- package/dist/types/setup/scenes/splash.d.ts +11 -0
- package/dist/types/setup/scenes/theme.d.ts +3 -0
- package/dist/types/setup/scenes/types.d.ts +110 -0
- package/dist/types/setup/scenes/web-search.d.ts +22 -0
- package/dist/types/setup/setup-version.d.ts +11 -0
- package/dist/types/setup/startup-splash.d.ts +9 -0
- package/dist/types/setup/wizard-overlay.d.ts +16 -0
- package/dist/types/setup/wizard.d.ts +25 -0
- package/dist/types/status-line/component.d.ts +182 -0
- package/dist/types/status-line/context-usage.d.ts +156 -0
- package/dist/types/status-line/footer.d.ts +30 -0
- package/dist/types/status-line/git-utils.d.ts +22 -0
- package/dist/types/status-line/host.d.ts +129 -0
- package/dist/types/status-line/index.d.ts +6 -0
- package/dist/types/status-line/loop.d.ts +18 -0
- package/dist/types/status-line/metrics.d.ts +21 -0
- package/dist/types/status-line/presets.d.ts +3 -0
- package/dist/types/status-line/schema.d.ts +15 -0
- package/dist/types/status-line/segments.d.ts +5 -0
- package/dist/types/status-line/separators.d.ts +3 -0
- package/dist/types/status-line/types.d.ts +236 -0
- package/dist/types/stdin-buffer.d.ts +4 -0
- package/dist/types/theme/color.d.ts +24 -0
- package/dist/types/theme/defaults/index.d.ts +9489 -0
- package/dist/types/theme/index.d.ts +4 -0
- package/dist/types/theme/loader.d.ts +23 -0
- package/dist/types/theme/mermaid-cache.d.ts +26 -0
- package/dist/types/theme/schema-validation.d.ts +3 -0
- package/dist/types/theme/schema.d.ts +25 -0
- package/dist/types/theme/session-color.d.ts +43 -0
- package/dist/types/theme/shimmer.d.ts +44 -0
- package/dist/types/theme/symbols.d.ts +34 -0
- package/dist/types/theme/theme-class.d.ts +299 -0
- package/dist/types/theme/theme.d.ts +111 -0
- package/dist/types/theme/tui-adapters.d.ts +30 -0
- package/dist/types/thinking.d.ts +165 -0
- package/dist/types/tools/agent-tree.d.ts +36 -0
- package/dist/types/tools/ask.d.ts +67 -0
- package/dist/types/tools/ast-edit.d.ts +53 -0
- package/dist/types/tools/ast-grep.d.ts +52 -0
- package/dist/types/tools/autoresearch.d.ts +156 -0
- package/dist/types/tools/bash-interactive.d.ts +28 -0
- package/dist/types/tools/bash.d.ts +103 -0
- package/dist/types/tools/conflict-detect.d.ts +43 -0
- package/dist/types/tools/debug.d.ts +60 -0
- package/dist/types/tools/default-renderer.d.ts +24 -0
- package/dist/types/tools/edit.d.ts +158 -0
- package/dist/types/tools/eval-format/code-mode-declarations.d.ts +5 -0
- package/dist/types/tools/eval-format/index.d.ts +5 -0
- package/dist/types/tools/eval-format/javascript.d.ts +2 -0
- package/dist/types/tools/eval-format/python.d.ts +2 -0
- package/dist/types/tools/eval.d.ts +94 -0
- package/dist/types/tools/fetch.d.ts +42 -0
- package/dist/types/tools/gh-format.d.ts +8 -0
- package/dist/types/tools/github.d.ts +144 -0
- package/dist/types/tools/glob.d.ts +44 -0
- package/dist/types/tools/goal.d.ts +42 -0
- package/dist/types/tools/grep.d.ts +64 -0
- package/dist/types/tools/grouped-file-output.d.ts +71 -0
- package/dist/types/tools/hashline-format.d.ts +28 -0
- package/dist/types/tools/hub.d.ts +340 -0
- package/dist/types/tools/index.d.ts +4 -0
- package/dist/types/tools/json-tree.d.ts +59 -0
- package/dist/types/tools/line-ranges.d.ts +29 -0
- package/dist/types/tools/list-limit.d.ts +15 -0
- package/dist/types/tools/lsp.d.ts +72 -0
- package/dist/types/tools/match-line-format.d.ts +11 -0
- package/dist/types/tools/mcp.d.ts +81 -0
- package/dist/types/tools/memory.d.ts +67 -0
- package/dist/types/tools/output-meta.d.ts +151 -0
- package/dist/types/tools/read.d.ts +139 -0
- package/dist/types/tools/renderer.d.ts +98 -0
- package/dist/types/tools/report-tool-issue.d.ts +8 -0
- package/dist/types/tools/resolve.d.ts +47 -0
- package/dist/types/tools/streaming-output.d.ts +282 -0
- package/dist/types/tools/subprocess.d.ts +24 -0
- package/dist/types/tools/task-repair-args.d.ts +53 -0
- package/dist/types/tools/task-yield-assembly.d.ts +20 -0
- package/dist/types/tools/task.d.ts +425 -0
- package/dist/types/tools/terminal-output.d.ts +8 -0
- package/dist/types/tools/think.d.ts +13 -0
- package/dist/types/tools/todo.d.ts +118 -0
- package/dist/types/tools/tool-errors.d.ts +7 -0
- package/dist/types/tools/vibe.d.ts +120 -0
- package/dist/types/tools/web-search.d.ts +195 -0
- package/dist/types/tools/write.d.ts +76 -0
- package/dist/types/tools/xd-url.d.ts +13 -0
- package/dist/types/tools/xdev.d.ts +52 -0
- package/dist/types/tui.d.ts +18 -0
- package/dist/types/utils.d.ts +2 -0
- package/package.json +37 -3
- package/src/app-keybindings.ts +760 -0
- package/src/apps/autoresearch-dashboard.ts +500 -0
- package/src/apps/autoresearch-data.ts +64 -0
- package/src/apps/cleanse-board.ts +341 -0
- package/src/apps/cleanse-picker.ts +57 -0
- package/src/apps/debug/log-formatting.ts +53 -0
- package/src/apps/debug/log-viewer.ts +868 -0
- package/src/apps/debug/protocol-probe.ts +267 -0
- package/src/apps/debug/raw-sse-buffer.ts +449 -0
- package/src/apps/debug/raw-sse.ts +282 -0
- package/src/apps/debug/terminal-info.ts +115 -0
- package/src/apps/debug/viewer-frame.ts +174 -0
- package/src/apps/git/avatar.ts +52 -0
- package/src/apps/git/colors.ts +109 -0
- package/src/apps/git/diff-pane.ts +1512 -0
- package/src/apps/git/git-tui.ts +889 -0
- package/src/apps/git/sidebar.ts +1204 -0
- package/src/apps/git/state.ts +113 -0
- package/src/apps/if-bench-board.ts +324 -0
- package/src/apps/live-visualizer.ts +238 -0
- package/src/apps/ps-data.ts +116 -0
- package/src/apps/ps-top.ts +422 -0
- package/src/apps/session-picker.ts +95 -0
- package/src/apps/setup-model-picker.ts +21 -0
- package/src/apps/standalone-picker.ts +111 -0
- package/src/autocomplete.ts +9 -13
- package/src/chat/advisor-message.ts +175 -0
- package/src/chat/assistant-message.ts +1214 -0
- package/src/chat/background-tan-message.ts +35 -0
- package/src/chat/bash-execution.ts +394 -0
- package/src/chat/cache-invalidation-marker.ts +94 -0
- package/src/chat/chat-transcript-builder.ts +593 -0
- package/src/chat/collab-prompt-message.ts +34 -0
- package/src/chat/compaction-summary-message.ts +261 -0
- package/src/chat/custom-message.ts +23 -0
- package/src/chat/display-preferences.ts +24 -0
- package/src/chat/eval-execution.ts +172 -0
- package/src/chat/execution-shared.ts +113 -0
- package/src/chat/extension-types.ts +46 -0
- package/src/chat/hook-message.ts +20 -0
- package/src/chat/image-loading.ts +122 -0
- package/src/chat/late-diagnostics-message.ts +92 -0
- package/src/chat/messages.ts +305 -0
- package/src/chat/reaction.ts +65 -0
- package/src/chat/read-target.ts +7 -0
- package/src/chat/read-tool-group.ts +873 -0
- package/src/chat/served-model-marker.ts +91 -0
- package/src/chat/skill-message.ts +220 -0
- package/src/chat/skill-title-input.ts +41 -0
- package/src/chat/stripped-tool-calls-placeholder.ts +35 -0
- package/src/chat/thinking-display.ts +312 -0
- package/src/chat/todo-reminder.ts +33 -0
- package/src/chat/tool-execution.ts +1395 -0
- package/src/chat/transcript-browser.ts +268 -0
- package/src/chat/transcript-entry.ts +96 -0
- package/src/chat/transcript-outline.ts +260 -0
- package/src/chat/transcript-render-helpers.ts +315 -0
- package/src/chat/ttsr-notification.ts +123 -0
- package/src/chat/user-message.ts +287 -0
- package/src/chrome/chat-block.ts +110 -0
- package/src/chrome/collab-qrcode.ts +74 -0
- package/src/chrome/context-thresholds.ts +85 -0
- package/src/chrome/countdown-timer.ts +74 -0
- package/src/chrome/diff.ts +266 -0
- package/src/chrome/dynamic-border.ts +36 -0
- package/src/chrome/error-block.ts +63 -0
- package/src/chrome/form-theme.ts +10 -0
- package/src/chrome/format.ts +66 -0
- package/src/chrome/index.ts +21 -0
- package/src/chrome/keybinding-hints.ts +55 -0
- package/src/chrome/live-board.ts +123 -0
- package/src/chrome/local-date.ts +20 -0
- package/src/chrome/message-divider.ts +51 -0
- package/src/chrome/message-frame.ts +164 -0
- package/src/chrome/message-notice.ts +103 -0
- package/src/chrome/overlay-box.ts +301 -0
- package/src/chrome/qrcode.ts +539 -0
- package/src/chrome/segment-track.ts +86 -0
- package/src/chrome/select-list-mouse-routing.ts +11 -0
- package/src/chrome/selector-helpers.ts +119 -0
- package/src/chrome/shared.ts +27 -0
- package/src/chrome/streaming-panel.ts +72 -0
- package/src/chrome/tool-activity.ts +44 -0
- package/src/chrome/transcript-container.ts +902 -0
- package/src/chrome/transcript-status.ts +27 -0
- package/src/chrome/visual-truncate.ts +70 -0
- package/src/components/disclosure.ts +235 -0
- package/src/components/editor.ts +10 -12
- package/src/components/form.ts +566 -0
- package/src/components/image.ts +80 -53
- package/src/components/input.ts +6 -27
- package/src/components/key-value-list.ts +88 -0
- package/src/components/layout/geometry.ts +202 -0
- package/src/components/layout/row.ts +283 -0
- package/src/components/layout/split-pane.ts +349 -0
- package/src/components/layout/stack.ts +261 -0
- package/src/components/markdown.ts +16 -12
- package/src/components/menu-selection.ts +248 -0
- package/src/components/metric.ts +132 -0
- package/src/components/progress-bar.ts +140 -0
- package/src/components/scroll-view.ts +372 -70
- package/src/components/scroll-viewport.ts +154 -0
- package/src/components/section.ts +77 -0
- package/src/components/select-list.ts +238 -159
- package/src/components/settings-list.ts +103 -80
- package/src/components/table.ts +127 -0
- package/src/components/tree-view.ts +481 -0
- package/src/components/wizard-step.ts +229 -0
- package/src/deccara.ts +1 -3
- package/src/hotkeys-markdown.ts +100 -0
- package/src/index.ts +18 -0
- package/src/keybinding-matchers.ts +99 -0
- package/src/keys.ts +2 -2
- package/src/lang-from-path.ts +252 -0
- package/src/overlays/advisor-config.ts +761 -0
- package/src/overlays/agent-activity.ts +113 -0
- package/src/overlays/agent-hub-projection.ts +250 -0
- package/src/overlays/agent-hub-renderer.ts +281 -0
- package/src/overlays/agent-hub-types.ts +74 -0
- package/src/overlays/agent-hub.ts +1562 -0
- package/src/overlays/agent-transcript-viewer.ts +669 -0
- package/src/overlays/agents-hub.ts +1203 -0
- package/src/overlays/ask-dialog.ts +1202 -0
- package/src/overlays/bordered-loader.ts +41 -0
- package/src/overlays/btw-history-panel.ts +591 -0
- package/src/overlays/btw-history.ts +33 -0
- package/src/overlays/btw-panel.ts +167 -0
- package/src/overlays/cleanse-panel.ts +167 -0
- package/src/overlays/codex-reset-fireworks.ts +375 -0
- package/src/overlays/composer-shape-preview.ts +137 -0
- package/src/overlays/composer-shape-registry.ts +82 -0
- package/src/overlays/copy-selector.ts +618 -0
- package/src/overlays/copy-targets.ts +210 -0
- package/src/overlays/error-banner.ts +39 -0
- package/src/overlays/extensions/display-text.ts +39 -0
- package/src/overlays/extensions/extension-dashboard.ts +645 -0
- package/src/overlays/extensions/extension-list.ts +667 -0
- package/src/overlays/extensions/inspector-model.ts +484 -0
- package/src/overlays/extensions/inspector-panel.ts +669 -0
- package/src/overlays/extensions/live-tool-session.ts +67 -0
- package/src/overlays/extensions/mcp-runtime.ts +289 -0
- package/src/overlays/extensions/state-manager.ts +337 -0
- package/src/overlays/extensions/types.ts +208 -0
- package/src/overlays/history-search.ts +268 -0
- package/src/overlays/hook-editor.ts +272 -0
- package/src/overlays/hook-input.ts +84 -0
- package/src/overlays/hook-selector.ts +635 -0
- package/src/overlays/hub-frame.ts +262 -0
- package/src/overlays/login-dialog.ts +231 -0
- package/src/overlays/logout-account-selector.ts +115 -0
- package/src/overlays/mcp-add-wizard.ts +1436 -0
- package/src/overlays/model-browser.ts +1176 -0
- package/src/overlays/model-hub.ts +2279 -0
- package/src/overlays/model-picker.ts +285 -0
- package/src/overlays/model-selector.ts +107 -0
- package/src/overlays/move-overlay.ts +197 -0
- package/src/overlays/oauth-selector.ts +446 -0
- package/src/overlays/omfg-panel.ts +136 -0
- package/src/overlays/pause-screen.ts +198 -0
- package/src/overlays/plan-review-overlay.ts +1227 -0
- package/src/overlays/plan-save-overlay.ts +74 -0
- package/src/overlays/plan-toc.ts +139 -0
- package/src/overlays/plugin-selector.ts +97 -0
- package/src/overlays/plugin-settings.ts +839 -0
- package/src/overlays/queue-mode-selector.ts +55 -0
- package/src/overlays/reset-usage-selector.ts +170 -0
- package/src/overlays/rewind-selector.ts +499 -0
- package/src/overlays/running-subagent-badge.ts +19 -0
- package/src/overlays/session-account-selector.ts +68 -0
- package/src/overlays/session-info-overlay.ts +96 -0
- package/src/overlays/session-observer-registry.ts +289 -0
- package/src/overlays/session-selector.ts +1137 -0
- package/src/overlays/settings-defs.ts +315 -0
- package/src/overlays/settings-selector.ts +1415 -0
- package/src/overlays/show-images-selector.ts +44 -0
- package/src/overlays/snapcompact-shape-preview-doc.md +14 -0
- package/src/overlays/snapcompact-shape-preview.ts +192 -0
- package/src/overlays/theme-selector.ts +62 -0
- package/src/overlays/thinking-selector.ts +51 -0
- package/src/overlays/tiny-title-download-progress.ts +102 -0
- package/src/overlays/tree-selector.ts +1121 -0
- package/src/overlays/usage-dashboard.ts +629 -0
- package/src/overlays/usage-display.ts +45 -0
- package/src/overlays/usage-row.ts +118 -0
- package/src/prompt/attachment-chips.ts +201 -0
- package/src/prompt/composer-attachments.ts +280 -0
- package/src/prompt/composer-cache.ts +304 -0
- package/src/prompt/composer.ts +934 -0
- package/src/prompt/custom-editor.ts +1392 -0
- package/src/prompt/data/emojis.json +1 -0
- package/src/prompt/editor-top-gap.ts +28 -0
- package/src/prompt/emoji-autocomplete.ts +285 -0
- package/src/prompt/github-ref-autocomplete.ts +75 -0
- package/src/prompt/gradient-highlight.ts +101 -0
- package/src/prompt/image-format.ts +28 -0
- package/src/prompt/image-references.ts +102 -0
- package/src/prompt/interactive-context-helpers.ts +126 -0
- package/src/prompt/internal-url-autocomplete.ts +155 -0
- package/src/prompt/macos-spelling.ts +456 -0
- package/src/prompt/magic-keyword-boundary.ts +23 -0
- package/src/prompt/magic-keywords.ts +42 -0
- package/src/prompt/markdown-prose.ts +245 -0
- package/src/prompt/model-mention-autocomplete.ts +94 -0
- package/src/prompt/model-mention-syntax.ts +41 -0
- package/src/prompt/orchestrate.ts +26 -0
- package/src/prompt/prompt-action-autocomplete.ts +337 -0
- package/src/prompt/queue-input.ts +132 -0
- package/src/prompt/skill-tokens.ts +36 -0
- package/src/prompt/tips.txt +27 -0
- package/src/prompt/tools-markdown.ts +29 -0
- package/src/prompt/ultrathink.ts +26 -0
- package/src/prompt/usage-amounts.ts +99 -0
- package/src/prompt/video.ts +47 -0
- package/src/prompt/welcome.ts +605 -0
- package/src/prompt/workflow.ts +26 -0
- package/src/render/code-cell.ts +244 -0
- package/src/render/file-list.ts +58 -0
- package/src/render/hyperlink.ts +192 -0
- package/src/render/index.ts +17 -0
- package/src/render/output-block.ts +267 -0
- package/src/render/output-pane.ts +299 -0
- package/src/render/render-utils.ts +1182 -0
- package/src/render/sixel.ts +69 -0
- package/src/render/status-line.ts +55 -0
- package/src/render/tool-card.ts +272 -0
- package/src/render/tree-list.ts +188 -0
- package/src/render/types.ts +19 -0
- package/src/render/utils.ts +109 -0
- package/src/render/width-aware-text.ts +60 -0
- package/src/setup/lazy.ts +17 -0
- package/src/setup/scenes/composer.ts +127 -0
- package/src/setup/scenes/glyph.ts +120 -0
- package/src/setup/scenes/model.ts +138 -0
- package/src/setup/scenes/outro.ts +24 -0
- package/src/setup/scenes/providers.ts +107 -0
- package/src/setup/scenes/sign-in.ts +373 -0
- package/src/setup/scenes/splash.ts +192 -0
- package/src/setup/scenes/theme.ts +343 -0
- package/src/setup/scenes/types.ts +111 -0
- package/src/setup/scenes/web-search.ts +165 -0
- package/src/setup/setup-version.ts +11 -0
- package/src/setup/startup-splash.ts +107 -0
- package/src/setup/wizard-overlay.ts +319 -0
- package/src/setup/wizard.ts +101 -0
- package/src/status-line/component.ts +3003 -0
- package/src/status-line/context-usage.ts +688 -0
- package/src/status-line/footer.ts +323 -0
- package/src/status-line/git-utils.ts +42 -0
- package/src/status-line/host.ts +97 -0
- package/src/status-line/index.ts +6 -0
- package/src/status-line/loop.ts +28 -0
- package/src/status-line/metrics.ts +94 -0
- package/src/status-line/presets.ts +107 -0
- package/src/status-line/schema.ts +57 -0
- package/src/status-line/segments.ts +934 -0
- package/src/status-line/separators.ts +55 -0
- package/src/status-line/types.ts +227 -0
- package/src/stdin-buffer.ts +4 -2
- package/src/theme/color.ts +95 -0
- package/src/theme/dark.json +95 -0
- package/src/theme/defaults/alabaster.json +93 -0
- package/src/theme/defaults/amethyst.json +96 -0
- package/src/theme/defaults/anthracite.json +93 -0
- package/src/theme/defaults/basalt.json +91 -0
- package/src/theme/defaults/birch.json +95 -0
- package/src/theme/defaults/dark-abyss.json +91 -0
- package/src/theme/defaults/dark-arctic.json +104 -0
- package/src/theme/defaults/dark-aurora.json +95 -0
- package/src/theme/defaults/dark-catppuccin.json +107 -0
- package/src/theme/defaults/dark-cavern.json +91 -0
- package/src/theme/defaults/dark-celestial.json +106 -0
- package/src/theme/defaults/dark-copper.json +95 -0
- package/src/theme/defaults/dark-cosmos.json +90 -0
- package/src/theme/defaults/dark-cyberpunk.json +102 -0
- package/src/theme/defaults/dark-dracula.json +98 -0
- package/src/theme/defaults/dark-eclipse.json +91 -0
- package/src/theme/defaults/dark-ember.json +95 -0
- package/src/theme/defaults/dark-equinox.json +90 -0
- package/src/theme/defaults/dark-forest.json +96 -0
- package/src/theme/defaults/dark-github.json +105 -0
- package/src/theme/defaults/dark-gruvbox.json +112 -0
- package/src/theme/defaults/dark-lavender.json +95 -0
- package/src/theme/defaults/dark-lunar.json +89 -0
- package/src/theme/defaults/dark-midnight.json +95 -0
- package/src/theme/defaults/dark-monochrome.json +94 -0
- package/src/theme/defaults/dark-monokai.json +98 -0
- package/src/theme/defaults/dark-nebula.json +90 -0
- package/src/theme/defaults/dark-nord.json +98 -0
- package/src/theme/defaults/dark-ocean.json +101 -0
- package/src/theme/defaults/dark-one.json +100 -0
- package/src/theme/defaults/dark-poimandres.json +115 -0
- package/src/theme/defaults/dark-rainforest.json +91 -0
- package/src/theme/defaults/dark-reef.json +91 -0
- package/src/theme/defaults/dark-retro.json +92 -0
- package/src/theme/defaults/dark-rose-pine.json +96 -0
- package/src/theme/defaults/dark-sakura.json +95 -0
- package/src/theme/defaults/dark-slate.json +95 -0
- package/src/theme/defaults/dark-solarized.json +97 -0
- package/src/theme/defaults/dark-solstice.json +90 -0
- package/src/theme/defaults/dark-starfall.json +91 -0
- package/src/theme/defaults/dark-sunset.json +99 -0
- package/src/theme/defaults/dark-swamp.json +90 -0
- package/src/theme/defaults/dark-synthwave.json +103 -0
- package/src/theme/defaults/dark-taiga.json +91 -0
- package/src/theme/defaults/dark-terminal.json +95 -0
- package/src/theme/defaults/dark-tokyo-night.json +101 -0
- package/src/theme/defaults/dark-tundra.json +91 -0
- package/src/theme/defaults/dark-twilight.json +91 -0
- package/src/theme/defaults/dark-volcanic.json +91 -0
- package/src/theme/defaults/graphite.json +92 -0
- package/src/theme/defaults/index.ts +201 -0
- package/src/theme/defaults/light-arctic.json +107 -0
- package/src/theme/defaults/light-aurora-day.json +91 -0
- package/src/theme/defaults/light-canyon.json +91 -0
- package/src/theme/defaults/light-catppuccin.json +106 -0
- package/src/theme/defaults/light-cirrus.json +90 -0
- package/src/theme/defaults/light-coral.json +95 -0
- package/src/theme/defaults/light-cyberpunk.json +96 -0
- package/src/theme/defaults/light-dawn.json +90 -0
- package/src/theme/defaults/light-dunes.json +91 -0
- package/src/theme/defaults/light-eucalyptus.json +95 -0
- package/src/theme/defaults/light-forest.json +100 -0
- package/src/theme/defaults/light-frost.json +95 -0
- package/src/theme/defaults/light-github.json +115 -0
- package/src/theme/defaults/light-glacier.json +91 -0
- package/src/theme/defaults/light-gruvbox.json +108 -0
- package/src/theme/defaults/light-haze.json +90 -0
- package/src/theme/defaults/light-honeycomb.json +95 -0
- package/src/theme/defaults/light-lagoon.json +91 -0
- package/src/theme/defaults/light-lavender.json +95 -0
- package/src/theme/defaults/light-meadow.json +91 -0
- package/src/theme/defaults/light-mint.json +95 -0
- package/src/theme/defaults/light-monochrome.json +101 -0
- package/src/theme/defaults/light-ocean.json +99 -0
- package/src/theme/defaults/light-one.json +99 -0
- package/src/theme/defaults/light-opal.json +91 -0
- package/src/theme/defaults/light-orchard.json +91 -0
- package/src/theme/defaults/light-paper.json +95 -0
- package/src/theme/defaults/light-poimandres.json +115 -0
- package/src/theme/defaults/light-prism.json +90 -0
- package/src/theme/defaults/light-retro.json +98 -0
- package/src/theme/defaults/light-sand.json +95 -0
- package/src/theme/defaults/light-savanna.json +91 -0
- package/src/theme/defaults/light-solarized.json +102 -0
- package/src/theme/defaults/light-soleil.json +90 -0
- package/src/theme/defaults/light-sunset.json +99 -0
- package/src/theme/defaults/light-synthwave.json +98 -0
- package/src/theme/defaults/light-tokyo-night.json +111 -0
- package/src/theme/defaults/light-wetland.json +91 -0
- package/src/theme/defaults/light-zenith.json +89 -0
- package/src/theme/defaults/limestone.json +94 -0
- package/src/theme/defaults/mahogany.json +97 -0
- package/src/theme/defaults/marble.json +93 -0
- package/src/theme/defaults/obsidian.json +91 -0
- package/src/theme/defaults/onyx.json +91 -0
- package/src/theme/defaults/pearl.json +93 -0
- package/src/theme/defaults/porcelain.json +91 -0
- package/src/theme/defaults/quartz.json +96 -0
- package/src/theme/defaults/sandstone.json +95 -0
- package/src/theme/defaults/titanium.json +90 -0
- package/src/theme/index.ts +5 -0
- package/src/theme/light.json +93 -0
- package/src/theme/loader.ts +200 -0
- package/src/theme/mermaid-cache.ts +92 -0
- package/src/theme/schema-validation.ts +119 -0
- package/src/theme/schema.ts +168 -0
- package/src/theme/session-color.ts +253 -0
- package/src/theme/shimmer.ts +307 -0
- package/src/theme/symbols.ts +1433 -0
- package/src/theme/theme-class.ts +787 -0
- package/src/theme/theme-schema.json +463 -0
- package/src/theme/theme.ts +810 -0
- package/src/theme/tui-adapters.ts +339 -0
- package/src/thinking.ts +380 -0
- package/src/tools/agent-tree.ts +128 -0
- package/src/tools/ask.ts +482 -0
- package/src/tools/ast-edit.ts +210 -0
- package/src/tools/ast-grep.ts +171 -0
- package/src/tools/autoresearch.ts +287 -0
- package/src/tools/bash-interactive.ts +295 -0
- package/src/tools/bash.ts +468 -0
- package/src/tools/conflict-detect.ts +77 -0
- package/src/tools/debug.ts +167 -0
- package/src/tools/default-renderer.ts +172 -0
- package/src/tools/edit.ts +1258 -0
- package/src/tools/eval-format/code-mode-declarations.ts +61 -0
- package/src/tools/eval-format/index.ts +16 -0
- package/src/tools/eval-format/javascript.ts +952 -0
- package/src/tools/eval-format/python.ts +544 -0
- package/src/tools/eval.ts +835 -0
- package/src/tools/fetch.ts +226 -0
- package/src/tools/gh-format.ts +18 -0
- package/src/tools/github.ts +686 -0
- package/src/tools/glob.ts +213 -0
- package/src/tools/goal.ts +153 -0
- package/src/tools/grep.ts +385 -0
- package/src/tools/grouped-file-output.ts +211 -0
- package/src/tools/hashline-format.ts +59 -0
- package/src/tools/hub.ts +1488 -0
- package/src/tools/index.ts +71 -0
- package/src/tools/json-tree.ts +388 -0
- package/src/tools/line-ranges.ts +98 -0
- package/src/tools/list-limit.ts +43 -0
- package/src/tools/lsp.ts +702 -0
- package/src/tools/match-line-format.ts +20 -0
- package/src/tools/mcp.ts +309 -0
- package/src/tools/memory.ts +220 -0
- package/src/tools/output-meta.ts +367 -0
- package/src/tools/read.ts +628 -0
- package/src/tools/renderer.ts +107 -0
- package/src/tools/report-tool-issue.ts +13 -0
- package/src/tools/resolve.ts +139 -0
- package/src/tools/streaming-output.ts +1576 -0
- package/src/tools/subprocess.ts +39 -0
- package/src/tools/task-repair-args.ts +118 -0
- package/src/tools/task-yield-assembly.ts +147 -0
- package/src/tools/task.ts +2110 -0
- package/src/tools/terminal-output.ts +153 -0
- package/src/tools/think.ts +28 -0
- package/src/tools/todo.ts +580 -0
- package/src/tools/tool-errors.ts +15 -0
- package/src/tools/vibe.ts +420 -0
- package/src/tools/web-search.ts +409 -0
- package/src/tools/write.ts +511 -0
- package/src/tools/xd-url.ts +28 -0
- package/src/tools/xdev.ts +201 -0
- package/src/tui.ts +70 -8
- package/src/utils.ts +8 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bordered output container with optional header and sections.
|
|
3
|
+
*/
|
|
4
|
+
import { ImageProtocol, TERMINAL } from "../terminal-capabilities";
|
|
5
|
+
import type { Theme, ThemeColor } from "../theme/theme";
|
|
6
|
+
import type { Component } from "../tui";
|
|
7
|
+
import { Ellipsis, padding, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "../utils";
|
|
8
|
+
import { getSixelLineMask } from "./sixel";
|
|
9
|
+
import type { State } from "./types";
|
|
10
|
+
import type { RenderCache } from "./utils";
|
|
11
|
+
import { getStateBgColor, Hasher, padToWidth } from "./utils";
|
|
12
|
+
|
|
13
|
+
/** Sections and presentation options for a bordered output block. */
|
|
14
|
+
export interface OutputBlockOptions {
|
|
15
|
+
header?: string;
|
|
16
|
+
headerMeta?: string;
|
|
17
|
+
state?: State;
|
|
18
|
+
sections?: Array<{ label?: string; lines: readonly string[]; separator?: boolean }>;
|
|
19
|
+
width: number;
|
|
20
|
+
applyBg?: boolean;
|
|
21
|
+
contentPaddingLeft?: number;
|
|
22
|
+
contentPaddingRight?: number;
|
|
23
|
+
/** Override the state-derived border color. Used for muted "legacy" tool
|
|
24
|
+
* frames that should not visually compete with framed-output tools. */
|
|
25
|
+
borderColor?: ThemeColor;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const FRAMED_BLOCK_COMPONENT = Symbol("framedBlockComponent");
|
|
29
|
+
|
|
30
|
+
/** A component marked as rendering its own output frame. */
|
|
31
|
+
export type FramedBlockComponent = Component & { [FRAMED_BLOCK_COMPONENT]?: true };
|
|
32
|
+
|
|
33
|
+
/** Mark a component as owning its output frame. */
|
|
34
|
+
export function markFramedBlockComponent<T extends Component>(component: T): T & FramedBlockComponent {
|
|
35
|
+
(component as T & FramedBlockComponent)[FRAMED_BLOCK_COMPONENT] = true;
|
|
36
|
+
return component as T & FramedBlockComponent;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Return whether a component owns its output frame. */
|
|
40
|
+
export function isFramedBlockComponent(component: Component): boolean {
|
|
41
|
+
return (component as FramedBlockComponent)[FRAMED_BLOCK_COMPONENT] === true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
type BlockRow =
|
|
45
|
+
| { kind: "bar"; leftChar: string; rightChar: string; label?: string; meta?: string }
|
|
46
|
+
| { kind: "bottom"; leftChar: string; rightChar: string }
|
|
47
|
+
| { kind: "content"; inner: string }
|
|
48
|
+
| { kind: "sixel"; raw: string };
|
|
49
|
+
|
|
50
|
+
function normalizeContentPaddingLeft(value: number | undefined): number {
|
|
51
|
+
if (value === undefined || !Number.isFinite(value)) return 1;
|
|
52
|
+
return Math.max(0, Math.floor(value));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Inner content width that {@link renderOutputBlock} wraps its body to, for a
|
|
57
|
+
* given outer `width`: both vertical borders plus symmetric content padding.
|
|
58
|
+
* An explicit left padding of zero keeps legacy flush blocks flush on both
|
|
59
|
+
* sides unless a right padding is provided separately.
|
|
60
|
+
*/
|
|
61
|
+
export function outputBlockContentWidth(
|
|
62
|
+
width: number,
|
|
63
|
+
contentPaddingLeft?: number,
|
|
64
|
+
contentPaddingRight?: number,
|
|
65
|
+
): number {
|
|
66
|
+
const left = normalizeContentPaddingLeft(contentPaddingLeft);
|
|
67
|
+
const right = normalizeContentPaddingLeft(contentPaddingRight ?? left);
|
|
68
|
+
return Math.max(1, width - 2 - left - right);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Render a bordered output block with optional header and sections. */
|
|
72
|
+
export function renderOutputBlock(options: OutputBlockOptions, theme: Theme): string[] {
|
|
73
|
+
const { header, headerMeta, state, sections = [], width, applyBg = true } = options;
|
|
74
|
+
const h = theme.boxRound.horizontal;
|
|
75
|
+
const v = theme.boxRound.vertical;
|
|
76
|
+
const cap = h.repeat(3);
|
|
77
|
+
const lineWidth = Math.max(0, width);
|
|
78
|
+
// Border colors: running/pending use accent, success uses dim (gray), error/warning keep their colors
|
|
79
|
+
const borderColor: ThemeColor =
|
|
80
|
+
options.borderColor ??
|
|
81
|
+
(state === "error"
|
|
82
|
+
? "error"
|
|
83
|
+
: state === "warning"
|
|
84
|
+
? "warning"
|
|
85
|
+
: state === "running" || state === "pending"
|
|
86
|
+
? "accent"
|
|
87
|
+
: "dim");
|
|
88
|
+
const border = (text: string) => theme.fg(borderColor, text);
|
|
89
|
+
const bgFn = (() => {
|
|
90
|
+
if (!state || !applyBg) return undefined;
|
|
91
|
+
const bgAnsi = theme.getBgAnsi(getStateBgColor(state));
|
|
92
|
+
// Keep block background stable even if inner content contains SGR resets (e.g. "\x1b[0m"),
|
|
93
|
+
// which would otherwise clear the outer background mid-line.
|
|
94
|
+
return (text: string) => {
|
|
95
|
+
const stabilized = text
|
|
96
|
+
.replace(/\x1b\[(?:0)?m/g, m => `${m}${bgAnsi}`)
|
|
97
|
+
.replace(/\x1b\[49m/g, m => `${m}${bgAnsi}`);
|
|
98
|
+
return `${bgAnsi}${stabilized}\x1b[49m`;
|
|
99
|
+
};
|
|
100
|
+
})();
|
|
101
|
+
|
|
102
|
+
const contentPaddingLeft = normalizeContentPaddingLeft(options.contentPaddingLeft);
|
|
103
|
+
const contentPaddingRight = normalizeContentPaddingLeft(options.contentPaddingRight ?? contentPaddingLeft);
|
|
104
|
+
const contentWidth = Math.max(
|
|
105
|
+
0,
|
|
106
|
+
lineWidth - visibleWidth(v) - contentPaddingLeft - contentPaddingRight - visibleWidth(v),
|
|
107
|
+
);
|
|
108
|
+
const contentLeftPadding = contentPaddingLeft > 0 ? padding(contentPaddingLeft) : "";
|
|
109
|
+
const contentRightPadding = contentPaddingRight > 0 ? padding(contentPaddingRight) : "";
|
|
110
|
+
|
|
111
|
+
// ── Layout pass: collect row descriptors before emitting the bordered lines. ──
|
|
112
|
+
const rows: BlockRow[] = [];
|
|
113
|
+
rows.push({
|
|
114
|
+
kind: "bar",
|
|
115
|
+
leftChar: theme.boxRound.topLeft,
|
|
116
|
+
rightChar: theme.boxRound.topRight,
|
|
117
|
+
label: header,
|
|
118
|
+
meta: headerMeta,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const normalizedSections = sections.length > 0 ? sections : [{ lines: [] as string[] }];
|
|
122
|
+
for (let sectionIndex = 0; sectionIndex < normalizedSections.length; sectionIndex++) {
|
|
123
|
+
const section = normalizedSections[sectionIndex]!;
|
|
124
|
+
// A labeled section always draws its titled separator bar. A label-less
|
|
125
|
+
// section can still request a plain divider via `separator`, but only
|
|
126
|
+
// between sections — leading with one would just double the header bar.
|
|
127
|
+
if (section.label) {
|
|
128
|
+
rows.push({
|
|
129
|
+
kind: "bar",
|
|
130
|
+
leftChar: theme.boxRound.teeRight,
|
|
131
|
+
rightChar: theme.boxRound.teeLeft,
|
|
132
|
+
label: section.label,
|
|
133
|
+
});
|
|
134
|
+
} else if (section.separator && sectionIndex > 0) {
|
|
135
|
+
rows.push({
|
|
136
|
+
kind: "bar",
|
|
137
|
+
leftChar: theme.boxRound.teeRight,
|
|
138
|
+
rightChar: theme.boxRound.teeLeft,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
const allLines = section.lines.flatMap(l => l.split("\n"));
|
|
142
|
+
const sixelLineMask = TERMINAL.imageProtocol === ImageProtocol.Sixel ? getSixelLineMask(allLines) : undefined;
|
|
143
|
+
for (let lineIndex = 0; lineIndex < allLines.length; lineIndex++) {
|
|
144
|
+
const line = allLines[lineIndex]!;
|
|
145
|
+
if (sixelLineMask?.[lineIndex]) {
|
|
146
|
+
rows.push({ kind: "sixel", raw: line });
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const wrappedLines = wrapTextWithAnsi(line.trimEnd(), contentWidth);
|
|
150
|
+
for (const wrappedLine of wrappedLines) {
|
|
151
|
+
const innerPadding = padding(Math.max(0, contentWidth - visibleWidth(wrappedLine)));
|
|
152
|
+
rows.push({ kind: "content", inner: `${wrappedLine}${innerPadding}` });
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
rows.push({ kind: "bottom", leftChar: theme.boxRound.bottomLeft, rightChar: theme.boxRound.bottomRight });
|
|
158
|
+
|
|
159
|
+
const H = rows.length;
|
|
160
|
+
|
|
161
|
+
const renderBar = (row: { leftChar: string; rightChar: string; label?: string; meta?: string }): string => {
|
|
162
|
+
const leftGlyphs = `${row.leftChar}${cap}`;
|
|
163
|
+
const rightGlyph = row.rightChar;
|
|
164
|
+
if (lineWidth <= 0) return border(leftGlyphs) + border(rightGlyph);
|
|
165
|
+
const labelText = [row.label, row.meta].filter(Boolean).join(theme.sep.dot);
|
|
166
|
+
if (!labelText) {
|
|
167
|
+
// No header: draw a clean, continuous top/separator bar (no 1-col gap).
|
|
168
|
+
const fillCount = Math.max(0, lineWidth - visibleWidth(leftGlyphs) - visibleWidth(rightGlyph));
|
|
169
|
+
return `${border(leftGlyphs)}${border(h.repeat(fillCount))}${border(rightGlyph)}`;
|
|
170
|
+
}
|
|
171
|
+
const rawLabel = ` ${labelText} `;
|
|
172
|
+
const leftWidth = visibleWidth(leftGlyphs);
|
|
173
|
+
const rightWidth = visibleWidth(rightGlyph);
|
|
174
|
+
const maxLabelWidth = Math.max(0, lineWidth - leftWidth - rightWidth);
|
|
175
|
+
const trimmedLabel = truncateToWidth(rawLabel, maxLabelWidth);
|
|
176
|
+
const labelWidth = visibleWidth(trimmedLabel);
|
|
177
|
+
const fillCount = Math.max(0, lineWidth - leftWidth - labelWidth - rightWidth);
|
|
178
|
+
const fillGlyphs = h.repeat(fillCount);
|
|
179
|
+
return `${border(leftGlyphs)}${trimmedLabel}${border(fillGlyphs)}${border(rightGlyph)}`;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const renderBottom = (row: { leftChar: string; rightChar: string }): string => {
|
|
183
|
+
const leftGlyphs = `${row.leftChar}${cap}`;
|
|
184
|
+
const rightGlyph = row.rightChar;
|
|
185
|
+
const fillCount = Math.max(0, lineWidth - visibleWidth(leftGlyphs) - visibleWidth(rightGlyph));
|
|
186
|
+
const fillGlyphs = h.repeat(fillCount);
|
|
187
|
+
return `${border(leftGlyphs)}${border(fillGlyphs)}${border(rightGlyph)}`;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const renderContent = (inner: string): string =>
|
|
191
|
+
`${border(v)}${contentLeftPadding}${inner}${contentRightPadding}${border(v)}`;
|
|
192
|
+
|
|
193
|
+
const clipFrame = lineWidth < Math.max(visibleWidth(cap) + 2, contentPaddingLeft + contentPaddingRight + 2);
|
|
194
|
+
const lines: string[] = [];
|
|
195
|
+
for (let r = 0; r < H; r++) {
|
|
196
|
+
const row = rows[r]!;
|
|
197
|
+
if (row.kind === "sixel") {
|
|
198
|
+
lines.push(row.raw);
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
const line =
|
|
202
|
+
row.kind === "bar" ? renderBar(row) : row.kind === "bottom" ? renderBottom(row) : renderContent(row.inner);
|
|
203
|
+
lines.push(padToWidth(clipFrame ? truncateToWidth(line, lineWidth, Ellipsis.Omit) : line, lineWidth, bgFn));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return lines;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Cached wrapper around `renderOutputBlock`.
|
|
211
|
+
*
|
|
212
|
+
* Since output blocks are re-rendered on every frame (via `render(width)` closures),
|
|
213
|
+
* but their content rarely changes, this cache avoids redundant `visibleWidth()` and
|
|
214
|
+
* `padding()` computations on ~99% of render calls.
|
|
215
|
+
*/
|
|
216
|
+
export class CachedOutputBlock {
|
|
217
|
+
#cache?: RenderCache;
|
|
218
|
+
#lastOptions?: OutputBlockOptions;
|
|
219
|
+
|
|
220
|
+
/** Render with caching. Returns the cached (shared, caller-immutable) lines if options haven't changed. */
|
|
221
|
+
render(options: OutputBlockOptions, theme: Theme): readonly string[] {
|
|
222
|
+
// Reference fast path: rebuild paths often hand back the same options
|
|
223
|
+
// object when nothing changed; skip the full content hash entirely.
|
|
224
|
+
if (this.#lastOptions === options && this.#cache) return this.#cache.lines;
|
|
225
|
+
const key = this.#buildKey(options);
|
|
226
|
+
if (this.#cache?.key === key) {
|
|
227
|
+
this.#lastOptions = options;
|
|
228
|
+
return this.#cache.lines;
|
|
229
|
+
}
|
|
230
|
+
const lines = renderOutputBlock(options, theme);
|
|
231
|
+
this.#cache = { key, lines };
|
|
232
|
+
this.#lastOptions = options;
|
|
233
|
+
return lines;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** Invalidate the cache, forcing a rebuild on next render. */
|
|
237
|
+
invalidate(): void {
|
|
238
|
+
this.#cache = undefined;
|
|
239
|
+
this.#lastOptions = undefined;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
#buildKey(options: OutputBlockOptions): bigint {
|
|
243
|
+
const h = new Hasher();
|
|
244
|
+
h.u32(options.width);
|
|
245
|
+
h.u32(normalizeContentPaddingLeft(options.contentPaddingLeft));
|
|
246
|
+
h.u32(
|
|
247
|
+
normalizeContentPaddingLeft(
|
|
248
|
+
options.contentPaddingRight ?? normalizeContentPaddingLeft(options.contentPaddingLeft),
|
|
249
|
+
),
|
|
250
|
+
);
|
|
251
|
+
h.optional(options.header);
|
|
252
|
+
h.optional(options.headerMeta);
|
|
253
|
+
h.optional(options.state);
|
|
254
|
+
h.optional(options.borderColor);
|
|
255
|
+
h.bool(options.applyBg ?? true);
|
|
256
|
+
if (options.sections) {
|
|
257
|
+
for (const s of options.sections) {
|
|
258
|
+
h.optional(s.label);
|
|
259
|
+
h.bool(s.separator ?? false);
|
|
260
|
+
for (const line of s.lines) {
|
|
261
|
+
h.str(line);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return h.digest();
|
|
266
|
+
}
|
|
267
|
+
}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { Text } from "../components/text";
|
|
2
|
+
import { ImageProtocol, TERMINAL } from "../terminal-capabilities";
|
|
3
|
+
import type { Theme } from "../theme/theme";
|
|
4
|
+
import type { Component } from "../tui";
|
|
5
|
+
import { getPaddingX } from "../utils";
|
|
6
|
+
import { truncateToVisualLines } from "../chrome/visual-truncate";
|
|
7
|
+
import { getSixelLineMask } from "./sixel";
|
|
8
|
+
import { formatExpandHint, replaceTabs } from "./render-utils";
|
|
9
|
+
|
|
10
|
+
/** Which side of an output stream remains visible when the pane is capped. */
|
|
11
|
+
export type OutputPaneEdge = "head" | "tail";
|
|
12
|
+
|
|
13
|
+
/** Inputs for the shared output capping and styling algorithm. */
|
|
14
|
+
export interface OutputPaneFormatOptions {
|
|
15
|
+
lines: readonly string[];
|
|
16
|
+
expanded: boolean;
|
|
17
|
+
collapsedMaxLines: number;
|
|
18
|
+
expandedMaxLines?: number;
|
|
19
|
+
edge?: OutputPaneEdge;
|
|
20
|
+
/** Apply the cap after terminal-width wrapping instead of to logical rows. */
|
|
21
|
+
visual?: boolean;
|
|
22
|
+
/** Content width used by visual capping. Required when `visual` is true. */
|
|
23
|
+
width?: number;
|
|
24
|
+
styleLine?: (line: string, index: number) => string;
|
|
25
|
+
/** Keep sixel payload rows byte-for-byte and show the complete payload. */
|
|
26
|
+
uncapSixel?: boolean;
|
|
27
|
+
showHiddenMarker?: boolean;
|
|
28
|
+
showExpandHint?: boolean;
|
|
29
|
+
showExpandHintWhenUncapped?: boolean;
|
|
30
|
+
formatHidden?: (hidden: number, shown: number, total: number, edge: OutputPaneEdge) => string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Result of formatting one bounded output pane. */
|
|
34
|
+
export interface OutputPaneFormatResult {
|
|
35
|
+
lines: readonly string[];
|
|
36
|
+
hiddenCount: number;
|
|
37
|
+
hasSixel: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Split terminal text without allowing carriage-return progress updates to
|
|
42
|
+
* corrupt following TUI rows. The final segment after a bare CR wins, matching
|
|
43
|
+
* a terminal cursor-return overwrite.
|
|
44
|
+
*/
|
|
45
|
+
export function splitTerminalOutputLines(text: string): string[] {
|
|
46
|
+
return text.split(/\r?\n/u).map(line => {
|
|
47
|
+
const carriageReturn = line.lastIndexOf("\r");
|
|
48
|
+
return carriageReturn < 0 ? line : line.slice(carriageReturn + 1);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function defaultHiddenLabel(hidden: number, shown: number, total: number, edge: OutputPaneEdge): string {
|
|
53
|
+
return edge === "tail"
|
|
54
|
+
? `… (${hidden} earlier lines, showing ${shown} of ${total})`
|
|
55
|
+
: `… ${hidden} more line${hidden === 1 ? "" : "s"}`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Style and cap output rows for code cells, tool cards, and live execution
|
|
60
|
+
* panes. Sixel rows are never styled or split; with `uncapSixel`, the complete
|
|
61
|
+
* payload is retained so terminal image protocols remain valid.
|
|
62
|
+
*/
|
|
63
|
+
export function formatOutputPaneLines(options: OutputPaneFormatOptions, theme: Theme): OutputPaneFormatResult {
|
|
64
|
+
const edge = options.edge ?? "head";
|
|
65
|
+
const rawLines = options.lines;
|
|
66
|
+
const sixelMask =
|
|
67
|
+
TERMINAL.imageProtocol === ImageProtocol.Sixel && rawLines.length > 0 ? getSixelLineMask(rawLines) : undefined;
|
|
68
|
+
const hasSixel = sixelMask?.some(Boolean) ?? false;
|
|
69
|
+
const styledLines = rawLines.map((line, index) =>
|
|
70
|
+
sixelMask?.[index] ? line : (options.styleLine?.(line, index) ?? line),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const configuredLimit = options.expanded ? options.expandedMaxLines : options.collapsedMaxLines;
|
|
74
|
+
const limit = hasSixel && options.uncapSixel ? undefined : configuredLimit;
|
|
75
|
+
let visibleLines: readonly string[] = styledLines;
|
|
76
|
+
let hiddenCount = 0;
|
|
77
|
+
|
|
78
|
+
if (limit !== undefined && Number.isFinite(limit)) {
|
|
79
|
+
const boundedLimit = Math.max(0, Math.floor(limit));
|
|
80
|
+
if (boundedLimit === 0) {
|
|
81
|
+
visibleLines = [];
|
|
82
|
+
hiddenCount = styledLines.length;
|
|
83
|
+
} else if (options.visual && edge === "tail") {
|
|
84
|
+
const visual = truncateToVisualLines(styledLines.join("\n"), boundedLimit, Math.max(1, options.width ?? 1));
|
|
85
|
+
visibleLines = visual.visualLines;
|
|
86
|
+
hiddenCount = visual.skippedCount;
|
|
87
|
+
} else if (options.visual) {
|
|
88
|
+
const rendered = new Text(styledLines.join("\n"), 0, 0).render(Math.max(1, options.width ?? 1));
|
|
89
|
+
visibleLines = rendered.slice(0, boundedLimit);
|
|
90
|
+
hiddenCount = Math.max(0, rendered.length - visibleLines.length);
|
|
91
|
+
} else if (styledLines.length > boundedLimit) {
|
|
92
|
+
hiddenCount = styledLines.length - boundedLimit;
|
|
93
|
+
visibleLines = edge === "tail" ? styledLines.slice(-boundedLimit) : styledLines.slice(0, boundedLimit);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const lines = [...visibleLines];
|
|
98
|
+
if (hiddenCount > 0 && options.showHiddenMarker !== false) {
|
|
99
|
+
const label = (options.formatHidden ?? defaultHiddenLabel)(
|
|
100
|
+
hiddenCount,
|
|
101
|
+
visibleLines.length,
|
|
102
|
+
hiddenCount + visibleLines.length,
|
|
103
|
+
edge,
|
|
104
|
+
);
|
|
105
|
+
const hint = options.showExpandHint === false ? "" : formatExpandHint(theme, options.expanded, true);
|
|
106
|
+
const marker = theme.fg("dim", `${label}${hint ? ` ${hint}` : ""}`);
|
|
107
|
+
if (edge === "tail") lines.unshift(marker);
|
|
108
|
+
else lines.push(marker);
|
|
109
|
+
} else if (!options.expanded && options.showExpandHintWhenUncapped) {
|
|
110
|
+
const hint = formatExpandHint(theme, false, true);
|
|
111
|
+
if (hint) lines.push(hint);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return { lines, hiddenCount, hasSixel };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Mutable options for a live {@link OutputPane}. */
|
|
118
|
+
export interface OutputPaneOptions extends Omit<OutputPaneFormatOptions, "lines"> {
|
|
119
|
+
paddingX?: number;
|
|
120
|
+
leadingBlank?: boolean;
|
|
121
|
+
maxStoredLines?: number;
|
|
122
|
+
/** Normalize each logical row before it enters the retained stream. */
|
|
123
|
+
normalizeLine?: (line: string) => string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Stateful, cached output viewport. Streaming callers append chunks while
|
|
128
|
+
* settled callers may replace all rows. Unchanged renders preserve array
|
|
129
|
+
* identity through the inner Text cache.
|
|
130
|
+
*/
|
|
131
|
+
export class OutputPane implements Component {
|
|
132
|
+
readonly #theme: Theme;
|
|
133
|
+
#options: OutputPaneOptions;
|
|
134
|
+
#lines: string[] = [];
|
|
135
|
+
#pendingCarriageReturn = false;
|
|
136
|
+
#text: Text;
|
|
137
|
+
#renderKey = "";
|
|
138
|
+
|
|
139
|
+
constructor(theme: Theme, options: OutputPaneOptions, text = "") {
|
|
140
|
+
this.#theme = theme;
|
|
141
|
+
this.#options = { ...options };
|
|
142
|
+
this.#text = new Text("", options.paddingX ?? 0, 0);
|
|
143
|
+
if (text) this.setText(text);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Replace the complete output snapshot. */
|
|
147
|
+
setText(text: string): void {
|
|
148
|
+
this.setLines(text ? splitTerminalOutputLines(text) : []);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Replace the complete output snapshot with caller-owned immutable rows. */
|
|
152
|
+
setLines(lines: readonly string[]): void {
|
|
153
|
+
const normalizeLine = this.#options.normalizeLine;
|
|
154
|
+
const normalized = normalizeLine ? lines.map(line => normalizeLine(line)) : [...lines];
|
|
155
|
+
this.#lines = this.#clampStoredLines(normalized);
|
|
156
|
+
this.#pendingCarriageReturn = false;
|
|
157
|
+
this.invalidate();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Append a streaming chunk. Bare CR overwrites the current logical row;
|
|
162
|
+
* a CRLF split across chunks remains a newline, so chunked and whole-text
|
|
163
|
+
* ingestion produce the same settled rows.
|
|
164
|
+
*/
|
|
165
|
+
append(chunk: string): void {
|
|
166
|
+
if (!chunk) return;
|
|
167
|
+
let index = 0;
|
|
168
|
+
if (this.#pendingCarriageReturn) {
|
|
169
|
+
this.#pendingCarriageReturn = false;
|
|
170
|
+
if (chunk[0] === "\n") {
|
|
171
|
+
this.#startLine();
|
|
172
|
+
index = 1;
|
|
173
|
+
} else {
|
|
174
|
+
this.#replaceTail("");
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
let segmentStart = index;
|
|
179
|
+
while (index < chunk.length) {
|
|
180
|
+
const char = chunk[index];
|
|
181
|
+
if (char !== "\r" && char !== "\n") {
|
|
182
|
+
index++;
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
this.#appendToTail(chunk.slice(segmentStart, index));
|
|
186
|
+
if (char === "\n") {
|
|
187
|
+
this.#startLine();
|
|
188
|
+
} else if (index + 1 < chunk.length) {
|
|
189
|
+
if (chunk[index + 1] === "\n") {
|
|
190
|
+
this.#startLine();
|
|
191
|
+
index++;
|
|
192
|
+
} else {
|
|
193
|
+
this.#replaceTail("");
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
this.#pendingCarriageReturn = true;
|
|
197
|
+
}
|
|
198
|
+
index++;
|
|
199
|
+
segmentStart = index;
|
|
200
|
+
}
|
|
201
|
+
this.#appendToTail(chunk.slice(segmentStart));
|
|
202
|
+
this.#lines = this.#clampStoredLines(this.#lines);
|
|
203
|
+
this.invalidate();
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** Settle a trailing bare carriage return once no later LF can pair with it. */
|
|
207
|
+
finish(): void {
|
|
208
|
+
if (!this.#pendingCarriageReturn) return;
|
|
209
|
+
this.#pendingCarriageReturn = false;
|
|
210
|
+
this.#replaceTail("");
|
|
211
|
+
this.invalidate();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** Update presentation without replacing streamed content. */
|
|
215
|
+
configure(options: Partial<OutputPaneOptions>): void {
|
|
216
|
+
const previousPadding = this.#options.paddingX ?? 0;
|
|
217
|
+
this.#options = { ...this.#options, ...options };
|
|
218
|
+
const nextPadding = this.#options.paddingX ?? 0;
|
|
219
|
+
if (previousPadding !== nextPadding) this.#text = new Text("", nextPadding, 0);
|
|
220
|
+
this.#lines = this.#clampStoredLines(this.#lines);
|
|
221
|
+
this.invalidate();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
setExpanded(expanded: boolean): void {
|
|
225
|
+
if (this.#options.expanded === expanded) return;
|
|
226
|
+
this.#options = { ...this.#options, expanded };
|
|
227
|
+
this.invalidate();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
get lineCount(): number {
|
|
231
|
+
return this.#lines.length;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
get hasSixel(): boolean {
|
|
235
|
+
if (TERMINAL.imageProtocol !== ImageProtocol.Sixel || this.#lines.length === 0) return false;
|
|
236
|
+
return getSixelLineMask(this.#lines).some(Boolean);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
getText(): string {
|
|
240
|
+
return this.#lines.join("\n");
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
render(width: number): readonly string[] {
|
|
244
|
+
const paddingX = getPaddingX(this.#options.paddingX ?? 0);
|
|
245
|
+
const contentWidth = Math.max(1, width - paddingX * 2);
|
|
246
|
+
const formatted = formatOutputPaneLines(
|
|
247
|
+
{
|
|
248
|
+
...this.#options,
|
|
249
|
+
lines: this.#lines,
|
|
250
|
+
width: contentWidth,
|
|
251
|
+
},
|
|
252
|
+
this.#theme,
|
|
253
|
+
);
|
|
254
|
+
const content = `${this.#options.leadingBlank && formatted.lines.length > 0 ? "\n" : ""}${formatted.lines.join("\n")}`;
|
|
255
|
+
const key = `${width}:${content.length}:${Bun.hash(content).toString(36)}`;
|
|
256
|
+
if (key !== this.#renderKey) {
|
|
257
|
+
this.#renderKey = key;
|
|
258
|
+
this.#text.setText(content);
|
|
259
|
+
}
|
|
260
|
+
return this.#text.render(width);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
invalidate(): void {
|
|
264
|
+
this.#renderKey = "";
|
|
265
|
+
this.#text.invalidate();
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
#appendToTail(text: string): void {
|
|
269
|
+
if (!text) return;
|
|
270
|
+
if (this.#lines.length === 0) this.#lines.push("");
|
|
271
|
+
const last = this.#lines.length - 1;
|
|
272
|
+
this.#replaceTail(`${this.#lines[last]}${text}`);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
#replaceTail(text: string): void {
|
|
276
|
+
const normalizeLine = this.#options.normalizeLine;
|
|
277
|
+
const normalized = normalizeLine ? normalizeLine(text) : text;
|
|
278
|
+
if (this.#lines.length === 0) this.#lines.push(normalized);
|
|
279
|
+
else this.#lines[this.#lines.length - 1] = normalized;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
#startLine(): void {
|
|
283
|
+
if (this.#lines.length === 0) this.#lines.push("");
|
|
284
|
+
this.#lines.push("");
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
#clampStoredLines(lines: string[]): string[] {
|
|
288
|
+
const maxStoredLines = this.#options.maxStoredLines;
|
|
289
|
+
if (maxStoredLines === undefined || lines.length <= maxStoredLines) return lines;
|
|
290
|
+
const boundedMax = Math.max(0, Math.floor(maxStoredLines));
|
|
291
|
+
return boundedMax === 0 ? [] : lines.slice(-boundedMax);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** Default styling for plain tool output while preserving existing ANSI. */
|
|
296
|
+
export function styleToolOutputLine(line: string, theme: Theme): string {
|
|
297
|
+
const normalized = replaceTabs(line);
|
|
298
|
+
return normalized.includes("\x1b[") ? normalized : theme.fg("toolOutput", normalized);
|
|
299
|
+
}
|