@kabmo-labs/kabmo 0.16.0 → 0.18.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/README.md +2 -2
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +552 -471
- package/dist/client/static/js/index-hp75vsv9.css +1 -0
- package/dist/client/static/js/{index-cpydmygd.js → index-tc09dtca.js} +897 -886
- package/package.json +1 -1
- package/src/client/components/common/MarkdownRenderer.tsx +136 -89
- package/src/client/components/common/anchored-menu/index.test.tsx +141 -0
- package/src/client/components/common/anchored-menu/index.tsx +143 -0
- package/src/client/components/common/code-surface/bracket-guide.test.ts +2 -2
- package/src/client/components/common/code-surface/bracket-guide.ts +2 -2
- package/src/client/components/common/code-surface/conflict-markers.ts +5 -5
- package/src/client/components/common/code-surface/extensions.ts +7 -4
- package/src/client/components/common/code-surface/theme.ts +34 -9
- package/src/client/components/common/code-surface/whitespace.test.ts +223 -0
- package/src/client/components/common/code-surface/whitespace.ts +140 -0
- package/src/client/components/common/markdown-review/ReviewPopover.tsx +144 -0
- package/src/client/components/common/markdown-review/ReviewSummary.tsx +108 -0
- package/src/client/components/common/markdown-review/index.tsx +129 -0
- package/src/client/components/common/{server-switcher/index.tsx → server-control/Panel.tsx} +92 -44
- package/src/client/components/common/server-control/index.test.tsx +217 -0
- package/src/client/components/common/server-control/index.tsx +120 -0
- package/src/client/components/layout/desktop-layout/TopNavbar.tsx +8 -50
- package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +42 -21
- package/src/client/components/layout/session-sidebar/CategoryHeader.worktree.test.tsx +36 -17
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +8 -7
- package/src/client/components/layout/session-sidebar/about-modal/NotesDialog.tsx +94 -0
- package/src/client/components/layout/session-sidebar/about-modal/VersionLine.test.tsx +68 -0
- package/src/client/components/layout/session-sidebar/about-modal/VersionLine.tsx +36 -0
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +57 -34
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +28 -10
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +7 -6
- package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +1 -1
- package/src/client/components/layout/update-popup/ReleaseNotes.tsx +8 -3
- package/src/client/components/layout/update-popup/index.tsx +5 -1
- package/src/client/components/mobile/mobile-main-view/Header.tsx +6 -12
- package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +13 -15
- package/src/client/components/mobile/mobile-right-sidebar/Header.tsx +23 -1
- package/src/client/components/mobile/mobile-right-sidebar/MissingFileBanner.tsx +30 -0
- package/src/client/components/mobile/mobile-right-sidebar/PreviewScroller.tsx +18 -2
- package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +41 -13
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +22 -67
- package/src/client/components/mobile/mobile-session-sidebar/ItemMenu.tsx +110 -0
- package/src/client/components/settings/Modal.tsx +9 -3
- package/src/client/components/settings/ProjectSelectorDropdown.tsx +19 -9
- package/src/client/components/settings/SettingsSidebarList.tsx +20 -0
- package/src/client/components/settings/categories/AgentSettings.tsx +38 -44
- package/src/client/components/settings/categories/CommandSettings.tsx +2 -2
- package/src/client/components/settings/categories/McpSettings.tsx +4 -21
- package/src/client/components/settings/categories/OmpSettings.tsx +147 -194
- package/src/client/components/settings/categories/ProjectSettings.tsx +122 -156
- package/src/client/components/settings/categories/SkillCatalogSettings.tsx +220 -260
- package/src/client/components/settings/categories/SkillSettings.tsx +8 -5
- package/src/client/components/settings/categories/TokenUsageSettings.tsx +211 -229
- package/src/client/components/settings/categories/agent-settings/DetailPane.tsx +229 -237
- package/src/client/components/settings/categories/agent-settings/ModelPicker.tsx +71 -0
- package/src/client/components/settings/categories/agent-settings/SidebarList.tsx +14 -2
- package/src/client/components/settings/categories/agent-settings/levels.ts +38 -0
- package/src/client/components/settings/categories/behavior-settings/Editor.tsx +27 -7
- package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +23 -5
- package/src/client/components/settings/categories/command-settings/DetailPane.tsx +75 -33
- package/src/client/components/settings/categories/command-settings/SidebarList.tsx +7 -0
- package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +91 -76
- package/src/client/components/settings/categories/mcp-settings/EnvVarsSection.tsx +83 -0
- package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +26 -13
- package/src/client/components/settings/categories/mcp-settings/SidebarList.tsx +20 -0
- package/src/client/components/settings/categories/omp-settings/ConfigTabs.tsx +97 -36
- package/src/client/components/settings/categories/omp-settings/EngineHeader.tsx +151 -0
- package/src/client/components/settings/categories/omp-settings/ExtensionsPanel.tsx +68 -32
- package/src/client/components/settings/categories/omp-settings/OrderedChips.tsx +119 -0
- package/src/client/components/settings/categories/omp-settings/PresetBar.tsx +14 -7
- package/src/client/components/settings/categories/omp-settings/RoleEditor.tsx +15 -6
- package/src/client/components/settings/categories/omp-settings/RowEditor.tsx +165 -226
- package/src/client/components/settings/categories/omp-settings/types.ts +28 -0
- package/src/client/components/settings/categories/project-settings/AccentPalette.test.tsx +189 -0
- package/src/client/components/settings/categories/project-settings/AccentPalette.tsx +156 -24
- package/src/client/components/settings/categories/project-settings/AddProjectModal.tsx +175 -0
- package/src/client/components/settings/categories/project-settings/DeleteProjectModal.tsx +107 -0
- package/src/client/components/settings/categories/project-settings/DetailsForm.tsx +40 -24
- package/src/client/components/settings/categories/project-settings/DetailsHeader.tsx +17 -7
- package/src/client/components/settings/categories/project-settings/IconGrid.tsx +164 -69
- package/src/client/components/settings/categories/project-settings/ModelDropdown.test.tsx +122 -0
- package/src/client/components/settings/categories/project-settings/ModelDropdown.tsx +124 -53
- package/src/client/components/settings/categories/project-settings/NameInput.tsx +57 -11
- package/src/client/components/settings/categories/project-settings/PathField.tsx +122 -0
- package/src/client/components/settings/categories/project-settings/SidebarList.tsx +100 -59
- package/src/client/components/settings/categories/skill-catalog/GitImportPanel.tsx +253 -0
- package/src/client/components/settings/categories/skill-catalog/SkillCard.tsx +89 -0
- package/src/client/components/settings/categories/skill-catalog/SourceRail.tsx +122 -0
- package/src/client/components/settings/categories/skill-catalog/catalog-ui.test.tsx +179 -0
- package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +236 -0
- package/src/client/components/settings/categories/skill-settings/DetailPane.tsx +164 -239
- package/src/client/components/settings/categories/skill-settings/InstructionsEditor.tsx +84 -0
- package/src/client/components/settings/categories/skill-settings/SidebarList.tsx +144 -87
- package/src/client/components/settings/categories/skill-settings/pane.test.tsx +188 -0
- package/src/client/components/settings/categories/skill-settings/row-meta.ts +58 -0
- package/src/client/components/settings/categories/token-usage-settings/Breakdown.tsx +242 -102
- package/src/client/components/settings/categories/token-usage-settings/Chart.tsx +130 -56
- package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +135 -0
- package/src/client/components/settings/categories/token-usage-settings/MetricsGrid.tsx +55 -33
- package/src/client/components/settings/categories/token-usage-settings/Provenance.tsx +59 -0
- package/src/client/components/settings/categories/token-usage-settings/panel.test.tsx +239 -0
- package/src/client/components/workspace/browser-panel/Screencast.test.ts +1 -0
- package/src/client/components/workspace/browser-panel/Screencast.tsx +17 -22
- package/src/client/components/workspace/browser-panel/TabStrip.test.tsx +158 -0
- package/src/client/components/workspace/browser-panel/TabStrip.tsx +90 -0
- package/src/client/components/workspace/browser-panel/index.tsx +50 -4
- package/src/client/components/workspace/browser-toolbar/index.tsx +41 -1
- package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +13 -2
- package/src/client/components/workspace/chat-timeline/index.tsx +6 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.test.ts +88 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +24 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.test.ts +46 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.tsx +15 -6
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.test.ts +34 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +5 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.test.ts +29 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +11 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactChip.tsx +7 -6
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.test.ts +24 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.ts +6 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.test.tsx +237 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +191 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +1 -1
- package/src/client/components/workspace/diff-panel/MergeDiffView.tsx +21 -7
- package/src/client/components/workspace/diff-panel/changes.test.ts +51 -0
- package/src/client/components/workspace/diff-panel/changes.ts +28 -12
- package/src/client/components/workspace/diff-panel/merge.test.ts +28 -0
- package/src/client/components/workspace/diff-panel/merge.ts +21 -1
- package/src/client/components/workspace/editor/Body.tsx +7 -0
- package/src/client/components/workspace/editor/FileDocument.tsx +15 -21
- package/src/client/components/workspace/editor/FilePane.tsx +12 -0
- package/src/client/components/workspace/editor/PreviewPane.tsx +70 -0
- package/src/client/components/workspace/editor/Toolbar.tsx +17 -1
- package/src/client/components/workspace/editor/index.tsx +25 -22
- package/src/client/components/workspace/editor/toolbar-clusters.test.ts +14 -0
- package/src/client/components/workspace/editor/toolbar-clusters.tsx +12 -86
- package/src/client/components/workspace/editor/toolbar-toggle.tsx +53 -0
- package/src/client/components/workspace/editor/toolbar-write-clusters.tsx +112 -0
- package/src/client/components/workspace/editor/viewers/SvgPreview.tsx +18 -2
- package/src/client/components/workspace/editor/viewers/viewers.test.ts +39 -0
- package/src/client/components/workspace/file-explorer/ContextMenu.tsx +18 -5
- package/src/client/components/workspace/file-explorer/Modals.tsx +15 -1
- package/src/client/components/workspace/file-explorer/RowLabel.tsx +68 -0
- package/src/client/components/workspace/file-explorer/TreeItem.tsx +47 -57
- package/src/client/components/workspace/file-explorer/collapsed-chain.test.ts +167 -0
- package/src/client/components/workspace/file-explorer/drag-props.ts +42 -0
- package/src/client/components/workspace/file-explorer/drag.test.ts +43 -0
- package/src/client/components/workspace/file-explorer/index.tsx +21 -20
- package/src/client/components/workspace/git-panel/commit-modal.test.ts +5 -3
- package/src/client/components/workspace/user-browser-panel/AddressBar.tsx +5 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateBar.test.tsx +201 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateBar.tsx +112 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateLayer.test.tsx +225 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateLayer.tsx +217 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateTarget.tsx +99 -0
- package/src/client/components/workspace/user-browser-panel/Frame.tsx +30 -1
- package/src/client/components/workspace/user-browser-panel/index.tsx +81 -2
- package/src/client/data/agent-data/builtin.ts +0 -10
- package/src/client/data/agent-data/orchestrator.ts +0 -45
- package/src/client/data/agent-data/specialist.ts +0 -100
- package/src/client/data/mock/token-usage.ts +170 -120
- package/src/client/data/settings/omp-schema.json +123 -4
- package/src/client/data/settings/project.ts +9 -28
- package/src/client/data/settings/skill.ts +6 -32
- package/src/client/hooks/browser/use-annotate.test.ts +143 -0
- package/src/client/hooks/browser/use-annotate.ts +98 -0
- package/src/client/hooks/browser/use-close-tab.test.ts +148 -0
- package/src/client/hooks/browser/use-close-tab.ts +67 -0
- package/src/client/hooks/browser/use-screencast.ts +13 -1
- package/src/client/hooks/chat/composer/browser-context.test.ts +117 -0
- package/src/client/hooks/chat/composer/browser-context.ts +40 -16
- package/src/client/hooks/chat/composer/items.test.ts +1 -1
- package/src/client/hooks/chat/composer/review-context.ts +38 -0
- package/src/client/hooks/chat/composer/use-draft.test.ts +132 -0
- package/src/client/hooks/chat/composer/use-draft.ts +31 -2
- package/src/client/hooks/chat/timeline/pending-model.ts +28 -0
- package/src/client/hooks/chat/timeline/row-window.test.ts +15 -2
- package/src/client/hooks/editor/use-document-annotations.ts +124 -0
- package/src/client/hooks/editor/use-editor-panel-ui.ts +52 -0
- package/src/client/hooks/editor/use-file-review-mode.ts +35 -0
- package/src/client/hooks/editor/use-preview-review.ts +148 -0
- package/src/client/hooks/settings/agents.ts +149 -0
- package/src/client/hooks/settings/crud-list.test.ts +28 -6
- package/src/client/hooks/settings/crud-list.ts +96 -57
- package/src/client/hooks/settings/omp-config.ts +164 -0
- package/src/client/hooks/settings/projects/index.ts +294 -0
- package/src/client/hooks/settings/projects.test.ts +237 -0
- package/src/client/hooks/settings/skill-catalog.ts +101 -9
- package/src/client/hooks/settings/skill-git-import.ts +153 -0
- package/src/client/hooks/settings/useTokenUsage.ts +125 -0
- package/src/client/hooks/settings/write-feedback.test.ts +104 -0
- package/src/client/hooks/settings/write-feedback.ts +63 -0
- package/src/client/hooks/shell/servers.test.ts +166 -0
- package/src/client/hooks/{desktop → shell}/servers.ts +17 -14
- package/src/client/hooks/ui/markdown-hydration.ts +125 -0
- package/src/client/hooks/ui/updates/index.test.ts +100 -1
- package/src/client/hooks/ui/updates/index.ts +50 -0
- package/src/client/hooks/ui/updates/notes.test.ts +138 -0
- package/src/client/hooks/ui/updates/notes.ts +57 -0
- package/src/client/hooks/ui/updates/shell-download.ts +1 -1
- package/src/client/hooks/ui/updates/shell-update.ts +2 -6
- package/src/client/hooks/workspace/file-row-drag.ts +41 -0
- package/src/client/hooks/workspace/file-tree-actions.ts +25 -1
- package/src/client/hooks/workspace/file-tree-edits.ts +23 -6
- package/src/client/hooks/workspace/root-drop-target.ts +77 -0
- package/src/client/hooks/workspace/unfolded-chains.ts +165 -0
- package/src/client/lib/browser/element-at.test.ts +229 -0
- package/src/client/lib/browser/element-at.ts +139 -0
- package/src/client/lib/desktop/dropped-paths.ts +1 -1
- package/src/client/lib/desktop/titlebar.test.ts +12 -3
- package/src/client/lib/desktop/titlebar.ts +1 -1
- package/src/client/lib/review/client.ts +73 -0
- package/src/client/lib/router/search-params.ts +42 -20
- package/src/client/lib/shell/desktop.ts +117 -0
- package/src/client/lib/shell/servers.ts +75 -0
- package/src/client/lib/shell/transport.ts +216 -0
- package/src/client/main.tsx +9 -0
- package/src/client/tailwind.css +65 -0
- package/src/server/lib/btw/lifecycle.server.ts +2 -2
- package/src/server/lib/db/schema.ts +7 -0
- package/src/server/lib/db/seed-terminal.test.ts +4 -0
- package/src/server/lib/fs/git-merge-conflict.test.ts +14 -1
- package/src/server/lib/omp/config/agent-definitions.test.ts +273 -0
- package/src/server/lib/omp/config/agents.ts +231 -61
- package/src/server/lib/omp/config/definitions.test.ts +9 -105
- package/src/server/lib/omp/config/extensions.ts +16 -7
- package/src/server/lib/omp/config/omp-config-files.test.ts +27 -0
- package/src/server/lib/omp/config/skill-sources.ts +49 -0
- package/src/server/lib/omp/config/skills-git-install.ts +155 -0
- package/src/server/lib/omp/config/skills-git-repo.ts +288 -0
- package/src/server/lib/omp/config/skills-git.test.ts +220 -0
- package/src/server/lib/omp/rpc/constants.test.ts +11 -0
- package/src/server/lib/omp/rpc/constants.ts +15 -0
- package/src/server/lib/omp/rpc/process.ts +11 -14
- package/src/server/lib/omp/rpc/session-commands.ts +6 -3
- package/src/server/lib/omp/rpc/utility-agent-dir.test.ts +134 -0
- package/src/server/lib/omp/rpc/utility-agent-dir.ts +138 -0
- package/src/server/lib/omp/rpc/utility.ts +12 -0
- package/src/server/lib/review/schema.server.ts +45 -0
- package/src/server/lib/review/store.server.ts +138 -0
- package/src/server/lib/terminal/attach-replay.test.ts +132 -0
- package/src/server/lib/terminal/output.test.ts +166 -0
- package/src/server/lib/terminal/output.ts +104 -0
- package/src/server/lib/terminal/runtime.server.ts +5 -0
- package/src/server/lib/terminal/send-result.test.ts +33 -0
- package/src/server/lib/terminal/send-result.ts +32 -0
- package/src/server/lib/terminal/session.server.ts +45 -11
- package/src/server/lib/terminal/store-liveness.test.ts +4 -0
- package/src/server/lib/updates/active-notes.test.ts +149 -0
- package/src/server/lib/updates/active-notes.ts +75 -0
- package/src/server/lib/updates/changelog-file.ts +42 -11
- package/src/server/lib/updates/changelog.test.ts +15 -1
- package/src/server/lib/updates/omp.ts +42 -15
- package/src/server/lib/updates/release-url.ts +27 -1
- package/src/server/lib/usage/index-parse.test.ts +200 -0
- package/src/server/lib/usage/index-parse.ts +178 -0
- package/src/server/lib/usage/index-query.server.ts +248 -0
- package/src/server/lib/usage/index-scan.server.ts +343 -0
- package/src/server/lib/usage/index-schema.server.ts +82 -0
- package/src/server/lib/usage/index.test.ts +234 -0
- package/src/server/lib/usage/providers.server.ts +4 -53
- package/src/server/lib/workspace/project-model.server.test.ts +102 -0
- package/src/server/lib/workspace/project-model.server.ts +47 -0
- package/src/server/lib/workspace/project-patch.server.ts +156 -0
- package/src/server/routes/agent/new.ts +8 -1
- package/src/server/routes/browser/index.ts +3 -0
- package/src/server/routes/browser/stream.ts +31 -2
- package/src/server/routes/browser/tabs.test.ts +94 -0
- package/src/server/routes/browser/tabs.ts +85 -0
- package/src/server/routes/index.ts +2 -0
- package/src/server/routes/review/bindings.ts +11 -0
- package/src/server/routes/review/index.ts +127 -0
- package/src/server/routes/review/routes.test.ts +191 -0
- package/src/server/routes/settings/agents.test.ts +180 -0
- package/src/server/routes/settings/agents.ts +99 -94
- package/src/server/routes/settings/mcp.test.ts +135 -0
- package/src/server/routes/settings/mcp.ts +14 -6
- package/src/server/routes/settings/projects.ts +53 -19
- package/src/server/routes/settings/settings-projects-routes.test.ts +214 -0
- package/src/server/routes/settings/settings-store-routes.test.ts +11 -115
- package/src/server/routes/settings/skills-catalog-actions.ts +195 -0
- package/src/server/routes/settings/skills.test.ts +225 -0
- package/src/server/routes/settings/skills.ts +18 -15
- package/src/server/routes/telemetry/tokens.test.ts +145 -0
- package/src/server/routes/telemetry/tokens.ts +70 -149
- package/src/server/routes/terminal/ws.ts +6 -5
- package/src/server/routes/updates/index.ts +2 -0
- package/src/server/routes/updates/notes.ts +34 -0
- package/src/server/routes/updates/routes.test.ts +49 -0
- package/src/shared/lib/browser/annotate.test.ts +283 -0
- package/src/shared/lib/browser/annotate.ts +231 -0
- package/src/shared/lib/browser/browser-viewer.test.ts +26 -4
- package/src/shared/lib/browser/frame-gate.test.ts +91 -0
- package/src/shared/lib/browser/frame-gate.ts +69 -0
- package/src/shared/lib/browser/frame-params.test.ts +43 -0
- package/src/shared/lib/browser/frame-params.ts +60 -0
- package/src/shared/lib/browser/frame-pipeline.test.ts +132 -0
- package/src/shared/lib/browser/frame-pipeline.ts +80 -0
- package/src/shared/lib/browser/page-context.ts +60 -4
- package/src/shared/lib/browser/snapshot.test.ts +115 -0
- package/src/shared/lib/browser/snapshot.ts +112 -0
- package/src/shared/lib/browser/tab-close.test.ts +74 -0
- package/src/shared/lib/browser/tab-close.ts +77 -0
- package/src/shared/lib/browser/viewer.ts +45 -26
- package/src/shared/lib/chat/timeline/block-chrome.ts +19 -0
- package/src/shared/lib/chat/timeline/tool-render-mode.ts +17 -4
- package/src/shared/lib/chat/tool/artifact.ts +55 -20
- package/src/shared/lib/chat/tool/bash-facts.ts +96 -0
- package/src/shared/lib/chat/tool/minimized.test.ts +98 -0
- package/src/shared/lib/chat/tool/minimized.ts +64 -0
- package/src/shared/lib/chat/tool/summary.test.ts +28 -8
- package/src/shared/lib/chat/tool/summary.ts +3 -32
- package/src/shared/lib/fs/folder-chain.test.ts +81 -1
- package/src/shared/lib/fs/folder-chain.ts +84 -0
- package/src/shared/lib/markdown/blocks/anchor.ts +63 -0
- package/src/shared/lib/markdown/blocks/blocks.test.ts +141 -0
- package/src/shared/lib/markdown/blocks/renderer.ts +120 -0
- package/src/shared/lib/markdown/blocks/scan.ts +100 -0
- package/src/shared/lib/markdown/blocks/types.ts +62 -0
- package/src/shared/lib/markdown/marked.ts +58 -147
- package/src/shared/lib/markdown/math-extensions.ts +168 -0
- package/src/shared/lib/markdown/review/prompt.ts +77 -0
- package/src/shared/lib/markdown/review/reconcile.ts +55 -0
- package/src/shared/lib/markdown/review/review.test.ts +96 -0
- package/src/shared/lib/markdown/xml-sections.test.ts +140 -0
- package/src/shared/lib/markdown/xml-sections.ts +139 -0
- package/src/shared/lib/models/provider/label.ts +57 -0
- package/src/shared/lib/omp/config/agent-file.test.ts +54 -0
- package/src/shared/lib/omp/config/agent-file.ts +43 -0
- package/src/shared/lib/omp/config/row-value.test.ts +95 -0
- package/src/shared/lib/omp/config/row-value.ts +97 -0
- package/src/shared/lib/omp/config/schema.test.ts +66 -0
- package/src/shared/lib/omp/config/schema.ts +6 -0
- package/src/shared/lib/omp/rpc/frame.test.ts +48 -47
- package/src/shared/lib/omp/rpc/frame.ts +49 -40
- package/src/shared/lib/omp/session/job-progress.test.ts +37 -1
- package/src/shared/lib/omp/session/job-progress.ts +31 -0
- package/src/shared/lib/omp/session/proc.ts +5 -0
- package/src/shared/lib/omp/session/wait.ts +5 -0
- package/src/shared/lib/ui/menu-anchor.test.ts +69 -0
- package/src/shared/lib/ui/menu-anchor.ts +89 -0
- package/src/shared/lib/ui/mobile-overlay.ts +61 -0
- package/src/shared/lib/ui/svg-scope.test.ts +97 -0
- package/src/shared/lib/ui/svg-scope.ts +134 -0
- package/src/shared/lib/usage/breakdown.test.ts +197 -0
- package/src/shared/lib/usage/breakdown.ts +241 -0
- package/src/shared/lib/usage/range.test.ts +204 -0
- package/src/shared/lib/usage/range.ts +240 -0
- package/src/shared/lib/usage/view.test.ts +85 -0
- package/src/shared/lib/usage/view.ts +74 -0
- package/src/shared/lib/workspace/project-accent.test.ts +69 -0
- package/src/shared/lib/workspace/project-accent.ts +63 -0
- package/src/shared/lib/workspace/project-icon.ts +40 -0
- package/src/shared/lib/workspace/project-model.test.ts +79 -0
- package/src/shared/lib/workspace/project-model.ts +64 -0
- package/src/shared/types/browser.ts +78 -0
- package/src/shared/types/index.ts +1 -0
- package/src/shared/types/settings/agent.ts +28 -6
- package/src/shared/types/settings/skill.ts +53 -3
- package/src/shared/types/settings/state.ts +4 -3
- package/src/shared/types/settings/write.ts +6 -0
- package/src/shared/types/tokenUsage.ts +128 -21
- package/src/shared/types/updates.ts +20 -0
- package/src/test-support/file-explorer-disk.test-util.ts +25 -1
- package/src/test-support/file-explorer-drag.test-util.ts +88 -0
- package/src/test-support/file-explorer.test-util.ts +47 -47
- package/dist/client/static/js/index-fjnq2z2d.css +0 -1
- package/src/client/components/common/code-surface/indent-guide.ts +0 -104
- package/src/client/components/common/server-switcher/index.test.tsx +0 -150
- package/src/client/components/settings/categories/skill-catalog/AddSourceModal.tsx +0 -133
- package/src/client/hooks/desktop/servers.test.ts +0 -73
- package/src/client/lib/desktop/bridge.ts +0 -203
- package/src/server/lib/omp/session/usage/aggregate-shaping.test.ts +0 -149
- package/src/server/lib/omp/session/usage/aggregate.test.ts +0 -243
- package/src/server/lib/omp/session/usage/aggregate.ts +0 -330
- package/src/server/lib/omp/session/usage/shaping.ts +0 -130
- package/src/shared/lib/code/editor/indent-guide-rule.test.ts +0 -65
- package/src/shared/lib/code/editor/indent-guide-rule.ts +0 -47
|
@@ -26,13 +26,23 @@ export interface SkillItem {
|
|
|
26
26
|
catalogSource?: string;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* A git repository offered as a skill source.
|
|
31
|
+
*
|
|
32
|
+
* There is deliberately no star count and no "last updated" here: Kabmo never
|
|
33
|
+
* fetched either one, and the two used to be rendered from literals (`'1.2K'`,
|
|
34
|
+
* `'Just now'`) — a panel stating a number no request produced. `skillCount` is
|
|
35
|
+
* `null` until a scan of that repository reports a real one, and the card says
|
|
36
|
+
* "Not scanned" rather than inventing a number.
|
|
37
|
+
*/
|
|
29
38
|
export interface SkillCatalogSource {
|
|
30
39
|
id: string;
|
|
31
40
|
name: string;
|
|
32
41
|
repo: string;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
42
|
+
/** SKILL.md files found by the last scan, or null when never scanned. */
|
|
43
|
+
skillCount: number | null;
|
|
44
|
+
/** Epoch ms of the last successful scan, or null. */
|
|
45
|
+
scannedAt?: number | null;
|
|
36
46
|
isCustom?: boolean;
|
|
37
47
|
}
|
|
38
48
|
|
|
@@ -45,4 +55,44 @@ export interface CatalogSkillItem {
|
|
|
45
55
|
githubUrl?: string;
|
|
46
56
|
instructions?: string;
|
|
47
57
|
installed?: boolean;
|
|
58
|
+
/** Install count reported by skills.sh; absent for a git-repo entry. */
|
|
59
|
+
installs?: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** One SKILL.md found inside a cloned repository. */
|
|
63
|
+
export interface GitSkillEntry {
|
|
64
|
+
/** Repo-relative directory holding the SKILL.md, e.g. `skills/review-pr`. */
|
|
65
|
+
path: string;
|
|
66
|
+
name: string;
|
|
67
|
+
description: string;
|
|
68
|
+
/** False when omp would refuse to load it (no `description` in frontmatter). */
|
|
69
|
+
loadable: boolean;
|
|
70
|
+
/** A skill with this name is already installed, so a plain install skips it. */
|
|
71
|
+
installed?: boolean;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** What `inspect_git_repo` answers: the repository and the skills inside it. */
|
|
75
|
+
export interface GitRepoInspection {
|
|
76
|
+
repo: string;
|
|
77
|
+
/** Branch/tag the clone resolved, when git reported one. */
|
|
78
|
+
ref?: string | null;
|
|
79
|
+
skills: GitSkillEntry[];
|
|
80
|
+
/** Notes worth showing (a scan hit its cap, a subtree was skipped, …). */
|
|
81
|
+
notes: string[];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** How an imported skill is installed. */
|
|
85
|
+
export type GitSkillInstallMode =
|
|
86
|
+
/** Copy the SKILL.md directory into a root Kabmo owns; editable here. */
|
|
87
|
+
| 'managed_copy'
|
|
88
|
+
/** `bunx skills add` into `~/.agents/skills`; read-only here, updatable. */
|
|
89
|
+
| 'registry';
|
|
90
|
+
|
|
91
|
+
export interface GitSkillInstallResult {
|
|
92
|
+
repo: string;
|
|
93
|
+
mode: GitSkillInstallMode;
|
|
94
|
+
installed: string[];
|
|
95
|
+
skipped: Array<{ name: string; reason: string }>;
|
|
96
|
+
/** The refreshed discovery list, so the pane needs no second round trip. */
|
|
97
|
+
skills: SkillItem[];
|
|
48
98
|
}
|
|
@@ -100,9 +100,10 @@ export interface SettingsState {
|
|
|
100
100
|
chatWidthMode: ChatWidthMode;
|
|
101
101
|
/**
|
|
102
102
|
* How a tool call is drawn in the transcript (`card` | `compact` | `trace` |
|
|
103
|
-
* `minimal`). A reading style: every mode renders the same call,
|
|
104
|
-
* body — only the frame, density and grouping change. Global, like
|
|
105
|
-
* width, because density is a property of the person and the
|
|
103
|
+
* `minimal` | `tui`). A reading style: every mode renders the same call,
|
|
104
|
+
* facts and body — only the frame, density and grouping change. Global, like
|
|
105
|
+
* the chat width, because density is a property of the person and the
|
|
106
|
+
* display.
|
|
106
107
|
*/
|
|
107
108
|
toolRenderStyle: ToolRenderMode;
|
|
108
109
|
/**
|
|
@@ -1,44 +1,151 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Token Usage surface's wire contract (`GET /api/telemetry/tokens`).
|
|
8
|
+
*
|
|
9
|
+
* One payload carries every view the panel can draw for the requested period:
|
|
10
|
+
* totals, the provider → model tree, the per-day rows the chart and the time
|
|
11
|
+
* breakdown are both derived from, and the project rows. The breakdown tabs
|
|
12
|
+
* therefore cost no request — they re-bucket data the client already holds.
|
|
13
|
+
*
|
|
14
|
+
* Every number here is RAW. Formatting (`$1.23`, `2.2M`) is the client's job,
|
|
15
|
+
* because a formatted string cannot be re-aggregated and cannot be compared
|
|
16
|
+
* against a threshold.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The PERIOD the panel reports — the one thing the header's switch selects.
|
|
21
|
+
*
|
|
22
|
+
* `today`/`7d`/`30d`/`90d` are trailing calendar spans ending today, labelled
|
|
23
|
+
* Day/Week/Month/90 days; `all` is unbounded. None of them is a grouping
|
|
24
|
+
* cadence: a period is a period, and every figure on the panel is the total for
|
|
25
|
+
* exactly that period.
|
|
26
|
+
*/
|
|
2
27
|
export type TimeRangeType = 'today' | '7d' | '30d' | '90d' | 'all' | 'custom';
|
|
3
|
-
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* How the selected period is chopped up for the chart and the time tab only.
|
|
31
|
+
*
|
|
32
|
+
* Derived from the period's own length (`granularityFor`), never chosen by the
|
|
33
|
+
* user: a month draws days, a quarter draws weeks, all time draws months.
|
|
34
|
+
*/
|
|
35
|
+
export type BucketGranularity = 'day' | 'week' | 'month';
|
|
36
|
+
/** Breakdown tabs. `provider` and `model` render as one two-level tree. */
|
|
37
|
+
export type BreakdownTab = 'provider' | 'model' | 'day' | 'project';
|
|
4
38
|
export type ChartMetric = 'cost' | 'tokens';
|
|
5
39
|
|
|
6
|
-
export interface
|
|
40
|
+
export interface TimeRangeOption {
|
|
41
|
+
id: TimeRangeType;
|
|
7
42
|
label: string;
|
|
8
|
-
|
|
9
|
-
|
|
43
|
+
/** The dates this range covers, already formatted for the header. */
|
|
44
|
+
dateRange: string;
|
|
10
45
|
}
|
|
11
46
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
47
|
+
/** Token and cost counters shared by every rollup row. */
|
|
48
|
+
export interface UsageCounters {
|
|
49
|
+
cost: number;
|
|
50
|
+
tokens: number;
|
|
51
|
+
input: number;
|
|
52
|
+
output: number;
|
|
53
|
+
cacheRead: number;
|
|
54
|
+
cacheWrite: number;
|
|
55
|
+
reasoning: number;
|
|
56
|
+
/** Cache-read rate: the observed input that was served from cache. */
|
|
57
|
+
cacheReadCost: number;
|
|
58
|
+
/** Usage records folded into this row. */
|
|
59
|
+
records: number;
|
|
60
|
+
/** Records carrying tokens but no provider-reported cost. */
|
|
61
|
+
unpriced: number;
|
|
15
62
|
}
|
|
16
63
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
tokens: string;
|
|
22
|
-
sharePercent: number;
|
|
23
|
-
dotColorClass: string;
|
|
64
|
+
/** Totals for the selected period. */
|
|
65
|
+
export interface UsageTotals extends UsageCounters {
|
|
66
|
+
/** Distinct days with at least one record. */
|
|
67
|
+
activeDays: number;
|
|
24
68
|
}
|
|
25
69
|
|
|
26
|
-
|
|
27
|
-
|
|
70
|
+
/** One point of the flat chart series (single line, e.g. the mobile view). */
|
|
71
|
+
export interface ChartSeriesPoint {
|
|
28
72
|
label: string;
|
|
29
|
-
|
|
73
|
+
cost: number;
|
|
74
|
+
tokens: number;
|
|
30
75
|
}
|
|
31
76
|
|
|
77
|
+
/** Display strings behind the headline tiles, already formatted. */
|
|
32
78
|
export interface TokenUsageMetricSet {
|
|
33
79
|
rawCost: string;
|
|
80
|
+
costPerMillion: string;
|
|
34
81
|
processedTokens: string;
|
|
35
82
|
activeRate: string;
|
|
36
83
|
cachedInput: string;
|
|
37
84
|
cachedPercent: string;
|
|
38
85
|
uncachedInput: string;
|
|
86
|
+
cacheWrite: string;
|
|
39
87
|
outputTokens: string;
|
|
40
88
|
reasoning: string;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
89
|
+
records: number;
|
|
90
|
+
unpricedRecords: number;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** One model under a provider. `model` is omp's own id, verbatim. */
|
|
94
|
+
export interface UsageModelRow extends UsageCounters {
|
|
95
|
+
model: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** One provider, with its models ordered by cost. */
|
|
99
|
+
export interface UsageProviderRow extends UsageCounters {
|
|
100
|
+
/** Canonical provider slug — stable identity, used as the selection key. */
|
|
101
|
+
id: string;
|
|
102
|
+
/** Display name (`Kenari.id`, `DeepSeek`, `Command Code`, …). */
|
|
103
|
+
name: string;
|
|
104
|
+
models: UsageModelRow[];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** One calendar day, with the per-provider split the stacked chart needs. */
|
|
108
|
+
export interface UsageDayRow extends UsageCounters {
|
|
109
|
+
/** `YYYY-MM-DD` in the reader's local calendar. */
|
|
110
|
+
day: string;
|
|
111
|
+
/** Cost/tokens keyed by canonical provider slug. */
|
|
112
|
+
providers: Record<string, { cost: number; tokens: number }>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** One project (the sessions-tree folder the transcript lives in). */
|
|
116
|
+
export interface UsageProjectRow extends UsageCounters {
|
|
117
|
+
project: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** How far the on-disk index has got, shown in the panel's footer. */
|
|
121
|
+
export interface UsageIndexState {
|
|
122
|
+
/** `building` while a scan is in flight; the panel polls and keeps the data. */
|
|
123
|
+
state: 'ready' | 'building' | 'failed';
|
|
124
|
+
/** Transcripts indexed (or visited so far, while building). */
|
|
125
|
+
transcripts: number;
|
|
126
|
+
/** Usage records indexed across every period. */
|
|
127
|
+
records: number;
|
|
128
|
+
/** Epoch ms of the last completed scan. */
|
|
129
|
+
indexedAt: number;
|
|
130
|
+
/** Wall-clock cost of that scan, so a slow disk is visible rather than guessed. */
|
|
131
|
+
scanMs: number;
|
|
132
|
+
/** Sentence for the panel when `state` is `failed`. */
|
|
133
|
+
error?: string;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Response body of `GET /api/telemetry/tokens`. */
|
|
137
|
+
export interface TokenUsagePayload {
|
|
138
|
+
generatedAt: number;
|
|
139
|
+
index: UsageIndexState;
|
|
140
|
+
timeRanges: TimeRangeOption[];
|
|
141
|
+
range: TimeRangeType;
|
|
142
|
+
/** Human period label, e.g. `Oct 5 – Nov 3, 2026`. */
|
|
143
|
+
periodLabel: string;
|
|
144
|
+
totals: UsageTotals;
|
|
145
|
+
/** Providers ordered by cost, each with its models ordered by cost. */
|
|
146
|
+
providers: UsageProviderRow[];
|
|
147
|
+
/** Daily rows ordered by day, ascending. */
|
|
148
|
+
days: UsageDayRow[];
|
|
149
|
+
/** Projects ordered by cost. */
|
|
150
|
+
projects: UsageProjectRow[];
|
|
44
151
|
}
|
|
@@ -78,6 +78,26 @@ export interface UpdateChangelog {
|
|
|
78
78
|
error: string | null;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* The release notes for the version a target is ACTUALLY RUNNING.
|
|
83
|
+
*
|
|
84
|
+
* This is the About modal's pair of "What's new" buttons: the update popup
|
|
85
|
+
* answers "what would I get", these answer "what am I running". Both versions
|
|
86
|
+
* are read server-side from the install itself, never from the caller, so the
|
|
87
|
+
* section shown always belongs to the copy on disk.
|
|
88
|
+
*/
|
|
89
|
+
export interface ActiveReleaseNotes {
|
|
90
|
+
target: UpdateTarget;
|
|
91
|
+
/** The installed/running version whose section is shown, or null when unreadable. */
|
|
92
|
+
version: string | null;
|
|
93
|
+
/** That version's changelog section, or null when the file does not name it. */
|
|
94
|
+
note: ReleaseNote | null;
|
|
95
|
+
/** The repository changelog, for the "Full changelog" link. */
|
|
96
|
+
changelogUrl: string;
|
|
97
|
+
/** Human-readable reason `note` is absent, or null. */
|
|
98
|
+
error: string | null;
|
|
99
|
+
}
|
|
100
|
+
|
|
81
101
|
export interface UpdateApplyResult {
|
|
82
102
|
success: boolean;
|
|
83
103
|
target: UpdateTarget;
|
|
@@ -48,13 +48,37 @@ function splitPath(path: string): { dir: string; name: string } {
|
|
|
48
48
|
return cut === -1 ? { dir: '.', name: path } : { dir: path.slice(0, cut), name: path.slice(cut + 1) };
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Apply a rename: remove the old entry, write the new one, kind preserved.
|
|
53
|
+
*
|
|
54
|
+
* A FOLDER takes its subtree with it — `fs.rename` moves the directory and
|
|
55
|
+
* everything under it, and a double that moved only the top entry would let a
|
|
56
|
+
* spec assert a tree the real route never produces (the reported rename of a
|
|
57
|
+
* collapsed chain left the levels beneath it behind for exactly that reason).
|
|
58
|
+
* Every directory the old path owned is rekeyed, and the entry is then placed
|
|
59
|
+
* the way a create places one.
|
|
60
|
+
*/
|
|
52
61
|
export function moveOnDisk(disk: Disk, fromPath: string, toPath: string): void {
|
|
53
62
|
const from = splitPath(fromPath);
|
|
54
63
|
const source = disk[from.dir];
|
|
55
64
|
const kind = source?.[from.name] === null ? 'folder' : 'file';
|
|
56
65
|
if (source) delete source[from.name];
|
|
66
|
+
if (kind === 'folder') {
|
|
67
|
+
const children = Object.keys(disk)
|
|
68
|
+
.filter((key) => key === fromPath || key.startsWith(`${fromPath}/`))
|
|
69
|
+
.map((key) => [key, disk[key]!] as const);
|
|
70
|
+
for (const [key] of children) delete disk[key];
|
|
71
|
+
for (const [key, listing] of children) disk[`${toPath}${key.slice(fromPath.length)}`] = listing;
|
|
72
|
+
}
|
|
57
73
|
const to = splitPath(toPath);
|
|
74
|
+
// The real route creates the destination's parents (`mkdir -p`), which is
|
|
75
|
+
// what makes a rename INTO a new nested folder work.
|
|
76
|
+
let parent = '';
|
|
77
|
+
for (const segment of to.dir === '.' ? [] : to.dir.split('/')) {
|
|
78
|
+
listingOf(disk, parent || '.')[segment] = null;
|
|
79
|
+
parent = parent ? `${parent}/${segment}` : segment;
|
|
80
|
+
listingOf(disk, parent);
|
|
81
|
+
}
|
|
58
82
|
writeToDisk(disk, to.dir, to.name, kind);
|
|
59
83
|
}
|
|
60
84
|
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Files panel harness's drag gestures, as a sequence of real DOM events.
|
|
8
|
+
*
|
|
9
|
+
* Split from `file-explorer.test-util.ts` (which is at the repository's line
|
|
10
|
+
* ceiling) and kept beside the disk double because the two answer the same
|
|
11
|
+
* question: a drag is only meaningful against a directory model that can move
|
|
12
|
+
* an entry. Three gestures are what the panel's specs drive it with:
|
|
13
|
+
*
|
|
14
|
+
* - **`dragRow`** — start on a row, drop on a row or the background.
|
|
15
|
+
* - **`hoverRow`** — start, hover an accepting row, and STOP. A hovered
|
|
16
|
+
* collapsed chain UNFOLDS, so the level it exposes is a row only afterwards;
|
|
17
|
+
* a spec that drags straight to that level would be aiming at a row that did
|
|
18
|
+
* not exist when the gesture began.
|
|
19
|
+
* - **`releaseDrag`** — let go without dropping anywhere.
|
|
20
|
+
*
|
|
21
|
+
* A real `DataTransfer` does not exist in happy-dom, and the handlers read only
|
|
22
|
+
* `setData`/`getData`/`dropEffect`, so a minimal stand-in is what the event
|
|
23
|
+
* carries — without it the row's `dragstart` handler would throw on `setData`.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { act } from 'preact/test-utils';
|
|
27
|
+
|
|
28
|
+
/** The shape the row handlers read off `event.dataTransfer`. */
|
|
29
|
+
export interface StubTransfer {
|
|
30
|
+
data: Record<string, string>;
|
|
31
|
+
effectAllowed: string;
|
|
32
|
+
dropEffect: string;
|
|
33
|
+
types: string[];
|
|
34
|
+
setData: (type: string, value: string) => void;
|
|
35
|
+
getData: (type: string) => string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The transfer object the drag handlers read (happy-dom has no `DataTransfer`). */
|
|
39
|
+
export function transferOf(): StubTransfer {
|
|
40
|
+
return {
|
|
41
|
+
data: {} as Record<string, string>,
|
|
42
|
+
effectAllowed: '',
|
|
43
|
+
dropEffect: '',
|
|
44
|
+
types: [] as string[],
|
|
45
|
+
setData(type: string, value: string) {
|
|
46
|
+
this.data[type] = value;
|
|
47
|
+
},
|
|
48
|
+
getData(type: string) {
|
|
49
|
+
return this.data[type] ?? '';
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Dispatch one drag action inside `act`, then let the render it queued settle.
|
|
56
|
+
*
|
|
57
|
+
* `passes` is how many empty turns the caller needs afterwards — the panel's own
|
|
58
|
+
* drag path is synchronous, so this is a flush, not a wait.
|
|
59
|
+
*/
|
|
60
|
+
export async function settleDrag(dispatch: () => void, passes: number): Promise<void> {
|
|
61
|
+
await act(async () => {
|
|
62
|
+
dispatch();
|
|
63
|
+
});
|
|
64
|
+
for (let i = 0; i < passes; i += 1) await act(async () => {});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Dispatch one drag event carrying the stub transfer. */
|
|
68
|
+
export function fireDrag(element: HTMLElement, type: string, transfer: StubTransfer): Event {
|
|
69
|
+
const event = new window.Event(type, { bubbles: true, cancelable: true });
|
|
70
|
+
Object.defineProperty(event, 'dataTransfer', { value: transfer });
|
|
71
|
+
element.dispatchEvent(event);
|
|
72
|
+
return event;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The element carrying a row's handlers, found by the row's visible text.
|
|
77
|
+
*
|
|
78
|
+
* The deepest `div` whose own text is exactly the name is the row's inner
|
|
79
|
+
* content, and the element that CLOSES over `[draggable]` is the handler row —
|
|
80
|
+
* dispatching on the wrapper would bubble past the row into the panel
|
|
81
|
+
* background, which is a different drop target.
|
|
82
|
+
*/
|
|
83
|
+
export function rowElementFor(container: HTMLElement, name: string): HTMLElement {
|
|
84
|
+
const matches = [...container.querySelectorAll('div')].filter((el) => el.textContent?.trim() === name);
|
|
85
|
+
const inner = matches[matches.length - 1];
|
|
86
|
+
if (!inner) throw new Error(`no row named ${name}`);
|
|
87
|
+
return (inner.closest('[draggable]') as HTMLElement | null) ?? (inner.parentElement as HTMLElement);
|
|
88
|
+
}
|
|
@@ -27,6 +27,7 @@ import { installDomGlobals, pristineWebSocket, restoreDomGlobals } from '@/test-
|
|
|
27
27
|
import type { TopicResolver } from '@/server/lib/realtime/hub.server';
|
|
28
28
|
import type { GitStatusPayload } from '@/server/lib/fs/git-status-read';
|
|
29
29
|
import { diskHas, entriesOf, moveOnDisk, writeToDisk, type Disk } from '@/test-support/file-explorer-disk.test-util';
|
|
30
|
+
import { fireDrag, rowElementFor, settleDrag, transferOf } from '@/test-support/file-explorer-drag.test-util';
|
|
30
31
|
|
|
31
32
|
export type { Disk } from '@/test-support/file-explorer-disk.test-util';
|
|
32
33
|
|
|
@@ -80,12 +81,30 @@ export interface FileExplorerHarness {
|
|
|
80
81
|
clickMenuRow: (label: string) => Promise<void>;
|
|
81
82
|
/** Drag `from` onto `to` (or the background when null): dragstart, dragover, drop. */
|
|
82
83
|
dragRow: (from: string, to: string | null) => Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Hover `over` with `from` in flight and stop there.
|
|
86
|
+
*
|
|
87
|
+
* A drop is not always the whole story: a hovered collapsed chain UNFOLDS, and
|
|
88
|
+
* the level it exposed is a row only once that has happened — which is what a
|
|
89
|
+
* drag to `dev/src/main` inside the row labelled `dev/src/main/code` needs.
|
|
90
|
+
*/
|
|
91
|
+
hoverRow: (from: string, over: string) => Promise<void>;
|
|
92
|
+
/** Let go of a drag started by `hoverRow`, without dropping it anywhere. */
|
|
93
|
+
releaseDrag: (from: string) => Promise<void>;
|
|
94
|
+
/** Start a drag and leave it in flight over nothing. */
|
|
95
|
+
startDrag: (from: string) => Promise<void>;
|
|
96
|
+
/** Drop the drag in flight on the panel background — the listing root. */
|
|
97
|
+
dropOnBackground: () => Promise<void>;
|
|
98
|
+
/** The element carrying a row's drag handlers, by the row's visible text. */
|
|
99
|
+
rowFor: (name: string) => HTMLElement;
|
|
83
100
|
/** DOM globals for the whole file (call from beforeAll / afterAll). */
|
|
84
101
|
install: () => void;
|
|
85
102
|
restore: () => void;
|
|
86
103
|
}
|
|
87
104
|
|
|
88
105
|
export function createFileExplorerHarness(): FileExplorerHarness {
|
|
106
|
+
/** The transfer of a drag left in flight by `startDrag`. */
|
|
107
|
+
let inFlight = transferOf();
|
|
89
108
|
const harness: FileExplorerHarness = {
|
|
90
109
|
disk: {},
|
|
91
110
|
dirReads: [],
|
|
@@ -295,53 +314,34 @@ export function createFileExplorerHarness(): FileExplorerHarness {
|
|
|
295
314
|
for (let i = 0; i < 5; i += 1) await act(async () => {});
|
|
296
315
|
},
|
|
297
316
|
async dragRow(from, to) {
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
Object.defineProperty(event, 'dataTransfer', { value: transfer });
|
|
327
|
-
element.dispatchEvent(event);
|
|
328
|
-
return event;
|
|
329
|
-
};
|
|
330
|
-
await act(async () => {
|
|
331
|
-
fire(source, 'dragstart');
|
|
332
|
-
});
|
|
333
|
-
for (let i = 0; i < 3; i += 1) await act(async () => {});
|
|
334
|
-
await act(async () => {
|
|
335
|
-
fire(target, 'dragover');
|
|
336
|
-
});
|
|
337
|
-
for (let i = 0; i < 3; i += 1) await act(async () => {});
|
|
338
|
-
await act(async () => {
|
|
339
|
-
fire(target, 'drop');
|
|
340
|
-
});
|
|
341
|
-
await act(async () => {
|
|
342
|
-
fire(source, 'dragend');
|
|
343
|
-
});
|
|
344
|
-
for (let i = 0; i < 20; i += 1) await act(async () => {});
|
|
317
|
+
const source = harness.rowFor(from);
|
|
318
|
+
const target = to === null ? harness.panelBackground() : harness.rowFor(to);
|
|
319
|
+
const transfer = transferOf();
|
|
320
|
+
await settleDrag(() => fireDrag(source, 'dragstart', transfer), 3);
|
|
321
|
+
await settleDrag(() => fireDrag(target, 'dragover', transfer), 3);
|
|
322
|
+
await settleDrag(() => fireDrag(target, 'drop', transfer), 0);
|
|
323
|
+
await settleDrag(() => fireDrag(source, 'dragend', transfer), 20);
|
|
324
|
+
},
|
|
325
|
+
async hoverRow(from, over) {
|
|
326
|
+
inFlight = transferOf();
|
|
327
|
+
await settleDrag(() => fireDrag(harness.rowFor(from), 'dragstart', inFlight), 3);
|
|
328
|
+
await settleDrag(() => fireDrag(harness.rowFor(over), 'dragover', inFlight), 5);
|
|
329
|
+
},
|
|
330
|
+
async releaseDrag(from) {
|
|
331
|
+
await settleDrag(() => fireDrag(harness.rowFor(from), 'dragend', inFlight), 20);
|
|
332
|
+
},
|
|
333
|
+
async startDrag(from) {
|
|
334
|
+
inFlight = transferOf();
|
|
335
|
+
await settleDrag(() => fireDrag(harness.rowFor(from), 'dragstart', inFlight), 3);
|
|
336
|
+
},
|
|
337
|
+
async dropOnBackground() {
|
|
338
|
+
const background = harness.panelBackground();
|
|
339
|
+
await settleDrag(() => fireDrag(background, 'dragenter', inFlight), 3);
|
|
340
|
+
await settleDrag(() => fireDrag(background, 'dragover', inFlight), 3);
|
|
341
|
+
await settleDrag(() => fireDrag(background, 'drop', inFlight), 20);
|
|
342
|
+
},
|
|
343
|
+
rowFor(name: string) {
|
|
344
|
+
return rowElementFor(harness.container, name);
|
|
345
345
|
},
|
|
346
346
|
};
|
|
347
347
|
return harness;
|