@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,325 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The provider list's column grid.
|
|
8
|
+
*
|
|
9
|
+
* Three things in this list read as one table and were not one: the mark, the
|
|
10
|
+
* status dot and the model count. The mark is an `<svg>` for a brand but a
|
|
11
|
+
* text-width PILL for the initials fallback, so every row's name began at a
|
|
12
|
+
* different x; the dot carried `ml-auto` and so followed the name's width; and
|
|
13
|
+
* the delete button existed only on some rows, shifting those rows' count
|
|
14
|
+
* column by its own width. Measured in a browser before the fix: 97 rows, three
|
|
15
|
+
* different dot positions.
|
|
16
|
+
*
|
|
17
|
+
* The layout is therefore: a fixed-size PLATE, a name that takes the slack
|
|
18
|
+
* (`flex-1`), a fixed dot slot, a fixed right-aligned count, and a delete slot
|
|
19
|
+
* reserved on every row. Those are geometry facts, so they are pinned here
|
|
20
|
+
* rather than left to a screenshot.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
24
|
+
import { Window } from 'happy-dom';
|
|
25
|
+
import { h, render } from 'preact';
|
|
26
|
+
import { act } from 'preact/test-utils';
|
|
27
|
+
import { ProviderSidebarList } from '@/client/components/settings/categories/provider-settings/SidebarList';
|
|
28
|
+
import { ProviderHeader } from '@/client/components/settings/categories/provider-settings/Header';
|
|
29
|
+
import type { ProviderItem } from '@/shared/types';
|
|
30
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
31
|
+
|
|
32
|
+
let container: HTMLElement;
|
|
33
|
+
|
|
34
|
+
function provider(overrides: Partial<ProviderItem> & { slug: string }): ProviderItem {
|
|
35
|
+
return {
|
|
36
|
+
id: `id-${overrides.slug}`,
|
|
37
|
+
name: overrides.slug,
|
|
38
|
+
icon: overrides.slug,
|
|
39
|
+
status: 'connected',
|
|
40
|
+
configuredIn: 'models.yml',
|
|
41
|
+
models: [],
|
|
42
|
+
...overrides,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
beforeEach(() => {
|
|
47
|
+
installDomGlobals(new Window());
|
|
48
|
+
container = document.createElement('div');
|
|
49
|
+
document.body.appendChild(container);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
afterEach(() => {
|
|
53
|
+
render(null, container);
|
|
54
|
+
container.remove();
|
|
55
|
+
restoreDomGlobals();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
interface MountOptions {
|
|
59
|
+
isRefreshing?: boolean;
|
|
60
|
+
isLoading?: boolean;
|
|
61
|
+
onRefresh?: () => void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function mountList(providers: ProviderItem[], options: MountOptions = {}): void {
|
|
65
|
+
act(() => {
|
|
66
|
+
render(
|
|
67
|
+
h(ProviderSidebarList, {
|
|
68
|
+
providers,
|
|
69
|
+
selectedProviderId: providers[0]?.id ?? '',
|
|
70
|
+
onSelectProvider: () => {},
|
|
71
|
+
onOpenAddModal: () => {},
|
|
72
|
+
onRefresh: options.onRefresh ?? (() => {}),
|
|
73
|
+
isRefreshing: options.isRefreshing ?? false,
|
|
74
|
+
isLoading: options.isLoading ?? false,
|
|
75
|
+
}),
|
|
76
|
+
container,
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Every provider row's select button, in list order. */
|
|
82
|
+
function rows(): HTMLElement[] {
|
|
83
|
+
return [...container.querySelectorAll('button[title]')].filter(
|
|
84
|
+
(button) => button.querySelector('span[aria-hidden]') !== null,
|
|
85
|
+
) as HTMLElement[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
describe('provider list columns', () => {
|
|
89
|
+
test('a row is a plate, a name and a count — and nothing else', () => {
|
|
90
|
+
mountList([
|
|
91
|
+
provider({ slug: 'a', name: 'A' }),
|
|
92
|
+
provider({ slug: 'b', name: 'A much longer provider name than the first' }),
|
|
93
|
+
]);
|
|
94
|
+
|
|
95
|
+
for (const row of rows()) {
|
|
96
|
+
const children = [...row.children] as HTMLElement[];
|
|
97
|
+
// Exactly three: the plate, the name, the count. The status dot and the
|
|
98
|
+
// per-row delete button were removed — the section already states the
|
|
99
|
+
// provider's state, and deleting belongs to the detail pane.
|
|
100
|
+
expect(children).toHaveLength(3);
|
|
101
|
+
const [plate, name, count] = children;
|
|
102
|
+
expect(plate.style.width).toBe('22px');
|
|
103
|
+
expect(plate.style.height).toBe('22px');
|
|
104
|
+
// The name absorbs the difference between short and long names.
|
|
105
|
+
expect(name.className).toContain('flex-1');
|
|
106
|
+
expect(name.className).toContain('truncate');
|
|
107
|
+
expect(count.className).toContain('w-8');
|
|
108
|
+
expect(count.className).toContain('text-right');
|
|
109
|
+
expect(count.className).toContain('tabular-nums');
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('no row carries a status dot or a delete control', () => {
|
|
114
|
+
mountList([
|
|
115
|
+
provider({ slug: 'native', inModelsYml: true }),
|
|
116
|
+
provider({ slug: 'discovered' }),
|
|
117
|
+
provider({ slug: 'off', disabled: true }),
|
|
118
|
+
]);
|
|
119
|
+
|
|
120
|
+
// A coloured circle repeated a state the section header already names, and a
|
|
121
|
+
// trash icon on every row made a dense list a field of mostly-hidden icons.
|
|
122
|
+
expect(container.querySelectorAll('span.rounded-full')).toHaveLength(0);
|
|
123
|
+
expect(container.querySelectorAll('button[aria-label^="Delete "]')).toHaveLength(0);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test('the mark sits on a rounded plate', () => {
|
|
127
|
+
mountList([provider({ slug: 'branded' })]);
|
|
128
|
+
|
|
129
|
+
const plate = rows()[0].children[0] as HTMLElement;
|
|
130
|
+
expect(plate.className).toContain('border');
|
|
131
|
+
expect(plate.className).toContain('bg-ink/5');
|
|
132
|
+
expect(plate.style.borderRadius).not.toBe('');
|
|
133
|
+
expect(plate.style.width).toBe(plate.style.height);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test('the count is a plain number, so the digits can be compared down the column', () => {
|
|
137
|
+
mountList([
|
|
138
|
+
provider({ slug: 'a', models: Array.from({ length: 109 }, (_, index) => ({
|
|
139
|
+
id: `m${index}`, name: `M${index}`, contextWindow: '', hasTools: true, hasVision: false, isVisible: true,
|
|
140
|
+
})) }),
|
|
141
|
+
provider({ slug: 'b', models: [] }),
|
|
142
|
+
]);
|
|
143
|
+
|
|
144
|
+
const counts = rows().map((row) => row.children[2].textContent);
|
|
145
|
+
expect(counts).toEqual(['109', '0']);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test('the row still names its state in the title, now that the dot is gone', () => {
|
|
149
|
+
mountList([provider({ slug: 'a', status: 'disconnected', oauth: true })]);
|
|
150
|
+
|
|
151
|
+
expect(rows()[0].getAttribute('title')).toContain('sign in with OAuth');
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
describe('provider header', () => {
|
|
156
|
+
test('the name and the slug share one left edge', () => {
|
|
157
|
+
// They used to be two stacked blocks with the slug indented by a hard-coded
|
|
158
|
+
// `pl-8`, which only matched while the mark happened to be 32px wide.
|
|
159
|
+
act(() => {
|
|
160
|
+
render(h(ProviderHeader, { provider: provider({ slug: 'gateway', name: 'Gateway' }) }), container);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
const plate = container.querySelector('span[aria-hidden]') as HTMLElement;
|
|
164
|
+
const column = plate.nextElementSibling as HTMLElement;
|
|
165
|
+
const [name, slug] = [...column.children] as HTMLElement[];
|
|
166
|
+
expect(plate).not.toBeNull();
|
|
167
|
+
// One column holds both lines: their left edges are the same element's.
|
|
168
|
+
expect(name.tagName).toBe('H2');
|
|
169
|
+
expect(slug.tagName).toBe('P');
|
|
170
|
+
expect(slug.className).not.toContain('pl-');
|
|
171
|
+
expect(column.className).toContain('min-w-0');
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
describe('icon containment', () => {
|
|
176
|
+
test('the mark is bounded: a fixed box, never the pill’s text width', () => {
|
|
177
|
+
// The initials fallback is a PILL by design (width follows the text) — right
|
|
178
|
+
// beside a name, wrong inside a plate: `ab.` at the unbounded 1.2x font came
|
|
179
|
+
// out ~25px wide in a 20px content box and spilled past the rounded edge.
|
|
180
|
+
mountList([provider({ slug: 'no-brand-mark-anywhere' })]);
|
|
181
|
+
|
|
182
|
+
const plate = rows()[0].children[0] as HTMLElement;
|
|
183
|
+
const mark = plate.firstElementChild as HTMLElement;
|
|
184
|
+
expect(mark.tagName).toBe('SPAN');
|
|
185
|
+
expect(mark.style.width).toBe('16px');
|
|
186
|
+
expect(mark.style.height).toBe('16px');
|
|
187
|
+
expect(mark.className).toContain('overflow-hidden');
|
|
188
|
+
// The plate reserves a hairline plus a gap on each side of that box.
|
|
189
|
+
expect(plate.style.width).toBe('22px');
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test('a three-character badge gets a smaller font than a two-character one', () => {
|
|
193
|
+
mountList([provider({ slug: 'toktok-id', name: 'Toktok ID' }), provider({ slug: 'tooker', name: 'Tooker' })]);
|
|
194
|
+
|
|
195
|
+
const fonts = rows().map((row) => (row.children[0].firstElementChild as HTMLElement).style.fontSize);
|
|
196
|
+
expect(fonts[0]).toBe('10px'); // `ti.`
|
|
197
|
+
expect(fonts[1]).toBe('13px'); // `t.`
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test('a brand mark is a block svg at the same box size', () => {
|
|
201
|
+
// `display: block` is the containment contract for the SVG half: an inline
|
|
202
|
+
// svg sits on the text baseline and adds descender space, so it can "fit"
|
|
203
|
+
// its attributes and still push the plate's edge.
|
|
204
|
+
mountList([provider({ slug: 'deepseek', name: 'DeepSeek' })]);
|
|
205
|
+
|
|
206
|
+
const mark = rows()[0].children[0].firstElementChild as HTMLElement;
|
|
207
|
+
expect(mark.tagName.toLowerCase()).toBe('svg');
|
|
208
|
+
expect(mark.getAttribute('width')).toBe('16');
|
|
209
|
+
expect(mark.getAttribute('height')).toBe('16');
|
|
210
|
+
expect(mark.style.display).toBe('block');
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
test('the header plate bounds its mark too', () => {
|
|
214
|
+
act(() => {
|
|
215
|
+
render(h(ProviderHeader, { provider: provider({ slug: 'gateway', name: 'Gateway' }) }), container);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
const plate = container.querySelector('span[aria-hidden]') as HTMLElement;
|
|
219
|
+
const mark = plate.firstElementChild as HTMLElement;
|
|
220
|
+
expect(plate.style.width).toBe('30px');
|
|
221
|
+
expect(mark.style.width === '22px' || mark.getAttribute('width') === '22').toBe(true);
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
describe('provider icon plate with a fetched web icon', () => {
|
|
226
|
+
const withIcon = provider({
|
|
227
|
+
slug: 'localtest',
|
|
228
|
+
iconUrl: '/api/provider-icon?slug=localtest&v=1700000000000',
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
test('an iconUrl is drawn as the site’s own picture, not a recoloured mark', () => {
|
|
232
|
+
// The whole point of fetching it: a brand logo in `currentColor` is a
|
|
233
|
+
// silhouette. The img is the one thing in this list allowed chroma.
|
|
234
|
+
mountList([withIcon]);
|
|
235
|
+
|
|
236
|
+
const plate = rows()[0].children[0] as HTMLElement;
|
|
237
|
+
const image = plate.querySelector('img') as HTMLImageElement;
|
|
238
|
+
expect(image).not.toBeNull();
|
|
239
|
+
expect(image.getAttribute('src')).toBe('/api/provider-icon?slug=localtest&v=1700000000000');
|
|
240
|
+
expect(image.className).toContain('object-contain');
|
|
241
|
+
// No filter/blend that would tint the logo.
|
|
242
|
+
expect(image.className).not.toContain('grayscale');
|
|
243
|
+
// The mark is not drawn beside it.
|
|
244
|
+
expect(plate.querySelector('svg[fill="currentColor"]')).toBeNull();
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
test('a provider without one keeps the bounded mark', () => {
|
|
248
|
+
mountList([provider({ slug: 'plain' })]);
|
|
249
|
+
const plate = rows()[0].children[0] as HTMLElement;
|
|
250
|
+
expect(plate.querySelector('img')).toBeNull();
|
|
251
|
+
expect(plate.firstElementChild?.tagName).toBe('SPAN');
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
test('the header shows the web icon and offers a refetch control', () => {
|
|
255
|
+
let pressed = 0;
|
|
256
|
+
act(() => {
|
|
257
|
+
render(
|
|
258
|
+
h(ProviderHeader, { provider: withIcon, onRefreshIcon: () => { pressed += 1; } }),
|
|
259
|
+
container,
|
|
260
|
+
);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
const plate = container.querySelector('span[aria-hidden]') as HTMLElement;
|
|
264
|
+
expect(plate.querySelector('img')?.getAttribute('src')).toContain('/api/provider-icon');
|
|
265
|
+
const refresh = container.querySelector('button[aria-label="Refresh provider icon"]') as HTMLButtonElement;
|
|
266
|
+
expect(refresh).not.toBeNull();
|
|
267
|
+
act(() => refresh.click());
|
|
268
|
+
expect(pressed).toBe(1);
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
describe('provider list refresh and loading', () => {
|
|
273
|
+
test('the refresh control sits beside add, and pressing it re-reads the list', () => {
|
|
274
|
+
let pressed = 0;
|
|
275
|
+
mountList([provider({ slug: 'a' })], { onRefresh: () => { pressed += 1; } });
|
|
276
|
+
|
|
277
|
+
const refresh = container.querySelector('button[aria-label="Refresh the provider list"]') as HTMLButtonElement;
|
|
278
|
+
const add = container.querySelector('button[aria-label="Add provider"]') as HTMLButtonElement;
|
|
279
|
+
expect(refresh).not.toBeNull();
|
|
280
|
+
expect(add).not.toBeNull();
|
|
281
|
+
// Same cluster, refresh first: the two controls act on the LIST, and the
|
|
282
|
+
// panel header has one row for them.
|
|
283
|
+
expect(refresh.parentElement).toBe(add.parentElement);
|
|
284
|
+
|
|
285
|
+
act(() => refresh.click());
|
|
286
|
+
expect(pressed).toBe(1);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
test('the button spins and refuses a second press while the read is in flight', () => {
|
|
290
|
+
mountList([provider({ slug: 'a' })], { isRefreshing: true });
|
|
291
|
+
|
|
292
|
+
const refresh = container.querySelector('button[aria-label="Refresh the provider list"]') as HTMLButtonElement;
|
|
293
|
+
expect(refresh.disabled).toBe(true);
|
|
294
|
+
expect(refresh.querySelector('svg')?.getAttribute('class')).toContain('animate-spin');
|
|
295
|
+
// The rows stay on screen: a refresh must not blank a list being read.
|
|
296
|
+
expect(rows().length).toBe(1);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
test('the first read draws a spinner instead of an empty list', () => {
|
|
300
|
+
mountList([], { isLoading: true });
|
|
301
|
+
|
|
302
|
+
const status = container.querySelector('[role="status"]');
|
|
303
|
+
expect(status).not.toBeNull();
|
|
304
|
+
expect(status?.textContent).toContain('Reading providers');
|
|
305
|
+
expect(status?.querySelector('svg')?.getAttribute('class')).toContain('animate-spin');
|
|
306
|
+
// "0 providers" over a spinner reads as a result, not as a wait.
|
|
307
|
+
expect(container.textContent).toContain('Loading…');
|
|
308
|
+
expect(container.textContent).not.toContain('0 providers');
|
|
309
|
+
expect(rows().length).toBe(0);
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
test('an empty list that finished loading says so, with no spinner', () => {
|
|
313
|
+
mountList([], { isLoading: false });
|
|
314
|
+
|
|
315
|
+
expect(container.querySelector('[role="status"]')).toBeNull();
|
|
316
|
+
expect(container.textContent).toContain('No providers detected yet');
|
|
317
|
+
expect(container.textContent).toContain('0 providers');
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
test('the refresh control is disabled while the first read runs', () => {
|
|
321
|
+
mountList([], { isLoading: true });
|
|
322
|
+
const refresh = container.querySelector('button[aria-label="Refresh the provider list"]') as HTMLButtonElement;
|
|
323
|
+
expect(refresh.disabled).toBe(true);
|
|
324
|
+
});
|
|
325
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What the two model dialogs TELL the user.
|
|
8
|
+
*
|
|
9
|
+
* Both shipped a claim the panel cannot make: the capabilities dialog hardcoded
|
|
10
|
+
* "Structured Output" and "Streaming" as supported for every model on earth,
|
|
11
|
+
* and the Add Model dialog could only register a chat model — so an embedding
|
|
12
|
+
* or image model was written as `kind: chat` and appeared in the chat picker.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
16
|
+
import { Window } from 'happy-dom';
|
|
17
|
+
import { h, render } from 'preact';
|
|
18
|
+
import { act } from 'preact/test-utils';
|
|
19
|
+
import { ModelCapabilitiesModal } from '@/client/components/settings/categories/provider-settings/ModelCapabilitiesModal';
|
|
20
|
+
import { AddModelModal } from '@/client/components/settings/categories/provider-settings/AddModelModal';
|
|
21
|
+
import type { ProviderItem, ProviderModel } from '@/shared/types';
|
|
22
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
23
|
+
|
|
24
|
+
let container: HTMLElement;
|
|
25
|
+
|
|
26
|
+
const provider: ProviderItem = {
|
|
27
|
+
id: 'omp-native-gateway',
|
|
28
|
+
name: 'gateway',
|
|
29
|
+
slug: 'gateway',
|
|
30
|
+
icon: 'gateway',
|
|
31
|
+
status: 'connected',
|
|
32
|
+
configuredIn: 'models.yml',
|
|
33
|
+
inModelsYml: true,
|
|
34
|
+
models: [],
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
function model(overrides: Partial<ProviderModel> & { id: string }): ProviderModel {
|
|
38
|
+
return {
|
|
39
|
+
name: overrides.id,
|
|
40
|
+
contextWindow: '128K ctx',
|
|
41
|
+
hasTools: true,
|
|
42
|
+
hasVision: false,
|
|
43
|
+
isVisible: true,
|
|
44
|
+
...overrides,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
beforeEach(() => {
|
|
49
|
+
installDomGlobals(new Window());
|
|
50
|
+
container = document.createElement('div');
|
|
51
|
+
document.body.appendChild(container);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
afterEach(() => {
|
|
55
|
+
render(null, container);
|
|
56
|
+
container.remove();
|
|
57
|
+
restoreDomGlobals();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
function text(): string {
|
|
61
|
+
return container.textContent ?? '';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
describe('ModelCapabilitiesModal', () => {
|
|
65
|
+
test('states what omp reports and nothing else', () => {
|
|
66
|
+
act(() => {
|
|
67
|
+
render(
|
|
68
|
+
h(ModelCapabilitiesModal, {
|
|
69
|
+
isOpen: true,
|
|
70
|
+
model: model({ id: 'gpt-x', hasVision: true, hasReasoning: true, thinkingEfforts: ['low', 'high'] }),
|
|
71
|
+
onClose: () => {},
|
|
72
|
+
}),
|
|
73
|
+
container,
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const body = text();
|
|
78
|
+
expect(body).toContain('Image input');
|
|
79
|
+
expect(body).toContain('Yes');
|
|
80
|
+
// The ladder omp declared, not an invented "extended reasoning".
|
|
81
|
+
expect(body).toContain('low · high');
|
|
82
|
+
// The two claims the panel used to make for every model are gone.
|
|
83
|
+
expect(body).not.toContain('Structured Output');
|
|
84
|
+
expect(body).not.toContain('Streaming');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('an unreported field says "not reported", which is not "no"', () => {
|
|
88
|
+
act(() => {
|
|
89
|
+
render(
|
|
90
|
+
h(ModelCapabilitiesModal, { isOpen: true, model: model({ id: 'm' }), onClose: () => {} }),
|
|
91
|
+
container,
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const body = text();
|
|
96
|
+
expect(body).toContain('not reported');
|
|
97
|
+
// The footer states the distinction the badge relies on: an absent field is
|
|
98
|
+
// not a denial.
|
|
99
|
+
expect(body).toContain('not the same as');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('a non-chat kind is named', () => {
|
|
103
|
+
act(() => {
|
|
104
|
+
render(
|
|
105
|
+
h(ModelCapabilitiesModal, { isOpen: true, model: model({ id: 'e', kind: 'embedding' }), onClose: () => {} }),
|
|
106
|
+
container,
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
expect(text()).toContain('Embedding (embedding)');
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe('AddModelModal', () => {
|
|
114
|
+
test('offers the kind picker, so a non-chat model is not registered as chat', () => {
|
|
115
|
+
act(() => {
|
|
116
|
+
render(
|
|
117
|
+
h(AddModelModal, {
|
|
118
|
+
isOpen: true,
|
|
119
|
+
provider,
|
|
120
|
+
onClose: () => {},
|
|
121
|
+
onAdded: () => {},
|
|
122
|
+
onError: () => {},
|
|
123
|
+
}),
|
|
124
|
+
container,
|
|
125
|
+
);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const select = [...container.querySelectorAll('select')].find((node) => (
|
|
129
|
+
[...node.options].some((option) => option.value === 'embedding')
|
|
130
|
+
));
|
|
131
|
+
expect(select).toBeDefined();
|
|
132
|
+
expect(select?.value).toBe('chat');
|
|
133
|
+
expect([...(select?.options ?? [])].map((option) => option.value)).toContain('rerank');
|
|
134
|
+
});
|
|
135
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The "add provider" preset rows draw their mark on the shared plate.
|
|
8
|
+
*
|
|
9
|
+
* The preset grid is a provider surface like the settings list and the composer
|
|
10
|
+
* picker, and it used the bare `ProviderIcon`: a brand SVG came out square while
|
|
11
|
+
* an unknown provider's initials came out as a text-width pill, so two cards in
|
|
12
|
+
* one grid started their names at different x. The plate is the fixed box that
|
|
13
|
+
* gives every card a shared origin — and a preset has no fetched web icon (it is
|
|
14
|
+
* offered for a provider that is not configured yet), so it must draw the
|
|
15
|
+
* built-in mark rather than an empty box.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
19
|
+
import { Window } from 'happy-dom';
|
|
20
|
+
import { h, render } from 'preact';
|
|
21
|
+
import { act } from 'preact/test-utils';
|
|
22
|
+
import { PresetPicker } from '@/client/components/settings/categories/provider-settings/PresetPicker';
|
|
23
|
+
import type { PresetProviderOption } from '@/shared/types/settings/provider';
|
|
24
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
25
|
+
|
|
26
|
+
let container: HTMLElement;
|
|
27
|
+
|
|
28
|
+
const presets: PresetProviderOption[] = [
|
|
29
|
+
{ id: 'openai', slug: 'openai', name: 'OpenAI', icon: 'openai', group: 'Hosted', defaultUrl: '' },
|
|
30
|
+
{ id: 'my-gw', slug: 'my-gw', name: 'My Gateway', icon: '', group: 'Hosted', defaultUrl: '' },
|
|
31
|
+
] as PresetProviderOption[];
|
|
32
|
+
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
installDomGlobals(new Window());
|
|
35
|
+
container = document.createElement('div');
|
|
36
|
+
document.body.appendChild(container);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
afterEach(() => {
|
|
40
|
+
act(() => render(null, container));
|
|
41
|
+
container.remove();
|
|
42
|
+
restoreDomGlobals();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('preset picker marks', () => {
|
|
46
|
+
test('every preset card carries an 18px plate with the built-in mark', () => {
|
|
47
|
+
act(() => {
|
|
48
|
+
render(
|
|
49
|
+
h(PresetPicker, { presets, selectedPresetId: '', onSelectPreset: () => {} }),
|
|
50
|
+
container,
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const plates = [...container.querySelectorAll('span[aria-hidden]')].filter(
|
|
55
|
+
(span) => (span as HTMLElement).style.width === '18px',
|
|
56
|
+
) as HTMLElement[];
|
|
57
|
+
expect(plates).toHaveLength(2);
|
|
58
|
+
// The known brand draws its glyph; the unknown one draws initials — never an
|
|
59
|
+
// empty plate, which would read as a missing icon.
|
|
60
|
+
expect(plates[0]?.querySelector('svg')).not.toBeNull();
|
|
61
|
+
expect(plates[1]?.textContent).toBe('mg.');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('a preset row has no web icon: it is offered for an unconfigured provider', () => {
|
|
65
|
+
act(() => {
|
|
66
|
+
render(
|
|
67
|
+
h(PresetPicker, { presets, selectedPresetId: 'openai', onSelectPreset: () => {} }),
|
|
68
|
+
container,
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
expect(container.querySelectorAll('img')).toHaveLength(0);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { ReactNode } from 'preact/compat';
|
|
2
2
|
import { AlertCircle } from 'lucide-preact';
|
|
3
|
+
import { ProviderIconPlate } from '@/client/components/common/provider-icon/Plate';
|
|
3
4
|
|
|
4
5
|
interface ProviderCardProps {
|
|
5
6
|
providerName: string;
|
|
7
|
+
/** Slug + fetched web icon, so the card header carries the provider's own mark. */
|
|
8
|
+
providerSlug?: string;
|
|
9
|
+
iconUrl?: string;
|
|
6
10
|
/** Where the credential was found, e.g. "models.yml · agent.db". */
|
|
7
11
|
credentialSources: string[];
|
|
8
12
|
/** Provider-side failure, already human-readable. */
|
|
@@ -14,11 +18,27 @@ interface ProviderCardProps {
|
|
|
14
18
|
/** Provider shell: header, credential provenance, error line, and content slot.
|
|
15
19
|
* Every listed provider has a resolved credential — a keyless provider is never
|
|
16
20
|
* rendered at all — so there is no "not configured" state here. */
|
|
17
|
-
export function ProviderCard({
|
|
21
|
+
export function ProviderCard({
|
|
22
|
+
providerName,
|
|
23
|
+
providerSlug,
|
|
24
|
+
iconUrl,
|
|
25
|
+
credentialSources,
|
|
26
|
+
error,
|
|
27
|
+
note,
|
|
28
|
+
children,
|
|
29
|
+
}: ProviderCardProps) {
|
|
18
30
|
return (
|
|
19
31
|
<section className="bg-paper border border-ink/15 rounded-lg shadow-xs">
|
|
20
32
|
<header className="flex items-center justify-between gap-2 px-3.5 py-2.5 border-b border-ink/10">
|
|
21
|
-
<span className="
|
|
33
|
+
<span className="flex min-w-0 items-center gap-2">
|
|
34
|
+
{providerSlug && (
|
|
35
|
+
<ProviderIconPlate
|
|
36
|
+
provider={{ slug: providerSlug, name: providerName, ...(iconUrl ? { iconUrl } : {}) }}
|
|
37
|
+
size={20}
|
|
38
|
+
/>
|
|
39
|
+
)}
|
|
40
|
+
<span className="truncate text-xs font-semibold text-ink">{providerName}</span>
|
|
41
|
+
</span>
|
|
22
42
|
<span
|
|
23
43
|
className="text-[10px] font-mono uppercase tracking-wider text-ink/50 truncate"
|
|
24
44
|
title={`Credentials from ${credentialSources.join(', ')}`}
|
|
@@ -22,6 +22,8 @@ export function ProviderDetail({ summary }: ProviderDetailProps) {
|
|
|
22
22
|
return (
|
|
23
23
|
<ProviderCard
|
|
24
24
|
providerName={summary.name}
|
|
25
|
+
providerSlug={summary.id}
|
|
26
|
+
iconUrl={summary.iconUrl}
|
|
25
27
|
credentialSources={summary.credentialSources}
|
|
26
28
|
error={summary.error}
|
|
27
29
|
note={summary.deepseek ? DEEPSEEK_NOTE : undefined}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { UsageReport } from '@/shared/types';
|
|
2
2
|
import { buildProviders, statusLabel, type ProviderEntry, type UsageProviderId } from '@/client/components/settings/categories/usage-settings/providers';
|
|
3
|
-
import {
|
|
3
|
+
import { ProviderIconPlate } from '@/client/components/common/provider-icon/Plate';
|
|
4
4
|
|
|
5
5
|
interface UsageSidebarListProps {
|
|
6
6
|
report: UsageReport;
|
|
@@ -8,11 +8,21 @@ interface UsageSidebarListProps {
|
|
|
8
8
|
onSelectProvider: (providerId: UsageProviderId) => void;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The provider's mark, on the same plate the provider settings list uses — so a
|
|
13
|
+
* gateway whose site logo was fetched shows that logo here too, instead of the
|
|
14
|
+
* initials its unknown slug would produce.
|
|
15
|
+
*/
|
|
16
|
+
function ProviderBadge({ provider }: { provider: ProviderEntry }) {
|
|
12
17
|
return (
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
<ProviderIconPlate
|
|
19
|
+
provider={{
|
|
20
|
+
slug: provider.id,
|
|
21
|
+
name: provider.name,
|
|
22
|
+
...(provider.iconUrl ? { iconUrl: provider.iconUrl } : {}),
|
|
23
|
+
}}
|
|
24
|
+
size={20}
|
|
25
|
+
/>
|
|
16
26
|
);
|
|
17
27
|
}
|
|
18
28
|
|
|
@@ -59,7 +69,7 @@ export function UsageSidebarList({
|
|
|
59
69
|
<div className="flex items-center justify-between gap-1.5">
|
|
60
70
|
<div className="flex items-center gap-1.5 min-w-0">
|
|
61
71
|
<div className="relative">
|
|
62
|
-
<ProviderBadge provider={provider}
|
|
72
|
+
<ProviderBadge provider={provider} />
|
|
63
73
|
<span
|
|
64
74
|
className={`absolute -top-0.5 -right-0.5 w-1.5 h-1.5 rounded-full ${
|
|
65
75
|
provider.error ? 'bg-error/60' : 'bg-ink'
|
|
@@ -11,6 +11,8 @@ export type UsageProviderId = string;
|
|
|
11
11
|
export interface ProviderEntry {
|
|
12
12
|
id: UsageProviderId;
|
|
13
13
|
name: string;
|
|
14
|
+
/** The provider's fetched web icon, when the server has one. */
|
|
15
|
+
iconUrl?: string;
|
|
14
16
|
/** Provider-side failure, already human-readable. */
|
|
15
17
|
error?: string;
|
|
16
18
|
/** Short status line under the name. */
|
|
@@ -46,6 +48,7 @@ export function buildProviders(report: UsageReport): ProviderEntry[] {
|
|
|
46
48
|
return report.providers.map((summary) => ({
|
|
47
49
|
id: summary.id,
|
|
48
50
|
name: summary.name,
|
|
51
|
+
...(summary.iconUrl ? { iconUrl: summary.iconUrl } : {}),
|
|
49
52
|
error: summary.error,
|
|
50
53
|
hint: providerHint(summary),
|
|
51
54
|
limits: summary.limits,
|
|
@@ -143,6 +143,25 @@ describe('buildProviders', () => {
|
|
|
143
143
|
expect(entries[0]?.summary.id).toBe('a');
|
|
144
144
|
});
|
|
145
145
|
|
|
146
|
+
test('the provider\'s fetched web icon rides on the row', () => {
|
|
147
|
+
// Both usage surfaces draw a mark, and the built-in glyph table cannot know
|
|
148
|
+
// a models.yml gateway — so the icon the provider list fetched has to travel
|
|
149
|
+
// with the summary or those rows show initials for a provider whose logo is
|
|
150
|
+
// already stored.
|
|
151
|
+
const entries = buildProviders({
|
|
152
|
+
isMock: false,
|
|
153
|
+
generatedAt: '',
|
|
154
|
+
providers: [
|
|
155
|
+
summary({ id: 'localtest', name: 'Local Test', iconUrl: '/api/provider-icon?slug=localtest&v=7' }),
|
|
156
|
+
summary({ id: 'plain', name: 'Plain' }),
|
|
157
|
+
],
|
|
158
|
+
});
|
|
159
|
+
expect(entries[0]?.iconUrl).toBe('/api/provider-icon?slug=localtest&v=7');
|
|
160
|
+
// Absent stays absent: an empty string would make the plate paint a broken
|
|
161
|
+
// image and then fall back, which is a flash for no reason.
|
|
162
|
+
expect('iconUrl' in (entries[1] ?? {})).toBe(false);
|
|
163
|
+
});
|
|
164
|
+
|
|
146
165
|
test('a kenari plan name is the hint', () => {
|
|
147
166
|
const entry = buildProviders({
|
|
148
167
|
isMock: false,
|