@kabmo-labs/kabmo 0.27.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bunfig.toml +6 -0
- package/dist/client/index.html +2 -2
- package/dist/client/index.js +530 -493
- package/dist/client/static/js/{index-e3qh2yps.js → index-43z47ngg.js} +1178 -1034
- package/dist/client/static/js/index-naa91727.css +1 -0
- package/dist/client/static/{manifest-q6h8k9e0.webmanifest → manifest-vdvdqpre.webmanifest} +1 -0
- package/marketplace/plugins/command-runner/package.json +3 -17
- package/marketplace/plugins/command-runner/settings-schema.json +14 -0
- package/marketplace/plugins/git-forge/README.md +17 -7
- package/marketplace/plugins/git-forge/package.json +4 -30
- package/marketplace/plugins/git-forge/panel.css +16 -0
- package/marketplace/plugins/git-forge/settings-schema.json +27 -0
- package/marketplace/plugins/git-forge/src/panel/Badge.tsx +35 -22
- package/marketplace/plugins/git-forge/src/panel/Change.tsx +20 -24
- package/marketplace/plugins/git-forge/src/panel/CiBadge.tsx +16 -7
- package/marketplace/plugins/git-forge/src/panel/Credential.tsx +31 -26
- package/marketplace/plugins/git-forge/src/panel/Glyph.tsx +18 -2
- package/marketplace/plugins/git-forge/src/panel/Header.tsx +160 -96
- package/marketplace/plugins/git-forge/src/panel/ItemView.tsx +60 -44
- package/marketplace/plugins/git-forge/src/panel/List.tsx +150 -22
- package/marketplace/plugins/git-forge/src/panel/Row.tsx +11 -5
- package/marketplace/plugins/git-forge/src/panel/Sidebar.tsx +17 -15
- package/marketplace/plugins/git-forge/src/panel/Write.tsx +84 -61
- package/marketplace/plugins/git-forge/src/panel/format.test.ts +99 -0
- package/marketplace/plugins/git-forge/src/panel/format.ts +59 -16
- package/marketplace/plugins/git-forge/src/panel/index.test.tsx +109 -5
- package/marketplace/plugins/git-forge/src/panel/index.tsx +37 -4
- package/marketplace/plugins/git-forge/src/panel/use-forge.ts +17 -0
- package/marketplace/plugins/git-forge/src/panel/write.test.tsx +31 -0
- package/marketplace/plugins/session-info/package.json +2 -10
- package/marketplace/plugins/session-info/settings-schema.json +8 -0
- package/marketplace/plugins/stats/README.md +17 -5
- package/marketplace/plugins/stats/package.json +3 -23
- package/marketplace/plugins/stats/settings-schema.json +20 -0
- package/marketplace/plugins/stats/src/app.tsx +1 -1
- package/marketplace/plugins/stats/src/groups.test.ts +46 -1
- package/marketplace/plugins/stats/src/groups.ts +22 -11
- package/marketplace/plugins/stats/src/harness-leases.test.ts +84 -0
- package/marketplace/plugins/stats/src/harness-leases.ts +132 -0
- package/marketplace/plugins/stats/src/labels.test.ts +54 -1
- package/marketplace/plugins/stats/src/labels.ts +33 -7
- package/marketplace/plugins/stats/src/sampler.test.ts +61 -0
- package/marketplace/plugins/stats/src/sampler.ts +39 -5
- package/marketplace/plugins/stats/src/snapshot.ts +6 -0
- package/package.json +4 -3
- package/public/manifest.webmanifest +1 -0
- package/src/client/components/common/ComposerTextarea.test.tsx +109 -0
- package/src/client/components/common/ComposerTextarea.tsx +6 -0
- package/src/client/components/common/ReloadPageButton.test.tsx +14 -0
- package/src/client/components/common/ReloadPageButton.tsx +11 -2
- package/src/client/components/common/diagram-viewer/read-block.test.ts +71 -0
- package/src/client/components/common/diagram-viewer/read-block.ts +40 -16
- package/src/client/components/common/file-icon/index.tsx +7 -1
- package/src/client/components/common/harness-glyph/brands.ts +7 -1
- package/src/client/components/common/harness-glyph/index.tsx +18 -1
- package/src/client/components/common/image-viewer/index.tsx +37 -165
- package/src/client/components/common/picker-search/index.tsx +70 -0
- package/src/client/components/common/search-select/index.tsx +2 -7
- package/src/client/components/common/session-actions-menu/index.test.tsx +106 -0
- package/src/client/components/common/session-actions-menu/index.tsx +43 -1
- package/src/client/components/common/session-row/TrailingSlot.tsx +9 -4
- package/src/client/components/common/session-row/index.tsx +4 -0
- package/src/client/components/common/session-row/session-row.test.tsx +6 -0
- package/src/client/components/common/zoom-pan-stage/index.tsx +258 -0
- package/src/client/components/common/zoom-pan-stage/zoom-pan-stage.test.tsx +87 -0
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +2 -1
- package/src/client/components/layout/session-sidebar/ClassicView.tsx +1 -1
- package/src/client/components/layout/session-sidebar/SessionItem.tsx +9 -1
- package/src/client/components/layout/session-sidebar/SessionListNotice.tsx +7 -3
- package/src/client/components/layout/session-sidebar/about-modal/HarnessRow.tsx +4 -1
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +12 -1
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.test.tsx +82 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +23 -3
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +1 -0
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +2 -1
- package/src/client/components/layout/session-sidebar/modern/index.tsx +1 -1
- package/src/client/components/layout/session-sidebar/scheduler-modal/ModelFields.tsx +202 -0
- package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +80 -19
- package/src/client/components/layout/session-sidebar/scheduler-modal/TaskList.tsx +29 -7
- package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +3 -0
- package/src/client/components/layout/session-sidebar/session-list-states.test.tsx +8 -0
- package/src/client/components/mobile/mobile-right-sidebar/EditorSurface.tsx +181 -0
- package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +41 -86
- package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +1 -1
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +2 -1
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.test.ts +6 -0
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +9 -1
- package/src/client/components/settings/Modal.tsx +6 -2
- package/src/client/components/settings/Sidebar.tsx +32 -7
- package/src/client/components/settings/categories/HarnessSettings.tsx +15 -9
- package/src/client/components/settings/categories/NotificationSettings.test.tsx +40 -15
- package/src/client/components/settings/categories/NotificationSettings.tsx +142 -64
- package/src/client/components/settings/categories/PanelPluginSettings.tsx +3 -3
- package/src/client/components/settings/categories/PluginSettings.tsx +1 -1
- package/src/client/components/settings/categories/harness-settings/ConfigForm.tsx +3 -6
- package/src/client/components/settings/categories/harness-settings/CustomHarnessForm.tsx +186 -0
- package/src/client/components/settings/categories/panel-plugins/GitFreshness.test.tsx +36 -0
- package/src/client/components/settings/categories/panel-plugins/InstalledList.tsx +11 -0
- package/src/client/components/settings/categories/panel-plugins/PluginCard.test.tsx +1 -0
- package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +15 -1
- package/src/client/components/settings/categories/panel-plugins/Section.tsx +1 -3
- package/src/client/components/settings/categories/panel-plugins/SettingsModal.test.tsx +165 -0
- package/src/client/components/settings/categories/panel-plugins/SettingsModal.tsx +260 -0
- package/src/client/components/settings/categories/panel-plugins/Toolbar.tsx +18 -4
- package/src/client/components/settings/categories/plugin-settings/MarketplacePane.tsx +64 -61
- package/src/client/components/settings/categories/plugin-settings/SidebarList.tsx +15 -4
- package/src/client/components/settings/groups.test.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.fork.test.ts +24 -0
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +8 -4
- package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +34 -0
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +3 -2
- package/src/client/components/workspace/chat-timeline/IrcNotice.test.tsx +55 -0
- package/src/client/components/workspace/chat-timeline/IrcNotice.tsx +71 -0
- package/src/client/components/workspace/chat-timeline/MessageItem.fork.test.ts +80 -0
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +13 -4
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/RunFooter.tsx +2 -1
- package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +2 -1
- package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +8 -0
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.test.tsx +9 -0
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +4 -1
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +19 -0
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +32 -3
- package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.search.test.tsx +72 -0
- package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +53 -33
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/chat-input/props.ts +5 -5
- package/src/client/components/workspace/chat-timeline/index.tsx +11 -5
- package/src/client/components/workspace/chat-timeline/target-picker/DraftTargetRow.tsx +1 -9
- package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.test.tsx +129 -0
- package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +30 -12
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.test.tsx +47 -1
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +55 -5
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +3 -2
- package/src/client/components/workspace/editor/FilePane.tsx +41 -4
- package/src/client/components/workspace/editor/Notices.tsx +2 -2
- package/src/client/components/workspace/editor/Pane.tsx +2 -2
- package/src/client/components/workspace/editor/Toolbar.tsx +20 -10
- package/src/client/components/workspace/editor/index.tsx +6 -10
- package/src/client/components/workspace/editor/toolbar-clusters.test.ts +5 -3
- package/src/client/components/workspace/editor/toolbar-clusters.tsx +26 -14
- package/src/client/components/workspace/editor/viewers/CsvGrid.tsx +52 -5
- package/src/client/components/workspace/editor/viewers/DataGrid.tsx +227 -41
- package/src/client/components/workspace/editor/viewers/DrawioView.tsx +93 -0
- package/src/client/components/workspace/editor/viewers/GridRow.tsx +91 -0
- package/src/client/components/workspace/editor/viewers/GridToolbar.tsx +53 -0
- package/src/client/components/workspace/editor/viewers/SheetView.tsx +152 -57
- package/src/client/components/workspace/editor/viewers/dispatch.tsx +42 -9
- package/src/client/components/workspace/editor/viewers/drawio-pages.test.ts +80 -0
- package/src/client/components/workspace/editor/viewers/drawio-pages.ts +63 -0
- package/src/client/components/workspace/editor/viewers/grid.test.ts +296 -0
- package/src/client/components/workspace/editor/viewers/use-cell-edit.ts +64 -0
- package/src/client/components/workspace/editor/viewers/use-grid-interaction.ts +216 -0
- package/src/client/components/workspace/editor/viewers/viewers.test.ts +47 -2
- package/src/client/components/workspace/editor/viewers/workbook.ts +149 -0
- package/src/client/components/workspace/file-explorer/ArchiveModals.tsx +262 -0
- package/src/client/components/workspace/file-explorer/ContextMenu.tsx +30 -6
- package/src/client/components/workspace/file-explorer/Modals.tsx +8 -3
- package/src/client/components/workspace/file-explorer/RootOverlays.tsx +60 -0
- package/src/client/components/workspace/file-explorer/RowLabel.tsx +6 -2
- package/src/client/components/workspace/file-explorer/TreeItem.tsx +39 -49
- package/src/client/components/workspace/file-explorer/TreeItemModals.tsx +80 -0
- package/src/client/components/workspace/file-explorer/index.tsx +53 -29
- package/src/client/components/workspace/file-explorer/selection.test.tsx +109 -0
- package/src/client/components/workspace/terminal-panel/RealtimeTerminalView.tsx +9 -1
- package/src/client/components/workspace/terminal-panel/focus.test.ts +70 -0
- package/src/client/components/workspace/terminal-panel/focus.ts +46 -0
- package/src/client/components/workspace/terminal-panel/index.tsx +14 -1
- package/src/client/components/workspace/terminal-panel/mount.ts +17 -9
- package/src/client/components/workspace/terminal-panel/scroll-hold.test.ts +158 -0
- package/src/client/components/workspace/terminal-panel/scroll-hold.ts +136 -0
- package/src/client/data/settings/omp-schema.json +169 -22
- package/src/client/glass.css +39 -14
- package/src/client/glass.test.ts +37 -0
- package/src/client/hooks/chat/composer/history.test.ts +267 -0
- package/src/client/hooks/chat/composer/history.ts +146 -0
- package/src/client/hooks/chat/composer/use-draft.ts +45 -1
- package/src/client/hooks/chat/omp/pending-sessions.waiting.test.ts +11 -10
- package/src/client/hooks/chat/omp/pending-waiting.ts +15 -7
- package/src/client/hooks/chat/omp/prompt-send.test.ts +11 -0
- package/src/client/hooks/chat/omp/prompt-send.ts +3 -0
- package/src/client/hooks/chat/timeline/actions.ts +4 -4
- package/src/client/hooks/chat/timeline/ask-frames.test.ts +54 -0
- package/src/client/hooks/chat/timeline/ask-frames.ts +29 -1
- package/src/client/hooks/chat/timeline/composer-modes.ts +13 -2
- package/src/client/hooks/chat/timeline/fork-open.ts +52 -0
- package/src/client/hooks/chat/timeline/index.ts +5 -2
- package/src/client/hooks/chat/timeline/mode-availability.ts +7 -0
- package/src/client/hooks/chat/timeline/modes-contract.ts +6 -0
- package/src/client/hooks/chat/timeline/modes-hydrate.ts +93 -0
- package/src/client/hooks/chat/timeline/modes.ts +32 -52
- package/src/client/hooks/chat/timeline/new-chat-open.ts +7 -6
- package/src/client/hooks/chat/timeline/new-chat.ts +10 -1
- package/src/client/hooks/chat/timeline/pending-dispatch.ts +4 -0
- package/src/client/hooks/chat/timeline/pending-session-mode.test.ts +136 -0
- package/src/client/hooks/chat/timeline/pending-session-mode.ts +69 -0
- package/src/client/hooks/chat/timeline/pending-warmup.test.ts +147 -0
- package/src/client/hooks/chat/timeline/pending-warmup.ts +62 -0
- package/src/client/hooks/chat/timeline/run-identity.test.ts +12 -0
- package/src/client/hooks/chat/timeline/run-identity.ts +4 -1
- package/src/client/hooks/chat/timeline/send-props.ts +2 -0
- package/src/client/hooks/chat/timeline/send-steer.test.ts +1 -0
- package/src/client/hooks/chat/timeline/send.test-util.ts +1 -0
- package/src/client/hooks/chat/timeline/send.test.ts +1 -0
- package/src/client/hooks/chat/timeline/session-harness.ts +4 -0
- package/src/client/hooks/chat/timeline/timeline-rail.test.ts +34 -2
- package/src/client/hooks/chat/timeline/use-fork-session.ts +9 -22
- package/src/client/hooks/chat/timeline/user-turns.ts +31 -2
- package/src/client/hooks/chat/waiting/cancel.ts +13 -6
- package/src/client/hooks/chat/waiting/choice.ts +13 -16
- package/src/client/hooks/chat/waiting/composer-wait.ts +70 -0
- package/src/client/hooks/chat/waiting/dispatch.ts +48 -28
- package/src/client/hooks/chat/waiting/held.ts +37 -13
- package/src/client/hooks/chat/waiting/hold.test.ts +22 -0
- package/src/client/hooks/chat/waiting/hold.ts +20 -11
- package/src/client/hooks/chat/waiting/restore.test.ts +69 -0
- package/src/client/hooks/chat/waiting/restore.ts +34 -0
- package/src/client/hooks/chat/waiting/store.ts +9 -3
- package/src/client/hooks/editor/file-editor-types.ts +36 -12
- package/src/client/hooks/editor/save-bytes.ts +79 -0
- package/src/client/hooks/editor/save-file.test.ts +1 -1
- package/src/client/hooks/editor/save-file.ts +35 -8
- package/src/client/hooks/editor/target-key.ts +17 -0
- package/src/client/hooks/editor/use-disk-digest.test.ts +82 -0
- package/src/client/hooks/editor/use-disk-digest.ts +164 -0
- package/src/client/hooks/editor/use-disk-sync.ts +212 -0
- package/src/client/hooks/editor/use-file-cache.ts +113 -0
- package/src/client/hooks/editor/use-file-editor.test.ts +120 -0
- package/src/client/hooks/editor/use-file-editor.ts +143 -57
- package/src/client/hooks/editor/use-file-read.ts +45 -12
- package/src/client/hooks/editor/use-file-writes.ts +4 -4
- package/src/client/hooks/editor/use-grid-selection.ts +160 -0
- package/src/client/hooks/models/harness-catalog.ts +15 -0
- package/src/client/hooks/models/use-harness-update.test.ts +35 -2
- package/src/client/hooks/models/use-harness-update.ts +49 -10
- package/src/client/hooks/ui/notifications.ts +17 -8
- package/src/client/hooks/workspace/diff-file.test.ts +72 -0
- package/src/client/hooks/workspace/diff-file.ts +12 -6
- package/src/client/hooks/workspace/file-archive.ts +220 -0
- package/src/client/hooks/workspace/file-clipboard.test.ts +4 -4
- package/src/client/hooks/workspace/file-clipboard.ts +37 -26
- package/src/client/hooks/workspace/file-selection.test.ts +67 -0
- package/src/client/hooks/workspace/file-selection.ts +156 -0
- package/src/client/hooks/workspace/file-tree-actions-clipboard.test.ts +5 -5
- package/src/client/hooks/workspace/file-tree-actions.ts +36 -8
- package/src/client/hooks/workspace/panel-registry.ts +1 -1
- package/src/client/hooks/workspace/scheduled-tasks.ts +26 -11
- package/src/client/lib/editor/workbook-drafts.ts +42 -0
- package/src/client/lib/launch/file-handlers.ts +2 -2
- package/src/client/lib/notifications/os.test.ts +1 -30
- package/src/client/lib/notifications/os.ts +0 -15
- package/src/client/lib/notifications/platform.test.ts +68 -0
- package/src/client/lib/notifications/platform.ts +36 -0
- package/src/client/lib/scrollbar-activity.test.ts +21 -88
- package/src/client/lib/scrollbar-activity.ts +71 -73
- package/src/client/lib/scrollbar-events.ts +143 -0
- package/src/client/lib/scrollbar-input.test.ts +126 -0
- package/src/client/lib/scrollbar-probe.test-util.ts +107 -0
- package/src/client/tailwind.css +32 -1
- package/src/server/db.server.test.ts +50 -1
- package/src/server/db.server.ts +36 -3
- package/src/server/index.ts +7 -0
- package/src/server/lib/chat/prompt-history.server.test.ts +92 -0
- package/src/server/lib/chat/prompt-history.server.ts +65 -0
- package/src/server/lib/chat/schema.server.ts +35 -0
- package/src/server/lib/db/schema.ts +3 -0
- package/src/server/lib/fs/archive.test.ts +139 -0
- package/src/server/lib/fs/archive.ts +259 -0
- package/src/server/lib/fs/git-diff.test.ts +26 -1
- package/src/server/lib/fs/git-diff.ts +43 -15
- package/src/server/lib/harness/acp/client.ts +81 -87
- package/src/server/lib/harness/acp/prewarm.server.ts +237 -0
- package/src/server/lib/harness/acp/prewarm.test.ts +171 -0
- package/src/server/lib/harness/acp/prompt.test.ts +70 -1
- package/src/server/lib/harness/acp/prompt.ts +32 -1
- package/src/server/lib/harness/acp/protocol.ts +23 -0
- package/src/server/lib/harness/acp/session-handshake.test.ts +26 -0
- package/src/server/lib/harness/acp/session-handshake.ts +22 -20
- package/src/server/lib/harness/acp/session-options.ts +16 -0
- package/src/server/lib/harness/acp/session-process.ts +43 -0
- package/src/server/lib/harness/acp/session.ts +11 -12
- package/src/server/lib/harness/acp/stdio.ts +129 -0
- package/src/server/lib/harness/acp/verbs.test.ts +97 -0
- package/src/server/lib/harness/acp/verbs.ts +16 -6
- package/src/server/lib/harness/auto-probe.server.ts +4 -3
- package/src/server/lib/harness/capabilities.ts +8 -0
- package/src/server/lib/harness/config.server.ts +3 -2
- package/src/server/lib/harness/custom.server.ts +209 -0
- package/src/server/lib/harness/launch-table.ts +19 -0
- package/src/server/lib/harness/launch.ts +6 -1
- package/src/server/lib/harness/provider-entry.ts +1 -1
- package/src/server/lib/harness/provider-file.server.ts +1 -1
- package/src/server/lib/harness/provider-sources.server.ts +2 -1
- package/src/server/lib/harness/provider-write.server.ts +2 -1
- package/src/server/lib/harness/register.server.ts +8 -1
- package/src/server/lib/harness/schema.server.ts +21 -0
- package/src/server/lib/harness/session-lease.server.test.ts +99 -0
- package/src/server/lib/harness/session-lease.server.ts +193 -0
- package/src/server/lib/harness/session-store.server.test.ts +8 -8
- package/src/server/lib/harness/session-store.server.ts +25 -4
- package/src/server/lib/harness/session-title.server.ts +12 -2
- package/src/server/lib/harness/spawn.server.ts +123 -20
- package/src/server/lib/harness/update-job-store.ts +12 -0
- package/src/server/lib/harness/update-queue.server.ts +18 -13
- package/src/server/lib/lifecycle/after-listen.ts +12 -1
- package/src/server/lib/lifecycle/paths.ts +19 -1
- package/src/server/lib/mcp/registry.server.ts +155 -0
- package/src/server/lib/mcp/registry.test.ts +169 -0
- package/src/server/lib/mcp/store.server.ts +38 -0
- package/src/server/lib/omp/rpc/frame-fold-contract.ts +59 -0
- package/src/server/lib/omp/rpc/frame-fold-frames.test.ts +64 -1
- package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +2 -1
- package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +5 -1
- package/src/server/lib/omp/rpc/frame-fold.test.ts +7 -2
- package/src/server/lib/omp/rpc/frame-fold.ts +6 -45
- package/src/server/lib/omp/rpc/lifecycle.test.ts +4 -0
- package/src/server/lib/omp/rpc/prewarm-pool.ts +19 -5
- package/src/server/lib/omp/rpc/run-model.test.ts +116 -0
- package/src/server/lib/omp/rpc/run-model.ts +4 -2
- package/src/server/lib/omp/session/auto-title.server.test.ts +4 -0
- package/src/server/lib/omp/session/delete.server.ts +1 -0
- package/src/server/lib/omp/session/goal-driver.test.ts +5 -1
- package/src/server/lib/omp/session/goal-settings.test.ts +5 -1
- package/src/server/lib/omp/session/sidebar-data.harness.test.ts +6 -3
- package/src/server/lib/omp/session/standby.server.ts +13 -2
- package/src/server/lib/panels/auto-update.server.test.ts +5 -2
- package/src/server/lib/panels/git-update.server.test.ts +5 -2
- package/src/server/lib/panels/install.server.test.ts +5 -2
- package/src/server/lib/panels/manifest.test.ts +47 -1
- package/src/server/lib/panels/manifest.ts +19 -0
- package/src/server/lib/panels/registry.server.ts +19 -2
- package/src/server/lib/panels/remove.server.test.ts +5 -2
- package/src/server/lib/panels/scan.server.ts +26 -2
- package/src/server/lib/panels/settings-schema.server.ts +72 -0
- package/src/server/lib/plugins/background.server.ts +21 -3
- package/src/server/lib/plugins/background.test.ts +13 -0
- package/src/server/lib/plugins/loader.server.ts +35 -51
- package/src/server/lib/plugins/mcp.server.ts +100 -0
- package/src/server/lib/plugins/mcp.test.ts +75 -0
- package/src/server/lib/plugins/schedule-runner.server.ts +153 -0
- package/src/server/lib/plugins/schedule-runner.test.ts +186 -0
- package/src/server/lib/plugins/schedule-store.server.ts +107 -0
- package/src/server/lib/plugins/schema.server.ts +8 -0
- package/src/server/lib/plugins/settings.server.ts +56 -19
- package/src/server/lib/plugins/shutdown.server.ts +58 -0
- package/src/server/lib/plugins/shutdown.test.ts +28 -3
- package/src/server/lib/realtime/topics/global.server.ts +5 -1
- package/src/server/lib/schedule/rows.server.ts +9 -0
- package/src/server/lib/schedule/runtime.server.test.ts +91 -0
- package/src/server/lib/schedule/runtime.server.ts +101 -23
- package/src/server/lib/schedule/schema.server.ts +15 -0
- package/src/server/lib/schedule/store.server.test.ts +34 -0
- package/src/server/lib/schedule/store.server.ts +33 -9
- package/src/server/lib/sessions/fork.server.test.ts +47 -0
- package/src/server/lib/sessions/fork.server.ts +17 -1
- package/src/server/lib/sessions/spawn.server.ts +2 -2
- package/src/server/lib/waiting/runtime.server.test.ts +48 -0
- package/src/server/lib/waiting/runtime.server.ts +22 -0
- package/src/server/lib/waiting/schema.server.ts +8 -0
- package/src/server/lib/waiting/store.server.test.ts +14 -0
- package/src/server/lib/waiting/store.server.ts +6 -2
- package/src/server/routes/agent/command-resume.test.ts +9 -4
- package/src/server/routes/agent/command.ts +11 -0
- package/src/server/routes/agent/new-mode.test.ts +40 -0
- package/src/server/routes/agent/new.ts +36 -10
- package/src/server/routes/agent/prewarm.ts +48 -7
- package/src/server/routes/chat/index.ts +5 -0
- package/src/server/routes/chat/prompt-history.test.ts +67 -0
- package/src/server/routes/chat/prompt-history.ts +31 -0
- package/src/server/routes/chat/stream.test.ts +21 -0
- package/src/server/routes/chat/stream.ts +5 -0
- package/src/server/routes/fs/action-archive.test.ts +128 -0
- package/src/server/routes/fs/action-bulk.ts +106 -0
- package/src/server/routes/fs/action-save-bytes.test.ts +59 -0
- package/src/server/routes/fs/action-transfer.test.ts +26 -0
- package/src/server/routes/fs/action.ts +100 -12
- package/src/server/routes/fs/archive.ts +20 -0
- package/src/server/routes/fs/digest.test.ts +100 -0
- package/src/server/routes/fs/digest.ts +106 -0
- package/src/server/routes/fs/grant.test.ts +5 -2
- package/src/server/routes/fs/index.ts +4 -0
- package/src/server/routes/fs/read.ts +6 -1
- package/src/server/routes/fs/scope.test.ts +6 -2
- package/src/server/routes/harness/custom.test.ts +131 -0
- package/src/server/routes/harness/import-action.ts +3 -3
- package/src/server/routes/harness/root.ts +47 -9
- package/src/server/routes/harness/summary.test.ts +50 -0
- package/src/server/routes/harness/update-status.ts +41 -2
- package/src/server/routes/harness/update.test.ts +56 -2
- package/src/server/routes/harness/update.ts +2 -2
- package/src/server/routes/panels/bindings.ts +2 -0
- package/src/server/routes/panels/settings.test.ts +165 -0
- package/src/server/routes/panels/settings.ts +106 -0
- package/src/server/routes/schedule/body.ts +14 -0
- package/src/server/routes/schedule/index.ts +28 -4
- package/src/server/routes/sessions/delete.test.ts +4 -0
- package/src/server/routes/settings/mcp.ts +9 -26
- package/src/server/routes/waiting/index.ts +21 -2
- package/src/server/routes/waiting/routes.test.ts +21 -0
- package/src/shared/lib/chat/ask-form/index.ts +39 -31
- package/src/shared/lib/chat/ask-form/labels.ts +46 -0
- package/src/shared/lib/chat/ask-form/tokens.ts +11 -2
- package/src/shared/lib/chat/ask-form.test.ts +57 -0
- package/src/shared/lib/chat/ask-questions.ts +31 -0
- package/src/shared/lib/chat/composer/delegation.ts +3 -3
- package/src/shared/lib/chat/composer/history.test.ts +67 -0
- package/src/shared/lib/chat/composer/history.ts +61 -0
- package/src/shared/lib/chat/irc-notice.ts +42 -0
- package/src/shared/lib/chat/timeline/fork-anchor.test.ts +99 -0
- package/src/shared/lib/chat/timeline/fork-anchor.ts +47 -0
- package/src/shared/lib/chat/todo/parser.ts +6 -4
- package/src/shared/lib/fs/archive.test.ts +101 -0
- package/src/shared/lib/fs/archive.ts +191 -0
- package/src/shared/lib/fs/clipboard.test.ts +32 -7
- package/src/shared/lib/fs/clipboard.ts +59 -14
- package/src/shared/lib/fs/content-hash.ts +29 -0
- package/src/shared/lib/fs/csv.test.ts +50 -0
- package/src/shared/lib/fs/csv.ts +40 -0
- package/src/shared/lib/fs/document-kind.test.ts +13 -6
- package/src/shared/lib/fs/document-kind.ts +18 -6
- package/src/shared/lib/fs/file-kind-classify.test.ts +4 -0
- package/src/shared/lib/fs/file-kind.test.ts +2 -7
- package/src/shared/lib/fs/file-kind.ts +4 -2
- package/src/shared/lib/fs/grid-edit.test.ts +24 -0
- package/src/shared/lib/fs/grid-edit.ts +29 -0
- package/src/shared/lib/fs/grid-selection.test.ts +137 -0
- package/src/shared/lib/fs/grid-selection.ts +138 -0
- package/src/shared/lib/harness/brand-color.ts +5 -0
- package/src/shared/lib/harness/catalog.test.ts +22 -0
- package/src/shared/lib/harness/catalog.ts +60 -7
- package/src/shared/lib/harness/config-fields.test.ts +25 -0
- package/src/shared/lib/harness/config-fields.ts +33 -3
- package/src/shared/lib/harness/dialects.ts +1 -1
- package/src/shared/lib/harness/fork.ts +60 -0
- package/src/shared/lib/harness/mcp-facts.test.ts +30 -0
- package/src/shared/lib/harness/mcp-facts.ts +69 -0
- package/src/shared/lib/harness/menu.test.ts +16 -1
- package/src/shared/lib/harness/menu.ts +2 -2
- package/src/shared/lib/harness/provider-contracts.ts +109 -0
- package/src/shared/lib/harness/provider-facts.test.ts +2 -1
- package/src/shared/lib/harness/provider-facts.ts +24 -115
- package/src/shared/lib/harness/provider-lookup.ts +37 -0
- package/src/shared/lib/harness/providers.ts +2 -1
- package/src/shared/lib/harness/rewind.ts +6 -6
- package/src/shared/lib/harness/session-modes.ts +31 -0
- package/src/shared/lib/harness/transcript.test.ts +29 -0
- package/src/shared/lib/harness/transcript.ts +19 -0
- package/src/shared/lib/harness/updates.ts +10 -0
- package/src/shared/lib/notifications/settings.test.ts +21 -0
- package/src/shared/lib/notifications/settings.ts +24 -0
- package/src/shared/lib/omp/session/mapper.test.ts +31 -0
- package/src/shared/lib/omp/session/mapper.ts +17 -0
- package/src/shared/lib/omp/session/messages-map-notice.test.ts +68 -0
- package/src/shared/lib/omp/session/messages-map.test.ts +1 -35
- package/src/shared/lib/omp/session/messages-map.ts +17 -0
- package/src/shared/lib/omp/session/prewarm.test.ts +28 -4
- package/src/shared/lib/omp/session/prewarm.ts +25 -6
- package/src/shared/lib/omp/session/stream-state.server.test.ts +25 -0
- package/src/shared/lib/omp/session/stream-state.server.ts +8 -4
- package/src/shared/lib/omp/session/wait.ts +10 -1
- package/src/shared/lib/panels/capabilities.test.ts +1 -1
- package/src/shared/lib/panels/capabilities.ts +3 -0
- package/src/shared/lib/plugins/settings.ts +22 -0
- package/src/shared/lib/schedule/parse.test.ts +48 -0
- package/src/shared/lib/schedule/parse.ts +69 -45
- package/src/shared/lib/schedule/timezone.ts +128 -0
- package/src/shared/lib/settings/defaults.ts +2 -0
- package/src/shared/lib/settings/sections.ts +8 -4
- package/src/shared/lib/ui/picker-filter.test.ts +23 -0
- package/src/shared/lib/ui/picker-filter.ts +20 -0
- package/src/shared/lib/workspace/refresh-cadence.test.ts +25 -1
- package/src/shared/lib/workspace/relative-time.ts +16 -0
- package/src/shared/types/chat.ts +4 -0
- package/src/shared/types/harness.ts +12 -1
- package/src/shared/types/omp/agent.ts +6 -0
- package/src/shared/types/omp/session.ts +18 -0
- package/src/shared/types/panels-registry.ts +3 -3
- package/src/shared/types/panels.ts +4 -2
- package/src/shared/types/schedule.ts +13 -0
- package/src/shared/types/settings/state.ts +18 -7
- package/src/shared/types/todo.ts +3 -1
- package/src/shared/types/waiting.ts +9 -0
- package/src/test-support/file-actions.test-util.ts +4 -0
- package/src/test-support/file-archive.test-util.ts +41 -0
- package/src/test-support/file-clipboard.test-util.ts +9 -6
- package/src/test-support/file-editor.test-util.ts +70 -5
- package/src/test-support/harness-table.test-util.ts +2 -0
- package/src/test-support/preload.ts +46 -0
- package/dist/client/static/js/index-32rpkj6b.css +0 -1
- package/src/client/hooks/editor/use-external-change-notice.ts +0 -71
- package/src/client/hooks/editor/use-external-change.test.ts +0 -88
- package/src/client/hooks/editor/use-external-change.ts +0 -146
|
@@ -16,6 +16,17 @@
|
|
|
16
16
|
* timeline and the sidebar faded. Nothing about that is a per-component
|
|
17
17
|
* decision, so nothing about it should be wired per component.
|
|
18
18
|
*
|
|
19
|
+
* ## Painted on the INPUT, not on the scroll it causes
|
|
20
|
+
*
|
|
21
|
+
* The bar is painted by the `wheel`/`touch*` handler itself, on the nearest
|
|
22
|
+
* ancestor under the pointer that can overflow. Waiting for the `scroll` event
|
|
23
|
+
* means painting a frame late at best and not at all at worst — a browser
|
|
24
|
+
* dispatches `scroll` at its own frame boundary, and the gate below declines
|
|
25
|
+
* the scrolls it cannot attribute to a user. The `scroll` path is still wired,
|
|
26
|
+
* and it is the one that covers a scrollbar-thumb drag and the document's own
|
|
27
|
+
* scroll; the input path is what makes "the bar appears the moment you scroll"
|
|
28
|
+
* true without depending on either.
|
|
29
|
+
*
|
|
19
30
|
* ## Why one document listener is enough
|
|
20
31
|
*
|
|
21
32
|
* `scroll` does not bubble, so a bubble-phase listener on `document` would only
|
|
@@ -80,6 +91,14 @@
|
|
|
80
91
|
* on `documentElement`.
|
|
81
92
|
*/
|
|
82
93
|
|
|
94
|
+
import {
|
|
95
|
+
belongsTo,
|
|
96
|
+
eventMoment,
|
|
97
|
+
isScrollKey,
|
|
98
|
+
nearestScroller,
|
|
99
|
+
scrolledElement,
|
|
100
|
+
} from '@/client/lib/scrollbar-events';
|
|
101
|
+
|
|
83
102
|
/** The attribute `tailwind.css` selects on. One name, two files. */
|
|
84
103
|
export const SCROLLBAR_ACTIVE_ATTRIBUTE = 'data-scrollbar-active';
|
|
85
104
|
|
|
@@ -115,68 +134,6 @@ interface ScrollbarActivityHost {
|
|
|
115
134
|
* and Bun/Node typings disagree on what `setTimeout` returns. */
|
|
116
135
|
type FadeTimer = ReturnType<typeof setTimeout>;
|
|
117
136
|
|
|
118
|
-
/** The element whose scrollbar the event describes. */
|
|
119
|
-
function scrolledElement(target: EventTarget | null): Element | null {
|
|
120
|
-
if (target === document || target === window || target === null) {
|
|
121
|
-
// The viewport's own scroll: the bar that is painted belongs to the root
|
|
122
|
-
// element, not to the document the event names.
|
|
123
|
-
return document.documentElement;
|
|
124
|
-
}
|
|
125
|
-
return target instanceof Element ? target : null;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* WHEN an event happened, on the one clock the arm is compared on.
|
|
130
|
-
*
|
|
131
|
-
* `Date.now()` read inside a handler is when the handler RAN, and the two are
|
|
132
|
-
* not the same moment: scroll events are coalesced and delivered at the next
|
|
133
|
-
* frame, so a main thread busy with a long task (a streamed markdown render, a
|
|
134
|
-
* 36 000px transcript re-layout) can delay delivery by hundreds of milliseconds.
|
|
135
|
-
* `Event.timeStamp` is stamped when the event is CREATED, which is what makes
|
|
136
|
-
* the arm's expiry mean "this input is old" rather than "this handler is late".
|
|
137
|
-
*
|
|
138
|
-
* Engines disagree about the scroll stamp — Chrome stamps at creation, WebKit
|
|
139
|
-
* at dispatch — so this clock cannot decide whether a scroll was the user's.
|
|
140
|
-
* That is why the gate is an ARM (did any input happen since the last reveal?)
|
|
141
|
-
* and not a gap: the arm only has to bound how stale an input may be, and both
|
|
142
|
-
* engines answer that.
|
|
143
|
-
*
|
|
144
|
-
* The fallback covers synthetic events and engines that report a non-positive
|
|
145
|
-
* stamp (`0` is what a hand-built `new Event('scroll')` carries). It answers
|
|
146
|
-
* `performance.now()` and not `Date.now()`: `Event.timeStamp` is a
|
|
147
|
-
* `DOMHighResTimeStamp`, so mixing in wall time would make the subtraction a
|
|
148
|
-
* difference of two different clocks — measured as a negative gap, which would
|
|
149
|
-
* make every programmatic scroll look armed.
|
|
150
|
-
*/
|
|
151
|
-
function eventMoment(event: Event): number {
|
|
152
|
-
const stamp = event.timeStamp;
|
|
153
|
-
return Number.isFinite(stamp) && stamp > 0 ? stamp : performance.now();
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Whether an input happened INSIDE the container that scrolled.
|
|
158
|
-
*
|
|
159
|
-
* An arm is spent by the first scroll that follows it, which is what stops a
|
|
160
|
-
* stream from pinning a bar — but "first scroll anywhere" was too loose: a
|
|
161
|
-
* wheel that cannot move its container (already at the top) produces no scroll
|
|
162
|
-
* event, so its arm stayed unspent for the rest of its life and the next
|
|
163
|
-
* PROGRAMMATIC scroll in any other panel could spend it. Measured: wheel up at
|
|
164
|
-
* `scrollTop = 0`, then `scrollTop = 500` 250ms later, and the bar lit for a
|
|
165
|
-
* scroll nobody made.
|
|
166
|
-
*
|
|
167
|
-
* Binding the arm to the subtree the input happened in closes that without
|
|
168
|
-
* adding a layout read: `contains` is a tree walk, not a `getComputedStyle`,
|
|
169
|
-
* and the wheel's target is already the element under the pointer.
|
|
170
|
-
*
|
|
171
|
-
* An input that names the document or the window itself (a keydown with nothing
|
|
172
|
-
* focused) is deliberately NOT bound — the scroller it drives is the focused
|
|
173
|
-
* one, which no target reveals, so it keeps the unbound behaviour.
|
|
174
|
-
*/
|
|
175
|
-
function belongsTo(element: Element, inputTarget: EventTarget | null): boolean {
|
|
176
|
-
if (inputTarget === null || inputTarget === document || inputTarget === window) return true;
|
|
177
|
-
if (inputTarget === element) return true;
|
|
178
|
-
return inputTarget instanceof Node ? element.contains(inputTarget) : false;
|
|
179
|
-
}
|
|
180
137
|
|
|
181
138
|
/**
|
|
182
139
|
* Wire the reveal rule for one document. Idempotent per document.
|
|
@@ -225,6 +182,45 @@ export function installScrollbarActivity(
|
|
|
225
182
|
armedAt = eventMoment(event);
|
|
226
183
|
armedIn = event.target;
|
|
227
184
|
};
|
|
185
|
+
|
|
186
|
+
/** Paint `element`'s bar and start its idle window over. */
|
|
187
|
+
const reveal = (element: Element) => {
|
|
188
|
+
element.setAttribute(SCROLLBAR_ACTIVE_ATTRIBUTE, '');
|
|
189
|
+
clearTimeout(timers.get(element));
|
|
190
|
+
timers.set(
|
|
191
|
+
element,
|
|
192
|
+
setTimeout(() => {
|
|
193
|
+
timers.delete(element);
|
|
194
|
+
element.removeAttribute(SCROLLBAR_ACTIVE_ATTRIBUTE);
|
|
195
|
+
}, idleMs),
|
|
196
|
+
);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Reveal the surface the user's input is aimed at, AT INPUT TIME.
|
|
201
|
+
*
|
|
202
|
+
* Waiting for the `scroll` event means the bar is painted on the frame after
|
|
203
|
+
* the input — and a scroll the gate declines (a programmatic follow, an
|
|
204
|
+
* engine that dispatches the scroll after the frame budget) paints nothing at
|
|
205
|
+
* all. Painting here makes "the bar appears the moment you scroll" true by
|
|
206
|
+
* construction, and it costs no layout: the walk stops at the first ancestor
|
|
207
|
+
* that can actually overflow.
|
|
208
|
+
*
|
|
209
|
+
* Only input paints, so a stream's auto-follow still cannot light a bar. Each
|
|
210
|
+
* wheel event of a gesture restarts the idle window, which is what makes the
|
|
211
|
+
* bar stay up for as long as the user keeps scrolling instead of for 5s after
|
|
212
|
+
* the first tick of the gesture.
|
|
213
|
+
*/
|
|
214
|
+
const revealUnderPointer = (event: Event) => {
|
|
215
|
+
const element = nearestScroller(event.target);
|
|
216
|
+
if (element) reveal(element);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const noteScrollingInput = (event: Event) => {
|
|
220
|
+
noteInput(event);
|
|
221
|
+
revealUnderPointer(event);
|
|
222
|
+
};
|
|
223
|
+
|
|
228
224
|
const pressPointer = (event: Event) => {
|
|
229
225
|
heldPointer = true;
|
|
230
226
|
noteInput(event);
|
|
@@ -238,9 +234,19 @@ export function installScrollbarActivity(
|
|
|
238
234
|
// Every one of these is passive: none of them ever calls `preventDefault`,
|
|
239
235
|
// and a non-passive wheel listener is a documented cause of scroll jank.
|
|
240
236
|
const INPUT_OPTIONS = { capture: true, passive: true } as const;
|
|
241
|
-
for (const type of ['wheel', 'touchstart', 'touchmove'
|
|
242
|
-
document.addEventListener(type,
|
|
237
|
+
for (const type of ['wheel', 'touchstart', 'touchmove'] as const) {
|
|
238
|
+
document.addEventListener(type, noteScrollingInput, INPUT_OPTIONS);
|
|
243
239
|
}
|
|
240
|
+
// Only the keys that scroll arm the gate. A keydown that types a character
|
|
241
|
+
// says nothing about scrolling, and arming on it let a stream's next
|
|
242
|
+
// auto-follow paint a bar while the reader was typing in the composer.
|
|
243
|
+
document.addEventListener(
|
|
244
|
+
'keydown',
|
|
245
|
+
(event) => {
|
|
246
|
+
if (isScrollKey(event as KeyboardEvent)) noteInput(event);
|
|
247
|
+
},
|
|
248
|
+
INPUT_OPTIONS,
|
|
249
|
+
);
|
|
244
250
|
// `mousedown`/`mouseup` ride along with the pointer pair so an engine that
|
|
245
251
|
// synthesizes no pointer events for a native scrollbar still counts the drag.
|
|
246
252
|
document.addEventListener('pointerdown', pressPointer, INPUT_OPTIONS);
|
|
@@ -282,15 +288,7 @@ export function installScrollbarActivity(
|
|
|
282
288
|
armedAt = null;
|
|
283
289
|
armedIn = null;
|
|
284
290
|
}
|
|
285
|
-
element
|
|
286
|
-
clearTimeout(timers.get(element));
|
|
287
|
-
timers.set(
|
|
288
|
-
element,
|
|
289
|
-
setTimeout(() => {
|
|
290
|
-
timers.delete(element);
|
|
291
|
-
element.removeAttribute(SCROLLBAR_ACTIVE_ATTRIBUTE);
|
|
292
|
-
}, idleMs),
|
|
293
|
-
);
|
|
291
|
+
reveal(element);
|
|
294
292
|
},
|
|
295
293
|
// Passive for the same reason the input listeners are.
|
|
296
294
|
{ capture: true, passive: true },
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The DOM questions the scrollbar reveal rule asks, split from the rule itself
|
|
8
|
+
* so each file stays readable: WHICH element a scroll is about, WHICH element
|
|
9
|
+
* an input is aimed at, WHEN an event happened, and whether a key scrolls.
|
|
10
|
+
*
|
|
11
|
+
* Nothing here keeps state. `scrollbar-activity.ts` owns the listener, the arm
|
|
12
|
+
* and the fade timer; these are the pure answers it consults, kept separate so
|
|
13
|
+
* they can be reasoned about (and changed) without reading the gate.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** The element whose scrollbar the event describes. */
|
|
17
|
+
export function scrolledElement(target: EventTarget | null): Element | null {
|
|
18
|
+
if (target === document || target === window || target === null) {
|
|
19
|
+
// The viewport's own scroll: the bar that is painted belongs to the root
|
|
20
|
+
// element, not to the document the event names.
|
|
21
|
+
return document.documentElement;
|
|
22
|
+
}
|
|
23
|
+
return target instanceof Element ? target : null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* WHEN an event happened, on the one clock the arm is compared on.
|
|
28
|
+
*
|
|
29
|
+
* `Date.now()` read inside a handler is when the handler RAN, and the two are
|
|
30
|
+
* not the same moment: scroll events are coalesced and delivered at the next
|
|
31
|
+
* frame, so a main thread busy with a long task (a streamed markdown render, a
|
|
32
|
+
* 36 000px transcript re-layout) can delay delivery by hundreds of milliseconds.
|
|
33
|
+
* `Event.timeStamp` is stamped when the event is CREATED, which is what makes
|
|
34
|
+
* the arm's expiry mean "this input is old" rather than "this handler is late".
|
|
35
|
+
*
|
|
36
|
+
* Engines disagree about the scroll stamp — Chrome stamps at creation, WebKit
|
|
37
|
+
* at dispatch — so this clock cannot decide whether a scroll was the user's.
|
|
38
|
+
* That is why the gate is an ARM (did any input happen since the last reveal?)
|
|
39
|
+
* and not a gap: the arm only has to bound how stale an input may be, and both
|
|
40
|
+
* engines answer that.
|
|
41
|
+
*
|
|
42
|
+
* The fallback covers synthetic events and engines that report a non-positive
|
|
43
|
+
* stamp (`0` is what a hand-built `new Event('scroll')` carries). It answers
|
|
44
|
+
* `performance.now()` and not `Date.now()`: `Event.timeStamp` is a
|
|
45
|
+
* `DOMHighResTimeStamp`, so mixing in wall time would make the subtraction a
|
|
46
|
+
* difference of two different clocks — measured as a negative gap, which would
|
|
47
|
+
* make every programmatic scroll look armed.
|
|
48
|
+
*/
|
|
49
|
+
export function eventMoment(event: Event): number {
|
|
50
|
+
const stamp = event.timeStamp;
|
|
51
|
+
return Number.isFinite(stamp) && stamp > 0 ? stamp : performance.now();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The `overflow` values that make an element a surface the USER can scroll. */
|
|
55
|
+
const SCROLLABLE_OVERFLOW: Readonly<Record<string, true>> = { auto: true, scroll: true, overlay: true };
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The nearest ancestor of `target` that the user's input would scroll.
|
|
59
|
+
*
|
|
60
|
+
* This answers, at INPUT time, the question the `scroll` event answers a frame
|
|
61
|
+
* later — which is what lets the bar be painted the moment the wheel turns
|
|
62
|
+
* instead of after the scroll lands. `target` itself is checked first, since a
|
|
63
|
+
* wheel over a scroller's own padding targets the scroller.
|
|
64
|
+
*
|
|
65
|
+
* No fallback to the document: an input over an element that names no scroller
|
|
66
|
+
* leaves the page's own reveal to the `scroll` path (where the root element is
|
|
67
|
+
* known to be the painted surface). Returning the root here would light the
|
|
68
|
+
* page's bar for a wheel that moved a panel.
|
|
69
|
+
*/
|
|
70
|
+
export function nearestScroller(target: EventTarget | null): Element | null {
|
|
71
|
+
let node: Element | null = target instanceof Element ? target : null;
|
|
72
|
+
for (; node && node !== document.body; node = node.parentElement) {
|
|
73
|
+
// The size test runs first: a node that cannot overflow is not a scroll
|
|
74
|
+
// surface whatever its `overflow` says, and reading it costs no style pass.
|
|
75
|
+
if (node.scrollHeight <= node.clientHeight + 1 && node.scrollWidth <= node.clientWidth + 1) continue;
|
|
76
|
+
// Through the node's own window rather than the global: the same tree is
|
|
77
|
+
// mounted in a document this module did not capture, and `getComputedStyle`
|
|
78
|
+
// is not a global in every host that runs it (the unit tests included).
|
|
79
|
+
const view = node.ownerDocument?.defaultView;
|
|
80
|
+
if (!view) continue;
|
|
81
|
+
const style = view.getComputedStyle(node);
|
|
82
|
+
if (SCROLLABLE_OVERFLOW[style.overflowY] || SCROLLABLE_OVERFLOW[style.overflowX]) return node;
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The keys that scroll the focused surface (never a typing key). */
|
|
88
|
+
const SCROLL_KEYS: Readonly<Record<string, true>> = {
|
|
89
|
+
ArrowUp: true,
|
|
90
|
+
ArrowDown: true,
|
|
91
|
+
ArrowLeft: true,
|
|
92
|
+
ArrowRight: true,
|
|
93
|
+
PageUp: true,
|
|
94
|
+
PageDown: true,
|
|
95
|
+
Home: true,
|
|
96
|
+
End: true,
|
|
97
|
+
' ': true,
|
|
98
|
+
Spacebar: true,
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Whether an input happened INSIDE the container that scrolled.
|
|
103
|
+
*
|
|
104
|
+
* An arm is spent by the first scroll that follows it, which is what stops a
|
|
105
|
+
* stream from pinning a bar — but "first scroll anywhere" was too loose: a
|
|
106
|
+
* wheel that cannot move its container (already at the top) produces no scroll
|
|
107
|
+
* event, so its arm stayed unspent for the rest of its life and the next
|
|
108
|
+
* PROGRAMMATIC scroll in any other panel could spend it. Measured: wheel up at
|
|
109
|
+
* `scrollTop = 0`, then `scrollTop = 500` 250ms later, and the bar lit for a
|
|
110
|
+
* scroll nobody made.
|
|
111
|
+
*
|
|
112
|
+
* Binding the arm to the subtree the input happened in closes that without
|
|
113
|
+
* adding a layout read: `contains` is a tree walk, not a `getComputedStyle`,
|
|
114
|
+
* and the wheel's target is already the element under the pointer.
|
|
115
|
+
*
|
|
116
|
+
* An input that names the document or the window itself (a keydown with nothing
|
|
117
|
+
* focused) is deliberately NOT bound — the scroller it drives is the focused
|
|
118
|
+
* one, which no target reveals, so it keeps the unbound behaviour. `body` and
|
|
119
|
+
* the root element are the same case in practice: a keydown with nothing
|
|
120
|
+
* focused targets `body`, and MEASURED in Chromium and WebKit 27.2, PageDown
|
|
121
|
+
* there scrolls the panel the reader last clicked — a container `body` neither
|
|
122
|
+
* contains nor is contained by. Treating `body` as bound is what made keyboard
|
|
123
|
+
* scrolling reveal no bar at all.
|
|
124
|
+
*/
|
|
125
|
+
export function belongsTo(element: Element, inputTarget: EventTarget | null): boolean {
|
|
126
|
+
if (
|
|
127
|
+
inputTarget === null
|
|
128
|
+
|| inputTarget === document
|
|
129
|
+
|| inputTarget === window
|
|
130
|
+
|| inputTarget === document.body
|
|
131
|
+
|| inputTarget === document.documentElement
|
|
132
|
+
) {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
if (inputTarget === element) return true;
|
|
136
|
+
return inputTarget instanceof Node ? element.contains(inputTarget) : false;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Whether a key press is a scroll of the focused surface (never a typing key). */
|
|
140
|
+
export function isScrollKey(event: KeyboardEvent): boolean {
|
|
141
|
+
if (event.metaKey || event.ctrlKey || event.altKey) return false;
|
|
142
|
+
return SCROLL_KEYS[event.key] === true;
|
|
143
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { afterAll, afterEach, beforeAll, describe, expect, jest, test } from 'bun:test';
|
|
7
|
+
|
|
8
|
+
import { SCROLLBAR_ACTIVE_ATTRIBUTE } from '@/client/lib/scrollbar-activity';
|
|
9
|
+
import {
|
|
10
|
+
IDLE_MS,
|
|
11
|
+
freshPage,
|
|
12
|
+
inputAt,
|
|
13
|
+
keyAt,
|
|
14
|
+
restoreNativeGlobals,
|
|
15
|
+
saveNativeGlobals,
|
|
16
|
+
scrollAt,
|
|
17
|
+
scrollSurface,
|
|
18
|
+
scroller,
|
|
19
|
+
} from '@/client/lib/scrollbar-probe.test-util';
|
|
20
|
+
|
|
21
|
+
beforeAll(saveNativeGlobals);
|
|
22
|
+
afterAll(restoreNativeGlobals);
|
|
23
|
+
afterEach(() => {
|
|
24
|
+
jest.useRealTimers();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The bar appears the moment the reader scrolls.
|
|
29
|
+
*
|
|
30
|
+
* Every case here asserts paint WITHOUT a `scroll` event: the reveal is driven
|
|
31
|
+
* by the input itself, so these fail if the rule goes back to waiting for the
|
|
32
|
+
* frame the browser dispatches `scroll` on (the reported "the scrollbar does
|
|
33
|
+
* not show up immediately when I scroll"). Measured before this rule: the
|
|
34
|
+
* attribute landed 13-27ms after a wheel, on the scroll frame, and a scroll
|
|
35
|
+
* the gate declined painted nothing at all.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
describe('the scrollbar reveal on input', () => {
|
|
39
|
+
test('a wheel paints the surface it is over, before any scroll event', () => {
|
|
40
|
+
jest.useFakeTimers();
|
|
41
|
+
freshPage();
|
|
42
|
+
const box = scrollSurface();
|
|
43
|
+
|
|
44
|
+
// No `scrollAt()`: this is the whole point. The bar is painted by the
|
|
45
|
+
// input, not by a scroll event the browser dispatches a frame later (or
|
|
46
|
+
// never, when the gate declines it). Measured before this rule: the
|
|
47
|
+
// attribute landed 13-27ms after the wheel, i.e. on the scroll frame, and
|
|
48
|
+
// a scroll the gate refused painted nothing at all.
|
|
49
|
+
inputAt(box);
|
|
50
|
+
|
|
51
|
+
expect(box.hasAttribute(SCROLLBAR_ACTIVE_ATTRIBUTE)).toBe(true);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('a wheel over a child paints the scroller that holds it', () => {
|
|
55
|
+
jest.useFakeTimers();
|
|
56
|
+
freshPage();
|
|
57
|
+
const box = scrollSurface();
|
|
58
|
+
const row = document.createElement('p');
|
|
59
|
+
box.appendChild(row);
|
|
60
|
+
|
|
61
|
+
inputAt(row);
|
|
62
|
+
|
|
63
|
+
expect(box.hasAttribute(SCROLLBAR_ACTIVE_ATTRIBUTE)).toBe(true);
|
|
64
|
+
expect(row.hasAttribute(SCROLLBAR_ACTIVE_ATTRIBUTE)).toBe(false);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('a wheel over something that cannot scroll paints nothing', () => {
|
|
68
|
+
jest.useFakeTimers();
|
|
69
|
+
freshPage();
|
|
70
|
+
const plain = scroller();
|
|
71
|
+
|
|
72
|
+
inputAt(plain);
|
|
73
|
+
|
|
74
|
+
// The page's own reveal belongs to its `scroll` event, where the painted
|
|
75
|
+
// surface is the root element. Lighting it here would paint the page's bar
|
|
76
|
+
// for a wheel that moved nothing at all.
|
|
77
|
+
expect(plain.hasAttribute(SCROLLBAR_ACTIVE_ATTRIBUTE)).toBe(false);
|
|
78
|
+
expect(document.documentElement.hasAttribute(SCROLLBAR_ACTIVE_ATTRIBUTE)).toBe(false);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('every wheel of a gesture restarts the idle window', () => {
|
|
82
|
+
jest.useFakeTimers();
|
|
83
|
+
freshPage();
|
|
84
|
+
const box = scrollSurface();
|
|
85
|
+
|
|
86
|
+
inputAt(box);
|
|
87
|
+
jest.advanceTimersByTime(IDLE_MS - 100);
|
|
88
|
+
inputAt(box);
|
|
89
|
+
jest.advanceTimersByTime(IDLE_MS - 100);
|
|
90
|
+
|
|
91
|
+
// The user is STILL scrolling: a bar that faded here would disappear from
|
|
92
|
+
// under a hand that never stopped.
|
|
93
|
+
expect(box.hasAttribute(SCROLLBAR_ACTIVE_ATTRIBUTE)).toBe(true);
|
|
94
|
+
|
|
95
|
+
jest.advanceTimersByTime(100);
|
|
96
|
+
expect(box.hasAttribute(SCROLLBAR_ACTIVE_ATTRIBUTE)).toBe(false);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('a keyboard scroll reveals the surface the engine scrolled', () => {
|
|
100
|
+
jest.useFakeTimers();
|
|
101
|
+
freshPage();
|
|
102
|
+
const box = scroller();
|
|
103
|
+
|
|
104
|
+
// MEASURED in Chromium and WebKit 27.2: PageDown with nothing focused walks
|
|
105
|
+
// the focused scroll chain, so the keydown's target is `body` while the
|
|
106
|
+
// panel that moves is a sibling subtree. Binding the arm to `body` refused
|
|
107
|
+
// every keyboard scroll, so the bar never appeared for them.
|
|
108
|
+
keyAt('PageDown');
|
|
109
|
+
scrollAt(box);
|
|
110
|
+
|
|
111
|
+
expect(box.hasAttribute(SCROLLBAR_ACTIVE_ATTRIBUTE)).toBe(true);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('a key that cannot scroll does not arm a reveal', () => {
|
|
115
|
+
jest.useFakeTimers();
|
|
116
|
+
freshPage();
|
|
117
|
+
const box = scroller();
|
|
118
|
+
|
|
119
|
+
// Typing in the composer must not let a stream's next auto-follow paint a
|
|
120
|
+
// bar: the key says nothing about scrolling.
|
|
121
|
+
keyAt('a');
|
|
122
|
+
scrollAt(box);
|
|
123
|
+
|
|
124
|
+
expect(box.hasAttribute(SCROLLBAR_ACTIVE_ATTRIBUTE)).toBe(false);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The scaffolding both scrollbar suites mount against.
|
|
8
|
+
*
|
|
9
|
+
* Every case gets its OWN document and its own install, because the module is
|
|
10
|
+
* idempotent per document and its input clock is per install: a shared document
|
|
11
|
+
* would make every case inherit the previous one's wheel (and would make a
|
|
12
|
+
* `useFakeTimers` clock that restarts at real time read as recent input).
|
|
13
|
+
*
|
|
14
|
+
* Mounted against happy-dom, the same way the other client tests are.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { Window } from 'happy-dom';
|
|
18
|
+
import { SCROLLBAR_INPUT_ARM_MS, installScrollbarActivity } from '@/client/lib/scrollbar-activity';
|
|
19
|
+
|
|
20
|
+
const DOM_GLOBALS = [
|
|
21
|
+
'window',
|
|
22
|
+
'document',
|
|
23
|
+
'navigator',
|
|
24
|
+
'Node',
|
|
25
|
+
'Element',
|
|
26
|
+
'HTMLElement',
|
|
27
|
+
'Event',
|
|
28
|
+
'CustomEvent',
|
|
29
|
+
] as const;
|
|
30
|
+
|
|
31
|
+
/** Short enough to drive in a test, long enough that the two windows do not overlap. */
|
|
32
|
+
export const IDLE_MS = 1_000;
|
|
33
|
+
/** The production arm; its real value is what the gate is about. */
|
|
34
|
+
export const ARM_MS = SCROLLBAR_INPUT_ARM_MS;
|
|
35
|
+
|
|
36
|
+
/** The runner's own globals, restored on teardown so later files still see native Event/CustomEvent/window. */
|
|
37
|
+
const nativeGlobals: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
|
|
38
|
+
|
|
39
|
+
export function saveNativeGlobals(): void {
|
|
40
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
41
|
+
for (const key of DOM_GLOBALS) {
|
|
42
|
+
if (!(key in nativeGlobals)) nativeGlobals[key] = target[key];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function restoreNativeGlobals(): void {
|
|
47
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
48
|
+
for (const key of DOM_GLOBALS) {
|
|
49
|
+
if (nativeGlobals[key] === undefined) delete target[key];
|
|
50
|
+
else target[key] = nativeGlobals[key];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** A fresh document with the reveal rule installed on it. */
|
|
55
|
+
export function freshPage(): void {
|
|
56
|
+
const win = new Window({ url: 'http://localhost' });
|
|
57
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
58
|
+
for (const key of DOM_GLOBALS) target[key] = (win as unknown as Record<string, unknown>)[key];
|
|
59
|
+
installScrollbarActivity(IDLE_MS, ARM_MS);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** A scroll container in the live document. */
|
|
63
|
+
export function scroller(): HTMLElement {
|
|
64
|
+
const element = document.createElement('div');
|
|
65
|
+
document.body.appendChild(element);
|
|
66
|
+
return element;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A container that MEASURES as scrollable.
|
|
71
|
+
*
|
|
72
|
+
* happy-dom lays nothing out, so every `scrollHeight`/`clientHeight` is 0 and
|
|
73
|
+
* the "can this overflow" test the input path uses would skip every node. The
|
|
74
|
+
* numbers are what Chromium reports for the same DOM shape.
|
|
75
|
+
*/
|
|
76
|
+
export function scrollSurface(): HTMLElement {
|
|
77
|
+
const element = document.createElement('div');
|
|
78
|
+
element.style.overflowY = 'auto';
|
|
79
|
+
Object.defineProperties(element, {
|
|
80
|
+
scrollHeight: { value: 900, configurable: true },
|
|
81
|
+
clientHeight: { value: 300, configurable: true },
|
|
82
|
+
scrollWidth: { value: 100, configurable: true },
|
|
83
|
+
clientWidth: { value: 100, configurable: true },
|
|
84
|
+
});
|
|
85
|
+
document.body.appendChild(element);
|
|
86
|
+
return element;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The event a browser dispatches at a scroller — it does not bubble. */
|
|
90
|
+
export function scrollAt(element: Element): void {
|
|
91
|
+
element.dispatchEvent(new Event('scroll'));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The input a browser delivers before a scroll the USER caused.
|
|
95
|
+
*
|
|
96
|
+
* Dispatched ON the scroller, because that is what a wheel does: it is targeted
|
|
97
|
+
* at the element under the pointer, and the arm is bound to that subtree so a
|
|
98
|
+
* wheel that could not move its container cannot later vouch for a programmatic
|
|
99
|
+
* scroll somewhere else. */
|
|
100
|
+
export function inputAt(element: Element = document.body): void {
|
|
101
|
+
element.dispatchEvent(new Event('wheel'));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** The keydown a browser delivers when the reader presses a scrolling key. */
|
|
105
|
+
export function keyAt(key: string): void {
|
|
106
|
+
document.body.dispatchEvent(new window.KeyboardEvent('keydown', { key, bubbles: true }));
|
|
107
|
+
}
|
package/src/client/tailwind.css
CHANGED
|
@@ -372,6 +372,36 @@
|
|
|
372
372
|
background-color: color-mix(in srgb, var(--theme-error) 75%, var(--theme-ink));
|
|
373
373
|
}
|
|
374
374
|
|
|
375
|
+
/* MONOCHROME: the composer's action pair (Stop / Send) is INK, not red/blue.
|
|
376
|
+
*
|
|
377
|
+
* The pair differs by hue in the colour mode — `bg-error-text` against
|
|
378
|
+
* `bg-info-text` — because that mode is the one place a user asks for chroma.
|
|
379
|
+
* Monochrome is the DEFAULT and it states itself as "every icon in the palette
|
|
380
|
+
* ink" (`icon-paint-ink.ts`), so two filled signal buttons were the only
|
|
381
|
+
* saturated objects left in a window that said it had no colour; reported as
|
|
382
|
+
* "btn send dan btn stop di mode monochrome kenapa masih berwarna?".
|
|
383
|
+
*
|
|
384
|
+
* The fill follows the app's own inverted surface (`bg-ink text-canvas`, used by
|
|
385
|
+
* every primary button), so the pair keeps the same geometry and the glyph's
|
|
386
|
+
* `text-canvas` stays the house pair — the palette's ink/canvas relationship,
|
|
387
|
+
* which is the one every body text already relies on.
|
|
388
|
+
*
|
|
389
|
+
* These rules are UNLAYERED and scoped to `:root:not([data-icon-style="color"])`
|
|
390
|
+
* for two reasons: a rule inside `@layer utilities` would sit at the same layer
|
|
391
|
+
* as the caller's `bg-info-text` and win only by source order, and the
|
|
392
|
+
* `:not(:disabled)` on hover keeps a disabled Send from re-stating the colour
|
|
393
|
+
* fill it was just moved off. The glyph itself is already handled by
|
|
394
|
+
* `monochromeSolidFillRules`, which keys on the very `bg-info-text` /
|
|
395
|
+
* `bg-error-text` classes this rule repaints.
|
|
396
|
+
*/
|
|
397
|
+
:root:not([data-icon-style="color"]) .composer-action {
|
|
398
|
+
background-color: var(--theme-ink);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
:root:not([data-icon-style="color"]) .composer-action:hover:not(:disabled) {
|
|
402
|
+
background-color: color-mix(in srgb, var(--theme-ink) 90%, transparent);
|
|
403
|
+
}
|
|
404
|
+
|
|
375
405
|
/* (The hero card's dot-grain texture lived here and was used by nothing: the
|
|
376
406
|
deploy hero it decorated is not part of this product. A texture with no
|
|
377
407
|
consumer is a rule that only drifts.) */
|
|
@@ -396,7 +426,8 @@
|
|
|
396
426
|
* The thumb is TRANSPARENT at rest and painted only while the user is
|
|
397
427
|
* scrolling that element. `installScrollbarActivity()` (see
|
|
398
428
|
* `src/client/lib/scrollbar-activity.ts`) puts `data-scrollbar-active` on the
|
|
399
|
-
* scroller itself
|
|
429
|
+
* scroller itself: on the input that starts a scroll, and again on each of its
|
|
430
|
+
* own `scroll` events, keeping it there for 5s after the last one. This
|
|
400
431
|
* stylesheet is the other half of that contract: a global `scroll` listener is
|
|
401
432
|
* one listener for every scroll container in the document, including ones that
|
|
402
433
|
* do not exist yet, which is why no component has to opt in.
|
|
@@ -200,7 +200,9 @@ describe('closeDb', () => {
|
|
|
200
200
|
// slot while `getDb()` was still opening, so the continuation assigned
|
|
201
201
|
// `resolved` on the DROPPED slot object. Nothing could reach that handle
|
|
202
202
|
// again, and on Windows its temp directory stayed locked — `EBUSY … a
|
|
203
|
-
// handle outlived its test`, reported against the two PRECEDING cases.
|
|
203
|
+
// handle outlived its test`, reported against the two PRECEDING cases. A
|
|
204
|
+
// retirement in this window never reaches `createDb`; the `disposed` check
|
|
205
|
+
// after it still closes a handle retired DURING initialisation.
|
|
204
206
|
const savedSlot = globalThis.__kabmoDb;
|
|
205
207
|
try {
|
|
206
208
|
Bun.env.KABMO_DB_PATH = path.join(tempRoot(), 'in-flight', 'db.sqlite');
|
|
@@ -244,6 +246,53 @@ describe('closeDb', () => {
|
|
|
244
246
|
}
|
|
245
247
|
});
|
|
246
248
|
|
|
249
|
+
test('an open uses the path configured when it was requested', async () => {
|
|
250
|
+
// A fire-and-forget `getDb()` can still be resolving while its suite tears
|
|
251
|
+
// down and deletes `KABMO_DB_PATH`. Re-reading the environment at resolution
|
|
252
|
+
// time then opens the DEFAULT path — the developer's real database — so the
|
|
253
|
+
// path is snapshotted when the open is requested.
|
|
254
|
+
const savedSlot = globalThis.__kabmoDb;
|
|
255
|
+
try {
|
|
256
|
+
const requested = path.join(tempRoot(), 'snapshot', 'db.sqlite');
|
|
257
|
+
Bun.env.KABMO_DB_PATH = requested;
|
|
258
|
+
globalThis.__kabmoDb = undefined;
|
|
259
|
+
|
|
260
|
+
const pending = getDb();
|
|
261
|
+
// The teardown that used to redirect this open.
|
|
262
|
+
delete Bun.env.KABMO_DB_PATH;
|
|
263
|
+
|
|
264
|
+
const db = await pending;
|
|
265
|
+
expect(existsSync(requested)).toBe(true);
|
|
266
|
+
await closeDb();
|
|
267
|
+
expect(db).toBeDefined();
|
|
268
|
+
} finally {
|
|
269
|
+
globalThis.__kabmoDb = savedSlot;
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
test('a retired open never creates the file it would have opened', async () => {
|
|
274
|
+
// The leak this pins: an open still resolving its path while the slot is
|
|
275
|
+
// retired used to reach `createDb` and leave a database file behind, then
|
|
276
|
+
// close it and reject. A fire-and-forget caller whose suite had already
|
|
277
|
+
// restored its environment resolved the DEFAULT path, so the file it
|
|
278
|
+
// created was the developer's real `~/.kabmo/db.sqlite` (measured on a full
|
|
279
|
+
// `bun test`, from an ACP child-outcome write finishing after teardown).
|
|
280
|
+
const savedSlot = globalThis.__kabmoDb;
|
|
281
|
+
try {
|
|
282
|
+
const dbPath = path.join(tempRoot(), 'never-opened', 'db.sqlite');
|
|
283
|
+
Bun.env.KABMO_DB_PATH = dbPath;
|
|
284
|
+
globalThis.__kabmoDb = undefined;
|
|
285
|
+
|
|
286
|
+
const pending = getDb();
|
|
287
|
+
await closeDb();
|
|
288
|
+
|
|
289
|
+
await expect(pending).rejects.toThrow(/retired/);
|
|
290
|
+
expect(existsSync(dbPath)).toBe(false);
|
|
291
|
+
} finally {
|
|
292
|
+
globalThis.__kabmoDb = savedSlot;
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
|
|
247
296
|
test('the returned promise settles only once the in-flight handle is closed', async () => {
|
|
248
297
|
// The bug this pins is a RACE, and it is the one the Release gate hit:
|
|
249
298
|
// retiring the slot is synchronous, but an open already in flight still
|