@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
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* "Accent colour" — the presets, and the custom colour beside them.
|
|
8
|
+
*
|
|
9
|
+
* What is pinned here is the WRITE GRANULARITY as much as the value: the custom
|
|
10
|
+
* control commits on the colour input's `change` and on the text field's
|
|
11
|
+
* blur/Enter, never on `input`. Dragging inside the system colour panel fires
|
|
12
|
+
* hundreds of `input`s, and each commit is a PATCH carrying the whole project —
|
|
13
|
+
* so committing per keystroke would flood the store and let the last one win.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
17
|
+
import { Window } from 'happy-dom';
|
|
18
|
+
import { h, render } from 'preact';
|
|
19
|
+
import { act } from 'preact/test-utils';
|
|
20
|
+
|
|
21
|
+
import { ProjectAccentPalette } from '@/client/components/settings/categories/project-settings/AccentPalette';
|
|
22
|
+
import { DEFAULT_CUSTOM_ACCENT } from '@/shared/lib/workspace/project-accent';
|
|
23
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
24
|
+
|
|
25
|
+
let container: HTMLElement;
|
|
26
|
+
const picks: string[] = [];
|
|
27
|
+
|
|
28
|
+
beforeAll(() => {
|
|
29
|
+
installDomGlobals(new Window({ url: 'http://localhost' }));
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
afterEach(() => {
|
|
33
|
+
if (container) render(null, container);
|
|
34
|
+
container?.remove();
|
|
35
|
+
picks.length = 0;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
afterAll(() => {
|
|
39
|
+
restoreDomGlobals();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
function mount(accentColor: string): HTMLElement {
|
|
43
|
+
container = document.body.appendChild(document.createElement('div'));
|
|
44
|
+
act(() =>
|
|
45
|
+
render(
|
|
46
|
+
h(ProjectAccentPalette, {
|
|
47
|
+
accentColor,
|
|
48
|
+
onSelectColor: (color: string) => picks.push(color),
|
|
49
|
+
}),
|
|
50
|
+
container,
|
|
51
|
+
),
|
|
52
|
+
);
|
|
53
|
+
return container;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function swatch(root: HTMLElement, label: string): HTMLElement {
|
|
57
|
+
const target = root.querySelector<HTMLElement>(`button[aria-label="${label}"]`);
|
|
58
|
+
if (!target) throw new Error(`no swatch labelled ${label}`);
|
|
59
|
+
return target;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function hexField(root: HTMLElement): HTMLInputElement {
|
|
63
|
+
const field = root.querySelector<HTMLInputElement>('input[type="text"]');
|
|
64
|
+
if (!field) throw new Error('no hex field');
|
|
65
|
+
return field;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function colorInput(root: HTMLElement): HTMLInputElement {
|
|
69
|
+
const field = root.querySelector<HTMLInputElement>('input[type="color"]');
|
|
70
|
+
if (!field) throw new Error('no colour input');
|
|
71
|
+
return field;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function type(field: HTMLInputElement, value: string): void {
|
|
75
|
+
act(() => {
|
|
76
|
+
field.value = value;
|
|
77
|
+
field.dispatchEvent(new Event('input', { bubbles: true }));
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** `KeyboardEvent`/`FocusEvent` are not among the installed DOM globals, and the
|
|
82
|
+
* happy-dom ones are what the field's own document dispatches. */
|
|
83
|
+
function eventField(field: HTMLInputElement, type: string, init: Record<string, unknown>): void {
|
|
84
|
+
const view = field.ownerDocument.defaultView as unknown as Record<string, new (name: string, init?: unknown) => Event>;
|
|
85
|
+
const Ctor = type === 'keydown' ? view.KeyboardEvent : view.FocusEvent;
|
|
86
|
+
if (!Ctor) throw new Error(`no ${type} constructor`);
|
|
87
|
+
act(() => {
|
|
88
|
+
field.dispatchEvent(new Ctor(type, init));
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function press(field: HTMLInputElement, key: string): void {
|
|
93
|
+
eventField(field, 'keydown', { key, bubbles: true });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function leave(field: HTMLInputElement): void {
|
|
97
|
+
eventField(field, 'blur', {});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
describe('ProjectAccentPalette', () => {
|
|
101
|
+
test('the stored preset is the selected swatch', () => {
|
|
102
|
+
const root = mount('#f43f5e');
|
|
103
|
+
expect(swatch(root, 'Rose').getAttribute('aria-pressed')).toBe('true');
|
|
104
|
+
expect(swatch(root, 'Teal').getAttribute('aria-pressed')).toBe('false');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('clicking a preset writes its value', () => {
|
|
108
|
+
const root = mount('#f43f5e');
|
|
109
|
+
act(() => swatch(root, 'Teal').click());
|
|
110
|
+
expect(picks).toEqual(['#2dd4bf']);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('no accent selects the None swatch and is NOT a custom colour', () => {
|
|
114
|
+
const root = mount('');
|
|
115
|
+
expect(swatch(root, 'No accent colour').getAttribute('aria-pressed')).toBe('true');
|
|
116
|
+
expect(root.textContent).not.toContain('Custom accent');
|
|
117
|
+
expect(hexField(root).value).toBe(DEFAULT_CUSTOM_ACCENT);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('a stored colour outside the palette reads as custom, and the field shows it', () => {
|
|
121
|
+
const root = mount('#7c3aed');
|
|
122
|
+
expect(root.textContent).toContain('Custom accent');
|
|
123
|
+
expect(hexField(root).value).toBe('#7c3aed');
|
|
124
|
+
// ...and no preset is highlighted, because none of them is that colour.
|
|
125
|
+
expect([...root.querySelectorAll('button[aria-label]')].some(
|
|
126
|
+
(button) => button.getAttribute('aria-pressed') === 'true',
|
|
127
|
+
)).toBe(false);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test('a typed hex is committed on Enter, normalised', () => {
|
|
131
|
+
const root = mount('#38bdf8');
|
|
132
|
+
const field = hexField(root);
|
|
133
|
+
type(field, '#ABC');
|
|
134
|
+
expect(picks).toEqual([]);
|
|
135
|
+
press(field, 'Enter');
|
|
136
|
+
expect(picks).toEqual(['#aabbcc']);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test('a typed hex is committed on blur', () => {
|
|
140
|
+
const root = mount('#38bdf8');
|
|
141
|
+
const field = hexField(root);
|
|
142
|
+
type(field, '#010203');
|
|
143
|
+
leave(field);
|
|
144
|
+
expect(picks).toEqual(['#010203']);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test('an unparseable draft writes nothing and the field returns to the stored colour', () => {
|
|
148
|
+
const root = mount('#38bdf8');
|
|
149
|
+
const field = hexField(root);
|
|
150
|
+
type(field, 'red;background:url(//evil)');
|
|
151
|
+
press(field, 'Enter');
|
|
152
|
+
expect(picks).toEqual([]);
|
|
153
|
+
expect(field.value).toBe('#38bdf8');
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test('Escape abandons the draft', () => {
|
|
157
|
+
const root = mount('#38bdf8');
|
|
158
|
+
const field = hexField(root);
|
|
159
|
+
type(field, '#abcdef');
|
|
160
|
+
press(field, 'Escape');
|
|
161
|
+
expect(field.value).toBe('#38bdf8');
|
|
162
|
+
leave(field);
|
|
163
|
+
expect(picks).toEqual([]);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test('emptying the field clears the accent rather than writing nothing', () => {
|
|
167
|
+
const root = mount('#38bdf8');
|
|
168
|
+
const field = hexField(root);
|
|
169
|
+
type(field, '');
|
|
170
|
+
leave(field);
|
|
171
|
+
expect(picks).toEqual(['']);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
test('the colour input writes on change, not on every input', () => {
|
|
175
|
+
const root = mount('#38bdf8');
|
|
176
|
+
const input = colorInput(root);
|
|
177
|
+
act(() => {
|
|
178
|
+
input.value = '#123456';
|
|
179
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
180
|
+
});
|
|
181
|
+
// Still dragging: the swatch previews it, the store hears nothing.
|
|
182
|
+
expect(picks).toEqual([]);
|
|
183
|
+
act(() => {
|
|
184
|
+
input.value = '#123456';
|
|
185
|
+
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
186
|
+
});
|
|
187
|
+
expect(picks).toEqual(['#123456']);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
@@ -1,41 +1,127 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The project's accent, as a row of swatches plus a custom colour.
|
|
8
|
+
*
|
|
9
|
+
* The palette is one table (`@/shared/lib/workspace/project-accent`) so the
|
|
10
|
+
* picker and the server cannot disagree about which presets exist. A custom
|
|
11
|
+
* accent is NOT a new table entry — it is a stored hex the palette does not
|
|
12
|
+
* contain, and the swatch row treats it as selected so the pane always shows the
|
|
13
|
+
* colour the sidebar is painting.
|
|
14
|
+
*
|
|
15
|
+
* The custom control writes only on COMMIT (the colour input's native `change`,
|
|
16
|
+
* the text field's blur/Enter), never on every `input`: dragging inside the
|
|
17
|
+
* system colour panel fires hundreds of `input`s and each one is a PATCH
|
|
18
|
+
* carrying the whole project.
|
|
19
|
+
*
|
|
20
|
+
* Those two listeners are attached NATIVELY, not through `onChange`/`onInput`
|
|
21
|
+
* props, because `preact/compat` rewrites `onChange` to the `input` event — under
|
|
22
|
+
* it a prop would commit on every drag tick, and the isolation of a test file
|
|
23
|
+
* (where compat may not be loaded yet) is no evidence about the app.
|
|
24
|
+
*/
|
|
3
25
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
{ label: 'Rose', value: '#f43f5e', bgHex: '#f43f5e' },
|
|
13
|
-
{ label: 'Vivid Blue', value: '#3b82f6', bgHex: '#3b82f6' },
|
|
14
|
-
{ label: 'Lime Green', value: '#84cc16', bgHex: '#84cc16' },
|
|
15
|
-
];
|
|
26
|
+
import { useEffect, useRef, useState } from 'preact/hooks';
|
|
27
|
+
import { Pipette, X } from 'lucide-preact';
|
|
28
|
+
import {
|
|
29
|
+
DEFAULT_CUSTOM_ACCENT,
|
|
30
|
+
PROJECT_ACCENT_OPTIONS,
|
|
31
|
+
normalizeHexAccent,
|
|
32
|
+
} from '@/shared/lib/workspace/project-accent';
|
|
33
|
+
import type { AccentColorOption } from '@/shared/types';
|
|
16
34
|
|
|
17
35
|
interface ProjectAccentPaletteProps {
|
|
18
36
|
accentColor: string;
|
|
19
37
|
onSelectColor: (color: string) => void;
|
|
20
38
|
options?: AccentColorOption[];
|
|
39
|
+
disabled?: boolean;
|
|
21
40
|
}
|
|
22
41
|
|
|
23
42
|
export function ProjectAccentPalette({
|
|
24
43
|
accentColor,
|
|
25
44
|
onSelectColor,
|
|
26
|
-
options =
|
|
45
|
+
options = PROJECT_ACCENT_OPTIONS,
|
|
46
|
+
disabled = false,
|
|
27
47
|
}: ProjectAccentPaletteProps) {
|
|
28
|
-
const colorList = options
|
|
48
|
+
const colorList = options.length > 0 ? options : PROJECT_ACCENT_OPTIONS;
|
|
49
|
+
const stored = accentColor.trim().toLowerCase();
|
|
50
|
+
// The palette's `''` entry is "no accent", so an empty accent is the None
|
|
51
|
+
// swatch, not a custom colour.
|
|
52
|
+
const isPreset = colorList.some((opt) => opt.value !== '' && opt.value.toLowerCase() === stored);
|
|
53
|
+
const isCustom = stored !== '' && !isPreset;
|
|
54
|
+
// What the custom control shows: the stored colour when there is one, so the
|
|
55
|
+
// field and the swatches never describe two different accents.
|
|
56
|
+
const current = normalizeHexAccent(stored) ?? DEFAULT_CUSTOM_ACCENT;
|
|
57
|
+
|
|
58
|
+
const [draft, setDraft] = useState(current);
|
|
59
|
+
// Follow the stored accent — after a preset is picked, after a PATCH lands,
|
|
60
|
+
// and after one is refused and the row reverts. The initial state already
|
|
61
|
+
// equals `current`, so this never paints a stale value first.
|
|
62
|
+
useEffect(() => setDraft(current), [current]);
|
|
63
|
+
|
|
64
|
+
const commit = (value: string) => {
|
|
65
|
+
const normalized = normalizeHexAccent(value);
|
|
66
|
+
if (normalized === null) {
|
|
67
|
+
setDraft(current);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
// Held until the stored accent catches up: clearing it here would snap the
|
|
71
|
+
// field back to the OLD colour while the PATCH is still in flight.
|
|
72
|
+
setDraft(normalized);
|
|
73
|
+
// Re-typing the colour that is already stored (Escape, then leaving the
|
|
74
|
+
// field) is not an edit; the server would answer `changed: false`.
|
|
75
|
+
if (normalized !== stored) onSelectColor(normalized);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const colorRef = useRef<HTMLInputElement>(null);
|
|
79
|
+
const hexRef = useRef<HTMLInputElement>(null);
|
|
80
|
+
// The listeners are bound once, so they read the LATEST commit through here
|
|
81
|
+
// instead of capturing the first render's `stored`.
|
|
82
|
+
const latest = useRef({ commit, clear: () => onSelectColor('') });
|
|
83
|
+
latest.current = { commit, clear: () => onSelectColor('') };
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
const color = colorRef.current;
|
|
87
|
+
const hex = hexRef.current;
|
|
88
|
+
if (!color || !hex) return;
|
|
89
|
+
|
|
90
|
+
const preview = (event: Event) => setDraft((event.target as HTMLInputElement).value.toLowerCase());
|
|
91
|
+
const settle = (event: Event) => latest.current.commit((event.target as HTMLInputElement).value);
|
|
92
|
+
// `blur`, not `focusout`: it is the event every browser fires when the field
|
|
93
|
+
// loses focus, and it needs no compat mapping to be seen.
|
|
94
|
+
const leaveField = () => {
|
|
95
|
+
const value = hex.value.trim();
|
|
96
|
+
if (value === '') latest.current.clear();
|
|
97
|
+
else latest.current.commit(value);
|
|
98
|
+
};
|
|
99
|
+
const typed = (event: KeyboardEvent) => {
|
|
100
|
+
if (event.key === 'Enter') {
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
leaveField();
|
|
103
|
+
}
|
|
104
|
+
if (event.key === 'Escape') setDraft(current);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
color.addEventListener('input', preview);
|
|
108
|
+
color.addEventListener('change', settle);
|
|
109
|
+
hex.addEventListener('blur', leaveField);
|
|
110
|
+
hex.addEventListener('keydown', typed);
|
|
111
|
+
return () => {
|
|
112
|
+
color.removeEventListener('input', preview);
|
|
113
|
+
color.removeEventListener('change', settle);
|
|
114
|
+
hex.removeEventListener('blur', leaveField);
|
|
115
|
+
hex.removeEventListener('keydown', typed);
|
|
116
|
+
};
|
|
117
|
+
}, [current]);
|
|
29
118
|
|
|
30
119
|
return (
|
|
31
120
|
<div className="space-y-2.5">
|
|
32
|
-
<h4 className="text-xs font-semibold text-ink">
|
|
33
|
-
Accent Color
|
|
34
|
-
</h4>
|
|
35
|
-
|
|
121
|
+
<h4 className="text-xs font-semibold text-ink">Accent colour</h4>
|
|
36
122
|
<div className="flex flex-wrap items-center gap-2.5">
|
|
37
123
|
{colorList.map((opt) => {
|
|
38
|
-
const isSelected =
|
|
124
|
+
const isSelected = stored === opt.value.toLowerCase();
|
|
39
125
|
|
|
40
126
|
if (opt.value === '') {
|
|
41
127
|
return (
|
|
@@ -43,8 +129,11 @@ export function ProjectAccentPalette({
|
|
|
43
129
|
key="none"
|
|
44
130
|
type="button"
|
|
45
131
|
onClick={() => onSelectColor('')}
|
|
46
|
-
|
|
47
|
-
|
|
132
|
+
disabled={disabled}
|
|
133
|
+
aria-label="No accent colour"
|
|
134
|
+
aria-pressed={isSelected}
|
|
135
|
+
title="No accent colour"
|
|
136
|
+
className={`w-7 h-7 rounded-full border flex items-center justify-center transition-all cursor-pointer disabled:opacity-50 ${
|
|
48
137
|
isSelected
|
|
49
138
|
? 'border-ink bg-ink/10 ring-2 ring-ink/30 ring-offset-2 ring-offset-paper'
|
|
50
139
|
: 'border-ink/25 bg-paper hover:border-ink/50 text-ink/60'
|
|
@@ -60,9 +149,12 @@ export function ProjectAccentPalette({
|
|
|
60
149
|
key={opt.value}
|
|
61
150
|
type="button"
|
|
62
151
|
onClick={() => onSelectColor(opt.value)}
|
|
152
|
+
disabled={disabled}
|
|
153
|
+
aria-label={opt.label}
|
|
154
|
+
aria-pressed={isSelected}
|
|
63
155
|
title={opt.label}
|
|
64
156
|
style={{ backgroundColor: opt.bgHex }}
|
|
65
|
-
className={`w-7 h-7 rounded-full transition-all cursor-pointer shadow-2xs ${
|
|
157
|
+
className={`w-7 h-7 rounded-full transition-all cursor-pointer shadow-2xs disabled:opacity-50 ${
|
|
66
158
|
isSelected
|
|
67
159
|
? 'ring-2 ring-ink ring-offset-2 ring-offset-paper scale-105'
|
|
68
160
|
: 'hover:scale-105 opacity-90 hover:opacity-100'
|
|
@@ -71,6 +163,46 @@ export function ProjectAccentPalette({
|
|
|
71
163
|
);
|
|
72
164
|
})}
|
|
73
165
|
</div>
|
|
166
|
+
|
|
167
|
+
<div className="flex items-center gap-2 pt-0.5">
|
|
168
|
+
<label
|
|
169
|
+
title="Pick a custom accent colour"
|
|
170
|
+
className={`relative w-7 h-7 shrink-0 rounded-full border overflow-hidden cursor-pointer transition-all ${
|
|
171
|
+
isCustom ? 'ring-2 ring-ink ring-offset-2 ring-offset-paper' : 'border-ink/25 hover:border-ink/50'
|
|
172
|
+
} ${disabled ? 'opacity-50 pointer-events-none' : ''}`}
|
|
173
|
+
>
|
|
174
|
+
<span aria-hidden="true" className="absolute inset-0" style={{ backgroundColor: draft }} />
|
|
175
|
+
<Pipette
|
|
176
|
+
size={12}
|
|
177
|
+
strokeWidth={2.2}
|
|
178
|
+
aria-hidden="true"
|
|
179
|
+
className="absolute inset-0 m-auto text-white/90 mix-blend-difference pointer-events-none"
|
|
180
|
+
/>
|
|
181
|
+
{/* The native picker opens the system colour panel, which is the only
|
|
182
|
+
way to choose a colour without re-implementing a wheel here. */}
|
|
183
|
+
<input
|
|
184
|
+
ref={colorRef}
|
|
185
|
+
type="color"
|
|
186
|
+
value={normalizeHexAccent(draft) ?? DEFAULT_CUSTOM_ACCENT}
|
|
187
|
+
disabled={disabled}
|
|
188
|
+
aria-label="Custom accent colour"
|
|
189
|
+
className="absolute inset-0 w-full h-full opacity-0 cursor-pointer"
|
|
190
|
+
/>
|
|
191
|
+
</label>
|
|
192
|
+
|
|
193
|
+
<input
|
|
194
|
+
ref={hexRef}
|
|
195
|
+
type="text"
|
|
196
|
+
value={draft}
|
|
197
|
+
disabled={disabled}
|
|
198
|
+
spellcheck={false}
|
|
199
|
+
aria-label="Custom accent colour hex"
|
|
200
|
+
placeholder={DEFAULT_CUSTOM_ACCENT}
|
|
201
|
+
onInput={(event) => setDraft(event.currentTarget.value)}
|
|
202
|
+
className="w-[86px] bg-paper border border-ink/20 rounded-md px-2 py-1 text-[11px] font-mono text-ink outline-none focus:border-ink/60 transition-colors disabled:opacity-50"
|
|
203
|
+
/>
|
|
204
|
+
<span className="text-[11px] text-ink/45">{isCustom ? 'Custom accent' : 'Pick any colour'}</span>
|
|
205
|
+
</div>
|
|
74
206
|
</div>
|
|
75
207
|
);
|
|
76
208
|
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* "Add project" inside Settings → Projects.
|
|
8
|
+
*
|
|
9
|
+
* The plus button used to POST `{ name: "Project 2" }` — an unbound folder with
|
|
10
|
+
* a generated name and no directory — which then listed no sessions and could
|
|
11
|
+
* not be pointed at a directory from this pane either. It now asks for the two
|
|
12
|
+
* facts a workspace actually needs (a name and a directory), pre-filling the
|
|
13
|
+
* name from the directory the way the New Workspace dialog does, and refuses
|
|
14
|
+
* before the request when either is missing.
|
|
15
|
+
*
|
|
16
|
+
* The directory is OPTIONAL on purpose: an unbound workspace is a legitimate
|
|
17
|
+
* grouping for chats with no omp project behind them, and the dialog says so
|
|
18
|
+
* instead of pretending the field is required.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { useState } from 'preact/hooks';
|
|
22
|
+
import { FolderOpen, Loader2 } from 'lucide-preact';
|
|
23
|
+
import { Modal } from '@/client/components/common/Modal';
|
|
24
|
+
import { FolderPicker } from '@/client/components/common/FolderPicker';
|
|
25
|
+
|
|
26
|
+
interface AddProjectModalProps {
|
|
27
|
+
isOpen: boolean;
|
|
28
|
+
isSaving: boolean;
|
|
29
|
+
onClose: () => void;
|
|
30
|
+
onSubmit: (input: { name: string; path: string }) => Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function baseName(path: string): string {
|
|
34
|
+
const trimmed = path.replace(/[\\/]+$/, '');
|
|
35
|
+
return (trimmed.split(/[\\/]/).pop() ?? '').toLowerCase();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function AddProjectForm({ isSaving, onClose, onSubmit }: Omit<AddProjectModalProps, 'isOpen'>) {
|
|
39
|
+
const [name, setName] = useState('');
|
|
40
|
+
const [path, setPath] = useState('');
|
|
41
|
+
const [pickerOpen, setPickerOpen] = useState(false);
|
|
42
|
+
// True while the name is still the one derived from a picked directory: a
|
|
43
|
+
// later pick may overwrite it, a typed name may not.
|
|
44
|
+
const [nameFromPath, setNameFromPath] = useState(true);
|
|
45
|
+
const [error, setError] = useState<string | null>(null);
|
|
46
|
+
|
|
47
|
+
const chooseDirectory = (picked: string) => {
|
|
48
|
+
setPath(picked);
|
|
49
|
+
if (nameFromPath || !name.trim()) {
|
|
50
|
+
setName(baseName(picked));
|
|
51
|
+
setNameFromPath(true);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const submit = async () => {
|
|
56
|
+
const trimmedName = name.trim();
|
|
57
|
+
if (!trimmedName) {
|
|
58
|
+
setError('Enter a project name.');
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
setError(null);
|
|
62
|
+
try {
|
|
63
|
+
await onSubmit({ name: trimmedName, path: path.trim() });
|
|
64
|
+
onClose();
|
|
65
|
+
} catch (cause) {
|
|
66
|
+
setError(cause instanceof Error ? cause.message : String(cause));
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<>
|
|
72
|
+
<Modal
|
|
73
|
+
onClose={isSaving ? () => {} : onClose}
|
|
74
|
+
ariaLabel="Add project"
|
|
75
|
+
maxWidthClass="max-w-[480px]"
|
|
76
|
+
header={
|
|
77
|
+
<div className="min-w-0">
|
|
78
|
+
<h2 className="text-sm font-semibold text-ink">Add project</h2>
|
|
79
|
+
<p className="text-[11px] text-ink/50">A name, and the directory its chats run in.</p>
|
|
80
|
+
</div>
|
|
81
|
+
}
|
|
82
|
+
footer={
|
|
83
|
+
<div className="flex items-center justify-end gap-2 px-5 py-3.5 border-t border-ink/10">
|
|
84
|
+
<button
|
|
85
|
+
type="button"
|
|
86
|
+
onClick={onClose}
|
|
87
|
+
disabled={isSaving}
|
|
88
|
+
className="px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50"
|
|
89
|
+
>
|
|
90
|
+
Cancel
|
|
91
|
+
</button>
|
|
92
|
+
<button
|
|
93
|
+
type="button"
|
|
94
|
+
onClick={() => void submit()}
|
|
95
|
+
disabled={isSaving}
|
|
96
|
+
className="px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 inline-flex items-center gap-1.5"
|
|
97
|
+
>
|
|
98
|
+
{isSaving && <Loader2 size={13} className="animate-spin" />}
|
|
99
|
+
<span>{isSaving ? 'Adding…' : 'Add project'}</span>
|
|
100
|
+
</button>
|
|
101
|
+
</div>
|
|
102
|
+
}
|
|
103
|
+
>
|
|
104
|
+
<div className="px-5 py-4 space-y-4">
|
|
105
|
+
<div className="space-y-1.5">
|
|
106
|
+
<label htmlFor="add-project-name" className="block text-xs font-semibold text-ink">
|
|
107
|
+
Name
|
|
108
|
+
</label>
|
|
109
|
+
<input
|
|
110
|
+
id="add-project-name"
|
|
111
|
+
type="text"
|
|
112
|
+
value={name}
|
|
113
|
+
onInput={(e) => {
|
|
114
|
+
setName(e.currentTarget.value);
|
|
115
|
+
setNameFromPath(false);
|
|
116
|
+
}}
|
|
117
|
+
placeholder="e.g. kabmo"
|
|
118
|
+
className="w-full bg-paper border border-ink/20 rounded-md px-3 py-2 text-xs text-ink outline-none focus:border-ink/60 transition-colors"
|
|
119
|
+
/>
|
|
120
|
+
<p className="text-[11px] text-ink/50">Unique — the sidebar identifies a workspace by it.</p>
|
|
121
|
+
</div>
|
|
122
|
+
|
|
123
|
+
<div className="space-y-1.5">
|
|
124
|
+
<label htmlFor="add-project-path" className="block text-xs font-semibold text-ink">
|
|
125
|
+
Directory <span className="text-ink/40 font-normal">(optional)</span>
|
|
126
|
+
</label>
|
|
127
|
+
<div className="flex items-center gap-2">
|
|
128
|
+
<input
|
|
129
|
+
id="add-project-path"
|
|
130
|
+
type="text"
|
|
131
|
+
value={path}
|
|
132
|
+
onInput={(e) => setPath(e.currentTarget.value)}
|
|
133
|
+
placeholder="~ or /absolute/path"
|
|
134
|
+
spellcheck={false}
|
|
135
|
+
className="flex-1 min-w-0 bg-paper border border-ink/20 rounded-md px-3 py-2 text-[11.5px] font-mono text-ink outline-none focus:border-ink/60 transition-colors"
|
|
136
|
+
/>
|
|
137
|
+
<button
|
|
138
|
+
type="button"
|
|
139
|
+
onClick={() => setPickerOpen(true)}
|
|
140
|
+
className="shrink-0 inline-flex items-center gap-1 px-2.5 py-2 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink transition-colors cursor-pointer"
|
|
141
|
+
>
|
|
142
|
+
<FolderOpen size={12} />
|
|
143
|
+
<span>Browse…</span>
|
|
144
|
+
</button>
|
|
145
|
+
</div>
|
|
146
|
+
<p className="text-[11px] text-ink/50">
|
|
147
|
+
Sessions under this directory are listed in the project. Leave it empty for a grouping with no directory
|
|
148
|
+
behind it.
|
|
149
|
+
</p>
|
|
150
|
+
</div>
|
|
151
|
+
|
|
152
|
+
{error && <p className="text-[11px] text-error">{error}</p>}
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
{pickerOpen && (
|
|
156
|
+
<FolderPicker
|
|
157
|
+
initialPath={path || undefined}
|
|
158
|
+
onSelect={(picked) => {
|
|
159
|
+
chooseDirectory(picked);
|
|
160
|
+
setPickerOpen(false);
|
|
161
|
+
}}
|
|
162
|
+
onClose={() => setPickerOpen(false)}
|
|
163
|
+
/>
|
|
164
|
+
)}
|
|
165
|
+
</Modal>
|
|
166
|
+
</>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export function AddProjectModal({ isOpen, isSaving, onClose, onSubmit }: AddProjectModalProps) {
|
|
171
|
+
// Mounted fresh per open, so every field starts from its own value with no
|
|
172
|
+
// reset effect to race the first paint (same reason as NewWorkspaceModal).
|
|
173
|
+
if (!isOpen) return null;
|
|
174
|
+
return <AddProjectForm isSaving={isSaving} onClose={onClose} onSubmit={onSubmit} />;
|
|
175
|
+
}
|