@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
|
@@ -11,86 +11,21 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { useCallback } from 'preact/hooks';
|
|
14
|
-
import type {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import type {
|
|
14
|
+
import type { ChatTimelineSendDeps, ChatTimelineSendResult } from '@/client/hooks/chat/timeline/send-props';
|
|
15
|
+
|
|
16
|
+
export type { ChatTimelineSendDeps, ChatTimelineSendResult };
|
|
17
|
+
import type { AgentImage, Attachment, PromptDispatchResult, QueuedMessageModel } from '@/shared/types';
|
|
18
18
|
import { buildPromptText } from '@/client/hooks/chat/timeline/prompt-text';
|
|
19
|
-
import { flushDeferredPick
|
|
19
|
+
import { flushDeferredPick } from '@/client/hooks/chat/timeline/deferred-model';
|
|
20
20
|
import { readTextAttachments } from '@/shared/lib/chat/attachments';
|
|
21
21
|
import { buildOptimisticRows, collectImages, streamMockFallback } from '@/client/hooks/chat/timeline/send-helpers';
|
|
22
22
|
import { adoptPendingSession, markPendingSessionSent } from '@/client/hooks/chat/omp/pending-sessions';
|
|
23
|
+
import { postModeCommand } from '@/client/hooks/chat/timeline/mode-post';
|
|
24
|
+
import type { ArmedGoal } from '@/shared/lib/omp/mode/actions';
|
|
23
25
|
import { blockTuiOnlySend } from '@/client/hooks/chat/timeline/tui-only-guard';
|
|
24
26
|
import { PHASE_VERBS } from '@/shared/lib/chat/timeline/tool-phrases';
|
|
25
27
|
import { formatClock } from '@/shared/lib/format/time';
|
|
26
28
|
|
|
27
|
-
export interface ChatTimelineSendDeps {
|
|
28
|
-
folders: any[];
|
|
29
|
-
selectedFolderId: number | null;
|
|
30
|
-
sessionId: string | null;
|
|
31
|
-
isOmpSession: boolean;
|
|
32
|
-
appSettings: Record<string, any>;
|
|
33
|
-
ompAgent: OmpAgentHandle;
|
|
34
|
-
setLocalMessages: Dispatch<SetStateAction<ChatMessageData[]>>;
|
|
35
|
-
persistMessages: (messages: any[]) => void;
|
|
36
|
-
setGenerating: (v: boolean, owned?: boolean) => void;
|
|
37
|
-
setGeneratingVerb: (v: string) => void;
|
|
38
|
-
/** Follow-gated scroll for stream chunks. */
|
|
39
|
-
scrollToBottom: (behavior?: ScrollBehavior) => void;
|
|
40
|
-
/** Explicit user-action scroll: re-engages follow mode (send/steer). */
|
|
41
|
-
jumpToBottom: (behavior?: ScrollBehavior) => void;
|
|
42
|
-
aiPlaceholderIdRef: { current: string | null };
|
|
43
|
-
adoptedSessionIdRef: { current: string | null };
|
|
44
|
-
optimisticUserIdRef: { current: string | null };
|
|
45
|
-
pendingUserDisplaysRef: { current: { sent: string; display: string }[] };
|
|
46
|
-
/** Adopt the spawned session's identity (model + the thinking level the first
|
|
47
|
-
* prompt runs with) so the composer replacing the pending view shows it. */
|
|
48
|
-
seedSession: (seed: SessionSeed) => void;
|
|
49
|
-
/** Model/thinking picked in the composer before the session existed —
|
|
50
|
-
* applied to the spawn command so the first prompt runs with them. */
|
|
51
|
-
pendingComposerModelRef: { current: { provider: string; modelId: string } | null };
|
|
52
|
-
pendingThinkingLevelRef: { current: string | null };
|
|
53
|
-
/** Global access-control mode (persisted user preference), read at send time
|
|
54
|
-
* so the spawn-capable requests carry the latest value. */
|
|
55
|
-
accessModeRef: { current: ApprovalMode };
|
|
56
|
-
/** Plan/goal picks made on a pending `new-…` chat, applied to the spawn that
|
|
57
|
-
* replaces it. Read here rather than from `modes` because the spawn happens
|
|
58
|
-
* outside the render that produced the pick, and it is the FIRST moment a
|
|
59
|
-
* child exists to carry the selection. */
|
|
60
|
-
spawnSelectionRef: { current: { plan: boolean; goal: boolean } | null };
|
|
61
|
-
/**
|
|
62
|
-
* The worktree the pending chat picked (`chat.spawnTarget`), read through a
|
|
63
|
-
* REF because the composer is remounted by a stretch, a tab switch and a
|
|
64
|
-
* reload while this handler is created once per deps record — the same reason
|
|
65
|
-
* the waiting pick keeps one.
|
|
66
|
-
*/
|
|
67
|
-
spawnWorktreeRef: { current: string | null };
|
|
68
|
-
/** Picks the composer made while a turn was streaming. Pushed onto the
|
|
69
|
-
* session here, immediately before the prompt they were meant for. */
|
|
70
|
-
deferredComposerPickRef: DeferredModelStore;
|
|
71
|
-
abortControllerRef: { current: AbortController | null };
|
|
72
|
-
setInputValue: (v: string) => void;
|
|
73
|
-
/** Surface a refused send. The optimistic bubbles are rolled back either
|
|
74
|
-
* way; without this the operator's turn simply VANISHES, which is the
|
|
75
|
-
* "prompt failed to send" report this exists to answer. */
|
|
76
|
-
reportActionError: (message: string) => void;
|
|
77
|
-
setSearchParams: (fn: (prev: URLSearchParams) => URLSearchParams, opts?: { replace?: boolean }) => void;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface ChatTimelineSendResult {
|
|
81
|
-
/** Steer the running turn; resolves with the outcome so a refusal can be
|
|
82
|
-
* reported (the composer is cleared before the request goes out). */
|
|
83
|
-
steerOmpAgent: (text: string, attachments: Attachment[]) => Promise<PromptDispatchResult>;
|
|
84
|
-
/** `model` re-applies a queued item's snapshot before the prompt runs
|
|
85
|
-
* (set_model / set_thinking_level RPC + prompt access mode). `busy: true`
|
|
86
|
-
* means omp REFUSED the prompt mid-turn — the caller queues it instead. */
|
|
87
|
-
executeSend: (
|
|
88
|
-
text: string,
|
|
89
|
-
attachments: Attachment[],
|
|
90
|
-
options?: { model?: QueuedMessageModel | null },
|
|
91
|
-
) => Promise<PromptDispatchResult>;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
29
|
export function useChatTimelineSend(deps: ChatTimelineSendDeps): ChatTimelineSendResult {
|
|
95
30
|
const {
|
|
96
31
|
folders,
|
|
@@ -115,6 +50,8 @@ export function useChatTimelineSend(deps: ChatTimelineSendDeps): ChatTimelineSen
|
|
|
115
50
|
deferredComposerPickRef,
|
|
116
51
|
accessModeRef,
|
|
117
52
|
spawnSelectionRef,
|
|
53
|
+
goalArmRef,
|
|
54
|
+
disarmGoal,
|
|
118
55
|
spawnWorktreeRef,
|
|
119
56
|
abortControllerRef,
|
|
120
57
|
setInputValue,
|
|
@@ -122,6 +59,48 @@ export function useChatTimelineSend(deps: ChatTimelineSendDeps): ChatTimelineSen
|
|
|
122
59
|
setSearchParams,
|
|
123
60
|
} = deps;
|
|
124
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Start the armed goal in `sessionId`, from the operator's own prompt.
|
|
64
|
+
*
|
|
65
|
+
* Awaited BEFORE the prompt leaves, so the order is a fact. Resolves TRUE when
|
|
66
|
+
* the goal consumed the prompt — the caller must then not send it again.
|
|
67
|
+
*
|
|
68
|
+
* - `create` — the record is written with `startTurn: false`, and the prompt
|
|
69
|
+
* that follows is the goal's first turn. The prompt is still sent.
|
|
70
|
+
* - `guided` — there is no objective yet (the model writes it at the end of
|
|
71
|
+
* the interview), so the operator's message IS the interview's opening
|
|
72
|
+
* turn: the extension renders its kickoff prompt with their words folded
|
|
73
|
+
* in (`<rough-goal>`) and runs that as turn one. The raw message is
|
|
74
|
+
* therefore NOT sent separately — it is already inside that turn.
|
|
75
|
+
*
|
|
76
|
+
* A refusal is reported rather than swallowed, and the prompt still goes out
|
|
77
|
+
* for `create`: the goal the operator set is missing, but their words are not
|
|
78
|
+
* the goal's business. A refused `guided` cannot fall back the same way — the
|
|
79
|
+
* interview kickoff is the extension's text — so it resolves false and the
|
|
80
|
+
* caller sends the message as an ordinary prompt.
|
|
81
|
+
*/
|
|
82
|
+
const startArmedGoal = useCallback(async (targetId: string, armed: ArmedGoal, promptText: string): Promise<boolean> => {
|
|
83
|
+
const posted = armed.kind === 'guided'
|
|
84
|
+
// `message` is the operator's prompt: the extension renders its kickoff
|
|
85
|
+
// with this as the visible content of turn one.
|
|
86
|
+
? await postModeCommand(targetId, 'goal', 'guided', { message: promptText, rough: '' })
|
|
87
|
+
: await postModeCommand(targetId, 'goal', 'create', {
|
|
88
|
+
objective: armed.objective,
|
|
89
|
+
...(armed.tokenBudget === undefined ? {} : { tokenBudget: armed.tokenBudget }),
|
|
90
|
+
...(armed.maxTurns === undefined ? {} : { maxTurns: armed.maxTurns }),
|
|
91
|
+
// The prompt that follows IS the goal's first turn. Without this the
|
|
92
|
+
// child would open its own hidden turn and the operator's message would
|
|
93
|
+
// arrive as a second turn — or be refused as `agent_busy`.
|
|
94
|
+
startTurn: false,
|
|
95
|
+
});
|
|
96
|
+
if (!posted.ok) {
|
|
97
|
+
reportActionError(`The goal was not started: ${posted.error ?? 'the child refused it'}`);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
disarmGoal();
|
|
101
|
+
return armed.kind === 'guided';
|
|
102
|
+
}, [disarmGoal, reportActionError]);
|
|
103
|
+
|
|
125
104
|
// Reads text-file attachments and builds the prompt + image payload for an
|
|
126
105
|
// omp delivery (mirror of executeSend's assembly block).
|
|
127
106
|
const prepareDeliverable = useCallback(async (
|
|
@@ -231,6 +210,13 @@ export function useChatTimelineSend(deps: ChatTimelineSendDeps): ChatTimelineSen
|
|
|
231
210
|
// Inline text-file contents into the prompt: the model sees the full file
|
|
232
211
|
// content as fenced blocks, not just the filename.
|
|
233
212
|
const promptText = await buildPromptText(text, textFiles);
|
|
213
|
+
// The armed goal is created HERE, at the fence of the prompt that will be
|
|
214
|
+
// its first turn — never earlier (nothing to act on) and never after the
|
|
215
|
+
// prompt (the goal would miss its opening turn). An armed INTERVIEW
|
|
216
|
+
// consumes this prompt as its kickoff, so nothing is sent after it.
|
|
217
|
+
const armed = goalArmRef.current;
|
|
218
|
+
const consumed = armed && sessionId ? await startArmedGoal(sessionId, armed, promptText) : false;
|
|
219
|
+
if (consumed) return { ok: true, busy: false };
|
|
234
220
|
const result = await ompAgent.sendPrompt(promptText, images, { accessMode: effectiveAccessMode });
|
|
235
221
|
if (!result.ok) {
|
|
236
222
|
// Roll back the optimistic bubbles on a failed send.
|
|
@@ -265,11 +251,17 @@ export function useChatTimelineSend(deps: ChatTimelineSendDeps): ChatTimelineSen
|
|
|
265
251
|
// here, and cleared below on success: a selection that outlived its
|
|
266
252
|
// spawn would re-apply to the NEXT new session the user opens.
|
|
267
253
|
const spawnModes = spawnSelectionRef.current;
|
|
254
|
+
// An armed goal is recorded between the spawn and the prompt: the id
|
|
255
|
+
// exists by then, and the prompt below is the goal's first turn. Not
|
|
256
|
+
// after the prompt — a fast turn could finish before the record landed,
|
|
257
|
+
// leaving a goal with no turn to act on.
|
|
258
|
+
const armed = goalArmRef.current;
|
|
268
259
|
const spawned = await ompAgent.sendNewPrompt(
|
|
269
260
|
promptText,
|
|
270
261
|
cwd,
|
|
271
262
|
images,
|
|
272
263
|
{ model: composerModel, thinkingLevel: composerThinking, accessMode: accessModeRef.current, modes: spawnModes },
|
|
264
|
+
armed ? (id) => startArmedGoal(id, armed, promptText) : undefined,
|
|
273
265
|
);
|
|
274
266
|
if (spawned) {
|
|
275
267
|
spawnSelectionRef.current = null;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The behaviour every dialog in the app owes the keyboard, in one hook.
|
|
8
|
+
*
|
|
9
|
+
* Three of the app's dialogs (Settings, About, the update sheet) shipped a scrim
|
|
10
|
+
* with NO `role="dialog"`, NO `aria-modal`, no Escape handler and no focus
|
|
11
|
+
* containment. Measured on the running console, with focus inside the About
|
|
12
|
+
* sheet: Escape did nothing, and one `Tab` from the last control landed on the
|
|
13
|
+
* page BEHIND the dialog (the "update" pill in the sidebar). A keyboard user
|
|
14
|
+
* could not close the sheet or reach its controls reliably, which is the whole
|
|
15
|
+
* of R-32.
|
|
16
|
+
*
|
|
17
|
+
* ## What it does, and why each part is not optional
|
|
18
|
+
*
|
|
19
|
+
* - **Focus moves into the panel on open.** Otherwise the first `Tab` walks the
|
|
20
|
+
* page behind the veil, which is exactly the measured failure.
|
|
21
|
+
* - **`Tab`/`Shift+Tab` wrap inside the panel.** Native `<dialog>` does this for
|
|
22
|
+
* free, but the app's shells are `div`s because the layouts place them inside
|
|
23
|
+
* transformed subtrees; the wrap is therefore stated here.
|
|
24
|
+
* - **Escape closes.** It is the key a keyboard user reaches for first.
|
|
25
|
+
* - **Focus returns to the opener.** A dialog that drops focus on `<body>` makes
|
|
26
|
+
* the next `Tab` start from the top of the page.
|
|
27
|
+
*
|
|
28
|
+
* A dialog also traps the POINTER implicitly: its scrim covers the viewport, so
|
|
29
|
+
* this hook only has to own the keyboard half.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
import { useEffect, useRef } from 'preact/hooks';
|
|
33
|
+
import type { RefObject } from 'preact';
|
|
34
|
+
|
|
35
|
+
/** Everything inside a dialog that can take focus, in visual order. */
|
|
36
|
+
const FOCUSABLE = [
|
|
37
|
+
'a[href]',
|
|
38
|
+
'button:not([disabled])',
|
|
39
|
+
'input:not([disabled]):not([type="hidden"])',
|
|
40
|
+
'select:not([disabled])',
|
|
41
|
+
'textarea:not([disabled])',
|
|
42
|
+
'[tabindex]:not([tabindex="-1"])',
|
|
43
|
+
].join(',');
|
|
44
|
+
|
|
45
|
+
/** Focusable descendants that are actually rendered (a phone leaves panels in the DOM). */
|
|
46
|
+
function focusablesIn(panel: HTMLElement): HTMLElement[] {
|
|
47
|
+
return Array.from(panel.querySelectorAll<HTMLElement>(FOCUSABLE)).filter(
|
|
48
|
+
(el) => el.getClientRects().length > 0,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface DialogBehaviourOptions {
|
|
53
|
+
/** Whether the dialog is on screen. The hook is inert while false. */
|
|
54
|
+
open: boolean;
|
|
55
|
+
/** Close request, from Escape. */
|
|
56
|
+
onClose: () => void;
|
|
57
|
+
/**
|
|
58
|
+
* Where focus lands on open. Defaults to the first focusable element; pass a
|
|
59
|
+
* node to land on a specific control (a phone's list view, a form's first
|
|
60
|
+
* field) or `null` for the panel itself.
|
|
61
|
+
*/
|
|
62
|
+
initialFocusRef?: RefObject<HTMLElement | null>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Wire a dialog's keyboard contract to `panelRef`.
|
|
67
|
+
*
|
|
68
|
+
* The panel must be the element that carries `role="dialog"`, so the label the
|
|
69
|
+
* caller sets there is the label a screen reader announces.
|
|
70
|
+
*/
|
|
71
|
+
export function useDialogBehaviour(panelRef: RefObject<HTMLElement | null>, options: DialogBehaviourOptions): void {
|
|
72
|
+
const { open, onClose, initialFocusRef } = options;
|
|
73
|
+
// The element that opened the dialog, restored on close. Held in a ref so a
|
|
74
|
+
// re-render does not overwrite it with an element inside the dialog.
|
|
75
|
+
const openerRef = useRef<HTMLElement | null>(null);
|
|
76
|
+
// The close callback changes identity on every parent render (it usually
|
|
77
|
+
// closes over state); reading it through a ref keeps the listeners installed
|
|
78
|
+
// exactly once per open instead of re-adding them on every render.
|
|
79
|
+
const closeRef = useRef(onClose);
|
|
80
|
+
closeRef.current = onClose;
|
|
81
|
+
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (!open) return;
|
|
84
|
+
const panel = panelRef.current;
|
|
85
|
+
if (!panel) return;
|
|
86
|
+
|
|
87
|
+
openerRef.current = (document.activeElement as HTMLElement | null) ?? null;
|
|
88
|
+
const initial = initialFocusRef?.current ?? focusablesIn(panel)[0] ?? panel;
|
|
89
|
+
// `preventScroll`: the panel may be taller than the viewport and the browser
|
|
90
|
+
// would otherwise jump to the control it just focused.
|
|
91
|
+
initial.focus({ preventScroll: true });
|
|
92
|
+
|
|
93
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
94
|
+
if (event.key === 'Escape') {
|
|
95
|
+
// A dialog opened ON TOP of another (the notes sheet over About) must
|
|
96
|
+
// close alone; the outer one never sees the key because this handler
|
|
97
|
+
// stops it. Registration order is mount order, which is stack order.
|
|
98
|
+
event.stopPropagation();
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
closeRef.current();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (event.key !== 'Tab') return;
|
|
104
|
+
const items = focusablesIn(panel);
|
|
105
|
+
if (items.length === 0) {
|
|
106
|
+
// Nothing to move to: keep focus on the panel rather than let the page
|
|
107
|
+
// behind the veil take it.
|
|
108
|
+
event.preventDefault();
|
|
109
|
+
panel.focus({ preventScroll: true });
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const first = items[0];
|
|
113
|
+
const last = items[items.length - 1];
|
|
114
|
+
const active = document.activeElement as HTMLElement | null;
|
|
115
|
+
// `!panel.contains(active)` covers the case the measurement found: focus
|
|
116
|
+
// was placed OUTSIDE on open (the panel had not mounted yet), and the
|
|
117
|
+
// first Tab must pull it in rather than continue from there.
|
|
118
|
+
if (!active || !panel.contains(active)) {
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
first.focus({ preventScroll: true });
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (event.shiftKey && active === first) {
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
last.focus({ preventScroll: true });
|
|
126
|
+
} else if (!event.shiftKey && active === last) {
|
|
127
|
+
event.preventDefault();
|
|
128
|
+
first.focus({ preventScroll: true });
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
document.addEventListener('keydown', onKeyDown, true);
|
|
133
|
+
return () => {
|
|
134
|
+
document.removeEventListener('keydown', onKeyDown, true);
|
|
135
|
+
// Restore only when the opener is still in the document: a dialog that
|
|
136
|
+
// closed because its opener was removed (a deleted row) has nothing to
|
|
137
|
+
// return to, and focusing a detached node silently does nothing.
|
|
138
|
+
const opener = openerRef.current;
|
|
139
|
+
if (opener && opener.isConnected) opener.focus({ preventScroll: true });
|
|
140
|
+
openerRef.current = null;
|
|
141
|
+
};
|
|
142
|
+
}, [open, panelRef, initialFocusRef]);
|
|
143
|
+
}
|
|
@@ -22,6 +22,7 @@ import { useKabmoSettingsWriter } from '@/client/hooks/settings/use-kabmo-settin
|
|
|
22
22
|
import { applyWindowChrome } from '@/client/hooks/ui/window-chrome';
|
|
23
23
|
import { DEFAULT_THEME_ID, resolveTheme } from '@/shared/lib/theme/catalog';
|
|
24
24
|
import { THEME_STYLE_ELEMENT_ID, themeStyleSheet } from '@/shared/lib/theme/css';
|
|
25
|
+
import { FIRST_FRAME_STYLE_ELEMENT_ID, firstFrameStyle } from '@/shared/lib/theme/first-frame';
|
|
25
26
|
|
|
26
27
|
/** Broadcast on every theme write. Detail is the new theme id. */
|
|
27
28
|
export const THEME_CHANGED_EVENT = 'omp:theme-changed';
|
|
@@ -53,6 +54,14 @@ export function initDocumentTheme(): void {
|
|
|
53
54
|
style.textContent = themeStyleSheet();
|
|
54
55
|
document.head.appendChild(style);
|
|
55
56
|
}
|
|
57
|
+
// A document served by an older shell has the rule without an id (or not at
|
|
58
|
+
// all). Create it here, so `applyDocumentTheme` below has one element to
|
|
59
|
+
// rewrite on every later palette change — including the very first one.
|
|
60
|
+
if (!document.getElementById(FIRST_FRAME_STYLE_ELEMENT_ID)) {
|
|
61
|
+
const firstFrame = document.createElement('style');
|
|
62
|
+
firstFrame.id = FIRST_FRAME_STYLE_ELEMENT_ID;
|
|
63
|
+
document.head.appendChild(firstFrame);
|
|
64
|
+
}
|
|
56
65
|
applyDocumentTheme(currentThemeId());
|
|
57
66
|
}
|
|
58
67
|
|
|
@@ -70,6 +79,14 @@ export function applyDocumentTheme(theme: string): void {
|
|
|
70
79
|
const root = document.documentElement;
|
|
71
80
|
root.dataset.theme = palette.id;
|
|
72
81
|
root.dataset.themeVariant = palette.variant;
|
|
82
|
+
// The inline first-frame rule is UNLAYERED, so it outranks `body` in the
|
|
83
|
+
// bundle at any specificity — which is why it is still the winner after a
|
|
84
|
+
// runtime switch, and why it has to be rewritten here. Measured: choosing a
|
|
85
|
+
// light palette left `body` painted `rgb(30,34,42)` from the previous dark
|
|
86
|
+
// one while `--theme-canvas` had already moved, so the whole window sat on
|
|
87
|
+
// the old ground. One rule, one writer (`shared/lib/theme/first-frame.ts`).
|
|
88
|
+
const firstFrame = document.getElementById(FIRST_FRAME_STYLE_ELEMENT_ID);
|
|
89
|
+
if (firstFrame) firstFrame.textContent = firstFrameStyle(palette);
|
|
73
90
|
// The chrome color is not simply the palette's canvas: it has to match the
|
|
74
91
|
// surface at the TOP of the window, which differs per layout. See
|
|
75
92
|
// `shared/lib/theme/chrome.ts` for the rule.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The tab strip's Copy Path action.
|
|
8
|
+
*
|
|
9
|
+
* A tab's path may be a diff's rather than a file's, so the strip has no
|
|
10
|
+
* workspace scope of its own to resolve it from; the layout owns the tabs and
|
|
11
|
+
* therefore the answer. Extracted from the layout because that component is at
|
|
12
|
+
* the repo's size ceiling and the action has no other dependency.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { useCallback } from 'preact/hooks';
|
|
16
|
+
import type { OpenedFile } from '@/shared/types/fs';
|
|
17
|
+
|
|
18
|
+
export function useCopyTabPath(): (tab: OpenedFile) => void {
|
|
19
|
+
return useCallback((tab: OpenedFile) => {
|
|
20
|
+
if (!tab.path) return;
|
|
21
|
+
void navigator.clipboard?.writeText(tab.path);
|
|
22
|
+
}, []);
|
|
23
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The phone's back gesture, in the one order the screens are stacked.
|
|
8
|
+
*
|
|
9
|
+
* Order is what the user sees, innermost first: the full-screen editor and diff
|
|
10
|
+
* cover everything, then the settings sheet, then the drawer screens, and only
|
|
11
|
+
* then does the shell walk WebView history. Without this, back reopened the
|
|
12
|
+
* previous session while leaving the drawer that opened it on screen — the
|
|
13
|
+
* screens live in component state, not in the URL, so nothing else could know
|
|
14
|
+
* the order.
|
|
15
|
+
*
|
|
16
|
+
* A hook rather than an effect inline in the layout: it owns a subscription, and
|
|
17
|
+
* the layout that calls it is already at the repo's size ceiling.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { useEffect } from 'preact/hooks';
|
|
21
|
+
import { registerBackHandler } from '@/client/lib/native/back';
|
|
22
|
+
|
|
23
|
+
export interface MobileBackStack {
|
|
24
|
+
/** The full-screen editor is open. */
|
|
25
|
+
editorOpen: boolean;
|
|
26
|
+
/** The full-screen diff is open. */
|
|
27
|
+
diffOpen: boolean;
|
|
28
|
+
/** The settings sheet is open. */
|
|
29
|
+
settingsOpen: boolean;
|
|
30
|
+
/** Anything other than the chat screen is showing. */
|
|
31
|
+
offMainScreen: boolean;
|
|
32
|
+
onCloseEditor: () => void;
|
|
33
|
+
onCloseDiff: () => void;
|
|
34
|
+
onCloseSettings: () => void;
|
|
35
|
+
onReturnToMain: () => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function useMobileBackStack(stack: MobileBackStack): void {
|
|
39
|
+
const {
|
|
40
|
+
editorOpen,
|
|
41
|
+
diffOpen,
|
|
42
|
+
settingsOpen,
|
|
43
|
+
offMainScreen,
|
|
44
|
+
onCloseEditor,
|
|
45
|
+
onCloseDiff,
|
|
46
|
+
onCloseSettings,
|
|
47
|
+
onReturnToMain,
|
|
48
|
+
} = stack;
|
|
49
|
+
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
return registerBackHandler(() => {
|
|
52
|
+
if (editorOpen) {
|
|
53
|
+
onCloseEditor();
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
if (diffOpen) {
|
|
57
|
+
onCloseDiff();
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
if (settingsOpen) {
|
|
61
|
+
onCloseSettings();
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
if (offMainScreen) {
|
|
65
|
+
onReturnToMain();
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
});
|
|
70
|
+
}, [editorOpen, diffOpen, settingsOpen, offMainScreen, onCloseEditor, onCloseDiff, onCloseSettings, onReturnToMain]);
|
|
71
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* No ICON is painted with a Tailwind PALETTE class.
|
|
8
|
+
*
|
|
9
|
+
* `DESIGN.md` says it in one line — never write a colour in a component, every
|
|
10
|
+
* colour is a `var(--theme-*)` or a Tailwind class mapped to one — and an icon is
|
|
11
|
+
* where the rule kept being broken, because a palette class there does not look
|
|
12
|
+
* wrong on the developer's own theme. Hence a source scan rather than a review
|
|
13
|
+
* note.
|
|
14
|
+
*
|
|
15
|
+
* ## The measurements behind it
|
|
16
|
+
*
|
|
17
|
+
* Over the 32 light palettes this build ships: `text-amber-500` reaches
|
|
18
|
+
* **1.64:1**, `text-sky-400` **1.63:1**, `text-emerald-500` **1.93:1**,
|
|
19
|
+
* `text-emerald-600` **2.87:1** — the floor for a graphic is 3:1. Every one of
|
|
20
|
+
* them was on an icon that MEANT something (a save in progress, a favourite
|
|
21
|
+
* star, a connected check), so the colour was the message and the message was
|
|
22
|
+
* invisible. A fixed rung also ignores the theme: it is correct for none of the
|
|
23
|
+
* 63 palettes and legible on about half.
|
|
24
|
+
*
|
|
25
|
+
* The theme's signal tokens are the answer, and they are not a matter of taste:
|
|
26
|
+
* `signalTextColor` solved `text-success` to 4.50:1 minimum on every palette of
|
|
27
|
+
* both variants.
|
|
28
|
+
*
|
|
29
|
+
* ## Scope: ICONS, not every coloured surface
|
|
30
|
+
*
|
|
31
|
+
* This walks the `<Icon className=…>` elements of files that import
|
|
32
|
+
* `lucide-preact`, and the icon modules that draw their own `<svg>`. It
|
|
33
|
+
* deliberately does NOT flag:
|
|
34
|
+
*
|
|
35
|
+
* - **A categorical chart series** (`TokenDistributionBar`), where the colours
|
|
36
|
+
* distinguish four series from each other rather than carry a status, and the
|
|
37
|
+
* theme has no token for "series 3".
|
|
38
|
+
* - **A decorative dot or gradient** (`raw-messages.ts`'s per-role dots, the
|
|
39
|
+
* wordmark's brand gradient), which is not an icon and is not what this rule
|
|
40
|
+
* is about.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
import { describe, expect, test } from 'bun:test';
|
|
44
|
+
import { Glob } from 'bun';
|
|
45
|
+
|
|
46
|
+
/** The Tailwind palette families that are NOT the theme's tokens. */
|
|
47
|
+
const FAMILIES =
|
|
48
|
+
'slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose';
|
|
49
|
+
|
|
50
|
+
/** `text-amber-500`, `fill-sky-400`, … — colour utilities, with a numeric rung. */
|
|
51
|
+
const PALETTE_CLASS = new RegExp(
|
|
52
|
+
`\\b(?:text|fill|stroke|bg|ring)-(?:${FAMILIES})-(?:50|[1-9]00|950)\\b(?:/\\d+)?`,
|
|
53
|
+
'g',
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
/** Icon modules that render their own `<svg>` instead of a Lucide component. */
|
|
57
|
+
const ICON_MODULE = /components\/(?:common|settings\/categories)\/[^/]*(?:icon|mark|logo|wordmark)[^/]*\//;
|
|
58
|
+
|
|
59
|
+
async function offendingIcons(): Promise<string[]> {
|
|
60
|
+
const found: string[] = [];
|
|
61
|
+
for await (const path of new Glob('src/client/**/*.{ts,tsx}').scan('.')) {
|
|
62
|
+
if (/\.test\.(ts|tsx)$/.test(path)) continue;
|
|
63
|
+
const source = await Bun.file(path).text();
|
|
64
|
+
const importsLucide = source.includes("from 'lucide-preact'");
|
|
65
|
+
if (!importsLucide && !ICON_MODULE.test(path)) continue;
|
|
66
|
+
|
|
67
|
+
// The className value of a Lucide element, or of an `<svg>` in an icon module.
|
|
68
|
+
const elements = importsLucide
|
|
69
|
+
? [...source.matchAll(/<([A-Z][A-Za-z0-9]*)\b[^>]*?className=(?:"([^"]*)"|\{`([^`]*)`\})[^>]*>/g)].filter(
|
|
70
|
+
([, name]) => !['div', 'span', 'button'].includes(name!),
|
|
71
|
+
)
|
|
72
|
+
: [...source.matchAll(/<svg\b[^>]*?className=(?:"([^"]*)"|\{`([^`]*)`\})[^>]*>/g)];
|
|
73
|
+
|
|
74
|
+
for (const element of elements) {
|
|
75
|
+
const classes = element[1] ?? element[2] ?? '';
|
|
76
|
+
for (const match of classes.matchAll(PALETTE_CLASS)) {
|
|
77
|
+
const line = source.slice(0, element.index).split('\n').length;
|
|
78
|
+
found.push(`${path}:${line} ${match[0]}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return found;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
describe('an icon is painted by the theme, never by a palette rung', () => {
|
|
86
|
+
test('no icon carries a Tailwind palette class', async () => {
|
|
87
|
+
// Measured on the 32 light palettes: amber-500 1.64:1, sky-400 1.63:1,
|
|
88
|
+
// emerald-500 1.93:1, emerald-600 2.87:1 — under the 3:1 non-text floor, on
|
|
89
|
+
// icons whose colour IS the message. The signal tokens clear it everywhere.
|
|
90
|
+
const offenders = await offendingIcons();
|
|
91
|
+
expect(offenders, offenders.join('\n')).toEqual([]);
|
|
92
|
+
});
|
|
93
|
+
});
|