@kabmo-labs/kabmo 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -7
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +523 -441
- package/dist/client/static/js/{index-rerjq5th.js → index-fcee4c13.js} +828 -818
- package/dist/client/static/js/index-sxdw908m.css +1 -0
- package/marketplace/plugins/command-runner/package.json +3 -2
- package/marketplace/plugins/git-forge/package.json +3 -2
- package/marketplace/plugins/session-info/package.json +3 -2
- package/marketplace/plugins/stats/package.json +3 -2
- package/package.json +3 -1
- package/src/client/components/auth/login-screen/index.tsx +2 -1
- package/src/client/components/common/ComposerPicker.tsx +1 -1
- package/src/client/components/common/FolderPicker.tsx +2 -2
- package/src/client/components/common/MarkdownRenderer.tsx +136 -89
- package/src/client/components/common/Modal.tsx +2 -2
- package/src/client/components/common/PWAInstallButton.tsx +2 -2
- package/src/client/components/common/ViewportSelector.tsx +1 -1
- package/src/client/components/common/anchored-menu/index.test.tsx +141 -0
- package/src/client/components/common/anchored-menu/index.tsx +147 -0
- package/src/client/components/common/batch-selection/SelectionCheckbox.tsx +2 -1
- package/src/client/components/common/brand-wordmark/index.test.tsx +13 -2
- package/src/client/components/common/brand-wordmark/index.tsx +13 -2
- package/src/client/components/common/checkbox/style.test.ts +139 -0
- package/src/client/components/common/checkbox/style.ts +51 -0
- package/src/client/components/common/context-usage-button/index.tsx +2 -2
- package/src/client/components/common/file-icon/index.tsx +23 -9
- package/src/client/components/common/header-controls/MoreMenu.tsx +1 -1
- package/src/client/components/common/markdown-review/ReviewPopover.tsx +144 -0
- package/src/client/components/common/markdown-review/ReviewSummary.tsx +108 -0
- package/src/client/components/common/markdown-review/index.tsx +129 -0
- package/src/client/components/common/panel-mark/index.tsx +97 -0
- package/src/client/components/common/provider-icon/glyphs.test.ts +1 -1
- package/src/client/components/common/provider-icon/index.test.ts +14 -0
- package/src/client/components/common/provider-icon/index.tsx +4 -0
- package/src/client/components/common/provider-icon/resolve.test.ts +8 -7
- package/src/client/components/common/provider-icon/resolve.ts +16 -3
- package/src/client/components/common/server-control/Panel.tsx +33 -23
- package/src/client/components/common/server-control/index.test.tsx +11 -5
- package/src/client/components/common/server-control/index.tsx +10 -8
- package/src/client/components/common/session-actions-menu/index.tsx +1 -1
- package/src/client/components/common/toolbar-row/index.tsx +1 -1
- package/src/client/components/layout/ActivityBar.tsx +22 -3
- package/src/client/components/layout/LeftDock.tsx +9 -2
- package/src/client/components/layout/PanelVisibilityMenu.tsx +1 -1
- package/src/client/components/layout/WindowAura.tsx +27 -0
- package/src/client/components/layout/desktop-layout/LeftColumn.tsx +1 -1
- package/src/client/components/layout/desktop-layout/TopNavbar.tsx +2 -2
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +11 -2
- package/src/client/components/layout/desktop-layout/index.tsx +3 -1
- package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +44 -23
- package/src/client/components/layout/session-sidebar/CategoryHeader.worktree.test.tsx +36 -17
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +8 -7
- package/src/client/components/layout/session-sidebar/Header.tsx +1 -1
- package/src/client/components/layout/session-sidebar/OverflowMenu.tsx +1 -1
- package/src/client/components/layout/session-sidebar/Toolbar.tsx +1 -1
- package/src/client/components/layout/session-sidebar/about-modal/NotesDialog.tsx +94 -0
- package/src/client/components/layout/session-sidebar/about-modal/VersionLine.test.tsx +68 -0
- package/src/client/components/layout/session-sidebar/about-modal/VersionLine.tsx +36 -0
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +57 -34
- package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +1 -1
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +40 -14
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +7 -6
- package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +1 -1
- package/src/client/components/layout/session-sidebar/new-workspace-modal/index.tsx +2 -2
- package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +2 -1
- package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +2 -2
- package/src/client/components/layout/update-popup/ReleaseNotes.tsx +8 -3
- package/src/client/components/layout/update-popup/index.tsx +5 -1
- package/src/client/components/mobile/LayoutWrapper.tsx +3 -1
- package/src/client/components/mobile/mobile-main-view/Header.tsx +2 -2
- package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +13 -15
- package/src/client/components/mobile/mobile-right-sidebar/Header.tsx +23 -1
- package/src/client/components/mobile/mobile-right-sidebar/MissingFileBanner.tsx +30 -0
- package/src/client/components/mobile/mobile-right-sidebar/PreviewScroller.tsx +18 -2
- package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +1 -1
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +22 -67
- package/src/client/components/mobile/mobile-session-sidebar/ItemMenu.tsx +110 -0
- package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +1 -1
- package/src/client/components/mobile/panel-chips.tsx +10 -2
- package/src/client/components/settings/Modal.tsx +4 -4
- package/src/client/components/settings/ProjectSelectorDropdown.tsx +2 -2
- package/src/client/components/settings/SettingsSidebarList.tsx +20 -0
- package/src/client/components/settings/apply-side-effects.test.ts +30 -0
- package/src/client/components/settings/apply-side-effects.ts +14 -0
- package/src/client/components/settings/categories/AgentSettings.tsx +23 -50
- package/src/client/components/settings/categories/AppearanceSettings.tsx +6 -0
- package/src/client/components/settings/categories/CommandSettings.tsx +2 -2
- package/src/client/components/settings/categories/McpSettings.tsx +4 -21
- package/src/client/components/settings/categories/OmpSettings.tsx +147 -194
- package/src/client/components/settings/categories/SkillSettings.tsx +2 -2
- package/src/client/components/settings/categories/TokenUsageSettings.tsx +211 -229
- package/src/client/components/settings/categories/agent-settings/DetailPane.tsx +229 -237
- package/src/client/components/settings/categories/agent-settings/ModelPicker.tsx +71 -0
- package/src/client/components/settings/categories/agent-settings/SidebarList.tsx +9 -2
- package/src/client/components/settings/categories/agent-settings/levels.ts +38 -0
- package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +2 -1
- package/src/client/components/settings/categories/appearance-settings/EditorTypingSection.tsx +2 -1
- package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +144 -0
- package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.test.tsx +120 -0
- package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.tsx +180 -0
- package/src/client/components/settings/categories/behavior-settings/Editor.tsx +27 -7
- package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +23 -5
- package/src/client/components/settings/categories/command-settings/DetailPane.tsx +75 -33
- package/src/client/components/settings/categories/command-settings/SidebarList.tsx +7 -0
- package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +93 -77
- package/src/client/components/settings/categories/mcp-settings/EnvVarsSection.tsx +83 -0
- package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +28 -15
- package/src/client/components/settings/categories/mcp-settings/SidebarList.tsx +20 -0
- package/src/client/components/settings/categories/omp-settings/ConfigTabs.tsx +97 -36
- package/src/client/components/settings/categories/omp-settings/EngineHeader.tsx +151 -0
- package/src/client/components/settings/categories/omp-settings/ExtensionsPanel.tsx +68 -32
- package/src/client/components/settings/categories/omp-settings/OrderedChips.tsx +119 -0
- package/src/client/components/settings/categories/omp-settings/PresetBar.tsx +14 -7
- package/src/client/components/settings/categories/omp-settings/RoleEditor.tsx +15 -6
- package/src/client/components/settings/categories/omp-settings/RowEditor.tsx +165 -226
- package/src/client/components/settings/categories/omp-settings/types.ts +28 -0
- package/src/client/components/settings/categories/panel-plugins/AvailableList.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/BuiltinList.tsx +21 -3
- package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +51 -2
- package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +43 -10
- package/src/client/components/settings/categories/plugin-settings/DetailPane.tsx +2 -1
- package/src/client/components/settings/categories/plugin-settings/SettingsSection.tsx +2 -1
- package/src/client/components/settings/categories/project-settings/ModelDropdown.tsx +1 -1
- package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +2 -1
- package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +2 -2
- package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +3 -2
- package/src/client/components/settings/categories/provider-settings/LogoutProviderModal.tsx +2 -2
- package/src/client/components/settings/categories/skill-catalog/GitImportPanel.tsx +3 -2
- package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +37 -8
- package/src/client/components/settings/categories/skill-settings/DetailPane.tsx +34 -14
- package/src/client/components/settings/categories/skill-settings/SidebarList.tsx +21 -0
- package/src/client/components/settings/categories/skill-settings/pane.test.tsx +15 -6
- package/src/client/components/settings/categories/token-usage-settings/Breakdown.tsx +242 -102
- package/src/client/components/settings/categories/token-usage-settings/Chart.tsx +130 -56
- package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +135 -0
- package/src/client/components/settings/categories/token-usage-settings/MetricsGrid.tsx +55 -33
- package/src/client/components/settings/categories/token-usage-settings/Provenance.tsx +59 -0
- package/src/client/components/settings/categories/token-usage-settings/panel.test.tsx +239 -0
- package/src/client/components/workspace/browser-panel/Screencast.test.ts +1 -0
- package/src/client/components/workspace/browser-panel/Screencast.tsx +17 -22
- package/src/client/components/workspace/browser-panel/TabStrip.test.tsx +158 -0
- package/src/client/components/workspace/browser-panel/TabStrip.tsx +90 -0
- package/src/client/components/workspace/browser-panel/index.tsx +50 -4
- package/src/client/components/workspace/browser-toolbar/index.tsx +41 -1
- package/src/client/components/workspace/btw-panel/TopicMenu.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/NewChatModal.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/UndoConfirmModal.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +13 -2
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.tsx +4 -3
- package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/plan-review/index.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +2 -6
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.test.ts +88 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +24 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.test.ts +34 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +5 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactChip.tsx +7 -6
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.test.tsx +237 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +191 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +1 -1
- package/src/client/components/workspace/context-panel/CostBreakdownPopover.tsx +1 -1
- package/src/client/components/workspace/diff-panel/MergeDiffView.tsx +21 -7
- package/src/client/components/workspace/diff-panel/changes.test.ts +51 -0
- package/src/client/components/workspace/diff-panel/changes.ts +28 -12
- package/src/client/components/workspace/diff-panel/index.tsx +2 -2
- package/src/client/components/workspace/diff-panel/merge.test.ts +28 -0
- package/src/client/components/workspace/diff-panel/merge.ts +21 -1
- package/src/client/components/workspace/editor/Body.tsx +7 -0
- package/src/client/components/workspace/editor/FileDocument.tsx +15 -21
- package/src/client/components/workspace/editor/FilePane.tsx +12 -0
- package/src/client/components/workspace/editor/PluginRail.tsx +1 -1
- package/src/client/components/workspace/editor/PreviewPane.tsx +70 -0
- package/src/client/components/workspace/editor/SaveDeletedFileModal.tsx +2 -2
- package/src/client/components/workspace/editor/TabContextMenu.tsx +1 -1
- package/src/client/components/workspace/editor/Tabs.tsx +1 -1
- package/src/client/components/workspace/editor/Toolbar.tsx +17 -1
- package/src/client/components/workspace/editor/index.tsx +25 -22
- package/src/client/components/workspace/editor/toolbar-clusters.test.ts +14 -0
- package/src/client/components/workspace/editor/toolbar-clusters.tsx +12 -86
- package/src/client/components/workspace/editor/toolbar-toggle.tsx +53 -0
- package/src/client/components/workspace/editor/toolbar-write-clusters.tsx +112 -0
- package/src/client/components/workspace/file-explorer/ContextMenu.tsx +1 -1
- package/src/client/components/workspace/file-explorer/Modals.tsx +10 -10
- package/src/client/components/workspace/file-explorer/RootMenu.tsx +1 -1
- package/src/client/components/workspace/git-panel/BranchToolbar.test.tsx +130 -0
- package/src/client/components/workspace/git-panel/BranchToolbar.tsx +21 -11
- package/src/client/components/workspace/git-panel/CommitBox.tsx +2 -1
- package/src/client/components/workspace/git-panel/Modals.tsx +2 -2
- package/src/client/components/workspace/git-panel/StashSection.tsx +2 -1
- package/src/client/components/workspace/git-panel/branch-modal/DeleteDialog.tsx +2 -1
- package/src/client/components/workspace/git-panel/branch-modal/RenameDialog.tsx +2 -1
- package/src/client/components/workspace/git-panel/commit-modal/index.tsx +2 -2
- package/src/client/components/workspace/git-panel/commit-modal.test.ts +5 -3
- package/src/client/components/workspace/git-panel/index.tsx +7 -0
- package/src/client/components/workspace/model-dropdown/Panel.tsx +1 -1
- package/src/client/components/workspace/model-dropdown/SpecsTooltip.tsx +1 -1
- package/src/client/components/workspace/plugin-panel/catalog.tsx +7 -0
- package/src/client/components/workspace/plugin-panel/resolve.tsx +4 -0
- package/src/client/components/workspace/search-panel/Body.tsx +1 -1
- package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +1 -1
- package/src/client/components/workspace/user-browser-panel/AddressBar.tsx +5 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateBar.test.tsx +201 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateBar.tsx +112 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateLayer.test.tsx +225 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateLayer.tsx +217 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateTarget.tsx +99 -0
- package/src/client/components/workspace/user-browser-panel/Frame.tsx +30 -1
- package/src/client/components/workspace/user-browser-panel/index.tsx +81 -2
- package/src/client/data/agent-data/builtin.ts +0 -10
- package/src/client/data/agent-data/orchestrator.ts +0 -45
- package/src/client/data/agent-data/specialist.ts +0 -100
- package/src/client/data/mock/token-usage.ts +170 -120
- package/src/client/data/settings/omp-schema.json +33 -1
- package/src/client/glass.css +785 -0
- package/src/client/glass.test.ts +346 -0
- package/src/client/hooks/browser/use-annotate.test.ts +143 -0
- package/src/client/hooks/browser/use-annotate.ts +98 -0
- package/src/client/hooks/browser/use-close-tab.test.ts +148 -0
- package/src/client/hooks/browser/use-close-tab.ts +67 -0
- package/src/client/hooks/browser/use-screencast.ts +13 -1
- package/src/client/hooks/chat/composer/browser-context.test.ts +117 -0
- package/src/client/hooks/chat/composer/browser-context.ts +40 -16
- package/src/client/hooks/chat/composer/items.test.ts +1 -1
- package/src/client/hooks/chat/composer/review-context.ts +38 -0
- package/src/client/hooks/chat/composer/use-draft.test.ts +132 -0
- package/src/client/hooks/chat/composer/use-draft.ts +31 -2
- package/src/client/hooks/chat/timeline/row-window.test.ts +15 -2
- package/src/client/hooks/editor/use-document-annotations.ts +124 -0
- package/src/client/hooks/editor/use-editor-panel-ui.ts +52 -0
- package/src/client/hooks/editor/use-file-review-mode.ts +35 -0
- package/src/client/hooks/editor/use-preview-review.ts +148 -0
- package/src/client/hooks/settings/agents.ts +149 -0
- package/src/client/hooks/settings/crud-list.test.ts +28 -6
- package/src/client/hooks/settings/crud-list.ts +96 -57
- package/src/client/hooks/settings/omp-config.ts +164 -0
- package/src/client/hooks/settings/useTokenUsage.ts +125 -0
- package/src/client/hooks/settings/write-feedback.test.ts +104 -0
- package/src/client/hooks/settings/write-feedback.ts +63 -0
- package/src/client/hooks/ui/glass-support.ts +57 -0
- package/src/client/hooks/ui/icon-style.ts +59 -0
- package/src/client/hooks/ui/markdown-hydration.ts +125 -0
- package/src/client/hooks/ui/stuck-header.test.ts +188 -0
- package/src/client/hooks/ui/stuck-header.ts +91 -0
- package/src/client/hooks/ui/style-attributes.test.ts +120 -0
- package/src/client/hooks/ui/surface-style.ts +56 -0
- package/src/client/hooks/ui/updates/index.test.ts +100 -1
- package/src/client/hooks/ui/updates/index.ts +50 -0
- package/src/client/hooks/ui/updates/notes.test.ts +138 -0
- package/src/client/hooks/ui/updates/notes.ts +57 -0
- package/src/client/hooks/workspace/panel-hues.ts +23 -0
- package/src/client/lib/browser/element-at.test.ts +229 -0
- package/src/client/lib/browser/element-at.ts +139 -0
- package/src/client/lib/review/client.ts +73 -0
- package/src/client/lib/router/search-params.ts +42 -20
- package/src/client/main.tsx +10 -0
- package/src/client/tailwind.css +329 -11
- package/src/server/lib/assets/shell-attributes.server.ts +80 -0
- package/src/server/lib/assets/shell-attributes.test.ts +86 -0
- package/src/server/lib/btw/lifecycle.server.ts +2 -2
- package/src/server/lib/db/schema.ts +7 -0
- package/src/server/lib/db/seed-terminal.test.ts +4 -0
- package/src/server/lib/omp/config/agent-definitions.test.ts +273 -0
- package/src/server/lib/omp/config/agents.ts +231 -61
- package/src/server/lib/omp/config/definitions.test.ts +9 -105
- package/src/server/lib/omp/config/extensions.ts +16 -7
- package/src/server/lib/omp/config/omp-config-files.test.ts +27 -0
- package/src/server/lib/omp/rpc/constants.test.ts +11 -0
- package/src/server/lib/omp/rpc/constants.ts +15 -0
- package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +1 -0
- package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +2 -30
- package/src/server/lib/omp/rpc/frame-fold.test.ts +55 -0
- package/src/server/lib/omp/rpc/frame-fold.ts +4 -0
- package/src/server/lib/omp/rpc/manager.ts +2 -2
- package/src/server/lib/omp/rpc/process-helpers.ts +11 -0
- package/src/server/lib/omp/rpc/process.test.ts +106 -0
- package/src/server/lib/omp/rpc/process.ts +39 -18
- package/src/server/lib/omp/rpc/run-settle.server.ts +12 -0
- package/src/server/lib/omp/rpc/run-settle.test.ts +22 -0
- package/src/server/lib/omp/rpc/session-command-guards.ts +5 -0
- package/src/server/lib/omp/rpc/session-commands.test.ts +9 -1
- package/src/server/lib/omp/rpc/session-commands.ts +17 -3
- package/src/server/lib/omp/rpc/terminal-settle.ts +29 -7
- package/src/server/lib/omp/rpc/utility-agent-dir.test.ts +134 -0
- package/src/server/lib/omp/rpc/utility-agent-dir.ts +138 -0
- package/src/server/lib/omp/rpc/utility.ts +12 -0
- package/src/server/lib/panels/bundled-catalog.server.ts +1 -0
- package/src/server/lib/panels/manifest.test.ts +20 -0
- package/src/server/lib/panels/manifest.ts +12 -0
- package/src/server/lib/panels/scan.server.ts +4 -0
- package/src/server/lib/queue/delivery-dispatch.server.test.ts +48 -0
- package/src/server/lib/queue/delivery-harness.ts +8 -4
- package/src/server/lib/queue/delivery.server.test.ts +29 -0
- package/src/server/lib/queue/delivery.server.ts +39 -0
- package/src/server/lib/queue/store.server.test.ts +22 -2
- package/src/server/lib/queue/store.server.ts +33 -11
- package/src/server/lib/review/schema.server.ts +45 -0
- package/src/server/lib/review/store.server.ts +138 -0
- package/src/server/lib/terminal/attach-replay.test.ts +132 -0
- package/src/server/lib/terminal/output.test.ts +166 -0
- package/src/server/lib/terminal/output.ts +104 -0
- package/src/server/lib/terminal/runtime.server.ts +5 -0
- package/src/server/lib/terminal/send-result.test.ts +33 -0
- package/src/server/lib/terminal/send-result.ts +32 -0
- package/src/server/lib/terminal/session.server.ts +45 -11
- package/src/server/lib/terminal/store-liveness.test.ts +4 -0
- package/src/server/lib/updates/active-notes.test.ts +149 -0
- package/src/server/lib/updates/active-notes.ts +75 -0
- package/src/server/lib/updates/changelog-file.ts +42 -11
- package/src/server/lib/updates/changelog.test.ts +15 -1
- package/src/server/lib/updates/omp.ts +42 -15
- package/src/server/lib/updates/release-url.ts +27 -1
- package/src/server/lib/usage/index-parse.test.ts +200 -0
- package/src/server/lib/usage/index-parse.ts +178 -0
- package/src/server/lib/usage/index-query.server.ts +248 -0
- package/src/server/lib/usage/index-scan.server.ts +343 -0
- package/src/server/lib/usage/index-schema.server.ts +82 -0
- package/src/server/lib/usage/index.test.ts +234 -0
- package/src/server/lib/usage/providers.server.ts +4 -53
- package/src/server/plugins/ssr.ts +22 -5
- package/src/server/routes/browser/index.ts +3 -0
- package/src/server/routes/browser/stream.ts +31 -2
- package/src/server/routes/browser/tabs.test.ts +94 -0
- package/src/server/routes/browser/tabs.ts +85 -0
- package/src/server/routes/index.ts +2 -0
- package/src/server/routes/review/bindings.ts +11 -0
- package/src/server/routes/review/index.ts +127 -0
- package/src/server/routes/review/routes.test.ts +191 -0
- package/src/server/routes/settings/agents.test.ts +180 -0
- package/src/server/routes/settings/agents.ts +95 -102
- package/src/server/routes/settings/mcp.test.ts +135 -0
- package/src/server/routes/settings/mcp.ts +14 -6
- package/src/server/routes/settings/settings-store-routes.test.ts +6 -113
- package/src/server/routes/telemetry/tokens.test.ts +145 -0
- package/src/server/routes/telemetry/tokens.ts +70 -149
- package/src/server/routes/terminal/ws.ts +6 -5
- package/src/server/routes/updates/index.ts +2 -0
- package/src/server/routes/updates/notes.ts +34 -0
- package/src/server/routes/updates/routes.test.ts +49 -0
- package/src/shared/lib/browser/annotate.test.ts +283 -0
- package/src/shared/lib/browser/annotate.ts +231 -0
- package/src/shared/lib/browser/browser-viewer.test.ts +26 -4
- package/src/shared/lib/browser/frame-gate.test.ts +91 -0
- package/src/shared/lib/browser/frame-gate.ts +69 -0
- package/src/shared/lib/browser/frame-params.test.ts +43 -0
- package/src/shared/lib/browser/frame-params.ts +60 -0
- package/src/shared/lib/browser/frame-pipeline.test.ts +132 -0
- package/src/shared/lib/browser/frame-pipeline.ts +80 -0
- package/src/shared/lib/browser/page-context.ts +60 -4
- package/src/shared/lib/browser/snapshot.test.ts +115 -0
- package/src/shared/lib/browser/snapshot.ts +112 -0
- package/src/shared/lib/browser/tab-close.test.ts +74 -0
- package/src/shared/lib/browser/tab-close.ts +77 -0
- package/src/shared/lib/browser/viewer.ts +45 -26
- package/src/shared/lib/chat/timeline/block-chrome.ts +19 -0
- package/src/shared/lib/chat/timeline/tool-render-mode.ts +17 -4
- package/src/shared/lib/chat/tool/artifact.ts +55 -20
- package/src/shared/lib/chat/tool/bash-facts.ts +96 -0
- package/src/shared/lib/chat/tool/minimized.test.ts +98 -0
- package/src/shared/lib/chat/tool/minimized.ts +64 -0
- package/src/shared/lib/chat/tool/summary.test.ts +28 -8
- package/src/shared/lib/chat/tool/summary.ts +3 -32
- package/src/shared/lib/icons/file-brand-color.ts +38 -0
- package/src/shared/lib/icons/icon-paint-css.test.ts +234 -0
- package/src/shared/lib/icons/icon-paint-css.ts +284 -0
- package/src/shared/lib/icons/icon-paint-panel.ts +100 -0
- package/src/shared/lib/icons/tint-hues.generated.ts +230 -0
- package/src/shared/lib/icons/tint.test.ts +273 -0
- package/src/shared/lib/icons/tint.ts +219 -0
- package/src/shared/lib/markdown/blocks/anchor.ts +63 -0
- package/src/shared/lib/markdown/blocks/blocks.test.ts +141 -0
- package/src/shared/lib/markdown/blocks/renderer.ts +120 -0
- package/src/shared/lib/markdown/blocks/scan.ts +100 -0
- package/src/shared/lib/markdown/blocks/types.ts +62 -0
- package/src/shared/lib/markdown/marked.ts +58 -147
- package/src/shared/lib/markdown/math-extensions.ts +168 -0
- package/src/shared/lib/markdown/review/prompt.ts +77 -0
- package/src/shared/lib/markdown/review/reconcile.ts +55 -0
- package/src/shared/lib/markdown/review/review.test.ts +96 -0
- package/src/shared/lib/markdown/xml-sections.test.ts +140 -0
- package/src/shared/lib/markdown/xml-sections.ts +139 -0
- package/src/shared/lib/models/provider/brand-color.test.ts +116 -0
- package/src/shared/lib/models/provider/brand-color.ts +103 -0
- package/src/shared/lib/models/provider/label.ts +57 -0
- package/src/shared/lib/omp/config/agent-file.test.ts +54 -0
- package/src/shared/lib/omp/config/agent-file.ts +43 -0
- package/src/shared/lib/omp/config/row-value.test.ts +95 -0
- package/src/shared/lib/omp/config/row-value.ts +97 -0
- package/src/shared/lib/omp/config/schema.test.ts +31 -0
- package/src/shared/lib/omp/config/schema.ts +6 -0
- package/src/shared/lib/omp/rpc/frame.test.ts +113 -47
- package/src/shared/lib/omp/rpc/frame.ts +107 -43
- package/src/shared/lib/settings/defaults.ts +4 -0
- package/src/shared/lib/theme/catalog.test.ts +5 -4
- package/src/shared/lib/theme/catalog.ts +18 -3
- package/src/shared/lib/theme/glass-support.test.ts +38 -0
- package/src/shared/lib/theme/glass-support.ts +73 -0
- package/src/shared/lib/theme/icon-style.test.ts +74 -0
- package/src/shared/lib/theme/icon-style.ts +90 -0
- package/src/shared/lib/theme/legibility.ts +91 -0
- package/src/shared/lib/theme/palettes/dark-extended.ts +152 -0
- package/src/shared/lib/theme/palettes/light-extended.ts +157 -0
- package/src/shared/lib/theme/surface-style.test.ts +68 -0
- package/src/shared/lib/theme/surface-style.ts +91 -0
- package/src/shared/lib/theme/theme.test.ts +11 -7
- package/src/shared/lib/ui/menu-anchor.test.ts +69 -0
- package/src/shared/lib/ui/menu-anchor.ts +89 -0
- package/src/shared/lib/usage/breakdown.test.ts +197 -0
- package/src/shared/lib/usage/breakdown.ts +241 -0
- package/src/shared/lib/usage/range.test.ts +204 -0
- package/src/shared/lib/usage/range.ts +240 -0
- package/src/shared/lib/usage/view.test.ts +85 -0
- package/src/shared/lib/usage/view.ts +74 -0
- package/src/shared/lib/workspace/panel-hues.test.ts +68 -0
- package/src/shared/lib/workspace/panel-hues.ts +57 -0
- package/src/shared/types/browser.ts +78 -0
- package/src/shared/types/index.ts +1 -0
- package/src/shared/types/panels-registry.ts +6 -0
- package/src/shared/types/panels.ts +14 -0
- package/src/shared/types/settings/agent.ts +28 -6
- package/src/shared/types/settings/state.ts +30 -3
- package/src/shared/types/settings/write.ts +6 -0
- package/src/shared/types/tokenUsage.ts +128 -21
- package/src/shared/types/updates.ts +20 -0
- package/src/test-support/fake-omp-frames.ts +163 -0
- package/dist/client/static/js/index-3ve31rzx.css +0 -1
- package/src/server/lib/omp/session/usage/aggregate-shaping.test.ts +0 -149
- package/src/server/lib/omp/session/usage/aggregate.test.ts +0 -243
- package/src/server/lib/omp/session/usage/aggregate.ts +0 -330
- package/src/server/lib/omp/session/usage/shaping.ts +0 -130
- /package/src/{client/components/common/file-icon/brand-paths.ts → shared/lib/icons/file-brand-paths.ts} +0 -0
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, expect, test } from 'bun:test';
|
|
7
|
+
import { THEMES } from '@/shared/lib/theme/catalog';
|
|
8
|
+
import { mixHex } from '@/shared/lib/theme/color';
|
|
9
|
+
import { contrastRatio } from '@/shared/lib/theme/legibility';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The composer's `glass` style is a STYLE, not a surface style: it is offered in
|
|
13
|
+
* the classic look too, where `[data-surface="glass"]` is not set. A `--glass-*`
|
|
14
|
+
* token that is only declared inside that attribute block therefore does not
|
|
15
|
+
* exist for the composer, and `background-color: var(--glass-card)` silently
|
|
16
|
+
* computes to `rgba(0,0,0,0)` — a card with no fill at all. That is not
|
|
17
|
+
* hypothetical: it shipped for the length of one edit, and the browser reported
|
|
18
|
+
* it as a transparent composer while `getComputedStyle` on the token returned an
|
|
19
|
+
* empty string.
|
|
20
|
+
*
|
|
21
|
+
* This asserts the shape of the contract rather than one value: every material
|
|
22
|
+
* token the composer rule READS has to be declared where the rule can see it,
|
|
23
|
+
* i.e. in `:root` (or a variant block), never only under the surface attribute.
|
|
24
|
+
*/
|
|
25
|
+
const read = (file: string): Promise<string> => Bun.file(new URL(file, import.meta.url)).text();
|
|
26
|
+
|
|
27
|
+
/** The body of the first rule whose selector starts a line, e.g. `[x] {`. */
|
|
28
|
+
function ruleBody(css: string, selector: string): string {
|
|
29
|
+
const start = css.search(new RegExp(`^${selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')} \\{`, 'm'));
|
|
30
|
+
if (start < 0) throw new Error(`no rule for ${selector}`);
|
|
31
|
+
const open = css.indexOf('{', start);
|
|
32
|
+
const close = css.indexOf('\n}', open);
|
|
33
|
+
if (close < 0) throw new Error(`unterminated rule for ${selector}`);
|
|
34
|
+
return css.slice(open + 1, close);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
describe('glass composer material', () => {
|
|
38
|
+
test('every --glass token the composer reads is declared in :root', async () => {
|
|
39
|
+
const [glass, tailwind] = await Promise.all([read('./glass.css'), read('./tailwind.css')]);
|
|
40
|
+
const composer = ruleBody(tailwind, '[data-composer-style="glass"]');
|
|
41
|
+
const root = ruleBody(glass, ':root');
|
|
42
|
+
|
|
43
|
+
const readTokens = [...new Set([...composer.matchAll(/var\((--glass-[a-z-]+)\)/g)].map((m) => m[1]))];
|
|
44
|
+
// The rule reads its whole material from tokens; a literal here would mean a
|
|
45
|
+
// second recipe for the same material, which is the defect this file guards.
|
|
46
|
+
expect(readTokens.length).toBeGreaterThanOrEqual(6);
|
|
47
|
+
|
|
48
|
+
for (const token of readTokens) {
|
|
49
|
+
expect({ token, declared: new RegExp(`${token}\\s*:`).test(root) }).toEqual({ token, declared: true });
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('the card carries a tint, transmitted light, a reflection and an edge', async () => {
|
|
54
|
+
const [glass, tailwind] = await Promise.all([read('./glass.css'), read('./tailwind.css')]);
|
|
55
|
+
const composer = ruleBody(tailwind, '[data-composer-style="glass"]');
|
|
56
|
+
const root = ruleBody(glass, ':root');
|
|
57
|
+
|
|
58
|
+
// Tint only is what read 1.03:1 against the surface beside it — a card you
|
|
59
|
+
// could not see. The four layers are the material.
|
|
60
|
+
expect(composer).toContain('background-color: var(--glass-card)');
|
|
61
|
+
expect(composer).toContain('background-image: var(--glass-sheen), var(--glass-bloom)');
|
|
62
|
+
expect(composer).toContain('box-shadow: var(--glass-card-edge), var(--glass-shadow)');
|
|
63
|
+
// The CARD's rim, not the window's: the window edge carries `#fff 95%` at
|
|
64
|
+
// 1.5px, which is a hard white line across a 620px card ("silau").
|
|
65
|
+
expect(root).toContain('--glass-card-edge:');
|
|
66
|
+
const cardEdge = root.slice(root.indexOf('--glass-card-edge:'), root.indexOf('--glass-edge:'));
|
|
67
|
+
expect(cardEdge).not.toContain('#fff 95%');
|
|
68
|
+
expect(root).toContain('--glass-bloom:');
|
|
69
|
+
// The bloom is light that came THROUGH the pane: its hue is the palette's,
|
|
70
|
+
// never a hardcoded colour — and it is the DARK variant's, because a palette
|
|
71
|
+
// hue is darker than paper and smudges a light card instead of lighting it.
|
|
72
|
+
const dark = glass.slice(glass.indexOf('[data-theme-variant="dark"]'));
|
|
73
|
+
expect(dark).toContain('--glass-bloom:');
|
|
74
|
+
expect(dark.slice(dark.indexOf('--glass-bloom:'))).toContain('var(--theme-info)');
|
|
75
|
+
expect(root).toContain('--glass-bloom: none;');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('a browser without a blur gets no bloom either', async () => {
|
|
79
|
+
const glass = await read('./glass.css');
|
|
80
|
+
// Two blocks restate the token list because CSS cannot OR a `@supports` with
|
|
81
|
+
// a `@media`; both have to drop the bloom, or the decoration outlives the
|
|
82
|
+
// translucency it exists for.
|
|
83
|
+
const supports = glass.slice(glass.indexOf('@supports not ('), glass.indexOf('@media (prefers-reduced-transparency'));
|
|
84
|
+
const reduced = glass.slice(glass.indexOf('@media (prefers-reduced-transparency'));
|
|
85
|
+
for (const block of [supports, reduced]) {
|
|
86
|
+
for (const token of ['--glass-bloom', '--glass-popover-bloom', '--glass-overlay-filter']) {
|
|
87
|
+
expect({ token, dropped: block.includes(`${token}: none;`) }).toEqual({ token, dropped: true });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The popover tier is the same argument as the composer's, one size down: a
|
|
95
|
+
* dropdown that carries only a tint reads as a LIFTED BOX, because on a dark
|
|
96
|
+
* palette a translucent paper only ever darkens it. Measured on the
|
|
97
|
+
* session-actions menu before the bloom — corner `(56,61,71)` over a body of
|
|
98
|
+
* `(41,44,52)` on a sidebar of `(51,58,67)`, 1.09:1 against what it covers.
|
|
99
|
+
*/
|
|
100
|
+
describe('glass popover material', () => {
|
|
101
|
+
test('the popover adds its own bloom on top of the shared material', async () => {
|
|
102
|
+
const [glass, tailwind] = await Promise.all([read('./glass.css'), read('./tailwind.css')]);
|
|
103
|
+
const root = ruleBody(glass, ':root');
|
|
104
|
+
expect(root).toContain('--glass-popover-bloom:');
|
|
105
|
+
|
|
106
|
+
// The shared block styles BOTH tiers and carries no bloom; the popover's own
|
|
107
|
+
// rule is the one that paints it, and it must name the popover ALONE — a
|
|
108
|
+
// shared rule would put a bloom inside a dialog's paragraph.
|
|
109
|
+
expect(glass).toContain(
|
|
110
|
+
'[data-surface="glass"] .glass-popover {\n background-image: var(--glass-sheen), var(--glass-popover-bloom);',
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const shared = glass.split('[data-surface="glass"] .glass-overlay,')[1] ?? '';
|
|
114
|
+
const sharedBody = shared.slice(0, shared.indexOf('}'));
|
|
115
|
+
expect(sharedBody).not.toContain('--glass-popover-bloom');
|
|
116
|
+
expect(sharedBody).toContain('background-image: linear-gradient(');
|
|
117
|
+
|
|
118
|
+
// A dialog keeps the sheen and the rim it was measured with: a dialog has
|
|
119
|
+
// prose in the middle, and the bloom's whole point is that it stays in the
|
|
120
|
+
// corners — which a dialog cannot afford to guess at.
|
|
121
|
+
expect(tailwind).toContain('[data-composer-style="glass"]');
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test('an anchored menu is a popover by construction, not by its caller', async () => {
|
|
125
|
+
const menu = await read('./components/common/anchored-menu/index.tsx');
|
|
126
|
+
const list = await read('./components/common/session-actions-menu/index.tsx');
|
|
127
|
+
// The primitive stamps the tier, so a caller that forgets it is the only way
|
|
128
|
+
// an anchored menu stays opaque under the glass surface.
|
|
129
|
+
expect(menu).toContain('glass-popover fixed');
|
|
130
|
+
expect(list).toContain('glass-popover fixed');
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* A workspace column is the same chrome as the sidebar beside it. Every view
|
|
136
|
+
* under it opens with its own `bg-paper` root, which is right in the classic look
|
|
137
|
+
* and wrong under the glass surface — measured, the 293px column composited to
|
|
138
|
+
* the palette's solid paper while the sidebar was the plane's chrome.
|
|
139
|
+
*/
|
|
140
|
+
describe('glass column material', () => {
|
|
141
|
+
test('a workspace column is chrome, and its view roots step aside for it', async () => {
|
|
142
|
+
const [glass, panels] = await Promise.all([
|
|
143
|
+
read('./glass.css'),
|
|
144
|
+
read('./components/layout/desktop-layout/WorkspacePanels.tsx'),
|
|
145
|
+
]);
|
|
146
|
+
// Measured: every right-panel view opens with its own `bg-paper` root, so the
|
|
147
|
+
// 293px column composited to solid paper while the sidebar beside it was the
|
|
148
|
+
// plane's chrome — two materials in one window ("right panel juga belum glass
|
|
149
|
+
// banget"). The marker is on the SLOT (one owner), never on each view.
|
|
150
|
+
expect(panels).toContain('data-panel-chrome=""');
|
|
151
|
+
expect(panels).toContain('glass-chrome w-full h-full');
|
|
152
|
+
expect(glass).toContain('[data-surface="glass"] [data-panel-chrome] > .bg-paper,');
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
test('a PLUGIN panel is reached through its scope span', async () => {
|
|
156
|
+
const [glass, dock] = await Promise.all([
|
|
157
|
+
read('./glass.css'),
|
|
158
|
+
read('./components/layout/LeftDock.tsx'),
|
|
159
|
+
]);
|
|
160
|
+
// A plugin's component renders inside `<span data-plugin-surface style="display: contents">`
|
|
161
|
+
// — the scope the server wraps its stylesheet in — and that span has a BOX
|
|
162
|
+
// even though it paints none, so the child combinator stops there. Measured
|
|
163
|
+
// on the three bundled marketplace plugins, every one painted
|
|
164
|
+
// `rgb(40,44,52)` over the column before this selector existed.
|
|
165
|
+
expect(glass).toContain('[data-surface="glass"] [data-panel-chrome] > [data-plugin-surface] > .bg-paper {');
|
|
166
|
+
// And the LEFT column carries the same marker: a plugin placed on the left
|
|
167
|
+
// draws its own `bg-paper` root too.
|
|
168
|
+
expect(dock).toContain('data-panel-chrome=""');
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* A dialog is the largest surface in the app and the one that showed the least:
|
|
174
|
+
* at 96% tint the veil contributes 4%, so a settings panel measured as a uniform
|
|
175
|
+
* fill with no material at all ("setting modal juga belum glass"). The material
|
|
176
|
+
* is LOCAL light plus a frosted veil, and both have to survive the fallbacks.
|
|
177
|
+
*/
|
|
178
|
+
describe('glass dialog material', () => {
|
|
179
|
+
test('the dialog paints its own light, and the popover does not borrow it', async () => {
|
|
180
|
+
const glass = await read('./glass.css');
|
|
181
|
+
expect(ruleBody(glass, ':root')).toContain('--glass-dialog-bloom:');
|
|
182
|
+
expect(glass).toContain('[data-surface="glass"] .glass-overlay {\n background-image: var(--glass-dialog-bloom);');
|
|
183
|
+
|
|
184
|
+
// The peak sits OUTSIDE the frame: on it, the light lands on the settings nav
|
|
185
|
+
// and drags its 12px labels from 3.8:1 to 3.0:1.
|
|
186
|
+
const dialog = glass.slice(glass.indexOf('--glass-dialog-bloom:'));
|
|
187
|
+
const dark = dialog.slice(dialog.indexOf('[data-theme-variant="dark"]'));
|
|
188
|
+
expect(dark.slice(0, dark.indexOf('}'))).toContain('at -4% -8%');
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test('a dialog chrome strip steps aside, and only the direct child does', async () => {
|
|
192
|
+
const glass = await read('./glass.css');
|
|
193
|
+
// Measured on the git commit history modal: its 1198x109 `bg-paper` header
|
|
194
|
+
// painted the palette's SOLID paper across the top of a 1200x792 panel, so the
|
|
195
|
+
// panel's highlight and top-left bloom never rendered and the face read as one
|
|
196
|
+
// flat value. The dialog's BODY keeps every card it draws.
|
|
197
|
+
expect(glass).toContain('[data-surface="glass"] .glass-overlay > .bg-paper {\n background-color: transparent;');
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test('both fallback blocks outrank the dark palette block', async () => {
|
|
201
|
+
const glass = await read('./glass.css');
|
|
202
|
+
// The dark tokens live in `[data-surface="glass"][data-theme-variant="dark"]`
|
|
203
|
+
// (0,2,0). A plain `[data-surface="glass"]` fallback is (0,1,0) and LOSES on
|
|
204
|
+
// every dark palette — measured, `.glass-chrome` kept alpha 0.38 under the
|
|
205
|
+
// block meant to make it opaque, i.e. a translucent plane with no blur behind
|
|
206
|
+
// it, the exact state these blocks exist to prevent. `:root` adds the
|
|
207
|
+
// pseudo-class that ties, and source order then wins.
|
|
208
|
+
const supports = glass.slice(glass.indexOf('@supports not ('), glass.indexOf('@media (prefers-reduced-transparency'));
|
|
209
|
+
const reduced = glass.slice(glass.indexOf('@media (prefers-reduced-transparency'));
|
|
210
|
+
for (const block of [supports, reduced]) {
|
|
211
|
+
expect(block).toContain(':root[data-surface="glass"] {');
|
|
212
|
+
// Not enough on its own: the token list has to be inside that block.
|
|
213
|
+
expect(block).toContain('--glass-chrome: var(--theme-paper);');
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
test('the veil is frosted under the glass surface and only there', async () => {
|
|
218
|
+
const [tailwind, glass] = await Promise.all([read('./tailwind.css'), read('./glass.css')]);
|
|
219
|
+
expect(tailwind).toContain("[data-surface='glass'] .modal-scrim {\n backdrop-filter: blur(20px) saturate(120%);");
|
|
220
|
+
|
|
221
|
+
// Both fallback blocks drop it with the rest of the material.
|
|
222
|
+
const supports = glass.slice(glass.indexOf('@supports not ('), glass.indexOf('@media (prefers-reduced-transparency'));
|
|
223
|
+
const reduced = glass.slice(glass.indexOf('@media (prefers-reduced-transparency'));
|
|
224
|
+
for (const block of [supports, reduced]) {
|
|
225
|
+
expect(block).toContain('--glass-dialog-bloom: none;');
|
|
226
|
+
expect(block).toContain('.modal-scrim {\n backdrop-filter: none;');
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* The material has to hold on EVERY palette in the catalog, not on the eighteen
|
|
233
|
+
* it was tuned against. The alphas are read out of `glass.css` itself, so this
|
|
234
|
+
* cannot drift from the shipped values, and the composite it measures is the one
|
|
235
|
+
* the browser computes: `color-mix(… paper N%, transparent)` over the plane,
|
|
236
|
+
* which is itself paper over canvas.
|
|
237
|
+
*
|
|
238
|
+
* The invariant is the one a new palette can break without anyone noticing: body
|
|
239
|
+
* text on the chrome and on a card keeps the 4.5:1 floor. Measured across all 63
|
|
240
|
+
* palettes, the worst is `solarized-light` at 4.89:1 — the same number its
|
|
241
|
+
* opaque paper has, which is what "the tint costs no contrast" means.
|
|
242
|
+
*/
|
|
243
|
+
describe('glass material across the catalog', () => {
|
|
244
|
+
const alphaOf = (body: string, token: string): number => {
|
|
245
|
+
const match = new RegExp(`${token}: color-mix\\(in srgb, var\\(--theme-paper\\) (\\d+)%, transparent\\)`).exec(body);
|
|
246
|
+
if (!match) throw new Error(`no ${token} alpha`);
|
|
247
|
+
return Number(match[1]) / 100;
|
|
248
|
+
};
|
|
249
|
+
const percentOf = (body: string, token: string): number => {
|
|
250
|
+
const match = new RegExp(`${token}: (\\d+)%;`).exec(body);
|
|
251
|
+
if (!match) throw new Error(`no ${token}`);
|
|
252
|
+
return Number(match[1]) / 100;
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
test('every palette keeps body text legible on the plane, the chrome and a card', async () => {
|
|
256
|
+
const glass = await read('./glass.css');
|
|
257
|
+
const light = ruleBody(glass, '[data-surface="glass"]');
|
|
258
|
+
const dark = ruleBody(glass, '[data-surface="glass"][data-theme-variant="dark"]');
|
|
259
|
+
const root = ruleBody(glass, ':root');
|
|
260
|
+
const darkVariant = ruleBody(glass, '[data-theme-variant="dark"]');
|
|
261
|
+
|
|
262
|
+
const alphas = {
|
|
263
|
+
light: {
|
|
264
|
+
tint: percentOf(light, '--glass-tint'),
|
|
265
|
+
chrome: alphaOf(light, '--glass-chrome'),
|
|
266
|
+
// A card's fill is surface-INDEPENDENT (the composer's `glass` style is
|
|
267
|
+
// offered in the classic look), so it lives on `:root` / the variant.
|
|
268
|
+
card: alphaOf(root, '--glass-card'),
|
|
269
|
+
},
|
|
270
|
+
dark: {
|
|
271
|
+
tint: percentOf(dark, '--glass-tint'),
|
|
272
|
+
chrome: alphaOf(dark, '--glass-chrome'),
|
|
273
|
+
card: alphaOf(darkVariant, '--glass-card'),
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
for (const theme of THEMES) {
|
|
278
|
+
const alpha = alphas[theme.variant];
|
|
279
|
+
const plane = mixHex(theme.canvas, theme.paper, alpha.tint);
|
|
280
|
+
const chrome = mixHex(plane, theme.paper, alpha.chrome);
|
|
281
|
+
const card = mixHex(plane, theme.paper, alpha.card);
|
|
282
|
+
for (const [tier, surface] of [['plane', plane], ['chrome', chrome], ['card', card]] as const) {
|
|
283
|
+
expect({ id: theme.id, tier, ratio: contrastRatio(theme.ink, surface) >= 4.5 }).toEqual({
|
|
284
|
+
id: theme.id,
|
|
285
|
+
tier,
|
|
286
|
+
ratio: true,
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* The material is DERIVED from the palette — `--glass-panel` is
|
|
295
|
+
* `color-mix(paper N%, transparent)` and the chrome is one more mix over it — so
|
|
296
|
+
* a theme does not "support glass" by declaring something; it supports it when
|
|
297
|
+
* its two surfaces and its ink survive the composite. That makes a bad port
|
|
298
|
+
* invisible in the classic look and illegible under the material, which is the
|
|
299
|
+
* failure this sweep exists to catch.
|
|
300
|
+
*
|
|
301
|
+
* The alphas are read out of `glass.css` rather than repeated here, so the test
|
|
302
|
+
* cannot drift from the shipped values, and the composite is the browser's own:
|
|
303
|
+
* plane = paper over canvas, chrome/card = paper over plane.
|
|
304
|
+
*/
|
|
305
|
+
describe('glass material on every catalog palette', () => {
|
|
306
|
+
/** A percentage out of a token, whether bare (`50%`) or inside a `color-mix`. */
|
|
307
|
+
const percentOf = (body: string, token: string): number => {
|
|
308
|
+
const match = new RegExp(`--glass-${token}:\\s*(?:color-mix\\(in srgb, var\\(--theme-paper\\)\\s*)?(\\d+(?:\\.\\d+)?)%`).exec(body);
|
|
309
|
+
if (!match) throw new Error(`--glass-${token} is not a percentage in this block`);
|
|
310
|
+
return Number(match[1]) / 100;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
test('body text keeps the 4.5:1 floor on the plane, the chrome and a card', async () => {
|
|
314
|
+
const glass = await read('./glass.css');
|
|
315
|
+
const surface = ruleBody(glass, '[data-surface="glass"]');
|
|
316
|
+
const surfaceDark = ruleBody(glass, '[data-surface="glass"][data-theme-variant="dark"]');
|
|
317
|
+
const root = ruleBody(glass, ':root');
|
|
318
|
+
const variantDark = ruleBody(glass, '[data-theme-variant="dark"]');
|
|
319
|
+
|
|
320
|
+
// The card's fill is surface-INDEPENDENT (the composer's `glass` style is
|
|
321
|
+
// offered in the classic look too), so it lives on `:root` and the variant
|
|
322
|
+
// block, not under the surface attribute.
|
|
323
|
+
const alphas = {
|
|
324
|
+
light: { tint: percentOf(surface, 'tint'), chrome: percentOf(surface, 'chrome'), card: percentOf(root, 'card') },
|
|
325
|
+
dark: { tint: percentOf(surfaceDark, 'tint'), chrome: percentOf(surfaceDark, 'chrome'), card: percentOf(variantDark, 'card') },
|
|
326
|
+
};
|
|
327
|
+
expect(alphas.light.tint).toBeGreaterThan(alphas.dark.tint - 1);
|
|
328
|
+
expect(alphas.light.chrome).toBeLessThan(alphas.dark.chrome + 0.5);
|
|
329
|
+
|
|
330
|
+
const failures: string[] = [];
|
|
331
|
+
for (const theme of THEMES) {
|
|
332
|
+
const alpha = alphas[theme.variant];
|
|
333
|
+
const plane = mixHex(theme.canvas, theme.paper, alpha.tint);
|
|
334
|
+
const tiers = {
|
|
335
|
+
plane,
|
|
336
|
+
chrome: mixHex(plane, theme.paper, alpha.chrome),
|
|
337
|
+
card: mixHex(plane, theme.paper, alpha.card),
|
|
338
|
+
};
|
|
339
|
+
for (const [tier, fill] of Object.entries(tiers)) {
|
|
340
|
+
const ratio = contrastRatio(theme.ink, fill);
|
|
341
|
+
if (ratio < 4.5) failures.push(`${theme.id} ${tier} ${ratio.toFixed(2)}:1`);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
expect(failures).toEqual([]);
|
|
345
|
+
});
|
|
346
|
+
});
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Annotating the user-browser panel.
|
|
8
|
+
*
|
|
9
|
+
* The failure this hook has to prevent is a mark outliving the page it was drawn
|
|
10
|
+
* on. An iframe's internal navigation is invisible from this origin — the host
|
|
11
|
+
* gets `onLoad` and nothing else — so a reload or a typed address is the only
|
|
12
|
+
* signal that the document under the marks changed. Sending that stale batch
|
|
13
|
+
* would point the agent at percentages of a page the user has left.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { afterAll, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
17
|
+
import { Window } from 'happy-dom';
|
|
18
|
+
import { h, render } from 'preact';
|
|
19
|
+
import { act } from 'preact/test-utils';
|
|
20
|
+
import { useState } from 'preact/hooks';
|
|
21
|
+
import { useAnnotate, type UseAnnotateResult } from '@/client/hooks/browser/use-annotate';
|
|
22
|
+
import type { AnnotateShape } from '@/shared/types';
|
|
23
|
+
|
|
24
|
+
const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'Event'] as const;
|
|
25
|
+
const native: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
|
|
26
|
+
|
|
27
|
+
beforeAll(() => {
|
|
28
|
+
const win = new Window({ url: 'http://localhost' });
|
|
29
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
30
|
+
for (const key of DOM_GLOBALS) {
|
|
31
|
+
native[key] = target[key];
|
|
32
|
+
target[key] = (win as unknown as Record<string, unknown>)[key];
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
afterAll(() => {
|
|
37
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
38
|
+
for (const key of DOM_GLOBALS) {
|
|
39
|
+
if (native[key] === undefined) delete target[key];
|
|
40
|
+
else target[key] = native[key];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
function mark(id: string, note = ''): AnnotateShape {
|
|
45
|
+
return { id, tool: 'box', start: { x: 0.1, y: 0.1 }, end: { x: 0.3, y: 0.3 }, label: '', note };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let container: HTMLElement | undefined;
|
|
49
|
+
let latest: UseAnnotateResult | undefined;
|
|
50
|
+
/** Drives the hook's page key, the way the panel's `frameKey` does. */
|
|
51
|
+
let navigate: (key: number) => void;
|
|
52
|
+
|
|
53
|
+
const api = (): UseAnnotateResult => {
|
|
54
|
+
if (!latest) throw new Error('hook not rendered');
|
|
55
|
+
return latest;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** Mount the hook with a page key the test can change. */
|
|
59
|
+
function mount(): void {
|
|
60
|
+
const Probe = () => {
|
|
61
|
+
const [frameKey, setFrameKey] = useState(0);
|
|
62
|
+
navigate = setFrameKey;
|
|
63
|
+
latest = useAnnotate(frameKey);
|
|
64
|
+
return h('div', null);
|
|
65
|
+
};
|
|
66
|
+
act(() => {
|
|
67
|
+
render(h(Probe, null), container!);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
beforeEach(() => {
|
|
72
|
+
container?.remove();
|
|
73
|
+
container = document.body.appendChild(document.createElement('div'));
|
|
74
|
+
latest = undefined;
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe('useAnnotate', () => {
|
|
78
|
+
test('starts closed, with the box tool and no marks', () => {
|
|
79
|
+
mount();
|
|
80
|
+
expect(api().active).toBe(false);
|
|
81
|
+
expect(api().tool).toBe('box');
|
|
82
|
+
expect(api().shapes).toEqual([]);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('toggle opens the mode and close shuts it, dropping the selection', () => {
|
|
86
|
+
mount();
|
|
87
|
+
act(() => api().toggle());
|
|
88
|
+
expect(api().active).toBe(true);
|
|
89
|
+
act(() => api().add(mark('a')));
|
|
90
|
+
expect(api().selectedId).toBe('a');
|
|
91
|
+
act(() => api().close());
|
|
92
|
+
expect(api().active).toBe(false);
|
|
93
|
+
expect(api().selectedId).toBeNull();
|
|
94
|
+
// Closing the mode is not the same as discarding the marks.
|
|
95
|
+
expect(api().shapes).toHaveLength(1);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('a finished mark is committed and becomes the one being described', () => {
|
|
99
|
+
mount();
|
|
100
|
+
act(() => api().add(mark('a')));
|
|
101
|
+
act(() => api().add(mark('b')));
|
|
102
|
+
expect(api().shapes.map((shape) => shape.id)).toEqual(['a', 'b']);
|
|
103
|
+
expect(api().selectedId).toBe('b');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('a note is stored on its own mark only', () => {
|
|
107
|
+
mount();
|
|
108
|
+
act(() => api().add(mark('a')));
|
|
109
|
+
act(() => api().add(mark('b')));
|
|
110
|
+
act(() => api().setNote('a', 'tombol mati'));
|
|
111
|
+
expect(api().shapes.map((shape) => shape.note)).toEqual(['tombol mati', '']);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('removing the selected mark clears the selection; removing another leaves it', () => {
|
|
115
|
+
mount();
|
|
116
|
+
act(() => api().add(mark('a')));
|
|
117
|
+
act(() => api().add(mark('b')));
|
|
118
|
+
act(() => api().remove('a'));
|
|
119
|
+
expect(api().selectedId).toBe('b');
|
|
120
|
+
act(() => api().remove('b'));
|
|
121
|
+
expect(api().selectedId).toBeNull();
|
|
122
|
+
expect(api().shapes).toEqual([]);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('reset clears the marks but leaves the mode as it was', () => {
|
|
126
|
+
mount();
|
|
127
|
+
act(() => api().toggle());
|
|
128
|
+
act(() => api().add(mark('a')));
|
|
129
|
+
act(() => api().reset());
|
|
130
|
+
expect(api().shapes).toEqual([]);
|
|
131
|
+
expect(api().active).toBe(true);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test('a new page drops every mark drawn on the old one', () => {
|
|
135
|
+
mount();
|
|
136
|
+
act(() => api().add(mark('a')));
|
|
137
|
+
act(() => api().add(mark('b')));
|
|
138
|
+
expect(api().shapes).toHaveLength(2);
|
|
139
|
+
act(() => navigate(1));
|
|
140
|
+
expect(api().shapes).toEqual([]);
|
|
141
|
+
expect(api().selectedId).toBeNull();
|
|
142
|
+
});
|
|
143
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Annotating the user-browser panel.
|
|
8
|
+
*
|
|
9
|
+
* The marks belong to ONE page view. An iframe's internal navigation is not
|
|
10
|
+
* observable from this origin (`onLoad` is all the host gets), so a mark made
|
|
11
|
+
* before a navigation would otherwise point at a different document than the
|
|
12
|
+
* one it was drawn on. `frameKey` therefore clears the marks: a reload or a
|
|
13
|
+
* typed address is a new page, and keeping them would send the agent
|
|
14
|
+
* coordinates for a page the user is no longer looking at.
|
|
15
|
+
*
|
|
16
|
+
* The mark being DRAGGED is not state here — it lives in the overlay that draws
|
|
17
|
+
* it, and arrives as one finished shape through `add`. A pointermove-driven
|
|
18
|
+
* value in this hook would re-render the panel (iframe included) on every move.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { useCallback, useEffect, useState } from 'preact/hooks';
|
|
22
|
+
import type { AnnotateShape, AnnotateTool } from '@/shared/types';
|
|
23
|
+
|
|
24
|
+
export interface UseAnnotateResult {
|
|
25
|
+
active: boolean;
|
|
26
|
+
tool: AnnotateTool;
|
|
27
|
+
shapes: AnnotateShape[];
|
|
28
|
+
/** The mark whose note field is open, if any. */
|
|
29
|
+
selectedId: string | null;
|
|
30
|
+
setTool: (tool: AnnotateTool) => void;
|
|
31
|
+
toggle: () => void;
|
|
32
|
+
close: () => void;
|
|
33
|
+
/** Commit one finished mark and open its note field. */
|
|
34
|
+
add: (shape: AnnotateShape) => void;
|
|
35
|
+
setNote: (id: string, note: string) => void;
|
|
36
|
+
/** Name the region a mark covers ("Ringkasan pesanan"); the user owns this fact. */
|
|
37
|
+
setLabel: (id: string, label: string) => void;
|
|
38
|
+
select: (id: string | null) => void;
|
|
39
|
+
remove: (id: string) => void;
|
|
40
|
+
reset: () => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let shapeSeq = 0;
|
|
44
|
+
|
|
45
|
+
/** Ids are unique per mark; the overlay stamps one when the drag starts. */
|
|
46
|
+
export function nextShapeId(): string {
|
|
47
|
+
shapeSeq += 1;
|
|
48
|
+
return `annot-${Date.now().toString(36)}-${shapeSeq}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function useAnnotate(frameKey: number): UseAnnotateResult {
|
|
52
|
+
const [active, setActive] = useState(false);
|
|
53
|
+
const [tool, setTool] = useState<AnnotateTool>('box');
|
|
54
|
+
const [shapes, setShapes] = useState<AnnotateShape[]>([]);
|
|
55
|
+
const [selectedId, setSelectedId] = useState<string | null>(null);
|
|
56
|
+
|
|
57
|
+
// A new page invalidates every mark on the old one.
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
setShapes([]);
|
|
60
|
+
setSelectedId(null);
|
|
61
|
+
}, [frameKey]);
|
|
62
|
+
|
|
63
|
+
const toggle = useCallback(() => {
|
|
64
|
+
setActive((prev) => !prev);
|
|
65
|
+
setSelectedId(null);
|
|
66
|
+
}, []);
|
|
67
|
+
|
|
68
|
+
const close = useCallback(() => {
|
|
69
|
+
setSelectedId(null);
|
|
70
|
+
setActive(false);
|
|
71
|
+
}, []);
|
|
72
|
+
|
|
73
|
+
const add = useCallback((shape: AnnotateShape) => {
|
|
74
|
+
setShapes((prev) => [...prev, shape]);
|
|
75
|
+
// A finished mark is the one the user is about to describe.
|
|
76
|
+
setSelectedId(shape.id);
|
|
77
|
+
}, []);
|
|
78
|
+
|
|
79
|
+
const setNote = useCallback((id: string, note: string) => {
|
|
80
|
+
setShapes((prev) => prev.map((shape) => (shape.id === id ? { ...shape, note } : shape)));
|
|
81
|
+
}, []);
|
|
82
|
+
|
|
83
|
+
const setLabel = useCallback((id: string, label: string) => {
|
|
84
|
+
setShapes((prev) => prev.map((shape) => (shape.id === id ? { ...shape, label } : shape)));
|
|
85
|
+
}, []);
|
|
86
|
+
|
|
87
|
+
const remove = useCallback((id: string) => {
|
|
88
|
+
setShapes((prev) => prev.filter((shape) => shape.id !== id));
|
|
89
|
+
setSelectedId((current) => (current === id ? null : current));
|
|
90
|
+
}, []);
|
|
91
|
+
|
|
92
|
+
const reset = useCallback(() => {
|
|
93
|
+
setShapes([]);
|
|
94
|
+
setSelectedId(null);
|
|
95
|
+
}, []);
|
|
96
|
+
|
|
97
|
+
return { active, tool, shapes, selectedId, setTool, toggle, close, add, setNote, setLabel, select: setSelectedId, remove, reset };
|
|
98
|
+
}
|