@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
|
@@ -5,8 +5,9 @@ import type { AIModelOption, ModelPreferences } from '@/shared/types';
|
|
|
5
5
|
import { useOnClickOutside } from '@/client/hooks/ui/on-click-outside';
|
|
6
6
|
import { invalidateModelsCache } from '@/shared/lib/models/client';
|
|
7
7
|
import { ModelDropdownPanel } from '@/client/components/workspace/model-dropdown/Panel';
|
|
8
|
-
import {
|
|
8
|
+
import { ProviderIconPlate } from '@/client/components/common/provider-icon/Plate';
|
|
9
9
|
import { useModelCatalog } from '@/client/components/workspace/model-dropdown/use-catalog';
|
|
10
|
+
import { useCollapsedSections } from '@/client/components/workspace/model-dropdown/collapsed';
|
|
10
11
|
import { buildPickerGroups } from '@/client/components/workspace/model-dropdown/groups';
|
|
11
12
|
import { modelKey } from '@/shared/lib/models/identity';
|
|
12
13
|
import { RECENT_MODELS_LIMIT, filterKnownKeys, readModelPreferences, recordRecentKey, toggleFavoriteKey } from '@/shared/lib/models/preferences';
|
|
@@ -30,7 +31,7 @@ export function ModelDropdown({
|
|
|
30
31
|
const [search, setSearch] = useState('');
|
|
31
32
|
const [focusedIndex, setFocusedIndex] = useState<number>(-1);
|
|
32
33
|
const [hoveredModel, setHoveredModel] = useState<AIModelOption | null>(null);
|
|
33
|
-
const [collapsedSections,
|
|
34
|
+
const [collapsedSections, toggleSection] = useCollapsedSections();
|
|
34
35
|
const {
|
|
35
36
|
models,
|
|
36
37
|
isLoading,
|
|
@@ -41,6 +42,32 @@ export function ModelDropdown({
|
|
|
41
42
|
applyPreferences,
|
|
42
43
|
} = useModelCatalog(externalSelectedModel);
|
|
43
44
|
|
|
45
|
+
/**
|
|
46
|
+
* The selected model's mark, resolved against the CATALOG when the value the
|
|
47
|
+
* composer handed us is a bare `{provider, id}` pair.
|
|
48
|
+
*
|
|
49
|
+
* The selection travels out of this component as `onSelectModel(model)` and
|
|
50
|
+
* comes back as a prop built by the parent from `provider` + `id` — which
|
|
51
|
+
* carries neither `providerIcon` nor `providerIconUrl`. Reading only the prop
|
|
52
|
+
* made the trigger fall back to initials for a provider whose site logo the
|
|
53
|
+
* picker itself was already showing one row below.
|
|
54
|
+
*/
|
|
55
|
+
const selectedMark = useMemo(() => {
|
|
56
|
+
if (!selectedModel) return null;
|
|
57
|
+
const fromCatalog = models.find(
|
|
58
|
+
(model) => model.provider === selectedModel.provider
|
|
59
|
+
&& (model.id === selectedModel.id || !selectedModel.id),
|
|
60
|
+
);
|
|
61
|
+
return {
|
|
62
|
+
icon: selectedModel.providerIcon ?? fromCatalog?.providerIcon,
|
|
63
|
+
slug: selectedModel.provider,
|
|
64
|
+
name: selectedModel.provider,
|
|
65
|
+
...(selectedModel.providerIconUrl ?? fromCatalog?.providerIconUrl
|
|
66
|
+
? { iconUrl: selectedModel.providerIconUrl ?? fromCatalog?.providerIconUrl }
|
|
67
|
+
: {}),
|
|
68
|
+
};
|
|
69
|
+
}, [selectedModel, models]);
|
|
70
|
+
|
|
44
71
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
45
72
|
useOnClickOutside(containerRef, () => {
|
|
46
73
|
setIsOpen(false);
|
|
@@ -76,10 +103,6 @@ export function ModelDropdown({
|
|
|
76
103
|
}
|
|
77
104
|
};
|
|
78
105
|
|
|
79
|
-
const toggleSection = (section: string) => {
|
|
80
|
-
setCollapsedSections(prev => ({ ...prev, [section]: !prev[section] }));
|
|
81
|
-
};
|
|
82
|
-
|
|
83
106
|
/**
|
|
84
107
|
* Flip one row's star. The optimistic stamp and the rollback both go through
|
|
85
108
|
* the preference pair — the flag on a row is derived state, so patching the
|
|
@@ -227,19 +250,19 @@ export function ModelDropdown({
|
|
|
227
250
|
>
|
|
228
251
|
{selectedModel ? (
|
|
229
252
|
<>
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
<span className="flex items-
|
|
253
|
+
{selectedModel.isCmdAgent ? (
|
|
254
|
+
<span className="inline-flex items-center justify-center w-[16px] h-[16px] rounded-[4px] border border-ink/20 bg-ink/5 text-ink/70 flex-shrink-0 font-mono text-[10px] font-bold">
|
|
255
|
+
⌘
|
|
256
|
+
</span>
|
|
257
|
+
) : (
|
|
258
|
+
<ProviderIconPlate provider={selectedMark ?? {}} size={16} />
|
|
259
|
+
)}
|
|
260
|
+
{/* Provider and model are two labels with a separator between them.
|
|
261
|
+
The PROVIDER never truncates: `kenari` and `kenari-jatis` are two
|
|
262
|
+
accounts, and an ellipsis made them render identically. The MODEL
|
|
263
|
+
takes the slack, because it is the part the reader is choosing
|
|
264
|
+
and the only part whose identity survives a cut. */}
|
|
265
|
+
<span className="flex items-baseline gap-1 min-w-0">
|
|
243
266
|
<span className="shrink-0 text-ink/50 font-normal">{selectedModel.provider}</span>
|
|
244
267
|
<span className="text-ink/30 flex-shrink-0">•</span>
|
|
245
268
|
<span className="min-w-0 flex-1 truncate">{selectedModel.name}</span>
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The model picker's live-update contract.
|
|
8
|
+
*
|
|
9
|
+
* Two regressions pinned here, both found in a real browser against a real
|
|
10
|
+
* server:
|
|
11
|
+
*
|
|
12
|
+
* 1. A topic-triggered reload with an EMPTY model list must clear the picker.
|
|
13
|
+
* `load()` used to require `modelList.length > 0`, so disabling/removing the
|
|
14
|
+
* LAST provider refreshed `GET /api/models` (which honestly answered `[]`)
|
|
15
|
+
* and then ignored the answer — the dropdown kept showing models that no
|
|
16
|
+
* longer exist until a full page reload. The `modelError` half pins the
|
|
17
|
+
* mirror rule: a FAILED read still keeps the previous list, so the picker
|
|
18
|
+
* does not flash the empty state over an omp registry hiccup.
|
|
19
|
+
*
|
|
20
|
+
* 2. Collapsing a section must survive a remount. The state used to be a plain
|
|
21
|
+
* `useState`, so the reload the stale-list bug forced reset every collapse.
|
|
22
|
+
* It is now persisted in the session UI slot (`chat.modelDropdownCollapsed`).
|
|
23
|
+
*
|
|
24
|
+
* The harness is a REAL realtime server: the picker dials it through the real
|
|
25
|
+
* client, and the reload is driven by publishing a `models` delta — the same
|
|
26
|
+
* signal a provider write produces — not by calling the hook directly.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
30
|
+
import { Window } from 'happy-dom';
|
|
31
|
+
import { h, render } from 'preact';
|
|
32
|
+
import { act } from 'preact/test-utils';
|
|
33
|
+
import { ModelDropdown } from '@/client/components/workspace/model-dropdown/index';
|
|
34
|
+
import { SessionStateProvider } from '@/client/components/common/session-state-provider/index';
|
|
35
|
+
import {
|
|
36
|
+
MODEL_DROPDOWN_COLLAPSED_KEY,
|
|
37
|
+
} from '@/client/components/workspace/model-dropdown/collapsed';
|
|
38
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
39
|
+
import { startRealtimeTestServer, type RealtimeTestServer } from '@/test-support/realtime-server';
|
|
40
|
+
import { invalidateModelsCache } from '@/shared/lib/models/client';
|
|
41
|
+
import { TOPIC_MODELS } from '@/shared/lib/realtime/protocol';
|
|
42
|
+
import { forgetSession, getSessionValue } from '@/shared/lib/workspace/session-state/store';
|
|
43
|
+
import type { ModelsData } from '@/shared/types';
|
|
44
|
+
|
|
45
|
+
const SESSION = 'model-dropdown-refresh';
|
|
46
|
+
|
|
47
|
+
const WITH_MODELS: ModelsData = {
|
|
48
|
+
models: { alpha: 'Alpha Model', beta: 'Beta Model' },
|
|
49
|
+
modelList: [
|
|
50
|
+
{ id: 'alpha-model', name: 'Alpha Model', provider: 'alpha', thinkingLevels: ['off', 'low'] },
|
|
51
|
+
{ id: 'beta-model', name: 'Beta Model', provider: 'beta', thinkingLevels: ['off', 'low'] },
|
|
52
|
+
],
|
|
53
|
+
defaultModel: null,
|
|
54
|
+
thinkingLevels: {},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const EMPTY_MODELS: ModelsData = { models: {}, modelList: [], defaultModel: null, thinkingLevels: {} };
|
|
58
|
+
|
|
59
|
+
/** A FAILED read: the route answers `modelList: []` WITH `modelError`. */
|
|
60
|
+
const ERROR_MODELS: ModelsData = {
|
|
61
|
+
models: {},
|
|
62
|
+
modelList: [],
|
|
63
|
+
defaultModel: null,
|
|
64
|
+
thinkingLevels: {},
|
|
65
|
+
modelError: 'Model list is temporarily unavailable. Check your configuration and try again.',
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const originalFetch = globalThis.fetch;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Serve `/api/models` from a payload the TEST swaps at the moment it writes.
|
|
72
|
+
*
|
|
73
|
+
* A positional queue assumes exactly one read per phase, and that assumption is
|
|
74
|
+
* what made this file flaky: `useModelCatalog` fetches on mount AND again on the
|
|
75
|
+
* realtime topic's first value, so on a runner where the socket's initial
|
|
76
|
+
* publish lands AFTER the mount fetch resolves, the mount phase consumes TWO
|
|
77
|
+
* entries — the second being the "after the write" payload — and the picker
|
|
78
|
+
* clears its rows before the test publishes anything. Measured in CI: the panel
|
|
79
|
+
* read `No models available` and the wait for `Alpha Model` timed out on Ubuntu
|
|
80
|
+
* and on Windows while passing locally. The stub therefore holds ONE payload and
|
|
81
|
+
* `serve()` replaces it; every read before the test's write sees the first one.
|
|
82
|
+
*/
|
|
83
|
+
function stubFetch(): { serve: (payload: unknown) => void } {
|
|
84
|
+
let payload: unknown = null;
|
|
85
|
+
globalThis.fetch = (async (input: RequestInfo | URL) => {
|
|
86
|
+
const url = String(input);
|
|
87
|
+
if (url.startsWith('/api/models')) {
|
|
88
|
+
return new Response(JSON.stringify(payload), { status: 200, headers: { 'Content-Type': 'application/json' } });
|
|
89
|
+
}
|
|
90
|
+
if (url.includes('/state')) {
|
|
91
|
+
return new Response(JSON.stringify({ state: {} }), { status: 200, headers: { 'Content-Type': 'application/json' } });
|
|
92
|
+
}
|
|
93
|
+
return new Response('{}', { status: 200, headers: { 'Content-Type': 'application/json' } });
|
|
94
|
+
}) as unknown as typeof fetch;
|
|
95
|
+
return { serve: (next: unknown) => { payload = next; } };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function sleep(ms: number): Promise<void> {
|
|
99
|
+
const { promise, resolve } = Promise.withResolvers<void>();
|
|
100
|
+
setTimeout(resolve, ms);
|
|
101
|
+
return promise;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function flush(times = 12, ms = 8): Promise<void> {
|
|
105
|
+
for (let i = 0; i < times; i += 1) {
|
|
106
|
+
await act(async () => {
|
|
107
|
+
await sleep(ms);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async function waitForDom(assertion: () => boolean, timeoutMs = 3_000): Promise<void> {
|
|
113
|
+
const deadline = Date.now() + timeoutMs;
|
|
114
|
+
while (Date.now() < deadline) {
|
|
115
|
+
if (assertion()) return;
|
|
116
|
+
await act(async () => {
|
|
117
|
+
await sleep(15);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
throw new Error('waitForDom timeout');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function trigger(el: HTMLElement): HTMLButtonElement {
|
|
124
|
+
const found = Array.from(el.querySelectorAll('button')).find(
|
|
125
|
+
(b) => b.getAttribute('title') === 'Select a model',
|
|
126
|
+
);
|
|
127
|
+
if (!found) throw new Error('no model-dropdown trigger');
|
|
128
|
+
return found as HTMLButtonElement;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function findButton(el: HTMLElement, text: string): HTMLButtonElement | null {
|
|
132
|
+
return (Array.from(el.querySelectorAll('button')).find((b) => (b.textContent ?? '').includes(text)) ??
|
|
133
|
+
null) as HTMLButtonElement | null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
let server: RealtimeTestServer;
|
|
137
|
+
let container: HTMLElement;
|
|
138
|
+
|
|
139
|
+
async function mountPicker(withProvider = false): Promise<HTMLElement> {
|
|
140
|
+
const host = document.createElement('div');
|
|
141
|
+
document.body.appendChild(host);
|
|
142
|
+
const picker = h(ModelDropdown, { onSelectModel: () => {} });
|
|
143
|
+
const node = withProvider
|
|
144
|
+
? h(SessionStateProvider, { sessionId: SESSION, children: picker })
|
|
145
|
+
: picker;
|
|
146
|
+
await act(async () => {
|
|
147
|
+
render(node, host);
|
|
148
|
+
});
|
|
149
|
+
await flush();
|
|
150
|
+
return host;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
describe('model picker live updates', () => {
|
|
154
|
+
// The catalog cache is MODULE state shared with every other suite in the
|
|
155
|
+
// process, and `afterEach` only protects the tests that follow. A file that
|
|
156
|
+
// read the catalog earlier — the real route, a stub, anything — leaves its
|
|
157
|
+
// payload here, and the FIRST case then mounts against that stale list
|
|
158
|
+
// instead of the stub this file installed: measured, `a reload carrying an
|
|
159
|
+
// EMPTY model list` waited 3s for `Alpha Model` and read an empty panel on
|
|
160
|
+
// both CI platforms while passing alone. Clear it before each case, not just
|
|
161
|
+
// after.
|
|
162
|
+
beforeEach(() => invalidateModelsCache());
|
|
163
|
+
|
|
164
|
+
afterEach(async () => {
|
|
165
|
+
await server?.stop();
|
|
166
|
+
invalidateModelsCache();
|
|
167
|
+
if (container) {
|
|
168
|
+
// A real unmount, not `remove()`: the picker's realtime subscription
|
|
169
|
+
// must be released or its late socket-close events re-render into a
|
|
170
|
+
// torn-down `document`.
|
|
171
|
+
render(null, container);
|
|
172
|
+
container.remove();
|
|
173
|
+
}
|
|
174
|
+
container = null as never;
|
|
175
|
+
if (document.body) document.body.innerHTML = '';
|
|
176
|
+
forgetSession(SESSION);
|
|
177
|
+
restoreDomGlobals();
|
|
178
|
+
globalThis.fetch = originalFetch;
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test('a reload carrying an EMPTY model list clears the picker', async () => {
|
|
182
|
+
server = await startRealtimeTestServer(new Map([[TOPIC_MODELS, async () => WITH_MODELS]]));
|
|
183
|
+
installDomGlobals(new Window({ url: `http://127.0.0.1:${server.port}` }));
|
|
184
|
+
const models = stubFetch();
|
|
185
|
+
models.serve(WITH_MODELS);
|
|
186
|
+
|
|
187
|
+
container = await mountPicker();
|
|
188
|
+
trigger(container).click();
|
|
189
|
+
const panelText = () => container.textContent ?? '';
|
|
190
|
+
// The rows arrive over the realtime socket, so this waits for the CONDITION
|
|
191
|
+
// rather than for a duration: a fixed flush is enough on a fast runner and
|
|
192
|
+
// is not on a Windows one (measured: the panel still read "No models
|
|
193
|
+
// available" 80ms after the click).
|
|
194
|
+
await waitForDom(() => panelText().includes('Alpha Model'));
|
|
195
|
+
expect(panelText()).toContain('Beta Model');
|
|
196
|
+
|
|
197
|
+
// The app clears its client cache after a provider write, then the topic
|
|
198
|
+
// delta drives the reload — mirrored here in that exact order. The payload
|
|
199
|
+
// is swapped BEFORE the signal so the reload cannot read the old one.
|
|
200
|
+
models.serve(EMPTY_MODELS);
|
|
201
|
+
invalidateModelsCache();
|
|
202
|
+
server.publish(TOPIC_MODELS, EMPTY_MODELS);
|
|
203
|
+
|
|
204
|
+
await waitForDom(() => panelText().includes('No models available'));
|
|
205
|
+
expect(panelText()).not.toContain('Alpha Model');
|
|
206
|
+
expect(panelText()).not.toContain('Beta Model');
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
test('a FAILED read (modelError) keeps the previous list', async () => {
|
|
210
|
+
server = await startRealtimeTestServer(new Map([[TOPIC_MODELS, async () => WITH_MODELS]]));
|
|
211
|
+
installDomGlobals(new Window({ url: `http://127.0.0.1:${server.port}` }));
|
|
212
|
+
const models = stubFetch();
|
|
213
|
+
models.serve(WITH_MODELS);
|
|
214
|
+
|
|
215
|
+
container = await mountPicker();
|
|
216
|
+
trigger(container).click();
|
|
217
|
+
const panelText = () => container.textContent ?? '';
|
|
218
|
+
await waitForDom(() => panelText().includes('Alpha Model'));
|
|
219
|
+
|
|
220
|
+
models.serve(ERROR_MODELS);
|
|
221
|
+
invalidateModelsCache();
|
|
222
|
+
server.publish(TOPIC_MODELS, ERROR_MODELS);
|
|
223
|
+
|
|
224
|
+
// The failure must NOT blank the rail — wait a beat and assert the rows
|
|
225
|
+
// are still there (and the failure is not republished as empty).
|
|
226
|
+
await flush(15, 15);
|
|
227
|
+
expect(panelText()).toContain('Alpha Model');
|
|
228
|
+
expect(panelText()).not.toContain('No models available');
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
test('a collapsed section is persisted and restored on remount', async () => {
|
|
232
|
+
server = await startRealtimeTestServer(new Map([[TOPIC_MODELS, async () => WITH_MODELS]]));
|
|
233
|
+
installDomGlobals(new Window({ url: `http://127.0.0.1:${server.port}` }));
|
|
234
|
+
const models = stubFetch();
|
|
235
|
+
models.serve(WITH_MODELS);
|
|
236
|
+
|
|
237
|
+
container = await mountPicker(true);
|
|
238
|
+
trigger(container).click();
|
|
239
|
+
const panelText = () => container.textContent ?? '';
|
|
240
|
+
await waitForDom(() => panelText().includes('Alpha Model'));
|
|
241
|
+
|
|
242
|
+
// Collapse the FIRST provider section. The group key is the provider name
|
|
243
|
+
// upper-cased (`buildPickerGroups`), and the header renders that key.
|
|
244
|
+
const header = findButton(container, 'ALPHA');
|
|
245
|
+
expect(header).not.toBeNull();
|
|
246
|
+
await act(async () => {
|
|
247
|
+
header!.click();
|
|
248
|
+
});
|
|
249
|
+
expect(getSessionValue<Record<string, boolean>>(SESSION, MODEL_DROPDOWN_COLLAPSED_KEY)).toEqual({ ALPHA: true });
|
|
250
|
+
expect(panelText()).not.toContain('Alpha Model');
|
|
251
|
+
|
|
252
|
+
// A fresh mount (as after a reload) restores the collapse from the store.
|
|
253
|
+
render(null, container);
|
|
254
|
+
container.remove();
|
|
255
|
+
container = await mountPicker(true);
|
|
256
|
+
trigger(container).click();
|
|
257
|
+
await waitForDom(() => panelText().includes('Beta Model'));
|
|
258
|
+
expect(panelText()).not.toContain('Alpha Model');
|
|
259
|
+
});
|
|
260
|
+
});
|
|
@@ -121,3 +121,37 @@ describe('composer model trigger label', () => {
|
|
|
121
121
|
expect(button.title).toBe('kenari • Deepseek-V4-1-Flash');
|
|
122
122
|
});
|
|
123
123
|
});
|
|
124
|
+
|
|
125
|
+
describe('trigger mark for a provider whose own icon was fetched', () => {
|
|
126
|
+
test('falls back to the CATALOG row when the selection prop is a bare provider/id pair', async () => {
|
|
127
|
+
// The composer hands the selection back as `{provider, id}` — it carries
|
|
128
|
+
// neither `providerIcon` nor `providerIconUrl`. Reading only the prop made
|
|
129
|
+
// the trigger draw initials for a provider whose logo the picker itself was
|
|
130
|
+
// showing one row below.
|
|
131
|
+
silenceRealtime();
|
|
132
|
+
const originalFetch = globalThis.fetch;
|
|
133
|
+
globalThis.fetch = (async () => new Response(JSON.stringify({
|
|
134
|
+
models: {},
|
|
135
|
+
modelList: [{
|
|
136
|
+
id: MODEL.id,
|
|
137
|
+
name: MODEL.name,
|
|
138
|
+
provider: MODEL.provider,
|
|
139
|
+
providerIconUrl: '/api/provider-icon?slug=kenari&v=1700000000000',
|
|
140
|
+
thinkingLevels: ['off'],
|
|
141
|
+
}],
|
|
142
|
+
defaultModel: null,
|
|
143
|
+
thinkingLevels: {},
|
|
144
|
+
}), { status: 200, headers: { 'content-type': 'application/json' } })) as unknown as typeof fetch;
|
|
145
|
+
try {
|
|
146
|
+
act(() => {
|
|
147
|
+
render(h(ModelDropdown, { selectedModel: { id: MODEL.id, name: MODEL.name, provider: MODEL.provider } }), container);
|
|
148
|
+
});
|
|
149
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
150
|
+
const image = container.querySelector('button[title] img') as HTMLImageElement | null;
|
|
151
|
+
expect(image).not.toBeNull();
|
|
152
|
+
expect(image?.getAttribute('src')).toContain('/api/provider-icon');
|
|
153
|
+
} finally {
|
|
154
|
+
globalThis.fetch = originalFetch;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
});
|
|
@@ -20,6 +20,10 @@ function toOption(m: ModelEntry): AIModelOption {
|
|
|
20
20
|
// down with it. `unknown` keeps the row visible and gives it a stable
|
|
21
21
|
// section instead of dropping a model the user may have selected.
|
|
22
22
|
provider: m.provider || 'unknown',
|
|
23
|
+
// The provider's fetched web icon, when the server has one. Carried through
|
|
24
|
+
// so the picker's section header and the selected model's mark can draw the
|
|
25
|
+
// site's own logo instead of the initials of a provider nobody has drawn.
|
|
26
|
+
...(m.providerIconUrl ? { providerIconUrl: m.providerIconUrl } : {}),
|
|
23
27
|
contextWindow: m.contextWindow,
|
|
24
28
|
thinkingLevel: ladder[0] ?? 'off',
|
|
25
29
|
thinkingLevels: ladder,
|
|
@@ -85,7 +89,14 @@ export function useModelCatalog(externalSelectedModel?: AIModelOption): ModelCat
|
|
|
85
89
|
const load = useCallback(async () => {
|
|
86
90
|
try {
|
|
87
91
|
const data = await fetchModelsData();
|
|
88
|
-
|
|
92
|
+
// Apply the catalog whenever it came back as a LIST — even an empty one.
|
|
93
|
+
// `modelList: []` is the honest answer when every provider was disabled
|
|
94
|
+
// or removed, and skipping it kept a picker showing models that no longer
|
|
95
|
+
// exist (measured: disable the last provider, the dropdown kept its rows
|
|
96
|
+
// until a reload). `modelError` marks a FAILED read (the omp registry
|
|
97
|
+
// hiccupped), which keeps the previous list rather than flashing the
|
|
98
|
+
// empty state over a transient failure.
|
|
99
|
+
if (Array.isArray(data.modelList) && !data.modelError) {
|
|
89
100
|
const prefs = readModelPreferences(data.modelPreferences);
|
|
90
101
|
const realModels = applyModelPreferences(data.modelList.map(toOption), prefs);
|
|
91
102
|
setPreferences(prefs);
|
|
@@ -103,7 +114,7 @@ export function useModelCatalog(externalSelectedModel?: AIModelOption): ModelCat
|
|
|
103
114
|
const match = realModels.find(m => m.id === defaultModel.modelId && m.provider === defaultModel.provider);
|
|
104
115
|
if (match) setSelectedModel(match);
|
|
105
116
|
}
|
|
106
|
-
} else if (Array.isArray(data.models)
|
|
117
|
+
} else if (Array.isArray(data.models)) {
|
|
107
118
|
const prefs = readModelPreferences(data.modelPreferences);
|
|
108
119
|
setPreferences(prefs);
|
|
109
120
|
setModelsState(applyModelPreferences(data.models, prefs));
|
|
@@ -2,7 +2,7 @@ import { useEffect, useMemo, useRef, useState } from 'preact/hooks';
|
|
|
2
2
|
import type { KeyboardEvent as ReactKeyboardEvent } from 'preact/compat';
|
|
3
3
|
import { Check, ChevronDown, Search } from 'lucide-preact';
|
|
4
4
|
import { statusLabel, type ProviderEntry, type UsageProviderId } from '@/client/components/settings/categories/usage-settings/providers';
|
|
5
|
-
import {
|
|
5
|
+
import { ProviderIconPlate } from '@/client/components/common/provider-icon/Plate';
|
|
6
6
|
import { useOnClickOutside } from '@/client/hooks/ui/on-click-outside';
|
|
7
7
|
|
|
8
8
|
interface ProviderSelectProps {
|
|
@@ -122,7 +122,16 @@ export function ProviderSelect({ providers, value, onChange }: ProviderSelectPro
|
|
|
122
122
|
className="flex w-full min-w-0 items-center justify-between gap-2 bg-paper border border-ink/15 rounded-lg px-3 py-1.5 text-xs text-ink hover:bg-ink/5 transition-colors"
|
|
123
123
|
>
|
|
124
124
|
<span className="flex min-w-0 items-center gap-2">
|
|
125
|
-
{selected &&
|
|
125
|
+
{selected && (
|
|
126
|
+
<ProviderIconPlate
|
|
127
|
+
provider={{
|
|
128
|
+
slug: selected.id,
|
|
129
|
+
name: selected.name,
|
|
130
|
+
...(selected.iconUrl ? { iconUrl: selected.iconUrl } : {}),
|
|
131
|
+
}}
|
|
132
|
+
size={16}
|
|
133
|
+
/>
|
|
134
|
+
)}
|
|
126
135
|
<span className="truncate font-medium">{selected?.name ?? 'Select provider'}</span>
|
|
127
136
|
{selected && (
|
|
128
137
|
<span className="truncate text-[10px] text-ink/50">{statusLabel(selected)}</span>
|
|
@@ -193,7 +202,14 @@ export function ProviderSelect({ providers, value, onChange }: ProviderSelectPro
|
|
|
193
202
|
}`}
|
|
194
203
|
>
|
|
195
204
|
<span className="flex min-w-0 items-center gap-2">
|
|
196
|
-
<
|
|
205
|
+
<ProviderIconPlate
|
|
206
|
+
provider={{
|
|
207
|
+
slug: provider.id,
|
|
208
|
+
name: provider.name,
|
|
209
|
+
...(provider.iconUrl ? { iconUrl: provider.iconUrl } : {}),
|
|
210
|
+
}}
|
|
211
|
+
size={18}
|
|
212
|
+
/>
|
|
197
213
|
<span className="min-w-0">
|
|
198
214
|
<span className="block truncate font-medium text-ink">{provider.name}</span>
|
|
199
215
|
<span className="block truncate text-[10px] text-ink/50">
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A workspace opens when a row inside it needs to be seen.
|
|
8
|
+
*
|
|
9
|
+
* Two rows are drawn without the folder being open: a session whose run is in
|
|
10
|
+
* flight (the spinner is the answer to "did my prompt land?"), and a chat omp
|
|
11
|
+
* has not written a transcript for yet (the row exists only because Kabmo drew
|
|
12
|
+
* it). A collapsed workspace hid exactly those two, so both are answered here.
|
|
13
|
+
*
|
|
14
|
+
* The flag is the SERVER's (`workspace_folders.is_expanded`, written through the
|
|
15
|
+
* same toggle the category header uses), so a reload and the other layout read
|
|
16
|
+
* one answer. The write is EDGE-triggered per session id: a folder this mount
|
|
17
|
+
* already opened is never written open again, so the structure push that every
|
|
18
|
+
* tool call causes does not re-issue it. A run whose session the structure does
|
|
19
|
+
* not carry yet stays "fresh" until the push that names its folder arrives.
|
|
20
|
+
*
|
|
21
|
+
* The hook also returns the folder ids holding a live run, which the caller
|
|
22
|
+
* forces open in the rendered list: the row has to be visible on the frame the
|
|
23
|
+
* spinner appears, not one round trip later. Same rule `withPendingRows`
|
|
24
|
+
* applies to a pending row's host folder.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { useEffect, useMemo, useRef } from 'preact/hooks';
|
|
28
|
+
import type { PendingSessionEntry } from '@/client/hooks/chat/omp/pending-sessions';
|
|
29
|
+
import { pendingHostFolderIds } from '@/client/hooks/chat/omp/pending-rows';
|
|
30
|
+
import { setFolderExpanded } from '@/client/hooks/workspace/folder-expansion';
|
|
31
|
+
import type { WorkspaceFolderData } from '@/shared/types';
|
|
32
|
+
|
|
33
|
+
export interface FolderAutoExpandInput {
|
|
34
|
+
folders: WorkspaceFolderData[];
|
|
35
|
+
/** True before the first sidebar snapshot lands. */
|
|
36
|
+
initializing: boolean;
|
|
37
|
+
/** Ids whose run is in flight — the sidebar's `stream` rows. */
|
|
38
|
+
runningIds: Set<string>;
|
|
39
|
+
pendingEntries: PendingSessionEntry[];
|
|
40
|
+
/** The session the URL has open; its folder is a pending row's fallback host. */
|
|
41
|
+
activeId: string | null;
|
|
42
|
+
/** `?folderId=`, the last resort before the first folder. */
|
|
43
|
+
urlFolderId: string | null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The folder whose rows carry `sessionId`, if the structure has scanned it. */
|
|
47
|
+
export function folderHosting(
|
|
48
|
+
folders: WorkspaceFolderData[],
|
|
49
|
+
sessionId: string,
|
|
50
|
+
): WorkspaceFolderData | undefined {
|
|
51
|
+
return folders.find((folder) => (
|
|
52
|
+
(folder.sessions ?? []).some((session) => String(session.id) === sessionId)
|
|
53
|
+
));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function useFolderAutoExpand(input: FolderAutoExpandInput): Set<string> {
|
|
57
|
+
const { folders, initializing, runningIds, pendingEntries, activeId, urlFolderId } = input;
|
|
58
|
+
|
|
59
|
+
const runningFolderIds = useMemo(() => {
|
|
60
|
+
const ids = new Set<string>();
|
|
61
|
+
for (const id of runningIds) {
|
|
62
|
+
const host = folderHosting(folders, id);
|
|
63
|
+
if (host) ids.add(String(host.id));
|
|
64
|
+
}
|
|
65
|
+
return ids;
|
|
66
|
+
}, [folders, runningIds]);
|
|
67
|
+
|
|
68
|
+
const seenRef = useRef({ running: new Set<string>(), pending: new Set<string>() });
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (initializing || folders.length === 0) return;
|
|
71
|
+
const seen = seenRef.current;
|
|
72
|
+
const nextRunning = new Set<string>();
|
|
73
|
+
const nextPending = new Set<string>();
|
|
74
|
+
const targets = new Set<string>();
|
|
75
|
+
|
|
76
|
+
for (const id of runningIds) {
|
|
77
|
+
if (seen.running.has(id)) {
|
|
78
|
+
nextRunning.add(id);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const host = folderHosting(folders, id);
|
|
82
|
+
// Not scanned yet: left "fresh" so the push that carries its row — and
|
|
83
|
+
// therefore its folder — still opens the workspace.
|
|
84
|
+
if (!host) continue;
|
|
85
|
+
nextRunning.add(id);
|
|
86
|
+
targets.add(String(host.id));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const pendingOptions = { activeId, urlFolderId };
|
|
90
|
+
for (const entry of pendingEntries) {
|
|
91
|
+
const id = String(entry.id);
|
|
92
|
+
if (seen.pending.has(id)) {
|
|
93
|
+
nextPending.add(id);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
nextPending.add(id);
|
|
97
|
+
for (const folderId of pendingHostFolderIds(folders, [entry], pendingOptions)) {
|
|
98
|
+
targets.add(folderId);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
seen.running = nextRunning;
|
|
103
|
+
seen.pending = nextPending;
|
|
104
|
+
|
|
105
|
+
for (const id of targets) {
|
|
106
|
+
const folder = folders.find((item) => String(item.id) === id);
|
|
107
|
+
if (!folder || folder.isExpanded) continue;
|
|
108
|
+
void setFolderExpanded(id, true);
|
|
109
|
+
}
|
|
110
|
+
}, [initializing, folders, runningIds, pendingEntries, activeId, urlFolderId]);
|
|
111
|
+
|
|
112
|
+
return runningFolderIds;
|
|
113
|
+
}
|
|
@@ -39,6 +39,13 @@ export function useOmpAgent(
|
|
|
39
39
|
sessionId: string | null,
|
|
40
40
|
callbacks: OmpAgentCallbacks,
|
|
41
41
|
activityRef: RefObject<string>,
|
|
42
|
+
/**
|
|
43
|
+
* The transcript on screen. A page reload mounts a fresh fold while the
|
|
44
|
+
* session keeps running server-side, so the card for a call that started
|
|
45
|
+
* before the reload exists only in these messages; the fold reads them to
|
|
46
|
+
* find the row a late result belongs to (see `resumedToolMessage`).
|
|
47
|
+
*/
|
|
48
|
+
messagesRef?: RefObject<ChatMessageData[]>,
|
|
42
49
|
): OmpAgentHandle {
|
|
43
50
|
const [state, setState] = useState<OmpAgentState>({ isGenerating: false, connected: false, error: null });
|
|
44
51
|
const callbacksRef = useRef(callbacks);
|
|
@@ -56,6 +63,18 @@ export function useOmpAgent(
|
|
|
56
63
|
// Phrase for an open provider-retry saga; while set it outranks the activity
|
|
57
64
|
// the doomed attempt names (see `fold-deps.ts`).
|
|
58
65
|
const providerRetryVerbRef = useRef<string | null>(null);
|
|
66
|
+
// Find the row that already owns a call this fold never streamed. Only the
|
|
67
|
+
// transcript can answer after a reload, and a call id is unique within a
|
|
68
|
+
// session, so the first row carrying it is the one to adopt.
|
|
69
|
+
const resumedToolMessage = useCallback((callId: string): ChatMessageData | undefined => {
|
|
70
|
+
const messages = messagesRef?.current;
|
|
71
|
+
if (!messages) return undefined;
|
|
72
|
+
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
73
|
+
const row = messages[index];
|
|
74
|
+
if (row?.toolCalls?.some((tc) => tc.id === callId)) return row;
|
|
75
|
+
}
|
|
76
|
+
return undefined;
|
|
77
|
+
}, [messagesRef]);
|
|
59
78
|
const { connect, disconnect, attachedSession } = useOmpAgentStream({
|
|
60
79
|
setState,
|
|
61
80
|
callbacksRef,
|
|
@@ -64,6 +83,7 @@ export function useOmpAgent(
|
|
|
64
83
|
activityRef,
|
|
65
84
|
currentThinkingLevelRef,
|
|
66
85
|
providerRetryVerbRef,
|
|
86
|
+
resumedToolMessage,
|
|
67
87
|
});
|
|
68
88
|
|
|
69
89
|
/** The session id this hook last prepared refs for, so an ADOPTION can be
|
|
@@ -78,6 +78,27 @@ export function withPendingRows(
|
|
|
78
78
|
return result;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* The folder ids the given pending entries' rows land in.
|
|
83
|
+
*
|
|
84
|
+
* The same resolution `withPendingRows` uses — one function, so the auto-expand
|
|
85
|
+
* rule in the sidebar controller cannot point at a different folder than the
|
|
86
|
+
* one the row is actually drawn in.
|
|
87
|
+
*/
|
|
88
|
+
export function pendingHostFolderIds(
|
|
89
|
+
folders: WorkspaceFolderData[],
|
|
90
|
+
entries: PendingSessionEntry[],
|
|
91
|
+
options: PendingRowOptions,
|
|
92
|
+
): string[] {
|
|
93
|
+
if (entries.length === 0 || folders.length === 0) return [];
|
|
94
|
+
const ids = new Set<string>();
|
|
95
|
+
for (const entry of entries) {
|
|
96
|
+
const target = resolvePendingFolder(folders, entry, options);
|
|
97
|
+
if (target) ids.add(String(target.id));
|
|
98
|
+
}
|
|
99
|
+
return [...ids];
|
|
100
|
+
}
|
|
101
|
+
|
|
81
102
|
/**
|
|
82
103
|
* Which folder a pending row belongs to: the one it was started in, else the
|
|
83
104
|
* one owning the session on screen, else the URL's pick, else the first folder.
|