@kabmo-labs/kabmo 0.22.0 → 0.24.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 +1 -1
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +873 -524
- package/dist/client/static/js/{index-297dck9a.js → index-jcr5twtp.js} +799 -795
- package/dist/client/static/js/index-z3w7n85q.css +1 -0
- package/marketplace/plugins/stats/package.json +2 -2
- package/marketplace/plugins/stats/src/groups.test.ts +14 -0
- package/marketplace/plugins/stats/src/groups.ts +20 -0
- package/marketplace/plugins/stats/src/labels.test.ts +9 -0
- package/marketplace/plugins/stats/src/labels.ts +7 -0
- package/marketplace/plugins/stats/src/server.ts +1 -1
- package/package.json +1 -1
- package/src/client/App.tsx +20 -19
- package/src/client/components/common/ComposerTextarea.tsx +10 -1
- package/src/client/components/common/Modal.tsx +2 -6
- package/src/client/components/common/PWAInstallButton.tsx +3 -2
- package/src/client/components/common/Toast.test.tsx +298 -0
- package/src/client/components/common/Toast.tsx +103 -37
- package/src/client/components/common/ToastStack.tsx +33 -12
- package/src/client/components/common/ViewportSelector.tsx +122 -114
- package/src/client/components/common/context-usage-button/Ring.tsx +38 -1
- package/src/client/components/common/context-usage-button/index.test.tsx +19 -3
- package/src/client/components/common/context-usage-button/index.tsx +5 -2
- package/src/client/components/common/harness-glyph/brands.ts +65 -0
- package/src/client/components/common/harness-glyph/harness-glyph.test.ts +185 -0
- package/src/client/components/common/harness-glyph/index.tsx +131 -0
- package/src/client/components/common/header-controls/MoreMenu.tsx +2 -1
- package/src/client/components/common/header-controls/index.tsx +16 -8
- package/src/client/components/common/header-panel-buttons/index.tsx +4 -3
- package/src/client/components/common/panel-mark/index.test.tsx +2 -2
- package/src/client/components/common/panel-mark/index.tsx +11 -2
- package/src/client/components/common/search-select/index.tsx +305 -0
- package/src/client/components/common/search-select/search-select.test.tsx +217 -0
- package/src/client/components/common/server-control/index.tsx +3 -2
- package/src/client/components/common/session-row/index.tsx +18 -1
- package/src/client/components/common/toolbar-row/index.tsx +57 -20
- package/src/client/components/layout/desktop-layout/LeftColumn.tsx +1 -3
- package/src/client/components/layout/desktop-layout/TopNavbar.tsx +3 -2
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +7 -1
- package/src/client/components/layout/desktop-layout/index.tsx +1 -3
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +1 -0
- package/src/client/components/layout/session-sidebar/SessionItem.tsx +18 -1
- package/src/client/components/layout/session-sidebar/SessionsView.tsx +1 -3
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.test.tsx +332 -0
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +310 -0
- package/src/client/components/layout/session-sidebar/about-modal/SocialLinks.tsx +63 -51
- package/src/client/components/layout/session-sidebar/about-modal/UpdateSection.tsx +4 -2
- package/src/client/components/layout/session-sidebar/about-modal/index.test.tsx +122 -0
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +136 -35
- package/src/client/components/layout/session-sidebar/harness-mark.test.tsx +126 -0
- package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +4 -3
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +1 -0
- package/src/client/components/mobile/LayoutWrapper.tsx +1 -7
- package/src/client/components/mobile/SessionSidebar.tsx +1 -3
- package/src/client/components/mobile/mobile-main-view/Header.tsx +3 -2
- package/src/client/components/mobile/mobile-session-sidebar/Dialogs.tsx +0 -8
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +1 -0
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +17 -1
- package/src/client/components/settings/Modal.tsx +26 -22
- package/src/client/components/settings/Sidebar.tsx +45 -5
- package/src/client/components/settings/categories/HarnessSettings.tsx +207 -0
- package/src/client/components/settings/categories/ProjectSettings.tsx +1 -3
- package/src/client/components/settings/categories/ProviderSettings.tsx +0 -4
- package/src/client/components/settings/categories/SkillCatalogSettings.tsx +13 -23
- package/src/client/components/settings/categories/agent-settings/ModelPicker.tsx +23 -30
- package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +20 -11
- package/src/client/components/settings/categories/chat-settings/GoalSection.tsx +16 -16
- package/src/client/components/settings/categories/harness-settings/AddProviderForm.tsx +219 -0
- package/src/client/components/settings/categories/harness-settings/ConfigForm.tsx +268 -0
- package/src/client/components/settings/categories/harness-settings/EnvProviderForm.tsx +146 -0
- package/src/client/components/settings/categories/harness-settings/HarnessCard.tsx +278 -0
- package/src/client/components/settings/categories/harness-settings/ImportSection.tsx +195 -0
- package/src/client/components/settings/categories/harness-settings/ProviderPanel.tsx +152 -0
- package/src/client/components/settings/categories/harness-settings/ToggleList.tsx +147 -0
- package/src/client/components/settings/categories/harness-settings/parts.test.tsx +97 -0
- package/src/client/components/settings/categories/harness-settings/parts.tsx +84 -0
- package/src/client/components/settings/categories/harness-settings/provider-panel.test.tsx +313 -0
- package/src/client/components/settings/categories/omp-settings/RoleEditor.test.ts +60 -39
- package/src/client/components/settings/categories/omp-settings/RoleRow.tsx +32 -41
- package/src/client/components/settings/categories/omp-settings/role-picker.test-util.ts +45 -0
- package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +1 -1
- package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +11 -4
- package/src/client/components/settings/groups.test.tsx +160 -0
- package/src/client/components/settings/harness-icons.test.tsx +134 -0
- package/src/client/components/workspace/browser-panel/AddressBar.tsx +3 -13
- package/src/client/components/workspace/browser-toolbar/clusters.tsx +237 -0
- package/src/client/components/workspace/browser-toolbar/index.test.tsx +167 -0
- package/src/client/components/workspace/browser-toolbar/index.tsx +99 -100
- package/src/client/components/workspace/btw-panel/Messages.tsx +4 -1
- package/src/client/components/workspace/btw-panel/index.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +11 -7
- package/src/client/components/workspace/chat-timeline/ChatOverlays.tsx +5 -2
- package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +13 -0
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +13 -0
- package/src/client/components/workspace/chat-timeline/GeneratingIndicator.test.ts +41 -0
- package/src/client/components/workspace/chat-timeline/GeneratingIndicator.tsx +19 -14
- package/src/client/components/workspace/chat-timeline/MessageList.test.ts +14 -0
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +6 -0
- package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +14 -0
- package/src/client/components/workspace/chat-timeline/RunFooter.tsx +4 -0
- package/src/client/components/workspace/chat-timeline/RunMark.tsx +58 -0
- package/src/client/components/workspace/chat-timeline/SubagentView.tsx +4 -1
- package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +4 -0
- package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +1 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +11 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.test.ts +13 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +8 -1
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +27 -1
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +48 -23
- package/src/client/components/workspace/chat-timeline/chat-input/composer-portal.test.tsx +1 -0
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +21 -1
- package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +7 -0
- package/src/client/components/workspace/chat-timeline/chat-input/props.ts +13 -0
- package/src/client/components/workspace/chat-timeline/chat-input/selection.ts +11 -2
- package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +1 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +17 -15
- package/src/client/components/workspace/chat-timeline/pending-harness.test.tsx +157 -0
- package/src/client/components/workspace/chat-timeline/run-mark.test.ts +104 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +11 -20
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/GroupedAsk.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/drafts.ts +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +2 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.test.ts +31 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +5 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.test.ts +56 -45
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +38 -94
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/wait-parts.tsx +76 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.ts +2 -1
- package/src/client/components/workspace/file-explorer/index.test.ts +25 -0
- package/src/client/components/workspace/file-explorer/index.tsx +10 -6
- package/src/client/components/workspace/git-panel/index.test.ts +13 -3
- package/src/client/components/workspace/git-panel/index.tsx +1 -3
- package/src/client/components/workspace/model-dropdown/Fullscreen.tsx +92 -0
- package/src/client/components/workspace/model-dropdown/HarnessTabs.tsx +290 -0
- package/src/client/components/workspace/model-dropdown/Item.tsx +11 -0
- package/src/client/components/workspace/model-dropdown/Panel.tsx +119 -8
- package/src/client/components/workspace/model-dropdown/Section.tsx +4 -0
- package/src/client/components/workspace/model-dropdown/fullscreen-picker.ts +51 -0
- package/src/client/components/workspace/model-dropdown/harness-models.test.ts +177 -0
- package/src/client/components/workspace/model-dropdown/harness-models.ts +148 -0
- package/src/client/components/workspace/model-dropdown/harness-tabs.test.tsx +336 -0
- package/src/client/components/workspace/model-dropdown/index.tsx +114 -85
- package/src/client/components/workspace/model-dropdown/placement.test.tsx +127 -0
- package/src/client/components/workspace/model-dropdown/popover-metrics.test.ts +107 -0
- package/src/client/components/workspace/model-dropdown/popover-metrics.ts +118 -0
- package/src/client/components/workspace/model-dropdown/row-mutations.ts +106 -0
- package/src/client/components/workspace/model-dropdown/trigger.test.ts +22 -2
- package/src/client/components/workspace/model-dropdown/use-popover-size.ts +89 -0
- package/src/client/data/settings/omp-schema.json +224 -17
- package/src/client/hooks/chat/composer/index.ts +11 -2
- package/src/client/hooks/chat/composer/items.test.ts +11 -0
- package/src/client/hooks/chat/composer/items.ts +4 -2
- package/src/client/hooks/chat/composer/model-selection.test.ts +110 -0
- package/src/client/hooks/chat/composer/model-selection.ts +45 -4
- package/src/client/hooks/chat/omp/prompt-send.ts +4 -2
- package/src/client/hooks/chat/timeline/actions.ts +10 -5
- package/src/client/hooks/chat/timeline/ask-frames.ts +5 -4
- package/src/client/hooks/chat/timeline/composer-local-actions.test.ts +19 -81
- package/src/client/hooks/chat/timeline/composer-modes.ts +11 -2
- package/src/client/hooks/chat/timeline/composer-refs.ts +16 -1
- package/src/client/hooks/chat/timeline/index.ts +27 -35
- package/src/client/hooks/chat/timeline/mode-availability.test.ts +51 -0
- package/src/client/hooks/chat/timeline/modes-contract.ts +6 -0
- package/src/client/hooks/chat/timeline/modes.ts +41 -2
- package/src/client/hooks/chat/timeline/new-chat-open.test.ts +86 -0
- package/src/client/hooks/chat/timeline/new-chat-open.ts +23 -5
- package/src/client/hooks/chat/timeline/new-chat.test.ts +32 -4
- package/src/client/hooks/chat/timeline/new-chat.ts +18 -6
- package/src/client/hooks/chat/timeline/prompt-text.test.ts +7 -0
- package/src/client/hooks/chat/timeline/prompt-text.ts +15 -6
- package/src/client/hooks/chat/timeline/rewind-actions.test.ts +51 -1
- package/src/client/hooks/chat/timeline/rewind-actions.ts +23 -1
- package/src/client/hooks/chat/timeline/run-identity.test.ts +52 -0
- package/src/client/hooks/chat/timeline/run-identity.ts +23 -11
- package/src/client/hooks/chat/timeline/send-execute.test.ts +55 -0
- package/src/client/hooks/chat/timeline/send-props.ts +11 -3
- package/src/client/hooks/chat/timeline/send-steer.test.ts +2 -3
- package/src/client/hooks/chat/timeline/send.test-util.ts +3 -2
- package/src/client/hooks/chat/timeline/send.test.ts +2 -3
- package/src/client/hooks/chat/timeline/send.ts +34 -8
- package/src/client/hooks/chat/timeline/session-harness.test.ts +163 -0
- package/src/client/hooks/chat/timeline/session-harness.ts +164 -0
- package/src/client/hooks/chat/timeline/session-load.test-util.ts +6 -2
- package/src/client/hooks/chat/timeline/session-load.test.ts +31 -0
- package/src/client/hooks/chat/timeline/session-load.ts +6 -14
- package/src/client/hooks/chat/timeline/session-shapes.ts +32 -0
- package/src/client/hooks/chat/timeline/spawn-harness.ts +41 -0
- package/src/client/hooks/chat/timeline/timeline-running.ts +55 -0
- package/src/client/hooks/chat/timeline/tui-only-guard.ts +9 -0
- package/src/client/hooks/chat/timeline/undo-confirmation.test.ts +131 -0
- package/src/client/hooks/models/harness-catalog.ts +114 -0
- package/src/client/hooks/models/provider-writes.test.ts +81 -0
- package/src/client/hooks/models/provider-writes.ts +144 -0
- package/src/client/hooks/models/use-harness-versions.test.ts +152 -0
- package/src/client/hooks/models/use-harness-versions.ts +136 -0
- package/src/client/hooks/models/use-harnesses-controller.ts +57 -0
- package/src/client/hooks/models/use-harnesses-signal.test.ts +128 -0
- package/src/client/hooks/models/use-harnesses.test.ts +187 -0
- package/src/client/hooks/models/use-harnesses.ts +215 -0
- package/src/client/hooks/settings/providers/index.ts +1 -3
- package/src/client/hooks/ui/editor-error-toast.ts +10 -3
- package/src/client/hooks/ui/icon-style.ts +28 -0
- package/src/client/hooks/ui/on-click-outside.test.ts +104 -0
- package/src/client/hooks/ui/on-click-outside.ts +14 -2
- package/src/client/hooks/ui/theme.ts +6 -0
- package/src/client/hooks/ui/toast-queue.test.ts +126 -0
- package/src/client/hooks/ui/toasts.ts +132 -27
- package/src/client/hooks/ui/ui-feedback.test.ts +4 -91
- package/src/client/lib/ui/control-plate.test.ts +76 -0
- package/src/client/lib/ui/control-plate.ts +65 -0
- package/src/client/tailwind.css +47 -1
- package/src/server/lib/assets/shell-attributes.server.ts +9 -2
- package/src/server/lib/assets/shell-attributes.test.ts +22 -6
- package/src/server/lib/db/schema.ts +4 -0
- package/src/server/lib/harness/acp/acp-audit.server.ts +107 -0
- package/src/server/lib/harness/acp/acp-goal-driver.server.ts +153 -0
- package/src/server/lib/harness/acp/acp-goal-state.server.ts +136 -0
- package/src/server/lib/harness/acp/acp-goal.server.ts +273 -0
- package/src/server/lib/harness/acp/acp-goal.test.ts +229 -0
- package/src/server/lib/harness/acp/acp-telemetry.server.ts +133 -0
- package/src/server/lib/harness/acp/acp-telemetry.test.ts +85 -0
- package/src/server/lib/harness/acp/acp-todos.server.ts +45 -0
- package/src/server/lib/harness/acp/acp-todos.test.ts +43 -0
- package/src/server/lib/harness/acp/activation.test.ts +81 -0
- package/src/server/lib/harness/acp/activation.ts +72 -0
- package/src/server/lib/harness/acp/calls.ts +97 -0
- package/src/server/lib/harness/acp/client.test.ts +73 -0
- package/src/server/lib/harness/acp/client.ts +339 -0
- package/src/server/lib/harness/acp/commands.test.ts +92 -0
- package/src/server/lib/harness/acp/commands.ts +165 -0
- package/src/server/lib/harness/acp/frames.test.ts +315 -0
- package/src/server/lib/harness/acp/frames.ts +349 -0
- package/src/server/lib/harness/acp/mapper.ts +204 -0
- package/src/server/lib/harness/acp/permissions.test.ts +66 -0
- package/src/server/lib/harness/acp/permissions.ts +155 -0
- package/src/server/lib/harness/acp/prompt.test.ts +130 -0
- package/src/server/lib/harness/acp/prompt.ts +134 -0
- package/src/server/lib/harness/acp/protocol.ts +162 -0
- package/src/server/lib/harness/acp/session-config.test.ts +73 -0
- package/src/server/lib/harness/acp/session-config.ts +148 -0
- package/src/server/lib/harness/acp/session-facts.ts +71 -0
- package/src/server/lib/harness/acp/session-handshake.ts +89 -0
- package/src/server/lib/harness/acp/session-idle.ts +51 -0
- package/src/server/lib/harness/acp/session-notifications.ts +95 -0
- package/src/server/lib/harness/acp/session-observers.test.ts +193 -0
- package/src/server/lib/harness/acp/session-options.ts +33 -0
- package/src/server/lib/harness/acp/session-permissions.test.ts +105 -0
- package/src/server/lib/harness/acp/session-permissions.ts +74 -0
- package/src/server/lib/harness/acp/session-reaper.test.ts +96 -0
- package/src/server/lib/harness/acp/session-turns.ts +95 -0
- package/src/server/lib/harness/acp/session-usage.ts +60 -0
- package/src/server/lib/harness/acp/session-web-state.ts +61 -0
- package/src/server/lib/harness/acp/session.test-util.ts +160 -0
- package/src/server/lib/harness/acp/session.test.ts +233 -0
- package/src/server/lib/harness/acp/session.ts +350 -0
- package/src/server/lib/harness/acp/turn.ts +199 -0
- package/src/server/lib/harness/acp/verbs.ts +87 -0
- package/src/server/lib/harness/auto-probe.server.test.ts +121 -0
- package/src/server/lib/harness/auto-probe.server.ts +178 -0
- package/src/server/lib/harness/capabilities.ts +67 -0
- package/src/server/lib/harness/config-invalidation.test.ts +91 -0
- package/src/server/lib/harness/config.server.test.ts +105 -0
- package/src/server/lib/harness/config.server.ts +98 -0
- package/src/server/lib/harness/enabled.server.test.ts +87 -0
- package/src/server/lib/harness/enabled.server.ts +61 -0
- package/src/server/lib/harness/launch-table.ts +195 -0
- package/src/server/lib/harness/launch.test.ts +220 -0
- package/src/server/lib/harness/launch.ts +216 -0
- package/src/server/lib/harness/probe-cache.server.test.ts +154 -0
- package/src/server/lib/harness/probe-cache.server.ts +177 -0
- package/src/server/lib/harness/provider-entry.ts +212 -0
- package/src/server/lib/harness/provider-file.server.ts +67 -0
- package/src/server/lib/harness/provider-import.test.ts +191 -0
- package/src/server/lib/harness/provider-probe.server.ts +123 -0
- package/src/server/lib/harness/provider-sources.server.test.ts +45 -0
- package/src/server/lib/harness/provider-sources.server.ts +308 -0
- package/src/server/lib/harness/provider-write-error.ts +19 -0
- package/src/server/lib/harness/provider-write.server.test.ts +308 -0
- package/src/server/lib/harness/provider-write.server.ts +339 -0
- package/src/server/lib/harness/provider-zcode.server.test.ts +270 -0
- package/src/server/lib/harness/provider-zcode.server.ts +324 -0
- package/src/server/lib/harness/register.server.ts +36 -0
- package/src/server/lib/harness/registry.ts +58 -0
- package/src/server/lib/harness/schema.server.ts +129 -0
- package/src/server/lib/harness/session-store.server.test.ts +175 -0
- package/src/server/lib/harness/session-store.server.ts +206 -0
- package/src/server/lib/harness/session-title.server.test.ts +109 -0
- package/src/server/lib/harness/session-title.server.ts +70 -0
- package/src/server/lib/harness/session.ts +74 -0
- package/src/server/lib/harness/spawn.server.ts +133 -0
- package/src/server/lib/harness/update-state.server.ts +185 -0
- package/src/server/lib/lifecycle/after-listen.ts +7 -0
- package/src/server/lib/models/provider-items.server.ts +1 -1
- package/src/server/lib/models/registry-refresh.server.test.ts +87 -0
- package/src/server/lib/models/registry-refresh.server.ts +98 -0
- package/src/server/lib/omp/config/models-config.ts +4 -0
- package/src/server/lib/omp/core/cli.ts +13 -0
- package/src/server/lib/omp/core/host-resolution.test.ts +6 -3
- package/src/server/lib/omp/rpc/child-config.ts +5 -4
- package/src/server/lib/omp/rpc/constants.test.ts +2 -1
- package/src/server/lib/omp/rpc/event-fanout.ts +9 -0
- package/src/server/lib/omp/rpc/forked-resume.test.ts +14 -3
- package/src/server/lib/omp/rpc/rpc-primitives.test.ts +11 -0
- package/src/server/lib/omp/rpc/session-registration.ts +7 -2
- package/src/server/lib/omp/rpc/session-registry.test.ts +2 -1
- package/src/server/lib/omp/rpc/session-registry.ts +74 -5
- package/src/server/lib/omp/session/acp-rows.server.ts +79 -0
- package/src/server/lib/omp/session/delete-flow.server.ts +15 -8
- package/src/server/lib/omp/session/delete.server.ts +12 -0
- package/src/server/lib/omp/session/sidebar-data.harness.test.ts +247 -0
- package/src/server/lib/omp/session/sidebar-data.server.ts +56 -3
- package/src/server/lib/queue/delivery.server.test.ts +4 -2
- package/src/server/lib/queue/payload.test.ts +67 -0
- package/src/server/lib/queue/payload.ts +9 -3
- package/src/server/lib/realtime/signals.server.test.ts +99 -0
- package/src/server/lib/realtime/signals.server.ts +25 -5
- package/src/server/lib/realtime/topics/session-data.server.ts +29 -0
- package/src/server/lib/realtime/topics/session.server.ts +3 -3
- package/src/server/routes/agent/command-resume.test.ts +77 -0
- package/src/server/routes/agent/command.test.ts +243 -2
- package/src/server/routes/agent/command.ts +78 -15
- package/src/server/routes/agent/harness-command.ts +133 -0
- package/src/server/routes/agent/new.ts +63 -1
- package/src/server/routes/chat/rewind.test.ts +147 -0
- package/src/server/routes/chat/rewind.ts +29 -7
- package/src/server/routes/chat/session.test.ts +240 -0
- package/src/server/routes/chat/session.ts +96 -4
- package/src/server/routes/harness/add-provider.test.ts +233 -0
- package/src/server/routes/harness/import-action.ts +272 -0
- package/src/server/routes/harness/import.test.ts +196 -0
- package/src/server/routes/harness/index.ts +13 -0
- package/src/server/routes/harness/root.ts +280 -0
- package/src/server/routes/harness/toggle.test.ts +127 -0
- package/src/server/routes/harness/update.ts +259 -0
- package/src/server/routes/harness/versions.test.ts +148 -0
- package/src/server/routes/harness/versions.ts +105 -0
- package/src/server/routes/index.ts +2 -0
- package/src/server/routes/sessions/delete-acp.test.ts +227 -0
- package/src/server/routes/sessions/queue.ts +7 -2
- package/src/server/routes/sessions/routes-queue.test.ts +52 -0
- package/src/server/routes/sessions/routes.test.ts +47 -13
- package/src/server/routes/sessions/session.ts +35 -0
- package/src/server/routes/settings/commands-harness.test.ts +92 -0
- package/src/server/routes/settings/commands.ts +26 -0
- package/src/server/routes/settings/model-override.ts +5 -2
- package/src/server/routes/settings/provider-entry.ts +2 -2
- package/src/server/routes/settings/provider-model.ts +2 -2
- package/src/server/routes/settings/provider-models.ts +2 -2
- package/src/server/routes/settings/provider-refresh.ts +6 -4
- package/src/server/routes/settings/providers.ts +3 -1
- package/src/server/routes/settings/settings-config-routes.test.ts +10 -2
- package/src/server/routes/settings/skills.ts +12 -0
- package/src/shared/lib/chat/ask-form/fields.ts +76 -0
- package/src/shared/lib/chat/ask-form/index.ts +323 -0
- package/src/shared/lib/chat/ask-form/tokens.ts +199 -0
- package/src/shared/lib/chat/ask-form/types.ts +43 -0
- package/src/shared/lib/chat/ask-form.test.ts +137 -0
- package/src/shared/lib/chat/ask-questions.test.ts +65 -1
- package/src/shared/lib/chat/ask-questions.ts +51 -145
- package/src/shared/lib/chat/ask-results.ts +198 -0
- package/src/shared/lib/chat/composer/client.ts +20 -8
- package/src/shared/lib/chat/context/usage.test.ts +8 -4
- package/src/shared/lib/chat/context/usage.ts +17 -3
- package/src/shared/lib/chat/omp/abort.test.ts +61 -0
- package/src/shared/lib/chat/omp/abort.ts +8 -2
- package/src/shared/lib/chat/omp/tool-frames.test.ts +23 -0
- package/src/shared/lib/chat/omp/tool-frames.ts +12 -2
- package/src/shared/lib/chat/timeline/omp-callbacks.ts +13 -1
- package/src/shared/lib/chat/timeline/prompt-error.test.ts +146 -0
- package/src/shared/lib/chat/timeline/prompt-error.ts +88 -0
- package/src/shared/lib/chat/tool/summary-wait.test.ts +18 -8
- package/src/shared/lib/chat/tool/wait-facts.ts +14 -8
- package/src/shared/lib/harness/brand-color.test.ts +66 -0
- package/src/shared/lib/harness/brand-color.ts +96 -0
- package/src/shared/lib/harness/catalog.test.ts +88 -0
- package/src/shared/lib/harness/catalog.ts +169 -0
- package/src/shared/lib/harness/config-fields.test.ts +139 -0
- package/src/shared/lib/harness/config-fields.ts +168 -0
- package/src/shared/lib/harness/config.test.ts +153 -0
- package/src/shared/lib/harness/config.ts +206 -0
- package/src/shared/lib/harness/dialects.test.ts +140 -0
- package/src/shared/lib/harness/dialects.ts +249 -0
- package/src/shared/lib/harness/enabled.test.ts +79 -0
- package/src/shared/lib/harness/enabled.ts +72 -0
- package/src/shared/lib/harness/menu.test.ts +94 -0
- package/src/shared/lib/harness/menu.ts +88 -0
- package/src/shared/lib/harness/provider-facts.test.ts +199 -0
- package/src/shared/lib/harness/provider-facts.ts +349 -0
- package/src/shared/lib/harness/provider-slug.ts +46 -0
- package/src/shared/lib/harness/providers.ts +175 -0
- package/src/shared/lib/harness/rewind.ts +24 -0
- package/src/shared/lib/harness/status.test.ts +158 -0
- package/src/shared/lib/harness/status.ts +112 -0
- package/src/shared/lib/harness/update-plan.test.ts +163 -0
- package/src/shared/lib/harness/update-plan.ts +140 -0
- package/src/shared/lib/harness/updates.test.ts +106 -0
- package/src/shared/lib/harness/updates.ts +177 -0
- package/src/shared/lib/icons/icon-paint-authority.test.ts +16 -4
- package/src/shared/lib/icons/icon-paint-authority.ts +57 -12
- package/src/shared/lib/icons/icon-paint-bucket.test.ts +84 -0
- package/src/shared/lib/icons/icon-paint-css.test.ts +23 -25
- package/src/shared/lib/icons/icon-paint-css.ts +69 -55
- package/src/shared/lib/icons/icon-paint-harness.test.ts +73 -0
- package/src/shared/lib/icons/icon-paint-harness.ts +75 -0
- package/src/shared/lib/icons/icon-paint-ink.ts +108 -0
- package/src/shared/lib/icons/icon-paint-panel.ts +19 -4
- package/src/shared/lib/icons/icon-paint-weight.ts +21 -2
- package/src/shared/lib/icons/icon-tone.ts +118 -21
- package/src/shared/lib/icons/tint-hues.generated.ts +100 -284
- package/src/shared/lib/icons/tint-tones.test.ts +79 -25
- package/src/shared/lib/icons/tint.ts +66 -6
- package/src/shared/lib/models/client.ts +10 -1
- package/src/shared/lib/models/provider/vendors.ts +72 -0
- package/src/shared/lib/omp/config/schema.test.ts +36 -0
- package/src/shared/lib/omp/dialog-methods.ts +4 -3
- package/src/shared/lib/omp/session/messages-map-trace.test.ts +42 -0
- package/src/shared/lib/omp/session/messages-map.ts +6 -1
- package/src/shared/lib/omp/session/parse-message-blocks-toolcall.test.ts +8 -0
- package/src/shared/lib/omp/session/parse-message-blocks.ts +6 -1
- package/src/shared/lib/omp/session/shell-trace.test.ts +69 -0
- package/src/shared/lib/omp/session/shell-trace.ts +63 -0
- package/src/shared/lib/omp/session/sidebar.ts +37 -10
- package/src/shared/lib/omp/session/wait-idle.test.ts +47 -0
- package/src/shared/lib/omp/session/wait-idle.ts +93 -0
- package/src/shared/lib/omp/session/wait.test.ts +34 -33
- package/src/shared/lib/omp/session/wait.ts +25 -39
- package/src/shared/lib/settings/sections.ts +24 -0
- package/src/shared/lib/theme/css.ts +2 -0
- package/src/shared/lib/theme/ink-scale.ts +21 -1
- package/src/shared/lib/theme/theme.test.ts +25 -9
- package/src/shared/lib/ui/safe-area.test.ts +28 -0
- package/src/shared/lib/ui/safe-area.ts +42 -0
- package/src/shared/lib/ui/toast-duration.test.ts +74 -0
- package/src/shared/lib/ui/toast-duration.ts +70 -0
- package/src/shared/types/harness-version.ts +59 -0
- package/src/shared/types/harness.ts +201 -0
- package/src/shared/types/index.ts +2 -0
- package/src/shared/types/omp/agent.ts +13 -0
- package/src/shared/types/settings/state.ts +10 -1
- package/src/shared/types/workspace.ts +10 -0
- package/src/test-support/env.ts +38 -0
- package/src/test-support/file-explorer-render.test-util.ts +37 -0
- package/src/test-support/file-explorer.test-util.ts +20 -18
- package/src/test-support/harness-table.test-util.ts +108 -0
- package/dist/client/static/js/index-7ppta1pb.css +0 -1
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Where the model picker renders, and the guard that keeps it usable there.
|
|
8
|
+
*
|
|
9
|
+
* Two placements, one content tree:
|
|
10
|
+
*
|
|
11
|
+
* - a desktop keeps the POPOVER, anchored above the trigger, so a picker never
|
|
12
|
+
* covers a 1440x900 workspace to choose a model;
|
|
13
|
+
* - a phone gets the WHOLE SCREEN, because the composer sits at the bottom of a
|
|
14
|
+
* 390px viewport — measured, the 86dvh sheet that came first left 344px of
|
|
15
|
+
* dead canvas above it and showed ~7 rows where the full screen shows 15.
|
|
16
|
+
*
|
|
17
|
+
* The load-bearing half is the click-outside guard. A portalled overlay is
|
|
18
|
+
* outside `containerRef` BY CONSTRUCTION, so an armed listener closes the picker
|
|
19
|
+
* on the `mousedown` that was meant to choose a row: measured in a real browser
|
|
20
|
+
* as "tap a model on a phone and nothing happens". The guard is therefore
|
|
21
|
+
* DISABLED in the full-screen placement, and these cases pin both directions —
|
|
22
|
+
* that it is off there, and that it still works in the popover.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
26
|
+
import { h, render } from 'preact';
|
|
27
|
+
import { act } from 'preact/test-utils';
|
|
28
|
+
import { Window } from 'happy-dom';
|
|
29
|
+
|
|
30
|
+
import { ModelFullscreen } from '@/client/components/workspace/model-dropdown/Fullscreen';
|
|
31
|
+
import { useFullscreenPicker } from '@/client/components/workspace/model-dropdown/fullscreen-picker';
|
|
32
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
33
|
+
|
|
34
|
+
let container: HTMLElement;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* `useKeyboardInset` observes the frame's border box, and happy-dom ships no
|
|
38
|
+
* `ResizeObserver`. The no-op below keeps the hook mounted without pretending to
|
|
39
|
+
* observe anything: this file asserts the FRAME (where it portals, what it
|
|
40
|
+
* draws), never the lift, which `keyboard-inset`'s own suite covers as pure
|
|
41
|
+
* arithmetic.
|
|
42
|
+
*/
|
|
43
|
+
class NoopResizeObserver {
|
|
44
|
+
observe(): void {}
|
|
45
|
+
unobserve(): void {}
|
|
46
|
+
disconnect(): void {}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
const win = new Window({ url: 'http://localhost' });
|
|
51
|
+
installDomGlobals(win);
|
|
52
|
+
(globalThis as unknown as Record<string, unknown>).ResizeObserver ??= NoopResizeObserver;
|
|
53
|
+
container = document.createElement('div');
|
|
54
|
+
document.body.appendChild(container);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
afterEach(() => {
|
|
58
|
+
render(null, container);
|
|
59
|
+
container.remove();
|
|
60
|
+
restoreDomGlobals();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
/** The placement decision, read through a throwaway component. */
|
|
64
|
+
function placement(isMobile: boolean | undefined): boolean {
|
|
65
|
+
let value = false;
|
|
66
|
+
function Probe() {
|
|
67
|
+
value = useFullscreenPicker(isMobile);
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
act(() => render(h(Probe, {}), container));
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
describe('model picker placement', () => {
|
|
75
|
+
test("the shell's verdict decides it, in both directions", () => {
|
|
76
|
+
// The shell already answered this from the user agent, the pointer and a
|
|
77
|
+
// landscape-phone height test. A picker that re-derived a different answer
|
|
78
|
+
// would paint a phone frame inside a desktop shell.
|
|
79
|
+
expect(placement(true)).toBe(true);
|
|
80
|
+
expect(placement(false)).toBe(false);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('with no verdict it reads the pointer, not a pixel breakpoint', () => {
|
|
84
|
+
// happy-dom's `matchMedia` answers false for everything, so this asserts the
|
|
85
|
+
// FALLBACK path is taken without throwing — the hook must not depend on the
|
|
86
|
+
// media query existing (a jsdom-style window has no `addEventListener` on it).
|
|
87
|
+
expect(placement(undefined)).toBe(false);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe('the full-screen frame', () => {
|
|
92
|
+
test('it portals to <body>, not into the composer', () => {
|
|
93
|
+
// The composer card can become a containing block for `position: fixed`
|
|
94
|
+
// through `backdrop-filter`/`transform`/`contain: layout`; rendered in place,
|
|
95
|
+
// `inset-0` would size the overlay to the CARD (measured: 710x164 at the
|
|
96
|
+
// card's box instead of 1440x900 at the viewport).
|
|
97
|
+
const host = document.createElement('div');
|
|
98
|
+
host.setAttribute('data-composer-style', '');
|
|
99
|
+
document.body.appendChild(host);
|
|
100
|
+
act(() => render(h(ModelFullscreen, { open: true, onClose: () => {}, children: 'rows' }), host));
|
|
101
|
+
|
|
102
|
+
const dialog = document.querySelector('[role="dialog"][aria-label="Select model"]');
|
|
103
|
+
expect(dialog).not.toBeNull();
|
|
104
|
+
expect(dialog?.closest('[data-composer-style]')).toBeNull();
|
|
105
|
+
expect(dialog?.parentElement).toBe(document.body);
|
|
106
|
+
host.remove();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test('closed draws nothing at all', () => {
|
|
110
|
+
act(() => render(h(ModelFullscreen, { open: false, onClose: () => {}, children: 'rows' }), container));
|
|
111
|
+
expect(document.querySelector('[role="dialog"]')).toBeNull();
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('the content is the picker’s own, and the close control dismisses it', () => {
|
|
115
|
+
// One tree, two frames: a full-screen view that re-implemented the list
|
|
116
|
+
// would drift from the popover (a new section landing in only one of them).
|
|
117
|
+
const children = h('div', { 'data-testid': 'picker-content' }, 'rows');
|
|
118
|
+
let closed = 0;
|
|
119
|
+
act(() => render(h(ModelFullscreen, { open: true, onClose: () => { closed += 1; }, children }), container));
|
|
120
|
+
|
|
121
|
+
expect(document.querySelector('[data-testid="picker-content"]')?.textContent).toBe('rows');
|
|
122
|
+
const close = document.querySelector<HTMLButtonElement>('button[aria-label="Close"]');
|
|
123
|
+
expect(close).not.toBeNull();
|
|
124
|
+
act(() => close?.click());
|
|
125
|
+
expect(closed).toBe(1);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The picker's SIZE contract, as arithmetic rather than a screenshot.
|
|
8
|
+
*
|
|
9
|
+
* Three measured failures are pinned here, each found in a real browser:
|
|
10
|
+
*
|
|
11
|
+
* - a `w-84 sm:w-96` constant (336/384px) put a 384px popover inside a 320px
|
|
12
|
+
* chat panel, hanging 64px past the composer's edge — and wider than a 390px
|
|
13
|
+
* phone screen;
|
|
14
|
+
* - a `max-h-[460px]` constant put the harness tab strip at y=22 under a 40px
|
|
15
|
+
* titlebar, so `elementFromPoint` on the first tab answered `HEADER`: the
|
|
16
|
+
* control was in the DOM and unreachable by pointer;
|
|
17
|
+
* - budgeting the width from the PANEL's width let a 437px card hang 29px past a
|
|
18
|
+
* 421px composer, because the card starts at the TRIGGER (13px inside the
|
|
19
|
+
* panel) and that overhang is space it cannot use.
|
|
20
|
+
*
|
|
21
|
+
* The height then went to 620 and came back to 460: a card that tall reads as a
|
|
22
|
+
* panel over the conversation rather than a menu beside the composer.
|
|
23
|
+
*
|
|
24
|
+
* The arithmetic lives in `popover-metrics.ts` so the rule can be asserted
|
|
25
|
+
* without a layout engine; the component only applies it.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { describe, expect, test } from 'bun:test';
|
|
29
|
+
import { popoverMetrics } from '@/client/components/workspace/model-dropdown/popover-metrics';
|
|
30
|
+
|
|
31
|
+
/** A roomy desktop: the trigger starts at the composer's left padding. */
|
|
32
|
+
const DESKTOP = {
|
|
33
|
+
triggerTop: 700,
|
|
34
|
+
anchorLeft: 328,
|
|
35
|
+
containerRight: 1000,
|
|
36
|
+
viewportWidth: 1440,
|
|
37
|
+
viewportTop: 0,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
describe('popover metrics: width', () => {
|
|
41
|
+
test('capped at 512 on a wide desktop so the list does not sprawl', () => {
|
|
42
|
+
expect(popoverMetrics(DESKTOP).width).toBe(512);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('never past the composer it belongs to', () => {
|
|
46
|
+
// A 421px panel whose trigger starts 13px inside it: the card may use
|
|
47
|
+
// 421 - 13 - 8 = 400px, not the panel's full width. The previous form used
|
|
48
|
+
// the width, produced 437, and hung 29px past the edge.
|
|
49
|
+
const { width } = popoverMetrics({
|
|
50
|
+
triggerTop: 700, anchorLeft: 328, containerRight: 736, viewportWidth: 1024, viewportTop: 0,
|
|
51
|
+
});
|
|
52
|
+
expect(width).toBe(400);
|
|
53
|
+
expect(328 + width).toBeLessThanOrEqual(736 - 8 + 1);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('a shrink-wrapped trigger does not shrink the card', () => {
|
|
57
|
+
// The budget names the PANEL edge, never the chip's own box: a 98px chip
|
|
58
|
+
// inside a 712px composer still gets the full cap.
|
|
59
|
+
const wide = popoverMetrics({ triggerTop: 700, anchorLeft: 328, containerRight: 1040, viewportWidth: 1440, viewportTop: 0 });
|
|
60
|
+
expect(wide.width).toBe(512);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('narrower than the screen on a phone', () => {
|
|
64
|
+
const { width } = popoverMetrics({
|
|
65
|
+
triggerTop: 600, anchorLeft: 12, containerRight: 378, viewportWidth: 390, viewportTop: 0,
|
|
66
|
+
});
|
|
67
|
+
expect(width).toBeLessThanOrEqual(390 - 12 - 8);
|
|
68
|
+
expect(width).toBeGreaterThanOrEqual(240);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('the viewport wins over a container wider than the screen', () => {
|
|
72
|
+
// A zoomed phone can report a container wider than the visible area.
|
|
73
|
+
const { width } = popoverMetrics({
|
|
74
|
+
triggerTop: 600, anchorLeft: 20, containerRight: 2000, viewportWidth: 390, viewportTop: 0,
|
|
75
|
+
});
|
|
76
|
+
expect(width).toBe(362);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('popover metrics: height', () => {
|
|
81
|
+
test('clears the titlebar: the card never starts under the chrome', () => {
|
|
82
|
+
// A trigger 100px from the top on a short window is the case that broke: a
|
|
83
|
+
// 180px floor pushed the card's top edge under the 40px titlebar and made
|
|
84
|
+
// its first row unclickable. The viewport wins.
|
|
85
|
+
const { height } = popoverMetrics({ ...DESKTOP, triggerTop: 100 });
|
|
86
|
+
expect(height).toBe(100 - 48);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('uses the room above the trigger when it is below the cap', () => {
|
|
90
|
+
// 300 - 48 = 252 available, so the whole band is used.
|
|
91
|
+
const { height } = popoverMetrics({ ...DESKTOP, triggerTop: 300 });
|
|
92
|
+
expect(height).toBe(252);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('the cap is 460 and it is a cap, not a size', () => {
|
|
96
|
+
expect(popoverMetrics({ ...DESKTOP, triggerTop: 1200 }).height).toBe(460);
|
|
97
|
+
// A short window still wins: 400 - 48 = 352.
|
|
98
|
+
expect(popoverMetrics({ ...DESKTOP, triggerTop: 400 }).height).toBe(352);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test('the phone keyboard shrinks the budget instead of hiding the card', () => {
|
|
102
|
+
const phone = { triggerTop: 700, anchorLeft: 12, containerRight: 378, viewportWidth: 390 };
|
|
103
|
+
const open = popoverMetrics({ ...phone, viewportTop: 0 });
|
|
104
|
+
const keyboarded = popoverMetrics({ ...phone, viewportTop: 260 });
|
|
105
|
+
expect(keyboarded.height).toBeLessThan(open.height);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* How big the model picker may be.
|
|
8
|
+
*
|
|
9
|
+
* Pure arithmetic, in its own module, because the rule is a CONSTRAINT rather
|
|
10
|
+
* than a style: the popover hangs upward from a trigger inside the composer, so
|
|
11
|
+
* its height is bounded by the space above that trigger and its width by the
|
|
12
|
+
* space to the right of that trigger. Expressing either as a constant failed in a
|
|
13
|
+
* real browser (a 384px card in a 320px panel; a 460px card whose top row sat
|
|
14
|
+
* under the 40px titlebar and could not be clicked). A pure function lets both be
|
|
15
|
+
* asserted.
|
|
16
|
+
*
|
|
17
|
+
* Both limits are measured from the ANCHOR — the trigger's left edge, which is
|
|
18
|
+
* where the card starts. Measuring the panel's WIDTH instead let a 437px card
|
|
19
|
+
* hang 29px past a 421px composer: the trigger sits 13px inside the panel (its
|
|
20
|
+
* padding and the toolbar rails before it), and that overhang is space the card
|
|
21
|
+
* cannot use. Measured at 1024x700.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/** Window chrome the popover must clear: the 40px titlebar plus 8px of air. */
|
|
25
|
+
export const CHROME_RESERVE = 48;
|
|
26
|
+
|
|
27
|
+
/** Air kept between the card's right edge and the panel/viewport edge. */
|
|
28
|
+
const GUTTER = 8;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Widest the picker ever gets, on a roomy desktop.
|
|
32
|
+
*
|
|
33
|
+
* 512, up from 384: at 384 a model row cut its own name. The row carries two
|
|
34
|
+
* marks, the model name, a context figure, a thinking chip and a favourite star,
|
|
35
|
+
* and `Agnes-2-5-Flash - Free` measured `scrollWidth 139 / clientWidth 0` once
|
|
36
|
+
* the trailing plates took their share.
|
|
37
|
+
*
|
|
38
|
+
* Exported because the About card sizes itself to this same cap: the console has
|
|
39
|
+
* one width class for its floating cards, and a second number there would drift.
|
|
40
|
+
*/
|
|
41
|
+
export const MAX_WIDTH = 512;
|
|
42
|
+
/** Narrowest it is allowed to get before it stops being usable. */
|
|
43
|
+
const MIN_WIDTH = 240;
|
|
44
|
+
/**
|
|
45
|
+
* Tallest it ever gets, on a roomy desktop.
|
|
46
|
+
*
|
|
47
|
+
* Back to 460 after trying 620: at 620 the card stood ~14 rows tall on a
|
|
48
|
+
* 1200px-tall window and read as a panel covering the conversation, not a menu
|
|
49
|
+
* over it. Only the WIDTH was the reported problem, and 512 is what fixed it —
|
|
50
|
+
* a taller card was not a request. Still a CAP, never a size: on a short window
|
|
51
|
+
* `roomAbove` wins and the card shrinks.
|
|
52
|
+
*/
|
|
53
|
+
const MAX_HEIGHT = 460;
|
|
54
|
+
/**
|
|
55
|
+
* Preferred height, honoured only while the space above the trigger allows it.
|
|
56
|
+
*
|
|
57
|
+
* A hard floor is what put the card under the titlebar: with 52px of room, a
|
|
58
|
+
* 180px minimum pushed the top edge behind the chrome and made the first row
|
|
59
|
+
* unclickable. A short card with an internally scrolling list is worse-looking
|
|
60
|
+
* and always usable, so the viewport wins.
|
|
61
|
+
*/
|
|
62
|
+
const MIN_HEIGHT = 180;
|
|
63
|
+
|
|
64
|
+
export interface PopoverInput {
|
|
65
|
+
/** Top edge of the trigger, in viewport coordinates. */
|
|
66
|
+
triggerTop: number;
|
|
67
|
+
/**
|
|
68
|
+
* Left edge of the trigger, in viewport coordinates — the card's anchor, and
|
|
69
|
+
* the only sane origin for a card that grows rightward from it.
|
|
70
|
+
*/
|
|
71
|
+
anchorLeft: number;
|
|
72
|
+
/**
|
|
73
|
+
* Right edge of the composer CARD the trigger sits in, in viewport
|
|
74
|
+
* coordinates.
|
|
75
|
+
*
|
|
76
|
+
* The PANEL, not the trigger: the trigger is a chip that shrink-wraps its
|
|
77
|
+
* label (measured 259px inside a 712px composer), so budgeting from it capped
|
|
78
|
+
* the card at 275px and truncated every model name. And not the panel's WIDTH
|
|
79
|
+
* either, which is what the previous form took — a width says nothing about
|
|
80
|
+
* how much of it is to the RIGHT of the anchor.
|
|
81
|
+
*/
|
|
82
|
+
containerRight: number;
|
|
83
|
+
/** Visible viewport width (`visualViewport.width` on a phone). */
|
|
84
|
+
viewportWidth: number;
|
|
85
|
+
/** Visible viewport offset, non-zero while a phone keyboard is up. */
|
|
86
|
+
viewportTop: number;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface PopoverSize {
|
|
90
|
+
width: number;
|
|
91
|
+
height: number;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The size to give the popover.
|
|
96
|
+
*
|
|
97
|
+
* Width: the space from the anchor to the nearer of the composer's right edge
|
|
98
|
+
* and the viewport's, less the gutter; floored at `MIN_WIDTH` and capped at
|
|
99
|
+
* `MAX_WIDTH`.
|
|
100
|
+
*
|
|
101
|
+
* Height: the space between the trigger and the chrome above it, capped at
|
|
102
|
+
* `MAX_HEIGHT`, floored at `MIN_HEIGHT`.
|
|
103
|
+
*/
|
|
104
|
+
export function popoverMetrics({
|
|
105
|
+
triggerTop,
|
|
106
|
+
anchorLeft,
|
|
107
|
+
containerRight,
|
|
108
|
+
viewportWidth,
|
|
109
|
+
viewportTop,
|
|
110
|
+
}: PopoverInput): PopoverSize {
|
|
111
|
+
const roomLeft = Math.min(containerRight, viewportWidth) - anchorLeft - GUTTER;
|
|
112
|
+
const roomAbove = triggerTop - viewportTop - CHROME_RESERVE;
|
|
113
|
+
return {
|
|
114
|
+
width: Math.max(MIN_WIDTH, Math.min(MAX_WIDTH, roomLeft)),
|
|
115
|
+
// `MIN_HEIGHT` is a PREFERENCE, not a clamp, for the reason stated on it.
|
|
116
|
+
height: roomAbove >= MIN_HEIGHT ? Math.min(MAX_HEIGHT, roomAbove) : Math.max(0, roomAbove),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The three things a model ROW can do besides being picked: star it, cycle its
|
|
8
|
+
* thinking level, mark it as the command agent.
|
|
9
|
+
*
|
|
10
|
+
* Extracted from the dropdown so that component stays a shell (state + layout)
|
|
11
|
+
* and these rules live in one place. Each one is a read-modify-write against the
|
|
12
|
+
* PREFERENCE STORE rather than against the row, because the star and the level
|
|
13
|
+
* are derived state: patching a row alone is undone by the next
|
|
14
|
+
* `applyModelPreferences`, which re-stamps every row from the store.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { TargetedMouseEvent } from 'preact';
|
|
18
|
+
import type { AIModelOption, ModelPreferences } from '@/shared/types';
|
|
19
|
+
import type { ModelCatalogState } from '@/client/components/workspace/model-dropdown/use-catalog';
|
|
20
|
+
import { readModelPreferences, toggleFavoriteKey } from '@/shared/lib/models/preferences';
|
|
21
|
+
import { modelKey } from '@/shared/lib/models/identity';
|
|
22
|
+
|
|
23
|
+
export interface RowMutationDeps {
|
|
24
|
+
preferences: ModelPreferences;
|
|
25
|
+
applyPreferences: ModelCatalogState['applyPreferences'];
|
|
26
|
+
setModels: ModelCatalogState['setModels'];
|
|
27
|
+
selectedModel: AIModelOption | null;
|
|
28
|
+
setSelectedModel: (model: AIModelOption) => void;
|
|
29
|
+
selectedModelKey: string;
|
|
30
|
+
onSelectModel?: (model: AIModelOption) => void;
|
|
31
|
+
onThinkingLevelChange?: (level: string) => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface RowMutations {
|
|
35
|
+
toggleFavorite: (model: AIModelOption, event: TargetedMouseEvent<HTMLElement>) => void;
|
|
36
|
+
cycleThinking: (model: AIModelOption) => void;
|
|
37
|
+
toggleAgentCmd: (model: AIModelOption) => void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function useRowMutations(deps: RowMutationDeps): RowMutations {
|
|
41
|
+
const {
|
|
42
|
+
preferences, applyPreferences, setModels, selectedModel, setSelectedModel,
|
|
43
|
+
selectedModelKey, onSelectModel, onThinkingLevelChange,
|
|
44
|
+
} = deps;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Flip one row's star. The optimistic stamp and the rollback BOTH go through
|
|
48
|
+
* the preference pair, and the server's answer is the authority: it also drops
|
|
49
|
+
* keys the registry no longer serves.
|
|
50
|
+
*/
|
|
51
|
+
const toggleFavorite = (model: AIModelOption, event: TargetedMouseEvent<HTMLElement>) => {
|
|
52
|
+
event.stopPropagation();
|
|
53
|
+
const key = modelKey(model);
|
|
54
|
+
const previous = preferences;
|
|
55
|
+
applyPreferences({ ...previous, favorites: toggleFavoriteKey(previous.favorites, key) });
|
|
56
|
+
void (async () => {
|
|
57
|
+
try {
|
|
58
|
+
const response = await fetch('/api/models', {
|
|
59
|
+
method: 'POST',
|
|
60
|
+
headers: { 'Content-Type': 'application/json' },
|
|
61
|
+
body: JSON.stringify({ actionType: 'toggleFavorite', provider: model.provider, modelId: model.id }),
|
|
62
|
+
});
|
|
63
|
+
if (!response.ok) throw new Error(`toggleFavorite failed: ${response.status}`);
|
|
64
|
+
const data = await response.json() as { modelPreferences?: unknown };
|
|
65
|
+
// An absent/malformed payload keeps the optimistic list rather than
|
|
66
|
+
// blanking the rail.
|
|
67
|
+
if (data.modelPreferences) applyPreferences(readModelPreferences(data.modelPreferences));
|
|
68
|
+
} catch {
|
|
69
|
+
// A failed write must not leave the star lit: the next reload would show
|
|
70
|
+
// it unlit anyway, so the rollback keeps the panel honest now.
|
|
71
|
+
applyPreferences(previous);
|
|
72
|
+
}
|
|
73
|
+
})();
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const cycleThinking = (model: AIModelOption) => {
|
|
77
|
+
const ladder = model.thinkingLevels ?? [];
|
|
78
|
+
if (ladder.length === 0) return;
|
|
79
|
+
const current = model.thinkingLevel ?? ladder[0];
|
|
80
|
+
const next = ladder[(ladder.indexOf(current) + 1) % ladder.length];
|
|
81
|
+
const key = modelKey(model);
|
|
82
|
+
setModels((prev) => prev.map((entry) => (modelKey(entry) === key ? { ...entry, thinkingLevel: next } : entry)));
|
|
83
|
+
// Only the ACTIVE model's preset may reach the live session: cycling another
|
|
84
|
+
// provider's row must not push its level onto this chat.
|
|
85
|
+
if (selectedModelKey === key && selectedModel) {
|
|
86
|
+
const nextSelected = { ...selectedModel, thinkingLevel: next };
|
|
87
|
+
setSelectedModel(nextSelected);
|
|
88
|
+
onSelectModel?.(nextSelected);
|
|
89
|
+
onThinkingLevelChange?.(next);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const toggleAgentCmd = (model: AIModelOption) => {
|
|
94
|
+
const next = !model.isCmdAgent;
|
|
95
|
+
const key = modelKey(model);
|
|
96
|
+
setModels((prev) => prev.map((entry) => (modelKey(entry) === key ? { ...entry, isCmdAgent: next } : entry)));
|
|
97
|
+
if (selectedModelKey === key && selectedModel) setSelectedModel({ ...selectedModel, isCmdAgent: next });
|
|
98
|
+
void fetch('/api/models', {
|
|
99
|
+
method: 'POST',
|
|
100
|
+
headers: { 'Content-Type': 'application/json' },
|
|
101
|
+
body: JSON.stringify({ actionType: 'toggleCmd', provider: model.provider, modelId: model.id }),
|
|
102
|
+
}).catch(() => {});
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return { toggleFavorite, cycleThinking, toggleAgentCmd };
|
|
106
|
+
}
|
|
@@ -31,6 +31,7 @@ import { h, render } from 'preact';
|
|
|
31
31
|
import { act } from 'preact/test-utils';
|
|
32
32
|
import { ModelDropdown } from '@/client/components/workspace/model-dropdown/index';
|
|
33
33
|
import type { AIModelOption } from '@/shared/types';
|
|
34
|
+
import { invalidateModelsCache } from '@/shared/lib/models/client';
|
|
34
35
|
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
35
36
|
import { restoreRealtime, silenceRealtime } from '@/test-support/silent-socket';
|
|
36
37
|
|
|
@@ -44,6 +45,14 @@ let container: HTMLElement;
|
|
|
44
45
|
|
|
45
46
|
beforeEach(() => {
|
|
46
47
|
installDomGlobals(new Window());
|
|
48
|
+
// `/api/models` is cached at MODULE level for a minute, so a file that ran
|
|
49
|
+
// earlier in the same `bun test` process leaves its own answer in place and
|
|
50
|
+
// this suite's fetch stub is never consulted — the trigger then draws
|
|
51
|
+
// initials from a response with no `providerIconUrl`. Measured on the Ubuntu
|
|
52
|
+
// gate as `Received: null` in the catalog-fallback case alone, while a
|
|
53
|
+
// single-file run passed every time. The same call opens the other suites
|
|
54
|
+
// that read this endpoint.
|
|
55
|
+
invalidateModelsCache();
|
|
47
56
|
// The picker reads the `models` topic on mount, and this window has no origin
|
|
48
57
|
// (`about:blank`), so a real dial would target `ws:///api/realtime/ws` and
|
|
49
58
|
// fail asynchronously — after this suite has restored the globals, which
|
|
@@ -146,8 +155,19 @@ describe('trigger mark for a provider whose own icon was fetched', () => {
|
|
|
146
155
|
act(() => {
|
|
147
156
|
render(h(ModelDropdown, { selectedModel: { id: MODEL.id, name: MODEL.name, provider: MODEL.provider } }), container);
|
|
148
157
|
});
|
|
149
|
-
|
|
150
|
-
|
|
158
|
+
// Drive the catalog fetch to completion by FLUSHING, not by waiting. The
|
|
159
|
+
// trigger starts with initials and swaps in the logo once the fetch's
|
|
160
|
+
// promise chain settles, and that chain is microtasks only — the stub
|
|
161
|
+
// answers an already-resolved `Response`. A fixed sleep was a guess about
|
|
162
|
+
// one round trip plus a re-render, measured on the Ubuntu gate as
|
|
163
|
+
// `Received: null` while the same file passed locally eight runs running.
|
|
164
|
+
const findImage = (): HTMLImageElement | null => container.querySelector('button[title] img');
|
|
165
|
+
for (let i = 0; i < 50 && !findImage(); i += 1) {
|
|
166
|
+
await act(async () => {
|
|
167
|
+
for (let tick = 0; tick < 8; tick += 1) await Promise.resolve();
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
const image = findImage();
|
|
151
171
|
expect(image).not.toBeNull();
|
|
152
172
|
expect(image?.getAttribute('src')).toContain('/api/provider-icon');
|
|
153
173
|
} finally {
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The model popover's measured box, re-measured on every event that moves it.
|
|
8
|
+
*
|
|
9
|
+
* MEASURED, not a constant, and not measured once. A window resize alone missed
|
|
10
|
+
* the two events that actually move the trigger — the composer GROWING as the
|
|
11
|
+
* user types (which lifts it) and a phone's visual viewport shrinking under the
|
|
12
|
+
* keyboard. Measured at 1024x576, a fixed-height cap put the harness tab strip at
|
|
13
|
+
* y=16, under the titlebar, and `elementFromPoint` on the first tab answered the
|
|
14
|
+
* HEADER: the strip was in the DOM and unreachable by pointer.
|
|
15
|
+
*
|
|
16
|
+
* The arithmetic itself lives in `popover-metrics.ts`, so the cases can be
|
|
17
|
+
* asserted without a layout engine; this hook is only the observers.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { useLayoutEffect, useState } from 'preact/hooks';
|
|
21
|
+
import type { RefObject } from 'preact/compat';
|
|
22
|
+
import { popoverMetrics, type PopoverSize } from '@/client/components/workspace/model-dropdown/popover-metrics';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param panelRef the card. Its nearest `[data-model-dropdown-root]` is the
|
|
26
|
+
* trigger the card grows upward from, and that trigger's nearest
|
|
27
|
+
* `[data-composer-style]` is the PANEL the card must stay inside.
|
|
28
|
+
*/
|
|
29
|
+
export function usePopoverSize(panelRef: RefObject<HTMLElement>): PopoverSize {
|
|
30
|
+
// The FIRST frame's size, before the layout effect measures anything. Taken
|
|
31
|
+
// from `popoverMetrics` rather than written out again, so the caps are stated
|
|
32
|
+
// once and a stale pair here cannot flash a card the rule would not allow.
|
|
33
|
+
const [size, setSize] = useState<PopoverSize>(() => popoverMetrics({
|
|
34
|
+
triggerTop: Number.POSITIVE_INFINITY,
|
|
35
|
+
anchorLeft: 0,
|
|
36
|
+
containerRight: Number.POSITIVE_INFINITY,
|
|
37
|
+
viewportWidth: Number.POSITIVE_INFINITY,
|
|
38
|
+
viewportTop: 0,
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
useLayoutEffect(() => {
|
|
42
|
+
// The TRIGGER's box, not the card's: the card grows upward from the trigger,
|
|
43
|
+
// so measuring the card would feed its own height back into the cap.
|
|
44
|
+
const anchorEl = panelRef.current?.closest('[data-model-dropdown-root]') ?? null;
|
|
45
|
+
if (!anchorEl) return;
|
|
46
|
+
const containerEl = anchorEl.closest('[data-composer-style]');
|
|
47
|
+
|
|
48
|
+
const measure = () => {
|
|
49
|
+
const anchor = anchorEl.getBoundingClientRect();
|
|
50
|
+
// The COMPOSER CARD's right EDGE, not its width and not the chip: the card
|
|
51
|
+
// starts at `anchor.left` and must not spill past that edge. A chip
|
|
52
|
+
// shrink-wraps its label (measured 259px inside a 712px composer), and a
|
|
53
|
+
// width says nothing about how much of it lies to the right of the anchor —
|
|
54
|
+
// which is how a 437px card came to hang 29px past a 421px composer.
|
|
55
|
+
const container = containerEl?.getBoundingClientRect();
|
|
56
|
+
const next = popoverMetrics({
|
|
57
|
+
triggerTop: anchor.top,
|
|
58
|
+
anchorLeft: anchor.left,
|
|
59
|
+
containerRight: container?.right ?? window.innerWidth,
|
|
60
|
+
viewportWidth: window.visualViewport?.width ?? window.innerWidth,
|
|
61
|
+
// Non-zero while a phone keyboard is up: the visible area starts lower,
|
|
62
|
+
// which is exactly the space the card would otherwise run behind.
|
|
63
|
+
viewportTop: Math.max(0, window.visualViewport?.offsetTop ?? 0),
|
|
64
|
+
});
|
|
65
|
+
setSize((prev) => (prev.width === next.width && prev.height === next.height ? prev : next));
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
measure();
|
|
69
|
+
window.addEventListener('resize', measure);
|
|
70
|
+
window.visualViewport?.addEventListener('resize', measure);
|
|
71
|
+
window.visualViewport?.addEventListener('scroll', measure);
|
|
72
|
+
// Both boxes move independently: the trigger lifts when the textarea grows or
|
|
73
|
+
// the toolbar rewraps, and the panel widens when the sidebar is dragged.
|
|
74
|
+
// Observing only the trigger left the card at its old width until the next
|
|
75
|
+
// window resize.
|
|
76
|
+
const observer = typeof ResizeObserver === 'function' ? new ResizeObserver(measure) : null;
|
|
77
|
+
observer?.observe(anchorEl);
|
|
78
|
+
if (containerEl) observer?.observe(containerEl);
|
|
79
|
+
|
|
80
|
+
return () => {
|
|
81
|
+
window.removeEventListener('resize', measure);
|
|
82
|
+
window.visualViewport?.removeEventListener('resize', measure);
|
|
83
|
+
window.visualViewport?.removeEventListener('scroll', measure);
|
|
84
|
+
observer?.disconnect();
|
|
85
|
+
};
|
|
86
|
+
}, [panelRef]);
|
|
87
|
+
|
|
88
|
+
return size;
|
|
89
|
+
}
|