@firstpick/pi-package-webui 0.11.0 → 0.11.2
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/DEVELOPMENT.md +181 -12
- package/README.md +41 -9
- package/TECHNICAL.md +91 -8
- package/bin/pi-webui.mjs +5432 -11428
- package/index.ts +10 -3
- package/lib/codex-cli-usage.mjs +232 -0
- package/lib/codex-usage-auth.mjs +39 -3
- package/lib/codex-usage-source.mjs +36 -0
- package/lib/component-update-state.mjs +2 -2
- package/lib/git-workflow-preference-values.mjs +122 -0
- package/lib/git-workflow-preferences.mjs +35 -563
- package/lib/package-updates.mjs +260 -0
- package/lib/rpc-supervisor-client.mjs +8 -4
- package/lib/server/app-runners.mjs +1667 -0
- package/lib/server/codex-fast-mode.mjs +161 -0
- package/lib/server/conversation-mode.mjs +218 -0
- package/lib/server/conversation-voice.mjs +318 -0
- package/lib/server/extension-ui-requests.mjs +114 -0
- package/lib/server/git-generation.mjs +459 -0
- package/lib/server/git-mutations.mjs +1827 -0
- package/lib/server/git-reads.mjs +608 -0
- package/lib/server/git-worktree-sessions.mjs +408 -0
- package/lib/server/helper-requests.mjs +82 -0
- package/lib/server/no-project-workspaces.mjs +103 -0
- package/lib/server/rpc-transports.mjs +394 -0
- package/lib/server/settings-store.mjs +544 -0
- package/lib/server/sse-delivery.mjs +138 -0
- package/lib/server/workspace-files.mjs +563 -0
- package/lib/update/supervisor.mjs +4 -0
- package/lib/webui-workspaces.mjs +2 -0
- package/package.json +5 -5
- package/public/activity-agents-controller.mjs +269 -0
- package/public/activity-events-controller.mjs +236 -0
- package/public/activity-intercom-controller.mjs +627 -0
- package/public/activity-queue-controller.mjs +534 -0
- package/public/activity-todo-view.mjs +89 -0
- package/public/activity-usage-controller.mjs +589 -0
- package/public/app.js +3761 -3878
- package/public/conversation-overview.css +84 -0
- package/public/conversation-overview.mjs +193 -0
- package/public/draft-conversations.mjs +135 -0
- package/public/focused-composer-controls.css +111 -0
- package/public/focused-composer-controls.mjs +143 -0
- package/public/focused-composer-disclosure.mjs +223 -0
- package/public/focused-shell-adapter.css +264 -0
- package/public/focused-shell-adapter.mjs +257 -0
- package/public/index.html +137 -80
- package/public/model-catalog-order.mjs +63 -0
- package/public/platform-event-stream.mjs +64 -0
- package/public/project-artifact-controller.mjs +218 -0
- package/public/project-file-viewer-controller.mjs +383 -0
- package/public/project-git-tools-controller.mjs +181 -0
- package/public/project-runners-controller.mjs +220 -0
- package/public/service-worker.js +52 -1
- package/public/session-attention-scheduler.mjs +182 -0
- package/public/session-composer-store.mjs +56 -0
- package/public/session-context.mjs +51 -0
- package/public/session-extension-requests.mjs +63 -0
- package/public/session-shelf-state.mjs +151 -0
- package/public/session-shelves.css +171 -0
- package/public/session-shelves.mjs +95 -0
- package/public/settings-navigation-controller.mjs +249 -0
- package/public/settings-navigation.css +61 -0
- package/public/settings-resource-controller.mjs +232 -0
- package/public/settings-workspace.css +19 -0
- package/public/settings-workspace.mjs +175 -0
- package/public/shell-actions.mjs +87 -0
- package/public/shell-attention-inbox.css +72 -0
- package/public/shell-attention-inbox.mjs +198 -0
- package/public/shell-context-actions.css +61 -0
- package/public/shell-context-actions.mjs +168 -0
- package/public/shell-inspector-resize.mjs +124 -0
- package/public/shell-navigation-resize.mjs +107 -0
- package/public/shell-navigation.mjs +127 -0
- package/public/shell-preferences.mjs +108 -0
- package/public/shell-surfaces.mjs +99 -0
- package/public/shell-tools-launcher.css +97 -0
- package/public/shell-tools-launcher.mjs +222 -0
- package/public/shell-view-host.mjs +115 -0
- package/public/shell-workspace.css +266 -0
- package/public/shell-workspace.mjs +402 -0
- package/public/sidebar-update-menu.css +190 -0
- package/public/sidebar-update-menu.mjs +512 -0
- package/public/styles.css +320 -169
- package/public/subagent-launch-slot-state.mjs +2 -2
- package/public/theme-contract.mjs +1 -1
- package/public/themed-selects.css +156 -0
- package/public/workspace-choices.mjs +104 -0
- package/tests/activity-agents-controller.test.mjs +652 -0
- package/tests/activity-events-controller.test.mjs +511 -0
- package/tests/app-runner-terminal-static.test.mjs +3 -3
- package/tests/append-system-http.test.mjs +7 -6
- package/tests/append-system-selector-static.test.mjs +6 -6
- package/tests/aur-review-widget-static.test.mjs +11 -3
- package/tests/boot-failure-diagnostics.test.mjs +8 -3
- package/tests/browser/activity-intercom-controller.spec.mjs +457 -0
- package/tests/browser/activity-navigation-integration.spec.mjs +45 -0
- package/tests/browser/activity-owner-integration.spec.mjs +201 -0
- package/tests/browser/activity-queue-controller.spec.mjs +405 -0
- package/tests/browser/activity-section-picker.spec.mjs +294 -0
- package/tests/browser/activity-todo-view.spec.mjs +60 -0
- package/tests/browser/activity-usage-controller.spec.mjs +416 -0
- package/tests/browser/compact-layout-integration.spec.mjs +58 -0
- package/tests/browser/composer-action-grid-reorder.spec.mjs +16 -0
- package/tests/browser/composer-disclosure.spec.mjs +389 -0
- package/tests/browser/composer-toolbar-polish.spec.mjs +343 -0
- package/tests/browser/control-deck-component-updates.spec.mjs +5 -14
- package/tests/browser/control-deck-side-panels.spec.mjs +27 -12
- package/tests/browser/control-visibility.spec.mjs +5 -0
- package/tests/browser/controls-layout.spec.mjs +21 -2
- package/tests/browser/conversation-overview.spec.mjs +251 -0
- package/tests/browser/draft-conversations.spec.mjs +276 -0
- package/tests/browser/empty-startup-fixture.mjs +135 -0
- package/tests/browser/empty-startup.spec.mjs +282 -0
- package/tests/browser/events-tree-context-menu.spec.mjs +1 -0
- package/tests/browser/focused-composer-more.spec.mjs +127 -0
- package/tests/browser/focused-model-shortcuts.spec.mjs +120 -0
- package/tests/browser/focused-navigation-fixture.mjs +32 -0
- package/tests/browser/focused-project-activity.spec.mjs +111 -0
- package/tests/browser/focused-shell-integration.spec.mjs +208 -0
- package/tests/browser/folder-picker-layout-fixture.mjs +13 -0
- package/tests/browser/folder-picker-layout.spec.mjs +302 -0
- package/tests/browser/footer-model-advanced-layout.spec.mjs +27 -14
- package/tests/browser/git-setup-cancel.spec.mjs +251 -0
- package/tests/browser/guided-git-fallback.spec.mjs +40 -21
- package/tests/browser/inspector-header.spec.mjs +221 -0
- package/tests/browser/inspector-overview-integration.spec.mjs +104 -0
- package/tests/browser/inspector-resize.spec.mjs +227 -0
- package/tests/browser/inspector-topic-overflow.spec.mjs +56 -0
- package/tests/browser/interaction-action-discovery.spec.mjs +332 -0
- package/tests/browser/interaction-attention-inbox.spec.mjs +364 -0
- package/tests/browser/interaction-attention-integration.spec.mjs +53 -0
- package/tests/browser/interaction-composer-controls.spec.mjs +267 -0
- package/tests/browser/interaction-composer-integration.spec.mjs +175 -0
- package/tests/browser/interaction-continuity.spec.mjs +50 -26
- package/tests/browser/interaction-model-picker.spec.mjs +86 -0
- package/tests/browser/last-terminal-close.spec.mjs +280 -0
- package/tests/browser/mobile-foundation.spec.mjs +172 -20
- package/tests/browser/model-catalog-groups.spec.mjs +104 -0
- package/tests/browser/more-row-menus.spec.mjs +258 -0
- package/tests/browser/new-tab-hit-target.spec.mjs +228 -0
- package/tests/browser/no-project-conversation.spec.mjs +113 -0
- package/tests/browser/optimistic-prompt.spec.mjs +3 -0
- package/tests/browser/overhaul-w7-accessibility.spec.mjs +227 -0
- package/tests/browser/overhaul-w7-capabilities.spec.mjs +298 -0
- package/tests/browser/overhaul-w7-companions.spec.mjs +290 -0
- package/tests/browser/overhaul-w7-focus-repairs.spec.mjs +210 -0
- package/tests/browser/overhaul-w7-layout-repairs.spec.mjs +183 -0
- package/tests/browser/overhaul-w7-parent-repairs.spec.mjs +97 -0
- package/tests/browser/overhaul-w7-pwa.spec.mjs +247 -0
- package/tests/browser/overhaul-w7-responsive.spec.mjs +450 -0
- package/tests/browser/overhaul-w7-update.spec.mjs +215 -0
- package/tests/browser/overhaul-w7-zoom.spec.mjs +243 -0
- package/tests/browser/overview-agent-ownership.spec.mjs +45 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +3 -0
- package/tests/browser/project-artifact-controller.spec.mjs +324 -0
- package/tests/browser/project-artifact-integration.spec.mjs +103 -0
- package/tests/browser/project-file-buffer-integration.spec.mjs +230 -0
- package/tests/browser/project-git-tools-integration.spec.mjs +369 -0
- package/tests/browser/session-fixture.mjs +118 -0
- package/tests/browser/session-ownership.spec.mjs +175 -0
- package/tests/browser/session-shelves-integration.spec.mjs +219 -0
- package/tests/browser/session-shelves.spec.mjs +340 -0
- package/tests/browser/session-sidebar-resize.spec.mjs +138 -0
- package/tests/browser/session-summary.spec.mjs +17 -12
- package/tests/browser/settings-complete-home.spec.mjs +463 -0
- package/tests/browser/settings-entrypoint.spec.mjs +104 -0
- package/tests/browser/settings-navigation-controller.spec.mjs +383 -0
- package/tests/browser/settings-navigation-integration.spec.mjs +348 -0
- package/tests/browser/settings-resource-lifetime.spec.mjs +349 -0
- package/tests/browser/settings-workspace-integration.spec.mjs +132 -0
- package/tests/browser/shell-ownership.spec.mjs +398 -0
- package/tests/browser/shell-rollout-fixture.mjs +259 -0
- package/tests/browser/shell-rollout.spec.mjs +357 -0
- package/tests/browser/shell-tools-launcher.spec.mjs +260 -0
- package/tests/browser/shell-workspace.spec.mjs +433 -0
- package/tests/browser/side-panel-section-reorder.spec.mjs +3 -1
- package/tests/browser/sidebar-floating-tooltips.spec.mjs +37 -0
- package/tests/browser/sidebar-update-integration.spec.mjs +277 -0
- package/tests/browser/sidebar-update-menu.spec.mjs +402 -0
- package/tests/browser/sidebar-update-progress.spec.mjs +472 -0
- package/tests/browser/stream-output-isolation.spec.mjs +6 -3
- package/tests/browser/themed-selects.spec.mjs +297 -0
- package/tests/browser/thread-start-flow.spec.mjs +481 -0
- package/tests/browser/ui-polish-activity-controls.spec.mjs +177 -0
- package/tests/browser/ui-polish-features.spec.mjs +85 -0
- package/tests/browser/ui-polish-file-header.spec.mjs +43 -0
- package/tests/browser/ui-polish-local-git.spec.mjs +183 -0
- package/tests/browser/ui-polish-mobile-recovery.spec.mjs +36 -0
- package/tests/browser/ui-polish-navigation.spec.mjs +127 -0
- package/tests/browser/ui-polish-session-actions.spec.mjs +282 -0
- package/tests/browser/user-noticeable-fixes.spec.mjs +10 -3
- package/tests/browser/windows-drive-parent.spec.mjs +4 -2
- package/tests/browser/workspace-draft-selection.spec.mjs +266 -0
- package/tests/codex-cli-usage.test.mjs +189 -0
- package/tests/codex-fast-mode-static.test.mjs +16 -11
- package/tests/codex-speed-mode-browser-state.test.mjs +6 -3
- package/tests/codex-usage-auth.test.mjs +168 -9
- package/tests/codex-usage-http.test.mjs +124 -0
- package/tests/codex-usage-source.test.mjs +146 -0
- package/tests/component-update-api-static.test.mjs +2 -2
- package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
- package/tests/control-deck-component-updates-static.test.mjs +9 -4
- package/tests/control-visibility-static.test.mjs +3 -3
- package/tests/controls-layout-static.test.mjs +5 -5
- package/tests/conversation-overview-adapter.test.mjs +100 -0
- package/tests/document-artifact-static.test.mjs +2 -1
- package/tests/draft-conversations.test.mjs +205 -0
- package/tests/empty-startup-launcher.test.mjs +197 -0
- package/tests/events-tree-context-menu-static.test.mjs +22 -18
- package/tests/fake-pi-session-ownership.test.mjs +302 -0
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/feature-system-prompt-optional-feature-static.test.mjs +1 -1
- package/tests/file-viewer-image-static.test.mjs +15 -11
- package/tests/file-viewer-search-static.test.mjs +5 -5
- package/tests/fixtures/fake-codex-app-server.mjs +61 -0
- package/tests/fixtures/fake-pi.mjs +41 -9
- package/tests/footer-provider-usage-visual-static.test.mjs +7 -6
- package/tests/foreground-transcript-catch-up-static.test.mjs +7 -4
- package/tests/git-footer-context-menu-static.test.mjs +1 -1
- package/tests/git-panel-file-preview-static.test.mjs +41 -48
- package/tests/git-panel-live-updates-static.test.mjs +2 -1
- package/tests/git-workflow-dispatch.test.mjs +66 -0
- package/tests/git-workflow-preferences.test.mjs +9 -1
- package/tests/guided-git-activation-static.test.mjs +14 -11
- package/tests/guided-git-fallback-ui-static.test.mjs +8 -5
- package/tests/guided-git-message-reliability-static.test.mjs +10 -6
- package/tests/guided-git-publication-backend-static.test.mjs +16 -11
- package/tests/http-endpoints-harness.test.mjs +29 -9
- package/tests/interaction-state-stability-static.test.mjs +4 -3
- package/tests/intercom-conversation-viewer-static.test.mjs +29 -17
- package/tests/intercom-tag-layout-static.test.mjs +13 -12
- package/tests/intercom-tag-overflow-layout.test.mjs +11 -10
- package/tests/main-output-loading-static.test.mjs +4 -4
- package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
- package/tests/mobile-compact-layout.test.mjs +2 -2
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +10 -7
- package/tests/mobile-phone-experience-static.test.mjs +3 -2
- package/tests/mobile-static.test.mjs +173 -135
- package/tests/model-catalog-order.test.mjs +103 -0
- package/tests/native-parity.test.mjs +6 -4
- package/tests/native-session-choice-owner.test.mjs +102 -0
- package/tests/native-update-lifecycle.test.mjs +10 -5
- package/tests/no-project-http-harness.test.mjs +328 -0
- package/tests/no-project-navigation.test.mjs +54 -0
- package/tests/no-project-workspaces.test.mjs +77 -0
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/optional-feature-migration-frontend.test.mjs +4 -4
- package/tests/optional-feature-prompt-impact-static.test.mjs +3 -3
- package/tests/package-updates.test.mjs +630 -0
- package/tests/persistent-ui-layout-static.test.mjs +3 -3
- package/tests/platform-event-stream.test.mjs +253 -0
- package/tests/project-file-viewer-controller.test.mjs +652 -0
- package/tests/project-git-tools-adapter.test.mjs +103 -0
- package/tests/project-git-tools-controller.test.mjs +577 -0
- package/tests/project-runners-controller.test.mjs +453 -0
- package/tests/prompt-input-vertical-scroll-static.test.mjs +3 -3
- package/tests/prompt-routing-input-clear-static.test.mjs +2 -2
- package/tests/questionnaire-dialog.test.mjs +6 -6
- package/tests/queue-edit-reorder-static.test.mjs +48 -51
- package/tests/rpc-supervisor-host.test.mjs +4 -1
- package/tests/safety-guard-auto-review-static.test.mjs +1 -1
- package/tests/sampling-native-controls-user-flow.test.mjs +7 -1
- package/tests/server-app-runners.test.mjs +536 -0
- package/tests/server-codex-fast-mode.test.mjs +346 -0
- package/tests/server-conversation-mode.test.mjs +386 -0
- package/tests/server-conversation-voice.test.mjs +426 -0
- package/tests/server-extension-ui-requests.test.mjs +357 -0
- package/tests/server-git-generation.test.mjs +558 -0
- package/tests/server-git-mutations.test.mjs +729 -0
- package/tests/server-git-reads.test.mjs +381 -0
- package/tests/server-git-worktree-sessions.test.mjs +502 -0
- package/tests/server-helper-requests.test.mjs +364 -0
- package/tests/server-rpc-transports.test.mjs +553 -0
- package/tests/server-settings-store.test.mjs +132 -0
- package/tests/server-shell-rollout.test.mjs +478 -0
- package/tests/server-sse-delivery.test.mjs +410 -0
- package/tests/server-workspace-files.test.mjs +546 -0
- package/tests/session-attention-scheduler.test.mjs +514 -0
- package/tests/session-composer-store.test.mjs +153 -0
- package/tests/session-context.test.mjs +134 -0
- package/tests/session-extension-requests.test.mjs +193 -0
- package/tests/session-ownership-adapter.test.mjs +130 -0
- package/tests/session-sampling-ui-static.test.mjs +10 -4
- package/tests/session-send-lifetime.test.mjs +140 -0
- package/tests/session-shelf-state.test.mjs +348 -0
- package/tests/session-shelves-adapter.test.mjs +79 -0
- package/tests/session-summary-lifetime.test.mjs +54 -0
- package/tests/settings-resource-controller.test.mjs +548 -0
- package/tests/shell-action-adapter.test.mjs +169 -0
- package/tests/shell-actions.test.mjs +182 -0
- package/tests/shell-navigation.test.mjs +348 -0
- package/tests/shell-preferences.test.mjs +367 -0
- package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
- package/tests/stream-output-isolation-static.test.mjs +1 -1
- package/tests/subagent-gate-visibility.test.mjs +1 -1
- package/tests/subagent-launch-slot-state.test.mjs +2 -2
- package/tests/subagent-launch-slots-static.test.mjs +1 -1
- package/tests/subagent-observability-static.test.mjs +2 -2
- package/tests/subagent-reliability-integration.test.mjs +13 -30
- package/tests/syntax-highlighting-static.test.mjs +3 -3
- package/tests/tab-close-continuity-static.test.mjs +1 -1
- package/tests/tab-metadata-ordering.test.mjs +99 -0
- package/tests/terminal-cwd-grouping-static.test.mjs +2 -2
- package/tests/terminal-tab-prompt-tooltip-static.test.mjs +2 -0
- package/tests/terminal-tab-workspace-static.test.mjs +5 -4
- package/tests/terminal-tabs-resize-static.test.mjs +1 -1
- package/tests/theme-contract.test.mjs +10 -3
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/tests/thread-display-title.test.mjs +44 -0
- package/tests/update-api-harness.test.mjs +15 -14
- package/tests/update-tab-restore-harness.test.mjs +3 -0
- package/tests/webui-settings-locking.test.mjs +2 -2
- package/tests/windows-drive-cwd-picker-static.test.mjs +7 -9
- package/tests/workspace-choices.test.mjs +114 -0
- package/tests/workspace-save-load-static.test.mjs +7 -4
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
let nextNavigatorId = 0;
|
|
2
|
+
const QUERY_LIMIT = 256;
|
|
3
|
+
const RESULT_LIMIT = 100;
|
|
4
|
+
|
|
5
|
+
/** Settings chrome only. The parent owns content, targets, availability and navigation. */
|
|
6
|
+
export function createSettingsNavigator({ document, onNavigate, onInvoke }) {
|
|
7
|
+
let navigate = onNavigate;
|
|
8
|
+
let invoke = onInvoke;
|
|
9
|
+
let disposed = false;
|
|
10
|
+
let snapshot = { category: null, categories: [], entries: [], target: null };
|
|
11
|
+
const categories = new Map();
|
|
12
|
+
const results = new Map();
|
|
13
|
+
let prefix;
|
|
14
|
+
do { prefix = `pi-settings-navigation-${++nextNavigatorId}`; }
|
|
15
|
+
while (document.getElementById(`${prefix}-search`));
|
|
16
|
+
|
|
17
|
+
function node(tag, className, text) {
|
|
18
|
+
const element = document.createElement(tag);
|
|
19
|
+
element.className = className;
|
|
20
|
+
if (text !== undefined) element.textContent = text;
|
|
21
|
+
return element;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function button(className, text) {
|
|
25
|
+
const element = node('button', className, text);
|
|
26
|
+
element.type = 'button';
|
|
27
|
+
return element;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const element = node('section', 'settings-navigation');
|
|
31
|
+
element.setAttribute('aria-label', 'Settings');
|
|
32
|
+
const searchBar = node('div', 'settings-navigation-search');
|
|
33
|
+
const searchLabel = node('label', 'settings-navigation-search-label', 'Search settings');
|
|
34
|
+
const search = node('input', 'settings-navigation-input');
|
|
35
|
+
search.type = 'search';
|
|
36
|
+
search.id = `${prefix}-search`;
|
|
37
|
+
search.maxLength = QUERY_LIMIT;
|
|
38
|
+
search.autocomplete = 'off';
|
|
39
|
+
search.placeholder = 'Find a setting…';
|
|
40
|
+
searchLabel.htmlFor = search.id;
|
|
41
|
+
const clear = button('settings-navigation-clear', 'Clear');
|
|
42
|
+
clear.setAttribute('aria-label', 'Clear settings search');
|
|
43
|
+
clear.hidden = true;
|
|
44
|
+
searchBar.append(searchLabel, search, clear);
|
|
45
|
+
const layout = node('div', 'settings-navigation-layout');
|
|
46
|
+
const nav = node('nav', 'settings-navigation-categories');
|
|
47
|
+
nav.setAttribute('aria-label', 'Settings categories');
|
|
48
|
+
const main = node('div', 'settings-navigation-main');
|
|
49
|
+
const heading = node('h2', 'settings-navigation-heading', 'Settings');
|
|
50
|
+
heading.id = `${prefix}-heading`;
|
|
51
|
+
const content = node('div', 'settings-navigation-content');
|
|
52
|
+
content.setAttribute('role', 'region');
|
|
53
|
+
content.setAttribute('aria-labelledby', heading.id);
|
|
54
|
+
const resultArea = node('div', 'settings-navigation-results');
|
|
55
|
+
resultArea.hidden = true;
|
|
56
|
+
const status = node('p', 'settings-navigation-status');
|
|
57
|
+
status.id = `${prefix}-status`;
|
|
58
|
+
status.setAttribute('role', 'status');
|
|
59
|
+
const list = node('ul', 'settings-navigation-result-list');
|
|
60
|
+
list.id = `${prefix}-results`;
|
|
61
|
+
list.setAttribute('aria-label', 'Settings search results');
|
|
62
|
+
search.setAttribute('aria-controls', list.id);
|
|
63
|
+
search.setAttribute('aria-describedby', status.id);
|
|
64
|
+
resultArea.append(status, list);
|
|
65
|
+
main.append(heading, content, resultArea);
|
|
66
|
+
layout.append(nav, main);
|
|
67
|
+
element.append(searchBar, layout);
|
|
68
|
+
|
|
69
|
+
// Reorder only displaced nodes: appending every keyed node would blur focused buttons.
|
|
70
|
+
function reconcile(container, records, items, create, paint) {
|
|
71
|
+
const retained = new Set(items.map((item) => item.id));
|
|
72
|
+
for (const [id, record] of records) {
|
|
73
|
+
if (retained.has(id)) continue;
|
|
74
|
+
retire(record);
|
|
75
|
+
records.delete(id);
|
|
76
|
+
}
|
|
77
|
+
let cursor = container.firstChild;
|
|
78
|
+
for (const item of items) {
|
|
79
|
+
let record = records.get(item.id);
|
|
80
|
+
if (!record) {
|
|
81
|
+
record = create();
|
|
82
|
+
records.set(item.id, record);
|
|
83
|
+
}
|
|
84
|
+
paint(record, item);
|
|
85
|
+
if (record.element !== cursor) container.insertBefore(record.element, cursor);
|
|
86
|
+
cursor = record.element.nextSibling;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function retire(record) {
|
|
91
|
+
record.binding = null;
|
|
92
|
+
for (const control of record.controls) control.onclick = null;
|
|
93
|
+
record.element.remove();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function bind(record, control, callback) {
|
|
97
|
+
const binding = record.binding;
|
|
98
|
+
control.onclick = () => {
|
|
99
|
+
if (disposed || record.binding !== binding || control.disabled || !control.isConnected ||
|
|
100
|
+
!element.contains(control) || control.closest('[hidden]')) return;
|
|
101
|
+
callback();
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function createResult() {
|
|
106
|
+
const row = node('li', 'settings-navigation-result');
|
|
107
|
+
const open = button('settings-navigation-open');
|
|
108
|
+
const label = node('span', 'settings-navigation-result-label');
|
|
109
|
+
const scope = node('span', 'settings-navigation-scope');
|
|
110
|
+
const description = node('span', 'settings-navigation-description');
|
|
111
|
+
const reason = node('p', 'settings-navigation-reason');
|
|
112
|
+
reason.id = `${prefix}-reason-${++nextNavigatorId}`;
|
|
113
|
+
const setup = button('settings-navigation-setup', 'Setup');
|
|
114
|
+
open.append(label, scope, description);
|
|
115
|
+
row.append(open, reason, setup);
|
|
116
|
+
return { element: row, open, label, scope, description, reason, setup, controls: [open, setup] };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function render() {
|
|
120
|
+
const focused = document.activeElement;
|
|
121
|
+
const ownedFocus = focused === clear || nav.contains(focused) || list.contains(focused);
|
|
122
|
+
const target = snapshot.target;
|
|
123
|
+
reconcile(nav, categories, snapshot.categories, () => {
|
|
124
|
+
const control = button('settings-navigation-category');
|
|
125
|
+
return { element: control, controls: [control] };
|
|
126
|
+
}, (record, category) => {
|
|
127
|
+
record.binding = {};
|
|
128
|
+
record.element.textContent = category.label;
|
|
129
|
+
if (category.id === snapshot.category) record.element.setAttribute('aria-current', 'page');
|
|
130
|
+
else record.element.removeAttribute('aria-current');
|
|
131
|
+
bind(record, record.element, () => navigate?.(category.id, null, target));
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const query = search.value.trim().slice(0, QUERY_LIMIT).toLowerCase();
|
|
135
|
+
content.hidden = !!query;
|
|
136
|
+
resultArea.hidden = !query;
|
|
137
|
+
clear.hidden = !search.value;
|
|
138
|
+
heading.textContent = snapshot.categories.find(({ id }) => id === snapshot.category)?.label || 'Settings';
|
|
139
|
+
const matches = query ? snapshot.entries.filter((entry) =>
|
|
140
|
+
[entry.label, entry.description, ...entry.aliases].some((text) => text.toLowerCase().includes(query))) : [];
|
|
141
|
+
status.textContent = !query ? '' : !matches.length ? 'No matching settings. Try another name or purpose.'
|
|
142
|
+
: matches.length > RESULT_LIMIT ? `${matches.length} results. Showing the first ${RESULT_LIMIT}; ${matches.length - RESULT_LIMIT} more results. Refine your search.`
|
|
143
|
+
: `${matches.length} ${matches.length === 1 ? 'result' : 'results'}`;
|
|
144
|
+
reconcile(list, results, matches.slice(0, RESULT_LIMIT), createResult, (record, entry) => {
|
|
145
|
+
record.binding = {};
|
|
146
|
+
record.label.textContent = entry.label;
|
|
147
|
+
record.scope.textContent = entry.scopeLabel;
|
|
148
|
+
record.scope.hidden = !entry.scopeLabel;
|
|
149
|
+
record.description.textContent = entry.description;
|
|
150
|
+
record.description.hidden = !entry.description;
|
|
151
|
+
record.open.disabled = !entry.available;
|
|
152
|
+
record.reason.textContent = entry.available ? '' : entry.reason;
|
|
153
|
+
record.reason.hidden = entry.available;
|
|
154
|
+
if (entry.available) record.open.removeAttribute('aria-describedby');
|
|
155
|
+
else record.open.setAttribute('aria-describedby', record.reason.id);
|
|
156
|
+
bind(record, record.open, () => navigate?.(entry.category, entry.id, target));
|
|
157
|
+
record.setup.hidden = entry.available || !entry.setupActionId;
|
|
158
|
+
record.setup.setAttribute('aria-label', `Setup ${entry.label}`);
|
|
159
|
+
bind(record, record.setup, () => invoke?.(entry.setupActionId, target));
|
|
160
|
+
});
|
|
161
|
+
if (ownedFocus && (!element.contains(focused) || focused.closest('[hidden]') || focused.disabled)) {
|
|
162
|
+
search.focus({ preventScroll: true });
|
|
163
|
+
} else if (focused && element.contains(focused) && !focused.closest('[hidden]') && !focused.disabled) {
|
|
164
|
+
if (document.activeElement !== focused) focused.focus({ preventScroll: true });
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function update({ category, categories: nextCategories, entries, target }) {
|
|
169
|
+
if (disposed) return;
|
|
170
|
+
snapshot = {
|
|
171
|
+
category, target,
|
|
172
|
+
categories: nextCategories.map(({ id, label }) => ({ id, label })),
|
|
173
|
+
entries: entries.map((entry) => ({ ...entry, aliases: [...entry.aliases] })),
|
|
174
|
+
};
|
|
175
|
+
render();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function clearSearch() {
|
|
179
|
+
if (disposed) return;
|
|
180
|
+
search.value = '';
|
|
181
|
+
render();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function handleInput() {
|
|
185
|
+
search.value = search.value.slice(0, QUERY_LIMIT);
|
|
186
|
+
render();
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function handleKeydown(event) {
|
|
190
|
+
if (disposed || event.defaultPrevented || event.isComposing || event.altKey || event.ctrlKey ||
|
|
191
|
+
event.metaKey || event.shiftKey || document.querySelector(':modal')) return;
|
|
192
|
+
const inSearch = event.target === search;
|
|
193
|
+
const categoryControls = [...nav.children];
|
|
194
|
+
const resultControls = [...list.querySelectorAll('button')].filter((control) => !control.disabled && !control.hidden);
|
|
195
|
+
const controls = categoryControls.includes(event.target) ? categoryControls : resultControls;
|
|
196
|
+
if (!inSearch && !controls.includes(event.target) && event.target !== clear) return;
|
|
197
|
+
if (event.key === 'Escape') {
|
|
198
|
+
if (!search.value) return;
|
|
199
|
+
event.preventDefault();
|
|
200
|
+
event.stopPropagation();
|
|
201
|
+
clearSearch();
|
|
202
|
+
search.focus({ preventScroll: true });
|
|
203
|
+
} else if (event.key === 'Enter' && inSearch && search.value.trim()) {
|
|
204
|
+
event.preventDefault();
|
|
205
|
+
resultControls.find((control) => control.classList.contains('settings-navigation-open'))?.click();
|
|
206
|
+
} else if (['ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) {
|
|
207
|
+
if (inSearch && !['ArrowDown', 'ArrowUp'].includes(event.key)) return;
|
|
208
|
+
if (controls === resultControls && ['ArrowLeft', 'ArrowRight'].includes(event.key)) return;
|
|
209
|
+
if (event.target === clear || !controls.length) return;
|
|
210
|
+
event.preventDefault();
|
|
211
|
+
const current = controls.indexOf(event.target);
|
|
212
|
+
const next = event.key === 'Home' ? 0 : event.key === 'End' ? controls.length - 1
|
|
213
|
+
: ['ArrowDown', 'ArrowRight'].includes(event.key) ? (current + 1) % controls.length
|
|
214
|
+
: current < 0 ? controls.length - 1 : (current - 1 + controls.length) % controls.length;
|
|
215
|
+
controls[next].focus();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function handleClear() {
|
|
220
|
+
clearSearch();
|
|
221
|
+
search.focus({ preventScroll: true });
|
|
222
|
+
}
|
|
223
|
+
search.addEventListener('input', handleInput);
|
|
224
|
+
clear.addEventListener('click', handleClear);
|
|
225
|
+
element.addEventListener('keydown', handleKeydown);
|
|
226
|
+
|
|
227
|
+
function dispose() {
|
|
228
|
+
if (disposed) return;
|
|
229
|
+
disposed = true;
|
|
230
|
+
search.removeEventListener('input', handleInput);
|
|
231
|
+
clear.removeEventListener('click', handleClear);
|
|
232
|
+
element.removeEventListener('keydown', handleKeydown);
|
|
233
|
+
for (const record of [...categories.values(), ...results.values()]) retire(record);
|
|
234
|
+
categories.clear();
|
|
235
|
+
results.clear();
|
|
236
|
+
snapshot = null;
|
|
237
|
+
navigate = null;
|
|
238
|
+
invoke = null;
|
|
239
|
+
content.hidden = false;
|
|
240
|
+
content.removeAttribute('role');
|
|
241
|
+
content.removeAttribute('aria-labelledby');
|
|
242
|
+
// Keep the borrowed nodes in the returned slot so the caller can restore them.
|
|
243
|
+
content.remove();
|
|
244
|
+
element.remove();
|
|
245
|
+
element.replaceChildren();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return { element, slots: { content }, update, clearSearch, dispose };
|
|
249
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
.settings-navigation {
|
|
2
|
+
min-width: 0;
|
|
3
|
+
color: var(--text);
|
|
4
|
+
font-size: var(--text-sm);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.settings-navigation [hidden] { display: none !important; }
|
|
8
|
+
|
|
9
|
+
.settings-navigation-search {
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
flex-wrap: wrap;
|
|
13
|
+
gap: 0.5rem;
|
|
14
|
+
padding-bottom: 0.75rem;
|
|
15
|
+
border-bottom: 1px solid var(--border);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.settings-navigation-search-label { font-weight: 650; }
|
|
19
|
+
.settings-navigation-input { flex: 1 1 12rem; min-width: 0; width: 100%; padding: 0.4rem 0.65rem; }
|
|
20
|
+
.settings-navigation-layout { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 1rem; padding-top: 0.75rem; }
|
|
21
|
+
.settings-navigation-categories { display: flex; flex-direction: column; gap: 0.25rem; align-self: start; }
|
|
22
|
+
.settings-navigation-main, .settings-navigation-content { min-width: 0; }
|
|
23
|
+
.settings-navigation-heading { margin: 0 0 0.75rem; font-size: var(--text-lg); font-weight: 650; }
|
|
24
|
+
|
|
25
|
+
.settings-navigation :is(.settings-navigation-category, .settings-navigation-open, .settings-navigation-setup, .settings-navigation-clear) {
|
|
26
|
+
border-radius: 0.45rem;
|
|
27
|
+
box-shadow: none;
|
|
28
|
+
font-size: var(--text-sm);
|
|
29
|
+
line-height: 1.35;
|
|
30
|
+
padding: 0.4rem 0.6rem;
|
|
31
|
+
transform: none;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.settings-navigation :is(.settings-navigation-category, .settings-navigation-open, .settings-navigation-setup, .settings-navigation-clear, .settings-navigation-input):focus-visible {
|
|
35
|
+
outline: 2px solid var(--accent-2);
|
|
36
|
+
outline-offset: 2px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.settings-navigation-category { text-align: left; background: transparent; border-color: transparent; overflow-wrap: anywhere; }
|
|
40
|
+
.settings-navigation-category[aria-current="page"] { background: var(--panel-2); border-color: var(--accent); color: var(--text); }
|
|
41
|
+
.settings-navigation-status { margin: 0 0 0.5rem; color: var(--muted); font-size: var(--text-xs); }
|
|
42
|
+
.settings-navigation-result-list { list-style: none; padding: 0; margin: 0; max-height: 32rem; overflow: auto; scrollbar-gutter: stable; }
|
|
43
|
+
.settings-navigation-result { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.35rem 0.6rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
|
|
44
|
+
.settings-navigation-open { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-content: center; gap: 0.2rem 0.5rem; width: 100%; text-align: left; background: transparent; border-color: transparent; }
|
|
45
|
+
.settings-navigation-open:disabled { opacity: 1; cursor: default; }
|
|
46
|
+
.settings-navigation-open:disabled:hover { border-color: transparent; }
|
|
47
|
+
.settings-navigation-result-label { font-weight: 650; overflow-wrap: anywhere; }
|
|
48
|
+
.settings-navigation-scope { align-self: start; color: var(--muted); font-size: var(--text-xs); overflow-wrap: anywhere; }
|
|
49
|
+
.settings-navigation-description { grid-column: 1 / -1; color: var(--muted); font-size: var(--text-xs); overflow-wrap: anywhere; }
|
|
50
|
+
.settings-navigation-reason { grid-column: 1; margin: 0; padding: 0 0.6rem; color: var(--muted); font-size: var(--text-xs); overflow-wrap: anywhere; }
|
|
51
|
+
.settings-navigation-setup { grid-column: 2; grid-row: 1 / 3; align-self: center; }
|
|
52
|
+
|
|
53
|
+
@media (max-width: 640px) {
|
|
54
|
+
.settings-navigation-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
|
|
55
|
+
.settings-navigation-search-label { grid-column: 1 / -1; }
|
|
56
|
+
.settings-navigation-layout { grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }
|
|
57
|
+
.settings-navigation-categories { flex-direction: row; flex-wrap: wrap; gap: 0.25rem; }
|
|
58
|
+
.settings-navigation-category { flex: 0 1 auto; }
|
|
59
|
+
.settings-navigation-result-list { max-height: 24rem; }
|
|
60
|
+
.settings-navigation-open { grid-template-columns: minmax(0, 1fr); }
|
|
61
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
const SCOPES = new Set(["session", "global", "model"]);
|
|
2
|
+
const FILTERS = new Set(["all", "enabled", "disabled"]);
|
|
3
|
+
const NO_MODELS = "No authenticated Pi models are available for a model default.";
|
|
4
|
+
|
|
5
|
+
function selection(scope, model = null) {
|
|
6
|
+
return Object.freeze({ scope, provider: model?.provider ?? null, modelId: model?.modelId ?? null });
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// API records are JSON data. Copy before freezing so callers retain their inputs.
|
|
10
|
+
function readOnlyCopy(value) {
|
|
11
|
+
if (Array.isArray(value)) return Object.freeze(value.map(readOnlyCopy));
|
|
12
|
+
if (value && typeof value === "object") {
|
|
13
|
+
return Object.freeze(Object.fromEntries(Object.entries(value).map(([key, item]) => [key, readOnlyCopy(item)])));
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function modelCatalog(value, { sort = false } = {}) {
|
|
19
|
+
const models = (Array.isArray(value) ? value : []).filter((model) =>
|
|
20
|
+
typeof model?.provider === "string" && model.provider.length > 0 &&
|
|
21
|
+
typeof model?.id === "string" && model.id.length > 0);
|
|
22
|
+
if (sort) models.sort((left, right) => `${left.provider}/${left.id}`.localeCompare(`${right.provider}/${right.id}`));
|
|
23
|
+
return readOnlyCopy(models);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function hasModel(models, selected) {
|
|
27
|
+
return models.some((model) => model.provider === selected.provider && model.id === selected.modelId);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function unavailableModel(selected) {
|
|
31
|
+
return `The exact model ${selected.provider}/${selected.modelId} is unavailable. Choose an available model.`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const EMPTY = Object.freeze({
|
|
35
|
+
kind: null, target: null, selection: selection("session"), resources: Object.freeze([]),
|
|
36
|
+
models: Object.freeze([]), configured: false, filter: "all", loading: false, savingName: "", error: "",
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
/** Owns one tools/skills presentation. Async methods return true only for accepted completions. */
|
|
40
|
+
export function createSettingsResourceController({ read, write, listModels, isCurrent, onChange, onMutation }) {
|
|
41
|
+
let owner = null;
|
|
42
|
+
let disposed = false;
|
|
43
|
+
|
|
44
|
+
function getSnapshot() {
|
|
45
|
+
if (!owner) return EMPTY;
|
|
46
|
+
const { kind, target, selection, resources, models, configured, filter, loading, savingName, error } = owner;
|
|
47
|
+
// The opaque target belongs to the parent; all controller-owned projections are frozen.
|
|
48
|
+
return Object.freeze({ kind, target, selection, resources, models, configured, filter, loading, savingName, error });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function current(state) {
|
|
52
|
+
return !disposed && state !== null && owner === state && isCurrent(state.target);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function capture(state) {
|
|
56
|
+
return { state, epoch: ++state.epoch, target: state.target, selection: state.selection };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function owns(token) {
|
|
60
|
+
return current(token.state) && token.state.epoch === token.epoch && token.state.selection === token.selection;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function changed() {
|
|
64
|
+
onChange?.(getSnapshot());
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function acceptData(state, data) {
|
|
68
|
+
state.resources = readOnlyCopy(Array.isArray(data?.[state.kind]) ? data[state.kind] : []);
|
|
69
|
+
state.configured = data?.configured === true;
|
|
70
|
+
state.ready = true;
|
|
71
|
+
if (state.selection.scope === "model") {
|
|
72
|
+
if (Array.isArray(data?.models)) state.models = modelCatalog(data.models);
|
|
73
|
+
if (!hasModel(state.models, state.selection)) state.error = unavailableModel(state.selection);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function load(state) {
|
|
78
|
+
if (!current(state)) return false;
|
|
79
|
+
const token = capture(state);
|
|
80
|
+
state.resources = EMPTY.resources;
|
|
81
|
+
state.configured = false;
|
|
82
|
+
state.ready = false;
|
|
83
|
+
state.error = "";
|
|
84
|
+
if (state.selection.scope === "model" && !hasModel(state.models, state.selection)) {
|
|
85
|
+
state.loading = false;
|
|
86
|
+
state.error = unavailableModel(state.selection);
|
|
87
|
+
changed();
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
state.loading = true;
|
|
91
|
+
changed();
|
|
92
|
+
if (!owns(token)) return false;
|
|
93
|
+
let accepted = false;
|
|
94
|
+
try {
|
|
95
|
+
const data = await read(state.kind, token.selection, token.target);
|
|
96
|
+
if (!owns(token)) return false;
|
|
97
|
+
acceptData(state, data);
|
|
98
|
+
accepted = true;
|
|
99
|
+
} catch (error) {
|
|
100
|
+
if (!owns(token)) return false;
|
|
101
|
+
state.error = error?.message || String(error);
|
|
102
|
+
} finally {
|
|
103
|
+
if (owns(token)) {
|
|
104
|
+
state.loading = false;
|
|
105
|
+
changed();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return accepted;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function open(kind, target) {
|
|
112
|
+
if (disposed || (kind !== "tools" && kind !== "skills")) return false;
|
|
113
|
+
owner = {
|
|
114
|
+
...EMPTY, kind, target, epoch: 0, modelSelection: null, ready: false,
|
|
115
|
+
};
|
|
116
|
+
return load(owner);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async function setScope(scope) {
|
|
120
|
+
const state = owner;
|
|
121
|
+
if (!current(state) || state.savingName || !SCOPES.has(scope)) return false;
|
|
122
|
+
if (scope === state.selection.scope && !state.loading) return false;
|
|
123
|
+
if (scope === "model" && !state.models.length) {
|
|
124
|
+
const token = capture(state);
|
|
125
|
+
state.loading = true;
|
|
126
|
+
state.error = "";
|
|
127
|
+
changed();
|
|
128
|
+
if (!owns(token)) return false;
|
|
129
|
+
try {
|
|
130
|
+
const models = await listModels(token.target);
|
|
131
|
+
if (!owns(token)) return false;
|
|
132
|
+
state.models = modelCatalog(models, { sort: true });
|
|
133
|
+
if (!state.models.length) {
|
|
134
|
+
state.error = NO_MODELS;
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
} catch (error) {
|
|
138
|
+
if (!owns(token)) return false;
|
|
139
|
+
state.error = error?.message || String(error);
|
|
140
|
+
return false;
|
|
141
|
+
} finally {
|
|
142
|
+
if (owns(token)) {
|
|
143
|
+
state.loading = false;
|
|
144
|
+
// Successful discovery is published together with the following model load.
|
|
145
|
+
if (state.error) changed();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (!owns(token)) return false;
|
|
149
|
+
}
|
|
150
|
+
if (scope === "model" && !state.modelSelection) {
|
|
151
|
+
const model = state.models[0];
|
|
152
|
+
state.modelSelection = selection("model", { provider: model.provider, modelId: model.id });
|
|
153
|
+
}
|
|
154
|
+
state.selection = scope === "model" ? state.modelSelection : selection(scope);
|
|
155
|
+
return load(state);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async function setModel(model) {
|
|
159
|
+
const state = owner;
|
|
160
|
+
if (!current(state) || state.savingName || state.selection.scope !== "model" || !hasModel(state.models, model ?? {})) return false;
|
|
161
|
+
if (state.selection.provider === model.provider && state.selection.modelId === model.modelId && !state.loading) return false;
|
|
162
|
+
state.modelSelection = selection("model", model);
|
|
163
|
+
state.selection = state.modelSelection;
|
|
164
|
+
return load(state);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function setFilter(filter) {
|
|
168
|
+
if (!current(owner) || !FILTERS.has(filter) || owner.filter === filter) return false;
|
|
169
|
+
owner.filter = filter;
|
|
170
|
+
changed();
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async function mutate(name, inherited) {
|
|
175
|
+
const state = owner;
|
|
176
|
+
if (!current(state) || state.loading || state.savingName || !state.ready) return false;
|
|
177
|
+
if (state.selection.scope === "model" && !hasModel(state.models, state.selection)) return false;
|
|
178
|
+
const resource = inherited ? null : state.resources.find((item) => item.name === name);
|
|
179
|
+
if (!inherited && !resource) return false;
|
|
180
|
+
const enabled = inherited ? null : resource.enabled === false;
|
|
181
|
+
const names = new Set(state.resources.filter((item) => item.enabled !== false).map((item) => item.name));
|
|
182
|
+
if (!inherited) {
|
|
183
|
+
if (enabled) names.add(name);
|
|
184
|
+
else names.delete(name);
|
|
185
|
+
}
|
|
186
|
+
const change = inherited ? Object.freeze({ inherit: true }) : Object.freeze({ enabled: Object.freeze([...names]) });
|
|
187
|
+
const token = capture(state);
|
|
188
|
+
state.savingName = inherited ? "inherit" : name;
|
|
189
|
+
state.error = "";
|
|
190
|
+
changed();
|
|
191
|
+
if (!owns(token)) return false;
|
|
192
|
+
let accepted = false;
|
|
193
|
+
try {
|
|
194
|
+
const data = await write(state.kind, token.selection, change, token.target);
|
|
195
|
+
if (!owns(token)) return false;
|
|
196
|
+
acceptData(state, data);
|
|
197
|
+
accepted = true;
|
|
198
|
+
} catch (error) {
|
|
199
|
+
if (!owns(token)) return false;
|
|
200
|
+
state.error = error?.message || String(error);
|
|
201
|
+
} finally {
|
|
202
|
+
if (owns(token)) {
|
|
203
|
+
state.savingName = "";
|
|
204
|
+
changed();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (accepted && owns(token)) {
|
|
208
|
+
onMutation?.(Object.freeze({
|
|
209
|
+
kind: state.kind, target: token.target, selection: token.selection,
|
|
210
|
+
name: inherited ? null : name, enabled, inherit: inherited,
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
return accepted;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function close() {
|
|
217
|
+
if (disposed || !owner) return false;
|
|
218
|
+
owner = null;
|
|
219
|
+
changed();
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function dispose() {
|
|
224
|
+
if (disposed) return;
|
|
225
|
+
const hadOwner = owner !== null;
|
|
226
|
+
disposed = true;
|
|
227
|
+
owner = null;
|
|
228
|
+
if (hadOwner) changed();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return { open, setScope, setModel, setFilter, toggle: (name) => mutate(name, false), inherit: () => mutate(null, true), close, getSnapshot, dispose };
|
|
232
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.settings-workspace { max-width: 72rem; margin: 0 auto; width: 100%; }
|
|
2
|
+
.settings-workspace .settings-navigation-layout { grid-template-columns: 10.5rem minmax(0, 1fr); gap: 1.5rem; }
|
|
3
|
+
.settings-workspace .settings-page { min-width: 0; }
|
|
4
|
+
.settings-workspace .control-group { padding: 0; margin: 0 0 1rem; border: 0; background: transparent; box-shadow: none; }
|
|
5
|
+
.settings-workspace .control-row { padding: .5rem 0; border-bottom: 1px solid var(--border); }
|
|
6
|
+
.settings-workspace .control-row-label { font-size: var(--text-sm); }
|
|
7
|
+
.settings-workspace .settings-page-note { color: var(--muted); font-size: var(--text-sm); line-height: 1.5; margin: 0 0 1rem; }
|
|
8
|
+
.settings-workspace .settings-action-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem .75rem; padding: .65rem 0; border-bottom: 1px solid var(--border); align-items: center; }
|
|
9
|
+
.settings-workspace .settings-action-row > button { justify-self: start; padding: .35rem .6rem; font-size: var(--text-sm); box-shadow: none; }
|
|
10
|
+
.settings-workspace .settings-action-row > p { grid-column: 1 / -1; margin: 0; font-size: var(--text-xs); color: var(--muted); }
|
|
11
|
+
.settings-workspace #conversationVoiceMenuPanel { display: flex; position: static; width: 100%; max-width: none; max-height: none; opacity: 1; visibility: visible; transform: none; box-shadow: none; flex-direction: column; border: 0; padding: 0; }
|
|
12
|
+
.settings-workspace .optional-feature-row { padding: .65rem; }
|
|
13
|
+
.settings-workspace .side-panel-version-row { margin: 1rem 0; }
|
|
14
|
+
.settings-workspace .sponsor-link { display: inline-flex; margin-top: 1rem; }
|
|
15
|
+
@media (max-width: 760px) {
|
|
16
|
+
.settings-workspace .settings-navigation-layout { grid-template-columns: minmax(0, 1fr); gap: .75rem; }
|
|
17
|
+
.settings-workspace .settings-navigation-categories { flex-direction: row; flex-wrap: wrap; }
|
|
18
|
+
.settings-workspace .settings-action-row { grid-template-columns: minmax(0, 1fr); }
|
|
19
|
+
}
|