@zyro-sec/tui 0.0.0-stage → 1.0.2
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/AGENTS.md +6 -0
- package/bunfig.toml +4 -0
- package/package.json +79 -4
- package/src/app.tsx +1632 -0
- package/src/assets/backgrounds/anime.png +0 -0
- package/src/assets/backgrounds/circuit.jpg +0 -0
- package/src/assets/backgrounds/cyber-grid.jpg +0 -0
- package/src/assets/backgrounds/datacenter.jpg +0 -0
- package/src/assets/backgrounds/hacker-desk.jpg +0 -0
- package/src/assets/backgrounds/matrix-code.jpg +0 -0
- package/src/attention-sounds.bun.ts +8 -0
- package/src/attention-sounds.node.ts +16 -0
- package/src/attention.ts +189 -0
- package/src/audio.d.ts +9 -0
- package/src/audio.ts +49 -0
- package/src/clipboard.ts +68 -0
- package/src/component/background-image.tsx +26 -0
- package/src/component/command-palette.tsx +74 -0
- package/src/component/devtools-bar.tsx +611 -0
- package/src/component/dialog-agent.tsx +33 -0
- package/src/component/dialog-background.tsx +102 -0
- package/src/component/dialog-config.tsx +494 -0
- package/src/component/dialog-debug.tsx +90 -0
- package/src/component/dialog-error-details.tsx +130 -0
- package/src/component/dialog-experiments.tsx +101 -0
- package/src/component/dialog-go-upsell.tsx +448 -0
- package/src/component/dialog-highlights.tsx +88 -0
- package/src/component/dialog-image-preview.tsx +85 -0
- package/src/component/dialog-install-mcp.tsx +67 -0
- package/src/component/dialog-integration.tsx +1332 -0
- package/src/component/dialog-mcp.tsx +184 -0
- package/src/component/dialog-model-free.tsx +79 -0
- package/src/component/dialog-model.tsx +238 -0
- package/src/component/dialog-open.tsx +509 -0
- package/src/component/dialog-pair.tsx +123 -0
- package/src/component/dialog-session-list.tsx +328 -0
- package/src/component/dialog-session-rename.tsx +37 -0
- package/src/component/dialog-shell-output.tsx +194 -0
- package/src/component/dialog-skill.tsx +93 -0
- package/src/component/dialog-speed.tsx +48 -0
- package/src/component/dialog-stash.tsx +90 -0
- package/src/component/dialog-status.tsx +50 -0
- package/src/component/dialog-theme-list.tsx +56 -0
- package/src/component/dialog-update.tsx +144 -0
- package/src/component/dialog-variant.tsx +43 -0
- package/src/component/dialog-workspace-file-changes.tsx +187 -0
- package/src/component/dialog-workspaces.tsx +413 -0
- package/src/component/dialog-worktree-name.tsx +40 -0
- package/src/component/error-component.tsx +258 -0
- package/src/component/fade-in-text.tsx +113 -0
- package/src/component/go-upsell-art.ts +338 -0
- package/src/component/logo.tsx +79 -0
- package/src/component/masked-text.ts +59 -0
- package/src/component/media-source.ts +43 -0
- package/src/component/migration-overlay.tsx +73 -0
- package/src/component/model-options.tsx +121 -0
- package/src/component/one-cell-spinner.tsx +75 -0
- package/src/component/panel-host.tsx +64 -0
- package/src/component/patch-diff.tsx +211 -0
- package/src/component/plugin-route-missing.tsx +21 -0
- package/src/component/prompt/autocomplete.tsx +1005 -0
- package/src/component/prompt/draft-stash.ts +47 -0
- package/src/component/prompt/index.tsx +2080 -0
- package/src/component/prompt/local-attachment.ts +188 -0
- package/src/component/prompt/metadata.tsx +193 -0
- package/src/component/prompt/move.tsx +181 -0
- package/src/component/reconnecting.tsx +40 -0
- package/src/component/retry-provider.tsx +202 -0
- package/src/component/session-frame.tsx +408 -0
- package/src/component/session-tabs-rail.tsx +94 -0
- package/src/component/session-tabs.tsx +1789 -0
- package/src/component/shimmer-text.tsx +64 -0
- package/src/component/spinner-frames.ts +1 -0
- package/src/component/spinner-renderable.ts +126 -0
- package/src/component/spinner.tsx +50 -0
- package/src/component/startup-loading.tsx +63 -0
- package/src/component/tab-pulse.tsx +819 -0
- package/src/component/terminal-pane.tsx +377 -0
- package/src/component/theme-error-toast.tsx +20 -0
- package/src/component/title-shimmer.tsx +272 -0
- package/src/component/todo-item.tsx +27 -0
- package/src/component/usage.tsx +329 -0
- package/src/component/use-connected.tsx +14 -0
- package/src/config/index.tsx +438 -0
- package/src/config/keybind.ts +367 -0
- package/src/config/new-session-location.ts +16 -0
- package/src/config/v1/index.tsx +149 -0
- package/src/config/v1/keybind.ts +463 -0
- package/src/context/args.tsx +31 -0
- package/src/context/attention.tsx +23 -0
- package/src/context/client-mcp.tsx +119 -0
- package/src/context/client.tsx +76 -0
- package/src/context/clipboard.tsx +19 -0
- package/src/context/data.tsx +69 -0
- package/src/context/editor.ts +408 -0
- package/src/context/epilogue.tsx +14 -0
- package/src/context/event.ts +32 -0
- package/src/context/exit.tsx +8 -0
- package/src/context/helper.tsx +26 -0
- package/src/context/interactivity.tsx +20 -0
- package/src/context/keymap.tsx +515 -0
- package/src/context/local.tsx +723 -0
- package/src/context/location.tsx +80 -0
- package/src/context/log.tsx +24 -0
- package/src/context/panel.tsx +59 -0
- package/src/context/path-format.tsx +12 -0
- package/src/context/permission.tsx +18 -0
- package/src/context/program-status.ts +94 -0
- package/src/context/prompt.tsx +18 -0
- package/src/context/route.tsx +73 -0
- package/src/context/runtime.tsx +98 -0
- package/src/context/session-tabs-model.ts +263 -0
- package/src/context/session-tabs.tsx +508 -0
- package/src/context/session-terminals.tsx +136 -0
- package/src/context/storage.tsx +150 -0
- package/src/context/theme.tsx +447 -0
- package/src/context/thinking.ts +20 -0
- package/src/context/update-notification.tsx +158 -0
- package/src/devtools/index.ts +41 -0
- package/src/editor-zed-sqlite.bun.ts +1 -0
- package/src/editor-zed-sqlite.node.ts +21 -0
- package/src/editor-zed.ts +277 -0
- package/src/editor.ts +86 -0
- package/src/feature-plugins/home/footer.tsx +116 -0
- package/src/feature-plugins/prompt/btw.tsx +190 -0
- package/src/feature-plugins/prompt/footer.tsx +163 -0
- package/src/feature-plugins/prompt/goal.tsx +211 -0
- package/src/feature-plugins/sidebar/context.tsx +52 -0
- package/src/feature-plugins/sidebar/footer.tsx +126 -0
- package/src/feature-plugins/sidebar/limit.tsx +47 -0
- package/src/feature-plugins/sidebar/mcp.tsx +103 -0
- package/src/feature-plugins/sidebar/todo.tsx +58 -0
- package/src/feature-plugins/system/diff-viewer-file-menu.tsx +87 -0
- package/src/feature-plugins/system/diff-viewer-file-tree-utils.ts +174 -0
- package/src/feature-plugins/system/diff-viewer-file-tree.tsx +274 -0
- package/src/feature-plugins/system/diff-viewer-image.tsx +96 -0
- package/src/feature-plugins/system/diff-viewer.tsx +1380 -0
- package/src/feature-plugins/system/notifications.ts +102 -0
- package/src/feature-plugins/system/plugins.tsx +356 -0
- package/src/feature-plugins/system/stats-data.ts +18 -0
- package/src/feature-plugins/system/stats.tsx +217 -0
- package/src/feature-plugins/system/storybook/footer.tsx +51 -0
- package/src/feature-plugins/system/storybook/highlights.tsx +71 -0
- package/src/feature-plugins/system/storybook/index.tsx +153 -0
- package/src/feature-plugins/system/storybook/link-clicks.tsx +125 -0
- package/src/feature-plugins/system/storybook/merman-layouts.tsx +200 -0
- package/src/feature-plugins/system/storybook/one-cell-spinner.fixtures.ts +144 -0
- package/src/feature-plugins/system/storybook/one-cell-spinner.tsx +293 -0
- package/src/feature-plugins/system/storybook/session-location-missing.tsx +80 -0
- package/src/feature-plugins/system/storybook/session-tabs.tsx +571 -0
- package/src/feature-plugins/system/storybook/subcell-spinner.fixtures.ts +115 -0
- package/src/feature-plugins/system/storybook/todo.tsx +166 -0
- package/src/index.tsx +2 -0
- package/src/logo.ts +21 -0
- package/src/mini/catalog.shared.ts +116 -0
- package/src/mini/demo.ts +1086 -0
- package/src/mini/entry.body.ts +244 -0
- package/src/mini/footer.command.tsx +1205 -0
- package/src/mini/footer.form.tsx +647 -0
- package/src/mini/footer.menu.tsx +313 -0
- package/src/mini/footer.permission.tsx +562 -0
- package/src/mini/footer.prompt.tsx +1533 -0
- package/src/mini/footer.subagent.tsx +268 -0
- package/src/mini/footer.ts +1193 -0
- package/src/mini/footer.view.tsx +1022 -0
- package/src/mini/footer.width.ts +118 -0
- package/src/mini/form.shared.ts +241 -0
- package/src/mini/index.ts +7 -0
- package/src/mini/mono.ts +277 -0
- package/src/mini/permission.shared.ts +199 -0
- package/src/mini/prompt.editor.ts +74 -0
- package/src/mini/prompt.shared.ts +192 -0
- package/src/mini/runtime.boot.ts +98 -0
- package/src/mini/runtime.lifecycle.ts +393 -0
- package/src/mini/runtime.queue.ts +320 -0
- package/src/mini/runtime.ts +1117 -0
- package/src/mini/scrollback.shared.ts +82 -0
- package/src/mini/scrollback.surface.ts +548 -0
- package/src/mini/scrollback.writer.tsx +380 -0
- package/src/mini/session-data.ts +13 -0
- package/src/mini/session.shared.ts +113 -0
- package/src/mini/splash.ts +307 -0
- package/src/mini/stream-v2.fragment.ts +83 -0
- package/src/mini/stream-v2.image.ts +38 -0
- package/src/mini/stream-v2.subagent.ts +1130 -0
- package/src/mini/stream-v2.transport.ts +1916 -0
- package/src/mini/stream.ts +152 -0
- package/src/mini/theme.ts +328 -0
- package/src/mini/tool.public.ts +3 -0
- package/src/mini/tool.ts +1394 -0
- package/src/mini/turn-summary.ts +21 -0
- package/src/mini/types.ts +482 -0
- package/src/mini/variant.shared.ts +58 -0
- package/src/mini/verbosity.ts +84 -0
- package/src/model-preference.ts +206 -0
- package/src/parsers-config.ts +386 -0
- package/src/plugin/api.tsx +486 -0
- package/src/plugin/builtins.ts +35 -0
- package/src/plugin/context.tsx +757 -0
- package/src/plugin/discovery.ts +67 -0
- package/src/plugin/markdown.ts +18 -0
- package/src/plugin/render.tsx +116 -0
- package/src/plugin/runtime-plugin-support.bun.ts +11 -0
- package/src/plugin/runtime-plugin-support.node.ts +1 -0
- package/src/plugin/source.ts +1 -0
- package/src/plugin/structure.ts +159 -0
- package/src/plugin/watch.ts +113 -0
- package/src/prompt/attachment.ts +97 -0
- package/src/prompt/codec.ts +61 -0
- package/src/prompt/content.ts +22 -0
- package/src/prompt/directory-completion.ts +97 -0
- package/src/prompt/directory-recents.ts +36 -0
- package/src/prompt/display.ts +41 -0
- package/src/prompt/frecency.tsx +80 -0
- package/src/prompt/history.tsx +175 -0
- package/src/prompt/mention.ts +173 -0
- package/src/prompt/parse.ts +25 -0
- package/src/prompt/part.ts +35 -0
- package/src/prompt/restore.ts +39 -0
- package/src/prompt/stash.tsx +93 -0
- package/src/prompt/traits.ts +29 -0
- package/src/routes/home.tsx +180 -0
- package/src/routes/session/activity-summary.ts +101 -0
- package/src/routes/session/anchor-view.tsx +53 -0
- package/src/routes/session/anchors.ts +85 -0
- package/src/routes/session/composer/context.ts +24 -0
- package/src/routes/session/composer/index.tsx +143 -0
- package/src/routes/session/composer/scripts-tab.tsx +166 -0
- package/src/routes/session/composer/shell-tab.tsx +149 -0
- package/src/routes/session/composer/subagents-tab.tsx +264 -0
- package/src/routes/session/composer/tabs.ts +91 -0
- package/src/routes/session/composer/terminals-tab.tsx +114 -0
- package/src/routes/session/dialog-execute.tsx +276 -0
- package/src/routes/session/dialog-fork.tsx +87 -0
- package/src/routes/session/dialog-message.tsx +89 -0
- package/src/routes/session/dialog-timeline.tsx +43 -0
- package/src/routes/session/form.tsx +1177 -0
- package/src/routes/session/group-view.tsx +407 -0
- package/src/routes/session/grouping/session.ts +184 -0
- package/src/routes/session/grouping/tree.ts +111 -0
- package/src/routes/session/history.ts +59 -0
- package/src/routes/session/index.tsx +3922 -0
- package/src/routes/session/location-missing.tsx +81 -0
- package/src/routes/session/message-navigation.ts +48 -0
- package/src/routes/session/message-parts.tsx +322 -0
- package/src/routes/session/mount-budget.ts +38 -0
- package/src/routes/session/permission.tsx +622 -0
- package/src/routes/session/render-context.tsx +44 -0
- package/src/routes/session/rows.ts +493 -0
- package/src/routes/session/sidebar.tsx +80 -0
- package/src/routes/session/thinking-syntax.ts +8 -0
- package/src/runtime.tsx +1 -0
- package/src/simulation/semantics.ts +12 -0
- package/src/theme/assets/aura.json +69 -0
- package/src/theme/assets/ayu.json +80 -0
- package/src/theme/assets/carbonfox.json +248 -0
- package/src/theme/assets/catppuccin-frappe.json +230 -0
- package/src/theme/assets/catppuccin-macchiato.json +230 -0
- package/src/theme/assets/catppuccin.json +112 -0
- package/src/theme/assets/cobalt2.json +225 -0
- package/src/theme/assets/cursor.json +249 -0
- package/src/theme/assets/dracula.json +219 -0
- package/src/theme/assets/everforest.json +241 -0
- package/src/theme/assets/flexoki.json +237 -0
- package/src/theme/assets/github.json +233 -0
- package/src/theme/assets/gruvbox.json +242 -0
- package/src/theme/assets/kanagawa.json +77 -0
- package/src/theme/assets/lucent-orng.json +234 -0
- package/src/theme/assets/material.json +235 -0
- package/src/theme/assets/matrix.json +77 -0
- package/src/theme/assets/mercury.json +252 -0
- package/src/theme/assets/monokai.json +221 -0
- package/src/theme/assets/nightowl.json +221 -0
- package/src/theme/assets/nord.json +223 -0
- package/src/theme/assets/one-dark.json +84 -0
- package/src/theme/assets/opencode.json +245 -0
- package/src/theme/assets/orng.json +249 -0
- package/src/theme/assets/osaka-jade.json +93 -0
- package/src/theme/assets/palenight.json +222 -0
- package/src/theme/assets/rosepine.json +234 -0
- package/src/theme/assets/solarized.json +223 -0
- package/src/theme/assets/synthwave84.json +226 -0
- package/src/theme/assets/tokyonight.json +243 -0
- package/src/theme/assets/v2/opencode-classic.json +387 -0
- package/src/theme/assets/v2/opencode.json +395 -0
- package/src/theme/assets/vercel.json +245 -0
- package/src/theme/assets/vesper.json +218 -0
- package/src/theme/assets/zenburn.json +223 -0
- package/src/theme/color.ts +48 -0
- package/src/theme/component.ts +51 -0
- package/src/theme/discovery.ts +21 -0
- package/src/theme/index.ts +109 -0
- package/src/theme/resolve.ts +53 -0
- package/src/theme/system.ts +144 -0
- package/src/theme/v1.ts +70 -0
- package/src/ui/animation.ts +235 -0
- package/src/ui/border.ts +21 -0
- package/src/ui/dialog-alert.tsx +51 -0
- package/src/ui/dialog-confirm.tsx +62 -0
- package/src/ui/dialog-export-options.tsx +316 -0
- package/src/ui/dialog-export-result.tsx +84 -0
- package/src/ui/dialog-help.tsx +40 -0
- package/src/ui/dialog-prompt.tsx +180 -0
- package/src/ui/dialog-select.tsx +1006 -0
- package/src/ui/dialog.tsx +560 -0
- package/src/ui/file-path.tsx +112 -0
- package/src/ui/layout.ts +26 -0
- package/src/ui/link.tsx +51 -0
- package/src/ui/one-cell-motion.ts +111 -0
- package/src/ui/pane-resize-handle.tsx +33 -0
- package/src/ui/pane-resize.ts +76 -0
- package/src/ui/select-controller.ts +45 -0
- package/src/ui/session-link.ts +92 -0
- package/src/ui/spinner.ts +368 -0
- package/src/ui/subcell.ts +37 -0
- package/src/ui/toast.tsx +222 -0
- package/src/ui/working-directory-actions.tsx +66 -0
- package/src/util/collapse-tool-output.ts +95 -0
- package/src/util/config-directories.ts +53 -0
- package/src/util/connected-provider.ts +15 -0
- package/src/util/delayed-presence.ts +34 -0
- package/src/util/diff.ts +84 -0
- package/src/util/error-details.ts +21 -0
- package/src/util/error.ts +141 -0
- package/src/util/filetype.ts +135 -0
- package/src/util/form.ts +146 -0
- package/src/util/highlights.ts +51 -0
- package/src/util/locale.ts +81 -0
- package/src/util/marquee.ts +51 -0
- package/src/util/media.ts +43 -0
- package/src/util/model.ts +33 -0
- package/src/util/path-format.ts +37 -0
- package/src/util/path.ts +12 -0
- package/src/util/permission.ts +188 -0
- package/src/util/persistence.ts +42 -0
- package/src/util/presentation.ts +42 -0
- package/src/util/project.ts +7 -0
- package/src/util/record.ts +3 -0
- package/src/util/renderer.ts +15 -0
- package/src/util/scroll.ts +29 -0
- package/src/util/selection.ts +103 -0
- package/src/util/session.ts +103 -0
- package/src/util/signal.ts +49 -0
- package/src/util/single-flight.ts +12 -0
- package/src/util/string-width.bun.ts +1 -0
- package/src/util/string-width.node.ts +26 -0
- package/src/util/string-width.ts +1 -0
- package/src/util/system.ts +23 -0
- package/src/util/todo.ts +43 -0
- package/src/util/tool-display.ts +70 -0
- package/src/util/usage-limits.ts +152 -0
- package/src/util/watch.ts +24 -0
- package/test/app-lifecycle.test.tsx +2962 -0
- package/test/clear-session.test.tsx +67 -0
- package/test/cli/cmd/tui/integration-options.test.ts +98 -0
- package/test/cli/cmd/tui/model-options.test.ts +105 -0
- package/test/cli/cmd/tui/notifications.test.ts +356 -0
- package/test/cli/tui/__snapshots__/inline-tool-wrap-snapshot.test.tsx.snap +22 -0
- package/test/cli/tui/anchors.test.ts +77 -0
- package/test/cli/tui/collapse-tool-output.test.ts +14 -0
- package/test/cli/tui/command-palette.test.tsx +86 -0
- package/test/cli/tui/composer-keymap.test.tsx +346 -0
- package/test/cli/tui/data.test.tsx +3669 -0
- package/test/cli/tui/dialog-integration.test.tsx +588 -0
- package/test/cli/tui/dialog-mcp.test.tsx +197 -0
- package/test/cli/tui/dialog-open.test.tsx +1037 -0
- package/test/cli/tui/dialog-prompt.test.tsx +253 -0
- package/test/cli/tui/dialog-select.test.tsx +740 -0
- package/test/cli/tui/dialog-session-list.test.tsx +130 -0
- package/test/cli/tui/diff-viewer-file-tree.test.tsx +256 -0
- package/test/cli/tui/diff-viewer-image.test.tsx +172 -0
- package/test/cli/tui/diff-viewer.test.tsx +2510 -0
- package/test/cli/tui/form.test.tsx +950 -0
- package/test/cli/tui/group-boundary.test.ts +63 -0
- package/test/cli/tui/group-view.test.tsx +352 -0
- package/test/cli/tui/grouping-tree.test.ts +82 -0
- package/test/cli/tui/inline-tool-wrap-snapshot.test.tsx +248 -0
- package/test/cli/tui/input-scope.test.tsx +282 -0
- package/test/cli/tui/keymap-arguments.test.tsx +45 -0
- package/test/cli/tui/message-navigation.test.ts +164 -0
- package/test/cli/tui/mount-budget.test.ts +74 -0
- package/test/cli/tui/permission.test.ts +7 -0
- package/test/cli/tui/plugins-dialog.test.tsx +217 -0
- package/test/cli/tui/prompt-interrupt-status.test.tsx +25 -0
- package/test/cli/tui/prompt-move.test.tsx +446 -0
- package/test/cli/tui/reasoning-body.test.tsx +80 -0
- package/test/cli/tui/script-changes.test.ts +41 -0
- package/test/cli/tui/session-grouping.test.ts +21 -0
- package/test/cli/tui/session-history.test.ts +124 -0
- package/test/cli/tui/session-rows.test.ts +616 -0
- package/test/cli/tui/session-verbosity.test.ts +307 -0
- package/test/cli/tui/theme-mode.test.tsx +179 -0
- package/test/cli/tui/thinking.test.ts +36 -0
- package/test/cli/tui/toast.test.tsx +117 -0
- package/test/cli/tui/use-event.test.tsx +295 -0
- package/test/client-mcp.test.tsx +226 -0
- package/test/clipboard.test.ts +148 -0
- package/test/command-selection.test.tsx +123 -0
- package/test/compact-admission.test.tsx +251 -0
- package/test/completion-notices.test.tsx +197 -0
- package/test/component/animation-ticks.test.tsx +212 -0
- package/test/component/dialog-error-details.test.tsx +110 -0
- package/test/component/dialog-export-options.test.tsx +68 -0
- package/test/component/dialog-highlights.test.tsx +73 -0
- package/test/component/dialog-model.test.tsx +145 -0
- package/test/component/dialog-shell-output.test.tsx +255 -0
- package/test/component/dialog-speed.test.tsx +114 -0
- package/test/component/dialog-update.test.tsx +111 -0
- package/test/component/dialog-variant.test.tsx +24 -0
- package/test/component/go-upsell-art.test.tsx +110 -0
- package/test/component/retry-provider.test.tsx +288 -0
- package/test/component/session-tabs-marquee.test.tsx +100 -0
- package/test/component/session-tabs-mouse.test.tsx +216 -0
- package/test/component/session-tabs-rail.test.tsx +120 -0
- package/test/component/session-tabs-status.test.tsx +345 -0
- package/test/component/shimmer-text.test.tsx +37 -0
- package/test/component/spinner-renderable.test.tsx +133 -0
- package/test/component/tab-pulse.test.tsx +196 -0
- package/test/component/terminal-pane-theme.test.ts +68 -0
- package/test/config-v2.test.tsx +335 -0
- package/test/config.test.tsx +184 -0
- package/test/context/local-selection.test.tsx +204 -0
- package/test/context/local.test.ts +15 -0
- package/test/context/program-status.test.ts +73 -0
- package/test/context/session-retention.test.ts +234 -0
- package/test/context/session-tabs-model.test.ts +341 -0
- package/test/context/session-tabs.test.tsx +864 -0
- package/test/context/storage.test.ts +37 -0
- package/test/context/theme.test.tsx +183 -0
- package/test/copy-session-id.test.tsx +79 -0
- package/test/editor.test.ts +69 -0
- package/test/feature-plugins/diff-viewer-file-tree-utils.test.ts +234 -0
- package/test/feature-plugins/goal.test.tsx +126 -0
- package/test/feature-plugins/home-footer.test.ts +13 -0
- package/test/feature-plugins/prompt-footer.test.tsx +303 -0
- package/test/feature-plugins/sidebar-context.test.tsx +70 -0
- package/test/feature-plugins/sidebar-footer.test.tsx +139 -0
- package/test/fixture/animation-ticks.ts +19 -0
- package/test/fixture/app.ts +95 -0
- package/test/fixture/diff-image.ts +7 -0
- package/test/fixture/fixture.ts +27 -0
- package/test/fixture/frame.ts +25 -0
- package/test/fixture/local.tsx +158 -0
- package/test/fixture/plugin/client-reads/tui.tsx +9 -0
- package/test/fixture/plugin/dialog-throw/tui.tsx +11 -0
- package/test/fixture/plugin/native-resources/tui.tsx +26 -0
- package/test/fixture/plugin/setup-keymap/tui.tsx +72 -0
- package/test/fixture/plugin/slot-string/tui.tsx +10 -0
- package/test/fixture/tui-client.ts +186 -0
- package/test/fixture/tui-environment.tsx +47 -0
- package/test/fixture/tui-runtime.ts +21 -0
- package/test/highlights.test.ts +43 -0
- package/test/interactivity.test.tsx +46 -0
- package/test/keybind.test.ts +7 -0
- package/test/keymap-scope.test.tsx +271 -0
- package/test/keymap.test.tsx +244 -0
- package/test/markdown-streaming.test.tsx +49 -0
- package/test/mini/blocker.responsive.test.tsx +732 -0
- package/test/mini/catalog.shared.test.ts +76 -0
- package/test/mini/entry.body.test.ts +622 -0
- package/test/mini/fixture/catalog.ts +63 -0
- package/test/mini/fixture/footer-api.ts +69 -0
- package/test/mini/fixture/tool-part.ts +20 -0
- package/test/mini/footer-keymap.test.tsx +141 -0
- package/test/mini/footer.menu.test.ts +43 -0
- package/test/mini/footer.responsive.test.tsx +438 -0
- package/test/mini/footer.test.ts +446 -0
- package/test/mini/footer.view.test.tsx +2627 -0
- package/test/mini/footer.width.test.ts +120 -0
- package/test/mini/form.shared.test.ts +66 -0
- package/test/mini/permission.shared.test.ts +195 -0
- package/test/mini/prompt.editor.test.ts +118 -0
- package/test/mini/prompt.shared.test.ts +104 -0
- package/test/mini/runtime.boot.test.ts +118 -0
- package/test/mini/runtime.queue.test.ts +443 -0
- package/test/mini/runtime.test.ts +591 -0
- package/test/mini/scrollback.image.test.ts +213 -0
- package/test/mini/scrollback.surface.test.ts +1078 -0
- package/test/mini/session.shared.test.ts +267 -0
- package/test/mini/splash.test.ts +196 -0
- package/test/mini/stream-v2.transport.test.ts +4705 -0
- package/test/mini/stream.test.ts +52 -0
- package/test/mini/theme.test.ts +438 -0
- package/test/mini/tool.test.ts +134 -0
- package/test/mini/variant.shared.test.ts +58 -0
- package/test/mini/verbosity.test.ts +53 -0
- package/test/model-preference.test.ts +70 -0
- package/test/new-session-id.test.tsx +102 -0
- package/test/new-session-location.test.ts +30 -0
- package/test/panel.test.ts +71 -0
- package/test/plugin-discovery.test.ts +18 -0
- package/test/plugin-keymap.test.tsx +143 -0
- package/test/plugin-markdown.test.tsx +120 -0
- package/test/plugin-model.test.tsx +46 -0
- package/test/plugin-native-resources.test.tsx +11 -0
- package/test/plugin-select.test.tsx +391 -0
- package/test/plugin-slot-output.test.tsx +23 -0
- package/test/plugin-source.test.ts +871 -0
- package/test/plugin-toast.test.tsx +62 -0
- package/test/preload.ts +17 -0
- package/test/prompt/attachment.test.ts +138 -0
- package/test/prompt/autocomplete.test.ts +218 -0
- package/test/prompt/codec.test.ts +136 -0
- package/test/prompt/display.test.ts +72 -0
- package/test/prompt/draft-stash.test.ts +42 -0
- package/test/prompt/history-composer.test.tsx +52 -0
- package/test/prompt/history-provider.test.tsx +108 -0
- package/test/prompt/history.test.ts +94 -0
- package/test/prompt/jsonl.test.ts +24 -0
- package/test/prompt/local-attachment.test.ts +244 -0
- package/test/prompt/mention.test.ts +119 -0
- package/test/prompt/parse.test.ts +46 -0
- package/test/prompt/part.test.ts +40 -0
- package/test/prompt/persistence.test.ts +23 -0
- package/test/prompt/traits.test.ts +25 -0
- package/test/prompt-cursor.test.tsx +27 -0
- package/test/prompt-offset.test.tsx +58 -0
- package/test/prompt-paste.test.tsx +127 -0
- package/test/prompt-shell-failure.test.tsx +76 -0
- package/test/routes/composer-tabs.test.tsx +97 -0
- package/test/runtime.test.tsx +37 -0
- package/test/session-activity-anchor.test.tsx +180 -0
- package/test/session-backfill-disclosure.test.tsx +89 -0
- package/test/session-dialog-resync.test.tsx +122 -0
- package/test/session-fork-pending.test.tsx +60 -0
- package/test/session-group-navigation.test.tsx +252 -0
- package/test/session-history-interactions.test.tsx +305 -0
- package/test/session-history-reveal.test.tsx +108 -0
- package/test/session-home.test.tsx +401 -0
- package/test/session-interrupt-undo.test.tsx +98 -0
- package/test/session-media-refs.test.tsx +360 -0
- package/test/session-mount-budget.test.tsx +137 -0
- package/test/session-panel.test.tsx +721 -0
- package/test/session-shell-output.test.tsx +114 -0
- package/test/session-shell-stopped.test.tsx +107 -0
- package/test/session-subagent-navigation.test.tsx +44 -0
- package/test/session-submit-scroll.test.tsx +85 -0
- package/test/session-terminal-availability.test.tsx +80 -0
- package/test/session-wheel-focus.test.tsx +176 -0
- package/test/simulation/semantics.test.ts +23 -0
- package/test/stats.test.ts +33 -0
- package/test/stats.view.test.tsx +94 -0
- package/test/theme/v2/component.test.ts +87 -0
- package/test/theme/v2/resolve.test.ts +424 -0
- package/test/theme/v2/select.test.ts +25 -0
- package/test/theme/v2/types.typecheck.ts +57 -0
- package/test/theme/v2/v1-migrate.test.ts +397 -0
- package/test/theme.test.ts +150 -0
- package/test/ui/dialog-layout.test.tsx +56 -0
- package/test/ui/file-path.test.ts +61 -0
- package/test/ui/layout.test.ts +31 -0
- package/test/ui/link.test.tsx +60 -0
- package/test/ui/pane-resize-handle.test.tsx +134 -0
- package/test/ui/pane-resize.test.ts +258 -0
- package/test/ui/select-controller.test.ts +44 -0
- package/test/ui/session-link.test.tsx +325 -0
- package/test/usage-limits.test.tsx +162 -0
- package/test/util/added-patch.test.ts +44 -0
- package/test/util/connected-provider.test.ts +59 -0
- package/test/util/delayed-presence.test.ts +114 -0
- package/test/util/error-details.test.ts +26 -0
- package/test/util/error.test.ts +36 -0
- package/test/util/filetype.test.ts +23 -0
- package/test/util/form.test.ts +110 -0
- package/test/util/locale.test.ts +32 -0
- package/test/util/marquee.test.ts +45 -0
- package/test/util/media.test.ts +54 -0
- package/test/util/model.test.ts +70 -0
- package/test/util/path-format.test.ts +15 -0
- package/test/util/permission.test.ts +23 -0
- package/test/util/presentation.test.ts +30 -0
- package/test/util/renderer.test.ts +42 -0
- package/test/util/selection-copy-on-select.test.tsx +64 -0
- package/test/util/selection-keys.test.ts +172 -0
- package/test/util/selection.test.ts +115 -0
- package/test/util/session.test.ts +70 -0
- package/test/util/tool-display.test.ts +65 -0
- package/test/util/usage-limits.test.ts +154 -0
- package/tsconfig.json +13 -0
- package/README.md +0 -3
|
@@ -0,0 +1,2627 @@
|
|
|
1
|
+
/** @jsxImportSource @opentui/solid */
|
|
2
|
+
import { afterAll, expect, test } from "bun:test"
|
|
3
|
+
import {
|
|
4
|
+
BoxRenderable,
|
|
5
|
+
ImageRenderable,
|
|
6
|
+
RGBA,
|
|
7
|
+
TextareaRenderable,
|
|
8
|
+
type CliRenderer,
|
|
9
|
+
type RootRenderable,
|
|
10
|
+
} from "@opentui/core"
|
|
11
|
+
import { createTestRenderer } from "@opentui/core/testing"
|
|
12
|
+
import { testRender } from "@opentui/solid"
|
|
13
|
+
import { createSignal } from "solid-js"
|
|
14
|
+
import type { FormInfo } from "@zyro-sec/client/promise"
|
|
15
|
+
import { Keymap } from "../../src/context/keymap"
|
|
16
|
+
import type { ClipboardContent, ClipboardService } from "../../src/context/clipboard"
|
|
17
|
+
import {
|
|
18
|
+
RUN_COMMAND_PANEL_ROWS,
|
|
19
|
+
RUN_SUBAGENT_PANEL_ROWS,
|
|
20
|
+
RunAgentSelectBody,
|
|
21
|
+
RunCommandMenuBody,
|
|
22
|
+
RunModelSelectBody,
|
|
23
|
+
RunSettingsBody,
|
|
24
|
+
RunSubagentSelectBody,
|
|
25
|
+
RunVariantSelectBody,
|
|
26
|
+
} from "../../src/mini/footer.command"
|
|
27
|
+
import { RunFooterView } from "../../src/mini/footer.view"
|
|
28
|
+
import { RunFooter } from "../../src/mini/footer"
|
|
29
|
+
import { RunEntryContent } from "../../src/mini/scrollback.writer"
|
|
30
|
+
import { RUN_THEME_FALLBACK, RUN_THEME_FALLBACK_LIGHT, resolveRunTheme, type RunTheme } from "../../src/mini/theme"
|
|
31
|
+
import { BLOCK_SOFT_SLIDE, SEED_MONO, WORK_SPINNERS } from "../../src/ui/one-cell-motion"
|
|
32
|
+
import { resolveMiniSettings } from "../../src/mini/runtime.boot"
|
|
33
|
+
import { applyMiniSettingChange } from "../../src/mini/verbosity"
|
|
34
|
+
import type {
|
|
35
|
+
FooterQueuedPrompt,
|
|
36
|
+
FooterState,
|
|
37
|
+
FooterSubagentState,
|
|
38
|
+
FooterSubagentTab,
|
|
39
|
+
FooterView,
|
|
40
|
+
MiniSettingChange,
|
|
41
|
+
MiniSettings,
|
|
42
|
+
QueuedPromptAction,
|
|
43
|
+
RunAgent,
|
|
44
|
+
RunCommand,
|
|
45
|
+
RunInput,
|
|
46
|
+
RunPrompt,
|
|
47
|
+
RunPromptPart,
|
|
48
|
+
RunProvider,
|
|
49
|
+
RunTuiConfig,
|
|
50
|
+
StreamCommit,
|
|
51
|
+
} from "../../src/mini/types"
|
|
52
|
+
import { selectedCommand } from "../../src/mini/footer.prompt"
|
|
53
|
+
import { RejectField } from "../../src/mini/footer.permission"
|
|
54
|
+
import { createTuiResolvedConfig } from "../fixture/tui-runtime"
|
|
55
|
+
import { tmpdir } from "../fixture/fixture"
|
|
56
|
+
import { diffImageFixture } from "../fixture/diff-image"
|
|
57
|
+
|
|
58
|
+
const tuiConfig = createTuiResolvedConfig()
|
|
59
|
+
const themeRenderer = await createTestRenderer({})
|
|
60
|
+
afterAll(async () => {
|
|
61
|
+
themeRenderer.renderer.destroy()
|
|
62
|
+
await themeRenderer.renderer.closed
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
async function nativeLightTheme() {
|
|
66
|
+
await using tmp = await tmpdir()
|
|
67
|
+
await Bun.write(`${tmp.path}/themes/mini-native-light.json`, JSON.stringify({ light: {} }))
|
|
68
|
+
const previous = process.env.OPENCODE_CONFIG_DIR
|
|
69
|
+
process.env.OPENCODE_CONFIG_DIR = tmp.path
|
|
70
|
+
try {
|
|
71
|
+
return await resolveRunTheme(
|
|
72
|
+
{
|
|
73
|
+
nativeScene: themeRenderer.renderer.nativeScene,
|
|
74
|
+
themeMode: "light",
|
|
75
|
+
getPalette: async (): ReturnType<CliRenderer["getPalette"]> => {
|
|
76
|
+
throw new Error("Palette unavailable")
|
|
77
|
+
},
|
|
78
|
+
} as CliRenderer,
|
|
79
|
+
{ name: "mini-native-light" },
|
|
80
|
+
)
|
|
81
|
+
} finally {
|
|
82
|
+
if (previous === undefined) delete process.env.OPENCODE_CONFIG_DIR
|
|
83
|
+
else process.env.OPENCODE_CONFIG_DIR = previous
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function command(input: { name: string; description: string; source?: "command" | "mcp" | "skill" }) {
|
|
88
|
+
return {
|
|
89
|
+
name: input.name,
|
|
90
|
+
description: input.description,
|
|
91
|
+
source: input.source,
|
|
92
|
+
} satisfies RunCommand
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function model(input: {
|
|
96
|
+
id: string
|
|
97
|
+
name: string
|
|
98
|
+
status?: "active" | "deprecated"
|
|
99
|
+
cost?: number
|
|
100
|
+
variants?: Record<string, Record<string, never>>
|
|
101
|
+
}) {
|
|
102
|
+
return {
|
|
103
|
+
name: input.name,
|
|
104
|
+
cost: {
|
|
105
|
+
input: input.cost ?? 1,
|
|
106
|
+
},
|
|
107
|
+
status: input.status ?? "active",
|
|
108
|
+
variants: input.variants,
|
|
109
|
+
} satisfies RunProvider["models"][string]
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function provider() {
|
|
113
|
+
return {
|
|
114
|
+
id: "opencode",
|
|
115
|
+
name: "opencode",
|
|
116
|
+
models: {
|
|
117
|
+
"gpt-5": model({ id: "gpt-5", name: "GPT-5", variants: { high: {}, minimal: {} } }),
|
|
118
|
+
"gpt-free": model({ id: "gpt-free", name: "GPT Free", cost: 0 }),
|
|
119
|
+
old: model({ id: "old", name: "Old Model", status: "deprecated" }),
|
|
120
|
+
},
|
|
121
|
+
} satisfies RunProvider
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function subagent(input: {
|
|
125
|
+
sessionID: string
|
|
126
|
+
label: string
|
|
127
|
+
description: string
|
|
128
|
+
status?: FooterSubagentTab["status"]
|
|
129
|
+
}) {
|
|
130
|
+
return {
|
|
131
|
+
sessionID: input.sessionID,
|
|
132
|
+
label: input.label,
|
|
133
|
+
description: input.description,
|
|
134
|
+
status: input.status ?? "running",
|
|
135
|
+
} satisfies FooterSubagentTab
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function footerState(input: Partial<FooterState> = {}) {
|
|
139
|
+
return createSignal<FooterState>({
|
|
140
|
+
phase: "idle",
|
|
141
|
+
status: "",
|
|
142
|
+
notice: "",
|
|
143
|
+
model: "gpt-5",
|
|
144
|
+
usage: undefined,
|
|
145
|
+
first: false,
|
|
146
|
+
interrupt: 0,
|
|
147
|
+
exit: 0,
|
|
148
|
+
...input,
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async function renderFooter(
|
|
153
|
+
input: {
|
|
154
|
+
tuiConfig?: RunTuiConfig
|
|
155
|
+
commands?: RunCommand[]
|
|
156
|
+
theme?: () => RunTheme
|
|
157
|
+
providers?: RunProvider[]
|
|
158
|
+
agents?: RunAgent[]
|
|
159
|
+
currentAgent?: string
|
|
160
|
+
currentModel?: RunInput["model"]
|
|
161
|
+
currentVariant?: string
|
|
162
|
+
subagents?: FooterSubagentState
|
|
163
|
+
width?: number
|
|
164
|
+
height?: number
|
|
165
|
+
state?: Partial<FooterState>
|
|
166
|
+
onCycle?: () => void
|
|
167
|
+
onSubmit?: (prompt: RunPrompt) => boolean | Promise<boolean>
|
|
168
|
+
clipboard?: Pick<ClipboardService, "read">
|
|
169
|
+
history?: RunPrompt[]
|
|
170
|
+
view?: FooterView
|
|
171
|
+
onFormReply?: (input: unknown) => void
|
|
172
|
+
miniSettings?: MiniSettings
|
|
173
|
+
mono?: boolean
|
|
174
|
+
onStatus?: (status: string) => void
|
|
175
|
+
onMiniSettingChange?: (change: MiniSettingChange) => void
|
|
176
|
+
queuedPrompts?: FooterQueuedPrompt[]
|
|
177
|
+
onQueuedPromptAction?: (action: QueuedPromptAction, inboxID: string) => Promise<void>
|
|
178
|
+
} = {},
|
|
179
|
+
) {
|
|
180
|
+
const [view, setView] = createSignal<FooterView>(input.view ?? { type: "prompt" })
|
|
181
|
+
const [subagents] = createSignal<FooterSubagentState>(
|
|
182
|
+
input.subagents ?? { tabs: [], details: {}, permissions: [], forms: [] },
|
|
183
|
+
)
|
|
184
|
+
const [state, setState] = footerState(input.state)
|
|
185
|
+
const [queuedPrompts, setQueuedPrompts] = createSignal(input.queuedPrompts ?? [])
|
|
186
|
+
const config = { ...(input.tuiConfig ?? tuiConfig), animations: input.tuiConfig?.animations ?? false }
|
|
187
|
+
const [miniSettings, setMiniSettings] = createSignal<MiniSettings>(input.miniSettings ?? resolveMiniSettings())
|
|
188
|
+
function Harness() {
|
|
189
|
+
return (
|
|
190
|
+
<Keymap.Provider config={config}>
|
|
191
|
+
<RunFooterView
|
|
192
|
+
directory={() => "/tmp"}
|
|
193
|
+
findFiles={async () => []}
|
|
194
|
+
agents={() => input.agents ?? []}
|
|
195
|
+
references={() => []}
|
|
196
|
+
commands={() => input.commands ?? []}
|
|
197
|
+
providers={() => input.providers}
|
|
198
|
+
currentAgent={() => input.currentAgent ?? "Build"}
|
|
199
|
+
currentAgentID={() => input.currentAgent?.toLowerCase() ?? "build"}
|
|
200
|
+
currentModel={() => input.currentModel}
|
|
201
|
+
variants={() => []}
|
|
202
|
+
currentVariant={() => input.currentVariant}
|
|
203
|
+
state={state}
|
|
204
|
+
view={view}
|
|
205
|
+
subagent={subagents}
|
|
206
|
+
queuedPrompts={queuedPrompts}
|
|
207
|
+
theme={input.theme ?? (() => RUN_THEME_FALLBACK)}
|
|
208
|
+
tuiConfig={config}
|
|
209
|
+
mono={input.mono ?? false}
|
|
210
|
+
miniSettings={miniSettings}
|
|
211
|
+
onSubmit={input.onSubmit ?? (() => true)}
|
|
212
|
+
clipboard={input.clipboard}
|
|
213
|
+
history={() => input.history ?? []}
|
|
214
|
+
onPermissionReply={() => {}}
|
|
215
|
+
onFormReply={(value) => input.onFormReply?.(value)}
|
|
216
|
+
onFormCancel={() => {}}
|
|
217
|
+
onCycle={input.onCycle ?? (() => {})}
|
|
218
|
+
onInterrupt={() => false}
|
|
219
|
+
onQueuedPromptAction={input.onQueuedPromptAction}
|
|
220
|
+
onEditorOpen={async () => undefined}
|
|
221
|
+
onInputClear={() => {}}
|
|
222
|
+
onExit={() => {}}
|
|
223
|
+
onAgentSelect={() => {}}
|
|
224
|
+
onModelSelect={() => {}}
|
|
225
|
+
onVariantSelect={() => {}}
|
|
226
|
+
onRows={() => {}}
|
|
227
|
+
onLayout={() => {}}
|
|
228
|
+
onStatus={(status) => input.onStatus?.(status)}
|
|
229
|
+
onMiniSettingChange={(change) => input.onMiniSettingChange?.(change)}
|
|
230
|
+
/>
|
|
231
|
+
</Keymap.Provider>
|
|
232
|
+
)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const app = await testRender(
|
|
236
|
+
() => (
|
|
237
|
+
<box width={input.width ?? 100} height={input.height ?? 8}>
|
|
238
|
+
<Harness />
|
|
239
|
+
</box>
|
|
240
|
+
),
|
|
241
|
+
{ width: input.width ?? 100, height: input.height ?? 8, kittyKeyboard: true, exitOnCtrlC: false },
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
return {
|
|
245
|
+
...app,
|
|
246
|
+
setView,
|
|
247
|
+
setState,
|
|
248
|
+
setMiniSettings,
|
|
249
|
+
setQueuedPrompts,
|
|
250
|
+
cleanup() {
|
|
251
|
+
app.renderer.currentFocusedRenderable?.blur()
|
|
252
|
+
app.renderer.currentFocusedEditor?.blur()
|
|
253
|
+
app.renderer.destroy()
|
|
254
|
+
},
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// OpenTUI image teardown crashes Bun 1.3.14's Windows test runner after the assertions pass.
|
|
259
|
+
// Keep the native preview coverage on Linux while the attachment behavior remains covered on both platforms below.
|
|
260
|
+
test.skipIf(process.platform === "win32").each([
|
|
261
|
+
{ width: 80, height: 24, mono: false, preview: true },
|
|
262
|
+
{ width: 24, height: 8, mono: false, preview: true },
|
|
263
|
+
{ width: 80, height: 24, mono: true, preview: true },
|
|
264
|
+
{ width: 80, height: 24, mono: false, preview: false },
|
|
265
|
+
])(
|
|
266
|
+
"mini pastes, previews, submits, and recalls an image ($width x $height, mono=$mono, preview=$preview)",
|
|
267
|
+
async (options) => {
|
|
268
|
+
const submitted: RunPrompt[] = []
|
|
269
|
+
const data = Buffer.from(diffImageFixture).toString("base64")
|
|
270
|
+
const app = await renderFooter({
|
|
271
|
+
...options,
|
|
272
|
+
tuiConfig: createTuiResolvedConfig({ prompt: { image_preview: options.preview } }),
|
|
273
|
+
clipboard: { read: async () => ({ data, mime: "image/png" }) },
|
|
274
|
+
onSubmit: (prompt) => {
|
|
275
|
+
submitted.push(prompt)
|
|
276
|
+
return true
|
|
277
|
+
},
|
|
278
|
+
})
|
|
279
|
+
try {
|
|
280
|
+
await app.renderOnce()
|
|
281
|
+
app.mockInput.pressKey("v", { ctrl: true })
|
|
282
|
+
await app.waitForFrame((frame) => frame.includes("[Image 1]"))
|
|
283
|
+
const image = app.renderer.root.findDescendantById("mini-prompt-image-0")
|
|
284
|
+
if (!options.mono && options.preview) {
|
|
285
|
+
expect(image).toBeInstanceOf(ImageRenderable)
|
|
286
|
+
if (!(image instanceof ImageRenderable)) throw new Error("Image preview missing")
|
|
287
|
+
await image.loadPromise
|
|
288
|
+
expect(image.image?.width).toBe(96)
|
|
289
|
+
expect(image.fit).toBe("fit")
|
|
290
|
+
expect(image.width).toBeGreaterThan(0)
|
|
291
|
+
expect(image.height).toBeGreaterThan(0)
|
|
292
|
+
expect(image.height).toBeLessThanOrEqual(4)
|
|
293
|
+
expect(image.x + image.width).toBeLessThanOrEqual(options.width)
|
|
294
|
+
await app.mockInput.typeText("x")
|
|
295
|
+
app.mockInput.pressKey("BACKSPACE")
|
|
296
|
+
await app.renderOnce()
|
|
297
|
+
expect(app.renderer.root.findDescendantById("mini-prompt-image-0")).toBe(image)
|
|
298
|
+
}
|
|
299
|
+
if (options.mono || !options.preview) expect(image).toBeUndefined()
|
|
300
|
+
app.mockInput.pressEnter()
|
|
301
|
+
await app.waitFor(() => submitted.length === 1)
|
|
302
|
+
expect(submitted[0]).toMatchObject({
|
|
303
|
+
text: "[Image 1] ",
|
|
304
|
+
parts: [
|
|
305
|
+
{
|
|
306
|
+
type: "file",
|
|
307
|
+
url: `data:image/png;base64,${data}`,
|
|
308
|
+
filename: "clipboard",
|
|
309
|
+
mime: "image/png",
|
|
310
|
+
source: { text: { start: 0, end: 9, value: "[Image 1]" } },
|
|
311
|
+
},
|
|
312
|
+
],
|
|
313
|
+
})
|
|
314
|
+
await app.waitFor(() => app.renderer.currentFocusedEditor?.plainText === "")
|
|
315
|
+
app.mockInput.pressKey("ARROW_UP")
|
|
316
|
+
await app.waitForFrame((frame) => frame.includes("[Image 1]"))
|
|
317
|
+
app.mockInput.pressEnter()
|
|
318
|
+
await app.waitFor(() => submitted.length === 2)
|
|
319
|
+
expect(submitted[1].parts).toEqual(submitted[0].parts)
|
|
320
|
+
} finally {
|
|
321
|
+
app.cleanup()
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
test("mini waits for image paste before submitting and drops a paste after editing the draft", async () => {
|
|
327
|
+
const pending = Promise.withResolvers<ClipboardContent | undefined>()
|
|
328
|
+
const submitted: RunPrompt[] = []
|
|
329
|
+
let reads = 0
|
|
330
|
+
const app = await renderFooter({
|
|
331
|
+
clipboard: {
|
|
332
|
+
read: () => {
|
|
333
|
+
reads += 1
|
|
334
|
+
return pending.promise
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
onSubmit: (prompt) => {
|
|
338
|
+
submitted.push(prompt)
|
|
339
|
+
return true
|
|
340
|
+
},
|
|
341
|
+
})
|
|
342
|
+
try {
|
|
343
|
+
await app.renderOnce()
|
|
344
|
+
await app.mockInput.typeText("inspect ")
|
|
345
|
+
app.mockInput.pressKey("v", { ctrl: true })
|
|
346
|
+
await app.waitFor(() => reads === 1)
|
|
347
|
+
app.mockInput.pressEnter()
|
|
348
|
+
expect(submitted).toHaveLength(0)
|
|
349
|
+
pending.resolve({ mime: "image/png", data: Buffer.from(diffImageFixture).toString("base64") })
|
|
350
|
+
await app.waitFor(() => submitted.length === 1)
|
|
351
|
+
expect(submitted[0].text).toBe("inspect [Image 1] ")
|
|
352
|
+
expect(submitted[0].parts).toHaveLength(1)
|
|
353
|
+
} finally {
|
|
354
|
+
app.cleanup()
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const changed = Promise.withResolvers<ClipboardContent | undefined>()
|
|
358
|
+
const cancelled: RunPrompt[] = []
|
|
359
|
+
const next = await renderFooter({
|
|
360
|
+
clipboard: { read: () => changed.promise },
|
|
361
|
+
onSubmit: (prompt) => {
|
|
362
|
+
cancelled.push(prompt)
|
|
363
|
+
return true
|
|
364
|
+
},
|
|
365
|
+
})
|
|
366
|
+
try {
|
|
367
|
+
await next.renderOnce()
|
|
368
|
+
await next.mockInput.typeText("old draft")
|
|
369
|
+
next.mockInput.pressKey("v", { ctrl: true })
|
|
370
|
+
await next.renderOnce()
|
|
371
|
+
next.mockInput.pressEnter()
|
|
372
|
+
next.mockInput.pressKey("c", { ctrl: true })
|
|
373
|
+
await next.mockInput.typeText("changed draft")
|
|
374
|
+
changed.resolve({ mime: "image/png", data: Buffer.from(diffImageFixture).toString("base64") })
|
|
375
|
+
await next.flush()
|
|
376
|
+
expect(cancelled).toEqual([])
|
|
377
|
+
expect(next.renderer.currentFocusedEditor?.plainText).toBe("changed draft")
|
|
378
|
+
} finally {
|
|
379
|
+
next.cleanup()
|
|
380
|
+
}
|
|
381
|
+
})
|
|
382
|
+
|
|
383
|
+
test("mini replaces selected text with a tracked image attachment", async () => {
|
|
384
|
+
const sent = Promise.withResolvers<RunPrompt>()
|
|
385
|
+
const app = await renderFooter({
|
|
386
|
+
clipboard: { read: async () => ({ mime: "image/png", data: Buffer.from(diffImageFixture).toString("base64") }) },
|
|
387
|
+
onSubmit: (prompt) => {
|
|
388
|
+
sent.resolve(prompt)
|
|
389
|
+
return true
|
|
390
|
+
},
|
|
391
|
+
})
|
|
392
|
+
try {
|
|
393
|
+
await app.renderOnce()
|
|
394
|
+
await app.mockInput.typeText("replace me")
|
|
395
|
+
app.renderer.currentFocusedEditor?.setSelection(0, 10)
|
|
396
|
+
app.mockInput.pressKey("v", { ctrl: true })
|
|
397
|
+
app.mockInput.pressEnter()
|
|
398
|
+
const prompt = await sent.promise
|
|
399
|
+
expect(prompt.text).toBe("[Image 1] ")
|
|
400
|
+
expect(prompt.parts).toMatchObject([{ type: "file", source: { text: { start: 0, end: 9, value: "[Image 1]" } } }])
|
|
401
|
+
} finally {
|
|
402
|
+
app.cleanup()
|
|
403
|
+
}
|
|
404
|
+
})
|
|
405
|
+
|
|
406
|
+
test("mini retains ordinary paste ANSI stripping and newline normalization", async () => {
|
|
407
|
+
const sent = Promise.withResolvers<RunPrompt>()
|
|
408
|
+
const app = await renderFooter({
|
|
409
|
+
onSubmit: (prompt) => {
|
|
410
|
+
sent.resolve(prompt)
|
|
411
|
+
return true
|
|
412
|
+
},
|
|
413
|
+
})
|
|
414
|
+
try {
|
|
415
|
+
await app.renderOnce()
|
|
416
|
+
await app.mockInput.pasteBracketedText("\x1b[31mred\x1b[0m\r\nplain")
|
|
417
|
+
app.mockInput.pressEnter()
|
|
418
|
+
expect((await sent.promise).text).toBe("red\nplain")
|
|
419
|
+
} finally {
|
|
420
|
+
app.cleanup()
|
|
421
|
+
}
|
|
422
|
+
})
|
|
423
|
+
|
|
424
|
+
test("mini places a mention and the cursor at measured offsets after wide text", async () => {
|
|
425
|
+
const sent = Promise.withResolvers<RunPrompt>()
|
|
426
|
+
const app = await renderFooter({
|
|
427
|
+
agents: ["helper", "助手"].map((id) => ({ id, name: id, mode: "subagent" as const, hidden: false })),
|
|
428
|
+
onSubmit: (prompt) => {
|
|
429
|
+
sent.resolve(prompt)
|
|
430
|
+
return true
|
|
431
|
+
},
|
|
432
|
+
})
|
|
433
|
+
try {
|
|
434
|
+
await app.renderOnce()
|
|
435
|
+
await app.mockInput.pasteBracketedText("\t👨👩👧நி @助")
|
|
436
|
+
await app.waitForFrame((frame) => frame.includes("@助手") && !frame.includes("@helper"))
|
|
437
|
+
app.mockInput.pressEnter()
|
|
438
|
+
// Down on the last row moves the cursor to the end of the text.
|
|
439
|
+
app.mockInput.pressArrow("left")
|
|
440
|
+
app.mockInput.pressArrow("down")
|
|
441
|
+
await app.mockInput.typeText("x")
|
|
442
|
+
expect(app.renderer.currentFocusedEditor?.plainText).toBe("\t👨👩👧நி @助手 x")
|
|
443
|
+
app.mockInput.pressEnter()
|
|
444
|
+
const buffer = app.renderer.currentFocusedEditor!.editBuffer
|
|
445
|
+
const [start, value] = [buffer.measureText("\t👨👩👧நி "), "@助手"]
|
|
446
|
+
expect(await sent.promise).toMatchObject({
|
|
447
|
+
text: "\t👨👩👧நி @助手 x",
|
|
448
|
+
parts: [{ type: "agent", name: "助手", source: { start, end: start + buffer.measureText(value), value } }],
|
|
449
|
+
})
|
|
450
|
+
} finally {
|
|
451
|
+
app.cleanup()
|
|
452
|
+
}
|
|
453
|
+
})
|
|
454
|
+
|
|
455
|
+
test("a failed clipboard read cancels a waiting submit without losing the draft", async () => {
|
|
456
|
+
const pending = Promise.withResolvers<ClipboardContent | undefined>()
|
|
457
|
+
const submitted: RunPrompt[] = []
|
|
458
|
+
const statuses: string[] = []
|
|
459
|
+
const app = await renderFooter({
|
|
460
|
+
clipboard: { read: () => pending.promise },
|
|
461
|
+
onStatus: (status) => statuses.push(status),
|
|
462
|
+
onSubmit: (prompt) => {
|
|
463
|
+
submitted.push(prompt)
|
|
464
|
+
return true
|
|
465
|
+
},
|
|
466
|
+
})
|
|
467
|
+
try {
|
|
468
|
+
await app.renderOnce()
|
|
469
|
+
await app.mockInput.typeText("inspect this")
|
|
470
|
+
app.mockInput.pressKey("v", { ctrl: true })
|
|
471
|
+
await app.renderOnce()
|
|
472
|
+
app.mockInput.pressEnter()
|
|
473
|
+
pending.reject(new Error("Clipboard unavailable"))
|
|
474
|
+
await app.waitFor(() => statuses.length > 0)
|
|
475
|
+
await app.flush()
|
|
476
|
+
expect(submitted).toEqual([])
|
|
477
|
+
expect(app.renderer.currentFocusedEditor?.plainText).toBe("inspect this")
|
|
478
|
+
app.mockInput.pressEnter()
|
|
479
|
+
await app.waitFor(() => submitted.length === 1)
|
|
480
|
+
} finally {
|
|
481
|
+
app.cleanup()
|
|
482
|
+
}
|
|
483
|
+
})
|
|
484
|
+
|
|
485
|
+
test("mini attaches dropped image paths and removes attachments with their labels", async () => {
|
|
486
|
+
await using tmp = await tmpdir()
|
|
487
|
+
await Bun.write(`${tmp.path}/one image.png`, diffImageFixture)
|
|
488
|
+
await Bun.write(`${tmp.path}/two.png`, diffImageFixture)
|
|
489
|
+
const submitted: RunPrompt[] = []
|
|
490
|
+
const sent = Promise.withResolvers<void>()
|
|
491
|
+
const app = await renderFooter({
|
|
492
|
+
onSubmit: (prompt) => {
|
|
493
|
+
submitted.push(prompt)
|
|
494
|
+
sent.resolve()
|
|
495
|
+
return true
|
|
496
|
+
},
|
|
497
|
+
})
|
|
498
|
+
try {
|
|
499
|
+
await app.renderOnce()
|
|
500
|
+
await app.mockInput.typeText("\u4e2d\u6587 ")
|
|
501
|
+
await app.mockInput.pasteBracketedText(`'${tmp.path}/one image.png' '${tmp.path}/two.png'`)
|
|
502
|
+
app.mockInput.pressEnter()
|
|
503
|
+
await sent.promise
|
|
504
|
+
expect(submitted[0].text).toBe("\u4e2d\u6587 [Image 1] [Image 2] ")
|
|
505
|
+
expect(submitted[0].parts).toMatchObject([
|
|
506
|
+
{ type: "file", filename: "one image.png", source: { text: { start: 5, end: 14, value: "[Image 1]" } } },
|
|
507
|
+
{ type: "file", filename: "two.png", source: { text: { start: 15, end: 24, value: "[Image 2]" } } },
|
|
508
|
+
])
|
|
509
|
+
await app.waitFor(() => app.renderer.currentFocusedEditor?.plainText === "")
|
|
510
|
+
app.mockInput.pressKey("ARROW_UP")
|
|
511
|
+
await app.waitForFrame((frame) => frame.includes("[Image 2]"))
|
|
512
|
+
app.renderer.currentFocusedEditor?.setText("no attachments")
|
|
513
|
+
app.mockInput.pressEnter()
|
|
514
|
+
await app.waitFor(() => submitted.length === 2)
|
|
515
|
+
expect(submitted[1].parts).toEqual([])
|
|
516
|
+
} finally {
|
|
517
|
+
app.cleanup()
|
|
518
|
+
}
|
|
519
|
+
})
|
|
520
|
+
|
|
521
|
+
test("mini preserves mentionless images through draft edits and a rejected submission", async () => {
|
|
522
|
+
const part = {
|
|
523
|
+
type: "file" as const,
|
|
524
|
+
url: `data:image/png;base64,${Buffer.from(diffImageFixture).toString("base64")}`,
|
|
525
|
+
}
|
|
526
|
+
const submitted: RunPrompt[] = []
|
|
527
|
+
const app = await renderFooter({
|
|
528
|
+
history: [{ text: "", parts: [part] }],
|
|
529
|
+
onSubmit: (prompt) => {
|
|
530
|
+
submitted.push(prompt)
|
|
531
|
+
return submitted.length > 1
|
|
532
|
+
},
|
|
533
|
+
})
|
|
534
|
+
try {
|
|
535
|
+
await app.renderOnce()
|
|
536
|
+
app.mockInput.pressKey("ARROW_UP")
|
|
537
|
+
await app.renderOnce()
|
|
538
|
+
await app.mockInput.typeText("look")
|
|
539
|
+
app.mockInput.pressEnter()
|
|
540
|
+
await app.waitFor(() => submitted.length === 1)
|
|
541
|
+
await app.waitFor(() => app.renderer.currentFocusedEditor?.plainText === "look")
|
|
542
|
+
expect(submitted[0].parts).toEqual([part])
|
|
543
|
+
app.mockInput.pressEnter()
|
|
544
|
+
await app.waitFor(() => submitted.length === 2)
|
|
545
|
+
expect(submitted[1].parts).toEqual([part])
|
|
546
|
+
} finally {
|
|
547
|
+
app.cleanup()
|
|
548
|
+
}
|
|
549
|
+
})
|
|
550
|
+
|
|
551
|
+
test("direct footer leads with the active agent and default model", async () => {
|
|
552
|
+
const app = await renderFooter({ state: { model: "Default model" } })
|
|
553
|
+
try {
|
|
554
|
+
await app.renderOnce()
|
|
555
|
+
const frame = app.captureCharFrame()
|
|
556
|
+
expect(
|
|
557
|
+
frame
|
|
558
|
+
.split("\n")
|
|
559
|
+
.find((line) => line.includes("Default model"))
|
|
560
|
+
?.trimEnd(),
|
|
561
|
+
).toBe("Build · Default model · ctrl+p menu")
|
|
562
|
+
expect(frame).not.toContain("BUILD")
|
|
563
|
+
} finally {
|
|
564
|
+
app.cleanup()
|
|
565
|
+
}
|
|
566
|
+
})
|
|
567
|
+
|
|
568
|
+
test("direct footer describes commands and context and shows the model provider", async () => {
|
|
569
|
+
const app = await renderFooter({
|
|
570
|
+
providers: [provider()],
|
|
571
|
+
currentModel: { providerID: "opencode", modelID: "gpt-5" },
|
|
572
|
+
state: { first: true },
|
|
573
|
+
})
|
|
574
|
+
try {
|
|
575
|
+
await app.renderOnce()
|
|
576
|
+
expect(app.captureCharFrame()).toContain("┃ Ask anything, / for commands, @ for context…")
|
|
577
|
+
expect(app.captureCharFrame()).toContain("Build · GPT-5 · opencode · ctrl+p menu")
|
|
578
|
+
} finally {
|
|
579
|
+
app.cleanup()
|
|
580
|
+
}
|
|
581
|
+
})
|
|
582
|
+
|
|
583
|
+
test.each([56, 160])("exit confirmation replaces routine footer details at %i columns", async (width) => {
|
|
584
|
+
const app = await renderFooter({
|
|
585
|
+
width,
|
|
586
|
+
currentAgent: "Build",
|
|
587
|
+
providers: [provider()],
|
|
588
|
+
currentModel: { providerID: "opencode", modelID: "gpt-5" },
|
|
589
|
+
currentVariant: "high",
|
|
590
|
+
state: { usage: { tokens: 12000, percent: 10 } },
|
|
591
|
+
queuedPrompts: [{ messageID: "queued", prompt: { text: "later", parts: [] }, delivery: "queue" }],
|
|
592
|
+
})
|
|
593
|
+
try {
|
|
594
|
+
await app.renderOnce()
|
|
595
|
+
const initial = app.captureCharFrame()
|
|
596
|
+
expect(initial).toContain("Build · GPT-5 [high] · 12.0K (10%)")
|
|
597
|
+
expect(initial.includes("ctrl+p menu")).toBe(width === 160)
|
|
598
|
+
app.setState((state) => ({ ...state, exit: 1 }))
|
|
599
|
+
await app.renderOnce()
|
|
600
|
+
const frame = app.captureCharFrame()
|
|
601
|
+
expect(frame).toContain("Press ctrl+c again to exit")
|
|
602
|
+
for (const text of ["Build", "GPT-5", "opencode", "high", "12.0K", "queued", "menu"])
|
|
603
|
+
expect(frame).not.toContain(text)
|
|
604
|
+
app.setState((state) => ({ ...state, exit: 0 }))
|
|
605
|
+
await app.renderOnce()
|
|
606
|
+
expect(app.captureCharFrame()).toBe(initial)
|
|
607
|
+
} finally {
|
|
608
|
+
app.cleanup()
|
|
609
|
+
}
|
|
610
|
+
})
|
|
611
|
+
|
|
612
|
+
test("direct footer preserves a partial multi-field form draft across permission preemption", async () => {
|
|
613
|
+
const request: FormInfo = {
|
|
614
|
+
id: "frm_preempted",
|
|
615
|
+
sessionID: "ses_child",
|
|
616
|
+
title: "Deployment",
|
|
617
|
+
fields: [
|
|
618
|
+
{ key: "service", type: "string", title: "Service", required: true },
|
|
619
|
+
{ key: "notes", type: "string", title: "Notes", required: true },
|
|
620
|
+
],
|
|
621
|
+
}
|
|
622
|
+
const app = await renderFooter({
|
|
623
|
+
height: 16,
|
|
624
|
+
view: { type: "form", request },
|
|
625
|
+
})
|
|
626
|
+
|
|
627
|
+
try {
|
|
628
|
+
await app.renderOnce()
|
|
629
|
+
"api".split("").forEach((key) => app.mockInput.pressKey(key))
|
|
630
|
+
app.mockInput.pressEnter()
|
|
631
|
+
await app.renderOnce()
|
|
632
|
+
"keep this 草稿".split("").forEach((key) => app.mockInput.pressKey(key))
|
|
633
|
+
expect(app.renderer.currentFocusedEditor?.plainText).toBe("keep this 草稿")
|
|
634
|
+
|
|
635
|
+
app.setView({
|
|
636
|
+
type: "permission",
|
|
637
|
+
request: {
|
|
638
|
+
id: "per_preempting",
|
|
639
|
+
sessionID: "ses_child",
|
|
640
|
+
action: "read",
|
|
641
|
+
resources: ["src/index.ts"],
|
|
642
|
+
},
|
|
643
|
+
})
|
|
644
|
+
await app.renderOnce()
|
|
645
|
+
expect(app.captureCharFrame()).toContain("Permission required")
|
|
646
|
+
|
|
647
|
+
app.setView({ type: "form", request })
|
|
648
|
+
await app.renderOnce()
|
|
649
|
+
expect(app.captureCharFrame()).toContain("2/2")
|
|
650
|
+
app.mockInput.pressKey("!")
|
|
651
|
+
expect(app.renderer.currentFocusedEditor?.plainText).toBe("keep this 草稿!")
|
|
652
|
+
|
|
653
|
+
app.setView({ type: "prompt" })
|
|
654
|
+
await app.renderOnce()
|
|
655
|
+
app.setView({ type: "form", request })
|
|
656
|
+
await app.renderOnce()
|
|
657
|
+
expect(app.captureCharFrame()).toContain("1/2")
|
|
658
|
+
expect(app.renderer.currentFocusedEditor?.plainText).toBe("")
|
|
659
|
+
} finally {
|
|
660
|
+
app.cleanup()
|
|
661
|
+
}
|
|
662
|
+
})
|
|
663
|
+
|
|
664
|
+
function expectPaletteList(list: BoxRenderable, selectedIndex: number) {
|
|
665
|
+
expect(list.backgroundColor.toInts()).toEqual((RUN_THEME_FALLBACK.footer.shade as RGBA).toInts())
|
|
666
|
+
expect((list.getChildren()[selectedIndex] as BoxRenderable).backgroundColor.toInts()).toEqual(
|
|
667
|
+
(RUN_THEME_FALLBACK.footer.actionFocusedBg as RGBA).toInts(),
|
|
668
|
+
)
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
function child(root: BoxRenderable | RootRenderable, index: number) {
|
|
672
|
+
return root.getChildren()[index] as BoxRenderable
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
function boxPath(root: BoxRenderable | RootRenderable, name: string): BoxRenderable[] | undefined {
|
|
676
|
+
for (const item of root.getChildren()) {
|
|
677
|
+
if (item.constructor.name === name) return root instanceof BoxRenderable ? [root] : []
|
|
678
|
+
if (!(item instanceof BoxRenderable)) continue
|
|
679
|
+
const path = boxPath(item, name)
|
|
680
|
+
if (path) return root instanceof BoxRenderable ? [root, ...path] : path
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
function footerComposerFrame(root: BoxRenderable | RootRenderable) {
|
|
685
|
+
return boxPath(root, "TextareaRenderable")!.at(-5)!
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
function footerStatusline(root: BoxRenderable | RootRenderable) {
|
|
689
|
+
return root.findDescendantById("mini-statusline") as BoxRenderable
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
function panelMenu(root: BoxRenderable | RootRenderable) {
|
|
693
|
+
const content = boxPath(root, "InputRenderable")!.at(-2)!
|
|
694
|
+
return child(content.getChildren().at(-1) as BoxRenderable, 0)
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
test("direct footer composer area does not adopt footer surface", async () => {
|
|
698
|
+
const surface = RGBA.fromHex("#123456")
|
|
699
|
+
const [theme, setTheme] = createSignal(RUN_THEME_FALLBACK)
|
|
700
|
+
const app = await renderFooter({ theme })
|
|
701
|
+
|
|
702
|
+
try {
|
|
703
|
+
await app.renderOnce()
|
|
704
|
+
const area = child(footerComposerFrame(app.renderer.root), 0)
|
|
705
|
+
|
|
706
|
+
expect(area.backgroundColor.toInts()).not.toEqual(surface.toInts())
|
|
707
|
+
setTheme({
|
|
708
|
+
...RUN_THEME_FALLBACK,
|
|
709
|
+
footer: {
|
|
710
|
+
...RUN_THEME_FALLBACK.footer,
|
|
711
|
+
surface,
|
|
712
|
+
},
|
|
713
|
+
})
|
|
714
|
+
await app.renderOnce()
|
|
715
|
+
|
|
716
|
+
expect(area.backgroundColor.toInts()).not.toEqual(surface.toInts())
|
|
717
|
+
} finally {
|
|
718
|
+
app.cleanup()
|
|
719
|
+
}
|
|
720
|
+
})
|
|
721
|
+
|
|
722
|
+
test("run entry content updates when live commit text changes", async () => {
|
|
723
|
+
const [commit, setCommit] = createSignal<StreamCommit>({
|
|
724
|
+
kind: "tool",
|
|
725
|
+
text: "I",
|
|
726
|
+
phase: "progress",
|
|
727
|
+
source: "tool",
|
|
728
|
+
messageID: "msg-1",
|
|
729
|
+
partID: "part-1",
|
|
730
|
+
tool: "shell",
|
|
731
|
+
})
|
|
732
|
+
|
|
733
|
+
const app = await testRender(
|
|
734
|
+
() => (
|
|
735
|
+
<box width={80} height={4}>
|
|
736
|
+
<RunEntryContent commit={commit()} theme={RUN_THEME_FALLBACK} />
|
|
737
|
+
</box>
|
|
738
|
+
),
|
|
739
|
+
{
|
|
740
|
+
width: 80,
|
|
741
|
+
height: 4,
|
|
742
|
+
},
|
|
743
|
+
)
|
|
744
|
+
|
|
745
|
+
try {
|
|
746
|
+
await app.renderOnce()
|
|
747
|
+
expect(app.captureCharFrame()).toContain("I")
|
|
748
|
+
|
|
749
|
+
setCommit({
|
|
750
|
+
kind: "tool",
|
|
751
|
+
text: "I need to inspect the codebase",
|
|
752
|
+
phase: "progress",
|
|
753
|
+
source: "tool",
|
|
754
|
+
messageID: "msg-1",
|
|
755
|
+
partID: "part-1",
|
|
756
|
+
tool: "shell",
|
|
757
|
+
})
|
|
758
|
+
await app.renderOnce()
|
|
759
|
+
|
|
760
|
+
expect(app.captureCharFrame()).toContain("I need to inspect the codebase")
|
|
761
|
+
} finally {
|
|
762
|
+
app.renderer.destroy()
|
|
763
|
+
}
|
|
764
|
+
})
|
|
765
|
+
|
|
766
|
+
test("run entry content preserves monochrome markdown grammar", async () => {
|
|
767
|
+
const [commit, setCommit] = createSignal<StreamCommit>({
|
|
768
|
+
kind: "assistant",
|
|
769
|
+
text: "• literal\n\n———\n\narrow →",
|
|
770
|
+
phase: "progress",
|
|
771
|
+
source: "assistant",
|
|
772
|
+
messageID: "msg-1",
|
|
773
|
+
partID: "part-1",
|
|
774
|
+
})
|
|
775
|
+
const app = await testRender(
|
|
776
|
+
() => (
|
|
777
|
+
<box width={60} height={8}>
|
|
778
|
+
<RunEntryContent commit={commit()} theme={RUN_THEME_FALLBACK} opts={{ mono: true }} />
|
|
779
|
+
</box>
|
|
780
|
+
),
|
|
781
|
+
{ width: 60, height: 8 },
|
|
782
|
+
)
|
|
783
|
+
|
|
784
|
+
try {
|
|
785
|
+
await app.renderOnce()
|
|
786
|
+
const rows = app
|
|
787
|
+
.captureCharFrame()
|
|
788
|
+
.split("\n")
|
|
789
|
+
.map((row) => row.trimEnd())
|
|
790
|
+
expect(rows).toContain("* literal")
|
|
791
|
+
expect(rows).toContain("------")
|
|
792
|
+
expect(rows).toContain("arrow ->")
|
|
793
|
+
expect(rows.join("\n")).not.toMatch(/[^\x00-\x7f]/)
|
|
794
|
+
|
|
795
|
+
setCommit({ ...commit(), text: "- Café\n- arrow →\n- third …" })
|
|
796
|
+
await app.renderOnce()
|
|
797
|
+
expect(app.captureCharFrame()).toContain("- arrow ->")
|
|
798
|
+
expect(app.captureCharFrame()).toContain("- third ...")
|
|
799
|
+
|
|
800
|
+
setCommit({ ...commit(), text: "| A | B |\n| - | - |\n| Café | → |" })
|
|
801
|
+
await app.renderOnce()
|
|
802
|
+
expect(app.captureCharFrame()).toContain("Caf?")
|
|
803
|
+
expect(app.captureCharFrame()).toContain("->")
|
|
804
|
+
setCommit({ ...commit(), text: "| A | B |\n| - | - |\n| Café | … |" })
|
|
805
|
+
await app.renderOnce()
|
|
806
|
+
expect(app.captureCharFrame()).toContain("...")
|
|
807
|
+
|
|
808
|
+
setCommit({ ...commit(), text: "```\nCafé → …\n```" })
|
|
809
|
+
await app.renderOnce()
|
|
810
|
+
expect(app.captureCharFrame()).toContain("Caf? -> ...")
|
|
811
|
+
expect(app.captureCharFrame()).not.toMatch(/[^\x00-\x7f]/)
|
|
812
|
+
} finally {
|
|
813
|
+
app.renderer.destroy()
|
|
814
|
+
}
|
|
815
|
+
})
|
|
816
|
+
|
|
817
|
+
test("run entry content toggles unchanged live markdown between color and monochrome", async () => {
|
|
818
|
+
const [mono, setMono] = createSignal(false)
|
|
819
|
+
const commit: StreamCommit = {
|
|
820
|
+
kind: "assistant",
|
|
821
|
+
text: "Active Café → …",
|
|
822
|
+
phase: "progress",
|
|
823
|
+
source: "assistant",
|
|
824
|
+
messageID: "msg-1",
|
|
825
|
+
partID: "part-1",
|
|
826
|
+
}
|
|
827
|
+
const app = await testRender(
|
|
828
|
+
() => (
|
|
829
|
+
<box width={60} height={4}>
|
|
830
|
+
<RunEntryContent commit={commit} theme={RUN_THEME_FALLBACK} opts={{ mono: mono() }} />
|
|
831
|
+
</box>
|
|
832
|
+
),
|
|
833
|
+
{ width: 60, height: 4 },
|
|
834
|
+
)
|
|
835
|
+
|
|
836
|
+
try {
|
|
837
|
+
await app.renderOnce()
|
|
838
|
+
const color = app.captureCharFrame()
|
|
839
|
+
expect(color).toContain("Active Café → …")
|
|
840
|
+
|
|
841
|
+
setMono(true)
|
|
842
|
+
await app.renderOnce()
|
|
843
|
+
expect(app.captureCharFrame()).toContain("Active Caf? -> ...")
|
|
844
|
+
expect(app.captureCharFrame()).not.toMatch(/[^\x00-\x7f]/)
|
|
845
|
+
|
|
846
|
+
setMono(false)
|
|
847
|
+
await app.renderOnce()
|
|
848
|
+
expect(app.captureCharFrame()).toBe(color)
|
|
849
|
+
} finally {
|
|
850
|
+
app.renderer.destroy()
|
|
851
|
+
}
|
|
852
|
+
})
|
|
853
|
+
|
|
854
|
+
test("run entry content eagerly renders final monochrome markdown", async () => {
|
|
855
|
+
const app = await testRender(
|
|
856
|
+
() => (
|
|
857
|
+
<box width={60} height={6}>
|
|
858
|
+
<RunEntryContent
|
|
859
|
+
commit={{ kind: "tool", text: "", phase: "final", source: "tool", tool: "subagent" }}
|
|
860
|
+
body={{ type: "markdown", content: "# Café →\n\n```markdown\nCafé →\n```" }}
|
|
861
|
+
theme={RUN_THEME_FALLBACK}
|
|
862
|
+
opts={{ mono: true }}
|
|
863
|
+
/>
|
|
864
|
+
</box>
|
|
865
|
+
),
|
|
866
|
+
{ width: 60, height: 6 },
|
|
867
|
+
)
|
|
868
|
+
|
|
869
|
+
try {
|
|
870
|
+
await app.renderOnce()
|
|
871
|
+
const frame = app.captureCharFrame()
|
|
872
|
+
// The heading (its marker concealed) and the fence's code.
|
|
873
|
+
expect(frame.match(/^Caf\? ->/gm)).toHaveLength(2)
|
|
874
|
+
expect(frame).not.toMatch(/[^\x00-\x7f]/)
|
|
875
|
+
} finally {
|
|
876
|
+
app.renderer.destroy()
|
|
877
|
+
}
|
|
878
|
+
})
|
|
879
|
+
|
|
880
|
+
test("direct command panel renders grouped actions without catalog commands", async () => {
|
|
881
|
+
const [commands] = createSignal<RunCommand[] | undefined>([
|
|
882
|
+
command({ name: "review", description: "Review code" }),
|
|
883
|
+
command({ name: "deploy", description: "Deploy prompt", source: "mcp" }),
|
|
884
|
+
])
|
|
885
|
+
const [subagents] = createSignal([])
|
|
886
|
+
const [variants] = createSignal(["high", "minimal"])
|
|
887
|
+
let status = 0
|
|
888
|
+
|
|
889
|
+
const app = await testRender(
|
|
890
|
+
() => (
|
|
891
|
+
<box width={100} height={RUN_COMMAND_PANEL_ROWS}>
|
|
892
|
+
<RunCommandMenuBody
|
|
893
|
+
theme={() => RUN_THEME_FALLBACK.footer}
|
|
894
|
+
commands={commands}
|
|
895
|
+
subagents={subagents}
|
|
896
|
+
queued={() => []}
|
|
897
|
+
variants={variants}
|
|
898
|
+
variantCycle="ctrl+t"
|
|
899
|
+
onClose={() => {}}
|
|
900
|
+
onAgent={() => {}}
|
|
901
|
+
onModel={() => {}}
|
|
902
|
+
onEditor={() => {}}
|
|
903
|
+
onSubagent={() => {}}
|
|
904
|
+
onQueued={() => {}}
|
|
905
|
+
onVariant={() => {}}
|
|
906
|
+
onVariantCycle={() => {}}
|
|
907
|
+
onStatus={() => status++}
|
|
908
|
+
onSettings={() => {}}
|
|
909
|
+
onCommand={() => {}}
|
|
910
|
+
onNew={() => {}}
|
|
911
|
+
onExit={() => {}}
|
|
912
|
+
/>
|
|
913
|
+
</box>
|
|
914
|
+
),
|
|
915
|
+
{
|
|
916
|
+
width: 100,
|
|
917
|
+
height: RUN_COMMAND_PANEL_ROWS + 1,
|
|
918
|
+
},
|
|
919
|
+
)
|
|
920
|
+
|
|
921
|
+
try {
|
|
922
|
+
await app.renderOnce()
|
|
923
|
+
const frame = app.captureCharFrame()
|
|
924
|
+
|
|
925
|
+
expect(frame).toContain("Commands")
|
|
926
|
+
expect(frame).toMatch(/^ {2}Commands/m)
|
|
927
|
+
expect(frame).toContain("Search")
|
|
928
|
+
expect(frame).toContain("Session")
|
|
929
|
+
expect(frame).toContain("Agent")
|
|
930
|
+
expect(frame).toContain("Open editor")
|
|
931
|
+
expect(frame).toContain("/editor")
|
|
932
|
+
expect(frame).toContain("Show status")
|
|
933
|
+
expect(frame).toContain("Compact session")
|
|
934
|
+
expect(frame).toContain("/compact")
|
|
935
|
+
expect(frame.match(/\bAgent\b/g)?.length).toBe(1)
|
|
936
|
+
expect(frame).not.toContain("┌")
|
|
937
|
+
expect(frame).not.toContain("┃")
|
|
938
|
+
expect(frame).not.toContain("/internal")
|
|
939
|
+
expect(frame).not.toContain("Choose model for future turns")
|
|
940
|
+
expect(frame).not.toContain("Cycle reasoning effort for future turns")
|
|
941
|
+
expect(frame).not.toContain("Review code")
|
|
942
|
+
expect(frame).not.toContain("Commands 8")
|
|
943
|
+
|
|
944
|
+
await app.mockInput.typeText("agent")
|
|
945
|
+
await app.renderOnce()
|
|
946
|
+
expect(app.captureCharFrame()).toContain("Switch agent")
|
|
947
|
+
|
|
948
|
+
app.mockInput.pressKey("u", { ctrl: true })
|
|
949
|
+
await app.mockInput.typeText("review")
|
|
950
|
+
await app.renderOnce()
|
|
951
|
+
expect(app.captureCharFrame()).toContain("No results found")
|
|
952
|
+
|
|
953
|
+
app.mockInput.pressKey("u", { ctrl: true })
|
|
954
|
+
await app.mockInput.typeText("deploy")
|
|
955
|
+
await app.renderOnce()
|
|
956
|
+
expect(app.captureCharFrame()).toContain("No results found")
|
|
957
|
+
|
|
958
|
+
app.mockInput.pressKey("u", { ctrl: true })
|
|
959
|
+
await app.mockInput.typeText("status")
|
|
960
|
+
await app.renderOnce()
|
|
961
|
+
expect(app.captureCharFrame()).toContain("Show status")
|
|
962
|
+
app.mockInput.pressEnter()
|
|
963
|
+
expect(status).toBe(1)
|
|
964
|
+
} finally {
|
|
965
|
+
app.renderer.destroy()
|
|
966
|
+
}
|
|
967
|
+
})
|
|
968
|
+
|
|
969
|
+
test.each([false, true])("settings change preferences and preview the work spinner (mono=%s)", async (mono) => {
|
|
970
|
+
const [settings, setSettings] = createSignal(resolveMiniSettings())
|
|
971
|
+
const [animations, setAnimations] = createSignal(true)
|
|
972
|
+
const app = await testRender(
|
|
973
|
+
() => (
|
|
974
|
+
<box width="100%" height="100%">
|
|
975
|
+
<RunSettingsBody
|
|
976
|
+
theme={() => RUN_THEME_FALLBACK.footer}
|
|
977
|
+
settings={settings}
|
|
978
|
+
onClose={() => {}}
|
|
979
|
+
onChange={(change) => {
|
|
980
|
+
setSettings((current) => applyMiniSettingChange(current, change))
|
|
981
|
+
}}
|
|
982
|
+
mono={mono}
|
|
983
|
+
animations={animations()}
|
|
984
|
+
/>
|
|
985
|
+
</box>
|
|
986
|
+
),
|
|
987
|
+
{ width: 100, height: RUN_COMMAND_PANEL_ROWS },
|
|
988
|
+
)
|
|
989
|
+
|
|
990
|
+
try {
|
|
991
|
+
await app.renderOnce()
|
|
992
|
+
const frame = app.captureCharFrame()
|
|
993
|
+
expect(frame).toContain("Settings")
|
|
994
|
+
expect(frame).toMatch(/^ +Settings/m)
|
|
995
|
+
expect(frame).toContain("Verbosity")
|
|
996
|
+
expect(frame).toContain("Thinking")
|
|
997
|
+
expect(frame).toContain("Tools")
|
|
998
|
+
expect(frame).toContain("Shell")
|
|
999
|
+
expect(frame).toContain("Turn summary")
|
|
1000
|
+
expect(frame).toContain("Footer details")
|
|
1001
|
+
expect(frame).toContain("Splash")
|
|
1002
|
+
expect(frame).toContain("Monochrome UI")
|
|
1003
|
+
expect(frame).toContain("left/right change")
|
|
1004
|
+
if (mono) expect(frame).not.toMatch(/[^\x00-\x7F]/)
|
|
1005
|
+
|
|
1006
|
+
app.mockInput.pressKey("ARROW_RIGHT")
|
|
1007
|
+
await app.renderOnce()
|
|
1008
|
+
expect(settings()).toEqual(applyMiniSettingChange(resolveMiniSettings(), { key: "verbosity", value: "everything" }))
|
|
1009
|
+
|
|
1010
|
+
app.mockInput.pressKey("ARROW_LEFT")
|
|
1011
|
+
await app.renderOnce()
|
|
1012
|
+
expect(settings()).toEqual(resolveMiniSettings())
|
|
1013
|
+
|
|
1014
|
+
app.mockInput.pressKey("ARROW_LEFT")
|
|
1015
|
+
await app.renderOnce()
|
|
1016
|
+
expect(settings()).toEqual(applyMiniSettingChange(resolveMiniSettings(), { key: "verbosity", value: "quiet" }))
|
|
1017
|
+
|
|
1018
|
+
app.mockInput.pressKey("ARROW_LEFT")
|
|
1019
|
+
await app.renderOnce()
|
|
1020
|
+
expect(settings()).toEqual(applyMiniSettingChange(resolveMiniSettings(), { key: "verbosity", value: "quiet" }))
|
|
1021
|
+
|
|
1022
|
+
app.mockInput.pressKey("ARROW_RIGHT")
|
|
1023
|
+
await app.renderOnce()
|
|
1024
|
+
expect(settings()).toEqual(resolveMiniSettings())
|
|
1025
|
+
|
|
1026
|
+
app.mockInput.pressKey("ARROW_DOWN")
|
|
1027
|
+
app.mockInput.pressKey("ARROW_RIGHT")
|
|
1028
|
+
await app.renderOnce()
|
|
1029
|
+
|
|
1030
|
+
expect(settings()).toEqual({
|
|
1031
|
+
...resolveMiniSettings(),
|
|
1032
|
+
thinking: "hide",
|
|
1033
|
+
})
|
|
1034
|
+
expect(app.captureCharFrame()).toContain("Custom")
|
|
1035
|
+
|
|
1036
|
+
app.mockInput.pressKey("ARROW_DOWN")
|
|
1037
|
+
app.mockInput.pressKey("ARROW_DOWN")
|
|
1038
|
+
app.mockInput.pressKey("ARROW_DOWN")
|
|
1039
|
+
app.mockInput.pressKey("ARROW_RIGHT")
|
|
1040
|
+
await app.renderOnce()
|
|
1041
|
+
|
|
1042
|
+
expect(settings()).toEqual({
|
|
1043
|
+
...resolveMiniSettings(),
|
|
1044
|
+
thinking: "hide",
|
|
1045
|
+
turn_summary: "hide",
|
|
1046
|
+
})
|
|
1047
|
+
|
|
1048
|
+
app.mockInput.pressKey("ARROW_DOWN")
|
|
1049
|
+
app.mockInput.pressKey("ARROW_DOWN")
|
|
1050
|
+
app.mockInput.pressKey("ARROW_RIGHT")
|
|
1051
|
+
await app.renderOnce()
|
|
1052
|
+
expect(settings().splash).toBe("hide")
|
|
1053
|
+
|
|
1054
|
+
app.mockInput.pressKey("ARROW_DOWN")
|
|
1055
|
+
app.mockInput.pressKey("ARROW_RIGHT")
|
|
1056
|
+
await app.renderOnce()
|
|
1057
|
+
expect(settings().mono).toBe(true)
|
|
1058
|
+
await app.mockInput.typeText("spinner")
|
|
1059
|
+
await app.renderOnce()
|
|
1060
|
+
expect(app.captureCharFrame()).toContain("soft slide")
|
|
1061
|
+
for (const [key, value] of [
|
|
1062
|
+
["ARROW_RIGHT", "block-soft-sweep"],
|
|
1063
|
+
["ARROW_LEFT", "block-soft-slide"],
|
|
1064
|
+
["ARROW_LEFT", "seed"],
|
|
1065
|
+
["ARROW_RIGHT", "block-soft-slide"],
|
|
1066
|
+
["ARROW_RIGHT", "block-soft-sweep"],
|
|
1067
|
+
["ARROW_RIGHT", "block-low-comet"],
|
|
1068
|
+
["ARROW_RIGHT", "block-low-duet"],
|
|
1069
|
+
] as const) {
|
|
1070
|
+
app.mockInput.pressKey(key)
|
|
1071
|
+
await app.renderOnce()
|
|
1072
|
+
expect(settings().work_spinner).toBe(value)
|
|
1073
|
+
const row = app
|
|
1074
|
+
.captureCharFrame()
|
|
1075
|
+
.split("\n")
|
|
1076
|
+
.find((line) => line.includes("Work"))!
|
|
1077
|
+
expect((mono ? SEED_MONO : WORK_SPINNERS[value]).frames).toContain(Array.from(row.trimStart())[0]!)
|
|
1078
|
+
}
|
|
1079
|
+
setSettings((current) => ({ ...current, work_spinner: "quadrant-orbit" }))
|
|
1080
|
+
app.resize(24, 8)
|
|
1081
|
+
await app.renderOnce()
|
|
1082
|
+
await app.renderOnce()
|
|
1083
|
+
expect(app.captureCharFrame()).toContain("quadrant orbit")
|
|
1084
|
+
setAnimations(false)
|
|
1085
|
+
await app.renderOnce()
|
|
1086
|
+
const row = app
|
|
1087
|
+
.captureCharFrame()
|
|
1088
|
+
.split("\n")
|
|
1089
|
+
.find((line) => line.includes("quadrant orbit"))!
|
|
1090
|
+
expect(row.trimStart()).toStartWith(mono ? "* " : "\u25aa ")
|
|
1091
|
+
await app.renderer.idle()
|
|
1092
|
+
} finally {
|
|
1093
|
+
app.renderer.destroy()
|
|
1094
|
+
}
|
|
1095
|
+
})
|
|
1096
|
+
|
|
1097
|
+
test("direct command panel shows subagent entry when available", async () => {
|
|
1098
|
+
const [commands] = createSignal<RunCommand[] | undefined>([])
|
|
1099
|
+
const [subagents] = createSignal([subagent({ sessionID: "s-1", label: "Explore", description: "Inspect auth flow" })])
|
|
1100
|
+
const [variants] = createSignal<string[]>([])
|
|
1101
|
+
|
|
1102
|
+
const app = await testRender(
|
|
1103
|
+
() => (
|
|
1104
|
+
<box width={100} height={RUN_COMMAND_PANEL_ROWS}>
|
|
1105
|
+
<RunCommandMenuBody
|
|
1106
|
+
theme={() => RUN_THEME_FALLBACK.footer}
|
|
1107
|
+
commands={commands}
|
|
1108
|
+
subagents={subagents}
|
|
1109
|
+
queued={() => []}
|
|
1110
|
+
variants={variants}
|
|
1111
|
+
variantCycle="ctrl+t"
|
|
1112
|
+
onClose={() => {}}
|
|
1113
|
+
onAgent={() => {}}
|
|
1114
|
+
onModel={() => {}}
|
|
1115
|
+
onEditor={() => {}}
|
|
1116
|
+
onSubagent={() => {}}
|
|
1117
|
+
onQueued={() => {}}
|
|
1118
|
+
onVariant={() => {}}
|
|
1119
|
+
onVariantCycle={() => {}}
|
|
1120
|
+
onStatus={() => {}}
|
|
1121
|
+
onSettings={() => {}}
|
|
1122
|
+
onCommand={() => {}}
|
|
1123
|
+
onNew={() => {}}
|
|
1124
|
+
onExit={() => {}}
|
|
1125
|
+
/>
|
|
1126
|
+
</box>
|
|
1127
|
+
),
|
|
1128
|
+
{
|
|
1129
|
+
width: 100,
|
|
1130
|
+
height: RUN_COMMAND_PANEL_ROWS,
|
|
1131
|
+
},
|
|
1132
|
+
)
|
|
1133
|
+
|
|
1134
|
+
try {
|
|
1135
|
+
await app.renderOnce()
|
|
1136
|
+
const frame = app.captureCharFrame()
|
|
1137
|
+
|
|
1138
|
+
expect(frame).toContain("View subagents")
|
|
1139
|
+
expect(frame).toContain("1 active")
|
|
1140
|
+
} finally {
|
|
1141
|
+
app.renderer.destroy()
|
|
1142
|
+
}
|
|
1143
|
+
})
|
|
1144
|
+
|
|
1145
|
+
test("direct command panel keeps completed subagents available", async () => {
|
|
1146
|
+
const [commands] = createSignal<RunCommand[] | undefined>([])
|
|
1147
|
+
const [subagents] = createSignal([
|
|
1148
|
+
subagent({ sessionID: "s-1", label: "Explore", description: "Inspect auth flow", status: "completed" }),
|
|
1149
|
+
])
|
|
1150
|
+
const [variants] = createSignal<string[]>([])
|
|
1151
|
+
|
|
1152
|
+
const app = await testRender(
|
|
1153
|
+
() => (
|
|
1154
|
+
<box width={100} height={RUN_COMMAND_PANEL_ROWS}>
|
|
1155
|
+
<RunCommandMenuBody
|
|
1156
|
+
theme={() => RUN_THEME_FALLBACK.footer}
|
|
1157
|
+
commands={commands}
|
|
1158
|
+
subagents={subagents}
|
|
1159
|
+
queued={() => []}
|
|
1160
|
+
variants={variants}
|
|
1161
|
+
variantCycle="ctrl+t"
|
|
1162
|
+
onClose={() => {}}
|
|
1163
|
+
onAgent={() => {}}
|
|
1164
|
+
onModel={() => {}}
|
|
1165
|
+
onEditor={() => {}}
|
|
1166
|
+
onSubagent={() => {}}
|
|
1167
|
+
onQueued={() => {}}
|
|
1168
|
+
onVariant={() => {}}
|
|
1169
|
+
onVariantCycle={() => {}}
|
|
1170
|
+
onStatus={() => {}}
|
|
1171
|
+
onSettings={() => {}}
|
|
1172
|
+
onCommand={() => {}}
|
|
1173
|
+
onNew={() => {}}
|
|
1174
|
+
onExit={() => {}}
|
|
1175
|
+
/>
|
|
1176
|
+
</box>
|
|
1177
|
+
),
|
|
1178
|
+
{
|
|
1179
|
+
width: 100,
|
|
1180
|
+
height: RUN_COMMAND_PANEL_ROWS,
|
|
1181
|
+
},
|
|
1182
|
+
)
|
|
1183
|
+
|
|
1184
|
+
try {
|
|
1185
|
+
await app.renderOnce()
|
|
1186
|
+
const frame = app.captureCharFrame()
|
|
1187
|
+
|
|
1188
|
+
expect(frame).toContain("View subagents")
|
|
1189
|
+
expect(frame).toContain("1 recent")
|
|
1190
|
+
} finally {
|
|
1191
|
+
app.renderer.destroy()
|
|
1192
|
+
}
|
|
1193
|
+
})
|
|
1194
|
+
|
|
1195
|
+
test("direct subagent panel toggles between active and inactive subagents", async () => {
|
|
1196
|
+
const [tabs] = createSignal([
|
|
1197
|
+
subagent({ sessionID: "s-1", label: "Explore", description: "Inspect auth flow" }),
|
|
1198
|
+
subagent({ sessionID: "s-2", label: "General", description: "Write migration plan", status: "completed" }),
|
|
1199
|
+
])
|
|
1200
|
+
const [current] = createSignal<string | undefined>("s-1")
|
|
1201
|
+
let rows = 0
|
|
1202
|
+
|
|
1203
|
+
const app = await testRender(
|
|
1204
|
+
() => (
|
|
1205
|
+
<box width={100} height={RUN_SUBAGENT_PANEL_ROWS}>
|
|
1206
|
+
<RunSubagentSelectBody
|
|
1207
|
+
theme={() => RUN_THEME_FALLBACK.footer}
|
|
1208
|
+
tabs={tabs}
|
|
1209
|
+
current={current}
|
|
1210
|
+
onClose={() => {}}
|
|
1211
|
+
onSelect={() => {}}
|
|
1212
|
+
onRows={(value) => {
|
|
1213
|
+
rows = value
|
|
1214
|
+
}}
|
|
1215
|
+
/>
|
|
1216
|
+
</box>
|
|
1217
|
+
),
|
|
1218
|
+
{
|
|
1219
|
+
width: 100,
|
|
1220
|
+
height: RUN_SUBAGENT_PANEL_ROWS + 1,
|
|
1221
|
+
},
|
|
1222
|
+
)
|
|
1223
|
+
|
|
1224
|
+
try {
|
|
1225
|
+
await app.renderOnce()
|
|
1226
|
+
const frame = app.captureCharFrame()
|
|
1227
|
+
const list = panelMenu(app.renderer.root)
|
|
1228
|
+
|
|
1229
|
+
expect(frame).toContain("Select subagent")
|
|
1230
|
+
expect(frame).toContain("Inspect auth flow")
|
|
1231
|
+
expect(frame).not.toContain("Write migration plan")
|
|
1232
|
+
expect(frame).not.toContain("done")
|
|
1233
|
+
expect(frame).toContain("tab show inactive")
|
|
1234
|
+
expect(frame).not.toContain("┌")
|
|
1235
|
+
expect(frame).not.toContain("┃")
|
|
1236
|
+
expectPaletteList(list, 0)
|
|
1237
|
+
expect(rows).toBe(7)
|
|
1238
|
+
|
|
1239
|
+
app.mockInput.pressKey("TAB")
|
|
1240
|
+
await app.renderOnce()
|
|
1241
|
+
const inactive = app.captureCharFrame()
|
|
1242
|
+
|
|
1243
|
+
expect(inactive).not.toContain("Inspect auth flow")
|
|
1244
|
+
expect(inactive).toContain("Write migration plan")
|
|
1245
|
+
expect(inactive).toContain("done")
|
|
1246
|
+
expect(inactive).toContain("tab show active")
|
|
1247
|
+
} finally {
|
|
1248
|
+
app.renderer.destroy()
|
|
1249
|
+
}
|
|
1250
|
+
})
|
|
1251
|
+
|
|
1252
|
+
test("direct subagent panel closes when moving up from the first item", async () => {
|
|
1253
|
+
const [tabs] = createSignal([
|
|
1254
|
+
subagent({ sessionID: "s-1", label: "Explore", description: "Inspect auth flow" }),
|
|
1255
|
+
subagent({ sessionID: "s-2", label: "General", description: "Write migration plan" }),
|
|
1256
|
+
])
|
|
1257
|
+
const [current] = createSignal<string | undefined>()
|
|
1258
|
+
let closed = 0
|
|
1259
|
+
|
|
1260
|
+
const app = await testRender(
|
|
1261
|
+
() => (
|
|
1262
|
+
<box width={100} height={RUN_SUBAGENT_PANEL_ROWS}>
|
|
1263
|
+
<RunSubagentSelectBody
|
|
1264
|
+
theme={() => RUN_THEME_FALLBACK.footer}
|
|
1265
|
+
tabs={tabs}
|
|
1266
|
+
current={current}
|
|
1267
|
+
onClose={() => closed++}
|
|
1268
|
+
onSelect={() => {}}
|
|
1269
|
+
/>
|
|
1270
|
+
</box>
|
|
1271
|
+
),
|
|
1272
|
+
{ width: 100, height: RUN_SUBAGENT_PANEL_ROWS },
|
|
1273
|
+
)
|
|
1274
|
+
|
|
1275
|
+
try {
|
|
1276
|
+
await app.renderOnce()
|
|
1277
|
+
app.mockInput.pressKey("ARROW_DOWN")
|
|
1278
|
+
app.mockInput.pressKey("ARROW_UP")
|
|
1279
|
+
expect(closed).toBe(0)
|
|
1280
|
+
|
|
1281
|
+
app.mockInput.pressKey("ARROW_UP")
|
|
1282
|
+
expect(closed).toBe(1)
|
|
1283
|
+
} finally {
|
|
1284
|
+
app.renderer.destroy()
|
|
1285
|
+
}
|
|
1286
|
+
})
|
|
1287
|
+
|
|
1288
|
+
test.each(["queue", "steer"] as const)("direct footer toggles and deletes pending %s prompts", async (delivery) => {
|
|
1289
|
+
const actions: string[] = []
|
|
1290
|
+
const app = await renderFooter({
|
|
1291
|
+
height: RUN_SUBAGENT_PANEL_ROWS,
|
|
1292
|
+
state: { phase: "running" },
|
|
1293
|
+
queuedPrompts: [{ messageID: "m-1", prompt: { text: "follow up", parts: [] }, delivery }],
|
|
1294
|
+
onQueuedPromptAction: async (action, inboxID) => {
|
|
1295
|
+
actions.push(`${action}:${inboxID}`)
|
|
1296
|
+
app.setQueuedPrompts((prompts) =>
|
|
1297
|
+
action === "cancel" ? [] : prompts.map((prompt) => ({ ...prompt, delivery: action })),
|
|
1298
|
+
)
|
|
1299
|
+
},
|
|
1300
|
+
})
|
|
1301
|
+
|
|
1302
|
+
try {
|
|
1303
|
+
await app.renderOnce()
|
|
1304
|
+
expect(app.captureCharFrame()).toContain("ctrl+x q 1 pending")
|
|
1305
|
+
app.mockInput.pressKey("ARROW_DOWN")
|
|
1306
|
+
await app.renderOnce()
|
|
1307
|
+
expect(app.captureCharFrame()).not.toContain("Pending prompts")
|
|
1308
|
+
|
|
1309
|
+
app.mockInput.pressKey("x", { ctrl: true })
|
|
1310
|
+
app.mockInput.pressKey("q")
|
|
1311
|
+
await app.renderOnce()
|
|
1312
|
+
const frame = app.captureCharFrame()
|
|
1313
|
+
const list = panelMenu(app.renderer.root)
|
|
1314
|
+
expect(frame).toContain("Pending prompts")
|
|
1315
|
+
expect(frame).toContain("follow up")
|
|
1316
|
+
expect(frame).toContain(delivery === "queue" ? "queued" : "steering")
|
|
1317
|
+
expect(frame).toContain(`enter ${delivery === "queue" ? "steer" : "queue"} · ctrl+d delete · ctrl+u undo`)
|
|
1318
|
+
expect(frame).not.toContain("┌")
|
|
1319
|
+
expect(frame).not.toContain("┃")
|
|
1320
|
+
expectPaletteList(list, 0)
|
|
1321
|
+
app.mockInput.pressEnter()
|
|
1322
|
+
await Bun.sleep(0)
|
|
1323
|
+
await app.renderOnce()
|
|
1324
|
+
expect(actions).toEqual([`${delivery === "queue" ? "steer" : "queue"}:m-1`])
|
|
1325
|
+
expect(app.captureCharFrame()).toContain("1 pending")
|
|
1326
|
+
|
|
1327
|
+
app.mockInput.pressKey("x", { ctrl: true })
|
|
1328
|
+
app.mockInput.pressKey("q")
|
|
1329
|
+
await app.renderOnce()
|
|
1330
|
+
expect(app.captureCharFrame()).toContain(delivery === "queue" ? "steering" : "queued")
|
|
1331
|
+
expect(app.captureCharFrame()).toContain(delivery === "queue" ? "enter queue" : "enter steer")
|
|
1332
|
+
app.mockInput.pressKey("d", { ctrl: true })
|
|
1333
|
+
await Bun.sleep(0)
|
|
1334
|
+
await app.renderOnce()
|
|
1335
|
+
expect(actions.at(-1)).toBe("cancel:m-1")
|
|
1336
|
+
expect(app.captureCharFrame()).not.toContain("Pending prompts")
|
|
1337
|
+
expect(app.captureCharFrame()).not.toContain("1 pending")
|
|
1338
|
+
} finally {
|
|
1339
|
+
app.cleanup()
|
|
1340
|
+
}
|
|
1341
|
+
})
|
|
1342
|
+
|
|
1343
|
+
test("undo appends a pending prompt to the draft", async () => {
|
|
1344
|
+
const actions: string[] = []
|
|
1345
|
+
const submitted: RunPrompt[] = []
|
|
1346
|
+
const queued: FooterQueuedPrompt = {
|
|
1347
|
+
messageID: "m-1",
|
|
1348
|
+
prompt: {
|
|
1349
|
+
messageID: "m-1",
|
|
1350
|
+
text: "look at main.ts",
|
|
1351
|
+
parts: [],
|
|
1352
|
+
},
|
|
1353
|
+
delivery: "queue",
|
|
1354
|
+
}
|
|
1355
|
+
const app = await renderFooter({
|
|
1356
|
+
queuedPrompts: [queued],
|
|
1357
|
+
onSubmit: (prompt) => {
|
|
1358
|
+
submitted.push(prompt)
|
|
1359
|
+
return true
|
|
1360
|
+
},
|
|
1361
|
+
onQueuedPromptAction: async (action, inboxID) => {
|
|
1362
|
+
actions.push(`${action}:${inboxID}`)
|
|
1363
|
+
app.setQueuedPrompts([])
|
|
1364
|
+
},
|
|
1365
|
+
})
|
|
1366
|
+
try {
|
|
1367
|
+
await app.renderOnce()
|
|
1368
|
+
await app.mockInput.typeText("existing draft")
|
|
1369
|
+
app.mockInput.pressKey("x", { ctrl: true })
|
|
1370
|
+
app.mockInput.pressKey("q")
|
|
1371
|
+
await app.renderOnce()
|
|
1372
|
+
app.mockInput.pressKey("u", { ctrl: true })
|
|
1373
|
+
await Bun.sleep(0)
|
|
1374
|
+
await app.renderOnce()
|
|
1375
|
+
expect(actions).toEqual(["cancel:m-1"])
|
|
1376
|
+
expect(app.captureCharFrame()).toContain("existing draft")
|
|
1377
|
+
expect(app.captureCharFrame()).toContain("look at main.ts")
|
|
1378
|
+
expect(app.captureCharFrame()).not.toContain("Pending prompts")
|
|
1379
|
+
await app.waitFor(() => app.renderer.currentFocusedEditor instanceof TextareaRenderable)
|
|
1380
|
+
app.mockInput.pressEnter()
|
|
1381
|
+
await Bun.sleep(0)
|
|
1382
|
+
await app.renderOnce()
|
|
1383
|
+
expect(submitted).toMatchObject([{ text: "existing draft\n\nlook at main.ts" }])
|
|
1384
|
+
expect(submitted[0].messageID).toBeUndefined()
|
|
1385
|
+
} finally {
|
|
1386
|
+
app.cleanup()
|
|
1387
|
+
}
|
|
1388
|
+
})
|
|
1389
|
+
|
|
1390
|
+
test("undo leaves the queue and input alone when cancellation fails", async () => {
|
|
1391
|
+
const statuses: string[] = []
|
|
1392
|
+
const app = await renderFooter({
|
|
1393
|
+
queuedPrompts: [{ messageID: "m-1", prompt: { text: "still queued", parts: [] }, delivery: "queue" }],
|
|
1394
|
+
onStatus: (status) => statuses.push(status),
|
|
1395
|
+
onQueuedPromptAction: async () => {
|
|
1396
|
+
throw new Error("cancel failed")
|
|
1397
|
+
},
|
|
1398
|
+
})
|
|
1399
|
+
try {
|
|
1400
|
+
await app.renderOnce()
|
|
1401
|
+
app.mockInput.pressKey("x", { ctrl: true })
|
|
1402
|
+
app.mockInput.pressKey("q")
|
|
1403
|
+
await app.renderOnce()
|
|
1404
|
+
app.mockInput.pressKey("u", { ctrl: true })
|
|
1405
|
+
await Bun.sleep(0)
|
|
1406
|
+
await app.renderOnce()
|
|
1407
|
+
expect(statuses.at(-1)).toContain("failed to undo pending prompt: cancel failed")
|
|
1408
|
+
expect(app.captureCharFrame()).toContain("Pending prompts")
|
|
1409
|
+
app.mockInput.pressKey("ESCAPE")
|
|
1410
|
+
await app.renderOnce()
|
|
1411
|
+
expect(app.captureCharFrame()).not.toContain("still queued")
|
|
1412
|
+
} finally {
|
|
1413
|
+
app.cleanup()
|
|
1414
|
+
}
|
|
1415
|
+
})
|
|
1416
|
+
|
|
1417
|
+
test("undo retains mentioned files when the prompt is sent again", async () => {
|
|
1418
|
+
const submitted: RunPrompt[] = []
|
|
1419
|
+
const app = await renderFooter({
|
|
1420
|
+
queuedPrompts: [
|
|
1421
|
+
{
|
|
1422
|
+
messageID: "m-1",
|
|
1423
|
+
delivery: "queue",
|
|
1424
|
+
prompt: {
|
|
1425
|
+
messageID: "m-1",
|
|
1426
|
+
text: "inspect @src/main.ts please",
|
|
1427
|
+
parts: [
|
|
1428
|
+
{
|
|
1429
|
+
type: "file",
|
|
1430
|
+
url: "file:///src/main.ts",
|
|
1431
|
+
filename: "main.ts",
|
|
1432
|
+
source: { type: "file", path: "src/main.ts", text: { start: 8, end: 20, value: "@src/main.ts" } },
|
|
1433
|
+
},
|
|
1434
|
+
],
|
|
1435
|
+
},
|
|
1436
|
+
},
|
|
1437
|
+
],
|
|
1438
|
+
onQueuedPromptAction: async () => {
|
|
1439
|
+
// A permission can unmount the composer while the cancellation is in flight.
|
|
1440
|
+
app.setView({
|
|
1441
|
+
type: "permission",
|
|
1442
|
+
request: { id: "per_undo", sessionID: "ses_child", action: "read", resources: ["src/index.ts"] },
|
|
1443
|
+
})
|
|
1444
|
+
app.setQueuedPrompts([])
|
|
1445
|
+
},
|
|
1446
|
+
onSubmit: (prompt) => {
|
|
1447
|
+
submitted.push(prompt)
|
|
1448
|
+
return true
|
|
1449
|
+
},
|
|
1450
|
+
})
|
|
1451
|
+
try {
|
|
1452
|
+
await app.renderOnce()
|
|
1453
|
+
await app.mockInput.pasteBracketedText("\t👨👩👧நி\f")
|
|
1454
|
+
await Bun.sleep(0)
|
|
1455
|
+
app.mockInput.pressKey("x", { ctrl: true })
|
|
1456
|
+
app.mockInput.pressKey("q")
|
|
1457
|
+
await app.renderOnce()
|
|
1458
|
+
app.mockInput.pressKey("u", { ctrl: true })
|
|
1459
|
+
await Bun.sleep(0)
|
|
1460
|
+
app.setView({ type: "prompt" })
|
|
1461
|
+
await Bun.sleep(0)
|
|
1462
|
+
await app.renderOnce()
|
|
1463
|
+
expect(app.captureCharFrame()).toContain("inspect @src/main.ts please")
|
|
1464
|
+
await app.mockInput.typeText("!")
|
|
1465
|
+
app.mockInput.pressEnter()
|
|
1466
|
+
await Bun.sleep(0)
|
|
1467
|
+
expect(submitted).toMatchObject([
|
|
1468
|
+
{ text: "\t👨👩👧நி\f\n\ninspect @src/main.ts please!", parts: [{ type: "file", url: "file:///src/main.ts" }] },
|
|
1469
|
+
])
|
|
1470
|
+
expect(submitted[0].messageID).toBeUndefined()
|
|
1471
|
+
} finally {
|
|
1472
|
+
app.cleanup()
|
|
1473
|
+
}
|
|
1474
|
+
})
|
|
1475
|
+
|
|
1476
|
+
test("an undone chip deletion keeps the chip's file", async () => {
|
|
1477
|
+
const submitted: RunPrompt[] = []
|
|
1478
|
+
const file: RunPromptPart = {
|
|
1479
|
+
type: "file",
|
|
1480
|
+
url: "file:///src/main.ts",
|
|
1481
|
+
filename: "main.ts",
|
|
1482
|
+
source: { type: "file", path: "src/main.ts", text: { start: 8, end: 20, value: "@src/main.ts" } },
|
|
1483
|
+
}
|
|
1484
|
+
const app = await renderFooter({
|
|
1485
|
+
queuedPrompts: [
|
|
1486
|
+
{ messageID: "m-1", delivery: "queue", prompt: { text: "inspect @src/main.ts please", parts: [file] } },
|
|
1487
|
+
],
|
|
1488
|
+
onQueuedPromptAction: async () => {
|
|
1489
|
+
app.setQueuedPrompts([])
|
|
1490
|
+
},
|
|
1491
|
+
onSubmit: (prompt) => {
|
|
1492
|
+
submitted.push(prompt)
|
|
1493
|
+
return true
|
|
1494
|
+
},
|
|
1495
|
+
})
|
|
1496
|
+
try {
|
|
1497
|
+
await app.renderOnce()
|
|
1498
|
+
app.mockInput.pressKey("x", { ctrl: true })
|
|
1499
|
+
app.mockInput.pressKey("q")
|
|
1500
|
+
await app.renderOnce()
|
|
1501
|
+
app.mockInput.pressKey("u", { ctrl: true })
|
|
1502
|
+
await Bun.sleep(0)
|
|
1503
|
+
const text = () => (app.renderer.currentFocusedEditor as TextareaRenderable | null)?.plainText
|
|
1504
|
+
await app.waitFor(() => text() === "inspect @src/main.ts please")
|
|
1505
|
+
app.mockInput.pressKey("u", { ctrl: true })
|
|
1506
|
+
await app.waitFor(() => text() === "")
|
|
1507
|
+
app.mockInput.pressKey("z", { super: true })
|
|
1508
|
+
await app.waitFor(() => text() === "inspect @src/main.ts please")
|
|
1509
|
+
app.mockInput.pressEnter()
|
|
1510
|
+
await Bun.sleep(0)
|
|
1511
|
+
expect(submitted).toMatchObject([{ text: "inspect @src/main.ts please", parts: [file] }])
|
|
1512
|
+
} finally {
|
|
1513
|
+
app.cleanup()
|
|
1514
|
+
}
|
|
1515
|
+
})
|
|
1516
|
+
|
|
1517
|
+
test("direct footer steers the oldest queued prompt from an empty composer", async () => {
|
|
1518
|
+
const steered: string[] = []
|
|
1519
|
+
const app = await renderFooter({
|
|
1520
|
+
queuedPrompts: [
|
|
1521
|
+
{ messageID: "m-steering", prompt: { text: "already steering", parts: [] }, delivery: "steer" },
|
|
1522
|
+
{ messageID: "m-1", prompt: { text: "first", parts: [] }, delivery: "queue" },
|
|
1523
|
+
{ messageID: "m-2", prompt: { text: "second", parts: [] }, delivery: "queue" },
|
|
1524
|
+
],
|
|
1525
|
+
onQueuedPromptAction: async (action, inboxID) => {
|
|
1526
|
+
if (action === "steer") steered.push(inboxID)
|
|
1527
|
+
},
|
|
1528
|
+
})
|
|
1529
|
+
|
|
1530
|
+
try {
|
|
1531
|
+
await app.renderOnce()
|
|
1532
|
+
app.mockInput.pressKey("x", { ctrl: true })
|
|
1533
|
+
app.mockInput.pressEnter()
|
|
1534
|
+
await Bun.sleep(0)
|
|
1535
|
+
expect(steered).toEqual([])
|
|
1536
|
+
app.mockInput.pressEnter()
|
|
1537
|
+
await Bun.sleep(0)
|
|
1538
|
+
expect(steered).toEqual(["m-1"])
|
|
1539
|
+
app.setQueuedPrompts((prompts) => prompts.filter((prompt) => prompt.delivery === "steer"))
|
|
1540
|
+
app.mockInput.pressEnter()
|
|
1541
|
+
await Bun.sleep(0)
|
|
1542
|
+
expect(steered).toEqual(["m-1"])
|
|
1543
|
+
} finally {
|
|
1544
|
+
app.cleanup()
|
|
1545
|
+
}
|
|
1546
|
+
})
|
|
1547
|
+
|
|
1548
|
+
test("direct footer preserves steer and queue submission shortcuts while busy", async () => {
|
|
1549
|
+
const submitted: RunPrompt[] = []
|
|
1550
|
+
const app = await renderFooter({
|
|
1551
|
+
state: { phase: "running" },
|
|
1552
|
+
onSubmit: (prompt) => {
|
|
1553
|
+
submitted.push(prompt)
|
|
1554
|
+
return true
|
|
1555
|
+
},
|
|
1556
|
+
})
|
|
1557
|
+
|
|
1558
|
+
try {
|
|
1559
|
+
await app.renderOnce()
|
|
1560
|
+
await app.mockInput.typeText("steer now")
|
|
1561
|
+
app.mockInput.pressEnter()
|
|
1562
|
+
await Bun.sleep(0)
|
|
1563
|
+
await app.mockInput.typeText("queue later")
|
|
1564
|
+
app.mockInput.pressKey("x", { ctrl: true })
|
|
1565
|
+
app.mockInput.pressEnter()
|
|
1566
|
+
await Bun.sleep(0)
|
|
1567
|
+
expect(submitted).toEqual([
|
|
1568
|
+
{ text: "steer now", parts: [], delivery: "steer" },
|
|
1569
|
+
{ text: "queue later", parts: [], delivery: "queue" },
|
|
1570
|
+
])
|
|
1571
|
+
} finally {
|
|
1572
|
+
app.cleanup()
|
|
1573
|
+
}
|
|
1574
|
+
})
|
|
1575
|
+
|
|
1576
|
+
test("direct footer does not steer queued work on a double submit", async () => {
|
|
1577
|
+
const submitted: RunPrompt[] = []
|
|
1578
|
+
const steered: string[] = []
|
|
1579
|
+
const app = await renderFooter({
|
|
1580
|
+
queuedPrompts: [{ messageID: "m-1", prompt: { text: "queued", parts: [] }, delivery: "queue" }],
|
|
1581
|
+
onSubmit: async (prompt) => {
|
|
1582
|
+
submitted.push(prompt)
|
|
1583
|
+
await Bun.sleep(10)
|
|
1584
|
+
return true
|
|
1585
|
+
},
|
|
1586
|
+
onQueuedPromptAction: async (action, inboxID) => {
|
|
1587
|
+
if (action === "steer") steered.push(inboxID)
|
|
1588
|
+
},
|
|
1589
|
+
})
|
|
1590
|
+
|
|
1591
|
+
try {
|
|
1592
|
+
await app.renderOnce()
|
|
1593
|
+
await app.mockInput.typeText("send once")
|
|
1594
|
+
app.mockInput.pressEnter()
|
|
1595
|
+
app.mockInput.pressEnter()
|
|
1596
|
+
await Bun.sleep(20)
|
|
1597
|
+
expect(submitted).toHaveLength(1)
|
|
1598
|
+
expect(steered).toEqual([])
|
|
1599
|
+
} finally {
|
|
1600
|
+
app.cleanup()
|
|
1601
|
+
}
|
|
1602
|
+
})
|
|
1603
|
+
|
|
1604
|
+
test("direct footer rejects local commands submitted with the queue shortcut", async () => {
|
|
1605
|
+
const submitted: RunPrompt[] = []
|
|
1606
|
+
const statuses: string[] = []
|
|
1607
|
+
const app = await renderFooter({
|
|
1608
|
+
onSubmit: (prompt) => {
|
|
1609
|
+
submitted.push(prompt)
|
|
1610
|
+
return true
|
|
1611
|
+
},
|
|
1612
|
+
onStatus: (status) => statuses.push(status),
|
|
1613
|
+
})
|
|
1614
|
+
|
|
1615
|
+
try {
|
|
1616
|
+
await app.renderOnce()
|
|
1617
|
+
await app.mockInput.typeText("/settings ")
|
|
1618
|
+
app.mockInput.pressKey("x", { ctrl: true })
|
|
1619
|
+
app.mockInput.pressEnter()
|
|
1620
|
+
await Bun.sleep(0)
|
|
1621
|
+
expect(submitted).toEqual([])
|
|
1622
|
+
expect(statuses).toContain("this prompt cannot be queued")
|
|
1623
|
+
} finally {
|
|
1624
|
+
app.cleanup()
|
|
1625
|
+
}
|
|
1626
|
+
})
|
|
1627
|
+
|
|
1628
|
+
// OpenTUI currently crashes Bun in the full `test/cli/run` directory run here.
|
|
1629
|
+
// Re-enable after the upstream OpenTUI fix lands in this repo.
|
|
1630
|
+
test.skip("direct footer recreates the frame across command panel transitions", async () => {
|
|
1631
|
+
const app = await renderFooter()
|
|
1632
|
+
|
|
1633
|
+
try {
|
|
1634
|
+
await app.renderOnce()
|
|
1635
|
+
|
|
1636
|
+
for (let index = 0; index < 3; index++) {
|
|
1637
|
+
const composerFrame = footerComposerFrame(app.renderer.root)
|
|
1638
|
+
app.mockInput.pressKey("p", { ctrl: true })
|
|
1639
|
+
await app.renderOnce()
|
|
1640
|
+
|
|
1641
|
+
expect(app.captureCharFrame()).toContain("Commands")
|
|
1642
|
+
expect(footerComposerFrame(app.renderer.root)).not.toBe(composerFrame)
|
|
1643
|
+
app.mockInput.pressKey("c", { ctrl: true })
|
|
1644
|
+
await app.renderOnce()
|
|
1645
|
+
expect(app.captureCharFrame()).not.toContain("Commands")
|
|
1646
|
+
expect(app.captureCharFrame()).not.toContain("┃")
|
|
1647
|
+
expect(app.captureCharFrame()).not.toContain("█")
|
|
1648
|
+
}
|
|
1649
|
+
} finally {
|
|
1650
|
+
app.cleanup()
|
|
1651
|
+
}
|
|
1652
|
+
})
|
|
1653
|
+
|
|
1654
|
+
test.skip("direct footer dispatches leader variant binding only when leader is registered", async () => {
|
|
1655
|
+
const calls: string[] = []
|
|
1656
|
+
const app = await renderFooter({
|
|
1657
|
+
tuiConfig: createTuiResolvedConfig({ keybinds: { leader: "ctrl+x", "variant.cycle": "<leader>t" } }),
|
|
1658
|
+
onCycle: () => calls.push("cycle"),
|
|
1659
|
+
})
|
|
1660
|
+
|
|
1661
|
+
try {
|
|
1662
|
+
await app.renderOnce()
|
|
1663
|
+
app.mockInput.pressKey("t")
|
|
1664
|
+
expect(calls).toEqual([])
|
|
1665
|
+
|
|
1666
|
+
app.mockInput.pressKey("x", { ctrl: true })
|
|
1667
|
+
app.mockInput.pressKey("t")
|
|
1668
|
+
expect(calls).toEqual(["cycle"])
|
|
1669
|
+
} finally {
|
|
1670
|
+
app.cleanup()
|
|
1671
|
+
}
|
|
1672
|
+
})
|
|
1673
|
+
|
|
1674
|
+
test("direct footer keeps leader variant binding inactive when leader is disabled", async () => {
|
|
1675
|
+
const calls: string[] = []
|
|
1676
|
+
const app = await renderFooter({
|
|
1677
|
+
tuiConfig: createTuiResolvedConfig({ keybinds: { leader: "none", "variant.cycle": "<leader>t" } }),
|
|
1678
|
+
onCycle: () => calls.push("cycle"),
|
|
1679
|
+
})
|
|
1680
|
+
|
|
1681
|
+
try {
|
|
1682
|
+
await app.renderOnce()
|
|
1683
|
+
app.mockInput.pressKey("t")
|
|
1684
|
+
app.mockInput.pressKey("x", { ctrl: true })
|
|
1685
|
+
app.mockInput.pressKey("t")
|
|
1686
|
+
|
|
1687
|
+
expect(calls).toEqual([])
|
|
1688
|
+
} finally {
|
|
1689
|
+
app.cleanup()
|
|
1690
|
+
}
|
|
1691
|
+
})
|
|
1692
|
+
|
|
1693
|
+
test("direct footer submits slash autocomplete selections without dispatching shell completions", async () => {
|
|
1694
|
+
const submits: RunPrompt[] = []
|
|
1695
|
+
const app = await renderFooter({
|
|
1696
|
+
commands: [command({ name: "review", description: "Review code" })],
|
|
1697
|
+
onSubmit(prompt) {
|
|
1698
|
+
submits.push(prompt)
|
|
1699
|
+
return true
|
|
1700
|
+
},
|
|
1701
|
+
})
|
|
1702
|
+
|
|
1703
|
+
try {
|
|
1704
|
+
await app.renderOnce()
|
|
1705
|
+
"/rev".split("").forEach((key) => app.mockInput.pressKey(key))
|
|
1706
|
+
await app.renderOnce()
|
|
1707
|
+
app.mockInput.pressEnter()
|
|
1708
|
+
await app.renderOnce()
|
|
1709
|
+
|
|
1710
|
+
"/rev".split("").forEach((key) => app.mockInput.pressKey(key))
|
|
1711
|
+
await app.renderOnce()
|
|
1712
|
+
app.mockInput.pressKey("TAB")
|
|
1713
|
+
await app.renderOnce()
|
|
1714
|
+
|
|
1715
|
+
"/re branch".split("").forEach((key) => app.mockInput.pressKey(key))
|
|
1716
|
+
Array.from({ length: 7 }).forEach(() => app.mockInput.pressKey("ARROW_LEFT"))
|
|
1717
|
+
app.mockInput.pressKey("v")
|
|
1718
|
+
await app.renderOnce()
|
|
1719
|
+
app.mockInput.pressEnter()
|
|
1720
|
+
await app.renderOnce()
|
|
1721
|
+
|
|
1722
|
+
"/nx".split("").forEach((key) => app.mockInput.pressKey(key))
|
|
1723
|
+
app.mockInput.pressKey("ARROW_LEFT")
|
|
1724
|
+
app.mockInput.pressKey("e")
|
|
1725
|
+
await app.renderOnce()
|
|
1726
|
+
app.mockInput.pressEnter()
|
|
1727
|
+
await app.renderOnce()
|
|
1728
|
+
|
|
1729
|
+
"/n scratch".split("").forEach((key) => app.mockInput.pressKey(key))
|
|
1730
|
+
Array.from({ length: 8 }).forEach(() => app.mockInput.pressKey("ARROW_LEFT"))
|
|
1731
|
+
app.mockInput.pressKey("e")
|
|
1732
|
+
await app.renderOnce()
|
|
1733
|
+
app.mockInput.pressEnter()
|
|
1734
|
+
await app.renderOnce()
|
|
1735
|
+
|
|
1736
|
+
app.mockInput.pressKey("!")
|
|
1737
|
+
"/settings".split("").forEach((key) => app.mockInput.pressKey(key))
|
|
1738
|
+
await app.renderOnce()
|
|
1739
|
+
app.mockInput.pressEnter()
|
|
1740
|
+
await app.renderOnce()
|
|
1741
|
+
|
|
1742
|
+
expect(submits).toEqual([
|
|
1743
|
+
{ text: "/review ", parts: [], command: { name: "review", arguments: "" }, delivery: "steer" },
|
|
1744
|
+
{ text: "/review ", parts: [], command: { name: "review", arguments: "" }, delivery: "steer" },
|
|
1745
|
+
{ text: "/review branch", parts: [], command: { name: "review", arguments: "branch" }, delivery: "steer" },
|
|
1746
|
+
{ text: "/new ", parts: [], delivery: "steer" },
|
|
1747
|
+
{ text: "/new ", parts: [], delivery: "steer" },
|
|
1748
|
+
])
|
|
1749
|
+
expect(app.renderer.currentFocusedEditor?.plainText).toBe("/settings ")
|
|
1750
|
+
} finally {
|
|
1751
|
+
app.cleanup()
|
|
1752
|
+
}
|
|
1753
|
+
})
|
|
1754
|
+
|
|
1755
|
+
test("direct footer closes settings with ctrl-c instead of arming exit", async () => {
|
|
1756
|
+
const app = await renderFooter({ height: 20 })
|
|
1757
|
+
|
|
1758
|
+
try {
|
|
1759
|
+
await app.renderOnce()
|
|
1760
|
+
"/settings".split("").forEach((key) => app.mockInput.pressKey(key))
|
|
1761
|
+
await app.renderOnce()
|
|
1762
|
+
app.mockInput.pressEnter()
|
|
1763
|
+
await app.renderOnce()
|
|
1764
|
+
expect(app.captureCharFrame()).toContain("Shell")
|
|
1765
|
+
|
|
1766
|
+
app.mockInput.pressKey("c", { ctrl: true })
|
|
1767
|
+
await app.renderOnce()
|
|
1768
|
+
expect(app.captureCharFrame()).not.toContain("Shell")
|
|
1769
|
+
expect(app.renderer.currentFocusedEditor?.plainText).toBe("")
|
|
1770
|
+
} finally {
|
|
1771
|
+
app.cleanup()
|
|
1772
|
+
}
|
|
1773
|
+
})
|
|
1774
|
+
|
|
1775
|
+
test("selectedCommand validates the bound command and refreshes its arguments", () => {
|
|
1776
|
+
expect(selectedCommand("/deploy prod", { name: "deploy", arguments: "" })).toEqual({
|
|
1777
|
+
name: "deploy",
|
|
1778
|
+
arguments: "prod",
|
|
1779
|
+
})
|
|
1780
|
+
expect(selectedCommand("/other", { name: "deploy", arguments: "" })).toBeUndefined()
|
|
1781
|
+
})
|
|
1782
|
+
|
|
1783
|
+
test("direct footer counts queued and steering work while running", async () => {
|
|
1784
|
+
const app = await renderFooter({
|
|
1785
|
+
width: 160,
|
|
1786
|
+
state: { phase: "running" },
|
|
1787
|
+
currentModel: { providerID: "opencode", modelID: "a-model-name-long-enough-to-force-responsive-truncation" },
|
|
1788
|
+
subagents: {
|
|
1789
|
+
tabs: [subagent({ sessionID: "s-1", label: "Explore", description: "Inspect auth flow" })],
|
|
1790
|
+
details: {},
|
|
1791
|
+
permissions: [],
|
|
1792
|
+
forms: [],
|
|
1793
|
+
},
|
|
1794
|
+
queuedPrompts: [
|
|
1795
|
+
{ messageID: "m-queued", prompt: { text: "follow up", parts: [] }, delivery: "queue" },
|
|
1796
|
+
{ messageID: "m-steering", prompt: { text: "steer now", parts: [] }, delivery: "steer" },
|
|
1797
|
+
],
|
|
1798
|
+
})
|
|
1799
|
+
|
|
1800
|
+
try {
|
|
1801
|
+
await app.renderOnce()
|
|
1802
|
+
const frame = app.captureCharFrame()
|
|
1803
|
+
const transparent = RGBA.fromValues(0, 0, 0, 0).toInts()
|
|
1804
|
+
const statusline = footerStatusline(app.renderer.root)
|
|
1805
|
+
expect(frame).toContain("ctrl+x q 2 pending · ↓ 1 subagent · Build")
|
|
1806
|
+
expect(frame).toMatch(/opencode · ctrl\+p menu *$/m)
|
|
1807
|
+
expect(frame).not.toContain("1 agent")
|
|
1808
|
+
expect(statusline.backgroundColor.toInts()).toEqual(transparent)
|
|
1809
|
+
} finally {
|
|
1810
|
+
app.cleanup()
|
|
1811
|
+
}
|
|
1812
|
+
})
|
|
1813
|
+
|
|
1814
|
+
test("direct footer admits the model and variant together before the agent and trailing menu", async () => {
|
|
1815
|
+
for (const expected of [
|
|
1816
|
+
{ width: 12, text: "" },
|
|
1817
|
+
{ width: 13, text: "GPT-5 [xhigh]" },
|
|
1818
|
+
{ width: 19, text: "GPT-5 [xhigh]" },
|
|
1819
|
+
{ width: 20, text: "Plan · GPT-5 [xhigh]" },
|
|
1820
|
+
{ width: 33, text: "Plan · GPT-5 [xhigh]" },
|
|
1821
|
+
{ width: 34, text: "Plan · GPT-5 [xhigh] · ctrl+p menu" },
|
|
1822
|
+
]) {
|
|
1823
|
+
const app = await renderFooter({
|
|
1824
|
+
currentAgent: "Plan",
|
|
1825
|
+
currentVariant: "xhigh",
|
|
1826
|
+
state: { model: "GPT-5" },
|
|
1827
|
+
width: expected.width,
|
|
1828
|
+
})
|
|
1829
|
+
|
|
1830
|
+
try {
|
|
1831
|
+
await app.renderOnce()
|
|
1832
|
+
const statusline = footerStatusline(app.renderer.root)
|
|
1833
|
+
expect(app.captureCharFrame().split("\n")[statusline.y].trimEnd()).toBe(expected.text)
|
|
1834
|
+
expect(statusline.height).toBe(1)
|
|
1835
|
+
} finally {
|
|
1836
|
+
app.cleanup()
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
})
|
|
1840
|
+
|
|
1841
|
+
test.each([16, 20, 24, 32])("status takeovers retain complete instructions at %i columns", async (width) => {
|
|
1842
|
+
for (const mono of [false, true]) {
|
|
1843
|
+
const app = await renderFooter({
|
|
1844
|
+
width,
|
|
1845
|
+
mono,
|
|
1846
|
+
currentVariant: "high",
|
|
1847
|
+
providers: [provider()],
|
|
1848
|
+
currentModel: { providerID: "opencode", modelID: "gpt-5" },
|
|
1849
|
+
state: { exit: 1, usage: { tokens: 12000, percent: 10 } },
|
|
1850
|
+
queuedPrompts: [{ messageID: "queued", prompt: { text: "later", parts: [] }, delivery: "queue" }],
|
|
1851
|
+
})
|
|
1852
|
+
try {
|
|
1853
|
+
for (const state of [
|
|
1854
|
+
{ phase: "idle" as const, exit: 1, interrupt: 0, notice: "", key: "ctrl+c", action: "exit" },
|
|
1855
|
+
{ phase: "running" as const, exit: 0, interrupt: 1, notice: "", key: "esc", action: "" },
|
|
1856
|
+
{ phase: "running" as const, exit: 0, interrupt: 0, notice: "failed to save settings", key: "", action: "" },
|
|
1857
|
+
]) {
|
|
1858
|
+
app.setState((previous) => ({ ...previous, ...state }))
|
|
1859
|
+
await app.renderOnce()
|
|
1860
|
+
await app.renderOnce()
|
|
1861
|
+
const statusline = footerStatusline(app.renderer.root)
|
|
1862
|
+
const text = app
|
|
1863
|
+
.captureCharFrame()
|
|
1864
|
+
.split("\n")
|
|
1865
|
+
.slice(statusline.y, statusline.y + statusline.height)
|
|
1866
|
+
.map((line) => line.trim())
|
|
1867
|
+
.join(" ")
|
|
1868
|
+
if (state.notice) expect(text.replace(/^[\u25aa*\-\\|/] /, "")).toBe(state.notice)
|
|
1869
|
+
if (state.key) {
|
|
1870
|
+
expect(text).toContain(state.key)
|
|
1871
|
+
expect(text).toMatch(state.action ? /exit/ : /stop|interrupt/)
|
|
1872
|
+
expect(statusline.height).toBe(1)
|
|
1873
|
+
}
|
|
1874
|
+
for (const value of ["Build", "GPT-5", "opencode", "high", "12.0K", "queued", "menu", "..."])
|
|
1875
|
+
expect(text).not.toContain(value)
|
|
1876
|
+
expect(!!statusline.findDescendantById("mini-work-spinner")).toBe(state.phase === "running")
|
|
1877
|
+
}
|
|
1878
|
+
} finally {
|
|
1879
|
+
app.cleanup()
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
})
|
|
1883
|
+
|
|
1884
|
+
test.each([
|
|
1885
|
+
{ field: "agent", text: "esc stop · GPT-5 [high]" },
|
|
1886
|
+
{
|
|
1887
|
+
field: "model",
|
|
1888
|
+
text: "esc stop · Build · long-model-long-model-lo… [high] · opencode · ctrl+p menu",
|
|
1889
|
+
},
|
|
1890
|
+
{ field: "provider", text: "esc stop · Build · GPT-5 [high]" },
|
|
1891
|
+
])("running footer abbreviates only the model and stops at an oversized $field", async ({ field, text }) => {
|
|
1892
|
+
const long = `long-${field}-`.repeat(20)
|
|
1893
|
+
const app = await renderFooter({
|
|
1894
|
+
width: 80,
|
|
1895
|
+
currentAgent: field === "agent" ? long : "Build",
|
|
1896
|
+
currentVariant: "high",
|
|
1897
|
+
currentModel: { providerID: "opencode", modelID: "gpt-5" },
|
|
1898
|
+
providers: [
|
|
1899
|
+
{
|
|
1900
|
+
...provider(),
|
|
1901
|
+
name: field === "provider" ? long : "opencode",
|
|
1902
|
+
models: { "gpt-5": model({ id: "gpt-5", name: field === "model" ? long : "GPT-5" }) },
|
|
1903
|
+
},
|
|
1904
|
+
],
|
|
1905
|
+
state: { phase: "running" },
|
|
1906
|
+
})
|
|
1907
|
+
try {
|
|
1908
|
+
await app.renderOnce()
|
|
1909
|
+
const statusline = footerStatusline(app.renderer.root)
|
|
1910
|
+
expect(app.captureCharFrame().split("\n")[statusline.y].trimEnd()).toBe("\u25aa " + text)
|
|
1911
|
+
expect(statusline.height).toBe(1)
|
|
1912
|
+
expect(statusline.findDescendantById("mini-work-spinner")?.width).toBe(1)
|
|
1913
|
+
} finally {
|
|
1914
|
+
app.cleanup()
|
|
1915
|
+
}
|
|
1916
|
+
})
|
|
1917
|
+
|
|
1918
|
+
test.each([8, 12])("production footer grows for wrapped instructions in %i rows", async (height) => {
|
|
1919
|
+
const app = await createTestRenderer({ width: 16, height, screenMode: "split-footer", footerHeight: 4 })
|
|
1920
|
+
const footer = new RunFooter(app.renderer, {
|
|
1921
|
+
directory: () => "/project",
|
|
1922
|
+
findFiles: async () => [],
|
|
1923
|
+
agents: [{ id: "build", name: "Build", mode: "primary", hidden: false }],
|
|
1924
|
+
references: [],
|
|
1925
|
+
agent: "build",
|
|
1926
|
+
modelLabel: "GPT-5",
|
|
1927
|
+
model: undefined,
|
|
1928
|
+
variant: undefined,
|
|
1929
|
+
first: false,
|
|
1930
|
+
theme: RUN_THEME_FALLBACK,
|
|
1931
|
+
tuiConfig: createTuiResolvedConfig({ keybinds: { "prompt.clear": "ctrl+shift+alt+x" } }),
|
|
1932
|
+
miniSettings: {
|
|
1933
|
+
current: {
|
|
1934
|
+
thinking: "hide",
|
|
1935
|
+
tools: "show",
|
|
1936
|
+
shell_output: "hide",
|
|
1937
|
+
turn_summary: "show",
|
|
1938
|
+
footer: "show",
|
|
1939
|
+
splash: "show",
|
|
1940
|
+
work_spinner: "block-soft-slide",
|
|
1941
|
+
mono: false,
|
|
1942
|
+
},
|
|
1943
|
+
},
|
|
1944
|
+
onPermissionReply: () => {},
|
|
1945
|
+
onFormReply: () => {},
|
|
1946
|
+
onFormCancel: () => {},
|
|
1947
|
+
onEditorOpen: async () => undefined,
|
|
1948
|
+
subscribeThemeSignal: () => () => {},
|
|
1949
|
+
})
|
|
1950
|
+
try {
|
|
1951
|
+
await app.renderOnce()
|
|
1952
|
+
const initial = app.renderer.footerHeight
|
|
1953
|
+
footer.requestExit()
|
|
1954
|
+
await app.renderOnce()
|
|
1955
|
+
await app.renderOnce()
|
|
1956
|
+
expect(app.renderer.footerHeight).toBe(initial + 1)
|
|
1957
|
+
expect(app.captureCharFrame()).toContain("ctrl+shift+alt+x")
|
|
1958
|
+
expect(app.captureCharFrame()).toContain("exit")
|
|
1959
|
+
expect(app.captureCharFrame()).not.toContain("GPT-5")
|
|
1960
|
+
footer.event({ type: "stream.patch", patch: { exit: 0, notice: "failed to save settings" } })
|
|
1961
|
+
await app.renderOnce()
|
|
1962
|
+
expect(app.captureCharFrame()).toContain("settings")
|
|
1963
|
+
footer.event({ type: "stream.patch", patch: { notice: "" } })
|
|
1964
|
+
await app.renderOnce()
|
|
1965
|
+
expect(app.renderer.footerHeight).toBe(initial)
|
|
1966
|
+
} finally {
|
|
1967
|
+
footer.destroy()
|
|
1968
|
+
app.renderer.destroy()
|
|
1969
|
+
}
|
|
1970
|
+
})
|
|
1971
|
+
|
|
1972
|
+
test("an oversized queue shortcut prevents backfilling shorter work and identity hints", async () => {
|
|
1973
|
+
const app = await renderFooter({
|
|
1974
|
+
width: 32,
|
|
1975
|
+
tuiConfig: createTuiResolvedConfig({ keybinds: { "session.queued_prompts": "ctrl+shift+alt+q" } }),
|
|
1976
|
+
queuedPrompts: [{ messageID: "queued", prompt: { text: "later", parts: [] }, delivery: "queue" }],
|
|
1977
|
+
subagents: {
|
|
1978
|
+
tabs: [subagent({ sessionID: "s-1", label: "Explore", description: "Inspect" })],
|
|
1979
|
+
details: {},
|
|
1980
|
+
permissions: [],
|
|
1981
|
+
forms: [],
|
|
1982
|
+
},
|
|
1983
|
+
state: { phase: "running" },
|
|
1984
|
+
})
|
|
1985
|
+
try {
|
|
1986
|
+
await app.renderOnce()
|
|
1987
|
+
const statusline = footerStatusline(app.renderer.root)
|
|
1988
|
+
expect(app.captureCharFrame().split("\n")[statusline.y].trimEnd()).toBe("\u25aa esc stop")
|
|
1989
|
+
} finally {
|
|
1990
|
+
app.cleanup()
|
|
1991
|
+
}
|
|
1992
|
+
})
|
|
1993
|
+
|
|
1994
|
+
test.each(["ctrl+i", "none"])("takeovers preserve configured shortcuts with hidden details (%s)", async (key) => {
|
|
1995
|
+
const app = await renderFooter({
|
|
1996
|
+
width: 16,
|
|
1997
|
+
tuiConfig: createTuiResolvedConfig({
|
|
1998
|
+
keybinds: { "session.interrupt": key, "prompt.clear": key, "command.palette.show": "none" },
|
|
1999
|
+
}),
|
|
2000
|
+
state: { phase: "running", interrupt: 1 },
|
|
2001
|
+
miniSettings: {
|
|
2002
|
+
thinking: "hide",
|
|
2003
|
+
tools: "show",
|
|
2004
|
+
shell_output: "hide",
|
|
2005
|
+
turn_summary: "show",
|
|
2006
|
+
footer: "hide",
|
|
2007
|
+
splash: "show",
|
|
2008
|
+
work_spinner: "block-soft-slide",
|
|
2009
|
+
mono: false,
|
|
2010
|
+
},
|
|
2011
|
+
})
|
|
2012
|
+
try {
|
|
2013
|
+
for (const exit of [0, 1]) {
|
|
2014
|
+
app.setState((state) => ({ ...state, exit }))
|
|
2015
|
+
await app.renderOnce()
|
|
2016
|
+
const frame = app.captureCharFrame()
|
|
2017
|
+
expect(frame).toContain(
|
|
2018
|
+
key === "none" ? (exit ? "Exit pending" : "Stop pending") : `${key} ${exit ? "exit" : "stop"}`,
|
|
2019
|
+
)
|
|
2020
|
+
for (const hidden of ["ctrl+c", "esc", "menu", "Build", "gpt-5"]) expect(frame).not.toContain(hidden)
|
|
2021
|
+
}
|
|
2022
|
+
} finally {
|
|
2023
|
+
app.cleanup()
|
|
2024
|
+
}
|
|
2025
|
+
})
|
|
2026
|
+
|
|
2027
|
+
test.each(["ctrl+g", "none"])("context actions use only configured bindings (%s)", async (queued) => {
|
|
2028
|
+
const app = await renderFooter({
|
|
2029
|
+
width: 96,
|
|
2030
|
+
tuiConfig: createTuiResolvedConfig({
|
|
2031
|
+
keybinds: {
|
|
2032
|
+
"session.interrupt": "ctrl+i",
|
|
2033
|
+
"session.queued_prompts": queued,
|
|
2034
|
+
"session.child.first": "ctrl+j",
|
|
2035
|
+
"command.palette.show": "ctrl+y",
|
|
2036
|
+
},
|
|
2037
|
+
}),
|
|
2038
|
+
queuedPrompts: [{ messageID: "queued", prompt: { text: "later", parts: [] }, delivery: "queue" }],
|
|
2039
|
+
subagents: {
|
|
2040
|
+
tabs: [subagent({ sessionID: "s-1", label: "Explore", description: "Inspect" })],
|
|
2041
|
+
details: {},
|
|
2042
|
+
permissions: [],
|
|
2043
|
+
forms: [],
|
|
2044
|
+
},
|
|
2045
|
+
state: { phase: "running" },
|
|
2046
|
+
})
|
|
2047
|
+
try {
|
|
2048
|
+
await app.renderOnce()
|
|
2049
|
+
const frame = app.captureCharFrame()
|
|
2050
|
+
expect(frame).toContain(
|
|
2051
|
+
queued === "none"
|
|
2052
|
+
? "ctrl+i interrupt · ctrl+j 1 subagent · Build · gpt-5 · ctrl+y menu"
|
|
2053
|
+
: "ctrl+i interrupt · ctrl+g 1 pending · ctrl+j 1 subagent · Build · gpt-5 · ctrl+y menu",
|
|
2054
|
+
)
|
|
2055
|
+
for (const hidden of ["ctrl+b", "ctrl+x", "ctrl+p", "esc", "↓"]) expect(frame).not.toContain(hidden)
|
|
2056
|
+
} finally {
|
|
2057
|
+
app.cleanup()
|
|
2058
|
+
}
|
|
2059
|
+
})
|
|
2060
|
+
|
|
2061
|
+
test("identity and context precede the provider and a non-fitting provider blocks the menu", async () => {
|
|
2062
|
+
const app = await renderFooter({
|
|
2063
|
+
width: 56,
|
|
2064
|
+
providers: [{ ...provider(), name: "Long provider display name" }],
|
|
2065
|
+
currentModel: { providerID: "opencode", modelID: "gpt-5" },
|
|
2066
|
+
currentVariant: "high",
|
|
2067
|
+
state: { usage: { tokens: 12000, percent: 10 } },
|
|
2068
|
+
})
|
|
2069
|
+
try {
|
|
2070
|
+
await app.renderOnce()
|
|
2071
|
+
const statusline = footerStatusline(app.renderer.root)
|
|
2072
|
+
expect(app.captureCharFrame().split("\n")[statusline.y].trimEnd()).toBe("Build · GPT-5 [high] · 12.0K (10%)")
|
|
2073
|
+
} finally {
|
|
2074
|
+
app.cleanup()
|
|
2075
|
+
}
|
|
2076
|
+
})
|
|
2077
|
+
|
|
2078
|
+
test("direct footer keeps work, model detail, context, and cost in priority order", async () => {
|
|
2079
|
+
const app = await renderFooter({
|
|
2080
|
+
currentAgent: "Plan",
|
|
2081
|
+
subagents: {
|
|
2082
|
+
tabs: [subagent({ sessionID: "s-1", label: "Explore", description: "Inspect auth flow" })],
|
|
2083
|
+
details: {},
|
|
2084
|
+
permissions: [],
|
|
2085
|
+
forms: [],
|
|
2086
|
+
},
|
|
2087
|
+
state: {
|
|
2088
|
+
phase: "running",
|
|
2089
|
+
model: "a-model-name-long-enough-to-force-responsive-truncation",
|
|
2090
|
+
usage: { tokens: 159600, percent: 16, cost: 4.23 },
|
|
2091
|
+
},
|
|
2092
|
+
width: 80,
|
|
2093
|
+
})
|
|
2094
|
+
|
|
2095
|
+
try {
|
|
2096
|
+
await app.renderOnce()
|
|
2097
|
+
const statusline = footerStatusline(app.renderer.root)
|
|
2098
|
+
expect(app.captureCharFrame().split("\n")[statusline.y].trimEnd()).toBe(
|
|
2099
|
+
"\u25aa esc stop · ↓ 1 sub · Plan · a-model-name-long-enough… · 159.6K (16%) · $4.23",
|
|
2100
|
+
)
|
|
2101
|
+
} finally {
|
|
2102
|
+
app.cleanup()
|
|
2103
|
+
}
|
|
2104
|
+
})
|
|
2105
|
+
|
|
2106
|
+
test("direct footer keeps the stop action before the menu at minimum width", async () => {
|
|
2107
|
+
const app = await renderFooter({ state: { phase: "running" }, width: 10 })
|
|
2108
|
+
|
|
2109
|
+
try {
|
|
2110
|
+
await app.renderOnce()
|
|
2111
|
+
expect(app.captureCharFrame()).toContain("esc stop")
|
|
2112
|
+
expect(app.captureCharFrame()).not.toContain("menu")
|
|
2113
|
+
} finally {
|
|
2114
|
+
app.cleanup()
|
|
2115
|
+
}
|
|
2116
|
+
})
|
|
2117
|
+
|
|
2118
|
+
test.each([false, true])("working marker stays visible with animations=%s and stops at idle", async (animations) => {
|
|
2119
|
+
const app = await renderFooter({
|
|
2120
|
+
width: 24,
|
|
2121
|
+
tuiConfig: createTuiResolvedConfig({ animations }),
|
|
2122
|
+
state: { phase: "running" },
|
|
2123
|
+
})
|
|
2124
|
+
try {
|
|
2125
|
+
await app.renderOnce()
|
|
2126
|
+
const line = app.captureCharFrame().split("\n")[footerStatusline(app.renderer.root).y]
|
|
2127
|
+
expect(line).toContain(" esc stop")
|
|
2128
|
+
expect(animations ? BLOCK_SOFT_SLIDE.frames : ["\u25aa"]).toContain(Array.from(line)[0]!)
|
|
2129
|
+
expect(app.renderer.root.findDescendantById("mini-work-spinner")?.width).toBe(1)
|
|
2130
|
+
app.setMiniSettings((settings) => ({ ...settings, work_spinner: "seed" }))
|
|
2131
|
+
await app.renderOnce()
|
|
2132
|
+
expect(app.captureCharFrame().split("\n")[footerStatusline(app.renderer.root).y]).toStartWith("\u25aa ")
|
|
2133
|
+
await app.renderer.idle()
|
|
2134
|
+
app.setState((state) => ({ ...state, phase: "idle" }))
|
|
2135
|
+
await app.renderOnce()
|
|
2136
|
+
expect(app.renderer.root.findDescendantById("mini-work-spinner")).toBeUndefined()
|
|
2137
|
+
} finally {
|
|
2138
|
+
app.cleanup()
|
|
2139
|
+
}
|
|
2140
|
+
})
|
|
2141
|
+
|
|
2142
|
+
test.each(["Build", "Plan"])("working marker matches the %s label and prompt rail across themes", async (agent) => {
|
|
2143
|
+
const [theme, setTheme] = createSignal(RUN_THEME_FALLBACK)
|
|
2144
|
+
const app = await renderFooter({
|
|
2145
|
+
currentAgent: agent,
|
|
2146
|
+
agents: [
|
|
2147
|
+
{ id: "build", name: "Build", mode: "primary", hidden: false },
|
|
2148
|
+
{ id: "plan", name: "Plan", mode: "primary", hidden: false },
|
|
2149
|
+
],
|
|
2150
|
+
theme,
|
|
2151
|
+
tuiConfig: createTuiResolvedConfig({ animations: false }),
|
|
2152
|
+
state: { phase: "running" },
|
|
2153
|
+
})
|
|
2154
|
+
try {
|
|
2155
|
+
for (const current of [RUN_THEME_FALLBACK, RUN_THEME_FALLBACK_LIGHT]) {
|
|
2156
|
+
setTheme(current)
|
|
2157
|
+
await app.renderOnce()
|
|
2158
|
+
const spans = app.captureSpans().lines.flatMap((line) => line.spans)
|
|
2159
|
+
const expected = (current.footer.categorical[agent === "Build" ? 0 : 1] as RGBA).toInts()
|
|
2160
|
+
expect(spans.find((span) => span.text.includes(agent))?.fg.toInts()).toEqual(expected)
|
|
2161
|
+
expect(spans.find((span) => span.text.includes("\u2503"))?.fg.toInts()).toEqual(expected)
|
|
2162
|
+
expect(spans.find((span) => span.text === "\u25aa")?.fg.toInts()).toEqual(expected)
|
|
2163
|
+
}
|
|
2164
|
+
} finally {
|
|
2165
|
+
app.cleanup()
|
|
2166
|
+
}
|
|
2167
|
+
})
|
|
2168
|
+
|
|
2169
|
+
test("configured agent color paints the label, prompt rail, and working marker", async () => {
|
|
2170
|
+
const app = await renderFooter({
|
|
2171
|
+
agents: [{ id: "build", name: "Build", mode: "primary", hidden: false, color: "#ff79c6" }],
|
|
2172
|
+
state: { phase: "running" },
|
|
2173
|
+
})
|
|
2174
|
+
try {
|
|
2175
|
+
await app.renderOnce()
|
|
2176
|
+
const spans = app.captureSpans().lines.flatMap((line) => line.spans)
|
|
2177
|
+
for (const text of ["Build", "\u2503", "\u25aa"]) {
|
|
2178
|
+
expect(spans.find((span) => span.text.includes(text))?.fg.toInts()).toEqual([255, 121, 198, 255])
|
|
2179
|
+
}
|
|
2180
|
+
} finally {
|
|
2181
|
+
app.cleanup()
|
|
2182
|
+
}
|
|
2183
|
+
})
|
|
2184
|
+
|
|
2185
|
+
test("spinner repaints keep the prompt instance, cursor state, and footer height stable", async () => {
|
|
2186
|
+
const app = await renderFooter({
|
|
2187
|
+
tuiConfig: createTuiResolvedConfig({ animations: true }),
|
|
2188
|
+
state: { phase: "running" },
|
|
2189
|
+
})
|
|
2190
|
+
try {
|
|
2191
|
+
await app.renderOnce()
|
|
2192
|
+
await app.mockInput.typeText("draft")
|
|
2193
|
+
await app.renderOnce()
|
|
2194
|
+
const editor = app.renderer.currentFocusedEditor
|
|
2195
|
+
const cursor = app.renderer.getCursorState()
|
|
2196
|
+
const height = app.renderer.footerHeight
|
|
2197
|
+
const frames = new Set<string>()
|
|
2198
|
+
for (let index = 0; index < 8; index++) {
|
|
2199
|
+
await Bun.sleep(40)
|
|
2200
|
+
await app.renderOnce()
|
|
2201
|
+
expect(app.renderer.currentFocusedEditor).toBe(editor)
|
|
2202
|
+
expect(editor?.plainText).toBe("draft")
|
|
2203
|
+
expect(app.renderer.getCursorState()).toEqual(cursor)
|
|
2204
|
+
expect(app.renderer.footerHeight).toBe(height)
|
|
2205
|
+
frames.add(JSON.stringify(app.captureSpans()))
|
|
2206
|
+
}
|
|
2207
|
+
expect(frames.size).toBeGreaterThan(1)
|
|
2208
|
+
} finally {
|
|
2209
|
+
app.cleanup()
|
|
2210
|
+
}
|
|
2211
|
+
})
|
|
2212
|
+
|
|
2213
|
+
test("direct footer reserves the working indicator beside complete status text", async () => {
|
|
2214
|
+
const app = await renderFooter({
|
|
2215
|
+
tuiConfig: createTuiResolvedConfig({ keybinds: { "session.interrupt": "none" } }),
|
|
2216
|
+
state: { phase: "running" },
|
|
2217
|
+
width: 22,
|
|
2218
|
+
})
|
|
2219
|
+
|
|
2220
|
+
try {
|
|
2221
|
+
await app.renderOnce()
|
|
2222
|
+
expect(app.captureCharFrame()).toContain("Running")
|
|
2223
|
+
expect(app.captureCharFrame()).not.toContain("interrupt")
|
|
2224
|
+
expect(footerStatusline(app.renderer.root).findDescendantById("mini-work-spinner")?.width).toBe(1)
|
|
2225
|
+
} finally {
|
|
2226
|
+
app.cleanup()
|
|
2227
|
+
}
|
|
2228
|
+
})
|
|
2229
|
+
|
|
2230
|
+
test("direct footer never offers backgrounding for a subagent", async () => {
|
|
2231
|
+
const app = await renderFooter({
|
|
2232
|
+
subagents: {
|
|
2233
|
+
tabs: [subagent({ sessionID: "s-1", label: "Explore", description: "Inspect auth flow" })],
|
|
2234
|
+
details: {},
|
|
2235
|
+
permissions: [],
|
|
2236
|
+
forms: [],
|
|
2237
|
+
},
|
|
2238
|
+
width: 160,
|
|
2239
|
+
})
|
|
2240
|
+
|
|
2241
|
+
try {
|
|
2242
|
+
await app.renderOnce()
|
|
2243
|
+
const frame = app.captureCharFrame()
|
|
2244
|
+
|
|
2245
|
+
expect(frame).toContain("↓ 1 subagent · Build · gpt-5 · ctrl+p menu")
|
|
2246
|
+
expect(frame).not.toContain("ctrl+b")
|
|
2247
|
+
expect(frame).not.toContain("queued")
|
|
2248
|
+
} finally {
|
|
2249
|
+
app.cleanup()
|
|
2250
|
+
}
|
|
2251
|
+
})
|
|
2252
|
+
|
|
2253
|
+
test("direct footer hides the subagent hint when only completed subagents remain", async () => {
|
|
2254
|
+
const app = await renderFooter({
|
|
2255
|
+
subagents: {
|
|
2256
|
+
tabs: [subagent({ sessionID: "s-1", label: "Explore", description: "Inspect auth flow", status: "completed" })],
|
|
2257
|
+
details: {},
|
|
2258
|
+
permissions: [],
|
|
2259
|
+
forms: [],
|
|
2260
|
+
},
|
|
2261
|
+
width: 160,
|
|
2262
|
+
})
|
|
2263
|
+
|
|
2264
|
+
try {
|
|
2265
|
+
await app.renderOnce()
|
|
2266
|
+
const frame = app.captureCharFrame()
|
|
2267
|
+
|
|
2268
|
+
expect(frame).toContain("Build")
|
|
2269
|
+
expect(frame).not.toContain("1 sub")
|
|
2270
|
+
} finally {
|
|
2271
|
+
app.cleanup()
|
|
2272
|
+
}
|
|
2273
|
+
})
|
|
2274
|
+
|
|
2275
|
+
test("direct footer omits interrupt key hint when interrupt is unbound", async () => {
|
|
2276
|
+
const app = await renderFooter({
|
|
2277
|
+
tuiConfig: createTuiResolvedConfig({ keybinds: { "session.interrupt": "none", "prompt.clear": "ctrl+l" } }),
|
|
2278
|
+
state: { phase: "running" },
|
|
2279
|
+
mono: true,
|
|
2280
|
+
})
|
|
2281
|
+
|
|
2282
|
+
try {
|
|
2283
|
+
await app.renderOnce()
|
|
2284
|
+
const frame = app.captureCharFrame()
|
|
2285
|
+
const statusline = frame.split("\n").find((line) => line.includes("Running"))
|
|
2286
|
+
|
|
2287
|
+
expect(frame).toContain("Running")
|
|
2288
|
+
expect(frame).not.toContain("interrupt")
|
|
2289
|
+
expect(frame).not.toContain("ctrl+l")
|
|
2290
|
+
expect(statusline).toMatch(/^\S/)
|
|
2291
|
+
} finally {
|
|
2292
|
+
app.cleanup()
|
|
2293
|
+
}
|
|
2294
|
+
})
|
|
2295
|
+
|
|
2296
|
+
test("direct footer shows full usage metadata when room is available", async () => {
|
|
2297
|
+
const app = await renderFooter({
|
|
2298
|
+
state: { usage: { tokens: 159600, percent: 16, cost: 4.23 } },
|
|
2299
|
+
})
|
|
2300
|
+
|
|
2301
|
+
try {
|
|
2302
|
+
await app.renderOnce()
|
|
2303
|
+
const frame = app.captureCharFrame()
|
|
2304
|
+
|
|
2305
|
+
expect(frame).toContain("159.6K (16%) · $4.23")
|
|
2306
|
+
} finally {
|
|
2307
|
+
app.cleanup()
|
|
2308
|
+
}
|
|
2309
|
+
})
|
|
2310
|
+
|
|
2311
|
+
test("direct footer keeps model, variant, and usage before the menu and rich stop label", async () => {
|
|
2312
|
+
const app = await renderFooter({
|
|
2313
|
+
state: { phase: "running", model: "GPT-5.6 SoL", usage: { tokens: 8400, percent: 1, cost: 0.01 } },
|
|
2314
|
+
currentVariant: "high",
|
|
2315
|
+
mono: true,
|
|
2316
|
+
width: 66,
|
|
2317
|
+
})
|
|
2318
|
+
|
|
2319
|
+
try {
|
|
2320
|
+
await app.renderOnce()
|
|
2321
|
+
const statusline = footerStatusline(app.renderer.root)
|
|
2322
|
+
expect(app.captureCharFrame().split("\n")[statusline.y].trimEnd()).toBe(
|
|
2323
|
+
"* esc stop - Build - GPT-5.6 SoL [high] - 8.4K (1%) - $0.01",
|
|
2324
|
+
)
|
|
2325
|
+
} finally {
|
|
2326
|
+
app.cleanup()
|
|
2327
|
+
}
|
|
2328
|
+
})
|
|
2329
|
+
|
|
2330
|
+
test("direct footer hides routine activity and shows explicit notices", async () => {
|
|
2331
|
+
let status = ""
|
|
2332
|
+
const app = await renderFooter({
|
|
2333
|
+
state: { usage: { tokens: 159600, percent: 16, cost: 4.23 } },
|
|
2334
|
+
currentAgent: "Plan",
|
|
2335
|
+
miniSettings: {
|
|
2336
|
+
thinking: "hide",
|
|
2337
|
+
tools: "show",
|
|
2338
|
+
shell_output: "hide",
|
|
2339
|
+
turn_summary: "show",
|
|
2340
|
+
footer: "hide",
|
|
2341
|
+
splash: "show",
|
|
2342
|
+
work_spinner: "block-soft-slide",
|
|
2343
|
+
mono: true,
|
|
2344
|
+
},
|
|
2345
|
+
mono: true,
|
|
2346
|
+
onStatus: (value) => (status = value),
|
|
2347
|
+
width: 160,
|
|
2348
|
+
})
|
|
2349
|
+
|
|
2350
|
+
try {
|
|
2351
|
+
await app.renderOnce()
|
|
2352
|
+
const initial = app.captureCharFrame()
|
|
2353
|
+
expect(initial).toContain("ctrl+p menu")
|
|
2354
|
+
expect(initial).not.toContain("Plan")
|
|
2355
|
+
expect(initial).not.toContain("gpt-5")
|
|
2356
|
+
expect(initial).not.toContain("159.6K")
|
|
2357
|
+
|
|
2358
|
+
app.setState((state) => ({ ...state, phase: "running", status: "assistant responding" }))
|
|
2359
|
+
await app.renderOnce()
|
|
2360
|
+
const changed = app.captureCharFrame()
|
|
2361
|
+
const statusline = footerStatusline(app.renderer.root)
|
|
2362
|
+
|
|
2363
|
+
expect(changed).not.toContain("running")
|
|
2364
|
+
expect(changed).not.toContain("assistant responding")
|
|
2365
|
+
expect(changed).not.toContain("interrupt")
|
|
2366
|
+
expect(changed).not.toContain("gpt-5")
|
|
2367
|
+
expect(changed).not.toContain("159.6K")
|
|
2368
|
+
expect(boxPath(statusline, "SpinnerRenderable")).toBeUndefined()
|
|
2369
|
+
|
|
2370
|
+
app.mockInput.pressKey("p", { ctrl: true })
|
|
2371
|
+
await app.renderOnce()
|
|
2372
|
+
await app.mockInput.typeText("status")
|
|
2373
|
+
app.mockInput.pressEnter()
|
|
2374
|
+
expect(status).toBe("running - agent Plan - gpt-5 - 159.6K (16%) - $4.23")
|
|
2375
|
+
|
|
2376
|
+
app.setState((state) => ({ ...state, notice: "variant high" }))
|
|
2377
|
+
await app.renderOnce()
|
|
2378
|
+
expect(app.captureCharFrame()).toContain("variant high")
|
|
2379
|
+
} finally {
|
|
2380
|
+
app.cleanup()
|
|
2381
|
+
}
|
|
2382
|
+
})
|
|
2383
|
+
|
|
2384
|
+
test("direct permission rejection submits through keymap return binding", async () => {
|
|
2385
|
+
let text = ""
|
|
2386
|
+
const submits: string[] = []
|
|
2387
|
+
function Harness() {
|
|
2388
|
+
return (
|
|
2389
|
+
<Keymap.Provider config={tuiConfig}>
|
|
2390
|
+
<RejectField
|
|
2391
|
+
theme={RUN_THEME_FALLBACK.footer}
|
|
2392
|
+
text={"中\t"}
|
|
2393
|
+
disabled={false}
|
|
2394
|
+
onChange={(input) => {
|
|
2395
|
+
text = input
|
|
2396
|
+
}}
|
|
2397
|
+
onConfirm={() => {
|
|
2398
|
+
submits.push(text)
|
|
2399
|
+
}}
|
|
2400
|
+
onCancel={() => {}}
|
|
2401
|
+
/>
|
|
2402
|
+
</Keymap.Provider>
|
|
2403
|
+
)
|
|
2404
|
+
}
|
|
2405
|
+
|
|
2406
|
+
const app = await testRender(
|
|
2407
|
+
() => (
|
|
2408
|
+
<box width={100} height={18}>
|
|
2409
|
+
<Harness />
|
|
2410
|
+
</box>
|
|
2411
|
+
),
|
|
2412
|
+
{ width: 100, height: 18, kittyKeyboard: true },
|
|
2413
|
+
)
|
|
2414
|
+
|
|
2415
|
+
try {
|
|
2416
|
+
await app.renderOnce()
|
|
2417
|
+
"retry".split("").forEach((key) => app.mockInput.pressKey(key))
|
|
2418
|
+
await app.renderOnce()
|
|
2419
|
+
expect(app.captureCharFrame()).toContain("retry")
|
|
2420
|
+
app.mockInput.pressEnter()
|
|
2421
|
+
await app.renderOnce()
|
|
2422
|
+
expect(submits).toEqual(["中\tretry"])
|
|
2423
|
+
} finally {
|
|
2424
|
+
app.renderer.currentFocusedRenderable?.blur()
|
|
2425
|
+
app.renderer.currentFocusedEditor?.blur()
|
|
2426
|
+
app.renderer.destroy()
|
|
2427
|
+
}
|
|
2428
|
+
})
|
|
2429
|
+
|
|
2430
|
+
test("direct model panel keeps native V2 light search and options readable on a transparent background", async () => {
|
|
2431
|
+
const theme = await nativeLightTheme()
|
|
2432
|
+
const background = RGBA.fromHex("#ffffff")
|
|
2433
|
+
const [providers] = createSignal<RunProvider[] | undefined>([
|
|
2434
|
+
provider(),
|
|
2435
|
+
{ id: "openai", name: "OpenAI", models: { "gpt-5": model({ id: "gpt-5", name: "GPT-5" }) } },
|
|
2436
|
+
])
|
|
2437
|
+
const [current] = createSignal<RunInput["model"]>({ providerID: "opencode", modelID: "gpt-5" })
|
|
2438
|
+
|
|
2439
|
+
const app = await testRender(
|
|
2440
|
+
() => (
|
|
2441
|
+
<box width={100} height={RUN_COMMAND_PANEL_ROWS} backgroundColor={background}>
|
|
2442
|
+
<RunModelSelectBody
|
|
2443
|
+
theme={() => theme.footer}
|
|
2444
|
+
providers={providers}
|
|
2445
|
+
current={current}
|
|
2446
|
+
onClose={() => {}}
|
|
2447
|
+
onSelect={() => {}}
|
|
2448
|
+
/>
|
|
2449
|
+
</box>
|
|
2450
|
+
),
|
|
2451
|
+
{
|
|
2452
|
+
width: 100,
|
|
2453
|
+
height: RUN_COMMAND_PANEL_ROWS + 1,
|
|
2454
|
+
},
|
|
2455
|
+
)
|
|
2456
|
+
|
|
2457
|
+
try {
|
|
2458
|
+
await app.renderOnce()
|
|
2459
|
+
const frame = app.captureCharFrame()
|
|
2460
|
+
const list = panelMenu(app.renderer.root)
|
|
2461
|
+
|
|
2462
|
+
expect(frame).toContain("Select model")
|
|
2463
|
+
expect(frame).toContain("Search")
|
|
2464
|
+
expect(frame).toContain("opencode")
|
|
2465
|
+
expect(frame).toContain("GPT-5")
|
|
2466
|
+
expect(frame).toContain("current")
|
|
2467
|
+
expect(frame).toContain("GPT Free")
|
|
2468
|
+
expect(frame).toContain("Free")
|
|
2469
|
+
expect(frame).not.toContain("┌")
|
|
2470
|
+
expect(frame).not.toContain("┃")
|
|
2471
|
+
expect(frame).not.toContain("Old Model")
|
|
2472
|
+
expect(frame).not.toContain("▀")
|
|
2473
|
+
expect(
|
|
2474
|
+
boxPath(app.renderer.root, "InputRenderable")
|
|
2475
|
+
?.slice(1)
|
|
2476
|
+
.every((box) => box.backgroundColor.a === 0),
|
|
2477
|
+
).toBe(true)
|
|
2478
|
+
expect(list.backgroundColor.a).toBe(0)
|
|
2479
|
+
expect((list.getChildren()[2] as BoxRenderable).backgroundColor.toInts()).toEqual(
|
|
2480
|
+
(theme.footer.actionFocusedBg as RGBA).toInts(),
|
|
2481
|
+
)
|
|
2482
|
+
|
|
2483
|
+
"gpt-5".split("").forEach((key) => app.mockInput.pressKey(key))
|
|
2484
|
+
await app.renderOnce()
|
|
2485
|
+
const search = app.captureCharFrame()
|
|
2486
|
+
|
|
2487
|
+
expect(search.match(/GPT-5/g)).toHaveLength(2)
|
|
2488
|
+
expect(search).toContain("opencode")
|
|
2489
|
+
expect(search).toContain("OpenAI")
|
|
2490
|
+
const spans = app.captureSpans().lines.flatMap((line) => line.spans)
|
|
2491
|
+
const query = spans.find((span) => span.text.includes("gpt-5"))!
|
|
2492
|
+
expect(query.fg.toInts()).toEqual((theme.footer.formfieldText as RGBA).toInts())
|
|
2493
|
+
expect(query.bg.toInts()).toEqual(background.toInts())
|
|
2494
|
+
expect(app.renderer.getCursorState().color.toInts()).toEqual(query.fg.toInts())
|
|
2495
|
+
expect(
|
|
2496
|
+
spans.filter((span) => span.text.includes("GPT-5")).map((span) => [span.fg.toInts(), span.bg.toInts()]),
|
|
2497
|
+
).toEqual([
|
|
2498
|
+
[(theme.footer.actionFocusedText as RGBA).toInts(), (theme.footer.actionFocusedBg as RGBA).toInts()],
|
|
2499
|
+
[(theme.footer.formfieldText as RGBA).toInts(), background.toInts()],
|
|
2500
|
+
])
|
|
2501
|
+
} finally {
|
|
2502
|
+
app.renderer.destroy()
|
|
2503
|
+
theme.block.syntax?.destroy()
|
|
2504
|
+
}
|
|
2505
|
+
})
|
|
2506
|
+
|
|
2507
|
+
test("direct permission buttons use secondary text over the native V2 light pane", async () => {
|
|
2508
|
+
const theme = await nativeLightTheme()
|
|
2509
|
+
const app = await renderFooter({
|
|
2510
|
+
theme: () => theme,
|
|
2511
|
+
height: 16,
|
|
2512
|
+
view: {
|
|
2513
|
+
type: "permission",
|
|
2514
|
+
request: { id: "per_light", sessionID: "ses_light", action: "read", resources: ["src/index.ts"] },
|
|
2515
|
+
},
|
|
2516
|
+
})
|
|
2517
|
+
try {
|
|
2518
|
+
await app.renderOnce()
|
|
2519
|
+
const spans = app.captureSpans().lines.flatMap((line) => line.spans)
|
|
2520
|
+
const inactive = spans.find((span) => span.text.includes("Reject"))!
|
|
2521
|
+
const selected = spans.find((span) => span.text.includes("Allow once"))!
|
|
2522
|
+
expect(inactive.fg.toInts()).toEqual((theme.footer.actionSecondaryText as RGBA).toInts())
|
|
2523
|
+
expect(inactive.bg.toInts()).toEqual((theme.footer.pane as RGBA).toInts())
|
|
2524
|
+
expect(selected.fg.toInts()).toEqual((theme.footer.actionFocusedText as RGBA).toInts())
|
|
2525
|
+
expect(selected.bg.toInts()).toEqual((theme.footer.actionFocusedBg as RGBA).toInts())
|
|
2526
|
+
} finally {
|
|
2527
|
+
app.cleanup()
|
|
2528
|
+
theme.block.syntax?.destroy()
|
|
2529
|
+
}
|
|
2530
|
+
})
|
|
2531
|
+
|
|
2532
|
+
test("direct agent panel shows eligible agents and marks the current agent", async () => {
|
|
2533
|
+
const theme = await nativeLightTheme()
|
|
2534
|
+
const [agents] = createSignal<RunAgent[]>([
|
|
2535
|
+
{ id: "build", name: "Build", description: "Build software", mode: "all", hidden: false },
|
|
2536
|
+
{ id: "review", name: "Review", description: "Review changes", mode: "primary", hidden: false },
|
|
2537
|
+
{ id: "explore", name: "Explore", mode: "subagent", hidden: false },
|
|
2538
|
+
{ id: "secret", name: "Secret", mode: "all", hidden: true },
|
|
2539
|
+
])
|
|
2540
|
+
const [current] = createSignal("review")
|
|
2541
|
+
let selected: string | undefined
|
|
2542
|
+
|
|
2543
|
+
const app = await testRender(
|
|
2544
|
+
() => (
|
|
2545
|
+
<box width={100} height={RUN_COMMAND_PANEL_ROWS}>
|
|
2546
|
+
<RunAgentSelectBody
|
|
2547
|
+
theme={() => theme.footer}
|
|
2548
|
+
agents={agents}
|
|
2549
|
+
current={current}
|
|
2550
|
+
onClose={() => {}}
|
|
2551
|
+
onSelect={(agent) => (selected = agent)}
|
|
2552
|
+
/>
|
|
2553
|
+
</box>
|
|
2554
|
+
),
|
|
2555
|
+
{
|
|
2556
|
+
width: 100,
|
|
2557
|
+
height: RUN_COMMAND_PANEL_ROWS,
|
|
2558
|
+
},
|
|
2559
|
+
)
|
|
2560
|
+
|
|
2561
|
+
try {
|
|
2562
|
+
await app.renderOnce()
|
|
2563
|
+
const frame = app.captureCharFrame()
|
|
2564
|
+
|
|
2565
|
+
expect(frame).toContain("Select agent")
|
|
2566
|
+
expect(frame).toContain("build")
|
|
2567
|
+
expect(frame).toContain("review")
|
|
2568
|
+
expect(frame).toContain("Review changes")
|
|
2569
|
+
expect(frame).toContain("current")
|
|
2570
|
+
expect(frame).not.toContain("explore")
|
|
2571
|
+
expect(frame).not.toContain("secret")
|
|
2572
|
+
|
|
2573
|
+
app.mockInput.pressEnter()
|
|
2574
|
+
expect(selected).toBe("review")
|
|
2575
|
+
await app.mockInput.typeText("review")
|
|
2576
|
+
await app.renderOnce()
|
|
2577
|
+
const query = app
|
|
2578
|
+
.captureSpans()
|
|
2579
|
+
.lines[app.renderer.currentFocusedRenderable!.y].spans.find((span) => span.text.includes("review"))!
|
|
2580
|
+
expect(query.fg.toInts()).toEqual((theme.footer.formfieldFocusedText as RGBA).toInts())
|
|
2581
|
+
expect(query.bg.toInts()).toEqual((theme.footer.formfieldFocusedBg as RGBA).toInts())
|
|
2582
|
+
expect(app.renderer.getCursorState().color.toInts()).toEqual(query.fg.toInts())
|
|
2583
|
+
} finally {
|
|
2584
|
+
app.renderer.destroy()
|
|
2585
|
+
theme.block.syntax?.destroy()
|
|
2586
|
+
}
|
|
2587
|
+
})
|
|
2588
|
+
|
|
2589
|
+
test("direct variant panel renders current variant selector", async () => {
|
|
2590
|
+
const [variants] = createSignal(["high", "minimal"])
|
|
2591
|
+
const [current] = createSignal<string | undefined>("high")
|
|
2592
|
+
|
|
2593
|
+
const app = await testRender(
|
|
2594
|
+
() => (
|
|
2595
|
+
<box width={100} height={RUN_COMMAND_PANEL_ROWS}>
|
|
2596
|
+
<RunVariantSelectBody
|
|
2597
|
+
theme={() => RUN_THEME_FALLBACK.footer}
|
|
2598
|
+
variants={variants}
|
|
2599
|
+
current={current}
|
|
2600
|
+
onClose={() => {}}
|
|
2601
|
+
onSelect={() => {}}
|
|
2602
|
+
/>
|
|
2603
|
+
</box>
|
|
2604
|
+
),
|
|
2605
|
+
{
|
|
2606
|
+
width: 100,
|
|
2607
|
+
height: RUN_COMMAND_PANEL_ROWS,
|
|
2608
|
+
},
|
|
2609
|
+
)
|
|
2610
|
+
|
|
2611
|
+
try {
|
|
2612
|
+
await app.renderOnce()
|
|
2613
|
+
const frame = app.captureCharFrame()
|
|
2614
|
+
const list = panelMenu(app.renderer.root)
|
|
2615
|
+
|
|
2616
|
+
expect(frame).toContain("Select variant")
|
|
2617
|
+
expect(frame).toContain("Default")
|
|
2618
|
+
expect(frame).toContain("high")
|
|
2619
|
+
expect(frame).toContain("minimal")
|
|
2620
|
+
expect(frame).toContain("current")
|
|
2621
|
+
expect(frame).not.toContain("┌")
|
|
2622
|
+
expect(frame).not.toContain("┃")
|
|
2623
|
+
expectPaletteList(list, 1)
|
|
2624
|
+
} finally {
|
|
2625
|
+
app.renderer.destroy()
|
|
2626
|
+
}
|
|
2627
|
+
})
|