@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
|
@@ -13,21 +13,68 @@
|
|
|
13
13
|
* function of its `content` — a keystroke in the source updates it live, which
|
|
14
14
|
* is the honest behaviour for a file that IS its own text.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* **An edit is a text edit.** A committed cell is written back into the table
|
|
17
|
+
* and the table is serialized to delimited text, which goes through the tab's
|
|
18
|
+
* ordinary `onChange` — so the dirty dot, the autosave, the conflict guard and
|
|
19
|
+
* the toolbar's Save are the same ones every text file has. There is no second
|
|
20
|
+
* save path for CSV.
|
|
21
|
+
*
|
|
22
|
+
* Editing is refused when the parse was CAPPED: the grid holds the first
|
|
23
|
+
* `MAX_CSV_ROWS` rows, and writing that table back would drop every row past
|
|
24
|
+
* the cap. The strip says so instead of silently truncating the file.
|
|
25
|
+
*
|
|
26
|
+
* Parsing and serialization live in `shared/lib/fs/csv.ts` (pure, unit-tested):
|
|
27
|
+
* quote handling is the whole difficulty, and it must not be re-implemented per
|
|
28
|
+
* surface.
|
|
18
29
|
*/
|
|
19
30
|
|
|
20
31
|
import { useMemo } from 'preact/hooks';
|
|
21
|
-
import { parseCsv } from '@/shared/lib/fs/csv';
|
|
32
|
+
import { parseCsv, serializeCsv } from '@/shared/lib/fs/csv';
|
|
33
|
+
import { replaceCell } from '@/shared/lib/fs/grid-edit';
|
|
22
34
|
import { DataGrid } from '@/client/components/workspace/editor/viewers/DataGrid';
|
|
23
35
|
|
|
24
36
|
interface CsvGridProps {
|
|
25
37
|
content: string;
|
|
26
38
|
/** Used only to pick the delimiter when the extension says TSV. */
|
|
27
39
|
path: string;
|
|
40
|
+
/** Write the edited text back into the tab's buffer; absent means read-only. */
|
|
41
|
+
onChange?: (next: string) => void;
|
|
28
42
|
}
|
|
29
43
|
|
|
30
|
-
export function CsvGrid({ content, path }: CsvGridProps) {
|
|
44
|
+
export function CsvGrid({ content, path, onChange }: CsvGridProps) {
|
|
31
45
|
const table = useMemo(() => parseCsv(content, path), [content, path]);
|
|
32
|
-
|
|
46
|
+
const editable = onChange !== undefined && !table.truncated;
|
|
47
|
+
const trailingNewline = content.endsWith('\n');
|
|
48
|
+
|
|
49
|
+
const editCell = editable
|
|
50
|
+
? (row: number, col: number, value: string) => {
|
|
51
|
+
onChange(serializeCsv(table.header, replaceCell(table.rows, row, col, value), table.delimiter, trailingNewline));
|
|
52
|
+
}
|
|
53
|
+
: undefined;
|
|
54
|
+
|
|
55
|
+
const editHeader = editable
|
|
56
|
+
? (col: number, value: string) => {
|
|
57
|
+
const header = table.header.slice();
|
|
58
|
+
while (header.length <= col) header.push('');
|
|
59
|
+
header[col] = value;
|
|
60
|
+
onChange(serializeCsv(header, table.rows, table.delimiter, trailingNewline));
|
|
61
|
+
}
|
|
62
|
+
: undefined;
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<DataGrid
|
|
66
|
+
header={table.header}
|
|
67
|
+
rows={table.rows}
|
|
68
|
+
truncated={table.truncated}
|
|
69
|
+
readOnlyNote={
|
|
70
|
+
table.truncated
|
|
71
|
+
? 'This file is too large to edit in the grid — use Show source.'
|
|
72
|
+
: editable
|
|
73
|
+
? 'Paste is not supported — double-click a cell to edit it.'
|
|
74
|
+
: 'This grid is read-only — use Show source to edit the cells.'
|
|
75
|
+
}
|
|
76
|
+
onEditCell={editCell}
|
|
77
|
+
onEditHeader={editHeader}
|
|
78
|
+
/>
|
|
79
|
+
);
|
|
33
80
|
}
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* The
|
|
7
|
+
* The table the CSV grid and the workbook viewer both draw.
|
|
8
8
|
*
|
|
9
9
|
* One component because a grid is a grid: two renderers would drift on the
|
|
10
10
|
* things that actually matter here — the sticky header, the frozen row-number
|
|
11
|
-
* gutter, the theme colours,
|
|
12
|
-
* only in how they produced the cells (a
|
|
11
|
+
* gutter, the theme colours, the truncation notice, the selection and the
|
|
12
|
+
* clipboard. The two callers differ only in how they produced the cells (a
|
|
13
|
+
* text parse, a workbook read) and in what an edit means to them.
|
|
13
14
|
*
|
|
14
15
|
* `table-fixed` with a `<colgroup>` is deliberate, and it is the lesson the diff
|
|
15
16
|
* panel's wrap toggle already paid for: an auto-layout table sizes a column by
|
|
@@ -18,33 +19,164 @@
|
|
|
18
19
|
* first column keeps the row number visible while the data scrolls, which is
|
|
19
20
|
* what makes a wide sheet readable at all.
|
|
20
21
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* **Editing is opt-in.** A caller that passes `onEditCell` gets a spreadsheet:
|
|
23
|
+
* double-click (or Enter, or typing) opens an input inside the cell, Enter and
|
|
24
|
+
* Tab commit and move, Escape cancels, and a click elsewhere commits. A caller
|
|
25
|
+
* that passes nothing gets the read-only grid it always had — which is what the
|
|
26
|
+
* CSV viewer does when its file is truncated, because writing a capped table
|
|
27
|
+
* back would drop every row past the cap.
|
|
28
|
+
*
|
|
29
|
+
* The event handlers live in `use-grid-interaction.ts`; this file is the
|
|
30
|
+
* selection state, the effects and the markup.
|
|
24
31
|
*/
|
|
25
32
|
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
import type { ComponentChildren } from 'preact';
|
|
34
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks';
|
|
35
|
+
import { copyToClipboard } from '@/client/hooks/ui/clipboard';
|
|
36
|
+
import { useGridSelection } from '@/client/hooks/editor/use-grid-selection';
|
|
37
|
+
import { useCellEdit, type CellEdit, type CellSection } from '@/client/components/workspace/editor/viewers/use-cell-edit';
|
|
38
|
+
import { useGridInteraction } from '@/client/components/workspace/editor/viewers/use-grid-interaction';
|
|
39
|
+
import { GridRow } from '@/client/components/workspace/editor/viewers/GridRow';
|
|
40
|
+
import { GridToolbar, type CopyState } from '@/client/components/workspace/editor/viewers/GridToolbar';
|
|
41
|
+
import {
|
|
42
|
+
columnLabel,
|
|
43
|
+
rangeAddress,
|
|
44
|
+
rangeColumnCount,
|
|
45
|
+
rangeRowCount,
|
|
46
|
+
rangeToTsv,
|
|
47
|
+
} from '@/shared/lib/fs/grid-selection';
|
|
30
48
|
|
|
31
49
|
interface DataGridProps {
|
|
32
50
|
/** Column labels; the first column of the grid is the row number. */
|
|
33
|
-
header:
|
|
34
|
-
rows:
|
|
51
|
+
header: string[];
|
|
52
|
+
rows: string[][];
|
|
35
53
|
/** The source held more rows or columns than were rendered. */
|
|
36
54
|
truncated: boolean;
|
|
55
|
+
/** What the grid is, for the status strip and the accessible name. */
|
|
56
|
+
label?: string;
|
|
57
|
+
/** What a paste is refused with — the grid never writes, so it must say why. */
|
|
58
|
+
readOnlyNote?: string;
|
|
59
|
+
/** Edit a data cell; absent means the grid is read-only. */
|
|
60
|
+
onEditCell?: (row: number, col: number, value: string) => void;
|
|
61
|
+
/** Edit a header cell; absent means the header is a label. */
|
|
62
|
+
onEditHeader?: (col: number, value: string) => void;
|
|
63
|
+
/** Caller-owned controls in the strip (a workbook's Save). */
|
|
64
|
+
actions?: ComponentChildren;
|
|
37
65
|
}
|
|
38
66
|
|
|
39
67
|
/** Width of the row-number gutter, and the reason it is not a percentage. */
|
|
40
68
|
const GUTTER_PX = 44;
|
|
41
69
|
|
|
42
|
-
|
|
70
|
+
/** How long the copy confirmation stays up. */
|
|
71
|
+
const COPY_FEEDBACK_MS = 1600;
|
|
72
|
+
|
|
73
|
+
export function DataGrid({
|
|
74
|
+
header,
|
|
75
|
+
rows,
|
|
76
|
+
truncated,
|
|
77
|
+
label,
|
|
78
|
+
readOnlyNote,
|
|
79
|
+
onEditCell,
|
|
80
|
+
onEditHeader,
|
|
81
|
+
actions,
|
|
82
|
+
}: DataGridProps) {
|
|
43
83
|
// A stable colgroup: fixed layout reads widths from it, and without one every
|
|
44
84
|
// column would size from the first row's cells.
|
|
45
|
-
const
|
|
85
|
+
const width = useMemo(
|
|
86
|
+
() => rows.reduce((widest, row) => Math.max(widest, row.length), header.length),
|
|
87
|
+
[header, rows],
|
|
88
|
+
);
|
|
89
|
+
const labels = useMemo(
|
|
90
|
+
() => Array.from({ length: width }, (_, index) => header[index] ?? columnLabel(index)),
|
|
91
|
+
[header, width],
|
|
92
|
+
);
|
|
93
|
+
// Ragged rows are padded once, so a short row cannot shift the cells after it
|
|
94
|
+
// and the selection arithmetic has one width to work with.
|
|
95
|
+
const cells = useMemo(
|
|
96
|
+
() => rows.map((row) => (row.length === width ? row : Array.from({ length: width }, (_, index) => row[index] ?? ''))),
|
|
97
|
+
[rows, width],
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const selection = useGridSelection(cells.length, width);
|
|
101
|
+
const scrollerRef = useRef<HTMLDivElement>(null);
|
|
102
|
+
const [copyState, setCopyState] = useState<CopyState>('idle');
|
|
46
103
|
|
|
47
|
-
|
|
104
|
+
const commitEdit = useCallback(
|
|
105
|
+
(edit: CellEdit) => {
|
|
106
|
+
if (edit.section === 'header') onEditHeader?.(edit.col, edit.value);
|
|
107
|
+
else onEditCell?.(edit.row, edit.col, edit.value);
|
|
108
|
+
},
|
|
109
|
+
[onEditCell, onEditHeader],
|
|
110
|
+
);
|
|
111
|
+
const editor = useCellEdit(commitEdit);
|
|
112
|
+
const edit = editor.edit;
|
|
113
|
+
|
|
114
|
+
const startEdit = useCallback(
|
|
115
|
+
(section: CellSection, row: number, col: number, initial?: string) => {
|
|
116
|
+
if (section === 'header' ? !onEditHeader : !onEditCell) return;
|
|
117
|
+
const current = section === 'header' ? (labels[col] ?? '') : (cells[row]?.[col] ?? '');
|
|
118
|
+
editor.begin(section, row, col, initial ?? current);
|
|
119
|
+
},
|
|
120
|
+
[cells, editor, labels, onEditCell, onEditHeader],
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
const copy = useCallback(async () => {
|
|
124
|
+
if (!selection.range) return;
|
|
125
|
+
const ok = await copyToClipboard(rangeToTsv(cells, selection.range));
|
|
126
|
+
setCopyState(ok ? 'copied' : 'failed');
|
|
127
|
+
}, [cells, selection.range]);
|
|
128
|
+
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
if (copyState === 'idle') return;
|
|
131
|
+
const timer = setTimeout(() => setCopyState('idle'), COPY_FEEDBACK_MS);
|
|
132
|
+
return () => clearTimeout(timer);
|
|
133
|
+
}, [copyState]);
|
|
134
|
+
|
|
135
|
+
// A drag that leaves the table still ends: the pointerup lands on whatever is
|
|
136
|
+
// under it, which is not necessarily a cell.
|
|
137
|
+
const { dragging, endDrag } = selection;
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
if (!dragging) return;
|
|
140
|
+
const end = () => endDrag();
|
|
141
|
+
window.addEventListener('pointerup', end);
|
|
142
|
+
window.addEventListener('pointercancel', end);
|
|
143
|
+
return () => {
|
|
144
|
+
window.removeEventListener('pointerup', end);
|
|
145
|
+
window.removeEventListener('pointercancel', end);
|
|
146
|
+
};
|
|
147
|
+
}, [dragging, endDrag]);
|
|
148
|
+
|
|
149
|
+
// Keyboard navigation must bring the active cell into view, or an arrow key
|
|
150
|
+
// past the fold moves a selection the user cannot see.
|
|
151
|
+
const active = selection.active;
|
|
152
|
+
useEffect(() => {
|
|
153
|
+
if (!active) return;
|
|
154
|
+
const cell = scrollerRef.current?.querySelector(`[data-row="${active.row}"][data-col="${active.col}"]`);
|
|
155
|
+
(cell as HTMLElement | null)?.scrollIntoView?.({ block: 'nearest', inline: 'nearest' });
|
|
156
|
+
}, [active]);
|
|
157
|
+
|
|
158
|
+
// Focus the input when a cell opens, and only then: keying this on the whole
|
|
159
|
+
// edit object would re-select the text on every keystroke.
|
|
160
|
+
const editKey = edit ? `${edit.section}:${edit.row}:${edit.col}` : '';
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
if (!editKey) return;
|
|
163
|
+
const input = scrollerRef.current?.querySelector('[data-edit-input]') as HTMLInputElement | null;
|
|
164
|
+
input?.focus();
|
|
165
|
+
input?.select();
|
|
166
|
+
}, [editKey]);
|
|
167
|
+
|
|
168
|
+
const interaction = useGridInteraction({
|
|
169
|
+
cells,
|
|
170
|
+
width,
|
|
171
|
+
selection,
|
|
172
|
+
editor,
|
|
173
|
+
scrollerRef,
|
|
174
|
+
startEdit,
|
|
175
|
+
onEditCell,
|
|
176
|
+
setCopyState,
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
if (width === 0 && cells.length === 0) {
|
|
48
180
|
return (
|
|
49
181
|
<div className="flex flex-1 items-center justify-center px-6 text-center text-xs text-ink/50">
|
|
50
182
|
This file has no rows.
|
|
@@ -52,48 +184,102 @@ export function DataGrid({ header, rows, truncated }: DataGridProps) {
|
|
|
52
184
|
);
|
|
53
185
|
}
|
|
54
186
|
|
|
187
|
+
const range = selection.range;
|
|
188
|
+
const status =
|
|
189
|
+
copyState === 'refused'
|
|
190
|
+
? (readOnlyNote ?? 'This grid is read-only.')
|
|
191
|
+
: range
|
|
192
|
+
? `${rangeAddress(range)} · ${rangeRowCount(range)}×${rangeColumnCount(range)}`
|
|
193
|
+
: 'Click a cell, drag to select a block';
|
|
194
|
+
|
|
55
195
|
return (
|
|
56
196
|
<div className="flex min-h-0 flex-1 flex-col">
|
|
57
197
|
{truncated && (
|
|
58
198
|
<div className="shrink-0 border-b border-warning/30 bg-warning/10 px-3 py-1 font-sans text-[11px] text-warning">
|
|
59
|
-
Showing the first {
|
|
199
|
+
Showing the first {cells.length.toLocaleString()} rows.
|
|
60
200
|
</div>
|
|
61
201
|
)}
|
|
62
|
-
<
|
|
63
|
-
|
|
202
|
+
<GridToolbar
|
|
203
|
+
status={status}
|
|
204
|
+
tone={copyState === 'refused' ? 'warning' : 'muted'}
|
|
205
|
+
actions={actions}
|
|
206
|
+
canCopy={range !== null}
|
|
207
|
+
copyState={copyState}
|
|
208
|
+
onCopy={() => void copy()}
|
|
209
|
+
/>
|
|
210
|
+
<div
|
|
211
|
+
ref={scrollerRef}
|
|
212
|
+
tabIndex={0}
|
|
213
|
+
role="grid"
|
|
214
|
+
aria-label={label ?? 'Spreadsheet'}
|
|
215
|
+
className="flex-1 overflow-auto outline-none"
|
|
216
|
+
onPointerDown={interaction.onPointerDown}
|
|
217
|
+
onPointerOver={interaction.onPointerOver}
|
|
218
|
+
onDblClick={interaction.onDoubleClick}
|
|
219
|
+
onInput={interaction.onInput}
|
|
220
|
+
onKeyDown={interaction.onKeyDown}
|
|
221
|
+
onCopy={interaction.onCopy}
|
|
222
|
+
onPaste={interaction.onPaste}
|
|
223
|
+
>
|
|
224
|
+
<table className="w-full table-fixed select-none border-collapse font-mono text-[11px]">
|
|
64
225
|
<colgroup>
|
|
65
226
|
<col style={{ width: `${GUTTER_PX}px` }} />
|
|
66
|
-
{
|
|
227
|
+
{labels.map((_, index) => (
|
|
67
228
|
<col key={index} />
|
|
68
229
|
))}
|
|
69
230
|
</colgroup>
|
|
70
231
|
<thead className="sticky top-0 z-10 bg-canvas">
|
|
71
232
|
<tr>
|
|
72
|
-
<th
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
233
|
+
<th
|
|
234
|
+
data-corner
|
|
235
|
+
title="Select all"
|
|
236
|
+
className="cursor-pointer border-b border-r border-ink/10 px-2 py-1 text-right font-normal text-ink/30"
|
|
237
|
+
>
|
|
238
|
+
#
|
|
239
|
+
</th>
|
|
240
|
+
{labels.map((cell, index) => {
|
|
241
|
+
const inRange = range !== null && index >= range.left && index <= range.right;
|
|
242
|
+
const isEditing = edit?.section === 'header' && edit.col === index;
|
|
243
|
+
return (
|
|
244
|
+
<th
|
|
245
|
+
key={index}
|
|
246
|
+
data-col-header={index}
|
|
247
|
+
title={cell}
|
|
248
|
+
className={`cursor-pointer border-b border-ink/10 px-2 py-1 text-left font-semibold ${
|
|
249
|
+
inRange ? 'bg-info/10 text-ink' : 'text-ink/80'
|
|
250
|
+
}`}
|
|
251
|
+
>
|
|
252
|
+
{isEditing ? (
|
|
253
|
+
<input
|
|
254
|
+
data-edit-input="true"
|
|
255
|
+
value={edit.value}
|
|
256
|
+
spellcheck={false}
|
|
257
|
+
className="w-full min-w-0 bg-transparent font-mono text-[11px] font-semibold text-ink outline-none"
|
|
258
|
+
/>
|
|
259
|
+
) : (
|
|
260
|
+
<span className="block truncate">{cell}</span>
|
|
261
|
+
)}
|
|
262
|
+
</th>
|
|
263
|
+
);
|
|
264
|
+
})}
|
|
82
265
|
</tr>
|
|
83
266
|
</thead>
|
|
84
267
|
<tbody>
|
|
85
|
-
{
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
268
|
+
{cells.map((row, rowIndex) => {
|
|
269
|
+
const inRange = range !== null && rowIndex >= range.top && rowIndex <= range.bottom;
|
|
270
|
+
return (
|
|
271
|
+
<GridRow
|
|
272
|
+
key={rowIndex}
|
|
273
|
+
cells={row}
|
|
274
|
+
rowIndex={rowIndex}
|
|
275
|
+
selectedLeft={inRange ? range.left : -1}
|
|
276
|
+
selectedRight={inRange ? range.right : -1}
|
|
277
|
+
activeCol={active?.row === rowIndex ? active.col : -1}
|
|
278
|
+
editingCol={edit?.section === 'data' && edit.row === rowIndex ? edit.col : -1}
|
|
279
|
+
editingValue={edit?.section === 'data' && edit.row === rowIndex ? edit.value : ''}
|
|
280
|
+
/>
|
|
281
|
+
);
|
|
282
|
+
})}
|
|
97
283
|
</tbody>
|
|
98
284
|
</table>
|
|
99
285
|
</div>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A `.drawio` file drawn as the diagram it is.
|
|
8
|
+
*
|
|
9
|
+
* Built on the TEXT buffer, like `SvgPreview`: a drawio file is XML the editor
|
|
10
|
+
* can show and save, so the eye toggle switches between the source and this
|
|
11
|
+
* render with no second fetch, and an edit in the source redraws the picture.
|
|
12
|
+
*
|
|
13
|
+
* The conversion is `@dskripchenko/drawio` (MIT, no runtime dependency, no
|
|
14
|
+
* DOM): it reads both page encodings — inline `<mxGraphModel>` and the
|
|
15
|
+
* base64+deflate one the desktop app saves by default — and emits SVG from the
|
|
16
|
+
* parsed cells. That division is deliberate: the SAFETY argument lives in the
|
|
17
|
+
* library and is covered by its own tests (HTML labels become text runs, colours
|
|
18
|
+
* are validated, `javascript:` links are refused, external images are not
|
|
19
|
+
* loaded unless asked), while this component owns only the parts that are
|
|
20
|
+
* Kabmo's — the page chrome, the multi-page stack, and the report of what could
|
|
21
|
+
* not be drawn.
|
|
22
|
+
*
|
|
23
|
+
* A multi-page file draws every page, stacked, each with its own caption: the
|
|
24
|
+
* alternative is silently showing page one of a five-page document. The
|
|
25
|
+
* renderer's `warnings` are printed for the same reason — a vendor stencil is
|
|
26
|
+
* drawn as a labelled placeholder, and saying so is what keeps the picture from
|
|
27
|
+
* being read as the file's own content.
|
|
28
|
+
*
|
|
29
|
+
* Zoom, pan, fit and the footer controls are `ZoomPanStage`, the same surface an
|
|
30
|
+
* image gets: a diagram and a picture are the same interaction, and a second
|
|
31
|
+
* copy of the fit arithmetic is how the two drift apart.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
import { useMemo, useRef } from 'preact/hooks';
|
|
35
|
+
import { ViewerError } from '@/client/components/workspace/editor/viewers/ViewerError';
|
|
36
|
+
import { renderDrawioPages } from '@/client/components/workspace/editor/viewers/drawio-pages';
|
|
37
|
+
import { ZoomPanStage } from '@/client/components/common/zoom-pan-stage';
|
|
38
|
+
import { nextSvgScopePrefix } from '@/shared/lib/ui/svg-scope';
|
|
39
|
+
|
|
40
|
+
interface DrawioViewProps {
|
|
41
|
+
content: string;
|
|
42
|
+
name: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function DrawioView({ content, name }: DrawioViewProps) {
|
|
46
|
+
// Allocated once per mounted preview, like `SvgPreview`'s id namespace.
|
|
47
|
+
const scopeRef = useRef('');
|
|
48
|
+
if (!scopeRef.current) scopeRef.current = nextSvgScopePrefix();
|
|
49
|
+
|
|
50
|
+
const result = useMemo(() => renderDrawioPages(content, scopeRef.current), [content]);
|
|
51
|
+
|
|
52
|
+
if (result.status === 'error') return <ViewerError name={name} message={result.message} />;
|
|
53
|
+
|
|
54
|
+
const pages = result.pages;
|
|
55
|
+
const caption =
|
|
56
|
+
pages.length === 1
|
|
57
|
+
? `${pages[0].name} · ${pages[0].width} × ${pages[0].height} px`
|
|
58
|
+
: `${pages.length} pages · ${pages.map((page) => page.name).join(', ')}`;
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<ZoomPanStage measureKey={pages} caption={caption}>
|
|
62
|
+
{/* A drawn page is already at its layout size, so the column must not be
|
|
63
|
+
scaled by the browser: the stage transforms it instead. */}
|
|
64
|
+
<div className="flex flex-col items-center gap-6 bg-paper p-6">
|
|
65
|
+
{pages.map((page, index) => (
|
|
66
|
+
<figure key={`${index}-${page.name}`} className="w-max">
|
|
67
|
+
{pages.length > 1 ? (
|
|
68
|
+
<figcaption className="mb-2 text-center font-sans text-[11px] uppercase tracking-wide text-ink/40">
|
|
69
|
+
{page.name}
|
|
70
|
+
</figcaption>
|
|
71
|
+
) : null}
|
|
72
|
+
{/* The page's own size, so the SVG's `max-width:100%` resolves
|
|
73
|
+
against a definite box instead of a shrink-to-fit parent. */}
|
|
74
|
+
<div
|
|
75
|
+
className="drawio-preview [&>svg]:block"
|
|
76
|
+
role="img"
|
|
77
|
+
aria-label={page.name}
|
|
78
|
+
style={{ width: `${page.width}px`, height: `${page.height}px` }}
|
|
79
|
+
dangerouslySetInnerHTML={{ __html: page.svg }}
|
|
80
|
+
/>
|
|
81
|
+
{page.warnings.length > 0 ? (
|
|
82
|
+
<ul className="mx-auto mt-2 max-w-[80ch] space-y-0.5 text-center font-sans text-[10.5px] text-ink/40">
|
|
83
|
+
{page.warnings.map((warning) => (
|
|
84
|
+
<li key={warning}>{warning}</li>
|
|
85
|
+
))}
|
|
86
|
+
</ul>
|
|
87
|
+
) : null}
|
|
88
|
+
</figure>
|
|
89
|
+
))}
|
|
90
|
+
</div>
|
|
91
|
+
</ZoomPanStage>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One data row of the spreadsheet grid, memoised.
|
|
8
|
+
*
|
|
9
|
+
* The memo is the reason this is a component at all: a 2000-row sheet is
|
|
10
|
+
* 200 000 cells, and a selection change touches only the rows inside the old
|
|
11
|
+
* and new rectangles. Without the memo every pointer move re-rendered the whole
|
|
12
|
+
* table, which is what made dragging a selection feel like the panel had hung.
|
|
13
|
+
* The props are deliberately primitives plus the row's own array, so the
|
|
14
|
+
* shallow compare is exact.
|
|
15
|
+
*
|
|
16
|
+
* Pointer events are NOT handled here: the grid delegates them from one
|
|
17
|
+
* listener and reads `data-row`/`data-col` off the target, so no cell mounts a
|
|
18
|
+
* closure.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { memo } from 'preact/compat';
|
|
22
|
+
|
|
23
|
+
export interface GridRowProps {
|
|
24
|
+
cells: readonly string[];
|
|
25
|
+
rowIndex: number;
|
|
26
|
+
/** First selected column in this row, or -1 when the row is outside the range. */
|
|
27
|
+
selectedLeft: number;
|
|
28
|
+
/** Last selected column in this row, or -1. */
|
|
29
|
+
selectedRight: number;
|
|
30
|
+
/** The active cell's column when it is in this row, else -1. */
|
|
31
|
+
activeCol: number;
|
|
32
|
+
/** The column being edited in this row, else -1. */
|
|
33
|
+
editingCol: number;
|
|
34
|
+
/** The draft text of the cell being edited. */
|
|
35
|
+
editingValue: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const GridRow = memo(function GridRow({
|
|
39
|
+
cells,
|
|
40
|
+
rowIndex,
|
|
41
|
+
selectedLeft,
|
|
42
|
+
selectedRight,
|
|
43
|
+
activeCol,
|
|
44
|
+
editingCol,
|
|
45
|
+
editingValue,
|
|
46
|
+
}: GridRowProps) {
|
|
47
|
+
const rowSelected = selectedLeft >= 0;
|
|
48
|
+
return (
|
|
49
|
+
<tr className="odd:bg-ink/[0.02]">
|
|
50
|
+
<th
|
|
51
|
+
data-row-header={rowIndex}
|
|
52
|
+
className={`cursor-pointer border-b border-r border-ink/10 px-2 py-0.5 text-right font-normal tabular-nums ${
|
|
53
|
+
rowSelected ? 'bg-info/10 text-ink/60' : 'text-ink/30'
|
|
54
|
+
}`}
|
|
55
|
+
title={`Select row ${rowIndex + 1}`}
|
|
56
|
+
>
|
|
57
|
+
{rowIndex + 1}
|
|
58
|
+
</th>
|
|
59
|
+
{cells.map((cell, col) => {
|
|
60
|
+
const inRange = rowSelected && col >= selectedLeft && col <= selectedRight;
|
|
61
|
+
const isActive = col === activeCol;
|
|
62
|
+
const isEditing = col === editingCol;
|
|
63
|
+
return (
|
|
64
|
+
<td
|
|
65
|
+
key={col}
|
|
66
|
+
data-row={rowIndex}
|
|
67
|
+
data-col={col}
|
|
68
|
+
title={cell}
|
|
69
|
+
className={`cursor-cell border-b border-ink/10 px-2 py-0.5 text-ink ${
|
|
70
|
+
inRange ? 'bg-info/10' : ''
|
|
71
|
+
} ${isActive ? 'ring-1 ring-inset ring-info' : ''}`}
|
|
72
|
+
>
|
|
73
|
+
{isEditing ? (
|
|
74
|
+
// The editor is an input INSIDE the cell, so the grid keeps its
|
|
75
|
+
// geometry while a value is typed. `data-edit-input` is how the
|
|
76
|
+
// grid's delegated handlers find it.
|
|
77
|
+
<input
|
|
78
|
+
data-edit-input="true"
|
|
79
|
+
value={editingValue}
|
|
80
|
+
spellcheck={false}
|
|
81
|
+
className="w-full min-w-0 bg-transparent font-mono text-[11px] text-ink outline-none"
|
|
82
|
+
/>
|
|
83
|
+
) : (
|
|
84
|
+
<span className="block truncate">{cell}</span>
|
|
85
|
+
)}
|
|
86
|
+
</td>
|
|
87
|
+
);
|
|
88
|
+
})}
|
|
89
|
+
</tr>
|
|
90
|
+
);
|
|
91
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The strip above the grid: the selection's address, whatever the caller adds
|
|
8
|
+
* (a workbook's Save), and the copy button.
|
|
9
|
+
*
|
|
10
|
+
* Split from `DataGrid` so the grid's own file stays under the repository's
|
|
11
|
+
* line ceiling, and because the strip is the one part of the grid that is pure
|
|
12
|
+
* presentation — it owns no selection and no clipboard state.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { ComponentChildren } from 'preact';
|
|
16
|
+
import { Check, Copy } from 'lucide-preact';
|
|
17
|
+
|
|
18
|
+
export type CopyState = 'idle' | 'copied' | 'failed' | 'refused';
|
|
19
|
+
|
|
20
|
+
interface GridToolbarProps {
|
|
21
|
+
/** The selection's address and size, or the empty-selection hint. */
|
|
22
|
+
status: string;
|
|
23
|
+
/** A refusal or a warning is drawn in the warning colour. */
|
|
24
|
+
tone?: 'muted' | 'warning';
|
|
25
|
+
/** Caller-owned controls, drawn before the copy button. */
|
|
26
|
+
actions?: ComponentChildren;
|
|
27
|
+
canCopy: boolean;
|
|
28
|
+
copyState: CopyState;
|
|
29
|
+
onCopy: () => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function GridToolbar({ status, tone = 'muted', actions, canCopy, copyState, onCopy }: GridToolbarProps) {
|
|
33
|
+
return (
|
|
34
|
+
<div className="flex shrink-0 items-center justify-between gap-2 border-b border-ink/10 bg-canvas px-2 py-1 font-sans text-[11px]">
|
|
35
|
+
<span className={`truncate ${tone === 'warning' ? 'text-warning' : 'text-ink/50'}`}>{status}</span>
|
|
36
|
+
<div className="flex shrink-0 items-center gap-2">
|
|
37
|
+
{actions}
|
|
38
|
+
<button
|
|
39
|
+
type="button"
|
|
40
|
+
onClick={onCopy}
|
|
41
|
+
disabled={!canCopy}
|
|
42
|
+
title="Copy the selected cells as tab-separated text"
|
|
43
|
+
className={`flex items-center gap-1 rounded px-1.5 py-0.5 transition-colors ${
|
|
44
|
+
canCopy ? 'text-ink/60 hover:bg-ink/5 hover:text-ink' : 'cursor-default text-ink/25'
|
|
45
|
+
} ${copyState === 'failed' ? 'text-error' : ''}`}
|
|
46
|
+
>
|
|
47
|
+
{copyState === 'copied' ? <Check size={12} /> : <Copy size={12} />}
|
|
48
|
+
<span>{copyState === 'copied' ? 'Copied' : copyState === 'failed' ? 'Copy failed' : 'Copy'}</span>
|
|
49
|
+
</button>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
}
|