@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
|
@@ -34,6 +34,9 @@ import { isRemoteGitUrl } from '@/shared/lib/git/url';
|
|
|
34
34
|
import { resolveInsideRoot } from '@/shared/lib/panels/resolve-asset';
|
|
35
35
|
|
|
36
36
|
/** An id segment: what a plugin id may look like. */
|
|
37
|
+
/** The only colour form a manifest may declare: `#RRGGBB`. */
|
|
38
|
+
const HEX_COLOR = /^#[0-9a-f]{6}$/i;
|
|
39
|
+
|
|
37
40
|
const ID_RE = /^[a-z0-9][a-z0-9._-]{0,63}$/i;
|
|
38
41
|
|
|
39
42
|
function trimmed(value: unknown): string | undefined {
|
|
@@ -87,6 +90,14 @@ export function toManifest(raw: unknown, root: string): PanelPluginManifest | {
|
|
|
87
90
|
return { error: `manifest readme "${readme}" escapes the plugin directory` };
|
|
88
91
|
}
|
|
89
92
|
|
|
93
|
+
// A mark colour reaches an inline custom property, so it is a HEX and nothing
|
|
94
|
+
// else: `color: url(...)`, `red; background: …` or a `var()` that resolves
|
|
95
|
+
// elsewhere are all refusals rather than values the host has to escape.
|
|
96
|
+
const color = trimmed(raw.color);
|
|
97
|
+
if (color && !HEX_COLOR.test(color)) {
|
|
98
|
+
return { error: `manifest color ${JSON.stringify(raw.color)} is not a #RRGGBB hex` };
|
|
99
|
+
}
|
|
100
|
+
|
|
90
101
|
const branding = isRecord(raw.branding) ? trimmed(raw.branding.icon) : undefined;
|
|
91
102
|
const engines = toEngines(raw.engines);
|
|
92
103
|
if ('error' in engines) return engines;
|
|
@@ -111,6 +122,7 @@ export function toManifest(raw: unknown, root: string): PanelPluginManifest | {
|
|
|
111
122
|
...(trimmed(raw.homepage) ? { homepage: trimmed(raw.homepage) } : {}),
|
|
112
123
|
...(icon ? { icon } : {}),
|
|
113
124
|
...(readme ? { readme } : {}),
|
|
125
|
+
...(color ? { color: color.toLowerCase() } : {}),
|
|
114
126
|
...(branding ? { branding: { icon: branding } } : {}),
|
|
115
127
|
...(author ? { author } : {}),
|
|
116
128
|
...(slots ? { slots } : {}),
|
|
@@ -127,6 +127,7 @@ export async function scanInstalledPlugins(options: {
|
|
|
127
127
|
...(manifest.author ? { author: manifest.author } : {}),
|
|
128
128
|
...(manifest.homepage ? { homepage: manifest.homepage } : {}),
|
|
129
129
|
...(manifest.slots ? { slots: manifest.slots } : {}),
|
|
130
|
+
...(manifest.color ? { color: manifest.color } : {}),
|
|
130
131
|
...(manifest.capabilities ? { capabilities: manifest.capabilities } : {}),
|
|
131
132
|
...(missingEntry ? { reason: `the build produced no ${missingEntry}` } : {}),
|
|
132
133
|
});
|
|
@@ -154,6 +155,9 @@ export async function scanInstalledPlugins(options: {
|
|
|
154
155
|
? { cssUrl: await cssUrl(pluginDir, manifest.css) }
|
|
155
156
|
: {}),
|
|
156
157
|
...(manifest.icon ? { iconUrl: await iconUrl(pluginDir, manifest.icon) } : {}),
|
|
158
|
+
// The plugin's own mark colour, so the activity bar can paint its brand
|
|
159
|
+
// instead of a hue hashed from its name.
|
|
160
|
+
...(manifest.color ? { color: manifest.color } : {}),
|
|
157
161
|
...(await readmeUrlFor(pluginDir, manifest)),
|
|
158
162
|
});
|
|
159
163
|
}
|
|
@@ -211,4 +211,52 @@ describe('queue dispatch', () => {
|
|
|
211
211
|
|
|
212
212
|
expect(delivered).toBe(false);
|
|
213
213
|
});
|
|
214
|
+
|
|
215
|
+
// omp refused the prompt because a turn was already in flight while the
|
|
216
|
+
// wrapper still read idle (a probe's stale answer had cleared its flags).
|
|
217
|
+
// Measured: 104 `agent_busy` failures in one session. The refusal is omp's
|
|
218
|
+
// own word that the session is busy, so the wrapper keeps `isBusy()` true and
|
|
219
|
+
// every later tick parks — one attempted dispatch, not one per retry — and the
|
|
220
|
+
// head keeps its place.
|
|
221
|
+
test('a busy refusal parks the queue instead of redispatching on every tick', async () => {
|
|
222
|
+
const sessionId = beginQueueTest();
|
|
223
|
+
queue.set(sessionId, [queueItem('a'), queueItem('b'), queueItem('c')]);
|
|
224
|
+
const { host, sent } = makeHost(sessionId);
|
|
225
|
+
// The wrapper's flags say idle; omp is actually mid-turn.
|
|
226
|
+
let wrapperBusy = false;
|
|
227
|
+
let ompBusy = true;
|
|
228
|
+
host.isBusy = () => wrapperBusy;
|
|
229
|
+
host.send = async (command) => {
|
|
230
|
+
if (command.type !== 'prompt') return {};
|
|
231
|
+
if (!ompBusy) {
|
|
232
|
+
sent.push(command);
|
|
233
|
+
return {};
|
|
234
|
+
}
|
|
235
|
+
// What the command dispatcher does with omp's `agent_busy` refusal: the
|
|
236
|
+
// typed error, and omp's verdict kept on the wrapper's own flags.
|
|
237
|
+
wrapperBusy = true;
|
|
238
|
+
throw new Error('agent_busy');
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
const delivered = await deliverQueueNow(host);
|
|
242
|
+
await flush();
|
|
243
|
+
expect(delivered).toBe(false);
|
|
244
|
+
|
|
245
|
+
// The retry timer and a client nudge both arrive while omp is still busy:
|
|
246
|
+
// neither may dispatch at the child again.
|
|
247
|
+
jest.advanceTimersByTime(2_000);
|
|
248
|
+
await flush();
|
|
249
|
+
await deliverQueueNow(host);
|
|
250
|
+
await flush();
|
|
251
|
+
expect(sent).toEqual([]);
|
|
252
|
+
expect(queue.get(sessionId)?.map((item) => item.text)).toEqual(['a', 'b', 'c']);
|
|
253
|
+
|
|
254
|
+
// The run ends: the head goes out, ahead of everything queued behind it.
|
|
255
|
+
ompBusy = false;
|
|
256
|
+
wrapperBusy = false;
|
|
257
|
+
await deliverQueueNow(host);
|
|
258
|
+
await flush();
|
|
259
|
+
expect(sent.map((command) => command.message)).toEqual(['a']);
|
|
260
|
+
expect(queue.get(sessionId)?.map((item) => item.text)).toEqual(['b', 'c']);
|
|
261
|
+
});
|
|
214
262
|
});
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
import { jest, mock } from 'bun:test';
|
|
23
23
|
import type { QueuedMessage } from '@/shared/types/chat';
|
|
24
|
+
import type { ClaimedQueueItem } from '@/server/lib/queue/store.server';
|
|
24
25
|
import type { QueueDeliveryHost } from '@/server/lib/queue/delivery.server';
|
|
25
26
|
|
|
26
27
|
// Hoisted above the registration, so spreading it here snapshots the REAL
|
|
@@ -40,14 +41,17 @@ export const queue = new Map<string, QueuedMessage[]>();
|
|
|
40
41
|
* after another has restored the real one. */
|
|
41
42
|
export function installStoreMock(): void {
|
|
42
43
|
mock.module('@/server/lib/queue/store.server', () => ({
|
|
43
|
-
claimHeadQueueItem: async (sessionId: string): Promise<
|
|
44
|
+
claimHeadQueueItem: async (sessionId: string): Promise<ClaimedQueueItem | null> => {
|
|
44
45
|
const items = queue.get(sessionId);
|
|
45
|
-
|
|
46
|
+
const head = items?.shift();
|
|
47
|
+
// The list index IS the position here, and the head is always index 0.
|
|
48
|
+
return head ? { ...head, position: 0 } : null;
|
|
46
49
|
},
|
|
47
50
|
hasQueuedItem: async (sessionId: string): Promise<boolean> => (queue.get(sessionId)?.length ?? 0) > 0,
|
|
48
|
-
requeueHeadQueueItem: async (sessionId: string, item:
|
|
51
|
+
requeueHeadQueueItem: async (sessionId: string, item: ClaimedQueueItem): Promise<void> => {
|
|
49
52
|
const items = queue.get(sessionId) ?? [];
|
|
50
|
-
|
|
53
|
+
const { position: _position, ...row } = item;
|
|
54
|
+
items.splice(0, 0, row);
|
|
51
55
|
queue.set(sessionId, items);
|
|
52
56
|
},
|
|
53
57
|
}));
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
import { afterAll, afterEach, beforeAll, describe, expect, jest, mock, test } from 'bun:test';
|
|
25
25
|
import {
|
|
26
26
|
beginQueueTest,
|
|
27
|
+
deliverQueueNow,
|
|
27
28
|
flush,
|
|
28
29
|
installStoreMock,
|
|
29
30
|
makeHost,
|
|
@@ -203,4 +204,32 @@ describe('queue delivery scheduling', () => {
|
|
|
203
204
|
expect(sent.filter((c) => c.type === 'prompt').length).toBe(1);
|
|
204
205
|
expect(queue.get(sessionId)).toEqual([]);
|
|
205
206
|
});
|
|
207
|
+
|
|
208
|
+
// The nudge path (`deliverQueueNow`) has no timer to dedupe it: a tab's 3s
|
|
209
|
+
// poll, a focus nudge and a run end can all be inside `deliverNext` at once.
|
|
210
|
+
// Two overlapping attempts claim two heads, and the requeues that follow
|
|
211
|
+
// decide which of the pair comes back first — measured on a live session as
|
|
212
|
+
// the panel's order changing on every `agent_busy` retry.
|
|
213
|
+
test('overlapping delivery attempts share one dispatch and leave the order alone', async () => {
|
|
214
|
+
const sessionId = beginQueueTest();
|
|
215
|
+
queue.set(sessionId, [queueItem('a'), queueItem('b'), queueItem('c')]);
|
|
216
|
+
const { host } = makeHost(sessionId);
|
|
217
|
+
let attempts = 0;
|
|
218
|
+
host.send = async () => {
|
|
219
|
+
attempts++;
|
|
220
|
+
throw new Error('agent_busy');
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const results = await Promise.all([
|
|
224
|
+
deliverQueueNow(host),
|
|
225
|
+
deliverQueueNow(host),
|
|
226
|
+
deliverQueueNow(host),
|
|
227
|
+
]);
|
|
228
|
+
await flush();
|
|
229
|
+
|
|
230
|
+
expect(results).toEqual([false, false, false]);
|
|
231
|
+
// One claim, one failed dispatch, one requeue — not three of each.
|
|
232
|
+
expect(attempts).toBe(1);
|
|
233
|
+
expect(queue.get(sessionId)?.map((item) => item.text)).toEqual(['a', 'b', 'c']);
|
|
234
|
+
});
|
|
206
235
|
});
|
|
@@ -70,6 +70,8 @@ interface PendingDelivery {
|
|
|
70
70
|
declare global {
|
|
71
71
|
// eslint-disable-next-line no-var
|
|
72
72
|
var __ompQueueDeliveryTimers: Map<string, PendingDelivery> | undefined;
|
|
73
|
+
// eslint-disable-next-line no-var
|
|
74
|
+
var __ompQueueDeliveryInFlight: Map<string, Promise<boolean>> | undefined;
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
/** Per-session pending delivery timer, so a second agent_end while one is
|
|
@@ -93,6 +95,24 @@ function clearPendingTimer(sessionId: string): void {
|
|
|
93
95
|
pendingTimers.delete(sessionId);
|
|
94
96
|
}
|
|
95
97
|
|
|
98
|
+
/**
|
|
99
|
+
* The delivery currently running for a session, if any.
|
|
100
|
+
*
|
|
101
|
+
* Every trigger — a run end, the retry timer, a tab's nudge (which runs
|
|
102
|
+
* {@link deliverQueueNow} with no timer at all) — enters here, and they overlap
|
|
103
|
+
* freely: a nudge fires while the retry's dispatch is still awaiting the RPC.
|
|
104
|
+
* Two overlapping attempts claim two different heads, and each requeue then
|
|
105
|
+
* decides the order the pair comes back in. Serialized per session, so one
|
|
106
|
+
* dispatch is in flight at a time and the queue is only ever touched by it.
|
|
107
|
+
*
|
|
108
|
+
* On `globalThis` for the same reason as the timers: a `--hot` reload must not
|
|
109
|
+
* lose track of a running delivery.
|
|
110
|
+
*/
|
|
111
|
+
function getInFlightDeliveries(): Map<string, Promise<boolean>> {
|
|
112
|
+
if (!globalThis.__ompQueueDeliveryInFlight) globalThis.__ompQueueDeliveryInFlight = new Map();
|
|
113
|
+
return globalThis.__ompQueueDeliveryInFlight;
|
|
114
|
+
}
|
|
115
|
+
|
|
96
116
|
/** Send one queued item to the session as a normal prompt. The model snapshot
|
|
97
117
|
* rides first (set_model / set_thinking_level) exactly like the composer's
|
|
98
118
|
* queued delivery did. Returns false when the dispatch failed.
|
|
@@ -202,8 +222,27 @@ async function armRetryIfQueued(session: QueueDeliveryHost): Promise<void> {
|
|
|
202
222
|
* strand the queue permanently: the timer had already been deleted from the map
|
|
203
223
|
* by its own callback, so nothing remained to retry it and no later trigger was
|
|
204
224
|
* guaranteed to arrive. Re-arming keeps the retry owned by this module.
|
|
225
|
+
*
|
|
226
|
+
* Concurrent calls share the running attempt instead of starting a second one:
|
|
227
|
+
* the dispatches that provoke them (`agent_busy` from omp while `isBusy()` still
|
|
228
|
+
* reads idle) otherwise overlap, and two overlapping claims plus two requeues
|
|
229
|
+
* reorder the queue.
|
|
205
230
|
*/
|
|
206
231
|
async function deliverNext(session: QueueDeliveryHost): Promise<boolean> {
|
|
232
|
+
const sessionId = session.sessionId;
|
|
233
|
+
const inFlight = getInFlightDeliveries();
|
|
234
|
+
const running = inFlight.get(sessionId);
|
|
235
|
+
if (running) return running;
|
|
236
|
+
const attempt = runDelivery(session);
|
|
237
|
+
inFlight.set(sessionId, attempt);
|
|
238
|
+
try {
|
|
239
|
+
return await attempt;
|
|
240
|
+
} finally {
|
|
241
|
+
if (inFlight.get(sessionId) === attempt) inFlight.delete(sessionId);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
async function runDelivery(session: QueueDeliveryHost): Promise<boolean> {
|
|
207
246
|
const sessionId = session.sessionId;
|
|
208
247
|
if (!session.isAlive()) return false;
|
|
209
248
|
if (session.isBusy()) {
|
|
@@ -35,9 +35,9 @@ import {
|
|
|
35
35
|
requeueHeadQueueItem,
|
|
36
36
|
reorderQueue,
|
|
37
37
|
rowToQueuedMessage,
|
|
38
|
+
type ClaimedQueueItem,
|
|
38
39
|
} from '@/server/lib/queue/store.server';
|
|
39
40
|
import { restoreStore } from '@/server/lib/queue/delivery-harness';
|
|
40
|
-
import type { QueuedMessage } from '@/shared/types/chat';
|
|
41
41
|
import { removeDir } from '@/test-support/remove-dir';
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -240,7 +240,7 @@ describe('claim, requeue and presence', () => {
|
|
|
240
240
|
useTempDb();
|
|
241
241
|
await appendQueueItem('s1', { text: 'first' });
|
|
242
242
|
await appendQueueItem('s1', { text: 'second' });
|
|
243
|
-
const failed = (await claimHeadQueueItem('s1')) as
|
|
243
|
+
const failed = (await claimHeadQueueItem('s1')) as ClaimedQueueItem;
|
|
244
244
|
expect(failed.text).toBe('first');
|
|
245
245
|
|
|
246
246
|
await requeueHeadQueueItem('s1', failed);
|
|
@@ -248,6 +248,26 @@ describe('claim, requeue and presence', () => {
|
|
|
248
248
|
expect((await claimHeadQueueItem('s1'))?.text).toBe('first');
|
|
249
249
|
});
|
|
250
250
|
|
|
251
|
+
// Measured live: a busy session rejected each dispatch (`agent_busy`) once
|
|
252
|
+
// per retry while the client's 3s nudge kept entering `deliverNext`, so two
|
|
253
|
+
// claims were in flight at once. `MIN(position) - 1` then put each failed
|
|
254
|
+
// item one slot too low and the pair came back swapped — the panel's order
|
|
255
|
+
// changed on every retry, and positions walked to -8..-1.
|
|
256
|
+
test('a requeue returns the item to its own slot, not below the queue', async () => {
|
|
257
|
+
useTempDb();
|
|
258
|
+
await appendQueueItem('s1', { text: 'a' });
|
|
259
|
+
await appendQueueItem('s1', { text: 'b' });
|
|
260
|
+
await appendQueueItem('s1', { text: 'c' });
|
|
261
|
+
|
|
262
|
+
// Two overlapping attempts: the second claims while the first dispatches.
|
|
263
|
+
const first = (await claimHeadQueueItem('s1')) as ClaimedQueueItem;
|
|
264
|
+
const second = (await claimHeadQueueItem('s1')) as ClaimedQueueItem;
|
|
265
|
+
await requeueHeadQueueItem('s1', first);
|
|
266
|
+
await requeueHeadQueueItem('s1', second);
|
|
267
|
+
|
|
268
|
+
expect((await listQueue('s1')).map((item) => item.text)).toEqual(['a', 'b', 'c']);
|
|
269
|
+
});
|
|
270
|
+
|
|
251
271
|
test('hasQueuedItem reports presence without claiming', async () => {
|
|
252
272
|
useTempDb();
|
|
253
273
|
expect(await hasQueuedItem('s1')).toBe(false);
|
|
@@ -83,11 +83,28 @@ interface QueueItemInput {
|
|
|
83
83
|
model?: unknown;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* A claimed row plus the position it held. A failed dispatch puts the item
|
|
88
|
+
* back at exactly that slot: recomputing "one below the current minimum" from
|
|
89
|
+
* a queue two deliveries touched reorders the rest — measured as a live queue
|
|
90
|
+
* whose eight rows walked from positions 0..7 down to -8..-1 while a busy
|
|
91
|
+
* session rejected each dispatch (`agent_busy`) once per retry.
|
|
92
|
+
*/
|
|
93
|
+
export interface ClaimedQueueItem extends QueuedMessage {
|
|
94
|
+
position: number;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The session's queued follow-ups in delivery order.
|
|
99
|
+
*
|
|
100
|
+
* `rowid` breaks a position tie: two rows can share a position when a reorder
|
|
101
|
+
* ships a list that a concurrent append was not part of, and SQLite is free to
|
|
102
|
+
* return equal keys in any order — which reads as the panel shuffling itself.
|
|
103
|
+
*/
|
|
87
104
|
export async function listQueue(sessionId: string): Promise<QueuedMessage[]> {
|
|
88
105
|
const db = await getDb();
|
|
89
106
|
const rows = (await db.all(
|
|
90
|
-
'SELECT * FROM queued_messages WHERE session_id = ? ORDER BY position ASC',
|
|
107
|
+
'SELECT * FROM queued_messages WHERE session_id = ? ORDER BY position ASC, rowid ASC',
|
|
91
108
|
[sessionId],
|
|
92
109
|
)) as QueueRow[];
|
|
93
110
|
return rows.map(rowToQueuedMessage);
|
|
@@ -171,18 +188,18 @@ export async function reorderQueue(sessionId: string, orderedIds: string[]): Pro
|
|
|
171
188
|
* call and stranded the queue silently, with nudges failing the same way.
|
|
172
189
|
* `getDb()` re-initializes instead, so a delivery heals the state it needs.
|
|
173
190
|
*/
|
|
174
|
-
export async function claimHeadQueueItem(sessionId: string): Promise<
|
|
191
|
+
export async function claimHeadQueueItem(sessionId: string): Promise<ClaimedQueueItem | null> {
|
|
175
192
|
const db = await getDb();
|
|
176
193
|
return withTransaction(db, () => {
|
|
177
194
|
const row = db.raw
|
|
178
|
-
.query('SELECT * FROM queued_messages WHERE session_id = ? ORDER BY position ASC LIMIT 1')
|
|
195
|
+
.query('SELECT * FROM queued_messages WHERE session_id = ? ORDER BY position ASC, rowid ASC LIMIT 1')
|
|
179
196
|
.get(sessionId) as QueueRow | undefined;
|
|
180
197
|
if (!row) return null;
|
|
181
198
|
db.raw.run('DELETE FROM queued_messages WHERE id = ?', [row.id]);
|
|
182
199
|
// The head left the queue: a panel showing it must be told, or it keeps
|
|
183
200
|
// rendering an item that is already being sent.
|
|
184
201
|
emitRealtimeSignal('session-data-dirty', sessionId);
|
|
185
|
-
return rowToQueuedMessage(row);
|
|
202
|
+
return { ...rowToQueuedMessage(row), position: row.position };
|
|
186
203
|
});
|
|
187
204
|
}
|
|
188
205
|
|
|
@@ -203,16 +220,21 @@ export async function hasQueuedItem(sessionId: string): Promise<boolean> {
|
|
|
203
220
|
}
|
|
204
221
|
|
|
205
222
|
/**
|
|
206
|
-
* Put a failed delivery back
|
|
207
|
-
* so it is retried before anything
|
|
208
|
-
*
|
|
223
|
+
* Put a failed delivery back where it was: the position it was claimed from,
|
|
224
|
+
* so it is retried before anything queued after it.
|
|
225
|
+
*
|
|
226
|
+
* The position is carried by the claim rather than recomputed. `MIN(position)
|
|
227
|
+
* - 1` looks equivalent and is not: with two attempts in flight the second
|
|
228
|
+
* claim has already removed the next row, so the first requeue lands one slot
|
|
229
|
+
* too low and the pair swaps. Every retry against a busy session then permutes
|
|
230
|
+
* the queue again.
|
|
209
231
|
*/
|
|
210
|
-
export async function requeueHeadQueueItem(sessionId: string, item:
|
|
232
|
+
export async function requeueHeadQueueItem(sessionId: string, item: ClaimedQueueItem): Promise<void> {
|
|
211
233
|
const db = await getDb();
|
|
212
234
|
db.raw.run(
|
|
213
235
|
`INSERT INTO queued_messages (id, session_id, position, message, attachments, provider, model_id, thinking_level, access_mode)
|
|
214
|
-
VALUES (?, ?,
|
|
215
|
-
[item.id, sessionId,
|
|
236
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
237
|
+
[item.id, sessionId, item.position, item.text, serializeAttachments(item.attachments),
|
|
216
238
|
item.model?.provider ?? null, item.model?.modelId ?? null, item.model?.thinkingLevel ?? null, item.model?.accessMode ?? null],
|
|
217
239
|
);
|
|
218
240
|
emitRealtimeSignal('session-data-dirty', sessionId);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The review-annotation table, kept out of `db.server.ts`'s bootstrap block for
|
|
8
|
+
* the same reason `schedule/schema.server.ts` is: created once per database open,
|
|
9
|
+
* owned by the feature that reads it.
|
|
10
|
+
*
|
|
11
|
+
* Why a table and not `session_ui_state`: that blob is the CLIENT's whole
|
|
12
|
+
* in-memory map, rewritten wholesale on every debounce, so two tabs (or two
|
|
13
|
+
* Kabmo instances on one database) clobber each other. An annotation is a
|
|
14
|
+
* judgement about a FILE and has to outlive the tab that made it.
|
|
15
|
+
*
|
|
16
|
+
* `block_key` is the identity — `type:hash#occurrence`, derived from the block's
|
|
17
|
+
* own text — so a judgement follows its paragraph when text above it moves. The
|
|
18
|
+
* line columns are display data refreshed on every save, never a join key.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import type { DbClient } from '@/server/lib/db/client';
|
|
22
|
+
|
|
23
|
+
const REVIEW_SCHEMA_SQL = `
|
|
24
|
+
CREATE TABLE IF NOT EXISTS document_annotations (
|
|
25
|
+
id TEXT PRIMARY KEY,
|
|
26
|
+
scope TEXT NOT NULL,
|
|
27
|
+
path TEXT NOT NULL,
|
|
28
|
+
block_key TEXT NOT NULL,
|
|
29
|
+
line_start INTEGER NOT NULL DEFAULT 0,
|
|
30
|
+
line_end INTEGER NOT NULL DEFAULT 0,
|
|
31
|
+
verdict TEXT NOT NULL,
|
|
32
|
+
note TEXT NOT NULL DEFAULT '',
|
|
33
|
+
quote TEXT NOT NULL DEFAULT '',
|
|
34
|
+
created_at INTEGER NOT NULL,
|
|
35
|
+
updated_at INTEGER NOT NULL,
|
|
36
|
+
UNIQUE (scope, path, block_key)
|
|
37
|
+
);
|
|
38
|
+
CREATE INDEX IF NOT EXISTS idx_document_annotations_doc
|
|
39
|
+
ON document_annotations (scope, path);
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
/** Idempotent: the review annotations, created on every database open. */
|
|
43
|
+
export async function ensureReviewSchema(db: DbClient): Promise<void> {
|
|
44
|
+
await db.exec(REVIEW_SCHEMA_SQL);
|
|
45
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* SQLite-backed store for a document's review annotations.
|
|
8
|
+
*
|
|
9
|
+
* One row per (scope, path, block key), and a save is an UPSERT: a block carries
|
|
10
|
+
* one judgement, and a second click changes the answer rather than stacking a
|
|
11
|
+
* thread. The `UNIQUE` constraint in the schema is the enforcement — two tabs
|
|
12
|
+
* saving the same block at once ends with one row, not two.
|
|
13
|
+
*
|
|
14
|
+
* `created_at` is preserved across an upsert while `updated_at` moves, so
|
|
15
|
+
* "oldest note first" and "most recently touched" are both answerable.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { randomUUID } from 'node:crypto';
|
|
19
|
+
|
|
20
|
+
import { getDb } from '@/server/db.server';
|
|
21
|
+
import type { DocumentAnnotation, BlockVerdict } from '@/shared/lib/markdown/blocks/types';
|
|
22
|
+
|
|
23
|
+
interface AnnotationRow {
|
|
24
|
+
id: string;
|
|
25
|
+
scope: string;
|
|
26
|
+
path: string;
|
|
27
|
+
block_key: string;
|
|
28
|
+
line_start: number;
|
|
29
|
+
line_end: number;
|
|
30
|
+
verdict: string;
|
|
31
|
+
note: string;
|
|
32
|
+
quote: string;
|
|
33
|
+
created_at: number;
|
|
34
|
+
updated_at: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function isVerdict(value: unknown): value is BlockVerdict {
|
|
38
|
+
return value === 'good' || value === 'needs-work';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function toAnnotation(row: AnnotationRow): DocumentAnnotation {
|
|
42
|
+
return {
|
|
43
|
+
id: row.id,
|
|
44
|
+
scope: row.scope,
|
|
45
|
+
path: row.path,
|
|
46
|
+
blockKey: row.block_key,
|
|
47
|
+
lineStart: row.line_start,
|
|
48
|
+
lineEnd: row.line_end,
|
|
49
|
+
// A row written by a future version with a third verdict reads as
|
|
50
|
+
// `needs-work` rather than disappearing: a judgement that cannot be
|
|
51
|
+
// interpreted is still a block the user flagged.
|
|
52
|
+
verdict: isVerdict(row.verdict) ? row.verdict : 'needs-work',
|
|
53
|
+
note: row.note,
|
|
54
|
+
quote: row.quote,
|
|
55
|
+
createdAt: row.created_at,
|
|
56
|
+
updatedAt: row.updated_at,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Every judgement stored for one document, oldest first. */
|
|
61
|
+
export async function listAnnotations(scope: string, path: string): Promise<DocumentAnnotation[]> {
|
|
62
|
+
const db = await getDb();
|
|
63
|
+
const rows = (await db.all(
|
|
64
|
+
'SELECT * FROM document_annotations WHERE scope = ? AND path = ? ORDER BY created_at ASC',
|
|
65
|
+
[scope, path],
|
|
66
|
+
)) as AnnotationRow[];
|
|
67
|
+
return rows.map(toAnnotation);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface AnnotationInput {
|
|
71
|
+
scope: string;
|
|
72
|
+
path: string;
|
|
73
|
+
blockKey: string;
|
|
74
|
+
lineStart: number;
|
|
75
|
+
lineEnd: number;
|
|
76
|
+
verdict: BlockVerdict;
|
|
77
|
+
note: string;
|
|
78
|
+
quote: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Insert or replace the judgement for one block, and answer the stored row. */
|
|
82
|
+
export async function saveAnnotation(input: AnnotationInput): Promise<DocumentAnnotation> {
|
|
83
|
+
const db = await getDb();
|
|
84
|
+
const now = Date.now();
|
|
85
|
+
const existing = (await db.get(
|
|
86
|
+
'SELECT id, created_at FROM document_annotations WHERE scope = ? AND path = ? AND block_key = ?',
|
|
87
|
+
[input.scope, input.path, input.blockKey],
|
|
88
|
+
)) as { id: string; created_at: number } | undefined;
|
|
89
|
+
const id = existing?.id ?? randomUUID();
|
|
90
|
+
const createdAt = existing?.created_at ?? now;
|
|
91
|
+
|
|
92
|
+
await db.run(
|
|
93
|
+
`INSERT INTO document_annotations
|
|
94
|
+
(id, scope, path, block_key, line_start, line_end, verdict, note, quote, created_at, updated_at)
|
|
95
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
96
|
+
ON CONFLICT (scope, path, block_key) DO UPDATE SET
|
|
97
|
+
line_start = excluded.line_start,
|
|
98
|
+
line_end = excluded.line_end,
|
|
99
|
+
verdict = excluded.verdict,
|
|
100
|
+
note = excluded.note,
|
|
101
|
+
quote = excluded.quote,
|
|
102
|
+
updated_at = excluded.updated_at`,
|
|
103
|
+
[
|
|
104
|
+
id,
|
|
105
|
+
input.scope,
|
|
106
|
+
input.path,
|
|
107
|
+
input.blockKey,
|
|
108
|
+
input.lineStart,
|
|
109
|
+
input.lineEnd,
|
|
110
|
+
input.verdict,
|
|
111
|
+
input.note,
|
|
112
|
+
input.quote,
|
|
113
|
+
createdAt,
|
|
114
|
+
now,
|
|
115
|
+
],
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
id,
|
|
120
|
+
scope: input.scope,
|
|
121
|
+
path: input.path,
|
|
122
|
+
blockKey: input.blockKey,
|
|
123
|
+
lineStart: input.lineStart,
|
|
124
|
+
lineEnd: input.lineEnd,
|
|
125
|
+
verdict: input.verdict,
|
|
126
|
+
note: input.note,
|
|
127
|
+
quote: input.quote,
|
|
128
|
+
createdAt,
|
|
129
|
+
updatedAt: now,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Remove one judgement. `false` means there was no row with that id. */
|
|
134
|
+
export async function deleteAnnotation(id: string): Promise<boolean> {
|
|
135
|
+
const db = await getDb();
|
|
136
|
+
const result = await db.run('DELETE FROM document_annotations WHERE id = ?', [id]);
|
|
137
|
+
return result.changes > 0;
|
|
138
|
+
}
|