@kabmo-labs/kabmo 0.11.1 → 0.12.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 +67 -421
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +426 -413
- package/dist/client/static/js/{index-amss8pge.js → index-0smc9gm2.js} +1123 -747
- package/dist/client/static/js/index-shexbk5f.css +1 -0
- package/marketplace/marketplace.json +13 -3
- package/marketplace/plugins/command-runner/package.json +4 -2
- package/marketplace/plugins/git-forge/README.md +219 -0
- package/marketplace/plugins/git-forge/icon.svg +20 -0
- package/marketplace/plugins/git-forge/package.json +56 -0
- package/marketplace/plugins/git-forge/src/app.tsx +82 -0
- package/marketplace/plugins/git-forge/src/command.test.ts +181 -0
- package/marketplace/plugins/git-forge/src/command.ts +119 -0
- package/marketplace/plugins/git-forge/src/header.tsx +87 -0
- package/marketplace/plugins/git-forge/src/panel/Badge.tsx +76 -0
- package/marketplace/plugins/git-forge/src/panel/Change.tsx +150 -0
- package/marketplace/plugins/git-forge/src/panel/CiBadge.tsx +51 -0
- package/marketplace/plugins/git-forge/src/panel/Credential.tsx +107 -0
- package/marketplace/plugins/git-forge/src/panel/Glyph.tsx +70 -0
- package/marketplace/plugins/git-forge/src/panel/Header.tsx +255 -0
- package/marketplace/plugins/git-forge/src/panel/ItemView.tsx +198 -0
- package/marketplace/plugins/git-forge/src/panel/List.tsx +89 -0
- package/marketplace/plugins/git-forge/src/panel/Row.tsx +68 -0
- package/marketplace/plugins/git-forge/src/panel/Sidebar.tsx +94 -0
- package/marketplace/plugins/git-forge/src/panel/Write.tsx +236 -0
- package/marketplace/plugins/git-forge/src/panel/format.ts +78 -0
- package/marketplace/plugins/git-forge/src/panel/index.test.tsx +344 -0
- package/marketplace/plugins/git-forge/src/panel/index.tsx +193 -0
- package/marketplace/plugins/git-forge/src/panel/use-forge.ts +250 -0
- package/marketplace/plugins/git-forge/src/panel/write.test.tsx +269 -0
- package/marketplace/plugins/git-forge/src/protocol.ts +308 -0
- package/marketplace/plugins/git-forge/src/server/adapters.test.ts +274 -0
- package/marketplace/plugins/git-forge/src/server/bitbucket.ts +307 -0
- package/marketplace/plugins/git-forge/src/server/capabilities.test.ts +116 -0
- package/marketplace/plugins/git-forge/src/server/capabilities.ts +105 -0
- package/marketplace/plugins/git-forge/src/server/ci.test.ts +88 -0
- package/marketplace/plugins/git-forge/src/server/ci.ts +118 -0
- package/marketplace/plugins/git-forge/src/server/context.ts +76 -0
- package/marketplace/plugins/git-forge/src/server/diff.test.ts +127 -0
- package/marketplace/plugins/git-forge/src/server/diff.ts +120 -0
- package/marketplace/plugins/git-forge/src/server/filters.test.ts +138 -0
- package/marketplace/plugins/git-forge/src/server/filters.ts +138 -0
- package/marketplace/plugins/git-forge/src/server/forges.test.ts +235 -0
- package/marketplace/plugins/git-forge/src/server/gitea.ts +296 -0
- package/marketplace/plugins/git-forge/src/server/github-extras.ts +92 -0
- package/marketplace/plugins/git-forge/src/server/github.ts +320 -0
- package/marketplace/plugins/git-forge/src/server/gitlab-detail.ts +207 -0
- package/marketplace/plugins/git-forge/src/server/gitlab.test.ts +195 -0
- package/marketplace/plugins/git-forge/src/server/gitlab.ts +176 -0
- package/marketplace/plugins/git-forge/src/server/http.test.ts +270 -0
- package/marketplace/plugins/git-forge/src/server/http.ts +329 -0
- package/marketplace/plugins/git-forge/src/server/map.ts +120 -0
- package/marketplace/plugins/git-forge/src/server/registry.ts +47 -0
- package/marketplace/plugins/git-forge/src/server/remote.test.ts +146 -0
- package/marketplace/plugins/git-forge/src/server/remote.ts +188 -0
- package/marketplace/plugins/git-forge/src/server/scope-probe.test.ts +98 -0
- package/marketplace/plugins/git-forge/src/server/scope-probe.ts +128 -0
- package/marketplace/plugins/git-forge/src/server/scope.ts +66 -0
- package/marketplace/plugins/git-forge/src/server/test-context.ts +67 -0
- package/marketplace/plugins/git-forge/src/server/test-host.ts +51 -0
- package/marketplace/plugins/git-forge/src/server/token.test.ts +107 -0
- package/marketplace/plugins/git-forge/src/server/token.ts +139 -0
- package/marketplace/plugins/git-forge/src/server/write-http.test.ts +127 -0
- package/marketplace/plugins/git-forge/src/server/write-http.ts +110 -0
- package/marketplace/plugins/git-forge/src/server/writes.test.ts +218 -0
- package/marketplace/plugins/git-forge/src/server/writes.ts +313 -0
- package/marketplace/plugins/git-forge/src/server.ts +284 -0
- package/marketplace/plugins/git-forge/tsconfig.json +16 -0
- package/marketplace/plugins/session-info/package.json +4 -2
- package/marketplace/plugins/stats/package.json +4 -2
- package/package.json +6 -1
- package/src/client/components/common/code-surface/blame-hover.ts +188 -0
- package/src/client/components/common/code-surface/blame-panel.test.ts +304 -0
- package/src/client/components/common/code-surface/blame-panel.ts +306 -0
- package/src/client/components/common/code-surface/blame.test.ts +303 -0
- package/src/client/components/common/code-surface/blame.ts +227 -0
- package/src/client/components/common/code-surface/conflict-markers.test.ts +135 -0
- package/src/client/components/common/code-surface/conflict-markers.ts +144 -0
- package/src/client/components/common/code-surface/documents.ts +48 -1
- package/src/client/components/common/code-surface/extensions.test.ts +4 -0
- package/src/client/components/common/code-surface/extensions.ts +44 -0
- package/src/client/components/common/code-surface/fold-stack.test.ts +4 -0
- package/src/client/components/common/code-surface/indent.test.ts +5 -0
- package/src/client/components/common/code-surface/index.tsx +16 -2
- package/src/client/components/common/code-surface/lint-parsers.test.ts +109 -0
- package/src/client/components/common/code-surface/lint-parsers.ts +134 -0
- package/src/client/components/common/code-surface/lint.test.ts +101 -0
- package/src/client/components/common/code-surface/lint.ts +85 -0
- package/src/client/components/common/code-surface/props.ts +17 -0
- package/src/client/components/common/code-surface/surface-failures.test.ts +132 -0
- package/src/client/components/common/code-surface/theme.ts +71 -0
- package/src/client/components/common/header-controls/index.test.tsx +1 -1
- package/src/client/components/common/header-controls/plugin-entry.test.tsx +1 -1
- package/src/client/components/common/header-controls/shell-chrome.test.tsx +1 -1
- package/src/client/components/common/provider-icon/Plate.tsx +88 -0
- package/src/client/components/common/provider-icon/index.tsx +55 -11
- package/src/client/components/layout/session-sidebar/SessionsView.tsx +5 -2
- package/src/client/components/mobile/SessionSidebar.tsx +2 -10
- package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +6 -0
- package/src/client/components/mobile/mobile-right-sidebar/StatusBar.tsx +8 -0
- package/src/client/components/settings/categories/AppearanceSettings.tsx +3 -0
- package/src/client/components/settings/categories/ProviderSettings.tsx +43 -41
- package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +97 -0
- package/src/client/components/settings/categories/panel-plugins/AvailableList.tsx +106 -54
- package/src/client/components/settings/categories/panel-plugins/GitFreshness.tsx +14 -1
- package/src/client/components/settings/categories/panel-plugins/InstalledList.tsx +39 -150
- package/src/client/components/settings/categories/panel-plugins/Meta.test.tsx +143 -0
- package/src/client/components/settings/categories/panel-plugins/Meta.tsx +157 -0
- package/src/client/components/settings/categories/panel-plugins/Placement.test.tsx +149 -0
- package/src/client/components/settings/categories/panel-plugins/Placement.tsx +99 -0
- package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +270 -0
- package/src/client/components/settings/categories/panel-plugins/Section.tsx +11 -3
- package/src/client/components/settings/categories/provider-settings/AddModelModal.tsx +25 -0
- package/src/client/components/settings/categories/provider-settings/AuthSection.tsx +135 -80
- package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +51 -21
- package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +175 -0
- package/src/client/components/settings/categories/provider-settings/EntryModal.tsx +275 -0
- package/src/client/components/settings/categories/provider-settings/Header.tsx +40 -9
- package/src/client/components/settings/categories/provider-settings/LoginModal.tsx +142 -160
- package/src/client/components/settings/categories/provider-settings/LogoutProviderModal.tsx +2 -2
- package/src/client/components/settings/categories/provider-settings/ModelCapabilitiesModal.tsx +84 -46
- package/src/client/components/settings/categories/provider-settings/ModelsList.tsx +217 -102
- package/src/client/components/settings/categories/provider-settings/PresetPicker.tsx +5 -2
- package/src/client/components/settings/categories/provider-settings/SidebarList.plugin.test.ts +3 -3
- package/src/client/components/settings/categories/provider-settings/SidebarList.tsx +158 -102
- package/src/client/components/settings/categories/provider-settings/auth-section.test.tsx +135 -0
- package/src/client/components/settings/categories/provider-settings/groups.test.ts +98 -0
- package/src/client/components/settings/categories/provider-settings/groups.ts +108 -0
- package/src/client/components/settings/categories/provider-settings/layout.test.tsx +325 -0
- package/src/client/components/settings/categories/provider-settings/model-dialogs.test.tsx +135 -0
- package/src/client/components/settings/categories/provider-settings/preset-picker.test.tsx +73 -0
- package/src/client/components/settings/categories/usage-settings/ProviderCard.tsx +22 -2
- package/src/client/components/settings/categories/usage-settings/ProviderDetail.tsx +2 -0
- package/src/client/components/settings/categories/usage-settings/SidebarList.tsx +16 -6
- package/src/client/components/settings/categories/usage-settings/providers.ts +3 -0
- package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +19 -0
- package/src/client/components/settings/categories/usage-settings/usage-icons.test.tsx +143 -0
- package/src/client/components/workspace/chat-timeline/MinimapShortcuts.test.ts +2 -1
- package/src/client/components/workspace/chat-timeline/chat-input/GoalBanner.test.ts +23 -19
- package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.test.ts +23 -19
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +20 -18
- package/src/client/components/workspace/chat-timeline/chat-input/compact.test.tsx +19 -6
- package/src/client/components/workspace/chat-timeline/index.tsx +7 -16
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.missing.test.ts +100 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.test.ts +3 -47
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +8 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/wait-test-util.ts +62 -0
- package/src/client/components/workspace/diff-panel/HunkStepper.tsx +62 -0
- package/src/client/components/workspace/diff-panel/MergeDiffView.tsx +29 -0
- package/src/client/components/workspace/diff-panel/Toolbar.tsx +32 -1
- package/src/client/components/workspace/diff-panel/changes.ts +69 -0
- package/src/client/components/workspace/diff-panel/chunks.ts +85 -0
- package/src/client/components/workspace/diff-panel/index.tsx +21 -1
- package/src/client/components/workspace/diff-panel/merge.test.ts +145 -0
- package/src/client/components/workspace/diff-panel/merge.ts +63 -68
- package/src/client/components/workspace/editor/EditorDropOverlay.tsx +6 -1
- package/src/client/components/workspace/editor/FileDocument.tsx +51 -1
- package/src/client/components/workspace/editor/FilePane.tsx +25 -1
- package/src/client/components/workspace/editor/StatusBar.tsx +19 -0
- package/src/client/components/workspace/editor/Toolbar.tsx +29 -5
- package/src/client/components/workspace/editor/toolbar-clusters.test.ts +86 -0
- package/src/client/components/workspace/editor/toolbar-clusters.tsx +48 -16
- package/src/client/components/workspace/editor/viewers/bytes.ts +16 -0
- package/src/client/components/workspace/git-panel/index.test.ts +46 -1
- package/src/client/components/workspace/git-panel/index.tsx +11 -38
- package/src/client/components/workspace/model-dropdown/Item.plugin.test.ts +66 -0
- package/src/client/components/workspace/model-dropdown/Item.tsx +71 -62
- package/src/client/components/workspace/model-dropdown/Section.tsx +31 -14
- package/src/client/components/workspace/model-dropdown/collapsed.ts +72 -0
- package/src/client/components/workspace/model-dropdown/index.tsx +42 -19
- package/src/client/components/workspace/model-dropdown/refresh.test.tsx +260 -0
- package/src/client/components/workspace/model-dropdown/trigger.test.ts +34 -0
- package/src/client/components/workspace/model-dropdown/use-catalog.ts +13 -2
- package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +19 -3
- package/src/client/hooks/chat/omp/folder-auto-expand.ts +113 -0
- package/src/client/hooks/chat/omp/index.ts +20 -0
- package/src/client/hooks/chat/omp/pending-rows.ts +21 -0
- package/src/client/hooks/chat/omp/pending-sessions.test.ts +16 -1
- package/src/client/hooks/chat/omp/session-sidebar-controller.test.ts +102 -0
- package/src/client/hooks/chat/omp/session-sidebar-controller.ts +21 -1
- package/src/client/hooks/chat/omp/stream.ts +8 -1
- package/src/client/hooks/chat/timeline/index.ts +1 -1
- package/src/client/hooks/chat/timeline/new-chat-open.ts +60 -0
- package/src/client/hooks/editor/blame-settings.ts +67 -0
- package/src/client/hooks/editor/blame.test.ts +272 -0
- package/src/client/hooks/editor/blame.ts +232 -0
- package/src/client/hooks/editor/file-editor-types.ts +23 -0
- package/src/client/hooks/editor/save-file.test.ts +20 -0
- package/src/client/hooks/editor/use-editor-drop.test-util.ts +198 -0
- package/src/client/hooks/editor/use-editor-drop.test.ts +70 -175
- package/src/client/hooks/editor/use-editor-drop.ts +19 -36
- package/src/client/hooks/editor/use-file-editor.ts +7 -1
- package/src/client/hooks/settings/providers/actions.ts +90 -194
- package/src/client/hooks/settings/providers/api.ts +7 -1
- package/src/client/hooks/settings/providers/index.ts +171 -59
- package/src/client/hooks/settings/providers/login.test.ts +79 -0
- package/src/client/hooks/settings/providers/login.ts +276 -0
- package/src/client/hooks/settings/providers/messages.ts +28 -0
- package/src/client/hooks/settings/providers/model-actions.ts +178 -0
- package/src/client/hooks/ui/editor-error-toast.ts +47 -0
- package/src/client/hooks/ui/open-file.ts +7 -0
- package/src/client/hooks/ui/toasts.ts +7 -0
- package/src/client/hooks/workspace/file-tabs.ts +4 -1
- package/src/client/hooks/workspace/folder-expansion.test.ts +62 -0
- package/src/client/hooks/workspace/folder-expansion.ts +33 -0
- package/src/client/hooks/workspace/git-action-outcome.ts +86 -0
- package/src/client/hooks/workspace/git-actions.ts +29 -2
- package/src/client/hooks/workspace/plugin-contributions.test.ts +117 -0
- package/src/client/hooks/workspace/plugin-contributions.ts +146 -0
- package/src/client/lib/editor-errors.test.ts +85 -0
- package/src/client/lib/editor-errors.ts +71 -0
- package/src/client/lib/fs/resolve-open.test.ts +125 -0
- package/src/client/lib/fs/resolve-open.ts +90 -0
- package/src/client/lib/git/action-message.test.ts +82 -0
- package/src/client/lib/git/action-message.ts +160 -0
- package/src/client/lib/launch/device-files.test.ts +160 -0
- package/src/client/lib/launch/device-files.ts +197 -0
- package/src/client/lib/native/open-paths.test.ts +140 -0
- package/src/client/lib/native/open-paths.ts +157 -0
- package/src/client/lib/plugins/bootstrap.test.ts +1 -1
- package/src/client/main.tsx +20 -0
- package/src/server/db.server.test.ts +39 -0
- package/src/server/db.server.ts +21 -2
- package/src/server/lib/db/schema.ts +2 -0
- package/src/server/lib/fs/external-roots.test.ts +100 -0
- package/src/server/lib/fs/external-roots.ts +101 -0
- package/src/server/lib/fs/git-actions-branch.ts +15 -2
- package/src/server/lib/fs/git-actions-shared.ts +24 -0
- package/src/server/lib/fs/git-actions-sync.test.ts +18 -7
- package/src/server/lib/fs/git-actions-worktree.ts +5 -1
- package/src/server/lib/fs/git-blame.test.ts +206 -0
- package/src/server/lib/fs/git-blame.ts +189 -0
- package/src/server/lib/fs/root.ts +14 -0
- package/src/server/lib/http/same-origin.ts +28 -7
- package/src/server/lib/models/catalog.server.ts +230 -0
- package/src/server/lib/models/catalog.test.ts +83 -0
- package/src/server/lib/models/credential-origin.server.ts +108 -0
- package/src/server/lib/models/credential-origin.test.ts +132 -0
- package/src/server/lib/models/provider-icon-fetch.ts +115 -0
- package/src/server/lib/models/provider-icon-parse.test.ts +134 -0
- package/src/server/lib/models/provider-icon-parse.ts +139 -0
- package/src/server/lib/models/provider-icon-store.server.ts +118 -0
- package/src/server/lib/models/provider-icon-store.test.ts +107 -0
- package/src/server/lib/models/provider-icon.server.ts +209 -0
- package/src/server/lib/models/provider-items.server.ts +211 -37
- package/src/server/lib/models/provider-items.test.ts +201 -0
- package/src/server/lib/models/provider-registry.server.test.ts +27 -9
- package/src/server/lib/models/provider-registry.server.ts +160 -67
- package/src/server/lib/models/registry.server.test.ts +3 -3
- package/src/server/lib/models/registry.server.ts +8 -0
- package/src/server/lib/omp/config/definitions.test.ts +5 -4
- package/src/server/lib/omp/config/models-config.ts +42 -0
- package/src/server/lib/omp/config/provider-entry.test.ts +205 -0
- package/src/server/lib/omp/config/provider-entry.ts +197 -0
- package/src/server/lib/omp/config/provider-seeds.ts +10 -0
- package/src/server/lib/omp/core/models-json.ts +69 -0
- package/src/server/lib/omp/session/messages.ts +17 -3
- package/src/server/lib/omp/session/sidebar-data.canonical.test.ts +13 -3
- package/src/server/lib/panels/bundled-catalog.server.ts +7 -0
- package/src/server/lib/panels/catalog-offers.server.ts +68 -0
- package/src/server/lib/panels/git-update.server.test.ts +14 -0
- package/src/server/lib/panels/git-update.server.ts +63 -1
- package/src/server/lib/panels/manifest.test.ts +65 -0
- package/src/server/lib/panels/manifest.ts +55 -1
- package/src/server/lib/panels/offers.server.test.ts +191 -0
- package/src/server/lib/panels/offers.server.ts +108 -0
- package/src/server/lib/panels/registry.server.test.ts +35 -1
- package/src/server/lib/panels/registry.server.ts +51 -142
- package/src/server/lib/panels/scan.server.ts +162 -0
- package/src/server/lib/route-adapter.ts +13 -2
- package/src/server/lib/tray/tray.test.ts +2 -1
- package/src/server/lib/usage/providers.server.ts +4 -1
- package/src/server/routes/chat/session.ts +7 -1
- package/src/server/routes/fs/git-blame-loader.test.ts +146 -0
- package/src/server/routes/fs/git.ts +17 -0
- package/src/server/routes/fs/grant.test.ts +135 -0
- package/src/server/routes/fs/grant.ts +79 -0
- package/src/server/routes/fs/index.ts +2 -0
- package/src/server/routes/fs/scope.ts +34 -17
- package/src/server/routes/omp/login.ts +41 -14
- package/src/server/routes/omp/routes.test.ts +23 -10
- package/src/server/routes/settings/index.ts +8 -0
- package/src/server/routes/settings/provider-entry.ts +108 -0
- package/src/server/routes/settings/provider-icon.ts +99 -0
- package/src/server/routes/settings/provider-model.ts +4 -1
- package/src/server/routes/settings/provider-refresh.ts +87 -0
- package/src/server/routes/settings/providers.ts +31 -2
- package/src/shared/lib/chat/omp/fold.test.ts +34 -0
- package/src/shared/lib/chat/omp/tool-frames.test.ts +20 -0
- package/src/shared/lib/chat/omp/tool-frames.ts +5 -1
- package/src/shared/lib/chat/omp/tool-results.ts +29 -3
- package/src/shared/lib/chat/tool/wait-facts.ts +4 -0
- package/src/shared/lib/fs/git-blame.test.ts +266 -0
- package/src/shared/lib/fs/git-blame.ts +246 -0
- package/src/shared/lib/git/url.ts +18 -0
- package/src/shared/lib/markdown/sanitize.test.ts +57 -0
- package/src/shared/lib/markdown/sanitize.ts +30 -7
- package/src/shared/lib/models/provider/connection.ts +135 -0
- package/src/shared/lib/models/provider/dialect.test.ts +4 -2
- package/src/shared/lib/models/provider/dialect.ts +76 -6
- package/src/shared/lib/models/provider/models.ts +2 -0
- package/src/shared/lib/models/provider/origin.ts +94 -0
- package/src/shared/lib/models/provider/provider-ui.test.ts +7 -0
- package/src/shared/lib/models/server-cache.ts +8 -3
- package/src/shared/lib/omp/session/messages-map-pending.test.ts +110 -0
- package/src/shared/lib/omp/session/messages-map.ts +34 -2
- package/src/shared/lib/omp/session/prewarm-misc.test.ts +7 -90
- package/src/shared/lib/omp/session/prewarm.test.ts +133 -0
- package/src/shared/lib/omp/session/prewarm.ts +23 -1
- package/src/shared/lib/omp/session/wait.test.ts +28 -0
- package/src/shared/lib/omp/session/wait.ts +38 -3
- package/src/shared/lib/panels/slot-labels.test.ts +61 -0
- package/src/shared/lib/panels/slot-labels.ts +133 -0
- package/src/shared/lib/workspace/panel-ids.ts +11 -0
- package/src/shared/types/fs.ts +6 -0
- package/src/shared/types/index.ts +1 -0
- package/src/shared/types/models.ts +12 -0
- package/src/shared/types/panels-registry.ts +277 -0
- package/src/shared/types/panels.ts +46 -213
- package/src/shared/types/settings/provider.ts +58 -0
- package/src/shared/types/settings/usage.ts +10 -0
- package/src/test-support/pristine-globals.ts +7 -0
- package/dist/client/static/js/index-bq6qeayr.css +0 -1
- package/src/client/components/settings/categories/provider-settings/ReconnectModal.tsx +0 -184
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Both Usage surfaces draw the provider's own mark.
|
|
8
|
+
*
|
|
9
|
+
* There are two of them — Settings → Usage (a sidebar list plus a card header)
|
|
10
|
+
* and the right-panel Usage view (a dropdown) — and both drew
|
|
11
|
+
* `ProviderIcon` alone, which resolves against the built-in glyph table. That
|
|
12
|
+
* table cannot know a `models.yml` gateway, so a provider whose site favicon
|
|
13
|
+
* had already been fetched and stored showed its logo in Settings → Providers
|
|
14
|
+
* and bare initials in both Usage surfaces. The plate is what closes that gap,
|
|
15
|
+
* and `iconUrl` is the field it needs on the summary.
|
|
16
|
+
*
|
|
17
|
+
* Pinned here rather than left to a screenshot: an `<img>` whose `src` is the
|
|
18
|
+
* stored icon URL, on a plate of the surface's own size, and a provider WITHOUT
|
|
19
|
+
* one still drawing the built-in mark (so a missing favicon cannot leave an
|
|
20
|
+
* empty box).
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
24
|
+
import { Window } from 'happy-dom';
|
|
25
|
+
import { render } from 'preact';
|
|
26
|
+
import { act } from 'preact/test-utils';
|
|
27
|
+
import { UsageSidebarList } from '@/client/components/settings/categories/usage-settings/SidebarList';
|
|
28
|
+
import { ProviderSelect } from '@/client/components/workspace/usage-panel/ProviderSelect';
|
|
29
|
+
import { ProviderCard } from '@/client/components/settings/categories/usage-settings/ProviderCard';
|
|
30
|
+
import type { UsageReport } from '@/shared/types';
|
|
31
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
32
|
+
|
|
33
|
+
const ICON = '/api/provider-icon?slug=localtest&v=7';
|
|
34
|
+
|
|
35
|
+
let container: HTMLElement;
|
|
36
|
+
|
|
37
|
+
const report: UsageReport = {
|
|
38
|
+
isMock: false,
|
|
39
|
+
generatedAt: '2026-01-01T00:00:00.000Z',
|
|
40
|
+
providers: [
|
|
41
|
+
{
|
|
42
|
+
id: 'localtest',
|
|
43
|
+
name: 'Local Test',
|
|
44
|
+
iconUrl: ICON,
|
|
45
|
+
credentialSources: ['models.yml'],
|
|
46
|
+
tracked: true,
|
|
47
|
+
limits: [],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: 'deepseek',
|
|
51
|
+
name: 'DeepSeek',
|
|
52
|
+
credentialSources: ['environment'],
|
|
53
|
+
tracked: false,
|
|
54
|
+
limits: [],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: 'plain',
|
|
58
|
+
name: 'Plain',
|
|
59
|
+
credentialSources: ['environment'],
|
|
60
|
+
tracked: false,
|
|
61
|
+
limits: [],
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
function mount(node: preact.ComponentChild): HTMLElement {
|
|
67
|
+
act(() => render(node, container));
|
|
68
|
+
return container;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
beforeEach(() => {
|
|
72
|
+
installDomGlobals(new Window());
|
|
73
|
+
container = document.createElement('div');
|
|
74
|
+
document.body.appendChild(container);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
afterEach(() => {
|
|
78
|
+
act(() => render(null, container));
|
|
79
|
+
container.remove();
|
|
80
|
+
restoreDomGlobals();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe('Settings → Usage sidebar', () => {
|
|
84
|
+
test('a stored web icon is drawn in colour, on a plate', () => {
|
|
85
|
+
const dom = mount(<UsageSidebarList report={report} selectedProviderId="localtest" onSelectProvider={() => {}} />);
|
|
86
|
+
const image = dom.querySelector('img');
|
|
87
|
+
expect(image?.getAttribute('src')).toBe(ICON);
|
|
88
|
+
// The plate is the fixed box; the image is inset inside it (12% per side).
|
|
89
|
+
const plate = image?.parentElement;
|
|
90
|
+
expect(plate?.style.width).toBe('20px');
|
|
91
|
+
expect(plate?.style.height).toBe('20px');
|
|
92
|
+
expect(plate?.getAttribute('aria-hidden')).toBe('true');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('a provider with no icon still draws the built-in mark', () => {
|
|
96
|
+
const dom = mount(<UsageSidebarList report={report} selectedProviderId="deepseek" onSelectProvider={() => {}} />);
|
|
97
|
+
// Three rows, one image: a provider without a stored favicon falls back to
|
|
98
|
+
// the glyph table (deepseek) or to its initials (plain), never to an empty
|
|
99
|
+
// plate.
|
|
100
|
+
expect(dom.querySelectorAll('img')).toHaveLength(1);
|
|
101
|
+
expect(dom.querySelectorAll('svg').length).toBeGreaterThan(0);
|
|
102
|
+
expect(dom.textContent).toContain('p.');
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe('right-panel Usage dropdown', () => {
|
|
107
|
+
const providers = [
|
|
108
|
+
{ id: 'localtest', name: 'Local Test', iconUrl: ICON, hint: 'Connected', limits: [], tracked: true, summary: report.providers[0]! },
|
|
109
|
+
{ id: 'plain', name: 'Plain', hint: 'Connected', limits: [], tracked: false, summary: report.providers[2]! },
|
|
110
|
+
];
|
|
111
|
+
|
|
112
|
+
test('the trigger and its option rows both carry the web icon', () => {
|
|
113
|
+
const dom = mount(<ProviderSelect providers={providers} value="localtest" onChange={() => {}} />);
|
|
114
|
+
const trigger = dom.querySelector('button[aria-haspopup="listbox"]');
|
|
115
|
+
const triggerImage = trigger?.querySelector('img');
|
|
116
|
+
expect(triggerImage?.getAttribute('src')).toBe(ICON);
|
|
117
|
+
expect(triggerImage?.parentElement?.style.width).toBe('16px');
|
|
118
|
+
|
|
119
|
+
act(() => (trigger as HTMLButtonElement).click());
|
|
120
|
+
const option = dom.querySelector('[role="option"]');
|
|
121
|
+
const optionImage = option?.querySelector('img');
|
|
122
|
+
expect(optionImage?.getAttribute('src')).toBe(ICON);
|
|
123
|
+
expect(optionImage?.parentElement?.style.width).toBe('18px');
|
|
124
|
+
// The second option has no icon URL, so only one row draws an image.
|
|
125
|
+
expect(dom.querySelectorAll('[role="option"] img')).toHaveLength(1);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
describe('Usage provider card header', () => {
|
|
130
|
+
test('the card names the provider and carries its mark', () => {
|
|
131
|
+
const dom = mount(<ProviderCard providerName="Local Test" providerSlug="localtest" iconUrl={ICON} credentialSources={['models.yml']}>body</ProviderCard>);
|
|
132
|
+
const header = dom.querySelector('header');
|
|
133
|
+
expect(header?.textContent).toContain('Local Test');
|
|
134
|
+
expect(header?.querySelector('img')?.getAttribute('src')).toBe(ICON);
|
|
135
|
+
expect(header?.querySelector('img')?.parentElement?.style.width).toBe('20px');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test('without a slug the header is the name alone', () => {
|
|
139
|
+
const dom = mount(<ProviderCard providerName="Bare" credentialSources={[]}>body</ProviderCard>);
|
|
140
|
+
expect(dom.querySelector('header img')).toBeNull();
|
|
141
|
+
expect(dom.querySelector('header')?.textContent).toContain('Bare');
|
|
142
|
+
});
|
|
143
|
+
});
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
* geometry correct: one button spanning the whole row (so no child can be the
|
|
17
17
|
* only element under the pointer), the visual line as a non-interactive span
|
|
18
18
|
* inside it, and every row's button wired to that row's turn. The rendered
|
|
19
|
-
* pixel behaviour is covered by the browser check recorded in
|
|
19
|
+
* pixel behaviour is covered by the browser check recorded in the wiki's App
|
|
20
|
+
* shell and layout page.
|
|
20
21
|
*/
|
|
21
22
|
|
|
22
23
|
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
@@ -17,37 +17,41 @@
|
|
|
17
17
|
* `ModeToggles.test.ts` does.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { afterAll,
|
|
20
|
+
import { afterAll, afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
21
21
|
import { Window } from 'happy-dom';
|
|
22
22
|
import { h, render } from 'preact';
|
|
23
23
|
import { GoalBanner, type GoalBannerProps } from '@/client/components/workspace/chat-timeline/chat-input/GoalBanner';
|
|
24
24
|
import type { GoalAction } from '@/client/hooks/chat/timeline/modes';
|
|
25
25
|
import type { GoalRecord } from '@/shared/lib/omp/mode/types';
|
|
26
|
-
|
|
27
|
-
const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'Event'] as const;
|
|
28
|
-
/** The runner's own globals, restored on teardown — deleting them would strip natives (Event/CustomEvent) every later file needs. */const nativeGlobals: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
|
|
26
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
29
27
|
|
|
30
28
|
let container: HTMLElement;
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
/**
|
|
31
|
+
* The SHARED DOM helpers, not a local save-and-restore map.
|
|
32
|
+
*
|
|
33
|
+
* `pristine-globals.ts` states why: Bun imports every file before any test
|
|
34
|
+
* runs, so a local `nativeGlobals` capture records whatever another suite had
|
|
35
|
+
* installed by then, and restoring it hands the next file a dead window. This
|
|
36
|
+
* file also never unmounted its last tree, so a component stayed mounted across
|
|
37
|
+
* `afterAll` — and a Preact flush that landed afterwards threw
|
|
38
|
+
* `ReferenceError: document is not defined` between the NEXT file's tests
|
|
39
|
+
* (measured on the Windows gate, which reports it as an `error`, not a failure).
|
|
40
|
+
*/
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
installDomGlobals(new Window({ url: 'http://localhost' }));
|
|
43
|
+
container = document.createElement('div');
|
|
44
|
+
document.body.appendChild(container);
|
|
41
45
|
});
|
|
42
46
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
else target[key] = nativeGlobals[key];
|
|
48
|
-
}
|
|
47
|
+
afterEach(() => {
|
|
48
|
+
render(null, container);
|
|
49
|
+
container.remove();
|
|
50
|
+
restoreDomGlobals();
|
|
49
51
|
});
|
|
50
52
|
|
|
53
|
+
afterAll(() => restoreDomGlobals());
|
|
54
|
+
|
|
51
55
|
const record: GoalRecord = {
|
|
52
56
|
id: 'g1',
|
|
53
57
|
objective: 'Migrate the importer to streaming\n\n## Success criteria\n- tests pass',
|
|
@@ -15,36 +15,40 @@
|
|
|
15
15
|
* `RightActivityBar.test.ts` does.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { afterAll,
|
|
18
|
+
import { afterAll, afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
19
19
|
import { Window } from 'happy-dom';
|
|
20
20
|
import { h, render } from 'preact';
|
|
21
21
|
import { ModeToggles, type ModeTogglesProps } from '@/client/components/workspace/chat-timeline/chat-input/ModeToggles';
|
|
22
22
|
import type { GoalRecord } from '@/shared/lib/omp/mode/types';
|
|
23
|
-
|
|
24
|
-
const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'Event'] as const;
|
|
25
|
-
/** The runner's own globals, restored on teardown — deleting them would strip natives (Event/CustomEvent) every later file needs. */const nativeGlobals: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
|
|
23
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
26
24
|
|
|
27
25
|
let container: HTMLElement;
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
/**
|
|
28
|
+
* The SHARED DOM helpers, not a local save-and-restore map.
|
|
29
|
+
*
|
|
30
|
+
* `pristine-globals.ts` states why: Bun imports every file before any test
|
|
31
|
+
* runs, so a local `nativeGlobals` capture records whatever another suite had
|
|
32
|
+
* installed by then, and restoring it hands the next file a dead window. This
|
|
33
|
+
* file also never unmounted its last tree, so a component stayed mounted across
|
|
34
|
+
* `afterAll` — and a Preact flush that landed afterwards threw
|
|
35
|
+
* `ReferenceError: document is not defined` between the NEXT file's tests
|
|
36
|
+
* (measured on the Windows gate, which reports it as an `error`, not a failure).
|
|
37
|
+
*/
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
installDomGlobals(new Window({ url: 'http://localhost' }));
|
|
40
|
+
container = document.createElement('div');
|
|
41
|
+
document.body.appendChild(container);
|
|
38
42
|
});
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
else target[key] = nativeGlobals[key];
|
|
45
|
-
}
|
|
44
|
+
afterEach(() => {
|
|
45
|
+
render(null, container);
|
|
46
|
+
container.remove();
|
|
47
|
+
restoreDomGlobals();
|
|
46
48
|
});
|
|
47
49
|
|
|
50
|
+
afterAll(() => restoreDomGlobals());
|
|
51
|
+
|
|
48
52
|
function paint(overrides: Partial<ModeTogglesProps> = {}): HTMLElement {
|
|
49
53
|
const props: ModeTogglesProps = {
|
|
50
54
|
plan: false,
|
|
@@ -19,35 +19,37 @@
|
|
|
19
19
|
* keep behaving as it did.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import { afterAll,
|
|
22
|
+
import { afterAll, afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
23
23
|
import { Window } from 'happy-dom';
|
|
24
24
|
import { h, render } from 'preact';
|
|
25
25
|
import { act } from 'preact/test-utils';
|
|
26
26
|
import { ComposerToolbar } from '@/client/components/workspace/chat-timeline/chat-input/Toolbar';
|
|
27
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
27
28
|
|
|
28
29
|
let container: HTMLElement;
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The SHARED DOM helpers, and an unmount between cases.
|
|
33
|
+
*
|
|
34
|
+
* A local `nativeGlobals` map is unsafe here for the reason `pristine-globals.ts`
|
|
35
|
+
* states: Bun imports every file before any test runs, so the capture can hold
|
|
36
|
+
* another suite's window. And a tree left mounted across `afterAll` lets a
|
|
37
|
+
* deferred Preact flush land after the globals are gone — measured on the
|
|
38
|
+
* Windows gate as `ReferenceError: document is not defined` between tests in the
|
|
39
|
+
* file that ran next.
|
|
40
|
+
*/
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
installDomGlobals(new Window({ url: 'http://localhost' }));
|
|
41
43
|
});
|
|
42
44
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
else target[key] = nativeGlobals[key];
|
|
48
|
-
}
|
|
45
|
+
afterEach(() => {
|
|
46
|
+
render(null, container);
|
|
47
|
+
container?.remove();
|
|
48
|
+
restoreDomGlobals();
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
+
afterAll(() => restoreDomGlobals());
|
|
52
|
+
|
|
51
53
|
interface MountOptions {
|
|
52
54
|
isGenerating: boolean;
|
|
53
55
|
chatRunning?: boolean;
|
|
@@ -23,6 +23,7 @@ import { Window } from 'happy-dom';
|
|
|
23
23
|
import { h, render } from 'preact';
|
|
24
24
|
import { act } from 'preact/test-utils';
|
|
25
25
|
import { ChatInput } from '@/client/components/workspace/chat-timeline/chat-input';
|
|
26
|
+
import { delay } from '@/client/hooks/chat/composer/file-reads';
|
|
26
27
|
import { restoreRealtime, silenceRealtime } from '@/test-support/silent-socket';
|
|
27
28
|
|
|
28
29
|
const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'HTMLInputElement', 'HTMLTextAreaElement', 'Event', 'MouseEvent', 'KeyboardEvent', 'FocusEvent'] as const;
|
|
@@ -54,15 +55,27 @@ beforeEach(() => {
|
|
|
54
55
|
silenceRealtime();
|
|
55
56
|
});
|
|
56
57
|
|
|
57
|
-
afterEach(() => {
|
|
58
|
-
|
|
58
|
+
afterEach(async () => {
|
|
59
|
+
// UNMOUNT, then drain while this window still exists — the same teardown
|
|
60
|
+
// `stretch-send.test.tsx` states for the same component. `container.remove()`
|
|
61
|
+
// alone left the whole `ChatInput` mounted: its model picker keeps a realtime
|
|
62
|
+
// subscription and a reconnect timer, and Preact's effect flush is deferred,
|
|
63
|
+
// so a render landed after `afterAll` deleted the globals and threw
|
|
64
|
+
// `ReferenceError: document is not defined` inside whichever file bun ran
|
|
65
|
+
// next. Measured on the Windows gate: `8648 pass, 0 fail, 1 error`, exit 1.
|
|
66
|
+
// The drain is a BARE timer — wrapping it in `act` queues another flush.
|
|
67
|
+
const host = container;
|
|
68
|
+
if (host) {
|
|
69
|
+
await act(async () => { render(null, host); });
|
|
70
|
+
host.remove();
|
|
71
|
+
}
|
|
59
72
|
container = null;
|
|
60
73
|
// The composer's model picker subscribes to the realtime topic, and its
|
|
61
|
-
// reconnect timer outlives this file's DOM
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
// the silence does not follow this file into the next one.
|
|
74
|
+
// reconnect timer outlives this file's DOM. `restoreRealtime` resets the
|
|
75
|
+
// client AND puts the real constructor back, so the silence does not follow
|
|
76
|
+
// this file into the next one.
|
|
65
77
|
restoreRealtime();
|
|
78
|
+
await delay(50);
|
|
66
79
|
});
|
|
67
80
|
|
|
68
81
|
interface MountOptions {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { useCallback, useMemo
|
|
1
|
+
import { useCallback, useMemo } from 'preact/hooks';
|
|
2
2
|
import { useSearchParams } from '@/client/lib/router/search-params';
|
|
3
3
|
import { AskFramesContext, splitAskFrames, type AskFramesHandle } from '@/client/hooks/chat/timeline/ask-frames';
|
|
4
4
|
import type { ExtensionUiDialogRequest } from '@/shared/types/omp/agent';
|
|
5
|
-
import type { Attachment } from '@/shared/types';
|
|
6
5
|
import type { UserTurnRef } from '@/shared/types/chat';
|
|
7
6
|
import type { ExtensionDialogResponse } from '@/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/Lazy';
|
|
8
7
|
import { PendingChatView } from '@/client/components/workspace/chat-timeline/PendingChatView';
|
|
@@ -21,6 +20,7 @@ import { useToasts } from '@/client/hooks/ui/toasts';
|
|
|
21
20
|
import { ChatOverlays } from '@/client/components/workspace/chat-timeline/ChatOverlays';
|
|
22
21
|
import { ToastStack } from '@/client/components/common/ToastStack';
|
|
23
22
|
import { composerRootFor } from '@/shared/lib/workspace/active-project';
|
|
23
|
+
import { useNewChatOpen } from '@/client/hooks/chat/timeline/new-chat-open';
|
|
24
24
|
import { useSidebarData } from '@/client/hooks/chat/omp/session-list';
|
|
25
25
|
import { useHeldWait } from '@/client/hooks/chat/waiting/held';
|
|
26
26
|
|
|
@@ -112,10 +112,7 @@ export function ChatTimeline({ className = '', appSettings = {}, onSessionTitle,
|
|
|
112
112
|
[framesByTool, orphanAsks, respondToFrame],
|
|
113
113
|
);
|
|
114
114
|
|
|
115
|
-
const
|
|
116
|
-
// Attachments of the row the modal was opened from: an image or inlined text
|
|
117
|
-
// file is half of the turn, and seeding the text alone dropped it.
|
|
118
|
-
const [newChatInitialAttachments, setNewChatInitialAttachments] = useState<Attachment[]>([]);
|
|
115
|
+
const newChat = useNewChatOpen({ folders, sessionId, selectedFolderId });
|
|
119
116
|
const { pendingUndo, undoing, error: undoError, requestUndo: handleRequestUndo, closeUndoConfirm, confirmUndo } = useUndoConfirmation(handleUndo);
|
|
120
117
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
121
118
|
|
|
@@ -149,10 +146,7 @@ export function ChatTimeline({ className = '', appSettings = {}, onSessionTitle,
|
|
|
149
146
|
void jumpToUserTurn(turn.id, turn.index);
|
|
150
147
|
}, [jumpToUserTurn]);
|
|
151
148
|
|
|
152
|
-
const handleNewChat =
|
|
153
|
-
setNewChatInitialContent(content);
|
|
154
|
-
setNewChatInitialAttachments(attachments ?? []);
|
|
155
|
-
}, []);
|
|
149
|
+
const handleNewChat = newChat.open;
|
|
156
150
|
|
|
157
151
|
const modelNames = useModelNames();
|
|
158
152
|
const providerNames = useProviderNames();
|
|
@@ -322,12 +316,9 @@ export function ChatTimeline({ className = '', appSettings = {}, onSessionTitle,
|
|
|
322
316
|
onCloseUndo={closeUndoConfirm}
|
|
323
317
|
onConfirmUndo={confirmUndo}
|
|
324
318
|
isOmpSession={Boolean(sessionId) && !sessionId.startsWith('new-') && Number.isNaN(Number(sessionId))}
|
|
325
|
-
newChatInitialContent={
|
|
326
|
-
newChatInitialAttachments={
|
|
327
|
-
onCloseNewChat={
|
|
328
|
-
setNewChatInitialContent(null);
|
|
329
|
-
setNewChatInitialAttachments([]);
|
|
330
|
-
}}
|
|
319
|
+
newChatInitialContent={newChat.content}
|
|
320
|
+
newChatInitialAttachments={newChat.attachments}
|
|
321
|
+
onCloseNewChat={newChat.close}
|
|
331
322
|
onSendNewChat={submitNewChat}
|
|
332
323
|
appSettings={appSettings}
|
|
333
324
|
accessMode={accessMode}
|
package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.missing.test.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `wait` card for a call whose result is MISSING.
|
|
8
|
+
*
|
|
9
|
+
* Two shapes reach this suite, and both used to render as a generic tool:
|
|
10
|
+
*
|
|
11
|
+
* - a page reloaded while the call blocks — the transcript holds the
|
|
12
|
+
* `toolCall` block and the `tool_execution_start` entry and no
|
|
13
|
+
* `toolResult`, so there is no `details` to read and the panel bailed out;
|
|
14
|
+
* - omp's own "Nothing to wait for" answer, which carries `details: {}`.
|
|
15
|
+
*
|
|
16
|
+
* Neither may claim a job list: an absent snapshot is UNKNOWN, not empty. The
|
|
17
|
+
* clock comes from the start entry, which is the only one such a call has.
|
|
18
|
+
*
|
|
19
|
+
* Rendered with `h()` against happy-dom through the shared harness
|
|
20
|
+
* (`wait-test-util.ts`); the live/settled half lives in `Wait.test.ts`.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
|
|
24
|
+
import { installWaitDom, mountWait as mount, restoreWaitDom, waitBar as bar } from '@/client/components/workspace/chat-timeline/tool-renderers/panels/wait-test-util';
|
|
25
|
+
import type { ToolCallData } from '@/shared/types';
|
|
26
|
+
|
|
27
|
+
beforeAll(installWaitDom);
|
|
28
|
+
afterAll(restoreWaitDom);
|
|
29
|
+
|
|
30
|
+
describe('Wait panel — a reloaded mid-call wait', () => {
|
|
31
|
+
// The transcript of a page reloaded while a wait blocks holds the `toolCall`
|
|
32
|
+
// block and NO `toolResult`, so there is no `details` at all. The panel used
|
|
33
|
+
// to require `details.op`, return nothing, and leave the card looking like a
|
|
34
|
+
// generic tool: a title, an empty body. The tool's own name is the evidence
|
|
35
|
+
// that this is a wait, and the start entry is its clock.
|
|
36
|
+
const PENDING: Partial<ToolCallData> & Pick<ToolCallData, 'type'> = {
|
|
37
|
+
type: 'wait',
|
|
38
|
+
name: 'wait',
|
|
39
|
+
status: 'running',
|
|
40
|
+
startedAt: Date.now() - 5_000,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
test('still draws the clock and the bar, not a generic Output block', async () => {
|
|
44
|
+
const el = await mount(PENDING);
|
|
45
|
+
expect(el.textContent ?? '').toContain('0:05');
|
|
46
|
+
expect(el.textContent ?? '').toContain('waiting');
|
|
47
|
+
expect(bar(el)).not.toBeNull();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('claims no job list it does not have', async () => {
|
|
51
|
+
const el = await mount(PENDING);
|
|
52
|
+
const text = el.textContent ?? '';
|
|
53
|
+
// No "Jobs" section, and no "no jobs" claim either: the list is UNKNOWN.
|
|
54
|
+
expect(text).not.toContain('Jobs');
|
|
55
|
+
expect(text).not.toContain('no jobs');
|
|
56
|
+
expect(text).toContain('running');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('an indeterminate bar, because nothing reported a position', async () => {
|
|
60
|
+
const el = await mount(PENDING);
|
|
61
|
+
expect(bar(el)?.getAttribute('aria-valuenow')).toBeNull();
|
|
62
|
+
expect(bar(el)?.querySelector('.wait-bar-sweep')).not.toBeNull();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("omp's own `details: {}` answer is not drawn as a jobless wait", async () => {
|
|
66
|
+
// "Nothing to wait for: no background job or service you started is
|
|
67
|
+
// running." carries `details: {}` — a real result with no snapshot.
|
|
68
|
+
const el = await mount({
|
|
69
|
+
type: 'wait',
|
|
70
|
+
name: 'wait',
|
|
71
|
+
status: 'error',
|
|
72
|
+
output: 'Nothing to wait for: no background job or service you started is running.',
|
|
73
|
+
details: {},
|
|
74
|
+
});
|
|
75
|
+
const text = el.textContent ?? '';
|
|
76
|
+
expect(text).toContain('Nothing to wait for');
|
|
77
|
+
expect(text).not.toContain('no jobs');
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe('Wait panel — a result it cannot read', () => {
|
|
82
|
+
test('still keeps the prose omp wrote beside the panel', async () => {
|
|
83
|
+
// The panel is chosen by the TOOL, not by the result: a `wait` whose result
|
|
84
|
+
// carries no snapshot is drawn as a wait and its text is kept, because the
|
|
85
|
+
// sentence is the only record of what happened.
|
|
86
|
+
const el = await mount({ type: 'wait', name: 'wait', status: 'success', output: 'Nothing to wait for.', details: {} });
|
|
87
|
+
expect(el.textContent ?? '').toContain('Nothing to wait for.');
|
|
88
|
+
// No clock is invented either: with no start entry and no measured span the
|
|
89
|
+
// stopwatch reads `—`, which is the honest answer.
|
|
90
|
+
expect(el.textContent ?? '').toContain('—');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('a call whose result was never written says so', async () => {
|
|
94
|
+
// The run died mid-call: omp wrote the start entry and nothing else, so
|
|
95
|
+
// there is no snapshot AND no prose. An empty body read as a panel that
|
|
96
|
+
// failed to draw.
|
|
97
|
+
const el = await mount({ type: 'wait', name: 'wait', status: 'success', startedAt: Date.now() - 4_000 });
|
|
98
|
+
expect(el.textContent ?? '').toContain('No result was recorded');
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -20,48 +20,12 @@
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
import { afterAll, beforeAll, describe, expect, setSystemTime, test } from 'bun:test';
|
|
23
|
-
import { Window } from 'happy-dom';
|
|
24
|
-
import { h, render } from 'preact';
|
|
25
|
-
import { act } from 'preact/test-utils';
|
|
26
|
-
import { Wait } from '@/client/components/workspace/chat-timeline/tool-renderers/panels/Wait';
|
|
27
23
|
import { WAIT_MAX_MS } from '@/shared/lib/omp/session/wait';
|
|
24
|
+
import { installWaitDom, mountWait as mount, restoreWaitDom, waitBar as bar } from '@/client/components/workspace/chat-timeline/tool-renderers/panels/wait-test-util';
|
|
28
25
|
import type { ToolCallData } from '@/shared/types';
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
let container: HTMLElement;
|
|
34
|
-
|
|
35
|
-
beforeAll(() => {
|
|
36
|
-
const win = new Window({ url: 'http://localhost' });
|
|
37
|
-
const target = globalThis as unknown as Record<string, unknown>;
|
|
38
|
-
for (const key of DOM_GLOBALS) {
|
|
39
|
-
nativeGlobals[key] = target[key];
|
|
40
|
-
target[key] = (win as unknown as Record<string, unknown>)[key];
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
afterAll(() => {
|
|
45
|
-
const target = globalThis as unknown as Record<string, unknown>;
|
|
46
|
-
for (const key of DOM_GLOBALS) {
|
|
47
|
-
if (nativeGlobals[key] === undefined) delete target[key];
|
|
48
|
-
else target[key] = nativeGlobals[key];
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
async function mount(partial: Partial<ToolCallData> & Pick<ToolCallData, 'type'>) {
|
|
53
|
-
const tool = { id: 'c1', name: partial.type, title: partial.type, ...partial } as ToolCallData;
|
|
54
|
-
container = document.createElement('div');
|
|
55
|
-
document.body.appendChild(container);
|
|
56
|
-
await act(async () => {
|
|
57
|
-
render(h(Wait, { tool }), container);
|
|
58
|
-
});
|
|
59
|
-
return container;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function bar(el: HTMLElement): HTMLElement | null {
|
|
63
|
-
return el.querySelector('[role="progressbar"]');
|
|
64
|
-
}
|
|
27
|
+
beforeAll(installWaitDom);
|
|
28
|
+
afterAll(restoreWaitDom);
|
|
65
29
|
|
|
66
30
|
/** A blocking wait: one bash job with no percentage, one task with one. */
|
|
67
31
|
const BLOCKING: Partial<ToolCallData> & Pick<ToolCallData, 'type'> = {
|
|
@@ -317,11 +281,3 @@ describe('Wait panel — interrupted and messaged', () => {
|
|
|
317
281
|
expect(text).toContain('sleeper reporting in');
|
|
318
282
|
});
|
|
319
283
|
});
|
|
320
|
-
|
|
321
|
-
describe('Wait panel — not a wait', () => {
|
|
322
|
-
test('falls back to the plain output for a result it cannot read', async () => {
|
|
323
|
-
const el = await mount({ type: 'wait', name: 'wait', status: 'success', output: 'Nothing to wait for.', details: {} });
|
|
324
|
-
expect(el.textContent ?? '').toContain('Nothing to wait for.');
|
|
325
|
-
expect(bar(el)).toBeNull();
|
|
326
|
-
});
|
|
327
|
-
});
|
|
@@ -251,7 +251,7 @@ export function Wait({ tool }: { tool: ToolCallData }) {
|
|
|
251
251
|
<ToolPanelHeader
|
|
252
252
|
icon={<Hourglass size={12} />}
|
|
253
253
|
label={view.op === 'wait' ? 'Waiting' : view.op}
|
|
254
|
-
badge={running ? 'running' : hitLimit ? 'limit reached' : interrupted ? 'interrupted' : 'settled'}
|
|
254
|
+
badge={running ? 'running' : hitLimit ? 'limit reached' : interrupted ? 'interrupted' : tool.status === 'error' ? 'failed' : 'settled'}
|
|
255
255
|
copyText={output || undefined}
|
|
256
256
|
copyLabel="Copy output"
|
|
257
257
|
/>
|
|
@@ -325,6 +325,13 @@ export function Wait({ tool }: { tool: ToolCallData }) {
|
|
|
325
325
|
</div>
|
|
326
326
|
)}
|
|
327
327
|
|
|
328
|
+
{/* A call whose result was never written — a run that died mid-call, so
|
|
329
|
+
not even omp's prose exists. Saying so is the honest answer; an empty
|
|
330
|
+
body would read as a panel that failed to draw. */}
|
|
331
|
+
{!running && !view.reported && !output && (
|
|
332
|
+
<p className="font-mono text-[10.5px] text-ink/45">No result was recorded.</p>
|
|
333
|
+
)}
|
|
334
|
+
|
|
328
335
|
{/* The prose omp writes: a completion summary, a refusal ("Nothing to
|
|
329
336
|
wait for…"), or the limit notice. It is the only place those
|
|
330
337
|
sentences exist, so it is never dropped. */}
|