@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,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The small pieces every panel-plugin card is built from.
|
|
8
|
+
*
|
|
9
|
+
* One module rather than markup repeated in the installed card and the store
|
|
10
|
+
* card: both describe the same plugin in the same vocabulary, and the version
|
|
11
|
+
* line, the author line and the slot badges were exactly the three places they
|
|
12
|
+
* drifted apart — a store card saying `v0.2.0` while the installed card said
|
|
13
|
+
* `0.2.0`, a contribution chip reading `rightPanel` on one and `Panel view` on
|
|
14
|
+
* the other.
|
|
15
|
+
*
|
|
16
|
+
* The palette is the app's: ink at varying opacity, `text-warning` for a
|
|
17
|
+
* pending update, `text-error` for a refusal. Nothing here introduces a colour.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { ExternalLink, FolderInput, GitBranch, Package, Store } from 'lucide-preact';
|
|
21
|
+
import type { ComponentChildren } from 'preact';
|
|
22
|
+
import type { PanelPluginAuthor, PanelPluginOrigin } from '@/shared/types';
|
|
23
|
+
import { isNewer } from '@/shared/lib/updates/semver';
|
|
24
|
+
import type { PluginContribution } from '@/client/hooks/workspace/plugin-contributions';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The installed version, and the newer one when there is one.
|
|
28
|
+
*
|
|
29
|
+
* Both numbers are shown together because either alone is a half answer: the
|
|
30
|
+
* installed version says what is running, the newer one says what updating would
|
|
31
|
+
* give. The arrow only appears when the source's version is strictly NEWER —
|
|
32
|
+
* an equal version renders as one number, or every up-to-date plugin would carry
|
|
33
|
+
* a pointless pair.
|
|
34
|
+
*/
|
|
35
|
+
export function VersionLine({ version, latest }: { version: string; latest?: string | undefined }) {
|
|
36
|
+
const newer = Boolean(latest && version && isNewer(latest, version));
|
|
37
|
+
if (!version) {
|
|
38
|
+
return <span className="text-[10px] font-mono text-ink/40">unversioned</span>;
|
|
39
|
+
}
|
|
40
|
+
if (!newer) {
|
|
41
|
+
return (
|
|
42
|
+
<span className="text-[10px] font-mono text-ink/50" title={`Installed version ${version}`}>
|
|
43
|
+
v{version}
|
|
44
|
+
</span>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
return (
|
|
48
|
+
<span className="flex items-center gap-1 text-[10px] font-mono" title={`Installed ${version}, available ${latest}`}>
|
|
49
|
+
<span className="text-ink/45">v{version}</span>
|
|
50
|
+
<span className="text-ink/30">→</span>
|
|
51
|
+
<span className="px-1 rounded bg-warning/15 text-warning border border-warning/25">v{latest}</span>
|
|
52
|
+
</span>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Who wrote the plugin. Absent when the manifest names nobody. */
|
|
57
|
+
export function AuthorLine({ author }: { author: PanelPluginAuthor | undefined }) {
|
|
58
|
+
if (!author) return <span className="text-[10px] text-ink/40">author unknown</span>;
|
|
59
|
+
const label = `by ${author.name}`;
|
|
60
|
+
if (!author.url) {
|
|
61
|
+
return (
|
|
62
|
+
<span className="text-[10px] text-ink/50 truncate" title={author.email ? `${author.name} <${author.email}>` : label}>
|
|
63
|
+
{label}
|
|
64
|
+
</span>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return (
|
|
68
|
+
<a
|
|
69
|
+
href={author.url}
|
|
70
|
+
target="_blank"
|
|
71
|
+
rel="noreferrer noopener"
|
|
72
|
+
className="flex items-center gap-0.5 text-[10px] text-ink/50 hover:text-ink truncate"
|
|
73
|
+
title={author.url}
|
|
74
|
+
>
|
|
75
|
+
{label}
|
|
76
|
+
<ExternalLink size={9} className="flex-shrink-0" />
|
|
77
|
+
</a>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const ORIGIN_FACTS: Record<PanelPluginOrigin, { label: string; detail: string; Icon: typeof Package }> = {
|
|
82
|
+
bundled: {
|
|
83
|
+
label: 'Bundled',
|
|
84
|
+
detail: 'Installed from Kabmo’s own store, and kept current by Kabmo’s update.',
|
|
85
|
+
Icon: Store,
|
|
86
|
+
},
|
|
87
|
+
git: {
|
|
88
|
+
label: 'Git',
|
|
89
|
+
detail: 'A git clone you own. Update it from its remote, or turn on automatic updates above.',
|
|
90
|
+
Icon: GitBranch,
|
|
91
|
+
},
|
|
92
|
+
local: {
|
|
93
|
+
label: 'Local',
|
|
94
|
+
detail: 'A directory in the marketplace. Nothing updates it — edit the files and rebuild.',
|
|
95
|
+
Icon: FolderInput,
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/** Where this install came from, which is also what keeps it current. */
|
|
100
|
+
export function OriginBadge({ origin }: { origin: PanelPluginOrigin }) {
|
|
101
|
+
const fact = ORIGIN_FACTS[origin];
|
|
102
|
+
return (
|
|
103
|
+
<span
|
|
104
|
+
className="flex items-center gap-1 px-1.5 py-0.5 rounded bg-ink/5 border border-ink/10 text-[10px] text-ink/55"
|
|
105
|
+
title={fact.detail}
|
|
106
|
+
>
|
|
107
|
+
<fact.Icon size={10} className="flex-shrink-0" />
|
|
108
|
+
{fact.label}
|
|
109
|
+
</span>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** One contributed slot, named in words with its count. */
|
|
114
|
+
export function SlotBadge({ item, declared }: { item: PluginContribution; declared: boolean }) {
|
|
115
|
+
return (
|
|
116
|
+
<span
|
|
117
|
+
className={`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] ${
|
|
118
|
+
declared
|
|
119
|
+
? 'border border-dashed border-ink/25 text-ink/45'
|
|
120
|
+
: 'bg-ink/10 text-ink/65'
|
|
121
|
+
}`}
|
|
122
|
+
title={declared ? `${item.detail} (declared by the manifest — its bundle has not registered it)` : item.detail}
|
|
123
|
+
>
|
|
124
|
+
{item.label}
|
|
125
|
+
{item.count > 1 ? <span className="font-mono text-ink/50">×{item.count}</span> : null}
|
|
126
|
+
{item.title ? <span className="text-ink/40 truncate max-w-[9rem]">· {item.title}</span> : null}
|
|
127
|
+
</span>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The slots a plugin contributes, wrapped so a narrow card still reads.
|
|
133
|
+
*
|
|
134
|
+
* `declared` is the whole point of the dashed variant: a manifest's claim is not
|
|
135
|
+
* the same fact as a live registration, and a reader who is deciding whether to
|
|
136
|
+
* switch a plugin on needs to know which one they are looking at.
|
|
137
|
+
*/
|
|
138
|
+
export function SlotBadges({ items, declared }: { items: PluginContribution[]; declared: boolean }) {
|
|
139
|
+
if (items.length === 0) return null;
|
|
140
|
+
return (
|
|
141
|
+
<div className="flex flex-wrap items-center gap-1">
|
|
142
|
+
{items.map((item) => (
|
|
143
|
+
<SlotBadge key={item.key} item={item} declared={declared} />
|
|
144
|
+
))}
|
|
145
|
+
</div>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** A label/value pair for the facts strip. `value` may be a node. */
|
|
150
|
+
export function Fact({ label, children }: { label: string; children: ComponentChildren }) {
|
|
151
|
+
return (
|
|
152
|
+
<span className="flex items-baseline gap-1 min-w-0">
|
|
153
|
+
<span className="text-[10px] uppercase tracking-wide text-ink/35 flex-shrink-0">{label}</span>
|
|
154
|
+
<span className="text-[10px] text-ink/60 truncate min-w-0">{children}</span>
|
|
155
|
+
</span>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The placement control a panel's own card carries.
|
|
8
|
+
*
|
|
9
|
+
* A plugin registers a SLOT, never a column — `app.rightPanel(...)` is a view
|
|
10
|
+
* with a button, and the user decides whether that button sits on the left dock
|
|
11
|
+
* or in the right column. The card therefore has to show where the panel is now
|
|
12
|
+
* and offer the move, and three failures each read as a different true
|
|
13
|
+
* statement:
|
|
14
|
+
*
|
|
15
|
+
* - a chip for a destination the slot cannot use offers a move the store
|
|
16
|
+
* refuses, so the button does nothing and looks broken;
|
|
17
|
+
* - the current destination left ENABLED invites a click that changes nothing;
|
|
18
|
+
* - a takeover given a chip row implies a choice it does not have (the editor
|
|
19
|
+
* column is its only home), which is a control that can never act.
|
|
20
|
+
*
|
|
21
|
+
* The move goes through the dock's store, which is what turns the rail on — so
|
|
22
|
+
* the assertion is on the store's state, not on a component's local flag.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
26
|
+
import { Window } from 'happy-dom';
|
|
27
|
+
import { h, render } from 'preact';
|
|
28
|
+
import { act } from 'preact/test-utils';
|
|
29
|
+
import { PlacementChips } from '@/client/components/settings/categories/panel-plugins/Placement';
|
|
30
|
+
import { pluginPanelKey } from '@/shared/lib/workspace/panel-ids';
|
|
31
|
+
import { readLeftDock, writeLeftDock } from '@/shared/lib/workspace/left-dock';
|
|
32
|
+
import type { LeftDockHandle } from '@/client/hooks/workspace/left-dock';
|
|
33
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
34
|
+
|
|
35
|
+
let container: HTMLElement;
|
|
36
|
+
|
|
37
|
+
beforeAll(() => {
|
|
38
|
+
installDomGlobals(new Window({ url: 'http://localhost' }));
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
afterEach(() => {
|
|
42
|
+
if (container) render(null, container);
|
|
43
|
+
writeLeftDock({ enabled: false, panels: [] });
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
afterAll(() => {
|
|
47
|
+
restoreDomGlobals();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The dock's real store behind a handle, so a click is observed where the layout
|
|
52
|
+
* reads it — a stubbed `setSide` would prove the button calls a function, not
|
|
53
|
+
* that the panel moved.
|
|
54
|
+
*/
|
|
55
|
+
function dockHandle(): LeftDockHandle {
|
|
56
|
+
return {
|
|
57
|
+
...readLeftDock(),
|
|
58
|
+
setEnabled: (enabled) => writeLeftDock({ enabled }),
|
|
59
|
+
setSide: (panelId, side) => {
|
|
60
|
+
const state = readLeftDock();
|
|
61
|
+
if (side === 'left') {
|
|
62
|
+
writeLeftDock({
|
|
63
|
+
enabled: true,
|
|
64
|
+
panels: state.panels.includes(panelId) ? state.panels : [...state.panels, panelId],
|
|
65
|
+
});
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
writeLeftDock({ panels: state.panels.filter((id) => id !== panelId) });
|
|
69
|
+
},
|
|
70
|
+
widthOf: () => 320,
|
|
71
|
+
commitWidth: () => {},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Mount one element and return the container. */
|
|
76
|
+
function mount(node: h.JSX.Element): HTMLElement {
|
|
77
|
+
container = document.createElement('div');
|
|
78
|
+
document.body.append(container);
|
|
79
|
+
act(() => render(node, container));
|
|
80
|
+
return container;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** The chips' buttons, by their short label. */
|
|
84
|
+
function chip(el: HTMLElement, label: 'Left' | 'Right'): HTMLButtonElement | undefined {
|
|
85
|
+
return [...el.querySelectorAll('button')].find((b) => b.textContent?.trim() === label) as
|
|
86
|
+
| HTMLButtonElement
|
|
87
|
+
| undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
describe('PlacementChips', () => {
|
|
91
|
+
test('a rightPanel offers both destinations, with the current one marked', () => {
|
|
92
|
+
const el = mount(
|
|
93
|
+
h(PlacementChips, { name: 'Stats', pluginId: 'stats', slot: 'rightPanel', dock: dockHandle() }),
|
|
94
|
+
);
|
|
95
|
+
const left = chip(el, 'Left');
|
|
96
|
+
const right = chip(el, 'Right');
|
|
97
|
+
expect(left).toBeDefined();
|
|
98
|
+
expect(right).toBeDefined();
|
|
99
|
+
// Nothing is placed, so the right column is where it is.
|
|
100
|
+
expect(right?.disabled).toBe(true);
|
|
101
|
+
expect(right?.getAttribute('aria-pressed')).toBe('true');
|
|
102
|
+
expect(left?.disabled).toBe(false);
|
|
103
|
+
expect(left?.getAttribute('aria-label')).toBe('Move Stats to the left dock');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('moving to the left writes the dock, and turns its rail on', () => {
|
|
107
|
+
const dock = dockHandle();
|
|
108
|
+
const el = mount(h(PlacementChips, { name: 'Stats', pluginId: 'stats', slot: 'rightPanel', dock }));
|
|
109
|
+
act(() => chip(el, 'Left')?.click());
|
|
110
|
+
|
|
111
|
+
const key = pluginPanelKey('stats', 'rightPanel');
|
|
112
|
+
expect(readLeftDock().panels).toEqual([key]);
|
|
113
|
+
// A placement with the rail off is a move with no button and no way back —
|
|
114
|
+
// the store couples them, and this is what proves the card goes through it.
|
|
115
|
+
expect(readLeftDock().enabled).toBe(true);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('the current destination is disabled, so a chip cannot re-place what is placed', () => {
|
|
119
|
+
const key = pluginPanelKey('stats', 'rightPanel');
|
|
120
|
+
writeLeftDock({ enabled: true, panels: [key] });
|
|
121
|
+
const el = mount(
|
|
122
|
+
h(PlacementChips, { name: 'Stats', pluginId: 'stats', slot: 'rightPanel', dock: dockHandle() }),
|
|
123
|
+
);
|
|
124
|
+
expect(chip(el, 'Left')?.disabled).toBe(true);
|
|
125
|
+
expect(chip(el, 'Left')?.getAttribute('aria-pressed')).toBe('true');
|
|
126
|
+
expect(chip(el, 'Right')?.disabled).toBe(false);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test('a takeover gets no chips — the editor column is its only home', () => {
|
|
130
|
+
const el = mount(
|
|
131
|
+
h(PlacementChips, { name: 'Scratchpad', pluginId: 'session-info', slot: 'panel', dock: dockHandle() }),
|
|
132
|
+
);
|
|
133
|
+
expect(el.querySelectorAll('button')).toHaveLength(0);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test('a second plugin panel is placed independently of the first', () => {
|
|
137
|
+
const dock = dockHandle();
|
|
138
|
+
const first = mount(
|
|
139
|
+
h(PlacementChips, { name: 'A', pluginId: 'a', slot: 'rightPanel', dock }),
|
|
140
|
+
);
|
|
141
|
+
act(() => chip(first, 'Left')?.click());
|
|
142
|
+
const second = mount(
|
|
143
|
+
h(PlacementChips, { name: 'B', pluginId: 'b', slot: 'rightPanel', dock }),
|
|
144
|
+
);
|
|
145
|
+
// B is still on the right: one plugin's placement must not drag another's.
|
|
146
|
+
expect(chip(second, 'Right')?.disabled).toBe(true);
|
|
147
|
+
expect(readLeftDock().panels).toEqual([pluginPanelKey('a', 'rightPanel')]);
|
|
148
|
+
});
|
|
149
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Where a contributed panel is drawn, and the control that moves it.
|
|
8
|
+
*
|
|
9
|
+
* A plugin registers a SLOT, never a column: `app.rightPanel(...)` is a view
|
|
10
|
+
* with its own button, and the USER decides whether that button lives on the
|
|
11
|
+
* left dock or in the right column. So a card that said only "right panel" was
|
|
12
|
+
* describing the registration and misdescribing the screen — a plugin sitting on
|
|
13
|
+
* the left dock read as if it were on the right.
|
|
14
|
+
*
|
|
15
|
+
* The rule is the slot's (`ridesSides`), never a per-call-site copy: a
|
|
16
|
+
* `rightPanel` rides left or right, a `panel` takeover rides the editor column
|
|
17
|
+
* and nothing else. A destination the slot cannot use is not offered, because a
|
|
18
|
+
* button that would be refused is worse than no button.
|
|
19
|
+
*
|
|
20
|
+
* The control is the same one the Panel placement section draws — one button per
|
|
21
|
+
* destination, the current one disabled — so a card and that section cannot
|
|
22
|
+
* teach two different gestures for one operation. It writes through the dock's
|
|
23
|
+
* own store, which is what turns the rail on when a panel is placed on the left.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { Columns2, PanelLeft, PanelRight } from 'lucide-preact';
|
|
27
|
+
import { panelSideOf, ridesSides, type PanelSide } from '@/shared/lib/workspace/left-dock';
|
|
28
|
+
import { pluginPanelKey, type PluginPanelSlot } from '@/shared/lib/workspace/panel-ids';
|
|
29
|
+
import type { LeftDockHandle } from '@/client/hooks/workspace/left-dock';
|
|
30
|
+
|
|
31
|
+
/** What each destination is called on a button, in a card and in the settings row. */
|
|
32
|
+
export const SIDE_LABEL: Record<PanelSide, string> = {
|
|
33
|
+
left: 'left dock',
|
|
34
|
+
right: 'right column',
|
|
35
|
+
editor: 'editor column',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** The short form a chip shows. */
|
|
39
|
+
const SIDE_SHORT: Record<PanelSide, string> = { left: 'Left', right: 'Right', editor: 'Editor' };
|
|
40
|
+
|
|
41
|
+
const SIDE_GLYPH: Record<PanelSide, typeof PanelLeft> = {
|
|
42
|
+
left: PanelLeft,
|
|
43
|
+
right: PanelRight,
|
|
44
|
+
editor: Columns2,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
interface PlacementChipsProps {
|
|
48
|
+
/** The panel's title, for the buttons' accessible names. */
|
|
49
|
+
name: string;
|
|
50
|
+
/** The plugin the panel belongs to. */
|
|
51
|
+
pluginId: string;
|
|
52
|
+
/** The slot it registered, which decides where it may go. */
|
|
53
|
+
slot: PluginPanelSlot;
|
|
54
|
+
/** The dock's handle, so a move goes through the store that owns placement. */
|
|
55
|
+
dock: LeftDockHandle;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The destinations one panel may be moved to, with the current one marked.
|
|
60
|
+
*
|
|
61
|
+
* Rendered only when there is a CHOICE. A takeover's only home is the editor
|
|
62
|
+
* column, and a chip row of one disabled button is a control that can never do
|
|
63
|
+
* anything — the badge beside it already says what the panel is.
|
|
64
|
+
*/
|
|
65
|
+
export function PlacementChips({ name, pluginId, slot, dock }: PlacementChipsProps) {
|
|
66
|
+
const destinations = ridesSides(slot);
|
|
67
|
+
if (destinations.length < 2) return null;
|
|
68
|
+
|
|
69
|
+
const key = pluginPanelKey(pluginId, slot);
|
|
70
|
+
const current = panelSideOf(key, dock);
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<span className="flex items-center gap-0.5 flex-shrink-0" data-placement-for={key}>
|
|
74
|
+
{destinations.map((side) => {
|
|
75
|
+
const Glyph = SIDE_GLYPH[side];
|
|
76
|
+
const here = side === current;
|
|
77
|
+
return (
|
|
78
|
+
<button
|
|
79
|
+
key={side}
|
|
80
|
+
type="button"
|
|
81
|
+
disabled={here}
|
|
82
|
+
onClick={() => dock.setSide(key, side)}
|
|
83
|
+
title={here ? `${name} is on the ${SIDE_LABEL[side]}` : `Move ${name} to the ${SIDE_LABEL[side]}`}
|
|
84
|
+
aria-label={here ? `${name} is on the ${SIDE_LABEL[side]}` : `Move ${name} to the ${SIDE_LABEL[side]}`}
|
|
85
|
+
aria-pressed={here}
|
|
86
|
+
className={`flex items-center gap-0.5 px-1 py-0.5 rounded border text-[10px] transition-colors ${
|
|
87
|
+
here
|
|
88
|
+
? 'border-ink/30 bg-ink/10 text-ink/50 cursor-default'
|
|
89
|
+
: 'border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink cursor-pointer'
|
|
90
|
+
}`}
|
|
91
|
+
>
|
|
92
|
+
<Glyph size={10} />
|
|
93
|
+
{SIDE_SHORT[side]}
|
|
94
|
+
</button>
|
|
95
|
+
);
|
|
96
|
+
})}
|
|
97
|
+
</span>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One INSTALLED panel plugin, as a card.
|
|
8
|
+
*
|
|
9
|
+
* The card answers five questions in the order a reader asks them: what is this
|
|
10
|
+
* (mark, name, id), which version am I running and is there a newer one, who
|
|
11
|
+
* wrote it and where did it come from, what does it actually add, and what can I
|
|
12
|
+
* do about it. Every one of those had a different home before — the version in a
|
|
13
|
+
* 10px corner, the origin nowhere, the contributions a single raw slot name —
|
|
14
|
+
* so a plugin could be installed, enabled and silently inert with nothing on
|
|
15
|
+
* screen saying why.
|
|
16
|
+
*
|
|
17
|
+
* The switch is the primary control and sits where a card's action belongs. The
|
|
18
|
+
* rest are icon buttons in the footer, and each one only appears when it can do
|
|
19
|
+
* something: Rebuild only for an unbuilt bundle, Update only for a clone behind
|
|
20
|
+
* its remote, README only when the plugin ships one.
|
|
21
|
+
*
|
|
22
|
+
* Its own file because the card grew past what the grid could hold and because
|
|
23
|
+
* the AVAILABLE (store) card is the same shape with a different footer — the two
|
|
24
|
+
* now share the version, author, origin and slot pieces in `Meta.tsx`.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { Hammer, Loader2, BookOpen } from 'lucide-preact';
|
|
28
|
+
import type { PanelGitStatus, PanelPluginStatus } from '@/shared/types';
|
|
29
|
+
import { PluginMark } from '@/client/components/settings/categories/panel-plugins/PluginMark';
|
|
30
|
+
import { RemovePluginButton } from '@/client/components/settings/categories/panel-plugins/InstallForm';
|
|
31
|
+
import { GitFreshness } from '@/client/components/settings/categories/panel-plugins/GitFreshness';
|
|
32
|
+
import {
|
|
33
|
+
AuthorLine,
|
|
34
|
+
Fact,
|
|
35
|
+
OriginBadge,
|
|
36
|
+
SlotBadge,
|
|
37
|
+
VersionLine,
|
|
38
|
+
} from '@/client/components/settings/categories/panel-plugins/Meta';
|
|
39
|
+
import { PlacementChips } from '@/client/components/settings/categories/panel-plugins/Placement';
|
|
40
|
+
import {
|
|
41
|
+
contributionBadges,
|
|
42
|
+
usePluginContributions,
|
|
43
|
+
} from '@/client/hooks/workspace/plugin-contributions';
|
|
44
|
+
import type { PluginSlots } from '@/client/lib/plugins/slots';
|
|
45
|
+
import { isPluginPanelSlot, pluginEnablementKey } from '@/shared/lib/workspace/panel-ids';
|
|
46
|
+
import type { LeftDockHandle } from '@/client/hooks/workspace/left-dock';
|
|
47
|
+
|
|
48
|
+
interface PluginCardProps {
|
|
49
|
+
plugin: PanelPluginStatus;
|
|
50
|
+
/** Registrations, once the plugin's bundle has loaded. */
|
|
51
|
+
entry: PluginSlots | undefined;
|
|
52
|
+
/** Why the plugin's bundle could not load, when it could not. */
|
|
53
|
+
failure: string | undefined;
|
|
54
|
+
iconUrl: string | undefined;
|
|
55
|
+
readmeUrl: string | undefined;
|
|
56
|
+
busy: string | null;
|
|
57
|
+
gitStatus: PanelGitStatus | undefined;
|
|
58
|
+
/** Panel placement, so a panel's own card can say (and change) where it lives. */
|
|
59
|
+
dock: LeftDockHandle;
|
|
60
|
+
onReadme: () => void;
|
|
61
|
+
onBuild: (pluginId: string) => Promise<boolean>;
|
|
62
|
+
onRemove: (pluginId: string) => Promise<boolean>;
|
|
63
|
+
onSetEnabled: (pluginId: string, enabled: boolean) => Promise<boolean>;
|
|
64
|
+
onUpdateGit: (pluginId: string) => Promise<boolean>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function PluginCard({
|
|
68
|
+
plugin,
|
|
69
|
+
entry,
|
|
70
|
+
failure,
|
|
71
|
+
iconUrl,
|
|
72
|
+
readmeUrl,
|
|
73
|
+
busy,
|
|
74
|
+
gitStatus,
|
|
75
|
+
dock,
|
|
76
|
+
onReadme,
|
|
77
|
+
onBuild,
|
|
78
|
+
onRemove,
|
|
79
|
+
onSetEnabled,
|
|
80
|
+
onUpdateGit,
|
|
81
|
+
}: PluginCardProps) {
|
|
82
|
+
// The ENABLEMENT key is the panel key, not the plugin id: it is the id the
|
|
83
|
+
// client filters its panel catalog by, so a switch that wrote the bare id
|
|
84
|
+
// would report success while the panel stayed hidden.
|
|
85
|
+
const panelKey = pluginEnablementKey(plugin.pluginId);
|
|
86
|
+
const toggling = busy === `enable:${panelKey}` || busy === `disable:${panelKey}`;
|
|
87
|
+
const contributions = usePluginContributions(plugin.pluginId);
|
|
88
|
+
const badges = contributionBadges(contributions, plugin.slots);
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<article
|
|
92
|
+
className={`flex flex-col gap-2 border rounded-lg p-3 transition-colors ${
|
|
93
|
+
plugin.enabled ? 'border-ink/10 bg-paper' : 'border-ink/10 bg-ink/[0.02]'
|
|
94
|
+
}`}
|
|
95
|
+
>
|
|
96
|
+
<header className="flex items-start gap-2.5">
|
|
97
|
+
<div className={plugin.enabled ? '' : 'opacity-50'}>
|
|
98
|
+
<PluginMark name={plugin.name} iconUrl={iconUrl} />
|
|
99
|
+
</div>
|
|
100
|
+
<div className="min-w-0 flex-1">
|
|
101
|
+
<div className="flex items-center gap-1.5 min-w-0">
|
|
102
|
+
<span className="text-xs font-medium text-ink truncate" title={plugin.name}>
|
|
103
|
+
{plugin.name}
|
|
104
|
+
</span>
|
|
105
|
+
{!plugin.built ? (
|
|
106
|
+
<span className="text-[10px] px-1 rounded bg-warning/15 text-warning border border-warning/25 flex-shrink-0">
|
|
107
|
+
not built
|
|
108
|
+
</span>
|
|
109
|
+
) : null}
|
|
110
|
+
</div>
|
|
111
|
+
<div className="flex items-center gap-1.5 min-w-0">
|
|
112
|
+
<span className="text-[11px] text-ink/45 font-mono truncate" title={plugin.pluginId}>
|
|
113
|
+
{plugin.pluginId}
|
|
114
|
+
</span>
|
|
115
|
+
<VersionLine version={plugin.version} latest={plugin.latestVersion} />
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
<button
|
|
119
|
+
type="button"
|
|
120
|
+
role="switch"
|
|
121
|
+
aria-checked={plugin.enabled}
|
|
122
|
+
aria-label={`${plugin.enabled ? 'Disable' : 'Enable'} ${plugin.name}`}
|
|
123
|
+
disabled={busy !== null}
|
|
124
|
+
onClick={() => void onSetEnabled(panelKey, !plugin.enabled)}
|
|
125
|
+
title={plugin.enabled ? 'Disable — keep the files, remove its buttons' : 'Enable this plugin'}
|
|
126
|
+
className={`relative w-8 h-4 rounded-full transition-colors flex-shrink-0 mt-0.5 disabled:opacity-40 ${
|
|
127
|
+
plugin.enabled ? 'bg-ink/70' : 'bg-ink/20'
|
|
128
|
+
}`}
|
|
129
|
+
>
|
|
130
|
+
{toggling ? (
|
|
131
|
+
<Loader2 size={9} className="absolute inset-0 m-auto animate-spin text-canvas" />
|
|
132
|
+
) : (
|
|
133
|
+
<span
|
|
134
|
+
className={`absolute top-0.5 w-3 h-3 rounded-full bg-canvas transition-all ${
|
|
135
|
+
plugin.enabled ? 'left-[18px]' : 'left-0.5'
|
|
136
|
+
}`}
|
|
137
|
+
/>
|
|
138
|
+
)}
|
|
139
|
+
</button>
|
|
140
|
+
</header>
|
|
141
|
+
|
|
142
|
+
{plugin.description ? (
|
|
143
|
+
<p className="text-[11px] text-ink/60 leading-relaxed line-clamp-2">{plugin.description}</p>
|
|
144
|
+
) : null}
|
|
145
|
+
|
|
146
|
+
<div className="flex items-center gap-2 flex-wrap">
|
|
147
|
+
<OriginBadge origin={plugin.origin} />
|
|
148
|
+
<AuthorLine author={plugin.author} />
|
|
149
|
+
{plugin.settingsCount ? (
|
|
150
|
+
<Fact label="settings">{plugin.settingsCount}</Fact>
|
|
151
|
+
) : null}
|
|
152
|
+
{plugin.homepage ? (
|
|
153
|
+
<a
|
|
154
|
+
href={plugin.homepage}
|
|
155
|
+
target="_blank"
|
|
156
|
+
rel="noreferrer noopener"
|
|
157
|
+
className="ml-auto text-[10px] text-ink/45 hover:text-ink truncate max-w-[10rem]"
|
|
158
|
+
title={plugin.homepage}
|
|
159
|
+
>
|
|
160
|
+
{hostOf(plugin.homepage)}
|
|
161
|
+
</a>
|
|
162
|
+
) : null}
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
{/* Four distinct states, and the difference matters: a plugin that is
|
|
166
|
+
switched off has no components BY DESIGN, one whose bundle failed has a
|
|
167
|
+
reason to show, one that is still loading is neither, and one that
|
|
168
|
+
loaded says what it contributes. */}
|
|
169
|
+
{!plugin.enabled ? (
|
|
170
|
+
<p className="text-[11px] text-ink/45">
|
|
171
|
+
Disabled — contributes nothing while the switch is off.
|
|
172
|
+
{badges.fromDeclaration ? ' The slots below are what its manifest declares.' : ''}
|
|
173
|
+
</p>
|
|
174
|
+
) : failure ? (
|
|
175
|
+
<p className="text-[11px] text-error leading-snug">Bundle failed to load — {failure}</p>
|
|
176
|
+
) : !entry ? (
|
|
177
|
+
<p className="text-[11px] text-ink/45">Loading bundle…</p>
|
|
178
|
+
) : badges.items.length === 0 ? (
|
|
179
|
+
<p className="text-[11px] text-ink/45">Loaded, but registers nothing — no panel, no button, no hook.</p>
|
|
180
|
+
) : null}
|
|
181
|
+
|
|
182
|
+
{/* The badges name what the plugin contributes; a PANEL one also carries
|
|
183
|
+
its placement, because a plugin registers a slot and never a column.
|
|
184
|
+
A card that said only "panel view" would misdescribe the screen for a
|
|
185
|
+
panel the user has already moved to the left dock. Chips are drawn
|
|
186
|
+
only for a LIVE registration: a declared-only row names a panel the
|
|
187
|
+
host never received, so there is nothing to place. */}
|
|
188
|
+
{badges.items.length > 0 ? (
|
|
189
|
+
<div className="flex flex-wrap items-center gap-x-2 gap-y-1">
|
|
190
|
+
{badges.items.map((item) => (
|
|
191
|
+
<span key={item.key} className="flex items-center gap-1">
|
|
192
|
+
<SlotBadge item={item} declared={badges.fromDeclaration} />
|
|
193
|
+
{!badges.fromDeclaration && isPluginPanelSlot(item.key) ? (
|
|
194
|
+
<PlacementChips
|
|
195
|
+
name={item.title ?? plugin.name}
|
|
196
|
+
pluginId={plugin.pluginId}
|
|
197
|
+
slot={item.key}
|
|
198
|
+
dock={dock}
|
|
199
|
+
/>
|
|
200
|
+
) : null}
|
|
201
|
+
</span>
|
|
202
|
+
))}
|
|
203
|
+
</div>
|
|
204
|
+
) : null}
|
|
205
|
+
|
|
206
|
+
{!plugin.built ? (
|
|
207
|
+
<p className="text-[11px] text-warning">
|
|
208
|
+
Not built{plugin.reason ? ` — ${plugin.reason}` : ''}. The bundle will 404 until it is built.
|
|
209
|
+
</p>
|
|
210
|
+
) : null}
|
|
211
|
+
|
|
212
|
+
{/* A git-installed plugin's freshness. Rendered for a clone only — a
|
|
213
|
+
bundled install is kept current by Kabmo's own update, so a git row
|
|
214
|
+
there would describe a remote it does not have. */}
|
|
215
|
+
{plugin.gitOrigin ? (
|
|
216
|
+
<GitFreshness
|
|
217
|
+
status={gitStatus}
|
|
218
|
+
origin={plugin.gitOrigin}
|
|
219
|
+
busy={busy}
|
|
220
|
+
pluginId={plugin.pluginId}
|
|
221
|
+
onUpdate={onUpdateGit}
|
|
222
|
+
latestVersion={plugin.latestVersion}
|
|
223
|
+
/>
|
|
224
|
+
) : null}
|
|
225
|
+
|
|
226
|
+
<footer className="mt-auto flex items-center gap-1.5 pt-1">
|
|
227
|
+
{!plugin.built ? (
|
|
228
|
+
<button
|
|
229
|
+
type="button"
|
|
230
|
+
onClick={() => void onBuild(plugin.pluginId)}
|
|
231
|
+
disabled={busy !== null}
|
|
232
|
+
title={plugin.reason ? `Rebuild — ${plugin.reason}` : 'Rebuild this plugin'}
|
|
233
|
+
className="flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded border border-warning/40 text-warning hover:bg-warning/10 disabled:opacity-40"
|
|
234
|
+
>
|
|
235
|
+
{busy === `build:${plugin.pluginId}` ? (
|
|
236
|
+
<Loader2 size={11} className="animate-spin" />
|
|
237
|
+
) : (
|
|
238
|
+
<Hammer size={11} />
|
|
239
|
+
)}
|
|
240
|
+
Rebuild
|
|
241
|
+
</button>
|
|
242
|
+
) : null}
|
|
243
|
+
{plugin.gitOrigin && gitStatus?.updateAvailable ? null : null}
|
|
244
|
+
<span className="ml-auto flex items-center gap-1">
|
|
245
|
+
{readmeUrl ? (
|
|
246
|
+
<button
|
|
247
|
+
type="button"
|
|
248
|
+
onClick={onReadme}
|
|
249
|
+
title={`Read ${plugin.name}'s README`}
|
|
250
|
+
aria-label={`Read ${plugin.name}'s README`}
|
|
251
|
+
className="p-1 rounded text-ink/40 hover:text-ink hover:bg-ink/5 flex-shrink-0"
|
|
252
|
+
>
|
|
253
|
+
<BookOpen size={13} />
|
|
254
|
+
</button>
|
|
255
|
+
) : null}
|
|
256
|
+
<RemovePluginButton pluginId={plugin.pluginId} disabled={busy !== null} onRemove={onRemove} />
|
|
257
|
+
</span>
|
|
258
|
+
</footer>
|
|
259
|
+
</article>
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** The host of a homepage URL, so a footer link reads as a name rather than a URL. */
|
|
264
|
+
function hostOf(url: string): string {
|
|
265
|
+
try {
|
|
266
|
+
return new URL(url).host.replace(/^www\./, '');
|
|
267
|
+
} catch {
|
|
268
|
+
return url;
|
|
269
|
+
}
|
|
270
|
+
}
|