@strands-agents/cli 0.2.4 → 0.4.0
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 +217 -133
- package/bin/strands.js +1 -5
- package/dist/src/{tui/strands-backend.js → agent/backend.js} +90 -28
- package/dist/src/agent/backend.js.map +1 -0
- package/dist/src/{tui/background/activity.js → agent/background.js} +173 -6
- package/dist/src/agent/background.js.map +1 -0
- package/dist/src/{tui/agent-configuration.js → agent/configuration.js} +62 -105
- package/dist/src/agent/configuration.js.map +1 -0
- package/dist/src/agent/context.js +112 -0
- package/dist/src/agent/context.js.map +1 -0
- package/dist/src/{tui/chat/sdk-projector.js → agent/events.js} +6 -5
- package/dist/src/agent/events.js.map +1 -0
- package/dist/src/{tui/permissions/file-change-preview.js → agent/file-changes.js} +10 -8
- package/dist/src/agent/file-changes.js.map +1 -0
- package/dist/src/agent/mcp.js +436 -0
- package/dist/src/agent/mcp.js.map +1 -0
- package/dist/src/agent/messaging.js +424 -0
- package/dist/src/agent/messaging.js.map +1 -0
- package/dist/src/agent/permission-rules.js +267 -0
- package/dist/src/agent/permission-rules.js.map +1 -0
- package/dist/src/agent/permissions.js +288 -0
- package/dist/src/agent/permissions.js.map +1 -0
- package/dist/src/agent/runtime.js +524 -0
- package/dist/src/agent/runtime.js.map +1 -0
- package/dist/src/{tui/workspace → agent}/sandbox.js +92 -25
- package/dist/src/agent/sandbox.js.map +1 -0
- package/dist/src/{tui/chat → agent}/shell.js +1 -1
- package/dist/src/agent/shell.js.map +1 -0
- package/dist/src/{tui → agent}/skills.js +37 -56
- package/dist/src/agent/skills.js.map +1 -0
- package/dist/src/{tui/builtin-tools.js → agent/tools.js} +2 -3
- package/dist/src/agent/tools.js.map +1 -0
- package/dist/src/agent/types.js.map +1 -0
- package/dist/src/{tui/voice/session.js → agent/voice.js} +221 -224
- package/dist/src/agent/voice.js.map +1 -0
- package/dist/src/{tui/acp/projection.js → cli/acp-events.js} +19 -4
- package/dist/src/cli/acp-events.js.map +1 -0
- package/dist/src/{tui/project/acp.js → cli/acp-python.js} +41 -18
- package/dist/src/cli/acp-python.js.map +1 -0
- package/dist/src/{tui/acp/server.js → cli/acp.js} +149 -46
- package/dist/src/cli/acp.js.map +1 -0
- package/dist/src/cli/arguments.js +8 -3
- package/dist/src/cli/arguments.js.map +1 -1
- package/dist/src/{console.js → cli/console.js} +69 -4
- package/dist/src/cli/console.js.map +1 -0
- package/dist/src/cli/invocation.js +75 -44
- package/dist/src/cli/invocation.js.map +1 -1
- package/dist/src/cli/run.js +66 -38
- package/dist/src/cli/run.js.map +1 -1
- package/dist/src/{tui → cli}/telemetry.js +2 -2
- package/dist/src/{tui → cli}/telemetry.js.map +1 -1
- package/dist/src/cli/update.js +35 -7
- package/dist/src/cli/update.js.map +1 -1
- package/dist/src/{tui/mcp/config.js → config/mcp.js} +25 -35
- package/dist/src/config/mcp.js.map +1 -0
- package/dist/src/{tui → config}/settings.js +78 -130
- package/dist/src/config/settings.js.map +1 -0
- package/dist/src/config/source.js +87 -0
- package/dist/src/config/source.js.map +1 -0
- package/dist/src/{tui/config.js → config/store.js} +178 -49
- package/dist/src/config/store.js.map +1 -0
- package/dist/src/{tui/workspace → config}/trust.js +12 -16
- package/dist/src/config/trust.js.map +1 -0
- package/dist/src/logging.js +3 -4
- package/dist/src/logging.js.map +1 -1
- package/dist/src/{tui/provider → model}/aws-config.js +13 -4
- package/dist/src/model/aws-config.js.map +1 -0
- package/dist/src/{tui/provider/bedrock-catalog.js → model/bedrock.js} +70 -3
- package/dist/src/model/bedrock.js.map +1 -0
- package/dist/src/{tui/provider → model}/discovery.js +11 -10
- package/dist/src/model/discovery.js.map +1 -0
- package/dist/src/{tui/provider → model}/environment.js +19 -16
- package/dist/src/model/environment.js.map +1 -0
- package/dist/src/{tui/model/display.js → model/metadata.js} +6 -1
- package/dist/src/model/metadata.js.map +1 -0
- package/dist/src/model/packages.js.map +1 -0
- package/dist/src/{tui/model → model}/runtime.js +31 -62
- package/dist/src/model/runtime.js.map +1 -0
- package/dist/src/{tui/model → model}/selection.js +9 -15
- package/dist/src/model/selection.js.map +1 -0
- package/dist/src/{tui/package-version.js → package-version.js} +6 -0
- package/dist/src/package-version.js.map +1 -0
- package/dist/src/paths.js +23 -0
- package/dist/src/paths.js.map +1 -0
- package/dist/src/project/archive.js +461 -0
- package/dist/src/project/archive.js.map +1 -0
- package/dist/src/{tui/project → project}/export.js +249 -72
- package/dist/src/project/export.js.map +1 -0
- package/dist/src/{tui/project → project}/import.js +58 -6
- package/dist/src/project/import.js.map +1 -0
- package/dist/src/{tui/project → project}/module-loader.js +1 -5
- package/dist/src/project/module-loader.js.map +1 -0
- package/dist/src/{tui/project → project}/packaging.js +25 -8
- package/dist/src/project/packaging.js.map +1 -0
- package/dist/src/project/portability.js +455 -0
- package/dist/src/project/portability.js.map +1 -0
- package/dist/src/{tui/project → project}/python.js +46 -31
- package/dist/src/project/python.js.map +1 -0
- package/dist/src/{tui/project → project}/source.js +45 -26
- package/dist/src/project/source.js.map +1 -0
- package/dist/src/project/typescript-backend.js +733 -0
- package/dist/src/project/typescript-backend.js.map +1 -0
- package/dist/src/project/typescript-worker.js +488 -0
- package/dist/src/project/typescript-worker.js.map +1 -0
- package/dist/src/{tui/project → project}/typescript.js +19 -7
- package/dist/src/project/typescript.js.map +1 -0
- package/dist/src/project/watch.js +33 -0
- package/dist/src/project/watch.js.map +1 -0
- package/dist/src/{tui/project → project}/worker.py +358 -106
- package/dist/src/session/agent-definition.js +35 -0
- package/dist/src/session/agent-definition.js.map +1 -0
- package/dist/src/session/catalog.js +156 -0
- package/dist/src/session/catalog.js.map +1 -0
- package/dist/src/{tui/session → session}/context.js +45 -5
- package/dist/src/session/context.js.map +1 -0
- package/dist/src/{tui/session → session}/desktop-profile.js +1 -0
- package/dist/src/session/desktop-profile.js.map +1 -0
- package/dist/src/{tui/session → session}/sessions.js +126 -27
- package/dist/src/session/sessions.js.map +1 -0
- package/dist/src/terminal/arguments.js +53 -0
- package/dist/src/terminal/arguments.js.map +1 -0
- package/dist/src/{tui/terminal → terminal}/composer.js +51 -24
- package/dist/src/terminal/composer.js.map +1 -0
- package/dist/src/terminal/directory-picker.js +182 -0
- package/dist/src/terminal/directory-picker.js.map +1 -0
- package/dist/src/terminal/ink.js.map +1 -0
- package/dist/src/terminal/mouse-input.js.map +1 -0
- package/dist/src/terminal/npm.js.map +1 -0
- package/dist/src/terminal/open-editor.js +40 -0
- package/dist/src/terminal/open-editor.js.map +1 -0
- package/dist/src/terminal/open-url.js +26 -0
- package/dist/src/terminal/open-url.js.map +1 -0
- package/dist/src/terminal/process-tree.js.map +1 -0
- package/dist/src/terminal/shell-output.js.map +1 -0
- package/dist/src/{tui/terminal → terminal}/terminal.js +40 -2
- package/dist/src/terminal/terminal.js.map +1 -0
- package/dist/src/{tui/terminal/sanitize.js → terminal/text.js} +40 -6
- package/dist/src/terminal/text.js.map +1 -0
- package/dist/src/terminal/theme-detection.js +197 -0
- package/dist/src/terminal/theme-detection.js.map +1 -0
- package/dist/src/{tui/view/fade-in.js → ui/animation.js} +26 -1
- package/dist/src/ui/animation.js.map +1 -0
- package/dist/src/ui/app.js +176 -0
- package/dist/src/ui/app.js.map +1 -0
- package/dist/src/ui/chat/attachments.js +135 -0
- package/dist/src/ui/chat/attachments.js.map +1 -0
- package/dist/src/{tui → ui}/chat/commands.js +55 -7
- package/dist/src/ui/chat/commands.js.map +1 -0
- package/dist/src/{tui → ui}/chat/controller.js +1176 -345
- package/dist/src/ui/chat/controller.js.map +1 -0
- package/dist/src/ui/chat/conversations.js +692 -0
- package/dist/src/ui/chat/conversations.js.map +1 -0
- package/dist/src/{tui → ui}/chat/help.js +11 -5
- package/dist/src/ui/chat/help.js.map +1 -0
- package/dist/src/ui/chat/panel-state.js +513 -0
- package/dist/src/ui/chat/panel-state.js.map +1 -0
- package/dist/src/{tui → ui}/chat/projector.js +93 -8
- package/dist/src/ui/chat/projector.js.map +1 -0
- package/dist/src/ui/chat/prompt.js +176 -0
- package/dist/src/ui/chat/prompt.js.map +1 -0
- package/dist/src/ui/chat/runtime.js +589 -0
- package/dist/src/ui/chat/runtime.js.map +1 -0
- package/dist/src/ui/chat/screen.js +1907 -0
- package/dist/src/ui/chat/screen.js.map +1 -0
- package/dist/src/{tui/chat/controller-helpers.js → ui/chat/state.js} +39 -3
- package/dist/src/ui/chat/state.js.map +1 -0
- package/dist/src/ui/chat/stream-presentation.js.map +1 -0
- package/dist/src/ui/chat/transcript-turn.js +189 -0
- package/dist/src/ui/chat/transcript-turn.js.map +1 -0
- package/dist/src/{tui/view → ui/chat}/transcript.js +66 -6
- package/dist/src/ui/chat/transcript.js.map +1 -0
- package/dist/src/ui/chat/types.js +2 -0
- package/dist/src/ui/chat/types.js.map +1 -0
- package/dist/src/ui/chat/view.js +249 -0
- package/dist/src/ui/chat/view.js.map +1 -0
- package/dist/src/ui/chat/voice.js +388 -0
- package/dist/src/ui/chat/voice.js.map +1 -0
- package/dist/src/ui/footer.js +110 -0
- package/dist/src/ui/footer.js.map +1 -0
- package/dist/src/{tui/view → ui}/frog-canvas.js +47 -50
- package/dist/src/ui/frog-canvas.js.map +1 -0
- package/dist/src/{tui/view → ui}/frog-drawing.js +36 -29
- package/dist/src/ui/frog-drawing.js.map +1 -0
- package/dist/src/{tui/view/frog-intro-renderer.js → ui/frog-renderer.js} +63 -46
- package/dist/src/ui/frog-renderer.js.map +1 -0
- package/dist/src/{tui/view/frog-easter-egg.js → ui/frog.js} +34 -6
- package/dist/src/ui/frog.js.map +1 -0
- package/dist/src/ui/interaction.js +525 -0
- package/dist/src/ui/interaction.js.map +1 -0
- package/dist/src/{tui/view → ui}/markdown.js +12 -9
- package/dist/src/ui/markdown.js.map +1 -0
- package/dist/src/ui/mcp-diagnostics.js +56 -0
- package/dist/src/ui/mcp-diagnostics.js.map +1 -0
- package/dist/src/ui/media.js +59 -0
- package/dist/src/ui/media.js.map +1 -0
- package/dist/src/ui/panels/agents.js +97 -0
- package/dist/src/ui/panels/agents.js.map +1 -0
- package/dist/src/ui/panels/configuration.js +201 -0
- package/dist/src/ui/panels/configuration.js.map +1 -0
- package/dist/src/ui/panels/context.js +102 -0
- package/dist/src/ui/panels/context.js.map +1 -0
- package/dist/src/ui/panels/export.js +17 -0
- package/dist/src/ui/panels/export.js.map +1 -0
- package/dist/src/ui/panels/help.js +22 -0
- package/dist/src/ui/panels/help.js.map +1 -0
- package/dist/src/ui/panels/models.js +180 -0
- package/dist/src/ui/panels/models.js.map +1 -0
- package/dist/src/ui/panels/panel.js +122 -0
- package/dist/src/ui/panels/panel.js.map +1 -0
- package/dist/src/ui/panels/permissions.js +90 -0
- package/dist/src/ui/panels/permissions.js.map +1 -0
- package/dist/src/ui/panels/sessions.js +54 -0
- package/dist/src/ui/panels/sessions.js.map +1 -0
- package/dist/src/ui/panels/settings.js +125 -0
- package/dist/src/ui/panels/settings.js.map +1 -0
- package/dist/src/ui/panels/shared.js +50 -0
- package/dist/src/ui/panels/shared.js.map +1 -0
- package/dist/src/ui/panels/tasks.js +15 -0
- package/dist/src/ui/panels/tasks.js.map +1 -0
- package/dist/src/ui/panels/voice.js +142 -0
- package/dist/src/ui/panels/voice.js.map +1 -0
- package/dist/src/{tui/permissions/settings.js → ui/permission-options.js} +13 -2
- package/dist/src/ui/permission-options.js.map +1 -0
- package/dist/src/{tui/view → ui}/presentation.js +170 -112
- package/dist/src/ui/presentation.js.map +1 -0
- package/dist/src/{tui → ui}/run.js +173 -36
- package/dist/src/ui/run.js.map +1 -0
- package/dist/src/{tui/view/setup-wizard/settings-panel.js → ui/setup/form.js} +6 -6
- package/dist/src/ui/setup/form.js.map +1 -0
- package/dist/src/ui/setup/menu.js +133 -0
- package/dist/src/ui/setup/menu.js.map +1 -0
- package/dist/src/{tui/view/setup-wizard → ui/setup}/providers.js +157 -20
- package/dist/src/ui/setup/providers.js.map +1 -0
- package/dist/src/{tui/view/setup-wizard → ui/setup}/steps.js +193 -147
- package/dist/src/ui/setup/steps.js.map +1 -0
- package/dist/src/ui/setup/wizard.js +2075 -0
- package/dist/src/ui/setup/wizard.js.map +1 -0
- package/dist/src/ui/startup.js +147 -0
- package/dist/src/ui/startup.js.map +1 -0
- package/dist/src/{tui/terminal/size.js → ui/terminal-size.js} +1 -1
- package/dist/src/ui/terminal-size.js.map +1 -0
- package/dist/src/ui/text-input.js +50 -0
- package/dist/src/ui/text-input.js.map +1 -0
- package/dist/src/{tui/view → ui}/theme.js +24 -31
- package/dist/src/ui/theme.js.map +1 -0
- package/dist/src/ui/update.js +126 -0
- package/dist/src/ui/update.js.map +1 -0
- package/dist/src/usage.js +0 -5
- package/dist/src/usage.js.map +1 -1
- package/dist/src/values.js +5 -0
- package/dist/src/values.js.map +1 -0
- package/package.json +16 -8
- package/src/agent/voice-sidecar.py +730 -0
- package/dist/src/console.js.map +0 -1
- package/dist/src/tui/acp/projection.js.map +0 -1
- package/dist/src/tui/acp/server.js.map +0 -1
- package/dist/src/tui/agent-configuration.js.map +0 -1
- package/dist/src/tui/background/activity.js.map +0 -1
- package/dist/src/tui/background/inbox.js +0 -120
- package/dist/src/tui/background/inbox.js.map +0 -1
- package/dist/src/tui/background/tasks.js +0 -98
- package/dist/src/tui/background/tasks.js.map +0 -1
- package/dist/src/tui/builtin-tools.js.map +0 -1
- package/dist/src/tui/chat/commands.js.map +0 -1
- package/dist/src/tui/chat/controller-helpers.js.map +0 -1
- package/dist/src/tui/chat/controller.js.map +0 -1
- package/dist/src/tui/chat/help.js.map +0 -1
- package/dist/src/tui/chat/panels.js +0 -407
- package/dist/src/tui/chat/panels.js.map +0 -1
- package/dist/src/tui/chat/projector.js.map +0 -1
- package/dist/src/tui/chat/sdk-projector.js.map +0 -1
- package/dist/src/tui/chat/shell.js.map +0 -1
- package/dist/src/tui/chat/types.js +0 -2
- package/dist/src/tui/chat/types.js.map +0 -1
- package/dist/src/tui/config.js.map +0 -1
- package/dist/src/tui/configuration-instructions.js +0 -14
- package/dist/src/tui/configuration-instructions.js.map +0 -1
- package/dist/src/tui/mcp/config.js.map +0 -1
- package/dist/src/tui/mcp.js +0 -98
- package/dist/src/tui/mcp.js.map +0 -1
- package/dist/src/tui/memory-options.js +0 -10
- package/dist/src/tui/memory-options.js.map +0 -1
- package/dist/src/tui/messaging.js +0 -193
- package/dist/src/tui/messaging.js.map +0 -1
- package/dist/src/tui/model/context.js +0 -69
- package/dist/src/tui/model/context.js.map +0 -1
- package/dist/src/tui/model/display.js.map +0 -1
- package/dist/src/tui/model/runtime.js.map +0 -1
- package/dist/src/tui/model/selection.js.map +0 -1
- package/dist/src/tui/npm.js.map +0 -1
- package/dist/src/tui/package-version.js.map +0 -1
- package/dist/src/tui/permissions/file-change-preview.js.map +0 -1
- package/dist/src/tui/permissions/policy.js +0 -222
- package/dist/src/tui/permissions/policy.js.map +0 -1
- package/dist/src/tui/permissions/settings.js.map +0 -1
- package/dist/src/tui/project/acp.js.map +0 -1
- package/dist/src/tui/project/archive.js +0 -241
- package/dist/src/tui/project/archive.js.map +0 -1
- package/dist/src/tui/project/configuration-secrets.js +0 -107
- package/dist/src/tui/project/configuration-secrets.js.map +0 -1
- package/dist/src/tui/project/configuration.js +0 -201
- package/dist/src/tui/project/configuration.js.map +0 -1
- package/dist/src/tui/project/export.js.map +0 -1
- package/dist/src/tui/project/import.js.map +0 -1
- package/dist/src/tui/project/module-loader.js.map +0 -1
- package/dist/src/tui/project/packaging.js.map +0 -1
- package/dist/src/tui/project/portable-dependencies.js +0 -34
- package/dist/src/tui/project/portable-dependencies.js.map +0 -1
- package/dist/src/tui/project/portable-mcp.js +0 -118
- package/dist/src/tui/project/portable-mcp.js.map +0 -1
- package/dist/src/tui/project/python.js.map +0 -1
- package/dist/src/tui/project/run.js +0 -116
- package/dist/src/tui/project/run.js.map +0 -1
- package/dist/src/tui/project/source.js.map +0 -1
- package/dist/src/tui/project/typescript.js.map +0 -1
- package/dist/src/tui/provider/aws-client.js +0 -67
- package/dist/src/tui/provider/aws-client.js.map +0 -1
- package/dist/src/tui/provider/aws-config.js.map +0 -1
- package/dist/src/tui/provider/bedrock-catalog.js.map +0 -1
- package/dist/src/tui/provider/discovery.js.map +0 -1
- package/dist/src/tui/provider/environment.js.map +0 -1
- package/dist/src/tui/provider/packages.js.map +0 -1
- package/dist/src/tui/run.js.map +0 -1
- package/dist/src/tui/runtime.js +0 -524
- package/dist/src/tui/runtime.js.map +0 -1
- package/dist/src/tui/session/agent-definition.js +0 -100
- package/dist/src/tui/session/agent-definition.js.map +0 -1
- package/dist/src/tui/session/catalog.js +0 -159
- package/dist/src/tui/session/catalog.js.map +0 -1
- package/dist/src/tui/session/context.js.map +0 -1
- package/dist/src/tui/session/conversation-helpers.js +0 -46
- package/dist/src/tui/session/conversation-helpers.js.map +0 -1
- package/dist/src/tui/session/conversations.js +0 -471
- package/dist/src/tui/session/conversations.js.map +0 -1
- package/dist/src/tui/session/desktop-profile.js.map +0 -1
- package/dist/src/tui/session/options.js +0 -44
- package/dist/src/tui/session/options.js.map +0 -1
- package/dist/src/tui/session/sessions.js.map +0 -1
- package/dist/src/tui/session/voice.js +0 -353
- package/dist/src/tui/session/voice.js.map +0 -1
- package/dist/src/tui/settings.js.map +0 -1
- package/dist/src/tui/skills.js.map +0 -1
- package/dist/src/tui/steering.js +0 -67
- package/dist/src/tui/steering.js.map +0 -1
- package/dist/src/tui/strands-backend.js.map +0 -1
- package/dist/src/tui/stream-presentation.js.map +0 -1
- package/dist/src/tui/terminal/composer.js.map +0 -1
- package/dist/src/tui/terminal/directory-picker.js +0 -76
- package/dist/src/tui/terminal/directory-picker.js.map +0 -1
- package/dist/src/tui/terminal/ink.js.map +0 -1
- package/dist/src/tui/terminal/mouse-input.js.map +0 -1
- package/dist/src/tui/terminal/open-url.js +0 -21
- package/dist/src/tui/terminal/open-url.js.map +0 -1
- package/dist/src/tui/terminal/process-tree.js.map +0 -1
- package/dist/src/tui/terminal/sanitize.js.map +0 -1
- package/dist/src/tui/terminal/shell-output.js.map +0 -1
- package/dist/src/tui/terminal/size.js.map +0 -1
- package/dist/src/tui/terminal/terminal.js.map +0 -1
- package/dist/src/tui/update-check.js +0 -37
- package/dist/src/tui/update-check.js.map +0 -1
- package/dist/src/tui/view/agents-panel.js +0 -21
- package/dist/src/tui/view/agents-panel.js.map +0 -1
- package/dist/src/tui/view/app.js +0 -1061
- package/dist/src/tui/view/app.js.map +0 -1
- package/dist/src/tui/view/chat-root.js +0 -49
- package/dist/src/tui/view/chat-root.js.map +0 -1
- package/dist/src/tui/view/chat-view.js +0 -145
- package/dist/src/tui/view/chat-view.js.map +0 -1
- package/dist/src/tui/view/command-palette.js +0 -15
- package/dist/src/tui/view/command-palette.js.map +0 -1
- package/dist/src/tui/view/custom-theme-editor.js +0 -301
- package/dist/src/tui/view/custom-theme-editor.js.map +0 -1
- package/dist/src/tui/view/effort-panel.js +0 -15
- package/dist/src/tui/view/effort-panel.js.map +0 -1
- package/dist/src/tui/view/export-panel.js +0 -14
- package/dist/src/tui/view/export-panel.js.map +0 -1
- package/dist/src/tui/view/fade-in.js.map +0 -1
- package/dist/src/tui/view/frog-canvas.js.map +0 -1
- package/dist/src/tui/view/frog-drawing.js.map +0 -1
- package/dist/src/tui/view/frog-easter-egg.js.map +0 -1
- package/dist/src/tui/view/frog-intro-renderer.js.map +0 -1
- package/dist/src/tui/view/help-footer.js +0 -48
- package/dist/src/tui/view/help-footer.js.map +0 -1
- package/dist/src/tui/view/interaction.js +0 -352
- package/dist/src/tui/view/interaction.js.map +0 -1
- package/dist/src/tui/view/markdown.js.map +0 -1
- package/dist/src/tui/view/mcp-trust-prompt.js +0 -17
- package/dist/src/tui/view/mcp-trust-prompt.js.map +0 -1
- package/dist/src/tui/view/media.js +0 -70
- package/dist/src/tui/view/media.js.map +0 -1
- package/dist/src/tui/view/model-panel.js +0 -77
- package/dist/src/tui/view/model-panel.js.map +0 -1
- package/dist/src/tui/view/panel-components.js +0 -17
- package/dist/src/tui/view/panel-components.js.map +0 -1
- package/dist/src/tui/view/panels.js +0 -139
- package/dist/src/tui/view/panels.js.map +0 -1
- package/dist/src/tui/view/presentation.js.map +0 -1
- package/dist/src/tui/view/prompt-editor.js +0 -82
- package/dist/src/tui/view/prompt-editor.js.map +0 -1
- package/dist/src/tui/view/provider-list.js +0 -14
- package/dist/src/tui/view/provider-list.js.map +0 -1
- package/dist/src/tui/view/rename-panel.js +0 -11
- package/dist/src/tui/view/rename-panel.js.map +0 -1
- package/dist/src/tui/view/sessions-panel.js +0 -15
- package/dist/src/tui/view/sessions-panel.js.map +0 -1
- package/dist/src/tui/view/settings-panel.js +0 -146
- package/dist/src/tui/view/settings-panel.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/brand.js +0 -34
- package/dist/src/tui/view/setup-wizard/brand.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/index.js +0 -1638
- package/dist/src/tui/view/setup-wizard/index.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/opening-menu.js +0 -99
- package/dist/src/tui/view/setup-wizard/opening-menu.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/path-completion.js +0 -53
- package/dist/src/tui/view/setup-wizard/path-completion.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/profile-fields.js +0 -29
- package/dist/src/tui/view/setup-wizard/profile-fields.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/progress.js +0 -43
- package/dist/src/tui/view/setup-wizard/progress.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/providers.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/settings-panel.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/steps.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/types.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/use-provider-discovery.js +0 -143
- package/dist/src/tui/view/setup-wizard/use-provider-discovery.js.map +0 -1
- package/dist/src/tui/view/startup-view.js +0 -79
- package/dist/src/tui/view/startup-view.js.map +0 -1
- package/dist/src/tui/view/text-input.js +0 -33
- package/dist/src/tui/view/text-input.js.map +0 -1
- package/dist/src/tui/view/theme-detection.js +0 -45
- package/dist/src/tui/view/theme-detection.js.map +0 -1
- package/dist/src/tui/view/theme.js.map +0 -1
- package/dist/src/tui/view/transcript-layout.js +0 -60
- package/dist/src/tui/view/transcript-layout.js.map +0 -1
- package/dist/src/tui/view/transcript-turn.js +0 -135
- package/dist/src/tui/view/transcript-turn.js.map +0 -1
- package/dist/src/tui/view/transcript.js.map +0 -1
- package/dist/src/tui/view/use-party-frame.js +0 -15
- package/dist/src/tui/view/use-party-frame.js.map +0 -1
- package/dist/src/tui/view/use-spinner.js +0 -14
- package/dist/src/tui/view/use-spinner.js.map +0 -1
- package/dist/src/tui/voice/session.js.map +0 -1
- package/dist/src/tui/workspace/sandbox.js.map +0 -1
- package/dist/src/tui/workspace/trust.js.map +0 -1
- package/src/tui/voice/sidecar.py +0 -631
- /package/dist/src/{tui/view/setup-wizard → agent}/types.js +0 -0
- /package/dist/src/{tui/provider → model}/packages.js +0 -0
- /package/dist/src/{tui/terminal → terminal}/ink.js +0 -0
- /package/dist/src/{tui/terminal → terminal}/mouse-input.js +0 -0
- /package/dist/src/{tui → terminal}/npm.js +0 -0
- /package/dist/src/{tui/terminal → terminal}/process-tree.js +0 -0
- /package/dist/src/{tui/terminal → terminal}/shell-output.js +0 -0
- /package/dist/src/{tui → ui/chat}/stream-presentation.js +0 -0
|
@@ -0,0 +1,1907 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createElement, useCallback, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore, } from 'react';
|
|
3
|
+
import { renderToString, useApp, useInput, usePaste, useStdout } from 'ink';
|
|
4
|
+
import { commandAssistance, parseCommandInvocation } from './commands.js';
|
|
5
|
+
import { isActiveTask, isConfigurationTool } from './state.js';
|
|
6
|
+
import { filePathsFromPaste, loadAttachments } from './attachments.js';
|
|
7
|
+
import { splitArguments } from '../../terminal/arguments.js';
|
|
8
|
+
import { SETTINGS_UPDATE_ACTION, permissionEscapeRow, settingsUpdateRow, } from './panel-state.js';
|
|
9
|
+
import { readCliVersion } from '../../package-version.js';
|
|
10
|
+
import { errorMessage, graphemes, sanitizeTerminalText } from '../../terminal/text.js';
|
|
11
|
+
import { useTerminalSize } from '../terminal-size.js';
|
|
12
|
+
import { browsingHistory, completeSuggestion, emptyEditor, reduceInputSequence, submitEditor, } from '../../terminal/composer.js';
|
|
13
|
+
import { parseMouseInput, selectScreenText, shouldProcessMouseInput, } from '../../terminal/mouse-input.js';
|
|
14
|
+
import { copyTerminalText, setTerminalMouseMotion } from '../../terminal/terminal.js';
|
|
15
|
+
import { openExternalUrl } from '../../terminal/open-url.js';
|
|
16
|
+
import { openAgentProject } from '../../terminal/open-editor.js';
|
|
17
|
+
import { canUseNativePicker, chooseFiles } from '../../terminal/directory-picker.js';
|
|
18
|
+
import { ChatView, QUEUED_PROMPT_ACTIONS } from './view.js';
|
|
19
|
+
import { agentGridLayout, moveAgentGridSelection, revealAgentGridSelection, scrollAgentGridViewport, } from '../panels/agents.js';
|
|
20
|
+
import { panelModelId } from '../footer.js';
|
|
21
|
+
import { errorPanelLayout, activateMetadataTarget, adjacentSliderOption, awsProfileItems, composerPanelContentHeight, composerPanelHeight, composerStatusLayout, configurationDockCodeSize, configurationDockHeight, configurationDockWidth, cycleModelPanelFocus, cycleMultiColumnPanelSelection, cyclePanelFilter, detailPageSize, elementAtMouse, elementContainsMouse, filterPanelRows, initialPanelFilter, isComposerPanel, mouseScrollDirection, moveMultiColumnPanelSelection, movePermissionSelection, moveSelection, panelRowCapacity, parsePanelControlTarget, permissionPanelLayout, registerElement, revealPanelSelection, scrollDetail, scrollPanelViewport, scrollTranscript, settingArrowValue, shouldToggleVoiceMute, sliderOptionAtMouse, } from '../interaction.js';
|
|
22
|
+
import { parseFrogCommand } from '../frog.js';
|
|
23
|
+
import { maxDetailScroll, maxPermissionScroll } from '../presentation.js';
|
|
24
|
+
import { CONFIGURATION_OPEN_CONTROL, configurationDocument, maxConfigurationScroll, passiveConfigurationDockHeight, } from '../panels/configuration.js';
|
|
25
|
+
import { ThemeProvider } from '../theme.js';
|
|
26
|
+
import { UpdatePrompt } from '../update.js';
|
|
27
|
+
export function ChatApp({ controller, introStartedAt, entranceFade, openUrl = openExternalUrl, openProject = openAgentProject, availableUpdate, updateStatus, promptForUpdate = false, developmentCheckout = readCliVersion().includes('development'), onRequestUpdate = () => { }, onDismissUpdate = () => { }, }) {
|
|
28
|
+
const snapshot = useSyncExternalStore(controller.subscribe, controller.getSnapshot);
|
|
29
|
+
const cliVersion = readCliVersion();
|
|
30
|
+
const [footerElements, registerFooterElement] = useElementMap();
|
|
31
|
+
const { exit, suspendTerminal } = useApp();
|
|
32
|
+
const { stdout } = useStdout();
|
|
33
|
+
const { columns: width, rows: height } = useTerminalSize();
|
|
34
|
+
const [editor, setEditorState] = useState(emptyEditor);
|
|
35
|
+
const [inputRevision, setInputRevision] = useState(0);
|
|
36
|
+
const [attachments, setAttachmentState] = useState([]);
|
|
37
|
+
const [suggestionSelection, setSuggestionSelection] = useState(0);
|
|
38
|
+
const [dismissedSuggestions, setDismissedSuggestions] = useState();
|
|
39
|
+
const [panelSelection, setPanelSelection] = useState(0);
|
|
40
|
+
const [panelQuery, setPanelQuery] = useState('');
|
|
41
|
+
const [agentNameEditor, setAgentNameEditor] = useState(emptyEditor);
|
|
42
|
+
const [panelFilter, setPanelFilter] = useState('all');
|
|
43
|
+
const [dockLanguage, setDockLanguage] = useState(undefined);
|
|
44
|
+
const [dockScroll, setDockScroll] = useState(undefined);
|
|
45
|
+
const [modelPanelFocus, setModelPanelFocus] = useState('providers');
|
|
46
|
+
const [modelProfileSelection, setModelProfileSelection] = useState(0);
|
|
47
|
+
const [settingsPanelFocus, setSettingsPanelFocus] = useState('categories');
|
|
48
|
+
const [panelViewportStart, setPanelViewportStart] = useState(0);
|
|
49
|
+
const [detailScroll, setDetailScroll] = useState(0);
|
|
50
|
+
const [transcriptScroll, setTranscriptScroll] = useState(0);
|
|
51
|
+
const [statusScroll, setStatusScroll] = useState(0);
|
|
52
|
+
// A ref, not state: the maximum changes on every streamed line and only clamps scroll input.
|
|
53
|
+
const maxTranscriptScrollRef = useRef(0);
|
|
54
|
+
const [pressedMetadata, setPressedMetadata] = useState();
|
|
55
|
+
const [hoveredMetadata, setHoveredMetadata] = useState();
|
|
56
|
+
const [pressedPanelFilter, setPressedPanelFilter] = useState();
|
|
57
|
+
const [pressedPanelRow, setPressedPanelRow] = useState();
|
|
58
|
+
const [pressedPanelControl, setPressedPanelControl] = useState();
|
|
59
|
+
const [pressedSuggestion, setPressedSuggestion] = useState();
|
|
60
|
+
const [hoveredPanelRow, setHoveredPanelRow] = useState();
|
|
61
|
+
const [hoveredPanelControl, setHoveredPanelControl] = useState();
|
|
62
|
+
const [hoveredPanelFilter, setHoveredPanelFilter] = useState();
|
|
63
|
+
const [hoveredSuggestion, setHoveredSuggestion] = useState();
|
|
64
|
+
const [hoveredAction, setHoveredAction] = useState();
|
|
65
|
+
const [hoveredJumpToBottom, setHoveredJumpToBottom] = useState(false);
|
|
66
|
+
const [updatePromptVersion, setUpdatePromptVersion] = useState();
|
|
67
|
+
const [pressedQueuedPrompt, setPressedQueuedPrompt] = useState();
|
|
68
|
+
const [focusedQueuedPrompt, setFocusedQueuedPrompt] = useState();
|
|
69
|
+
const [focusedBackgroundTask, setFocusedBackgroundTask] = useState();
|
|
70
|
+
const [hoveredBackgroundTask, setHoveredBackgroundTask] = useState(false);
|
|
71
|
+
const [editingQueuedPromptId, setEditingQueuedPromptId] = useState();
|
|
72
|
+
const [screenSelection, setScreenSelection] = useState([]);
|
|
73
|
+
const [clipboardNotice, setClipboardNotice] = useState();
|
|
74
|
+
const [frog, setFrog] = useState();
|
|
75
|
+
const [frogBrandAnimationId, setFrogBrandAnimationId] = useState();
|
|
76
|
+
const [party, setParty] = useState(false);
|
|
77
|
+
const [expandedToolGroups, setExpandedToolGroups] = useState(new Set());
|
|
78
|
+
const editorRef = useRef(editor);
|
|
79
|
+
const attachmentsRef = useRef(attachments);
|
|
80
|
+
const conversationDrafts = useRef(new Map());
|
|
81
|
+
const editorConversation = useRef(snapshot.conversationId);
|
|
82
|
+
const attachmentWorkRef = useRef({ pending: Promise.resolve() });
|
|
83
|
+
const pendingInputRef = useRef(undefined);
|
|
84
|
+
const inputCommitRef = useRef({
|
|
85
|
+
revision: 0,
|
|
86
|
+
resolve: undefined,
|
|
87
|
+
});
|
|
88
|
+
const queuedPromptDraftRef = useRef(undefined);
|
|
89
|
+
const nextFrogId = useRef(0);
|
|
90
|
+
const nextFrogBrandAnimationId = useRef(0);
|
|
91
|
+
const previousFrogVariant = useRef(undefined);
|
|
92
|
+
const leftMouseDownRef = useRef(false);
|
|
93
|
+
const copyNoticeTimerRef = useRef(undefined);
|
|
94
|
+
const selectionDragRef = useRef(undefined);
|
|
95
|
+
const panelSliderDraggingRef = useRef(false);
|
|
96
|
+
const panelSliderValueRef = useRef(undefined);
|
|
97
|
+
const mouseMoveStateRef = useRef({
|
|
98
|
+
column: -1,
|
|
99
|
+
row: -1,
|
|
100
|
+
acceptedAt: Number.NEGATIVE_INFINITY,
|
|
101
|
+
});
|
|
102
|
+
const suggestionSelectionRef = useRef(0);
|
|
103
|
+
const panelSelectionRef = useRef(0);
|
|
104
|
+
const panelViewportStartRef = useRef(0);
|
|
105
|
+
const detailReturnRef = useRef(undefined);
|
|
106
|
+
const [metadataElements, registerMetadataElement] = useElementMap();
|
|
107
|
+
const panelElement = useRef(undefined);
|
|
108
|
+
const dockElement = useRef(undefined);
|
|
109
|
+
const [panelRowElements, registerPanelRowElement] = useElementMap();
|
|
110
|
+
const [panelControlElements, registerPanelControlElement] = useElementMap();
|
|
111
|
+
const [panelFilterElements, registerPanelFilterElement] = useElementMap();
|
|
112
|
+
const panelSearchElement = useRef(undefined);
|
|
113
|
+
const panelSliderElement = useRef(undefined);
|
|
114
|
+
const [suggestionElements, registerSuggestionElement] = useElementMap();
|
|
115
|
+
const [queuedPromptElements, registerQueuedPromptElement] = useElementMap();
|
|
116
|
+
const statusElement = useRef(undefined);
|
|
117
|
+
const backgroundTaskElement = useRef(undefined);
|
|
118
|
+
const [toolGroupElements, registerToolGroupElement] = useElementMap();
|
|
119
|
+
const frogElement = useRef(undefined);
|
|
120
|
+
const jumpToBottomElement = useRef(undefined);
|
|
121
|
+
const frogPressRef = useRef(undefined);
|
|
122
|
+
const toolGroupPressRef = useRef(undefined);
|
|
123
|
+
const consideredStartupUpdate = useRef(undefined);
|
|
124
|
+
const startupUpdatePrompt = useRef(false);
|
|
125
|
+
const restartedIntroAt = useRef(undefined);
|
|
126
|
+
const installableUpdate = developmentCheckout ? undefined : availableUpdate;
|
|
127
|
+
const settingsUpdateStatus = updateStatus ?? (developmentCheckout ? 'development' : installableUpdate ? 'available' : 'checking');
|
|
128
|
+
const setEditor = useCallback((next) => {
|
|
129
|
+
editorRef.current = next;
|
|
130
|
+
setEditorState(next);
|
|
131
|
+
}, []);
|
|
132
|
+
const setAttachments = useCallback((next) => {
|
|
133
|
+
attachmentsRef.current = next;
|
|
134
|
+
setAttachmentState(next);
|
|
135
|
+
}, []);
|
|
136
|
+
useLayoutEffect(() => {
|
|
137
|
+
if (editorConversation.current === snapshot.conversationId)
|
|
138
|
+
return;
|
|
139
|
+
conversationDrafts.current.set(editorConversation.current, {
|
|
140
|
+
editor: editorRef.current,
|
|
141
|
+
attachments: attachmentsRef.current,
|
|
142
|
+
});
|
|
143
|
+
editorConversation.current = snapshot.conversationId;
|
|
144
|
+
const draft = conversationDrafts.current.get(snapshot.conversationId);
|
|
145
|
+
setEditor(draft?.editor ?? emptyEditor());
|
|
146
|
+
setAttachments(draft?.attachments ?? []);
|
|
147
|
+
setTranscriptScroll(0);
|
|
148
|
+
}, [snapshot.conversationId, setEditor, setAttachments]);
|
|
149
|
+
const clearAttachments = useCallback(() => {
|
|
150
|
+
attachmentWorkRef.current = { pending: Promise.resolve() };
|
|
151
|
+
setAttachments([]);
|
|
152
|
+
}, [setAttachments]);
|
|
153
|
+
const cancelPendingInput = useCallback(() => {
|
|
154
|
+
pendingInputRef.current?.events.splice(0);
|
|
155
|
+
pendingInputRef.current = undefined;
|
|
156
|
+
attachmentWorkRef.current = { pending: Promise.resolve() };
|
|
157
|
+
inputCommitRef.current.resolve?.();
|
|
158
|
+
inputCommitRef.current.resolve = undefined;
|
|
159
|
+
}, []);
|
|
160
|
+
const handleExit = useCallback((exitCode) => {
|
|
161
|
+
cancelPendingInput();
|
|
162
|
+
if (!controller.busy || !controller.cancel()) {
|
|
163
|
+
controller.close(exitCode);
|
|
164
|
+
}
|
|
165
|
+
}, [cancelPendingInput, controller]);
|
|
166
|
+
const currentInputQueue = useCallback(() => {
|
|
167
|
+
const pending = pendingInputRef.current;
|
|
168
|
+
const current = controller.getSnapshot();
|
|
169
|
+
if (pending &&
|
|
170
|
+
(pending.controller !== controller ||
|
|
171
|
+
pending.conversationId !== current.conversationId ||
|
|
172
|
+
pending.panelId !== current.panel?.id ||
|
|
173
|
+
current.panel?.kind === 'permission' ||
|
|
174
|
+
updatePromptVersion !== undefined ||
|
|
175
|
+
current.status === 'closed')) {
|
|
176
|
+
cancelPendingInput();
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
return pending;
|
|
180
|
+
}, [cancelPendingInput, controller, updatePromptVersion]);
|
|
181
|
+
const rememberDetailParent = useCallback(() => {
|
|
182
|
+
const current = viewPropsRef.current;
|
|
183
|
+
detailReturnRef.current = {
|
|
184
|
+
id: current.snapshot.panel.id,
|
|
185
|
+
query: current.panelQuery,
|
|
186
|
+
filter: current.panelFilter,
|
|
187
|
+
selection: panelSelectionRef.current,
|
|
188
|
+
viewport: panelViewportStartRef.current,
|
|
189
|
+
};
|
|
190
|
+
}, []);
|
|
191
|
+
const resetPanelPosition = useCallback(() => {
|
|
192
|
+
panelSelectionRef.current = 0;
|
|
193
|
+
panelViewportStartRef.current = 0;
|
|
194
|
+
setPanelSelection(0);
|
|
195
|
+
setPanelViewportStart(0);
|
|
196
|
+
}, []);
|
|
197
|
+
const activateRow = useCallback((row) => {
|
|
198
|
+
if (row.value === SETTINGS_UPDATE_ACTION) {
|
|
199
|
+
if (installableUpdate) {
|
|
200
|
+
setUpdatePromptVersion(installableUpdate);
|
|
201
|
+
}
|
|
202
|
+
return Promise.resolve(true);
|
|
203
|
+
}
|
|
204
|
+
const panelKind = controller.getSnapshot().panel?.kind;
|
|
205
|
+
if ((panelKind === 'help' && row.value?.startsWith('help:detail:')) ||
|
|
206
|
+
(panelKind === 'tasks' && row.value?.startsWith('task:')) ||
|
|
207
|
+
(panelKind === 'agents' && row.value?.startsWith('delegate:'))) {
|
|
208
|
+
rememberDetailParent();
|
|
209
|
+
}
|
|
210
|
+
if (panelKind === 'skills' && row.value) {
|
|
211
|
+
const input = `/${decodeURIComponent(row.value)}`;
|
|
212
|
+
const current = editorRef.current;
|
|
213
|
+
setEditor({
|
|
214
|
+
...current,
|
|
215
|
+
input,
|
|
216
|
+
cursor: graphemes(input).length,
|
|
217
|
+
historyIndex: current.history.length,
|
|
218
|
+
draft: input,
|
|
219
|
+
});
|
|
220
|
+
controller.dismissPanel();
|
|
221
|
+
return Promise.resolve(true);
|
|
222
|
+
}
|
|
223
|
+
if (panelKind === 'agents' && row.value === 'rename:save') {
|
|
224
|
+
row = { ...row, value: `rename:save:${encodeURIComponent(agentNameEditor.input)}` };
|
|
225
|
+
}
|
|
226
|
+
return controller.activatePanelRow(row).then((activated) => {
|
|
227
|
+
if (panelKind === 'models' &&
|
|
228
|
+
!row.value?.startsWith('aws-profile:') &&
|
|
229
|
+
activated &&
|
|
230
|
+
controller.getSnapshot().panel?.kind === 'models') {
|
|
231
|
+
controller.dismissPanel();
|
|
232
|
+
}
|
|
233
|
+
if (activated && row.value?.startsWith('aws-profile:')) {
|
|
234
|
+
setModelPanelFocus('profiles');
|
|
235
|
+
setModelProfileSelection(0);
|
|
236
|
+
}
|
|
237
|
+
return activated;
|
|
238
|
+
});
|
|
239
|
+
}, [agentNameEditor.input, controller, installableUpdate, rememberDetailParent, setEditor]);
|
|
240
|
+
const finishQueuedPromptEdit = useCallback(() => {
|
|
241
|
+
const draft = queuedPromptDraftRef.current;
|
|
242
|
+
queuedPromptDraftRef.current = undefined;
|
|
243
|
+
setEditingQueuedPromptId(undefined);
|
|
244
|
+
if (draft) {
|
|
245
|
+
setEditor(draft);
|
|
246
|
+
}
|
|
247
|
+
}, [setEditor]);
|
|
248
|
+
const editQueuedPrompt = useCallback((id) => {
|
|
249
|
+
const prompt = snapshot.queuedPrompts.find((candidate) => candidate.id === id && candidate.source !== 'peer');
|
|
250
|
+
if (!prompt)
|
|
251
|
+
return;
|
|
252
|
+
setFocusedQueuedPrompt(undefined);
|
|
253
|
+
const currentEditor = editorRef.current;
|
|
254
|
+
queuedPromptDraftRef.current ??= currentEditor;
|
|
255
|
+
setEditingQueuedPromptId(id);
|
|
256
|
+
setEditor({
|
|
257
|
+
...currentEditor,
|
|
258
|
+
input: prompt.prompt,
|
|
259
|
+
cursor: graphemes(prompt.prompt).length,
|
|
260
|
+
historyIndex: currentEditor.history.length,
|
|
261
|
+
draft: prompt.prompt,
|
|
262
|
+
});
|
|
263
|
+
}, [setEditor, snapshot.queuedPrompts]);
|
|
264
|
+
const activateQueuedPrompt = useCallback((value) => {
|
|
265
|
+
const target = parseQueuedPromptTarget(value);
|
|
266
|
+
if (!target)
|
|
267
|
+
return;
|
|
268
|
+
if (target.action === 'up' || target.action === 'down') {
|
|
269
|
+
controller.moveQueuedPrompt(target.id, target.action === 'up' ? -1 : 1);
|
|
270
|
+
}
|
|
271
|
+
else if (target.action === 'delete') {
|
|
272
|
+
controller.removeQueuedPrompt(target.id);
|
|
273
|
+
}
|
|
274
|
+
else if (target.action === 'steer') {
|
|
275
|
+
if (editingQueuedPromptId === target.id) {
|
|
276
|
+
controller.updateQueuedPrompt(target.id, editorRef.current.input);
|
|
277
|
+
finishQueuedPromptEdit();
|
|
278
|
+
}
|
|
279
|
+
controller.steerQueued(target.id);
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
setFocusedQueuedPrompt(undefined);
|
|
283
|
+
if (editingQueuedPromptId === target.id)
|
|
284
|
+
finishQueuedPromptEdit();
|
|
285
|
+
else
|
|
286
|
+
editQueuedPrompt(target.id);
|
|
287
|
+
}
|
|
288
|
+
}, [controller, editingQueuedPromptId, editQueuedPrompt, finishQueuedPromptEdit]);
|
|
289
|
+
const selectPanelRow = useCallback((selection, capacity, rowCount) => {
|
|
290
|
+
panelSelectionRef.current = selection;
|
|
291
|
+
setPanelSelection(selection);
|
|
292
|
+
const start = revealPanelSelection(selection, panelViewportStartRef.current, capacity, rowCount);
|
|
293
|
+
panelViewportStartRef.current = start;
|
|
294
|
+
setPanelViewportStart(start);
|
|
295
|
+
}, []);
|
|
296
|
+
const resetHover = useCallback(() => {
|
|
297
|
+
setHoveredPanelRow(undefined);
|
|
298
|
+
setHoveredPanelControl(undefined);
|
|
299
|
+
setHoveredPanelFilter(undefined);
|
|
300
|
+
setHoveredSuggestion(undefined);
|
|
301
|
+
setHoveredAction(undefined);
|
|
302
|
+
setHoveredJumpToBottom(false);
|
|
303
|
+
setHoveredMetadata(undefined);
|
|
304
|
+
setHoveredBackgroundTask(false);
|
|
305
|
+
}, []);
|
|
306
|
+
const resetPressed = useCallback(() => {
|
|
307
|
+
setPressedMetadata(undefined);
|
|
308
|
+
setPressedPanelFilter(undefined);
|
|
309
|
+
setPressedPanelRow(undefined);
|
|
310
|
+
setPressedPanelControl(undefined);
|
|
311
|
+
setPressedSuggestion(undefined);
|
|
312
|
+
setPressedQueuedPrompt(undefined);
|
|
313
|
+
}, []);
|
|
314
|
+
const actionableCommandToken = controller.actionableCommandToken(editor.input);
|
|
315
|
+
// An unedited recalled `/command` keeps the arrow keys on history instead of opening the palette.
|
|
316
|
+
const recalledEntry = browsingHistory(editor) && editor.input === editor.history[editor.historyIndex];
|
|
317
|
+
const rawAssistance = snapshot.panel || dismissedSuggestions === editor.input || recalledEntry
|
|
318
|
+
? undefined
|
|
319
|
+
: controller.commandAssistance
|
|
320
|
+
? controller.commandAssistance(editor.input)
|
|
321
|
+
: commandAssistance(editor.input, actionableCommandToken);
|
|
322
|
+
const assistance = rawAssistance &&
|
|
323
|
+
(rawAssistance.message !== undefined || rawAssistance.completions.length > 0 || /^\/[^\s]+\s$/.test(editor.input))
|
|
324
|
+
? rawAssistance
|
|
325
|
+
: undefined;
|
|
326
|
+
const suggestions = assistance?.completions ?? [];
|
|
327
|
+
const sourcePanelRows = snapshot.panel?.kind === 'settings' && snapshot.panel.settingsCategory === 'Updates'
|
|
328
|
+
? [settingsUpdateRow(cliVersion, settingsUpdateStatus), ...snapshot.panel.rows]
|
|
329
|
+
: snapshot.panel?.rows;
|
|
330
|
+
const panelRows = snapshot.panel
|
|
331
|
+
? filterPanelRows(sourcePanelRows ?? [], panelQuery, snapshot.panel.kind === 'settings' && snapshot.panel.settingsCategory ? 'all' : panelFilter, snapshot.panel.kind === 'models')
|
|
332
|
+
: undefined;
|
|
333
|
+
const composerHeight = isComposerPanel(snapshot.panel?.kind)
|
|
334
|
+
? composerPanelHeight(snapshot, height, party, width)
|
|
335
|
+
: undefined;
|
|
336
|
+
const statusLayout = composerStatusLayout(snapshot, height);
|
|
337
|
+
useEffect(() => {
|
|
338
|
+
setStatusScroll((value) => Math.min(value, statusLayout.maxScroll));
|
|
339
|
+
}, [statusLayout.maxScroll]);
|
|
340
|
+
useEffect(() => {
|
|
341
|
+
setStatusScroll(0);
|
|
342
|
+
setFocusedQueuedPrompt(undefined);
|
|
343
|
+
setFocusedBackgroundTask(undefined);
|
|
344
|
+
}, [controller, snapshot.conversationId]);
|
|
345
|
+
useEffect(() => {
|
|
346
|
+
if (focusedBackgroundTask &&
|
|
347
|
+
!snapshot.tasks.some((task) => task.id === focusedBackgroundTask && isActiveTask(task.status))) {
|
|
348
|
+
setFocusedBackgroundTask(undefined);
|
|
349
|
+
}
|
|
350
|
+
}, [focusedBackgroundTask, snapshot.tasks]);
|
|
351
|
+
useEffect(() => {
|
|
352
|
+
if (!focusedQueuedPrompt)
|
|
353
|
+
return;
|
|
354
|
+
const target = parseQueuedPromptTarget(focusedQueuedPrompt);
|
|
355
|
+
const index = snapshot.queuedPrompts.findIndex((prompt) => prompt.id === target?.id && prompt.source !== 'peer');
|
|
356
|
+
if (index < 0) {
|
|
357
|
+
setFocusedQueuedPrompt(undefined);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
setStatusScroll((value) => revealPanelSelection(snapshot.pendingSteering.length + index, value, statusLayout.viewportHeight, statusLayout.maxScroll + statusLayout.viewportHeight));
|
|
361
|
+
}, [
|
|
362
|
+
focusedQueuedPrompt,
|
|
363
|
+
snapshot.queuedPrompts,
|
|
364
|
+
snapshot.pendingSteering.length,
|
|
365
|
+
statusLayout.viewportHeight,
|
|
366
|
+
statusLayout.maxScroll,
|
|
367
|
+
]);
|
|
368
|
+
const viewProps = {
|
|
369
|
+
agentNameEditor,
|
|
370
|
+
snapshot,
|
|
371
|
+
input: editor.input,
|
|
372
|
+
cursor: editor.cursor,
|
|
373
|
+
terminalWidth: width,
|
|
374
|
+
terminalHeight: height,
|
|
375
|
+
suggestions,
|
|
376
|
+
...(panelRows ? { panelRows } : {}),
|
|
377
|
+
panelQuery,
|
|
378
|
+
panelFilter,
|
|
379
|
+
modelPanelFocus,
|
|
380
|
+
modelProfileSelection,
|
|
381
|
+
settingsPanelFocus,
|
|
382
|
+
panelViewportStart,
|
|
383
|
+
suggestionSelection,
|
|
384
|
+
panelSelection,
|
|
385
|
+
detailScroll,
|
|
386
|
+
...(dockLanguage ? { dockLanguage } : {}),
|
|
387
|
+
...(dockScroll !== undefined ? { dockScroll } : {}),
|
|
388
|
+
transcriptScroll,
|
|
389
|
+
statusScroll,
|
|
390
|
+
...(actionableCommandToken ? { actionableCommandToken } : {}),
|
|
391
|
+
...(assistance ? { commandAssistance: assistance } : {}),
|
|
392
|
+
...(composerHeight !== undefined ? { composerHeight } : {}),
|
|
393
|
+
party,
|
|
394
|
+
expandedToolGroups,
|
|
395
|
+
attachments,
|
|
396
|
+
...(focusedBackgroundTask ? { focusedBackgroundTask } : {}),
|
|
397
|
+
hoveredBackgroundTask,
|
|
398
|
+
};
|
|
399
|
+
const viewPropsRef = useRef(viewProps);
|
|
400
|
+
viewPropsRef.current = viewProps;
|
|
401
|
+
const registerPanelElement = useCallback((element) => {
|
|
402
|
+
panelElement.current = element ?? undefined;
|
|
403
|
+
}, []);
|
|
404
|
+
const registerDockElement = useCallback((element) => {
|
|
405
|
+
dockElement.current = element ?? undefined;
|
|
406
|
+
}, []);
|
|
407
|
+
const registerStatusElement = useCallback((element) => {
|
|
408
|
+
statusElement.current = element ?? undefined;
|
|
409
|
+
}, []);
|
|
410
|
+
const registerBackgroundTaskElement = useCallback((element) => {
|
|
411
|
+
backgroundTaskElement.current = element ?? undefined;
|
|
412
|
+
}, []);
|
|
413
|
+
const registerPanelSearchElement = useCallback((element) => {
|
|
414
|
+
panelSearchElement.current = element ?? undefined;
|
|
415
|
+
}, []);
|
|
416
|
+
const registerPanelSliderElement = useCallback((element) => {
|
|
417
|
+
panelSliderElement.current = element ?? undefined;
|
|
418
|
+
}, []);
|
|
419
|
+
const registerFrogElement = useCallback((element) => {
|
|
420
|
+
frogElement.current = element ?? undefined;
|
|
421
|
+
}, []);
|
|
422
|
+
const registerJumpToBottomElement = useCallback((element) => {
|
|
423
|
+
jumpToBottomElement.current = element ?? undefined;
|
|
424
|
+
}, []);
|
|
425
|
+
const updateMaxTranscriptScroll = useCallback((maximum) => {
|
|
426
|
+
maxTranscriptScrollRef.current = maximum;
|
|
427
|
+
setTranscriptScroll((value) => Math.min(value, maximum));
|
|
428
|
+
}, []);
|
|
429
|
+
const attachPaths = useCallback((paths, work = attachmentWorkRef.current) => {
|
|
430
|
+
if (work !== attachmentWorkRef.current)
|
|
431
|
+
return Promise.resolve();
|
|
432
|
+
work.pending = work.pending.then(async () => {
|
|
433
|
+
if (work !== attachmentWorkRef.current)
|
|
434
|
+
return;
|
|
435
|
+
try {
|
|
436
|
+
const loaded = await loadAttachments([...attachmentsRef.current.map((attachment) => attachment.path), ...paths], controller.getSnapshot().runtime.cwd);
|
|
437
|
+
if (work === attachmentWorkRef.current)
|
|
438
|
+
setAttachments(loaded);
|
|
439
|
+
}
|
|
440
|
+
catch (cause) {
|
|
441
|
+
if (work === attachmentWorkRef.current)
|
|
442
|
+
controller.showError?.('attachment failed', errorMessage(cause));
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
return work.pending;
|
|
446
|
+
}, [controller, setAttachments]);
|
|
447
|
+
const handleFileCommand = useCallback(async (argument) => {
|
|
448
|
+
if (argument.trim().toLowerCase() === 'clear') {
|
|
449
|
+
clearAttachments();
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
if (argument.trim()) {
|
|
453
|
+
try {
|
|
454
|
+
await attachPaths(splitArguments(argument));
|
|
455
|
+
}
|
|
456
|
+
catch (cause) {
|
|
457
|
+
controller.showError?.('attachment failed', errorMessage(cause));
|
|
458
|
+
}
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
if (!canUseNativePicker()) {
|
|
462
|
+
controller.showError?.('file picker unavailable', 'Use /file <path> to attach one or more files.');
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
const work = attachmentWorkRef.current;
|
|
466
|
+
try {
|
|
467
|
+
const paths = await chooseFiles();
|
|
468
|
+
if (paths.length > 0) {
|
|
469
|
+
await attachPaths(paths, work);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
catch (cause) {
|
|
473
|
+
if (work === attachmentWorkRef.current)
|
|
474
|
+
controller.showError?.('file picker failed', errorMessage(cause));
|
|
475
|
+
}
|
|
476
|
+
}, [attachPaths, clearAttachments, controller]);
|
|
477
|
+
const dispatchPrompt = useCallback((prompt) => {
|
|
478
|
+
if (editingQueuedPromptId && controller.updateQueuedPrompt(editingQueuedPromptId, prompt)) {
|
|
479
|
+
finishQueuedPromptEdit();
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
const command = prompt.trim().toLowerCase();
|
|
483
|
+
const invocation = parseCommandInvocation(prompt.trim());
|
|
484
|
+
if (invocation?.prefix === '/' && invocation.name.toLowerCase() === 'file') {
|
|
485
|
+
void handleFileCommand(invocation.argument);
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
if (command === '/party') {
|
|
489
|
+
setParty((enabled) => !enabled);
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
if (command === '/strands') {
|
|
493
|
+
openUrl('https://strandsagents.com');
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
const variant = parseFrogCommand(prompt, previousFrogVariant.current);
|
|
497
|
+
if (variant) {
|
|
498
|
+
nextFrogId.current += 1;
|
|
499
|
+
previousFrogVariant.current = variant;
|
|
500
|
+
setFrog({ id: nextFrogId.current, variant });
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
if (!/^[!/$]/.test(prompt.trimStart())) {
|
|
504
|
+
const pendingAttachments = attachmentsRef.current;
|
|
505
|
+
clearAttachments();
|
|
506
|
+
if (pendingAttachments.length > 0) {
|
|
507
|
+
void controller.submit({ text: prompt, attachments: pendingAttachments });
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
void controller.submit(prompt);
|
|
512
|
+
}, [clearAttachments, controller, editingQueuedPromptId, finishQueuedPromptEdit, handleFileCommand, openUrl]);
|
|
513
|
+
const finishFrog = useCallback((id) => {
|
|
514
|
+
setFrog((current) => (current?.id === id ? undefined : current));
|
|
515
|
+
}, []);
|
|
516
|
+
const openConfigurationProject = useCallback(() => {
|
|
517
|
+
const project = controller.getSnapshot().configuration?.project;
|
|
518
|
+
if (!project)
|
|
519
|
+
return;
|
|
520
|
+
void suspendTerminal(() => openProject(project)).catch((cause) => {
|
|
521
|
+
controller.showError?.('could not open project', `${project.root}\n${errorMessage(cause)}`);
|
|
522
|
+
});
|
|
523
|
+
}, [controller, openProject, suspendTerminal]);
|
|
524
|
+
useLayoutEffect(() => {
|
|
525
|
+
const { snapshot, terminalWidth, terminalHeight, panelRows, composerHeight } = viewPropsRef.current;
|
|
526
|
+
if (snapshot.panel && panelRows) {
|
|
527
|
+
if (snapshot.panel.kind === 'agents') {
|
|
528
|
+
const { capacity, columns } = agentGridLayout(terminalWidth, terminalHeight);
|
|
529
|
+
const start = revealAgentGridSelection(panelSelectionRef.current, panelViewportStartRef.current, capacity, panelRows.length, columns);
|
|
530
|
+
panelViewportStartRef.current = start;
|
|
531
|
+
setPanelViewportStart(start);
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
const capacity = panelRowCapacity(snapshot.panel.kind, composerHeight === undefined ? terminalHeight : composerPanelContentHeight(snapshot.panel, composerHeight));
|
|
535
|
+
const start = revealPanelSelection(panelSelectionRef.current, panelViewportStartRef.current, capacity, panelRows.length);
|
|
536
|
+
panelViewportStartRef.current = start;
|
|
537
|
+
setPanelViewportStart(start);
|
|
538
|
+
}
|
|
539
|
+
}, [width, height, composerHeight]);
|
|
540
|
+
useEffect(() => {
|
|
541
|
+
if (snapshot.status === 'closed') {
|
|
542
|
+
cancelPendingInput();
|
|
543
|
+
exit();
|
|
544
|
+
}
|
|
545
|
+
}, [cancelPendingInput, exit, snapshot.status]);
|
|
546
|
+
useLayoutEffect(() => cancelPendingInput, [cancelPendingInput, controller, snapshot.conversationId, updatePromptVersion]);
|
|
547
|
+
useLayoutEffect(() => {
|
|
548
|
+
const commit = inputCommitRef.current;
|
|
549
|
+
if (commit.revision === inputRevision) {
|
|
550
|
+
commit.resolve?.();
|
|
551
|
+
commit.resolve = undefined;
|
|
552
|
+
}
|
|
553
|
+
}, [inputRevision]);
|
|
554
|
+
useEffect(() => {
|
|
555
|
+
suggestionSelectionRef.current = 0;
|
|
556
|
+
setSuggestionSelection(0);
|
|
557
|
+
setDismissedSuggestions(undefined);
|
|
558
|
+
}, [editor.input]);
|
|
559
|
+
useLayoutEffect(() => {
|
|
560
|
+
resetPanelPosition();
|
|
561
|
+
if (snapshot.panel?.kind === 'agents' && snapshot.panel.renameInput) {
|
|
562
|
+
const { id, defaultName } = snapshot.panel.renameInput;
|
|
563
|
+
setAgentNameEditor({ ...emptyEditor(), input: defaultName, cursor: graphemes(defaultName).length });
|
|
564
|
+
const selected = snapshot.panel.rows.findIndex((row) => row.value === `conversation:${encodeURIComponent(id)}`);
|
|
565
|
+
panelSelectionRef.current = Math.max(0, selected);
|
|
566
|
+
setPanelSelection(panelSelectionRef.current);
|
|
567
|
+
const { capacity, columns } = agentGridLayout(width, height);
|
|
568
|
+
const start = revealAgentGridSelection(selected, 0, capacity, snapshot.panel.rows.length, columns);
|
|
569
|
+
panelViewportStartRef.current = start;
|
|
570
|
+
setPanelViewportStart(start);
|
|
571
|
+
}
|
|
572
|
+
if (snapshot.panel?.kind === 'permission' && snapshot.panel.selected !== undefined) {
|
|
573
|
+
panelSelectionRef.current = snapshot.panel.selected;
|
|
574
|
+
setPanelSelection(snapshot.panel.selected);
|
|
575
|
+
}
|
|
576
|
+
setPanelQuery('');
|
|
577
|
+
setModelProfileSelection(0);
|
|
578
|
+
setPanelFilter(initialPanelFilter(snapshot.panel));
|
|
579
|
+
setModelPanelFocus(snapshot.panel?.kind === 'permissions'
|
|
580
|
+
? 'providers'
|
|
581
|
+
: (snapshot.panel?.kind === 'models' ||
|
|
582
|
+
snapshot.panel?.kind === 'sessions' ||
|
|
583
|
+
snapshot.panel?.kind === 'help') &&
|
|
584
|
+
snapshot.panel.filters?.length
|
|
585
|
+
? 'providers'
|
|
586
|
+
: 'models');
|
|
587
|
+
const detailReturn = detailReturnRef.current;
|
|
588
|
+
if (snapshot.panel && snapshot.panel.id === detailReturn?.id) {
|
|
589
|
+
const rows = filterPanelRows(snapshot.panel.rows, detailReturn.query, detailReturn.filter);
|
|
590
|
+
const selected = Math.max(0, Math.min(detailReturn.selection, rows.length - 1));
|
|
591
|
+
const capacity = panelRowCapacity(snapshot.panel.kind, composerPanelHeight(snapshot, height, party, width));
|
|
592
|
+
const start = revealPanelSelection(selected, detailReturn.viewport, capacity, rows.length);
|
|
593
|
+
setPanelQuery(detailReturn.query);
|
|
594
|
+
setPanelFilter(detailReturn.filter);
|
|
595
|
+
setModelPanelFocus('models');
|
|
596
|
+
panelSelectionRef.current = selected;
|
|
597
|
+
setPanelSelection(selected);
|
|
598
|
+
panelViewportStartRef.current = start;
|
|
599
|
+
setPanelViewportStart(start);
|
|
600
|
+
}
|
|
601
|
+
if (snapshot.panel?.kind !== 'help-detail' && snapshot.panel?.kind !== 'detail') {
|
|
602
|
+
detailReturnRef.current = undefined;
|
|
603
|
+
}
|
|
604
|
+
setSettingsPanelFocus('categories');
|
|
605
|
+
setPressedPanelFilter(undefined);
|
|
606
|
+
setPressedPanelRow(undefined);
|
|
607
|
+
setPressedPanelControl(undefined);
|
|
608
|
+
resetHover();
|
|
609
|
+
setPressedQueuedPrompt(undefined);
|
|
610
|
+
setFocusedQueuedPrompt(undefined);
|
|
611
|
+
setFocusedBackgroundTask(undefined);
|
|
612
|
+
setDetailScroll(0);
|
|
613
|
+
panelSliderDraggingRef.current = false;
|
|
614
|
+
panelSliderValueRef.current = activeSliderOption(snapshot.panel);
|
|
615
|
+
}, [snapshot.panel?.id, resetPanelPosition, resetHover]);
|
|
616
|
+
useEffect(() => {
|
|
617
|
+
if (!snapshot.activeTurn && snapshot.completedTurns.length === 0) {
|
|
618
|
+
setExpandedToolGroups((current) => (current.size > 0 ? new Set() : current));
|
|
619
|
+
}
|
|
620
|
+
}, [snapshot.activeTurn, snapshot.completedTurns.length]);
|
|
621
|
+
const activeTurnId = snapshot.activeTurn?.id;
|
|
622
|
+
useEffect(() => {
|
|
623
|
+
if (activeTurnId !== undefined) {
|
|
624
|
+
setDockScroll(undefined);
|
|
625
|
+
}
|
|
626
|
+
}, [activeTurnId]);
|
|
627
|
+
useEffect(() => {
|
|
628
|
+
if (editingQueuedPromptId &&
|
|
629
|
+
!snapshot.queuedPrompts.some((prompt) => prompt.id === editingQueuedPromptId && prompt.source !== 'peer')) {
|
|
630
|
+
finishQueuedPromptEdit();
|
|
631
|
+
}
|
|
632
|
+
}, [editingQueuedPromptId, finishQueuedPromptEdit, snapshot.queuedPrompts]);
|
|
633
|
+
const activeSliderValue = activeSliderOption(snapshot.panel);
|
|
634
|
+
useEffect(() => {
|
|
635
|
+
panelSliderValueRef.current = activeSliderValue;
|
|
636
|
+
}, [activeSliderValue]);
|
|
637
|
+
useEffect(() => {
|
|
638
|
+
setTranscriptScroll(0);
|
|
639
|
+
}, [snapshot.activeTurn?.id]);
|
|
640
|
+
useEffect(() => {
|
|
641
|
+
if (!installableUpdate || consideredStartupUpdate.current === installableUpdate)
|
|
642
|
+
return;
|
|
643
|
+
consideredStartupUpdate.current = installableUpdate;
|
|
644
|
+
if (promptForUpdate &&
|
|
645
|
+
!controller.busy &&
|
|
646
|
+
!snapshot.activeTurn &&
|
|
647
|
+
snapshot.completedTurns.length === 0 &&
|
|
648
|
+
editorRef.current.input.length === 0) {
|
|
649
|
+
startupUpdatePrompt.current = true;
|
|
650
|
+
setUpdatePromptVersion(installableUpdate);
|
|
651
|
+
}
|
|
652
|
+
}, [controller.busy, installableUpdate, promptForUpdate, snapshot.activeTurn, snapshot.completedTurns.length]);
|
|
653
|
+
const dismissUpdatePrompt = useCallback(() => {
|
|
654
|
+
setUpdatePromptVersion(undefined);
|
|
655
|
+
if (startupUpdatePrompt.current) {
|
|
656
|
+
restartedIntroAt.current = Date.now();
|
|
657
|
+
}
|
|
658
|
+
startupUpdatePrompt.current = false;
|
|
659
|
+
onDismissUpdate();
|
|
660
|
+
}, [onDismissUpdate]);
|
|
661
|
+
useEffect(() => {
|
|
662
|
+
setTerminalMouseMotion(true, stdout);
|
|
663
|
+
return () => {
|
|
664
|
+
setTerminalMouseMotion(false, stdout);
|
|
665
|
+
};
|
|
666
|
+
}, [stdout]);
|
|
667
|
+
useEffect(() => () => {
|
|
668
|
+
clearTimeout(copyNoticeTimerRef.current);
|
|
669
|
+
}, []);
|
|
670
|
+
const copyText = useCallback((text) => {
|
|
671
|
+
const characterCount = graphemes(text).length;
|
|
672
|
+
void copyTerminalText(text, stdout).then((copied) => {
|
|
673
|
+
clearTimeout(copyNoticeTimerRef.current);
|
|
674
|
+
setClipboardNotice(copied ? { status: 'success', characterCount } : { status: 'error' });
|
|
675
|
+
copyNoticeTimerRef.current = setTimeout(() => {
|
|
676
|
+
setClipboardNotice(undefined);
|
|
677
|
+
}, 2_000);
|
|
678
|
+
});
|
|
679
|
+
}, [stdout]);
|
|
680
|
+
const handleMouse = useCallback((mouse) => {
|
|
681
|
+
if (!shouldProcessMouseInput(mouse, mouseMoveStateRef.current)) {
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
const { snapshot, terminalWidth, terminalHeight, suggestions, panelRows, composerHeight, party, dockLanguage } = viewPropsRef.current;
|
|
685
|
+
const currentEditor = editorRef.current;
|
|
686
|
+
const button = mouse.button & 3;
|
|
687
|
+
const scroll = mouseScrollDirection(mouse);
|
|
688
|
+
if (scroll !== undefined) {
|
|
689
|
+
setFocusedQueuedPrompt(undefined);
|
|
690
|
+
resetHover();
|
|
691
|
+
leftMouseDownRef.current = false;
|
|
692
|
+
frogPressRef.current = undefined;
|
|
693
|
+
toolGroupPressRef.current = undefined;
|
|
694
|
+
selectionDragRef.current = undefined;
|
|
695
|
+
setScreenSelection([]);
|
|
696
|
+
panelSliderDraggingRef.current = false;
|
|
697
|
+
setPressedPanelRow(undefined);
|
|
698
|
+
setPressedPanelControl(undefined);
|
|
699
|
+
setPressedSuggestion(undefined);
|
|
700
|
+
if (statusElement.current && elementContainsMouse(statusElement.current, mouse)) {
|
|
701
|
+
const { maxScroll } = composerStatusLayout(snapshot, terminalHeight);
|
|
702
|
+
setStatusScroll((value) => scrollDetail(value, scroll, maxScroll, false, 3));
|
|
703
|
+
}
|
|
704
|
+
else if (snapshot.panel?.kind === 'detail' ||
|
|
705
|
+
snapshot.panel?.kind === 'help-detail' ||
|
|
706
|
+
snapshot.panel?.kind === 'error') {
|
|
707
|
+
const maxScroll = snapshot.panel.kind === 'detail' || snapshot.panel.kind === 'help-detail'
|
|
708
|
+
? maxDetailScroll(snapshot.panel, terminalWidth, composerHeight)
|
|
709
|
+
: errorPanelLayout(snapshot.panel, Math.max(1, terminalWidth - 2), composerHeight).maxScroll;
|
|
710
|
+
const followTail = 'followTail' in snapshot.panel && snapshot.panel.followTail === true;
|
|
711
|
+
setDetailScroll((value) => scrollDetail(value, scroll, maxScroll, followTail, 3));
|
|
712
|
+
}
|
|
713
|
+
else if (snapshot.panel?.kind === 'config') {
|
|
714
|
+
const { maxScroll } = configurationScrollBounds(snapshot.panel.configuration, viewPropsRef.current.panelFilter, configurationDockWidth(terminalWidth, true), configurationDockHeight(snapshot, terminalHeight, party), (language) => activeConfigurationDiff(snapshot, language));
|
|
715
|
+
setDetailScroll((value) => scrollDetail(value, scroll, maxScroll, false, 3));
|
|
716
|
+
}
|
|
717
|
+
else if (snapshot.panel?.kind === 'permission') {
|
|
718
|
+
const maxScroll = maxPermissionScroll(snapshot.panel, terminalHeight, terminalWidth, composerHeight, panelSelectionRef.current);
|
|
719
|
+
const previewHeight = permissionPanelLayout(Math.max(1, terminalWidth - 2), composerHeight ?? terminalHeight, snapshot.panel.rows.length).previewHeight;
|
|
720
|
+
setDetailScroll((value) => scrollDetail(value, scroll, maxScroll, false, Math.min(3, Math.max(1, previewHeight - 1))));
|
|
721
|
+
}
|
|
722
|
+
else if (snapshot.panel?.kind === 'agents') {
|
|
723
|
+
if (snapshot.panel.renameInput)
|
|
724
|
+
return;
|
|
725
|
+
const { capacity, columns } = agentGridLayout(terminalWidth, terminalHeight);
|
|
726
|
+
const nextStart = scrollAgentGridViewport(panelViewportStartRef.current, scroll, panelRows?.length ?? 0, capacity, columns);
|
|
727
|
+
panelViewportStartRef.current = nextStart;
|
|
728
|
+
setPanelViewportStart(nextStart);
|
|
729
|
+
}
|
|
730
|
+
else if (snapshot.panel?.kind === 'voice') {
|
|
731
|
+
const rows = panelRows ?? [];
|
|
732
|
+
const hoveredIndex = elementAtMouse(panelRowElements, mouse);
|
|
733
|
+
const speakerSection = (index) => rows[index]?.section === 'Voice' || rows[index]?.section === 'Model';
|
|
734
|
+
const current = panelSelectionRef.current;
|
|
735
|
+
const selected = hoveredIndex !== undefined && speakerSection(hoveredIndex) !== speakerSection(current)
|
|
736
|
+
? hoveredIndex
|
|
737
|
+
: current;
|
|
738
|
+
const nextSelection = moveMultiColumnPanelSelection('voice', rows, selected, scroll < 0 ? { upArrow: true } : { downArrow: true }, 1);
|
|
739
|
+
if (nextSelection !== undefined) {
|
|
740
|
+
panelSelectionRef.current = nextSelection;
|
|
741
|
+
setPanelSelection(nextSelection);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
else if (snapshot.panel?.kind === 'models' &&
|
|
745
|
+
snapshot.panel.awsProfile?.open &&
|
|
746
|
+
elementAtMouse(panelFilterElements, mouse)?.startsWith('aws-profile:')) {
|
|
747
|
+
const total = awsProfileItems(snapshot.panel, viewPropsRef.current.panelFilter).length;
|
|
748
|
+
setModelPanelFocus('profiles');
|
|
749
|
+
setModelProfileSelection((selected) => Math.max(0, Math.min(total - 1, selected + scroll)));
|
|
750
|
+
}
|
|
751
|
+
else if (snapshot.panel) {
|
|
752
|
+
const rows = panelRows ?? [];
|
|
753
|
+
const capacity = panelRowCapacity(snapshot.panel.kind, composerHeight === undefined ? terminalHeight : composerPanelContentHeight(snapshot.panel, composerHeight));
|
|
754
|
+
const nextStart = scrollPanelViewport(panelViewportStartRef.current, scroll, rows.length, capacity);
|
|
755
|
+
panelViewportStartRef.current = nextStart;
|
|
756
|
+
setPanelViewportStart(nextStart);
|
|
757
|
+
}
|
|
758
|
+
else if (snapshot.configuration && dockElement.current && elementContainsMouse(dockElement.current, mouse)) {
|
|
759
|
+
const configuration = snapshot.configuration;
|
|
760
|
+
const dockWidth = configurationDockWidth(terminalWidth, false);
|
|
761
|
+
const dockHeight = passiveConfigurationDockHeight(configurationDockHeight(snapshot, terminalHeight, party), configuration, snapshot.configurationDiffs, dockLanguage, dockWidth);
|
|
762
|
+
const { maxScroll } = configurationScrollBounds(configuration, dockLanguage ?? configuration.preferredLanguage, dockWidth, dockHeight, (language) => snapshot.configurationDiffs?.[language]);
|
|
763
|
+
setDockScroll((value) => scrollDetail(value ?? 0, scroll, maxScroll, false, 3));
|
|
764
|
+
}
|
|
765
|
+
else if (suggestions.length > 0) {
|
|
766
|
+
const nextSelection = moveSelection(suggestionSelectionRef.current, scroll < 0 ? { upArrow: true } : { downArrow: true }, suggestions.length, suggestions.length);
|
|
767
|
+
if (nextSelection !== undefined) {
|
|
768
|
+
suggestionSelectionRef.current = nextSelection;
|
|
769
|
+
setSuggestionSelection(nextSelection);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
else {
|
|
773
|
+
setTranscriptScroll((value) => scrollTranscript(value, scroll, maxTranscriptScrollRef.current));
|
|
774
|
+
}
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
const panelHit = panelElement.current ? elementContainsMouse(panelElement.current, mouse) : false;
|
|
778
|
+
const metadataTarget = panelHit ? undefined : elementAtMouse(metadataElements, mouse);
|
|
779
|
+
const footerTarget = panelHit ? undefined : elementAtMouse(footerElements, mouse);
|
|
780
|
+
const footerAction = !snapshot.panel || footerTarget === 'settings' || footerTarget === 'setup' ? footerTarget : undefined;
|
|
781
|
+
const jumpToBottomHit = !snapshot.panel && viewPropsRef.current.transcriptScroll > 0 && jumpToBottomElement.current
|
|
782
|
+
? elementContainsMouse(jumpToBottomElement.current, mouse)
|
|
783
|
+
: false;
|
|
784
|
+
const panelRowIndex = snapshot.panel ? elementAtMouse(panelRowElements, mouse) : undefined;
|
|
785
|
+
const panelControlTarget = snapshot.panel?.kind === 'agents' ||
|
|
786
|
+
snapshot.panel?.kind === 'settings' ||
|
|
787
|
+
snapshot.panel?.kind === 'voice' ||
|
|
788
|
+
snapshot.panel?.kind === 'config' ||
|
|
789
|
+
snapshot.panel?.kind === 'permissions'
|
|
790
|
+
? elementAtMouse(panelControlElements, mouse)
|
|
791
|
+
: undefined;
|
|
792
|
+
const panelFilterId = snapshot.panel || snapshot.configuration ? elementAtMouse(panelFilterElements, mouse) : undefined;
|
|
793
|
+
const suggestionIndex = !snapshot.panel && suggestions.length > 0 ? elementAtMouse(suggestionElements, mouse) : undefined;
|
|
794
|
+
const queuedPromptTarget = !snapshot.panel && statusElement.current && elementContainsMouse(statusElement.current, mouse)
|
|
795
|
+
? elementAtMouse(queuedPromptElements, mouse)
|
|
796
|
+
: undefined;
|
|
797
|
+
const backgroundTaskHit = !snapshot.panel && backgroundTaskElement.current
|
|
798
|
+
? elementContainsMouse(backgroundTaskElement.current, mouse)
|
|
799
|
+
: false;
|
|
800
|
+
const toolGroupTarget = !snapshot.panel ? elementAtMouse(toolGroupElements, mouse) : undefined;
|
|
801
|
+
const sliderElement = snapshot.panel?.kind === 'effort' || snapshot.panel?.kind === 'permissions' || snapshot.panel?.kind === 'voice'
|
|
802
|
+
? panelSliderElement.current
|
|
803
|
+
: undefined;
|
|
804
|
+
const sliderHit = sliderElement ? elementContainsMouse(sliderElement, mouse) : false;
|
|
805
|
+
const searchElement = snapshot.panel?.kind === 'models' ||
|
|
806
|
+
snapshot.panel?.kind === 'sessions' ||
|
|
807
|
+
snapshot.panel?.kind === 'help' ||
|
|
808
|
+
snapshot.panel?.kind === 'tasks' ||
|
|
809
|
+
snapshot.panel?.kind === 'permissions'
|
|
810
|
+
? panelSearchElement.current
|
|
811
|
+
: undefined;
|
|
812
|
+
const searchHit = searchElement ? elementContainsMouse(searchElement, mouse) : false;
|
|
813
|
+
const frogHit = !snapshot.panel && suggestions.length === 0 && frogElement.current
|
|
814
|
+
? elementContainsMouse(frogElement.current, mouse)
|
|
815
|
+
: false;
|
|
816
|
+
if (mouse.action === 'move' && !leftMouseDownRef.current) {
|
|
817
|
+
setHoveredPanelRow(panelRowIndex);
|
|
818
|
+
setHoveredPanelControl(panelControlTarget);
|
|
819
|
+
setHoveredPanelFilter(panelFilterId);
|
|
820
|
+
setHoveredSuggestion(suggestionIndex);
|
|
821
|
+
setHoveredAction(footerAction);
|
|
822
|
+
setHoveredJumpToBottom(jumpToBottomHit);
|
|
823
|
+
setHoveredMetadata(metadataTarget);
|
|
824
|
+
setHoveredBackgroundTask(backgroundTaskHit);
|
|
825
|
+
}
|
|
826
|
+
if (mouse.action === 'press' && button === 0) {
|
|
827
|
+
resetHover();
|
|
828
|
+
setFrog(undefined);
|
|
829
|
+
leftMouseDownRef.current = true;
|
|
830
|
+
frogPressRef.current = frogHit ? { column: mouse.column, row: mouse.row } : undefined;
|
|
831
|
+
toolGroupPressRef.current = toolGroupTarget;
|
|
832
|
+
setScreenSelection([]);
|
|
833
|
+
selectionDragRef.current =
|
|
834
|
+
sliderHit ||
|
|
835
|
+
panelControlTarget ||
|
|
836
|
+
toolGroupTarget ||
|
|
837
|
+
queuedPromptTarget ||
|
|
838
|
+
backgroundTaskHit ||
|
|
839
|
+
jumpToBottomHit
|
|
840
|
+
? undefined
|
|
841
|
+
: {
|
|
842
|
+
anchor: mouse,
|
|
843
|
+
lines: sanitizeTerminalText(renderToString(createElement(ChatView, {
|
|
844
|
+
...viewPropsRef.current,
|
|
845
|
+
input: currentEditor.input,
|
|
846
|
+
cursor: currentEditor.cursor,
|
|
847
|
+
}), { columns: terminalWidth })).split('\n'),
|
|
848
|
+
};
|
|
849
|
+
setPressedMetadata(metadataTarget);
|
|
850
|
+
setPressedPanelFilter(panelFilterId);
|
|
851
|
+
setPressedPanelRow(panelRowIndex);
|
|
852
|
+
setPressedPanelControl(panelControlTarget);
|
|
853
|
+
setPressedSuggestion(suggestionIndex);
|
|
854
|
+
setPressedQueuedPrompt(queuedPromptTarget);
|
|
855
|
+
setFocusedQueuedPrompt(undefined);
|
|
856
|
+
if (!backgroundTaskHit)
|
|
857
|
+
setFocusedBackgroundTask(undefined);
|
|
858
|
+
if (searchHit) {
|
|
859
|
+
setModelPanelFocus('search');
|
|
860
|
+
}
|
|
861
|
+
else if (sliderHit && snapshot.panel?.kind === 'permissions') {
|
|
862
|
+
setModelPanelFocus('providers');
|
|
863
|
+
}
|
|
864
|
+
else if (panelFilterId) {
|
|
865
|
+
setModelPanelFocus(panelFilterId.startsWith('aws-profile:') ? 'profiles' : 'providers');
|
|
866
|
+
setSettingsPanelFocus('categories');
|
|
867
|
+
}
|
|
868
|
+
else if (panelRowIndex !== undefined) {
|
|
869
|
+
setModelPanelFocus('models');
|
|
870
|
+
setSettingsPanelFocus('settings');
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
const leftRelease = mouse.action === 'release' && leftMouseDownRef.current;
|
|
874
|
+
const frogClicked = leftRelease &&
|
|
875
|
+
frogHit &&
|
|
876
|
+
frogPressRef.current?.column === mouse.column &&
|
|
877
|
+
frogPressRef.current?.row === mouse.row;
|
|
878
|
+
const toolGroupClicked = leftRelease && toolGroupTarget !== undefined && toolGroupPressRef.current === toolGroupTarget;
|
|
879
|
+
const completedSelection = leftRelease && selectionDragRef.current
|
|
880
|
+
? selectScreenText(selectionDragRef.current.lines, selectionDragRef.current.anchor, mouse)
|
|
881
|
+
: undefined;
|
|
882
|
+
if (mouse.action === 'release') {
|
|
883
|
+
leftMouseDownRef.current = false;
|
|
884
|
+
frogPressRef.current = undefined;
|
|
885
|
+
toolGroupPressRef.current = undefined;
|
|
886
|
+
selectionDragRef.current = undefined;
|
|
887
|
+
resetPressed();
|
|
888
|
+
}
|
|
889
|
+
const updateSliderSelection = () => {
|
|
890
|
+
const slider = panelSlider(snapshot.panel);
|
|
891
|
+
if (!sliderElement || !slider || slider.disabled) {
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
if (snapshot.panel?.kind === 'voice') {
|
|
895
|
+
const index = panelRows?.findIndex((row) => row.value === 'voice:enabled') ?? -1;
|
|
896
|
+
if (index >= 0) {
|
|
897
|
+
panelSelectionRef.current = index;
|
|
898
|
+
setPanelSelection(index);
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
const option = sliderOptionAtMouse(slider, sliderElement, mouse);
|
|
902
|
+
if (!option || option.id === panelSliderValueRef.current) {
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
panelSliderValueRef.current = option.id;
|
|
906
|
+
void activateRow({
|
|
907
|
+
label: slider.label,
|
|
908
|
+
description: option.label,
|
|
909
|
+
value: snapshot.panel?.kind === 'permissions'
|
|
910
|
+
? `permissions:preset:${option.id}`
|
|
911
|
+
: snapshot.panel?.kind === 'voice'
|
|
912
|
+
? `voice:enabled=${option.id}`
|
|
913
|
+
: `effort:${option.id}`,
|
|
914
|
+
});
|
|
915
|
+
};
|
|
916
|
+
if (mouse.action === 'move' && panelSliderDraggingRef.current) {
|
|
917
|
+
updateSliderSelection();
|
|
918
|
+
return;
|
|
919
|
+
}
|
|
920
|
+
if (mouse.action === 'press' && button === 0 && sliderHit) {
|
|
921
|
+
panelSliderDraggingRef.current = true;
|
|
922
|
+
updateSliderSelection();
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
if (mouse.action === 'release' && panelSliderDraggingRef.current) {
|
|
926
|
+
panelSliderDraggingRef.current = false;
|
|
927
|
+
updateSliderSelection();
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
if (completedSelection) {
|
|
931
|
+
setScreenSelection(completedSelection.segments);
|
|
932
|
+
copyText(completedSelection.text);
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
if (frogClicked) {
|
|
936
|
+
setFrogBrandAnimationId(++nextFrogBrandAnimationId.current);
|
|
937
|
+
return;
|
|
938
|
+
}
|
|
939
|
+
if (toolGroupClicked) {
|
|
940
|
+
setExpandedToolGroups((current) => {
|
|
941
|
+
const next = new Set(current);
|
|
942
|
+
if (next.has(toolGroupTarget)) {
|
|
943
|
+
next.delete(toolGroupTarget);
|
|
944
|
+
}
|
|
945
|
+
else {
|
|
946
|
+
next.add(toolGroupTarget);
|
|
947
|
+
}
|
|
948
|
+
return next;
|
|
949
|
+
});
|
|
950
|
+
return;
|
|
951
|
+
}
|
|
952
|
+
if (mouse.action === 'move') {
|
|
953
|
+
const selection = selectionDragRef.current
|
|
954
|
+
? selectScreenText(selectionDragRef.current.lines, selectionDragRef.current.anchor, mouse)
|
|
955
|
+
: undefined;
|
|
956
|
+
if (selection) {
|
|
957
|
+
resetPressed();
|
|
958
|
+
setScreenSelection(selection.segments);
|
|
959
|
+
}
|
|
960
|
+
return;
|
|
961
|
+
}
|
|
962
|
+
if (mouse.action !== 'release' || (!leftRelease && button !== 0)) {
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
if (jumpToBottomHit) {
|
|
966
|
+
setTranscriptScroll(0);
|
|
967
|
+
}
|
|
968
|
+
else if (panelFilterId) {
|
|
969
|
+
if (snapshot.panel?.kind === 'models' && panelFilterId.startsWith('aws-profile:')) {
|
|
970
|
+
void activateRow({ label: '', description: '', value: panelFilterId });
|
|
971
|
+
}
|
|
972
|
+
else if (snapshot.panel?.kind === 'settings' && snapshot.panel.settingsCategory) {
|
|
973
|
+
void activateRow({ label: '', description: '', value: panelFilterId });
|
|
974
|
+
}
|
|
975
|
+
else if (!snapshot.panel && (panelFilterId === 'typescript' || panelFilterId === 'python')) {
|
|
976
|
+
setDockLanguage(panelFilterId);
|
|
977
|
+
setDockScroll(undefined);
|
|
978
|
+
}
|
|
979
|
+
else {
|
|
980
|
+
if (snapshot.panel?.kind === 'models' && snapshot.panel.awsProfile?.open) {
|
|
981
|
+
void controller.activatePanelRow({ label: '', description: '', value: 'aws-profile:toggle' });
|
|
982
|
+
setModelProfileSelection(0);
|
|
983
|
+
}
|
|
984
|
+
setPanelFilter(panelFilterId);
|
|
985
|
+
setDetailScroll(0);
|
|
986
|
+
resetPanelPosition();
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
else if (panelControlTarget) {
|
|
990
|
+
if (panelControlTarget === CONFIGURATION_OPEN_CONTROL) {
|
|
991
|
+
openConfigurationProject();
|
|
992
|
+
return;
|
|
993
|
+
}
|
|
994
|
+
const target = parsePanelControlTarget(panelControlTarget);
|
|
995
|
+
const row = target ? panelRows?.[target.index] : undefined;
|
|
996
|
+
if (!row?.value || !target) {
|
|
997
|
+
return;
|
|
998
|
+
}
|
|
999
|
+
if (snapshot.panel?.kind === 'voice') {
|
|
1000
|
+
panelSelectionRef.current = target.index;
|
|
1001
|
+
setPanelSelection(target.index);
|
|
1002
|
+
}
|
|
1003
|
+
void activateRow({
|
|
1004
|
+
...row,
|
|
1005
|
+
value: snapshot.panel?.kind === 'agents' && snapshot.panel.renameInput
|
|
1006
|
+
? target.value
|
|
1007
|
+
: row.control?.kind === 'toggle'
|
|
1008
|
+
? row.value
|
|
1009
|
+
: `${row.value}=${target.value}`,
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
else if (panelRowIndex !== undefined) {
|
|
1013
|
+
if (snapshot.panel?.kind === 'agents' && snapshot.panel.renameInput)
|
|
1014
|
+
return;
|
|
1015
|
+
panelSelectionRef.current = panelRowIndex;
|
|
1016
|
+
setPanelSelection(panelRowIndex);
|
|
1017
|
+
const row = panelRows?.[panelRowIndex];
|
|
1018
|
+
if (row?.value && (snapshot.panel?.kind !== 'settings' || !row.control)) {
|
|
1019
|
+
void activateRow(row);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
else if (snapshot.panel && !panelHit && !metadataTarget && !footerAction) {
|
|
1023
|
+
controller.dismissPanel();
|
|
1024
|
+
}
|
|
1025
|
+
else if (suggestionIndex !== undefined) {
|
|
1026
|
+
suggestionSelectionRef.current = suggestionIndex;
|
|
1027
|
+
setSuggestionSelection(suggestionIndex);
|
|
1028
|
+
const suggestion = suggestions[suggestionIndex];
|
|
1029
|
+
if (suggestion) {
|
|
1030
|
+
if (suggestion.replacement) {
|
|
1031
|
+
setEditor(completeSuggestion(currentEditor, suggestion));
|
|
1032
|
+
}
|
|
1033
|
+
else {
|
|
1034
|
+
const result = submitEditor(currentEditor, `/${suggestion.name}`);
|
|
1035
|
+
setEditor(result.state);
|
|
1036
|
+
if (result.action === 'submit') {
|
|
1037
|
+
dispatchPrompt(result.prompt);
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
else if (queuedPromptTarget) {
|
|
1043
|
+
activateQueuedPrompt(queuedPromptTarget);
|
|
1044
|
+
}
|
|
1045
|
+
else if (backgroundTaskHit) {
|
|
1046
|
+
const tasks = snapshot.tasks.filter((task) => task.source === 'background' && isActiveTask(task.status));
|
|
1047
|
+
const task = tasks.find((candidate) => candidate.id === viewPropsRef.current.focusedBackgroundTask) ?? tasks[0];
|
|
1048
|
+
if (task)
|
|
1049
|
+
controller.openTask(task.id);
|
|
1050
|
+
}
|
|
1051
|
+
else if (footerAction) {
|
|
1052
|
+
if (footerAction === 'parent') {
|
|
1053
|
+
controller.returnToParent?.();
|
|
1054
|
+
}
|
|
1055
|
+
else if (footerAction === 'update' && availableUpdate) {
|
|
1056
|
+
startupUpdatePrompt.current = false;
|
|
1057
|
+
setUpdatePromptVersion(availableUpdate);
|
|
1058
|
+
}
|
|
1059
|
+
else {
|
|
1060
|
+
void controller.submit(`/${footerAction}`);
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
else if (metadataTarget) {
|
|
1064
|
+
void activateMetadataTarget(controller, metadataTarget);
|
|
1065
|
+
}
|
|
1066
|
+
}, [
|
|
1067
|
+
activateRow,
|
|
1068
|
+
activateQueuedPrompt,
|
|
1069
|
+
availableUpdate,
|
|
1070
|
+
copyText,
|
|
1071
|
+
controller,
|
|
1072
|
+
dispatchPrompt,
|
|
1073
|
+
footerElements,
|
|
1074
|
+
metadataElements,
|
|
1075
|
+
openConfigurationProject,
|
|
1076
|
+
panelControlElements,
|
|
1077
|
+
panelFilterElements,
|
|
1078
|
+
panelRowElements,
|
|
1079
|
+
queuedPromptElements,
|
|
1080
|
+
resetHover,
|
|
1081
|
+
resetPanelPosition,
|
|
1082
|
+
resetPressed,
|
|
1083
|
+
setEditor,
|
|
1084
|
+
suggestionElements,
|
|
1085
|
+
toolGroupElements,
|
|
1086
|
+
]);
|
|
1087
|
+
const handleInput = useCallback((character, key) => {
|
|
1088
|
+
const { snapshot, terminalWidth, terminalHeight, suggestions, panelRows, panelQuery, panelFilter, modelPanelFocus, modelProfileSelection, settingsPanelFocus, composerHeight, party, } = viewPropsRef.current;
|
|
1089
|
+
const currentEditor = editorRef.current;
|
|
1090
|
+
const mouse = parseMouseInput(character);
|
|
1091
|
+
if (mouse) {
|
|
1092
|
+
handleMouse(mouse);
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1095
|
+
selectionDragRef.current = undefined;
|
|
1096
|
+
setScreenSelection([]);
|
|
1097
|
+
resetHover();
|
|
1098
|
+
setPressedPanelRow(undefined);
|
|
1099
|
+
setPressedPanelControl(undefined);
|
|
1100
|
+
setPressedSuggestion(undefined);
|
|
1101
|
+
setPressedQueuedPrompt(undefined);
|
|
1102
|
+
if (!snapshot.panel && editingQueuedPromptId && key.ctrl && character === 'd') {
|
|
1103
|
+
controller.removeQueuedPrompt(editingQueuedPromptId);
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
if (key.ctrl && (character === 'c' || character === 'd')) {
|
|
1107
|
+
handleExit(character === 'c' ? 130 : 0);
|
|
1108
|
+
return;
|
|
1109
|
+
}
|
|
1110
|
+
if (frog && key.escape) {
|
|
1111
|
+
setFrog(undefined);
|
|
1112
|
+
return;
|
|
1113
|
+
}
|
|
1114
|
+
if (snapshot.composerStatus) {
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
if (snapshot.panel?.kind === 'voice' &&
|
|
1118
|
+
shouldToggleVoiceMute(character, key, currentEditor.input, snapshot.voice?.status)) {
|
|
1119
|
+
controller.toggleVoiceMute?.();
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1122
|
+
if (snapshot.panel) {
|
|
1123
|
+
if (snapshot.panel.kind === 'agents' && snapshot.panel.renameInput) {
|
|
1124
|
+
if (key.escape) {
|
|
1125
|
+
controller.dismissPanel();
|
|
1126
|
+
}
|
|
1127
|
+
else if (key.return) {
|
|
1128
|
+
void activateRow({ label: 'Save', description: '', value: 'rename:save' });
|
|
1129
|
+
}
|
|
1130
|
+
else if (!key.tab) {
|
|
1131
|
+
setAgentNameEditor((current) => reduceInputSequence(current, character.replace(/\r?\n/g, ' '), key, 'idle').state);
|
|
1132
|
+
}
|
|
1133
|
+
return;
|
|
1134
|
+
}
|
|
1135
|
+
if (snapshot.panel.kind === 'detail' ||
|
|
1136
|
+
snapshot.panel.kind === 'help-detail' ||
|
|
1137
|
+
snapshot.panel.kind === 'error') {
|
|
1138
|
+
if (key.escape || key.return || key.backspace || key.delete || character === '\u007f') {
|
|
1139
|
+
controller.dismissPanel();
|
|
1140
|
+
return;
|
|
1141
|
+
}
|
|
1142
|
+
const errorLayout = snapshot.panel.kind === 'error'
|
|
1143
|
+
? errorPanelLayout(snapshot.panel, Math.max(1, terminalWidth - 2), composerHeight)
|
|
1144
|
+
: undefined;
|
|
1145
|
+
const page = errorLayout?.contentHeight ?? detailPageSize(composerHeight ?? terminalHeight);
|
|
1146
|
+
const maxScroll = snapshot.panel.kind === 'detail' || snapshot.panel.kind === 'help-detail'
|
|
1147
|
+
? maxDetailScroll(snapshot.panel, terminalWidth, composerHeight)
|
|
1148
|
+
: errorLayout.maxScroll;
|
|
1149
|
+
const followTail = 'followTail' in snapshot.panel && snapshot.panel.followTail === true;
|
|
1150
|
+
if (key.upArrow) {
|
|
1151
|
+
setDetailScroll((value) => scrollDetail(value, -1, maxScroll, followTail, 1));
|
|
1152
|
+
}
|
|
1153
|
+
else if (key.downArrow) {
|
|
1154
|
+
setDetailScroll((value) => scrollDetail(value, 1, maxScroll, followTail, 1));
|
|
1155
|
+
}
|
|
1156
|
+
else if (key.pageUp) {
|
|
1157
|
+
setDetailScroll((value) => scrollDetail(value, -1, maxScroll, followTail, page));
|
|
1158
|
+
}
|
|
1159
|
+
else if (key.pageDown) {
|
|
1160
|
+
setDetailScroll((value) => scrollDetail(value, 1, maxScroll, followTail, page));
|
|
1161
|
+
}
|
|
1162
|
+
else if (key.home) {
|
|
1163
|
+
setDetailScroll(followTail ? maxScroll : 0);
|
|
1164
|
+
}
|
|
1165
|
+
else if (key.end) {
|
|
1166
|
+
setDetailScroll(followTail ? 0 : maxScroll);
|
|
1167
|
+
}
|
|
1168
|
+
return;
|
|
1169
|
+
}
|
|
1170
|
+
if (snapshot.panel.kind === 'config') {
|
|
1171
|
+
if (key.escape) {
|
|
1172
|
+
controller.dismissPanel();
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
if (character.toLowerCase() === 'e' && snapshot.panel.configuration.project) {
|
|
1176
|
+
openConfigurationProject();
|
|
1177
|
+
return;
|
|
1178
|
+
}
|
|
1179
|
+
if (key.leftArrow || key.rightArrow || key.tab) {
|
|
1180
|
+
setPanelFilter(cyclePanelFilter(snapshot.panel.filters ?? [], panelFilter, key.leftArrow || (key.tab && key.shift) ? -1 : 1));
|
|
1181
|
+
setDetailScroll(0);
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
const { maxScroll, codeSize } = configurationScrollBounds(snapshot.panel.configuration, panelFilter, configurationDockWidth(terminalWidth, true), configurationDockHeight(snapshot, terminalHeight, party), (language) => activeConfigurationDiff(snapshot, language));
|
|
1185
|
+
if (key.upArrow) {
|
|
1186
|
+
setDetailScroll((value) => scrollDetail(value, -1, maxScroll, false, 1));
|
|
1187
|
+
}
|
|
1188
|
+
else if (key.downArrow) {
|
|
1189
|
+
setDetailScroll((value) => scrollDetail(value, 1, maxScroll, false, 1));
|
|
1190
|
+
}
|
|
1191
|
+
else if (key.pageUp) {
|
|
1192
|
+
setDetailScroll((value) => scrollDetail(value, -1, maxScroll, false, codeSize.height));
|
|
1193
|
+
}
|
|
1194
|
+
else if (key.pageDown) {
|
|
1195
|
+
setDetailScroll((value) => scrollDetail(value, 1, maxScroll, false, codeSize.height));
|
|
1196
|
+
}
|
|
1197
|
+
else if (key.home) {
|
|
1198
|
+
setDetailScroll(0);
|
|
1199
|
+
}
|
|
1200
|
+
else if (key.end) {
|
|
1201
|
+
setDetailScroll(maxScroll);
|
|
1202
|
+
}
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1205
|
+
if (snapshot.panel.kind === 'export' && snapshot.panel.nameInput) {
|
|
1206
|
+
if (key.escape) {
|
|
1207
|
+
controller.dismissPanel();
|
|
1208
|
+
}
|
|
1209
|
+
else if (key.return) {
|
|
1210
|
+
const name = panelQuery.trim() || snapshot.panel.nameInput.defaultName;
|
|
1211
|
+
void activateRow({
|
|
1212
|
+
label: 'Continue',
|
|
1213
|
+
description: name,
|
|
1214
|
+
value: `export:name:${snapshot.panel.nameInput.language}:${encodeURIComponent(name)}`,
|
|
1215
|
+
});
|
|
1216
|
+
}
|
|
1217
|
+
else {
|
|
1218
|
+
const edit = queryEdit(character, key, ' ');
|
|
1219
|
+
if (edit)
|
|
1220
|
+
setPanelQuery(edit);
|
|
1221
|
+
}
|
|
1222
|
+
return;
|
|
1223
|
+
}
|
|
1224
|
+
const rows = panelRows ?? [];
|
|
1225
|
+
const rowCapacity = snapshot.panel.kind === 'agents'
|
|
1226
|
+
? agentGridLayout(terminalWidth, terminalHeight).capacity
|
|
1227
|
+
: panelRowCapacity(snapshot.panel.kind, composerHeight === undefined
|
|
1228
|
+
? terminalHeight
|
|
1229
|
+
: composerPanelContentHeight(snapshot.panel, composerHeight));
|
|
1230
|
+
if (snapshot.panel.kind === 'permission' && key.escape) {
|
|
1231
|
+
const escapeRow = permissionEscapeRow(rows, snapshot.panel.stage);
|
|
1232
|
+
if (escapeRow) {
|
|
1233
|
+
void activateRow(escapeRow);
|
|
1234
|
+
}
|
|
1235
|
+
return;
|
|
1236
|
+
}
|
|
1237
|
+
if (snapshot.panel.kind === 'permission' && (key.pageUp || key.pageDown || key.home || key.end)) {
|
|
1238
|
+
const maximum = maxPermissionScroll(snapshot.panel, terminalHeight, terminalWidth, composerHeight, panelSelectionRef.current);
|
|
1239
|
+
const pageSize = Math.max(1, permissionPanelLayout(Math.max(1, terminalWidth - 2), composerHeight ?? terminalHeight, snapshot.panel.rows.length).previewHeight - 1);
|
|
1240
|
+
if (key.home) {
|
|
1241
|
+
setDetailScroll(0);
|
|
1242
|
+
}
|
|
1243
|
+
else if (key.end) {
|
|
1244
|
+
setDetailScroll(maximum);
|
|
1245
|
+
}
|
|
1246
|
+
else {
|
|
1247
|
+
setDetailScroll((value) => scrollDetail(value, key.pageUp ? -1 : 1, maximum, false, pageSize));
|
|
1248
|
+
}
|
|
1249
|
+
return;
|
|
1250
|
+
}
|
|
1251
|
+
if (key.escape) {
|
|
1252
|
+
if (snapshot.panel.kind === 'models' && snapshot.panel.awsProfile?.open) {
|
|
1253
|
+
void activateRow({ label: '', description: '', value: 'aws-profile:toggle' });
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
if ((snapshot.panel.kind === 'models' ||
|
|
1257
|
+
snapshot.panel.kind === 'sessions' ||
|
|
1258
|
+
snapshot.panel.kind === 'help' ||
|
|
1259
|
+
snapshot.panel.kind === 'tasks' ||
|
|
1260
|
+
snapshot.panel.kind === 'permissions' ||
|
|
1261
|
+
snapshot.panel.kind === 'mcp') &&
|
|
1262
|
+
modelPanelFocus === 'search') {
|
|
1263
|
+
setPanelQuery('');
|
|
1264
|
+
setModelPanelFocus('models');
|
|
1265
|
+
resetPanelPosition();
|
|
1266
|
+
}
|
|
1267
|
+
else if (panelQuery) {
|
|
1268
|
+
setPanelQuery('');
|
|
1269
|
+
}
|
|
1270
|
+
else {
|
|
1271
|
+
controller.dismissPanel();
|
|
1272
|
+
}
|
|
1273
|
+
return;
|
|
1274
|
+
}
|
|
1275
|
+
const copyableModelId = panelModelId(snapshot.panel, rows[hoveredPanelRow ?? panelSelectionRef.current]);
|
|
1276
|
+
if (copyableModelId && key.ctrl && !key.meta && !key.super && character.toLowerCase() === 'y') {
|
|
1277
|
+
copyText(copyableModelId);
|
|
1278
|
+
return;
|
|
1279
|
+
}
|
|
1280
|
+
if (snapshot.panel.kind === 'mcp') {
|
|
1281
|
+
if (modelPanelFocus === 'search') {
|
|
1282
|
+
if (key.return || key.downArrow) {
|
|
1283
|
+
setModelPanelFocus('models');
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
const edit = queryEdit(character, key);
|
|
1287
|
+
if (edit) {
|
|
1288
|
+
setPanelQuery(edit);
|
|
1289
|
+
resetPanelPosition();
|
|
1290
|
+
}
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
const selected = rows[Math.min(panelSelectionRef.current, rows.length - 1)];
|
|
1294
|
+
const name = selected?.value?.startsWith('mcp:toggle:')
|
|
1295
|
+
? decodeURIComponent(selected.value.slice('mcp:toggle:'.length))
|
|
1296
|
+
: undefined;
|
|
1297
|
+
if (key.rightArrow) {
|
|
1298
|
+
if (name) {
|
|
1299
|
+
rememberDetailParent();
|
|
1300
|
+
controller.openMcpDetail(name);
|
|
1301
|
+
}
|
|
1302
|
+
return;
|
|
1303
|
+
}
|
|
1304
|
+
if (character === 'R' && !key.ctrl && !key.meta && !key.super) {
|
|
1305
|
+
if (name && snapshot.panel.canRetry) {
|
|
1306
|
+
void controller.retryMcpServer(name);
|
|
1307
|
+
}
|
|
1308
|
+
return;
|
|
1309
|
+
}
|
|
1310
|
+
if (key.return) {
|
|
1311
|
+
if (selected?.control)
|
|
1312
|
+
void activateRow(selected);
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1315
|
+
if (character === '/') {
|
|
1316
|
+
setModelPanelFocus('search');
|
|
1317
|
+
return;
|
|
1318
|
+
}
|
|
1319
|
+
const nextSelection = moveSelection(panelSelectionRef.current, key, rows.length, rowCapacity);
|
|
1320
|
+
if (nextSelection !== undefined) {
|
|
1321
|
+
selectPanelRow(nextSelection, rowCapacity, rows.length);
|
|
1322
|
+
return;
|
|
1323
|
+
}
|
|
1324
|
+
const edit = snapshot.panel.searchable ? queryEdit(character, key) : undefined;
|
|
1325
|
+
if (edit) {
|
|
1326
|
+
setModelPanelFocus('search');
|
|
1327
|
+
setPanelQuery(edit);
|
|
1328
|
+
resetPanelPosition();
|
|
1329
|
+
}
|
|
1330
|
+
return;
|
|
1331
|
+
}
|
|
1332
|
+
if (snapshot.panel.kind === 'effort') {
|
|
1333
|
+
const slider = snapshot.panel.slider;
|
|
1334
|
+
// Arrow keys already apply the effort, so Enter just closes like Escape.
|
|
1335
|
+
if (key.return) {
|
|
1336
|
+
controller.dismissPanel();
|
|
1337
|
+
return;
|
|
1338
|
+
}
|
|
1339
|
+
if (key.leftArrow || key.rightArrow) {
|
|
1340
|
+
const option = slider.disabled ? undefined : adjacentSliderOption(slider, key.leftArrow ? -1 : 1);
|
|
1341
|
+
if (option) {
|
|
1342
|
+
void activateRow({ label: slider.label, description: option.label, value: `effort:${option.id}` });
|
|
1343
|
+
}
|
|
1344
|
+
return;
|
|
1345
|
+
}
|
|
1346
|
+
return;
|
|
1347
|
+
}
|
|
1348
|
+
if (snapshot.panel.kind === 'tasks' || snapshot.panel.kind === 'permissions') {
|
|
1349
|
+
if (key.tab) {
|
|
1350
|
+
setModelPanelFocus(snapshot.panel.kind === 'tasks'
|
|
1351
|
+
? modelPanelFocus === 'models'
|
|
1352
|
+
? 'search'
|
|
1353
|
+
: 'models'
|
|
1354
|
+
: modelPanelFocus === 'providers'
|
|
1355
|
+
? 'models'
|
|
1356
|
+
: 'providers');
|
|
1357
|
+
return;
|
|
1358
|
+
}
|
|
1359
|
+
if (snapshot.panel.kind === 'permissions' && modelPanelFocus === 'providers') {
|
|
1360
|
+
if (key.leftArrow || key.rightArrow) {
|
|
1361
|
+
const option = adjacentSliderOption(snapshot.panel.slider, key.leftArrow ? -1 : 1);
|
|
1362
|
+
if (option) {
|
|
1363
|
+
void activateRow({
|
|
1364
|
+
label: snapshot.panel.slider.label,
|
|
1365
|
+
description: option.label,
|
|
1366
|
+
value: `permissions:preset:${option.id}`,
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
if (modelPanelFocus === 'search' && (key.downArrow || key.return)) {
|
|
1373
|
+
setModelPanelFocus('models');
|
|
1374
|
+
return;
|
|
1375
|
+
}
|
|
1376
|
+
if (modelPanelFocus === 'models') {
|
|
1377
|
+
const selected = rows[Math.min(panelSelectionRef.current, rows.length - 1)];
|
|
1378
|
+
const activate = key.return || (snapshot.panel.kind === 'permissions' && character === ' ');
|
|
1379
|
+
if (activate && selected?.value) {
|
|
1380
|
+
void activateRow(selected);
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
const nextSelection = moveSelection(panelSelectionRef.current, key, rows.length, rowCapacity);
|
|
1384
|
+
if (nextSelection !== undefined) {
|
|
1385
|
+
selectPanelRow(nextSelection, rowCapacity, rows.length);
|
|
1386
|
+
return;
|
|
1387
|
+
}
|
|
1388
|
+
if (character === '/') {
|
|
1389
|
+
setModelPanelFocus('search');
|
|
1390
|
+
}
|
|
1391
|
+
return;
|
|
1392
|
+
}
|
|
1393
|
+
const edit = queryEdit(character, key);
|
|
1394
|
+
if (edit) {
|
|
1395
|
+
setPanelQuery(edit);
|
|
1396
|
+
resetPanelPosition();
|
|
1397
|
+
}
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
if (snapshot.panel.kind === 'models' || snapshot.panel.kind === 'sessions' || snapshot.panel.kind === 'help') {
|
|
1401
|
+
if (snapshot.panel.kind === 'models' && snapshot.panel.awsProfile?.open && (key.tab || character === '/')) {
|
|
1402
|
+
void controller.activatePanelRow({ label: '', description: '', value: 'aws-profile:toggle' });
|
|
1403
|
+
setModelProfileSelection(0);
|
|
1404
|
+
}
|
|
1405
|
+
if (snapshot.panel.kind === 'help' && character === '/' && modelPanelFocus !== 'search') {
|
|
1406
|
+
setModelPanelFocus('search');
|
|
1407
|
+
return;
|
|
1408
|
+
}
|
|
1409
|
+
if (key.tab) {
|
|
1410
|
+
setModelPanelFocus(snapshot.panel.kind === 'models'
|
|
1411
|
+
? cycleModelPanelFocus(modelPanelFocus, snapshot.panel, key.shift ? -1 : 1, panelFilter)
|
|
1412
|
+
: modelPanelFocus === 'providers'
|
|
1413
|
+
? 'models'
|
|
1414
|
+
: modelPanelFocus === 'models'
|
|
1415
|
+
? 'providers'
|
|
1416
|
+
: 'models');
|
|
1417
|
+
return;
|
|
1418
|
+
}
|
|
1419
|
+
if (snapshot.panel.kind === 'models' && modelPanelFocus === 'profiles') {
|
|
1420
|
+
const items = awsProfileItems(snapshot.panel, panelFilter);
|
|
1421
|
+
if (key.return && items[modelProfileSelection]) {
|
|
1422
|
+
void activateRow({ label: '', description: '', value: items[modelProfileSelection].id });
|
|
1423
|
+
}
|
|
1424
|
+
else if (key.upArrow && modelProfileSelection === 0) {
|
|
1425
|
+
setModelPanelFocus('providers');
|
|
1426
|
+
}
|
|
1427
|
+
else if (character === '/') {
|
|
1428
|
+
setModelPanelFocus('search');
|
|
1429
|
+
}
|
|
1430
|
+
else {
|
|
1431
|
+
const next = moveSelection(modelProfileSelection, key, items.length, rowCapacity);
|
|
1432
|
+
if (next !== undefined)
|
|
1433
|
+
setModelProfileSelection(next);
|
|
1434
|
+
}
|
|
1435
|
+
return;
|
|
1436
|
+
}
|
|
1437
|
+
if (modelPanelFocus === 'search' && (key.downArrow || key.return)) {
|
|
1438
|
+
setModelPanelFocus('models');
|
|
1439
|
+
return;
|
|
1440
|
+
}
|
|
1441
|
+
if (snapshot.panel.kind === 'help' && modelPanelFocus === 'providers' && (key.return || key.rightArrow)) {
|
|
1442
|
+
setModelPanelFocus('models');
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
if (modelPanelFocus === 'providers' && snapshot.panel.filters?.length && (key.upArrow || key.downArrow)) {
|
|
1446
|
+
if (snapshot.panel.kind === 'models' && awsProfileItems(snapshot.panel, panelFilter).length) {
|
|
1447
|
+
const index = snapshot.panel.filters.findIndex((item) => item.id === panelFilter);
|
|
1448
|
+
if ((key.downArrow && index === snapshot.panel.filters.length - 1) || (key.upArrow && index === 0)) {
|
|
1449
|
+
setModelPanelFocus('profiles');
|
|
1450
|
+
setModelProfileSelection(key.upArrow ? awsProfileItems(snapshot.panel, panelFilter).length - 1 : 0);
|
|
1451
|
+
return;
|
|
1452
|
+
}
|
|
1453
|
+
if (snapshot.panel.awsProfile?.open) {
|
|
1454
|
+
void controller.activatePanelRow({ label: '', description: '', value: 'aws-profile:toggle' });
|
|
1455
|
+
setModelProfileSelection(0);
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
setPanelFilter(cyclePanelFilter(snapshot.panel.filters, panelFilter, key.upArrow ? -1 : 1));
|
|
1459
|
+
resetPanelPosition();
|
|
1460
|
+
return;
|
|
1461
|
+
}
|
|
1462
|
+
if (modelPanelFocus === 'models') {
|
|
1463
|
+
const selected = rows[Math.min(panelSelectionRef.current, rows.length - 1)];
|
|
1464
|
+
if (key.return && selected?.value) {
|
|
1465
|
+
void activateRow(selected);
|
|
1466
|
+
return;
|
|
1467
|
+
}
|
|
1468
|
+
const nextSelection = moveSelection(panelSelectionRef.current, key, rows.length, rowCapacity);
|
|
1469
|
+
if (nextSelection !== undefined) {
|
|
1470
|
+
selectPanelRow(nextSelection, rowCapacity, rows.length);
|
|
1471
|
+
return;
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
if (modelPanelFocus === 'models' && character === '/') {
|
|
1475
|
+
setModelPanelFocus('search');
|
|
1476
|
+
return;
|
|
1477
|
+
}
|
|
1478
|
+
const edit = modelPanelFocus === 'search' || snapshot.panel.kind === 'help' ? queryEdit(character, key) : undefined;
|
|
1479
|
+
if (edit) {
|
|
1480
|
+
if (snapshot.panel.kind === 'help')
|
|
1481
|
+
setModelPanelFocus('search');
|
|
1482
|
+
setPanelQuery(edit);
|
|
1483
|
+
resetPanelPosition();
|
|
1484
|
+
}
|
|
1485
|
+
return;
|
|
1486
|
+
}
|
|
1487
|
+
if (snapshot.panel.kind === 'settings') {
|
|
1488
|
+
if (key.tab) {
|
|
1489
|
+
setSettingsPanelFocus(settingsPanelFocus === 'categories' ? 'settings' : 'categories');
|
|
1490
|
+
return;
|
|
1491
|
+
}
|
|
1492
|
+
if (settingsPanelFocus === 'categories') {
|
|
1493
|
+
if ((key.upArrow || key.downArrow) && snapshot.panel.filters?.length) {
|
|
1494
|
+
const category = cyclePanelFilter(snapshot.panel.filters, `settings:${snapshot.panel.settingsCategory}`, key.upArrow ? -1 : 1);
|
|
1495
|
+
void activateRow({ label: '', description: '', value: category });
|
|
1496
|
+
}
|
|
1497
|
+
else if (key.return || key.rightArrow) {
|
|
1498
|
+
setSettingsPanelFocus('settings');
|
|
1499
|
+
}
|
|
1500
|
+
return;
|
|
1501
|
+
}
|
|
1502
|
+
const selected = rows[Math.min(panelSelectionRef.current, rows.length - 1)];
|
|
1503
|
+
if (key.leftArrow || key.rightArrow) {
|
|
1504
|
+
const value = selected && settingArrowValue(selected, key.leftArrow ? -1 : 1);
|
|
1505
|
+
if (selected && value) {
|
|
1506
|
+
void activateRow({ ...selected, value });
|
|
1507
|
+
}
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1510
|
+
if ((key.return || character === ' ') && selected?.value) {
|
|
1511
|
+
void activateRow(selected);
|
|
1512
|
+
return;
|
|
1513
|
+
}
|
|
1514
|
+
const nextSelection = moveSelection(panelSelectionRef.current, key, rows.length, rowCapacity);
|
|
1515
|
+
if (nextSelection !== undefined) {
|
|
1516
|
+
selectPanelRow(nextSelection, rowCapacity, rows.length);
|
|
1517
|
+
}
|
|
1518
|
+
return;
|
|
1519
|
+
}
|
|
1520
|
+
if (key.tab) {
|
|
1521
|
+
const nextSelection = cycleMultiColumnPanelSelection(snapshot.panel.kind, rows, panelSelectionRef.current, key.shift ? -1 : 1);
|
|
1522
|
+
if (nextSelection !== undefined) {
|
|
1523
|
+
selectPanelRow(nextSelection, rowCapacity, rows.length);
|
|
1524
|
+
return;
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
if (key.tab && snapshot.panel.filters?.length) {
|
|
1528
|
+
setPanelFilter(cyclePanelFilter(snapshot.panel.filters, panelFilter, key.shift ? -1 : 1));
|
|
1529
|
+
resetPanelPosition();
|
|
1530
|
+
return;
|
|
1531
|
+
}
|
|
1532
|
+
if (snapshot.panel.kind === 'voice') {
|
|
1533
|
+
if (key.leftArrow || key.rightArrow) {
|
|
1534
|
+
const selected = rows[Math.min(panelSelectionRef.current, rows.length - 1)];
|
|
1535
|
+
const value = selected && settingArrowValue(selected, key.leftArrow ? -1 : 1);
|
|
1536
|
+
if (selected && value) {
|
|
1537
|
+
void activateRow({ ...selected, value });
|
|
1538
|
+
}
|
|
1539
|
+
return;
|
|
1540
|
+
}
|
|
1541
|
+
const nextSelection = moveMultiColumnPanelSelection(snapshot.panel.kind, rows, panelSelectionRef.current, key, Math.max(1, Math.floor(rowCapacity / 2)));
|
|
1542
|
+
if (nextSelection !== undefined) {
|
|
1543
|
+
selectPanelRow(nextSelection, rowCapacity, rows.length);
|
|
1544
|
+
return;
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
if (snapshot.panel.kind === 'export' && (key.leftArrow || key.rightArrow)) {
|
|
1548
|
+
const nextSelection = Math.max(0, Math.min(rows.length - 1, panelSelectionRef.current + (key.leftArrow ? -1 : 1)));
|
|
1549
|
+
selectPanelRow(nextSelection, rowCapacity, rows.length);
|
|
1550
|
+
return;
|
|
1551
|
+
}
|
|
1552
|
+
if ((snapshot.panel.kind === 'voice' || snapshot.panel.kind === 'tools') && character === ' ') {
|
|
1553
|
+
const selected = rows[Math.min(panelSelectionRef.current, rows.length - 1)];
|
|
1554
|
+
if (selected?.value) {
|
|
1555
|
+
void activateRow(selected);
|
|
1556
|
+
}
|
|
1557
|
+
return;
|
|
1558
|
+
}
|
|
1559
|
+
if (snapshot.panel.kind === 'agents') {
|
|
1560
|
+
const selected = rows[Math.min(panelSelectionRef.current, rows.length - 1)];
|
|
1561
|
+
if (character.toLowerCase() === 'r' &&
|
|
1562
|
+
!key.ctrl &&
|
|
1563
|
+
!key.meta &&
|
|
1564
|
+
selected?.value?.startsWith('conversation:')) {
|
|
1565
|
+
void activateRow({ ...selected, value: `${selected.value}=rename` });
|
|
1566
|
+
return;
|
|
1567
|
+
}
|
|
1568
|
+
if (key.return) {
|
|
1569
|
+
if (selected?.value)
|
|
1570
|
+
void activateRow(selected);
|
|
1571
|
+
return;
|
|
1572
|
+
}
|
|
1573
|
+
const { columns } = agentGridLayout(terminalWidth, terminalHeight);
|
|
1574
|
+
const next = key.tab && rows.length > 0
|
|
1575
|
+
? (panelSelectionRef.current + (key.shift ? -1 : 1) + rows.length) % rows.length
|
|
1576
|
+
: moveAgentGridSelection(panelSelectionRef.current, key, rows.length, columns, rowCapacity);
|
|
1577
|
+
if (next !== undefined) {
|
|
1578
|
+
panelSelectionRef.current = next;
|
|
1579
|
+
setPanelSelection(next);
|
|
1580
|
+
const start = revealAgentGridSelection(next, panelViewportStartRef.current, rowCapacity, rows.length, columns);
|
|
1581
|
+
panelViewportStartRef.current = start;
|
|
1582
|
+
setPanelViewportStart(start);
|
|
1583
|
+
return;
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
if (snapshot.panel.kind === 'permission' && (key.upArrow || key.downArrow || key.leftArrow || key.rightArrow)) {
|
|
1587
|
+
const layout = permissionPanelLayout(Math.max(1, terminalWidth - 2), composerHeight ?? terminalHeight, rows.length);
|
|
1588
|
+
const next = movePermissionSelection(panelSelectionRef.current, key, rows.length, layout.optionGrid);
|
|
1589
|
+
if (next !== undefined) {
|
|
1590
|
+
selectPanelRow(next, layout.optionCapacity, rows.length);
|
|
1591
|
+
}
|
|
1592
|
+
return;
|
|
1593
|
+
}
|
|
1594
|
+
if (key.rightArrow && snapshot.panel.kind === 'skills') {
|
|
1595
|
+
const selected = rows[Math.min(panelSelectionRef.current, rows.length - 1)];
|
|
1596
|
+
if (selected?.value) {
|
|
1597
|
+
rememberDetailParent();
|
|
1598
|
+
controller.openSkillDetail(decodeURIComponent(selected.value));
|
|
1599
|
+
}
|
|
1600
|
+
return;
|
|
1601
|
+
}
|
|
1602
|
+
if (key.return) {
|
|
1603
|
+
const selected = rows[Math.min(panelSelectionRef.current, rows.length - 1)];
|
|
1604
|
+
if (selected?.value) {
|
|
1605
|
+
void activateRow(selected);
|
|
1606
|
+
}
|
|
1607
|
+
else if (!snapshot.panel.searchable) {
|
|
1608
|
+
controller.dismissPanel();
|
|
1609
|
+
}
|
|
1610
|
+
return;
|
|
1611
|
+
}
|
|
1612
|
+
const nextSelection = moveSelection(panelSelectionRef.current, key, rows.length, rowCapacity);
|
|
1613
|
+
if (nextSelection !== undefined) {
|
|
1614
|
+
selectPanelRow(nextSelection, rowCapacity, rows.length);
|
|
1615
|
+
return;
|
|
1616
|
+
}
|
|
1617
|
+
const edit = snapshot.panel.searchable ? queryEdit(character, key) : undefined;
|
|
1618
|
+
if (edit) {
|
|
1619
|
+
setPanelQuery(edit);
|
|
1620
|
+
resetPanelPosition();
|
|
1621
|
+
}
|
|
1622
|
+
return;
|
|
1623
|
+
}
|
|
1624
|
+
if (key.meta && (key.upArrow || key.downArrow)) {
|
|
1625
|
+
const prompts = snapshot.queuedPrompts.filter((prompt) => prompt.source !== 'peer');
|
|
1626
|
+
const index = prompts.findIndex((prompt) => prompt.id === editingQueuedPromptId);
|
|
1627
|
+
const next = index < 0 ? (key.upArrow ? prompts.length - 1 : 0) : index + (key.upArrow ? -1 : 1);
|
|
1628
|
+
if (prompts[next])
|
|
1629
|
+
editQueuedPrompt(prompts[next].id);
|
|
1630
|
+
return;
|
|
1631
|
+
}
|
|
1632
|
+
const backgroundTasks = snapshot.tasks.filter((task) => task.source === 'background' && isActiveTask(task.status));
|
|
1633
|
+
if (key.tab &&
|
|
1634
|
+
(focusedQueuedPrompt ||
|
|
1635
|
+
focusedBackgroundTask ||
|
|
1636
|
+
(suggestions.length === 0 &&
|
|
1637
|
+
!currentEditor.input.startsWith('/') &&
|
|
1638
|
+
(queuedPromptElements.size > 0 || backgroundTasks.length > 0)))) {
|
|
1639
|
+
const targets = [
|
|
1640
|
+
undefined,
|
|
1641
|
+
...snapshot.queuedPrompts.flatMap((prompt) => QUEUED_PROMPT_ACTIONS.map(({ action }) => `${prompt.id}:${action}`)),
|
|
1642
|
+
...(backgroundTasks.length > 0 ? ['background'] : []),
|
|
1643
|
+
];
|
|
1644
|
+
let index = Math.max(0, targets.indexOf(focusedBackgroundTask ? 'background' : focusedQueuedPrompt));
|
|
1645
|
+
let selected;
|
|
1646
|
+
do {
|
|
1647
|
+
index = (index + (key.shift ? -1 : 1) + targets.length) % targets.length;
|
|
1648
|
+
selected = targets[index];
|
|
1649
|
+
} while (selected && selected !== 'background' && !queuedPromptElements.has(selected));
|
|
1650
|
+
setFocusedQueuedPrompt(selected === 'background' ? undefined : selected);
|
|
1651
|
+
setFocusedBackgroundTask(selected === 'background' ? backgroundTasks[0].id : undefined);
|
|
1652
|
+
return;
|
|
1653
|
+
}
|
|
1654
|
+
if (focusedBackgroundTask) {
|
|
1655
|
+
if (key.escape || key.upArrow) {
|
|
1656
|
+
setFocusedBackgroundTask(undefined);
|
|
1657
|
+
}
|
|
1658
|
+
else if (key.return) {
|
|
1659
|
+
controller.openTask(focusedBackgroundTask);
|
|
1660
|
+
setFocusedBackgroundTask(undefined);
|
|
1661
|
+
}
|
|
1662
|
+
else if (key.leftArrow || key.rightArrow || key.downArrow) {
|
|
1663
|
+
const index = backgroundTasks.findIndex((task) => task.id === focusedBackgroundTask);
|
|
1664
|
+
const direction = key.leftArrow ? -1 : 1;
|
|
1665
|
+
setFocusedBackgroundTask(backgroundTasks[(index + direction + backgroundTasks.length) % backgroundTasks.length]?.id);
|
|
1666
|
+
}
|
|
1667
|
+
return;
|
|
1668
|
+
}
|
|
1669
|
+
if (focusedQueuedPrompt) {
|
|
1670
|
+
if (key.escape)
|
|
1671
|
+
setFocusedQueuedPrompt(undefined);
|
|
1672
|
+
else if (key.return)
|
|
1673
|
+
activateQueuedPrompt(focusedQueuedPrompt);
|
|
1674
|
+
return;
|
|
1675
|
+
}
|
|
1676
|
+
if (backgroundTasks.length > 0 &&
|
|
1677
|
+
suggestions.length === 0 &&
|
|
1678
|
+
!editingQueuedPromptId &&
|
|
1679
|
+
!key.ctrl &&
|
|
1680
|
+
!key.meta &&
|
|
1681
|
+
key.downArrow &&
|
|
1682
|
+
currentEditor.input === '') {
|
|
1683
|
+
setFocusedBackgroundTask(backgroundTasks[0].id);
|
|
1684
|
+
return;
|
|
1685
|
+
}
|
|
1686
|
+
if (editingQueuedPromptId && key.escape) {
|
|
1687
|
+
finishQueuedPromptEdit();
|
|
1688
|
+
return;
|
|
1689
|
+
}
|
|
1690
|
+
const phase = editingQueuedPromptId ? 'idle' : controller.busy ? 'running' : 'idle';
|
|
1691
|
+
// Esc closes the palette before it can cancel a running turn.
|
|
1692
|
+
if (viewPropsRef.current.commandAssistance && key.escape) {
|
|
1693
|
+
setDismissedSuggestions(currentEditor.input);
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
if (key.escape && snapshot.parentAgent && controller.returnToParent?.())
|
|
1697
|
+
return;
|
|
1698
|
+
if (suggestions.length > 0) {
|
|
1699
|
+
const current = Math.min(suggestionSelectionRef.current, suggestions.length - 1);
|
|
1700
|
+
const next = moveSelection(current, key, suggestions.length, suggestions.length);
|
|
1701
|
+
if (next !== undefined) {
|
|
1702
|
+
suggestionSelectionRef.current = next;
|
|
1703
|
+
setSuggestionSelection(next);
|
|
1704
|
+
return;
|
|
1705
|
+
}
|
|
1706
|
+
const selected = suggestions[current];
|
|
1707
|
+
if (key.tab) {
|
|
1708
|
+
setEditor(completeSuggestion(currentEditor, selected));
|
|
1709
|
+
return;
|
|
1710
|
+
}
|
|
1711
|
+
if (key.return) {
|
|
1712
|
+
if (selected.replacement && currentEditor.input.trim() !== selected.replacement.trim()) {
|
|
1713
|
+
setEditor(completeSuggestion(currentEditor, selected));
|
|
1714
|
+
return;
|
|
1715
|
+
}
|
|
1716
|
+
const prompt = selected.replacement ? currentEditor.input : `/${selected.name}`;
|
|
1717
|
+
const result = submitEditor(currentEditor, prompt);
|
|
1718
|
+
setEditor(result.state);
|
|
1719
|
+
if (result.action === 'submit') {
|
|
1720
|
+
dispatchPrompt(result.prompt);
|
|
1721
|
+
}
|
|
1722
|
+
return;
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
if (key.pageUp || key.pageDown || (key.ctrl && (key.upArrow || key.downArrow || key.home || key.end))) {
|
|
1726
|
+
if (key.ctrl && key.home) {
|
|
1727
|
+
setTranscriptScroll(maxTranscriptScrollRef.current);
|
|
1728
|
+
return;
|
|
1729
|
+
}
|
|
1730
|
+
if (key.ctrl && key.end) {
|
|
1731
|
+
setTranscriptScroll(0);
|
|
1732
|
+
return;
|
|
1733
|
+
}
|
|
1734
|
+
const direction = key.pageUp || key.upArrow ? -1 : 1;
|
|
1735
|
+
setTranscriptScroll((value) => scrollTranscript(value, direction, maxTranscriptScrollRef.current, key.pageUp || key.pageDown ? Math.max(3, terminalHeight - 8) : 3));
|
|
1736
|
+
return;
|
|
1737
|
+
}
|
|
1738
|
+
if (shouldToggleVoiceMute(character, key, currentEditor.input, snapshot.voice?.status)) {
|
|
1739
|
+
controller.toggleVoiceMute?.();
|
|
1740
|
+
return;
|
|
1741
|
+
}
|
|
1742
|
+
if (key.return && !currentEditor.input.trim()) {
|
|
1743
|
+
if (editingQueuedPromptId && controller.updateQueuedPrompt(editingQueuedPromptId, '')) {
|
|
1744
|
+
finishQueuedPromptEdit();
|
|
1745
|
+
return;
|
|
1746
|
+
}
|
|
1747
|
+
if (attachmentsRef.current.length > 0) {
|
|
1748
|
+
dispatchPrompt('');
|
|
1749
|
+
return;
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
const result = reduceInputSequence(currentEditor, character, key, phase);
|
|
1753
|
+
setEditor(result.state);
|
|
1754
|
+
if (result.action === 'submit') {
|
|
1755
|
+
dispatchPrompt(result.prompt);
|
|
1756
|
+
}
|
|
1757
|
+
else if (result.action === 'cancel') {
|
|
1758
|
+
controller.cancel();
|
|
1759
|
+
}
|
|
1760
|
+
}, [
|
|
1761
|
+
activateRow,
|
|
1762
|
+
activateQueuedPrompt,
|
|
1763
|
+
controller,
|
|
1764
|
+
copyText,
|
|
1765
|
+
dispatchPrompt,
|
|
1766
|
+
editingQueuedPromptId,
|
|
1767
|
+
editQueuedPrompt,
|
|
1768
|
+
finishQueuedPromptEdit,
|
|
1769
|
+
focusedQueuedPrompt,
|
|
1770
|
+
focusedBackgroundTask,
|
|
1771
|
+
frog,
|
|
1772
|
+
handleExit,
|
|
1773
|
+
handleMouse,
|
|
1774
|
+
openConfigurationProject,
|
|
1775
|
+
hoveredPanelRow,
|
|
1776
|
+
rememberDetailParent,
|
|
1777
|
+
resetHover,
|
|
1778
|
+
resetPanelPosition,
|
|
1779
|
+
queuedPromptElements,
|
|
1780
|
+
selectPanelRow,
|
|
1781
|
+
setEditor,
|
|
1782
|
+
]);
|
|
1783
|
+
const inputHandlerRef = useRef({ handleInput, editingQueuedPromptId, currentInputQueue });
|
|
1784
|
+
inputHandlerRef.current = { handleInput, editingQueuedPromptId, currentInputQueue };
|
|
1785
|
+
useInput((text, key) => {
|
|
1786
|
+
const pending = currentInputQueue();
|
|
1787
|
+
if (pending && !(key.ctrl && (text === 'c' || text === 'd'))) {
|
|
1788
|
+
pending.events.push({ kind: 'key', text, key });
|
|
1789
|
+
return;
|
|
1790
|
+
}
|
|
1791
|
+
handleInput(text, key);
|
|
1792
|
+
}, { isActive: updatePromptVersion === undefined });
|
|
1793
|
+
usePaste((text) => {
|
|
1794
|
+
const existing = currentInputQueue();
|
|
1795
|
+
if (existing) {
|
|
1796
|
+
existing.events.push({ kind: 'paste', text });
|
|
1797
|
+
return;
|
|
1798
|
+
}
|
|
1799
|
+
const current = controller.getSnapshot();
|
|
1800
|
+
if (current.panel?.kind === 'permission') {
|
|
1801
|
+
handleInput(text, {});
|
|
1802
|
+
return;
|
|
1803
|
+
}
|
|
1804
|
+
const pending = {
|
|
1805
|
+
events: [{ kind: 'paste', text }],
|
|
1806
|
+
controller,
|
|
1807
|
+
conversationId: current.conversationId,
|
|
1808
|
+
panelId: current.panel?.id,
|
|
1809
|
+
};
|
|
1810
|
+
pendingInputRef.current = pending;
|
|
1811
|
+
void (async () => {
|
|
1812
|
+
while (inputHandlerRef.current.currentInputQueue() === pending && pending.events.length > 0) {
|
|
1813
|
+
const next = pending.events.shift();
|
|
1814
|
+
const currentSnapshot = controller.getSnapshot();
|
|
1815
|
+
if (next.kind === 'paste' && !currentSnapshot.panel && !inputHandlerRef.current.editingQueuedPromptId) {
|
|
1816
|
+
const work = attachmentWorkRef.current;
|
|
1817
|
+
const paths = await filePathsFromPaste(next.text, currentSnapshot.runtime.cwd).catch(() => undefined);
|
|
1818
|
+
if (inputHandlerRef.current.currentInputQueue() !== pending)
|
|
1819
|
+
return;
|
|
1820
|
+
if (paths) {
|
|
1821
|
+
await attachPaths(paths, work);
|
|
1822
|
+
if (inputHandlerRef.current.currentInputQueue() !== pending)
|
|
1823
|
+
return;
|
|
1824
|
+
}
|
|
1825
|
+
else {
|
|
1826
|
+
inputHandlerRef.current.handleInput(next.text, {});
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
else {
|
|
1830
|
+
inputHandlerRef.current.handleInput(next.text, next.kind === 'key' ? next.key : {});
|
|
1831
|
+
}
|
|
1832
|
+
pending.panelId = controller.getSnapshot().panel?.id;
|
|
1833
|
+
await new Promise((resolve) => {
|
|
1834
|
+
inputCommitRef.current.resolve = resolve;
|
|
1835
|
+
setInputRevision(++inputCommitRef.current.revision);
|
|
1836
|
+
});
|
|
1837
|
+
}
|
|
1838
|
+
if (pendingInputRef.current === pending)
|
|
1839
|
+
pendingInputRef.current = undefined;
|
|
1840
|
+
})();
|
|
1841
|
+
}, { isActive: updatePromptVersion === undefined });
|
|
1842
|
+
if (updatePromptVersion) {
|
|
1843
|
+
return (_jsx(ThemeProvider, { settings: snapshot.settings, children: _jsx(UpdatePrompt, { version: updatePromptVersion, width: width, height: height, onUpdate: onRequestUpdate, onExit: handleExit, onLater: dismissUpdatePrompt, onDisable: async () => {
|
|
1844
|
+
const disabled = (await controller.setSettings?.({ updatePrompts: false })) ?? false;
|
|
1845
|
+
if (disabled) {
|
|
1846
|
+
dismissUpdatePrompt();
|
|
1847
|
+
}
|
|
1848
|
+
return disabled;
|
|
1849
|
+
} }) }));
|
|
1850
|
+
}
|
|
1851
|
+
return (_jsx(ChatView, { ...viewProps, ...(entranceFade !== undefined ? { entranceFade } : {}), ...(restartedIntroAt.current !== undefined || introStartedAt !== undefined
|
|
1852
|
+
? { introStartedAt: restartedIntroAt.current ?? introStartedAt }
|
|
1853
|
+
: {}), snapshot: snapshot, onActionElement: registerFooterElement, ...(hoveredAction !== undefined ? { hoveredAction } : {}), ...(installableUpdate ? { availableUpdate: installableUpdate } : {}), ...(hoveredMetadata ? { hoveredMetadata } : {}), ...(controller.voice ? { voice: controller.voice } : {}), onMaxTranscriptScroll: updateMaxTranscriptScroll, onMetadataElement: registerMetadataElement, onPanelElement: registerPanelElement, onDockElement: registerDockElement, onPanelRowElement: registerPanelRowElement, onPanelControlElement: registerPanelControlElement, onPanelFilterElement: registerPanelFilterElement, onPanelSearchElement: registerPanelSearchElement, onPanelSliderElement: registerPanelSliderElement, onSuggestionElement: registerSuggestionElement, ...(pressedMetadata ? { pressedMetadata } : {}), ...(pressedPanelFilter ? { pressedPanelFilter } : {}), ...(pressedPanelRow !== undefined ? { pressedPanelRow } : {}), ...(pressedPanelControl ? { pressedPanelControl } : {}), ...(hoveredPanelControl ? { hoveredPanelControl } : {}), ...(pressedSuggestion !== undefined ? { pressedSuggestion } : {}), ...(hoveredPanelRow !== undefined ? { hoveredPanelRow } : {}), ...(hoveredPanelFilter ? { hoveredPanelFilter } : {}), ...(hoveredSuggestion !== undefined ? { hoveredSuggestion } : {}), ...(pressedQueuedPrompt ? { pressedQueuedPrompt } : {}), ...(focusedQueuedPrompt ? { focusedQueuedPrompt } : {}), ...(editingQueuedPromptId ? { editingQueuedPromptId } : {}), ...(frog ? { frog, onFrogComplete: finishFrog } : {}), ...(frogBrandAnimationId !== undefined ? { frogBrandAnimationId } : {}), selection: screenSelection, ...(clipboardNotice ? { clipboardNotice } : {}), onQueuedPromptElement: registerQueuedPromptElement, onBackgroundTaskElement: registerBackgroundTaskElement, onStatusElement: registerStatusElement, onFrogElement: registerFrogElement, onJumpToBottomElement: registerJumpToBottomElement, hoveredJumpToBottom: hoveredJumpToBottom, onToolGroupElement: registerToolGroupElement }));
|
|
1854
|
+
}
|
|
1855
|
+
function useElementMap() {
|
|
1856
|
+
const elements = useRef(new Map()).current;
|
|
1857
|
+
const register = useCallback((key, element) => {
|
|
1858
|
+
registerElement(elements, key, element);
|
|
1859
|
+
}, [elements]);
|
|
1860
|
+
return [elements, register];
|
|
1861
|
+
}
|
|
1862
|
+
function configurationScrollBounds(configuration, language, dockWidth, dockHeight, diffFor) {
|
|
1863
|
+
const selected = configurationDocument(configuration, language);
|
|
1864
|
+
const codeSize = configurationDockCodeSize(dockWidth, dockHeight);
|
|
1865
|
+
const maxScroll = maxConfigurationScroll(selected.document.source, codeSize.width, codeSize.height, diffFor(selected.language));
|
|
1866
|
+
return { maxScroll, codeSize };
|
|
1867
|
+
}
|
|
1868
|
+
function activeConfigurationDiff(snapshot, language) {
|
|
1869
|
+
const active = (snapshot.activeTurn ?? snapshot.completedTurns.at(-1))?.entries.some((entry) => entry.type === 'tool' && isConfigurationTool(entry.name));
|
|
1870
|
+
return active ? snapshot.configurationDiffs?.[language] : undefined;
|
|
1871
|
+
}
|
|
1872
|
+
function parseQueuedPromptTarget(target) {
|
|
1873
|
+
const separator = target.lastIndexOf(':');
|
|
1874
|
+
const id = target.slice(0, separator);
|
|
1875
|
+
const action = target.slice(separator + 1);
|
|
1876
|
+
if (!id || (action !== 'edit' && action !== 'steer' && action !== 'delete' && action !== 'up' && action !== 'down')) {
|
|
1877
|
+
return undefined;
|
|
1878
|
+
}
|
|
1879
|
+
return { id, action };
|
|
1880
|
+
}
|
|
1881
|
+
/** The change a key makes to a single-line panel query, or `undefined` when the key does not edit it. */
|
|
1882
|
+
function queryEdit(character, key, newline = '') {
|
|
1883
|
+
if (key.backspace || key.delete || character === '\u007f') {
|
|
1884
|
+
return (query) => graphemes(query).slice(0, -1).join('');
|
|
1885
|
+
}
|
|
1886
|
+
if (key.ctrl && character === 'u')
|
|
1887
|
+
return () => '';
|
|
1888
|
+
if (key.ctrl || key.meta || key.super || !character)
|
|
1889
|
+
return undefined;
|
|
1890
|
+
const clean = sanitizeTerminalText(character).replaceAll('\n', newline);
|
|
1891
|
+
return clean ? (query) => query + clean : undefined;
|
|
1892
|
+
}
|
|
1893
|
+
function panelSlider(panel) {
|
|
1894
|
+
if (panel?.kind === 'effort' || panel?.kind === 'permissions')
|
|
1895
|
+
return panel.slider;
|
|
1896
|
+
if (panel?.kind === 'voice') {
|
|
1897
|
+
const control = panel.rows.find((row) => row.value === 'voice:enabled')?.control;
|
|
1898
|
+
return control?.kind === 'segmented'
|
|
1899
|
+
? { label: 'Voice', options: control.options.map(({ value: id, ...option }) => ({ id, ...option })) }
|
|
1900
|
+
: undefined;
|
|
1901
|
+
}
|
|
1902
|
+
return undefined;
|
|
1903
|
+
}
|
|
1904
|
+
function activeSliderOption(panel) {
|
|
1905
|
+
return panelSlider(panel)?.options.find((option) => option.active)?.id;
|
|
1906
|
+
}
|
|
1907
|
+
//# sourceMappingURL=screen.js.map
|