@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
|
@@ -26,58 +26,9 @@ import { buildKenariReport } from '@/server/lib/usage/kenari';
|
|
|
26
26
|
import { fetchOmpUsageSnapshot, type OmpUsageSnapshot } from '@/server/lib/usage/omp-usage.server';
|
|
27
27
|
import { fetchVendorBalance, type VendorBalance } from '@/server/lib/usage/vendor-balance.server';
|
|
28
28
|
import { kenariProviderSlugs, listCredentialedProviders, type CredentialedProvider } from '@/server/lib/usage/provider-key';
|
|
29
|
-
import {
|
|
29
|
+
import { canonicalProviderSlug, providerDisplayName } from '@/shared/lib/models/provider/label';
|
|
30
30
|
import type { KenariUsageReport, UsageProviderSummary } from '@/shared/types';
|
|
31
31
|
|
|
32
|
-
/** Slug aliases omp uses interchangeably, folded onto one display entry. */
|
|
33
|
-
const SLUG_ALIASES: Record<string, string> = {
|
|
34
|
-
'command-code': 'commandcode',
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Brand spellings a title-case pass cannot produce. Kept small on purpose: the
|
|
39
|
-
* slug is the identity, this is only how it is printed.
|
|
40
|
-
*/
|
|
41
|
-
const BRAND_NAMES: Record<string, string> = {
|
|
42
|
-
openai: 'OpenAI',
|
|
43
|
-
kenari: 'Kenari.id',
|
|
44
|
-
deepseek: 'DeepSeek',
|
|
45
|
-
'openai-codex': 'OpenAI Codex',
|
|
46
|
-
'google-gemini-cli': 'Google Gemini CLI',
|
|
47
|
-
'google-antigravity': 'Google Antigravity',
|
|
48
|
-
'github-copilot': 'GitHub Copilot',
|
|
49
|
-
zai: 'Z.AI',
|
|
50
|
-
'zai-coding-plan': 'Z.AI Coding Plan',
|
|
51
|
-
xai: 'xAI',
|
|
52
|
-
'xai-oauth': 'xAI (OAuth)',
|
|
53
|
-
'kimi-code': 'Kimi Code',
|
|
54
|
-
'qwen-portal': 'Qwen Portal',
|
|
55
|
-
'minimax-code': 'MiniMax Code',
|
|
56
|
-
'minimax-code-cn': 'MiniMax Code (CN)',
|
|
57
|
-
'alibaba-token-plan': 'Alibaba Token Plan',
|
|
58
|
-
'alibaba-coding-plan': 'Alibaba Coding Plan',
|
|
59
|
-
'zhipu-coding-plan': 'Zhipu Coding Plan',
|
|
60
|
-
'gitlab-duo': 'GitLab Duo',
|
|
61
|
-
'gitlab-duo-agent': 'GitLab Duo Agent',
|
|
62
|
-
'charm-hyper': 'Charm Hyper',
|
|
63
|
-
'cline-pass': 'Cline Pass',
|
|
64
|
-
'opencode-go': 'OpenCode Go',
|
|
65
|
-
'xiaomi-token-plan-sgp': 'Xiaomi Token Plan (SGP)',
|
|
66
|
-
'xiaomi-token-plan-ams': 'Xiaomi Token Plan (AMS)',
|
|
67
|
-
'xiaomi-token-plan-cn': 'Xiaomi Token Plan (CN)',
|
|
68
|
-
'openai-codex-device': 'OpenAI Codex (Device)',
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
function canonicalSlug(slug: string): string {
|
|
72
|
-
const lower = slug.trim().toLowerCase();
|
|
73
|
-
return SLUG_ALIASES[lower] ?? lower;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/** Human-readable provider name: brand spelling when known, title case otherwise. */
|
|
77
|
-
function displayName(slug: string): string {
|
|
78
|
-
return BRAND_NAMES[slug] ?? titleCaseProviderSlug(slug);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
32
|
/**
|
|
82
33
|
* omp's own display names for the providers it knows (slug → name), e.g.
|
|
83
34
|
* `commandcode` → "Command Code". Best-effort: a cold or busy omp degrades to
|
|
@@ -88,7 +39,7 @@ async function loadProviderNames(): Promise<Record<string, string>> {
|
|
|
88
39
|
const { providers } = await fetchOmpRegistrySnapshot();
|
|
89
40
|
const names: Record<string, string> = {};
|
|
90
41
|
for (const provider of providers) {
|
|
91
|
-
const slug =
|
|
42
|
+
const slug = canonicalProviderSlug(provider.id);
|
|
92
43
|
const name = provider.name.trim();
|
|
93
44
|
if (slug && name) names[slug] = name;
|
|
94
45
|
}
|
|
@@ -118,7 +69,7 @@ async function loadVendorBalances(slugs: string[]): Promise<Map<string, VendorBa
|
|
|
118
69
|
function mergeCredentials(entries: CredentialedProvider[]): Map<string, string[]> {
|
|
119
70
|
const bySlug = new Map<string, string[]>();
|
|
120
71
|
for (const entry of entries) {
|
|
121
|
-
const slug =
|
|
72
|
+
const slug = canonicalProviderSlug(entry.slug);
|
|
122
73
|
if (!slug) continue;
|
|
123
74
|
const sources = bySlug.get(slug) ?? [];
|
|
124
75
|
for (const source of entry.sources) {
|
|
@@ -189,7 +140,7 @@ export async function buildUsageProviders(options: { force?: boolean } = {}): Pr
|
|
|
189
140
|
const { tracked, limitsUnavailable } = resolveUsageTracking(slug, snapshot);
|
|
190
141
|
const summary: UsageProviderSummary = {
|
|
191
142
|
id: slug,
|
|
192
|
-
name: names[slug] ??
|
|
143
|
+
name: names[slug] ?? providerDisplayName(slug),
|
|
193
144
|
...(iconUrls.get(slug) ? { iconUrl: iconUrls.get(slug) } : {}),
|
|
194
145
|
credentialSources: sources,
|
|
195
146
|
// A vendor balance is real quota data even when omp has no adapter for it.
|
|
@@ -21,8 +21,15 @@ import {
|
|
|
21
21
|
} from '@/server/lib/assets/theme-shell.server';
|
|
22
22
|
import { readSettingsBlob } from '@/shared/lib/settings/keys';
|
|
23
23
|
import { resolveTheme } from '@/shared/lib/theme/catalog';
|
|
24
|
+
import { applyShellDocumentFacts } from '@/server/lib/assets/shell-attributes.server';
|
|
25
|
+
import { SURFACE_STYLE_SETTING_KEY } from '@/shared/lib/theme/surface-style';
|
|
26
|
+
import { ICON_STYLE_SETTING_KEY } from '@/shared/lib/theme/icon-style';
|
|
24
27
|
import { windowChromeColor } from '@/shared/lib/theme/chrome';
|
|
25
28
|
import { THEME_STYLE_ELEMENT_ID, themeStyleSheet } from '@/shared/lib/theme/css';
|
|
29
|
+
import {
|
|
30
|
+
ICON_PAINT_STYLE_ELEMENT_ID,
|
|
31
|
+
iconPaintStyleSheet,
|
|
32
|
+
} from '@/shared/lib/icons/icon-paint-css';
|
|
26
33
|
import { isAndroidDevice, shellVersion } from '@/shared/lib/updates/shell-ua';
|
|
27
34
|
|
|
28
35
|
/** HTML-escape a string for interpolation into the failure page's `<pre>`. */
|
|
@@ -92,6 +99,7 @@ function storedThemeId(settings: Record<string, unknown>): string | undefined {
|
|
|
92
99
|
return typeof theme === 'string' && theme.length > 0 ? theme : undefined;
|
|
93
100
|
}
|
|
94
101
|
|
|
102
|
+
|
|
95
103
|
/**
|
|
96
104
|
* The HTML shell is generated per request, so its cacheability is declared
|
|
97
105
|
* rather than left to the browser's heuristics.
|
|
@@ -216,6 +224,10 @@ export const ssrRoutes = new Elysia({ name: 'ssr' }).get('*', async ({ request }
|
|
|
216
224
|
// a second tag: with both present Chrome reads the first one, so an appended
|
|
217
225
|
// tag would leave a dark theme painting light browser chrome.
|
|
218
226
|
const themeStyle = `<style id="${THEME_STYLE_ELEMENT_ID}">${themeStyleSheet()}</style>`;
|
|
227
|
+
// The brand colours are generated from a TS table too, for the same reason:
|
|
228
|
+
// the bundler cannot carry a stylesheet derived from data, and a hand-written
|
|
229
|
+
// copy in `tailwind.css` would be 35 pairs that drift from the table.
|
|
230
|
+
const brandStyle = `<style id="${ICON_PAINT_STYLE_ELEMENT_ID}">${iconPaintStyleSheet()}</style>`;
|
|
219
231
|
// The frame the browser paints BEFORE the bundle's stylesheet lands: the UA's
|
|
220
232
|
// own canvas is white, and on a dark install that is a measured white flash
|
|
221
233
|
// for the length of the CSS request. The palette's ground is the only correct
|
|
@@ -243,11 +255,16 @@ export const ssrRoutes = new Elysia({ name: 'ssr' }).get('*', async ({ request }
|
|
|
243
255
|
|
|
244
256
|
return maybeCompress(
|
|
245
257
|
new Response(
|
|
246
|
-
shellHtml
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
258
|
+
applyShellDocumentFacts(shellHtml, {
|
|
259
|
+
palette: theme,
|
|
260
|
+
// The two presentation styles are read from the same blob as the
|
|
261
|
+
// palette, so the FIRST frame is already the material the user chose:
|
|
262
|
+
// without this a glass install paints one opaque frame and swaps.
|
|
263
|
+
surfaceStyle: readSettingsBlob(settings)[SURFACE_STYLE_SETTING_KEY],
|
|
264
|
+
iconStyle: readSettingsBlob(settings)[ICON_STYLE_SETTING_KEY],
|
|
265
|
+
chromeColor: chrome,
|
|
266
|
+
})
|
|
267
|
+
.replace('<!--app-head-->', firstFrame + themeStyle + brandStyle + fontLink)
|
|
251
268
|
.replace(SHELL_MARKER, `<script>window.__OMP_BOOTSTRAP__=${bootstrap}</script>`),
|
|
252
269
|
{ headers: HTML_HEADERS },
|
|
253
270
|
),
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { bindingsFor, type HandlerBinding } from '@/server/lib/route-adapter';
|
|
2
2
|
import * as browserStream from '@/server/routes/browser/stream';
|
|
3
|
+
import * as browserTabs from '@/server/routes/browser/tabs';
|
|
3
4
|
|
|
4
5
|
export const browserBindings: HandlerBinding[] = [
|
|
5
6
|
...bindingsFor(browserStream, '/api/browser/:sessionId/stream'),
|
|
7
|
+
// Mutating route: `bindingsFor` adds the 405 GET fallback on its own.
|
|
8
|
+
...bindingsFor(browserTabs, '/api/browser/:sessionId/tabs/close'),
|
|
6
9
|
];
|
|
@@ -37,6 +37,9 @@ import { BROWSER_POLL_MS, STREAM_HEARTBEAT_MS } from '@/shared/lib/workspace/ref
|
|
|
37
37
|
|
|
38
38
|
const BROWSER_OFFLINE: BrowserViewState = { status: 'browser-offline', tabs: [] };
|
|
39
39
|
|
|
40
|
+
/** How soon a frame held under backpressure is offered to the stream again. */
|
|
41
|
+
const FRAME_FLUSH_RETRY_MS = 120;
|
|
42
|
+
|
|
40
43
|
export async function loader({ params, request }: LoaderFunctionArgs) {
|
|
41
44
|
const sessionId = params.sessionId ?? '';
|
|
42
45
|
const preferTargetId = new URL(request.url).searchParams.get('target') ?? undefined;
|
|
@@ -81,6 +84,11 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
|
|
|
81
84
|
const cleanup = (): void => {
|
|
82
85
|
if (closed) return;
|
|
83
86
|
closed = true;
|
|
87
|
+
pendingFrame = null;
|
|
88
|
+
if (frameTimer !== null) {
|
|
89
|
+
clearTimeout(frameTimer);
|
|
90
|
+
frameTimer = null;
|
|
91
|
+
}
|
|
84
92
|
detachViewer();
|
|
85
93
|
dropWatcher();
|
|
86
94
|
unsubscribeAgent?.();
|
|
@@ -104,12 +112,33 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
|
|
|
104
112
|
handlers.send('action', payload);
|
|
105
113
|
};
|
|
106
114
|
|
|
107
|
-
|
|
108
|
-
|
|
115
|
+
let pendingFrame: BrowserViewFrame | null = null;
|
|
116
|
+
let frameTimer: ReturnType<typeof setTimeout> | null = null;
|
|
117
|
+
|
|
118
|
+
const flushFrame = (): void => {
|
|
119
|
+
if (closed || !pendingFrame) return;
|
|
109
120
|
if (handlers.isBackpressured()) return;
|
|
121
|
+
const frame = pendingFrame;
|
|
122
|
+
pendingFrame = null;
|
|
110
123
|
handlers.send('frame', frame);
|
|
111
124
|
};
|
|
112
125
|
|
|
126
|
+
const emitFrame = (frame: BrowserViewFrame): void => {
|
|
127
|
+
// Backpressure: hold the NEWEST frame instead of dropping it. A drop is
|
|
128
|
+
// only harmless while the page keeps painting; an idle tab (the normal
|
|
129
|
+
// state of a tab the agent finished with) produces exactly one frame —
|
|
130
|
+
// the seeding snapshot — so dropping it is what put the panel back on
|
|
131
|
+
// "waiting for the first frame".
|
|
132
|
+
pendingFrame = frame;
|
|
133
|
+
flushFrame();
|
|
134
|
+
if (!pendingFrame || frameTimer !== null) return;
|
|
135
|
+
frameTimer = setTimeout(() => {
|
|
136
|
+
frameTimer = null;
|
|
137
|
+
flushFrame();
|
|
138
|
+
if (pendingFrame) emitFrame(pendingFrame);
|
|
139
|
+
}, FRAME_FLUSH_RETRY_MS);
|
|
140
|
+
};
|
|
141
|
+
|
|
113
142
|
const tick = async (): Promise<void> => {
|
|
114
143
|
if (closed || tickInFlight) return;
|
|
115
144
|
tickInFlight = true;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `POST /api/browser/:sessionId/tabs/close` — the refusals, which are the whole
|
|
8
|
+
* contract reachable without a real Chromium.
|
|
9
|
+
*
|
|
10
|
+
* A close request is an ACT of the user on someone else's browser, so every
|
|
11
|
+
* path that does not close must say why: no session, no shared browser, a tab
|
|
12
|
+
* that belongs to another session, a malformed id. The happy path itself is a
|
|
13
|
+
* single CDP call whose behaviour is measured in `shared/lib/browser/tab-close.ts`
|
|
14
|
+
* (Chromium 1248: `{"success":true}`, the socket survives, the attached session
|
|
15
|
+
* dies on its own), and its policy — which ids may be closed at all — is pinned
|
|
16
|
+
* in `tab-close.test.ts`.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
20
|
+
import path from 'node:path';
|
|
21
|
+
|
|
22
|
+
import { action } from '@/server/routes/browser/tabs';
|
|
23
|
+
|
|
24
|
+
const originalMock = Bun.env.MOCK;
|
|
25
|
+
const globals = globalThis as unknown as { __ompSessions?: Map<string, unknown> };
|
|
26
|
+
const SESSION = 'tabs-close-test-session';
|
|
27
|
+
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
delete Bun.env.MOCK;
|
|
30
|
+
if (!globals.__ompSessions) globals.__ompSessions = new Map();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
afterEach(() => {
|
|
34
|
+
globals.__ompSessions?.delete(SESSION);
|
|
35
|
+
if (originalMock === undefined) delete Bun.env.MOCK;
|
|
36
|
+
else Bun.env.MOCK = originalMock;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
function post(body: unknown, sessionId = SESSION): Promise<Response> {
|
|
40
|
+
return action({
|
|
41
|
+
params: { sessionId },
|
|
42
|
+
request: new Request(`http://localhost/api/browser/${sessionId}/tabs/close`, {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
headers: { 'content-type': 'application/json' },
|
|
45
|
+
body: typeof body === 'string' ? body : JSON.stringify(body),
|
|
46
|
+
}),
|
|
47
|
+
} as never) as Promise<Response>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
describe('browser tab close route', () => {
|
|
51
|
+
test('a session this process does not run owns no tabs to close', async () => {
|
|
52
|
+
const res = await post({ targetId: 'abc' });
|
|
53
|
+
expect(res.status).toBe(404);
|
|
54
|
+
expect(((await res.json()) as { error: string }).error).toContain('not running');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('a malformed target id is refused before any browser is touched', async () => {
|
|
58
|
+
globals.__ompSessions?.set(SESSION, { pid: process.pid, cwd: process.cwd(), isAlive: () => true });
|
|
59
|
+
for (const targetId of [undefined, '', 'a b', '../x', 7]) {
|
|
60
|
+
const res = await post({ targetId });
|
|
61
|
+
expect(res.status).toBe(400);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('a body that is not JSON is refused with 400, not a crash', async () => {
|
|
66
|
+
globals.__ompSessions?.set(SESSION, { pid: process.pid, cwd: process.cwd(), isAlive: () => true });
|
|
67
|
+
const res = await post('{not json');
|
|
68
|
+
expect(res.status).toBe(400);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('a project with no running shared browser reports 503', async () => {
|
|
72
|
+
globals.__ompSessions?.set(SESSION, {
|
|
73
|
+
pid: process.pid,
|
|
74
|
+
// A directory with no scope.json: discovery finds no runtime for it.
|
|
75
|
+
cwd: path.join(process.cwd(), 'tmp-no-browser-here'),
|
|
76
|
+
isAlive: () => true,
|
|
77
|
+
});
|
|
78
|
+
const res = await post({ targetId: 'abc' });
|
|
79
|
+
expect(res.status).toBe(503);
|
|
80
|
+
expect(((await res.json()) as { error: string }).error).toContain('No shared browser');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('MOCK mode never reaches a daemon', async () => {
|
|
84
|
+
Bun.env.MOCK = '1';
|
|
85
|
+
globals.__ompSessions?.set(SESSION, { pid: process.pid, cwd: process.cwd(), isAlive: () => true });
|
|
86
|
+
const res = await post({ targetId: 'abc' });
|
|
87
|
+
expect(res.status).toBe(503);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('a missing sessionId is a client error, not a silent no-op', async () => {
|
|
91
|
+
const res = await post({ targetId: 'abc' }, '');
|
|
92
|
+
expect(res.status).toBe(400);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* POST /api/browser/:sessionId/tabs/close — close one page this session's omp
|
|
8
|
+
* agent opened in the project-shared Chromium.
|
|
9
|
+
*
|
|
10
|
+
* Why the panel needs it: an agent that visits several pages leaves them all
|
|
11
|
+
* open in the shared daemon. The panel attaches to the newest owned target, so
|
|
12
|
+
* a pile of stale tabs is one more reason it shows the wrong page, and each one
|
|
13
|
+
* keeps a renderer alive.
|
|
14
|
+
*
|
|
15
|
+
* The ownership rule and the CDP behaviour are `shared/lib/browser/tab-close.ts`
|
|
16
|
+
* (one copy, so the panel and this route cannot disagree). This module only
|
|
17
|
+
* turns them into status codes:
|
|
18
|
+
*
|
|
19
|
+
* - 404 the session is not running here — there is no agent whose tab to close
|
|
20
|
+
* - 503 no shared browser for the session's project (nothing to connect to)
|
|
21
|
+
* - 403 the target is not one of THIS session's tabs
|
|
22
|
+
* - 200 closed, with the surviving tabs and the neighbour to select next
|
|
23
|
+
*
|
|
24
|
+
* A target the browser no longer knows is reported as `alreadyClosed: true`
|
|
25
|
+
* rather than an error: the caller asked for a tab to be gone, and it is.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { json, type ActionFunctionArgs } from '@/server/lib/remix-compat';
|
|
29
|
+
import { parseJsonBody, requireParam } from '@/server/lib/route-adapter';
|
|
30
|
+
import { isMockMode } from '@/server/mock.server';
|
|
31
|
+
import { getRpcSession } from '@/server/lib/omp/rpc/session-registry';
|
|
32
|
+
import { findProjectRuntimeDir, readOwnedTargetIds } from '@/server/lib/browser/runtime';
|
|
33
|
+
import { acquireConnection, releaseConnection } from '@/shared/lib/browser/connection';
|
|
34
|
+
import { closeVerdict, neighbourTargetId, readCloseTarget } from '@/shared/lib/browser/tab-close';
|
|
35
|
+
|
|
36
|
+
interface CloseBody {
|
|
37
|
+
targetId?: unknown;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function action({ request, params }: ActionFunctionArgs) {
|
|
41
|
+
const sessionId = requireParam(params, 'sessionId');
|
|
42
|
+
if (!sessionId) return json({ error: 'Missing session id' }, { status: 400 });
|
|
43
|
+
if (isMockMode()) {
|
|
44
|
+
return json({ error: 'The shared browser is not available in MOCK mode' }, { status: 503 });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const parsed = await parseJsonBody<CloseBody>(request);
|
|
48
|
+
if (!parsed.ok) return json({ error: 'Invalid JSON body' }, { status: 400 });
|
|
49
|
+
const targetId = readCloseTarget(parsed.body.targetId);
|
|
50
|
+
if (!targetId) return json({ error: 'Missing or malformed targetId' }, { status: 400 });
|
|
51
|
+
|
|
52
|
+
const session = getRpcSession(sessionId);
|
|
53
|
+
if (!session || !session.isAlive() || session.pid === undefined) {
|
|
54
|
+
return json({ error: 'This session is not running, so it owns no browser tabs' }, { status: 404 });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const runtime = await findProjectRuntimeDir(session.cwd);
|
|
58
|
+
if (!runtime) return json({ error: 'No shared browser is running for this project' }, { status: 503 });
|
|
59
|
+
|
|
60
|
+
// Ownership is decided against the on-disk registry, the same source the
|
|
61
|
+
// viewer scopes its tab list to: the daemon hosts every session's pages, so
|
|
62
|
+
// a target id from another one must be refused rather than attempted.
|
|
63
|
+
const owned = await readOwnedTargetIds(runtime.runtimeDir, runtime.daemonName, session.pid);
|
|
64
|
+
const verdict = closeVerdict(targetId, owned);
|
|
65
|
+
if (!verdict.ok) {
|
|
66
|
+
return json({ error: verdict.reason, remaining: verdict.remaining }, { status: 403 });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const conn = await acquireConnection(runtime.wsUrl).catch(() => null);
|
|
70
|
+
if (!conn) return json({ error: 'Could not reach the shared browser' }, { status: 503 });
|
|
71
|
+
try {
|
|
72
|
+
const reply = await conn.send('Target.closeTarget', { targetId }).catch((error: unknown) => error);
|
|
73
|
+
if (reply instanceof Error) {
|
|
74
|
+
// "No target found for targetId" is the page having gone away already:
|
|
75
|
+
// the outcome the caller asked for, not a failure of this request.
|
|
76
|
+
if (reply.message.includes('No target found')) {
|
|
77
|
+
return json({ ok: true, alreadyClosed: true, remaining: verdict.remaining, next: neighbourTargetId(owned, targetId) });
|
|
78
|
+
}
|
|
79
|
+
return json({ error: reply.message }, { status: 502 });
|
|
80
|
+
}
|
|
81
|
+
return json({ ok: true, alreadyClosed: false, remaining: verdict.remaining, next: neighbourTargetId(owned, targetId) });
|
|
82
|
+
} finally {
|
|
83
|
+
releaseConnection(runtime.wsUrl, conn);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -23,6 +23,7 @@ import { modelsBindings } from '@/server/routes/models';
|
|
|
23
23
|
import { ompBindings } from '@/server/routes/omp';
|
|
24
24
|
import { updatesBindings } from '@/server/routes/updates';
|
|
25
25
|
import { wikiBindings } from '@/server/routes/wiki';
|
|
26
|
+
import { reviewBindings } from '@/server/routes/review/bindings';
|
|
26
27
|
import { panelsBindings } from '@/server/routes/panels/bindings';
|
|
27
28
|
import { pluginsBindings } from '@/server/routes/plugins/bindings';
|
|
28
29
|
import { realtimeWsRoutes } from '@/server/routes/realtime/ws';
|
|
@@ -52,6 +53,7 @@ const allBindings: HandlerBinding[] = [
|
|
|
52
53
|
...ompBindings,
|
|
53
54
|
...updatesBindings,
|
|
54
55
|
...wikiBindings,
|
|
56
|
+
...reviewBindings,
|
|
55
57
|
...panelsBindings,
|
|
56
58
|
...pluginsBindings,
|
|
57
59
|
...healthBindings,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { bindingsFor, type HandlerBinding } from '@/server/lib/route-adapter';
|
|
7
|
+
import * as review from '@/server/routes/review/index';
|
|
8
|
+
|
|
9
|
+
export const reviewBindings: HandlerBinding[] = bindingsFor(review, '/api/review', {
|
|
10
|
+
mutating: ['POST', 'DELETE'],
|
|
11
|
+
});
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `/api/review` — a document's review annotations.
|
|
8
|
+
*
|
|
9
|
+
* GET `?path=&root=&repo=` → `{ annotations, scope }`
|
|
10
|
+
* POST → upsert one judgement for one block
|
|
11
|
+
* DELETE `?id=` → remove one
|
|
12
|
+
*
|
|
13
|
+
* The scope is resolved HERE, from the same `root`/`repo` pair every other file
|
|
14
|
+
* route takes, so an annotation can never name a directory the caller could not
|
|
15
|
+
* read: `resolveRoot` falls back the same way and `resolveWithinRoot` refuses an
|
|
16
|
+
* escape. The stored key is `<resolvedRoot>\0<repo>`, the spelling the realtime
|
|
17
|
+
* workspace topics already use for the same pair.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { json, NO_STORE_HEADERS } from '@/server/lib/remix-compat';
|
|
21
|
+
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@/server/lib/remix-compat';
|
|
22
|
+
import { methodNotAllowedResponse } from '@/server/lib/route-adapter';
|
|
23
|
+
import { getDefaultFsRoot, resolveRoot, resolveWithinRoot } from '@/server/lib/fs/root';
|
|
24
|
+
import { normalizeRelativePath } from '@/server/lib/fs/relative-path';
|
|
25
|
+
import { isMockMode } from '@/server/mock.server';
|
|
26
|
+
import { deleteAnnotation, listAnnotations, saveAnnotation } from '@/server/lib/review/store.server';
|
|
27
|
+
import type { BlockVerdict } from '@/shared/lib/markdown/blocks/types';
|
|
28
|
+
|
|
29
|
+
/** The scope key for one (root, repo) pair, or null when the pair is invalid. */
|
|
30
|
+
async function resolveScope(root: string | null, repo: string | null): Promise<{ scope: string; repo: string } | null> {
|
|
31
|
+
const resolvedRoot = await resolveRoot(root, await getDefaultFsRoot(isMockMode()));
|
|
32
|
+
const scopedRepo = repo && repo !== '.' ? repo : '.';
|
|
33
|
+
// A nested repo is only valid INSIDE this root; anything else is the same 403
|
|
34
|
+
// `/api/fs/dir` answers rather than a silently different document.
|
|
35
|
+
if (scopedRepo !== '.' && resolveWithinRoot(resolvedRoot, scopedRepo) === null) return null;
|
|
36
|
+
return { scope: `${resolvedRoot}\u0000${scopedRepo}`, repo: scopedRepo };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function normalizedPath(raw: unknown): string | null {
|
|
40
|
+
if (typeof raw !== 'string' || !raw.trim()) return null;
|
|
41
|
+
return normalizeRelativePath(raw);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function loader({ request }: LoaderFunctionArgs) {
|
|
45
|
+
const url = new URL(request.url);
|
|
46
|
+
const path = normalizedPath(url.searchParams.get('path'));
|
|
47
|
+
if (!path) return json({ error: 'path is required' }, { status: 400, headers: NO_STORE_HEADERS });
|
|
48
|
+
const target = await resolveScope(url.searchParams.get('root'), url.searchParams.get('repo'));
|
|
49
|
+
if (!target) return json({ error: 'Invalid repo path' }, { status: 403, headers: NO_STORE_HEADERS });
|
|
50
|
+
|
|
51
|
+
const annotations = await listAnnotations(target.scope, path);
|
|
52
|
+
return json({ annotations, scope: target.scope }, { headers: NO_STORE_HEADERS });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** One field at a time, so a bad body names what is wrong instead of "invalid". */
|
|
56
|
+
interface ParsedBody {
|
|
57
|
+
scope?: never;
|
|
58
|
+
root: string | null;
|
|
59
|
+
repo: string | null;
|
|
60
|
+
path: string | null;
|
|
61
|
+
blockKey: string | null;
|
|
62
|
+
lineStart: number;
|
|
63
|
+
lineEnd: number;
|
|
64
|
+
verdict: BlockVerdict | null;
|
|
65
|
+
note: string;
|
|
66
|
+
quote: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function parseBody(raw: unknown): ParsedBody | string {
|
|
70
|
+
if (typeof raw !== 'object' || raw === null) return 'body must be an object';
|
|
71
|
+
const body = raw as Record<string, unknown>;
|
|
72
|
+
const blockKey = typeof body.blockKey === 'string' ? body.blockKey.trim() : '';
|
|
73
|
+
if (!blockKey) return 'blockKey is required';
|
|
74
|
+
if (body.verdict !== 'good' && body.verdict !== 'needs-work') return 'verdict must be "good" or "needs-work"';
|
|
75
|
+
const line = (value: unknown): number => (typeof value === 'number' && Number.isInteger(value) && value >= 0 ? value : 0);
|
|
76
|
+
return {
|
|
77
|
+
root: typeof body.root === 'string' ? body.root : null,
|
|
78
|
+
repo: typeof body.repo === 'string' ? body.repo : null,
|
|
79
|
+
path: normalizedPath(body.path),
|
|
80
|
+
blockKey,
|
|
81
|
+
lineStart: line(body.lineStart),
|
|
82
|
+
lineEnd: line(body.lineEnd),
|
|
83
|
+
verdict: body.verdict,
|
|
84
|
+
note: typeof body.note === 'string' ? body.note.slice(0, 4000) : '',
|
|
85
|
+
quote: typeof body.quote === 'string' ? body.quote.slice(0, 400) : '',
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async function saveFrom({ request }: ActionFunctionArgs) {
|
|
90
|
+
const parsed = parseBody(await request.json().catch(() => null));
|
|
91
|
+
if (typeof parsed === 'string') return json({ error: parsed }, { status: 400 });
|
|
92
|
+
if (!parsed.path) return json({ error: 'path is required' }, { status: 400 });
|
|
93
|
+
if (!parsed.verdict) return json({ error: 'verdict is required' }, { status: 400 });
|
|
94
|
+
const target = await resolveScope(parsed.root, parsed.repo);
|
|
95
|
+
if (!target) return json({ error: 'Invalid repo path' }, { status: 403 });
|
|
96
|
+
|
|
97
|
+
const annotation = await saveAnnotation({
|
|
98
|
+
scope: target.scope,
|
|
99
|
+
path: parsed.path,
|
|
100
|
+
blockKey: parsed.blockKey as string,
|
|
101
|
+
lineStart: parsed.lineStart,
|
|
102
|
+
lineEnd: parsed.lineEnd,
|
|
103
|
+
verdict: parsed.verdict,
|
|
104
|
+
note: parsed.note,
|
|
105
|
+
quote: parsed.quote,
|
|
106
|
+
});
|
|
107
|
+
return json({ annotation }, { headers: NO_STORE_HEADERS });
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function removeFrom({ request }: ActionFunctionArgs) {
|
|
111
|
+
const id = new URL(request.url).searchParams.get('id');
|
|
112
|
+
if (!id) return json({ error: 'id is required' }, { status: 400 });
|
|
113
|
+
const removed = await deleteAnnotation(id);
|
|
114
|
+
if (!removed) return json({ error: 'No annotation with that id' }, { status: 404 });
|
|
115
|
+
return json({ success: true }, { headers: NO_STORE_HEADERS });
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export async function action(args: ActionFunctionArgs) {
|
|
119
|
+
switch (args.request.method) {
|
|
120
|
+
case 'POST':
|
|
121
|
+
return saveFrom(args);
|
|
122
|
+
case 'DELETE':
|
|
123
|
+
return removeFrom(args);
|
|
124
|
+
default:
|
|
125
|
+
return methodNotAllowedResponse();
|
|
126
|
+
}
|
|
127
|
+
}
|