@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
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
} from 'lucide-preact';
|
|
8
8
|
import { EditorViewButtons, useEditorViewActions } from '@/client/components/common/editor-view-buttons';
|
|
9
9
|
import { ToolbarRow } from '@/client/components/common/toolbar-row';
|
|
10
|
-
import {
|
|
10
|
+
import { buildEditorClusters } from '@/client/components/workspace/editor/toolbar-clusters';
|
|
11
|
+
import { ACTION_CLASS } from '@/client/components/workspace/editor/toolbar-toggle';
|
|
11
12
|
import { writeKabmoSettings } from '@/shared/lib/settings/client';
|
|
12
13
|
import { EDITOR_BLAME_CHANGED_EVENT, currentEditorBlame, useEditorBlame } from '@/client/hooks/editor/blame-settings';
|
|
13
14
|
|
|
@@ -25,6 +26,13 @@ interface EditorToolbarProps {
|
|
|
25
26
|
*/
|
|
26
27
|
hasPreview: boolean;
|
|
27
28
|
isPreview: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* A rendered markdown document is on screen, so blocks can be judged. False
|
|
31
|
+
* for every other kind: a CSV grid and an SVG picture have no markdown blocks.
|
|
32
|
+
*/
|
|
33
|
+
hasReview: boolean;
|
|
34
|
+
/** Review mode is on for this tab. */
|
|
35
|
+
isReviewing: boolean;
|
|
28
36
|
/** True for the 1.5s after a copy landed, so the button can confirm it. */
|
|
29
37
|
copied: boolean;
|
|
30
38
|
/**
|
|
@@ -59,6 +67,8 @@ interface EditorToolbarProps {
|
|
|
59
67
|
onToggleFind: () => void;
|
|
60
68
|
onSave: () => void;
|
|
61
69
|
onTogglePreview: () => void;
|
|
70
|
+
/** Turn review mode on or off; the panel owns the state. */
|
|
71
|
+
onToggleReview: () => void;
|
|
62
72
|
onToggleWordWrap: () => void;
|
|
63
73
|
onZoomIn: () => void;
|
|
64
74
|
onZoomOut: () => void;
|
|
@@ -94,6 +104,8 @@ export function EditorToolbar({
|
|
|
94
104
|
wordWrap,
|
|
95
105
|
hasPreview,
|
|
96
106
|
isPreview,
|
|
107
|
+
hasReview,
|
|
108
|
+
isReviewing,
|
|
97
109
|
copied,
|
|
98
110
|
byteViewer = false,
|
|
99
111
|
saveDisabled = false,
|
|
@@ -105,6 +117,7 @@ export function EditorToolbar({
|
|
|
105
117
|
onToggleFind,
|
|
106
118
|
onSave,
|
|
107
119
|
onTogglePreview,
|
|
120
|
+
onToggleReview,
|
|
108
121
|
onToggleWordWrap,
|
|
109
122
|
onZoomIn,
|
|
110
123
|
onZoomOut,
|
|
@@ -177,6 +190,8 @@ export function EditorToolbar({
|
|
|
177
190
|
hasPreview,
|
|
178
191
|
isPreview,
|
|
179
192
|
wordWrap,
|
|
193
|
+
hasReview,
|
|
194
|
+
isReviewing,
|
|
180
195
|
blameInline: blame.inline,
|
|
181
196
|
findOpen,
|
|
182
197
|
copied,
|
|
@@ -193,6 +208,7 @@ export function EditorToolbar({
|
|
|
193
208
|
copyLabel: copied ? 'Copied' : byteViewer ? 'Copy image' : 'Copy content',
|
|
194
209
|
maximizeLabel,
|
|
195
210
|
onTogglePreview,
|
|
211
|
+
onToggleReview,
|
|
196
212
|
onToggleFind,
|
|
197
213
|
onToggleWordWrap,
|
|
198
214
|
onToggleBlameInline: () => {
|
|
@@ -27,6 +27,8 @@ import { useSplitEditor } from '@/client/hooks/editor/use-split-editor';
|
|
|
27
27
|
import { useExternalChangeNotice } from '@/client/hooks/editor/use-external-change-notice';
|
|
28
28
|
import { useEditorPanelKeys } from '@/client/hooks/editor/use-editor-panel-keys';
|
|
29
29
|
import { useCloseGuard } from '@/client/hooks/editor/use-close-guard';
|
|
30
|
+
import { useFileReviewMode } from '@/client/hooks/editor/use-file-review-mode';
|
|
31
|
+
import { useEditorPanelUi } from '@/client/hooks/editor/use-editor-panel-ui';
|
|
30
32
|
import type { EditorProps } from '@/client/components/workspace/editor/props';
|
|
31
33
|
|
|
32
34
|
export function Editor({
|
|
@@ -54,18 +56,16 @@ export function Editor({
|
|
|
54
56
|
const activeFile = openedFiles.find(f => f.id === resolvedActiveFileId);
|
|
55
57
|
|
|
56
58
|
const [previewMode, setPreviewMode, previewReady] = useSessionState<Record<string | number, boolean>>('editor.previewMode', {});
|
|
59
|
+
// Review mode: the same per-tab toggle the phone editor uses (one key, one rule).
|
|
60
|
+
// Off by default — the surface swallows block clicks, which is the last thing a
|
|
61
|
+
// reader who only wanted to follow a link asked for.
|
|
62
|
+
const review = useFileReviewMode(String(resolvedActiveFileId ?? ''));
|
|
57
63
|
const [zoomLevel, setZoomLevel] = useSessionState<number>('editor.zoomLevel', EDITOR_DEFAULT_FONT_SIZE);
|
|
58
64
|
const [isMaximized, setIsMaximized] = useState(false);
|
|
59
65
|
const [wordWrap, setWordWrap] = useSessionState<boolean>('editor.wordWrap', true);
|
|
60
|
-
// The panel's
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
const [paletteOpen, setPaletteOpen] = useState(false);
|
|
64
|
-
// A counter, not a boolean: the dialog lives in the document (where the caret and the
|
|
65
|
-
// handle are), so a boolean would need a matching "closed" write from there.
|
|
66
|
-
const [goToLineRequest, setGoToLineRequest] = useState(0);
|
|
67
|
-
const [quickOpen, setQuickOpen] = useState(false);
|
|
68
|
-
const [saveAsOpen, setSaveAsOpen] = useState(false);
|
|
66
|
+
// The panel's transient UI (palette, go-to-line, quick open, Save As) lives in its own
|
|
67
|
+
// hook: all four are things the user is doing right now, and none is persisted.
|
|
68
|
+
const panelUi = useEditorPanelUi();
|
|
69
69
|
const { sessionId } = useSessionStateContext();
|
|
70
70
|
// The split's state and its derived values. `enabled: false` in a split pane, which never
|
|
71
71
|
// splits again — the column has two panes, not a tree.
|
|
@@ -200,7 +200,7 @@ export function Editor({
|
|
|
200
200
|
return;
|
|
201
201
|
}
|
|
202
202
|
if (command === 'goToLine') {
|
|
203
|
-
|
|
203
|
+
panelUi.openGoToLine();
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
206
|
// Everything else is the editor's, and it runs through the editor's own
|
|
@@ -210,11 +210,11 @@ export function Editor({
|
|
|
210
210
|
|
|
211
211
|
const panelKeys = useEditorPanelKeys({
|
|
212
212
|
find,
|
|
213
|
-
paletteOpen,
|
|
214
|
-
setPaletteOpen,
|
|
213
|
+
paletteOpen: panelUi.paletteOpen,
|
|
214
|
+
setPaletteOpen: panelUi.setPaletteOpen,
|
|
215
215
|
runCommand,
|
|
216
216
|
saveNow: editor.saveNow,
|
|
217
|
-
openQuickOpen: () => setQuickOpen(true),
|
|
217
|
+
openQuickOpen: () => panelUi.setQuickOpen(true),
|
|
218
218
|
reopenClosed: onReopenClosed,
|
|
219
219
|
});
|
|
220
220
|
|
|
@@ -244,16 +244,19 @@ export function Editor({
|
|
|
244
244
|
setWordWrap,
|
|
245
245
|
viewerKind,
|
|
246
246
|
isPreview: Boolean(isPreview),
|
|
247
|
+
// A review needs a rendered document: the source view has no blocks.
|
|
248
|
+
isReviewing: Boolean(isPreview) && review.active,
|
|
249
|
+
onToggleReview: review.toggle,
|
|
247
250
|
isMaximized,
|
|
248
251
|
setIsMaximized,
|
|
249
252
|
zoomLevel,
|
|
250
253
|
setZoomLevel,
|
|
251
|
-
paletteOpen,
|
|
252
|
-
setPaletteOpen,
|
|
253
|
-
goToLineRequest,
|
|
254
|
-
onSaveAs: () => setSaveAsOpen(true),
|
|
255
|
-
quickOpen,
|
|
256
|
-
onCloseQuickOpen: () => setQuickOpen(false),
|
|
254
|
+
paletteOpen: panelUi.paletteOpen,
|
|
255
|
+
setPaletteOpen: panelUi.setPaletteOpen,
|
|
256
|
+
goToLineRequest: panelUi.goToLineRequest,
|
|
257
|
+
onSaveAs: () => panelUi.setSaveAsOpen(true),
|
|
258
|
+
quickOpen: panelUi.quickOpen,
|
|
259
|
+
onCloseQuickOpen: () => panelUi.setQuickOpen(false),
|
|
257
260
|
onOpenPath,
|
|
258
261
|
rootPath,
|
|
259
262
|
repoPath,
|
|
@@ -318,10 +321,10 @@ export function Editor({
|
|
|
318
321
|
onReload={editor.resolveConflictByReload}
|
|
319
322
|
onKeepMine={keepMineAgainstDisk}
|
|
320
323
|
body={<EditorBody {...bodyProps} />}
|
|
321
|
-
saveAsOpen={saveAsOpen}
|
|
322
|
-
onSaveAsClose={() => setSaveAsOpen(false)}
|
|
324
|
+
saveAsOpen={panelUi.saveAsOpen}
|
|
325
|
+
onSaveAsClose={() => panelUi.setSaveAsOpen(false)}
|
|
323
326
|
onSavedAs={(path) => {
|
|
324
|
-
setSaveAsOpen(false);
|
|
327
|
+
panelUi.setSaveAsOpen(false);
|
|
325
328
|
// The new file gets its OWN tab and the original stays open, which is what makes
|
|
326
329
|
// Save As reversible by closing one tab.
|
|
327
330
|
onOpenPath?.(path);
|
|
@@ -34,6 +34,9 @@ function state(): ToolbarState {
|
|
|
34
34
|
previewLabel: 'Preview',
|
|
35
35
|
isPreview: false,
|
|
36
36
|
onTogglePreview: noop,
|
|
37
|
+
hasReview: false,
|
|
38
|
+
isReviewing: false,
|
|
39
|
+
onToggleReview: noop,
|
|
37
40
|
findLabel: 'Find and replace',
|
|
38
41
|
findOpen: false,
|
|
39
42
|
onToggleFind: noop,
|
|
@@ -76,6 +79,17 @@ describe('buildEditorClusters order', () => {
|
|
|
76
79
|
expect(pinned).toEqual(['save', 'view-modes', 'maximize']);
|
|
77
80
|
});
|
|
78
81
|
|
|
82
|
+
test('the review toggle exists only where a rendered document can be judged', () => {
|
|
83
|
+
expect(buildEditorClusters(state()).map((cluster) => cluster.id)).not.toContain('review');
|
|
84
|
+
const reviewing = buildEditorClusters({ ...state(), hasReview: true, isReviewing: true });
|
|
85
|
+
expect(reviewing.map((cluster) => cluster.id)).toContain('review');
|
|
86
|
+
// A reading AID, but one that changes what a click means: it sits with the
|
|
87
|
+
// view toggles, after every write and before the reading-only clusters.
|
|
88
|
+
const ids = reviewing.map((cluster) => cluster.id);
|
|
89
|
+
expect(ids.indexOf('review')).toBeGreaterThan(ids.indexOf('save-as'));
|
|
90
|
+
expect(ids.indexOf('review')).toBeLessThan(ids.indexOf('preview'));
|
|
91
|
+
});
|
|
92
|
+
|
|
79
93
|
test('a byte viewer drops the text-only clusters, Save as among them', () => {
|
|
80
94
|
const ids = buildEditorClusters({ ...state(), byteViewer: true }).map((cluster) => cluster.id);
|
|
81
95
|
for (const absent of ['save', 'save-as', 'find', 'wrap', 'blame', 'zoom']) {
|
|
@@ -27,14 +27,10 @@ import type { ComponentChildren } from 'preact';
|
|
|
27
27
|
import {
|
|
28
28
|
Copy,
|
|
29
29
|
Download,
|
|
30
|
-
Eye,
|
|
31
|
-
EyeOff,
|
|
32
30
|
GitCommitVertical,
|
|
33
31
|
Maximize,
|
|
34
32
|
Minimize,
|
|
35
33
|
RotateCcw,
|
|
36
|
-
Save,
|
|
37
|
-
SaveAll,
|
|
38
34
|
Search,
|
|
39
35
|
WrapText,
|
|
40
36
|
ZoomIn,
|
|
@@ -42,16 +38,22 @@ import {
|
|
|
42
38
|
} from 'lucide-preact';
|
|
43
39
|
|
|
44
40
|
import type { ToolbarCluster } from '@/client/components/common/toolbar-row';
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
import {
|
|
42
|
+
previewClusters,
|
|
43
|
+
reviewCluster,
|
|
44
|
+
writeClusters,
|
|
45
|
+
} from '@/client/components/workspace/editor/toolbar-write-clusters';
|
|
46
|
+
import { ACTION_CLASS, Toggle } from '@/client/components/workspace/editor/toolbar-toggle';
|
|
49
47
|
|
|
50
48
|
/** The state the toolbar draws, already resolved by the caller. */
|
|
51
49
|
export interface ToolbarState {
|
|
52
50
|
byteViewer: boolean;
|
|
53
51
|
hasPreview: boolean;
|
|
54
52
|
isPreview: boolean;
|
|
53
|
+
/** The file has annotatable blocks (markdown) and a rendered preview to judge. */
|
|
54
|
+
hasReview: boolean;
|
|
55
|
+
/** Review mode is on, so the button reads as pressed. */
|
|
56
|
+
isReviewing: boolean;
|
|
55
57
|
wordWrap: boolean;
|
|
56
58
|
/** The inline blame label is drawn (the setting, not whether a file has blame). */
|
|
57
59
|
blameInline: boolean;
|
|
@@ -67,6 +69,7 @@ export interface ToolbarState {
|
|
|
67
69
|
copyLabel: string;
|
|
68
70
|
maximizeLabel: string;
|
|
69
71
|
onTogglePreview: () => void;
|
|
72
|
+
onToggleReview: () => void;
|
|
70
73
|
onToggleFind: () => void;
|
|
71
74
|
onToggleWordWrap: () => void;
|
|
72
75
|
onToggleBlameInline: () => void;
|
|
@@ -83,34 +86,6 @@ export interface ToolbarState {
|
|
|
83
86
|
viewModeButtons: ComponentChildren;
|
|
84
87
|
}
|
|
85
88
|
|
|
86
|
-
/** One pressed-state toggle. */
|
|
87
|
-
function Toggle({
|
|
88
|
-
label,
|
|
89
|
-
pressed,
|
|
90
|
-
title,
|
|
91
|
-
onClick,
|
|
92
|
-
children,
|
|
93
|
-
}: {
|
|
94
|
-
label: string;
|
|
95
|
-
pressed: boolean;
|
|
96
|
-
title?: string;
|
|
97
|
-
onClick: () => void;
|
|
98
|
-
children: ComponentChildren;
|
|
99
|
-
}) {
|
|
100
|
-
return (
|
|
101
|
-
<button
|
|
102
|
-
type="button"
|
|
103
|
-
onClick={onClick}
|
|
104
|
-
className={`${ACTION_CLASS} hover:bg-ink/5 ${pressed ? 'text-ink' : 'hover:text-ink'}`}
|
|
105
|
-
title={title ?? label}
|
|
106
|
-
aria-label={label}
|
|
107
|
-
aria-pressed={pressed}
|
|
108
|
-
>
|
|
109
|
-
{children}
|
|
110
|
-
</button>
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
89
|
/**
|
|
115
90
|
* The clusters, in hiding order.
|
|
116
91
|
*
|
|
@@ -123,56 +98,7 @@ function Toggle({
|
|
|
123
98
|
export function buildEditorClusters(state: ToolbarState): ToolbarCluster[] {
|
|
124
99
|
const clusters: ToolbarCluster[] = [];
|
|
125
100
|
|
|
126
|
-
|
|
127
|
-
clusters.push({
|
|
128
|
-
id: 'save',
|
|
129
|
-
// The primary action of the panel: a menu row must never be the only way to
|
|
130
|
-
// save a file.
|
|
131
|
-
pinned: true,
|
|
132
|
-
actions: [{ label: 'Save file', icon: Save, onSelect: state.onSave, disabled: state.saveDisabled }],
|
|
133
|
-
children: state.saveButton,
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
clusters.push({
|
|
137
|
-
id: 'save-as',
|
|
138
|
-
// Never pinned: it is a rare operation, and the row's space belongs to Save.
|
|
139
|
-
// It IS placed directly after Save, because unpinned clusters take the row in
|
|
140
|
-
// ROW ORDER: measured at the 320px floor, the 26px blame cluster added after
|
|
141
|
-
// it claimed the last 30px and pushed `Save as` into `⋯` — a reading aid
|
|
142
|
-
// evicting a write. Sibling writes outrank reading aids here.
|
|
143
|
-
actions: [{ label: 'Save as…', icon: SaveAll, onSelect: state.onSaveAs }],
|
|
144
|
-
children: (
|
|
145
|
-
<button
|
|
146
|
-
type="button"
|
|
147
|
-
onClick={state.onSaveAs}
|
|
148
|
-
className={`${ACTION_CLASS} hover:bg-ink/5 hover:text-ink`}
|
|
149
|
-
title="Save the buffer to a new file"
|
|
150
|
-
aria-label="Save as"
|
|
151
|
-
>
|
|
152
|
-
<SaveAll size={14} />
|
|
153
|
-
</button>
|
|
154
|
-
),
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (state.hasPreview) {
|
|
159
|
-
clusters.push({
|
|
160
|
-
id: 'preview',
|
|
161
|
-
actions: [
|
|
162
|
-
{
|
|
163
|
-
label: state.previewLabel,
|
|
164
|
-
icon: state.isPreview ? EyeOff : Eye,
|
|
165
|
-
onSelect: state.onTogglePreview,
|
|
166
|
-
active: state.isPreview,
|
|
167
|
-
},
|
|
168
|
-
],
|
|
169
|
-
children: (
|
|
170
|
-
<Toggle label={state.previewLabel} pressed={state.isPreview} onClick={state.onTogglePreview}>
|
|
171
|
-
{state.isPreview ? <EyeOff size={14} /> : <Eye size={14} />}
|
|
172
|
-
</Toggle>
|
|
173
|
-
),
|
|
174
|
-
});
|
|
175
|
-
}
|
|
101
|
+
clusters.push(...writeClusters(state), ...reviewCluster(state), ...previewClusters(state));
|
|
176
102
|
|
|
177
103
|
if (!state.byteViewer) {
|
|
178
104
|
clusters.push({
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The editor toolbar's two shared primitives: the icon-button shell and the
|
|
8
|
+
* pressed-state toggle every control in the row is built from.
|
|
9
|
+
*
|
|
10
|
+
* In their own module because both cluster tables (`toolbar-clusters` for the
|
|
11
|
+
* reading aids, `toolbar-write-clusters` for saves and view toggles) draw with
|
|
12
|
+
* them — importing one from the other would be a cycle between two tables that
|
|
13
|
+
* are peers.
|
|
14
|
+
*
|
|
15
|
+
* **Every action is an icon-only `<button>` carrying both a `title` and an
|
|
16
|
+
* `aria-label`** — a bare `<svg onClick>` is unreachable by keyboard and
|
|
17
|
+
* invisible to a screen reader. That rule is the reason this shell exists rather
|
|
18
|
+
* than each call site re-deriving it.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import type { ComponentChildren } from 'preact';
|
|
22
|
+
|
|
23
|
+
/** Shared icon-button shell. */
|
|
24
|
+
export const ACTION_CLASS =
|
|
25
|
+
'flex items-center justify-center p-1.5 rounded transition-colors cursor-pointer disabled:cursor-default disabled:opacity-50';
|
|
26
|
+
|
|
27
|
+
/** One pressed-state toggle. */
|
|
28
|
+
export function Toggle({
|
|
29
|
+
label,
|
|
30
|
+
pressed,
|
|
31
|
+
title,
|
|
32
|
+
onClick,
|
|
33
|
+
children,
|
|
34
|
+
}: {
|
|
35
|
+
label: string;
|
|
36
|
+
pressed: boolean;
|
|
37
|
+
title?: string;
|
|
38
|
+
onClick: () => void;
|
|
39
|
+
children: ComponentChildren;
|
|
40
|
+
}) {
|
|
41
|
+
return (
|
|
42
|
+
<button
|
|
43
|
+
type="button"
|
|
44
|
+
onClick={onClick}
|
|
45
|
+
className={`${ACTION_CLASS} hover:bg-ink/5 ${pressed ? 'text-ink' : 'hover:text-ink'}`}
|
|
46
|
+
title={title ?? label}
|
|
47
|
+
aria-label={label}
|
|
48
|
+
aria-pressed={pressed}
|
|
49
|
+
>
|
|
50
|
+
{children}
|
|
51
|
+
</button>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The WRITE clusters and the two VIEW-MODE toggles — the left half of the editor
|
|
8
|
+
* toolbar, split from `toolbar-clusters.tsx` for the per-file ceiling.
|
|
9
|
+
*
|
|
10
|
+
* The boundary is the two rules that were already there: writes come first and
|
|
11
|
+
* are the ones allowed to be pinned, while the reading aids (find, wrap, zoom,
|
|
12
|
+
* blame) may move into `⋯` on a narrow panel. Keeping the write pair beside the
|
|
13
|
+
* two view toggles is what stops a reading aid from being added in front of them
|
|
14
|
+
* — the measured bug the original comment records (`Save as` pushed into `⋯` by
|
|
15
|
+
* a later, narrower cluster).
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { Eye, EyeOff, MessageSquare, SaveAll } from 'lucide-preact';
|
|
19
|
+
|
|
20
|
+
import type { ToolbarState } from '@/client/components/workspace/editor/toolbar-clusters';
|
|
21
|
+
import { ACTION_CLASS, Toggle } from '@/client/components/workspace/editor/toolbar-toggle';
|
|
22
|
+
import type { ToolbarCluster } from '@/client/components/common/toolbar-row';
|
|
23
|
+
|
|
24
|
+
/** Save and Save as: never a menu row for the panel's own primary action. */
|
|
25
|
+
export function writeClusters(state: ToolbarState): ToolbarCluster[] {
|
|
26
|
+
if (state.byteViewer) return [];
|
|
27
|
+
return [
|
|
28
|
+
{
|
|
29
|
+
id: 'save',
|
|
30
|
+
// The primary action of the panel: a menu row must never be the only way to
|
|
31
|
+
// save a file.
|
|
32
|
+
pinned: true,
|
|
33
|
+
actions: [{ label: 'Save file', icon: SaveAll, onSelect: state.onSave, disabled: state.saveDisabled }],
|
|
34
|
+
children: state.saveButton,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'save-as',
|
|
38
|
+
// Never pinned: it is a rare operation, and the row's space belongs to Save.
|
|
39
|
+
// It IS placed directly after Save, because unpinned clusters take the row in
|
|
40
|
+
// ROW ORDER: measured at the 320px floor, the 26px blame cluster added after
|
|
41
|
+
// it claimed the last 30px and pushed `Save as` into `⋯` — a reading aid
|
|
42
|
+
// evicting a write. Sibling writes outrank reading aids here.
|
|
43
|
+
actions: [{ label: 'Save as…', icon: SaveAll, onSelect: state.onSaveAs }],
|
|
44
|
+
children: (
|
|
45
|
+
<button
|
|
46
|
+
type="button"
|
|
47
|
+
onClick={state.onSaveAs}
|
|
48
|
+
className={`${ACTION_CLASS} hover:bg-ink/5 hover:text-ink`}
|
|
49
|
+
title="Save the buffer to a new file"
|
|
50
|
+
aria-label="Save as"
|
|
51
|
+
>
|
|
52
|
+
<SaveAll size={14} />
|
|
53
|
+
</button>
|
|
54
|
+
),
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The review toggle — only where there is a rendered document to judge.
|
|
61
|
+
*
|
|
62
|
+
* Annotating the SOURCE has no blocks, so the button exists only while the
|
|
63
|
+
* preview branch is the one on screen: a control that switched a mode nothing
|
|
64
|
+
* could use would be a lie about what the panel can do.
|
|
65
|
+
*/
|
|
66
|
+
export function reviewCluster(state: ToolbarState): ToolbarCluster[] {
|
|
67
|
+
if (!state.hasReview) return [];
|
|
68
|
+
const label = state.isReviewing ? 'Exit review mode' : 'Review this document';
|
|
69
|
+
return [
|
|
70
|
+
{
|
|
71
|
+
id: 'review',
|
|
72
|
+
actions: [{ label, icon: MessageSquare, onSelect: state.onToggleReview, active: state.isReviewing }],
|
|
73
|
+
children: (
|
|
74
|
+
<Toggle
|
|
75
|
+
label={label}
|
|
76
|
+
pressed={state.isReviewing}
|
|
77
|
+
title={
|
|
78
|
+
state.isReviewing
|
|
79
|
+
? 'Review mode is on — click a block to judge it'
|
|
80
|
+
: 'Review: click blocks to mark them good or needing work'
|
|
81
|
+
}
|
|
82
|
+
onClick={state.onToggleReview}
|
|
83
|
+
>
|
|
84
|
+
<MessageSquare size={14} />
|
|
85
|
+
</Toggle>
|
|
86
|
+
),
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** The rendered-view toggle (markdown prose, CSV grid, SVG picture). */
|
|
92
|
+
export function previewClusters(state: ToolbarState): ToolbarCluster[] {
|
|
93
|
+
if (!state.hasPreview) return [];
|
|
94
|
+
return [
|
|
95
|
+
{
|
|
96
|
+
id: 'preview',
|
|
97
|
+
actions: [
|
|
98
|
+
{
|
|
99
|
+
label: state.previewLabel,
|
|
100
|
+
icon: state.isPreview ? EyeOff : Eye,
|
|
101
|
+
onSelect: state.onTogglePreview,
|
|
102
|
+
active: state.isPreview,
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
children: (
|
|
106
|
+
<Toggle label={state.previewLabel} pressed={state.isPreview} onClick={state.onTogglePreview}>
|
|
107
|
+
{state.isPreview ? <EyeOff size={14} /> : <Eye size={14} />}
|
|
108
|
+
</Toggle>
|
|
109
|
+
),
|
|
110
|
+
},
|
|
111
|
+
];
|
|
112
|
+
}
|
|
@@ -20,8 +20,9 @@
|
|
|
20
20
|
* container whose size is driven by the SVG's own viewBox.
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
import { useMemo } from 'preact/hooks';
|
|
23
|
+
import { useMemo, useRef } from 'preact/hooks';
|
|
24
24
|
import { sanitizeMermaidSvg } from '@/shared/lib/markdown/sanitize';
|
|
25
|
+
import { nextSvgScopePrefix, scopeSvgIds } from '@/shared/lib/ui/svg-scope';
|
|
25
26
|
|
|
26
27
|
interface SvgPreviewProps {
|
|
27
28
|
content: string;
|
|
@@ -29,7 +30,22 @@ interface SvgPreviewProps {
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
export function SvgPreview({ content, name }: SvgPreviewProps) {
|
|
32
|
-
|
|
33
|
+
// The id namespace is allocated ONCE per mounted preview and kept across
|
|
34
|
+
// edits: a prefix that changed with every keystroke would rewrite every id
|
|
35
|
+
// on every render for no benefit, and the sanitized markup is memoized on
|
|
36
|
+
// `content` alone.
|
|
37
|
+
const scopeRef = useRef('');
|
|
38
|
+
if (!scopeRef.current) scopeRef.current = nextSvgScopePrefix();
|
|
39
|
+
|
|
40
|
+
// SCOPED BEFORE SANITIZED, and the order is the fix rather than a detail.
|
|
41
|
+
// DOMPurify drops any `id` whose value is already a property of the page
|
|
42
|
+
// (`body`, `title`, `name`, …) because that attribute is its DOM-clobbering
|
|
43
|
+
// vector, and the `fill="url(#body)"` that referenced it is left behind — a
|
|
44
|
+
// gradient-painted shape silently adopts the wrong paint. See `svg-scope`.
|
|
45
|
+
const safeSvg = useMemo(
|
|
46
|
+
() => sanitizeMermaidSvg(scopeSvgIds(content, scopeRef.current)),
|
|
47
|
+
[content],
|
|
48
|
+
);
|
|
33
49
|
|
|
34
50
|
return (
|
|
35
51
|
<div className="flex-1 overflow-auto bg-paper">
|
|
@@ -139,6 +139,45 @@ describe('SvgPreview', () => {
|
|
|
139
139
|
expect(container.querySelector('script')).toBeNull();
|
|
140
140
|
expect((globalThis as Record<string, unknown>).__pwned).toBeUndefined();
|
|
141
141
|
});
|
|
142
|
+
|
|
143
|
+
// THE gradient regression. DOMPurify drops an `id` whose value is already a
|
|
144
|
+
// property of the page — `body` is — while the `fill="url(#body)"` that
|
|
145
|
+
// referenced it survives, so the shape silently paints with whatever else
|
|
146
|
+
// claims that name. Measured on a real icon: the chicken's body and head came
|
|
147
|
+
// out dark green instead of cream. The ids are therefore prefixed before the
|
|
148
|
+
// sanitizer sees them, and BOTH halves must move together.
|
|
149
|
+
test('a defs id the page already owns survives, and its reference follows', async () => {
|
|
150
|
+
await mount(
|
|
151
|
+
h(SvgPreview, {
|
|
152
|
+
content:
|
|
153
|
+
'<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10"><defs><linearGradient id="body"><stop offset="0" stop-color="#fff"/></linearGradient></defs><rect width="10" height="10" fill="url(#body)"/></svg>',
|
|
154
|
+
name: 'icon.svg',
|
|
155
|
+
}),
|
|
156
|
+
);
|
|
157
|
+
// happy-dom's own sanitizer keeps these; the browser's is the one that
|
|
158
|
+
// would have dropped `id="body"`, which is why the prefix exists at all.
|
|
159
|
+
const gradient = container.querySelector('linearGradient, lineargradient');
|
|
160
|
+
const rect = container.querySelector('rect');
|
|
161
|
+
expect(rect).not.toBeNull();
|
|
162
|
+
const declared = gradient?.getAttribute('id') ?? '';
|
|
163
|
+
expect(declared).toMatch(/^svg\d+-body$/);
|
|
164
|
+
expect(rect?.getAttribute('fill')).toBe(`url(#${declared})`);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// Two previews must not resolve one another's definitions: `defs` ids are
|
|
168
|
+
// document-scoped, so an unprefixed pair means the second picture paints with
|
|
169
|
+
// the first one's gradient.
|
|
170
|
+
test('two previews scoped their ids apart', async () => {
|
|
171
|
+
const markup =
|
|
172
|
+
'<svg xmlns="http://www.w3.org/2000/svg"><defs><linearGradient id="paint"/></defs><rect width="4" height="4" fill="url(#paint)"/></svg>';
|
|
173
|
+
await mount(h(SvgPreview, { content: markup, name: 'a.svg' }));
|
|
174
|
+
const firstId = container.querySelector('linearGradient, lineargradient')?.getAttribute('id');
|
|
175
|
+
await mount(h(SvgPreview, { content: markup, name: 'b.svg' }));
|
|
176
|
+
const secondId = container.querySelector('linearGradient, lineargradient')?.getAttribute('id');
|
|
177
|
+
expect(firstId).toBeTruthy();
|
|
178
|
+
expect(secondId).toBeTruthy();
|
|
179
|
+
expect(firstId).not.toBe(secondId);
|
|
180
|
+
});
|
|
142
181
|
});
|
|
143
182
|
|
|
144
183
|
describe('DocxView', () => {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
|
|
30
30
|
import { createPortal } from 'preact/compat';
|
|
31
31
|
import type { ReactNode, RefObject } from 'preact/compat';
|
|
32
|
-
import { ClipboardPaste, Copy, CopyPlus, Edit2, ExternalLink, Eye, FilePlus, FolderPlus, GitCompare, History, Scissors, Trash2 } from 'lucide-preact';
|
|
32
|
+
import { ChevronDown, ChevronRight, ClipboardPaste, Copy, CopyPlus, Edit2, ExternalLink, Eye, FilePlus, FolderPlus, GitCompare, History, Scissors, Trash2 } from 'lucide-preact';
|
|
33
33
|
|
|
34
34
|
interface ContextMenuProps {
|
|
35
35
|
x: number;
|
|
@@ -38,6 +38,10 @@ interface ContextMenuProps {
|
|
|
38
38
|
hasGitStatus?: boolean;
|
|
39
39
|
/** Label of the Paste row, or null when a paste cannot land on this target. */
|
|
40
40
|
pasteLabel: string | null;
|
|
41
|
+
/** True when this row's label names more than one directory (a chain). */
|
|
42
|
+
chainLabel?: boolean;
|
|
43
|
+
/** True when this row is an unfolded chain's outermost level. */
|
|
44
|
+
foldable?: boolean;
|
|
41
45
|
/** True while a transfer is in flight; the acting rows disable on it. */
|
|
42
46
|
busy: boolean;
|
|
43
47
|
onAction: (actionType: string) => void;
|
|
@@ -55,13 +59,22 @@ const SEPARATOR_PX = 9;
|
|
|
55
59
|
const PADDING_PX = 8;
|
|
56
60
|
|
|
57
61
|
/** The rows this target offers, in order — the menu's single source of truth. */
|
|
58
|
-
function buildRows(options: { isFolder: boolean; hasGitStatus?: boolean; pasteLabel: string | null; busy: boolean }): MenuEntry[] {
|
|
59
|
-
const { isFolder, hasGitStatus, pasteLabel, busy } = options;
|
|
62
|
+
function buildRows(options: { isFolder: boolean; hasGitStatus?: boolean; pasteLabel: string | null; busy: boolean; chainLabel?: boolean; foldable?: boolean }): MenuEntry[] {
|
|
63
|
+
const { isFolder, hasGitStatus, pasteLabel, busy, chainLabel, foldable } = options;
|
|
60
64
|
const entries: MenuEntry[] = [];
|
|
61
65
|
|
|
62
66
|
if (isFolder) {
|
|
63
67
|
entries.push({ kind: 'item', id: 'new_file', label: 'New File', icon: <FilePlus size={13} className="text-ink/60" /> });
|
|
64
68
|
entries.push({ kind: 'item', id: 'new_folder', label: 'New Folder', icon: <FolderPlus size={13} className="text-ink/60" /> });
|
|
69
|
+
// A row labelled `dev/src/main/code` is one row standing for four
|
|
70
|
+
// directories: the levels inside it cannot be dropped on or renamed until
|
|
71
|
+
// they are rows, and this is the explicit way to make them so.
|
|
72
|
+
if (chainLabel) {
|
|
73
|
+
entries.push({ kind: 'item', id: 'unfold', label: 'Unfold Folders', icon: <ChevronDown size={13} className="text-ink/60" /> });
|
|
74
|
+
}
|
|
75
|
+
if (foldable) {
|
|
76
|
+
entries.push({ kind: 'item', id: 'fold', label: 'Fold Folders', icon: <ChevronRight size={13} className="text-ink/60" /> });
|
|
77
|
+
}
|
|
65
78
|
entries.push({ kind: 'separator' });
|
|
66
79
|
} else {
|
|
67
80
|
entries.push({ kind: 'item', id: 'view', label: 'View', icon: <Eye size={13} className="text-ink/60" /> });
|
|
@@ -100,9 +113,9 @@ function menuHeightOf(entries: MenuEntry[]): number {
|
|
|
100
113
|
return items * ROW_PX + separators * SEPARATOR_PX + PADDING_PX;
|
|
101
114
|
}
|
|
102
115
|
|
|
103
|
-
export function FileContextMenu({ x, y, isFolder, hasGitStatus, pasteLabel, busy, onAction, menuRef }: ContextMenuProps) {
|
|
116
|
+
export function FileContextMenu({ x, y, isFolder, hasGitStatus, pasteLabel, chainLabel, foldable, busy, onAction, menuRef }: ContextMenuProps) {
|
|
104
117
|
const menuWidth = 190;
|
|
105
|
-
const entries = buildRows({ isFolder, hasGitStatus, pasteLabel, busy });
|
|
118
|
+
const entries = buildRows({ isFolder, hasGitStatus, pasteLabel, busy, chainLabel, foldable });
|
|
106
119
|
const menuHeight = menuHeightOf(entries);
|
|
107
120
|
|
|
108
121
|
const posX = typeof window !== 'undefined' ? Math.max(10, Math.min(x, window.innerWidth - menuWidth - 12)) : x;
|