@zyro-sec/app 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +234 -0
- package/README.md +106 -2
- package/bunfig.toml +3 -0
- package/component-tests/activity-chips.spec.ts +47 -0
- package/component-tests/browser-pane-restore.spec.ts +1294 -0
- package/component-tests/browser-pane.spec.ts +2338 -0
- package/component-tests/browser-settings.spec.ts +315 -0
- package/component-tests/browser-site-chooser.spec.ts +628 -0
- package/component-tests/components-lab.spec.ts +24 -0
- package/component-tests/composer.spec.ts +876 -0
- package/component-tests/debug-bar.spec.ts +237 -0
- package/component-tests/dialog-popups.spec.ts +49 -0
- package/component-tests/file-icon.spec.ts +14 -0
- package/component-tests/focus-rescue.fixture.tsx +30 -0
- package/component-tests/focus-rescue.spec.ts +83 -0
- package/component-tests/focus-ring.spec.ts +112 -0
- package/component-tests/fork-dialog.spec.ts +61 -0
- package/component-tests/grow.fixture.tsx +42 -0
- package/component-tests/grow.spec.ts +74 -0
- package/component-tests/image-preview.spec.ts +157 -0
- package/component-tests/input-surfaces.spec.ts +351 -0
- package/component-tests/line-comment.spec.ts +118 -0
- package/component-tests/list.spec.ts +7 -0
- package/component-tests/model-picker.spec.ts +45 -0
- package/component-tests/new-session-wordmark.spec.ts +135 -0
- package/component-tests/open-in-border.spec.ts +18 -0
- package/component-tests/pairing.spec.ts +40 -0
- package/component-tests/panel-sidebar-side.spec.ts +103 -0
- package/component-tests/plugin-graph.spec.ts +61 -0
- package/component-tests/plugin-host.fixture.tsx +995 -0
- package/component-tests/plugin-host.spec.ts +2362 -0
- package/component-tests/presence.fixture.tsx +59 -0
- package/component-tests/presence.spec.ts +104 -0
- package/component-tests/session-containment.fixture.tsx +79 -0
- package/component-tests/session-containment.spec.ts +145 -0
- package/component-tests/session-location-missing.spec.ts +52 -0
- package/component-tests/session-question-dock.spec.ts +1655 -0
- package/component-tests/sources-experiment.spec.ts +98 -0
- package/component-tests/ssh-reconnect.spec.ts +97 -0
- package/component-tests/subagent-bar.spec.ts +29 -0
- package/component-tests/terminal.spec.ts +148 -0
- package/component-tests/timeline-detail.spec.ts +311 -0
- package/component-tests/timeline-virtualizer.fixture.tsx +272 -0
- package/component-tests/timeline-virtualizer.spec.ts +269 -0
- package/component-tests/toast.spec.ts +23 -0
- package/component-tests/tooltip.spec.ts +169 -0
- package/component-tests/websearch.spec.ts +86 -0
- package/e2e/AGENTS.md +25 -0
- package/e2e/QUARANTINE.md +12 -0
- package/e2e/regression/background-read-failure.spec.ts +43 -0
- package/e2e/regression/btw-sidebar.spec.ts +339 -0
- package/e2e/regression/command-palette.spec.ts +822 -0
- package/e2e/regression/composer.spec.ts +1727 -0
- package/e2e/regression/directory-picker.spec.ts +133 -0
- package/e2e/regression/home.spec.ts +779 -0
- package/e2e/regression/mcp-workspace-toggle.spec.ts +695 -0
- package/e2e/regression/menu-scrollbars.spec.ts +78 -0
- package/e2e/regression/mobile-composer-submit-focus.spec.ts +88 -0
- package/e2e/regression/mobile-model-pickers.spec.ts +433 -0
- package/e2e/regression/mobile-plugin-drawers.spec.ts +194 -0
- package/e2e/regression/mobile-plugins.spec.ts +309 -0
- package/e2e/regression/mobile-session-options.spec.ts +101 -0
- package/e2e/regression/mobile-session.spec.ts +442 -0
- package/e2e/regression/mobile-timeline-scroll.spec.ts +919 -0
- package/e2e/regression/multi-server.spec.ts +498 -0
- package/e2e/regression/new-session.spec.ts +1666 -0
- package/e2e/regression/panel-edges.spec.ts +79 -0
- package/e2e/regression/patch-border.spec.ts +69 -0
- package/e2e/regression/patch-sticky-header.spec.ts +320 -0
- package/e2e/regression/review.spec.ts +2397 -0
- package/e2e/regression/session-header.spec.ts +1020 -0
- package/e2e/regression/session-location-sync.spec.ts +412 -0
- package/e2e/regression/session-notice-truncation.spec.ts +92 -0
- package/e2e/regression/session-panel-scrollbar.spec.ts +46 -0
- package/e2e/regression/session-queue.spec.ts +1704 -0
- package/e2e/regression/session-request-docks.spec.ts +719 -0
- package/e2e/regression/session-summary.spec.ts +1092 -0
- package/e2e/regression/session-timeline-accessibility.spec.ts +216 -0
- package/e2e/regression/session-timeline-locale-projection.spec.ts +24 -0
- package/e2e/regression/session-timeline-reducer-projection.spec.ts +53 -0
- package/e2e/regression/session-timeline-tool-projection.spec.ts +94 -0
- package/e2e/regression/session-websearch-dock.spec.ts +122 -0
- package/e2e/regression/settings-search.spec.ts +516 -0
- package/e2e/regression/settings-wsl.spec.ts +433 -0
- package/e2e/regression/settings.spec.ts +2901 -0
- package/e2e/regression/shell-panel-spacing.spec.ts +95 -0
- package/e2e/regression/side-panels.spec.ts +524 -0
- package/e2e/regression/subagent-child-navigation.spec.ts +540 -0
- package/e2e/regression/tabs.spec.ts +3294 -0
- package/e2e/regression/terminal.spec.ts +691 -0
- package/e2e/regression/timeline-cache.spec.ts +798 -0
- package/e2e/regression/timeline-geometry.spec.ts +1204 -0
- package/e2e/regression/timeline-history.spec.ts +1073 -0
- package/e2e/regression/timeline-stream.spec.ts +3409 -0
- package/e2e/regression/whats-new.spec.ts +242 -0
- package/e2e/reproduction/timeline-suspense/index.html +34 -0
- package/e2e/reproduction/timeline-suspense/main.tsx +335 -0
- package/e2e/reproduction/timeline-suspense/playwright.config.ts +34 -0
- package/e2e/reproduction/timeline-suspense/timeline-suspense.repro.ts +182 -0
- package/e2e/reproduction/timeline-suspense/vite.config.ts +7 -0
- package/e2e/screenshots/session-project-menu.png +0 -0
- package/e2e/service-worker/cache.spec.ts +573 -0
- package/e2e/service-worker/playwright.config.ts +14 -0
- package/e2e/stability/README.md +61 -0
- package/e2e/stability/adverse.spec.ts +279 -0
- package/e2e/stability/environment-matrix.spec.ts +128 -0
- package/e2e/stability/file-matrix.spec.ts +133 -0
- package/e2e/stability/file-mutation.spec.ts +126 -0
- package/e2e/stability/fixture.test.ts +80 -0
- package/e2e/stability/interaction.spec.ts +232 -0
- package/e2e/stability/lifecycle.spec.ts +175 -0
- package/e2e/stability/oracle-browser.spec.ts +81 -0
- package/e2e/stability/oracle.test.ts +388 -0
- package/e2e/stability/playwright.config.ts +31 -0
- package/e2e/stability/scroll-interaction.spec.ts +520 -0
- package/e2e/stability/shell-matrix.spec.ts +299 -0
- package/e2e/stability/tool-mutation.spec.ts +58 -0
- package/e2e/stability/tools.spec.ts +232 -0
- package/e2e/stability/transition-matrix.spec.ts +214 -0
- package/e2e/tsconfig.json +11 -0
- package/e2e/user-story/model-selection-flow.spec.ts +216 -0
- package/e2e/utils/app-direction.fixture.tsx +105 -0
- package/e2e/utils/app-direction.html +25 -0
- package/e2e/utils/app.ts +227 -0
- package/e2e/utils/command-palette.ts +62 -0
- package/e2e/utils/console.ts +23 -0
- package/e2e/utils/direction.ts +28 -0
- package/e2e/utils/drafts.ts +52 -0
- package/e2e/utils/errors.ts +14 -0
- package/e2e/utils/markdown-sessions.ts +120 -0
- package/e2e/utils/mock-api.ts +570 -0
- package/e2e/utils/mock-server.ts +1726 -0
- package/e2e/utils/notifications.ts +51 -0
- package/e2e/utils/persistent-pty.ts +546 -0
- package/e2e/utils/prompt-motion.ts +116 -0
- package/e2e/utils/serve.ts +65 -0
- package/e2e/utils/session-fixture.ts +472 -0
- package/e2e/utils/settings-wsl.fixture.tsx +416 -0
- package/e2e/utils/settings-wsl.html +27 -0
- package/e2e/utils/side-panel.ts +41 -0
- package/e2e/utils/sse-transport.ts +352 -0
- package/e2e/utils/terminal.ts +31 -0
- package/e2e/utils/timeline.ts +1141 -0
- package/e2e/utils/visual-stability/analyzer.ts +259 -0
- package/e2e/utils/visual-stability/capture.ts +57 -0
- package/e2e/utils/visual-stability/index.ts +15 -0
- package/e2e/utils/visual-stability/invariant.ts +113 -0
- package/e2e/utils/visual-stability/model.ts +47 -0
- package/e2e/utils/visual-stability/probe.ts +261 -0
- package/e2e/utils/visual-stability/regions.ts +18 -0
- package/e2e/utils/visual-stability/reporter.ts +71 -0
- package/e2e/utils/visual-stability/scenario.ts +21 -0
- package/e2e/utils/visual-stability.ts +52 -0
- package/e2e/utils/waits.ts +25 -0
- package/e2e/utils/windows-menu.fixture.tsx +99 -0
- package/e2e/utils/windows-menu.html +22 -0
- package/e2e/utils/workspace.ts +222 -0
- package/happydom.ts +77 -0
- package/index.html +29 -0
- package/manifest.json +36 -0
- package/package.json +83 -4
- package/perf/README.md +190 -0
- package/perf/composer.bench.ts +107 -0
- package/perf/desktop.bench.ts +22 -0
- package/perf/diff.bench.ts +104 -0
- package/perf/docks.bench.ts +109 -0
- package/perf/fixtures/composer.ts +166 -0
- package/perf/fixtures/diffs.ts +165 -0
- package/perf/fixtures/drag.ts +73 -0
- package/perf/fixtures/events.ts +106 -0
- package/perf/fixtures/home.ts +274 -0
- package/perf/fixtures/mock.ts +118 -0
- package/perf/fixtures/review.ts +33 -0
- package/perf/fixtures/scripts.ts +37 -0
- package/perf/fixtures/storage.ts +29 -0
- package/perf/fixtures/tabs.ts +21 -0
- package/perf/fixtures/timeline.ts +458 -0
- package/perf/home.bench.ts +74 -0
- package/perf/model-picker.bench.ts +168 -0
- package/perf/navigation.bench.ts +310 -0
- package/perf/question.bench.ts +85 -0
- package/perf/review.bench.ts +109 -0
- package/perf/send.bench.ts +54 -0
- package/perf/stream.bench.ts +108 -0
- package/perf/subagent-pill.bench.ts +348 -0
- package/perf/tabs.bench.ts +229 -0
- package/perf/timeline.bench.ts +167 -0
- package/playwright.components.config.ts +7 -0
- package/playwright.config.ts +85 -0
- package/public/_headers +28 -0
- package/public/assets/Inter.ttf +0 -0
- package/public/assets/JetBrainsMonoNerdFontMono-Bold.woff2 +0 -0
- package/public/assets/JetBrainsMonoNerdFontMono-Regular.woff2 +0 -0
- package/public/oc-theme-preload.js +33 -0
- package/src/app.tsx +142 -0
- package/src/components-lab/browser.tsx +745 -0
- package/src/components-lab/catalog.test.ts +58 -0
- package/src/components-lab/catalog.ts +195 -0
- package/src/components-lab/dialog-story-runtime.tsx +840 -0
- package/src/components-lab/focus-rings.stories.tsx +710 -0
- package/src/components-lab/focus-visibility.stories.tsx +2669 -0
- package/src/components-lab/force-focus.ts +52 -0
- package/src/components-lab/inspector.css +28 -0
- package/src/components-lab/lab.tsx +114 -0
- package/src/components-lab/machine.test.ts +177 -0
- package/src/components-lab/machine.ts +229 -0
- package/src/components-lab/motion.test.ts +17 -0
- package/src/components-lab/motion.ts +100 -0
- package/src/composer/adapter.ts +151 -0
- package/src/composer/attachments/attachments.css +123 -0
- package/src/composer/attachments/attachments.ts +363 -0
- package/src/composer/attachments/destination.ts +81 -0
- package/src/composer/attachments/upload-machine.ts +185 -0
- package/src/composer/attachments/uploads.test.ts +127 -0
- package/src/composer/attachments/uploads.tsx +228 -0
- package/src/composer/client-slash-command.test.ts +20 -0
- package/src/composer/client-slash-command.ts +28 -0
- package/src/composer/commands.tsx +175 -0
- package/src/composer/comment-focus-machine.test.ts +112 -0
- package/src/composer/comment-focus-machine.ts +141 -0
- package/src/composer/comment-note.test.ts +82 -0
- package/src/composer/comment-note.ts +127 -0
- package/src/composer/comments.test.ts +109 -0
- package/src/composer/comments.tsx +279 -0
- package/src/composer/composer-touch.stories.tsx +298 -0
- package/src/composer/composer.stories.tsx +765 -0
- package/src/composer/composer.tsx +244 -0
- package/src/composer/dropzone.tsx +92 -0
- package/src/composer/editor/actions.test.ts +176 -0
- package/src/composer/editor/actions.ts +191 -0
- package/src/composer/editor/dom.test.ts +168 -0
- package/src/composer/editor/dom.ts +274 -0
- package/src/composer/editor/editor.css +101 -0
- package/src/composer/editor/editor.tsx +1764 -0
- package/src/composer/editor/interaction.test.ts +13 -0
- package/src/composer/editor/interaction.ts +838 -0
- package/src/composer/editor/machine.test.ts +47 -0
- package/src/composer/editor/machine.ts +63 -0
- package/src/composer/editor/mention-search-machine.test.ts +111 -0
- package/src/composer/editor/mention-search-machine.ts +226 -0
- package/src/composer/editor/quote-comment.stories.tsx +133 -0
- package/src/composer/editor/quote-comment.tsx +191 -0
- package/src/composer/history/entry.test.ts +100 -0
- package/src/composer/history/entry.ts +140 -0
- package/src/composer/history/store.ts +83 -0
- package/src/composer/machine.test.ts +459 -0
- package/src/composer/machine.ts +561 -0
- package/src/composer/media.ts +18 -0
- package/src/composer/model-chip-machine.test.ts +96 -0
- package/src/composer/model-chip-machine.ts +82 -0
- package/src/composer/model-label.test.ts +177 -0
- package/src/composer/model-label.ts +120 -0
- package/src/composer/model.ts +683 -0
- package/src/composer/persistence.tsx +163 -0
- package/src/composer/prompt-parts.ts +52 -0
- package/src/composer/prompt-status-machine.test.ts +76 -0
- package/src/composer/prompt-status-machine.ts +48 -0
- package/src/composer/prompt.test.ts +320 -0
- package/src/composer/prompt.ts +334 -0
- package/src/composer/quote-comment-machine.test.ts +154 -0
- package/src/composer/quote-comment-machine.ts +211 -0
- package/src/composer/quote-position.ts +32 -0
- package/src/composer/quote-source.ts +48 -0
- package/src/composer/reload-machine.ts +51 -0
- package/src/composer/request.test.ts +360 -0
- package/src/composer/request.ts +245 -0
- package/src/composer/retry.test.ts +107 -0
- package/src/composer/retry.ts +63 -0
- package/src/composer/schema.test.ts +317 -0
- package/src/composer/schema.ts +424 -0
- package/src/composer/selection.ts +354 -0
- package/src/composer/session-match.test.ts +20 -0
- package/src/composer/session-match.ts +18 -0
- package/src/composer/state.ts +271 -0
- package/src/composer/submission-state.ts +3 -0
- package/src/composer/submit.test.ts +1785 -0
- package/src/composer/submit.ts +1073 -0
- package/src/composer/suggestions/machine.test.ts +420 -0
- package/src/composer/suggestions/machine.ts +573 -0
- package/src/composer/types.ts +60 -0
- package/src/desktop.ts +25 -0
- package/src/entry.tsx +119 -0
- package/src/env.d.ts +41 -0
- package/src/home/home.standalone.stories.tsx +260 -0
- package/src/home/machine.test.ts +286 -0
- package/src/home/machine.ts +344 -0
- package/src/home/model.ts +162 -0
- package/src/home/projects/actions.tsx +189 -0
- package/src/home/projects/add.ts +10 -0
- package/src/home/projects/browse-view.tsx +264 -0
- package/src/home/projects/browse.tsx +33 -0
- package/src/home/projects/controller.tsx +109 -0
- package/src/home/projects/file-manager.ts +26 -0
- package/src/home/projects/import-machine.test.ts +117 -0
- package/src/home/projects/import-machine.ts +133 -0
- package/src/home/projects/landing.tsx +77 -0
- package/src/home/projects/menu.tsx +70 -0
- package/src/home/projects/region.tsx +63 -0
- package/src/home/projects/reveal.ts +39 -0
- package/src/home/projects/start.ts +114 -0
- package/src/home/projects/view.css +79 -0
- package/src/home/projects/view.tsx +763 -0
- package/src/home/route.tsx +177 -0
- package/src/home/scroll.ts +180 -0
- package/src/home/sessions/alt-hold.test.ts +45 -0
- package/src/home/sessions/alt-hold.ts +20 -0
- package/src/home/sessions/archive.test.ts +51 -0
- package/src/home/sessions/archive.ts +25 -0
- package/src/home/sessions/controller.tsx +669 -0
- package/src/home/sessions/delete-dialog.stories.tsx +70 -0
- package/src/home/sessions/index.test.ts +171 -0
- package/src/home/sessions/index.ts +60 -0
- package/src/home/sessions/load-machine.test.ts +223 -0
- package/src/home/sessions/load-machine.ts +430 -0
- package/src/home/sessions/open.test.ts +16 -0
- package/src/home/sessions/open.ts +18 -0
- package/src/home/sessions/queries.ts +95 -0
- package/src/home/sessions/records.test.ts +85 -0
- package/src/home/sessions/records.ts +58 -0
- package/src/home/sessions/region.tsx +66 -0
- package/src/home/sessions/row-machine.test.ts +203 -0
- package/src/home/sessions/row-machine.ts +365 -0
- package/src/home/sessions/search-machine.test.ts +117 -0
- package/src/home/sessions/search-machine.ts +181 -0
- package/src/home/sessions/search.ts +218 -0
- package/src/home/sessions/view.css +101 -0
- package/src/home/sessions/view.tsx +1123 -0
- package/src/home/start/command-palette.tsx +88 -0
- package/src/index.css +419 -0
- package/src/index.ts +5 -0
- package/src/new-session/brick-breaker-machine.test.ts +120 -0
- package/src/new-session/brick-breaker-machine.ts +110 -0
- package/src/new-session/brick-breaker.tsx +551 -0
- package/src/new-session/commands.tsx +61 -0
- package/src/new-session/composer-adapter.ts +309 -0
- package/src/new-session/draft.standalone.stories.tsx +214 -0
- package/src/new-session/layout.ts +2 -0
- package/src/new-session/location/dialog.css +204 -0
- package/src/new-session/location/dialog.standalone.stories.tsx +122 -0
- package/src/new-session/location/dialog.tsx +677 -0
- package/src/new-session/location/machine.test.ts +180 -0
- package/src/new-session/location/machine.ts +239 -0
- package/src/new-session/machine.test.ts +344 -0
- package/src/new-session/machine.ts +293 -0
- package/src/new-session/mcp.ts +132 -0
- package/src/new-session/pin-board-machine.test.ts +116 -0
- package/src/new-session/pin-board-machine.ts +188 -0
- package/src/new-session/pin-board.tsx +1072 -0
- package/src/new-session/pin-quads.ts +252 -0
- package/src/new-session/pin-sound.ts +193 -0
- package/src/new-session/project/controller.ts +111 -0
- package/src/new-session/project/selector.test.tsx +101 -0
- package/src/new-session/project/selector.tsx +108 -0
- package/src/new-session/route.tsx +115 -0
- package/src/new-session/screen.tsx +107 -0
- package/src/new-session/view.tsx +424 -0
- package/src/new-session/wordmark-machine.test.ts +236 -0
- package/src/new-session/wordmark-machine.ts +237 -0
- package/src/new-session/wordmark.css +71 -0
- package/src/new-session/wordmark.stories.tsx +109 -0
- package/src/new-session/wordmark.tsx +1222 -0
- package/src/new-session/workspace/branch-machine.test.ts +243 -0
- package/src/new-session/workspace/branch-machine.ts +233 -0
- package/src/new-session/workspace/checkout-machine.test.ts +73 -0
- package/src/new-session/workspace/checkout-machine.ts +69 -0
- package/src/new-session/workspace/controller.test.ts +82 -0
- package/src/new-session/workspace/controller.ts +291 -0
- package/src/new-session/workspace/selector.tsx +230 -0
- package/src/providers/catalog/console-settle.ts +80 -0
- package/src/providers/catalog/console.test.ts +21 -0
- package/src/providers/catalog/console.ts +37 -0
- package/src/providers/catalog/integrations.ts +30 -0
- package/src/providers/catalog/order.ts +10 -0
- package/src/providers/catalog/plugin.ts +15 -0
- package/src/providers/catalog/providers.ts +111 -0
- package/src/providers/catalog/settle-machine.test.ts +123 -0
- package/src/providers/catalog/settle-machine.ts +109 -0
- package/src/providers/connect/chatgpt-usage-limit.stories.tsx +25 -0
- package/src/providers/connect/chatgpt-usage-limit.tsx +83 -0
- package/src/providers/connect/chatgpt-welcome.stories.tsx +23 -0
- package/src/providers/connect/chatgpt-welcome.tsx +37 -0
- package/src/providers/connect/console.tsx +67 -0
- package/src/providers/connect/controller.ts +672 -0
- package/src/providers/connect/dialog-machine.test.ts +654 -0
- package/src/providers/connect/dialog-machine.ts +875 -0
- package/src/providers/connect/dialog.standalone.stories.tsx +187 -0
- package/src/providers/connect/dialog.tsx +1564 -0
- package/src/providers/connect/form-machine.test.ts +200 -0
- package/src/providers/connect/form-machine.ts +419 -0
- package/src/providers/connect/go-upsell-hero-art.test.ts +194 -0
- package/src/providers/connect/go-upsell-hero-art.ts +749 -0
- package/src/providers/connect/go-upsell-hero-machine.test.ts +88 -0
- package/src/providers/connect/go-upsell-hero-machine.ts +68 -0
- package/src/providers/connect/go-upsell-hero.tsx +17 -0
- package/src/providers/connect/machine.test.ts +513 -0
- package/src/providers/connect/machine.ts +644 -0
- package/src/providers/connect/mcp-dialog.stories.tsx +89 -0
- package/src/providers/connect/mcp-dialog.tsx +316 -0
- package/src/providers/connect/mcp-machine.test.ts +239 -0
- package/src/providers/connect/mcp-machine.ts +328 -0
- package/src/providers/connect/mcp-sign-in.tsx +112 -0
- package/src/providers/connect/mcp.tsx +298 -0
- package/src/providers/connect/models.css +71 -0
- package/src/providers/connect/remote.test.ts +50 -0
- package/src/providers/connect/remote.tsx +10 -0
- package/src/providers/connect/step-actions.tsx +18 -0
- package/src/providers/connect/tip.tsx +110 -0
- package/src/providers/connect/usage-exceeded.tsx +62 -0
- package/src/providers/custom-managed-provider.svg +31 -0
- package/src/providers/models/agent.test.ts +25 -0
- package/src/providers/models/agent.ts +7 -0
- package/src/providers/models/configured.ts +33 -0
- package/src/providers/models/details.tsx +168 -0
- package/src/providers/models/manage.css +97 -0
- package/src/providers/models/manage.standalone.stories.tsx +59 -0
- package/src/providers/models/manage.tsx +170 -0
- package/src/providers/models/models.test.ts +55 -0
- package/src/providers/models/models.tsx +279 -0
- package/src/providers/models/provider-group.tsx +293 -0
- package/src/providers/models/search.test.ts +13 -0
- package/src/providers/models/search.ts +20 -0
- package/src/providers/models/select-dialog-machine.test.ts +455 -0
- package/src/providers/models/select-dialog-machine.ts +702 -0
- package/src/providers/models/select-dialog.css +240 -0
- package/src/providers/models/select-dialog.standalone.stories.tsx +225 -0
- package/src/providers/models/select-dialog.tsx +1359 -0
- package/src/providers/models/selection-machine.test.ts +290 -0
- package/src/providers/models/selection-machine.ts +408 -0
- package/src/providers/models/selection.tsx +787 -0
- package/src/providers/models/speed.test.ts +17 -0
- package/src/providers/models/speed.ts +17 -0
- package/src/providers/models/tooltip.tsx +152 -0
- package/src/providers/models/unpaid.standalone.stories.tsx +76 -0
- package/src/providers/models/unpaid.tsx +199 -0
- package/src/providers/models/variant.test.ts +79 -0
- package/src/providers/models/variant.ts +74 -0
- package/src/providers/opencode-logo.tsx +17 -0
- package/src/runtime/animated-presence.ts +66 -0
- package/src/runtime/array-move.test.ts +19 -0
- package/src/runtime/array-move.ts +8 -0
- package/src/runtime/i18n/am.ts +1409 -0
- package/src/runtime/i18n/ar.ts +1560 -0
- package/src/runtime/i18n/az.ts +1481 -0
- package/src/runtime/i18n/bg.ts +1491 -0
- package/src/runtime/i18n/bn.ts +1477 -0
- package/src/runtime/i18n/br.ts +1527 -0
- package/src/runtime/i18n/bs.ts +1561 -0
- package/src/runtime/i18n/ca.ts +1523 -0
- package/src/runtime/i18n/cs.ts +1520 -0
- package/src/runtime/i18n/da.ts +1527 -0
- package/src/runtime/i18n/de.ts +1517 -0
- package/src/runtime/i18n/desktop-native.test.ts +84 -0
- package/src/runtime/i18n/desktop-native.ts +366 -0
- package/src/runtime/i18n/dv.ts +1519 -0
- package/src/runtime/i18n/dz.ts +1504 -0
- package/src/runtime/i18n/el.ts +1509 -0
- package/src/runtime/i18n/en.ts +1560 -0
- package/src/runtime/i18n/es.ts +1583 -0
- package/src/runtime/i18n/et.ts +1456 -0
- package/src/runtime/i18n/fa.ts +1470 -0
- package/src/runtime/i18n/fi.ts +1472 -0
- package/src/runtime/i18n/fo.ts +1469 -0
- package/src/runtime/i18n/fr.ts +1543 -0
- package/src/runtime/i18n/he.ts +1455 -0
- package/src/runtime/i18n/hi.ts +1475 -0
- package/src/runtime/i18n/hr.ts +1506 -0
- package/src/runtime/i18n/hu.ts +1492 -0
- package/src/runtime/i18n/hy.ts +1478 -0
- package/src/runtime/i18n/id.ts +1541 -0
- package/src/runtime/i18n/is.ts +1468 -0
- package/src/runtime/i18n/it.ts +1517 -0
- package/src/runtime/i18n/ja.ts +1484 -0
- package/src/runtime/i18n/ka.ts +1476 -0
- package/src/runtime/i18n/km.ts +1461 -0
- package/src/runtime/i18n/ko.ts +1469 -0
- package/src/runtime/i18n/language.test.ts +35 -0
- package/src/runtime/i18n/language.tsx +468 -0
- package/src/runtime/i18n/lo.ts +1454 -0
- package/src/runtime/i18n/lt.ts +1529 -0
- package/src/runtime/i18n/lv.ts +1509 -0
- package/src/runtime/i18n/machine.test.ts +148 -0
- package/src/runtime/i18n/machine.ts +164 -0
- package/src/runtime/i18n/mk.ts +1488 -0
- package/src/runtime/i18n/mn.ts +1485 -0
- package/src/runtime/i18n/ms.ts +1480 -0
- package/src/runtime/i18n/my.ts +1489 -0
- package/src/runtime/i18n/ne.ts +1478 -0
- package/src/runtime/i18n/nl.ts +1491 -0
- package/src/runtime/i18n/no.ts +1536 -0
- package/src/runtime/i18n/pa.ts +1478 -0
- package/src/runtime/i18n/pl.ts +1540 -0
- package/src/runtime/i18n/ro.ts +1511 -0
- package/src/runtime/i18n/ru.ts +1596 -0
- package/src/runtime/i18n/si.ts +1477 -0
- package/src/runtime/i18n/sk.ts +1526 -0
- package/src/runtime/i18n/sl.ts +1527 -0
- package/src/runtime/i18n/sq.ts +1480 -0
- package/src/runtime/i18n/sr.ts +1502 -0
- package/src/runtime/i18n/sv.ts +1478 -0
- package/src/runtime/i18n/tg.ts +1493 -0
- package/src/runtime/i18n/th.ts +1505 -0
- package/src/runtime/i18n/tk.ts +1472 -0
- package/src/runtime/i18n/tr.ts +1550 -0
- package/src/runtime/i18n/uk.ts +1598 -0
- package/src/runtime/i18n/ur.ts +1488 -0
- package/src/runtime/i18n/uz.ts +1490 -0
- package/src/runtime/i18n/vi.ts +1473 -0
- package/src/runtime/i18n/zh.ts +1474 -0
- package/src/runtime/i18n/zht.ts +1468 -0
- package/src/runtime/persistence/README.md +151 -0
- package/src/runtime/persistence/base64.ts +11 -0
- package/src/runtime/persistence/consumers.test.ts +168 -0
- package/src/runtime/persistence/drafts-machine.test.ts +214 -0
- package/src/runtime/persistence/drafts-machine.ts +385 -0
- package/src/runtime/persistence/drafts.test.ts +515 -0
- package/src/runtime/persistence/drafts.ts +687 -0
- package/src/runtime/persistence/equality.ts +9 -0
- package/src/runtime/persistence/namespace-machine.test.ts +232 -0
- package/src/runtime/persistence/namespace-machine.ts +304 -0
- package/src/runtime/persistence/namespace.test.ts +304 -0
- package/src/runtime/persistence/namespace.ts +126 -0
- package/src/runtime/persistence/persist-machine.test.ts +185 -0
- package/src/runtime/persistence/persist-machine.ts +192 -0
- package/src/runtime/persistence/persist.test.ts +243 -0
- package/src/runtime/persistence/persist.ts +159 -0
- package/src/runtime/persistence/schema.test.ts +208 -0
- package/src/runtime/persistence/schema.ts +130 -0
- package/src/runtime/persistence/storage-machine.test.ts +61 -0
- package/src/runtime/persistence/storage-machine.ts +57 -0
- package/src/runtime/persistence/storage.test.ts +70 -0
- package/src/runtime/persistence/storage.ts +707 -0
- package/src/runtime/platform/base-path-router.tsx +66 -0
- package/src/runtime/platform/base-path.test.ts +50 -0
- package/src/runtime/platform/base-path.ts +28 -0
- package/src/runtime/platform/drag-out.test.ts +58 -0
- package/src/runtime/platform/drag-out.ts +53 -0
- package/src/runtime/platform/external-link.tsx +21 -0
- package/src/runtime/platform/keyboard.ts +41 -0
- package/src/runtime/platform/platform.tsx +185 -0
- package/src/runtime/platform/pwa.ts +50 -0
- package/src/runtime/platform/web.ts +63 -0
- package/src/runtime/plugin/app-links.test.ts +17 -0
- package/src/runtime/plugin/app-links.ts +88 -0
- package/src/runtime/plugin/attach-machine.test.ts +174 -0
- package/src/runtime/plugin/attach-machine.ts +152 -0
- package/src/runtime/plugin/attachment.ts +15 -0
- package/src/runtime/plugin/builtins.ts +15 -0
- package/src/runtime/plugin/closed-tabs-view.tsx +315 -0
- package/src/runtime/plugin/closed-tabs.test.ts +82 -0
- package/src/runtime/plugin/closed-tabs.ts +196 -0
- package/src/runtime/plugin/commands.test.ts +23 -0
- package/src/runtime/plugin/commands.tsx +86 -0
- package/src/runtime/plugin/composer-write-machine.test.ts +151 -0
- package/src/runtime/plugin/composer-write-machine.ts +111 -0
- package/src/runtime/plugin/deferred-menu-machine.test.ts +127 -0
- package/src/runtime/plugin/deferred-menu-machine.ts +163 -0
- package/src/runtime/plugin/dialog-machine.test.ts +62 -0
- package/src/runtime/plugin/dialog-machine.ts +81 -0
- package/src/runtime/plugin/dialogs.stories.tsx +66 -0
- package/src/runtime/plugin/dialogs.tsx +177 -0
- package/src/runtime/plugin/embed-flight-machine.test.ts +350 -0
- package/src/runtime/plugin/embed-flight-machine.ts +468 -0
- package/src/runtime/plugin/embed-geometry.test.ts +18 -0
- package/src/runtime/plugin/embed-geometry.ts +19 -0
- package/src/runtime/plugin/embed-snapshot-machine.test.ts +242 -0
- package/src/runtime/plugin/embed-snapshot-machine.ts +267 -0
- package/src/runtime/plugin/embeds.tsx +773 -0
- package/src/runtime/plugin/extension-plugins.tsx +299 -0
- package/src/runtime/plugin/hmr.tsx +33 -0
- package/src/runtime/plugin/host-apis.tsx +1315 -0
- package/src/runtime/plugin/host-layout-machine.test.ts +214 -0
- package/src/runtime/plugin/host-layout-machine.ts +269 -0
- package/src/runtime/plugin/host.tsx +1106 -0
- package/src/runtime/plugin/instance-machine.test.ts +387 -0
- package/src/runtime/plugin/instance-machine.ts +409 -0
- package/src/runtime/plugin/ipc-machine.test.ts +172 -0
- package/src/runtime/plugin/ipc-machine.ts +213 -0
- package/src/runtime/plugin/ipc.test.ts +166 -0
- package/src/runtime/plugin/ipc.ts +220 -0
- package/src/runtime/plugin/link-check-machine.test.ts +115 -0
- package/src/runtime/plugin/link-check-machine.ts +142 -0
- package/src/runtime/plugin/link-check.ts +82 -0
- package/src/runtime/plugin/located-machine.test.ts +124 -0
- package/src/runtime/plugin/located-machine.ts +125 -0
- package/src/runtime/plugin/located.ts +82 -0
- package/src/runtime/plugin/machine.test.ts +222 -0
- package/src/runtime/plugin/machine.ts +318 -0
- package/src/runtime/plugin/menubar-items.ts +28 -0
- package/src/runtime/plugin/mobile.tsx +199 -0
- package/src/runtime/plugin/module.test.ts +57 -0
- package/src/runtime/plugin/module.ts +64 -0
- package/src/runtime/plugin/mounted-session.ts +420 -0
- package/src/runtime/plugin/new-tab-machine.test.ts +207 -0
- package/src/runtime/plugin/new-tab-machine.ts +240 -0
- package/src/runtime/plugin/pane-drag-machine.test.ts +217 -0
- package/src/runtime/plugin/pane-drag-machine.ts +263 -0
- package/src/runtime/plugin/pane-drag.tsx +290 -0
- package/src/runtime/plugin/panel-keys.ts +15 -0
- package/src/runtime/plugin/panel-menu.ts +29 -0
- package/src/runtime/plugin/panel-trigger.tsx +180 -0
- package/src/runtime/plugin/panels.tsx +733 -0
- package/src/runtime/plugin/plugin-gui-machine.test.ts +186 -0
- package/src/runtime/plugin/plugin-gui-machine.ts +178 -0
- package/src/runtime/plugin/plugins.tsx +137 -0
- package/src/runtime/plugin/prompt-gate.test.ts +113 -0
- package/src/runtime/plugin/prompt-gate.ts +36 -0
- package/src/runtime/plugin/render.tsx +348 -0
- package/src/runtime/plugin/root.tsx +141 -0
- package/src/runtime/plugin/server-shell.tsx +113 -0
- package/src/runtime/plugin/servers.tsx +270 -0
- package/src/runtime/plugin/session-store-machine.test.ts +82 -0
- package/src/runtime/plugin/session-store-machine.ts +140 -0
- package/src/runtime/plugin/settings-page-view.tsx +53 -0
- package/src/runtime/plugin/settings-pages.ts +23 -0
- package/src/runtime/plugin/side-region.tsx +635 -0
- package/src/runtime/plugin/startup.ts +107 -0
- package/src/runtime/plugin/store-machine.test.ts +69 -0
- package/src/runtime/plugin/store-machine.ts +139 -0
- package/src/runtime/plugin/stores.ts +339 -0
- package/src/runtime/plugin/tab-strip-scroll.test.ts +40 -0
- package/src/runtime/plugin/tab-strip-scroll.ts +130 -0
- package/src/runtime/plugin/titlebar-items.css +20 -0
- package/src/runtime/plugin/titlebar-items.stories.tsx +97 -0
- package/src/runtime/plugin/titlebar-items.tsx +96 -0
- package/src/runtime/plugin/ui.tsx +292 -0
- package/src/runtime/plugin/web-href.test.ts +11 -0
- package/src/runtime/plugin/web-href.ts +10 -0
- package/src/runtime/polyfills.test.ts +61 -0
- package/src/runtime/polyfills.ts +39 -0
- package/src/runtime/presence-machine.test.ts +260 -0
- package/src/runtime/presence-machine.ts +329 -0
- package/src/runtime/presence.ts +165 -0
- package/src/runtime/server/api.test.ts +64 -0
- package/src/runtime/server/api.ts +58 -0
- package/src/runtime/server/client.test.ts +131 -0
- package/src/runtime/server/client.tsx +308 -0
- package/src/runtime/server/current.tsx +55 -0
- package/src/runtime/server/data.test.ts +440 -0
- package/src/runtime/server/data.ts +286 -0
- package/src/runtime/server/errors.test.ts +151 -0
- package/src/runtime/server/errors.ts +135 -0
- package/src/runtime/server/global-sync/bootstrap.test.ts +179 -0
- package/src/runtime/server/global-sync/bootstrap.ts +96 -0
- package/src/runtime/server/global-sync/child-store.test.ts +47 -0
- package/src/runtime/server/global-sync/child-store.ts +206 -0
- package/src/runtime/server/global-sync/machine.test.ts +96 -0
- package/src/runtime/server/global-sync/machine.ts +84 -0
- package/src/runtime/server/global-sync/types.ts +46 -0
- package/src/runtime/server/global-sync/utils.test.ts +154 -0
- package/src/runtime/server/global-sync/utils.ts +165 -0
- package/src/runtime/server/health-machine.test.ts +227 -0
- package/src/runtime/server/health-machine.ts +357 -0
- package/src/runtime/server/health.test.ts +169 -0
- package/src/runtime/server/health.ts +236 -0
- package/src/runtime/server/image.test.ts +214 -0
- package/src/runtime/server/image.ts +40 -0
- package/src/runtime/server/loopback.test.ts +17 -0
- package/src/runtime/server/loopback.ts +22 -0
- package/src/runtime/server/machine.test.ts +162 -0
- package/src/runtime/server/machine.ts +275 -0
- package/src/runtime/server/media.ts +88 -0
- package/src/runtime/server/persistence.test.ts +117 -0
- package/src/runtime/server/persistence.ts +105 -0
- package/src/runtime/server/plugin-machine.test.ts +128 -0
- package/src/runtime/server/plugin-machine.ts +170 -0
- package/src/runtime/server/refcount.test.ts +30 -0
- package/src/runtime/server/refcount.ts +37 -0
- package/src/runtime/server/registry.test.ts +152 -0
- package/src/runtime/server/registry.tsx +363 -0
- package/src/runtime/server/request-queue-machine.test.ts +151 -0
- package/src/runtime/server/request-queue-machine.ts +307 -0
- package/src/runtime/server/request-queue.test.ts +315 -0
- package/src/runtime/server/request-queue.ts +173 -0
- package/src/runtime/server/runtime.tsx +396 -0
- package/src/runtime/server/scope.test.ts +52 -0
- package/src/runtime/server/scope.ts +69 -0
- package/src/runtime/server/scoped-cache.test.ts +72 -0
- package/src/runtime/server/scoped-cache.ts +119 -0
- package/src/runtime/server/server-sync/connection.ts +34 -0
- package/src/runtime/server/server-sync/endpoint-machine.test.ts +87 -0
- package/src/runtime/server/server-sync/endpoint-machine.ts +62 -0
- package/src/runtime/server/server-sync/machine.test.ts +86 -0
- package/src/runtime/server/server-sync/machine.ts +70 -0
- package/src/runtime/server/session-index.ts +23 -0
- package/src/runtime/server/sync.tsx +206 -0
- package/src/runtime/server/types.ts +151 -0
- package/src/servers/connect/browser.ts +15 -0
- package/src/servers/connect/connect.fixture.tsx +222 -0
- package/src/servers/connect/controller.ts +237 -0
- package/src/servers/connect/dialog.stories.tsx +67 -0
- package/src/servers/connect/dialog.tsx +255 -0
- package/src/servers/connect/machine.test.ts +487 -0
- package/src/servers/connect/machine.ts +427 -0
- package/src/servers/connect/method.tsx +31 -0
- package/src/servers/connect/pairing.test.ts +67 -0
- package/src/servers/connect/pairing.ts +134 -0
- package/src/servers/connect/redeem.ts +50 -0
- package/src/servers/connect/scanner-machine.test.ts +114 -0
- package/src/servers/connect/scanner-machine.ts +164 -0
- package/src/servers/connect/scanner.css +47 -0
- package/src/servers/connect/scanner.tsx +173 -0
- package/src/servers/connect/screen.css +108 -0
- package/src/servers/connect/screen.stories.tsx +63 -0
- package/src/servers/connect/screen.tsx +164 -0
- package/src/servers/registry/add-menu.tsx +62 -0
- package/src/servers/registry/controller.test.ts +26 -0
- package/src/servers/registry/controller.ts +86 -0
- package/src/servers/registry/label.tsx +23 -0
- package/src/servers/registry/management.test.ts +40 -0
- package/src/servers/registry/management.ts +17 -0
- package/src/servers/registry/plugin-row.tsx +57 -0
- package/src/servers/registry/row-items.tsx +18 -0
- package/src/servers/registry/row-menu.tsx +152 -0
- package/src/servers/registry/row.stories.tsx +51 -0
- package/src/servers/registry/row.tsx +47 -0
- package/src/session/commands/dialog-jump-to-message.tsx +197 -0
- package/src/session/commands/export-machine.test.ts +99 -0
- package/src/session/commands/export-machine.ts +117 -0
- package/src/session/commands/export-session.tsx +108 -0
- package/src/session/commands/export.test.ts +105 -0
- package/src/session/commands/export.ts +89 -0
- package/src/session/commands/fork-dialog.stories.tsx +68 -0
- package/src/session/commands/fork-dialog.tsx +198 -0
- package/src/session/commands/jump-to-message-machine.test.ts +123 -0
- package/src/session/commands/jump-to-message-machine.ts +161 -0
- package/src/session/commands/jump-to-message.stories.tsx +226 -0
- package/src/session/commands/jump-to-message.tsx +161 -0
- package/src/session/commands/machine.test.ts +305 -0
- package/src/session/commands/machine.ts +272 -0
- package/src/session/commands/rename-session.ts +31 -0
- package/src/session/commands/use-session-commands.tsx +813 -0
- package/src/session/composer/activity-chips.css +242 -0
- package/src/session/composer/activity-chips.stories.tsx +280 -0
- package/src/session/composer/activity-chips.tsx +485 -0
- package/src/session/composer/adapter.ts +74 -0
- package/src/session/composer/composer-docks.stories.tsx +278 -0
- package/src/session/composer/composer-lane.css +93 -0
- package/src/session/composer/composer-lane.tsx +45 -0
- package/src/session/composer/controller.ts +86 -0
- package/src/session/composer/focus-machine.test.ts +285 -0
- package/src/session/composer/focus-machine.ts +212 -0
- package/src/session/composer/focus.tsx +161 -0
- package/src/session/composer/free-limit-panel.standalone.stories.tsx +45 -0
- package/src/session/composer/free-limit-panel.tsx +133 -0
- package/src/session/composer/go-limit-tray.tsx +137 -0
- package/src/session/composer/location-missing-machine.test.ts +97 -0
- package/src/session/composer/location-missing-machine.ts +144 -0
- package/src/session/composer/location-missing.css +73 -0
- package/src/session/composer/location-missing.standalone.stories.tsx +161 -0
- package/src/session/composer/location-missing.tsx +193 -0
- package/src/session/composer/plugin-pills.tsx +215 -0
- package/src/session/composer/queue-machine.test.ts +565 -0
- package/src/session/composer/queue-machine.ts +934 -0
- package/src/session/composer/queue-panel-machine.test.ts +121 -0
- package/src/session/composer/queue-panel-machine.ts +229 -0
- package/src/session/composer/queue-panel.css +10 -0
- package/src/session/composer/queue-panel.stories.tsx +86 -0
- package/src/session/composer/queue-panel.tsx +314 -0
- package/src/session/composer/queue.test.ts +314 -0
- package/src/session/composer/queue.ts +610 -0
- package/src/session/composer/recovery-story.tsx +38 -0
- package/src/session/composer/region.tsx +689 -0
- package/src/session/composer/selection.test.ts +28 -0
- package/src/session/composer/selection.ts +28 -0
- package/src/session/composer/session-composer-region-controller.ts +28 -0
- package/src/session/composer/session-composer-region.tsx +115 -0
- package/src/session/composer/shell-panel-machine.test.ts +261 -0
- package/src/session/composer/shell-panel-machine.ts +338 -0
- package/src/session/composer/shell-panel.ts +181 -0
- package/src/session/composer/spring-height-machine.test.ts +380 -0
- package/src/session/composer/spring-height-machine.ts +489 -0
- package/src/session/composer/spring-height.tsx +586 -0
- package/src/session/composer/subagent-bar.tsx +116 -0
- package/src/session/composer/timeline-actions.ts +49 -0
- package/src/session/composer/todo-pill.css +32 -0
- package/src/session/composer/todo-pill.stories.tsx +158 -0
- package/src/session/composer/todo-pill.tsx +157 -0
- package/src/session/composer/todos.ts +43 -0
- package/src/session/delete-machine.test.ts +83 -0
- package/src/session/delete-machine.ts +128 -0
- package/src/session/fork-machine.test.ts +152 -0
- package/src/session/fork-machine.ts +169 -0
- package/src/session/fork.ts +164 -0
- package/src/session/handoff-machine.test.ts +262 -0
- package/src/session/handoff-machine.ts +256 -0
- package/src/session/handoff.ts +112 -0
- package/src/session/header/drag-area.tsx +86 -0
- package/src/session/header/fit-machine.test.ts +143 -0
- package/src/session/header/fit-machine.ts +95 -0
- package/src/session/header/fit.ts +134 -0
- package/src/session/header/separator.tsx +22 -0
- package/src/session/header/session-header-actions.stories.tsx +45 -0
- package/src/session/header/session-header-actions.tsx +89 -0
- package/src/session/header/session-header.tsx +12 -0
- package/src/session/header/session-working-indicator.tsx +44 -0
- package/src/session/helpers.ts +42 -0
- package/src/session/list.test.ts +64 -0
- package/src/session/list.ts +18 -0
- package/src/session/message-id-from-hash.test.ts +10 -0
- package/src/session/message-id-from-hash.ts +8 -0
- package/src/session/model.ts +150 -0
- package/src/session/preparing-composer.tsx +72 -0
- package/src/session/question-switch.stories.tsx +380 -0
- package/src/session/requests/auto-approve-machine.test.ts +345 -0
- package/src/session/requests/auto-approve-machine.ts +247 -0
- package/src/session/requests/auto-approve.ts +274 -0
- package/src/session/requests/background.ts +312 -0
- package/src/session/requests/elicitation-controller.ts +129 -0
- package/src/session/requests/elicitation-machine.test.ts +209 -0
- package/src/session/requests/elicitation-machine.ts +277 -0
- package/src/session/requests/job-list.test.ts +18 -0
- package/src/session/requests/model.ts +348 -0
- package/src/session/requests/permission-machine.test.ts +130 -0
- package/src/session/requests/permission-machine.ts +105 -0
- package/src/session/requests/question-controller.ts +130 -0
- package/src/session/requests/question-keys.test.ts +106 -0
- package/src/session/requests/question-keys.ts +81 -0
- package/src/session/requests/question-machine.test.ts +257 -0
- package/src/session/requests/question-machine.ts +293 -0
- package/src/session/requests/question-motion.ts +26 -0
- package/src/session/requests/question-state.ts +21 -0
- package/src/session/requests/question-switch-machine.test.ts +114 -0
- package/src/session/requests/question-switch-machine.ts +130 -0
- package/src/session/requests/session-elicitation-dock.css +49 -0
- package/src/session/requests/session-elicitation-dock.tsx +223 -0
- package/src/session/requests/session-permission-dock.tsx +108 -0
- package/src/session/requests/session-question-dock-classic.tsx +726 -0
- package/src/session/requests/session-question-dock-experimental.tsx +1510 -0
- package/src/session/requests/session-question-dock.tsx +15 -0
- package/src/session/requests/session-request-tree.test.ts +119 -0
- package/src/session/requests/session-request-tree.ts +87 -0
- package/src/session/requests/session-websearch-dock.css +61 -0
- package/src/session/requests/session-websearch-dock.tsx +112 -0
- package/src/session/requests/steer-background.test.ts +66 -0
- package/src/session/requests/steer-background.ts +28 -0
- package/src/session/requests/websearch-machine.test.ts +425 -0
- package/src/session/requests/websearch-machine.ts +627 -0
- package/src/session/requests/websearch.ts +152 -0
- package/src/session/resolution-machine.test.ts +414 -0
- package/src/session/resolution-machine.ts +330 -0
- package/src/session/revert-machine.test.ts +365 -0
- package/src/session/revert-machine.ts +345 -0
- package/src/session/revert.ts +340 -0
- package/src/session/route-error.tsx +73 -0
- package/src/session/route.tsx +299 -0
- package/src/session/screen-layout.ts +147 -0
- package/src/session/screen.tsx +625 -0
- package/src/session/search.ts +3 -0
- package/src/session/server-unavailable-panel.standalone.stories.tsx +88 -0
- package/src/session/server-unavailable-panel.tsx +86 -0
- package/src/session/session-domain.test.ts +57 -0
- package/src/session/session-domain.ts +33 -0
- package/src/session/session-frame.tsx +28 -0
- package/src/session/session-identity-header.css +142 -0
- package/src/session/session-identity-header.tsx +674 -0
- package/src/session/session-layout.ts +73 -0
- package/src/session/session-model-helpers.test.ts +29 -0
- package/src/session/session-model-helpers.ts +33 -0
- package/src/session/session-panel-width.test.ts +25 -0
- package/src/session/session-panel-width.ts +58 -0
- package/src/session/session-read-menu-item.tsx +54 -0
- package/src/session/session-reference-menu.tsx +106 -0
- package/src/session/session-resolution.ts +141 -0
- package/src/session/session-screen.stories.tsx +363 -0
- package/src/session/sizing-machine.test.ts +89 -0
- package/src/session/sizing-machine.ts +74 -0
- package/src/session/story-model.tsx +420 -0
- package/src/session/timeline/background-work.stories.tsx +27 -0
- package/src/session/timeline/cache-machine.test.ts +50 -0
- package/src/session/timeline/cache-machine.ts +37 -0
- package/src/session/timeline/cache.ts +200 -0
- package/src/session/timeline/cold-mount.test.ts +162 -0
- package/src/session/timeline/cold-mount.ts +179 -0
- package/src/session/timeline/controller-projection.test.ts +305 -0
- package/src/session/timeline/controller-projection.ts +131 -0
- package/src/session/timeline/controller.tsx +467 -0
- package/src/session/timeline/cursor-machine.test.ts +398 -0
- package/src/session/timeline/cursor-machine.ts +433 -0
- package/src/session/timeline/cursor.ts +207 -0
- package/src/session/timeline/follow.ts +40 -0
- package/src/session/timeline/header-actions-machine.test.ts +126 -0
- package/src/session/timeline/header-actions-machine.ts +204 -0
- package/src/session/timeline/history-machine.test.ts +304 -0
- package/src/session/timeline/history-machine.ts +296 -0
- package/src/session/timeline/inline-quotes.ts +4 -0
- package/src/session/timeline/interaction.ts +474 -0
- package/src/session/timeline/machine.test.ts +290 -0
- package/src/session/timeline/machine.ts +271 -0
- package/src/session/timeline/message-timeline.tsx +779 -0
- package/src/session/timeline/model.test.ts +393 -0
- package/src/session/timeline/model.ts +201 -0
- package/src/session/timeline/observe-element-offset.test.ts +323 -0
- package/src/session/timeline/observe-element-offset.ts +106 -0
- package/src/session/timeline/projection.ts +7 -0
- package/src/session/timeline/quote-background.ts +141 -0
- package/src/session/timeline/quote-highlight.ts +203 -0
- package/src/session/timeline/quote-machine.test.ts +277 -0
- package/src/session/timeline/quote-machine.ts +360 -0
- package/src/session/timeline/quote-text.ts +332 -0
- package/src/session/timeline/quote.stories.tsx +88 -0
- package/src/session/timeline/quote.tsx +547 -0
- package/src/session/timeline/reconnect-machine.test.ts +115 -0
- package/src/session/timeline/reconnect-machine.ts +130 -0
- package/src/session/timeline/search-bar.css +19 -0
- package/src/session/timeline/search-bar.stories.tsx +122 -0
- package/src/session/timeline/search-bar.tsx +94 -0
- package/src/session/timeline/search-controller.ts +364 -0
- package/src/session/timeline/search-machine.test.ts +320 -0
- package/src/session/timeline/search-machine.ts +342 -0
- package/src/session/timeline/selected-effect.ts +19 -0
- package/src/session/timeline/sources.stories.tsx +352 -0
- package/src/session/timeline/sync-machine.ts +265 -0
- package/src/session/timeline/turn-diff-machine.ts +115 -0
- package/src/session/timeline/turn-diffs.test.ts +178 -0
- package/src/session/timeline/turn-diffs.ts +67 -0
- package/src/session/timeline/virtual-items.ts +3 -0
- package/src/session/timeline/virtualizer.tsx +1321 -0
- package/src/session/timeline/voice-delegation.test.ts +69 -0
- package/src/session/timeline/voice-delegation.ts +38 -0
- package/src/session/title.ts +15 -0
- package/src/session/usage-exceeded-dialogs.test.ts +41 -0
- package/src/session/usage-exceeded-dialogs.tsx +158 -0
- package/src/session/viewed-machine.test.ts +27 -0
- package/src/session/viewed-machine.ts +24 -0
- package/src/settings/about/about.tsx +199 -0
- package/src/settings/about/animated-wordmark.tsx +85 -0
- package/src/settings/about/anomaly-brush.svg +1 -0
- package/src/settings/about/contributors.test.ts +17 -0
- package/src/settings/about/contributors.ts +27 -0
- package/src/settings/about/legal.svg +9 -0
- package/src/settings/about/machine.test.ts +90 -0
- package/src/settings/about/machine.ts +119 -0
- package/src/settings/about/notices/apache-2.0.txt +201 -0
- package/src/settings/about/notices/betteroffice-notice.txt +2 -0
- package/src/settings/about/notices/crates.ts +770 -0
- package/src/settings/about/notices/dialog.tsx +113 -0
- package/src/settings/about/notices/fonts/OFL-1.1.txt +91 -0
- package/src/settings/about/notices/fonts.ts +107 -0
- package/src/settings/about/notices/notices.ts +37 -0
- package/src/settings/appearance/appearance.tsx +176 -0
- package/src/settings/command.tsx +29 -0
- package/src/settings/experimental/experimental.tsx +93 -0
- package/src/settings/extension-load-machine.test.ts +117 -0
- package/src/settings/extension-load-machine.ts +158 -0
- package/src/settings/extension-load.tsx +85 -0
- package/src/settings/general/behavior.ts +102 -0
- package/src/settings/general/controllers.test.ts +56 -0
- package/src/settings/general/controllers.ts +271 -0
- package/src/settings/general/general.tsx +404 -0
- package/src/settings/general/interface-mode.css +261 -0
- package/src/settings/general/interface-mode.tsx +190 -0
- package/src/settings/general/machine.test.ts +188 -0
- package/src/settings/general/machine.ts +224 -0
- package/src/settings/general/sound-preview-machine.test.ts +114 -0
- package/src/settings/general/sound-preview-machine.ts +109 -0
- package/src/settings/keybinds/keybinds.tsx +624 -0
- package/src/settings/keybinds/machine.test.ts +142 -0
- package/src/settings/keybinds/machine.ts +149 -0
- package/src/settings/keybinds/migration.ts +42 -0
- package/src/settings/list.tsx +10 -0
- package/src/settings/model.test.ts +249 -0
- package/src/settings/model.tsx +685 -0
- package/src/settings/models/machine.test.ts +123 -0
- package/src/settings/models/machine.ts +161 -0
- package/src/settings/models/models.tsx +285 -0
- package/src/settings/navigation.tsx +223 -0
- package/src/settings/notifications/notifications.tsx +160 -0
- package/src/settings/pages.ts +33 -0
- package/src/settings/palette.ts +44 -0
- package/src/settings/providers/account-actions.ts +112 -0
- package/src/settings/providers/account-name.tsx +46 -0
- package/src/settings/providers/accounts.test.ts +29 -0
- package/src/settings/providers/accounts.ts +11 -0
- package/src/settings/providers/console-extensions.test.ts +103 -0
- package/src/settings/providers/console-extensions.ts +110 -0
- package/src/settings/providers/console-link.tsx +121 -0
- package/src/settings/providers/extensions.tsx +425 -0
- package/src/settings/providers/machine.test.ts +270 -0
- package/src/settings/providers/machine.ts +357 -0
- package/src/settings/providers/plugin-update-machine.test.ts +155 -0
- package/src/settings/providers/plugin-update-machine.ts +151 -0
- package/src/settings/providers/providers.tsx +702 -0
- package/src/settings/rename-machine.test.ts +123 -0
- package/src/settings/rename-machine.ts +167 -0
- package/src/settings/rename.ts +120 -0
- package/src/settings/route.test.ts +117 -0
- package/src/settings/route.ts +160 -0
- package/src/settings/row.tsx +21 -0
- package/src/settings/scroller.ts +6 -0
- package/src/settings/search-catalog.ts +319 -0
- package/src/settings/search-empty.tsx +87 -0
- package/src/settings/search-field.tsx +101 -0
- package/src/settings/search-index.ts +193 -0
- package/src/settings/search-machine.test.ts +249 -0
- package/src/settings/search-machine.ts +308 -0
- package/src/settings/search-results.test.ts +151 -0
- package/src/settings/search-results.ts +75 -0
- package/src/settings/search-reveal.ts +76 -0
- package/src/settings/search.css +168 -0
- package/src/settings/search.tsx +283 -0
- package/src/settings/server-scope.tsx +12 -0
- package/src/settings/servers/inventory.test.ts +50 -0
- package/src/settings/servers/inventory.ts +100 -0
- package/src/settings/servers/machine.test.ts +148 -0
- package/src/settings/servers/machine.ts +176 -0
- package/src/settings/servers/servers.tsx +178 -0
- package/src/settings/servers/switcher.tsx +77 -0
- package/src/settings/servers/unavailable.tsx +99 -0
- package/src/settings/settings.css +2478 -0
- package/src/settings/shell.standalone.stories.tsx +60 -0
- package/src/settings/shell.tsx +434 -0
- package/src/settings/surface.tsx +297 -0
- package/src/settings/tab-header.ts +12 -0
- package/src/settings/timeline-detail.css +334 -0
- package/src/settings/timeline-detail.stories.tsx +54 -0
- package/src/settings/timeline-detail.tsx +221 -0
- package/src/settings/workspaces/delete-machine.test.ts +298 -0
- package/src/settings/workspaces/delete-machine.ts +392 -0
- package/src/settings/workspaces/project-extensions.tsx +537 -0
- package/src/settings/workspaces/project-folder-missing.tsx +29 -0
- package/src/settings/workspaces/project-lsp.test.ts +65 -0
- package/src/settings/workspaces/project-lsp.ts +31 -0
- package/src/settings/workspaces/project-machine.test.ts +285 -0
- package/src/settings/workspaces/project-machine.ts +374 -0
- package/src/settings/workspaces/project-model.ts +201 -0
- package/src/settings/workspaces/project-options.tsx +81 -0
- package/src/settings/workspaces/project-row.tsx +121 -0
- package/src/settings/workspaces/project.css +397 -0
- package/src/settings/workspaces/project.tsx +266 -0
- package/src/settings/workspaces/projects.tsx +199 -0
- package/src/settings/workspaces/queries.ts +66 -0
- package/src/settings/workspaces/workspaces.tsx +705 -0
- package/src/shell/commands/command-search.tsx +41 -0
- package/src/shell/commands/command.test.ts +118 -0
- package/src/shell/commands/command.tsx +584 -0
- package/src/shell/commands/desktop-menu.test.ts +48 -0
- package/src/shell/commands/desktop-menu.ts +322 -0
- package/src/shell/commands/desktop.tsx +27 -0
- package/src/shell/commands/dialog.css +263 -0
- package/src/shell/commands/dialog.standalone.stories.tsx +247 -0
- package/src/shell/commands/dialog.tsx +318 -0
- package/src/shell/commands/highlight-machine.test.ts +64 -0
- package/src/shell/commands/highlight-machine.ts +54 -0
- package/src/shell/commands/key-sequence.tsx +38 -0
- package/src/shell/commands/keymap.test.ts +219 -0
- package/src/shell/commands/keymap.ts +275 -0
- package/src/shell/commands/palette.ts +466 -0
- package/src/shell/commands/safe-triangle.ts +64 -0
- package/src/shell/commands/search-machine.test.ts +218 -0
- package/src/shell/commands/search-machine.ts +274 -0
- package/src/shell/commands/search.ts +136 -0
- package/src/shell/commands/session-search.tsx +111 -0
- package/src/shell/commands/suspend-machine.test.ts +59 -0
- package/src/shell/commands/suspend-machine.ts +46 -0
- package/src/shell/deep-links/deep-links.ts +65 -0
- package/src/shell/deep-links/machine.test.ts +67 -0
- package/src/shell/deep-links/machine.ts +67 -0
- package/src/shell/errors/description.test.ts +32 -0
- package/src/shell/errors/description.ts +32 -0
- package/src/shell/errors/error.tsx +515 -0
- package/src/shell/errors/machine.test.ts +178 -0
- package/src/shell/errors/machine.ts +217 -0
- package/src/shell/layout/helpers.test.ts +76 -0
- package/src/shell/layout/helpers.ts +78 -0
- package/src/shell/layout/project-avatar-state.ts +157 -0
- package/src/shell/layout/project-icon.tsx +31 -0
- package/src/shell/layout/project-icons.tsx +34 -0
- package/src/shell/layout/session-tab-avatar.tsx +28 -0
- package/src/shell/mobile-drawer.css +90 -0
- package/src/shell/mobile-drawer.tsx +53 -0
- package/src/shell/mobile-panel-drawer.css +34 -0
- package/src/shell/mobile-panel-drawer.tsx +98 -0
- package/src/shell/notifications/coordinator.ts +160 -0
- package/src/shell/notifications/focus-lock-machine.test.ts +79 -0
- package/src/shell/notifications/focus-lock-machine.ts +76 -0
- package/src/shell/notifications/machine.test.ts +297 -0
- package/src/shell/notifications/machine.ts +313 -0
- package/src/shell/notifications/notification.test.ts +28 -0
- package/src/shell/notifications/notification.tsx +526 -0
- package/src/shell/notifications/sound.ts +113 -0
- package/src/shell/notifications/toast.tsx +53 -0
- package/src/shell/palette-menu.css +105 -0
- package/src/shell/panel-motion-machine.test.ts +167 -0
- package/src/shell/panel-motion-machine.ts +217 -0
- package/src/shell/panel-motion.test.ts +26 -0
- package/src/shell/panel-motion.ts +435 -0
- package/src/shell/project-navigation.ts +21 -0
- package/src/shell/routes/routes.tsx +140 -0
- package/src/shell/routes/session-reference-lookup-machine.test.ts +111 -0
- package/src/shell/routes/session-reference-lookup-machine.ts +86 -0
- package/src/shell/routes/session-ui-navigate-machine.test.ts +124 -0
- package/src/shell/routes/session-ui-navigate-machine.ts +127 -0
- package/src/shell/routes/session-ui-provider.tsx +267 -0
- package/src/shell/routes/session.test.ts +46 -0
- package/src/shell/routes/session.ts +30 -0
- package/src/shell/search-list.css +366 -0
- package/src/shell/shell.tsx +340 -0
- package/src/shell/sidebar-peek-machine.test.ts +240 -0
- package/src/shell/sidebar-peek-machine.ts +331 -0
- package/src/shell/sidebar-peek.css +28 -0
- package/src/shell/sidebar-peek.ts +482 -0
- package/src/shell/sidebar-toggle.tsx +255 -0
- package/src/shell/state/helpers.ts +69 -0
- package/src/shell/state/intent-machine.test.ts +155 -0
- package/src/shell/state/intent-machine.ts +216 -0
- package/src/shell/state/layout.test.ts +169 -0
- package/src/shell/state/layout.tsx +794 -0
- package/src/shell/state/scoped-machine.test.ts +69 -0
- package/src/shell/state/scoped-machine.ts +77 -0
- package/src/shell/state/scroll-machine.test.ts +109 -0
- package/src/shell/state/scroll-machine.ts +94 -0
- package/src/shell/state/scroll.test.ts +83 -0
- package/src/shell/state/scroll.ts +124 -0
- package/src/shell/state/session-preferences.ts +62 -0
- package/src/shell/state/session-tabs.test.ts +188 -0
- package/src/shell/state/session-tabs.ts +257 -0
- package/src/shell/tabs/closed.ts +83 -0
- package/src/shell/tabs/hydration-machine.test.ts +98 -0
- package/src/shell/tabs/hydration-machine.ts +115 -0
- package/src/shell/tabs/memory.ts +41 -0
- package/src/shell/tabs/navigation-switch.ts +75 -0
- package/src/shell/tabs/pins.test.ts +68 -0
- package/src/shell/tabs/pins.ts +194 -0
- package/src/shell/tabs/preview-machine.test.ts +89 -0
- package/src/shell/tabs/preview-machine.ts +46 -0
- package/src/shell/tabs/preview.test.ts +153 -0
- package/src/shell/tabs/preview.ts +102 -0
- package/src/shell/tabs/project-sessions.ts +60 -0
- package/src/shell/tabs/promotion-machine.test.ts +203 -0
- package/src/shell/tabs/promotion-machine.ts +194 -0
- package/src/shell/tabs/schema.ts +86 -0
- package/src/shell/tabs/tabs.test.ts +331 -0
- package/src/shell/tabs/tabs.tsx +927 -0
- package/src/shell/time.test.ts +23 -0
- package/src/shell/time.ts +31 -0
- package/src/shell/titlebar/auto-tab-groups.test.ts +76 -0
- package/src/shell/titlebar/auto-tab-groups.ts +88 -0
- package/src/shell/titlebar/auto-tab-sections.tsx +207 -0
- package/src/shell/titlebar/history-machine.test.ts +184 -0
- package/src/shell/titlebar/history-machine.ts +149 -0
- package/src/shell/titlebar/history.ts +64 -0
- package/src/shell/titlebar/inbox-branch-machine.test.ts +146 -0
- package/src/shell/titlebar/inbox-branch-machine.ts +265 -0
- package/src/shell/titlebar/inbox-card.stories.tsx +197 -0
- package/src/shell/titlebar/inbox-list.stories.tsx +342 -0
- package/src/shell/titlebar/inbox-model.ts +539 -0
- package/src/shell/titlebar/inbox-settle-machine.test.ts +108 -0
- package/src/shell/titlebar/inbox-settle-machine.ts +141 -0
- package/src/shell/titlebar/inbox-working.test.ts +26 -0
- package/src/shell/titlebar/inbox-working.ts +22 -0
- package/src/shell/titlebar/inbox.tsx +985 -0
- package/src/shell/titlebar/mobile-tabs-machine.test.ts +105 -0
- package/src/shell/titlebar/mobile-tabs-machine.ts +102 -0
- package/src/shell/titlebar/navigation-story.tsx +207 -0
- package/src/shell/titlebar/pinned-area.css +164 -0
- package/src/shell/titlebar/pinned-area.tsx +629 -0
- package/src/shell/titlebar/project-session-row.tsx +334 -0
- package/src/shell/titlebar/recent-sessions-model.test.ts +657 -0
- package/src/shell/titlebar/recent-sessions-model.ts +469 -0
- package/src/shell/titlebar/recent-sessions.tsx +1415 -0
- package/src/shell/titlebar/recent-view-menu.tsx +147 -0
- package/src/shell/titlebar/recent-view.test.ts +99 -0
- package/src/shell/titlebar/recent-view.ts +183 -0
- package/src/shell/titlebar/recently-closed-tabs-menu.css +25 -0
- package/src/shell/titlebar/recently-closed-tabs-menu.tsx +260 -0
- package/src/shell/titlebar/route-machine.test.ts +259 -0
- package/src/shell/titlebar/route-machine.ts +206 -0
- package/src/shell/titlebar/route-sync.ts +191 -0
- package/src/shell/titlebar/session-events.test.ts +23 -0
- package/src/shell/titlebar/session-events.ts +41 -0
- package/src/shell/titlebar/session-rename-dialog-machine.test.ts +151 -0
- package/src/shell/titlebar/session-rename-dialog-machine.ts +159 -0
- package/src/shell/titlebar/sidebar-customized.standalone.stories.tsx +16 -0
- package/src/shell/titlebar/sidebar-customized.tsx +747 -0
- package/src/shell/titlebar/sidebar-pins.tsx +462 -0
- package/src/shell/titlebar/sidebar-sessions.test.ts +96 -0
- package/src/shell/titlebar/sidebar-sessions.ts +29 -0
- package/src/shell/titlebar/sidebar-view-menu.tsx +191 -0
- package/src/shell/titlebar/sidebar-view.test.ts +185 -0
- package/src/shell/titlebar/sidebar-view.ts +208 -0
- package/src/shell/titlebar/tab-group-drag-machine.ts +1479 -0
- package/src/shell/titlebar/tab-groups-ui.tsx +1246 -0
- package/src/shell/titlebar/tab-groups.css +269 -0
- package/src/shell/titlebar/tab-groups.test.ts +667 -0
- package/src/shell/titlebar/tab-groups.ts +496 -0
- package/src/shell/titlebar/tab-hints-machine.test.ts +97 -0
- package/src/shell/titlebar/tab-hints-machine.ts +79 -0
- package/src/shell/titlebar/tab-load-machine.test.ts +178 -0
- package/src/shell/titlebar/tab-load-machine.ts +233 -0
- package/src/shell/titlebar/tab-nav.css +581 -0
- package/src/shell/titlebar/tab-nav.tsx +891 -0
- package/src/shell/titlebar/tab-order.test.ts +22 -0
- package/src/shell/titlebar/tab-order.ts +24 -0
- package/src/shell/titlebar/tab-popover-machine.test.ts +79 -0
- package/src/shell/titlebar/tab-popover-machine.ts +92 -0
- package/src/shell/titlebar/tab-popover.css +129 -0
- package/src/shell/titlebar/tab-popover.tsx +144 -0
- package/src/shell/titlebar/tab-rename-machine.test.ts +206 -0
- package/src/shell/titlebar/tab-rename-machine.ts +297 -0
- package/src/shell/titlebar/tab-strip.standalone.stories.tsx +19 -0
- package/src/shell/titlebar/tab-strip.tsx +1228 -0
- package/src/shell/titlebar/tab-title.test.ts +14 -0
- package/src/shell/titlebar/tab-title.ts +6 -0
- package/src/shell/titlebar/titlebar.css +197 -0
- package/src/shell/titlebar/titlebar.tsx +1075 -0
- package/src/shell/titlebar/windows-menu.test.ts +20 -0
- package/src/shell/titlebar/windows-menu.tsx +193 -0
- package/src/sst-env.d.ts +12 -0
- package/src/theme-preload.test.ts +56 -0
- package/src/tips/model.ts +155 -0
- package/src/tips/queue.test.ts +43 -0
- package/src/tips/queue.ts +46 -0
- package/src/usage/dialog.css +8 -0
- package/src/usage/dialog.standalone.stories.tsx +137 -0
- package/src/usage/dialog.tsx +570 -0
- package/src/usage/format.ts +39 -0
- package/src/usage/limits.test.ts +141 -0
- package/src/usage/limits.ts +189 -0
- package/src/usage/machine.test.ts +128 -0
- package/src/usage/machine.ts +159 -0
- package/src/usage/model.tsx +55 -0
- package/src/voice/call-machine.test.ts +245 -0
- package/src/voice/call-machine.ts +327 -0
- package/src/voice/call.ts +362 -0
- package/src/voice/composer.tsx +300 -0
- package/src/voice/context.tsx +152 -0
- package/src/voice/coordination.test.ts +58 -0
- package/src/voice/fixtures/history.ts +51 -0
- package/src/voice/gate-machine.test.ts +91 -0
- package/src/voice/gate-machine.ts +148 -0
- package/src/voice/handoff.test.ts +35 -0
- package/src/voice/handoff.ts +20 -0
- package/src/voice/machine.test.ts +303 -0
- package/src/voice/machine.ts +349 -0
- package/src/voice/messages.test.ts +49 -0
- package/src/voice/messages.ts +15 -0
- package/src/voice/panel-machine.test.ts +106 -0
- package/src/voice/panel-machine.ts +167 -0
- package/src/voice/protocol.ts +62 -0
- package/src/voice/replies.ts +71 -0
- package/src/voice/reply-machine.test.ts +290 -0
- package/src/voice/reply-machine.ts +303 -0
- package/src/voice/search.test.ts +35 -0
- package/src/voice/search.ts +134 -0
- package/src/voice/spec.ts +114 -0
- package/src/voice/tail-machine.test.ts +124 -0
- package/src/voice/tail-machine.ts +155 -0
- package/src/voice/tail.ts +55 -0
- package/src/voice/tools.test.ts +320 -0
- package/src/voice/tools.ts +336 -0
- package/src/voice/transport-machine.test.ts +295 -0
- package/src/voice/transport-machine.ts +338 -0
- package/src/voice/transport.test.ts +295 -0
- package/src/voice/transport.ts +313 -0
- package/src/voice/voice.css +84 -0
- package/src/workspaces/create.test.ts +120 -0
- package/src/workspaces/create.ts +23 -0
- package/src/workspaces/files/artifact.test.ts +103 -0
- package/src/workspaces/files/artifact.ts +74 -0
- package/src/workspaces/files/content-cache-accounting.test.ts +79 -0
- package/src/workspaces/files/content-cache.ts +74 -0
- package/src/workspaces/files/content-machine.test.ts +269 -0
- package/src/workspaces/files/content-machine.ts +243 -0
- package/src/workspaces/files/model.tsx +423 -0
- package/src/workspaces/files/path.test.ts +76 -0
- package/src/workspaces/files/path.ts +143 -0
- package/src/workspaces/files/tree-machine.test.ts +300 -0
- package/src/workspaces/files/tree-machine.ts +286 -0
- package/src/workspaces/files/tree-store.ts +142 -0
- package/src/workspaces/files/types.ts +85 -0
- package/src/workspaces/files/view-cache.ts +164 -0
- package/src/workspaces/files/watcher.test.ts +114 -0
- package/src/workspaces/files/watcher.ts +42 -0
- package/src/workspaces/inventory.test.ts +151 -0
- package/src/workspaces/inventory.ts +64 -0
- package/src/workspaces/location-machine.test.ts +135 -0
- package/src/workspaces/location-machine.ts +159 -0
- package/src/workspaces/location.tsx +111 -0
- package/src/workspaces/path-key.ts +5 -0
- package/src/workspaces/paths.test.ts +193 -0
- package/src/workspaces/paths.ts +123 -0
- package/src/workspaces/selection/combobox-machine.test.ts +286 -0
- package/src/workspaces/selection/combobox-machine.ts +331 -0
- package/src/workspaces/selection/dialog.css +234 -0
- package/src/workspaces/selection/dialog.standalone.stories.tsx +66 -0
- package/src/workspaces/selection/dialog.tsx +867 -0
- package/src/workspaces/selection/domain.test.ts +603 -0
- package/src/workspaces/selection/domain.ts +609 -0
- package/src/workspaces/selection/picker.test.ts +37 -0
- package/src/workspaces/selection/picker.tsx +77 -0
- package/src/workspaces/selection/policy.ts +8 -0
- package/src/workspaces/selection/queue-machine.test.ts +116 -0
- package/src/workspaces/selection/queue-machine.ts +203 -0
- package/src/workspaces/selection/tree-machine.test.ts +293 -0
- package/src/workspaces/selection/tree-machine.ts +506 -0
- package/test-browser/animated-presence-state.test.ts +134 -0
- package/test-browser/auto-scroll.test.ts +111 -0
- package/test-browser/browser-pane-model.test.ts +522 -0
- package/test-browser/child-store-eviction.test.ts +86 -0
- package/test-browser/command-palette-search.test.ts +157 -0
- package/test-browser/command-palette.test.ts +262 -0
- package/test-browser/composer-attachment-errors.test.tsx +140 -0
- package/test-browser/composer-attachment-ownership.test.tsx +132 -0
- package/test-browser/composer-drag-cancel.test.tsx +41 -0
- package/test-browser/composer-file-search.test.ts +183 -0
- package/test-browser/composer-ime.test.ts +58 -0
- package/test-browser/composer-submit-loading.test.ts +235 -0
- package/test-browser/composer-write-batch.test.ts +201 -0
- package/test-browser/draft-history-cache.test.ts +139 -0
- package/test-browser/elicitation-dock.test.ts +110 -0
- package/test-browser/file-tree-store.test.ts +113 -0
- package/test-browser/fixtures/model-selection.ts +646 -0
- package/test-browser/message-page-publication.test.ts +46 -0
- package/test-browser/model-selection.test.ts +25 -0
- package/test-browser/motion-dom.test.ts +367 -0
- package/test-browser/motion-spring.test.ts +75 -0
- package/test-browser/pane-drag.test.tsx +136 -0
- package/test-browser/panel-motion.test.ts +398 -0
- package/test-browser/persisted-consumers.test.ts +40 -0
- package/test-browser/playwright-config.test.ts +72 -0
- package/test-browser/plugin-catalog.test.ts +67 -0
- package/test-browser/plugin-link-check.test.ts +102 -0
- package/test-browser/plugin-migrations.test.ts +170 -0
- package/test-browser/plugin-primitives.test.ts +616 -0
- package/test-browser/plugin-server-stream.test.ts +88 -0
- package/test-browser/presence.test.ts +236 -0
- package/test-browser/project-avatar-hover.test.ts +143 -0
- package/test-browser/prompt-motion.test.ts +10 -0
- package/test-browser/prompt-persistence.test.ts +312 -0
- package/test-browser/prompt-scope.test.ts +15 -0
- package/test-browser/provider-catalog.test.ts +54 -0
- package/test-browser/pwa-route.test.ts +96 -0
- package/test-browser/question-dock.test.ts +128 -0
- package/test-browser/schema-persistence.test.ts +294 -0
- package/test-browser/selected-effect.test.ts +36 -0
- package/test-browser/server-connection-sync.test.ts +34 -0
- package/test-browser/server-notification-state.test.ts +662 -0
- package/test-browser/session-activity-elapsed.test.ts +62 -0
- package/test-browser/session-background.test.ts +377 -0
- package/test-browser/session-message-handoffs.test.ts +118 -0
- package/test-browser/session-resolution.test.ts +385 -0
- package/test-browser/settings-keybinds.test.ts +196 -0
- package/test-browser/shell-panel.test.ts +219 -0
- package/test-browser/sidebar-peek.test.ts +149 -0
- package/test-browser/solid-router-cleanup.test.ts +66 -0
- package/test-browser/solid-runtime.test.ts +95 -0
- package/test-browser/solid-virtual.test.ts +249 -0
- package/test-browser/ssh-composer.test.ts +41 -0
- package/test-browser/ssh-health.test.ts +142 -0
- package/test-browser/theme-preload.test.ts +9 -0
- package/test-browser/timeline-cache.test.ts +571 -0
- package/test-browser/timeline-projection.test.ts +363 -0
- package/test-browser/toast-owner.test.ts +66 -0
- package/test-browser/websearch-request.test.ts +277 -0
- package/tsconfig.json +35 -0
- package/vite.config.ts +62 -0
- package/vite.icons.test.ts +133 -0
- package/vite.icons.ts +65 -0
- package/vite.js +142 -0
- package/vite.pwa.ts +69 -0
|
@@ -0,0 +1,1785 @@
|
|
|
1
|
+
import { afterEach, describe, expect, jest, test } from "bun:test"
|
|
2
|
+
import type { SessionRef } from "@zyro-sec/plugin/gui"
|
|
3
|
+
import type { ModelSelection } from "@/providers/models/selection"
|
|
4
|
+
import { PROMPT_GATE_TIMEOUT_MS, settlePromptGates } from "@/runtime/plugin/prompt-gate"
|
|
5
|
+
import type { SessionMessageHandoff } from "@/session/handoff"
|
|
6
|
+
import { Skill } from "@zyro-sec/schema/skill"
|
|
7
|
+
import { createRoot } from "solid-js"
|
|
8
|
+
import type {
|
|
9
|
+
ActiveComposerAdapter,
|
|
10
|
+
ComposerControls,
|
|
11
|
+
ComposerDelivery,
|
|
12
|
+
ComposerSession,
|
|
13
|
+
NewSessionComposerAdapter,
|
|
14
|
+
} from "./adapter"
|
|
15
|
+
import { createMemoryComposerState, type Prompt } from "./state"
|
|
16
|
+
import { composerSubmitView } from "./machine"
|
|
17
|
+
import { createComposerSubmit } from "./submit"
|
|
18
|
+
import { createSteerBackground } from "@/session/requests/steer-background"
|
|
19
|
+
import { setMediaBlobLoader } from "@/runtime/persistence/drafts"
|
|
20
|
+
import type { ComposerStateTarget } from "./submission-state"
|
|
21
|
+
|
|
22
|
+
// SAFETY: submission reads only the selected model's id, name, and provider id.
|
|
23
|
+
const selectedModel = {
|
|
24
|
+
id: "model-1",
|
|
25
|
+
name: "Model 1",
|
|
26
|
+
provider: { id: "provider-1" },
|
|
27
|
+
} as NonNullable<ReturnType<ModelSelection["current"]>>
|
|
28
|
+
|
|
29
|
+
const selection = {
|
|
30
|
+
ready: Object.assign(() => true, { promise: undefined }),
|
|
31
|
+
key: () => ({ providerID: "provider-1", modelID: "model-1" }),
|
|
32
|
+
current: () => selectedModel,
|
|
33
|
+
recent: () => [selectedModel],
|
|
34
|
+
favorite: { list: () => [], toggle() {} },
|
|
35
|
+
list: () => [selectedModel],
|
|
36
|
+
cycle() {},
|
|
37
|
+
set() {},
|
|
38
|
+
visible: () => true,
|
|
39
|
+
setVisibility() {},
|
|
40
|
+
variant: {
|
|
41
|
+
configured: () => undefined,
|
|
42
|
+
current: () => "balanced",
|
|
43
|
+
list: () => ["balanced"],
|
|
44
|
+
set() {},
|
|
45
|
+
cycle() {},
|
|
46
|
+
},
|
|
47
|
+
} satisfies ModelSelection
|
|
48
|
+
|
|
49
|
+
function controls(): ComposerControls {
|
|
50
|
+
return {
|
|
51
|
+
agents: {
|
|
52
|
+
available: [{ name: "build", mode: "primary" }],
|
|
53
|
+
options: ["build"],
|
|
54
|
+
current: "build",
|
|
55
|
+
visible: true,
|
|
56
|
+
select() {},
|
|
57
|
+
},
|
|
58
|
+
model: { selection, paid: true, loading: false },
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function active(state: ComposerStateTarget, target: ComposerSession, ctl = controls): ActiveComposerAdapter {
|
|
63
|
+
return {
|
|
64
|
+
kind: "active-session",
|
|
65
|
+
state,
|
|
66
|
+
ready: () => true,
|
|
67
|
+
controls: ctl,
|
|
68
|
+
working: () => false,
|
|
69
|
+
session: () => target,
|
|
70
|
+
interrupt: async () => undefined,
|
|
71
|
+
submitted() {},
|
|
72
|
+
setEditor() {},
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function fresh(state: ComposerStateTarget, start: NewSessionComposerAdapter["start"]): NewSessionComposerAdapter {
|
|
77
|
+
return { kind: "new-session", state, ready: () => true, controls, working: () => false, submitted() {}, start }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function submitInput(
|
|
81
|
+
adapter: ActiveComposerAdapter | NewSessionComposerAdapter,
|
|
82
|
+
notify: Parameters<typeof createComposerSubmit>[0]["notify"] = {
|
|
83
|
+
missingSelection() {},
|
|
84
|
+
unqueueable() {},
|
|
85
|
+
failed() {},
|
|
86
|
+
},
|
|
87
|
+
mode: "normal" | "shell" = "normal",
|
|
88
|
+
commands: () => readonly { name: string }[] | undefined = () => [],
|
|
89
|
+
history: string[] = [],
|
|
90
|
+
clientCommand?: (text: string) => (() => void | Promise<void>) | undefined,
|
|
91
|
+
delivery: (alternate: boolean) => ComposerDelivery = () => "steer",
|
|
92
|
+
ready?: Parameters<typeof createComposerSubmit>[0]["ready"],
|
|
93
|
+
comments: Parameters<typeof createComposerSubmit>[0]["comments"] = {
|
|
94
|
+
capture: () => [],
|
|
95
|
+
clear() {},
|
|
96
|
+
remove() {},
|
|
97
|
+
restore() {},
|
|
98
|
+
},
|
|
99
|
+
) {
|
|
100
|
+
return createComposerSubmit({
|
|
101
|
+
adapter,
|
|
102
|
+
ready,
|
|
103
|
+
mode: () => mode,
|
|
104
|
+
commands,
|
|
105
|
+
clientCommand,
|
|
106
|
+
delivery,
|
|
107
|
+
editor: () => undefined,
|
|
108
|
+
queueScroll() {},
|
|
109
|
+
addToHistory: (prompt) =>
|
|
110
|
+
history.push(`add:${prompt.map((part) => ("content" in part ? part.content : part.type)).join("")}`),
|
|
111
|
+
removeFromHistory: (prompt) =>
|
|
112
|
+
history.push(`remove:${prompt.map((part) => ("content" in part ? part.content : part.type)).join("")}`),
|
|
113
|
+
resetHistory() {},
|
|
114
|
+
closePopover() {},
|
|
115
|
+
notify,
|
|
116
|
+
comments,
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const sessions = { count: 0 }
|
|
121
|
+
|
|
122
|
+
function session(input: {
|
|
123
|
+
calls: string[]
|
|
124
|
+
prompt?: (value: Parameters<ComposerSession["data"]["session"]["prompt"]>[0]) => Promise<void>
|
|
125
|
+
handoff?: ComposerSession["handoff"]
|
|
126
|
+
statuses?: ("idle" | "running")[]
|
|
127
|
+
current?: ComposerSession["current"]
|
|
128
|
+
admitted?: (messageID: string) => boolean
|
|
129
|
+
shell?: ComposerSession["api"]["shell"]
|
|
130
|
+
command?: ComposerSession["api"]["command"]
|
|
131
|
+
switchAgent?: ComposerSession["api"]["switchAgent"]
|
|
132
|
+
switchModel?: ComposerSession["api"]["switchModel"]
|
|
133
|
+
background?: ComposerSession["background"]
|
|
134
|
+
accept?: () => void
|
|
135
|
+
/** Requests leave as the data layer's send chain lets them: each once the one before it has settled. */
|
|
136
|
+
chained?: boolean
|
|
137
|
+
}): ComposerSession {
|
|
138
|
+
// The requests made so far, settled or not: the next one starts once they all have.
|
|
139
|
+
const chain: Promise<unknown>[] = []
|
|
140
|
+
|
|
141
|
+
const sequence: ComposerSession["data"]["session"]["sequence"] = (_sessionID, send, prepare) => {
|
|
142
|
+
const run = async () => {
|
|
143
|
+
await prepare?.()
|
|
144
|
+
|
|
145
|
+
return send()
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (!input.chained) return run()
|
|
149
|
+
const next = Promise.all(chain.splice(0)).then(run)
|
|
150
|
+
|
|
151
|
+
chain.push(next.catch(() => undefined))
|
|
152
|
+
|
|
153
|
+
return next
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return {
|
|
157
|
+
// Unique per test: what this client knows about a session outlives the test that sent to it.
|
|
158
|
+
id: `session-${++sessions.count}`,
|
|
159
|
+
background: input.background,
|
|
160
|
+
directory: "C:/repo",
|
|
161
|
+
handoff: input.handoff ?? { set() {}, hold() {}, settle() {}, clear() {} },
|
|
162
|
+
current: input.current ?? (() => undefined),
|
|
163
|
+
admitted: input.admitted ?? (() => false),
|
|
164
|
+
api: {
|
|
165
|
+
switchAgent:
|
|
166
|
+
input.switchAgent ??
|
|
167
|
+
(async () => {
|
|
168
|
+
input.calls.push("switch-agent")
|
|
169
|
+
}),
|
|
170
|
+
switchModel:
|
|
171
|
+
input.switchModel ??
|
|
172
|
+
(async () => {
|
|
173
|
+
input.calls.push("switch-model")
|
|
174
|
+
}),
|
|
175
|
+
shell:
|
|
176
|
+
input.shell ??
|
|
177
|
+
(async () => {
|
|
178
|
+
input.calls.push("shell")
|
|
179
|
+
}),
|
|
180
|
+
command: input.command ?? (async () => undefined),
|
|
181
|
+
revert: {
|
|
182
|
+
commit: async () => {
|
|
183
|
+
input.calls.push("revert-commit")
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
file: { list: async () => ({ data: [{ path: "src/api.ts" }] }) },
|
|
188
|
+
data: {
|
|
189
|
+
location: { command: { list: () => [] } },
|
|
190
|
+
session: {
|
|
191
|
+
setStatus: (_sessionID, status) => input.statuses?.push(status),
|
|
192
|
+
acceptSend: () => {
|
|
193
|
+
input.calls.push("accept-send")
|
|
194
|
+
input.accept?.()
|
|
195
|
+
},
|
|
196
|
+
sequence,
|
|
197
|
+
// Like the data layer: admit locally, then prepare and send in the session's send chain.
|
|
198
|
+
prompt: (value) => {
|
|
199
|
+
input.calls.push("admit")
|
|
200
|
+
|
|
201
|
+
return sequence(value.sessionID, async () => {
|
|
202
|
+
await value.prepare?.()
|
|
203
|
+
input.calls.push("send")
|
|
204
|
+
await input.prompt?.(value)
|
|
205
|
+
|
|
206
|
+
// The admitted inbox item, as the server returns it.
|
|
207
|
+
return {
|
|
208
|
+
id: value.id ?? "msg_admitted",
|
|
209
|
+
sessionID: value.sessionID,
|
|
210
|
+
time: { created: 0 },
|
|
211
|
+
type: "user" as const,
|
|
212
|
+
payload: { text: value.text },
|
|
213
|
+
delivery: value.delivery ?? "steer",
|
|
214
|
+
}
|
|
215
|
+
})
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function text(state: ComposerStateTarget) {
|
|
223
|
+
return state
|
|
224
|
+
.current()
|
|
225
|
+
.map((part) => ("content" in part ? part.content : ""))
|
|
226
|
+
.join("")
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
describe("Composer submission", () => {
|
|
230
|
+
test("retains the submitting session before waiting for server admission", async () => {
|
|
231
|
+
const calls: string[] = []
|
|
232
|
+
|
|
233
|
+
const admitted = Promise.withResolvers<void>()
|
|
234
|
+
|
|
235
|
+
const state = createMemoryComposerState({ prompt: "Hello" }).capture()
|
|
236
|
+
|
|
237
|
+
const adapter = {
|
|
238
|
+
...active(state, session({ calls, prompt: () => admitted.promise })),
|
|
239
|
+
beforeSubmit: () => calls.push("keep-preview"),
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const submitted = submitInput(adapter).submit(new Event("submit"))
|
|
243
|
+
|
|
244
|
+
expect(calls).toEqual(["keep-preview"])
|
|
245
|
+
await submitted
|
|
246
|
+
admitted.resolve()
|
|
247
|
+
expect(calls[0]).toBe("keep-preview")
|
|
248
|
+
expect(calls).toContain("admit")
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
// Runs the promise jobs queued so far: more turns than a send's longest chain before its request leaves.
|
|
252
|
+
const flush = async () => {
|
|
253
|
+
for (const _ of Array.from({ length: 32 })) await Promise.resolve()
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const typed = (content: string): Prompt => [{ type: "text", content, start: 0, end: content.length }]
|
|
257
|
+
|
|
258
|
+
// A composer of `target` whose sends wait on `ready`, with what it reported as failed.
|
|
259
|
+
const gated = (
|
|
260
|
+
target: ComposerSession,
|
|
261
|
+
ready: (sessionID: string) => Promise<void>,
|
|
262
|
+
input: { prompt: string; mode?: "normal" | "shell"; calls?: string[] },
|
|
263
|
+
) => {
|
|
264
|
+
const state = createMemoryComposerState({ prompt: input.prompt }).capture()
|
|
265
|
+
const failures: string[] = []
|
|
266
|
+
const history: string[] = []
|
|
267
|
+
const adapter = { ...active(state, target), interrupt: async () => void input.calls?.push("interrupt") }
|
|
268
|
+
|
|
269
|
+
const submission = submitInput(
|
|
270
|
+
adapter,
|
|
271
|
+
{ missingSelection() {}, unqueueable() {}, failed: (kind) => failures.push(kind) },
|
|
272
|
+
input.mode ?? "normal",
|
|
273
|
+
() => [{ name: "review" }],
|
|
274
|
+
history,
|
|
275
|
+
undefined,
|
|
276
|
+
() => "steer",
|
|
277
|
+
ready,
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
return { state, submission, failures, history }
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
test("a prompt shows at once, and its composer takes no other send until what the plugins prepare is ready", async () => {
|
|
284
|
+
const calls: string[] = []
|
|
285
|
+
const gate = Promise.withResolvers<void>()
|
|
286
|
+
const sent = Promise.withResolvers<void>()
|
|
287
|
+
const target = session({ calls, prompt: async () => sent.resolve() })
|
|
288
|
+
|
|
289
|
+
const composer = gated(
|
|
290
|
+
target,
|
|
291
|
+
(sessionID) => {
|
|
292
|
+
calls.push(sessionID === target.id ? "gate" : "gate for another session")
|
|
293
|
+
|
|
294
|
+
return gate.promise
|
|
295
|
+
},
|
|
296
|
+
{ prompt: "Hello" },
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
const submitted = composer.submission.submit(new Event("submit"))
|
|
300
|
+
await flush()
|
|
301
|
+
|
|
302
|
+
// The prompt is admitted locally and the composer cleared, but nothing has left, and the send is still the
|
|
303
|
+
// composer's: its view offers Stop for it.
|
|
304
|
+
expect(calls.filter((call) => call === "gate" || call === "admit" || call === "send")).toEqual(["gate", "admit"])
|
|
305
|
+
expect(text(composer.state)).toBe("")
|
|
306
|
+
expect(composer.submission.state().type).toBe("sending")
|
|
307
|
+
|
|
308
|
+
// A second Enter, on whatever was typed meanwhile, starts no second send.
|
|
309
|
+
composer.state.set(typed("again"), 5)
|
|
310
|
+
await composer.submission.submit(new Event("submit"))
|
|
311
|
+
expect(calls.filter((call) => call === "gate" || call === "admit")).toEqual(["gate", "admit"])
|
|
312
|
+
expect(text(composer.state)).toBe("again")
|
|
313
|
+
|
|
314
|
+
gate.resolve()
|
|
315
|
+
await submitted
|
|
316
|
+
await sent.promise
|
|
317
|
+
expect(calls.filter((call) => call === "gate" || call === "admit" || call === "send")).toEqual(["gate", "admit", "send"])
|
|
318
|
+
expect(composer.submission.state()).toEqual({ type: "idle", attempt: 1 })
|
|
319
|
+
})
|
|
320
|
+
|
|
321
|
+
test.each([
|
|
322
|
+
{ name: "a prompt", prompt: "Hello", left: "Hello" },
|
|
323
|
+
{ name: "a prompt, with a draft typed since", prompt: "Hello", edit: "next", left: "Hello\n\nnext" },
|
|
324
|
+
{ name: "a server command", prompt: "/review now", left: "/review now" },
|
|
325
|
+
])("Stop while $name waits on the gate cancels that send: nothing reaches the server and its text comes back", async (row) => {
|
|
326
|
+
const calls: string[] = []
|
|
327
|
+
const timeline: string[] = []
|
|
328
|
+
const statuses: ("idle" | "running")[] = []
|
|
329
|
+
const gate = Promise.withResolvers<void>()
|
|
330
|
+
|
|
331
|
+
const target = session({
|
|
332
|
+
calls,
|
|
333
|
+
statuses,
|
|
334
|
+
handoff: { set: () => timeline.push("set"), hold() {}, settle: () => timeline.push("settle"), clear: () => timeline.push("clear") },
|
|
335
|
+
command: async () => void calls.push("command"),
|
|
336
|
+
})
|
|
337
|
+
|
|
338
|
+
const composer = gated(target, () => gate.promise, { prompt: row.prompt, calls })
|
|
339
|
+
const submitted = composer.submission.submit(new Event("submit"))
|
|
340
|
+
await flush()
|
|
341
|
+
expect(composer.submission.state().type).toBe("sending")
|
|
342
|
+
expect(text(composer.state)).toBe("")
|
|
343
|
+
|
|
344
|
+
if (row.edit) composer.state.set(typed(row.edit), row.edit.length)
|
|
345
|
+
await composer.submission.stop()
|
|
346
|
+
await submitted
|
|
347
|
+
await flush()
|
|
348
|
+
|
|
349
|
+
// Neither the request nor an interrupt: the Session was never told of this send.
|
|
350
|
+
expect(calls.filter((call) => call === "send" || call === "command" || call === "interrupt")).toEqual([])
|
|
351
|
+
expect(text(composer.state)).toBe(row.left)
|
|
352
|
+
expect(composer.failures).toEqual([])
|
|
353
|
+
expect(composer.submission.state()).toEqual({ type: "idle", attempt: 1 })
|
|
354
|
+
// A prompt that showed in the Session is taken out of it again, and the Session is not left looking busy.
|
|
355
|
+
expect(timeline).toEqual(row.prompt.startsWith("/") ? [] : ["set", "clear"])
|
|
356
|
+
expect(statuses.at(-1) ?? "idle").toBe("idle")
|
|
357
|
+
expect(composer.history).toEqual([`add:${row.prompt}`, `remove:${row.prompt}`])
|
|
358
|
+
|
|
359
|
+
// What the send waited for is ready later: the result belongs to a send that no longer exists.
|
|
360
|
+
gate.resolve()
|
|
361
|
+
await flush()
|
|
362
|
+
expect(calls.filter((call) => call === "send" || call === "command")).toEqual([])
|
|
363
|
+
expect(composer.submission.state()).toEqual({ type: "idle", attempt: 1 })
|
|
364
|
+
})
|
|
365
|
+
|
|
366
|
+
test.each([
|
|
367
|
+
{
|
|
368
|
+
name: "a prompt into a staged revert, with another agent and model selected",
|
|
369
|
+
prompt: "Hello",
|
|
370
|
+
current: { agent: "plan", model: { id: "old", providerID: "old" }, revert: { messageID: "msg_reverted" } },
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
name: "a prompt with another agent and model selected",
|
|
374
|
+
prompt: "Hello",
|
|
375
|
+
current: { agent: "plan", model: { id: "old", providerID: "old" } },
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
name: "a server command with another agent and model selected",
|
|
379
|
+
prompt: "/review now",
|
|
380
|
+
current: { agent: "plan", model: { id: "old", providerID: "old" } },
|
|
381
|
+
},
|
|
382
|
+
])("Stop while $name waits on the gate changes nothing on the server", async (row) => {
|
|
383
|
+
const calls: string[] = []
|
|
384
|
+
const gate = Promise.withResolvers<void>()
|
|
385
|
+
const target = session({ calls, current: () => row.current, command: async () => void calls.push("command") })
|
|
386
|
+
const composer = gated(target, () => gate.promise, { prompt: row.prompt, calls })
|
|
387
|
+
const submitted = composer.submission.submit(new Event("submit"))
|
|
388
|
+
|
|
389
|
+
await flush()
|
|
390
|
+
await composer.submission.stop()
|
|
391
|
+
await submitted
|
|
392
|
+
gate.resolve()
|
|
393
|
+
await flush()
|
|
394
|
+
|
|
395
|
+
// Only the prompt's local admission, which the cancelled send takes back: no revert commit, switch or request.
|
|
396
|
+
expect(calls.filter((call) => call !== "admit")).toEqual([])
|
|
397
|
+
expect(text(composer.state)).toBe(row.prompt)
|
|
398
|
+
})
|
|
399
|
+
|
|
400
|
+
test("Stop while a prompt waits on the gate keeps a comment added meanwhile, though no text was typed", async () => {
|
|
401
|
+
const gate = Promise.withResolvers<void>()
|
|
402
|
+
const composer = gated(session({ calls: [] }), () => gate.promise, { prompt: "Hello" })
|
|
403
|
+
composer.state.context.add({ type: "file", path: "src/sent.ts", comment: "Sent with it", commentID: "sent" })
|
|
404
|
+
const submitted = composer.submission.submit(new Event("submit"))
|
|
405
|
+
|
|
406
|
+
await flush()
|
|
407
|
+
expect(composer.state.context.items()).toEqual([])
|
|
408
|
+
composer.state.context.add({ type: "file", path: "src/later.ts", comment: "Added while it waited", commentID: "later" })
|
|
409
|
+
await composer.submission.stop()
|
|
410
|
+
await submitted
|
|
411
|
+
await flush()
|
|
412
|
+
|
|
413
|
+
expect(text(composer.state)).toBe("Hello")
|
|
414
|
+
expect(composer.state.context.items().map((item) => item.type === "file" && item.comment)).toEqual([
|
|
415
|
+
"Sent with it",
|
|
416
|
+
"Added while it waited",
|
|
417
|
+
])
|
|
418
|
+
})
|
|
419
|
+
|
|
420
|
+
// The composer the person presses Stop in is not always the one that made the send: a new session's composer
|
|
421
|
+
// unmounts as soon as Enter is pressed, and a tab switch away and back mounts a session's composer anew.
|
|
422
|
+
test.each([
|
|
423
|
+
{ name: "a new session's first prompt, from the session's own composer", draft: true },
|
|
424
|
+
{ name: "a prompt whose composer a tab switch has replaced", draft: false },
|
|
425
|
+
])("Stop cancels $name while it waits on the gate", async (row) => {
|
|
426
|
+
const calls: string[] = []
|
|
427
|
+
const timeline: string[] = []
|
|
428
|
+
const failures: string[] = []
|
|
429
|
+
const gate = Promise.withResolvers<void>()
|
|
430
|
+
// The send ends one way or the other: its prompt leaves the timeline, or its request leaves the window.
|
|
431
|
+
const ended = Promise.withResolvers<void>()
|
|
432
|
+
|
|
433
|
+
const target = session({
|
|
434
|
+
calls,
|
|
435
|
+
prompt: async () => ended.resolve(),
|
|
436
|
+
handoff: {
|
|
437
|
+
set: () => timeline.push("set"),
|
|
438
|
+
hold() {},
|
|
439
|
+
settle() {},
|
|
440
|
+
clear: () => {
|
|
441
|
+
timeline.push("clear")
|
|
442
|
+
ended.resolve()
|
|
443
|
+
},
|
|
444
|
+
},
|
|
445
|
+
})
|
|
446
|
+
|
|
447
|
+
const image = {
|
|
448
|
+
type: "image" as const,
|
|
449
|
+
id: "attachment",
|
|
450
|
+
filename: "shot.png",
|
|
451
|
+
mime: "image/png",
|
|
452
|
+
blob: { id: "attachment", url: "data:image/png;base64,YQ==" },
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
const draft = createMemoryComposerState({ prompt: "first prompt" }).capture()
|
|
456
|
+
draft.set([...draft.current(), image])
|
|
457
|
+
// What the session's composer holds: its own draft, which a new session's first prompt is moved to.
|
|
458
|
+
const seen = row.draft ? createMemoryComposerState().capture() : draft
|
|
459
|
+
|
|
460
|
+
const sender = row.draft
|
|
461
|
+
? fresh(draft, async (_selection, submission) => {
|
|
462
|
+
submission.retarget(seen)
|
|
463
|
+
|
|
464
|
+
return { session: target, cleanupReady: Promise.resolve() }
|
|
465
|
+
})
|
|
466
|
+
: active(draft, target)
|
|
467
|
+
|
|
468
|
+
const notify = { missingSelection() {}, unqueueable() {}, failed: (kind: string) => void failures.push(kind) }
|
|
469
|
+
|
|
470
|
+
const compose = (adapter: ActiveComposerAdapter | NewSessionComposerAdapter) =>
|
|
471
|
+
submitInput(adapter, notify, undefined, undefined, undefined, undefined, undefined, () => gate.promise)
|
|
472
|
+
|
|
473
|
+
const unmount = createRoot((dispose) => {
|
|
474
|
+
void compose(sender).submit(new Event("submit"))
|
|
475
|
+
|
|
476
|
+
return dispose
|
|
477
|
+
})
|
|
478
|
+
|
|
479
|
+
// A new session's composer goes at Enter; a tab switch comes once the prompt shows and waits.
|
|
480
|
+
if (row.draft) unmount()
|
|
481
|
+
await flush()
|
|
482
|
+
|
|
483
|
+
if (!row.draft) unmount()
|
|
484
|
+
expect(timeline).toEqual(["set"])
|
|
485
|
+
expect(text(seen)).toBe("")
|
|
486
|
+
|
|
487
|
+
await compose({ ...active(seen, target), interrupt: async () => void calls.push("interrupt") }).stop()
|
|
488
|
+
// What the send waited for is ready later: the cancelled prompt must not leave then either.
|
|
489
|
+
gate.resolve()
|
|
490
|
+
await ended.promise
|
|
491
|
+
await flush()
|
|
492
|
+
|
|
493
|
+
expect(calls.filter((call) => call === "send" || call === "interrupt")).toEqual([])
|
|
494
|
+
expect(timeline).toEqual(["set", "clear"])
|
|
495
|
+
expect(text(seen)).toBe("first prompt")
|
|
496
|
+
expect(seen.current()).toContainEqual(image)
|
|
497
|
+
expect(failures).toEqual([])
|
|
498
|
+
|
|
499
|
+
// Nothing waits any more, so the next Stop interrupts the session as before.
|
|
500
|
+
await compose({ ...active(seen, target), interrupt: async () => void calls.push("interrupt") }).stop()
|
|
501
|
+
expect(calls.filter((call) => call === "interrupt")).toEqual(["interrupt"])
|
|
502
|
+
})
|
|
503
|
+
|
|
504
|
+
// A session's draft composer and its own composer are two of these. Each press of Enter is one send, and the server
|
|
505
|
+
// must receive them in that order, whatever each waited for: here the prompt waits on the gate, the server command
|
|
506
|
+
// on the gate and on the prompt, and the shell command, which has no gate, on both.
|
|
507
|
+
describe("order", () => {
|
|
508
|
+
afterEach(() => void jest.useRealTimers())
|
|
509
|
+
|
|
510
|
+
test.each(["is ready", "times out"] as const)(
|
|
511
|
+
"a prompt, a server command and a shell command reach the server in that order when the gate %s",
|
|
512
|
+
async (how) => {
|
|
513
|
+
if (how === "times out") jest.useFakeTimers()
|
|
514
|
+
const calls: string[] = []
|
|
515
|
+
const gate = Promise.withResolvers<void>()
|
|
516
|
+
|
|
517
|
+
const target = session({
|
|
518
|
+
calls,
|
|
519
|
+
chained: true,
|
|
520
|
+
prompt: async () => void calls.push("prompt"),
|
|
521
|
+
command: async () => void calls.push("command"),
|
|
522
|
+
shell: async () => void calls.push("shell"),
|
|
523
|
+
})
|
|
524
|
+
|
|
525
|
+
// SAFETY: the gate under test never reads the session.
|
|
526
|
+
const ref = { key: `server\n${target.id}`, id: target.id } as SessionRef
|
|
527
|
+
const never = { plugin: "browser", value: { ready: () => new Promise<void>(() => undefined) } }
|
|
528
|
+
|
|
529
|
+
const ready = () =>
|
|
530
|
+
how === "times out" ? settlePromptGates([never], () => true, ref) : gate.promise
|
|
531
|
+
|
|
532
|
+
const sends = [
|
|
533
|
+
gated(target, ready, { prompt: "Hello" }),
|
|
534
|
+
gated(target, ready, { prompt: "/review now" }),
|
|
535
|
+
gated(target, ready, { prompt: "ls", mode: "shell" }),
|
|
536
|
+
].map((composer) => composer.submission.submit(new Event("submit")))
|
|
537
|
+
|
|
538
|
+
await flush()
|
|
539
|
+
// The shell command has nothing to wait for of its own, and still does not go first.
|
|
540
|
+
expect(calls.filter((call) => call === "prompt" || call === "command" || call === "shell")).toEqual([])
|
|
541
|
+
|
|
542
|
+
if (how === "times out") jest.advanceTimersByTime(PROMPT_GATE_TIMEOUT_MS)
|
|
543
|
+
gate.resolve()
|
|
544
|
+
await Promise.all(sends)
|
|
545
|
+
await flush()
|
|
546
|
+
expect(calls.filter((call) => call === "prompt" || call === "command" || call === "shell")).toEqual([
|
|
547
|
+
"prompt",
|
|
548
|
+
"command",
|
|
549
|
+
"shell",
|
|
550
|
+
])
|
|
551
|
+
},
|
|
552
|
+
)
|
|
553
|
+
})
|
|
554
|
+
|
|
555
|
+
test("marks the session accepted only once the send is admitted", async () => {
|
|
556
|
+
const calls: string[] = []
|
|
557
|
+
const accepted = Promise.withResolvers<void>()
|
|
558
|
+
const state = createMemoryComposerState({ prompt: "Hello" }).capture()
|
|
559
|
+
|
|
560
|
+
await submitInput(active(state, session({ calls, accept: () => accepted.resolve() }))).submit(
|
|
561
|
+
new Event("submit"),
|
|
562
|
+
)
|
|
563
|
+
await accepted.promise
|
|
564
|
+
|
|
565
|
+
expect(calls.filter((call) => call === "accept-send")).toHaveLength(1)
|
|
566
|
+
})
|
|
567
|
+
|
|
568
|
+
test("an empty submit does not retain a preview", async () => {
|
|
569
|
+
const calls: string[] = []
|
|
570
|
+
|
|
571
|
+
const state = createMemoryComposerState().capture()
|
|
572
|
+
|
|
573
|
+
const adapter = {
|
|
574
|
+
...active(state, session({ calls })),
|
|
575
|
+
beforeSubmit: () => calls.push("keep-preview"),
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
await submitInput(adapter).submit(new Event("submit"))
|
|
579
|
+
expect(calls).toEqual([])
|
|
580
|
+
})
|
|
581
|
+
|
|
582
|
+
test("pressing Enter and then Send while an image attachment resolves sends the prompt once", async () => {
|
|
583
|
+
const state = createMemoryComposerState({ prompt: "ship it" }).capture()
|
|
584
|
+
const id = `media:${"a".repeat(64)}`
|
|
585
|
+
state.set([
|
|
586
|
+
...state.current(),
|
|
587
|
+
{ type: "image", id, filename: "shot.png", mime: "image/png", blob: { id, url: "" } },
|
|
588
|
+
])
|
|
589
|
+
// The image's bytes load through the media loader, which answers only when the test lets it.
|
|
590
|
+
const loaded = Promise.withResolvers<string | undefined>()
|
|
591
|
+
setMediaBlobLoader("composer-double-submit", () => loaded.promise)
|
|
592
|
+
const handoffs: SessionMessageHandoff[] = []
|
|
593
|
+
|
|
594
|
+
const calls: string[] = []
|
|
595
|
+
|
|
596
|
+
const submission = submitInput({
|
|
597
|
+
...active(
|
|
598
|
+
state,
|
|
599
|
+
session({ calls, handoff: { set: (handoff) => handoffs.push(handoff), hold() {}, settle() {}, clear() {} } }),
|
|
600
|
+
),
|
|
601
|
+
beforeSubmit: () => calls.push("keep-preview"),
|
|
602
|
+
})
|
|
603
|
+
|
|
604
|
+
const enter = submission.submit(new Event("submit"))
|
|
605
|
+
const send = submission.submit(new Event("submit"))
|
|
606
|
+
|
|
607
|
+
expect(calls).toEqual(["keep-preview"])
|
|
608
|
+
loaded.resolve("data:image/png;base64,YQ==")
|
|
609
|
+
await Promise.all([enter, send])
|
|
610
|
+
setMediaBlobLoader("composer-double-submit", undefined)
|
|
611
|
+
|
|
612
|
+
expect(handoffs.map((handoff) => handoff.message.text)).toEqual(["ship it"])
|
|
613
|
+
expect(state.current()).toEqual([{ type: "text", content: "", start: 0, end: 0 }])
|
|
614
|
+
})
|
|
615
|
+
|
|
616
|
+
test.each(["steer", "queue"] as const)(
|
|
617
|
+
"sends only the selected quote as a %s, including its comment mentions, without clearing the draft",
|
|
618
|
+
async (delivery) => {
|
|
619
|
+
const state = createMemoryComposerState({ prompt: "/review keep this draft" }).capture()
|
|
620
|
+
|
|
621
|
+
const image = {
|
|
622
|
+
type: "image" as const,
|
|
623
|
+
id: "unrelated-image",
|
|
624
|
+
filename: "draft.png",
|
|
625
|
+
mime: "image/png",
|
|
626
|
+
blob: { id: "unrelated-image", url: "data:image/png;base64,YQ==" },
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
state.set([...state.current(), image], 5)
|
|
630
|
+
state.mode.set("shell")
|
|
631
|
+
state.context.add({ type: "quote", text: "Selected passage", commentID: "selected", comment: "Old comment" })
|
|
632
|
+
state.context.add({ type: "quote", text: "Unrelated passage", commentID: "other" })
|
|
633
|
+
state.context.add({ type: "file", path: "unrelated.ts" })
|
|
634
|
+
const before = state.current()
|
|
635
|
+
|
|
636
|
+
const requests: Parameters<ComposerSession["data"]["session"]["prompt"]>[0][] = []
|
|
637
|
+
|
|
638
|
+
const calls: string[] = []
|
|
639
|
+
|
|
640
|
+
const submission = submitInput(
|
|
641
|
+
{
|
|
642
|
+
...active(state, session({ calls, prompt: async (value) => void requests.push(value) })),
|
|
643
|
+
beforeSubmit: () => calls.push("keep-preview"),
|
|
644
|
+
},
|
|
645
|
+
undefined,
|
|
646
|
+
"shell",
|
|
647
|
+
undefined,
|
|
648
|
+
undefined,
|
|
649
|
+
undefined,
|
|
650
|
+
(alternate) => {
|
|
651
|
+
expect(alternate).toBe(true)
|
|
652
|
+
|
|
653
|
+
return delivery
|
|
654
|
+
},
|
|
655
|
+
)
|
|
656
|
+
|
|
657
|
+
expect(await submission.submitComment("quote:c=selected", "Compare @src/api.ts with @here")).toBe(true)
|
|
658
|
+
expect(calls[0]).toBe("keep-preview")
|
|
659
|
+
expect(requests).toHaveLength(1)
|
|
660
|
+
expect(requests[0]?.text).toBe(
|
|
661
|
+
"> Selected passage\n\nCompare @src/api.ts with @here",
|
|
662
|
+
)
|
|
663
|
+
expect(requests[0]).toMatchObject({
|
|
664
|
+
delivery,
|
|
665
|
+
files: [{ uri: "file:///C:/repo/src/api.ts", name: "api.ts" }],
|
|
666
|
+
agents: [],
|
|
667
|
+
skills: [],
|
|
668
|
+
metadata: {
|
|
669
|
+
displayText: "",
|
|
670
|
+
comments: [{ type: "quote", text: "Selected passage", comment: "Compare @src/api.ts with @here" }],
|
|
671
|
+
attachments: [],
|
|
672
|
+
},
|
|
673
|
+
})
|
|
674
|
+
expect(state.current()).toBe(before)
|
|
675
|
+
expect(state.cursor()).toBe(5)
|
|
676
|
+
expect(state.mode.current()).toBe("shell")
|
|
677
|
+
expect(state.context.items().map((item) => item.key)).toEqual([
|
|
678
|
+
"quote:c=other",
|
|
679
|
+
"file:unrelated.ts:undefined:undefined",
|
|
680
|
+
])
|
|
681
|
+
},
|
|
682
|
+
)
|
|
683
|
+
|
|
684
|
+
test("a file comment sends alone with Enter's delivery and leaves the composer and the file's comments", async () => {
|
|
685
|
+
const state = createMemoryComposerState({ prompt: "Keep this draft" }).capture()
|
|
686
|
+
|
|
687
|
+
state.context.add({
|
|
688
|
+
type: "file",
|
|
689
|
+
path: "src/api.ts",
|
|
690
|
+
selection: { startLine: 2, startChar: 0, endLine: 3, endChar: 0 },
|
|
691
|
+
comment: "Rename this",
|
|
692
|
+
commentID: "c1",
|
|
693
|
+
})
|
|
694
|
+
state.context.add({ type: "quote", text: "Unrelated passage", commentID: "other" })
|
|
695
|
+
const key = state.context.items()[0]?.key ?? ""
|
|
696
|
+
|
|
697
|
+
const requests: Parameters<ComposerSession["data"]["session"]["prompt"]>[0][] = []
|
|
698
|
+
|
|
699
|
+
const removed: string[] = []
|
|
700
|
+
|
|
701
|
+
const alternates: boolean[] = []
|
|
702
|
+
|
|
703
|
+
const submission = submitInput(
|
|
704
|
+
active(state, session({ calls: [], prompt: async (value) => void requests.push(value) })),
|
|
705
|
+
undefined,
|
|
706
|
+
undefined,
|
|
707
|
+
undefined,
|
|
708
|
+
undefined,
|
|
709
|
+
undefined,
|
|
710
|
+
(alternate) => {
|
|
711
|
+
alternates.push(alternate)
|
|
712
|
+
|
|
713
|
+
return "queue"
|
|
714
|
+
},
|
|
715
|
+
undefined,
|
|
716
|
+
{ capture: () => [], clear() {}, remove: (path, id) => void removed.push(`${path}#${id}`), restore() {} },
|
|
717
|
+
)
|
|
718
|
+
|
|
719
|
+
expect(await submission.submitComment(key, "Rename this", { alternate: false })).toBe(true)
|
|
720
|
+
expect(alternates).toEqual([false])
|
|
721
|
+
expect(requests[0]?.delivery).toBe("queue")
|
|
722
|
+
expect(requests[0]?.metadata).toMatchObject({ comments: [{ path: "src/api.ts", comment: "Rename this" }] })
|
|
723
|
+
expect(removed).toEqual(["src/api.ts#c1"])
|
|
724
|
+
expect(state.current()).toEqual([{ type: "text", content: "Keep this draft", start: 0, end: 15 }])
|
|
725
|
+
expect(state.context.items().map((item) => item.key)).toEqual(["quote:c=other"])
|
|
726
|
+
})
|
|
727
|
+
|
|
728
|
+
test("a failed quote send retains its latest comment and prevents duplicate submissions while pending", async () => {
|
|
729
|
+
const state = createMemoryComposerState({ prompt: "Keep this draft" }).capture()
|
|
730
|
+
|
|
731
|
+
state.context.add({ type: "quote", text: "Selected passage", commentID: "selected" })
|
|
732
|
+
const failed = Promise.withResolvers<void>()
|
|
733
|
+
|
|
734
|
+
const started = Promise.withResolvers<void>()
|
|
735
|
+
|
|
736
|
+
const errors: string[] = []
|
|
737
|
+
|
|
738
|
+
const calls: string[] = []
|
|
739
|
+
|
|
740
|
+
const submission = submitInput(
|
|
741
|
+
active(
|
|
742
|
+
state,
|
|
743
|
+
session({
|
|
744
|
+
calls,
|
|
745
|
+
prompt: async () => {
|
|
746
|
+
started.resolve()
|
|
747
|
+
await failed.promise
|
|
748
|
+
},
|
|
749
|
+
}),
|
|
750
|
+
),
|
|
751
|
+
{ missingSelection() {}, unqueueable() {}, failed: (_kind, error) => void errors.push(String(error)) },
|
|
752
|
+
)
|
|
753
|
+
|
|
754
|
+
const pending = submission.submitComment("quote:c=selected", "Latest comment")
|
|
755
|
+
|
|
756
|
+
await started.promise
|
|
757
|
+
expect(await submission.submitComment("quote:c=selected", "Duplicate")).toBe(false)
|
|
758
|
+
failed.reject(new Error("Could not send"))
|
|
759
|
+
expect(await pending).toBe(false)
|
|
760
|
+
expect(errors).toHaveLength(1)
|
|
761
|
+
expect(state.current()).toEqual([{ type: "text", content: "Keep this draft", start: 0, end: 15 }])
|
|
762
|
+
expect(state.context.items()).toMatchObject([
|
|
763
|
+
{ key: "quote:c=selected", text: "Selected passage", comment: "Latest comment" },
|
|
764
|
+
])
|
|
765
|
+
expect(calls.filter((call) => call === "send")).toHaveLength(2)
|
|
766
|
+
})
|
|
767
|
+
|
|
768
|
+
test("a quote send keeps sending while the composer sends it, and fails only once the composer can retry", async () => {
|
|
769
|
+
const state = createMemoryComposerState().capture()
|
|
770
|
+
state.context.add({ type: "quote", text: "Selected passage", commentID: "selected" })
|
|
771
|
+
const release = Promise.withResolvers<void>()
|
|
772
|
+
const failed = Promise.withResolvers<void>()
|
|
773
|
+
|
|
774
|
+
const submission = submitInput(active(state, session({ calls: [], prompt: () => release.promise })), {
|
|
775
|
+
missingSelection() {},
|
|
776
|
+
unqueueable() {},
|
|
777
|
+
failed: () => failed.resolve(),
|
|
778
|
+
})
|
|
779
|
+
|
|
780
|
+
jest.useFakeTimers()
|
|
781
|
+
state.quoteComment.set("quote:c=selected")
|
|
782
|
+
state.quoteComment.send("note", submission.submitComment)
|
|
783
|
+
// A silent server holds a prompt for a minute per attempt; the send has not failed until the composer says so.
|
|
784
|
+
jest.advanceTimersByTime(5 * 60_000)
|
|
785
|
+
jest.useRealTimers()
|
|
786
|
+
expect(state.quoteComment.state()).toMatchObject({ status: "sending", draft: "note" })
|
|
787
|
+
expect(composerSubmitView(submission.state()).canSubmit).toBe(false)
|
|
788
|
+
|
|
789
|
+
release.reject(new Error("offline"))
|
|
790
|
+
await failed.promise
|
|
791
|
+
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
792
|
+
expect(state.quoteComment.state()).toMatchObject({ status: "failed", draft: "note" })
|
|
793
|
+
expect(composerSubmitView(submission.state()).canSubmit).toBe(true)
|
|
794
|
+
})
|
|
795
|
+
|
|
796
|
+
test("a prompt that fails after a newer one went out leaves the Session running", async () => {
|
|
797
|
+
const state = createMemoryComposerState({ prompt: "first" }).capture()
|
|
798
|
+
const statuses: ("idle" | "running")[] = []
|
|
799
|
+
const first = Promise.withResolvers<void>()
|
|
800
|
+
const second = Promise.withResolvers<void>()
|
|
801
|
+
const failed = { count: 0, settled: Promise.withResolvers<void>() }
|
|
802
|
+
|
|
803
|
+
const target = session({
|
|
804
|
+
calls: [],
|
|
805
|
+
statuses,
|
|
806
|
+
prompt: async (value) => {
|
|
807
|
+
if (value.text === "first") return first.promise
|
|
808
|
+
await second.promise
|
|
809
|
+
},
|
|
810
|
+
})
|
|
811
|
+
|
|
812
|
+
const submission = submitInput(
|
|
813
|
+
{ ...active(state, target), working: () => statuses.at(-1) === "running" },
|
|
814
|
+
{
|
|
815
|
+
missingSelection() {},
|
|
816
|
+
unqueueable() {},
|
|
817
|
+
failed: () => {
|
|
818
|
+
failed.count++
|
|
819
|
+
failed.settled.resolve()
|
|
820
|
+
},
|
|
821
|
+
},
|
|
822
|
+
)
|
|
823
|
+
|
|
824
|
+
await submission.submit(new Event("submit"))
|
|
825
|
+
state.set([{ type: "text", content: "second", start: 0, end: 6 }])
|
|
826
|
+
await submission.submit(new Event("submit"))
|
|
827
|
+
first.reject(new Error("offline"))
|
|
828
|
+
await failed.settled.promise
|
|
829
|
+
// The second prompt's turn may already run; only the server's events may end it.
|
|
830
|
+
expect(statuses).toEqual(["running"])
|
|
831
|
+
|
|
832
|
+
failed.settled = Promise.withResolvers<void>()
|
|
833
|
+
second.reject(new Error("offline"))
|
|
834
|
+
await failed.settled.promise
|
|
835
|
+
expect(failed.count).toBe(2)
|
|
836
|
+
expect(statuses).toEqual(["running", "idle"])
|
|
837
|
+
})
|
|
838
|
+
|
|
839
|
+
test("resends a failed prompt under its ID only while what it sends is unchanged", async () => {
|
|
840
|
+
const state = createMemoryComposerState({ prompt: "ship it" }).capture()
|
|
841
|
+
|
|
842
|
+
const note = {
|
|
843
|
+
type: "note" as const,
|
|
844
|
+
origin: "browser",
|
|
845
|
+
label: "button#save",
|
|
846
|
+
icon: "select-element",
|
|
847
|
+
subject: 'the "button#save" element',
|
|
848
|
+
live: { subject: 'the "button#save" element (browser ref @e42)' },
|
|
849
|
+
comment: "Rename this",
|
|
850
|
+
commentID: "note",
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
state.context.add(note)
|
|
854
|
+
const sent: string[] = []
|
|
855
|
+
const run = { fail: true, queued: false, settled: Promise.withResolvers<void>() }
|
|
856
|
+
|
|
857
|
+
const submission = submitInput(
|
|
858
|
+
active(
|
|
859
|
+
state,
|
|
860
|
+
session({
|
|
861
|
+
calls: [],
|
|
862
|
+
prompt: async (value) => {
|
|
863
|
+
sent.push(value.id ?? "")
|
|
864
|
+
|
|
865
|
+
if (run.fail) throw new Error("offline")
|
|
866
|
+
run.settled.resolve()
|
|
867
|
+
},
|
|
868
|
+
}),
|
|
869
|
+
),
|
|
870
|
+
{ missingSelection() {}, unqueueable() {}, failed: () => run.settled.resolve() },
|
|
871
|
+
"normal",
|
|
872
|
+
undefined,
|
|
873
|
+
undefined,
|
|
874
|
+
undefined,
|
|
875
|
+
() => (run.queued ? "queue" : "steer"),
|
|
876
|
+
)
|
|
877
|
+
|
|
878
|
+
const send = async () => {
|
|
879
|
+
run.settled = Promise.withResolvers<void>()
|
|
880
|
+
sent.length = 0
|
|
881
|
+
await submission.submit(new Event("submit"))
|
|
882
|
+
await run.settled.promise
|
|
883
|
+
|
|
884
|
+
return sent[0]
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
const first = await send()
|
|
888
|
+
expect(state.retry.current()).toMatchObject({ id: first })
|
|
889
|
+
expect(await send()).toBe(first)
|
|
890
|
+
|
|
891
|
+
// The browser plugin re-picked the element, so the note now names another ref.
|
|
892
|
+
state.context.replaceComments([{ ...note, live: { subject: 'the "button#save" element (browser ref @e7)' } }])
|
|
893
|
+
const edited = await send()
|
|
894
|
+
expect(edited).not.toBe(first)
|
|
895
|
+
|
|
896
|
+
run.queued = true
|
|
897
|
+
const queued = await send()
|
|
898
|
+
expect(queued).not.toBe(edited)
|
|
899
|
+
|
|
900
|
+
run.fail = false
|
|
901
|
+
expect(await send()).toBe(queued)
|
|
902
|
+
expect(state.retry.current()).toBeUndefined()
|
|
903
|
+
})
|
|
904
|
+
|
|
905
|
+
test("an unedited resend after a failed send keeps its ID and its file order", async () => {
|
|
906
|
+
const state = createMemoryComposerState({ prompt: "review these" }).capture()
|
|
907
|
+
state.context.add({ type: "file", path: "src/a.ts" })
|
|
908
|
+
state.context.add({ type: "file", path: "src/b.ts", comment: "Check this", commentID: "b" })
|
|
909
|
+
const keys = state.context.items().map((item) => item.key)
|
|
910
|
+
const sent: string[] = []
|
|
911
|
+
const failed = { settled: Promise.withResolvers<void>() }
|
|
912
|
+
|
|
913
|
+
const submission = submitInput(
|
|
914
|
+
active(
|
|
915
|
+
state,
|
|
916
|
+
session({
|
|
917
|
+
calls: [],
|
|
918
|
+
prompt: async (value) => {
|
|
919
|
+
sent.push(value.id ?? "")
|
|
920
|
+
throw new Error("offline")
|
|
921
|
+
},
|
|
922
|
+
}),
|
|
923
|
+
),
|
|
924
|
+
{ missingSelection() {}, unqueueable() {}, failed: () => failed.settled.resolve() },
|
|
925
|
+
)
|
|
926
|
+
|
|
927
|
+
const send = async () => {
|
|
928
|
+
failed.settled = Promise.withResolvers<void>()
|
|
929
|
+
sent.length = 0
|
|
930
|
+
await submission.submit(new Event("submit"))
|
|
931
|
+
await failed.settled.promise
|
|
932
|
+
|
|
933
|
+
return sent[0]
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
const first = await send()
|
|
937
|
+
// Restoring used to list the commented file first, so the resend fingerprinted differently and took a new ID.
|
|
938
|
+
expect(state.context.items().map((item) => item.key)).toEqual(keys)
|
|
939
|
+
expect(await send()).toBe(first)
|
|
940
|
+
})
|
|
941
|
+
|
|
942
|
+
test("a failed server command restores its draft without a retry ID, which it never sent", async () => {
|
|
943
|
+
const state = createMemoryComposerState({ prompt: "/review" }).capture()
|
|
944
|
+
const failed = Promise.withResolvers<void>()
|
|
945
|
+
|
|
946
|
+
await submitInput(
|
|
947
|
+
active(
|
|
948
|
+
state,
|
|
949
|
+
session({
|
|
950
|
+
calls: [],
|
|
951
|
+
command: async () => {
|
|
952
|
+
throw new Error("offline")
|
|
953
|
+
},
|
|
954
|
+
}),
|
|
955
|
+
),
|
|
956
|
+
{ missingSelection() {}, unqueueable() {}, failed: () => failed.resolve() },
|
|
957
|
+
"normal",
|
|
958
|
+
() => [{ name: "review" }],
|
|
959
|
+
).submit(new Event("submit"))
|
|
960
|
+
await failed.promise
|
|
961
|
+
|
|
962
|
+
expect(text(state)).toBe("/review")
|
|
963
|
+
expect(state.retry.current()).toBeUndefined()
|
|
964
|
+
})
|
|
965
|
+
|
|
966
|
+
test("applies the selection and runs a client argument command without admitting it to the session", async () => {
|
|
967
|
+
const state = createMemoryComposerState().capture()
|
|
968
|
+
|
|
969
|
+
const image = {
|
|
970
|
+
type: "image" as const,
|
|
971
|
+
id: "attachment",
|
|
972
|
+
filename: "diagram.png",
|
|
973
|
+
mime: "image/png",
|
|
974
|
+
blob: { id: "attachment", url: "data:image/png;base64,YQ==" },
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
state.set([{ type: "text", content: "/btw why this approach?", start: 0, end: 23 }, image])
|
|
978
|
+
state.context.add({ type: "file", path: "src/retry.ts" })
|
|
979
|
+
const calls: string[] = []
|
|
980
|
+
const history: string[] = []
|
|
981
|
+
|
|
982
|
+
await submitInput(
|
|
983
|
+
{ ...active(state, session({ calls })), beforeSubmit: () => calls.push("keep-preview") },
|
|
984
|
+
undefined,
|
|
985
|
+
"normal",
|
|
986
|
+
undefined,
|
|
987
|
+
history,
|
|
988
|
+
(text) => {
|
|
989
|
+
expect(text).toBe("/btw why this approach?")
|
|
990
|
+
|
|
991
|
+
return () => {
|
|
992
|
+
calls.push("btw")
|
|
993
|
+
}
|
|
994
|
+
},
|
|
995
|
+
).submit(new Event("submit"))
|
|
996
|
+
|
|
997
|
+
// Client commands such as /btw generate with the session's model, so the composer's selection commits first.
|
|
998
|
+
expect(calls).toEqual(["keep-preview", "switch-agent", "switch-model", "btw"])
|
|
999
|
+
expect(history).toEqual([])
|
|
1000
|
+
expect(state.current()).toEqual([{ type: "text", content: "", start: 0, end: 0 }, image])
|
|
1001
|
+
expect(state.context.items()).toHaveLength(1)
|
|
1002
|
+
})
|
|
1003
|
+
|
|
1004
|
+
test.each([
|
|
1005
|
+
// The prompt admits before the selection commits, so a steer shows as pending while it does.
|
|
1006
|
+
{
|
|
1007
|
+
current: { agent: "plan", model: { id: "old", providerID: "old" } },
|
|
1008
|
+
calls: ["admit", "switch-agent", "switch-model", "send"],
|
|
1009
|
+
},
|
|
1010
|
+
// An unchanged selection sends without a model request to wait on.
|
|
1011
|
+
{
|
|
1012
|
+
current: { agent: "build", model: { providerID: "provider-1", id: "model-1", variant: "balanced" } },
|
|
1013
|
+
calls: ["admit", "send"],
|
|
1014
|
+
},
|
|
1015
|
+
// A prompt commits a staged revert, which would delete the model switch made after its boundary. The revert
|
|
1016
|
+
// settles before admission, whose row it would also delete.
|
|
1017
|
+
{
|
|
1018
|
+
current: { agent: "plan", model: { id: "old", providerID: "old" }, revert: { messageID: "msg_reverted" } },
|
|
1019
|
+
calls: ["switch-agent", "revert-commit", "switch-model", "admit", "send"],
|
|
1020
|
+
},
|
|
1021
|
+
])("applies the selection before sending one captured value: $calls", async (row) => {
|
|
1022
|
+
const state = createMemoryComposerState({ prompt: "ship it" }).capture()
|
|
1023
|
+
state.context.add({ type: "file", path: "notes.md", description: "the failing version" })
|
|
1024
|
+
const calls: string[] = []
|
|
1025
|
+
const admitted = Promise.withResolvers<Parameters<ComposerSession["data"]["session"]["prompt"]>[0]>()
|
|
1026
|
+
const target = session({ calls, current: () => row.current, prompt: async (value) => admitted.resolve(value) })
|
|
1027
|
+
|
|
1028
|
+
await submitInput(active(state, target)).submit(new Event("submit"))
|
|
1029
|
+
const request = await admitted.promise
|
|
1030
|
+
|
|
1031
|
+
expect(calls).toEqual([...row.calls])
|
|
1032
|
+
expect(request.delivery).toBe("steer")
|
|
1033
|
+
expect(request.text).toBe("ship it")
|
|
1034
|
+
expect(request.id).toMatch(/^msg_/)
|
|
1035
|
+
expect(request.metadata).toMatchObject({
|
|
1036
|
+
displayText: "ship it",
|
|
1037
|
+
agent: "build",
|
|
1038
|
+
model: { providerID: "provider-1", modelID: "model-1", variant: "balanced" },
|
|
1039
|
+
})
|
|
1040
|
+
// A file chip goes with this prompt only, like the TUI's mentionless files.
|
|
1041
|
+
expect(request.files).toMatchObject([{ name: "notes.md", description: "the failing version" }])
|
|
1042
|
+
expect(request.files?.[0]?.mention).toBeUndefined()
|
|
1043
|
+
expect(state.current()).toEqual([{ type: "text", content: "", start: 0, end: 0 }])
|
|
1044
|
+
expect(state.context.items()).toEqual([])
|
|
1045
|
+
})
|
|
1046
|
+
|
|
1047
|
+
test.each(["", "Align these targets"])("hands off and admits uncommented notes with instruction %j", async (text) => {
|
|
1048
|
+
const draft = createMemoryComposerState({ prompt: text }).capture()
|
|
1049
|
+
|
|
1050
|
+
const notes = [
|
|
1051
|
+
{
|
|
1052
|
+
type: "note" as const,
|
|
1053
|
+
origin: "example",
|
|
1054
|
+
label: "Save",
|
|
1055
|
+
title: "button#save",
|
|
1056
|
+
subtitle: "Browser annotation",
|
|
1057
|
+
icon: "select-element",
|
|
1058
|
+
subject: 'the "Save" element',
|
|
1059
|
+
href: "example:save",
|
|
1060
|
+
live: { subject: 'the "Save" element (live reference @e42)', href: "example:save#e42" },
|
|
1061
|
+
comment: "",
|
|
1062
|
+
},
|
|
1063
|
+
{
|
|
1064
|
+
type: "note" as const,
|
|
1065
|
+
origin: "another-plugin",
|
|
1066
|
+
label: "Cancel",
|
|
1067
|
+
icon: "select-element",
|
|
1068
|
+
subject: 'the "Cancel" element',
|
|
1069
|
+
comment: "",
|
|
1070
|
+
},
|
|
1071
|
+
]
|
|
1072
|
+
|
|
1073
|
+
notes.forEach((note, index) => draft.context.add({ ...note, commentID: `${index}` }))
|
|
1074
|
+
const handoffs: SessionMessageHandoff[] = []
|
|
1075
|
+
const first: Parameters<NewSessionComposerAdapter["start"]>[2][] = []
|
|
1076
|
+
const admitted = Promise.withResolvers<Parameters<ComposerSession["data"]["session"]["prompt"]>[0]>()
|
|
1077
|
+
const calls: string[] = []
|
|
1078
|
+
|
|
1079
|
+
const target = session({
|
|
1080
|
+
calls,
|
|
1081
|
+
handoff: { set: (value) => handoffs.push(value), hold() {}, settle() {}, clear() {} },
|
|
1082
|
+
prompt: async (value) => admitted.resolve(value),
|
|
1083
|
+
})
|
|
1084
|
+
|
|
1085
|
+
await submitInput(
|
|
1086
|
+
fresh(draft, async (_selection, _submission, message) => {
|
|
1087
|
+
first.push(message)
|
|
1088
|
+
|
|
1089
|
+
return { session: target, cleanupReady: Promise.resolve() }
|
|
1090
|
+
}),
|
|
1091
|
+
).submit(new Event("submit"))
|
|
1092
|
+
|
|
1093
|
+
expect(calls).toContain("admit")
|
|
1094
|
+
const request = await admitted.promise
|
|
1095
|
+
expect(request.metadata).toMatchObject({ displayText: text, comments: notes })
|
|
1096
|
+
expect(first).toMatchObject([{ text, metadata: { displayText: text, comments: notes } }])
|
|
1097
|
+
expect(handoffs).toMatchObject([{ message: { text, metadata: { displayText: text, comments: notes } } }])
|
|
1098
|
+
expect(draft.context.items()).toEqual([])
|
|
1099
|
+
})
|
|
1100
|
+
|
|
1101
|
+
test.each(["steer", "queue"] as const)(
|
|
1102
|
+
"shows a %s in the session as the composer clears, before its selection commits",
|
|
1103
|
+
async (delivery) => {
|
|
1104
|
+
const state = createMemoryComposerState({ prompt: "ship it" }).capture()
|
|
1105
|
+
const committed = Promise.withResolvers<void>()
|
|
1106
|
+
const handoffs: SessionMessageHandoff[] = []
|
|
1107
|
+
const statuses: ("idle" | "running")[] = []
|
|
1108
|
+
|
|
1109
|
+
const target = session({
|
|
1110
|
+
calls: [],
|
|
1111
|
+
statuses,
|
|
1112
|
+
handoff: { set: (handoff) => handoffs.push(handoff), hold() {}, settle() {}, clear() {} },
|
|
1113
|
+
switchModel: async () => committed.promise,
|
|
1114
|
+
})
|
|
1115
|
+
|
|
1116
|
+
await submitInput(
|
|
1117
|
+
active(state, target),
|
|
1118
|
+
undefined,
|
|
1119
|
+
"normal",
|
|
1120
|
+
undefined,
|
|
1121
|
+
undefined,
|
|
1122
|
+
undefined,
|
|
1123
|
+
() => delivery,
|
|
1124
|
+
).submit(new Event("submit"))
|
|
1125
|
+
|
|
1126
|
+
expect(state.current()).toEqual([{ type: "text", content: "", start: 0, end: 0 }])
|
|
1127
|
+
expect(statuses).toEqual(["running"])
|
|
1128
|
+
// A queued prompt shows in the queue once admitted, not in the transcript.
|
|
1129
|
+
expect(handoffs).toMatchObject(
|
|
1130
|
+
delivery === "steer"
|
|
1131
|
+
? [
|
|
1132
|
+
{
|
|
1133
|
+
message: { type: "user", text: "ship it" },
|
|
1134
|
+
selection: { agent: "build", model: { id: "model-1", providerID: "provider-1", variant: "balanced" } },
|
|
1135
|
+
},
|
|
1136
|
+
]
|
|
1137
|
+
: [],
|
|
1138
|
+
)
|
|
1139
|
+
committed.resolve()
|
|
1140
|
+
},
|
|
1141
|
+
)
|
|
1142
|
+
|
|
1143
|
+
test("applies the captured agent and model before a custom command without passing over its overrides", async () => {
|
|
1144
|
+
const state = createMemoryComposerState({ prompt: "/review changes" }).capture()
|
|
1145
|
+
const calls: string[] = []
|
|
1146
|
+
const selected = controls()
|
|
1147
|
+
const agent = Promise.withResolvers<void>()
|
|
1148
|
+
const started = Promise.withResolvers<void>()
|
|
1149
|
+
const committed = Promise.withResolvers<void>()
|
|
1150
|
+
const completed = Promise.withResolvers<void>()
|
|
1151
|
+
const accepted = Promise.withResolvers<void>()
|
|
1152
|
+
|
|
1153
|
+
const target = session({
|
|
1154
|
+
calls,
|
|
1155
|
+
accept: () => accepted.resolve(),
|
|
1156
|
+
switchAgent: async (request) => {
|
|
1157
|
+
expect(request.agent).toBe("build")
|
|
1158
|
+
calls.push("agent")
|
|
1159
|
+
started.resolve()
|
|
1160
|
+
await agent.promise
|
|
1161
|
+
},
|
|
1162
|
+
switchModel: async (request) => {
|
|
1163
|
+
expect(request.model).toEqual({ providerID: "provider-1", id: "model-1", variant: "balanced" })
|
|
1164
|
+
calls.push("model")
|
|
1165
|
+
await committed.promise
|
|
1166
|
+
},
|
|
1167
|
+
command: async (request) => {
|
|
1168
|
+
expect(request).toMatchObject({ name: "review", text: "changes", delivery: "steer" })
|
|
1169
|
+
expect(request).not.toHaveProperty("model")
|
|
1170
|
+
expect(request).not.toHaveProperty("agent")
|
|
1171
|
+
calls.push("command")
|
|
1172
|
+
completed.resolve()
|
|
1173
|
+
},
|
|
1174
|
+
})
|
|
1175
|
+
|
|
1176
|
+
selected.model.selection = {
|
|
1177
|
+
...selection,
|
|
1178
|
+
trackSessionCommit: (_id, value) => {
|
|
1179
|
+
expect(value).toEqual({
|
|
1180
|
+
agent: "build",
|
|
1181
|
+
model: { providerID: "provider-1", modelID: "model-1" },
|
|
1182
|
+
variant: "balanced",
|
|
1183
|
+
})
|
|
1184
|
+
calls.push("track")
|
|
1185
|
+
|
|
1186
|
+
return () => calls.push("cancel")
|
|
1187
|
+
},
|
|
1188
|
+
}
|
|
1189
|
+
await submitInput(
|
|
1190
|
+
active(state, target, () => selected),
|
|
1191
|
+
undefined,
|
|
1192
|
+
"normal",
|
|
1193
|
+
() => [{ name: "review" }],
|
|
1194
|
+
).submit(new Event("submit"))
|
|
1195
|
+
await started.promise
|
|
1196
|
+
expect(calls).toEqual(["track", "agent"])
|
|
1197
|
+
selected.agents.current = "plan"
|
|
1198
|
+
selected.model.selection = { ...selection, variant: { ...selection.variant, current: () => "high" } }
|
|
1199
|
+
agent.resolve()
|
|
1200
|
+
committed.resolve()
|
|
1201
|
+
await completed.promise
|
|
1202
|
+
await accepted.promise
|
|
1203
|
+
expect(calls).toEqual(["track", "agent", "model", "command", "accept-send"])
|
|
1204
|
+
})
|
|
1205
|
+
|
|
1206
|
+
test("cancels selection tracking and does not execute a command when selection fails", async () => {
|
|
1207
|
+
const state = createMemoryComposerState({ prompt: "/review changes" }).capture()
|
|
1208
|
+
const calls: string[] = []
|
|
1209
|
+
const selected = controls()
|
|
1210
|
+
const failed = Promise.withResolvers<unknown>()
|
|
1211
|
+
const error = new Error("model unavailable")
|
|
1212
|
+
|
|
1213
|
+
const target = session({
|
|
1214
|
+
calls,
|
|
1215
|
+
switchModel: async () => {
|
|
1216
|
+
throw error
|
|
1217
|
+
},
|
|
1218
|
+
command: async () => {
|
|
1219
|
+
calls.push("command")
|
|
1220
|
+
},
|
|
1221
|
+
})
|
|
1222
|
+
|
|
1223
|
+
selected.model.selection = {
|
|
1224
|
+
...selection,
|
|
1225
|
+
trackSessionCommit: () => {
|
|
1226
|
+
calls.push("track")
|
|
1227
|
+
|
|
1228
|
+
return () => {
|
|
1229
|
+
calls.push("cancel")
|
|
1230
|
+
}
|
|
1231
|
+
},
|
|
1232
|
+
}
|
|
1233
|
+
await submitInput(
|
|
1234
|
+
active(state, target, () => selected),
|
|
1235
|
+
{ missingSelection() {}, unqueueable() {}, failed: (_kind, error) => failed.resolve(error) },
|
|
1236
|
+
"normal",
|
|
1237
|
+
() => [{ name: "review" }],
|
|
1238
|
+
).submit(new Event("submit"))
|
|
1239
|
+
expect(await failed.promise).toBe(error)
|
|
1240
|
+
expect(calls).toEqual(["track", "switch-agent", "cancel"])
|
|
1241
|
+
expect(state.current()[0]).toMatchObject({ content: "/review changes" })
|
|
1242
|
+
})
|
|
1243
|
+
|
|
1244
|
+
test("restores and retries an unacknowledged admission", async () => {
|
|
1245
|
+
const state = createMemoryComposerState().capture()
|
|
1246
|
+
|
|
1247
|
+
const prompt: Prompt = [
|
|
1248
|
+
{ type: "text", content: "retry ", start: 0, end: 6 },
|
|
1249
|
+
{ type: "file", path: "src/app.ts", content: "@src/app.ts", start: 6, end: 17 },
|
|
1250
|
+
{
|
|
1251
|
+
type: "image",
|
|
1252
|
+
id: "attachment",
|
|
1253
|
+
filename: "image.png",
|
|
1254
|
+
mime: "image/png",
|
|
1255
|
+
blob: { id: "attachment", url: "data:image/png;base64,YQ==" },
|
|
1256
|
+
},
|
|
1257
|
+
]
|
|
1258
|
+
|
|
1259
|
+
state.set(prompt)
|
|
1260
|
+
state.context.add({ type: "file", path: "notes.md", description: "the failing version" })
|
|
1261
|
+
|
|
1262
|
+
const note = {
|
|
1263
|
+
type: "note" as const,
|
|
1264
|
+
origin: "example",
|
|
1265
|
+
label: "Target",
|
|
1266
|
+
title: "#target",
|
|
1267
|
+
subtitle: "Browser annotation",
|
|
1268
|
+
icon: "select-element",
|
|
1269
|
+
subject: "the target",
|
|
1270
|
+
live: { subject: "the live target" },
|
|
1271
|
+
comment: "",
|
|
1272
|
+
commentID: "target",
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
state.context.add(note)
|
|
1276
|
+
const attempts: string[] = []
|
|
1277
|
+
const calls: string[] = []
|
|
1278
|
+
const statuses: ("idle" | "running")[] = []
|
|
1279
|
+
const first = Promise.withResolvers<void>()
|
|
1280
|
+
const second = Promise.withResolvers<void>()
|
|
1281
|
+
|
|
1282
|
+
const target = session({
|
|
1283
|
+
calls,
|
|
1284
|
+
statuses,
|
|
1285
|
+
prompt: async (value) => {
|
|
1286
|
+
attempts.push(value.id ?? "")
|
|
1287
|
+
throw new Error("network unavailable")
|
|
1288
|
+
},
|
|
1289
|
+
})
|
|
1290
|
+
|
|
1291
|
+
const notify = {
|
|
1292
|
+
missingSelection() {},
|
|
1293
|
+
unqueueable() {},
|
|
1294
|
+
failed: () => (attempts.length === 2 ? first.resolve() : second.resolve()),
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
const history: string[] = []
|
|
1298
|
+
const submission = submitInput(active(state, target), notify, "normal", () => [], history)
|
|
1299
|
+
|
|
1300
|
+
await submission.submit(new Event("submit"))
|
|
1301
|
+
await first.promise
|
|
1302
|
+
await submission.submit(new Event("submit"))
|
|
1303
|
+
await second.promise
|
|
1304
|
+
|
|
1305
|
+
expect(attempts).toHaveLength(4)
|
|
1306
|
+
expect(new Set(attempts).size).toBe(1)
|
|
1307
|
+
// A retried admission reuses its submission's selection commit.
|
|
1308
|
+
const submitted = ["admit", "switch-agent", "switch-model", "send", "admit", "send"]
|
|
1309
|
+
expect(calls).toEqual([...submitted, ...submitted])
|
|
1310
|
+
expect(statuses).toEqual(["running", "idle", "running", "idle"])
|
|
1311
|
+
expect(state.current()).toEqual(prompt)
|
|
1312
|
+
// In the order it was sent, so the resend's request matches the first.
|
|
1313
|
+
expect(state.context.items()).toMatchObject([
|
|
1314
|
+
{ type: "file", path: "notes.md", description: "the failing version" },
|
|
1315
|
+
note,
|
|
1316
|
+
])
|
|
1317
|
+
// The caret returns after the mention text; attachments take no caret positions.
|
|
1318
|
+
expect(state.cursor()).toBe(17)
|
|
1319
|
+
// The restored prompt is the draft again, so history does not also keep it (and its attachments).
|
|
1320
|
+
const entry = "retry @src/app.tsimage"
|
|
1321
|
+
expect(history).toEqual([`add:${entry}`, `remove:${entry}`, `add:${entry}`, `remove:${entry}`])
|
|
1322
|
+
})
|
|
1323
|
+
|
|
1324
|
+
test("restores first-prompt comments into the promoted Session", async () => {
|
|
1325
|
+
const draft = createMemoryComposerState({ prompt: "first prompt" }).capture()
|
|
1326
|
+
draft.store[1]("context", "items", [
|
|
1327
|
+
{
|
|
1328
|
+
key: "file:src/app.ts:1:1:comment",
|
|
1329
|
+
type: "file",
|
|
1330
|
+
path: "src/app.ts",
|
|
1331
|
+
comment: "Keep this comment",
|
|
1332
|
+
selection: { startLine: 1, startChar: 0, endLine: 1, endChar: 4 },
|
|
1333
|
+
},
|
|
1334
|
+
])
|
|
1335
|
+
expect(draft.context.items()).toHaveLength(1)
|
|
1336
|
+
const promoted = createMemoryComposerState().capture()
|
|
1337
|
+
const failed = Promise.withResolvers<void>()
|
|
1338
|
+
const target = session({ calls: [], shell: async () => Promise.reject(new Error("send failed")) })
|
|
1339
|
+
|
|
1340
|
+
const adapter = fresh(draft, async (_selection, submission) => {
|
|
1341
|
+
submission.retarget(promoted)
|
|
1342
|
+
|
|
1343
|
+
return { session: target, cleanupReady: Promise.resolve() }
|
|
1344
|
+
})
|
|
1345
|
+
|
|
1346
|
+
await submitInput(
|
|
1347
|
+
adapter,
|
|
1348
|
+
{ missingSelection() {}, unqueueable() {}, failed: () => failed.resolve() },
|
|
1349
|
+
"shell",
|
|
1350
|
+
).submit(new Event("submit"))
|
|
1351
|
+
await failed.promise
|
|
1352
|
+
|
|
1353
|
+
expect(promoted.current()).toMatchObject([{ type: "text", content: "first prompt" }])
|
|
1354
|
+
expect(promoted.context.items()).toMatchObject([{ type: "file", path: "src/app.ts", comment: "Keep this comment" }])
|
|
1355
|
+
expect(promoted.mode.current()).toBe("shell")
|
|
1356
|
+
})
|
|
1357
|
+
|
|
1358
|
+
test("moves a first prompt and its quote sources to the promoted Session, and recovers it with the follow-up typed there", async () => {
|
|
1359
|
+
const draft = createMemoryComposerState({ prompt: "first prompt" }).capture()
|
|
1360
|
+
draft.context.add({ type: "quote", commentID: "quote-source", text: "quoted passage" })
|
|
1361
|
+
const key = draft.context.items()[0]!.key
|
|
1362
|
+
const source = [{ partID: "part-source", revealID: "message-source", start: 4, end: 18, text: "quoted passage" }]
|
|
1363
|
+
draft.quoteSource.add(key, source)
|
|
1364
|
+
// The Session's composer already holds a follow-up typed while it prepared.
|
|
1365
|
+
const promoted = createMemoryComposerState({ prompt: "follow-up" }).capture()
|
|
1366
|
+
const moved: (typeof promoted.quoteSource.state.sources)[string][] = []
|
|
1367
|
+
const release = Promise.withResolvers<void>()
|
|
1368
|
+
const failed = Promise.withResolvers<void>()
|
|
1369
|
+
|
|
1370
|
+
const target = session({
|
|
1371
|
+
calls: [],
|
|
1372
|
+
prompt: async () => {
|
|
1373
|
+
await release.promise
|
|
1374
|
+
throw new Error("network unavailable")
|
|
1375
|
+
},
|
|
1376
|
+
})
|
|
1377
|
+
|
|
1378
|
+
await submitInput(
|
|
1379
|
+
fresh(draft, async (_selection, submission) => {
|
|
1380
|
+
submission.retarget(promoted, { preserveDraft: true })
|
|
1381
|
+
moved.push(promoted.quoteSource.state.sources[key])
|
|
1382
|
+
|
|
1383
|
+
return { session: target, cleanupReady: Promise.resolve() }
|
|
1384
|
+
}),
|
|
1385
|
+
{ missingSelection() {}, unqueueable() {}, failed: () => failed.resolve() },
|
|
1386
|
+
).submit(new Event("submit"))
|
|
1387
|
+
|
|
1388
|
+
expect(moved).toEqual([source])
|
|
1389
|
+
expect(text(draft)).toBe("")
|
|
1390
|
+
expect(text(promoted)).toBe("follow-up")
|
|
1391
|
+
release.resolve()
|
|
1392
|
+
await failed.promise
|
|
1393
|
+
|
|
1394
|
+
expect(text(promoted)).toBe("first prompt\n\nfollow-up")
|
|
1395
|
+
expect(promoted.context.items()).toMatchObject([{ key, type: "quote", text: "quoted passage" }])
|
|
1396
|
+
expect(promoted.quoteSource.state.sources[key]).toEqual(source)
|
|
1397
|
+
// A recovered follow-up changes the payload, so it is not a retry of the failed admission.
|
|
1398
|
+
expect(promoted.retry.current()).toBeUndefined()
|
|
1399
|
+
})
|
|
1400
|
+
|
|
1401
|
+
test("does not restore a failed prompt over one typed after the composer cleared", async () => {
|
|
1402
|
+
const state = createMemoryComposerState({ prompt: "submitted" }).capture()
|
|
1403
|
+
const release = Promise.withResolvers<void>()
|
|
1404
|
+
const failed = Promise.withResolvers<void>()
|
|
1405
|
+
const history: string[] = []
|
|
1406
|
+
|
|
1407
|
+
const target = session({
|
|
1408
|
+
calls: [],
|
|
1409
|
+
prompt: async () => {
|
|
1410
|
+
await release.promise
|
|
1411
|
+
throw new Error("network unavailable")
|
|
1412
|
+
},
|
|
1413
|
+
})
|
|
1414
|
+
|
|
1415
|
+
await submitInput(
|
|
1416
|
+
active(state, target),
|
|
1417
|
+
{ missingSelection() {}, unqueueable() {}, failed: () => failed.resolve() },
|
|
1418
|
+
"normal",
|
|
1419
|
+
() => [],
|
|
1420
|
+
history,
|
|
1421
|
+
).submit(new Event("submit"))
|
|
1422
|
+
state.set([{ type: "text", content: "new draft", start: 0, end: 9 }])
|
|
1423
|
+
release.resolve()
|
|
1424
|
+
await failed.promise
|
|
1425
|
+
|
|
1426
|
+
expect(text(state)).toBe("new draft")
|
|
1427
|
+
expect(history).toEqual(["add:submitted"])
|
|
1428
|
+
})
|
|
1429
|
+
|
|
1430
|
+
test("does not restore a prompt already acknowledged by the durable inbox", async () => {
|
|
1431
|
+
const state = createMemoryComposerState({ prompt: "admitted prompt" }).capture()
|
|
1432
|
+
const checked = Promise.withResolvers<void>()
|
|
1433
|
+
const attempts: string[] = []
|
|
1434
|
+
|
|
1435
|
+
const target = session({
|
|
1436
|
+
calls: [],
|
|
1437
|
+
admitted: () => {
|
|
1438
|
+
checked.resolve()
|
|
1439
|
+
|
|
1440
|
+
return true
|
|
1441
|
+
},
|
|
1442
|
+
prompt: async (value) => {
|
|
1443
|
+
attempts.push(value.id ?? "")
|
|
1444
|
+
throw new Error("response lost")
|
|
1445
|
+
},
|
|
1446
|
+
})
|
|
1447
|
+
|
|
1448
|
+
await submitInput(active(state, target)).submit(new Event("submit"))
|
|
1449
|
+
await checked.promise
|
|
1450
|
+
|
|
1451
|
+
expect(state.current()).toEqual([{ type: "text", content: "", start: 0, end: 0 }])
|
|
1452
|
+
expect(attempts).toHaveLength(2)
|
|
1453
|
+
expect(new Set(attempts).size).toBe(1)
|
|
1454
|
+
})
|
|
1455
|
+
|
|
1456
|
+
describe("steering while foreground work runs", () => {
|
|
1457
|
+
// A long shell command blocks the run; moving it resolves only the move, never the admission.
|
|
1458
|
+
// `unstarted` moves before the shell's job starts, so the server finds nothing to move and the call still blocks.
|
|
1459
|
+
function running(
|
|
1460
|
+
input: {
|
|
1461
|
+
fail?: boolean
|
|
1462
|
+
failOnce?: boolean
|
|
1463
|
+
unstarted?: boolean
|
|
1464
|
+
blocking?: { partID: string }[]
|
|
1465
|
+
prompt?: () => Promise<void>
|
|
1466
|
+
} = {},
|
|
1467
|
+
) {
|
|
1468
|
+
const calls: string[] = []
|
|
1469
|
+
const failures: string[] = []
|
|
1470
|
+
const state = createMemoryComposerState({ prompt: "use Beta instead" }).capture()
|
|
1471
|
+
const blocking = { parts: input.blocking ?? [{ partID: "prt_shell" }] }
|
|
1472
|
+
|
|
1473
|
+
const claim = createSteerBackground({
|
|
1474
|
+
sessionID: () => "session-1",
|
|
1475
|
+
blocking: () => blocking.parts,
|
|
1476
|
+
move: async () => {
|
|
1477
|
+
calls.push("background")
|
|
1478
|
+
|
|
1479
|
+
if (input.fail) throw new Error("server unavailable")
|
|
1480
|
+
|
|
1481
|
+
if (input.failOnce) {
|
|
1482
|
+
input.failOnce = false
|
|
1483
|
+
throw new Error("server unavailable")
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
if (input.unstarted) {
|
|
1487
|
+
input.unstarted = false
|
|
1488
|
+
|
|
1489
|
+
return
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
blocking.parts = []
|
|
1493
|
+
},
|
|
1494
|
+
})
|
|
1495
|
+
|
|
1496
|
+
const target = session({ calls, prompt: input.prompt, background: () => claim("session-1") })
|
|
1497
|
+
const adapter = { ...active(state, target), working: () => true }
|
|
1498
|
+
const notify = { missingSelection() {}, unqueueable() {}, failed: () => void failures.push("failed") }
|
|
1499
|
+
|
|
1500
|
+
const submit = async (delivery: ComposerDelivery = "steer", working = true) => {
|
|
1501
|
+
state.set([{ type: "text", content: "use Beta instead", start: 0, end: 16 }])
|
|
1502
|
+
await submitInput(
|
|
1503
|
+
{ ...adapter, working: () => working },
|
|
1504
|
+
notify,
|
|
1505
|
+
"normal",
|
|
1506
|
+
() => [],
|
|
1507
|
+
[],
|
|
1508
|
+
undefined,
|
|
1509
|
+
() => delivery,
|
|
1510
|
+
).submit(new Event("submit"))
|
|
1511
|
+
// The send settles after submit returns; let it and the move that follows it finish.
|
|
1512
|
+
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
return { calls, failures, submit, blocking }
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
test("moves the work to the background once the steer is admitted, and only once", async () => {
|
|
1519
|
+
const run = running()
|
|
1520
|
+
|
|
1521
|
+
await run.submit()
|
|
1522
|
+
expect(run.calls).toEqual(["admit", "switch-agent", "switch-model", "send", "accept-send", "background"])
|
|
1523
|
+
|
|
1524
|
+
await run.submit()
|
|
1525
|
+
expect(run.calls.filter((call) => call === "background")).toHaveLength(1)
|
|
1526
|
+
})
|
|
1527
|
+
|
|
1528
|
+
test("a steer moves work that its previous steer's move missed", async () => {
|
|
1529
|
+
const run = running({ unstarted: true })
|
|
1530
|
+
|
|
1531
|
+
await run.submit()
|
|
1532
|
+
await run.submit()
|
|
1533
|
+
expect(run.calls.filter((call) => call === "background")).toHaveLength(2)
|
|
1534
|
+
})
|
|
1535
|
+
|
|
1536
|
+
test("a steer sent while the previous one is admitted moves the work when the previous move fails", async () => {
|
|
1537
|
+
const admitted = Promise.withResolvers<void>()
|
|
1538
|
+
const attempts = { count: 0 }
|
|
1539
|
+
|
|
1540
|
+
const run = running({
|
|
1541
|
+
failOnce: true,
|
|
1542
|
+
prompt: async () => {
|
|
1543
|
+
attempts.count++
|
|
1544
|
+
|
|
1545
|
+
if (attempts.count === 1) await admitted.promise
|
|
1546
|
+
},
|
|
1547
|
+
})
|
|
1548
|
+
|
|
1549
|
+
await run.submit()
|
|
1550
|
+
await run.submit()
|
|
1551
|
+
admitted.resolve()
|
|
1552
|
+
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
1553
|
+
expect(run.calls.filter((call) => call === "background")).toHaveLength(2)
|
|
1554
|
+
expect(run.blocking.parts).toEqual([])
|
|
1555
|
+
})
|
|
1556
|
+
|
|
1557
|
+
test("moves a shell that starts while the steer is admitted", async () => {
|
|
1558
|
+
const run = running({
|
|
1559
|
+
blocking: [],
|
|
1560
|
+
prompt: async () => {
|
|
1561
|
+
run.blocking.parts = [{ partID: "prt_shell" }]
|
|
1562
|
+
},
|
|
1563
|
+
})
|
|
1564
|
+
|
|
1565
|
+
await run.submit()
|
|
1566
|
+
expect(run.calls.filter((call) => call === "background")).toHaveLength(1)
|
|
1567
|
+
expect(run.blocking.parts).toEqual([])
|
|
1568
|
+
})
|
|
1569
|
+
|
|
1570
|
+
test("leaves the work alone for a queued prompt or an idle session", async () => {
|
|
1571
|
+
const run = running()
|
|
1572
|
+
|
|
1573
|
+
await run.submit("queue")
|
|
1574
|
+
await run.submit("steer", false)
|
|
1575
|
+
expect(run.calls).not.toContain("background")
|
|
1576
|
+
})
|
|
1577
|
+
|
|
1578
|
+
test("still sends the steer when the move fails, and a later steer tries again", async () => {
|
|
1579
|
+
const run = running({ fail: true })
|
|
1580
|
+
|
|
1581
|
+
await run.submit()
|
|
1582
|
+
await run.submit()
|
|
1583
|
+
expect(run.failures).toEqual([])
|
|
1584
|
+
expect(run.calls.filter((call) => call === "send")).toHaveLength(2)
|
|
1585
|
+
expect(run.calls.filter((call) => call === "background")).toHaveLength(2)
|
|
1586
|
+
})
|
|
1587
|
+
|
|
1588
|
+
test("a steer that fails to send leaves the work for the next one", async () => {
|
|
1589
|
+
const attempts = { count: 0 }
|
|
1590
|
+
|
|
1591
|
+
const run = running({
|
|
1592
|
+
prompt: async () => {
|
|
1593
|
+
attempts.count++
|
|
1594
|
+
|
|
1595
|
+
// The first submission's admission and its single retry both fail.
|
|
1596
|
+
if (attempts.count <= 2) throw new Error("network unavailable")
|
|
1597
|
+
},
|
|
1598
|
+
})
|
|
1599
|
+
|
|
1600
|
+
await run.submit()
|
|
1601
|
+
expect(run.failures).toEqual(["failed"])
|
|
1602
|
+
expect(run.calls).not.toContain("background")
|
|
1603
|
+
|
|
1604
|
+
await run.submit()
|
|
1605
|
+
expect(run.calls.filter((call) => call === "background")).toHaveLength(1)
|
|
1606
|
+
})
|
|
1607
|
+
})
|
|
1608
|
+
|
|
1609
|
+
test("hands off image-only first prompts and admits them before cleanup is ready", async () => {
|
|
1610
|
+
const draft = createMemoryComposerState().capture()
|
|
1611
|
+
|
|
1612
|
+
const prompt: Prompt = [
|
|
1613
|
+
{ type: "text", content: "", start: 0, end: 0 },
|
|
1614
|
+
{
|
|
1615
|
+
type: "image",
|
|
1616
|
+
id: "attachment",
|
|
1617
|
+
filename: "image.png",
|
|
1618
|
+
mime: "image/png",
|
|
1619
|
+
blob: { id: "attachment", url: "data:image/png;base64,YQ==" },
|
|
1620
|
+
},
|
|
1621
|
+
]
|
|
1622
|
+
|
|
1623
|
+
draft.set(prompt)
|
|
1624
|
+
const handedOff = Promise.withResolvers<SessionMessageHandoff>()
|
|
1625
|
+
const admitted = Promise.withResolvers<void>()
|
|
1626
|
+
const cleanup = Promise.withResolvers<void>()
|
|
1627
|
+
|
|
1628
|
+
const target = session({
|
|
1629
|
+
calls: [],
|
|
1630
|
+
handoff: { set: handedOff.resolve, hold() {}, settle() {}, clear() {} },
|
|
1631
|
+
prompt: async () => admitted.resolve(),
|
|
1632
|
+
})
|
|
1633
|
+
|
|
1634
|
+
const submitted = submitInput(
|
|
1635
|
+
fresh(draft, async () => ({ session: target, cleanupReady: cleanup.promise })),
|
|
1636
|
+
).submit(new Event("submit"))
|
|
1637
|
+
|
|
1638
|
+
await admitted.promise
|
|
1639
|
+
expect(draft.current()).toEqual(prompt)
|
|
1640
|
+
cleanup.resolve()
|
|
1641
|
+
await submitted
|
|
1642
|
+
expect(draft.current()).toEqual([{ type: "text", content: "", start: 0, end: 0 }])
|
|
1643
|
+
|
|
1644
|
+
expect((await handedOff.promise).message).toMatchObject({
|
|
1645
|
+
type: "user",
|
|
1646
|
+
text: "",
|
|
1647
|
+
files: [
|
|
1648
|
+
{
|
|
1649
|
+
data: "",
|
|
1650
|
+
mime: "image/png",
|
|
1651
|
+
source: { type: "uri", uri: "data:image/png;base64,YQ==" },
|
|
1652
|
+
name: "image.png",
|
|
1653
|
+
},
|
|
1654
|
+
],
|
|
1655
|
+
})
|
|
1656
|
+
})
|
|
1657
|
+
|
|
1658
|
+
test.each([
|
|
1659
|
+
{ case: "is admitted", fails: false, admitted: false, result: "settle" },
|
|
1660
|
+
{ case: "loses its response after admission", fails: true, admitted: true, result: "settle" },
|
|
1661
|
+
{ case: "fails", fails: true, admitted: false, result: "clear" },
|
|
1662
|
+
])("a steer's handoff waits for its echo or ends when its send $case", async (row) => {
|
|
1663
|
+
const state = createMemoryComposerState({ prompt: "steer" }).capture()
|
|
1664
|
+
const handoff: string[] = []
|
|
1665
|
+
const ended = Promise.withResolvers<void>()
|
|
1666
|
+
|
|
1667
|
+
const target = session({
|
|
1668
|
+
calls: [],
|
|
1669
|
+
admitted: () => row.admitted,
|
|
1670
|
+
handoff: {
|
|
1671
|
+
set: (value) => handoff.push(`set:${value.message.id}`),
|
|
1672
|
+
hold: (value) => handoff.push(`hold:${value.message.id}`),
|
|
1673
|
+
settle: (id) => {
|
|
1674
|
+
handoff.push(`settle:${id}`)
|
|
1675
|
+
ended.resolve()
|
|
1676
|
+
},
|
|
1677
|
+
clear: (id) => {
|
|
1678
|
+
handoff.push(`clear:${id}`)
|
|
1679
|
+
ended.resolve()
|
|
1680
|
+
},
|
|
1681
|
+
},
|
|
1682
|
+
prompt: async () => {
|
|
1683
|
+
if (row.fails) throw new Error("response lost")
|
|
1684
|
+
},
|
|
1685
|
+
})
|
|
1686
|
+
|
|
1687
|
+
await submitInput(active(state, target)).submit(new Event("submit"))
|
|
1688
|
+
await ended.promise
|
|
1689
|
+
|
|
1690
|
+
expect(handoff).toHaveLength(2)
|
|
1691
|
+
expect(handoff[1]).toBe(handoff[0]!.replace("set:", `${row.result}:`))
|
|
1692
|
+
})
|
|
1693
|
+
|
|
1694
|
+
test("forwards structured mentions to custom commands", async () => {
|
|
1695
|
+
const state = createMemoryComposerState().capture()
|
|
1696
|
+
state.set([
|
|
1697
|
+
{ type: "text", content: "/review ", start: 0, end: 8 },
|
|
1698
|
+
{ type: "file", path: "src/app.ts", content: "@src/app.ts", start: 8, end: 19 },
|
|
1699
|
+
{ type: "text", content: " ", start: 19, end: 20 },
|
|
1700
|
+
{ type: "agent", name: "review", content: "@review", start: 20, end: 27 },
|
|
1701
|
+
{ type: "text", content: " ", start: 27, end: 28 },
|
|
1702
|
+
{
|
|
1703
|
+
type: "skill",
|
|
1704
|
+
id: Skill.ID.make("effect"),
|
|
1705
|
+
name: Skill.Name.make("Effect"),
|
|
1706
|
+
content: "@effect",
|
|
1707
|
+
start: 28,
|
|
1708
|
+
end: 35,
|
|
1709
|
+
},
|
|
1710
|
+
])
|
|
1711
|
+
const sent = Promise.withResolvers<Parameters<ComposerSession["api"]["command"]>[0]>()
|
|
1712
|
+
const target = session({ calls: [], command: async (value) => sent.resolve(value) })
|
|
1713
|
+
|
|
1714
|
+
await submitInput(active(state, target), undefined, "normal", () => [{ name: "review" }]).submit(
|
|
1715
|
+
new Event("submit"),
|
|
1716
|
+
)
|
|
1717
|
+
const request = await sent.promise
|
|
1718
|
+
|
|
1719
|
+
expect(request.files).toMatchObject([{ name: "app.ts", mention: { text: "@src/app.ts" } }])
|
|
1720
|
+
expect(request.agents).toMatchObject([{ name: "review", mention: { text: "@review" } }])
|
|
1721
|
+
expect(request.skills).toMatchObject([{ id: "effect", name: "Effect", mention: { text: "@effect" } }])
|
|
1722
|
+
expect(request.delivery).toBe("steer")
|
|
1723
|
+
})
|
|
1724
|
+
|
|
1725
|
+
test("captures commands before creating a session in a new worktree", async () => {
|
|
1726
|
+
const state = createMemoryComposerState({ prompt: "/review https://github.com/example/repo/pull/1" }).capture()
|
|
1727
|
+
const catalog = [{ name: "review" }]
|
|
1728
|
+
const sent = Promise.withResolvers<"prompt" | "command">()
|
|
1729
|
+
const requests: Parameters<ComposerSession["api"]["command"]>[0][] = []
|
|
1730
|
+
|
|
1731
|
+
const target = session({
|
|
1732
|
+
calls: [],
|
|
1733
|
+
prompt: async () => sent.resolve("prompt"),
|
|
1734
|
+
command: async (value) => {
|
|
1735
|
+
requests.push(value)
|
|
1736
|
+
sent.resolve("command")
|
|
1737
|
+
},
|
|
1738
|
+
})
|
|
1739
|
+
|
|
1740
|
+
target.directory = "C:/new-worktree"
|
|
1741
|
+
target.data.location.command.list = () => undefined
|
|
1742
|
+
|
|
1743
|
+
const adapter = fresh(state, async () => {
|
|
1744
|
+
// The destination catalog has not loaded, and the source composer is leaving.
|
|
1745
|
+
catalog.splice(0)
|
|
1746
|
+
|
|
1747
|
+
return { session: target, cleanupReady: Promise.resolve() }
|
|
1748
|
+
})
|
|
1749
|
+
|
|
1750
|
+
await submitInput(adapter, undefined, "normal", () => catalog).submit(new Event("submit"))
|
|
1751
|
+
|
|
1752
|
+
expect(await sent.promise).toBe("command")
|
|
1753
|
+
expect(requests).toEqual([
|
|
1754
|
+
{
|
|
1755
|
+
sessionID: target.id,
|
|
1756
|
+
name: "review",
|
|
1757
|
+
text: "https://github.com/example/repo/pull/1",
|
|
1758
|
+
files: [],
|
|
1759
|
+
agents: [],
|
|
1760
|
+
skills: [],
|
|
1761
|
+
delivery: "steer",
|
|
1762
|
+
},
|
|
1763
|
+
])
|
|
1764
|
+
})
|
|
1765
|
+
|
|
1766
|
+
test("does not run an empty shell command from hidden attachments", async () => {
|
|
1767
|
+
const state = createMemoryComposerState().capture()
|
|
1768
|
+
state.set([
|
|
1769
|
+
{ type: "text", content: "", start: 0, end: 0 },
|
|
1770
|
+
{
|
|
1771
|
+
type: "image",
|
|
1772
|
+
id: "attachment",
|
|
1773
|
+
filename: "notes.txt",
|
|
1774
|
+
mime: "text/plain",
|
|
1775
|
+
blob: { id: "attachment", url: "data:text/plain;base64,bm90ZXM=" },
|
|
1776
|
+
},
|
|
1777
|
+
])
|
|
1778
|
+
const calls: string[] = []
|
|
1779
|
+
|
|
1780
|
+
await submitInput(active(state, session({ calls })), undefined, "shell").submit(new Event("submit"))
|
|
1781
|
+
|
|
1782
|
+
expect(calls).toEqual([])
|
|
1783
|
+
expect(state.current().some((part) => part.type === "image")).toBe(true)
|
|
1784
|
+
})
|
|
1785
|
+
})
|