@kabmo-labs/kabmo 0.17.0 → 0.19.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 +10 -7
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +523 -441
- package/dist/client/static/js/{index-rerjq5th.js → index-fcee4c13.js} +828 -818
- package/dist/client/static/js/index-sxdw908m.css +1 -0
- package/marketplace/plugins/command-runner/package.json +3 -2
- package/marketplace/plugins/git-forge/package.json +3 -2
- package/marketplace/plugins/session-info/package.json +3 -2
- package/marketplace/plugins/stats/package.json +3 -2
- package/package.json +3 -1
- package/src/client/components/auth/login-screen/index.tsx +2 -1
- package/src/client/components/common/ComposerPicker.tsx +1 -1
- package/src/client/components/common/FolderPicker.tsx +2 -2
- package/src/client/components/common/MarkdownRenderer.tsx +136 -89
- package/src/client/components/common/Modal.tsx +2 -2
- package/src/client/components/common/PWAInstallButton.tsx +2 -2
- package/src/client/components/common/ViewportSelector.tsx +1 -1
- package/src/client/components/common/anchored-menu/index.test.tsx +141 -0
- package/src/client/components/common/anchored-menu/index.tsx +147 -0
- package/src/client/components/common/batch-selection/SelectionCheckbox.tsx +2 -1
- package/src/client/components/common/brand-wordmark/index.test.tsx +13 -2
- package/src/client/components/common/brand-wordmark/index.tsx +13 -2
- package/src/client/components/common/checkbox/style.test.ts +139 -0
- package/src/client/components/common/checkbox/style.ts +51 -0
- package/src/client/components/common/context-usage-button/index.tsx +2 -2
- package/src/client/components/common/file-icon/index.tsx +23 -9
- package/src/client/components/common/header-controls/MoreMenu.tsx +1 -1
- 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/panel-mark/index.tsx +97 -0
- package/src/client/components/common/provider-icon/glyphs.test.ts +1 -1
- package/src/client/components/common/provider-icon/index.test.ts +14 -0
- package/src/client/components/common/provider-icon/index.tsx +4 -0
- package/src/client/components/common/provider-icon/resolve.test.ts +8 -7
- package/src/client/components/common/provider-icon/resolve.ts +16 -3
- package/src/client/components/common/server-control/Panel.tsx +33 -23
- package/src/client/components/common/server-control/index.test.tsx +11 -5
- package/src/client/components/common/server-control/index.tsx +10 -8
- package/src/client/components/common/session-actions-menu/index.tsx +1 -1
- package/src/client/components/common/toolbar-row/index.tsx +1 -1
- package/src/client/components/layout/ActivityBar.tsx +22 -3
- package/src/client/components/layout/LeftDock.tsx +9 -2
- package/src/client/components/layout/PanelVisibilityMenu.tsx +1 -1
- package/src/client/components/layout/WindowAura.tsx +27 -0
- package/src/client/components/layout/desktop-layout/LeftColumn.tsx +1 -1
- package/src/client/components/layout/desktop-layout/TopNavbar.tsx +2 -2
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +11 -2
- package/src/client/components/layout/desktop-layout/index.tsx +3 -1
- package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +44 -23
- 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/Header.tsx +1 -1
- package/src/client/components/layout/session-sidebar/OverflowMenu.tsx +1 -1
- package/src/client/components/layout/session-sidebar/Toolbar.tsx +1 -1
- 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/ActionRow.tsx +1 -1
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +40 -14
- 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/session-sidebar/new-workspace-modal/index.tsx +2 -2
- package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +2 -1
- package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +2 -2
- 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/LayoutWrapper.tsx +3 -1
- package/src/client/components/mobile/mobile-main-view/Header.tsx +2 -2
- 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 +1 -1
- 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/mobile/mobile-session-sidebar/Toolbar.tsx +1 -1
- package/src/client/components/mobile/panel-chips.tsx +10 -2
- package/src/client/components/settings/Modal.tsx +4 -4
- package/src/client/components/settings/ProjectSelectorDropdown.tsx +2 -2
- package/src/client/components/settings/SettingsSidebarList.tsx +20 -0
- package/src/client/components/settings/apply-side-effects.test.ts +30 -0
- package/src/client/components/settings/apply-side-effects.ts +14 -0
- package/src/client/components/settings/categories/AgentSettings.tsx +23 -50
- package/src/client/components/settings/categories/AppearanceSettings.tsx +6 -0
- 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/SkillSettings.tsx +2 -2
- 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 +9 -2
- package/src/client/components/settings/categories/agent-settings/levels.ts +38 -0
- package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +2 -1
- package/src/client/components/settings/categories/appearance-settings/EditorTypingSection.tsx +2 -1
- package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +144 -0
- package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.test.tsx +120 -0
- package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.tsx +180 -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 +93 -77
- package/src/client/components/settings/categories/mcp-settings/EnvVarsSection.tsx +83 -0
- package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +28 -15
- 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/panel-plugins/AvailableList.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/BuiltinList.tsx +21 -3
- package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +51 -2
- package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +43 -10
- package/src/client/components/settings/categories/plugin-settings/DetailPane.tsx +2 -1
- package/src/client/components/settings/categories/plugin-settings/SettingsSection.tsx +2 -1
- package/src/client/components/settings/categories/project-settings/ModelDropdown.tsx +1 -1
- package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +2 -1
- package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +2 -2
- package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +3 -2
- package/src/client/components/settings/categories/provider-settings/LogoutProviderModal.tsx +2 -2
- package/src/client/components/settings/categories/skill-catalog/GitImportPanel.tsx +3 -2
- package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +37 -8
- package/src/client/components/settings/categories/skill-settings/DetailPane.tsx +34 -14
- package/src/client/components/settings/categories/skill-settings/SidebarList.tsx +21 -0
- package/src/client/components/settings/categories/skill-settings/pane.test.tsx +15 -6
- 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/btw-panel/TopicMenu.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/NewChatModal.tsx +3 -3
- 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/UndoConfirmModal.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +13 -2
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.tsx +4 -3
- package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/plan-review/index.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +2 -6
- 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/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/shared/ArtifactChip.tsx +7 -6
- 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/context-panel/CostBreakdownPopover.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/index.tsx +2 -2
- 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/PluginRail.tsx +1 -1
- package/src/client/components/workspace/editor/PreviewPane.tsx +70 -0
- package/src/client/components/workspace/editor/SaveDeletedFileModal.tsx +2 -2
- package/src/client/components/workspace/editor/TabContextMenu.tsx +1 -1
- package/src/client/components/workspace/editor/Tabs.tsx +1 -1
- 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/file-explorer/ContextMenu.tsx +1 -1
- package/src/client/components/workspace/file-explorer/Modals.tsx +10 -10
- package/src/client/components/workspace/file-explorer/RootMenu.tsx +1 -1
- package/src/client/components/workspace/git-panel/BranchToolbar.test.tsx +130 -0
- package/src/client/components/workspace/git-panel/BranchToolbar.tsx +21 -11
- package/src/client/components/workspace/git-panel/CommitBox.tsx +2 -1
- package/src/client/components/workspace/git-panel/Modals.tsx +2 -2
- package/src/client/components/workspace/git-panel/StashSection.tsx +2 -1
- package/src/client/components/workspace/git-panel/branch-modal/DeleteDialog.tsx +2 -1
- package/src/client/components/workspace/git-panel/branch-modal/RenameDialog.tsx +2 -1
- package/src/client/components/workspace/git-panel/commit-modal/index.tsx +2 -2
- package/src/client/components/workspace/git-panel/commit-modal.test.ts +5 -3
- package/src/client/components/workspace/git-panel/index.tsx +7 -0
- package/src/client/components/workspace/model-dropdown/Panel.tsx +1 -1
- package/src/client/components/workspace/model-dropdown/SpecsTooltip.tsx +1 -1
- package/src/client/components/workspace/plugin-panel/catalog.tsx +7 -0
- package/src/client/components/workspace/plugin-panel/resolve.tsx +4 -0
- package/src/client/components/workspace/search-panel/Body.tsx +1 -1
- package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +1 -1
- 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 +33 -1
- package/src/client/glass.css +785 -0
- package/src/client/glass.test.ts +346 -0
- 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/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/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/ui/glass-support.ts +57 -0
- package/src/client/hooks/ui/icon-style.ts +59 -0
- package/src/client/hooks/ui/markdown-hydration.ts +125 -0
- package/src/client/hooks/ui/stuck-header.test.ts +188 -0
- package/src/client/hooks/ui/stuck-header.ts +91 -0
- package/src/client/hooks/ui/style-attributes.test.ts +120 -0
- package/src/client/hooks/ui/surface-style.ts +56 -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/workspace/panel-hues.ts +23 -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/review/client.ts +73 -0
- package/src/client/lib/router/search-params.ts +42 -20
- package/src/client/main.tsx +10 -0
- package/src/client/tailwind.css +329 -11
- package/src/server/lib/assets/shell-attributes.server.ts +80 -0
- package/src/server/lib/assets/shell-attributes.test.ts +86 -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/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/rpc/constants.test.ts +11 -0
- package/src/server/lib/omp/rpc/constants.ts +15 -0
- package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +1 -0
- package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +2 -30
- package/src/server/lib/omp/rpc/frame-fold.test.ts +55 -0
- package/src/server/lib/omp/rpc/frame-fold.ts +4 -0
- package/src/server/lib/omp/rpc/manager.ts +2 -2
- package/src/server/lib/omp/rpc/process-helpers.ts +11 -0
- package/src/server/lib/omp/rpc/process.test.ts +106 -0
- package/src/server/lib/omp/rpc/process.ts +39 -18
- package/src/server/lib/omp/rpc/run-settle.server.ts +12 -0
- package/src/server/lib/omp/rpc/run-settle.test.ts +22 -0
- package/src/server/lib/omp/rpc/session-command-guards.ts +5 -0
- package/src/server/lib/omp/rpc/session-commands.test.ts +9 -1
- package/src/server/lib/omp/rpc/session-commands.ts +17 -3
- package/src/server/lib/omp/rpc/terminal-settle.ts +29 -7
- 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/panels/bundled-catalog.server.ts +1 -0
- package/src/server/lib/panels/manifest.test.ts +20 -0
- package/src/server/lib/panels/manifest.ts +12 -0
- package/src/server/lib/panels/scan.server.ts +4 -0
- package/src/server/lib/queue/delivery-dispatch.server.test.ts +48 -0
- package/src/server/lib/queue/delivery-harness.ts +8 -4
- package/src/server/lib/queue/delivery.server.test.ts +29 -0
- package/src/server/lib/queue/delivery.server.ts +39 -0
- package/src/server/lib/queue/store.server.test.ts +22 -2
- package/src/server/lib/queue/store.server.ts +33 -11
- 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/plugins/ssr.ts +22 -5
- 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 +95 -102
- package/src/server/routes/settings/mcp.test.ts +135 -0
- package/src/server/routes/settings/mcp.ts +14 -6
- package/src/server/routes/settings/settings-store-routes.test.ts +6 -113
- 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/icons/file-brand-color.ts +38 -0
- package/src/shared/lib/icons/icon-paint-css.test.ts +234 -0
- package/src/shared/lib/icons/icon-paint-css.ts +284 -0
- package/src/shared/lib/icons/icon-paint-panel.ts +100 -0
- package/src/shared/lib/icons/tint-hues.generated.ts +230 -0
- package/src/shared/lib/icons/tint.test.ts +273 -0
- package/src/shared/lib/icons/tint.ts +219 -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/brand-color.test.ts +116 -0
- package/src/shared/lib/models/provider/brand-color.ts +103 -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 +31 -0
- package/src/shared/lib/omp/config/schema.ts +6 -0
- package/src/shared/lib/omp/rpc/frame.test.ts +113 -47
- package/src/shared/lib/omp/rpc/frame.ts +107 -43
- package/src/shared/lib/settings/defaults.ts +4 -0
- package/src/shared/lib/theme/catalog.test.ts +5 -4
- package/src/shared/lib/theme/catalog.ts +18 -3
- package/src/shared/lib/theme/glass-support.test.ts +38 -0
- package/src/shared/lib/theme/glass-support.ts +73 -0
- package/src/shared/lib/theme/icon-style.test.ts +74 -0
- package/src/shared/lib/theme/icon-style.ts +90 -0
- package/src/shared/lib/theme/legibility.ts +91 -0
- package/src/shared/lib/theme/palettes/dark-extended.ts +152 -0
- package/src/shared/lib/theme/palettes/light-extended.ts +157 -0
- package/src/shared/lib/theme/surface-style.test.ts +68 -0
- package/src/shared/lib/theme/surface-style.ts +91 -0
- package/src/shared/lib/theme/theme.test.ts +11 -7
- 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/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/panel-hues.test.ts +68 -0
- package/src/shared/lib/workspace/panel-hues.ts +57 -0
- package/src/shared/types/browser.ts +78 -0
- package/src/shared/types/index.ts +1 -0
- package/src/shared/types/panels-registry.ts +6 -0
- package/src/shared/types/panels.ts +14 -0
- package/src/shared/types/settings/agent.ts +28 -6
- package/src/shared/types/settings/state.ts +30 -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/fake-omp-frames.ts +163 -0
- package/dist/client/static/js/index-3ve31rzx.css +0 -1
- 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/{client/components/common/file-icon/brand-paths.ts → shared/lib/icons/file-brand-paths.ts} +0 -0
|
@@ -11,10 +11,23 @@
|
|
|
11
11
|
* and the browser-panel insert appends to the text beside the attachments that
|
|
12
12
|
* arrived with it. Extracted from the timeline hook, which is at the repo's
|
|
13
13
|
* per-file ceiling.
|
|
14
|
+
*
|
|
15
|
+
* A LANDING draft (no `?sessionId=` in the URL) is memory-only.
|
|
16
|
+
*
|
|
17
|
+
* The landing mounts `SessionStateProvider` on its fallback id (`'1'`), which
|
|
18
|
+
* is not a chat: the composer there is disabled until a workspace is picked, so
|
|
19
|
+
* nothing the user does can send or clear it. Persisting under that id made the
|
|
20
|
+
* slot permanent — measured: a browser-panel annotation appended once at the
|
|
21
|
+
* landing was still sitting in the composer on every later launch, looking like
|
|
22
|
+
* text a new chat had inherited. A draft belongs to the chat named in the URL;
|
|
23
|
+
* with no chat named, it is kept for this page session only.
|
|
14
24
|
*/
|
|
15
25
|
|
|
26
|
+
import { useState } from 'preact/hooks';
|
|
27
|
+
import { useSearchParams } from '@/client/lib/router/search-params';
|
|
16
28
|
import { useSessionState } from '@/client/hooks/workspace/session-state';
|
|
17
29
|
import { useBrowserPageContextInsert } from '@/client/hooks/chat/composer/browser-context';
|
|
30
|
+
import { useReviewIncludeInsert } from '@/client/hooks/chat/composer/review-context';
|
|
18
31
|
import { CHAT_DRAFT_ATTACHMENTS_KEY, CHAT_DRAFT_KEY } from '@/shared/lib/chat/composer/draft';
|
|
19
32
|
import type { Attachment } from '@/shared/types';
|
|
20
33
|
|
|
@@ -26,8 +39,24 @@ export interface ComposerDraftState {
|
|
|
26
39
|
}
|
|
27
40
|
|
|
28
41
|
export function useComposerDraft(): ComposerDraftState {
|
|
29
|
-
const [
|
|
42
|
+
const [searchParams] = useSearchParams();
|
|
43
|
+
const scoped = Boolean(searchParams.get('sessionId'));
|
|
44
|
+
|
|
45
|
+
// Both branches are mounted unconditionally (hook order) and the scope only
|
|
46
|
+
// picks which one this render OBSERVES: the session copy keeps following the
|
|
47
|
+
// store, and the landing copy keeps whatever was typed at the landing, so
|
|
48
|
+
// stepping into a chat and back does not destroy either.
|
|
49
|
+
const [storedText, setStoredText] = useSessionState<string>(CHAT_DRAFT_KEY, '');
|
|
50
|
+
const [storedAttachments, setStoredAttachments] = useSessionState<Attachment[]>(CHAT_DRAFT_ATTACHMENTS_KEY, []);
|
|
51
|
+
const [landingText, setLandingText] = useState('');
|
|
52
|
+
const [landingAttachments, setLandingAttachments] = useState<Attachment[]>([]);
|
|
53
|
+
|
|
54
|
+
const inputValue = scoped ? storedText : landingText;
|
|
55
|
+
const setInputValue = scoped ? setStoredText : setLandingText;
|
|
30
56
|
useBrowserPageContextInsert(setInputValue);
|
|
31
|
-
|
|
57
|
+
useReviewIncludeInsert(setInputValue);
|
|
58
|
+
|
|
59
|
+
const inputAttachments = scoped ? storedAttachments : landingAttachments;
|
|
60
|
+
const setInputAttachments = scoped ? setStoredAttachments : setLandingAttachments;
|
|
32
61
|
return { inputValue, setInputValue, inputAttachments, setInputAttachments };
|
|
33
62
|
}
|
|
@@ -50,6 +50,9 @@ const scrollWrites: Array<{ top: number; behavior?: ScrollBehavior }> = [];
|
|
|
50
50
|
/** Frames are queued, never run by the platform, so a test drives them. */
|
|
51
51
|
let frames: Array<() => void> = [];
|
|
52
52
|
|
|
53
|
+
/** The runner's own globals, captured before this suite overwrites them. */
|
|
54
|
+
const saved: Record<string, unknown> = {};
|
|
55
|
+
|
|
53
56
|
function drainFrames(rounds = 6): void {
|
|
54
57
|
for (let i = 0; i < rounds && frames.length > 0; i += 1) {
|
|
55
58
|
const pending = frames;
|
|
@@ -119,6 +122,8 @@ beforeAll(async () => {
|
|
|
119
122
|
cancelAnimationFrame: () => {},
|
|
120
123
|
};
|
|
121
124
|
for (const [key, value] of Object.entries(globals)) {
|
|
125
|
+
// Captured BEFORE the overwrite, so the runner's own values come back.
|
|
126
|
+
saved[key] = (globalThis as Record<string, unknown>)[key];
|
|
122
127
|
(globalThis as Record<string, unknown>)[key] = value;
|
|
123
128
|
}
|
|
124
129
|
// Preact binds its environment at module evaluation, so the modules below
|
|
@@ -129,8 +134,16 @@ beforeAll(async () => {
|
|
|
129
134
|
});
|
|
130
135
|
|
|
131
136
|
afterAll(() => {
|
|
132
|
-
|
|
133
|
-
|
|
137
|
+
// RESTORED, never deleted: `requestAnimationFrame`/`cancelAnimationFrame` are
|
|
138
|
+
// in `installDomGlobals`'s list (`pristine-globals.ts`), so a later suite that
|
|
139
|
+
// installs a window keeps whatever this file left behind. Deleting them made
|
|
140
|
+
// every following Preact suite that schedules a frame die with
|
|
141
|
+
// `ReferenceError: cancelAnimationFrame is not defined` (measured:
|
|
142
|
+
// `session-pagination.test.ts`'s rail jump, and the unhandled errors that
|
|
143
|
+
// followed it through `session-switch` and `scroll-reading-back`).
|
|
144
|
+
for (const [key, value] of Object.entries(saved)) {
|
|
145
|
+
if (value === undefined) delete (globalThis as Record<string, unknown>)[key];
|
|
146
|
+
else (globalThis as Record<string, unknown>)[key] = value;
|
|
134
147
|
}
|
|
135
148
|
});
|
|
136
149
|
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One document's annotations, loaded and written.
|
|
8
|
+
*
|
|
9
|
+
* The hook owns the three states the review surface must distinguish, because
|
|
10
|
+
* collapsing them is how a failed read looks like "no annotations yet":
|
|
11
|
+
*
|
|
12
|
+
* - `loading` — a read is in flight;
|
|
13
|
+
* - `error` — the read failed, and the message is shown as-is;
|
|
14
|
+
* - an empty list — the read SUCCEEDED and there is nothing stored.
|
|
15
|
+
*
|
|
16
|
+
* A write optimistically replaces the row for its block and rolls back to the
|
|
17
|
+
* previous list when the server refuses, so the mark on screen never disagrees
|
|
18
|
+
* with what is stored. The tradeoff is deliberate: an optimistic write is what
|
|
19
|
+
* makes a click feel instant, and the rollback is the half that keeps it honest.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
|
|
23
|
+
|
|
24
|
+
import { fetchAnnotations, removeAnnotation, saveAnnotation } from '@/client/lib/review/client';
|
|
25
|
+
import type { BlockVerdict, DocumentAnnotation, ReviewTarget } from '@/shared/lib/markdown/blocks/types';
|
|
26
|
+
|
|
27
|
+
export interface UseDocumentAnnotationsResult {
|
|
28
|
+
annotations: DocumentAnnotation[];
|
|
29
|
+
loading: boolean;
|
|
30
|
+
/** The read's or a write's failure, shown verbatim. */
|
|
31
|
+
error: string | null;
|
|
32
|
+
/** Store a judgement for one block. Resolves whether or not the write landed. */
|
|
33
|
+
save: (input: { blockKey: string; lineStart: number; lineEnd: number; verdict: BlockVerdict; note: string; quote: string }) => Promise<void>;
|
|
34
|
+
/** Remove one judgement by its stored id. */
|
|
35
|
+
remove: (id: string) => Promise<void>;
|
|
36
|
+
/** Re-read after a failure. */
|
|
37
|
+
reload: () => void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function useDocumentAnnotations(target: ReviewTarget | null, enabled: boolean): UseDocumentAnnotationsResult {
|
|
41
|
+
const [annotations, setAnnotations] = useState<DocumentAnnotation[]>([]);
|
|
42
|
+
const [loading, setLoading] = useState(false);
|
|
43
|
+
const [error, setError] = useState<string | null>(null);
|
|
44
|
+
const [revision, setRevision] = useState(0);
|
|
45
|
+
|
|
46
|
+
const path = target?.path ?? null;
|
|
47
|
+
const root = target?.root ?? null;
|
|
48
|
+
const repo = target?.repo ?? null;
|
|
49
|
+
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (!enabled || !path) {
|
|
52
|
+
setAnnotations([]);
|
|
53
|
+
setError(null);
|
|
54
|
+
setLoading(false);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const controller = new AbortController();
|
|
58
|
+
setLoading(true);
|
|
59
|
+
setError(null);
|
|
60
|
+
fetchAnnotations({ path, root, repo }, controller.signal)
|
|
61
|
+
.then((rows) => {
|
|
62
|
+
if (controller.signal.aborted) return;
|
|
63
|
+
setAnnotations(rows);
|
|
64
|
+
})
|
|
65
|
+
.catch((cause: unknown) => {
|
|
66
|
+
if (controller.signal.aborted) return;
|
|
67
|
+
setError(cause instanceof Error ? cause.message : 'Could not read annotations');
|
|
68
|
+
})
|
|
69
|
+
.finally(() => {
|
|
70
|
+
if (!controller.signal.aborted) setLoading(false);
|
|
71
|
+
});
|
|
72
|
+
return () => controller.abort();
|
|
73
|
+
// The primitives, never the object: a caller builds `target` inline.
|
|
74
|
+
}, [enabled, path, root, repo, revision]);
|
|
75
|
+
|
|
76
|
+
// The latest list, so a rollback restores what was there — not what the
|
|
77
|
+
// render that created this closure saw.
|
|
78
|
+
const latest = useRef(annotations);
|
|
79
|
+
latest.current = annotations;
|
|
80
|
+
|
|
81
|
+
const save = useCallback<UseDocumentAnnotationsResult['save']>(
|
|
82
|
+
async (input) => {
|
|
83
|
+
if (!path) return;
|
|
84
|
+
const previous = latest.current;
|
|
85
|
+
const optimistic: DocumentAnnotation = {
|
|
86
|
+
id: `pending:${input.blockKey}`,
|
|
87
|
+
scope: '',
|
|
88
|
+
path,
|
|
89
|
+
blockKey: input.blockKey,
|
|
90
|
+
lineStart: input.lineStart,
|
|
91
|
+
lineEnd: input.lineEnd,
|
|
92
|
+
verdict: input.verdict,
|
|
93
|
+
note: input.note,
|
|
94
|
+
quote: input.quote,
|
|
95
|
+
createdAt: Date.now(),
|
|
96
|
+
updatedAt: Date.now(),
|
|
97
|
+
};
|
|
98
|
+
setAnnotations([...previous.filter((row) => row.blockKey !== input.blockKey), optimistic]);
|
|
99
|
+
setError(null);
|
|
100
|
+
try {
|
|
101
|
+
const stored = await saveAnnotation({ path, root, repo }, input);
|
|
102
|
+
setAnnotations((current) => current.map((row) => (row.blockKey === input.blockKey ? stored : row)));
|
|
103
|
+
} catch (cause) {
|
|
104
|
+
setAnnotations(previous);
|
|
105
|
+
setError(cause instanceof Error ? cause.message : 'Could not save the annotation');
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
[path, root, repo],
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const remove = useCallback<UseDocumentAnnotationsResult['remove']>(async (id) => {
|
|
112
|
+
const previous = latest.current;
|
|
113
|
+
setAnnotations(previous.filter((row) => row.id !== id));
|
|
114
|
+
setError(null);
|
|
115
|
+
try {
|
|
116
|
+
await removeAnnotation(id);
|
|
117
|
+
} catch (cause) {
|
|
118
|
+
setAnnotations(previous);
|
|
119
|
+
setError(cause instanceof Error ? cause.message : 'Could not remove the annotation');
|
|
120
|
+
}
|
|
121
|
+
}, []);
|
|
122
|
+
|
|
123
|
+
return { annotations, loading, error, save, remove, reload: () => setRevision((value) => value + 1) };
|
|
124
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The editor panel's transient UI: the command palette, the go-to-line dialog,
|
|
8
|
+
* quick open and Save As.
|
|
9
|
+
*
|
|
10
|
+
* One hook because these four are one decision — each is a thing the user is
|
|
11
|
+
* doing RIGHT NOW, so none of them is persisted — and because the panel that
|
|
12
|
+
* owns them also owns the chords that open them. Extracting them keeps
|
|
13
|
+
* `index.tsx` under the per-file ceiling as the panel gained a review mode, and
|
|
14
|
+
* it is the same split `use-editor-panel-keys` already makes for the keyboard.
|
|
15
|
+
*
|
|
16
|
+
* `goToLineRequest` is a COUNTER rather than a boolean: the dialog lives in the
|
|
17
|
+
* document (where the caret and the handle are), so a boolean would need a
|
|
18
|
+
* matching "closed" write from that side to be re-openable.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { useCallback, useState } from 'preact/hooks';
|
|
22
|
+
|
|
23
|
+
export interface EditorPanelUi {
|
|
24
|
+
paletteOpen: boolean;
|
|
25
|
+
setPaletteOpen: (open: boolean) => void;
|
|
26
|
+
/** Bumped once per request; the document opens the dialog when it moves. */
|
|
27
|
+
goToLineRequest: number;
|
|
28
|
+
openGoToLine: () => void;
|
|
29
|
+
quickOpen: boolean;
|
|
30
|
+
setQuickOpen: (open: boolean) => void;
|
|
31
|
+
saveAsOpen: boolean;
|
|
32
|
+
setSaveAsOpen: (open: boolean) => void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function useEditorPanelUi(): EditorPanelUi {
|
|
36
|
+
const [paletteOpen, setPaletteOpen] = useState(false);
|
|
37
|
+
const [goToLineRequest, setGoToLineRequest] = useState(0);
|
|
38
|
+
const [quickOpen, setQuickOpen] = useState(false);
|
|
39
|
+
const [saveAsOpen, setSaveAsOpen] = useState(false);
|
|
40
|
+
const openGoToLine = useCallback(() => setGoToLineRequest((previous) => previous + 1), []);
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
paletteOpen,
|
|
44
|
+
setPaletteOpen,
|
|
45
|
+
goToLineRequest,
|
|
46
|
+
openGoToLine,
|
|
47
|
+
quickOpen,
|
|
48
|
+
setQuickOpen,
|
|
49
|
+
saveAsOpen,
|
|
50
|
+
setSaveAsOpen,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Review mode for one open document, as a per-tab persisted toggle.
|
|
8
|
+
*
|
|
9
|
+
* ONE key (`editor.reviewMode`) and one owner, shared by the desktop pane and the
|
|
10
|
+
* phone's full-screen editor: both draw the same surface, both remember the
|
|
11
|
+
* choice per tab, and a second copy of this rule is how the two layouts end up
|
|
12
|
+
* disagreeing about whether a document is being reviewed.
|
|
13
|
+
*
|
|
14
|
+
* Off by default, and that default is the feature: review mode swallows clicks
|
|
15
|
+
* inside the document — links, copy buttons, the diagram viewer all become block
|
|
16
|
+
* selections. A reader who never asked to review anything keeps every one of
|
|
17
|
+
* them, which is why the mode is entered from a toolbar button and nowhere else.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { useSessionState } from '@/client/hooks/workspace/session-state';
|
|
21
|
+
|
|
22
|
+
export interface FileReviewMode {
|
|
23
|
+
/** This tab is being reviewed. */
|
|
24
|
+
active: boolean;
|
|
25
|
+
/** Turn it on or off. */
|
|
26
|
+
toggle: () => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function useFileReviewMode(tabKey: string): FileReviewMode {
|
|
30
|
+
const [mode, setMode] = useSessionState<Record<string, boolean>>('editor.reviewMode', {});
|
|
31
|
+
return {
|
|
32
|
+
active: mode[tabKey] === true,
|
|
33
|
+
toggle: () => setMode((previous) => ({ ...previous, [tabKey]: previous[tabKey] !== true })),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The review surface's state for one previewed document: which block the judge
|
|
8
|
+
* panel is open on, and the stored marks with their block identities.
|
|
9
|
+
*
|
|
10
|
+
* Whether the mode is ON is the editor panel's state (`useFileReviewMode`) — this
|
|
11
|
+
* hook only answers "what happens while it is on", so the toolbar button and the
|
|
12
|
+
* surface cannot disagree about it.
|
|
13
|
+
*
|
|
14
|
+
* ## Blocks come from the RENDER, never from the file
|
|
15
|
+
*
|
|
16
|
+
* The caller stores them from `MarkdownRenderer`'s `onBlocks`. That list is what
|
|
17
|
+
* is actually on screen: a document the markdown healer cut short, or one a
|
|
18
|
+
* plugin's directive replaced, renders fewer (or different) blocks than it has
|
|
19
|
+
* paragraphs, and a mark must only ever attach to a block a reader can click.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { useCallback, useMemo, useState } from 'preact/hooks';
|
|
23
|
+
|
|
24
|
+
import { useDocumentAnnotations } from '@/client/hooks/editor/use-document-annotations';
|
|
25
|
+
import { reconcileAnnotations, tallyAnnotations } from '@/shared/lib/markdown/review/reconcile';
|
|
26
|
+
import { emitReviewBlock, formatReviewBlock } from '@/shared/lib/markdown/review/prompt';
|
|
27
|
+
import type { BlockVerdict, DocumentAnnotation, MdBlock, ReviewTarget } from '@/shared/lib/markdown/blocks/types';
|
|
28
|
+
|
|
29
|
+
export interface UsePreviewReviewOptions {
|
|
30
|
+
file: { name: string; path: string; root?: string | null; repo?: string | null };
|
|
31
|
+
/** Review mode, owned by the editor's toolbar. */
|
|
32
|
+
active: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface PreviewReviewState {
|
|
36
|
+
/** Verdicts the renderer paints, keyed by block key. */
|
|
37
|
+
marks: ReadonlyMap<string, BlockVerdict>;
|
|
38
|
+
/** The block the judge panel is open on. */
|
|
39
|
+
selected: string | null;
|
|
40
|
+
selectedBlock: MdBlock | null;
|
|
41
|
+
selectedAnnotation: DocumentAnnotation | null;
|
|
42
|
+
/** Where that block was on screen when it was picked (the panel anchors there). */
|
|
43
|
+
anchor: { top: number; left: number } | null;
|
|
44
|
+
/** Stored marks whose block is no longer rendered — shown, never dropped. */
|
|
45
|
+
outdated: DocumentAnnotation[];
|
|
46
|
+
counts: { good: number; needsWork: number };
|
|
47
|
+
loading: boolean;
|
|
48
|
+
error: string | null;
|
|
49
|
+
/** The render reports what it produced. */
|
|
50
|
+
setBlocks: (blocks: MdBlock[]) => void;
|
|
51
|
+
pick: (block: MdBlock, rect: DOMRect) => void;
|
|
52
|
+
close: () => void;
|
|
53
|
+
save: (input: { block: MdBlock; verdict: BlockVerdict; note: string }) => void;
|
|
54
|
+
remove: (id: string) => void;
|
|
55
|
+
/** Put the review in the composer draft. False when there is nothing to send. */
|
|
56
|
+
send: () => boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function usePreviewReview({ file, active }: UsePreviewReviewOptions): PreviewReviewState {
|
|
60
|
+
const [blocks, setBlocksState] = useState<MdBlock[]>([]);
|
|
61
|
+
const [selected, setSelected] = useState<string | null>(null);
|
|
62
|
+
const [anchor, setAnchor] = useState<{ top: number; left: number } | null>(null);
|
|
63
|
+
|
|
64
|
+
// Primitives, not the object: a caller builds `file` inline.
|
|
65
|
+
const target = useMemo<ReviewTarget>(
|
|
66
|
+
() => ({ path: file.path, root: file.root ?? null, repo: file.repo ?? null }),
|
|
67
|
+
[file.path, file.root, file.repo],
|
|
68
|
+
);
|
|
69
|
+
const { annotations, loading, error, save, remove } = useDocumentAnnotations(target, active);
|
|
70
|
+
|
|
71
|
+
const { attached, outdated } = useMemo(
|
|
72
|
+
() => reconcileAnnotations(blocks, annotations),
|
|
73
|
+
[blocks, annotations],
|
|
74
|
+
);
|
|
75
|
+
const marks = useMemo(
|
|
76
|
+
() => new Map([...attached.values()].map((row) => [row.blockKey, row.verdict])),
|
|
77
|
+
[attached],
|
|
78
|
+
);
|
|
79
|
+
const counts = useMemo(() => tallyAnnotations(attached), [attached]);
|
|
80
|
+
const selectedBlock = useMemo(
|
|
81
|
+
() => (selected ? blocks.find((block) => block.key === selected) ?? null : null),
|
|
82
|
+
[blocks, selected],
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const setBlocks = useCallback((next: MdBlock[]) => {
|
|
86
|
+
// The render hands back fresh objects every parse; comparing identity would
|
|
87
|
+
// store a new list on every keystroke for a document that did not change.
|
|
88
|
+
setBlocksState((previous) => sameBlockKeys(previous, next) ? previous : next);
|
|
89
|
+
}, []);
|
|
90
|
+
|
|
91
|
+
const pick = useCallback((block: MdBlock, rect: DOMRect) => {
|
|
92
|
+
setSelected(block.key);
|
|
93
|
+
// `fixed` coordinates: the judge panel is drawn where the block WAS. It
|
|
94
|
+
// closes on scroll instead of tracking, because a rendered document
|
|
95
|
+
// rehydrates (mermaid, math, directives) and every one of those moves blocks.
|
|
96
|
+
setAnchor({ top: rect.bottom + 6, left: Math.max(8, rect.left) });
|
|
97
|
+
}, []);
|
|
98
|
+
|
|
99
|
+
const close = useCallback(() => {
|
|
100
|
+
setSelected(null);
|
|
101
|
+
setAnchor(null);
|
|
102
|
+
}, []);
|
|
103
|
+
|
|
104
|
+
const saveBlock = useCallback<PreviewReviewState['save']>(
|
|
105
|
+
({ block, verdict, note }) => {
|
|
106
|
+
void save({
|
|
107
|
+
blockKey: block.key,
|
|
108
|
+
lineStart: block.lineStart,
|
|
109
|
+
lineEnd: block.lineEnd,
|
|
110
|
+
verdict,
|
|
111
|
+
note,
|
|
112
|
+
quote: block.quote,
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
[save],
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const send = useCallback(() => {
|
|
119
|
+
const block = formatReviewBlock({ path: file.path, annotations: [...attached.values()] });
|
|
120
|
+
if (!block) return false;
|
|
121
|
+
emitReviewBlock(block);
|
|
122
|
+
return true;
|
|
123
|
+
}, [attached, file.path]);
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
marks,
|
|
127
|
+
selected,
|
|
128
|
+
selectedBlock,
|
|
129
|
+
selectedAnnotation: selectedBlock ? attached.get(selectedBlock.key) ?? null : null,
|
|
130
|
+
anchor,
|
|
131
|
+
outdated,
|
|
132
|
+
counts,
|
|
133
|
+
loading,
|
|
134
|
+
error,
|
|
135
|
+
setBlocks,
|
|
136
|
+
pick,
|
|
137
|
+
close,
|
|
138
|
+
save: saveBlock,
|
|
139
|
+
remove: (id) => void remove(id),
|
|
140
|
+
send,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Same block list? Keys alone: the text a block shows is already in the HTML. */
|
|
145
|
+
function sameBlockKeys(left: readonly MdBlock[], right: readonly MdBlock[]): boolean {
|
|
146
|
+
if (left.length !== right.length) return false;
|
|
147
|
+
return left.every((block, index) => block.key === right[index]?.key);
|
|
148
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Agents panel's list, over omp's own agent definition files.
|
|
8
|
+
*
|
|
9
|
+
* `GET /api/settings/agents` lists what `discoverNativeAgents` finds (user root
|
|
10
|
+
* plus the selected workspace's `.omp/agents`), and every write posts a
|
|
11
|
+
* `write`/`delete` action that lands in a markdown file — the only place omp
|
|
12
|
+
* reads agents from. Each write answers with the re-read list, which is adopted
|
|
13
|
+
* verbatim so the panel shows the files that exist rather than a draft that was
|
|
14
|
+
* never saved.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { useCallback, useEffect, useState } from 'preact/hooks';
|
|
18
|
+
import type { AgentItem, WriteOutcome } from '@/shared/types';
|
|
19
|
+
|
|
20
|
+
export interface AgentsController {
|
|
21
|
+
agents: AgentItem[];
|
|
22
|
+
selectedId: string | null;
|
|
23
|
+
selected: AgentItem | undefined;
|
|
24
|
+
isLoading: boolean;
|
|
25
|
+
/** Why the list could not be read, or null. */
|
|
26
|
+
loadError: string | null;
|
|
27
|
+
reload: () => void;
|
|
28
|
+
select: (id: string) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Write one definition. `previousFileName` is the file the open definition
|
|
31
|
+
* was read from, which a rename replaces instead of leaving two copies.
|
|
32
|
+
*/
|
|
33
|
+
save: (agent: AgentItem, previousFileName?: string | null) => Promise<WriteOutcome>;
|
|
34
|
+
remove: (agent: AgentItem) => Promise<WriteOutcome>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function readAgents(data: unknown): AgentItem[] | null {
|
|
38
|
+
if (typeof data !== 'object' || data === null || !('agents' in data)) return null;
|
|
39
|
+
return Array.isArray(data.agents) ? (data.agents as AgentItem[]) : null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function readError(data: unknown): string | undefined {
|
|
43
|
+
if (typeof data !== 'object' || data === null || !('error' in data)) return undefined;
|
|
44
|
+
return typeof data.error === 'string' ? data.error : undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function useAgents(query: string): AgentsController {
|
|
48
|
+
const [agents, setAgents] = useState<AgentItem[]>([]);
|
|
49
|
+
const [selectedId, setSelectedId] = useState<string | null>(null);
|
|
50
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
51
|
+
const [loadError, setLoadError] = useState<string | null>(null);
|
|
52
|
+
const [nonce, setNonce] = useState(0);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
let active = true;
|
|
56
|
+
setIsLoading(true);
|
|
57
|
+
fetch(`/api/settings/agents${query}`)
|
|
58
|
+
.then(async (res) => {
|
|
59
|
+
const data: unknown = await res.json().catch(() => null);
|
|
60
|
+
if (!res.ok) throw new Error(readError(data) ?? `GET /api/settings/agents answered ${res.status}`);
|
|
61
|
+
return data;
|
|
62
|
+
})
|
|
63
|
+
.then((data) => {
|
|
64
|
+
if (!active) return;
|
|
65
|
+
const list = readAgents(data) ?? [];
|
|
66
|
+
setAgents(list);
|
|
67
|
+
setLoadError(null);
|
|
68
|
+
setSelectedId((prev) => (list.some((agent) => agent.id === prev) ? prev : (list[0]?.id ?? null)));
|
|
69
|
+
})
|
|
70
|
+
.catch((err) => {
|
|
71
|
+
if (!active) return;
|
|
72
|
+
console.error('Failed to load agents:', err);
|
|
73
|
+
setLoadError(err instanceof Error ? err.message : String(err));
|
|
74
|
+
})
|
|
75
|
+
.finally(() => {
|
|
76
|
+
if (active) setIsLoading(false);
|
|
77
|
+
});
|
|
78
|
+
return () => {
|
|
79
|
+
active = false;
|
|
80
|
+
};
|
|
81
|
+
}, [query, nonce]);
|
|
82
|
+
|
|
83
|
+
const reload = useCallback(() => setNonce((n) => n + 1), []);
|
|
84
|
+
const select = useCallback((id: string) => setSelectedId(id), []);
|
|
85
|
+
|
|
86
|
+
const write = useCallback(async (body: Record<string, unknown>): Promise<WriteOutcome> => {
|
|
87
|
+
try {
|
|
88
|
+
const res = await fetch('/api/settings/agents', {
|
|
89
|
+
method: 'POST',
|
|
90
|
+
headers: { 'Content-Type': 'application/json' },
|
|
91
|
+
body: JSON.stringify(body),
|
|
92
|
+
});
|
|
93
|
+
const data: unknown = await res.json().catch(() => null);
|
|
94
|
+
const error = readError(data) ?? (res.ok ? undefined : `The write answered ${res.status}`);
|
|
95
|
+
if (error) return { ok: false, error };
|
|
96
|
+
const list = readAgents(data);
|
|
97
|
+
if (list) {
|
|
98
|
+
setAgents(list);
|
|
99
|
+
const written = body.fileName;
|
|
100
|
+
const match = typeof written === 'string'
|
|
101
|
+
? list.find((agent) => agent.fileName === written)
|
|
102
|
+
: undefined;
|
|
103
|
+
if (match) setSelectedId(match.id);
|
|
104
|
+
}
|
|
105
|
+
return { ok: true };
|
|
106
|
+
} catch (err) {
|
|
107
|
+
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
108
|
+
}
|
|
109
|
+
}, []);
|
|
110
|
+
|
|
111
|
+
const save = useCallback((agent: AgentItem, previousFileName?: string | null) => {
|
|
112
|
+
const fileName = agent.name.trim();
|
|
113
|
+
return write({
|
|
114
|
+
type: 'write',
|
|
115
|
+
fileName,
|
|
116
|
+
name: agent.name,
|
|
117
|
+
description: agent.description,
|
|
118
|
+
...(agent.model ? { model: agent.model } : {}),
|
|
119
|
+
...(agent.thinkingLevel ? { thinkingLevel: agent.thinkingLevel } : {}),
|
|
120
|
+
// `tools: undefined` leaves the file's own allowlist untouched.
|
|
121
|
+
...(agent.tools ? { tools: agent.tools } : {}),
|
|
122
|
+
...(agent.spawns ? { spawns: agent.spawns } : {}),
|
|
123
|
+
systemPrompt: agent.systemPrompt,
|
|
124
|
+
...(previousFileName && previousFileName !== fileName ? { previousFileName } : {}),
|
|
125
|
+
});
|
|
126
|
+
}, [write]);
|
|
127
|
+
|
|
128
|
+
const remove = useCallback(async (agent: AgentItem): Promise<WriteOutcome> => {
|
|
129
|
+
if (!agent.fileName) return { ok: false, error: 'This agent has no definition file to delete.' };
|
|
130
|
+
const outcome = await write({ type: 'delete', fileName: agent.fileName });
|
|
131
|
+
if (outcome.ok) {
|
|
132
|
+
setSelectedId((current) => (current === agent.id ? null : current));
|
|
133
|
+
setAgents((prev) => prev.filter((item) => item.id !== agent.id));
|
|
134
|
+
}
|
|
135
|
+
return outcome;
|
|
136
|
+
}, [write]);
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
agents,
|
|
140
|
+
selectedId,
|
|
141
|
+
selected: agents.find((agent) => agent.id === selectedId),
|
|
142
|
+
isLoading,
|
|
143
|
+
loadError,
|
|
144
|
+
reload,
|
|
145
|
+
select,
|
|
146
|
+
save,
|
|
147
|
+
remove,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
@@ -22,6 +22,7 @@ import { Window } from 'happy-dom';
|
|
|
22
22
|
import { h, render } from 'preact';
|
|
23
23
|
import { act } from 'preact/test-utils';
|
|
24
24
|
import { useCrudList, type CrudListConfig, type CrudListController } from '@/client/hooks/settings/crud-list';
|
|
25
|
+
import type { WriteOutcome } from '@/shared/types';
|
|
25
26
|
|
|
26
27
|
const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'Event', 'CustomEvent'] as const;
|
|
27
28
|
/** The runner's own globals, restored on teardown so later files still have them. */
|
|
@@ -198,14 +199,18 @@ describe('useCrudList save', () => {
|
|
|
198
199
|
expect(controller?.items.map((row) => row.id)).toEqual(['z']);
|
|
199
200
|
});
|
|
200
201
|
|
|
201
|
-
test('
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
respond = (_url, init) => ((init?.method ?? 'GET') === 'GET'
|
|
202
|
+
test('a refusal returns its sentence and touches nothing', async () => {
|
|
203
|
+
// The panes report `outcome.error`; a swallowed refusal used to paint
|
|
204
|
+
// "Saved successfully" over a row the server had rejected.
|
|
205
|
+
config = baseConfig();
|
|
206
|
+
respond = (_url, init) => ((init?.method ?? 'GET') === 'GET'
|
|
207
|
+
? json({ things: [{ id: 'a' }] })
|
|
208
|
+
: json({ error: 'A saved thing needs a name' }, 400));
|
|
206
209
|
await mount(h(CrudProbe, {}));
|
|
207
210
|
await flush(() => controller?.startCreate());
|
|
208
|
-
|
|
211
|
+
const outcomes: WriteOutcome[] = [];
|
|
212
|
+
await flush(() => { void controller?.save({ id: 'b' }).then((result) => outcomes.push(result)); });
|
|
213
|
+
expect(outcomes[0]).toEqual({ ok: false, error: 'A saved thing needs a name' });
|
|
209
214
|
expect(controller?.items.map((row) => row.id)).toEqual(['a']);
|
|
210
215
|
// The refusal returns before any of the success bookkeeping, so the create
|
|
211
216
|
// draft is still open for the user to retry or abandon.
|
|
@@ -213,6 +218,23 @@ describe('useCrudList save', () => {
|
|
|
213
218
|
expect(controller?.selectedId).toBeNull();
|
|
214
219
|
});
|
|
215
220
|
|
|
221
|
+
test('a write that lands reports ok', async () => {
|
|
222
|
+
config = baseConfig();
|
|
223
|
+
await mount(h(CrudProbe, {}));
|
|
224
|
+
await flush(() => controller?.select('a'));
|
|
225
|
+
const outcomes: WriteOutcome[] = [];
|
|
226
|
+
await flush(() => { void controller?.save({ id: 'a', name: 'renamed' }).then((result) => outcomes.push(result)); });
|
|
227
|
+
expect(outcomes[0]).toEqual({ ok: true });
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
test('a failed list read is reported instead of reading as an empty list', async () => {
|
|
231
|
+
config = baseConfig();
|
|
232
|
+
respond = () => json({ error: 'the agent directory is unreadable' }, 500);
|
|
233
|
+
await mount(h(CrudProbe, {}));
|
|
234
|
+
expect(controller?.loadError).toBe('the agent directory is unreadable');
|
|
235
|
+
expect(controller?.items).toEqual([]);
|
|
236
|
+
});
|
|
237
|
+
|
|
216
238
|
test('serverListOnly never upserts optimistically', async () => {
|
|
217
239
|
config = baseConfig({ serverListOnly: true });
|
|
218
240
|
await mount(h(CrudProbe, {}));
|