@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,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Naming a mark in the annotation bar.
|
|
8
|
+
*
|
|
9
|
+
* The rule this file exists for: the panel must never present "no element" as
|
|
10
|
+
* though the page had nothing there. A cross-origin frame (the normal dev-server
|
|
11
|
+
* case — same host, different port) makes the DOM unreadable, and the bar says
|
|
12
|
+
* exactly that, so the user knows the label is the only identity available
|
|
13
|
+
* rather than assuming the tool failed silently.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { afterAll, afterEach, 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
|
+
|
|
21
|
+
import { AnnotateBar } from '@/client/components/workspace/user-browser-panel/AnnotateBar';
|
|
22
|
+
import { missingElementReason } from '@/client/components/workspace/user-browser-panel/AnnotateTarget';
|
|
23
|
+
import type { AnnotateShape } from '@/shared/types';
|
|
24
|
+
|
|
25
|
+
const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'Event', 'MouseEvent'] as const;
|
|
26
|
+
const native: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
|
|
27
|
+
|
|
28
|
+
beforeAll(() => {
|
|
29
|
+
const win = new Window({ url: 'http://localhost' });
|
|
30
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
31
|
+
for (const key of DOM_GLOBALS) {
|
|
32
|
+
if (!(key in native)) native[key] = target[key];
|
|
33
|
+
target[key] = (win as unknown as Record<string, unknown>)[key];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
afterAll(() => {
|
|
38
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
39
|
+
for (const key of DOM_GLOBALS) {
|
|
40
|
+
if (native[key] === undefined) delete target[key];
|
|
41
|
+
else target[key] = native[key];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
function mark(overrides: Partial<AnnotateShape> = {}): AnnotateShape {
|
|
46
|
+
return {
|
|
47
|
+
id: 'a',
|
|
48
|
+
tool: 'box',
|
|
49
|
+
start: { x: 0.1, y: 0.1 },
|
|
50
|
+
end: { x: 0.3, y: 0.3 },
|
|
51
|
+
label: '',
|
|
52
|
+
note: '',
|
|
53
|
+
...overrides,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
let container: HTMLElement | undefined;
|
|
58
|
+
let labels: Array<[string, string]> = [];
|
|
59
|
+
let notes: Array<[string, string]> = [];
|
|
60
|
+
|
|
61
|
+
interface MountOptions {
|
|
62
|
+
shapes?: AnnotateShape[];
|
|
63
|
+
selectedId?: string | null;
|
|
64
|
+
readability?: Parameters<typeof AnnotateBar>[0]['readability'];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function mount({ shapes = [mark()], selectedId = 'a', readability = null }: MountOptions = {}): HTMLElement {
|
|
68
|
+
labels = [];
|
|
69
|
+
notes = [];
|
|
70
|
+
container = document.body.appendChild(document.createElement('div'));
|
|
71
|
+
act(() => {
|
|
72
|
+
render(h(AnnotateBar, {
|
|
73
|
+
tool: 'box',
|
|
74
|
+
shapes,
|
|
75
|
+
selectedId,
|
|
76
|
+
readability,
|
|
77
|
+
onTool: () => {},
|
|
78
|
+
onLabel: (id, label) => labels.push([id, label]),
|
|
79
|
+
onNote: (id, note) => notes.push([id, note]),
|
|
80
|
+
onRemove: () => {},
|
|
81
|
+
onReset: () => {},
|
|
82
|
+
onCancel: () => {},
|
|
83
|
+
onSend: () => {},
|
|
84
|
+
}), container!);
|
|
85
|
+
});
|
|
86
|
+
return container;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const byText = (root: HTMLElement, text: string): HTMLButtonElement | undefined =>
|
|
90
|
+
[...root.querySelectorAll('button')].find((node) => node.textContent === text);
|
|
91
|
+
|
|
92
|
+
beforeEach(() => {
|
|
93
|
+
container?.remove();
|
|
94
|
+
container = undefined;
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
afterEach(() => {
|
|
98
|
+
if (container) render(null, container);
|
|
99
|
+
container?.remove();
|
|
100
|
+
container = undefined;
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
describe('label chips', () => {
|
|
104
|
+
test('the offered vocabulary is rendered as chips', () => {
|
|
105
|
+
const root = mount();
|
|
106
|
+
for (const name of ['header', 'form', 'tabel', 'modal']) {
|
|
107
|
+
expect(byText(root, name)).toBeDefined();
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('picking a chip names the mark', () => {
|
|
112
|
+
const root = mount();
|
|
113
|
+
act(() => byText(root, 'form')!.click());
|
|
114
|
+
expect(labels).toEqual([['a', 'form']]);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('picking the chip already in force clears it, so a wrong pick is one click away', () => {
|
|
118
|
+
const root = mount({ shapes: [mark({ label: 'form' })] });
|
|
119
|
+
act(() => byText(root, 'form')!.click());
|
|
120
|
+
expect(labels).toEqual([['a', '']]);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test('the chip matching the mark is the pressed one', () => {
|
|
124
|
+
const root = mount({ shapes: [mark({ label: 'tabel' })] });
|
|
125
|
+
expect(byText(root, 'tabel')?.getAttribute('aria-pressed')).toBe('true');
|
|
126
|
+
expect(byText(root, 'form')?.getAttribute('aria-pressed')).toBe('false');
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test('the free-text field carries the mark’s own label', () => {
|
|
130
|
+
const root = mount({ shapes: [mark({ label: 'Ringkasan pesanan' })] });
|
|
131
|
+
const input = root.querySelector<HTMLInputElement>('input[aria-label="Nama bagian yang ditandai"]');
|
|
132
|
+
expect(input?.value).toBe('Ringkasan pesanan');
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test('typing in the field names the mark directly', () => {
|
|
136
|
+
const root = mount();
|
|
137
|
+
const input = root.querySelector<HTMLInputElement>('input[aria-label="Nama bagian yang ditandai"]')!;
|
|
138
|
+
act(() => {
|
|
139
|
+
input.value = 'keranjang';
|
|
140
|
+
input.dispatchEvent(new window.Event('input', { bubbles: true }));
|
|
141
|
+
});
|
|
142
|
+
expect(labels).toEqual([['a', 'keranjang']]);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test('the note field is separate from the label', () => {
|
|
146
|
+
const root = mount();
|
|
147
|
+
const note = root.querySelector<HTMLTextAreaElement>('textarea[aria-label="Catatan anotasi"]')!;
|
|
148
|
+
act(() => {
|
|
149
|
+
note.value = 'tombol mati';
|
|
150
|
+
note.dispatchEvent(new window.Event('input', { bubbles: true }));
|
|
151
|
+
});
|
|
152
|
+
expect(notes).toEqual([['a', 'tombol mati']]);
|
|
153
|
+
expect(labels).toEqual([]);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
describe('element readout', () => {
|
|
158
|
+
test('a readable element is printed with its state', () => {
|
|
159
|
+
const root = mount({
|
|
160
|
+
shapes: [mark({ element: { path: 'body > form > select#prov', tag: 'select', state: 'nilai "Bali", 3 opsi' } })],
|
|
161
|
+
});
|
|
162
|
+
const readout = root.textContent ?? '';
|
|
163
|
+
expect(readout).toContain('body > form > select#prov');
|
|
164
|
+
expect(readout).toContain('nilai "Bali", 3 opsi');
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test('a cross-origin page says why there is no element, in words', () => {
|
|
168
|
+
const root = mount({ readability: { ok: false, reason: 'cross-origin' } });
|
|
169
|
+
expect(root.textContent).toContain('beda origin');
|
|
170
|
+
expect(root.textContent).toContain('nama bagian');
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test('empty space is a different message from an unreadable page', () => {
|
|
174
|
+
const root = mount({ readability: { ok: false, reason: 'no-element' } });
|
|
175
|
+
expect(root.textContent).toContain('tidak ada elemen');
|
|
176
|
+
expect(root.textContent).not.toContain('beda origin');
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test('a successful lookup prints no reason line at all', () => {
|
|
180
|
+
const root = mount({
|
|
181
|
+
shapes: [mark({ element: { path: 'body > button', tag: 'button' } })],
|
|
182
|
+
readability: { ok: true, element: { path: 'body > button', tag: 'button' } },
|
|
183
|
+
});
|
|
184
|
+
expect(root.textContent).not.toContain('beda origin');
|
|
185
|
+
expect(root.textContent).not.toContain('tidak ada elemen');
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
describe('missingElementReason', () => {
|
|
190
|
+
test('no lookup yet says nothing', () => {
|
|
191
|
+
expect(missingElementReason(null)).toBeNull();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
test('a successful lookup says nothing', () => {
|
|
195
|
+
expect(missingElementReason({ ok: true, element: { path: 'body > a', tag: 'a' } })).toBeNull();
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
test('a frame that is not loaded yet is its own reason', () => {
|
|
199
|
+
expect(missingElementReason({ ok: false, reason: 'no-frame' })).toContain('belum dimuat');
|
|
200
|
+
});
|
|
201
|
+
});
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The annotation bar: which tool, what you are saying, and the two exits.
|
|
8
|
+
*
|
|
9
|
+
* It sits above the page rather than in the toolbar because the note belongs to
|
|
10
|
+
* the mark the user just drew — a note field in the address bar would be a
|
|
11
|
+
* second place to type about the same thing. The bar also spells out the limit
|
|
12
|
+
* the panel cannot hide: the page is the user's own frame, so no screenshot
|
|
13
|
+
* exists and the mark travels as coordinates plus words.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { Send, Trash2, X } from 'lucide-preact';
|
|
17
|
+
import { AnnotateTarget } from '@/client/components/workspace/user-browser-panel/AnnotateTarget';
|
|
18
|
+
import type { ElementAtResult } from '@/client/lib/browser/element-at';
|
|
19
|
+
import { ANNOTATE_TOOL_LABEL } from '@/shared/lib/browser/annotate';
|
|
20
|
+
import type { AnnotateShape, AnnotateTool } from '@/shared/types';
|
|
21
|
+
|
|
22
|
+
interface AnnotateBarProps {
|
|
23
|
+
tool: AnnotateTool;
|
|
24
|
+
shapes: AnnotateShape[];
|
|
25
|
+
selectedId: string | null;
|
|
26
|
+
/** How the last mark's element lookup went, for the "why no element" line. */
|
|
27
|
+
readability: ElementAtResult | null;
|
|
28
|
+
onTool: (tool: AnnotateTool) => void;
|
|
29
|
+
onLabel: (id: string, label: string) => void;
|
|
30
|
+
onNote: (id: string, note: string) => void;
|
|
31
|
+
onRemove: (id: string) => void;
|
|
32
|
+
onReset: () => void;
|
|
33
|
+
onCancel: () => void;
|
|
34
|
+
onSend: () => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const TOOLS: AnnotateTool[] = ['box', 'pin', 'arrow'];
|
|
38
|
+
|
|
39
|
+
const TOOL_BUTTON =
|
|
40
|
+
'px-2 py-1 rounded text-[11px] font-mono border transition-colors cursor-pointer';
|
|
41
|
+
const ACTION_BUTTON =
|
|
42
|
+
'flex items-center gap-1 px-2 py-1 rounded text-[11px] border border-ink/15 hover:border-ink/40 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed';
|
|
43
|
+
|
|
44
|
+
export function AnnotateBar({
|
|
45
|
+
tool,
|
|
46
|
+
shapes,
|
|
47
|
+
selectedId,
|
|
48
|
+
readability,
|
|
49
|
+
onTool,
|
|
50
|
+
onLabel,
|
|
51
|
+
onNote,
|
|
52
|
+
onRemove,
|
|
53
|
+
onReset,
|
|
54
|
+
onCancel,
|
|
55
|
+
onSend,
|
|
56
|
+
}: AnnotateBarProps) {
|
|
57
|
+
const selected = shapes.find((shape) => shape.id === selectedId) ?? null;
|
|
58
|
+
const usable = shapes.length > 0;
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<div className="flex-shrink-0 border-b border-ink/10 bg-paper px-2.5 py-1.5 space-y-1.5 select-none">
|
|
62
|
+
<div className="flex items-center gap-1.5">
|
|
63
|
+
<span className="text-[10px] uppercase font-mono text-ink/50 mr-1">Anotasi</span>
|
|
64
|
+
{TOOLS.map((entry) => (
|
|
65
|
+
<button
|
|
66
|
+
key={entry}
|
|
67
|
+
type="button"
|
|
68
|
+
onClick={() => onTool(entry)}
|
|
69
|
+
aria-pressed={tool === entry}
|
|
70
|
+
className={`${TOOL_BUTTON} ${tool === entry ? 'bg-ink text-canvas border-ink' : 'bg-canvas text-ink/70 border-ink/15 hover:border-ink/40'}`}
|
|
71
|
+
>
|
|
72
|
+
{ANNOTATE_TOOL_LABEL[entry]}
|
|
73
|
+
</button>
|
|
74
|
+
))}
|
|
75
|
+
<span className="text-[11px] font-mono text-ink/45 ml-1">
|
|
76
|
+
{shapes.length > 0 ? `${shapes.length} tanda` : 'tarik di halaman untuk menandai'}
|
|
77
|
+
</span>
|
|
78
|
+
<div className="flex-1" />
|
|
79
|
+
<button type="button" onClick={onReset} disabled={!usable} className={ACTION_BUTTON} title="Hapus semua tanda">
|
|
80
|
+
<Trash2 size={12} /> Bersihkan
|
|
81
|
+
</button>
|
|
82
|
+
<button type="button" onClick={onSend} disabled={!usable} className={ACTION_BUTTON} title="Kirim anotasi ke draft chat">
|
|
83
|
+
<Send size={12} /> Kirim ke chat
|
|
84
|
+
</button>
|
|
85
|
+
<button type="button" onClick={onCancel} className={ACTION_BUTTON} title="Tutup mode anotasi">
|
|
86
|
+
<X size={12} />
|
|
87
|
+
</button>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
{selected ? (
|
|
91
|
+
<div className="flex items-start gap-1.5">
|
|
92
|
+
<div className="flex-1 min-w-0">
|
|
93
|
+
<AnnotateTarget
|
|
94
|
+
shape={selected}
|
|
95
|
+
index={shapes.indexOf(selected) + 1}
|
|
96
|
+
readability={readability}
|
|
97
|
+
onLabel={(label) => onLabel(selected.id, label)}
|
|
98
|
+
onNote={(note) => onNote(selected.id, note)}
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
101
|
+
<button type="button" onClick={() => onRemove(selected.id)} className={ACTION_BUTTON} title="Hapus tanda ini">
|
|
102
|
+
<Trash2 size={12} />
|
|
103
|
+
</button>
|
|
104
|
+
</div>
|
|
105
|
+
) : (
|
|
106
|
+
<p className="text-[11px] text-ink/45">
|
|
107
|
+
Halaman ini tidak bisa di-screenshot — yang dikirim adalah area, nama bagian, dan catatanmu.
|
|
108
|
+
</p>
|
|
109
|
+
)}
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The annotation surface over the user's page.
|
|
8
|
+
*
|
|
9
|
+
* Two things are pinned here, and both are user-visible failures otherwise:
|
|
10
|
+
*
|
|
11
|
+
* - A drag becomes a mark whose points are NORMALIZED to the measured surface,
|
|
12
|
+
* so the same gesture at 100% and 200% zoom describes the same place. The
|
|
13
|
+
* panel's CSS `zoom` is applied by an ancestor, and `getBoundingClientRect`
|
|
14
|
+
* already reports the zoomed box — measured in Chromium at 150%: iframe
|
|
15
|
+
* 900×450, overlay 900×450 — so the ratio is scale-free by construction.
|
|
16
|
+
* - A click with no drag is not a region. Every stray click would otherwise
|
|
17
|
+
* become an empty mark in the prompt.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
21
|
+
import { Window } from 'happy-dom';
|
|
22
|
+
import { h, render } from 'preact';
|
|
23
|
+
import { act } from 'preact/test-utils';
|
|
24
|
+
import { AnnotateLayer } from '@/client/components/workspace/user-browser-panel/AnnotateLayer';
|
|
25
|
+
import type { AnnotateShape } from '@/shared/types';
|
|
26
|
+
|
|
27
|
+
const DOM_GLOBALS = [
|
|
28
|
+
'window',
|
|
29
|
+
'document',
|
|
30
|
+
'navigator',
|
|
31
|
+
'Node',
|
|
32
|
+
'Element',
|
|
33
|
+
'HTMLElement',
|
|
34
|
+
'Event',
|
|
35
|
+
'PointerEvent',
|
|
36
|
+
'ResizeObserver',
|
|
37
|
+
] as const;
|
|
38
|
+
const native: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
|
|
39
|
+
|
|
40
|
+
const WIDTH = 400;
|
|
41
|
+
const HEIGHT = 200;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The prototype members this suite replaces, and whether they were the
|
|
45
|
+
* prototype's OWN before.
|
|
46
|
+
*
|
|
47
|
+
* A happy-dom `Window`'s prototypes belong to the MODULE, not to the window
|
|
48
|
+
* object: a second `new Window()` in a later suite hands back the same
|
|
49
|
+
* `HTMLElement.prototype`, so a stub installed here and left behind is still
|
|
50
|
+
* installed for every file after this one. Measured: `getBoundingClientRect`
|
|
51
|
+
* answered this suite's 400×200 box to `toolbar-row/index.test.tsx`, whose
|
|
52
|
+
* `ToolbarRow` read a 400px row for a toolbar it asked to be 400 wide with
|
|
53
|
+
* three 60px clusters — one cluster too many, so the row rendered `⋯` and the
|
|
54
|
+
* case failed, in a file that names none of this.
|
|
55
|
+
*
|
|
56
|
+
* Restoring by ASSIGNMENT is not enough, and is its own leak: these members are
|
|
57
|
+
* inherited (`Element.prototype` owns `getBoundingClientRect`), so assigning
|
|
58
|
+
* the function back leaves an OWN property on `HTMLElement.prototype` that
|
|
59
|
+
* shadows the ancestor — and that shadow is what the next suite's
|
|
60
|
+
* `Element.prototype.getBoundingClientRect` stub then fails to reach. Only a
|
|
61
|
+
* member that was an own property is written back; the rest are deleted.
|
|
62
|
+
*/
|
|
63
|
+
const protoStubs: Record<string, { own: boolean; value: unknown }> = {};
|
|
64
|
+
let stubbedProto: Record<string, unknown> | undefined;
|
|
65
|
+
|
|
66
|
+
beforeAll(() => {
|
|
67
|
+
const win = new Window({ url: 'http://localhost' });
|
|
68
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
69
|
+
for (const key of DOM_GLOBALS) {
|
|
70
|
+
if (!(key in native)) native[key] = target[key];
|
|
71
|
+
target[key] = (win as unknown as Record<string, unknown>)[key];
|
|
72
|
+
}
|
|
73
|
+
// happy-dom has no layout: the surface reports the box these cases drag on.
|
|
74
|
+
const proto = win.HTMLElement.prototype as unknown as Record<string, unknown>;
|
|
75
|
+
stubbedProto = proto;
|
|
76
|
+
for (const key of ['getBoundingClientRect', 'setPointerCapture', 'releasePointerCapture']) {
|
|
77
|
+
const descriptor = Object.getOwnPropertyDescriptor(proto, key);
|
|
78
|
+
protoStubs[key] = { own: descriptor !== undefined, value: proto[key] };
|
|
79
|
+
}
|
|
80
|
+
proto.getBoundingClientRect = () => ({
|
|
81
|
+
x: 0, y: 0, left: 0, top: 0, right: WIDTH, bottom: HEIGHT, width: WIDTH, height: HEIGHT,
|
|
82
|
+
toJSON: () => ({}),
|
|
83
|
+
});
|
|
84
|
+
proto.setPointerCapture = () => {};
|
|
85
|
+
proto.releasePointerCapture = () => {};
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
afterAll(() => {
|
|
89
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
90
|
+
for (const key of DOM_GLOBALS) {
|
|
91
|
+
if (native[key] === undefined) delete target[key];
|
|
92
|
+
else target[key] = native[key];
|
|
93
|
+
}
|
|
94
|
+
// Put the prototype back BEFORE the globals go: the next suite gets its own
|
|
95
|
+
// window object but this same prototype.
|
|
96
|
+
if (stubbedProto) {
|
|
97
|
+
for (const [key, { own, value }] of Object.entries(protoStubs)) {
|
|
98
|
+
if (own) stubbedProto[key] = value;
|
|
99
|
+
else delete stubbedProto[key];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
let container: HTMLElement | undefined;
|
|
105
|
+
let added: AnnotateShape[] = [];
|
|
106
|
+
let measured: { width: number; height: number }[] = [];
|
|
107
|
+
|
|
108
|
+
function mount(tool: AnnotateShape['tool'] = 'box'): HTMLElement {
|
|
109
|
+
added = [];
|
|
110
|
+
measured = [];
|
|
111
|
+
container = document.body.appendChild(document.createElement('div'));
|
|
112
|
+
act(() => {
|
|
113
|
+
render(h(AnnotateLayer, {
|
|
114
|
+
shapes: [],
|
|
115
|
+
tool,
|
|
116
|
+
selectedId: null,
|
|
117
|
+
onMeasure: (size) => measured.push(size),
|
|
118
|
+
onAdd: (shape) => added.push(shape),
|
|
119
|
+
onSelect: () => {},
|
|
120
|
+
}), container!);
|
|
121
|
+
});
|
|
122
|
+
const surface = container.querySelector('div');
|
|
123
|
+
if (!surface) throw new Error('overlay did not render');
|
|
124
|
+
return surface as HTMLElement;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** A pointer gesture as the browser delivers it. */
|
|
128
|
+
function drag(surface: HTMLElement, from: [number, number], to: [number, number], target: EventTarget = surface): void {
|
|
129
|
+
act(() => {
|
|
130
|
+
target.dispatchEvent(new window.PointerEvent('pointerdown', { clientX: from[0], clientY: from[1], button: 0, bubbles: true }));
|
|
131
|
+
target.dispatchEvent(new window.PointerEvent('pointermove', { clientX: to[0], clientY: to[1], bubbles: true }));
|
|
132
|
+
target.dispatchEvent(new window.PointerEvent('pointerup', { clientX: to[0], clientY: to[1], bubbles: true }));
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
beforeEach(() => {
|
|
137
|
+
container?.remove();
|
|
138
|
+
container = undefined;
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
afterEach(() => {
|
|
142
|
+
if (container) render(null, container);
|
|
143
|
+
container?.remove();
|
|
144
|
+
container = undefined;
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe('AnnotateLayer', () => {
|
|
148
|
+
test('reports the measured box, which is what makes a percentage resolvable', () => {
|
|
149
|
+
mount();
|
|
150
|
+
expect(measured).toContainEqual({ width: WIDTH, height: HEIGHT });
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test('a drag becomes a mark with points normalized to the surface', () => {
|
|
154
|
+
const surface = mount();
|
|
155
|
+
drag(surface, [40, 20], [120, 70]);
|
|
156
|
+
expect(added).toHaveLength(1);
|
|
157
|
+
const shape = added[0]!;
|
|
158
|
+
expect(shape.tool).toBe('box');
|
|
159
|
+
expect(shape.start.x).toBeCloseTo(0.1, 5);
|
|
160
|
+
expect(shape.start.y).toBeCloseTo(0.1, 5);
|
|
161
|
+
expect(shape.end.x).toBeCloseTo(0.3, 5);
|
|
162
|
+
expect(shape.end.y).toBeCloseTo(0.35, 5);
|
|
163
|
+
expect(shape.note).toBe('');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test('the same gesture describes the same place at any panel size', () => {
|
|
167
|
+
const surface = mount();
|
|
168
|
+
drag(surface, [WIDTH / 4, HEIGHT / 4], [WIDTH / 2, HEIGHT / 2]);
|
|
169
|
+
const small = added[0]!;
|
|
170
|
+
added = [];
|
|
171
|
+
// A drag over the same fractions of a bigger box is the same mark.
|
|
172
|
+
drag(surface, [WIDTH / 2, HEIGHT / 2], [WIDTH / 4, HEIGHT / 4]);
|
|
173
|
+
const reversed = added[0]!;
|
|
174
|
+
expect(reversed.start).toEqual({ x: 0.5, y: 0.5 });
|
|
175
|
+
expect(reversed.end).toEqual({ x: 0.25, y: 0.25 });
|
|
176
|
+
expect(small.start).toEqual({ x: 0.25, y: 0.25 });
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test('a click with no drag is not a mark', () => {
|
|
180
|
+
const surface = mount();
|
|
181
|
+
drag(surface, [50, 50], [51, 51]);
|
|
182
|
+
expect(added).toEqual([]);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
test('a pin counts without a drag, because a point is the whole mark', () => {
|
|
186
|
+
const surface = mount('pin');
|
|
187
|
+
drag(surface, [100, 40], [100, 40]);
|
|
188
|
+
expect(added).toHaveLength(1);
|
|
189
|
+
expect(added[0]!.start).toEqual({ x: 0.25, y: 0.2 });
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test('a pointer that leaves the surface clamps instead of storing an out-of-range point', () => {
|
|
193
|
+
const surface = mount();
|
|
194
|
+
drag(surface, [10, 10], [WIDTH + 200, HEIGHT + 200]);
|
|
195
|
+
expect(added[0]!.end).toEqual({ x: 1, y: 1 });
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
test('the overlay covers the page, so no pointer reaches the iframe underneath', () => {
|
|
199
|
+
const surface = mount();
|
|
200
|
+
expect(surface.className).toContain('absolute');
|
|
201
|
+
expect(surface.className).toContain('inset-0');
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
describe('AnnotateLayer marks', () => {
|
|
206
|
+
test('every committed mark is painted with its number', () => {
|
|
207
|
+
container = document.body.appendChild(document.createElement('div'));
|
|
208
|
+
const shapes: AnnotateShape[] = [
|
|
209
|
+
{ id: 'a', tool: 'box', start: { x: 0.1, y: 0.1 }, end: { x: 0.2, y: 0.2 }, label: '', note: '' },
|
|
210
|
+
{ id: 'b', tool: 'pin', start: { x: 0.5, y: 0.5 }, end: { x: 0.5, y: 0.5 }, label: '', note: '' },
|
|
211
|
+
];
|
|
212
|
+
act(() => {
|
|
213
|
+
render(h(AnnotateLayer, {
|
|
214
|
+
shapes,
|
|
215
|
+
tool: 'box',
|
|
216
|
+
selectedId: null,
|
|
217
|
+
onMeasure: () => {},
|
|
218
|
+
onAdd: () => {},
|
|
219
|
+
onSelect: () => {},
|
|
220
|
+
}), container!);
|
|
221
|
+
});
|
|
222
|
+
const numbers = [...container.querySelectorAll('text')].map((node) => node.textContent);
|
|
223
|
+
expect(numbers).toEqual(['1', '2']);
|
|
224
|
+
});
|
|
225
|
+
});
|