@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
|
@@ -132,6 +132,8 @@ interface RenameModalProps {
|
|
|
132
132
|
isFolder: boolean;
|
|
133
133
|
renameValue: string;
|
|
134
134
|
originalPath: string;
|
|
135
|
+
/** The row's label, when it differs from the path (a collapsed chain). */
|
|
136
|
+
displayName?: string;
|
|
135
137
|
/** The server's refusal (an existing destination, a bad path), shown inline. */
|
|
136
138
|
error?: string | null;
|
|
137
139
|
isLoading: boolean;
|
|
@@ -148,8 +150,13 @@ interface RenameModalProps {
|
|
|
148
150
|
* `lib/deep/a.ts` both renames the file and moves it, and its parents are
|
|
149
151
|
* created on the way. A leaf-only field would have made that a create-then-
|
|
150
152
|
* delete, which is not a rename.
|
|
153
|
+
*
|
|
154
|
+
* A collapsed chain row is LABELLED `dev/src/main/code` while its path is the
|
|
155
|
+
* deepest directory only, so the field shows the path and the dialog says which
|
|
156
|
+
* of the two it renames — typing the label would otherwise move the deepest
|
|
157
|
+
* directory out and leave the rest of the chain behind.
|
|
151
158
|
*/
|
|
152
|
-
export function FileRenameModal({ isFolder, renameValue, originalPath, error, isLoading, onChange, onCancel, onSubmit }: RenameModalProps) {
|
|
159
|
+
export function FileRenameModal({ isFolder, renameValue, originalPath, displayName, error, isLoading, onChange, onCancel, onSubmit }: RenameModalProps) {
|
|
153
160
|
return createPortal(
|
|
154
161
|
<div className="fixed inset-0 bg-ink/20 z-[100] flex items-center justify-center p-4 backdrop-blur-sm">
|
|
155
162
|
<form onSubmit={onSubmit} className="bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans">
|
|
@@ -167,6 +174,13 @@ export function FileRenameModal({ isFolder, renameValue, originalPath, error, is
|
|
|
167
174
|
<p className="text-[10px] text-ink/40 mb-2">
|
|
168
175
|
Paths are relative to the tree — <span className="font-mono">lib/deep/name.ts</span> moves it too.
|
|
169
176
|
</p>
|
|
177
|
+
{displayName && (
|
|
178
|
+
<p className="text-[11px] text-ink/50 mb-2">
|
|
179
|
+
The row is <span className="font-mono">{displayName}</span>; this renames{' '}
|
|
180
|
+
<span className="font-mono">{originalPath}</span>. Use{' '}
|
|
181
|
+
<span className="font-mono">Unfold Folders</span> to rename a folder inside the chain.
|
|
182
|
+
</p>
|
|
183
|
+
)}
|
|
170
184
|
{error && <p className="text-[11px] text-error mb-2">{error}</p>}
|
|
171
185
|
<div className="flex justify-end space-x-2">
|
|
172
186
|
<button
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Files panel's row LABEL: the disclosure glyph, the icon, the name and the
|
|
8
|
+
* two git marks.
|
|
9
|
+
*
|
|
10
|
+
* Split from `TreeItem.tsx` because it is the row's leaf markup and has no
|
|
11
|
+
* behaviour of its own — every fact it draws is derived by the row and handed
|
|
12
|
+
* in, so the split costs no prop drilling and keeps the row component under the
|
|
13
|
+
* repository's line ceiling.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { ChevronDown, ChevronRight } from 'lucide-preact';
|
|
17
|
+
import { FileIcon } from '@/client/components/common/file-icon';
|
|
18
|
+
import type { FolderGitStatusInfo } from '@/shared/lib/fs/git-status';
|
|
19
|
+
|
|
20
|
+
interface TreeRowLabelProps {
|
|
21
|
+
name: string;
|
|
22
|
+
path: string;
|
|
23
|
+
isFolder: boolean;
|
|
24
|
+
isOpen: boolean;
|
|
25
|
+
/** Git-ignored entries render faded rather than being hidden. */
|
|
26
|
+
ignored: boolean;
|
|
27
|
+
/** This file's own change, when it has one. */
|
|
28
|
+
gitStatus: { colorClass: string; label: string; charStatus: string } | null;
|
|
29
|
+
/** The roll-up a folder wears instead: one dot, its tone from the changes. */
|
|
30
|
+
folderStatus: FolderGitStatusInfo | null | undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function TreeRowLabel({ name, path, isFolder, isOpen, ignored, gitStatus, folderStatus }: TreeRowLabelProps) {
|
|
34
|
+
const tone = gitStatus ? gitStatus.colorClass : folderStatus ? folderStatus.colorClass : ignored ? 'text-ink/40' : '';
|
|
35
|
+
return (
|
|
36
|
+
<>
|
|
37
|
+
{isFolder ? (
|
|
38
|
+
isOpen ? <ChevronDown size={12} className="flex-shrink-0 text-ink/40" /> : <ChevronRight size={12} className="flex-shrink-0 text-ink/40" />
|
|
39
|
+
) : (
|
|
40
|
+
<span className="w-3 flex-shrink-0"></span>
|
|
41
|
+
)}
|
|
42
|
+
|
|
43
|
+
<FileIcon name={name} isFolder={isFolder} isOpen={isOpen} size={12} className={`flex-shrink-0${ignored ? ' opacity-40' : ''}`} />
|
|
44
|
+
<span className={`truncate min-w-0 flex-1 ${tone}`} title={ignored ? `${path} — git-ignored` : undefined}>
|
|
45
|
+
{name}
|
|
46
|
+
</span>
|
|
47
|
+
|
|
48
|
+
{gitStatus && (
|
|
49
|
+
<span
|
|
50
|
+
className={`font-mono text-[9px] font-bold px-1 rounded flex-shrink-0 ${gitStatus.colorClass}`}
|
|
51
|
+
title={`Git: ${gitStatus.label}`}
|
|
52
|
+
>
|
|
53
|
+
{gitStatus.charStatus}
|
|
54
|
+
</span>
|
|
55
|
+
)}
|
|
56
|
+
|
|
57
|
+
{folderStatus && (
|
|
58
|
+
<span
|
|
59
|
+
className={`w-1.5 h-1.5 rounded-full flex-shrink-0 ${
|
|
60
|
+
folderStatus.hasDeleted ? 'bg-error' :
|
|
61
|
+
folderStatus.hasModified || folderStatus.hasStaged ? 'bg-info' : 'bg-success'
|
|
62
|
+
}`}
|
|
63
|
+
title={`${folderStatus.count} changed file${folderStatus.count > 1 ? 's' : ''}`}
|
|
64
|
+
/>
|
|
65
|
+
)}
|
|
66
|
+
</>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { useEffect, useState } from 'preact/hooks';
|
|
2
|
-
import {
|
|
3
|
-
import { FileIcon } from '@/client/components/common/file-icon';
|
|
2
|
+
import { TreeRowLabel } from '@/client/components/workspace/file-explorer/RowLabel';
|
|
4
3
|
import { FileContextMenu } from '@/client/components/workspace/file-explorer/ContextMenu';
|
|
5
4
|
import { FileCreateModal, FileDeleteModal, FileHistoryModal, FileRenameModal } from '@/client/components/workspace/file-explorer/Modals';
|
|
6
5
|
import { getGitStatusInfo, type FolderGitStatusInfo } from '@/shared/lib/fs/git-status';
|
|
6
|
+
import { isChainRow } from '@/shared/lib/fs/folder-chain';
|
|
7
7
|
import { useFileActions } from '@/client/hooks/workspace/file-tree-actions';
|
|
8
8
|
import { useFileRowDrag } from '@/client/hooks/workspace/file-row-drag';
|
|
9
9
|
import { useOnClickOutside } from '@/client/hooks/ui/on-click-outside';
|
|
10
10
|
import { useLongPress } from '@/client/hooks/ui/long-press';
|
|
11
11
|
import type { FileClipboard, ClipboardTarget } from '@/client/hooks/workspace/file-clipboard';
|
|
12
|
+
import type { FileTreeDragProps } from '@/client/components/workspace/file-explorer/drag-props';
|
|
12
13
|
import type { GitChange } from '@/shared/types/git';
|
|
13
14
|
|
|
14
|
-
interface FileTreeItemProps {
|
|
15
|
+
interface FileTreeItemProps extends FileTreeDragProps {
|
|
15
16
|
file: any;
|
|
16
17
|
rootPath?: string;
|
|
17
18
|
/** Absolute base dir of the listing (server-reported `root`), anchors Copy Path. */
|
|
@@ -31,12 +32,6 @@ interface FileTreeItemProps {
|
|
|
31
32
|
gitFolderMap?: Map<string, FolderGitStatusInfo>;
|
|
32
33
|
/** The panel's clipboard — one instance for the whole tree, passed down. */
|
|
33
34
|
clipboard: FileClipboard;
|
|
34
|
-
/** The row currently being dragged, or null. Panel state: see `FileTreeItem`. */
|
|
35
|
-
dragging: ClipboardTarget | null;
|
|
36
|
-
/** A drag of this row started / ended / was dropped on `target`. */
|
|
37
|
-
onDragStart: (target: ClipboardTarget) => void;
|
|
38
|
-
onDragEnd: () => void;
|
|
39
|
-
onDropOn: (target: ClipboardTarget) => void;
|
|
40
35
|
/**
|
|
41
36
|
* True on a device typed into with a finger. A row is a drag SOURCE, and on
|
|
42
37
|
* touch a long press starts a native drag of the whole panel — the reported
|
|
@@ -87,6 +82,9 @@ export function FileTreeItem({
|
|
|
87
82
|
onDragStart,
|
|
88
83
|
onDragEnd,
|
|
89
84
|
onDropOn,
|
|
85
|
+
onUnfold,
|
|
86
|
+
onFold,
|
|
87
|
+
foldRoots,
|
|
90
88
|
touch = false,
|
|
91
89
|
}: FileTreeItemProps) {
|
|
92
90
|
const isFolder = file.type === 'folder';
|
|
@@ -126,6 +124,21 @@ export function FileTreeItem({
|
|
|
126
124
|
}
|
|
127
125
|
}, [isFolder, actualIsOpen, file.children, file.path, onLoadChildren, isLoadingChildren, attempted]);
|
|
128
126
|
|
|
127
|
+
/**
|
|
128
|
+
* The row as a drag source and a drop target.
|
|
129
|
+
*
|
|
130
|
+
* The row's own identity is what both roles need: a drop on a FILE lands in
|
|
131
|
+
* that file's directory — the same rule a paste obeys (`pasteTargetDir`) — so
|
|
132
|
+
* a drop beside a file is a real destination rather than an invisible one.
|
|
133
|
+
* The handlers themselves live in the hook, which owns the two platform facts
|
|
134
|
+
* they depend on (see `useFileRowDrag`).
|
|
135
|
+
*/
|
|
136
|
+
const target: ClipboardTarget = {
|
|
137
|
+
path: file.path,
|
|
138
|
+
name: file.name,
|
|
139
|
+
kind: isFolder ? 'folder' : 'file',
|
|
140
|
+
};
|
|
141
|
+
|
|
129
142
|
const actions = useFileActions({
|
|
130
143
|
file: { path: file.path, name: file.name, basePath, rootPath, repo },
|
|
131
144
|
diff: { staged: gitChange?.staged || (gitChange?.status ? gitChange.status[0] !== ' ' && gitChange.status[0] !== '?' : false), status: gitStatusInfo?.charStatus },
|
|
@@ -133,6 +146,13 @@ export function FileTreeItem({
|
|
|
133
146
|
onActionComplete,
|
|
134
147
|
onCreated,
|
|
135
148
|
onRenamed,
|
|
149
|
+
// A collapsed chain row's label names directories that are not rows, so an
|
|
150
|
+
// unfold is the only way to reach the ones inside it.
|
|
151
|
+
onUnfold: onUnfold && isChainRow({ type: isFolder ? 'folder' : 'file', name: file.name }) ? () => onUnfold(target) : undefined,
|
|
152
|
+
// An UNFOLDED chain draws `dev` → `src` → `main` → `code`, and folding is
|
|
153
|
+
// asked for on the row that starts it: the outermost level named by the
|
|
154
|
+
// chain the listing actually folded.
|
|
155
|
+
onFold: onFold && foldRoots?.has(file.path) ? () => onFold(foldRoots.get(file.path)!) : undefined,
|
|
136
156
|
clipboard,
|
|
137
157
|
isFolder,
|
|
138
158
|
});
|
|
@@ -182,72 +202,36 @@ export function FileTreeItem({
|
|
|
182
202
|
actions.openContextMenu(e.clientX, e.clientY);
|
|
183
203
|
};
|
|
184
204
|
|
|
185
|
-
|
|
186
|
-
* The row as a drag source and a drop target.
|
|
187
|
-
*
|
|
188
|
-
* The row's own identity is what both roles need: a drop on a FILE lands in
|
|
189
|
-
* that file's directory — the same rule a paste obeys (`pasteTargetDir`) — so
|
|
190
|
-
* a drop beside a file is a real destination rather than an invisible one.
|
|
191
|
-
* The handlers themselves live in the hook, which owns the two platform facts
|
|
192
|
-
* they depend on (see `useFileRowDrag`).
|
|
193
|
-
*/
|
|
194
|
-
const target: ClipboardTarget = {
|
|
195
|
-
path: file.path,
|
|
196
|
-
name: file.name,
|
|
197
|
-
kind: isFolder ? 'folder' : 'file',
|
|
198
|
-
};
|
|
199
|
-
const drag = useFileRowDrag({ target, dragging, clipboard, onDragStart, onDragEnd, onDropOn });
|
|
205
|
+
const drag = useFileRowDrag({ target, dragging, clipboard, onDragStart, onDragEnd, onDropOn, onHoverAccept: onUnfold });
|
|
200
206
|
|
|
201
207
|
return (
|
|
202
208
|
<div>
|
|
203
209
|
<div
|
|
204
210
|
className={`flex items-center space-x-1.5 py-1 px-2 hover:bg-ink/5 cursor-pointer rounded group select-none ${
|
|
205
211
|
drag.isDragging ? 'opacity-40' : ''
|
|
206
|
-
} ${drag.
|
|
212
|
+
} ${drag.isDropHovered ? 'bg-info/10 ring-1 ring-info/40 ring-inset' : ''}`}
|
|
207
213
|
draggable={!touch}
|
|
208
214
|
onClick={handleToggle}
|
|
209
215
|
onContextMenu={handleContextMenu}
|
|
210
216
|
onDragStart={drag.onDragStart}
|
|
211
217
|
onDragEnd={drag.onDragEnd}
|
|
212
218
|
onDragOver={drag.onDragOver}
|
|
219
|
+
onDragLeave={drag.onDragLeave}
|
|
213
220
|
onDrop={drag.onDrop}
|
|
214
221
|
onTouchStart={longPress.onTouchStart}
|
|
215
222
|
onTouchMove={longPress.onTouchMove}
|
|
216
223
|
onTouchEnd={longPress.onTouchEnd}
|
|
217
224
|
onTouchCancel={longPress.onTouchCancel}
|
|
218
225
|
>
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
title={isIgnored ? `${file.path} — git-ignored` : undefined}
|
|
229
|
-
>
|
|
230
|
-
{file.name}
|
|
231
|
-
</span>
|
|
232
|
-
|
|
233
|
-
{gitStatusInfo && (
|
|
234
|
-
<span
|
|
235
|
-
className={`font-mono text-[9px] font-bold px-1 rounded flex-shrink-0 ${gitStatusInfo.colorClass}`}
|
|
236
|
-
title={`Git: ${gitStatusInfo.label}`}
|
|
237
|
-
>
|
|
238
|
-
{gitStatusInfo.charStatus}
|
|
239
|
-
</span>
|
|
240
|
-
)}
|
|
241
|
-
|
|
242
|
-
{folderStatus && (
|
|
243
|
-
<span
|
|
244
|
-
className={`w-1.5 h-1.5 rounded-full flex-shrink-0 ${
|
|
245
|
-
folderStatus.hasDeleted ? 'bg-error' :
|
|
246
|
-
folderStatus.hasModified || folderStatus.hasStaged ? 'bg-info' : 'bg-success'
|
|
247
|
-
}`}
|
|
248
|
-
title={`${folderStatus.count} changed file${folderStatus.count > 1 ? 's' : ''}`}
|
|
249
|
-
/>
|
|
250
|
-
)}
|
|
226
|
+
<TreeRowLabel
|
|
227
|
+
name={file.name}
|
|
228
|
+
path={file.path}
|
|
229
|
+
isFolder={isFolder}
|
|
230
|
+
isOpen={actualIsOpen}
|
|
231
|
+
ignored={isIgnored}
|
|
232
|
+
gitStatus={gitStatusInfo}
|
|
233
|
+
folderStatus={folderStatus}
|
|
234
|
+
/>
|
|
251
235
|
</div>
|
|
252
236
|
|
|
253
237
|
{actualIsOpen && isLoadingChildren && (
|
|
@@ -277,6 +261,9 @@ export function FileTreeItem({
|
|
|
277
261
|
onDragStart={onDragStart}
|
|
278
262
|
onDragEnd={onDragEnd}
|
|
279
263
|
onDropOn={onDropOn}
|
|
264
|
+
onUnfold={onUnfold}
|
|
265
|
+
onFold={onFold}
|
|
266
|
+
foldRoots={foldRoots}
|
|
280
267
|
touch={touch}
|
|
281
268
|
/>
|
|
282
269
|
))}
|
|
@@ -290,6 +277,8 @@ export function FileTreeItem({
|
|
|
290
277
|
isFolder={isFolder}
|
|
291
278
|
hasGitStatus={hasGitStatus}
|
|
292
279
|
pasteLabel={actions.pasteLabel}
|
|
280
|
+
chainLabel={actions.chainLabel}
|
|
281
|
+
foldable={actions.foldable}
|
|
293
282
|
busy={actions.busy}
|
|
294
283
|
onAction={actions.handleAction}
|
|
295
284
|
/>
|
|
@@ -324,6 +313,7 @@ export function FileTreeItem({
|
|
|
324
313
|
isFolder={isFolder}
|
|
325
314
|
renameValue={actions.renameValue}
|
|
326
315
|
originalPath={file.path}
|
|
316
|
+
displayName={isChainRow({ type: isFolder ? 'folder' : 'file', name: file.name }) ? file.name : undefined}
|
|
327
317
|
error={actions.renameError}
|
|
328
318
|
isLoading={actions.busy}
|
|
329
319
|
onChange={actions.setRenameValue}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A collapsed folder chain is ONE row standing for several directories, and
|
|
8
|
+
* that is where both reported bugs came from.
|
|
9
|
+
*
|
|
10
|
+
* `dev/src/main/code` is drawn as a single row whose `path` is the DEEPEST
|
|
11
|
+
* directory, so the levels inside its label are not rows at all:
|
|
12
|
+
*
|
|
13
|
+
* - **A drop** on the row landed in `code`, because that was the only path the
|
|
14
|
+
* row could name — dragging something onto `main` was impossible.
|
|
15
|
+
* - **A rename** could only address `code`, so typing `dev2/src/main` moved it
|
|
16
|
+
* out and left `dev/src/main` behind, and renaming `main` was unexpressible.
|
|
17
|
+
*
|
|
18
|
+
* The fix is one mechanism on both paths: the chain is UNFOLDED into a row per
|
|
19
|
+
* directory — on a hovering drag, or from the row's menu — after which every
|
|
20
|
+
* level is an ordinary folder that can be dropped on, renamed and created
|
|
21
|
+
* inside. These specs assert the two reported cases through a real DOM, plus
|
|
22
|
+
* the two halves that keep the unfold honest: Fold puts the chain back, and a
|
|
23
|
+
* rename that PRESERVES the chain keeps it unfolded.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
27
|
+
import { createFileExplorerHarness } from '@/test-support/file-explorer.test-util';
|
|
28
|
+
|
|
29
|
+
const panel = createFileExplorerHarness();
|
|
30
|
+
|
|
31
|
+
beforeAll(() => {
|
|
32
|
+
panel.install();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
afterEach(() => {
|
|
36
|
+
panel.unmount();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
afterAll(() => {
|
|
40
|
+
panel.restore();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
/** `dev/src/main/code/a.ts`: four directories, three of them folded away. */
|
|
44
|
+
const CHAIN = {
|
|
45
|
+
'.': { dev: null },
|
|
46
|
+
dev: { src: null },
|
|
47
|
+
'dev/src': { main: null },
|
|
48
|
+
'dev/src/main': { code: null },
|
|
49
|
+
'dev/src/main/code': { 'a.ts': 'file' },
|
|
50
|
+
} as const;
|
|
51
|
+
|
|
52
|
+
describe('Files panel collapsed chains', () => {
|
|
53
|
+
test('dragging onto a level inside the chain drops there, not in the deepest folder', async () => {
|
|
54
|
+
panel.disk = { ...structuredClone(CHAIN), '.': { dev: null, 'moved.ts': 'file' } } as never;
|
|
55
|
+
await panel.mount();
|
|
56
|
+
// One row, naming the whole chain — the levels are not rows yet.
|
|
57
|
+
expect(panel.visibleNames()).toContain('dev/src/main/code');
|
|
58
|
+
|
|
59
|
+
// Hovering the row unfolds it, which is what puts `main` on screen; the
|
|
60
|
+
// drop then lands on the row that names it.
|
|
61
|
+
await panel.hoverRow('moved.ts', 'dev/src/main/code');
|
|
62
|
+
expect(panel.visibleNames()).toContain('main');
|
|
63
|
+
|
|
64
|
+
await panel.dragRow('moved.ts', 'main');
|
|
65
|
+
|
|
66
|
+
expect(panel.transferRequests).toEqual([
|
|
67
|
+
{
|
|
68
|
+
actionType: 'paste',
|
|
69
|
+
sourcePath: 'moved.ts',
|
|
70
|
+
mode: 'cut',
|
|
71
|
+
targetPath: 'dev/src/main',
|
|
72
|
+
targetKind: 'folder',
|
|
73
|
+
root: '/ws',
|
|
74
|
+
},
|
|
75
|
+
]);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('the row menu unfolds the chain, so every level becomes a row', async () => {
|
|
79
|
+
panel.disk = structuredClone(CHAIN) as never;
|
|
80
|
+
await panel.mount();
|
|
81
|
+
|
|
82
|
+
await panel.rightClickRow('dev/src/main/code');
|
|
83
|
+
expect(panel.buttonLabels()).toContain('Unfold Folders');
|
|
84
|
+
await panel.clickMenuRow('Unfold Folders');
|
|
85
|
+
|
|
86
|
+
// Outermost first: each level is its own row, and the levels above the
|
|
87
|
+
// deepest are drawn open (a hidden row would hide the level below it).
|
|
88
|
+
const names = panel.visibleNames();
|
|
89
|
+
for (const name of ['dev', 'src', 'main', 'code']) expect(names).toContain(name);
|
|
90
|
+
expect(names).not.toContain('dev/src/main/code');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('renaming a folder inside the chain renames THAT folder', async () => {
|
|
94
|
+
panel.disk = structuredClone(CHAIN) as never;
|
|
95
|
+
await panel.mount();
|
|
96
|
+
|
|
97
|
+
await panel.rightClickRow('dev/src/main/code');
|
|
98
|
+
await panel.clickMenuRow('Unfold Folders');
|
|
99
|
+
|
|
100
|
+
await panel.rightClickRow('main');
|
|
101
|
+
await panel.clickMenuRow('Rename');
|
|
102
|
+
// The field names the row's own path, which is what makes `dev2/src/main`
|
|
103
|
+
// mean "move `main`" rather than "move the deepest directory".
|
|
104
|
+
expect(panel.renameInput()?.value).toBe('dev/src/main');
|
|
105
|
+
await panel.submitRename('dev2/src/main');
|
|
106
|
+
|
|
107
|
+
expect(panel.renameRequests.at(-1)).toEqual({
|
|
108
|
+
actionType: 'rename',
|
|
109
|
+
path: 'dev/src/main',
|
|
110
|
+
newPath: 'dev2/src/main',
|
|
111
|
+
root: '/ws',
|
|
112
|
+
});
|
|
113
|
+
// `main` moved with everything under it; `dev` and `dev2` are now separate
|
|
114
|
+
// trees, which is what the paths say.
|
|
115
|
+
expect(panel.disk['dev2/src']).toEqual({ main: null });
|
|
116
|
+
expect(panel.disk['dev2/src/main']).toEqual({ code: null });
|
|
117
|
+
expect(panel.disk['dev2/src/main/code']).toEqual({ 'a.ts': 'file' });
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('renaming the chain’s start keeps it unfolded, at its new paths', async () => {
|
|
121
|
+
panel.disk = structuredClone(CHAIN) as never;
|
|
122
|
+
await panel.mount();
|
|
123
|
+
|
|
124
|
+
await panel.rightClickRow('dev/src/main/code');
|
|
125
|
+
await panel.clickMenuRow('Unfold Folders');
|
|
126
|
+
await panel.rightClickRow('dev');
|
|
127
|
+
await panel.clickMenuRow('Rename');
|
|
128
|
+
await panel.submitRename('dev2');
|
|
129
|
+
|
|
130
|
+
const names = panel.visibleNames();
|
|
131
|
+
expect(names).toContain('dev2');
|
|
132
|
+
expect(names).toContain('src');
|
|
133
|
+
expect(names).toContain('main');
|
|
134
|
+
expect(names).toContain('code');
|
|
135
|
+
expect(names).not.toContain('dev');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test('Fold Folders puts the chain back into the one row it is listed as', async () => {
|
|
139
|
+
panel.disk = structuredClone(CHAIN) as never;
|
|
140
|
+
await panel.mount();
|
|
141
|
+
|
|
142
|
+
await panel.rightClickRow('dev/src/main/code');
|
|
143
|
+
await panel.clickMenuRow('Unfold Folders');
|
|
144
|
+
await panel.rightClickRow('dev');
|
|
145
|
+
expect(panel.buttonLabels()).toContain('Fold Folders');
|
|
146
|
+
await panel.clickMenuRow('Fold Folders');
|
|
147
|
+
|
|
148
|
+
expect(panel.visibleNames()).toContain('dev/src/main/code');
|
|
149
|
+
expect(panel.visibleNames()).not.toContain('main');
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test('the rename dialog says which of the two it renames', async () => {
|
|
153
|
+
panel.disk = structuredClone(CHAIN) as never;
|
|
154
|
+
await panel.mount();
|
|
155
|
+
|
|
156
|
+
await panel.rightClickRow('dev/src/main/code');
|
|
157
|
+
await panel.clickMenuRow('Rename');
|
|
158
|
+
|
|
159
|
+
// The row reads as four directories while the rename moves one, and only
|
|
160
|
+
// the dialog can say so — otherwise a path typed from the label leaves the
|
|
161
|
+
// rest of the chain behind.
|
|
162
|
+
const text = panel.documentText();
|
|
163
|
+
expect(text).toContain('this renames');
|
|
164
|
+
expect(text).toContain('dev/src/main/code');
|
|
165
|
+
expect(text).toContain('Unfold Folders');
|
|
166
|
+
});
|
|
167
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Files panel's drag-and-drop contract, shared by the panel and the row.
|
|
8
|
+
*
|
|
9
|
+
* Split from `TreeItem.tsx` because the panel owns every one of these and each
|
|
10
|
+
* row only forwards them: declaring them once is what stops the two from
|
|
11
|
+
* drifting on which of them a nested row must be handed. The behaviour lives in
|
|
12
|
+
* `useFileRowDrag`; this file names what is handed down.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { ClipboardTarget } from '@/client/hooks/workspace/file-clipboard';
|
|
16
|
+
|
|
17
|
+
export interface FileTreeDragProps {
|
|
18
|
+
/** The row currently being dragged, or null. Panel state — see `useFileRowDrag`. */
|
|
19
|
+
dragging: ClipboardTarget | null;
|
|
20
|
+
/** A drag of this row started / ended / was dropped on `target`. */
|
|
21
|
+
onDragStart: (target: ClipboardTarget) => void;
|
|
22
|
+
onDragEnd: () => void;
|
|
23
|
+
onDropOn: (target: ClipboardTarget) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Split a collapsed chain row into one row per directory.
|
|
26
|
+
*
|
|
27
|
+
* A chain row's label names directories that are not rows at all, so they
|
|
28
|
+
* cannot be dropped on or renamed. The panel calls this when a drag hovers an
|
|
29
|
+
* accepting row and when the row's own menu asks for it.
|
|
30
|
+
*/
|
|
31
|
+
onUnfold?: (target: ClipboardTarget) => void;
|
|
32
|
+
/** Fold an unfolded chain back into the one row it is listed as. */
|
|
33
|
+
onFold?: (deepestPath: string) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Outermost level of each unfolded chain → the chain's deepest path.
|
|
36
|
+
*
|
|
37
|
+
* Only the outermost level offers Fold: it is the row the listing folds, and
|
|
38
|
+
* the one that still reads as the chain's beginning once the levels inside it
|
|
39
|
+
* are drawn separately.
|
|
40
|
+
*/
|
|
41
|
+
foldRoots?: ReadonlyMap<string, string>;
|
|
42
|
+
}
|
|
@@ -25,6 +25,12 @@
|
|
|
25
25
|
* already lives in, or a folder into its own subtree, must not reach the
|
|
26
26
|
* server: a request would be a move the user did not ask for.
|
|
27
27
|
*
|
|
28
|
+
* 5. **The blue block belongs to the row under the POINTER, not to every legal
|
|
29
|
+
* target.** It was drawn from `acceptsDrop` — the capability — so a drag
|
|
30
|
+
* painted every folder and file on screen at once and read as "everything is
|
|
31
|
+
* selected" (measured: dragging `a.ts` over `b` and `c` highlighted both).
|
|
32
|
+
* The background's tint had the same bug, over the whole tree.
|
|
33
|
+
*
|
|
28
34
|
* Driven through the shared harness, so this file and the listing specs exercise
|
|
29
35
|
* one mount and one HTTP stub.
|
|
30
36
|
*/
|
|
@@ -145,4 +151,41 @@ describe('Files panel drag and drop', () => {
|
|
|
145
151
|
|
|
146
152
|
expect(panel.dirReads).toContain('.');
|
|
147
153
|
});
|
|
154
|
+
|
|
155
|
+
test('only the row under the pointer is highlighted during a drag', async () => {
|
|
156
|
+
panel.disk = { '.': { 'a.ts': 'file', first: null, second: null }, first: { 'x.ts': 'file' }, second: { 'y.ts': 'file' } };
|
|
157
|
+
await panel.mount();
|
|
158
|
+
|
|
159
|
+
await panel.hoverRow('a.ts', 'first');
|
|
160
|
+
|
|
161
|
+
// `second` would accept the drop just as well, and used to be painted.
|
|
162
|
+
const highlighted = [...panel.container.querySelectorAll('[class*="bg-info"]')]
|
|
163
|
+
.map((el) => el.textContent?.trim() ?? '');
|
|
164
|
+
expect(highlighted).toEqual(['first']);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test('the highlight leaves the row when the pointer does, and the drop still lands', async () => {
|
|
168
|
+
// `a.ts` lives INSIDE `dest`, so dropping it on the background is a real
|
|
169
|
+
// move to the root rather than the no-op the rule refuses.
|
|
170
|
+
panel.disk = { '.': { dest: null, other: null }, dest: { 'a.ts': 'file' }, other: {} };
|
|
171
|
+
await panel.mount();
|
|
172
|
+
await panel.clickRow('dest');
|
|
173
|
+
|
|
174
|
+
await panel.hoverRow('a.ts', 'other');
|
|
175
|
+
expect(panel.container.querySelectorAll('[class*="bg-info"]')).toHaveLength(1);
|
|
176
|
+
|
|
177
|
+
// Leaving the row for the background: the row's block goes out and the
|
|
178
|
+
// drop lands at the root, which is where the pointer is.
|
|
179
|
+
await panel.dropOnBackground();
|
|
180
|
+
expect(panel.transferRequests[0]?.targetPath).toBe('.');
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
test('the background is not tinted for the whole gesture', async () => {
|
|
184
|
+
panel.disk = { '.': { 'a.ts': 'file', dest: null }, dest: {} };
|
|
185
|
+
await panel.mount();
|
|
186
|
+
|
|
187
|
+
// The drag is in flight and no row is hovered: nothing to promise yet.
|
|
188
|
+
await panel.startDrag('a.ts');
|
|
189
|
+
expect(panel.container.querySelectorAll('[class*="bg-info"]')).toHaveLength(0);
|
|
190
|
+
});
|
|
148
191
|
});
|
|
@@ -11,6 +11,7 @@ import { useFileListing } from '@/client/hooks/workspace/file-listing';
|
|
|
11
11
|
import { useFileCreate } from '@/client/hooks/workspace/file-create';
|
|
12
12
|
import { useFileClipboard, type ClipboardTarget } from '@/client/hooks/workspace/file-clipboard';
|
|
13
13
|
import { useFileTreeEdits } from '@/client/hooks/workspace/file-tree-edits';
|
|
14
|
+
import { useUnfoldedChains } from '@/client/hooks/workspace/unfolded-chains';
|
|
14
15
|
import { filterFileTree } from '@/client/components/workspace/file-explorer/filter';
|
|
15
16
|
import { useRepoList, useRepoScope } from '@/client/hooks/workspace/repo-scope';
|
|
16
17
|
import { useRealtimeTopic } from '@/client/hooks/ui/realtime';
|
|
@@ -18,6 +19,8 @@ import { useToasts } from '@/client/hooks/ui/toasts';
|
|
|
18
19
|
import { useTouchDevice } from '@/client/hooks/ui/touch-device';
|
|
19
20
|
import { ToastStack } from '@/client/components/common/ToastStack';
|
|
20
21
|
import { fsTopic } from '@/shared/lib/realtime/protocol';
|
|
22
|
+
import { unfoldChains } from '@/shared/lib/fs/folder-chain';
|
|
23
|
+
import { useRootDropTarget } from '@/client/hooks/workspace/root-drop-target';
|
|
21
24
|
|
|
22
25
|
export function FileExplorer({ className = '', enabled = true, rootPath, onOpenFile, refreshKey = 0, onRefresh }: { className?: string, enabled?: boolean, rootPath?: string, onOpenFile?: (file: any) => void, refreshKey?: number, onRefresh?: () => void }) {
|
|
23
26
|
const [searchQuery, setSearchQuery] = useSessionState<string>('files.searchQuery', '');
|
|
@@ -117,8 +120,15 @@ export function FileExplorer({ className = '', enabled = true, rootPath, onOpenF
|
|
|
117
120
|
setExpandedPaths,
|
|
118
121
|
setStoredExpandedPaths,
|
|
119
122
|
reload: refresh,
|
|
123
|
+
onMoved: (fromPath, toPath) => rekeyUnfold(fromPath, toPath),
|
|
120
124
|
});
|
|
121
125
|
|
|
126
|
+
// A collapsed chain row is ONE row standing for several directories, so the
|
|
127
|
+
// levels inside its label have no row to drop on (a drop lands in the deepest
|
|
128
|
+
// directory) and no row to rename. Unfolding — on a hovering drag, or from the
|
|
129
|
+
// row's own menu — turns each level back into a row.
|
|
130
|
+
const { unfolded, unfold, fold, rekey: rekeyUnfold } = useUnfoldedChains({ scope: listing.scope, setExpandedPaths, setStoredExpandedPaths });
|
|
131
|
+
|
|
122
132
|
// One clipboard for the whole tree, owned here and passed down: a
|
|
123
133
|
// subscription per row would be hundreds of listeners for a value that
|
|
124
134
|
// changes on a right-click.
|
|
@@ -156,11 +166,7 @@ export function FileExplorer({ className = '', enabled = true, rootPath, onOpenF
|
|
|
156
166
|
*/
|
|
157
167
|
const [dragging, setDragging] = useState<ClipboardTarget | null>(null);
|
|
158
168
|
|
|
159
|
-
|
|
160
|
-
* Whether the listing root may accept the drag in flight — the background is
|
|
161
|
-
* a drop target like any other, and the rule is the same one a row uses.
|
|
162
|
-
*/
|
|
163
|
-
const rootAcceptsDrop = Boolean(dragging) && clipboard.moveRefusalFor(dragging!, rootTarget) === null;
|
|
169
|
+
const root = useRootDropTarget({ dragging, clipboard, target: rootTarget });
|
|
164
170
|
|
|
165
171
|
// The root's own "New File": the panel background is the one target whose
|
|
166
172
|
// create belongs at the tree's top, and it is the only action the root menu
|
|
@@ -186,7 +192,8 @@ export function FileExplorer({ className = '', enabled = true, rootPath, onOpenF
|
|
|
186
192
|
|
|
187
193
|
const tree = listing.files;
|
|
188
194
|
|
|
189
|
-
const
|
|
195
|
+
const projected = unfoldChains(tree, unfolded);
|
|
196
|
+
const files = filterFileTree(projected.nodes, searchQuery);
|
|
190
197
|
// The button spins for this panel's own read OR a topic push: the server
|
|
191
198
|
// republishes `fs:` on every tool call, so the tree moved with nothing on
|
|
192
199
|
// screen saying so otherwise.
|
|
@@ -210,7 +217,7 @@ export function FileExplorer({ className = '', enabled = true, rootPath, onOpenF
|
|
|
210
217
|
<div
|
|
211
218
|
className={`flex-1 scrollbar-overlay-container p-2 font-mono text-[11px] text-ink/80 ${
|
|
212
219
|
touch ? 'file-tree-touch' : ''
|
|
213
|
-
} ${
|
|
220
|
+
} ${root.highlighted ? 'bg-info/[0.06]' : ''}`}
|
|
214
221
|
onContextMenu={(e) => {
|
|
215
222
|
// The panel's own background. A row stops propagation before this
|
|
216
223
|
// runs, so this handler only ever sees a right-click that named NO
|
|
@@ -218,19 +225,10 @@ export function FileExplorer({ className = '', enabled = true, rootPath, onOpenF
|
|
|
218
225
|
e.preventDefault();
|
|
219
226
|
setRootMenu({ x: e.clientX, y: e.clientY });
|
|
220
227
|
}}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
if (!rootAcceptsDrop) return;
|
|
226
|
-
e.preventDefault();
|
|
227
|
-
if (e.dataTransfer) e.dataTransfer.dropEffect = 'move';
|
|
228
|
-
}}
|
|
229
|
-
onDrop={(e) => {
|
|
230
|
-
if (!rootAcceptsDrop) return;
|
|
231
|
-
e.preventDefault();
|
|
232
|
-
clipboard.move(dragging!, rootTarget);
|
|
233
|
-
}}
|
|
228
|
+
onDragEnter={root.onDragEnter}
|
|
229
|
+
onDragLeave={root.onDragLeave}
|
|
230
|
+
onDragOver={root.onDragOver}
|
|
231
|
+
onDrop={root.onDrop}
|
|
234
232
|
>
|
|
235
233
|
{listing.isLoading && files.length === 0 ? (
|
|
236
234
|
<div className="p-4 text-center text-ink/40">
|
|
@@ -265,6 +263,9 @@ export function FileExplorer({ className = '', enabled = true, rootPath, onOpenF
|
|
|
265
263
|
if (!dragging) return;
|
|
266
264
|
clipboard.move(dragging, target);
|
|
267
265
|
}}
|
|
266
|
+
onUnfold={unfold}
|
|
267
|
+
onFold={fold}
|
|
268
|
+
foldRoots={projected.roots}
|
|
268
269
|
touch={touch}
|
|
269
270
|
/>
|
|
270
271
|
))
|