@neurocode-ai/app 1.18.8
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 +35 -0
- package/README.md +50 -0
- package/V1_API_MIGRATION.md +220 -0
- package/bunfig.toml +3 -0
- package/create-effect-simplification-spec.md +515 -0
- package/e2e/performance/AGENTS.md +13 -0
- package/e2e/performance/README.md +79 -0
- package/e2e/performance/benchmark.ts +144 -0
- package/e2e/performance/chrome-trace.ts +95 -0
- package/e2e/performance/playwright.config.ts +20 -0
- package/e2e/performance/playwright.uncapped.config.ts +13 -0
- package/e2e/performance/timeline/first-navigation-benchmark.spec.ts +87 -0
- package/e2e/performance/timeline/first-navigation-metrics.ts +32 -0
- package/e2e/performance/timeline/first-navigation-probe.ts +86 -0
- package/e2e/performance/timeline/home-tab-navigation-benchmark.spec.ts +114 -0
- package/e2e/performance/timeline/navigation-milestones.ts +128 -0
- package/e2e/performance/timeline/review-pane-scaling-benchmark.spec.ts +312 -0
- package/e2e/performance/timeline/session-parent-hydration-benchmark.spec.ts +172 -0
- package/e2e/performance/timeline/session-tab-flash.spec.ts +67 -0
- package/e2e/performance/timeline/session-tab-repaint-probe.ts +251 -0
- package/e2e/performance/timeline/session-tab-switch-benchmark.spec.ts +144 -0
- package/e2e/performance/timeline/session-tab-switch-metrics.ts +59 -0
- package/e2e/performance/timeline/session-tab-switch-probe.ts +226 -0
- package/e2e/performance/timeline/session-timeline-benchmark.fixture.ts +504 -0
- package/e2e/performance/timeline/session-timeline-benchmark.spec.ts +306 -0
- package/e2e/performance/timeline/session-timeline-profile.ts +40 -0
- package/e2e/performance/timeline/session-timeline-stream-probe.ts +547 -0
- package/e2e/performance/timeline/session-timeline-stress.fixture.ts +369 -0
- package/e2e/performance/timeline/timeline-test-helpers.ts +134 -0
- package/e2e/performance/timeline-stability/README.md +61 -0
- package/e2e/performance/timeline-stability/adverse.spec.ts +250 -0
- package/e2e/performance/timeline-stability/context-matrix.spec.ts +192 -0
- package/e2e/performance/timeline-stability/environment-matrix.spec.ts +113 -0
- package/e2e/performance/timeline-stability/file-matrix.spec.ts +121 -0
- package/e2e/performance/timeline-stability/file-mutation.spec.ts +113 -0
- package/e2e/performance/timeline-stability/fixture.test.ts +68 -0
- package/e2e/performance/timeline-stability/fixture.ts +566 -0
- package/e2e/performance/timeline-stability/interaction.spec.ts +242 -0
- package/e2e/performance/timeline-stability/lifecycle.spec.ts +157 -0
- package/e2e/performance/timeline-stability/oracle-browser.spec.ts +75 -0
- package/e2e/performance/timeline-stability/playwright.config.ts +17 -0
- package/e2e/performance/timeline-stability/scroll-interaction.spec.ts +353 -0
- package/e2e/performance/timeline-stability/shell-matrix.spec.ts +255 -0
- package/e2e/performance/timeline-stability/tool-mutation.spec.ts +106 -0
- package/e2e/performance/timeline-stability/tools.spec.ts +198 -0
- package/e2e/performance/timeline-stability/transition-matrix.spec.ts +272 -0
- package/e2e/performance/unit/chrome-trace-write.test.ts +15 -0
- package/e2e/performance/unit/first-navigation-metrics.test.ts +32 -0
- package/e2e/performance/unit/mock-server.test.ts +46 -0
- package/e2e/performance/unit/navigation-milestones.test.ts +34 -0
- package/e2e/performance/unit/session-tab-repaint-probe.test.ts +42 -0
- package/e2e/performance/unit/session-tab-switch-metrics.test.ts +86 -0
- package/e2e/performance/unit/session-tab-switch-probe.test.ts +55 -0
- package/e2e/performance/unit/session-timeline-stream-probe.test.ts +14 -0
- package/e2e/performance/unit/session-timeline-visual-tracking.test.ts +16 -0
- package/e2e/performance/unit/timeline-test-helpers.test.ts +10 -0
- package/e2e/performance/unit/visual-stability.test.ts +392 -0
- package/e2e/regression/cross-server-tab-close.spec.ts +153 -0
- package/e2e/regression/file-browser-sidebar-tab-switch.spec.ts +150 -0
- package/e2e/regression/legacy-new-session.spec.ts +41 -0
- package/e2e/regression/new-session-panel-corner.spec.ts +83 -0
- package/e2e/regression/prompt-input-v2-command-draft.spec.ts +50 -0
- package/e2e/regression/prompt-thinking-level.spec.ts +84 -0
- package/e2e/regression/remote-session-settings.spec.ts +302 -0
- package/e2e/regression/remote-tab-busy.spec.ts +131 -0
- package/e2e/regression/review-image-flash.spec.ts +202 -0
- package/e2e/regression/review-line-comment.spec.ts +158 -0
- package/e2e/regression/review-open-file.spec.ts +163 -0
- package/e2e/regression/review-state-persistence.spec.ts +155 -0
- package/e2e/regression/review-tab-switch.spec.ts +147 -0
- package/e2e/regression/review-terminal-stacked.spec.ts +308 -0
- package/e2e/regression/session-list-path-loading.spec.ts +41 -0
- package/e2e/regression/session-request-docks.spec.ts +221 -0
- package/e2e/regression/session-timeline-accessibility.spec.ts +22 -0
- package/e2e/regression/session-timeline-collapse-state.spec.ts +439 -0
- package/e2e/regression/session-timeline-context-resize.spec.ts +374 -0
- package/e2e/regression/session-timeline-context-state.spec.ts +31 -0
- package/e2e/regression/session-timeline-file-projection.spec.ts +52 -0
- package/e2e/regression/session-timeline-file-state.spec.ts +94 -0
- package/e2e/regression/session-timeline-history-root.spec.ts +242 -0
- package/e2e/regression/session-timeline-lifecycle-state.spec.ts +111 -0
- package/e2e/regression/session-timeline-locale-projection.spec.ts +25 -0
- package/e2e/regression/session-timeline-projection.spec.ts +287 -0
- package/e2e/regression/session-timeline-reasoning-projection.spec.ts +93 -0
- package/e2e/regression/session-timeline-reducer-projection.spec.ts +43 -0
- package/e2e/regression/session-timeline-shell-outline.spec.ts +228 -0
- package/e2e/regression/session-timeline-tool-projection.spec.ts +99 -0
- package/e2e/regression/session-timeline-tool-state.spec.ts +77 -0
- package/e2e/regression/session-timeline-transport.spec.ts +116 -0
- package/e2e/regression/session-todo-dock-navigation.spec.ts +190 -0
- package/e2e/regression/subagent-child-navigation.spec.ts +203 -0
- package/e2e/regression/tab-navigate-mousedown.spec.ts +127 -0
- package/e2e/regression/terminal-composer-focus.spec.ts +227 -0
- package/e2e/regression/terminal-hidden.spec.ts +117 -0
- package/e2e/regression/terminal-tab-switch.spec.ts +165 -0
- package/e2e/reproduction/timeline-suspense/index.html +34 -0
- package/e2e/reproduction/timeline-suspense/main.tsx +315 -0
- package/e2e/reproduction/timeline-suspense/playwright.config.ts +34 -0
- package/e2e/reproduction/timeline-suspense/timeline-suspense.repro.ts +179 -0
- package/e2e/reproduction/timeline-suspense/vite.config.ts +7 -0
- package/e2e/smoke/session-timeline.fixture.ts +315 -0
- package/e2e/smoke/session-timeline.spec.ts +740 -0
- package/e2e/tsconfig.json +20 -0
- package/e2e/utils/errors.ts +18 -0
- package/e2e/utils/mock-server.ts +443 -0
- package/e2e/utils/sse-transport.ts +312 -0
- package/e2e/utils/visual-stability/analyzer.ts +209 -0
- package/e2e/utils/visual-stability/capture.ts +51 -0
- package/e2e/utils/visual-stability/index.ts +8 -0
- package/e2e/utils/visual-stability/invariant.ts +112 -0
- package/e2e/utils/visual-stability/model.ts +47 -0
- package/e2e/utils/visual-stability/probe.ts +226 -0
- package/e2e/utils/visual-stability/regions.ts +18 -0
- package/e2e/utils/visual-stability/reporter.ts +63 -0
- package/e2e/utils/visual-stability/scenario.ts +20 -0
- package/e2e/utils/visual-stability.ts +54 -0
- package/e2e/utils/waits.ts +11 -0
- package/happydom.ts +75 -0
- package/index.html +28 -0
- package/package.json +96 -0
- package/playwright.config.ts +45 -0
- package/public/_headers +17 -0
- package/public/apple-touch-icon-v3.png +1 -0
- package/public/apple-touch-icon.png +1 -0
- package/public/assets/Inter.ttf +0 -0
- package/public/assets/JetBrainsMonoNerdFontMono-Regular.woff2 +0 -0
- package/public/favicon-96x96-v3.png +1 -0
- package/public/favicon-96x96.png +1 -0
- package/public/favicon-v3.ico +1 -0
- package/public/favicon-v3.svg +1 -0
- package/public/favicon.ico +1 -0
- package/public/favicon.svg +1 -0
- package/public/oc-theme-preload.js +40 -0
- package/public/site.webmanifest +1 -0
- package/public/social-share-zen.png +1 -0
- package/public/social-share.png +1 -0
- package/public/web-app-manifest-192x192.png +1 -0
- package/public/web-app-manifest-512x512.png +1 -0
- package/src/addons/serialize.test.ts +327 -0
- package/src/addons/serialize.ts +642 -0
- package/src/app.tsx +659 -0
- package/src/assets/help/home.png +0 -0
- package/src/assets/help/introducing-tabs.mp4 +0 -0
- package/src/assets/help/placeholder.png +0 -0
- package/src/assets/help/tabs.png +0 -0
- package/src/components/command-palette.ts +281 -0
- package/src/components/command-tooltip-keybind.test.ts +22 -0
- package/src/components/command-tooltip-keybind.ts +11 -0
- package/src/components/debug-bar.tsx +550 -0
- package/src/components/dialog-command-palette-v2.css +220 -0
- package/src/components/dialog-command-palette-v2.tsx +342 -0
- package/src/components/dialog-connect-provider.stories.tsx +73 -0
- package/src/components/dialog-connect-provider.tsx +1178 -0
- package/src/components/dialog-custom-provider-form.ts +158 -0
- package/src/components/dialog-custom-provider.test.ts +80 -0
- package/src/components/dialog-custom-provider.tsx +330 -0
- package/src/components/dialog-edit-project-v2.tsx +156 -0
- package/src/components/dialog-edit-project.tsx +170 -0
- package/src/components/dialog-fork.tsx +104 -0
- package/src/components/dialog-manage-models.tsx +265 -0
- package/src/components/dialog-release-notes.tsx +144 -0
- package/src/components/dialog-select-directory-v2.css +107 -0
- package/src/components/dialog-select-directory-v2.tsx +378 -0
- package/src/components/dialog-select-directory.tsx +191 -0
- package/src/components/dialog-select-file.tsx +189 -0
- package/src/components/dialog-select-mcp.tsx +92 -0
- package/src/components/dialog-select-model-search.test.ts +19 -0
- package/src/components/dialog-select-model-search.ts +18 -0
- package/src/components/dialog-select-model-unpaid-v2.stories.tsx +55 -0
- package/src/components/dialog-select-model-unpaid-v2.tsx +175 -0
- package/src/components/dialog-select-model-unpaid.tsx +147 -0
- package/src/components/dialog-select-model.tsx +549 -0
- package/src/components/dialog-select-server.tsx +722 -0
- package/src/components/dialog-settings.tsx +94 -0
- package/src/components/dialog-usage-exceeded.tsx +44 -0
- package/src/components/directory-picker-domain.test.ts +248 -0
- package/src/components/directory-picker-domain.ts +407 -0
- package/src/components/directory-picker-policy.ts +7 -0
- package/src/components/directory-picker.test.ts +21 -0
- package/src/components/directory-picker.tsx +45 -0
- package/src/components/edit-project.ts +122 -0
- package/src/components/file-tree-v2-model.test.ts +74 -0
- package/src/components/file-tree-v2-model.ts +107 -0
- package/src/components/file-tree-v2.tsx +299 -0
- package/src/components/file-tree.test.ts +80 -0
- package/src/components/file-tree.tsx +509 -0
- package/src/components/help-button.tsx +148 -0
- package/src/components/link.tsx +26 -0
- package/src/components/model-tooltip.tsx +124 -0
- package/src/components/pierre-tree.test.ts +23 -0
- package/src/components/prompt-input/attachments.test.ts +108 -0
- package/src/components/prompt-input/attachments.ts +228 -0
- package/src/components/prompt-input/build-request-parts.test.ts +396 -0
- package/src/components/prompt-input/build-request-parts.ts +213 -0
- package/src/components/prompt-input/context-items.tsx +98 -0
- package/src/components/prompt-input/contracts.ts +57 -0
- package/src/components/prompt-input/drag-overlay.tsx +25 -0
- package/src/components/prompt-input/editor-dom.test.ts +99 -0
- package/src/components/prompt-input/editor-dom.ts +148 -0
- package/src/components/prompt-input/files.ts +98 -0
- package/src/components/prompt-input/history-store.ts +47 -0
- package/src/components/prompt-input/history.test.ts +153 -0
- package/src/components/prompt-input/history.ts +256 -0
- package/src/components/prompt-input/image-attachments.css +43 -0
- package/src/components/prompt-input/image-attachments.tsx +168 -0
- package/src/components/prompt-input/paste.ts +24 -0
- package/src/components/prompt-input/placeholder.test.ts +48 -0
- package/src/components/prompt-input/placeholder.ts +20 -0
- package/src/components/prompt-input/slash-popover.tsx +376 -0
- package/src/components/prompt-input/submission-state.ts +33 -0
- package/src/components/prompt-input/submit.test.ts +598 -0
- package/src/components/prompt-input/submit.ts +634 -0
- package/src/components/prompt-input/transient-state.ts +46 -0
- package/src/components/prompt-input-v2.tsx +592 -0
- package/src/components/prompt-input.stories.tsx +223 -0
- package/src/components/prompt-input.tsx +1790 -0
- package/src/components/prompt-project-selector.tsx +593 -0
- package/src/components/prompt-workspace-selector.tsx +128 -0
- package/src/components/server/server-row-menu.tsx +96 -0
- package/src/components/server/server-row.tsx +127 -0
- package/src/components/session/index.ts +7 -0
- package/src/components/session/open-in-app-v2.tsx +98 -0
- package/src/components/session/open-in-app.tsx +229 -0
- package/src/components/session/session-context-breakdown.test.ts +61 -0
- package/src/components/session/session-context-breakdown.ts +132 -0
- package/src/components/session/session-context-format.ts +20 -0
- package/src/components/session/session-context-metrics.test.ts +99 -0
- package/src/components/session/session-context-metrics.ts +65 -0
- package/src/components/session/session-context-tab.tsx +343 -0
- package/src/components/session/session-header.tsx +568 -0
- package/src/components/session/session-new-design-view.tsx +16 -0
- package/src/components/session/session-new-view.tsx +91 -0
- package/src/components/session/session-sortable-tab-v2.tsx +74 -0
- package/src/components/session/session-sortable-tab.tsx +78 -0
- package/src/components/session/session-sortable-terminal-tab-v2.tsx +284 -0
- package/src/components/session/session-sortable-terminal-tab.tsx +193 -0
- package/src/components/session-context-usage.tsx +169 -0
- package/src/components/settings-dialog.tsx +43 -0
- package/src/components/settings-general.tsx +794 -0
- package/src/components/settings-keybinds.tsx +553 -0
- package/src/components/settings-list.tsx +5 -0
- package/src/components/settings-models.tsx +149 -0
- package/src/components/settings-providers.tsx +264 -0
- package/src/components/settings-server-picker.tsx +106 -0
- package/src/components/settings-servers.tsx +33 -0
- package/src/components/settings-v2/dialog-server-v2.tsx +134 -0
- package/src/components/settings-v2/dialog-settings-v2.tsx +98 -0
- package/src/components/settings-v2/general.tsx +722 -0
- package/src/components/settings-v2/index.tsx +1 -0
- package/src/components/settings-v2/interface-transition.stories.tsx +76 -0
- package/src/components/settings-v2/interface-transition.tsx +54 -0
- package/src/components/settings-v2/models.tsx +138 -0
- package/src/components/settings-v2/parts/list.tsx +6 -0
- package/src/components/settings-v2/parts/row.tsx +20 -0
- package/src/components/settings-v2/providers.tsx +264 -0
- package/src/components/settings-v2/servers.tsx +139 -0
- package/src/components/settings-v2/settings-v2.css +675 -0
- package/src/components/status-popover-body.tsx +514 -0
- package/src/components/status-popover-indicator.test.ts +36 -0
- package/src/components/status-popover-indicator.ts +20 -0
- package/src/components/status-popover.tsx +190 -0
- package/src/components/terminal.tsx +759 -0
- package/src/components/titlebar-history.test.ts +63 -0
- package/src/components/titlebar-history.ts +57 -0
- package/src/components/titlebar-session-events.test.ts +32 -0
- package/src/components/titlebar-session-events.ts +35 -0
- package/src/components/titlebar-tab-gesture.test.ts +33 -0
- package/src/components/titlebar-tab-gesture.ts +17 -0
- package/src/components/titlebar-tab-nav.css +100 -0
- package/src/components/titlebar-tab-nav.tsx +429 -0
- package/src/components/titlebar-tab-popover.css +127 -0
- package/src/components/titlebar-tab-popover.tsx +92 -0
- package/src/components/titlebar-tab-strip.tsx +333 -0
- package/src/components/titlebar.css +77 -0
- package/src/components/titlebar.tsx +776 -0
- package/src/components/ui/drawer.tsx +119 -0
- package/src/components/updater-action.test.ts +26 -0
- package/src/components/updater-action.ts +51 -0
- package/src/components/virtual-scroll-element.test.ts +18 -0
- package/src/components/virtual-scroll-element.ts +4 -0
- package/src/components/windows-app-menu.tsx +131 -0
- package/src/constants/file-picker.ts +89 -0
- package/src/context/closed-tabs.ts +40 -0
- package/src/context/command-keybind.test.ts +69 -0
- package/src/context/command.test.ts +55 -0
- package/src/context/command.tsx +467 -0
- package/src/context/comments.test.ts +188 -0
- package/src/context/comments.tsx +261 -0
- package/src/context/directory-sync.ts +155 -0
- package/src/context/file/content-cache.ts +88 -0
- package/src/context/file/path.test.ts +360 -0
- package/src/context/file/path.ts +151 -0
- package/src/context/file/tree-store.ts +174 -0
- package/src/context/file/types.ts +41 -0
- package/src/context/file/view-cache.ts +147 -0
- package/src/context/file/watcher.test.ts +149 -0
- package/src/context/file/watcher.ts +53 -0
- package/src/context/file-content-eviction-accounting.test.ts +65 -0
- package/src/context/file.tsx +303 -0
- package/src/context/global-sync/bootstrap.test.ts +231 -0
- package/src/context/global-sync/bootstrap.ts +536 -0
- package/src/context/global-sync/child-store.test.ts +276 -0
- package/src/context/global-sync/child-store.ts +396 -0
- package/src/context/global-sync/event-reducer.test.ts +616 -0
- package/src/context/global-sync/event-reducer.ts +478 -0
- package/src/context/global-sync/eviction.ts +28 -0
- package/src/context/global-sync/home-session-index.test.ts +154 -0
- package/src/context/global-sync/home-session-index.ts +174 -0
- package/src/context/global-sync/mcp.test.ts +54 -0
- package/src/context/global-sync/mcp.ts +19 -0
- package/src/context/global-sync/queue.test.ts +46 -0
- package/src/context/global-sync/queue.ts +87 -0
- package/src/context/global-sync/session-cache.test.ts +104 -0
- package/src/context/global-sync/session-cache.ts +62 -0
- package/src/context/global-sync/session-load.ts +33 -0
- package/src/context/global-sync/session-trim.test.ts +59 -0
- package/src/context/global-sync/session-trim.ts +57 -0
- package/src/context/global-sync/types.ts +135 -0
- package/src/context/global-sync/utils.test.ts +133 -0
- package/src/context/global-sync/utils.ts +171 -0
- package/src/context/global.tsx +161 -0
- package/src/context/highlights.tsx +233 -0
- package/src/context/language.tsx +243 -0
- package/src/context/layout-helpers.ts +38 -0
- package/src/context/layout-scroll.test.ts +64 -0
- package/src/context/layout-scroll.ts +126 -0
- package/src/context/layout-tabs.test.ts +82 -0
- package/src/context/layout-tabs.ts +103 -0
- package/src/context/layout.test.ts +69 -0
- package/src/context/layout.tsx +1075 -0
- package/src/context/local-agent.test.ts +29 -0
- package/src/context/local-agent.ts +7 -0
- package/src/context/local.tsx +417 -0
- package/src/context/mcp.ts +19 -0
- package/src/context/model-variant.test.ts +86 -0
- package/src/context/model-variant.ts +52 -0
- package/src/context/models.tsx +173 -0
- package/src/context/notification.tsx +478 -0
- package/src/context/permission-auto-respond.test.ts +125 -0
- package/src/context/permission-auto-respond.ts +60 -0
- package/src/context/permission.tsx +484 -0
- package/src/context/platform.tsx +142 -0
- package/src/context/prompt-state.test.ts +29 -0
- package/src/context/prompt-state.ts +266 -0
- package/src/context/prompt.tsx +170 -0
- package/src/context/sdk.tsx +17 -0
- package/src/context/server-sdk.test.ts +196 -0
- package/src/context/server-sdk.tsx +444 -0
- package/src/context/server-session-v2-reducer.test.ts +156 -0
- package/src/context/server-session-v2-reducer.ts +502 -0
- package/src/context/server-session.test.ts +1638 -0
- package/src/context/server-session.ts +1425 -0
- package/src/context/server-sync.test.ts +231 -0
- package/src/context/server-sync.tsx +753 -0
- package/src/context/server.test.ts +245 -0
- package/src/context/server.tsx +360 -0
- package/src/context/settings.test.ts +79 -0
- package/src/context/settings.tsx +531 -0
- package/src/context/sync-optimistic.test.ts +123 -0
- package/src/context/sync.tsx +119 -0
- package/src/context/tab-memory.ts +36 -0
- package/src/context/tabs.test.ts +107 -0
- package/src/context/tabs.tsx +387 -0
- package/src/context/terminal-title.ts +24 -0
- package/src/context/terminal.test.ts +91 -0
- package/src/context/terminal.tsx +546 -0
- package/src/custom-elements.d.ts +1 -0
- package/src/desktop-menu.test.ts +13 -0
- package/src/desktop-menu.ts +223 -0
- package/src/entry.tsx +182 -0
- package/src/env.d.ts +31 -0
- package/src/hooks/provider-catalog.test.ts +59 -0
- package/src/hooks/provider-catalog.ts +27 -0
- package/src/hooks/use-providers.ts +71 -0
- package/src/i18n/ar.ts +1008 -0
- package/src/i18n/br.ts +1024 -0
- package/src/i18n/bs.ts +1100 -0
- package/src/i18n/da.ts +1092 -0
- package/src/i18n/de.ts +1037 -0
- package/src/i18n/en.ts +1102 -0
- package/src/i18n/es.ts +1108 -0
- package/src/i18n/fr.ts +1037 -0
- package/src/i18n/ja.ts +1016 -0
- package/src/i18n/ko.ts +1015 -0
- package/src/i18n/no.ts +1111 -0
- package/src/i18n/parity.test.ts +118 -0
- package/src/i18n/pl.ts +1024 -0
- package/src/i18n/ru.ts +1103 -0
- package/src/i18n/th.ts +1087 -0
- package/src/i18n/tr.ts +1106 -0
- package/src/i18n/uk.ts +1105 -0
- package/src/i18n/zh.ts +1078 -0
- package/src/i18n/zht.ts +1074 -0
- package/src/index.css +330 -0
- package/src/index.ts +30 -0
- package/src/pages/directory-layout.tsx +122 -0
- package/src/pages/error-description.test.ts +17 -0
- package/src/pages/error-description.ts +11 -0
- package/src/pages/error.tsx +372 -0
- package/src/pages/home/home-controller.ts +108 -0
- package/src/pages/home/home-projects-controller.tsx +128 -0
- package/src/pages/home/home-projects-view.tsx +615 -0
- package/src/pages/home/home-projects.tsx +40 -0
- package/src/pages/home/home-scroll-controller.ts +145 -0
- package/src/pages/home/home-session-search-controller.ts +114 -0
- package/src/pages/home/home-sessions-controller.tsx +314 -0
- package/src/pages/home/home-sessions-view.tsx +550 -0
- package/src/pages/home/home-sessions.tsx +48 -0
- package/src/pages/home/legacy-home.tsx +142 -0
- package/src/pages/home-session-archive.test.ts +51 -0
- package/src/pages/home-session-archive.ts +27 -0
- package/src/pages/home-session-open.test.ts +31 -0
- package/src/pages/home-session-open.ts +14 -0
- package/src/pages/home.tsx +50 -0
- package/src/pages/layout/deep-links.ts +50 -0
- package/src/pages/layout/helpers.test.ts +321 -0
- package/src/pages/layout/helpers.ts +150 -0
- package/src/pages/layout/inline-editor.tsx +126 -0
- package/src/pages/layout/project-avatar-state.ts +49 -0
- package/src/pages/layout/session-tab-avatar.tsx +60 -0
- package/src/pages/layout/sidebar-items.tsx +335 -0
- package/src/pages/layout/sidebar-project.tsx +377 -0
- package/src/pages/layout/sidebar-shell.tsx +125 -0
- package/src/pages/layout/sidebar-workspace.tsx +488 -0
- package/src/pages/layout-new.tsx +53 -0
- package/src/pages/layout.tsx +2441 -0
- package/src/pages/new-session.tsx +282 -0
- package/src/pages/session/composer/index.ts +4 -0
- package/src/pages/session/composer/prompt-model-selection.ts +133 -0
- package/src/pages/session/composer/session-composer-controls.ts +129 -0
- package/src/pages/session/composer/session-composer-region-controller.ts +145 -0
- package/src/pages/session/composer/session-composer-region.tsx +168 -0
- package/src/pages/session/composer/session-composer-state.test.ts +138 -0
- package/src/pages/session/composer/session-composer-state.ts +204 -0
- package/src/pages/session/composer/session-followup-dock.tsx +109 -0
- package/src/pages/session/composer/session-permission-dock.tsx +74 -0
- package/src/pages/session/composer/session-question-dock.tsx +640 -0
- package/src/pages/session/composer/session-request-tree.ts +52 -0
- package/src/pages/session/composer/session-revert-dock.stories.tsx +124 -0
- package/src/pages/session/composer/session-revert-dock.tsx +188 -0
- package/src/pages/session/composer/session-todo-dock.tsx +277 -0
- package/src/pages/session/composer/todo-panel-motion.stories.tsx +622 -0
- package/src/pages/session/file-tab-scroll.test.ts +40 -0
- package/src/pages/session/file-tab-scroll.ts +67 -0
- package/src/pages/session/file-tabs.tsx +800 -0
- package/src/pages/session/handoff.ts +36 -0
- package/src/pages/session/helpers.test.ts +214 -0
- package/src/pages/session/helpers.ts +209 -0
- package/src/pages/session/message-gesture.test.ts +62 -0
- package/src/pages/session/message-gesture.ts +21 -0
- package/src/pages/session/message-id-from-hash.ts +6 -0
- package/src/pages/session/new-session-layout.ts +2 -0
- package/src/pages/session/review-tab.tsx +172 -0
- package/src/pages/session/session-layout.ts +30 -0
- package/src/pages/session/session-lineage.ts +69 -0
- package/src/pages/session/session-model-helpers.test.ts +151 -0
- package/src/pages/session/session-model-helpers.ts +63 -0
- package/src/pages/session/session-ownership.ts +37 -0
- package/src/pages/session/session-panel-layout.test.ts +19 -0
- package/src/pages/session/session-panel-layout.ts +6 -0
- package/src/pages/session/session-panel-width.test.ts +52 -0
- package/src/pages/session/session-panel-width.ts +19 -0
- package/src/pages/session/session-side-panel.tsx +865 -0
- package/src/pages/session/terminal-label.ts +16 -0
- package/src/pages/session/terminal-panel-v2.tsx +352 -0
- package/src/pages/session/terminal-panel.test.ts +25 -0
- package/src/pages/session/terminal-panel.tsx +343 -0
- package/src/pages/session/timeline/measure.test.ts +30 -0
- package/src/pages/session/timeline/measure.ts +5 -0
- package/src/pages/session/timeline/message-timeline.tsx +1864 -0
- package/src/pages/session/timeline/model.test.ts +95 -0
- package/src/pages/session/timeline/model.ts +128 -0
- package/src/pages/session/timeline/observe-element-offset.test.ts +199 -0
- package/src/pages/session/timeline/observe-element-offset.ts +73 -0
- package/src/pages/session/timeline/projection.test.ts +96 -0
- package/src/pages/session/timeline/projection.ts +81 -0
- package/src/pages/session/timeline/row-reconciliation.ts +56 -0
- package/src/pages/session/timeline/rows-current.test.ts +170 -0
- package/src/pages/session/timeline/rows.ts +344 -0
- package/src/pages/session/timeline/summary-diffs.test.ts +42 -0
- package/src/pages/session/timeline/summary-diffs.ts +20 -0
- package/src/pages/session/timeline/timeline-row.ts +80 -0
- package/src/pages/session/timeline/virtual-items.ts +3 -0
- package/src/pages/session/usage-exceeded-dialogs.tsx +104 -0
- package/src/pages/session/use-composer-commands.tsx +83 -0
- package/src/pages/session/use-session-commands.tsx +606 -0
- package/src/pages/session/use-session-hash-scroll.test.ts +16 -0
- package/src/pages/session/use-session-hash-scroll.ts +202 -0
- package/src/pages/session/v2/review-diff-kinds.test.ts +70 -0
- package/src/pages/session/v2/review-diff-kinds.ts +62 -0
- package/src/pages/session/v2/review-panel-v2-state.ts +41 -0
- package/src/pages/session/v2/review-panel-v2.tsx +255 -0
- package/src/pages/session/v2/session-file-browser-tab.tsx +181 -0
- package/src/pages/session/v2/session-file-list-v2.tsx +166 -0
- package/src/pages/session.tsx +2385 -0
- package/src/sst-env.d.ts +12 -0
- package/src/theme-preload.test.ts +46 -0
- package/src/updater.ts +17 -0
- package/src/utils/agent.ts +44 -0
- package/src/utils/aim.ts +138 -0
- package/src/utils/base64.ts +10 -0
- package/src/utils/comment-note.ts +88 -0
- package/src/utils/diffs.test.ts +75 -0
- package/src/utils/diffs.ts +50 -0
- package/src/utils/file-manager.ts +24 -0
- package/src/utils/id.ts +93 -0
- package/src/utils/notification-click.test.ts +27 -0
- package/src/utils/notification-click.ts +13 -0
- package/src/utils/path-key.ts +24 -0
- package/src/utils/persist.test.ts +211 -0
- package/src/utils/persist.ts +661 -0
- package/src/utils/prompt.test.ts +44 -0
- package/src/utils/prompt.ts +203 -0
- package/src/utils/refcount.test.ts +49 -0
- package/src/utils/refcount.ts +32 -0
- package/src/utils/runtime-adapters.test.ts +64 -0
- package/src/utils/runtime-adapters.ts +39 -0
- package/src/utils/same.ts +6 -0
- package/src/utils/scoped-cache.test.ts +69 -0
- package/src/utils/scoped-cache.ts +104 -0
- package/src/utils/search-keydown.ts +116 -0
- package/src/utils/server-compat.test.ts +193 -0
- package/src/utils/server-compat.ts +512 -0
- package/src/utils/server-errors.test.ts +175 -0
- package/src/utils/server-errors.ts +109 -0
- package/src/utils/server-health.test.ts +178 -0
- package/src/utils/server-health.ts +172 -0
- package/src/utils/server-protocol.test.ts +40 -0
- package/src/utils/server-protocol.ts +35 -0
- package/src/utils/server-scope.test.ts +61 -0
- package/src/utils/server-scope.ts +73 -0
- package/src/utils/server.test.ts +23 -0
- package/src/utils/server.ts +62 -0
- package/src/utils/session-message.test.ts +214 -0
- package/src/utils/session-message.ts +355 -0
- package/src/utils/session-route.test.ts +71 -0
- package/src/utils/session-route.ts +39 -0
- package/src/utils/session-title.ts +7 -0
- package/src/utils/session.test.ts +94 -0
- package/src/utils/session.ts +37 -0
- package/src/utils/solid-dnd.tsx +49 -0
- package/src/utils/sound.ts +102 -0
- package/src/utils/terminal-websocket-url.test.ts +80 -0
- package/src/utils/terminal-websocket-url.ts +35 -0
- package/src/utils/terminal-writer.test.ts +64 -0
- package/src/utils/terminal-writer.ts +65 -0
- package/src/utils/time.ts +22 -0
- package/src/utils/toast.tsx +34 -0
- package/src/utils/uuid.test.ts +78 -0
- package/src/utils/uuid.ts +12 -0
- package/src/utils/worktree.test.ts +58 -0
- package/src/utils/worktree.ts +76 -0
- package/src/wsl/add-server-probes.ts +57 -0
- package/src/wsl/context.tsx +36 -0
- package/src/wsl/dialog-add-server.tsx +463 -0
- package/src/wsl/dialog-add-wsl-server.css +392 -0
- package/src/wsl/settings-model.test.ts +231 -0
- package/src/wsl/settings-model.ts +341 -0
- package/src/wsl/settings.tsx +173 -0
- package/src/wsl/types.ts +85 -0
- package/sst-env.d.ts +10 -0
- package/test-browser/command-palette.test.ts +78 -0
- package/test-browser/motion-spring.test.ts +20 -0
- package/test-browser/prompt-attachments.test.ts +90 -0
- package/test-browser/prompt-persistence.test.ts +71 -0
- package/test-browser/prompt-scope.test.ts +14 -0
- package/test-browser/prompt-submission-state.test.ts +73 -0
- package/test-browser/prompt-transient-state.test.ts +38 -0
- package/test-browser/review-panel-v2-state.test.ts +65 -0
- package/test-browser/session-lineage.test.ts +231 -0
- package/test-browser/session-ownership.test.ts +45 -0
- package/test-browser/solid-virtual.test.ts +112 -0
- package/test-browser/toast-owner.test.ts +26 -0
- package/tsconfig.json +26 -0
- package/vendor/opencode-ai-client-1.17.13.tgz +0 -0
- package/vite.config.ts +33 -0
- package/vite.js +48 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Binary } from "@neurocode-ai/core/util/binary"
|
|
2
|
+
import { createMemo } from "solid-js"
|
|
3
|
+
import { useServerSync } from "./server-sync"
|
|
4
|
+
import { useSDK } from "./sdk"
|
|
5
|
+
import type { Message, Part } from "@neurocode-ai/sdk/v2/client"
|
|
6
|
+
|
|
7
|
+
const SKIP_PARTS = new Set(["patch", "step-start", "step-finish"])
|
|
8
|
+
|
|
9
|
+
function sortParts(parts: Part[]) {
|
|
10
|
+
return parts.filter((part) => !!part?.id).sort((a, b) => cmp(a.id, b.id))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const cmp = (a: string, b: string) => (a < b ? -1 : a > b ? 1 : 0)
|
|
14
|
+
|
|
15
|
+
type OptimisticStore = {
|
|
16
|
+
message: Record<string, Message[] | undefined>
|
|
17
|
+
part: Record<string, Part[] | undefined>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type OptimisticAddInput = {
|
|
21
|
+
sessionID: string
|
|
22
|
+
message: Message
|
|
23
|
+
parts: Part[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type OptimisticRemoveInput = {
|
|
27
|
+
sessionID: string
|
|
28
|
+
messageID: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type OptimisticItem = {
|
|
32
|
+
message: Message
|
|
33
|
+
parts: Part[]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type MessagePage = {
|
|
37
|
+
session: Message[]
|
|
38
|
+
part: { id: string; part: Part[] }[]
|
|
39
|
+
cursor?: string
|
|
40
|
+
complete: boolean
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const hasParts = (parts: Part[] | undefined, want: Part[]) => {
|
|
44
|
+
if (!parts) return want.length === 0
|
|
45
|
+
return want.every((part) => Binary.search(parts, part.id, (item) => item.id).found)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const mergeParts = (parts: Part[] | undefined, want: Part[]) => {
|
|
49
|
+
if (!parts) return sortParts(want)
|
|
50
|
+
const next = [...parts]
|
|
51
|
+
let changed = false
|
|
52
|
+
for (const part of want) {
|
|
53
|
+
const result = Binary.search(next, part.id, (item) => item.id)
|
|
54
|
+
if (result.found) continue
|
|
55
|
+
next.splice(result.index, 0, part)
|
|
56
|
+
changed = true
|
|
57
|
+
}
|
|
58
|
+
if (!changed) return parts
|
|
59
|
+
return next
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function mergeOptimisticPage(page: MessagePage, items: OptimisticItem[]) {
|
|
63
|
+
if (items.length === 0) return { ...page, confirmed: [] as string[] }
|
|
64
|
+
|
|
65
|
+
const session = [...page.session]
|
|
66
|
+
const part = new Map(page.part.map((item) => [item.id, sortParts(item.part)]))
|
|
67
|
+
const confirmed: string[] = []
|
|
68
|
+
|
|
69
|
+
for (const item of items) {
|
|
70
|
+
const result = Binary.search(session, item.message.id, (message) => message.id)
|
|
71
|
+
const found = result.found
|
|
72
|
+
if (!found) session.splice(result.index, 0, item.message)
|
|
73
|
+
|
|
74
|
+
const current = part.get(item.message.id)
|
|
75
|
+
if (found && hasParts(current, item.parts)) {
|
|
76
|
+
confirmed.push(item.message.id)
|
|
77
|
+
continue
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
part.set(item.message.id, mergeParts(current, item.parts))
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
cursor: page.cursor,
|
|
85
|
+
complete: page.complete,
|
|
86
|
+
session,
|
|
87
|
+
part: [...part.entries()].sort((a, b) => cmp(a[0], b[0])).map(([id, part]) => ({ id, part })),
|
|
88
|
+
confirmed,
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function applyOptimisticAdd(draft: OptimisticStore, input: OptimisticAddInput) {
|
|
93
|
+
const messages = draft.message[input.sessionID]
|
|
94
|
+
if (messages) {
|
|
95
|
+
const result = Binary.search(messages, input.message.id, (m) => m.id)
|
|
96
|
+
messages.splice(result.index, 0, input.message)
|
|
97
|
+
} else {
|
|
98
|
+
draft.message[input.sessionID] = [input.message]
|
|
99
|
+
}
|
|
100
|
+
draft.part[input.message.id] = sortParts(input.parts)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function applyOptimisticRemove(draft: OptimisticStore, input: OptimisticRemoveInput) {
|
|
104
|
+
const messages = draft.message[input.sessionID]
|
|
105
|
+
if (messages) {
|
|
106
|
+
const result = Binary.search(messages, input.messageID, (m) => m.id)
|
|
107
|
+
if (result.found) messages.splice(result.index, 1)
|
|
108
|
+
}
|
|
109
|
+
delete draft.part[input.messageID]
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export const useSync = () => {
|
|
113
|
+
const serverSync = useServerSync()
|
|
114
|
+
const sdk = useSDK()
|
|
115
|
+
|
|
116
|
+
return createMemo(() => serverSync().ensureDirSyncContext(sdk().directory))
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export type DirectorySync = ReturnType<ReturnType<typeof useSync>>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createRoot, type Owner } from "solid-js"
|
|
2
|
+
|
|
3
|
+
type Entry = {
|
|
4
|
+
value: unknown
|
|
5
|
+
dispose: VoidFunction
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function createTabMemory(owner: Owner | null) {
|
|
9
|
+
const entries = new Map<string, Map<string, Entry>>()
|
|
10
|
+
|
|
11
|
+
const remove = (key: string) => {
|
|
12
|
+
const state = entries.get(key)
|
|
13
|
+
if (!state) return
|
|
14
|
+
for (const entry of state.values()) entry.dispose()
|
|
15
|
+
entries.delete(key)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
get<T>(key: string, name: string) {
|
|
20
|
+
return entries.get(key)?.get(name)?.value as T | undefined
|
|
21
|
+
},
|
|
22
|
+
ensure<T>(key: string, name: string, init: () => T) {
|
|
23
|
+
const state = entries.get(key) ?? new Map<string, Entry>()
|
|
24
|
+
if (!entries.has(key)) entries.set(key, state)
|
|
25
|
+
const existing = state.get(name)
|
|
26
|
+
if (existing) return existing.value as T
|
|
27
|
+
const entry = createRoot((dispose) => ({ value: init(), dispose }), owner)
|
|
28
|
+
state.set(name, entry)
|
|
29
|
+
return entry.value
|
|
30
|
+
},
|
|
31
|
+
remove,
|
|
32
|
+
dispose() {
|
|
33
|
+
for (const key of entries.keys()) remove(key)
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test"
|
|
2
|
+
import { createRoot, getOwner, onCleanup } from "solid-js"
|
|
3
|
+
import { createTabMemory } from "./tab-memory"
|
|
4
|
+
import { nextTabAfterClose, pushClosedTab, removeClosedTabs, takeClosedTab, type ClosedTab } from "./closed-tabs"
|
|
5
|
+
import type { SessionTab, Tab } from "./tabs"
|
|
6
|
+
import type { ServerConnection } from "./server"
|
|
7
|
+
|
|
8
|
+
const server = "local\nhttp://localhost:4096" as ServerConnection.Key
|
|
9
|
+
|
|
10
|
+
function sessionTab(sessionId: string): SessionTab {
|
|
11
|
+
return { type: "session", server, sessionId }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
describe("tab memory", () => {
|
|
15
|
+
test("keeps state until its tab is removed", () => {
|
|
16
|
+
createRoot((dispose) => {
|
|
17
|
+
const memory = createTabMemory(getOwner())
|
|
18
|
+
let disposed = 0
|
|
19
|
+
const first = memory.ensure("tab", "prompt", () => {
|
|
20
|
+
onCleanup(() => disposed++)
|
|
21
|
+
return { value: "prompt" }
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
expect(memory.ensure("tab", "prompt", () => ({ value: "other" }))).toBe(first)
|
|
25
|
+
expect(memory.get<typeof first>("tab", "prompt")).toBe(first)
|
|
26
|
+
expect(memory.get("missing", "prompt")).toBeUndefined()
|
|
27
|
+
expect(memory.ensure("other", "prompt", () => ({ value: "other" }))).not.toBe(first)
|
|
28
|
+
|
|
29
|
+
memory.remove("tab")
|
|
30
|
+
expect(disposed).toBe(1)
|
|
31
|
+
expect(memory.ensure("tab", "prompt", () => ({ value: "new" }))).not.toBe(first)
|
|
32
|
+
dispose()
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
describe("closed tab stack", () => {
|
|
38
|
+
test("records session tabs with their index", () => {
|
|
39
|
+
const stack = pushClosedTab([], sessionTab("a"), 2)
|
|
40
|
+
|
|
41
|
+
expect(stack).toEqual([{ tab: sessionTab("a"), index: 2 }])
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
test("ignores draft tabs", () => {
|
|
45
|
+
const draft: Tab = { type: "draft", draftID: "d1", server, directory: "/tmp" }
|
|
46
|
+
|
|
47
|
+
expect(pushClosedTab([], draft, 0)).toEqual([])
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
test("caps the stack size", () => {
|
|
51
|
+
const stack = Array.from({ length: 30 }, (_, i) => i).reduce<ClosedTab[]>(
|
|
52
|
+
(acc, i) => pushClosedTab(acc, sessionTab(`s${i}`), i),
|
|
53
|
+
[],
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
expect(stack).toHaveLength(25)
|
|
57
|
+
expect(stack[0]?.tab.sessionId).toBe("s5")
|
|
58
|
+
expect(stack.at(-1)?.tab.sessionId).toBe("s29")
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
test("pops the most recently closed tab", () => {
|
|
62
|
+
const stack = [
|
|
63
|
+
{ tab: sessionTab("a"), index: 0 },
|
|
64
|
+
{ tab: sessionTab("b"), index: 1 },
|
|
65
|
+
]
|
|
66
|
+
const result = takeClosedTab(stack, [])
|
|
67
|
+
|
|
68
|
+
expect(result.entry?.tab.sessionId).toBe("b")
|
|
69
|
+
expect(result.stack).toEqual([{ tab: sessionTab("a"), index: 0 }])
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
test("skips entries whose tab is already open", () => {
|
|
73
|
+
const stack = [
|
|
74
|
+
{ tab: sessionTab("a"), index: 0 },
|
|
75
|
+
{ tab: sessionTab("b"), index: 1 },
|
|
76
|
+
]
|
|
77
|
+
const result = takeClosedTab(stack, [sessionTab("b")])
|
|
78
|
+
|
|
79
|
+
expect(result.entry?.tab.sessionId).toBe("a")
|
|
80
|
+
expect(result.stack).toEqual([])
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
test("returns no entry when everything is open or empty", () => {
|
|
84
|
+
expect(takeClosedTab([], []).entry).toBeUndefined()
|
|
85
|
+
|
|
86
|
+
const result = takeClosedTab([{ tab: sessionTab("a"), index: 0 }], [sessionTab("a")])
|
|
87
|
+
expect(result.entry).toBeUndefined()
|
|
88
|
+
expect(result.stack).toEqual([])
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
test("purges removed sessions", () => {
|
|
92
|
+
const stack = [
|
|
93
|
+
{ tab: sessionTab("a"), index: 0 },
|
|
94
|
+
{ tab: sessionTab("b"), index: 1 },
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
expect(removeClosedTabs(stack, server, ["a"])).toEqual([{ tab: sessionTab("b"), index: 1 }])
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
test("does not navigate when a background tab closes", () => {
|
|
101
|
+
const tabs = [sessionTab("a"), sessionTab("b"), sessionTab("c")]
|
|
102
|
+
|
|
103
|
+
expect(nextTabAfterClose(tabs, 1, false)).toBeUndefined()
|
|
104
|
+
expect(nextTabAfterClose(tabs, 1, true)).toEqual(sessionTab("c"))
|
|
105
|
+
expect(nextTabAfterClose([sessionTab("a")], 0, true)).toBeNull()
|
|
106
|
+
})
|
|
107
|
+
})
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
import type { Session } from "@neurocode-ai/sdk/v2/client"
|
|
2
|
+
import { createSimpleContext } from "@neurocode-ai/ui/context"
|
|
3
|
+
import { createStore, produce } from "solid-js/store"
|
|
4
|
+
import { Persist, persisted, removePersisted, draftPersistedKeys } from "@/utils/persist"
|
|
5
|
+
import { ServerConnection, useServer } from "./server"
|
|
6
|
+
import { createEffect, getOwner, onCleanup, startTransition } from "solid-js"
|
|
7
|
+
import { useLocation, useNavigate, useParams } from "@solidjs/router"
|
|
8
|
+
import { usePlatform } from "./platform"
|
|
9
|
+
import { uuid } from "@/utils/uuid"
|
|
10
|
+
import { SessionTabsRemovedDetail } from "@/components/titlebar-session-events"
|
|
11
|
+
import { sessionHref } from "@/utils/session-route"
|
|
12
|
+
import { createTabMemory } from "./tab-memory"
|
|
13
|
+
import { nextTabAfterClose, pushClosedTab, removeClosedTabs, takeClosedTab, type ClosedTab } from "./closed-tabs"
|
|
14
|
+
import { createDraftPromptSession, type PromptModel } from "./prompt-state"
|
|
15
|
+
|
|
16
|
+
export type SessionTab = {
|
|
17
|
+
type: "session"
|
|
18
|
+
server: ServerConnection.Key
|
|
19
|
+
sessionId: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type DraftTab = {
|
|
23
|
+
type: "draft"
|
|
24
|
+
draftID: string
|
|
25
|
+
server: ServerConnection.Key
|
|
26
|
+
directory: string
|
|
27
|
+
worktree?: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type Tab = SessionTab | DraftTab
|
|
31
|
+
|
|
32
|
+
export type TabInfo = {
|
|
33
|
+
title?: string
|
|
34
|
+
directory?: string
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type RecentTab = {
|
|
38
|
+
key?: string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const draftHref = (draftID: string) => `/new-session?draftId=${encodeURIComponent(draftID)}`
|
|
42
|
+
|
|
43
|
+
export const tabHref = (tab: Tab) =>
|
|
44
|
+
tab.type === "draft" ? draftHref(tab.draftID) : sessionHref(tab.server, tab.sessionId)
|
|
45
|
+
|
|
46
|
+
export const tabKey = (tab: Tab) => (tab.type === "draft" ? `draft:${tab.draftID}` : `${tab.server}\n${tabHref(tab)}`)
|
|
47
|
+
|
|
48
|
+
export function sessionHasOpenTab(tabs: Tab[], server: ServerConnection.Key, session: Session) {
|
|
49
|
+
return tabs.some((tab) => tab.type === "session" && tab.server === server && tab.sessionId === session.id)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const { use: useTabs, provider: TabsProvider } = createSimpleContext({
|
|
53
|
+
name: "Tabs",
|
|
54
|
+
gate: false,
|
|
55
|
+
init: () => {
|
|
56
|
+
const server = useServer()
|
|
57
|
+
const platform = usePlatform()
|
|
58
|
+
const fallback = server.key
|
|
59
|
+
const [store, setStore, _, ready] = persisted(
|
|
60
|
+
{
|
|
61
|
+
...Persist.window("tabs"),
|
|
62
|
+
migrate: (value: unknown) => {
|
|
63
|
+
if (!Array.isArray(value)) return value
|
|
64
|
+
return value.map((tab) => {
|
|
65
|
+
if (!tab || typeof tab !== "object" || "server" in tab) return tab
|
|
66
|
+
return { ...tab, server: fallback }
|
|
67
|
+
})
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
createStore<Tab[]>([]),
|
|
71
|
+
)
|
|
72
|
+
const [recent, setRecent, , recentReady] = persisted(Persist.window("tabs.recent"), createStore<RecentTab>({}))
|
|
73
|
+
const [info, setInfo] = persisted(Persist.window("tabs.info"), createStore<Record<string, TabInfo>>({}))
|
|
74
|
+
const [closed, setClosed, , closedReady] = persisted(Persist.window("tabs.closed"), createStore<ClosedTab[]>([]))
|
|
75
|
+
|
|
76
|
+
const params = useParams()
|
|
77
|
+
const navigate = useNavigate()
|
|
78
|
+
const location = useLocation()
|
|
79
|
+
const memory = createTabMemory(getOwner())
|
|
80
|
+
|
|
81
|
+
const closing = new Set<string>()
|
|
82
|
+
let recentWrite = 0
|
|
83
|
+
let recentValue: string | undefined
|
|
84
|
+
|
|
85
|
+
const recentKey = () => (recentWrite ? recentValue : recent.key)
|
|
86
|
+
|
|
87
|
+
const setRecentKey = (key: string | undefined) => {
|
|
88
|
+
const write = ++recentWrite
|
|
89
|
+
recentValue = key
|
|
90
|
+
if (recentReady()) {
|
|
91
|
+
setRecent("key", key)
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
void recentReady.promise?.then(() => {
|
|
95
|
+
if (write === recentWrite) setRecent("key", key)
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const updateClosed = (update: (stack: ClosedTab[]) => ClosedTab[]) => {
|
|
100
|
+
const apply = () => setClosed((stack) => update(stack))
|
|
101
|
+
if (closedReady()) {
|
|
102
|
+
apply()
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
void closedReady.promise?.then(apply)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const removeDraftPersisted = (draftID: string) => {
|
|
109
|
+
for (const key of draftPersistedKeys()) removePersisted(Persist.draft(draftID, key), platform)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const removeInfo = (key: string) => {
|
|
113
|
+
if (!info[key]) return
|
|
114
|
+
setInfo(
|
|
115
|
+
produce((draft) => {
|
|
116
|
+
delete draft[key]
|
|
117
|
+
}),
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
onCleanup(memory.dispose)
|
|
122
|
+
|
|
123
|
+
createEffect(() => {
|
|
124
|
+
if (!ready() || !recentReady()) return
|
|
125
|
+
const servers = new Set(server.list.map(ServerConnection.key))
|
|
126
|
+
const next = store.filter((tab) => servers.has(tab.server))
|
|
127
|
+
if (next.length !== store.length) {
|
|
128
|
+
for (const tab of store) {
|
|
129
|
+
if (!servers.has(tab.server)) {
|
|
130
|
+
const key = tabKey(tab)
|
|
131
|
+
memory.remove(key)
|
|
132
|
+
removeInfo(key)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
setStore(() => next)
|
|
136
|
+
}
|
|
137
|
+
if (recent.key && !next.some((tab) => tabKey(tab) === recent.key)) setRecentKey(undefined)
|
|
138
|
+
const keys = new Set(next.map(tabKey))
|
|
139
|
+
for (const key of Object.keys(info)) {
|
|
140
|
+
if (!keys.has(key)) removeInfo(key)
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
createEffect(() => {
|
|
145
|
+
if (!closedReady()) return
|
|
146
|
+
const servers = new Set(server.list.map(ServerConnection.key))
|
|
147
|
+
const next = closed.filter((entry) => servers.has(entry.tab.server))
|
|
148
|
+
if (next.length !== closed.length) setClosed(() => next)
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
const navigateTab = (tab: Tab) => {
|
|
152
|
+
const href = tabHref(tab)
|
|
153
|
+
setRecentKey(tabKey(tab))
|
|
154
|
+
navigate(href)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const removeTab = (index: number) => {
|
|
158
|
+
const tab = store[index]
|
|
159
|
+
if (!tab) return
|
|
160
|
+
const key = tabKey(tab)
|
|
161
|
+
const draftID = tab.type === "draft" ? tab.draftID : undefined
|
|
162
|
+
const nextTab = nextTabAfterClose(store, index, recentKey() === key && location.pathname !== "/")
|
|
163
|
+
closing.add(key)
|
|
164
|
+
void startTransition(() => {
|
|
165
|
+
setStore(
|
|
166
|
+
produce((tabs) => {
|
|
167
|
+
tabs.splice(index, 1)
|
|
168
|
+
}),
|
|
169
|
+
)
|
|
170
|
+
if (nextTab === null) {
|
|
171
|
+
setRecentKey(undefined)
|
|
172
|
+
navigate("/")
|
|
173
|
+
}
|
|
174
|
+
if (nextTab) navigateTab(nextTab)
|
|
175
|
+
}).finally(() => closing.delete(key))
|
|
176
|
+
memory.remove(key)
|
|
177
|
+
removeInfo(key)
|
|
178
|
+
if (draftID) removeDraftPersisted(draftID)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const actions = {
|
|
182
|
+
addSessionTab: (tab: Omit<SessionTab, "type">) => {
|
|
183
|
+
const next = { type: "session" as const, ...tab }
|
|
184
|
+
const existing = store.find((item) => tabKey(item) === tabKey(next))
|
|
185
|
+
if (existing) return existing
|
|
186
|
+
void startTransition(() => {
|
|
187
|
+
setStore(
|
|
188
|
+
produce((tabs) => {
|
|
189
|
+
if (tabs.some((item) => tabKey(item) === tabKey(next))) return
|
|
190
|
+
tabs.push(next)
|
|
191
|
+
}),
|
|
192
|
+
)
|
|
193
|
+
})
|
|
194
|
+
return next
|
|
195
|
+
},
|
|
196
|
+
reorder(keys: string[]) {
|
|
197
|
+
setStore(
|
|
198
|
+
produce((tabs) => {
|
|
199
|
+
const byKey = new Map(tabs.map((tab) => [tabKey(tab), tab]))
|
|
200
|
+
const next = keys.map((key) => byKey.get(key)).filter((tab): tab is Tab => !!tab)
|
|
201
|
+
if (next.length !== tabs.length) return
|
|
202
|
+
tabs.splice(0, tabs.length, ...next)
|
|
203
|
+
}),
|
|
204
|
+
)
|
|
205
|
+
},
|
|
206
|
+
draft(draftID: string) {
|
|
207
|
+
const tab = store.find((item) => item.type === "draft" && item.draftID === draftID)
|
|
208
|
+
if (!tab || tab.type !== "draft") throw new Error(`Draft not found: ${draftID}`)
|
|
209
|
+
return tab
|
|
210
|
+
},
|
|
211
|
+
async newDraft(draft: Omit<DraftTab, "type" | "draftID">, prompt?: string, model?: PromptModel) {
|
|
212
|
+
const draftID = uuid()
|
|
213
|
+
const tab = { type: "draft" as const, draftID, ...draft }
|
|
214
|
+
memory.ensure(tabKey(tab), "prompt", () => createDraftPromptSession(draftID, { prompt, model }))
|
|
215
|
+
await startTransition(() => {
|
|
216
|
+
setStore(
|
|
217
|
+
produce((tabs) => {
|
|
218
|
+
tabs.push(tab)
|
|
219
|
+
}),
|
|
220
|
+
)
|
|
221
|
+
navigate(draftHref(draftID))
|
|
222
|
+
})
|
|
223
|
+
return tab
|
|
224
|
+
},
|
|
225
|
+
updateDraft(draftID: string, draft: Partial<Omit<DraftTab, "type" | "draftID">>) {
|
|
226
|
+
void startTransition(() => {
|
|
227
|
+
setStore(
|
|
228
|
+
(tab) => tab.type === "draft" && tab.draftID === draftID,
|
|
229
|
+
produce((tab) => Object.assign(tab, draft)),
|
|
230
|
+
)
|
|
231
|
+
})
|
|
232
|
+
},
|
|
233
|
+
promoteDraft(draftID: string, session: Omit<SessionTab, "type">) {
|
|
234
|
+
// Keep the replacement and navigation atomic so /new-session never renders
|
|
235
|
+
// after its backing draft tab has been removed from the store.
|
|
236
|
+
const active = location.pathname === "/new-session" && location.query.draftId === draftID
|
|
237
|
+
const next = { type: "session" as const, ...session }
|
|
238
|
+
void startTransition(() => {
|
|
239
|
+
setStore(
|
|
240
|
+
produce((tabs) => {
|
|
241
|
+
const index = tabs.findIndex((tab) => tab.type === "draft" && tab.draftID === draftID)
|
|
242
|
+
if (index !== -1) tabs[index] = next
|
|
243
|
+
}),
|
|
244
|
+
)
|
|
245
|
+
if (recent.key === `draft:${draftID}`) setRecentKey(tabKey(next))
|
|
246
|
+
if (active) navigateTab(next)
|
|
247
|
+
})
|
|
248
|
+
memory.remove(`draft:${draftID}`)
|
|
249
|
+
removeDraftPersisted(draftID)
|
|
250
|
+
},
|
|
251
|
+
removeTab,
|
|
252
|
+
// User-initiated close: records the tab so it can be reopened.
|
|
253
|
+
// Cleanup paths (missing sessions, archive, server removal) go through
|
|
254
|
+
// removeTab and friends directly and are not recorded.
|
|
255
|
+
closeTab(index: number) {
|
|
256
|
+
const tab = store[index]
|
|
257
|
+
if (!tab) return
|
|
258
|
+
if (tab.type === "session") updateClosed((stack) => pushClosedTab(stack, tab, index))
|
|
259
|
+
removeTab(index)
|
|
260
|
+
},
|
|
261
|
+
reopenClosedTab() {
|
|
262
|
+
if (!closedReady()) {
|
|
263
|
+
void closedReady.promise?.then(() => actions.reopenClosedTab())
|
|
264
|
+
return
|
|
265
|
+
}
|
|
266
|
+
const result = takeClosedTab(closed, store)
|
|
267
|
+
if (result.stack.length === closed.length) return
|
|
268
|
+
setClosed(() => result.stack)
|
|
269
|
+
const entry = result.entry
|
|
270
|
+
if (!entry) return
|
|
271
|
+
const index = Math.min(entry.index, store.length)
|
|
272
|
+
void startTransition(() => {
|
|
273
|
+
setStore(
|
|
274
|
+
produce((tabs) => {
|
|
275
|
+
if (tabs.some((item) => tabKey(item) === tabKey(entry.tab))) return
|
|
276
|
+
tabs.splice(index, 0, entry.tab)
|
|
277
|
+
}),
|
|
278
|
+
)
|
|
279
|
+
navigateTab(entry.tab)
|
|
280
|
+
})
|
|
281
|
+
},
|
|
282
|
+
removeSessionTab(input: Omit<SessionTab, "type">) {
|
|
283
|
+
updateClosed((stack) => removeClosedTabs(stack, input.server, [input.sessionId]))
|
|
284
|
+
const index = store.findIndex(
|
|
285
|
+
(tab) => tab.type === "session" && tab.server === input.server && tab.sessionId === input.sessionId,
|
|
286
|
+
)
|
|
287
|
+
if (index !== -1) removeTab(index)
|
|
288
|
+
},
|
|
289
|
+
removeServer(key: ServerConnection.Key) {
|
|
290
|
+
updateClosed((stack) => stack.filter((entry) => entry.tab.server !== key))
|
|
291
|
+
const drafts = store.flatMap((tab) => (tab.type === "draft" && tab.server === key ? [tab.draftID] : []))
|
|
292
|
+
const removed = store.filter((tab) => tab.server === key).map(tabKey)
|
|
293
|
+
setStore((tabs) => tabs.filter((tab) => tab.server !== key))
|
|
294
|
+
for (const key of removed) memory.remove(key)
|
|
295
|
+
for (const key of removed) removeInfo(key)
|
|
296
|
+
if (recent.key && removed.includes(recent.key)) setRecentKey(undefined)
|
|
297
|
+
for (const draftID of drafts) removeDraftPersisted(draftID)
|
|
298
|
+
if (server.key === key) navigate("/")
|
|
299
|
+
},
|
|
300
|
+
removeSessions: (input: SessionTabsRemovedDetail) => {
|
|
301
|
+
const targetServer = input.server ?? server.key
|
|
302
|
+
updateClosed((stack) => removeClosedTabs(stack, targetServer, input.sessionIDs))
|
|
303
|
+
const removed = store
|
|
304
|
+
.filter(
|
|
305
|
+
(tab) => tab.type === "session" && tab.server === targetServer && input.sessionIDs.includes(tab.sessionId),
|
|
306
|
+
)
|
|
307
|
+
.map(tabKey)
|
|
308
|
+
void startTransition(() => {
|
|
309
|
+
setStore(
|
|
310
|
+
produce((tabs) => {
|
|
311
|
+
const sessionIDs = new Set(input.sessionIDs)
|
|
312
|
+
const currentHref =
|
|
313
|
+
targetServer === server.key && params.dir && params.id
|
|
314
|
+
? tabHref({
|
|
315
|
+
type: "session",
|
|
316
|
+
server: targetServer,
|
|
317
|
+
sessionId: params.id,
|
|
318
|
+
})
|
|
319
|
+
: undefined
|
|
320
|
+
const currentIndex = currentHref
|
|
321
|
+
? tabs.findIndex(
|
|
322
|
+
(tab) => tab.type === "session" && tab.server === targetServer && tabHref(tab) === currentHref,
|
|
323
|
+
)
|
|
324
|
+
: -1
|
|
325
|
+
const currentTab = tabs[currentIndex]
|
|
326
|
+
const removedCurrent =
|
|
327
|
+
currentTab?.type === "session" &&
|
|
328
|
+
currentTab.server === targetServer &&
|
|
329
|
+
sessionIDs.has(currentTab.sessionId)
|
|
330
|
+
|
|
331
|
+
for (let i = tabs.length - 1; i >= 0; i--) {
|
|
332
|
+
const tab = tabs[i]
|
|
333
|
+
if (!tab || tab.type !== "session") continue
|
|
334
|
+
if (tab.server !== targetServer) continue
|
|
335
|
+
if (!sessionIDs.has(tab.sessionId)) continue
|
|
336
|
+
tabs.splice(i, 1)
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
if (!removedCurrent) return
|
|
340
|
+
const nextTab =
|
|
341
|
+
tabs.slice(currentIndex).find((tab) => tab.type === "session") ??
|
|
342
|
+
tabs.slice(0, currentIndex).findLast((tab) => tab.type === "session")
|
|
343
|
+
if (nextTab) navigateTab(nextTab)
|
|
344
|
+
else navigate("/")
|
|
345
|
+
}),
|
|
346
|
+
)
|
|
347
|
+
if (recent.key && removed.includes(recent.key)) setRecentKey(undefined)
|
|
348
|
+
})
|
|
349
|
+
for (const key of removed) memory.remove(key)
|
|
350
|
+
for (const key of removed) removeInfo(key)
|
|
351
|
+
},
|
|
352
|
+
rememberSessionInfo(tab: SessionTab, session: Session) {
|
|
353
|
+
const key = tabKey(tab)
|
|
354
|
+
const next = { title: session.title, directory: session.directory }
|
|
355
|
+
const current = info[key]
|
|
356
|
+
if (current?.title === next.title && current.directory === next.directory) return
|
|
357
|
+
setInfo(key, next)
|
|
358
|
+
},
|
|
359
|
+
select: navigateTab,
|
|
360
|
+
remember(tab: Tab) {
|
|
361
|
+
const key = tabKey(tab)
|
|
362
|
+
if (recentKey() !== key) setRecentKey(key)
|
|
363
|
+
},
|
|
364
|
+
toggleHome(input: { home: boolean; current?: Tab }) {
|
|
365
|
+
if (input.home) {
|
|
366
|
+
const tab = store.find((tab) => tabKey(tab) === recentKey())
|
|
367
|
+
if (tab) navigateTab(tab)
|
|
368
|
+
return
|
|
369
|
+
}
|
|
370
|
+
if (input.current) {
|
|
371
|
+
setRecentKey(tabKey(input.current))
|
|
372
|
+
navigate("/")
|
|
373
|
+
return
|
|
374
|
+
}
|
|
375
|
+
navigate("/")
|
|
376
|
+
},
|
|
377
|
+
state<T>(tab: Tab, name: string, init: () => T) {
|
|
378
|
+
return memory.ensure(tabKey(tab), name, init)
|
|
379
|
+
},
|
|
380
|
+
stateValue<T>(tab: Tab, name: string) {
|
|
381
|
+
return memory.get<T>(tabKey(tab), name)
|
|
382
|
+
},
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
return { ...actions, store, info, ready, recentReady }
|
|
386
|
+
},
|
|
387
|
+
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const template = "Terminal {{number}}"
|
|
2
|
+
|
|
3
|
+
const numbered = [
|
|
4
|
+
template,
|
|
5
|
+
"محطة طرفية {{number}}",
|
|
6
|
+
"Терминал {{number}}",
|
|
7
|
+
"ターミナル {{number}}",
|
|
8
|
+
"터미널 {{number}}",
|
|
9
|
+
"เทอร์มินัล {{number}}",
|
|
10
|
+
"终端 {{number}}",
|
|
11
|
+
"終端機 {{number}}",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
export function defaultTitle(number: number) {
|
|
15
|
+
return template.replace("{{number}}", String(number))
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function isDefaultTitle(title: string, number: number) {
|
|
19
|
+
return numbered.some((text) => title === text.replace("{{number}}", String(number)))
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function titleNumber(title: string, max: number) {
|
|
23
|
+
return Array.from({ length: max }, (_, idx) => idx + 1).find((number) => isDefaultTitle(title, number))
|
|
24
|
+
}
|