@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
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
createEditorHarness,
|
|
20
20
|
freshState,
|
|
21
21
|
stubFetch,
|
|
22
|
+
stubHash,
|
|
22
23
|
} from '@/test-support/file-editor.test-util';
|
|
23
24
|
|
|
24
25
|
const editor = createEditorHarness();
|
|
@@ -73,6 +74,9 @@ describe('useFileEditor revalidation', () => {
|
|
|
73
74
|
|
|
74
75
|
await editor.mount();
|
|
75
76
|
expect(editor.mounted?.isLoading).toBe(true);
|
|
77
|
+
// The reload glyph is about RE-reads; the opening read is already reported
|
|
78
|
+
// by `isLoading`, so both must not spin it.
|
|
79
|
+
expect(editor.mounted?.isReading).toBe(false);
|
|
76
80
|
expect(editor.mounted?.loaded).toBe(false);
|
|
77
81
|
|
|
78
82
|
release();
|
|
@@ -82,6 +86,33 @@ describe('useFileEditor revalidation', () => {
|
|
|
82
86
|
expect(editor.mounted?.content).toBe(DISK);
|
|
83
87
|
});
|
|
84
88
|
|
|
89
|
+
// The manual "Reload from disk" re-reads content that is already on screen,
|
|
90
|
+
// where `isLoading` deliberately stays false (a spinner over live content is
|
|
91
|
+
// the bug it prevents) — so the toolbar's reload glyph had nothing to spin
|
|
92
|
+
// for. `isReading` is that signal, and only for a re-read.
|
|
93
|
+
test('a re-read reports isReading and never isLoading', async () => {
|
|
94
|
+
const state = freshState();
|
|
95
|
+
stubFetch(state);
|
|
96
|
+
await editor.mount();
|
|
97
|
+
expect(editor.mounted?.isReading).toBe(false);
|
|
98
|
+
|
|
99
|
+
let release: () => void = () => {};
|
|
100
|
+
const gate = new Promise<void>((resolve) => { release = resolve; });
|
|
101
|
+
const realFetch = globalThis.fetch;
|
|
102
|
+
globalThis.fetch = (async (input: string | URL | Request, init?: RequestInit) => {
|
|
103
|
+
await gate;
|
|
104
|
+
return realFetch(input, init);
|
|
105
|
+
}) as typeof fetch;
|
|
106
|
+
|
|
107
|
+
await editor.run(() => editor.mounted?.reset());
|
|
108
|
+
expect(editor.mounted?.isReading).toBe(true);
|
|
109
|
+
expect(editor.mounted?.isLoading).toBe(false);
|
|
110
|
+
|
|
111
|
+
release();
|
|
112
|
+
await editor.settle();
|
|
113
|
+
expect(editor.mounted?.isReading).toBe(false);
|
|
114
|
+
});
|
|
115
|
+
|
|
85
116
|
// A textarea's API value drops every CR, so a CRLF file reaches the buffer as
|
|
86
117
|
// LF — and multipart/form-data turns a bare LF back into CRLF, so the payload
|
|
87
118
|
// cannot carry the ending. The file's own ending therefore travels as its own
|
|
@@ -118,6 +149,95 @@ describe('useFileEditor revalidation', () => {
|
|
|
118
149
|
});
|
|
119
150
|
});
|
|
120
151
|
|
|
152
|
+
describe('useFileEditor auto-refresh', () => {
|
|
153
|
+
/**
|
|
154
|
+
* Ask the watcher now, the way coming back to the window does.
|
|
155
|
+
*
|
|
156
|
+
* The probe is a promise, so the whole turn runs inside `act` (`runAsync`): a
|
|
157
|
+
* verdict delivered outside it updates state without committing the effects,
|
|
158
|
+
* and the re-read under test is an effect.
|
|
159
|
+
*/
|
|
160
|
+
async function focusWindow() {
|
|
161
|
+
await editor.runAsync(async () => {
|
|
162
|
+
window.dispatchEvent(new Event('focus'));
|
|
163
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
test('a file changed from outside replaces a CLEAN buffer', async () => {
|
|
168
|
+
const state = freshState();
|
|
169
|
+
stubFetch(state);
|
|
170
|
+
await editor.mount();
|
|
171
|
+
expect(editor.mounted?.content).toBe(DISK);
|
|
172
|
+
|
|
173
|
+
// Another process (an agent's tool call, `git checkout`) rewrote the file.
|
|
174
|
+
state.body = `${DISK}const c = 3;\n`;
|
|
175
|
+
await focusWindow();
|
|
176
|
+
|
|
177
|
+
expect(editor.mounted?.content).toBe(state.body);
|
|
178
|
+
expect(editor.mounted?.isDirty).toBe(false);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test('a file rewritten with the SAME bytes does not touch the buffer', async () => {
|
|
182
|
+
const state = freshState();
|
|
183
|
+
stubFetch(state);
|
|
184
|
+
await editor.mount();
|
|
185
|
+
const readsAfterMount = state.reads;
|
|
186
|
+
|
|
187
|
+
// A `touch`, a formatter that changed nothing, a checkout of the revision
|
|
188
|
+
// already open: the mtime moved, the bytes did not.
|
|
189
|
+
await focusWindow();
|
|
190
|
+
|
|
191
|
+
expect(state.reads).toBe(readsAfterMount);
|
|
192
|
+
expect(editor.mounted?.content).toBe(DISK);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
test('a DIRTY buffer is never replaced — the panel is told instead', async () => {
|
|
196
|
+
const state = freshState();
|
|
197
|
+
stubFetch(state);
|
|
198
|
+
await editor.mount();
|
|
199
|
+
|
|
200
|
+
editor.mounted?.onChange('my own edit');
|
|
201
|
+
await editor.settle();
|
|
202
|
+
|
|
203
|
+
state.body = `${DISK}const c = 3;\n`;
|
|
204
|
+
await focusWindow();
|
|
205
|
+
|
|
206
|
+
expect(editor.mounted?.content).toBe('my own edit');
|
|
207
|
+
expect(editor.mounted?.isDirty).toBe(true);
|
|
208
|
+
// The panel is told, so the external-change strip can offer the two answers.
|
|
209
|
+
expect(editor.mounted?.diskChange?.hash).toBe(stubHash(state.body));
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
test('reloadFromDisk re-reads a clean buffer on demand', async () => {
|
|
213
|
+
const state = freshState();
|
|
214
|
+
stubFetch(state);
|
|
215
|
+
await editor.mount();
|
|
216
|
+
const readsAfterMount = state.reads;
|
|
217
|
+
|
|
218
|
+
state.body = `${DISK}const c = 3;\n`;
|
|
219
|
+
await editor.run(() => editor.mounted?.reloadFromDisk());
|
|
220
|
+
await editor.settle();
|
|
221
|
+
|
|
222
|
+
expect(state.reads).toBe(readsAfterMount + 1);
|
|
223
|
+
expect(editor.mounted?.content).toBe(state.body);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
test('reloadFromDisk discards a dirty buffer', async () => {
|
|
227
|
+
const state = freshState();
|
|
228
|
+
stubFetch(state);
|
|
229
|
+
await editor.mount();
|
|
230
|
+
|
|
231
|
+
editor.mounted?.onChange('my own edit');
|
|
232
|
+
await editor.settle();
|
|
233
|
+
await editor.run(() => editor.mounted?.reloadFromDisk());
|
|
234
|
+
await editor.settle();
|
|
235
|
+
|
|
236
|
+
expect(editor.mounted?.content).toBe(DISK);
|
|
237
|
+
expect(editor.mounted?.isDirty).toBe(false);
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
|
|
121
241
|
describe('useFileEditor unsupported files', () => {
|
|
122
242
|
test('a kind refusal reports the server sentence as unsupported', async () => {
|
|
123
243
|
const state = freshState();
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks';
|
|
2
2
|
import { getLanguageFromPath } from '@/shared/lib/code/language';
|
|
3
3
|
import { resolveViewer } from '@/client/hooks/editor/resolve-viewer';
|
|
4
|
-
import {
|
|
5
|
-
import { retainKeys } from '@/client/hooks/editor/save-file';
|
|
4
|
+
import { toDiskText, toLf, type LineEnding } from '@/shared/lib/code/line-endings';
|
|
6
5
|
import { deviceFileFor } from '@/client/lib/launch/device-files';
|
|
7
6
|
import { fileHandleFor } from '@/client/lib/launch/file-handlers';
|
|
8
7
|
import { useFileRead } from '@/client/hooks/editor/use-file-read';
|
|
9
8
|
import { useFileTransfer } from '@/client/hooks/editor/use-file-transfer';
|
|
10
9
|
import { useFileWrites } from '@/client/hooks/editor/use-file-writes';
|
|
11
10
|
import { useWriteConflict } from '@/client/hooks/editor/use-write-conflict';
|
|
11
|
+
import { useDiskSync } from '@/client/hooks/editor/use-disk-sync';
|
|
12
|
+
import { useFileCache } from '@/client/hooks/editor/use-file-cache';
|
|
13
|
+
import { editorTargetKey as targetKey } from '@/client/hooks/editor/target-key';
|
|
12
14
|
import type { FileEditorSaveStatus, FileEditorTarget, UseFileEditorOptions, UseFileEditorResult } from '@/client/hooks/editor/file-editor-types';
|
|
13
15
|
|
|
14
16
|
export type { FileEditorSaveStatus, FileEditorTarget, UseFileEditorOptions, UseFileEditorResult } from '@/client/hooks/editor/file-editor-types';
|
|
15
17
|
|
|
16
|
-
function targetKey(target: FileEditorTarget): string {
|
|
17
|
-
return String(target.id ?? target.path ?? target.name);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
18
|
/**
|
|
21
19
|
* Owns the file-editing contract shared by the desktop editor and the phone's
|
|
22
20
|
* full-screen editor: read, debounced FormData save, copy, download, dirty
|
|
@@ -52,7 +50,25 @@ export function useFileEditor(
|
|
|
52
50
|
* inline attachment, a handle-backed file, or a read that failed.
|
|
53
51
|
*/
|
|
54
52
|
const [mtimes, setMtimes] = useState<Record<string, number | null>>({});
|
|
53
|
+
/**
|
|
54
|
+
* The content hash of the bytes each cached file was read at (or last wrote).
|
|
55
|
+
*
|
|
56
|
+
* The auto-refresh watcher compares the disk against it, so a file rewritten
|
|
57
|
+
* with identical bytes — a checkout of the revision already open, a formatter
|
|
58
|
+
* that changes nothing, a `touch` — never replaces a buffer. `null` means "no
|
|
59
|
+
* fingerprint": an inline attachment, a failed read, a file too large for the
|
|
60
|
+
* digest, or a handle-backed write (nothing to hash against).
|
|
61
|
+
*/
|
|
62
|
+
const [hashes, setHashes] = useState<Record<string, string | null>>({});
|
|
55
63
|
const [saveStatus, setSaveStatus] = useState<FileEditorSaveStatus>('idle');
|
|
64
|
+
/**
|
|
65
|
+
* Files whose BINARY document (a workbook) holds unsaved edits.
|
|
66
|
+
*
|
|
67
|
+
* Kept beside the text caches rather than inside them because the value is a
|
|
68
|
+
* flag, not a buffer: the edited workbook itself lives in the viewer's draft
|
|
69
|
+
* store, and this set is what the tab strip and the close guard read.
|
|
70
|
+
*/
|
|
71
|
+
const [binaryDirtyKeys, setBinaryDirtyKeys] = useState<ReadonlySet<string>>(() => new Set());
|
|
56
72
|
/** Bumped by `reset()` to re-run the read effect for the active file. */
|
|
57
73
|
const [revision, setRevision] = useState(0);
|
|
58
74
|
|
|
@@ -60,20 +76,21 @@ export function useFileEditor(
|
|
|
60
76
|
// An inline `content` (attachment chip) can carry CRLF too, and the buffer it
|
|
61
77
|
// feeds is LF-only — normalizing here keeps `isDirty` comparing like with like.
|
|
62
78
|
const content = target ? (contents[key] ?? (target.content !== undefined ? toLf(target.content) : '')) : '';
|
|
63
|
-
const
|
|
79
|
+
const textDirty = content !== (baselines[key] ?? content);
|
|
80
|
+
const isDirty = textDirty || binaryDirtyKeys.has(key);
|
|
64
81
|
/**
|
|
65
82
|
* The dirty set, derived from the two caches rather than tracked separately:
|
|
66
83
|
* a second copy would be a second thing to keep in step, and the comparison is
|
|
67
84
|
* a string identity check per open buffer.
|
|
68
85
|
*/
|
|
69
86
|
const dirtyKeys = useMemo(() => {
|
|
70
|
-
const next = new Set<string>();
|
|
87
|
+
const next = new Set<string>(binaryDirtyKeys);
|
|
71
88
|
for (const [bufferKey, text] of Object.entries(contents)) {
|
|
72
89
|
const baseline = baselines[bufferKey];
|
|
73
90
|
if (baseline !== undefined && text !== baseline) next.add(bufferKey);
|
|
74
91
|
}
|
|
75
92
|
return next;
|
|
76
|
-
}, [contents, baselines]);
|
|
93
|
+
}, [contents, baselines, binaryDirtyKeys]);
|
|
77
94
|
|
|
78
95
|
// The viewer, its bytes and the image URL — see `resolve-viewer.ts` for the
|
|
79
96
|
// three rules this derivation encodes (the kind comes from the path; a
|
|
@@ -84,6 +101,8 @@ export function useFileEditor(
|
|
|
84
101
|
// duplicate fetch while the first one is still in flight.
|
|
85
102
|
const loadedRef = useRef<Set<string>>(new Set());
|
|
86
103
|
const pendingRef = useRef<{ timer: number; file: FileEditorTarget; content: string } | null>(null);
|
|
104
|
+
/** Reads on their way — see `useFileRead`. */
|
|
105
|
+
const readingRef = useRef(0);
|
|
87
106
|
|
|
88
107
|
// Live mirrors of the content maps: a read response resolves long after it
|
|
89
108
|
// was requested, and it has to know whether the buffer it read is still the
|
|
@@ -98,23 +117,30 @@ export function useFileEditor(
|
|
|
98
117
|
lineEndingsRef.current = lineEndings;
|
|
99
118
|
const mtimesRef = useRef(mtimes);
|
|
100
119
|
mtimesRef.current = mtimes;
|
|
120
|
+
const hashesRef = useRef(hashes);
|
|
121
|
+
hashesRef.current = hashes;
|
|
101
122
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
123
|
+
/**
|
|
124
|
+
* The cache's lifecycle (refresh everything, drop closed tabs, switch the saved
|
|
125
|
+
* ending) lives in its own hook — see `use-file-cache.ts` for why the five caches
|
|
126
|
+
* must move together.
|
|
127
|
+
*/
|
|
128
|
+
const { remember, reset, retain, setEol } = useFileCache({
|
|
129
|
+
target,
|
|
130
|
+
loadedRef,
|
|
131
|
+
bumpRevision: () => setRevision((prev) => prev + 1),
|
|
132
|
+
setContents,
|
|
133
|
+
setBaselines,
|
|
134
|
+
setLineEndings,
|
|
135
|
+
setMtimes,
|
|
136
|
+
setHashes,
|
|
137
|
+
});
|
|
112
138
|
|
|
113
139
|
/**
|
|
114
140
|
* The read path lives in its own hook — see `use-file-read.ts` for the two
|
|
115
141
|
* flags it reports and why the kind refusal is separate from a failed read.
|
|
116
142
|
*/
|
|
117
|
-
const { isLoading, loadError, unsupported } = useFileRead({
|
|
143
|
+
const { isLoading, isReading, loadError, unsupported } = useFileRead({
|
|
118
144
|
target,
|
|
119
145
|
key,
|
|
120
146
|
isBinaryViewer,
|
|
@@ -123,6 +149,7 @@ export function useFileEditor(
|
|
|
123
149
|
contentsRef,
|
|
124
150
|
baselinesRef,
|
|
125
151
|
pendingRef,
|
|
152
|
+
readingRef,
|
|
126
153
|
remember,
|
|
127
154
|
});
|
|
128
155
|
|
|
@@ -145,9 +172,15 @@ export function useFileEditor(
|
|
|
145
172
|
pendingRef,
|
|
146
173
|
flushOnUnmount,
|
|
147
174
|
onSaveStart: () => setSaveStatus('saving'),
|
|
148
|
-
onSaved: (fileKey, text) => {
|
|
175
|
+
onSaved: (fileKey, text, written) => {
|
|
149
176
|
setSaveStatus('saved');
|
|
150
177
|
setBaselines((prev) => ({ ...prev, [fileKey]: text }));
|
|
178
|
+
// Adopt what the server reported about the bytes it just wrote: the mtime
|
|
179
|
+
// is the next save's conflict base, and the hash is the auto-refresh
|
|
180
|
+
// baseline. Without them the watcher would read the user's own save as an
|
|
181
|
+
// external change, and the next save would be refused against its base.
|
|
182
|
+
if (written.mtimeMs !== null) setMtimes((prev) => ({ ...prev, [fileKey]: written.mtimeMs }));
|
|
183
|
+
if (written.hash !== null) setHashes((prev) => ({ ...prev, [fileKey]: written.hash }));
|
|
151
184
|
onFileSaved?.();
|
|
152
185
|
},
|
|
153
186
|
onSaveFailed: () => setSaveStatus(reportSaveError ? 'error' : 'idle'),
|
|
@@ -186,6 +219,48 @@ export function useFileEditor(
|
|
|
186
219
|
bumpRevision: () => setRevision((prev) => prev + 1),
|
|
187
220
|
});
|
|
188
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Drop the debounced write for `fileKey`, if one is armed.
|
|
224
|
+
*
|
|
225
|
+
* A Reload throws the buffer away, so the write that buffer had queued must go
|
|
226
|
+
* with it — and the read path yields to a queued write, so leaving it armed
|
|
227
|
+
* would also make the reload land nowhere.
|
|
228
|
+
*/
|
|
229
|
+
const discardPendingWrite = useCallback((fileKey: string) => {
|
|
230
|
+
const queued = pendingRef.current;
|
|
231
|
+
if (!queued || targetKey(queued.file) !== fileKey) return;
|
|
232
|
+
window.clearTimeout(queued.timer);
|
|
233
|
+
pendingRef.current = null;
|
|
234
|
+
}, []);
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* The disk watcher and the answers it produces — one cluster, in its own hook
|
|
238
|
+
* (see `use-disk-sync.ts`): a clean buffer follows the disk, a dirty one is
|
|
239
|
+
* never replaced, and a file that still hashes the same is not a change.
|
|
240
|
+
*
|
|
241
|
+
* The conflict machine is passed in rather than imported there so "adopt the
|
|
242
|
+
* mtime" and "discard and re-read" stay the SAME implementations the strips
|
|
243
|
+
* call; a second copy is how one of them refuses a save the other accepted.
|
|
244
|
+
*/
|
|
245
|
+
const { diskChange, reloadFromDisk, keepMineAgainstDisk } = useDiskSync({
|
|
246
|
+
key,
|
|
247
|
+
target,
|
|
248
|
+
baseHash: hashes[key] ?? null,
|
|
249
|
+
revision,
|
|
250
|
+
hashesRef,
|
|
251
|
+
mtimesRef,
|
|
252
|
+
contentsRef,
|
|
253
|
+
baselinesRef,
|
|
254
|
+
pendingRef,
|
|
255
|
+
readingRef,
|
|
256
|
+
loadedRef,
|
|
257
|
+
bumpRevision: () => setRevision((prev) => prev + 1),
|
|
258
|
+
adoptDiskMtime: conflictState.adopt,
|
|
259
|
+
clearConflict: conflictState.clear,
|
|
260
|
+
reloadDiscardingEdits: conflictState.reload,
|
|
261
|
+
discardPendingWrite,
|
|
262
|
+
});
|
|
263
|
+
|
|
189
264
|
useEffect(() => {
|
|
190
265
|
if (saveStatus !== 'saved') return;
|
|
191
266
|
const timer = window.setTimeout(() => setSaveStatus('idle'), 1500);
|
|
@@ -199,6 +274,43 @@ export function useFileEditor(
|
|
|
199
274
|
setSaveStatus('idle');
|
|
200
275
|
}, [key]);
|
|
201
276
|
|
|
277
|
+
const setBinaryDirty = useCallback(
|
|
278
|
+
(dirty: boolean) => {
|
|
279
|
+
if (!target) return;
|
|
280
|
+
const fileKey = targetKey(target);
|
|
281
|
+
setBinaryDirtyKeys((previous) => {
|
|
282
|
+
if (previous.has(fileKey) === dirty) return previous;
|
|
283
|
+
const next = new Set(previous);
|
|
284
|
+
if (dirty) next.add(fileKey);
|
|
285
|
+
else next.delete(fileKey);
|
|
286
|
+
return next;
|
|
287
|
+
});
|
|
288
|
+
},
|
|
289
|
+
[target],
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* `retain` also drops the binary flags of tabs that are no longer open: a
|
|
294
|
+
* closed tab's flag would otherwise keep the close guard armed for a file
|
|
295
|
+
* that is not on screen.
|
|
296
|
+
*/
|
|
297
|
+
const retainAll = useCallback(
|
|
298
|
+
(ids: Array<number | string>) => {
|
|
299
|
+
retain(ids);
|
|
300
|
+
const keep = new Set(ids.map(String));
|
|
301
|
+
setBinaryDirtyKeys((previous) => {
|
|
302
|
+
let changed = false;
|
|
303
|
+
const next = new Set<string>();
|
|
304
|
+
for (const fileKey of previous) {
|
|
305
|
+
if (keep.has(fileKey)) next.add(fileKey);
|
|
306
|
+
else changed = true;
|
|
307
|
+
}
|
|
308
|
+
return changed ? next : previous;
|
|
309
|
+
});
|
|
310
|
+
},
|
|
311
|
+
[retain],
|
|
312
|
+
);
|
|
313
|
+
|
|
202
314
|
const onChange = useCallback(
|
|
203
315
|
(next: string) => {
|
|
204
316
|
if (!target || isBinaryViewer) return;
|
|
@@ -225,40 +337,12 @@ export function useFileEditor(
|
|
|
225
337
|
byteViewer: isBinaryViewer,
|
|
226
338
|
});
|
|
227
339
|
|
|
228
|
-
const reset = useCallback(() => {
|
|
229
|
-
// Invalidate every key, then let the read effect refetch the active one.
|
|
230
|
-
// Content is deliberately NOT cleared: it stays on screen until the fresh
|
|
231
|
-
// bytes land, so a refresh can never blank the editor (or drop the file
|
|
232
|
-
// that is open) while the request is in flight.
|
|
233
|
-
loadedRef.current.clear();
|
|
234
|
-
setRevision((prev) => prev + 1);
|
|
235
|
-
}, []);
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Switch the ending this buffer saves in.
|
|
239
|
-
*
|
|
240
|
-
* Only the ending moves: the BUFFER is LF-only either way, and the bytes are built
|
|
241
|
-
* at write time, so nothing on screen changes and no re-read is needed.
|
|
242
|
-
*/
|
|
243
|
-
const setEol = useCallback((next: LineEnding) => {
|
|
244
|
-
if (!target) return;
|
|
245
|
-
setLineEndings((prev) => ({ ...prev, [targetKey(target)]: next }));
|
|
246
|
-
}, [target]);
|
|
247
|
-
|
|
248
|
-
const retain = useCallback((ids: Array<number | string>) => {
|
|
249
|
-
const keep = new Set(ids.map(String));
|
|
250
|
-
for (const loaded of Array.from(loadedRef.current)) {
|
|
251
|
-
if (!keep.has(loaded)) loadedRef.current.delete(loaded);
|
|
252
|
-
}
|
|
253
|
-
setContents((prev) => retainKeys(prev, keep));
|
|
254
|
-
setLineEndings((prev) => retainKeys(prev, keep));
|
|
255
|
-
setMtimes((prev) => retainKeys(prev, keep));
|
|
256
|
-
}, []);
|
|
257
340
|
|
|
258
341
|
return {
|
|
259
342
|
content,
|
|
260
343
|
onChange,
|
|
261
344
|
isLoading,
|
|
345
|
+
isReading,
|
|
262
346
|
// A byte viewer has no buffer to wait for, and inline content is already in
|
|
263
347
|
// hand; otherwise the key's entry exists only once the read resolved.
|
|
264
348
|
loaded: target ? isBinaryViewer || target.content !== undefined || contents[key] !== undefined : false,
|
|
@@ -267,6 +351,7 @@ export function useFileEditor(
|
|
|
267
351
|
saveStatus,
|
|
268
352
|
copied,
|
|
269
353
|
isDirty,
|
|
354
|
+
setBinaryDirty,
|
|
270
355
|
eol: lineEndings[key] ?? 'lf',
|
|
271
356
|
setEol,
|
|
272
357
|
baseMtimeMs: mtimes[key] ?? null,
|
|
@@ -288,17 +373,18 @@ export function useFileEditor(
|
|
|
288
373
|
copy,
|
|
289
374
|
download,
|
|
290
375
|
reset,
|
|
291
|
-
retain,
|
|
376
|
+
retain: retainAll,
|
|
292
377
|
saveMissingConfirm: writes.saveMissingConfirm,
|
|
293
378
|
confirmSaveMissing: writes.confirmSaveMissing,
|
|
294
379
|
cancelSaveMissing: writes.cancelSaveMissing,
|
|
295
380
|
conflict: conflictState.conflict,
|
|
296
|
-
resolveConflictByReload:
|
|
381
|
+
resolveConflictByReload: () => {
|
|
382
|
+
if (key) discardPendingWrite(key);
|
|
383
|
+
conflictState.reload();
|
|
384
|
+
},
|
|
297
385
|
resolveConflictByKeepingMine: conflictState.keepMine,
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
revertToDisk: conflictState.reload,
|
|
302
|
-
adoptDiskMtime: conflictState.adopt,
|
|
386
|
+
reloadFromDisk,
|
|
387
|
+
diskChange,
|
|
388
|
+
keepMineAgainstDisk,
|
|
303
389
|
};
|
|
304
390
|
}
|
|
@@ -71,17 +71,35 @@ export interface UseFileReadOptions {
|
|
|
71
71
|
/** The queued write, which owns the key if it is still pending. */
|
|
72
72
|
pendingRef: LiveRef<PendingWrite | null>;
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
74
|
+
* How many reads are in flight, so the auto-refresh watcher does not ask for a
|
|
75
|
+
* second one while the first is still on its way.
|
|
76
|
+
*/
|
|
77
|
+
readingRef: LiveRef<number>;
|
|
78
|
+
/**
|
|
79
|
+
* Store bytes, the line ending they arrived with, the mtime they were read at,
|
|
80
|
+
* and the hash of those bytes.
|
|
76
81
|
*
|
|
77
82
|
* The mtime is the save path's conflict base: a write whose base no longer
|
|
78
83
|
* matches the disk is refused rather than clobbering another writer's change.
|
|
84
|
+
* The hash is the auto-refresh watcher's baseline: a file that still hashes
|
|
85
|
+
* the same has not changed, however far its mtime moved.
|
|
79
86
|
*/
|
|
80
|
-
remember: (fileKey: string, text: string, mtimeMs: number | null) => void;
|
|
87
|
+
remember: (fileKey: string, text: string, mtimeMs: number | null, hash: string | null) => void;
|
|
81
88
|
}
|
|
82
89
|
|
|
83
90
|
export interface FileReadState {
|
|
84
91
|
isLoading: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* A read is in flight over content that is already on screen — the manual
|
|
94
|
+
* "Reload from disk" (or a workspace refresh), never the first load.
|
|
95
|
+
*
|
|
96
|
+
* `isLoading` deliberately stays `false` for those reads (a spinner over live
|
|
97
|
+
* content is the bug it prevents), so the toolbar's reload glyph had no state
|
|
98
|
+
* to spin for. This is that state, and it is false during a first load so the
|
|
99
|
+
* glyph does not spin while the opening read is what the overlay already
|
|
100
|
+
* reports.
|
|
101
|
+
*/
|
|
102
|
+
isReading: boolean;
|
|
85
103
|
loadError: string | null;
|
|
86
104
|
/** Set only for a refusal about the file's kind; see the module note. */
|
|
87
105
|
unsupported: string | null;
|
|
@@ -101,15 +119,18 @@ export function useFileRead({
|
|
|
101
119
|
contentsRef,
|
|
102
120
|
baselinesRef,
|
|
103
121
|
pendingRef,
|
|
122
|
+
readingRef,
|
|
104
123
|
remember,
|
|
105
124
|
}: UseFileReadOptions): FileReadState {
|
|
106
125
|
const [isLoading, setIsLoading] = useState(false);
|
|
126
|
+
const [reading, setReading] = useState(false);
|
|
107
127
|
const [loadError, setLoadError] = useState<string | null>(null);
|
|
108
128
|
const [unsupported, setUnsupported] = useState<string | null>(null);
|
|
109
129
|
|
|
110
130
|
// Read the active file once per key. A cancelled guard keeps a late response
|
|
111
131
|
// from a previous file from overwriting the one now on screen.
|
|
112
132
|
useEffect(() => {
|
|
133
|
+
setReading(false);
|
|
113
134
|
if (!target) return;
|
|
114
135
|
const fileKey = targetKey(target);
|
|
115
136
|
if (loadedRef.current.has(fileKey)) return;
|
|
@@ -129,7 +150,7 @@ export function useFileRead({
|
|
|
129
150
|
if (target.content !== undefined) {
|
|
130
151
|
// Inline content (an attachment chip) has no file behind it, so there is no
|
|
131
152
|
// mtime to check a later write against.
|
|
132
|
-
remember(fileKey, target.content, null);
|
|
153
|
+
remember(fileKey, target.content, null, null);
|
|
133
154
|
setLoadError(null);
|
|
134
155
|
setUnsupported(null);
|
|
135
156
|
return;
|
|
@@ -153,10 +174,12 @@ export function useFileRead({
|
|
|
153
174
|
const params = new URLSearchParams({ path: target.path });
|
|
154
175
|
if (target.root) params.set('root', target.root);
|
|
155
176
|
if (target.repo && target.repo !== '.') params.set('repo', target.repo);
|
|
177
|
+
readingRef.current += 1;
|
|
178
|
+
setReading(true);
|
|
156
179
|
fetch(`/api/fs/read?${params.toString()}`)
|
|
157
180
|
.then(async (res) => {
|
|
158
181
|
const data = (await res.json().catch(() => null)) as
|
|
159
|
-
| { content?: unknown; error?: string; kind?: 'binary' | 'too-large'; mtimeMs?: unknown }
|
|
182
|
+
| { content?: unknown; error?: string; kind?: 'binary' | 'too-large'; mtimeMs?: unknown; hash?: unknown }
|
|
160
183
|
| null;
|
|
161
184
|
if (!res.ok || !data || typeof data.content !== 'string') {
|
|
162
185
|
const error: FileReadError = new Error(data?.error || `HTTP ${res.status}`);
|
|
@@ -166,9 +189,13 @@ export function useFileRead({
|
|
|
166
189
|
else if (res.status === 415) error.kind = 'binary';
|
|
167
190
|
throw error;
|
|
168
191
|
}
|
|
169
|
-
return {
|
|
192
|
+
return {
|
|
193
|
+
text: data.content,
|
|
194
|
+
mtimeMs: typeof data.mtimeMs === 'number' ? data.mtimeMs : null,
|
|
195
|
+
hash: typeof data.hash === 'string' ? data.hash : null,
|
|
196
|
+
};
|
|
170
197
|
})
|
|
171
|
-
.then(({ text, mtimeMs }) => {
|
|
198
|
+
.then(({ text, mtimeMs, hash }) => {
|
|
172
199
|
if (cancelled) return;
|
|
173
200
|
// These bytes were read before the response arrived, so anything typed
|
|
174
201
|
// since is newer. Applying them would replace those keystrokes (and,
|
|
@@ -178,7 +205,7 @@ export function useFileRead({
|
|
|
178
205
|
if (typed !== undefined && typed !== baselinesRef.current[fileKey]) return;
|
|
179
206
|
const queued = pendingRef.current;
|
|
180
207
|
if (queued && targetKey(queued.file) === fileKey) return;
|
|
181
|
-
remember(fileKey, text, mtimeMs);
|
|
208
|
+
remember(fileKey, text, mtimeMs, hash);
|
|
182
209
|
})
|
|
183
210
|
.catch((err: unknown) => {
|
|
184
211
|
if (cancelled) return;
|
|
@@ -186,20 +213,26 @@ export function useFileRead({
|
|
|
186
213
|
if (!firstLoad) return;
|
|
187
214
|
// An empty buffer, never a substitute: the next save would write the
|
|
188
215
|
// substitute over the real file.
|
|
189
|
-
remember(fileKey, '', null);
|
|
216
|
+
remember(fileKey, '', null, null);
|
|
190
217
|
const message = err instanceof Error ? err.message : 'Failed to read file';
|
|
191
218
|
const kind = (err as FileReadError)?.kind;
|
|
192
219
|
setUnsupported(kind ? message : null);
|
|
193
220
|
setLoadError(message);
|
|
194
221
|
})
|
|
195
222
|
.finally(() => {
|
|
196
|
-
|
|
223
|
+
readingRef.current -= 1;
|
|
224
|
+
if (!cancelled) {
|
|
225
|
+
setIsLoading(false);
|
|
226
|
+
setReading(false);
|
|
227
|
+
}
|
|
197
228
|
});
|
|
198
229
|
|
|
199
230
|
return () => {
|
|
200
231
|
cancelled = true;
|
|
201
232
|
};
|
|
202
|
-
}, [key, target, remember, revision, isBinaryViewer, loadedRef, contentsRef, baselinesRef, pendingRef]);
|
|
233
|
+
}, [key, target, remember, revision, isBinaryViewer, loadedRef, contentsRef, baselinesRef, pendingRef, readingRef]);
|
|
203
234
|
|
|
204
|
-
|
|
235
|
+
// A first load keeps `isLoading` true for the same read, so the reload glyph
|
|
236
|
+
// must not also claim it: this flag is about re-reads only.
|
|
237
|
+
return { isLoading, isReading: reading && !isLoading, loadError, unsupported };
|
|
205
238
|
}
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
|
|
29
29
|
import { fileHandleFor } from '@/client/lib/launch/file-handlers';
|
|
30
30
|
import type { LineEnding } from '@/shared/lib/code/line-endings';
|
|
31
|
-
import { saveEditorFile } from '@/client/hooks/editor/save-file';
|
|
31
|
+
import { saveEditorFile, type WrittenFile } from '@/client/hooks/editor/save-file';
|
|
32
32
|
import type { FileEditorTarget } from '@/client/hooks/editor/use-file-editor';
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -72,8 +72,8 @@ export interface FileWriteDeps {
|
|
|
72
72
|
flushOnUnmount: boolean;
|
|
73
73
|
/** A write started; the toolbar shows `saving`. */
|
|
74
74
|
onSaveStart: () => void;
|
|
75
|
-
/** A write landed; the baseline
|
|
76
|
-
onSaved: (fileKey: string, text: string) => void;
|
|
75
|
+
/** A write landed; the baseline, the conflict base and the digest all move. */
|
|
76
|
+
onSaved: (fileKey: string, text: string, written: WrittenFile) => void;
|
|
77
77
|
/** A write was refused or dropped. */
|
|
78
78
|
onSaveFailed: () => void;
|
|
79
79
|
/**
|
|
@@ -161,7 +161,7 @@ export function useFileWrites({
|
|
|
161
161
|
interactive: options.interactive === true,
|
|
162
162
|
baseMtimeMs,
|
|
163
163
|
});
|
|
164
|
-
if (outcome.status === 'written') onSaved(fileKey, text);
|
|
164
|
+
if (outcome.status === 'written') onSaved(fileKey, text, outcome.written);
|
|
165
165
|
else if (outcome.status === 'needs-permission') onNeedsPermission();
|
|
166
166
|
else if (outcome.status === 'conflict') onConflict(fileKey, outcome.diskMtimeMs);
|
|
167
167
|
else onSaveFailed();
|