pi-ui-extend 0.1.1
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/README.md +307 -0
- package/bin/pix.mjs +219 -0
- package/dist/app/app.d.ts +96 -0
- package/dist/app/app.js +871 -0
- package/dist/app/blink-controller.d.ts +23 -0
- package/dist/app/blink-controller.js +82 -0
- package/dist/app/cli.d.ts +8 -0
- package/dist/app/cli.js +83 -0
- package/dist/app/clipboard.d.ts +1 -0
- package/dist/app/clipboard.js +24 -0
- package/dist/app/command-controller.d.ts +18 -0
- package/dist/app/command-controller.js +58 -0
- package/dist/app/command-host.d.ts +44 -0
- package/dist/app/command-host.js +1 -0
- package/dist/app/command-model-actions.d.ts +12 -0
- package/dist/app/command-model-actions.js +176 -0
- package/dist/app/command-navigation-actions.d.ts +19 -0
- package/dist/app/command-navigation-actions.js +267 -0
- package/dist/app/command-registry.d.ts +32 -0
- package/dist/app/command-registry.js +225 -0
- package/dist/app/command-runtime.d.ts +5 -0
- package/dist/app/command-runtime.js +32 -0
- package/dist/app/command-session-actions.d.ts +20 -0
- package/dist/app/command-session-actions.js +295 -0
- package/dist/app/constants.d.ts +52 -0
- package/dist/app/constants.js +103 -0
- package/dist/app/conversation-entry-renderer.d.ts +21 -0
- package/dist/app/conversation-entry-renderer.js +81 -0
- package/dist/app/conversation-shell-renderer.d.ts +5 -0
- package/dist/app/conversation-shell-renderer.js +43 -0
- package/dist/app/conversation-tool-renderer.d.ts +16 -0
- package/dist/app/conversation-tool-renderer.js +216 -0
- package/dist/app/conversation-viewport.d.ts +55 -0
- package/dist/app/conversation-viewport.js +252 -0
- package/dist/app/dcp-stats.d.ts +2 -0
- package/dist/app/dcp-stats.js +116 -0
- package/dist/app/editor-layout-renderer.d.ts +31 -0
- package/dist/app/editor-layout-renderer.js +211 -0
- package/dist/app/editor-panels.d.ts +4 -0
- package/dist/app/editor-panels.js +130 -0
- package/dist/app/extension-actions-controller.d.ts +22 -0
- package/dist/app/extension-actions-controller.js +60 -0
- package/dist/app/extension-event-bus.d.ts +3 -0
- package/dist/app/extension-event-bus.js +23 -0
- package/dist/app/extension-ui-controller.d.ts +57 -0
- package/dist/app/extension-ui-controller.js +532 -0
- package/dist/app/file-link-opener.d.ts +2 -0
- package/dist/app/file-link-opener.js +66 -0
- package/dist/app/file-links.d.ts +10 -0
- package/dist/app/file-links.js +117 -0
- package/dist/app/guards.d.ts +3 -0
- package/dist/app/guards.js +9 -0
- package/dist/app/icons.d.ts +37 -0
- package/dist/app/icons.js +97 -0
- package/dist/app/id.d.ts +1 -0
- package/dist/app/id.js +4 -0
- package/dist/app/image-click-targets.d.ts +5 -0
- package/dist/app/image-click-targets.js +32 -0
- package/dist/app/image-opener.d.ts +2 -0
- package/dist/app/image-opener.js +64 -0
- package/dist/app/input-action-controller.d.ts +47 -0
- package/dist/app/input-action-controller.js +209 -0
- package/dist/app/input-controller.d.ts +60 -0
- package/dist/app/input-controller.js +425 -0
- package/dist/app/input-paste-handler.d.ts +27 -0
- package/dist/app/input-paste-handler.js +146 -0
- package/dist/app/menu-items-controller.d.ts +32 -0
- package/dist/app/menu-items-controller.js +182 -0
- package/dist/app/message-content.d.ts +8 -0
- package/dist/app/message-content.js +115 -0
- package/dist/app/model-ref.d.ts +13 -0
- package/dist/app/model-ref.js +50 -0
- package/dist/app/model-usage-controller.d.ts +35 -0
- package/dist/app/model-usage-controller.js +99 -0
- package/dist/app/model-usage-status.d.ts +125 -0
- package/dist/app/model-usage-status.js +749 -0
- package/dist/app/mouse-controller.d.ts +182 -0
- package/dist/app/mouse-controller.js +968 -0
- package/dist/app/native-modifiers.d.ts +3 -0
- package/dist/app/native-modifiers.js +60 -0
- package/dist/app/nerd-font-controller.d.ts +11 -0
- package/dist/app/nerd-font-controller.js +90 -0
- package/dist/app/popup-action-controller.d.ts +44 -0
- package/dist/app/popup-action-controller.js +278 -0
- package/dist/app/popup-menu-controller.d.ts +183 -0
- package/dist/app/popup-menu-controller.js +1070 -0
- package/dist/app/prompt-enhancer-controller.d.ts +40 -0
- package/dist/app/prompt-enhancer-controller.js +215 -0
- package/dist/app/queued-message-controller.d.ts +62 -0
- package/dist/app/queued-message-controller.js +377 -0
- package/dist/app/render-controller.d.ts +41 -0
- package/dist/app/render-controller.js +378 -0
- package/dist/app/render-text.d.ts +19 -0
- package/dist/app/render-text.js +67 -0
- package/dist/app/request-history.d.ts +23 -0
- package/dist/app/request-history.js +131 -0
- package/dist/app/runtime.d.ts +39 -0
- package/dist/app/runtime.js +195 -0
- package/dist/app/screen-selection.d.ts +6 -0
- package/dist/app/screen-selection.js +9 -0
- package/dist/app/screen-styler.d.ts +34 -0
- package/dist/app/screen-styler.js +168 -0
- package/dist/app/scroll-controller.d.ts +51 -0
- package/dist/app/scroll-controller.js +207 -0
- package/dist/app/session-event-controller.d.ts +69 -0
- package/dist/app/session-event-controller.js +338 -0
- package/dist/app/session-history.d.ts +23 -0
- package/dist/app/session-history.js +164 -0
- package/dist/app/session-lifecycle-controller.d.ts +55 -0
- package/dist/app/session-lifecycle-controller.js +116 -0
- package/dist/app/session-search.d.ts +24 -0
- package/dist/app/session-search.js +215 -0
- package/dist/app/shell-command.d.ts +27 -0
- package/dist/app/shell-command.js +176 -0
- package/dist/app/shell-controller.d.ts +28 -0
- package/dist/app/shell-controller.js +124 -0
- package/dist/app/slash-commands.d.ts +6 -0
- package/dist/app/slash-commands.js +75 -0
- package/dist/app/startup-checks.d.ts +8 -0
- package/dist/app/startup-checks.js +59 -0
- package/dist/app/startup-info.d.ts +3 -0
- package/dist/app/startup-info.js +176 -0
- package/dist/app/status-controller.d.ts +35 -0
- package/dist/app/status-controller.js +105 -0
- package/dist/app/status-line-renderer.d.ts +68 -0
- package/dist/app/status-line-renderer.js +453 -0
- package/dist/app/subagents-files.d.ts +10 -0
- package/dist/app/subagents-files.js +193 -0
- package/dist/app/subagents-model.d.ts +23 -0
- package/dist/app/subagents-model.js +224 -0
- package/dist/app/subagents-widget-controller.d.ts +43 -0
- package/dist/app/subagents-widget-controller.js +311 -0
- package/dist/app/tab-line-renderer.d.ts +26 -0
- package/dist/app/tab-line-renderer.js +222 -0
- package/dist/app/tabs-controller.d.ts +100 -0
- package/dist/app/tabs-controller.js +885 -0
- package/dist/app/terminal-controller.d.ts +40 -0
- package/dist/app/terminal-controller.js +135 -0
- package/dist/app/terminal-edit-shortcuts.d.ts +23 -0
- package/dist/app/terminal-edit-shortcuts.js +138 -0
- package/dist/app/terminal-output-buffer.d.ts +20 -0
- package/dist/app/terminal-output-buffer.js +52 -0
- package/dist/app/toast-controller.d.ts +13 -0
- package/dist/app/toast-controller.js +40 -0
- package/dist/app/toast-renderer.d.ts +9 -0
- package/dist/app/toast-renderer.js +79 -0
- package/dist/app/todo-model.d.ts +22 -0
- package/dist/app/todo-model.js +179 -0
- package/dist/app/todo-widget-controller.d.ts +21 -0
- package/dist/app/todo-widget-controller.js +59 -0
- package/dist/app/tool-block-renderer.d.ts +26 -0
- package/dist/app/tool-block-renderer.js +439 -0
- package/dist/app/types.d.ts +550 -0
- package/dist/app/types.js +1 -0
- package/dist/app/update.d.ts +36 -0
- package/dist/app/update.js +315 -0
- package/dist/app/voice-controller.d.ts +52 -0
- package/dist/app/voice-controller.js +600 -0
- package/dist/app/workspace-actions-controller.d.ts +40 -0
- package/dist/app/workspace-actions-controller.js +215 -0
- package/dist/app/workspace-undo.d.ts +44 -0
- package/dist/app/workspace-undo.js +215 -0
- package/dist/config.d.ts +62 -0
- package/dist/config.js +527 -0
- package/dist/context-progress-bar.d.ts +17 -0
- package/dist/context-progress-bar.js +48 -0
- package/dist/default-pix-config.d.ts +1 -0
- package/dist/default-pix-config.js +375 -0
- package/dist/fuzzy.d.ts +23 -0
- package/dist/fuzzy.js +165 -0
- package/dist/input-editor-files.d.ts +15 -0
- package/dist/input-editor-files.js +62 -0
- package/dist/input-editor.d.ts +186 -0
- package/dist/input-editor.js +835 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +12 -0
- package/dist/markdown-format.d.ts +22 -0
- package/dist/markdown-format.js +542 -0
- package/dist/sdk.d.ts +3 -0
- package/dist/sdk.js +1 -0
- package/dist/syntax-highlight.d.ts +22 -0
- package/dist/syntax-highlight.js +528 -0
- package/dist/terminal-width.d.ts +6 -0
- package/dist/terminal-width.js +245 -0
- package/dist/theme.d.ts +56 -0
- package/dist/theme.js +118 -0
- package/dist/tool-renderers/apply-patch.d.ts +2 -0
- package/dist/tool-renderers/apply-patch.js +36 -0
- package/dist/tool-renderers/ast.d.ts +2 -0
- package/dist/tool-renderers/ast.js +5 -0
- package/dist/tool-renderers/compress.d.ts +2 -0
- package/dist/tool-renderers/compress.js +126 -0
- package/dist/tool-renderers/index.d.ts +3 -0
- package/dist/tool-renderers/index.js +44 -0
- package/dist/tool-renderers/question.d.ts +2 -0
- package/dist/tool-renderers/question.js +88 -0
- package/dist/tool-renderers/read.d.ts +2 -0
- package/dist/tool-renderers/read.js +36 -0
- package/dist/tool-renderers/repo.d.ts +2 -0
- package/dist/tool-renderers/repo.js +13 -0
- package/dist/tool-renderers/shell.d.ts +3 -0
- package/dist/tool-renderers/shell.js +27 -0
- package/dist/tool-renderers/skill.d.ts +2 -0
- package/dist/tool-renderers/skill.js +132 -0
- package/dist/tool-renderers/subagents.d.ts +2 -0
- package/dist/tool-renderers/subagents.js +51 -0
- package/dist/tool-renderers/todo.d.ts +2 -0
- package/dist/tool-renderers/todo.js +9 -0
- package/dist/tool-renderers/types.d.ts +42 -0
- package/dist/tool-renderers/types.js +1 -0
- package/dist/tool-renderers/utils.d.ts +31 -0
- package/dist/tool-renderers/utils.js +230 -0
- package/dist/tool-renderers/web.d.ts +3 -0
- package/dist/tool-renderers/web.js +9 -0
- package/dist/tool-renderers/write.d.ts +2 -0
- package/dist/tool-renderers/write.js +42 -0
- package/dist/ui.d.ts +56 -0
- package/dist/ui.js +94 -0
- package/docs/release.md +81 -0
- package/extensions/question/contract.ts +100 -0
- package/extensions/question/index.ts +34 -0
- package/extensions/question/render.ts +28 -0
- package/extensions/question/result.ts +86 -0
- package/extensions/question/tool-description.ts +11 -0
- package/extensions/question/tui.ts +629 -0
- package/extensions/question/types.ts +123 -0
- package/extensions/session-title/config.ts +169 -0
- package/extensions/session-title/index.ts +459 -0
- package/extensions/terminal-bell/index.ts +315 -0
- package/external/pi-tools-suite/README.md +242 -0
- package/external/pi-tools-suite/index.ts +1 -0
- package/external/pi-tools-suite/licenses/ollama-pi-web-search.MIT +21 -0
- package/external/pi-tools-suite/licenses/opencode-mystatus-MIT.txt +21 -0
- package/external/pi-tools-suite/package.json +53 -0
- package/external/pi-tools-suite/src/antigravity-auth/auth-store.ts +194 -0
- package/external/pi-tools-suite/src/antigravity-auth/commands.ts +80 -0
- package/external/pi-tools-suite/src/antigravity-auth/constants.ts +26 -0
- package/external/pi-tools-suite/src/antigravity-auth/headers.ts +20 -0
- package/external/pi-tools-suite/src/antigravity-auth/index.ts +104 -0
- package/external/pi-tools-suite/src/antigravity-auth/models.ts +86 -0
- package/external/pi-tools-suite/src/antigravity-auth/oauth.ts +305 -0
- package/external/pi-tools-suite/src/antigravity-auth/payload.ts +423 -0
- package/external/pi-tools-suite/src/antigravity-auth/status.ts +78 -0
- package/external/pi-tools-suite/src/antigravity-auth/stream.ts +302 -0
- package/external/pi-tools-suite/src/antigravity-auth/types.ts +113 -0
- package/external/pi-tools-suite/src/ast-grep/index.ts +6 -0
- package/external/pi-tools-suite/src/ast-grep/render.ts +70 -0
- package/external/pi-tools-suite/src/ast-grep/schema.ts +109 -0
- package/external/pi-tools-suite/src/ast-grep/tool.ts +345 -0
- package/external/pi-tools-suite/src/ast-grep/types.ts +55 -0
- package/external/pi-tools-suite/src/ast-grep/utils.ts +65 -0
- package/external/pi-tools-suite/src/async-subagents/async-subagents.sample.jsonc +222 -0
- package/external/pi-tools-suite/src/async-subagents/commands.ts +518 -0
- package/external/pi-tools-suite/src/async-subagents/constants.ts +11 -0
- package/external/pi-tools-suite/src/async-subagents/core/agent-strategy.ts +74 -0
- package/external/pi-tools-suite/src/async-subagents/core/attachment-bridge.ts +133 -0
- package/external/pi-tools-suite/src/async-subagents/core/cleanup.ts +66 -0
- package/external/pi-tools-suite/src/async-subagents/core/concurrency.ts +90 -0
- package/external/pi-tools-suite/src/async-subagents/core/config.ts +819 -0
- package/external/pi-tools-suite/src/async-subagents/core/log-limits.ts +166 -0
- package/external/pi-tools-suite/src/async-subagents/core/model-fallback.ts +133 -0
- package/external/pi-tools-suite/src/async-subagents/core/paths.ts +47 -0
- package/external/pi-tools-suite/src/async-subagents/core/pi-invocation.ts +35 -0
- package/external/pi-tools-suite/src/async-subagents/core/presets.ts +67 -0
- package/external/pi-tools-suite/src/async-subagents/core/process.ts +15 -0
- package/external/pi-tools-suite/src/async-subagents/core/prompt.ts +66 -0
- package/external/pi-tools-suite/src/async-subagents/core/registry.ts +224 -0
- package/external/pi-tools-suite/src/async-subagents/core/retry.ts +191 -0
- package/external/pi-tools-suite/src/async-subagents/core/routing.ts +259 -0
- package/external/pi-tools-suite/src/async-subagents/core/sessions.ts +138 -0
- package/external/pi-tools-suite/src/async-subagents/core/spawn.ts +688 -0
- package/external/pi-tools-suite/src/async-subagents/core/state.ts +281 -0
- package/external/pi-tools-suite/src/async-subagents/core/stop.ts +131 -0
- package/external/pi-tools-suite/src/async-subagents/core/structured-result.ts +237 -0
- package/external/pi-tools-suite/src/async-subagents/core/tool-guard.ts +34 -0
- package/external/pi-tools-suite/src/async-subagents/core/types.ts +150 -0
- package/external/pi-tools-suite/src/async-subagents/core/ultrawork-auto.ts +184 -0
- package/external/pi-tools-suite/src/async-subagents/core/utils.ts +11 -0
- package/external/pi-tools-suite/src/async-subagents/format.ts +41 -0
- package/external/pi-tools-suite/src/async-subagents/index.ts +422 -0
- package/external/pi-tools-suite/src/async-subagents/lib.ts +88 -0
- package/external/pi-tools-suite/src/async-subagents/live.ts +10 -0
- package/external/pi-tools-suite/src/async-subagents/polling.ts +83 -0
- package/external/pi-tools-suite/src/async-subagents/render.ts +230 -0
- package/external/pi-tools-suite/src/async-subagents/subagent-overlay.ts +77 -0
- package/external/pi-tools-suite/src/async-subagents/tasks.ts +120 -0
- package/external/pi-tools-suite/src/async-subagents/tools/cleanup.ts +99 -0
- package/external/pi-tools-suite/src/async-subagents/tools/result.ts +179 -0
- package/external/pi-tools-suite/src/async-subagents/tools/spawn.ts +372 -0
- package/external/pi-tools-suite/src/async-subagents/tools/status.ts +60 -0
- package/external/pi-tools-suite/src/async-subagents/tools/stop.ts +79 -0
- package/external/pi-tools-suite/src/async-subagents/tools/subagents.ts +152 -0
- package/external/pi-tools-suite/src/async-subagents/tools/wait.ts +67 -0
- package/external/pi-tools-suite/src/async-subagents/types.ts +45 -0
- package/external/pi-tools-suite/src/async-subagents/ui.ts +5 -0
- package/external/pi-tools-suite/src/compress/commands.ts +440 -0
- package/external/pi-tools-suite/src/compress/compress-tool.ts +368 -0
- package/external/pi-tools-suite/src/compress/compression-blocks.ts +524 -0
- package/external/pi-tools-suite/src/compress/config.ts +310 -0
- package/external/pi-tools-suite/src/compress/dcp-tui-filter.ts +498 -0
- package/external/pi-tools-suite/src/compress/index.ts +397 -0
- package/external/pi-tools-suite/src/compress/prompts.ts +269 -0
- package/external/pi-tools-suite/src/compress/pruner-candidates.ts +176 -0
- package/external/pi-tools-suite/src/compress/pruner-compression-blocks.ts +260 -0
- package/external/pi-tools-suite/src/compress/pruner-message-ids.ts +147 -0
- package/external/pi-tools-suite/src/compress/pruner-metadata.ts +268 -0
- package/external/pi-tools-suite/src/compress/pruner-nudge.ts +315 -0
- package/external/pi-tools-suite/src/compress/pruner-tools.ts +263 -0
- package/external/pi-tools-suite/src/compress/pruner-types.ts +25 -0
- package/external/pi-tools-suite/src/compress/pruner.ts +92 -0
- package/external/pi-tools-suite/src/compress/state.ts +486 -0
- package/external/pi-tools-suite/src/compress/ui.ts +308 -0
- package/external/pi-tools-suite/src/config.ts +176 -0
- package/external/pi-tools-suite/src/context-usage.ts +31 -0
- package/external/pi-tools-suite/src/default-pi-tools-suite-config.ts +355 -0
- package/external/pi-tools-suite/src/index.ts +46 -0
- package/external/pi-tools-suite/src/lib/lsp.ts +62 -0
- package/external/pi-tools-suite/src/lib/project.ts +42 -0
- package/external/pi-tools-suite/src/lib/tool-args.ts +137 -0
- package/external/pi-tools-suite/src/lsp/_shared/config.ts +156 -0
- package/external/pi-tools-suite/src/lsp/_shared/glob.ts +60 -0
- package/external/pi-tools-suite/src/lsp/_shared/output.ts +102 -0
- package/external/pi-tools-suite/src/lsp/_shared/paths.ts +138 -0
- package/external/pi-tools-suite/src/lsp/_shared/runner.ts +64 -0
- package/external/pi-tools-suite/src/lsp/_shared/template.ts +23 -0
- package/external/pi-tools-suite/src/lsp/_shared/trust.ts +116 -0
- package/external/pi-tools-suite/src/lsp/_shared/types.ts +98 -0
- package/external/pi-tools-suite/src/lsp/async.ts +29 -0
- package/external/pi-tools-suite/src/lsp/child-process.ts +81 -0
- package/external/pi-tools-suite/src/lsp/client.ts +340 -0
- package/external/pi-tools-suite/src/lsp/constants.ts +9 -0
- package/external/pi-tools-suite/src/lsp/diagnostics-store.ts +64 -0
- package/external/pi-tools-suite/src/lsp/documents.ts +24 -0
- package/external/pi-tools-suite/src/lsp/index.ts +31 -0
- package/external/pi-tools-suite/src/lsp/lsp-utils.ts +37 -0
- package/external/pi-tools-suite/src/lsp/manager.ts +190 -0
- package/external/pi-tools-suite/src/lsp/mutation-events.ts +78 -0
- package/external/pi-tools-suite/src/lsp/renderer.ts +1 -0
- package/external/pi-tools-suite/src/lsp/tool-result.ts +6 -0
- package/external/pi-tools-suite/src/lsp/tsserver.ts +107 -0
- package/external/pi-tools-suite/src/lsp/types.ts +15 -0
- package/external/pi-tools-suite/src/model-tools/apply-patch.ts +590 -0
- package/external/pi-tools-suite/src/model-tools/index.ts +430 -0
- package/external/pi-tools-suite/src/model-tools/path-utils.ts +6 -0
- package/external/pi-tools-suite/src/model-tools/tool-args.ts +11 -0
- package/external/pi-tools-suite/src/prompt-commands/index.ts +349 -0
- package/external/pi-tools-suite/src/repo-discovery/index.ts +384 -0
- package/external/pi-tools-suite/src/repo-discovery/project.ts +7 -0
- package/external/pi-tools-suite/src/startup-section.ts +13 -0
- package/external/pi-tools-suite/src/terminal-bell/index.ts +309 -0
- package/external/pi-tools-suite/src/todo/index.ts +201 -0
- package/external/pi-tools-suite/src/todo/state/auto-clear.ts +13 -0
- package/external/pi-tools-suite/src/todo/state/invariants.ts +21 -0
- package/external/pi-tools-suite/src/todo/state/persistence.ts +94 -0
- package/external/pi-tools-suite/src/todo/state/replay.ts +38 -0
- package/external/pi-tools-suite/src/todo/state/selectors.ts +49 -0
- package/external/pi-tools-suite/src/todo/state/state-reducer.ts +362 -0
- package/external/pi-tools-suite/src/todo/state/state.ts +18 -0
- package/external/pi-tools-suite/src/todo/state/store.ts +52 -0
- package/external/pi-tools-suite/src/todo/state/task-graph.ts +57 -0
- package/external/pi-tools-suite/src/todo/todo.ts +487 -0
- package/external/pi-tools-suite/src/todo/tool/response-envelope.ts +143 -0
- package/external/pi-tools-suite/src/todo/tool/types.ts +188 -0
- package/external/pi-tools-suite/src/todo/view/format.ts +18 -0
- package/external/pi-tools-suite/src/todo/view/labels.ts +13 -0
- package/external/pi-tools-suite/src/tool-descriptions.ts +369 -0
- package/external/pi-tools-suite/src/usage/index.ts +152 -0
- package/external/pi-tools-suite/src/usage/lib/copilot.ts +535 -0
- package/external/pi-tools-suite/src/usage/lib/google.ts +478 -0
- package/external/pi-tools-suite/src/usage/lib/openai.ts +268 -0
- package/external/pi-tools-suite/src/usage/lib/types.ts +114 -0
- package/external/pi-tools-suite/src/usage/lib/utils.ts +134 -0
- package/external/pi-tools-suite/src/usage/lib/zhipu.ts +228 -0
- package/external/pi-tools-suite/src/web-search/index.ts +397 -0
- package/package.json +89 -0
- package/skills/context7/SKILL.md +69 -0
- package/skills/context7/scripts/context7.sh +73 -0
- package/skills/handoff/SKILL.md +15 -0
- package/skills/pdf/LICENSE.txt +30 -0
- package/skills/pdf/SKILL.md +314 -0
- package/skills/pdf/forms.md +294 -0
- package/skills/pdf/reference.md +612 -0
- package/skills/pdf/scripts/check_bounding_boxes.py +65 -0
- package/skills/pdf/scripts/check_fillable_fields.py +11 -0
- package/skills/pdf/scripts/convert_pdf_to_images.py +33 -0
- package/skills/pdf/scripts/create_validation_image.py +37 -0
- package/skills/pdf/scripts/extract_form_field_info.py +122 -0
- package/skills/pdf/scripts/extract_form_structure.py +115 -0
- package/skills/pdf/scripts/fill_fillable_fields.py +98 -0
- package/skills/pdf/scripts/fill_pdf_form_with_annotations.py +107 -0
- package/skills/playwright-cli/SKILL.md +388 -0
- package/skills/playwright-cli/references/element-attributes.md +23 -0
- package/skills/playwright-cli/references/playwright-tests.md +39 -0
- package/skills/playwright-cli/references/request-mocking.md +87 -0
- package/skills/playwright-cli/references/running-code.md +241 -0
- package/skills/playwright-cli/references/session-management.md +225 -0
- package/skills/playwright-cli/references/spec-driven-testing.md +305 -0
- package/skills/playwright-cli/references/storage-state.md +275 -0
- package/skills/playwright-cli/references/test-generation.md +134 -0
- package/skills/playwright-cli/references/tracing.md +139 -0
- package/skills/playwright-cli/references/video-recording.md +143 -0
- package/skills/simplify/SKILL.md +51 -0
- package/skills/skill-creator/LICENSE.txt +202 -0
- package/skills/skill-creator/SKILL.md +485 -0
- package/skills/skill-creator/agents/analyzer.md +274 -0
- package/skills/skill-creator/agents/comparator.md +202 -0
- package/skills/skill-creator/agents/grader.md +223 -0
- package/skills/skill-creator/assets/eval_review.html +146 -0
- package/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/skills/skill-creator/references/schemas.md +430 -0
- package/skills/skill-creator/scripts/__init__.py +0 -0
- package/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/skills/skill-creator/scripts/generate_report.py +326 -0
- package/skills/skill-creator/scripts/improve_description.py +247 -0
- package/skills/skill-creator/scripts/package_skill.py +136 -0
- package/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/skills/skill-creator/scripts/run_eval.py +310 -0
- package/skills/skill-creator/scripts/run_loop.py +328 -0
- package/skills/skill-creator/scripts/utils.py +47 -0
|
@@ -0,0 +1,968 @@
|
|
|
1
|
+
import { copyTextToClipboard } from "./clipboard.js";
|
|
2
|
+
import { stringifyUnknown } from "./message-content.js";
|
|
3
|
+
import { horizontalPaddingLayout } from "./render-text.js";
|
|
4
|
+
import { orderedSelection, samePoint } from "./screen-selection.js";
|
|
5
|
+
import { openImageContent as openSystemImageContent } from "./image-opener.js";
|
|
6
|
+
import { stringDisplayWidth } from "../terminal-width.js";
|
|
7
|
+
import { formatDcpStatsToast } from "./dcp-stats.js";
|
|
8
|
+
import { detectFileLinks } from "./file-links.js";
|
|
9
|
+
import { openFileLink as openDetectedFileLink } from "./file-link-opener.js";
|
|
10
|
+
const CLICK_FLASH_MS = 100;
|
|
11
|
+
export class AppMouseController {
|
|
12
|
+
host;
|
|
13
|
+
popupMenus;
|
|
14
|
+
popupActions;
|
|
15
|
+
scrollController;
|
|
16
|
+
commandController;
|
|
17
|
+
renderedTargets = new Map();
|
|
18
|
+
renderedRowTexts = new Map();
|
|
19
|
+
renderedRowBackgrounds = new Map();
|
|
20
|
+
renderedImageTargets = new Map();
|
|
21
|
+
statusModelTarget;
|
|
22
|
+
statusThinkingTarget;
|
|
23
|
+
statusContextTarget;
|
|
24
|
+
statusModelUsageTarget;
|
|
25
|
+
statusUserJumpTarget;
|
|
26
|
+
statusThinkingExpandTarget;
|
|
27
|
+
statusCompactToolsTarget;
|
|
28
|
+
statusSessionTarget;
|
|
29
|
+
statusPromptEnhancerTarget;
|
|
30
|
+
statusVoiceMicTarget;
|
|
31
|
+
statusVoiceLanguageTarget;
|
|
32
|
+
tabLineTargets = [];
|
|
33
|
+
mouseSelection;
|
|
34
|
+
scrollBarDragActive = false;
|
|
35
|
+
inputScrollBarDragActive = false;
|
|
36
|
+
autoScrollTimer;
|
|
37
|
+
autoScrollDirection;
|
|
38
|
+
autoScrollDistance = 0;
|
|
39
|
+
autoScrollAccumulator = 0;
|
|
40
|
+
autoScrollLastTick = 0;
|
|
41
|
+
autoScrollCursorX = 1;
|
|
42
|
+
clickFlash;
|
|
43
|
+
clickFlashTimer;
|
|
44
|
+
clickFlashDirty = false;
|
|
45
|
+
renderedConversationFrame;
|
|
46
|
+
constructor(host, popupMenus, popupActions, scrollController, commandController) {
|
|
47
|
+
this.host = host;
|
|
48
|
+
this.popupMenus = popupMenus;
|
|
49
|
+
this.popupActions = popupActions;
|
|
50
|
+
this.scrollController = scrollController;
|
|
51
|
+
this.commandController = commandController;
|
|
52
|
+
}
|
|
53
|
+
handleMouse(event) {
|
|
54
|
+
if (this.handleInputScrollBar(event))
|
|
55
|
+
return;
|
|
56
|
+
if (this.handleConversationScrollBar(event))
|
|
57
|
+
return;
|
|
58
|
+
this.showClickFlashOnPress(event);
|
|
59
|
+
if (this.handleMouseSelection(event))
|
|
60
|
+
return;
|
|
61
|
+
if (this.withClickFlash(event, () => this.handleImageClick(event)))
|
|
62
|
+
return;
|
|
63
|
+
if (this.withClickFlash(event, () => this.handleFileLinkClick(event)))
|
|
64
|
+
return;
|
|
65
|
+
if (event.button === 0 && this.withClickFlash(event, () => this.handleTabLineClick(event)))
|
|
66
|
+
return;
|
|
67
|
+
if (event.button === 0 && this.withClickFlash(event, () => this.handleStatusModelClick(event)))
|
|
68
|
+
return;
|
|
69
|
+
if (event.button === 0 && this.withClickFlash(event, () => this.handleStatusThinkingClick(event)))
|
|
70
|
+
return;
|
|
71
|
+
if (event.button === 0 && this.withClickFlash(event, () => this.handleStatusContextClick(event)))
|
|
72
|
+
return;
|
|
73
|
+
if (event.button === 0 && this.withClickFlash(event, () => this.handleStatusModelUsageClick(event)))
|
|
74
|
+
return;
|
|
75
|
+
if (event.button === 0 && this.withClickFlash(event, () => this.handleStatusUserJumpClick(event)))
|
|
76
|
+
return;
|
|
77
|
+
if (event.button === 0 && this.withClickFlash(event, () => this.handleStatusThinkingExpandClick(event)))
|
|
78
|
+
return;
|
|
79
|
+
if (event.button === 0 && this.withClickFlash(event, () => this.handleStatusCompactToolsClick(event)))
|
|
80
|
+
return;
|
|
81
|
+
if (event.button === 0 && this.withClickFlash(event, () => this.handleStatusSessionClick(event)))
|
|
82
|
+
return;
|
|
83
|
+
if (event.button === 0 && this.withClickFlash(event, () => this.handleStatusPromptEnhancerClick(event)))
|
|
84
|
+
return;
|
|
85
|
+
if (event.button === 0 && this.withClickFlash(event, () => this.handleStatusVoiceMicClick(event)))
|
|
86
|
+
return;
|
|
87
|
+
if (event.button === 0 && this.withClickFlash(event, () => this.handleStatusVoiceLanguageClick(event)))
|
|
88
|
+
return;
|
|
89
|
+
if (event.button === 0 && this.withClickFlash(event, () => this.handleExtensionInputClick(event)))
|
|
90
|
+
return;
|
|
91
|
+
if (event.button === 0 && this.withClickFlash(event, () => this.handleInputClick(event)))
|
|
92
|
+
return;
|
|
93
|
+
const target = this.renderedTargets.get(event.y);
|
|
94
|
+
if (event.button === 64) {
|
|
95
|
+
if (target?.kind === "popup-menu") {
|
|
96
|
+
this.popupMenus.scrollActivePopupMenu(-3);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (this.handleInputWheel(event, -3))
|
|
100
|
+
return;
|
|
101
|
+
this.scrollController.scrollByLines(-3);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (event.button === 65) {
|
|
105
|
+
if (target?.kind === "popup-menu") {
|
|
106
|
+
this.popupMenus.scrollActivePopupMenu(3);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (this.handleInputWheel(event, 3))
|
|
110
|
+
return;
|
|
111
|
+
this.scrollController.scrollByLines(3);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (event.button !== 0)
|
|
115
|
+
return;
|
|
116
|
+
if (target?.kind === "toast") {
|
|
117
|
+
if (this.copyErrorToast(target.id)) {
|
|
118
|
+
this.showClickFlashForEvent(event);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
this.host.dismissToast(target.id);
|
|
122
|
+
this.showClickFlashForEvent(event);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (target?.kind === "popup-menu") {
|
|
126
|
+
const activeMenu = this.popupMenus.getActivePopupMenu(this.popupMenus.syncActivePopupMenu() ?? "slash");
|
|
127
|
+
activeMenu.selectedIndex = target.index;
|
|
128
|
+
activeMenu.moveSelection(0);
|
|
129
|
+
void this.popupActions.submitActivePopupMenu();
|
|
130
|
+
this.showClickFlashForEvent(event);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (target?.kind === "popup-menu-close") {
|
|
134
|
+
this.popupMenus.cancelActivePopupMenu();
|
|
135
|
+
this.showClickFlashForEvent(event);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (target?.kind === "todo-panel") {
|
|
139
|
+
this.host.setTodoPanelExpanded(!this.host.getTodoPanelExpanded());
|
|
140
|
+
this.showClickFlashForEvent(event);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (target?.kind === "subagents-panel") {
|
|
144
|
+
this.host.setSubagentsPanelExpanded(!this.host.getSubagentsPanelExpanded());
|
|
145
|
+
this.showClickFlashForEvent(event);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (target?.kind === "user-message") {
|
|
149
|
+
this.openUserMessageMenu(target.id);
|
|
150
|
+
this.showClickFlashForEvent(event);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (target?.kind === "queue-message") {
|
|
154
|
+
this.openQueueMessageMenu(target.id);
|
|
155
|
+
this.showClickFlashForEvent(event);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (target?.kind === "tool") {
|
|
159
|
+
const entry = this.host.findEntry(target.id);
|
|
160
|
+
if (entry?.kind === "tool" || entry?.kind === "thinking" || entry?.kind === "shell") {
|
|
161
|
+
entry.expanded = !entry.expanded;
|
|
162
|
+
this.host.touchEntry(entry);
|
|
163
|
+
this.showClickFlashForEvent(event);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
activeClickFlash() {
|
|
168
|
+
return this.clickFlash;
|
|
169
|
+
}
|
|
170
|
+
consumeClickFlashDirty() {
|
|
171
|
+
const dirty = this.clickFlashDirty;
|
|
172
|
+
this.clickFlashDirty = false;
|
|
173
|
+
return dirty;
|
|
174
|
+
}
|
|
175
|
+
withClickFlash(event, handler) {
|
|
176
|
+
const flash = this.clickFlashForEvent(event);
|
|
177
|
+
if (!handler())
|
|
178
|
+
return false;
|
|
179
|
+
if (!event.released)
|
|
180
|
+
this.showClickFlash(flash);
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
showClickFlashOnPress(event) {
|
|
184
|
+
if (event.released || event.button !== 0)
|
|
185
|
+
return;
|
|
186
|
+
const region = this.clickFlashRegionForEvent(event) ?? this.inputClickFlashRegionForEvent(event);
|
|
187
|
+
if (!region)
|
|
188
|
+
return;
|
|
189
|
+
this.showClickFlash(this.clickFlashForRegion(region));
|
|
190
|
+
}
|
|
191
|
+
showClickFlashForEvent(event) {
|
|
192
|
+
if (event.released)
|
|
193
|
+
return;
|
|
194
|
+
this.showClickFlash(this.clickFlashForEvent(event));
|
|
195
|
+
}
|
|
196
|
+
showClickFlash(flash) {
|
|
197
|
+
if (this.clickFlashTimer)
|
|
198
|
+
clearTimeout(this.clickFlashTimer);
|
|
199
|
+
this.clickFlash = flash;
|
|
200
|
+
this.clickFlashDirty = true;
|
|
201
|
+
this.host.render();
|
|
202
|
+
this.clickFlashTimer = setTimeout(() => {
|
|
203
|
+
this.clickFlash = undefined;
|
|
204
|
+
this.clickFlashTimer = undefined;
|
|
205
|
+
this.clickFlashDirty = true;
|
|
206
|
+
this.host.render();
|
|
207
|
+
}, CLICK_FLASH_MS);
|
|
208
|
+
}
|
|
209
|
+
clickFlashForEvent(event) {
|
|
210
|
+
return this.clickFlashForRegion(this.clickFlashRegionForEvent(event) ?? {
|
|
211
|
+
y: event.y,
|
|
212
|
+
startColumn: event.x,
|
|
213
|
+
endColumn: event.x + 1,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
clickFlashForRegion(region) {
|
|
217
|
+
const normalizedRegion = this.normalizedClickFlashRegion(region);
|
|
218
|
+
const background = this.renderedRowBackgrounds.get(normalizedRegion.y);
|
|
219
|
+
return {
|
|
220
|
+
...normalizedRegion,
|
|
221
|
+
text: displayCellsInColumnRange(this.renderedRowTexts.get(normalizedRegion.y) ?? "", normalizedRegion.startColumn, normalizedRegion.endColumn),
|
|
222
|
+
...(background === undefined ? {} : { background }),
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
clickFlashRegionForEvent(event) {
|
|
226
|
+
const imageTarget = this.imageTargetAt(event);
|
|
227
|
+
if (imageTarget)
|
|
228
|
+
return { y: event.y, startColumn: imageTarget.start + 1, endColumn: imageTarget.end + 1 };
|
|
229
|
+
const link = this.fileLinkAt(event);
|
|
230
|
+
if (link)
|
|
231
|
+
return { y: event.y, startColumn: link.start + 1, endColumn: link.end + 1 };
|
|
232
|
+
const tabTarget = this.tabLineTargetAt(event);
|
|
233
|
+
if (tabTarget)
|
|
234
|
+
return { y: tabTarget.row, startColumn: tabTarget.startColumn, endColumn: tabTarget.endColumn };
|
|
235
|
+
const statusTarget = this.statusTargetAt(event);
|
|
236
|
+
if (statusTarget)
|
|
237
|
+
return statusTarget;
|
|
238
|
+
if (this.renderedTargets.has(event.y)) {
|
|
239
|
+
const bounds = nonBlankLineBounds(this.renderedRowTexts.get(event.y) ?? "", event.x);
|
|
240
|
+
return { y: event.y, startColumn: bounds.startColumn, endColumn: bounds.endColumn };
|
|
241
|
+
}
|
|
242
|
+
return undefined;
|
|
243
|
+
}
|
|
244
|
+
normalizedClickFlashRegion(region) {
|
|
245
|
+
const columns = Math.max(1, this.host.terminalColumns());
|
|
246
|
+
const y = Math.max(1, region.y);
|
|
247
|
+
const startColumn = Math.max(1, Math.min(columns, region.startColumn));
|
|
248
|
+
const endColumn = Math.max(startColumn + 1, Math.min(columns + 1, region.endColumn));
|
|
249
|
+
return { y, startColumn, endColumn };
|
|
250
|
+
}
|
|
251
|
+
inputClickFlashRegionForEvent(event) {
|
|
252
|
+
if (!this.inputGeometry(event))
|
|
253
|
+
return undefined;
|
|
254
|
+
return { y: event.y, startColumn: event.x, endColumn: event.x + 1 };
|
|
255
|
+
}
|
|
256
|
+
imageTargetAt(event) {
|
|
257
|
+
const targets = this.renderedImageTargets.get(event.y);
|
|
258
|
+
return targets?.find((candidate) => event.x >= candidate.start + 1 && event.x <= candidate.end);
|
|
259
|
+
}
|
|
260
|
+
fileLinkAt(event) {
|
|
261
|
+
const text = this.renderedRowTexts.get(event.y);
|
|
262
|
+
if (!text)
|
|
263
|
+
return undefined;
|
|
264
|
+
return detectFileLinks(text, this.host.cwd()).find((candidate) => event.x >= candidate.start + 1 && event.x <= candidate.end);
|
|
265
|
+
}
|
|
266
|
+
statusTargetAt(event) {
|
|
267
|
+
const target = [
|
|
268
|
+
this.statusModelTarget,
|
|
269
|
+
this.statusThinkingTarget,
|
|
270
|
+
this.statusContextTarget,
|
|
271
|
+
this.statusModelUsageTarget,
|
|
272
|
+
this.statusUserJumpTarget,
|
|
273
|
+
this.statusThinkingExpandTarget,
|
|
274
|
+
this.statusCompactToolsTarget,
|
|
275
|
+
this.statusSessionTarget,
|
|
276
|
+
this.statusPromptEnhancerTarget,
|
|
277
|
+
this.statusVoiceMicTarget,
|
|
278
|
+
this.statusVoiceLanguageTarget,
|
|
279
|
+
].find((candidate) => !!candidate
|
|
280
|
+
&& event.y === candidate.row
|
|
281
|
+
&& event.x >= candidate.startColumn
|
|
282
|
+
&& event.x < candidate.endColumn);
|
|
283
|
+
if (!target)
|
|
284
|
+
return undefined;
|
|
285
|
+
return {
|
|
286
|
+
y: target.row,
|
|
287
|
+
startColumn: target.startColumn,
|
|
288
|
+
endColumn: target.endColumn,
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
handleImageClick(event) {
|
|
292
|
+
if (event.button !== 0 || !event.released)
|
|
293
|
+
return false;
|
|
294
|
+
const imageTarget = this.imageTargetAt(event);
|
|
295
|
+
if (!imageTarget)
|
|
296
|
+
return false;
|
|
297
|
+
const entry = this.host.findEntry(imageTarget.entryId);
|
|
298
|
+
const images = entry?.kind === "user" || entry?.kind === "tool" ? entry.images : undefined;
|
|
299
|
+
const image = images?.[imageTarget.imageIndex];
|
|
300
|
+
if (!image) {
|
|
301
|
+
this.host.showToast("Image data is not available for this message.", "warning");
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
304
|
+
const opened = this.host.openImageContent?.(image) ?? openSystemImageContent(image);
|
|
305
|
+
this.host.showToast(opened ? "Opened image." : "Could not open image with the system viewer.", opened ? "success" : "warning");
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
308
|
+
handleFileLinkClick(event) {
|
|
309
|
+
const modifiedPress = isModifiedPrimaryButton(event.button) && !event.released;
|
|
310
|
+
const plainRelease = event.button === 0 && event.released;
|
|
311
|
+
if (!modifiedPress && !plainRelease)
|
|
312
|
+
return false;
|
|
313
|
+
const link = this.fileLinkAt(event);
|
|
314
|
+
if (!link)
|
|
315
|
+
return false;
|
|
316
|
+
const opened = this.host.openFileLink?.(link) ?? openDetectedFileLink(link);
|
|
317
|
+
if (!opened)
|
|
318
|
+
this.host.showToast("Could not open file link. Install the Zed CLI or set ZED_CLI.", "warning");
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
handleConversationScrollBar(event) {
|
|
322
|
+
if (!this.scrollBarDragActive && this.tabLineTargetAt(event))
|
|
323
|
+
return false;
|
|
324
|
+
const columns = this.host.terminalColumns();
|
|
325
|
+
const terminalRows = this.host.terminalRows();
|
|
326
|
+
const tabPanelRows = this.host.tabPanelRows(terminalRows);
|
|
327
|
+
const rows = editorLayoutRows(terminalRows, tabPanelRows);
|
|
328
|
+
const topOffset = editorLayoutTopOffset(tabPanelRows);
|
|
329
|
+
if (columns <= 0 || rows <= 0)
|
|
330
|
+
return false;
|
|
331
|
+
const { bodyHeight } = this.host.editorLayoutRenderer().computeLayout(columns, rows);
|
|
332
|
+
const localY = event.y - topOffset;
|
|
333
|
+
const insideBody = localY >= 1 && localY <= bodyHeight;
|
|
334
|
+
const onScrollBar = insideBody && event.x === columns && !!this.scrollController.scrollBarMetrics(columns, bodyHeight);
|
|
335
|
+
const baseButton = event.button & 3;
|
|
336
|
+
const draggingLeftButton = (event.button & 32) !== 0 && baseButton === 0;
|
|
337
|
+
if (event.released) {
|
|
338
|
+
if (!this.scrollBarDragActive && !onScrollBar)
|
|
339
|
+
return false;
|
|
340
|
+
this.scrollBarDragActive = false;
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
343
|
+
if (event.button === 0 && onScrollBar) {
|
|
344
|
+
this.scrollBarDragActive = true;
|
|
345
|
+
this.scrollController.scrollToScrollbarPosition(localY - 1);
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
if (!draggingLeftButton || !this.scrollBarDragActive)
|
|
349
|
+
return false;
|
|
350
|
+
const bodyRow = Math.max(0, Math.min(Math.max(0, bodyHeight - 1), localY - 1));
|
|
351
|
+
this.scrollController.scrollToScrollbarPosition(bodyRow);
|
|
352
|
+
return true;
|
|
353
|
+
}
|
|
354
|
+
handleInputScrollBar(event) {
|
|
355
|
+
if (!this.inputScrollBarDragActive && this.tabLineTargetAt(event))
|
|
356
|
+
return false;
|
|
357
|
+
const geometry = this.inputGeometry(event);
|
|
358
|
+
if (!geometry?.renderedInput.scrollBar)
|
|
359
|
+
return this.finishInputScrollBarDrag(event);
|
|
360
|
+
const { renderedInput, localY, inputStartRow } = geometry;
|
|
361
|
+
const scrollBar = renderedInput.scrollBar;
|
|
362
|
+
const editorRow = localY - inputStartRow - renderedInput.editorStartRowOffset;
|
|
363
|
+
const insideTrack = editorRow >= 0 && editorRow < scrollBar.trackHeight;
|
|
364
|
+
const onScrollBar = insideTrack && event.x === this.host.terminalColumns();
|
|
365
|
+
const baseButton = event.button & 3;
|
|
366
|
+
const draggingLeftButton = (event.button & 32) !== 0 && baseButton === 0;
|
|
367
|
+
if (event.released)
|
|
368
|
+
return this.finishInputScrollBarDrag(event, onScrollBar);
|
|
369
|
+
if (event.button === 0 && onScrollBar) {
|
|
370
|
+
this.inputScrollBarDragActive = true;
|
|
371
|
+
this.scrollInputToTrackRow(editorRow, scrollBar.trackHeight, renderedInput.totalLineCount, renderedInput.visibleRowCount);
|
|
372
|
+
return true;
|
|
373
|
+
}
|
|
374
|
+
if (!draggingLeftButton || !this.inputScrollBarDragActive)
|
|
375
|
+
return false;
|
|
376
|
+
const trackRow = Math.max(0, Math.min(scrollBar.trackHeight - 1, editorRow));
|
|
377
|
+
this.scrollInputToTrackRow(trackRow, scrollBar.trackHeight, renderedInput.totalLineCount, renderedInput.visibleRowCount);
|
|
378
|
+
return true;
|
|
379
|
+
}
|
|
380
|
+
finishInputScrollBarDrag(event, onScrollBar = false) {
|
|
381
|
+
if (!event.released)
|
|
382
|
+
return false;
|
|
383
|
+
if (!this.inputScrollBarDragActive && !onScrollBar)
|
|
384
|
+
return false;
|
|
385
|
+
this.inputScrollBarDragActive = false;
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
handleInputWheel(event, delta) {
|
|
389
|
+
const geometry = this.inputGeometry(event);
|
|
390
|
+
if (!geometry)
|
|
391
|
+
return false;
|
|
392
|
+
const { renderedInput, localY, inputStartRow, contentWidth } = geometry;
|
|
393
|
+
const inputEndRow = inputStartRow + renderedInput.lines.length;
|
|
394
|
+
const editorStartRow = inputStartRow + renderedInput.editorStartRowOffset;
|
|
395
|
+
if (localY < editorStartRow || localY >= inputEndRow)
|
|
396
|
+
return false;
|
|
397
|
+
if (this.host.inputEditor().scrollByVisualLines(delta, contentWidth, renderedInput.visibleRowCount, "", "")) {
|
|
398
|
+
this.host.render();
|
|
399
|
+
}
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
scrollInputToTrackRow(trackRow, trackHeight, totalLineCount, visibleRowCount) {
|
|
403
|
+
const maxScroll = Math.max(0, totalLineCount - visibleRowCount);
|
|
404
|
+
const ratio = trackHeight <= 1 ? 0 : trackRow / (trackHeight - 1);
|
|
405
|
+
const scrollOffset = Math.round(maxScroll * ratio);
|
|
406
|
+
const { contentWidth } = horizontalPaddingLayout(this.host.terminalColumns());
|
|
407
|
+
if (this.host.inputEditor().setVisualScrollOffset(scrollOffset, contentWidth, visibleRowCount, "", "")) {
|
|
408
|
+
this.host.render();
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
inputGeometry(event) {
|
|
412
|
+
const columns = this.host.terminalColumns();
|
|
413
|
+
const terminalRows = this.host.terminalRows();
|
|
414
|
+
const tabPanelRows = this.host.tabPanelRows(terminalRows);
|
|
415
|
+
const rows = editorLayoutRows(terminalRows, tabPanelRows);
|
|
416
|
+
const localY = event.y - editorLayoutTopOffset(tabPanelRows);
|
|
417
|
+
const { renderedInput, inputStartRow } = this.host.editorLayoutRenderer().computeLayout(columns, rows);
|
|
418
|
+
const inputEndRow = inputStartRow + renderedInput.lines.length;
|
|
419
|
+
if (localY < inputStartRow || localY >= inputEndRow)
|
|
420
|
+
return undefined;
|
|
421
|
+
const { contentWidth } = horizontalPaddingLayout(columns);
|
|
422
|
+
return { renderedInput, inputStartRow, localY, contentWidth };
|
|
423
|
+
}
|
|
424
|
+
tabLineTargetAt(event) {
|
|
425
|
+
return this.tabLineTargets.find((candidate) => (event.y === candidate.row
|
|
426
|
+
&& event.x >= candidate.startColumn
|
|
427
|
+
&& event.x < candidate.endColumn));
|
|
428
|
+
}
|
|
429
|
+
handleTabLineClick(event) {
|
|
430
|
+
const target = this.tabLineTargetAt(event);
|
|
431
|
+
if (!target)
|
|
432
|
+
return false;
|
|
433
|
+
if (target.kind === "new-tab")
|
|
434
|
+
this.host.openNewTab();
|
|
435
|
+
else if (target.kind === "close")
|
|
436
|
+
this.host.closeTab(target.tabId);
|
|
437
|
+
else if (target.active)
|
|
438
|
+
void this.commandController.runResumeCommand({ preserveStatus: true, placement: "under-tabs" });
|
|
439
|
+
else
|
|
440
|
+
this.host.switchToTab(target.tabId);
|
|
441
|
+
return true;
|
|
442
|
+
}
|
|
443
|
+
handleStatusModelClick(event) {
|
|
444
|
+
const target = this.statusModelTarget;
|
|
445
|
+
if (!target)
|
|
446
|
+
return false;
|
|
447
|
+
if (event.y !== target.row || event.x < target.startColumn || event.x >= target.endColumn)
|
|
448
|
+
return false;
|
|
449
|
+
this.popupMenus.openDirectPopupMenu("model");
|
|
450
|
+
this.host.render();
|
|
451
|
+
return true;
|
|
452
|
+
}
|
|
453
|
+
handleStatusThinkingClick(event) {
|
|
454
|
+
const target = this.statusThinkingTarget;
|
|
455
|
+
if (!target)
|
|
456
|
+
return false;
|
|
457
|
+
if (event.y !== target.row || event.x < target.startColumn || event.x >= target.endColumn)
|
|
458
|
+
return false;
|
|
459
|
+
this.popupMenus.openDirectPopupMenu("thinking");
|
|
460
|
+
this.host.render();
|
|
461
|
+
return true;
|
|
462
|
+
}
|
|
463
|
+
handleStatusContextClick(event) {
|
|
464
|
+
const target = this.statusContextTarget;
|
|
465
|
+
if (!target)
|
|
466
|
+
return false;
|
|
467
|
+
if (event.y !== target.row || event.x < target.startColumn || event.x >= target.endColumn)
|
|
468
|
+
return false;
|
|
469
|
+
const session = this.host.runtimeSession();
|
|
470
|
+
if (!session)
|
|
471
|
+
return false;
|
|
472
|
+
this.host.showToast(formatDcpStatsToast(session), "info");
|
|
473
|
+
return true;
|
|
474
|
+
}
|
|
475
|
+
handleStatusModelUsageClick(event) {
|
|
476
|
+
const target = this.statusModelUsageTarget;
|
|
477
|
+
if (!target)
|
|
478
|
+
return false;
|
|
479
|
+
if (event.y !== target.row || event.x < target.startColumn || event.x >= target.endColumn)
|
|
480
|
+
return false;
|
|
481
|
+
void this.host.refreshModelUsageStatus();
|
|
482
|
+
return true;
|
|
483
|
+
}
|
|
484
|
+
handleStatusUserJumpClick(event) {
|
|
485
|
+
const target = this.statusUserJumpTarget;
|
|
486
|
+
if (!target)
|
|
487
|
+
return false;
|
|
488
|
+
if (event.y !== target.row || event.x < target.startColumn || event.x >= target.endColumn)
|
|
489
|
+
return false;
|
|
490
|
+
this.popupMenus.openDirectPopupMenu("user-message-jump", { preserveStatus: true });
|
|
491
|
+
this.host.render();
|
|
492
|
+
return true;
|
|
493
|
+
}
|
|
494
|
+
handleStatusThinkingExpandClick(event) {
|
|
495
|
+
const target = this.statusThinkingExpandTarget;
|
|
496
|
+
if (!target)
|
|
497
|
+
return false;
|
|
498
|
+
if (event.y !== target.row || event.x < target.startColumn || event.x >= target.endColumn)
|
|
499
|
+
return false;
|
|
500
|
+
this.host.toggleAllThinkingExpanded?.();
|
|
501
|
+
return true;
|
|
502
|
+
}
|
|
503
|
+
handleStatusCompactToolsClick(event) {
|
|
504
|
+
const target = this.statusCompactToolsTarget;
|
|
505
|
+
if (!target)
|
|
506
|
+
return false;
|
|
507
|
+
if (event.y !== target.row || event.x < target.startColumn || event.x >= target.endColumn)
|
|
508
|
+
return false;
|
|
509
|
+
this.host.toggleSuperCompactTools?.();
|
|
510
|
+
return true;
|
|
511
|
+
}
|
|
512
|
+
handleStatusSessionClick(event) {
|
|
513
|
+
const target = this.statusSessionTarget;
|
|
514
|
+
if (!target)
|
|
515
|
+
return false;
|
|
516
|
+
if (event.y !== target.row || event.x < target.startColumn || event.x >= target.endColumn)
|
|
517
|
+
return false;
|
|
518
|
+
void this.commandController.runResumeCommand({ preserveStatus: true });
|
|
519
|
+
return true;
|
|
520
|
+
}
|
|
521
|
+
handleStatusPromptEnhancerClick(event) {
|
|
522
|
+
const target = this.statusPromptEnhancerTarget;
|
|
523
|
+
if (!target)
|
|
524
|
+
return false;
|
|
525
|
+
if (event.y !== target.row || event.x < target.startColumn || event.x >= target.endColumn)
|
|
526
|
+
return false;
|
|
527
|
+
void this.host.enhancePrompt();
|
|
528
|
+
return true;
|
|
529
|
+
}
|
|
530
|
+
handleStatusVoiceMicClick(event) {
|
|
531
|
+
const target = this.statusVoiceMicTarget;
|
|
532
|
+
if (!target)
|
|
533
|
+
return false;
|
|
534
|
+
if (event.y !== target.row || event.x < target.startColumn || event.x >= target.endColumn)
|
|
535
|
+
return false;
|
|
536
|
+
this.host.toggleVoiceRecording();
|
|
537
|
+
return true;
|
|
538
|
+
}
|
|
539
|
+
handleStatusVoiceLanguageClick(event) {
|
|
540
|
+
const target = this.statusVoiceLanguageTarget;
|
|
541
|
+
if (!target)
|
|
542
|
+
return false;
|
|
543
|
+
if (event.y !== target.row || event.x < target.startColumn || event.x >= target.endColumn)
|
|
544
|
+
return false;
|
|
545
|
+
this.host.toggleVoiceLanguage();
|
|
546
|
+
return true;
|
|
547
|
+
}
|
|
548
|
+
handleInputClick(event) {
|
|
549
|
+
const columns = this.host.terminalColumns();
|
|
550
|
+
const terminalRows = this.host.terminalRows();
|
|
551
|
+
const tabPanelRows = this.host.tabPanelRows(terminalRows);
|
|
552
|
+
const rows = editorLayoutRows(terminalRows, tabPanelRows);
|
|
553
|
+
const localY = event.y - editorLayoutTopOffset(tabPanelRows);
|
|
554
|
+
const { renderedInput, inputStartRow } = this.host.editorLayoutRenderer().computeLayout(columns, rows);
|
|
555
|
+
const inputEndRow = inputStartRow + renderedInput.lines.length;
|
|
556
|
+
if (localY < inputStartRow || localY >= inputEndRow)
|
|
557
|
+
return false;
|
|
558
|
+
if (localY < inputStartRow + renderedInput.editorStartRowOffset)
|
|
559
|
+
return false;
|
|
560
|
+
const visibleRowOffset = localY - inputStartRow - renderedInput.editorStartRowOffset;
|
|
561
|
+
const visualRow = renderedInput.scrollOffset + visibleRowOffset;
|
|
562
|
+
const { left, contentWidth } = horizontalPaddingLayout(columns);
|
|
563
|
+
const cursor = this.host.inputEditor().offsetAtVisualPosition(visualRow, event.x - left, contentWidth, "", "");
|
|
564
|
+
this.host.resetRequestHistoryNavigation();
|
|
565
|
+
this.host.inputEditor().setCursor(cursor, { preserveScroll: true });
|
|
566
|
+
this.host.render();
|
|
567
|
+
return true;
|
|
568
|
+
}
|
|
569
|
+
handleExtensionInputClick(event) {
|
|
570
|
+
const columns = this.host.terminalColumns();
|
|
571
|
+
const terminalRows = this.host.terminalRows();
|
|
572
|
+
const tabPanelRows = this.host.tabPanelRows(terminalRows);
|
|
573
|
+
const rows = editorLayoutRows(terminalRows, tabPanelRows);
|
|
574
|
+
const localY = event.y - editorLayoutTopOffset(tabPanelRows);
|
|
575
|
+
const { renderedInput, inputStartRow } = this.host.editorLayoutRenderer().computeLayout(columns, rows);
|
|
576
|
+
const inputEndRow = inputStartRow + renderedInput.editorStartRowOffset;
|
|
577
|
+
if (localY < inputStartRow || localY >= inputEndRow)
|
|
578
|
+
return false;
|
|
579
|
+
const { left, contentWidth } = horizontalPaddingLayout(columns);
|
|
580
|
+
return this.host.handleExtensionInputMouse({
|
|
581
|
+
...event,
|
|
582
|
+
localRow: localY - inputStartRow,
|
|
583
|
+
localColumn: event.x - left,
|
|
584
|
+
width: contentWidth,
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
openUserMessageMenu(entryId) {
|
|
588
|
+
if (!this.popupMenus.openUserMessageMenu(entryId))
|
|
589
|
+
return;
|
|
590
|
+
this.host.render();
|
|
591
|
+
}
|
|
592
|
+
openQueueMessageMenu(entryId) {
|
|
593
|
+
if (!this.popupMenus.openQueueMessageMenu(entryId))
|
|
594
|
+
return;
|
|
595
|
+
this.host.render();
|
|
596
|
+
}
|
|
597
|
+
copyErrorToast(toastId) {
|
|
598
|
+
const toast = this.host.toastEntry(toastId);
|
|
599
|
+
if (toast?.kind !== "error")
|
|
600
|
+
return false;
|
|
601
|
+
try {
|
|
602
|
+
this.copyTextToClipboard(toast.message);
|
|
603
|
+
this.host.dismissToast(toastId);
|
|
604
|
+
this.host.showToast("Error copied to clipboard", "success");
|
|
605
|
+
}
|
|
606
|
+
catch (error) {
|
|
607
|
+
this.host.showToast(`Copy failed: ${stringifyUnknown(error)}`, "error");
|
|
608
|
+
}
|
|
609
|
+
return true;
|
|
610
|
+
}
|
|
611
|
+
handleMouseSelection(event) {
|
|
612
|
+
const point = { x: event.x, y: event.y };
|
|
613
|
+
const baseButton = event.button & 3;
|
|
614
|
+
const draggingLeftButton = (event.button & 32) !== 0 && baseButton === 0;
|
|
615
|
+
if (event.released) {
|
|
616
|
+
if (!this.mouseSelection)
|
|
617
|
+
return false;
|
|
618
|
+
this.stopAutoScroll();
|
|
619
|
+
this.updateSelectionCurrentFromMouse(event, { autoScroll: false });
|
|
620
|
+
const selection = this.mouseSelection;
|
|
621
|
+
this.mouseSelection = undefined;
|
|
622
|
+
if (!selection.moved && samePoint(selection.anchor, point)) {
|
|
623
|
+
this.host.render();
|
|
624
|
+
return false;
|
|
625
|
+
}
|
|
626
|
+
const selectedText = this.getSelectedText(selection);
|
|
627
|
+
this.host.render();
|
|
628
|
+
if (selectedText.trim().length === 0)
|
|
629
|
+
return true;
|
|
630
|
+
try {
|
|
631
|
+
this.copyTextToClipboard(selectedText);
|
|
632
|
+
this.host.showToast("Copied to clipboard", "success");
|
|
633
|
+
}
|
|
634
|
+
catch (error) {
|
|
635
|
+
this.host.showToast(`Copy failed: ${stringifyUnknown(error)}`, "error");
|
|
636
|
+
}
|
|
637
|
+
return true;
|
|
638
|
+
}
|
|
639
|
+
if (draggingLeftButton) {
|
|
640
|
+
if (!this.mouseSelection)
|
|
641
|
+
return false;
|
|
642
|
+
this.updateSelectionCurrentFromMouse(event);
|
|
643
|
+
this.host.render();
|
|
644
|
+
return true;
|
|
645
|
+
}
|
|
646
|
+
if (event.button === 0) {
|
|
647
|
+
this.stopAutoScroll();
|
|
648
|
+
const conversationPoint = this.conversationPointFromMouse(event, false);
|
|
649
|
+
this.mouseSelection = conversationPoint
|
|
650
|
+
? {
|
|
651
|
+
anchor: conversationPoint.screen,
|
|
652
|
+
current: conversationPoint.screen,
|
|
653
|
+
moved: false,
|
|
654
|
+
kind: "conversation",
|
|
655
|
+
conversationAnchor: conversationPoint.conversation,
|
|
656
|
+
conversationCurrent: conversationPoint.conversation,
|
|
657
|
+
}
|
|
658
|
+
: { anchor: point, current: point, moved: false, kind: "screen" };
|
|
659
|
+
return true;
|
|
660
|
+
}
|
|
661
|
+
return false;
|
|
662
|
+
}
|
|
663
|
+
syncConversationSelectionForRender(startLine, bodyHeight, topReservedRows, width) {
|
|
664
|
+
this.renderedConversationFrame = {
|
|
665
|
+
bodyHeight,
|
|
666
|
+
topRow: topReservedRows + 1,
|
|
667
|
+
viewportColumns: width,
|
|
668
|
+
};
|
|
669
|
+
const selection = this.mouseSelection;
|
|
670
|
+
if (selection?.kind !== "conversation" || !selection.conversationAnchor || !selection.conversationCurrent)
|
|
671
|
+
return;
|
|
672
|
+
const range = orderedConversationSelection(selection.conversationAnchor, selection.conversationCurrent);
|
|
673
|
+
const visibleStartLine = Math.max(range.start.line, startLine);
|
|
674
|
+
const visibleEndLine = Math.min(range.end.line, startLine + Math.max(0, bodyHeight - 1));
|
|
675
|
+
if (visibleEndLine < visibleStartLine) {
|
|
676
|
+
selection.screenAnchor = { x: 1, y: 0 };
|
|
677
|
+
selection.screenCurrent = { x: 1, y: 0 };
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
const startX = visibleStartLine === range.start.line ? range.start.x : 1;
|
|
681
|
+
const endX = visibleEndLine === range.end.line ? range.end.x : width + 1;
|
|
682
|
+
selection.screenAnchor = {
|
|
683
|
+
x: Math.max(1, Math.min(width + 1, startX)),
|
|
684
|
+
y: topReservedRows + (visibleStartLine - startLine) + 1,
|
|
685
|
+
};
|
|
686
|
+
selection.screenCurrent = {
|
|
687
|
+
x: Math.max(1, Math.min(width + 1, endX)),
|
|
688
|
+
y: topReservedRows + (visibleEndLine - startLine) + 1,
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
updateSelectionCurrentFromMouse(event, options = {}) {
|
|
692
|
+
const selection = this.mouseSelection;
|
|
693
|
+
if (!selection)
|
|
694
|
+
return;
|
|
695
|
+
if (selection.kind === "conversation") {
|
|
696
|
+
const conversationPoint = this.conversationPointFromMouse(event, true);
|
|
697
|
+
if (!conversationPoint)
|
|
698
|
+
return;
|
|
699
|
+
selection.current = conversationPoint.screen;
|
|
700
|
+
selection.conversationCurrent = conversationPoint.conversation;
|
|
701
|
+
selection.moved = selection.moved
|
|
702
|
+
|| !samePoint(selection.anchor, conversationPoint.screen)
|
|
703
|
+
|| !sameConversationPoint(selection.conversationAnchor, conversationPoint.conversation);
|
|
704
|
+
if (options.autoScroll ?? true)
|
|
705
|
+
this.updateAutoScroll(event);
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
selection.current = { x: event.x, y: event.y };
|
|
709
|
+
selection.moved = selection.moved || !samePoint(selection.anchor, selection.current);
|
|
710
|
+
this.stopAutoScroll();
|
|
711
|
+
}
|
|
712
|
+
getSelectedText(selection) {
|
|
713
|
+
if (selection.kind === "conversation" && selection.conversationAnchor && selection.conversationCurrent) {
|
|
714
|
+
return this.getSelectedConversationText(selection.conversationAnchor, selection.conversationCurrent);
|
|
715
|
+
}
|
|
716
|
+
return this.getSelectedScreenText(selection.anchor, selection.current);
|
|
717
|
+
}
|
|
718
|
+
copyTextToClipboard(text) {
|
|
719
|
+
(this.host.copyTextToClipboard ?? copyTextToClipboard)(text);
|
|
720
|
+
}
|
|
721
|
+
getSelectedScreenText(anchor, current) {
|
|
722
|
+
const range = orderedSelection(anchor, current);
|
|
723
|
+
const inputFrame = this.inputFrameCopyRows();
|
|
724
|
+
const lines = [];
|
|
725
|
+
for (let row = range.start.y; row <= range.end.y; row += 1) {
|
|
726
|
+
const text = this.renderedRowTexts.get(row) ?? "";
|
|
727
|
+
const startColumn = row === range.start.y ? range.start.x : 1;
|
|
728
|
+
const endColumn = row === range.end.y ? range.end.x : text.length + 1;
|
|
729
|
+
const selectedLine = screenSelectionLineText(row, text, startColumn, endColumn, inputFrame);
|
|
730
|
+
if (selectedLine !== undefined)
|
|
731
|
+
lines.push(selectedLine.trimEnd());
|
|
732
|
+
}
|
|
733
|
+
return lines.join("\n").replace(/\s+$/u, "");
|
|
734
|
+
}
|
|
735
|
+
inputFrameCopyRows() {
|
|
736
|
+
const columns = this.host.terminalColumns();
|
|
737
|
+
const terminalRows = this.host.terminalRows();
|
|
738
|
+
const tabPanelRows = this.host.tabPanelRows(terminalRows);
|
|
739
|
+
const rows = editorLayoutRows(terminalRows, tabPanelRows);
|
|
740
|
+
const layout = this.host.editorLayoutRenderer().computeLayout(columns, rows);
|
|
741
|
+
const topOffset = editorLayoutTopOffset(tabPanelRows);
|
|
742
|
+
const toScreenRow = (layoutRow) => Math.max(1, Math.min(terminalRows, topOffset + layoutRow));
|
|
743
|
+
const toScreenRowExclusive = (layoutRow) => Math.max(1, Math.min(terminalRows + 1, topOffset + layoutRow));
|
|
744
|
+
return {
|
|
745
|
+
inputStartRow: toScreenRow(layout.inputStartRow),
|
|
746
|
+
inputEndRow: toScreenRowExclusive(layout.inputStartRow + layout.renderedInput.lines.length),
|
|
747
|
+
inputSeparatorRow: toScreenRow(layout.inputSeparatorRow),
|
|
748
|
+
inputBottomSeparatorRow: toScreenRow(layout.inputBottomSeparatorRow),
|
|
749
|
+
contentStartColumn: 2,
|
|
750
|
+
contentEndColumn: columns,
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
getSelectedConversationText(anchor, current) {
|
|
754
|
+
const range = orderedConversationSelection(anchor, current);
|
|
755
|
+
const width = this.conversationArea()?.viewportColumns ?? this.host.terminalColumns();
|
|
756
|
+
const count = range.end.line - range.start.line + 1;
|
|
757
|
+
const renderedLines = this.host.conversationViewport().slice(width, range.start.line, count);
|
|
758
|
+
const lines = [];
|
|
759
|
+
for (let index = 0; index < count; index += 1) {
|
|
760
|
+
const text = renderedLines[index]?.text ?? "";
|
|
761
|
+
const line = range.start.line + index;
|
|
762
|
+
const startColumn = line === range.start.line ? range.start.x : 1;
|
|
763
|
+
const endColumn = line === range.end.line ? range.end.x : text.length + 1;
|
|
764
|
+
const startIndex = Math.max(0, Math.min(text.length, startColumn - 1));
|
|
765
|
+
const endIndex = Math.max(startIndex, Math.min(text.length, endColumn - 1));
|
|
766
|
+
lines.push(text.slice(startIndex, endIndex).trimEnd());
|
|
767
|
+
}
|
|
768
|
+
return lines.join("\n").replace(/\s+$/u, "");
|
|
769
|
+
}
|
|
770
|
+
conversationPointFromMouse(event, clampToViewport) {
|
|
771
|
+
const area = this.conversationArea();
|
|
772
|
+
if (!area || area.bodyHeight <= 0)
|
|
773
|
+
return undefined;
|
|
774
|
+
if (!clampToViewport && (event.y < area.topRow || event.y > area.bottomRow || event.x === this.host.terminalColumns()))
|
|
775
|
+
return undefined;
|
|
776
|
+
const screenY = Math.max(area.topRow, Math.min(area.bottomRow, event.y));
|
|
777
|
+
const screenX = Math.max(1, Math.min(area.viewportColumns + 1, event.x));
|
|
778
|
+
return {
|
|
779
|
+
conversation: {
|
|
780
|
+
line: area.metrics.start + (screenY - area.topRow),
|
|
781
|
+
x: screenX,
|
|
782
|
+
},
|
|
783
|
+
screen: { x: screenX, y: screenY },
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
conversationArea() {
|
|
787
|
+
const columns = this.host.terminalColumns();
|
|
788
|
+
const frame = this.renderedConversationFrame ?? this.computeConversationFrame(columns);
|
|
789
|
+
if (!frame)
|
|
790
|
+
return undefined;
|
|
791
|
+
const { bodyHeight, topRow } = frame;
|
|
792
|
+
if (columns <= 0 || bodyHeight <= 0)
|
|
793
|
+
return undefined;
|
|
794
|
+
const metrics = this.scrollController.scrollMetrics(columns, bodyHeight);
|
|
795
|
+
const viewportColumns = Math.max(1, Math.min(columns, frame.viewportColumns, metrics.viewportColumns));
|
|
796
|
+
return {
|
|
797
|
+
bodyHeight,
|
|
798
|
+
bottomRow: topRow + bodyHeight - 1,
|
|
799
|
+
metrics,
|
|
800
|
+
topRow,
|
|
801
|
+
viewportColumns,
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
computeConversationFrame(columns) {
|
|
805
|
+
const terminalRows = this.host.terminalRows();
|
|
806
|
+
const tabPanelRows = this.host.tabPanelRows(terminalRows);
|
|
807
|
+
const rows = editorLayoutRows(terminalRows, tabPanelRows);
|
|
808
|
+
const { bodyHeight } = this.host.editorLayoutRenderer().computeLayout(columns, rows);
|
|
809
|
+
if (bodyHeight <= 0)
|
|
810
|
+
return undefined;
|
|
811
|
+
const metrics = this.scrollController.scrollMetrics(columns, bodyHeight);
|
|
812
|
+
return {
|
|
813
|
+
bodyHeight,
|
|
814
|
+
topRow: editorLayoutTopOffset(tabPanelRows) + 1,
|
|
815
|
+
viewportColumns: metrics.viewportColumns,
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
updateAutoScroll(event) {
|
|
819
|
+
const area = this.conversationArea();
|
|
820
|
+
if (!area) {
|
|
821
|
+
this.stopAutoScroll();
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
this.autoScrollCursorX = event.x;
|
|
825
|
+
if (event.y < area.topRow) {
|
|
826
|
+
this.startAutoScroll(-1, area.topRow - event.y);
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
if (event.y > area.bottomRow) {
|
|
830
|
+
this.startAutoScroll(1, event.y - area.bottomRow);
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
this.stopAutoScroll();
|
|
834
|
+
}
|
|
835
|
+
startAutoScroll(direction, distance) {
|
|
836
|
+
this.autoScrollDirection = direction;
|
|
837
|
+
this.autoScrollDistance = Math.max(1, distance);
|
|
838
|
+
if (this.autoScrollTimer)
|
|
839
|
+
return;
|
|
840
|
+
this.autoScrollAccumulator = 0;
|
|
841
|
+
this.autoScrollLastTick = Date.now();
|
|
842
|
+
this.autoScrollTimer = setInterval(() => this.tickAutoScroll(), 16);
|
|
843
|
+
}
|
|
844
|
+
stopAutoScroll() {
|
|
845
|
+
if (this.autoScrollTimer)
|
|
846
|
+
clearInterval(this.autoScrollTimer);
|
|
847
|
+
this.autoScrollTimer = undefined;
|
|
848
|
+
this.autoScrollDirection = undefined;
|
|
849
|
+
this.autoScrollDistance = 0;
|
|
850
|
+
this.autoScrollAccumulator = 0;
|
|
851
|
+
this.autoScrollLastTick = 0;
|
|
852
|
+
}
|
|
853
|
+
tickAutoScroll() {
|
|
854
|
+
if (this.mouseSelection?.kind !== "conversation" || !this.autoScrollDirection) {
|
|
855
|
+
this.stopAutoScroll();
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
const now = Date.now();
|
|
859
|
+
const elapsedSeconds = Math.max(0.001, Math.min(0.08, (now - this.autoScrollLastTick) / 1000));
|
|
860
|
+
this.autoScrollLastTick = now;
|
|
861
|
+
const linesPerSecond = Math.min(48, 8 + this.autoScrollDistance * 7);
|
|
862
|
+
this.autoScrollAccumulator += this.autoScrollDirection * linesPerSecond * elapsedSeconds;
|
|
863
|
+
const delta = Math.trunc(this.autoScrollAccumulator);
|
|
864
|
+
if (delta === 0)
|
|
865
|
+
return;
|
|
866
|
+
this.autoScrollAccumulator -= delta;
|
|
867
|
+
const scrolled = this.scrollController.scrollByLines(delta, { render: false });
|
|
868
|
+
this.updateConversationSelectionAtAutoScrollEdge();
|
|
869
|
+
if (scrolled)
|
|
870
|
+
this.host.render();
|
|
871
|
+
}
|
|
872
|
+
updateConversationSelectionAtAutoScrollEdge() {
|
|
873
|
+
const selection = this.mouseSelection;
|
|
874
|
+
if (selection?.kind !== "conversation" || !this.autoScrollDirection)
|
|
875
|
+
return;
|
|
876
|
+
const area = this.conversationArea();
|
|
877
|
+
if (!area)
|
|
878
|
+
return;
|
|
879
|
+
const screenY = this.autoScrollDirection < 0 ? area.topRow : area.bottomRow;
|
|
880
|
+
const screenX = Math.max(1, Math.min(area.viewportColumns + 1, this.autoScrollCursorX));
|
|
881
|
+
selection.current = { x: screenX, y: screenY };
|
|
882
|
+
selection.conversationCurrent = {
|
|
883
|
+
line: area.metrics.start + (screenY - area.topRow),
|
|
884
|
+
x: screenX,
|
|
885
|
+
};
|
|
886
|
+
selection.moved = true;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
function orderedConversationSelection(anchor, current) {
|
|
890
|
+
if (anchor.line < current.line)
|
|
891
|
+
return { start: anchor, end: current };
|
|
892
|
+
if (anchor.line > current.line)
|
|
893
|
+
return { start: current, end: anchor };
|
|
894
|
+
return anchor.x <= current.x ? { start: anchor, end: current } : { start: current, end: anchor };
|
|
895
|
+
}
|
|
896
|
+
export function screenSelectionLineText(row, text, startColumn, endColumn, inputFrame) {
|
|
897
|
+
if (inputFrame && (row === inputFrame.inputSeparatorRow || row === inputFrame.inputBottomSeparatorRow)) {
|
|
898
|
+
return undefined;
|
|
899
|
+
}
|
|
900
|
+
let copyStartColumn = startColumn;
|
|
901
|
+
let copyEndColumn = endColumn;
|
|
902
|
+
if (inputFrame && row >= inputFrame.inputStartRow && row < inputFrame.inputEndRow) {
|
|
903
|
+
copyStartColumn = Math.max(copyStartColumn, inputFrame.contentStartColumn);
|
|
904
|
+
copyEndColumn = Math.min(copyEndColumn, inputFrame.contentEndColumn);
|
|
905
|
+
}
|
|
906
|
+
const startIndex = Math.max(0, Math.min(text.length, copyStartColumn - 1));
|
|
907
|
+
const endIndex = Math.max(startIndex, Math.min(text.length, copyEndColumn - 1));
|
|
908
|
+
return text.slice(startIndex, endIndex);
|
|
909
|
+
}
|
|
910
|
+
function sameConversationPoint(left, right) {
|
|
911
|
+
return !!left && left.line === right.line && left.x === right.x;
|
|
912
|
+
}
|
|
913
|
+
function displayCellsInColumnRange(text, startColumn, endColumn) {
|
|
914
|
+
let cells = "";
|
|
915
|
+
for (let column = startColumn; column < endColumn; column += 1) {
|
|
916
|
+
cells += displayCellAtColumn(text, column);
|
|
917
|
+
}
|
|
918
|
+
return cells;
|
|
919
|
+
}
|
|
920
|
+
function nonBlankLineBounds(text, fallbackColumn) {
|
|
921
|
+
let startColumn;
|
|
922
|
+
let endColumn;
|
|
923
|
+
let displayColumn = 1;
|
|
924
|
+
for (let index = 0; index < text.length;) {
|
|
925
|
+
const codePoint = text.codePointAt(index) ?? 0;
|
|
926
|
+
const char = String.fromCodePoint(codePoint);
|
|
927
|
+
const width = stringDisplayWidth(char);
|
|
928
|
+
index += char.length;
|
|
929
|
+
if (width <= 0)
|
|
930
|
+
continue;
|
|
931
|
+
if (/\S/u.test(char)) {
|
|
932
|
+
startColumn ??= displayColumn;
|
|
933
|
+
endColumn = displayColumn + width;
|
|
934
|
+
}
|
|
935
|
+
displayColumn += width;
|
|
936
|
+
}
|
|
937
|
+
return startColumn === undefined || endColumn === undefined
|
|
938
|
+
? { startColumn: fallbackColumn, endColumn: fallbackColumn + 1 }
|
|
939
|
+
: { startColumn, endColumn };
|
|
940
|
+
}
|
|
941
|
+
function displayCellAtColumn(text, column) {
|
|
942
|
+
if (column < 1)
|
|
943
|
+
return " ";
|
|
944
|
+
let displayColumn = 1;
|
|
945
|
+
for (let index = 0; index < text.length;) {
|
|
946
|
+
const codePoint = text.codePointAt(index) ?? 0;
|
|
947
|
+
const char = String.fromCodePoint(codePoint);
|
|
948
|
+
const width = stringDisplayWidth(char);
|
|
949
|
+
index += char.length;
|
|
950
|
+
if (width <= 0)
|
|
951
|
+
continue;
|
|
952
|
+
if (column >= displayColumn && column < displayColumn + width)
|
|
953
|
+
return width === 1 ? char : " ";
|
|
954
|
+
displayColumn += width;
|
|
955
|
+
}
|
|
956
|
+
return " ";
|
|
957
|
+
}
|
|
958
|
+
function isModifiedPrimaryButton(button) {
|
|
959
|
+
const primaryButton = (button & 3) === 0;
|
|
960
|
+
const modifierBits = button & (8 | 16);
|
|
961
|
+
return primaryButton && modifierBits !== 0;
|
|
962
|
+
}
|
|
963
|
+
function editorLayoutRows(terminalRows, tabPanelRows) {
|
|
964
|
+
return Math.max(1, terminalRows - tabPanelRows);
|
|
965
|
+
}
|
|
966
|
+
function editorLayoutTopOffset(tabPanelRows) {
|
|
967
|
+
return tabPanelRows;
|
|
968
|
+
}
|