@oh-my-pi/pi-tui 18.2.4 → 18.2.6
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 +23 -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/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/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 +57 -4
- package/src/utils.ts +8 -0
|
@@ -0,0 +1,1204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Right sidebar of the git TUI.
|
|
3
|
+
*
|
|
4
|
+
* Dirty tree → file management: unstaged/staged sections with stage/unstage
|
|
5
|
+
* actions plus a commit form (amend toggle, summary input, description
|
|
6
|
+
* editor, commit button). Clean tree → HEAD commit view: subject, body,
|
|
7
|
+
* author with avatar photo, parents, and the commit's file list.
|
|
8
|
+
*
|
|
9
|
+
* The sidebar is not a TUI component itself: the root composes its rendered
|
|
10
|
+
* lines and forwards key/mouse input. Every rendered frame records a hit
|
|
11
|
+
* target per row so mouse clicks resolve against what is actually visible.
|
|
12
|
+
*/
|
|
13
|
+
import { Editor } from "../../components/editor";
|
|
14
|
+
import { FormField, type FormFieldTheme, TextFormField } from "../../components/form";
|
|
15
|
+
import { Image, type ImageBudget } from "../../components/image";
|
|
16
|
+
import { MenuSelection } from "../../components/menu-selection";
|
|
17
|
+
import { ScrollView } from "../../components/scroll-view";
|
|
18
|
+
import { TreeView } from "../../components/tree-view";
|
|
19
|
+
import { matchesKey } from "../../keys";
|
|
20
|
+
import { TERMINAL } from "../../terminal-capabilities";
|
|
21
|
+
import { truncateToWidth, visibleWidth } from "../../utils";
|
|
22
|
+
import { getEditorTheme, theme } from "../../theme/theme";
|
|
23
|
+
import { type AvatarSource, identiconLines } from "./avatar";
|
|
24
|
+
import { pill, selectionBgAnsi, softPill, tintChip, withBg } from "./colors";
|
|
25
|
+
import type { ChangedFile, GitViewState } from "./state";
|
|
26
|
+
|
|
27
|
+
/** Generated conventional commit fields shown in the commit form. */
|
|
28
|
+
export interface GitCommitMessage {
|
|
29
|
+
type: string;
|
|
30
|
+
scope?: string | null;
|
|
31
|
+
summary: string;
|
|
32
|
+
body: readonly string[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Actions the sidebar raises to the root component. */
|
|
36
|
+
export type SidebarAction =
|
|
37
|
+
/** `selection` omitted → whole tree; `label` names the target for the status line. */
|
|
38
|
+
| { type: "stage"; selection?: { files: ChangedFile[]; label: string } }
|
|
39
|
+
| { type: "unstage"; selection?: { files: ChangedFile[]; label: string } }
|
|
40
|
+
/** `delete`: throw away the row's changes (a dir batches every file underneath). */
|
|
41
|
+
| { type: "discard"; selection: { files: ChangedFile[]; label: string } }
|
|
42
|
+
| { type: "generate" }
|
|
43
|
+
/** Wand pill: AI-filter the unstaged tree against a natural-language prompt. */
|
|
44
|
+
| { type: "stage-ai"; prompt: string }
|
|
45
|
+
| { type: "commit"; message: string; amend: boolean; stageAll: boolean };
|
|
46
|
+
|
|
47
|
+
type FileTarget = { kind: "file"; file: ChangedFile } | { kind: "dir"; key: string };
|
|
48
|
+
/** A foldable file-list section header (unstaged/staged). */
|
|
49
|
+
type SectionTarget = { kind: "section"; area: "unstaged" | "staged" };
|
|
50
|
+
|
|
51
|
+
type Target =
|
|
52
|
+
| FileTarget
|
|
53
|
+
| { kind: "view-style"; style: "path" | "tree" }
|
|
54
|
+
| SectionTarget
|
|
55
|
+
| { kind: "stage-all" }
|
|
56
|
+
| { kind: "unstage-all" }
|
|
57
|
+
| { kind: "stage-ai" }
|
|
58
|
+
| { kind: "stage-ai-input" }
|
|
59
|
+
| { kind: "amend" }
|
|
60
|
+
| { kind: "summary" }
|
|
61
|
+
| { kind: "description" }
|
|
62
|
+
| { kind: "commit-button" };
|
|
63
|
+
|
|
64
|
+
interface Row {
|
|
65
|
+
text?: string;
|
|
66
|
+
/** File/dir rows are formatted only when they enter the viewport. */
|
|
67
|
+
entry?: SidebarFileEntry;
|
|
68
|
+
target?: Target;
|
|
69
|
+
/** Column-scoped hit targets for rows carrying several buttons. */
|
|
70
|
+
hits?: { from: number; to: number; target: Target }[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const KIND_LETTER: Record<ChangedFile["kind"], string> = {
|
|
74
|
+
modified: "M",
|
|
75
|
+
added: "A",
|
|
76
|
+
deleted: "D",
|
|
77
|
+
renamed: "R",
|
|
78
|
+
untracked: "?",
|
|
79
|
+
conflicted: "U",
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const KIND_COLOR: Record<ChangedFile["kind"], "warning" | "success" | "error" | "accent" | "muted"> = {
|
|
83
|
+
modified: "warning",
|
|
84
|
+
added: "success",
|
|
85
|
+
deleted: "error",
|
|
86
|
+
renamed: "accent",
|
|
87
|
+
untracked: "muted",
|
|
88
|
+
conflicted: "error",
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const SUMMARY_LIMIT = 72;
|
|
92
|
+
|
|
93
|
+
const SIDEBAR_FORM_THEME: FormFieldTheme = {
|
|
94
|
+
label: text => theme.fg("muted", text),
|
|
95
|
+
description: text => theme.fg("dim", text),
|
|
96
|
+
error: text => theme.fg("error", text),
|
|
97
|
+
hint: text => theme.fg("dim", text),
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
function targetKey(target: Target): string {
|
|
101
|
+
if (target.kind === "file") return `file:${target.file.area}:${target.file.path}`;
|
|
102
|
+
if (target.kind === "dir") return `dir:${target.key}`;
|
|
103
|
+
if (target.kind === "section") return `section:${target.area}`;
|
|
104
|
+
if (target.kind === "view-style") return `view:${target.style}`;
|
|
105
|
+
return target.kind;
|
|
106
|
+
}
|
|
107
|
+
/** One rendered entry of a file section: nested dirs (tree mode) or flat files. */
|
|
108
|
+
interface SidebarFileEntry {
|
|
109
|
+
target: FileTarget;
|
|
110
|
+
/** Tree indentation depth; omitted in flat path mode. */
|
|
111
|
+
depth?: number;
|
|
112
|
+
file?: ChangedFile;
|
|
113
|
+
/** Dir entries: display name (compressed chain) + collapse state. */
|
|
114
|
+
dirName?: string;
|
|
115
|
+
collapsed?: boolean;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
interface TreeDir {
|
|
119
|
+
name: string;
|
|
120
|
+
dirs: Map<string, TreeDir>;
|
|
121
|
+
files: ChangedFile[];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
type GitTreeNode =
|
|
125
|
+
| { kind: "dir"; key: string; name: string; children: GitTreeNode[] }
|
|
126
|
+
| { kind: "file"; key: string; file: ChangedFile };
|
|
127
|
+
|
|
128
|
+
class GitFileTree {
|
|
129
|
+
readonly #roots: GitTreeNode[] = [];
|
|
130
|
+
readonly #tree: TreeView<GitTreeNode, string>;
|
|
131
|
+
readonly #section: string;
|
|
132
|
+
readonly #collapsed: ReadonlySet<string>;
|
|
133
|
+
#files: readonly ChangedFile[] | undefined;
|
|
134
|
+
#version = -1;
|
|
135
|
+
#entries: SidebarFileEntry[] = [];
|
|
136
|
+
|
|
137
|
+
constructor(section: string, collapsed: ReadonlySet<string>) {
|
|
138
|
+
this.#section = section;
|
|
139
|
+
this.#collapsed = collapsed;
|
|
140
|
+
this.#tree = new TreeView({
|
|
141
|
+
roots: this.#roots,
|
|
142
|
+
getKey: node => node.key,
|
|
143
|
+
getChildren: node => (node.kind === "dir" ? node.children : []),
|
|
144
|
+
isExpanded: node => node.kind !== "dir" || !this.#collapsed.has(node.key),
|
|
145
|
+
theme,
|
|
146
|
+
renderRow: node => (node.kind === "dir" ? `${node.name}/` : node.file.path),
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
entries(files: readonly ChangedFile[], version: number): SidebarFileEntry[] {
|
|
151
|
+
if (files !== this.#files) {
|
|
152
|
+
this.#files = files;
|
|
153
|
+
this.#roots.splice(0, this.#roots.length, ...this.#buildNodes(files));
|
|
154
|
+
this.#tree.invalidate();
|
|
155
|
+
this.#version = version;
|
|
156
|
+
} else if (version !== this.#version) {
|
|
157
|
+
this.#tree.invalidate();
|
|
158
|
+
this.#version = version;
|
|
159
|
+
} else {
|
|
160
|
+
return this.#entries;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
this.#entries = this.#tree.rows.map(row =>
|
|
164
|
+
row.item.kind === "dir"
|
|
165
|
+
? {
|
|
166
|
+
target: { kind: "dir", key: row.item.key },
|
|
167
|
+
depth: row.depth,
|
|
168
|
+
dirName: row.item.name,
|
|
169
|
+
collapsed: this.#collapsed.has(row.item.key),
|
|
170
|
+
}
|
|
171
|
+
: { target: { kind: "file", file: row.item.file }, depth: row.depth, file: row.item.file },
|
|
172
|
+
);
|
|
173
|
+
return this.#entries;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
dispose(): void {
|
|
177
|
+
this.#tree.dispose();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
#buildNodes(files: readonly ChangedFile[]): GitTreeNode[] {
|
|
181
|
+
const root: TreeDir = { name: "", dirs: new Map(), files: [] };
|
|
182
|
+
for (const file of files) {
|
|
183
|
+
const parts = file.path.split("/");
|
|
184
|
+
let node = root;
|
|
185
|
+
for (const part of parts.slice(0, -1)) {
|
|
186
|
+
let next = node.dirs.get(part);
|
|
187
|
+
if (!next) {
|
|
188
|
+
next = { name: part, dirs: new Map(), files: [] };
|
|
189
|
+
node.dirs.set(part, next);
|
|
190
|
+
}
|
|
191
|
+
node = next;
|
|
192
|
+
}
|
|
193
|
+
node.files.push(file);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const compress = (node: TreeDir): void => {
|
|
197
|
+
for (const [key, child] of Array.from(node.dirs)) {
|
|
198
|
+
let merged = child;
|
|
199
|
+
while (merged.files.length === 0 && merged.dirs.size === 1) {
|
|
200
|
+
const [only] = merged.dirs.values();
|
|
201
|
+
merged = { name: `${merged.name}/${only.name}`, dirs: only.dirs, files: only.files };
|
|
202
|
+
}
|
|
203
|
+
if (merged !== child) {
|
|
204
|
+
node.dirs.delete(key);
|
|
205
|
+
node.dirs.set(key, merged);
|
|
206
|
+
}
|
|
207
|
+
compress(merged);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
compress(root);
|
|
211
|
+
|
|
212
|
+
const children = (node: TreeDir, prefix: string): GitTreeNode[] => [
|
|
213
|
+
...[...node.dirs.values()]
|
|
214
|
+
.sort((left, right) => left.name.localeCompare(right.name))
|
|
215
|
+
.map(dir => {
|
|
216
|
+
const path = `${prefix}${dir.name}`;
|
|
217
|
+
return {
|
|
218
|
+
kind: "dir" as const,
|
|
219
|
+
key: `${this.#section}:${path}`,
|
|
220
|
+
name: dir.name,
|
|
221
|
+
children: children(dir, `${path}/`),
|
|
222
|
+
};
|
|
223
|
+
}),
|
|
224
|
+
...node.files.map(file => ({
|
|
225
|
+
kind: "file" as const,
|
|
226
|
+
key: `file:${file.area}:${file.path}`,
|
|
227
|
+
file,
|
|
228
|
+
})),
|
|
229
|
+
];
|
|
230
|
+
return children(root, "");
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** File row: status letter, dimmed directory, bright basename, +/− counts. */
|
|
235
|
+
function fileRowText(file: ChangedFile, width: number, selected: boolean, focused: boolean, depth?: number): string {
|
|
236
|
+
const prefix = `${theme.fg(KIND_COLOR[file.kind], KIND_LETTER[file.kind])} `;
|
|
237
|
+
const prefixWidth = 2;
|
|
238
|
+
const slash = file.path.lastIndexOf("/");
|
|
239
|
+
const dir = depth === undefined && slash >= 0 ? file.path.slice(0, slash + 1) : "";
|
|
240
|
+
const base = slash >= 0 ? file.path.slice(slash + 1) : file.path;
|
|
241
|
+
const indent = depth === undefined ? "" : " ".repeat(depth);
|
|
242
|
+
let counts = "";
|
|
243
|
+
if (file.additions !== undefined || file.deletions !== undefined) {
|
|
244
|
+
const added = file.additions ? theme.fg("success", `+${file.additions}`) : "";
|
|
245
|
+
const removed = file.deletions ? theme.fg("error", `−${file.deletions}`) : "";
|
|
246
|
+
counts = [added, removed].filter(Boolean).join(" ");
|
|
247
|
+
}
|
|
248
|
+
const countsWidth = visibleWidth(counts);
|
|
249
|
+
const pathBudget = width - 2 - prefixWidth - (countsWidth ? countsWidth + 1 : 0) - indent.length;
|
|
250
|
+
let pathText: string;
|
|
251
|
+
const full = dir + base;
|
|
252
|
+
if (full.length <= pathBudget) {
|
|
253
|
+
pathText = theme.fg("dim", dir) + base;
|
|
254
|
+
} else {
|
|
255
|
+
const tail = full.slice(Math.max(0, full.length - pathBudget + 1));
|
|
256
|
+
pathText = theme.fg("dim", "…") + tail;
|
|
257
|
+
}
|
|
258
|
+
if (file.kind === "deleted") pathText = theme.strikethrough(pathText);
|
|
259
|
+
const pad = Math.max(
|
|
260
|
+
0,
|
|
261
|
+
width - 2 - prefixWidth - visibleWidth(pathText) - (countsWidth ? countsWidth + 1 : 0) - indent.length,
|
|
262
|
+
);
|
|
263
|
+
const bar = selected ? theme.fg("accent", "▎") : " ";
|
|
264
|
+
const line = `${bar}${indent}${prefix}${pathText}${" ".repeat(pad)}${countsWidth ? ` ${counts}` : ""}`;
|
|
265
|
+
return selected && focused ? `${withBg(line, selectionBgAnsi())}\x1b[0m` : line;
|
|
266
|
+
}
|
|
267
|
+
/** Directory row in tree mode: chevron + compressed dir-chain name. */
|
|
268
|
+
function dirRowText(entry: SidebarFileEntry, width: number, selected: boolean, focused: boolean): string {
|
|
269
|
+
const bar = selected ? theme.fg("accent", "▎") : " ";
|
|
270
|
+
const chevron = entry.collapsed ? "▸" : "▾";
|
|
271
|
+
const indent = " ".repeat(entry.depth ?? 0);
|
|
272
|
+
const text = `${bar}${indent}${theme.fg("muted", chevron)}${theme.fg("dim", `${entry.dirName}/`)}`;
|
|
273
|
+
const line = truncateToWidth(text + " ".repeat(Math.max(0, width - visibleWidth(text))), width);
|
|
274
|
+
return selected && focused ? `${withBg(line, selectionBgAnsi())}\x1b[0m` : line;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** Section header row: clicking the label toggles the fold; the action pill stages/unstages. */
|
|
278
|
+
function sectionHeaderRow(
|
|
279
|
+
label: string,
|
|
280
|
+
pills: readonly { action: string; target: Target }[],
|
|
281
|
+
target: Target,
|
|
282
|
+
width: number,
|
|
283
|
+
selected: boolean,
|
|
284
|
+
focused: boolean,
|
|
285
|
+
): Row {
|
|
286
|
+
const left = theme.bold(label);
|
|
287
|
+
const rendered = pills.map(pill => softPill(` ${pill.action} `, { active: true }));
|
|
288
|
+
const rightWidth = rendered.reduce((sum, text) => sum + visibleWidth(text), 0) + Math.max(0, rendered.length - 1);
|
|
289
|
+
const pad = Math.max(1, width - 2 - visibleWidth(left) - rightWidth);
|
|
290
|
+
let line = ` ${left}${" ".repeat(pad)}`;
|
|
291
|
+
let col = 1 + visibleWidth(left) + pad;
|
|
292
|
+
const hits: Row["hits"] = [];
|
|
293
|
+
rendered.forEach((text, index) => {
|
|
294
|
+
if (index > 0) {
|
|
295
|
+
line += " ";
|
|
296
|
+
col += 1;
|
|
297
|
+
}
|
|
298
|
+
hits.push({ from: col, to: col + visibleWidth(text), target: pills[index].target });
|
|
299
|
+
line += text;
|
|
300
|
+
col += visibleWidth(text);
|
|
301
|
+
});
|
|
302
|
+
line += " ";
|
|
303
|
+
return {
|
|
304
|
+
text: selected && focused ? `${withBg(line, selectionBgAnsi())}\x1b[0m` : line,
|
|
305
|
+
target,
|
|
306
|
+
hits,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** Sidebar state machine + renderer. */
|
|
311
|
+
export class Sidebar {
|
|
312
|
+
readonly #model: GitViewState;
|
|
313
|
+
readonly #avatars: AvatarSource;
|
|
314
|
+
readonly #onSelectFile: (file: ChangedFile | null) => void;
|
|
315
|
+
readonly #onAction: (action: SidebarAction) => void;
|
|
316
|
+
readonly #onFocusDiff: () => void;
|
|
317
|
+
readonly #requestRender: () => void;
|
|
318
|
+
readonly summary: TextFormField;
|
|
319
|
+
readonly description = new Editor(getEditorTheme());
|
|
320
|
+
readonly #descriptionField: FormField;
|
|
321
|
+
/** "What should we stage?" textbox opened by the unstaged-header wand pill. */
|
|
322
|
+
readonly aiInput: TextFormField;
|
|
323
|
+
readonly #imageBudget: ImageBudget | undefined;
|
|
324
|
+
focused = false;
|
|
325
|
+
amend = false;
|
|
326
|
+
generating = false;
|
|
327
|
+
#aiPromptOpen = false;
|
|
328
|
+
/** File-list presentation: flat paths or a collapsible directory tree. */
|
|
329
|
+
viewStyle: "path" | "tree" = "tree";
|
|
330
|
+
readonly #collapsed = new Set<string>();
|
|
331
|
+
readonly #collapsedSections = new Set<SectionTarget["area"]>();
|
|
332
|
+
readonly #selection = new MenuSelection<Target>([], { getKey: targetKey, getSearchText: targetKey });
|
|
333
|
+
#treeVersion = 0;
|
|
334
|
+
readonly #targetByKey = new Map<string, Target>();
|
|
335
|
+
readonly #fileEntryCache = new Map<
|
|
336
|
+
string,
|
|
337
|
+
{
|
|
338
|
+
files: readonly ChangedFile[];
|
|
339
|
+
style: "path" | "tree";
|
|
340
|
+
treeVersion: number;
|
|
341
|
+
entries: SidebarFileEntry[];
|
|
342
|
+
rows: Row[];
|
|
343
|
+
}
|
|
344
|
+
>();
|
|
345
|
+
readonly #fileTrees = new Map<string, GitFileTree>();
|
|
346
|
+
#targetSnapshot:
|
|
347
|
+
| {
|
|
348
|
+
clean: boolean;
|
|
349
|
+
unstaged: readonly ChangedFile[];
|
|
350
|
+
staged: readonly ChangedFile[];
|
|
351
|
+
headFiles: readonly ChangedFile[] | undefined;
|
|
352
|
+
style: "path" | "tree";
|
|
353
|
+
treeVersion: number;
|
|
354
|
+
}
|
|
355
|
+
| undefined;
|
|
356
|
+
/** Tree depth per target key (file/dir rows only); parent-jump for `←`. */
|
|
357
|
+
readonly #entryDepth = new Map<string, number>();
|
|
358
|
+
readonly #scrollView = new ScrollView([], { height: 1, totalRows: 0, scrollbar: "never" });
|
|
359
|
+
/** One-shot: the next render scrolls the selected row into view. Set on
|
|
360
|
+
* explicit selection changes so wheel scrolling can roam freely. */
|
|
361
|
+
#followSelection = false;
|
|
362
|
+
#visibleRows: (Row | undefined)[] = [];
|
|
363
|
+
#lastWidth = 40;
|
|
364
|
+
#lastHeight = 24;
|
|
365
|
+
#avatarImage: { email: string; image: Image } | undefined;
|
|
366
|
+
|
|
367
|
+
constructor(options: {
|
|
368
|
+
model: GitViewState;
|
|
369
|
+
avatars: AvatarSource;
|
|
370
|
+
imageBudget?: ImageBudget;
|
|
371
|
+
onSelectFile: (file: ChangedFile | null) => void;
|
|
372
|
+
onAction: (action: SidebarAction) => void;
|
|
373
|
+
onFocusDiff: () => void;
|
|
374
|
+
requestRender: () => void;
|
|
375
|
+
}) {
|
|
376
|
+
this.#model = options.model;
|
|
377
|
+
this.#avatars = options.avatars;
|
|
378
|
+
this.#imageBudget = options.imageBudget;
|
|
379
|
+
this.#onSelectFile = options.onSelectFile;
|
|
380
|
+
this.#onAction = options.onAction;
|
|
381
|
+
this.#onFocusDiff = options.onFocusDiff;
|
|
382
|
+
this.#requestRender = options.requestRender;
|
|
383
|
+
this.summary = new TextFormField({
|
|
384
|
+
theme: SIDEBAR_FORM_THEME,
|
|
385
|
+
prompt: "",
|
|
386
|
+
spaceBeforeControl: false,
|
|
387
|
+
spaceAfterControl: false,
|
|
388
|
+
onSubmit: () => this.#moveSelection(1),
|
|
389
|
+
onCancel: () => this.#select({ kind: "commit-button" }),
|
|
390
|
+
});
|
|
391
|
+
this.aiInput = new TextFormField({
|
|
392
|
+
theme: SIDEBAR_FORM_THEME,
|
|
393
|
+
prompt: "",
|
|
394
|
+
spaceBeforeControl: false,
|
|
395
|
+
spaceAfterControl: false,
|
|
396
|
+
onSubmit: value => {
|
|
397
|
+
const prompt = value.trim();
|
|
398
|
+
if (prompt.length === 0) return;
|
|
399
|
+
this.#closeAiPrompt();
|
|
400
|
+
this.#select({ kind: "section", area: "unstaged" });
|
|
401
|
+
this.#onAction({ type: "stage-ai", prompt });
|
|
402
|
+
},
|
|
403
|
+
onCancel: () => {
|
|
404
|
+
this.#closeAiPrompt();
|
|
405
|
+
this.#select({ kind: "section", area: "unstaged" });
|
|
406
|
+
},
|
|
407
|
+
});
|
|
408
|
+
this.description.setBorderVisible(false);
|
|
409
|
+
this.description.setMaxHeight(5);
|
|
410
|
+
this.#descriptionField = new FormField(this.description, {
|
|
411
|
+
theme: SIDEBAR_FORM_THEME,
|
|
412
|
+
spaceBeforeControl: false,
|
|
413
|
+
spaceAfterControl: false,
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/** Currently selected target, if any. */
|
|
418
|
+
get selected(): Target | undefined {
|
|
419
|
+
return this.#selection.selectedItem ?? this.#selection.visibleItems[0] ?? this.#selection.items[0];
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
get selectedFile(): ChangedFile | null {
|
|
423
|
+
const target = this.selected;
|
|
424
|
+
return target?.kind === "file" ? target.file : null;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/** Re-sync selection after a model refresh; returns the file to show. */
|
|
428
|
+
reconcile(): ChangedFile | null {
|
|
429
|
+
const previousTargets = this.#selection.items;
|
|
430
|
+
const previousKey = this.#selection.selectedKey;
|
|
431
|
+
this.#rebuildTargets();
|
|
432
|
+
// Staging/unstaging removes the selected row from its section; land on
|
|
433
|
+
// the nearest surviving file/dir row instead of falling back to the top.
|
|
434
|
+
if (previousKey !== undefined && !this.#targetByKey.has(previousKey)) {
|
|
435
|
+
const survivor = this.#nearestSurvivor(previousTargets, previousKey);
|
|
436
|
+
if (survivor) this.#selection.setSelectedKey(targetKey(survivor));
|
|
437
|
+
}
|
|
438
|
+
const target = this.selected;
|
|
439
|
+
if (this.#selection.selectedKey !== previousKey) this.#followSelection = true;
|
|
440
|
+
if (target?.kind === "file") return target.file;
|
|
441
|
+
const firstFile = this.#selection.items.find(candidate => candidate.kind === "file");
|
|
442
|
+
if (firstFile?.kind === "file" && (!target || target.kind === "section")) {
|
|
443
|
+
return firstFile.file;
|
|
444
|
+
}
|
|
445
|
+
return firstFile?.kind === "file" ? firstFile.file : null;
|
|
446
|
+
}
|
|
447
|
+
/** Closest file/dir row (in previous display order) that still exists after a rebuild. */
|
|
448
|
+
#nearestSurvivor(previousTargets: readonly Target[], previousKey: string): Target | undefined {
|
|
449
|
+
const index = previousTargets.findIndex(target => targetKey(target) === previousKey);
|
|
450
|
+
if (index < 0) return undefined;
|
|
451
|
+
const survivorAt = (i: number): Target | undefined => {
|
|
452
|
+
const candidate = previousTargets[i];
|
|
453
|
+
if (candidate.kind !== "file" && candidate.kind !== "dir") return undefined;
|
|
454
|
+
return this.#targetByKey.get(targetKey(candidate));
|
|
455
|
+
};
|
|
456
|
+
for (let i = index + 1; i < previousTargets.length; i++) {
|
|
457
|
+
const survivor = survivorAt(i);
|
|
458
|
+
if (survivor) return survivor;
|
|
459
|
+
}
|
|
460
|
+
for (let i = index - 1; i >= 0; i--) {
|
|
461
|
+
const survivor = survivorAt(i);
|
|
462
|
+
if (survivor) return survivor;
|
|
463
|
+
}
|
|
464
|
+
return undefined;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/** Section entries in display order: tree dirs + files, or flat files. */
|
|
468
|
+
#fileEntries(files: readonly ChangedFile[], section: string): SidebarFileEntry[] {
|
|
469
|
+
const cached = this.#fileEntryCache.get(section);
|
|
470
|
+
if (cached?.files === files && cached.style === this.viewStyle && cached.treeVersion === this.#treeVersion) {
|
|
471
|
+
return cached.entries;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
let entries: SidebarFileEntry[];
|
|
475
|
+
if (this.viewStyle === "path") {
|
|
476
|
+
entries = files.map(file => ({ target: { kind: "file", file } as const, file }));
|
|
477
|
+
} else {
|
|
478
|
+
let fileTree = this.#fileTrees.get(section);
|
|
479
|
+
if (!fileTree) {
|
|
480
|
+
fileTree = new GitFileTree(section, this.#collapsed);
|
|
481
|
+
this.#fileTrees.set(section, fileTree);
|
|
482
|
+
}
|
|
483
|
+
entries = fileTree.entries(files, this.#treeVersion);
|
|
484
|
+
}
|
|
485
|
+
this.#fileEntryCache.set(section, {
|
|
486
|
+
files,
|
|
487
|
+
style: this.viewStyle,
|
|
488
|
+
treeVersion: this.#treeVersion,
|
|
489
|
+
entries,
|
|
490
|
+
rows: entries.map(entry => ({ entry, target: entry.target })),
|
|
491
|
+
});
|
|
492
|
+
return entries;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
#rebuildTargets(): void {
|
|
496
|
+
const headFiles = this.#model.headCommit?.files;
|
|
497
|
+
const snapshot = this.#targetSnapshot;
|
|
498
|
+
if (
|
|
499
|
+
snapshot?.clean === this.#model.clean &&
|
|
500
|
+
snapshot.unstaged === this.#model.unstaged &&
|
|
501
|
+
snapshot.staged === this.#model.staged &&
|
|
502
|
+
snapshot.headFiles === headFiles &&
|
|
503
|
+
snapshot.style === this.viewStyle &&
|
|
504
|
+
snapshot.treeVersion === this.#treeVersion
|
|
505
|
+
) {
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
const targets: Target[] = [];
|
|
510
|
+
this.#entryDepth.clear();
|
|
511
|
+
this.#targetByKey.clear();
|
|
512
|
+
const pushTarget = (target: Target): void => {
|
|
513
|
+
targets.push(target);
|
|
514
|
+
this.#targetByKey.set(targetKey(target), target);
|
|
515
|
+
};
|
|
516
|
+
const pushEntry = (entry: SidebarFileEntry): void => {
|
|
517
|
+
this.#entryDepth.set(targetKey(entry.target), entry.depth ?? 0);
|
|
518
|
+
pushTarget(entry.target);
|
|
519
|
+
};
|
|
520
|
+
const pushSection = (files: readonly ChangedFile[], section: string): void => {
|
|
521
|
+
for (const entry of this.#fileEntries(files, section)) pushEntry(entry);
|
|
522
|
+
};
|
|
523
|
+
if (this.#model.clean) {
|
|
524
|
+
pushSection(headFiles ?? [], "commit");
|
|
525
|
+
} else {
|
|
526
|
+
pushTarget({ kind: "section", area: "unstaged" });
|
|
527
|
+
if (this.#aiPromptOpen) pushTarget({ kind: "stage-ai-input" });
|
|
528
|
+
if (!this.#collapsedSections.has("unstaged")) pushSection(this.#model.unstaged, "unstaged");
|
|
529
|
+
pushTarget({ kind: "section", area: "staged" });
|
|
530
|
+
if (!this.#collapsedSections.has("staged")) pushSection(this.#model.staged, "staged");
|
|
531
|
+
pushTarget({ kind: "amend" });
|
|
532
|
+
pushTarget({ kind: "summary" });
|
|
533
|
+
pushTarget({ kind: "description" });
|
|
534
|
+
pushTarget({ kind: "commit-button" });
|
|
535
|
+
}
|
|
536
|
+
const retainKey = this.#selection.selectedKey;
|
|
537
|
+
this.#selection.setItems(targets, retainKey);
|
|
538
|
+
this.#targetSnapshot = {
|
|
539
|
+
clean: this.#model.clean,
|
|
540
|
+
unstaged: this.#model.unstaged,
|
|
541
|
+
staged: this.#model.staged,
|
|
542
|
+
headFiles,
|
|
543
|
+
style: this.viewStyle,
|
|
544
|
+
treeVersion: this.#treeVersion,
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
#select(target: Target): void {
|
|
549
|
+
const key = targetKey(target);
|
|
550
|
+
if (this.#selection.items.some(item => targetKey(item) === key)) this.#selection.setSelectedKey(key);
|
|
551
|
+
else this.#selection.setSelectedIndex(0);
|
|
552
|
+
this.#followSelection = true;
|
|
553
|
+
this.summary.focused = this.focused && target.kind === "summary";
|
|
554
|
+
this.#descriptionField.focused = this.focused && target.kind === "description";
|
|
555
|
+
this.aiInput.focused = this.focused && target.kind === "stage-ai-input";
|
|
556
|
+
if (target.kind === "file") this.#onSelectFile(target.file);
|
|
557
|
+
this.#requestRender();
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/** Called by the root when pane focus changes. */
|
|
561
|
+
setFocused(focused: boolean): void {
|
|
562
|
+
this.focused = focused;
|
|
563
|
+
const target = this.selected;
|
|
564
|
+
this.summary.focused = focused && target?.kind === "summary";
|
|
565
|
+
this.#descriptionField.focused = focused && target?.kind === "description";
|
|
566
|
+
this.aiInput.focused = focused && target?.kind === "stage-ai-input";
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
#moveSelection(delta: number): void {
|
|
570
|
+
if (this.#selection.items.length === 0) return;
|
|
571
|
+
if (!this.#selection.move(delta, false)) return;
|
|
572
|
+
const current = this.#selection.selectedItem;
|
|
573
|
+
if (current) this.#select(current);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
#activate(target: Target): void {
|
|
577
|
+
switch (target.kind) {
|
|
578
|
+
case "file": {
|
|
579
|
+
const action = this.#stageActionFor(target);
|
|
580
|
+
if (action) this.#onAction(action);
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
case "dir": {
|
|
584
|
+
if (this.#collapsed.has(target.key)) this.#collapsed.delete(target.key);
|
|
585
|
+
else this.#collapsed.add(target.key);
|
|
586
|
+
this.#treeVersion++;
|
|
587
|
+
this.#requestRender();
|
|
588
|
+
break;
|
|
589
|
+
}
|
|
590
|
+
case "view-style":
|
|
591
|
+
this.viewStyle = target.style;
|
|
592
|
+
this.#treeVersion++;
|
|
593
|
+
this.#requestRender();
|
|
594
|
+
break;
|
|
595
|
+
case "section":
|
|
596
|
+
this.#toggleSection(target.area);
|
|
597
|
+
break;
|
|
598
|
+
case "stage-all":
|
|
599
|
+
this.#onAction({ type: "stage" });
|
|
600
|
+
break;
|
|
601
|
+
case "unstage-all":
|
|
602
|
+
this.#onAction({ type: "unstage" });
|
|
603
|
+
break;
|
|
604
|
+
case "stage-ai":
|
|
605
|
+
this.#openAiPrompt();
|
|
606
|
+
break;
|
|
607
|
+
case "stage-ai-input":
|
|
608
|
+
break;
|
|
609
|
+
case "amend":
|
|
610
|
+
this.#toggleAmend();
|
|
611
|
+
break;
|
|
612
|
+
case "summary":
|
|
613
|
+
case "description":
|
|
614
|
+
break;
|
|
615
|
+
case "commit-button":
|
|
616
|
+
this.#submitCommit();
|
|
617
|
+
break;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/** Stage/unstage action for a file, dir, or section-header row; dirs and sections batch every file underneath. */
|
|
622
|
+
#stageActionFor(target: FileTarget | SectionTarget): SidebarAction | null {
|
|
623
|
+
if (target.kind === "section") return target.area === "unstaged" ? { type: "stage" } : { type: "unstage" };
|
|
624
|
+
const selected = this.#selectionFor(target);
|
|
625
|
+
if (!selected) return null;
|
|
626
|
+
const { area, ...selection } = selected;
|
|
627
|
+
return area === "unstaged" ? { type: "stage", selection } : { type: "unstage", selection };
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/** Discard action for a file or dir row; null on a commit-area row. */
|
|
631
|
+
#discardActionFor(target: FileTarget): SidebarAction | null {
|
|
632
|
+
const selected = this.#selectionFor(target);
|
|
633
|
+
if (!selected) return null;
|
|
634
|
+
return { type: "discard", selection: { files: selected.files, label: selected.label } };
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/** Files under a file/dir row plus a status-line label; null outside the unstaged/staged sections. */
|
|
638
|
+
#selectionFor(target: FileTarget): { files: ChangedFile[]; label: string; area: "unstaged" | "staged" } | null {
|
|
639
|
+
if (target.kind === "file") {
|
|
640
|
+
const area = target.file.area;
|
|
641
|
+
if (area !== "unstaged" && area !== "staged") return null;
|
|
642
|
+
return { files: [target.file], label: target.file.path, area };
|
|
643
|
+
}
|
|
644
|
+
// Dir keys are `<section>:<path from repo root>` (see #fileEntries).
|
|
645
|
+
const sep = target.key.indexOf(":");
|
|
646
|
+
const area = target.key.slice(0, sep);
|
|
647
|
+
if (area !== "unstaged" && area !== "staged") return null;
|
|
648
|
+
const dirPath = target.key.slice(sep + 1);
|
|
649
|
+
const files = (area === "unstaged" ? this.#model.unstaged : this.#model.staged).filter(file =>
|
|
650
|
+
file.path.startsWith(`${dirPath}/`),
|
|
651
|
+
);
|
|
652
|
+
if (files.length === 0) return null;
|
|
653
|
+
return { files, label: `${dirPath}/`, area };
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/** Open the AI staging textbox under the unstaged header and focus it. */
|
|
657
|
+
#openAiPrompt(): void {
|
|
658
|
+
this.#aiPromptOpen = true;
|
|
659
|
+
this.#treeVersion++;
|
|
660
|
+
this.#rebuildTargets();
|
|
661
|
+
this.#select({ kind: "stage-ai-input" });
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
#closeAiPrompt(): void {
|
|
665
|
+
this.#aiPromptOpen = false;
|
|
666
|
+
this.aiInput.setValue("");
|
|
667
|
+
this.#treeVersion++;
|
|
668
|
+
this.#requestRender();
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
#toggleAmend(): void {
|
|
672
|
+
this.amend = !this.amend;
|
|
673
|
+
const head = this.#model.headCommit;
|
|
674
|
+
if (this.amend && head && this.summary.getValue().length === 0 && this.description.getText().length === 0) {
|
|
675
|
+
this.summary.setValue(head.subject);
|
|
676
|
+
this.description.setText(head.body);
|
|
677
|
+
}
|
|
678
|
+
this.#requestRender();
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
#submitCommit(): void {
|
|
682
|
+
const summary = this.summary.getValue().trim();
|
|
683
|
+
const body = this.description.getText().trim();
|
|
684
|
+
const stageAll = this.#model.staged.length === 0;
|
|
685
|
+
if (stageAll && this.#model.unstaged.length === 0 && !this.amend) return;
|
|
686
|
+
if (!summary) {
|
|
687
|
+
if (!body) this.#onAction({ type: "generate" });
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
const message = body ? `${summary}\n\n${body}` : summary;
|
|
691
|
+
this.#onAction({ type: "commit", message, amend: this.amend, stageAll });
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/** Clear the commit form after a successful commit. */
|
|
695
|
+
clearForm(): void {
|
|
696
|
+
this.summary.setValue("");
|
|
697
|
+
this.description.setText("");
|
|
698
|
+
this.amend = false;
|
|
699
|
+
}
|
|
700
|
+
/** Replace the form with one generated conventional commit. */
|
|
701
|
+
setGeneratedCommit(commit: GitCommitMessage): void {
|
|
702
|
+
const scope = commit.scope ? `(${commit.scope})` : "";
|
|
703
|
+
this.summary.setValue(`${commit.type}${scope}: ${commit.summary}`);
|
|
704
|
+
this.description.setText(commit.body.map(detail => `- ${detail}`).join("\n"));
|
|
705
|
+
this.#requestRender();
|
|
706
|
+
}
|
|
707
|
+
/** Reflect whether an inference request currently owns the commit form. */
|
|
708
|
+
setGenerating(generating: boolean): void {
|
|
709
|
+
this.generating = generating;
|
|
710
|
+
this.#requestRender();
|
|
711
|
+
}
|
|
712
|
+
/** Escape while the sidebar has focus: blur a text input first. True when consumed. */
|
|
713
|
+
handleEscape(): boolean {
|
|
714
|
+
const target = this.selected;
|
|
715
|
+
if (target?.kind === "stage-ai-input") {
|
|
716
|
+
this.#closeAiPrompt();
|
|
717
|
+
this.#select({ kind: "section", area: "unstaged" });
|
|
718
|
+
return true;
|
|
719
|
+
}
|
|
720
|
+
if (target?.kind === "summary" || target?.kind === "description") {
|
|
721
|
+
this.#select({ kind: "commit-button" });
|
|
722
|
+
return true;
|
|
723
|
+
}
|
|
724
|
+
return false;
|
|
725
|
+
}
|
|
726
|
+
/** True while a commit-form text input is capturing letter keys. */
|
|
727
|
+
get editing(): boolean {
|
|
728
|
+
const target = this.selected;
|
|
729
|
+
return (
|
|
730
|
+
this.focused &&
|
|
731
|
+
(target?.kind === "summary" || target?.kind === "description" || target?.kind === "stage-ai-input")
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* Move selection to the next/previous visible file row. False at the
|
|
737
|
+
* boundary. `from` anchors the walk at the file currently shown in the
|
|
738
|
+
* diff pane, so hunk rollover works even when the sidebar selection sits
|
|
739
|
+
* on a dir row or a commit-form control.
|
|
740
|
+
*/
|
|
741
|
+
selectAdjacentFile(direction: 1 | -1, from?: ChangedFile | null): boolean {
|
|
742
|
+
this.#rebuildTargets();
|
|
743
|
+
const items = this.#selection.items;
|
|
744
|
+
let start = from
|
|
745
|
+
? items.findIndex(
|
|
746
|
+
target => target.kind === "file" && target.file.path === from.path && target.file.area === from.area,
|
|
747
|
+
)
|
|
748
|
+
: -1;
|
|
749
|
+
if (start < 0) {
|
|
750
|
+
const current = this.selected;
|
|
751
|
+
start = current ? items.findIndex(target => targetKey(target) === targetKey(current)) : -1;
|
|
752
|
+
}
|
|
753
|
+
for (let i = start + direction; i >= 0 && i < items.length; i += direction) {
|
|
754
|
+
const target = items[i];
|
|
755
|
+
if (target?.kind === "file") {
|
|
756
|
+
this.#select(target);
|
|
757
|
+
return true;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
return false;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/** Select the commit summary input (the `c` shortcut). False on a clean tree. */
|
|
764
|
+
focusCommitForm(): boolean {
|
|
765
|
+
this.#rebuildTargets();
|
|
766
|
+
const summary = this.#selection.items.find(target => target.kind === "summary");
|
|
767
|
+
if (!summary) return false;
|
|
768
|
+
this.#select(summary);
|
|
769
|
+
return true;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
/** `←`: collapse an expanded dir, otherwise jump to the parent dir row. */
|
|
773
|
+
#collapseOrParent(): void {
|
|
774
|
+
const target = this.selected;
|
|
775
|
+
if (target?.kind === "section" && !this.#collapsedSections.has(target.area)) {
|
|
776
|
+
this.#toggleSection(target.area);
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
if (!target || (target.kind !== "file" && target.kind !== "dir")) return;
|
|
780
|
+
if (target.kind === "dir" && !this.#collapsed.has(target.key)) {
|
|
781
|
+
this.#collapsed.add(target.key);
|
|
782
|
+
this.#treeVersion++;
|
|
783
|
+
this.#requestRender();
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
const items = this.#selection.items;
|
|
787
|
+
const index = items.findIndex(candidate => targetKey(candidate) === targetKey(target));
|
|
788
|
+
const depth = this.#entryDepth.get(targetKey(target)) ?? 0;
|
|
789
|
+
for (let i = index - 1; i >= 0; i--) {
|
|
790
|
+
const candidate = items[i];
|
|
791
|
+
// Section headers/buttons bound the tree walk.
|
|
792
|
+
if (!candidate || (candidate.kind !== "file" && candidate.kind !== "dir")) return;
|
|
793
|
+
if (candidate.kind === "dir" && (this.#entryDepth.get(targetKey(candidate)) ?? 0) < depth) {
|
|
794
|
+
this.#select(candidate);
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
/** `→`: expand a collapsed dir, step into an expanded one, open a file. */
|
|
801
|
+
#expandOrOpen(): void {
|
|
802
|
+
const target = this.selected;
|
|
803
|
+
if (target?.kind === "section") {
|
|
804
|
+
if (this.#collapsedSections.has(target.area)) this.#toggleSection(target.area);
|
|
805
|
+
else this.#moveSelection(1);
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
if (target?.kind === "dir") {
|
|
809
|
+
if (this.#collapsed.has(target.key)) {
|
|
810
|
+
this.#collapsed.delete(target.key);
|
|
811
|
+
this.#treeVersion++;
|
|
812
|
+
this.#requestRender();
|
|
813
|
+
} else {
|
|
814
|
+
this.#moveSelection(1);
|
|
815
|
+
}
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
if (target?.kind === "file") this.#onFocusDiff();
|
|
819
|
+
}
|
|
820
|
+
/** Fold/unfold a whole section; hidden rows drop out of keyboard navigation. */
|
|
821
|
+
#toggleSection(area: SectionTarget["area"]): void {
|
|
822
|
+
if (!this.#collapsedSections.delete(area)) this.#collapsedSections.add(area);
|
|
823
|
+
this.#treeVersion++;
|
|
824
|
+
this.#requestRender();
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
handleInput(data: string): void {
|
|
828
|
+
this.#rebuildTargets();
|
|
829
|
+
const target = this.selected;
|
|
830
|
+
|
|
831
|
+
if (target?.kind === "stage-ai-input" && this.focused) {
|
|
832
|
+
if (matchesKey(data, "up")) return this.#moveSelection(-1);
|
|
833
|
+
if (matchesKey(data, "down")) return this.#moveSelection(1);
|
|
834
|
+
if (!matchesKey(data, "pageUp") && !matchesKey(data, "pageDown")) {
|
|
835
|
+
this.aiInput.handleInput(data);
|
|
836
|
+
this.#requestRender();
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
if (target?.kind === "summary" && this.focused) {
|
|
842
|
+
if (matchesKey(data, "up")) return this.#moveSelection(-1);
|
|
843
|
+
if (matchesKey(data, "down")) return this.#moveSelection(1);
|
|
844
|
+
if (!matchesKey(data, "pageUp") && !matchesKey(data, "pageDown")) {
|
|
845
|
+
this.summary.handleInput(data);
|
|
846
|
+
this.#requestRender();
|
|
847
|
+
return;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
if (target?.kind === "description" && this.focused) {
|
|
851
|
+
const cursor = this.description.getCursor();
|
|
852
|
+
const lineCount = this.description.getLines().length;
|
|
853
|
+
if (matchesKey(data, "up") && cursor.line === 0) return this.#moveSelection(-1);
|
|
854
|
+
if (matchesKey(data, "down") && cursor.line >= lineCount - 1) return this.#moveSelection(1);
|
|
855
|
+
if (!matchesKey(data, "pageUp") && !matchesKey(data, "pageDown")) {
|
|
856
|
+
this.#descriptionField.handleInput(data);
|
|
857
|
+
this.#requestRender();
|
|
858
|
+
return;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
if (matchesKey(data, "up") || data === "k") this.#moveSelection(-1);
|
|
863
|
+
else if (matchesKey(data, "down") || data === "j") this.#moveSelection(1);
|
|
864
|
+
else if (matchesKey(data, "left") || data === "h") this.#collapseOrParent();
|
|
865
|
+
else if (matchesKey(data, "right") || data === "l") this.#expandOrOpen();
|
|
866
|
+
else if (matchesKey(data, "home") || data === "g") this.#moveSelection(-this.#selection.items.length);
|
|
867
|
+
else if (matchesKey(data, "end") || data === "G") this.#moveSelection(this.#selection.items.length);
|
|
868
|
+
else if (matchesKey(data, "pageUp")) this.#moveSelection(-Math.max(1, this.#lastHeight - 4));
|
|
869
|
+
else if (matchesKey(data, "pageDown")) this.#moveSelection(Math.max(1, this.#lastHeight - 4));
|
|
870
|
+
else if (matchesKey(data, "enter") && target) {
|
|
871
|
+
// Enter opens a file (focus the diff); space/s/u do the staging.
|
|
872
|
+
if (target.kind === "file") this.#onFocusDiff();
|
|
873
|
+
else this.#activate(target);
|
|
874
|
+
} else if (data === " " && (target?.kind === "file" || target?.kind === "dir" || target?.kind === "section")) {
|
|
875
|
+
// Space stages/unstages the row — folders and section headers act on every file underneath.
|
|
876
|
+
// Enter/click toggle dir/section collapse; ←/→ fold explicitly.
|
|
877
|
+
const action = this.#stageActionFor(target);
|
|
878
|
+
if (action) this.#onAction(action);
|
|
879
|
+
} else if (
|
|
880
|
+
(data === "s" || data === "u") &&
|
|
881
|
+
(target?.kind === "file" || target?.kind === "dir" || target?.kind === "section")
|
|
882
|
+
) {
|
|
883
|
+
const action = this.#stageActionFor(target);
|
|
884
|
+
if (action?.type === (data === "s" ? "stage" : "unstage")) this.#onAction(action);
|
|
885
|
+
} else if (matchesKey(data, "delete") && (target?.kind === "file" || target?.kind === "dir")) {
|
|
886
|
+
const action = this.#discardActionFor(target);
|
|
887
|
+
if (action) this.#onAction(action);
|
|
888
|
+
} else if (data === "t") {
|
|
889
|
+
this.viewStyle = this.viewStyle === "path" ? "tree" : "path";
|
|
890
|
+
this.#treeVersion++;
|
|
891
|
+
this.#requestRender();
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
/** Wheel scroll over the sidebar. */
|
|
896
|
+
handleWheel(delta: number): void {
|
|
897
|
+
this.#scrollView.scroll(delta * 3);
|
|
898
|
+
this.#requestRender();
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/** Left click at sidebar-local coordinates. */
|
|
902
|
+
handleClick(row: number, col: number): void {
|
|
903
|
+
const visible = this.#visibleRows[row];
|
|
904
|
+
if (!visible) return;
|
|
905
|
+
const hit = visible.hits?.find(candidate => col >= candidate.from && col < candidate.to);
|
|
906
|
+
const target = hit?.target ?? visible.target;
|
|
907
|
+
if (!target) return;
|
|
908
|
+
// Selection follows the row; column-scoped buttons (header pills) fire
|
|
909
|
+
// their own action without stealing it.
|
|
910
|
+
const selectTarget = visible.target ?? target;
|
|
911
|
+
const wasSelected = this.selected && targetKey(this.selected) === targetKey(selectTarget);
|
|
912
|
+
this.#select(selectTarget);
|
|
913
|
+
if (target.kind !== "file" && target.kind !== "summary" && target.kind !== "description") {
|
|
914
|
+
this.#activate(target);
|
|
915
|
+
} else if (target.kind === "file" && wasSelected) {
|
|
916
|
+
this.#activate(target);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
render(width: number, height: number): string[] {
|
|
921
|
+
this.#lastWidth = width;
|
|
922
|
+
this.#lastHeight = height;
|
|
923
|
+
this.#rebuildTargets();
|
|
924
|
+
const selected = this.selected;
|
|
925
|
+
const selectedKey = selected ? targetKey(selected) : undefined;
|
|
926
|
+
const isSelected = (target: Target): boolean => selectedKey === targetKey(target);
|
|
927
|
+
|
|
928
|
+
const rows: Row[] = [];
|
|
929
|
+
let pinned: Row[] = [];
|
|
930
|
+
if (this.#model.clean) {
|
|
931
|
+
rows.push(...this.#commitViewRows(width));
|
|
932
|
+
} else {
|
|
933
|
+
rows.push(...this.#changesHeaderRows(width));
|
|
934
|
+
rows.push(...this.#fileListRows(width, isSelected));
|
|
935
|
+
pinned = this.#commitFormRows(width, isSelected);
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
const listHeight = Math.max(1, height - pinned.length);
|
|
939
|
+
this.#scrollView.setHeight(listHeight);
|
|
940
|
+
this.#scrollView.setTotalRows(rows.length);
|
|
941
|
+
// Scroll the selected row into view only after an explicit selection
|
|
942
|
+
// change; unconditional following would snap wheel scrolling back to
|
|
943
|
+
// the selection on every render.
|
|
944
|
+
if (this.#followSelection) {
|
|
945
|
+
this.#followSelection = false;
|
|
946
|
+
const selectedRow = rows.findIndex(row => row.target && selectedKey === targetKey(row.target));
|
|
947
|
+
if (selectedRow >= 0) this.#scrollView.setActiveRow(selectedRow);
|
|
948
|
+
this.#scrollView.setActiveRow(undefined);
|
|
949
|
+
}
|
|
950
|
+
const { start, end } = this.#scrollView.getVisibleRange();
|
|
951
|
+
|
|
952
|
+
this.#visibleRows = [];
|
|
953
|
+
const windowed: string[] = [];
|
|
954
|
+
for (let i = 0; i < listHeight; i++) {
|
|
955
|
+
const row = i < end - start ? rows[start + i] : undefined;
|
|
956
|
+
windowed.push(row ? truncateToWidth(this.#rowText(row, width, selectedKey), width) : "");
|
|
957
|
+
this.#visibleRows.push(row);
|
|
958
|
+
}
|
|
959
|
+
this.#scrollView.setLines(windowed);
|
|
960
|
+
const lines = [...this.#scrollView.render(width)];
|
|
961
|
+
for (const row of pinned) {
|
|
962
|
+
lines.push(truncateToWidth(this.#rowText(row, width, selectedKey), width));
|
|
963
|
+
this.#visibleRows.push(row);
|
|
964
|
+
}
|
|
965
|
+
return lines.slice(0, height);
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
/** Permanently release viewport, form, and avatar resources. */
|
|
969
|
+
dispose(): void {
|
|
970
|
+
this.#scrollView.dispose();
|
|
971
|
+
this.summary.dispose();
|
|
972
|
+
this.aiInput.dispose();
|
|
973
|
+
this.#descriptionField.dispose();
|
|
974
|
+
for (const tree of this.#fileTrees.values()) tree.dispose();
|
|
975
|
+
this.#fileTrees.clear();
|
|
976
|
+
this.#avatarImage = undefined;
|
|
977
|
+
}
|
|
978
|
+
/** Centered `Path | Tree` toggle row with column-scoped hit targets. */
|
|
979
|
+
#viewToggleRow(width: number): Row {
|
|
980
|
+
const nerd = theme.getSymbolPreset() === "nerd";
|
|
981
|
+
const pathPill = softPill(` ${nerd ? "" : "☰"} Path `, { active: this.viewStyle === "path" });
|
|
982
|
+
const treePill = softPill(` ${nerd ? "" : "└"} Tree `, { active: this.viewStyle === "tree" });
|
|
983
|
+
const total = visibleWidth(pathPill) + 1 + visibleWidth(treePill);
|
|
984
|
+
const left = Math.max(1, Math.floor((width - total) / 2));
|
|
985
|
+
return {
|
|
986
|
+
text: `${" ".repeat(left)}${pathPill} ${treePill}`,
|
|
987
|
+
hits: [
|
|
988
|
+
{ from: left, to: left + visibleWidth(pathPill), target: { kind: "view-style", style: "path" } },
|
|
989
|
+
{
|
|
990
|
+
from: left + visibleWidth(pathPill) + 1,
|
|
991
|
+
to: left + total,
|
|
992
|
+
target: { kind: "view-style", style: "tree" },
|
|
993
|
+
},
|
|
994
|
+
],
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
#entryRows(files: readonly ChangedFile[], section: string): Row[] {
|
|
999
|
+
const entries = this.#fileEntries(files, section);
|
|
1000
|
+
const cached = this.#fileEntryCache.get(section);
|
|
1001
|
+
return cached?.entries === entries ? cached.rows : entries.map(entry => ({ entry, target: entry.target }));
|
|
1002
|
+
}
|
|
1003
|
+
#rowText(row: Row, width: number, selectedKey: string | undefined): string {
|
|
1004
|
+
const entry = row.entry;
|
|
1005
|
+
if (!entry) return row.text ?? "";
|
|
1006
|
+
const selected = selectedKey === targetKey(entry.target);
|
|
1007
|
+
if (entry.target.kind === "dir") return dirRowText(entry, width, selected, this.focused);
|
|
1008
|
+
return fileRowText(
|
|
1009
|
+
entry.target.file,
|
|
1010
|
+
width,
|
|
1011
|
+
selected,
|
|
1012
|
+
this.focused,
|
|
1013
|
+
this.viewStyle === "tree" ? entry.depth : undefined,
|
|
1014
|
+
);
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
#changesHeaderRows(width: number): Row[] {
|
|
1018
|
+
const total = this.#model.unstaged.length + this.#model.staged.length;
|
|
1019
|
+
const branch = this.#model.branch ? tintChip(` ${this.#model.branch} `, theme.getColorHex("accent")) : "";
|
|
1020
|
+
const label = theme.bold(`${total} file change${total === 1 ? "" : "s"} on `);
|
|
1021
|
+
return [
|
|
1022
|
+
{ text: ` ${label}${branch}` },
|
|
1023
|
+
this.#viewToggleRow(width),
|
|
1024
|
+
{ text: theme.fg("borderMuted", "─".repeat(Math.max(0, width))) },
|
|
1025
|
+
];
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
#fileListRows(width: number, isSelected: (target: Target) => boolean): Row[] {
|
|
1029
|
+
const rows: Row[] = [];
|
|
1030
|
+
const unstaged: SectionTarget = { kind: "section", area: "unstaged" };
|
|
1031
|
+
const unstagedFolded = this.#collapsedSections.has("unstaged");
|
|
1032
|
+
const wand = theme.getSymbolPreset() === "nerd" ? "" : "✦";
|
|
1033
|
+
rows.push(
|
|
1034
|
+
sectionHeaderRow(
|
|
1035
|
+
`${unstagedFolded ? "▸" : "▾"} Unstaged Files (${this.#model.unstaged.length})`,
|
|
1036
|
+
[
|
|
1037
|
+
{ action: "Stage All", target: { kind: "stage-all" } },
|
|
1038
|
+
{ action: wand, target: { kind: "stage-ai" } },
|
|
1039
|
+
],
|
|
1040
|
+
unstaged,
|
|
1041
|
+
width,
|
|
1042
|
+
isSelected(unstaged),
|
|
1043
|
+
this.focused,
|
|
1044
|
+
),
|
|
1045
|
+
);
|
|
1046
|
+
if (this.#aiPromptOpen) rows.push(this.#aiPromptRow(width, isSelected));
|
|
1047
|
+
if (!unstagedFolded) {
|
|
1048
|
+
rows.push(...this.#entryRows(this.#model.unstaged, "unstaged"));
|
|
1049
|
+
if (this.#model.unstaged.length === 0) rows.push({ text: theme.fg("dim", " no unstaged files") });
|
|
1050
|
+
}
|
|
1051
|
+
rows.push({ text: "" });
|
|
1052
|
+
const staged: SectionTarget = { kind: "section", area: "staged" };
|
|
1053
|
+
const stagedFolded = this.#collapsedSections.has("staged");
|
|
1054
|
+
rows.push(
|
|
1055
|
+
sectionHeaderRow(
|
|
1056
|
+
`${stagedFolded ? "▸" : "▾"} Staged Files (${this.#model.staged.length})`,
|
|
1057
|
+
[{ action: "Unstage All", target: { kind: "unstage-all" } }],
|
|
1058
|
+
staged,
|
|
1059
|
+
width,
|
|
1060
|
+
isSelected(staged),
|
|
1061
|
+
this.focused,
|
|
1062
|
+
),
|
|
1063
|
+
);
|
|
1064
|
+
if (!stagedFolded) {
|
|
1065
|
+
rows.push(...this.#entryRows(this.#model.staged, "staged"));
|
|
1066
|
+
if (this.#model.staged.length === 0) rows.push({ text: theme.fg("dim", " no staged files") });
|
|
1067
|
+
}
|
|
1068
|
+
return rows;
|
|
1069
|
+
}
|
|
1070
|
+
/** Inline "What should we stage?" textbox under the unstaged header. */
|
|
1071
|
+
#aiPromptRow(width: number, isSelected: (target: Target) => boolean): Row {
|
|
1072
|
+
const target: Target = { kind: "stage-ai-input" };
|
|
1073
|
+
const bar = isSelected(target) ? theme.fg("accent", "▎") : theme.fg("borderMuted", "▏");
|
|
1074
|
+
const line =
|
|
1075
|
+
this.aiInput.getValue().length === 0 && !this.aiInput.focused
|
|
1076
|
+
? theme.fg("dim", "What should we stage?")
|
|
1077
|
+
: (this.aiInput.render(width - 4)[0] ?? "");
|
|
1078
|
+
return { text: ` ${bar}${line}`, target };
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
#commitFormRows(width: number, isSelected: (target: Target) => boolean): Row[] {
|
|
1082
|
+
const rows: Row[] = [];
|
|
1083
|
+
rows.push({ text: theme.fg("borderMuted", "─".repeat(Math.max(0, width))) });
|
|
1084
|
+
|
|
1085
|
+
const amendTarget: Target = { kind: "amend" };
|
|
1086
|
+
const amendBox = this.amend ? theme.fg("accent", "▣") : theme.fg("muted", "☐");
|
|
1087
|
+
const amendLine = ` ${amendBox} Amend previous commit`;
|
|
1088
|
+
rows.push({
|
|
1089
|
+
text: isSelected(amendTarget) && this.focused ? `${withBg(amendLine, selectionBgAnsi())}\x1b[0m` : amendLine,
|
|
1090
|
+
target: amendTarget,
|
|
1091
|
+
});
|
|
1092
|
+
|
|
1093
|
+
const summaryTarget: Target = { kind: "summary" };
|
|
1094
|
+
const summaryLen = this.summary.getValue().length;
|
|
1095
|
+
const counter = theme.fg(summaryLen > SUMMARY_LIMIT ? "warning" : "dim", String(SUMMARY_LIMIT - summaryLen));
|
|
1096
|
+
const summaryLabel = theme.fg("muted", "Commit summary");
|
|
1097
|
+
rows.push({
|
|
1098
|
+
text: ` ${summaryLabel}${" ".repeat(Math.max(1, width - 2 - visibleWidth(summaryLabel) - visibleWidth(counter)))}${counter}`,
|
|
1099
|
+
});
|
|
1100
|
+
const summaryLine = this.summary.render(width - 4)[0] ?? "";
|
|
1101
|
+
const summaryBar = isSelected(summaryTarget) ? theme.fg("accent", "▎") : theme.fg("borderMuted", "▏");
|
|
1102
|
+
rows.push({ text: ` ${summaryBar}${summaryLine}`, target: summaryTarget });
|
|
1103
|
+
|
|
1104
|
+
const descriptionTarget: Target = { kind: "description" };
|
|
1105
|
+
const descriptionLines = this.#descriptionField.render(width - 4);
|
|
1106
|
+
const descriptionBar = isSelected(descriptionTarget) ? theme.fg("accent", "▎") : theme.fg("borderMuted", "▏");
|
|
1107
|
+
if (this.description.getText().length === 0 && !this.#descriptionField.focused) {
|
|
1108
|
+
rows.push({ text: ` ${descriptionBar}${theme.fg("dim", "Description")}`, target: descriptionTarget });
|
|
1109
|
+
} else {
|
|
1110
|
+
for (const line of descriptionLines.length > 0 ? descriptionLines : [""]) {
|
|
1111
|
+
rows.push({ text: ` ${descriptionBar}${line}`, target: descriptionTarget });
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
rows.push({ text: "" });
|
|
1115
|
+
|
|
1116
|
+
const commitTarget: Target = { kind: "commit-button" };
|
|
1117
|
+
const hasChanges = this.#model.staged.length > 0 || this.#model.unstaged.length > 0 || this.amend;
|
|
1118
|
+
const summary = this.summary.getValue().trim();
|
|
1119
|
+
const description = this.description.getText().trim();
|
|
1120
|
+
const canActivate = hasChanges && !this.generating && (summary.length > 0 || description.length === 0);
|
|
1121
|
+
const label = this.generating
|
|
1122
|
+
? "-○- Generating commit message"
|
|
1123
|
+
: this.#model.staged.length > 0
|
|
1124
|
+
? "-○- Commit staged changes"
|
|
1125
|
+
: "-○- Stage all & commit";
|
|
1126
|
+
const pad = Math.max(0, Math.floor((width - 4 - visibleWidth(label)) / 2));
|
|
1127
|
+
const inner = `${" ".repeat(pad)}${label}${" ".repeat(pad)}`;
|
|
1128
|
+
const button = pill(inner, theme.getColorHex("accent"), {
|
|
1129
|
+
dim: !canActivate,
|
|
1130
|
+
selected: canActivate && isSelected(commitTarget) && this.focused,
|
|
1131
|
+
});
|
|
1132
|
+
rows.push({ text: ` ${button}`, target: commitTarget });
|
|
1133
|
+
return rows;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
#commitViewRows(width: number): Row[] {
|
|
1137
|
+
const rows: Row[] = [];
|
|
1138
|
+
const head = this.#model.headCommit;
|
|
1139
|
+
if (!head) {
|
|
1140
|
+
rows.push({ text: "" }, { text: theme.fg("dim", " No commits yet") });
|
|
1141
|
+
return rows;
|
|
1142
|
+
}
|
|
1143
|
+
for (const line of Bun.wrapAnsi(theme.bold(head.subject), width - 2).split("\n")) {
|
|
1144
|
+
rows.push({ text: ` ${line}` });
|
|
1145
|
+
}
|
|
1146
|
+
if (head.body) {
|
|
1147
|
+
rows.push({ text: "" });
|
|
1148
|
+
const bodyLines = Bun.wrapAnsi(head.body, width - 2)
|
|
1149
|
+
.split("\n")
|
|
1150
|
+
.slice(0, 8);
|
|
1151
|
+
for (const line of bodyLines) rows.push({ text: theme.fg("muted", ` ${line}`) });
|
|
1152
|
+
}
|
|
1153
|
+
rows.push({ text: "" });
|
|
1154
|
+
|
|
1155
|
+
for (const line of this.#avatarRows(head.authorEmail)) rows.push({ text: ` ${line}` });
|
|
1156
|
+
rows.push({ text: ` ${theme.bold(head.authorName)} ${theme.fg("dim", `<${head.authorEmail}>`)}` });
|
|
1157
|
+
const when = head.authorDate ? new Date(head.authorDate) : null;
|
|
1158
|
+
if (when && !Number.isNaN(when.getTime())) {
|
|
1159
|
+
rows.push({ text: theme.fg("dim", ` authored ${when.toLocaleString()}`) });
|
|
1160
|
+
}
|
|
1161
|
+
if (head.parents.length > 0) {
|
|
1162
|
+
rows.push({
|
|
1163
|
+
text: ` ${theme.fg("dim", "parent:")} ${theme.fg("accent", head.parents.map(sha => sha.slice(0, 8)).join(" "))}`,
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
rows.push({ text: theme.fg("borderMuted", "─".repeat(Math.max(0, width))) });
|
|
1167
|
+
if (!head.filesLoaded) {
|
|
1168
|
+
rows.push({ text: theme.fg("dim", " Loading changed files…") });
|
|
1169
|
+
return rows;
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
const additions = head.files.reduce((sum, file) => sum + (file.additions ?? 0), 0);
|
|
1173
|
+
const deletions = head.files.reduce((sum, file) => sum + (file.deletions ?? 0), 0);
|
|
1174
|
+
rows.push({
|
|
1175
|
+
text: ` ${theme.bold(`${head.files.length} modified`)} ${theme.fg("success", `+${additions}`)} ${theme.fg("error", `−${deletions}`)} ${theme.fg("dim", `· ${head.shortSha}`)}`,
|
|
1176
|
+
});
|
|
1177
|
+
rows.push(this.#viewToggleRow(width));
|
|
1178
|
+
rows.push(...this.#entryRows(head.files, "commit"));
|
|
1179
|
+
return rows;
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
#avatarRows(email: string): string[] {
|
|
1183
|
+
const identicon = (): string[] =>
|
|
1184
|
+
identiconLines(email, (hex, text) => {
|
|
1185
|
+
const value = Number.parseInt(hex.replace("#", ""), 16);
|
|
1186
|
+
return `\x1b[38;2;${(value >> 16) & 0xff};${(value >> 8) & 0xff};${value & 0xff}m${text}\x1b[0m`;
|
|
1187
|
+
});
|
|
1188
|
+
if (!TERMINAL.imageProtocol) return identicon();
|
|
1189
|
+
const png = this.#avatars.get(email, this.#model.cwd);
|
|
1190
|
+
if (png === null || png === undefined) return identicon();
|
|
1191
|
+
if (this.#avatarImage?.email !== email) {
|
|
1192
|
+
this.#avatarImage = {
|
|
1193
|
+
email,
|
|
1194
|
+
image: new Image(
|
|
1195
|
+
png,
|
|
1196
|
+
"image/png",
|
|
1197
|
+
{ fallbackColor: text => theme.fg("dim", text) },
|
|
1198
|
+
{ maxHeightCells: 3, budget: this.#imageBudget, imageKey: `git-avatar:${email}` },
|
|
1199
|
+
),
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
return [...this.#avatarImage.image.render(this.#lastWidth - 2)];
|
|
1203
|
+
}
|
|
1204
|
+
}
|