@kabmo-labs/kabmo 0.21.1 → 0.22.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 +7 -2
- package/dist/client/index.html +9 -8
- package/dist/client/index.js +334 -334
- package/dist/client/static/js/{index-thwqf24c.js → index-297dck9a.js} +784 -791
- package/dist/client/static/js/index-7ppta1pb.css +1 -0
- package/extensions/kabmo-modes/commands.ts +17 -3
- package/extensions/kabmo-modes/goal-start.ts +101 -0
- package/extensions/kabmo-modes/goal.test.ts +80 -5
- package/extensions/kabmo-modes/goal.ts +13 -38
- package/extensions/kabmo-modes/prompts.test.ts +12 -0
- package/extensions/kabmo-modes/prompts.ts +9 -2
- package/index.html +8 -7
- package/package.json +2 -2
- package/src/cli/lib/args.js +9 -0
- package/src/cli/lib/args.test.js +26 -0
- package/src/cli/lib/commands/doctor.js +153 -0
- package/src/cli/lib/commands/doctor.test.js +139 -0
- package/src/cli/lib/commands/serve.js +23 -10
- package/src/cli/lib/commands/status.js +22 -3
- package/src/cli/lib/omp-setup.js +131 -0
- package/src/cli/lib/omp-setup.test.js +115 -0
- package/src/cli/main.js +1 -1
- package/src/client/components/common/DemoDataBadge.tsx +52 -0
- package/src/client/components/common/FolderPicker.tsx +2 -2
- package/src/client/components/common/Modal.tsx +15 -1
- package/src/client/components/common/code-surface/blame-panel.ts +1 -1
- package/src/client/components/common/context-usage-button/index.test.tsx +1 -1
- package/src/client/components/common/context-usage-button/index.tsx +4 -4
- package/src/client/components/common/demo-data-badge.test.tsx +58 -0
- package/src/client/components/common/diagram-viewer/index.tsx +2 -2
- package/src/client/components/common/editor-view-buttons/index.tsx +2 -2
- package/src/client/components/common/header-controls/MoreMenu.tsx +1 -1
- package/src/client/components/common/header-controls/index.tsx +4 -1
- package/src/client/components/common/markdown-review/ReviewPopover.tsx +2 -2
- package/src/client/components/common/markdown-review/ReviewSummary.tsx +1 -1
- package/src/client/components/common/panel-mark/index.tsx +2 -1
- package/src/client/components/common/server-control/Panel.tsx +3 -3
- package/src/client/components/common/server-control/index.tsx +1 -1
- package/src/client/components/common/shell-update-button/Modal.tsx +1 -1
- package/src/client/components/common/todo-row/index.tsx +1 -1
- package/src/client/components/layout/ActivityBar.tsx +4 -0
- package/src/client/components/layout/ShellNotice.tsx +33 -0
- package/src/client/components/layout/desktop-layout/index.tsx +14 -16
- package/src/client/components/layout/desktop-layout/resizer/index.tsx +14 -1
- package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +2 -1
- package/src/client/components/layout/session-sidebar/ClassicView.tsx +5 -1
- package/src/client/components/layout/session-sidebar/SessionList.tsx +1 -1
- package/src/client/components/layout/session-sidebar/SessionListNotice.tsx +56 -0
- package/src/client/components/layout/session-sidebar/SessionsView.tsx +2 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateSection.tsx +1 -1
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +12 -1
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +2 -1
- package/src/client/components/layout/session-sidebar/modern/index.tsx +6 -2
- package/src/client/components/layout/session-sidebar/new-workspace-modal/CloneField.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 +1 -1
- package/src/client/components/layout/session-sidebar/scheduler-modal/TaskList.tsx +3 -3
- package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +1 -1
- package/src/client/components/layout/session-sidebar/session-list-states.test.tsx +150 -0
- package/src/client/components/layout/session-sidebar/variant-props.ts +6 -0
- package/src/client/components/mobile/LayoutWrapper.tsx +20 -30
- package/src/client/components/mobile/MainView.tsx +5 -2
- package/src/client/components/mobile/RightSidebar.tsx +1 -1
- package/src/client/components/mobile/SessionSidebar.tsx +3 -0
- package/src/client/components/mobile/mobile-main-view/Header.tsx +2 -2
- package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +7 -1
- package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +1 -1
- package/src/client/components/settings/Modal.tsx +15 -1
- package/src/client/components/settings/ProjectSelectorDropdown.tsx +1 -1
- package/src/client/components/settings/Sidebar.tsx +2 -2
- package/src/client/components/settings/categories/OmpSettings.tsx +1 -1
- package/src/client/components/settings/categories/TokenUsageSettings.tsx +1 -1
- package/src/client/components/settings/categories/agent-settings/DetailPane.tsx +3 -3
- package/src/client/components/settings/categories/appearance-settings/EditorFontSection.tsx +1 -1
- package/src/client/components/settings/categories/appearance-settings/EditorThemeSection.tsx +2 -2
- package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +5 -5
- package/src/client/components/settings/categories/appearance-settings/SidebarStyleSection.tsx +1 -1
- package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.tsx +1 -1
- package/src/client/components/settings/categories/appearance-settings/ThemeCard.tsx +1 -1
- package/src/client/components/settings/categories/chat-settings/ComposerStyleSection.tsx +1 -1
- package/src/client/components/settings/categories/chat-settings/GoalSection.tsx +1 -1
- package/src/client/components/settings/categories/command-settings/DetailPane.tsx +2 -2
- package/src/client/components/settings/categories/omp-settings/ConfigTabs.tsx +5 -5
- package/src/client/components/settings/categories/omp-settings/EngineHeader.tsx +3 -3
- package/src/client/components/settings/categories/omp-settings/RoleRow.tsx +2 -2
- package/src/client/components/settings/categories/panel-plugins/LeftDockSettings.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +4 -3
- package/src/client/components/settings/categories/plugin-settings/SidebarList.tsx +2 -2
- package/src/client/components/settings/categories/project-settings/AddProjectModal.tsx +1 -1
- package/src/client/components/settings/categories/project-settings/NameInput.tsx +1 -1
- package/src/client/components/settings/categories/project-settings/PathField.tsx +1 -1
- package/src/client/components/settings/categories/provider-settings/AddModelModal.tsx +3 -3
- package/src/client/components/settings/categories/provider-settings/AddProviderModal.tsx +1 -1
- package/src/client/components/settings/categories/provider-settings/AuthSection.tsx +2 -2
- package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +1 -1
- package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +4 -4
- package/src/client/components/settings/categories/provider-settings/EntryModal.tsx +2 -2
- package/src/client/components/settings/categories/provider-settings/LoginModal.tsx +1 -1
- package/src/client/components/settings/categories/provider-settings/ModelCapabilitiesModal.tsx +1 -1
- package/src/client/components/settings/categories/provider-settings/ModelsList.tsx +2 -2
- package/src/client/components/settings/categories/provider-settings/PriceFields.tsx +1 -1
- package/src/client/components/settings/categories/token-usage-settings/Breakdown.tsx +4 -4
- package/src/client/components/settings/categories/token-usage-settings/Chart.tsx +2 -2
- package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +1 -1
- package/src/client/components/settings/categories/token-usage-settings/MetricsGrid.tsx +1 -1
- package/src/client/components/settings/categories/usage-settings/KenariCard.tsx +5 -5
- package/src/client/components/workspace/browser-panel/AddressBar.tsx +1 -1
- package/src/client/components/workspace/browser-panel/Screencast.tsx +6 -6
- package/src/client/components/workspace/browser-panel/TabStrip.tsx +1 -1
- package/src/client/components/workspace/browser-panel/index.tsx +1 -1
- package/src/client/components/workspace/browser-toolbar/index.tsx +5 -5
- package/src/client/components/workspace/chat-timeline/AttachmentChips.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/GeneratingIndicator.tsx +13 -26
- package/src/client/components/workspace/chat-timeline/GoalNotice.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/MinimapShortcuts.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/QueueList.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/SubagentView.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/SystemNotice.tsx +5 -5
- package/src/client/components/workspace/chat-timeline/TaskResultContent.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +4 -4
- package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/ArmedGoalStrip.tsx +71 -0
- package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +4 -3
- package/src/client/components/workspace/chat-timeline/chat-input/GoalBanner.test.ts +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/GoalBanner.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.test.ts +176 -0
- package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.tsx +70 -81
- package/src/client/components/workspace/chat-timeline/chat-input/GoalSurfaces.tsx +10 -1
- package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.test.ts +20 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +13 -7
- package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +65 -3
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +69 -19
- package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/chat-input/composer-portal.test.tsx +174 -0
- package/src/client/components/workspace/chat-timeline/chat-input/goal-modal-parts.tsx +80 -0
- package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +15 -3
- package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/plan-review/index.tsx +1 -1
- 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/ask-panel/FrameControl.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OptionRow.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OrphanAsks.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionCard.tsx +4 -4
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/Header.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/SelectBody.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/hashline-patch/index.tsx +4 -4
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/AstEdit.tsx +6 -6
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +13 -13
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Checkpoint.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/ContextNotes.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Debug.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Edit.tsx +9 -9
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Eval.tsx +10 -10
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/FileMatches.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Goal.tsx +5 -5
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/GoalRecord.tsx +5 -5
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Lsp.tsx +6 -6
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/ManageSkill.tsx +5 -5
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Mcp.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Memory.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.tsx +15 -15
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Resolve.tsx +4 -4
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/SearchFs.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/SearchTool.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/SecurityScan.tsx +4 -4
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/TaskResult.tsx +7 -7
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Think.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Todo.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.missing.test.ts +4 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +17 -17
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/WebSearch.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactChip.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/EnvelopeHeader.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ExcerptCode.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/FallbackOutput.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/JsonCodeBlock.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/OutputWindow.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolFactChips.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolPanelHeader.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +1 -1
- package/src/client/components/workspace/context-panel/RawJsonViewer.tsx +2 -2
- package/src/client/components/workspace/context-panel/StatsGrid.tsx +1 -1
- package/src/client/components/workspace/context-panel/index.tsx +1 -1
- package/src/client/components/workspace/diff-panel/ConflictBanner.tsx +1 -1
- package/src/client/components/workspace/editor/EmptyEditor.tsx +1 -1
- package/src/client/components/workspace/editor/FindWidget.tsx +1 -1
- package/src/client/components/workspace/editor/Tabs.tsx +1 -1
- package/src/client/components/workspace/editor/Toolbar.tsx +1 -1
- package/src/client/components/workspace/file-explorer/OutlineSection.tsx +2 -2
- package/src/client/components/workspace/file-explorer/RowLabel.tsx +1 -1
- package/src/client/components/workspace/file-explorer/index.tsx +1 -1
- package/src/client/components/workspace/git-panel/BranchToolbar.tsx +2 -2
- package/src/client/components/workspace/git-panel/ChangesList.tsx +3 -3
- package/src/client/components/workspace/git-panel/ConflictItem.tsx +3 -3
- package/src/client/components/workspace/git-panel/FileItem.tsx +2 -2
- package/src/client/components/workspace/git-panel/StashSection.tsx +5 -5
- package/src/client/components/workspace/git-panel/TreeItem.tsx +2 -2
- package/src/client/components/workspace/git-panel/branch-modal/BranchRow.tsx +4 -4
- package/src/client/components/workspace/git-panel/branch-modal/DeleteDialog.tsx +2 -2
- package/src/client/components/workspace/git-panel/index.tsx +1 -1
- package/src/client/components/workspace/model-dropdown/Item.tsx +3 -3
- package/src/client/components/workspace/model-dropdown/Section.tsx +1 -1
- package/src/client/components/workspace/model-dropdown/index.tsx +3 -3
- package/src/client/components/workspace/plan-panel/index.tsx +2 -2
- package/src/client/components/workspace/repo-picker/Modal.tsx +1 -1
- package/src/client/components/workspace/repo-picker/Row.tsx +6 -6
- package/src/client/components/workspace/search-panel/Body.tsx +2 -2
- package/src/client/components/workspace/search-panel/Results.tsx +1 -1
- package/src/client/components/workspace/search-panel/index.tsx +1 -1
- package/src/client/components/workspace/terminal-panel/index.tsx +1 -1
- package/src/client/components/workspace/todo-panel/PhaseGroup.tsx +1 -1
- package/src/client/components/workspace/todo-panel/index.tsx +2 -2
- package/src/client/components/workspace/user-browser-panel/AddressBar.tsx +5 -5
- package/src/client/components/workspace/user-browser-panel/AnnotateBar.test.tsx +13 -13
- package/src/client/components/workspace/user-browser-panel/AnnotateBar.tsx +4 -4
- package/src/client/components/workspace/user-browser-panel/AnnotateLayer.tsx +1 -1
- package/src/client/components/workspace/user-browser-panel/AnnotateTarget.tsx +7 -7
- package/src/client/components/workspace/user-browser-panel/Frame.tsx +1 -1
- package/src/client/components/workspace/wiki-panel/Nav.tsx +1 -1
- package/src/client/components/workspace/wiki-panel/index.tsx +2 -2
- package/src/client/glass.css +50 -0
- package/src/client/glass.test.ts +68 -24
- package/src/client/hooks/chat/composer/browser-context.test.ts +6 -6
- package/src/client/hooks/chat/composer/use-draft.test.ts +2 -2
- package/src/client/hooks/chat/omp/prompt-send.test.ts +36 -0
- package/src/client/hooks/chat/omp/prompt-send.ts +24 -18
- package/src/client/hooks/chat/omp/session-list.tsx +24 -70
- package/src/client/hooks/chat/omp/session-merges.ts +89 -0
- package/src/client/hooks/chat/omp/session-sidebar-controller.ts +4 -1
- package/src/client/hooks/chat/timeline/armed-goal-send.test.ts +168 -0
- package/src/client/hooks/chat/timeline/armed-goal.test.ts +178 -0
- package/src/client/hooks/chat/timeline/goal-command.ts +57 -27
- package/src/client/hooks/chat/timeline/index.ts +7 -4
- package/src/client/hooks/chat/timeline/mode-post.ts +46 -0
- package/src/client/hooks/chat/timeline/modes-contract.ts +94 -0
- package/src/client/hooks/chat/timeline/modes.ts +60 -95
- package/src/client/hooks/chat/timeline/send-props.ts +97 -0
- package/src/client/hooks/chat/timeline/send-steer.test.ts +6 -0
- package/src/client/hooks/chat/timeline/send.test-util.ts +55 -8
- package/src/client/hooks/chat/timeline/send.test.ts +17 -1
- package/src/client/hooks/chat/timeline/send.ts +64 -72
- package/src/client/hooks/ui/dialog-behaviour.ts +143 -0
- package/src/client/hooks/ui/theme.ts +17 -0
- package/src/client/hooks/workspace/copy-tab-path.ts +23 -0
- package/src/client/hooks/workspace/mobile-back.ts +71 -0
- package/src/client/palette-class.test.ts +93 -0
- package/src/client/tailwind-contrast.test.ts +194 -0
- package/src/client/tailwind.css +327 -8
- package/src/server/lib/assets/theme-shell.server.ts +4 -10
- package/src/server/lib/omp/config/provider-seeds.test.ts +39 -1
- package/src/server/lib/omp/config/provider-seeds.ts +32 -3
- package/src/server/lib/omp/config/provider-vision-compat.test.ts +140 -0
- package/src/server/lib/omp/core/host-resolution.test.ts +1 -55
- package/src/server/lib/omp/core/install-hint.test.ts +48 -0
- package/src/server/lib/omp/core/install-hint.ts +64 -0
- package/src/server/lib/omp/core/startup.test.ts +125 -0
- package/src/server/lib/omp/core/startup.ts +5 -1
- package/src/server/lib/omp/mode/request.ts +14 -6
- package/src/server/plugins/ssr.ts +2 -1
- package/src/shared/lib/browser/annotate.test.ts +22 -22
- package/src/shared/lib/browser/annotate.ts +14 -14
- package/src/shared/lib/browser/page-context.ts +6 -6
- package/src/shared/lib/icons/icon-paint-authority.test.ts +86 -0
- package/src/shared/lib/icons/icon-paint-authority.ts +94 -0
- package/src/shared/lib/icons/icon-paint-css.test.ts +44 -8
- package/src/shared/lib/icons/icon-paint-css.ts +18 -1
- package/src/shared/lib/icons/icon-paint-panel.ts +15 -18
- package/src/shared/lib/icons/icon-paint-weight.ts +20 -1
- package/src/shared/lib/icons/icon-tone.ts +58 -13
- package/src/shared/lib/icons/tint-hues.generated.ts +51 -6
- package/src/shared/lib/icons/tint-tones.test.ts +257 -0
- package/src/shared/lib/icons/tint.test.ts +3 -211
- package/src/shared/lib/icons/tint.ts +23 -25
- package/src/shared/lib/omp/mode/actions.ts +40 -0
- package/src/shared/lib/omp/mode/types.ts +12 -0
- package/src/shared/lib/theme/css.ts +21 -0
- package/src/shared/lib/theme/first-frame.ts +38 -0
- package/src/shared/lib/theme/ink-scale.test.ts +151 -0
- package/src/shared/lib/theme/ink-scale.ts +103 -0
- package/src/shared/lib/theme/shell-palette.test.ts +22 -5
- package/src/shared/lib/theme/shell-palette.ts +9 -4
- package/src/shared/lib/theme/theme.test.ts +28 -3
- package/src/shared/lib/workspace/project-accent.test.ts +33 -1
- package/src/shared/lib/workspace/project-accent.ts +23 -0
- package/src/shared/types/omp/agent.ts +24 -9
- package/dist/client/static/js/index-0721wrkf.css +0 -1
|
@@ -32,85 +32,30 @@ import {
|
|
|
32
32
|
type GoalRecord,
|
|
33
33
|
} from '@/shared/lib/omp/mode/types';
|
|
34
34
|
import { goalMarkerPatch, useModeMarkers, type ModesResponse } from '@/client/hooks/chat/timeline/mode-markers';
|
|
35
|
-
import { createGoalAction } from '@/client/hooks/chat/timeline/goal-command';
|
|
35
|
+
import { createGoalAction, type GoalActionResult } from '@/client/hooks/chat/timeline/goal-command';
|
|
36
|
+
import { postModeCommand } from '@/client/hooks/chat/timeline/mode-post';
|
|
36
37
|
import { isGoalOpen } from '@/shared/lib/omp/mode/status';
|
|
37
38
|
import { isPendingSessionId } from '@/shared/lib/omp/session/default-title';
|
|
38
39
|
import { isModeMarker } from '@/shared/lib/omp/mode/constants';
|
|
40
|
+
import type { ArmedGoal, GoalAction } from '@/shared/lib/omp/mode/actions';
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
plan: boolean;
|
|
42
|
-
/** omp's own `enabled` flag: the agent is working toward the goal right now.
|
|
43
|
-
* False for a PAUSED goal, which still exists (see `goalOpen`). */
|
|
44
|
-
goal: boolean;
|
|
45
|
-
/** A goal this chat still owns — omp's `enabled` OR an open record. This is
|
|
46
|
-
* the flag every surface should gate on: pausing clears `enabled` while the
|
|
47
|
-
* record stays resumable, so gating on `goal` alone made the goal vanish
|
|
48
|
-
* from the composer (strip gone, button off, modal offering to create a
|
|
49
|
-
* second goal over the paused one). */
|
|
50
|
-
goalOpen: boolean;
|
|
51
|
-
goalRecord: GoalRecord | null;
|
|
52
|
-
/**
|
|
53
|
-
* The child's last automatic goal turn (`KABMO_GOAL_CONTINUATION`), or
|
|
54
|
-
* null when the loop has not reported one for the current goal. Cleared when
|
|
55
|
-
* the goal itself changes: a counter from the previous goal names a turn this
|
|
56
|
-
* one never took.
|
|
57
|
-
*/
|
|
58
|
-
goalContinuation: GoalContinuation | null;
|
|
59
|
-
/**
|
|
60
|
-
* True while the child's loop is deciding whether to open another automatic
|
|
61
|
-
* turn. The decision is a synchronous guard chain with no other frame, so
|
|
62
|
-
* this is the only signal for the window in which the goal is neither
|
|
63
|
-
* streaming nor idle.
|
|
64
|
-
*/
|
|
65
|
-
goalEvaluating: boolean;
|
|
66
|
-
/** True while a mode command is in flight; the toggle shows a pending state
|
|
67
|
-
* rather than flipping optimistically and snapping back. */
|
|
68
|
-
pending: boolean;
|
|
69
|
-
/** omp refuses to enter one mode while the other is active, so Plan is not
|
|
70
|
-
* offered while Goal is on — a button whose only outcome is a refusal is
|
|
71
|
-
* worse than an absent one. The child enforces the same rule, because this
|
|
72
|
-
* flag only hides a button: a stale client or a typed `/plan` used to reach
|
|
73
|
-
* the child and turn both modes on. */
|
|
74
|
-
planAvailable: boolean;
|
|
75
|
-
/**
|
|
76
|
-
* The last refusal, from either side of the wire: the route's own error, or a
|
|
77
|
-
* `KABMO_MODE_ERROR` the extension emitted (an unknown action, a missing
|
|
78
|
-
* omp API, the plan/goal exclusion). Surfaced by the composer because a mode
|
|
79
|
-
* command that fails silently leaves the toggle pressed over a mode the child
|
|
80
|
-
* is not in.
|
|
81
|
-
*/
|
|
82
|
-
error: string | null;
|
|
83
|
-
/** Clear the refusal once it has been shown. */
|
|
84
|
-
clearError: () => void;
|
|
85
|
-
/**
|
|
86
|
-
* For a pending `new-…` chat only: the selection its spawn must carry, since
|
|
87
|
-
* there is no child to command yet. Null once the session exists — from then
|
|
88
|
-
* on the child is authoritative and the value is written to its transcript.
|
|
89
|
-
*
|
|
90
|
-
* A ref rather than a value because the reader is the SEND path
|
|
91
|
-
* (`executeSend`), which runs outside the render that produced it.
|
|
92
|
-
*/
|
|
93
|
-
spawnSelectionRef: { current: KabmoModeSelection | null };
|
|
94
|
-
onTogglePlan: (enabled: boolean) => void;
|
|
95
|
-
/** Goal needs an objective, so the toggle opens a modal instead of sending a
|
|
96
|
-
* bare enable — see `GoalModal`. */
|
|
97
|
-
onGoalAction: (action: GoalAction) => void;
|
|
98
|
-
}
|
|
42
|
+
import type { ChatTimelineModes } from '@/client/hooks/chat/timeline/modes-contract';
|
|
99
43
|
|
|
100
|
-
export type
|
|
101
|
-
|
|
102
|
-
| { kind: 'guided'; rough: string }
|
|
103
|
-
| { kind: 'pause' }
|
|
104
|
-
| { kind: 'resume' }
|
|
105
|
-
| { kind: 'drop' }
|
|
106
|
-
| { kind: 'budget'; value: number | 'off' };
|
|
44
|
+
export type { ChatTimelineModes };
|
|
45
|
+
export type { ArmedGoal, GoalAction };
|
|
107
46
|
|
|
108
47
|
export function useChatTimelineModes(sessionId: string | null): ChatTimelineModes {
|
|
109
48
|
// A pending `new-…` chat has no omp session to command: `/api/agent/:id`
|
|
110
|
-
// answers 404 and nothing persists.
|
|
49
|
+
// answers 404 and nothing persists. Plan's selection lives in
|
|
111
50
|
// `spawnSelectionRef` instead, and the SEND path hands it to the spawn
|
|
112
51
|
// (`executeSend` → `sendNewPrompt` → the session's `KABMO_MODES`
|
|
113
52
|
// environment), which is the earliest moment a child exists to carry it.
|
|
53
|
+
//
|
|
54
|
+
// A GOAL uses the same seam for its own half: the objective is ARMED in
|
|
55
|
+
// `goalArmRef` and created by the fence of the next prompt (see the header).
|
|
56
|
+
const [goalArm, setGoalArm] = useState<ArmedGoal | null>(null);
|
|
57
|
+
const goalArmRef = useRef<ArmedGoal | null>(null);
|
|
58
|
+
goalArmRef.current = goalArm;
|
|
114
59
|
const [plan, setPlanState] = useState(false);
|
|
115
60
|
const [goal, setGoalState] = useState(false);
|
|
116
61
|
const [goalRecord, setGoalRecord] = useState<GoalRecord | null>(null);
|
|
@@ -224,24 +169,13 @@ export function useChatTimelineModes(sessionId: string | null): ChatTimelineMode
|
|
|
224
169
|
const send = useCallback(
|
|
225
170
|
async (scope: 'plan' | 'goal', action: string, payload?: Record<string, unknown>) => {
|
|
226
171
|
const sessionId = sessionRef.current;
|
|
227
|
-
if (!sessionId) return false;
|
|
172
|
+
if (!sessionId) return { ok: false, error: 'No session to command.' };
|
|
228
173
|
setPending(true);
|
|
229
174
|
setError(null);
|
|
230
175
|
try {
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
body: JSON.stringify({ type: 'kabmo_mode', scope, action, ...(payload ? { payload } : {}) }),
|
|
235
|
-
});
|
|
236
|
-
if (!res.ok) {
|
|
237
|
-
const body = (await res.json().catch(() => ({}))) as { error?: string };
|
|
238
|
-
setError(body.error ?? 'Mode command failed');
|
|
239
|
-
return false;
|
|
240
|
-
}
|
|
241
|
-
return true;
|
|
242
|
-
} catch (err) {
|
|
243
|
-
setError(err instanceof Error ? err.message : 'Mode command failed');
|
|
244
|
-
return false;
|
|
176
|
+
const posted = await postModeCommand(sessionId, scope, action, payload);
|
|
177
|
+
if (!posted.ok) setError(posted.error ?? 'Mode command failed');
|
|
178
|
+
return posted;
|
|
245
179
|
} finally {
|
|
246
180
|
setPending(false);
|
|
247
181
|
}
|
|
@@ -267,8 +201,8 @@ export function useChatTimelineModes(sessionId: string | null): ChatTimelineMode
|
|
|
267
201
|
// the lie the refusal exists to prevent (measured: `plan on` against a
|
|
268
202
|
// live goal returned 200, the child refused, and the button stayed on).
|
|
269
203
|
setPlanState(enabled);
|
|
270
|
-
void send('plan', enabled ? 'on' : 'off').then((
|
|
271
|
-
if (!ok) setPlanState(previous);
|
|
204
|
+
void send('plan', enabled ? 'on' : 'off').then((result) => {
|
|
205
|
+
if (!result.ok) setPlanState(previous);
|
|
272
206
|
});
|
|
273
207
|
},
|
|
274
208
|
[send],
|
|
@@ -284,20 +218,48 @@ export function useChatTimelineModes(sessionId: string | null): ChatTimelineMode
|
|
|
284
218
|
[send],
|
|
285
219
|
);
|
|
286
220
|
|
|
221
|
+
const disarmGoal = useCallback(() => {
|
|
222
|
+
setGoalArm(null);
|
|
223
|
+
goalArmRef.current = null;
|
|
224
|
+
}, []);
|
|
225
|
+
|
|
287
226
|
const onGoalAction = useCallback(
|
|
288
|
-
(action: GoalAction) => {
|
|
289
|
-
|
|
290
|
-
//
|
|
291
|
-
//
|
|
292
|
-
//
|
|
293
|
-
//
|
|
227
|
+
async (action: GoalAction): Promise<GoalActionResult> => {
|
|
228
|
+
setError(null);
|
|
229
|
+
// A goal the operator set but has not started: arming is a local record,
|
|
230
|
+
// not a command, because there is nothing to command yet (and on a
|
|
231
|
+
// pending chat, no child at all). `executeSend` creates it at the fence
|
|
232
|
+
// of the next prompt, with `startTurn: false` so that prompt is turn one.
|
|
233
|
+
if (action.kind === 'create' && !goalRecord) {
|
|
234
|
+
setGoalArm({
|
|
235
|
+
kind: 'create',
|
|
236
|
+
objective: action.objective,
|
|
237
|
+
...(action.tokenBudget === undefined ? {} : { tokenBudget: action.tokenBudget }),
|
|
238
|
+
...(action.maxTurns === undefined ? {} : { maxTurns: action.maxTurns }),
|
|
239
|
+
});
|
|
240
|
+
return { ok: true, armed: true };
|
|
241
|
+
}
|
|
242
|
+
if (action.kind === 'guided') {
|
|
243
|
+
// An interview is a CONVERSATION, so it cannot create a goal record the
|
|
244
|
+
// way `create` does — the model writes the objective at the end. It is
|
|
245
|
+
// still ARMED: the operator's next message is what starts it, and
|
|
246
|
+
// folding that message into the kickoff is what keeps the transcript
|
|
247
|
+
// opening on their own words instead of on a question to nobody.
|
|
248
|
+
setGoalArm({ kind: 'guided', rough: action.rough });
|
|
249
|
+
return { ok: true, armed: true };
|
|
250
|
+
}
|
|
294
251
|
if (isPendingSessionId(sessionRef.current)) {
|
|
295
|
-
|
|
296
|
-
|
|
252
|
+
// Pause/Resume/Drop/Budget describe a record a chat with no child does
|
|
253
|
+
// not have; a start is handled above by arming.
|
|
254
|
+
const reason = 'There is no goal in this chat yet. Set one first.';
|
|
255
|
+
setError(reason);
|
|
256
|
+
return { ok: false, error: reason };
|
|
297
257
|
}
|
|
298
|
-
runGoalAction(action);
|
|
258
|
+
const result = await runGoalAction(action);
|
|
259
|
+
if (result.ok) setGoalArm(null);
|
|
260
|
+
return result;
|
|
299
261
|
},
|
|
300
|
-
[runGoalAction],
|
|
262
|
+
[runGoalAction, goalRecord],
|
|
301
263
|
);
|
|
302
264
|
|
|
303
265
|
const clearError = useCallback(() => setError(null), []);
|
|
@@ -318,6 +280,9 @@ export function useChatTimelineModes(sessionId: string | null): ChatTimelineMode
|
|
|
318
280
|
error,
|
|
319
281
|
clearError,
|
|
320
282
|
spawnSelectionRef,
|
|
283
|
+
goalArm,
|
|
284
|
+
disarmGoal,
|
|
285
|
+
goalArmRef,
|
|
321
286
|
onTogglePlan,
|
|
322
287
|
onGoalAction,
|
|
323
288
|
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The send path's deps and result, split from its implementation so the hook
|
|
8
|
+
* file stays under the repo's per-file ceiling — the same split `chat-input/
|
|
9
|
+
* props.ts` makes for the composer.
|
|
10
|
+
*
|
|
11
|
+
* Every field is documented where it changes behaviour; `send.ts` reads them
|
|
12
|
+
* all.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { Dispatch, SetStateAction } from 'preact/compat';
|
|
16
|
+
import type { Attachment, ChatMessageData, OmpAgentHandle, PromptDispatchResult, QueuedMessageModel } from '@/shared/types';
|
|
17
|
+
import type { ApprovalMode } from '@/shared/lib/omp/config/access-mode';
|
|
18
|
+
import type { SessionSeed } from '@/client/hooks/chat/timeline/session-load';
|
|
19
|
+
import type { DeferredModelStore } from '@/client/hooks/chat/timeline/deferred-model';
|
|
20
|
+
import type { ArmedGoal } from '@/shared/lib/omp/mode/actions';
|
|
21
|
+
|
|
22
|
+
export interface ChatTimelineSendDeps {
|
|
23
|
+
folders: any[];
|
|
24
|
+
selectedFolderId: number | null;
|
|
25
|
+
sessionId: string | null;
|
|
26
|
+
isOmpSession: boolean;
|
|
27
|
+
appSettings: Record<string, any>;
|
|
28
|
+
ompAgent: OmpAgentHandle;
|
|
29
|
+
setLocalMessages: Dispatch<SetStateAction<ChatMessageData[]>>;
|
|
30
|
+
persistMessages: (messages: any[]) => void;
|
|
31
|
+
setGenerating: (v: boolean, owned?: boolean) => void;
|
|
32
|
+
setGeneratingVerb: (v: string) => void;
|
|
33
|
+
/** Follow-gated scroll for stream chunks. */
|
|
34
|
+
scrollToBottom: (behavior?: ScrollBehavior) => void;
|
|
35
|
+
/** Explicit user-action scroll: re-engages follow mode (send/steer). */
|
|
36
|
+
jumpToBottom: (behavior?: ScrollBehavior) => void;
|
|
37
|
+
aiPlaceholderIdRef: { current: string | null };
|
|
38
|
+
adoptedSessionIdRef: { current: string | null };
|
|
39
|
+
optimisticUserIdRef: { current: string | null };
|
|
40
|
+
pendingUserDisplaysRef: { current: { sent: string; display: string }[] };
|
|
41
|
+
/** Adopt the spawned session's identity (model + the thinking level the first
|
|
42
|
+
* prompt runs with) so the composer replacing the pending view shows it. */
|
|
43
|
+
seedSession: (seed: SessionSeed) => void;
|
|
44
|
+
/** Model/thinking picked in the composer before the session existed —
|
|
45
|
+
* applied to the spawn command so the first prompt runs with them. */
|
|
46
|
+
pendingComposerModelRef: { current: { provider: string; modelId: string } | null };
|
|
47
|
+
pendingThinkingLevelRef: { current: string | null };
|
|
48
|
+
/** Global access-control mode (persisted user preference), read at send time
|
|
49
|
+
* so the spawn-capable requests carry the latest value. */
|
|
50
|
+
accessModeRef: { current: ApprovalMode };
|
|
51
|
+
/** Plan/goal picks made on a pending `new-…` chat, applied to the spawn that
|
|
52
|
+
* replaces it. Read here rather than from `modes` because the spawn happens
|
|
53
|
+
* outside the render that produced the pick, and it is the FIRST moment a
|
|
54
|
+
* child exists to carry the selection. */
|
|
55
|
+
spawnSelectionRef: { current: { plan: boolean; goal: boolean } | null };
|
|
56
|
+
/**
|
|
57
|
+
* The goal the operator ARMED, read at send time. The goal is created by the
|
|
58
|
+
* fence of THIS prompt — just before the prompt is dispatched — with
|
|
59
|
+
* `startTurn: false`, so the turn the operator just wrote is the goal's first
|
|
60
|
+
* turn. Read through a ref for the same reason `spawnSelectionRef` is: the
|
|
61
|
+
* send runs outside the render that produced the pick.
|
|
62
|
+
*/
|
|
63
|
+
goalArmRef: { current: ArmedGoal | null };
|
|
64
|
+
/** Clears the armed goal once it has been consumed by this send. */
|
|
65
|
+
disarmGoal: () => void;
|
|
66
|
+
/**
|
|
67
|
+
* The worktree the pending chat picked (`chat.spawnTarget`), read through a
|
|
68
|
+
* REF because the composer is remounted by a stretch, a tab switch and a
|
|
69
|
+
* reload while this handler is created once per deps record — the same reason
|
|
70
|
+
* the waiting pick keeps one.
|
|
71
|
+
*/
|
|
72
|
+
spawnWorktreeRef: { current: string | null };
|
|
73
|
+
/** Picks the composer made while a turn was streaming. Pushed onto the
|
|
74
|
+
* session here, immediately before the prompt they were meant for. */
|
|
75
|
+
deferredComposerPickRef: DeferredModelStore;
|
|
76
|
+
abortControllerRef: { current: AbortController | null };
|
|
77
|
+
setInputValue: (v: string) => void;
|
|
78
|
+
/** Surface a refused send. The optimistic bubbles are rolled back either
|
|
79
|
+
* way; without this the operator's turn simply VANISHES, which is the
|
|
80
|
+
* "prompt failed to send" report this exists to answer. */
|
|
81
|
+
reportActionError: (message: string) => void;
|
|
82
|
+
setSearchParams: (fn: (prev: URLSearchParams) => URLSearchParams, opts?: { replace?: boolean }) => void;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface ChatTimelineSendResult {
|
|
86
|
+
/** Steer the running turn; resolves with the outcome so a refusal can be
|
|
87
|
+
* reported (the composer is cleared before the request goes out). */
|
|
88
|
+
steerOmpAgent: (text: string, attachments: Attachment[]) => Promise<PromptDispatchResult>;
|
|
89
|
+
/** `model` re-applies a queued item's snapshot before the prompt runs
|
|
90
|
+
* (set_model / set_thinking_level RPC + prompt access mode). `busy: true`
|
|
91
|
+
* means omp REFUSED the prompt mid-turn — the caller queues it instead. */
|
|
92
|
+
executeSend: (
|
|
93
|
+
text: string,
|
|
94
|
+
attachments: Attachment[],
|
|
95
|
+
options?: { model?: QueuedMessageModel | null },
|
|
96
|
+
) => Promise<PromptDispatchResult>;
|
|
97
|
+
}
|
|
@@ -12,6 +12,7 @@ import { Window } from 'happy-dom';
|
|
|
12
12
|
import { h, render } from 'preact';
|
|
13
13
|
import { act } from 'preact/test-utils';
|
|
14
14
|
import type { ChatMessageData, OmpAgentHandle } from '@/shared/types';
|
|
15
|
+
import type { ArmedGoal } from '@/shared/lib/omp/mode/actions';
|
|
15
16
|
import {
|
|
16
17
|
useChatTimelineSend,
|
|
17
18
|
type ChatTimelineSendDeps,
|
|
@@ -151,6 +152,9 @@ function makeSendHarness(options: {
|
|
|
151
152
|
const params: string[] = [];
|
|
152
153
|
const seeds: SessionSeed[] = [];
|
|
153
154
|
const spawnSelectionRef = { current: { plan: true, goal: false } };
|
|
155
|
+
/** No goal armed unless a case arms one. */
|
|
156
|
+
const goalArmRef: { current: ArmedGoal | null } = { current: null };
|
|
157
|
+
const disarmGoal = () => { goalArmRef.current = null; };
|
|
154
158
|
const spawnWorktreeRef = { current: null as string | null };
|
|
155
159
|
const adoptedSessionIdRef = { current: null };
|
|
156
160
|
const deps: ChatTimelineSendDeps = {
|
|
@@ -182,6 +186,8 @@ function makeSendHarness(options: {
|
|
|
182
186
|
deferredComposerPickRef: options.deferredPick ?? { current: null },
|
|
183
187
|
accessModeRef: { current: 'always-ask' },
|
|
184
188
|
spawnSelectionRef,
|
|
189
|
+
goalArmRef,
|
|
190
|
+
disarmGoal,
|
|
185
191
|
spawnWorktreeRef,
|
|
186
192
|
abortControllerRef: { current: null },
|
|
187
193
|
setInputValue: (v) => {
|
|
@@ -18,6 +18,7 @@ import { Window } from 'happy-dom';
|
|
|
18
18
|
import { h, render } from 'preact';
|
|
19
19
|
import { act } from 'preact/test-utils';
|
|
20
20
|
import type { ChatMessageData, OmpAgentHandle } from '@/shared/types';
|
|
21
|
+
import type { ArmedGoal } from '@/shared/lib/omp/mode/actions';
|
|
21
22
|
import {
|
|
22
23
|
useChatTimelineSend,
|
|
23
24
|
type ChatTimelineSendDeps,
|
|
@@ -28,13 +29,11 @@ import type { SessionSeed } from '@/client/hooks/chat/timeline/session-load';
|
|
|
28
29
|
const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'Event', 'CustomEvent'] as const;
|
|
29
30
|
|
|
30
31
|
let installed: { restore: () => void } | null = null;
|
|
32
|
+
/** How many files currently want the DOM installed. */
|
|
33
|
+
let holders = 0;
|
|
31
34
|
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
* runner's own globals back so later files are unaffected.
|
|
35
|
-
*/
|
|
36
|
-
export function installDomGlobals(): void {
|
|
37
|
-
if (installed) return;
|
|
35
|
+
/** Put happy-dom's globals in place, remembering the runner's own. */
|
|
36
|
+
function install(): void {
|
|
38
37
|
const native: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
|
|
39
38
|
const win = new Window({ url: 'http://localhost' });
|
|
40
39
|
const target = globalThis as unknown as Record<string, unknown>;
|
|
@@ -53,8 +52,46 @@ export function installDomGlobals(): void {
|
|
|
53
52
|
};
|
|
54
53
|
}
|
|
55
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Give the file a DOM, as a HOLD.
|
|
57
|
+
*
|
|
58
|
+
* REFERENCE-COUNTED, because several files share this harness and `bun test`
|
|
59
|
+
* runs them in one process: `send-execute.test.ts` and `send-refusal.test.ts`
|
|
60
|
+
* both install in `beforeAll` and restore in `afterAll`. With a plain
|
|
61
|
+
* installed/not-installed flag the second file's install was a no-op and the
|
|
62
|
+
* FIRST file's restore then removed the DOM from under it — measured on the
|
|
63
|
+
* Windows gate, where all eight `executeSend` cases failed with
|
|
64
|
+
* `ReferenceError: document is not defined` while the same file passed alone.
|
|
65
|
+
* The globals go only when the last holder lets go.
|
|
66
|
+
*/
|
|
67
|
+
export function installDomGlobals(): void {
|
|
68
|
+
holders += 1;
|
|
69
|
+
ensureDom();
|
|
70
|
+
}
|
|
71
|
+
|
|
56
72
|
export function restoreDomGlobals(): void {
|
|
57
|
-
|
|
73
|
+
if (holders === 0) return;
|
|
74
|
+
holders -= 1;
|
|
75
|
+
if (holders === 0) installed?.restore();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Make sure the DOM really is on `globalThis`, whatever the flag says.
|
|
80
|
+
*
|
|
81
|
+
* The flag alone is not trustworthy. `pristine-globals.ts` is a SECOND manager
|
|
82
|
+
* of the same names, and its `restoreDomGlobals` DELETES a global whose pristine
|
|
83
|
+
* value was undefined — which is exactly `document` under `bun test`. A file
|
|
84
|
+
* that uses that helper while this harness held the DOM therefore strips it and
|
|
85
|
+
* leaves `installed` pointing at a restore for globals that are already gone.
|
|
86
|
+
* Measured on the Windows gate: all eight `executeSend` cases failed with
|
|
87
|
+
* `ReferenceError: document is not defined` from `makeSendHarness`, while the
|
|
88
|
+
* same file passed alone. Checking the global is what makes the two managers
|
|
89
|
+
* safe in either order.
|
|
90
|
+
*/
|
|
91
|
+
function ensureDom(): void {
|
|
92
|
+
if (installed && typeof (globalThis as Record<string, unknown>).document !== 'undefined') return;
|
|
93
|
+
installed = null;
|
|
94
|
+
install();
|
|
58
95
|
}
|
|
59
96
|
|
|
60
97
|
/** The runner's own fetch, reached through `Bun` so a leaked stub cannot be mistaken for it. */
|
|
@@ -150,6 +187,8 @@ export interface SendHarness {
|
|
|
150
187
|
params: string[];
|
|
151
188
|
seeds: SessionSeed[];
|
|
152
189
|
spawnSelectionRef: { current: { plan: boolean; goal: boolean } | null };
|
|
190
|
+
/** The armed goal, so a case can arm one and read what the send consumed. */
|
|
191
|
+
goalArmRef: { current: ArmedGoal | null };
|
|
153
192
|
adoptedSessionIdRef: { current: string | null };
|
|
154
193
|
}
|
|
155
194
|
|
|
@@ -161,7 +200,9 @@ export function makeSendHarness(options: {
|
|
|
161
200
|
agent?: AgentRecorder | Partial<AgentCalls>;
|
|
162
201
|
deferredPick?: { current: unknown };
|
|
163
202
|
} = {}): SendHarness {
|
|
164
|
-
|
|
203
|
+
// Ensure, never HOLD: a case's DOM comes from its file's `beforeAll`, and
|
|
204
|
+
// counting here would leave the globals installed for the whole process.
|
|
205
|
+
ensureDom();
|
|
165
206
|
const { messages, setLocalMessages } = makeMessages();
|
|
166
207
|
// `options.agent` is either overrides for the recorder's `AgentCalls` or
|
|
167
208
|
// the finished recorder itself; the two forms are told apart by shape.
|
|
@@ -176,6 +217,9 @@ export function makeSendHarness(options: {
|
|
|
176
217
|
const params: string[] = [];
|
|
177
218
|
const seeds: SessionSeed[] = [];
|
|
178
219
|
const spawnSelectionRef = { current: { plan: true, goal: false } };
|
|
220
|
+
/** No goal armed unless a case arms one. */
|
|
221
|
+
const goalArmRef: { current: ArmedGoal | null } = { current: null };
|
|
222
|
+
const disarmGoal = () => { goalArmRef.current = null; };
|
|
179
223
|
const spawnWorktreeRef = { current: null as string | null };
|
|
180
224
|
const adoptedSessionIdRef = { current: null };
|
|
181
225
|
const deps: ChatTimelineSendDeps = {
|
|
@@ -207,6 +251,8 @@ export function makeSendHarness(options: {
|
|
|
207
251
|
deferredComposerPickRef: (options.deferredPick ?? { current: null }) as ChatTimelineSendDeps['deferredComposerPickRef'],
|
|
208
252
|
accessModeRef: { current: 'always-ask' },
|
|
209
253
|
spawnSelectionRef,
|
|
254
|
+
goalArmRef,
|
|
255
|
+
disarmGoal,
|
|
210
256
|
spawnWorktreeRef,
|
|
211
257
|
abortControllerRef: { current: null },
|
|
212
258
|
setInputValue: (v) => {
|
|
@@ -238,6 +284,7 @@ export function makeSendHarness(options: {
|
|
|
238
284
|
params,
|
|
239
285
|
seeds,
|
|
240
286
|
spawnSelectionRef,
|
|
287
|
+
goalArmRef,
|
|
241
288
|
adoptedSessionIdRef,
|
|
242
289
|
};
|
|
243
290
|
}
|
|
@@ -13,6 +13,7 @@ import { Window } from 'happy-dom';
|
|
|
13
13
|
import { h, render } from 'preact';
|
|
14
14
|
import { act } from 'preact/test-utils';
|
|
15
15
|
import type { ChatMessageData, OmpAgentHandle } from '@/shared/types';
|
|
16
|
+
import type { ArmedGoal } from '@/shared/lib/omp/mode/actions';
|
|
16
17
|
import {
|
|
17
18
|
useChatTimelineSend,
|
|
18
19
|
type ChatTimelineSendDeps,
|
|
@@ -125,7 +126,10 @@ interface SendHarness {
|
|
|
125
126
|
generating: boolean[];
|
|
126
127
|
drafts: string[];
|
|
127
128
|
params: string[];
|
|
129
|
+
reported: string[];
|
|
128
130
|
seeds: SessionSeed[];
|
|
131
|
+
/** The armed goal, so a case can arm one and read what the send consumed. */
|
|
132
|
+
goalArmRef: { current: ArmedGoal | null };
|
|
129
133
|
spawnSelectionRef: { current: { plan: boolean; goal: boolean } | null };
|
|
130
134
|
adoptedSessionIdRef: { current: string | null };
|
|
131
135
|
}
|
|
@@ -150,7 +154,12 @@ function makeSendHarness(options: {
|
|
|
150
154
|
const drafts: string[] = [];
|
|
151
155
|
const params: string[] = [];
|
|
152
156
|
const seeds: SessionSeed[] = [];
|
|
157
|
+
/** Refusals the send reported (`reportActionError`). */
|
|
158
|
+
const reported: string[] = [];
|
|
153
159
|
const spawnSelectionRef = { current: { plan: true, goal: false } };
|
|
160
|
+
/** No goal armed unless a case arms one. */
|
|
161
|
+
const goalArmRef: { current: ArmedGoal | null } = { current: null };
|
|
162
|
+
const disarmGoal = () => { goalArmRef.current = null; };
|
|
154
163
|
const spawnWorktreeRef = { current: null as string | null };
|
|
155
164
|
const adoptedSessionIdRef = { current: null };
|
|
156
165
|
const deps: ChatTimelineSendDeps = {
|
|
@@ -182,12 +191,16 @@ function makeSendHarness(options: {
|
|
|
182
191
|
deferredComposerPickRef: options.deferredPick ?? { current: null },
|
|
183
192
|
accessModeRef: { current: 'always-ask' },
|
|
184
193
|
spawnSelectionRef,
|
|
194
|
+
goalArmRef,
|
|
195
|
+
disarmGoal,
|
|
185
196
|
spawnWorktreeRef,
|
|
186
197
|
abortControllerRef: { current: null },
|
|
187
198
|
setInputValue: (v) => {
|
|
188
199
|
drafts.push(v);
|
|
189
200
|
},
|
|
190
|
-
reportActionError: () => {
|
|
201
|
+
reportActionError: (message: string) => {
|
|
202
|
+
reported.push(message);
|
|
203
|
+
},
|
|
191
204
|
setSearchParams: (fn) => {
|
|
192
205
|
params.push(fn(new URLSearchParams('sessionId=new-1')).toString());
|
|
193
206
|
},
|
|
@@ -208,8 +221,10 @@ function makeSendHarness(options: {
|
|
|
208
221
|
generating,
|
|
209
222
|
drafts,
|
|
210
223
|
params,
|
|
224
|
+
reported,
|
|
211
225
|
seeds,
|
|
212
226
|
spawnSelectionRef,
|
|
227
|
+
goalArmRef,
|
|
213
228
|
adoptedSessionIdRef,
|
|
214
229
|
};
|
|
215
230
|
}
|
|
@@ -232,3 +247,4 @@ describe('steerOmpAgent', () => {
|
|
|
232
247
|
expect(h1.drafts).toEqual([]);
|
|
233
248
|
});
|
|
234
249
|
});
|
|
250
|
+
|