@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,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The two post-mount hydration passes a rendered markdown document needs.
|
|
8
|
+
*
|
|
9
|
+
* Extracted from `MarkdownRenderer` for the per-file ceiling, and they belong in
|
|
10
|
+
* a hook because they are not rendering: both observe the container and swap
|
|
11
|
+
* placeholders for real content after the HTML string landed.
|
|
12
|
+
*
|
|
13
|
+
* ## Why an observer, in both cases
|
|
14
|
+
*
|
|
15
|
+
* The container's `innerHTML` can be replaced with an IDENTICAL string — the
|
|
16
|
+
* chat timeline re-renders a message, a preview re-renders after a save — and
|
|
17
|
+
* the effect does not re-run for an unchanged dependency. New placeholders would
|
|
18
|
+
* then sit unhydrated forever. Each hydrator writes only inside the placeholder
|
|
19
|
+
* elements it found, so it never re-triggers its own observer.
|
|
20
|
+
*
|
|
21
|
+
* ## KaTeX is lazy, mermaid is not
|
|
22
|
+
*
|
|
23
|
+
* `marked.ts` emits a `math-pending` span and `katex.ts` swaps it once ~522 kB
|
|
24
|
+
* of JS arrives; a message with no math must never pay for that fetch. Mermaid
|
|
25
|
+
* bakes the palette into its SVG, so every theme write has to re-render it — the
|
|
26
|
+
* trigger is the `data-theme` ATTRIBUTE rather than the `omp:theme-changed`
|
|
27
|
+
* event, because the navbar toggle and the settings modal are both writers and
|
|
28
|
+
* observing the attribute catches all of them.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
import type { RefObject } from 'preact';
|
|
32
|
+
import { useEffect, useLayoutEffect } from 'preact/hooks';
|
|
33
|
+
|
|
34
|
+
import { hydrateMathBlocks } from '@/shared/lib/markdown/katex';
|
|
35
|
+
import { hydrateMermaidBlocks } from '@/shared/lib/markdown/mermaid';
|
|
36
|
+
|
|
37
|
+
const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
|
|
38
|
+
|
|
39
|
+
/** Replace `math-pending` placeholders for real KaTeX markup, when there are any. */
|
|
40
|
+
export function useMathHydration(container: RefObject<HTMLElement>, html: string, active: boolean): void {
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (!active || typeof window === 'undefined') return;
|
|
43
|
+
const element = container.current;
|
|
44
|
+
if (!element) return;
|
|
45
|
+
|
|
46
|
+
let cancelled = false;
|
|
47
|
+
const hydrate = async () => {
|
|
48
|
+
if (!element.isConnected) return;
|
|
49
|
+
await hydrateMathBlocks(element);
|
|
50
|
+
if (cancelled) return;
|
|
51
|
+
};
|
|
52
|
+
void hydrate();
|
|
53
|
+
const observer = new MutationObserver(() => {
|
|
54
|
+
if (element.isConnected) void hydrateMathBlocks(element);
|
|
55
|
+
});
|
|
56
|
+
observer.observe(element, { childList: true });
|
|
57
|
+
|
|
58
|
+
return () => {
|
|
59
|
+
cancelled = true;
|
|
60
|
+
observer.disconnect();
|
|
61
|
+
};
|
|
62
|
+
}, [container, active, html]);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface MermaidHydrationOptions {
|
|
66
|
+
container: RefObject<HTMLElement>;
|
|
67
|
+
html: string;
|
|
68
|
+
active: boolean;
|
|
69
|
+
/** The block the open diagram viewer was read from, so a theme write can re-read it. */
|
|
70
|
+
diagramBlock: RefObject<HTMLElement | null>;
|
|
71
|
+
/**
|
|
72
|
+
* The block the viewer is showing, re-rendered for the new palette.
|
|
73
|
+
*
|
|
74
|
+
* The caller reads it (`readDiagramBlock`) because the snapshot type belongs
|
|
75
|
+
* to the viewer, not to hydration — this module never needs to know what a
|
|
76
|
+
* diagram IS.
|
|
77
|
+
*/
|
|
78
|
+
onDiagramBlock: (block: HTMLElement) => void;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Draw every `mermaid-block` placeholder, and re-draw on a palette change. */
|
|
82
|
+
export function useMermaidHydration({
|
|
83
|
+
container,
|
|
84
|
+
html,
|
|
85
|
+
active,
|
|
86
|
+
diagramBlock,
|
|
87
|
+
onDiagramBlock,
|
|
88
|
+
}: MermaidHydrationOptions): void {
|
|
89
|
+
useIsomorphicLayoutEffect(() => {
|
|
90
|
+
if (!active || typeof window === 'undefined') return;
|
|
91
|
+
const element = container.current;
|
|
92
|
+
if (!element) return;
|
|
93
|
+
|
|
94
|
+
let timer: number | undefined;
|
|
95
|
+
const hydrate = async () => {
|
|
96
|
+
if (!element.isConnected) return;
|
|
97
|
+
await hydrateMermaidBlocks(element);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
void hydrate();
|
|
101
|
+
const observer = new MutationObserver(() => {
|
|
102
|
+
if (element.isConnected) void hydrateMermaidBlocks(element, { cachedOnly: true });
|
|
103
|
+
window.clearTimeout(timer);
|
|
104
|
+
timer = window.setTimeout(() => void hydrate(), 120);
|
|
105
|
+
});
|
|
106
|
+
observer.observe(element, { childList: true });
|
|
107
|
+
|
|
108
|
+
const rehydrateForTheme = async () => {
|
|
109
|
+
await hydrate();
|
|
110
|
+
const block = diagramBlock.current;
|
|
111
|
+
// A timeline re-render can replace the block under an open viewer; keep
|
|
112
|
+
// the last snapshot then rather than closing the viewer on the user.
|
|
113
|
+
if (!block?.isConnected) return;
|
|
114
|
+
onDiagramBlock(block);
|
|
115
|
+
};
|
|
116
|
+
const themeObserver = new MutationObserver(() => void rehydrateForTheme());
|
|
117
|
+
themeObserver.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] });
|
|
118
|
+
|
|
119
|
+
return () => {
|
|
120
|
+
window.clearTimeout(timer);
|
|
121
|
+
observer.disconnect();
|
|
122
|
+
themeObserver.disconnect();
|
|
123
|
+
};
|
|
124
|
+
}, [container, html, active, diagramBlock, onDiagramBlock]);
|
|
125
|
+
}
|
|
@@ -21,7 +21,12 @@ import { Window } from 'happy-dom';
|
|
|
21
21
|
import { h, render } from 'preact';
|
|
22
22
|
import { act } from 'preact/test-utils';
|
|
23
23
|
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
isUpdateApplyResult,
|
|
26
|
+
UPDATE_RECHECK_MIN_GAP_MS,
|
|
27
|
+
useUpdates,
|
|
28
|
+
type UseUpdatesResult,
|
|
29
|
+
} from '@/client/hooks/ui/updates';
|
|
25
30
|
import type { RestartWatchDeps } from '@/client/hooks/ui/updates/restart';
|
|
26
31
|
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
27
32
|
|
|
@@ -197,6 +202,100 @@ describe('an update that restarts its own server', () => {
|
|
|
197
202
|
});
|
|
198
203
|
});
|
|
199
204
|
|
|
205
|
+
describe('a console left open across a release', () => {
|
|
206
|
+
/** Count the checks a render has issued. */
|
|
207
|
+
const checks = (harness: Harness): number =>
|
|
208
|
+
harness.requests.filter((url) => url.includes('/api/updates/check')).length;
|
|
209
|
+
|
|
210
|
+
/** Move `Date.now` past the re-check floor for the duration of `run`. */
|
|
211
|
+
async function pastCooldown(run: () => Promise<void> | void): Promise<void> {
|
|
212
|
+
const realNow = Date.now;
|
|
213
|
+
const origin = realNow();
|
|
214
|
+
Date.now = () => origin + UPDATE_RECHECK_MIN_GAP_MS + 1;
|
|
215
|
+
try {
|
|
216
|
+
await run();
|
|
217
|
+
} finally {
|
|
218
|
+
Date.now = realNow;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
test('the tab becoming visible again re-reads the status', async () => {
|
|
223
|
+
const harness = await mount(
|
|
224
|
+
() => Response.json(checkPayload()),
|
|
225
|
+
() => ({ pid: 100, startedAt: '2026-10-15T00:00:00.000Z', uptime: 900 }),
|
|
226
|
+
);
|
|
227
|
+
expect(checks(harness)).toBe(1);
|
|
228
|
+
|
|
229
|
+
await pastCooldown(async () => {
|
|
230
|
+
win.document.dispatchEvent(new win.Event('visibilitychange'));
|
|
231
|
+
await act(async () => {});
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
expect(checks(harness)).toBe(2);
|
|
235
|
+
expect(harness.updates.info?.kabmo.latest).toBe('2.0.0');
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
test('the interval re-reads a console that never left the screen', async () => {
|
|
239
|
+
let tick: (() => void) | null = null;
|
|
240
|
+
const realSetInterval = win.setInterval;
|
|
241
|
+
const realClearInterval = win.clearInterval;
|
|
242
|
+
win.setInterval = ((handler: Parameters<typeof win.setInterval>[0]) => {
|
|
243
|
+
tick = handler as () => void;
|
|
244
|
+
return 1;
|
|
245
|
+
}) as unknown as typeof win.setInterval;
|
|
246
|
+
win.clearInterval = (() => undefined) as typeof win.clearInterval;
|
|
247
|
+
|
|
248
|
+
try {
|
|
249
|
+
const harness = await mount(
|
|
250
|
+
() => Response.json(checkPayload()),
|
|
251
|
+
() => ({ pid: 100, startedAt: '2026-10-15T00:00:00.000Z', uptime: 900 }),
|
|
252
|
+
);
|
|
253
|
+
expect(checks(harness)).toBe(1);
|
|
254
|
+
|
|
255
|
+
await pastCooldown(async () => {
|
|
256
|
+
tick?.();
|
|
257
|
+
await act(async () => {});
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
expect(checks(harness)).toBe(2);
|
|
261
|
+
} finally {
|
|
262
|
+
win.setInterval = realSetInterval;
|
|
263
|
+
win.clearInterval = realClearInterval;
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
test('a re-check inside the cooldown does not read npm again', async () => {
|
|
268
|
+
const harness = await mount(
|
|
269
|
+
() => Response.json(checkPayload()),
|
|
270
|
+
() => ({ pid: 100, startedAt: '2026-10-15T00:00:00.000Z', uptime: 900 }),
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
// `focus` and `visibilitychange` both fire on the same return to the app.
|
|
274
|
+
win.document.dispatchEvent(new win.Event('visibilitychange'));
|
|
275
|
+
win.dispatchEvent(new win.Event('focus'));
|
|
276
|
+
await act(async () => {});
|
|
277
|
+
|
|
278
|
+
expect(checks(harness)).toBe(1);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
test('an unmounted console stops listening', async () => {
|
|
282
|
+
const harness = await mount(
|
|
283
|
+
() => Response.json(checkPayload()),
|
|
284
|
+
() => ({ pid: 100, startedAt: '2026-10-15T00:00:00.000Z', uptime: 900 }),
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
act(() => render(null, container));
|
|
288
|
+
|
|
289
|
+
await pastCooldown(async () => {
|
|
290
|
+
win.document.dispatchEvent(new win.Event('visibilitychange'));
|
|
291
|
+
win.dispatchEvent(new win.Event('focus'));
|
|
292
|
+
await act(async () => {});
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
expect(checks(harness)).toBe(1);
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
|
|
200
299
|
describe('an update that does not restart', () => {
|
|
201
300
|
test('re-checks instead of reloading', async () => {
|
|
202
301
|
const harness = await mount(
|
|
@@ -38,6 +38,23 @@ export interface UseUpdatesOptions {
|
|
|
38
38
|
restart?: RestartWatchDeps;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* How often a console left open re-reads the update status.
|
|
43
|
+
*
|
|
44
|
+
* The mount check alone was the published-release gap users hit: a server that
|
|
45
|
+
* booted before `vX` reached npm kept that answer for the life of the page, so
|
|
46
|
+
* the "update available" popup never appeared until a restart. Half an hour is
|
|
47
|
+
* the cost of one registry read plus one `omp --version` spawn per open console.
|
|
48
|
+
*/
|
|
49
|
+
export const UPDATE_RECHECK_INTERVAL_MS = 30 * 60_000;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Floor between automatic re-checks. `focus` and `visibilitychange` both fire
|
|
53
|
+
* on the same return to the app, and a burst of them must not become a burst of
|
|
54
|
+
* registry reads; the manual "Check again" button bypasses this.
|
|
55
|
+
*/
|
|
56
|
+
export const UPDATE_RECHECK_MIN_GAP_MS = 60_000;
|
|
57
|
+
|
|
41
58
|
function responseMessage(payload: unknown, fallback: string): string {
|
|
42
59
|
if (typeof payload !== 'object' || payload === null) return fallback;
|
|
43
60
|
|
|
@@ -65,12 +82,14 @@ export function useUpdates(options: UseUpdatesOptions = {}): UseUpdatesResult {
|
|
|
65
82
|
const [progress, setProgress] = useState<UpdateLogState | null>(null);
|
|
66
83
|
const [error, setError] = useState<string | null>(null);
|
|
67
84
|
const inFlightCheckRef = useRef<Promise<void> | null>(null);
|
|
85
|
+
const lastCheckAtRef = useRef(0);
|
|
68
86
|
const didAutoCheckRef = useRef(false);
|
|
69
87
|
const applyAbortRef = useRef<AbortController | null>(null);
|
|
70
88
|
|
|
71
89
|
const check = useCallback(() => {
|
|
72
90
|
if (inFlightCheckRef.current) return inFlightCheckRef.current;
|
|
73
91
|
|
|
92
|
+
lastCheckAtRef.current = Date.now();
|
|
74
93
|
const request = (async () => {
|
|
75
94
|
setChecking(true);
|
|
76
95
|
setError(null);
|
|
@@ -239,6 +258,37 @@ export function useUpdates(options: UseUpdatesOptions = {}): UseUpdatesResult {
|
|
|
239
258
|
void check();
|
|
240
259
|
}, [check]);
|
|
241
260
|
|
|
261
|
+
/**
|
|
262
|
+
* Re-read the status without a reload.
|
|
263
|
+
*
|
|
264
|
+
* Two triggers because a console has two ways of being away and coming back:
|
|
265
|
+
* a browser tab reports `visibilitychange`, and a native shell window reports
|
|
266
|
+
* `focus` (the WKWebView/WebView keeps `visibilityState: visible` while the
|
|
267
|
+
* app is in the background). The interval is the fallback for a console that
|
|
268
|
+
* never left the screen — the page that stays open for days is exactly the
|
|
269
|
+
* one the mount check used to strand.
|
|
270
|
+
*/
|
|
271
|
+
useEffect(() => {
|
|
272
|
+
const recheck = () => {
|
|
273
|
+
if (document.visibilityState === 'hidden') return;
|
|
274
|
+
if (Date.now() - lastCheckAtRef.current < UPDATE_RECHECK_MIN_GAP_MS) return;
|
|
275
|
+
void check();
|
|
276
|
+
};
|
|
277
|
+
const onVisibilityChange = () => {
|
|
278
|
+
if (document.visibilityState === 'visible') recheck();
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
document.addEventListener('visibilitychange', onVisibilityChange);
|
|
282
|
+
window.addEventListener('focus', recheck);
|
|
283
|
+
const timer = window.setInterval(recheck, UPDATE_RECHECK_INTERVAL_MS);
|
|
284
|
+
|
|
285
|
+
return () => {
|
|
286
|
+
document.removeEventListener('visibilitychange', onVisibilityChange);
|
|
287
|
+
window.removeEventListener('focus', recheck);
|
|
288
|
+
window.clearInterval(timer);
|
|
289
|
+
};
|
|
290
|
+
}, [check]);
|
|
291
|
+
|
|
242
292
|
useEffect(() => () => applyAbortRef.current?.abort(), []);
|
|
243
293
|
|
|
244
294
|
return {
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `useActiveReleaseNotes` — the About modal's per-target "What's new" read.
|
|
8
|
+
*
|
|
9
|
+
* The contract that matters: the only thing sent is WHICH product (both
|
|
10
|
+
* versions are derived server-side), the payload's own `error` field is what the
|
|
11
|
+
* dialog shows, and a closed dialog makes no request at all. Stubbed `fetch`
|
|
12
|
+
* records the URL, so a target mix-up cannot pass as a rendering detail.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
16
|
+
import { Window } from 'happy-dom';
|
|
17
|
+
import { h, render } from 'preact';
|
|
18
|
+
import { act } from 'preact/test-utils';
|
|
19
|
+
|
|
20
|
+
import { useActiveReleaseNotes } from '@/client/hooks/ui/updates/notes';
|
|
21
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
22
|
+
import type { ActiveReleaseNotes, UpdateTarget } from '@/shared/types/updates';
|
|
23
|
+
|
|
24
|
+
let container: HTMLElement;
|
|
25
|
+
const originalFetch = Bun.fetch;
|
|
26
|
+
|
|
27
|
+
/** The runner's own globals are restored in `afterAll`; `fetch` is not a DOM global. */
|
|
28
|
+
function Harness({ target }: { target: UpdateTarget | null }) {
|
|
29
|
+
const notes = useActiveReleaseNotes(target);
|
|
30
|
+
return h(
|
|
31
|
+
'span',
|
|
32
|
+
{ id: 'out' },
|
|
33
|
+
JSON.stringify({
|
|
34
|
+
version: notes.data?.version ?? null,
|
|
35
|
+
note: notes.data?.note?.version ?? null,
|
|
36
|
+
loading: notes.loading,
|
|
37
|
+
error: notes.error,
|
|
38
|
+
}),
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function payload(overrides: Partial<ActiveReleaseNotes> = {}): ActiveReleaseNotes {
|
|
43
|
+
return {
|
|
44
|
+
target: 'kabmo',
|
|
45
|
+
version: '3.9.0',
|
|
46
|
+
note: { version: '3.9.0', date: '2026-01-01', url: 'https://example.test/v3.9.0', body: '* notes' },
|
|
47
|
+
changelogUrl: 'https://example.test/CHANGELOG.md',
|
|
48
|
+
error: null,
|
|
49
|
+
...overrides,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** A fetch double that records the URLs asked and answers one payload. */
|
|
54
|
+
function stubFetch(asked: string[], body: unknown, status = 200): void {
|
|
55
|
+
globalThis.fetch = (async (input: string | URL | Request) => {
|
|
56
|
+
asked.push(String(input));
|
|
57
|
+
return { ok: status < 400, status, json: async () => body } as Response;
|
|
58
|
+
}) as unknown as typeof fetch;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function mount(target: UpdateTarget | null): Promise<Record<string, unknown>> {
|
|
62
|
+
await act(async () => {
|
|
63
|
+
render(h(Harness, { target }), container);
|
|
64
|
+
});
|
|
65
|
+
// The read is an effect: let its promise settle and re-render.
|
|
66
|
+
for (let i = 0; i < 20; i += 1) await act(async () => {});
|
|
67
|
+
return JSON.parse(container.querySelector('#out')?.textContent ?? '{}') as Record<string, unknown>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
beforeAll(() => {
|
|
71
|
+
installDomGlobals(new Window({ url: 'http://localhost' }));
|
|
72
|
+
container = document.createElement('div');
|
|
73
|
+
document.body.appendChild(container);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
afterEach(() => {
|
|
77
|
+
act(() => render(null, container));
|
|
78
|
+
globalThis.fetch = originalFetch;
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
afterAll(() => {
|
|
82
|
+
container.remove();
|
|
83
|
+
restoreDomGlobals();
|
|
84
|
+
globalThis.fetch = originalFetch;
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
describe('useActiveReleaseNotes', () => {
|
|
88
|
+
test('asks for the target and reports the section for the running version', async () => {
|
|
89
|
+
const asked: string[] = [];
|
|
90
|
+
stubFetch(asked, payload());
|
|
91
|
+
|
|
92
|
+
const out = await mount('kabmo');
|
|
93
|
+
|
|
94
|
+
expect(asked).toEqual(['/api/updates/notes?target=kabmo']);
|
|
95
|
+
expect(out).toMatchObject({ version: '3.9.0', note: '3.9.0', loading: false, error: null });
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('the per-target URL is the product, never a caller-supplied version', async () => {
|
|
99
|
+
const asked: string[] = [];
|
|
100
|
+
stubFetch(asked, payload({ target: 'omp', version: '18.3.0' }));
|
|
101
|
+
|
|
102
|
+
await mount('omp');
|
|
103
|
+
|
|
104
|
+
expect(asked).toEqual(['/api/updates/notes?target=omp']);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('a payload error is what the dialog shows', async () => {
|
|
108
|
+
stubFetch([], payload({ version: '9.9.9', note: null, error: 'No changelog section for v9.9.9' }));
|
|
109
|
+
|
|
110
|
+
const out = await mount('omp');
|
|
111
|
+
|
|
112
|
+
expect(out).toMatchObject({
|
|
113
|
+
version: '9.9.9',
|
|
114
|
+
note: null,
|
|
115
|
+
loading: false,
|
|
116
|
+
error: 'No changelog section for v9.9.9',
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('a non-ok response is reported instead of rendering nothing', async () => {
|
|
121
|
+
stubFetch([], { error: 'Unknown update target' }, 400);
|
|
122
|
+
|
|
123
|
+
const out = await mount('kabmo');
|
|
124
|
+
|
|
125
|
+
expect(out.error).toBe('Could not load release notes (HTTP 400)');
|
|
126
|
+
expect(out.loading).toBe(false);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test('a closed dialog makes no request', async () => {
|
|
130
|
+
const asked: string[] = [];
|
|
131
|
+
stubFetch(asked, payload());
|
|
132
|
+
|
|
133
|
+
const out = await mount(null);
|
|
134
|
+
|
|
135
|
+
expect(asked).toEqual([]);
|
|
136
|
+
expect(out).toMatchObject({ version: null, note: null, loading: false, error: null });
|
|
137
|
+
});
|
|
138
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The About modal's per-target "What's new": the changelog section for the
|
|
3
|
+
* version this install is running.
|
|
4
|
+
*
|
|
5
|
+
* One request per target when its dialog opens — the payload is one release
|
|
6
|
+
* section, which cannot change while the dialog is on screen. The server derives
|
|
7
|
+
* both versions itself, so the only thing this hook sends is WHICH product.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { useEffect, useRef, useState } from 'preact/hooks';
|
|
11
|
+
import type { ActiveReleaseNotes, UpdateTarget } from '@/shared/types/updates';
|
|
12
|
+
|
|
13
|
+
export interface UseActiveReleaseNotesResult {
|
|
14
|
+
data: ActiveReleaseNotes | null;
|
|
15
|
+
loading: boolean;
|
|
16
|
+
error: string | null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function useActiveReleaseNotes(target: UpdateTarget | null): UseActiveReleaseNotesResult {
|
|
20
|
+
const [data, setData] = useState<ActiveReleaseNotes | null>(null);
|
|
21
|
+
const [loading, setLoading] = useState(false);
|
|
22
|
+
const [error, setError] = useState<string | null>(null);
|
|
23
|
+
const abortRef = useRef<AbortController | null>(null);
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (!target) {
|
|
27
|
+
setData(null);
|
|
28
|
+
setLoading(false);
|
|
29
|
+
setError(null);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const controller = new AbortController();
|
|
34
|
+
abortRef.current = controller;
|
|
35
|
+
setLoading(true);
|
|
36
|
+
setError(null);
|
|
37
|
+
|
|
38
|
+
void (async () => {
|
|
39
|
+
try {
|
|
40
|
+
const response = await fetch(`/api/updates/notes?target=${target}`, { signal: controller.signal });
|
|
41
|
+
const payload = (await response.json()) as ActiveReleaseNotes;
|
|
42
|
+
if (!response.ok) throw new Error(`Could not load release notes (HTTP ${response.status})`);
|
|
43
|
+
setData(payload);
|
|
44
|
+
setError(payload.error);
|
|
45
|
+
} catch (cause) {
|
|
46
|
+
if (controller.signal.aborted) return;
|
|
47
|
+
setError(cause instanceof Error ? cause.message : 'Could not load release notes');
|
|
48
|
+
} finally {
|
|
49
|
+
if (!controller.signal.aborted) setLoading(false);
|
|
50
|
+
}
|
|
51
|
+
})();
|
|
52
|
+
|
|
53
|
+
return () => controller.abort();
|
|
54
|
+
}, [target]);
|
|
55
|
+
|
|
56
|
+
return { data, loading, error };
|
|
57
|
+
}
|
|
@@ -283,7 +283,7 @@ export interface DesktopIdentity {
|
|
|
283
283
|
|
|
284
284
|
function readDesktopIdentity(): DesktopIdentity | null {
|
|
285
285
|
if (typeof window === 'undefined') return null;
|
|
286
|
-
// `window.__kabmoDesktop` is declared by `lib/desktop
|
|
286
|
+
// `window.__kabmoDesktop` is declared by `lib/shell/desktop` — the same
|
|
287
287
|
// object the shell injects, so this reads the shell's own contract rather
|
|
288
288
|
// than re-declaring its shape here.
|
|
289
289
|
return window.__kabmoDesktop ?? null;
|
|
@@ -30,12 +30,8 @@
|
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
import { useCallback, useRef, useState } from 'preact/hooks';
|
|
33
|
-
import {
|
|
34
|
-
|
|
35
|
-
bridgeError,
|
|
36
|
-
isDesktopShell,
|
|
37
|
-
type ShellUpdateOutcome,
|
|
38
|
-
} from '@/client/lib/desktop/bridge';
|
|
33
|
+
import { applyShellUpdate, type ShellUpdateOutcome } from '@/client/lib/shell/desktop';
|
|
34
|
+
import { bridgeError, isDesktopShell } from '@/client/lib/shell/transport';
|
|
39
35
|
import type { ShellDownload } from '@/client/hooks/ui/updates/shell-download';
|
|
40
36
|
|
|
41
37
|
/** What the control is doing right now. */
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
* onto the folder it already sits in would move it out.
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
+
import { useEffect, useState } from 'preact/hooks';
|
|
29
30
|
import type { TargetedDragEvent } from 'preact';
|
|
30
31
|
import type { ClipboardTarget, FileClipboard } from '@/client/hooks/workspace/file-clipboard';
|
|
31
32
|
|
|
@@ -40,6 +41,15 @@ export interface FileRowDragOptions {
|
|
|
40
41
|
onDragStart: (target: ClipboardTarget) => void;
|
|
41
42
|
onDragEnd: () => void;
|
|
42
43
|
onDropOn: (target: ClipboardTarget) => void;
|
|
44
|
+
/**
|
|
45
|
+
* The drag has been hovering this row and this row would accept it.
|
|
46
|
+
*
|
|
47
|
+
* What makes a COLLAPSED CHAIN reachable: `dev/src/main/code` is one row, so
|
|
48
|
+
* the levels inside its label are not drop targets at all and a drop lands in
|
|
49
|
+
* the deepest directory. The panel unfolds the row when this fires, which
|
|
50
|
+
* turns each level into a row of its own before the user lets go.
|
|
51
|
+
*/
|
|
52
|
+
onHoverAccept?: (target: ClipboardTarget) => void;
|
|
43
53
|
}
|
|
44
54
|
|
|
45
55
|
export interface FileRowDrag {
|
|
@@ -47,9 +57,20 @@ export interface FileRowDrag {
|
|
|
47
57
|
isDragging: boolean;
|
|
48
58
|
/** True while this row would accept the drag in flight. */
|
|
49
59
|
acceptsDrop: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* True only while the pointer is OVER this row AND it would accept the drag.
|
|
62
|
+
*
|
|
63
|
+
* Deliberately not `acceptsDrop`: that one is a CAPABILITY ("a drop here would
|
|
64
|
+
* be legal"), so styling it highlighted every on-screen folder and file the
|
|
65
|
+
* instant a drag started — measured, dragging `a.ts` over a tree of `b` and
|
|
66
|
+
* `c` painted BOTH rows' `bg-info` blocks. A highlight is a promise about the
|
|
67
|
+
* drop the pointer is on, so it has to be driven by the pointer.
|
|
68
|
+
*/
|
|
69
|
+
isDropHovered: boolean;
|
|
50
70
|
onDragStart: (e: TargetedDragEvent<HTMLElement>) => void;
|
|
51
71
|
onDragEnd: () => void;
|
|
52
72
|
onDragOver: (e: TargetedDragEvent<HTMLElement>) => void;
|
|
73
|
+
onDragLeave: () => void;
|
|
53
74
|
onDrop: (e: TargetedDragEvent<HTMLElement>) => void;
|
|
54
75
|
}
|
|
55
76
|
|
|
@@ -60,13 +81,27 @@ export function useFileRowDrag({
|
|
|
60
81
|
onDragStart,
|
|
61
82
|
onDragEnd,
|
|
62
83
|
onDropOn,
|
|
84
|
+
onHoverAccept,
|
|
63
85
|
}: FileRowDragOptions): FileRowDrag {
|
|
64
86
|
const isDragging = dragging?.path === target.path;
|
|
65
87
|
const acceptsDrop = Boolean(dragging) && !isDragging && clipboard.moveRefusalFor(dragging!, target) === null;
|
|
88
|
+
/**
|
|
89
|
+
* The row the pointer is over, owned here rather than by the panel: `dragover`
|
|
90
|
+
* and `dragleave` are per row, and a row that could not leave its own state
|
|
91
|
+
* would stay highlighted after the pointer moved on.
|
|
92
|
+
*/
|
|
93
|
+
const [hovered, setHovered] = useState(false);
|
|
94
|
+
// A drag that ENDED (dropped, cancelled, or left the window) leaves no row
|
|
95
|
+
// hovering: `dragleave` is not guaranteed for the row the drop happened on.
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (!dragging) setHovered(false);
|
|
98
|
+
}, [dragging]);
|
|
99
|
+
const isDropHovered = hovered && acceptsDrop;
|
|
66
100
|
|
|
67
101
|
return {
|
|
68
102
|
isDragging,
|
|
69
103
|
acceptsDrop,
|
|
104
|
+
isDropHovered,
|
|
70
105
|
onDragStart: (e) => {
|
|
71
106
|
// The tree's own payload is what a drop INSIDE the panel reads, and
|
|
72
107
|
// `text/plain` carries the path so a drag out to another surface (a
|
|
@@ -83,10 +118,16 @@ export function useFileRowDrag({
|
|
|
83
118
|
// Claimed even when refused — see the module doc: the background is the
|
|
84
119
|
// root's target, and letting this bubble would move the entry there.
|
|
85
120
|
e.stopPropagation();
|
|
121
|
+
setHovered(acceptsDrop);
|
|
86
122
|
if (!acceptsDrop) return;
|
|
87
123
|
e.preventDefault();
|
|
88
124
|
if (e.dataTransfer) e.dataTransfer.dropEffect = 'move';
|
|
125
|
+
// Hovering an accepting row is the moment its hidden levels can be
|
|
126
|
+
// offered: `dragover` fires repeatedly and the panel's own set makes the
|
|
127
|
+
// repeat a no-op, so this is idempotent by construction.
|
|
128
|
+
onHoverAccept?.(target);
|
|
89
129
|
},
|
|
130
|
+
onDragLeave: () => setHovered(false),
|
|
90
131
|
onDrop: (e) => {
|
|
91
132
|
if (!dragging) return;
|
|
92
133
|
e.stopPropagation();
|
|
@@ -51,6 +51,16 @@ export interface FileActionDeps {
|
|
|
51
51
|
onCreated?: (entry: CreatedEntry) => void;
|
|
52
52
|
/** A row the panel just renamed, moved locally — same reason as `onCreated`. */
|
|
53
53
|
onRenamed?: (fromPath: string, toPath: string) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Split this row's collapsed chain into one row per directory.
|
|
56
|
+
*
|
|
57
|
+
* Present only where an unfold makes sense (a folder whose label names more
|
|
58
|
+
* than one directory); the menu row that calls it is drawn from the same
|
|
59
|
+
* condition, so a menu never offers an action the panel cannot perform.
|
|
60
|
+
*/
|
|
61
|
+
onUnfold?: () => void;
|
|
62
|
+
/** Fold this row back into the one chain row it is listed as. */
|
|
63
|
+
onFold?: () => void;
|
|
54
64
|
/** The panel's clipboard: Cut/Copy fill it, Paste reads it. */
|
|
55
65
|
clipboard: FileClipboard;
|
|
56
66
|
/** Whether this row is a folder — what Cut/Copy/Paste need to name their target. */
|
|
@@ -80,6 +90,14 @@ export interface FileActions {
|
|
|
80
90
|
busy: boolean;
|
|
81
91
|
/** Label of the row's Paste action, or null when a paste cannot land here. */
|
|
82
92
|
pasteLabel: string | null;
|
|
93
|
+
/**
|
|
94
|
+
* True when the row's label names more than one directory — a collapsed
|
|
95
|
+
* chain, whose inner levels are not rows and therefore not renameable until
|
|
96
|
+
* it is unfolded.
|
|
97
|
+
*/
|
|
98
|
+
chainLabel: boolean;
|
|
99
|
+
/** True when this row is an unfolded chain's outermost level, so it can fold. */
|
|
100
|
+
foldable: boolean;
|
|
83
101
|
/** The fetcher's own state/data, for the history modal. */
|
|
84
102
|
fetcherState: string;
|
|
85
103
|
fetcherData: FsActionResponse | undefined;
|
|
@@ -93,7 +111,7 @@ export interface FileActions {
|
|
|
93
111
|
closeHistory: () => void;
|
|
94
112
|
}
|
|
95
113
|
|
|
96
|
-
export function useFileActions({ file, diff, onOpenFile, onActionComplete, onCreated, onRenamed, clipboard, isFolder }: FileActionDeps): FileActions {
|
|
114
|
+
export function useFileActions({ file, diff, onOpenFile, onActionComplete, onCreated, onRenamed, onUnfold, onFold, clipboard, isFolder }: FileActionDeps): FileActions {
|
|
97
115
|
const actionFetcher = useFetcher<FsActionResponse>();
|
|
98
116
|
const [contextMenu, setContextMenu] = useState<{ x: number; y: number } | null>(null);
|
|
99
117
|
const contextMenuRef = useRef<HTMLDivElement>(null);
|
|
@@ -212,6 +230,10 @@ export function useFileActions({ file, diff, onOpenFile, onActionComplete, onCre
|
|
|
212
230
|
} else if (actionType === 'rename') {
|
|
213
231
|
setRenameValue(file.path);
|
|
214
232
|
setShowRenameModal(true);
|
|
233
|
+
} else if (actionType === 'unfold') {
|
|
234
|
+
onUnfold?.();
|
|
235
|
+
} else if (actionType === 'fold') {
|
|
236
|
+
onFold?.();
|
|
215
237
|
} else if (actionType === 'new_file') {
|
|
216
238
|
create.openDialog('file');
|
|
217
239
|
} else if (actionType === 'new_folder') {
|
|
@@ -264,6 +286,8 @@ export function useFileActions({ file, diff, onOpenFile, onActionComplete, onCre
|
|
|
264
286
|
renameError,
|
|
265
287
|
busy: actionFetcher.state !== 'idle' || create.busy || clipboard.busy,
|
|
266
288
|
pasteLabel,
|
|
289
|
+
chainLabel: onUnfold !== undefined,
|
|
290
|
+
foldable: onFold !== undefined,
|
|
267
291
|
fetcherState: actionFetcher.state,
|
|
268
292
|
fetcherData: actionFetcher.data,
|
|
269
293
|
handleAction,
|