@firstpick/pi-package-webui 0.9.0 → 0.9.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/README.md +236 -24
- package/bin/pi-webui-launcher.mjs +23 -12
- package/bin/pi-webui.mjs +493 -65
- package/lib/agent-run-adapters.mjs +500 -0
- package/lib/agent-run-protocol.mjs +262 -0
- package/lib/agent-run-registry.mjs +339 -0
- package/lib/app-runner-terminal.mjs +40 -0
- package/lib/git-workflow-preferences.mjs +11 -4
- package/lib/trust-boundaries.mjs +2 -0
- package/lib/ui-layout-settings.mjs +172 -28
- package/lib/update/package-layout.mjs +50 -0
- package/lib/update/plan.mjs +11 -0
- package/package.json +2 -2
- package/public/app.js +1376 -337
- package/public/index.html +113 -68
- package/public/service-worker.js +1 -1
- package/public/styles.css +371 -93
- package/tests/agent-run-adapters.test.mjs +217 -0
- package/tests/agent-run-launcher.test.mjs +41 -0
- package/tests/agent-run-protocol.test.mjs +82 -0
- package/tests/agent-run-registry.test.mjs +102 -0
- package/tests/app-runner-terminal-static.test.mjs +28 -0
- package/tests/app-runner-terminal.test.mjs +65 -0
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/control-deck-side-panels.spec.mjs +354 -0
- package/tests/browser/controls-layout.spec.mjs +122 -0
- package/tests/browser/file-tree-git-ignored.spec.mjs +113 -0
- package/tests/browser/interaction-continuity.spec.mjs +159 -0
- package/tests/browser/mobile-foundation.spec.mjs +26 -0
- package/tests/browser/model-search-focus.spec.mjs +96 -0
- package/tests/browser/optimistic-prompt.spec.mjs +22 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +224 -66
- package/tests/browser/subagent-observability.spec.mjs +87 -0
- package/tests/chat-scroll-intent-static.test.mjs +1 -1
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/component-update-api-static.test.mjs +2 -1
- package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
- package/tests/control-deck-component-updates-static.test.mjs +2 -0
- package/tests/control-deck-side-panels-static.test.mjs +68 -0
- package/tests/controls-layout-static.test.mjs +22 -0
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/file-tree-git-ignored-static.test.mjs +152 -0
- package/tests/file-tree-search-layout-static.test.mjs +2 -1
- package/tests/fixtures/fake-pi.mjs +43 -7
- package/tests/footer-provider-usage-visual-static.test.mjs +10 -8
- package/tests/git-workflow-preferences.test.mjs +55 -6
- package/tests/http-endpoints-harness.test.mjs +173 -14
- package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +3 -3
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +18 -5
- package/tests/open-issue-wizard-static.test.mjs +2 -2
- package/tests/persistent-ui-layout-static.test.mjs +13 -13
- package/tests/questionnaire-dialog.test.mjs +3 -3
- package/tests/remote-auth-settings-harness.test.mjs +1 -1
- package/tests/session-sampling-ui-static.test.mjs +3 -3
- package/tests/side-panel-context-menu-static.test.mjs +1 -1
- package/tests/side-panel-resize-static.test.mjs +26 -16
- package/tests/side-panel-section-height-removal-static.test.mjs +4 -4
- package/tests/side-panel-section-reorder-static.test.mjs +16 -70
- package/tests/subagent-gate-visibility.test.mjs +2 -1
- package/tests/subagent-launch-slots.test.mjs +1 -1
- package/tests/subagent-observability-static.test.mjs +32 -0
- package/tests/subagent-reliability-integration.test.mjs +161 -0
- package/tests/subagents-helper.test.mjs +344 -4
- package/tests/terminal-tabs-resize-static.test.mjs +35 -0
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/tests/ui-layout-settings.test.mjs +104 -32
- package/tests/update-api-harness.test.mjs +24 -10
- package/tests/update-package-layout.test.mjs +38 -0
- package/tests/update-plan.test.mjs +11 -1
- package/tests/webui-settings-locking.test.mjs +33 -3
- package/webui-rpc-helper.mjs +417 -28
package/public/app.js
CHANGED
|
@@ -33,6 +33,7 @@ const elements = {
|
|
|
33
33
|
tabBar: $("#tabBar"),
|
|
34
34
|
terminalTabsToggleButton: $("#terminalTabsToggleButton"),
|
|
35
35
|
terminalTabsShell: $(".terminal-tabs-shell"),
|
|
36
|
+
terminalTabsResizeHandle: $("#terminalTabsResizeHandle"),
|
|
36
37
|
terminalTabsDrawerContent: $("#terminalTabsDrawerContent"),
|
|
37
38
|
terminalTabsBackdrop: $("#terminalTabsBackdrop"),
|
|
38
39
|
workspaceSaveButton: $("#workspaceSaveButton"),
|
|
@@ -336,6 +337,15 @@ const elements = {
|
|
|
336
337
|
sidePanelContextMenu: $("#sidePanelContextMenu"),
|
|
337
338
|
gitFooterContextMenu: $("#gitFooterContextMenu"),
|
|
338
339
|
sidePanelResizeHandle: $("#sidePanelResizeHandle"),
|
|
340
|
+
sidePanelResizeHandleLeft: $("#sidePanelLeftResizeHandle"),
|
|
341
|
+
sidePanelLeftExpandButton: $("#sidePanelLeftExpandButton"),
|
|
342
|
+
sidePanelLeft: $("#sidePanelLeft"),
|
|
343
|
+
sidePanelBodyLeft: $("#sidePanelBodyLeft"),
|
|
344
|
+
sidePanelBodyRight: $("#sidePanelBodyRight"),
|
|
345
|
+
toggleSidePanelLeftButton: $("#toggleSidePanelLeftButton"),
|
|
346
|
+
controlDeckPlacementSelect: $("#controlDeckPlacementSelect"),
|
|
347
|
+
controlDeckPlacementStatus: $("#controlDeckPlacementStatus"),
|
|
348
|
+
controlDeckMovementAnnouncer: $("#controlDeckMovementAnnouncer"),
|
|
339
349
|
sidePanelEditButton: $("#sidePanelEditButton"),
|
|
340
350
|
sidePanelEditHint: $("#sidePanelEditHint"),
|
|
341
351
|
toggleSidePanelButton: $("#toggleSidePanelButton"),
|
|
@@ -556,6 +566,9 @@ const transcriptRenderer = createTranscriptRenderer({
|
|
|
556
566
|
const PI_WEBUI_NPM_URL = "https://www.npmjs.com/package/@firstpick/pi-package-webui";
|
|
557
567
|
|
|
558
568
|
let currentState = null;
|
|
569
|
+
let tabStateCache = new Map();
|
|
570
|
+
let tabStatsCache = new Map();
|
|
571
|
+
let tabWorkspaceCache = new Map();
|
|
559
572
|
let tabs = [];
|
|
560
573
|
let activeTabId = null;
|
|
561
574
|
let activeTabGeneration = 0;
|
|
@@ -582,6 +595,8 @@ let sidePanelSectionEditMode = false;
|
|
|
582
595
|
let sidePanelSectionPointerDrag = null;
|
|
583
596
|
let sidePanelSectionLastDragOverKey = "";
|
|
584
597
|
let sidePanelSectionSuppressClickUntil = 0;
|
|
598
|
+
let controlDeckPresentationReconcileFrame = null;
|
|
599
|
+
let controlDeckPresentationReconcileActive = false;
|
|
585
600
|
let composerActionPointerDrag = null;
|
|
586
601
|
let composerActionLastDragOverKey = "";
|
|
587
602
|
let composerActionSuppressClickUntil = 0;
|
|
@@ -591,6 +606,7 @@ let composerActionLayoutRestoreFrame = null;
|
|
|
591
606
|
let fileTreeDragState = null;
|
|
592
607
|
let fileViewerResizeState = null;
|
|
593
608
|
let sidePanelResizeState = null;
|
|
609
|
+
let terminalTabsResizeState = null;
|
|
594
610
|
let sidePanelWidthPreferenceRevision = 0;
|
|
595
611
|
let fileTreeSearchTimer = null;
|
|
596
612
|
let fileTreeSearchRequestSerial = 0;
|
|
@@ -804,6 +820,7 @@ let nativeSettingsDirty = false;
|
|
|
804
820
|
let sessionSummaryOverlayTabId = null;
|
|
805
821
|
let sessionSummaryOverlayFocusReturn = null;
|
|
806
822
|
let sessionSummaryOverlayFocusReturnKey = "";
|
|
823
|
+
let sessionSummaryControlsRenderSignature = "";
|
|
807
824
|
const sessionSummaryByTab = new Map();
|
|
808
825
|
let pathPickerState = null;
|
|
809
826
|
let firstTerminalCwdPromptShown = false;
|
|
@@ -902,6 +919,8 @@ let claudeUsageRenderSignature = "";
|
|
|
902
919
|
let latestSubagents = null;
|
|
903
920
|
let subagentsError = null;
|
|
904
921
|
let subagentsLoading = false;
|
|
922
|
+
let subagentsRefreshQueued = false;
|
|
923
|
+
let subagentsRefreshPromise = null;
|
|
905
924
|
let subagentsClearingFinished = false;
|
|
906
925
|
let subagentAutoClearEnabled = false;
|
|
907
926
|
let refreshSubagentsTimer = null;
|
|
@@ -1052,6 +1071,9 @@ const INTERFACE_DENSITY_STORAGE_KEY = "pi-webui-interface-density";
|
|
|
1052
1071
|
const SIDE_PANEL_SECTION_STORAGE_KEY = "pi-webui-side-panel-sections-collapsed";
|
|
1053
1072
|
const SIDE_PANEL_SECTION_VISIBILITY_STORAGE_KEY = "pi-webui-side-panel-sections-hidden";
|
|
1054
1073
|
const SIDE_PANEL_SECTION_ORDER_STORAGE_KEY = "pi-webui-side-panel-section-order-v1";
|
|
1074
|
+
const CONTROL_DECK_LAYOUT_STORAGE_KEY = "pi-webui-control-deck-layout-v2";
|
|
1075
|
+
const CONTROL_DECK_DEFAULT_PLACEMENT = "right";
|
|
1076
|
+
const CONTROL_DECK_SIDES = ["left", "right"];
|
|
1055
1077
|
const SIDE_PANEL_SECTION_POINTER_DRAG_THRESHOLD_PX = 6;
|
|
1056
1078
|
const COMPOSER_ACTION_ORDER_STORAGE_KEY = "pi-webui-composer-action-order-v1";
|
|
1057
1079
|
const COMPOSER_ACTION_LAYOUT_STORAGE_KEY = "pi-webui-composer-action-layout-v2";
|
|
@@ -1071,6 +1093,7 @@ const THINKING_VISIBILITY_STORAGE_KEY = "pi-webui-thinking-visible";
|
|
|
1071
1093
|
const BUSY_PROMPT_BEHAVIOR_STORAGE_KEY = "pi-webui-busy-prompt-behavior";
|
|
1072
1094
|
const SKILL_USAGE_STORAGE_KEY = "pi-webui-skill-usage-v1";
|
|
1073
1095
|
const TERMINAL_TABS_LAYOUT_STORAGE_KEY = "pi-webui-terminal-tabs-layout";
|
|
1096
|
+
const TERMINAL_TABS_SIDEBAR_WIDTH_STORAGE_KEY = "pi-webui-terminal-tabs-sidebar-width";
|
|
1074
1097
|
const SUBAGENT_OPEN_MODE_STORAGE_KEY = "pi-webui-subagent-open-mode";
|
|
1075
1098
|
const SUBAGENT_AUTO_CLEAR_STORAGE_KEY = "pi-webui-subagent-auto-clear";
|
|
1076
1099
|
const TERMINAL_CUSTOM_GROUPS_STORAGE_KEY = "pi-webui-terminal-custom-groups-v1";
|
|
@@ -1196,6 +1219,8 @@ const SIDE_PANEL_WIDTH_STORAGE_KEY = "pi-webui-side-panel-width";
|
|
|
1196
1219
|
const SIDE_PANEL_WIDTH_DEFAULT_PX = 384;
|
|
1197
1220
|
const SIDE_PANEL_WIDTH_MIN_PX = 320;
|
|
1198
1221
|
const SIDE_PANEL_WIDTH_MAX_PX = 4096;
|
|
1222
|
+
const TERMINAL_TABS_SIDEBAR_WIDTH_MIN_PX = 208;
|
|
1223
|
+
const TERMINAL_TABS_SIDEBAR_WIDTH_MAX_PX = 4096;
|
|
1199
1224
|
const FILE_VIEWER_CONTEXT_RADIUS_LINES = 6;
|
|
1200
1225
|
const FILE_TREE_ROOT_PATH = "";
|
|
1201
1226
|
const FILE_TREE_DRAG_MIME = "application/x-pi-webui-file-path";
|
|
@@ -1230,7 +1255,7 @@ let themeCatalogScopes = { global: { available: true }, project: { available: fa
|
|
|
1230
1255
|
let themeCustomizerGeneration = 0;
|
|
1231
1256
|
let themeCustomizerState = null;
|
|
1232
1257
|
const TERMINAL_TABS_LAYOUTS = new Set(["top", "left"]);
|
|
1233
|
-
const TERMINAL_TABS_LAYOUT_LABELS = { top: "Top bar", left: "
|
|
1258
|
+
const TERMINAL_TABS_LAYOUT_LABELS = { top: "Top bar", left: "Sidebar" };
|
|
1234
1259
|
const SUBAGENT_OPEN_MODES = new Set(["overlay", "tab"]);
|
|
1235
1260
|
const SUBAGENT_OPEN_MODE_LABELS = { overlay: "Overlay", tab: "Tab / terminal" };
|
|
1236
1261
|
const BUSY_PROMPT_BEHAVIOR_VALUES = new Set(["followUp", "steer"]);
|
|
@@ -2161,6 +2186,11 @@ function renderMobilePhoneExperience({ focus = false } = {}) {
|
|
|
2161
2186
|
}
|
|
2162
2187
|
document.documentElement.dataset.mobilePresentation = mobilePresentation;
|
|
2163
2188
|
const route = mobileShellState.route;
|
|
2189
|
+
const surface = mobileShellElement("mobileShellSurface");
|
|
2190
|
+
// Capture focus before route rendering can temporarily unmount canonical
|
|
2191
|
+
// Settings controls. Streaming state refreshes rebuild the mobile shell, and
|
|
2192
|
+
// the surface renderer remounts those same controls later in this pass.
|
|
2193
|
+
const surfaceFocusSnapshot = captureMobileSurfaceRenderFocus(surface);
|
|
2164
2194
|
const activeTabRecord = activeTab();
|
|
2165
2195
|
const activeState = activeTabRecord ? mobileTabActivityState(activeTabRecord) : "idle";
|
|
2166
2196
|
const title = mobileShellElement("mobileSessionTitle");
|
|
@@ -2207,8 +2237,6 @@ function renderMobilePhoneExperience({ focus = false } = {}) {
|
|
|
2207
2237
|
mobileWidgetAreaUnmount();
|
|
2208
2238
|
mobileCanonicalUnmount();
|
|
2209
2239
|
}
|
|
2210
|
-
const surface = mobileShellElement("mobileShellSurface");
|
|
2211
|
-
const surfaceFocusSnapshot = captureMobileSurfaceRenderFocus(surface);
|
|
2212
2240
|
if (mobileShellState.surface === "none") mobileSurfaceRenderFocus = null;
|
|
2213
2241
|
if (surface) {
|
|
2214
2242
|
surface.hidden = mobileShellState.surface === "none";
|
|
@@ -2472,6 +2500,7 @@ const OPTIONAL_FEATURES = [
|
|
|
2472
2500
|
packageName: "@firstpick/pi-prompts-git-pr",
|
|
2473
2501
|
capabilityLabel: "/git-staged-msg",
|
|
2474
2502
|
description: "Generate staged commit messages for the guided Git workflow.",
|
|
2503
|
+
setup: "git-workflow",
|
|
2475
2504
|
},
|
|
2476
2505
|
{
|
|
2477
2506
|
id: "releaseNpm",
|
|
@@ -2500,6 +2529,7 @@ const OPTIONAL_FEATURES = [
|
|
|
2500
2529
|
packageName: "@firstpick/pi-extension-workflows",
|
|
2501
2530
|
capabilityLabel: "/workflow or workflow subprocess widget event",
|
|
2502
2531
|
description: "Modular workflow runner with live subprocess output shown in a non-blocking Web UI widget.",
|
|
2532
|
+
setup: "workflows",
|
|
2503
2533
|
},
|
|
2504
2534
|
{
|
|
2505
2535
|
id: "featureSystemPrompt",
|
|
@@ -2514,6 +2544,7 @@ const OPTIONAL_FEATURES = [
|
|
|
2514
2544
|
packageName: "@firstpick/pi-extension-safety-guard",
|
|
2515
2545
|
capabilityLabel: "/safety-guard or /safety-guard-setup command",
|
|
2516
2546
|
description: "Configurable guardrails for dangerous bash commands and protected file edits.",
|
|
2547
|
+
setup: "safety-guard",
|
|
2517
2548
|
},
|
|
2518
2549
|
{
|
|
2519
2550
|
id: "tuiSkillsCommand",
|
|
@@ -2550,6 +2581,7 @@ const OPTIONAL_FEATURES = [
|
|
|
2550
2581
|
capabilityLabel: "questionnaire tool in /tools",
|
|
2551
2582
|
description: "Native TUI and WebUI single- or multi-select question series with Other answers and resumable clarification.",
|
|
2552
2583
|
manageWith: "tools",
|
|
2584
|
+
setup: "tools",
|
|
2553
2585
|
},
|
|
2554
2586
|
{
|
|
2555
2587
|
id: "naturalConversation",
|
|
@@ -3651,7 +3683,7 @@ function isMobileView() {
|
|
|
3651
3683
|
}
|
|
3652
3684
|
|
|
3653
3685
|
function isSidePanelOverlayView() {
|
|
3654
|
-
return
|
|
3686
|
+
return isControlDeckOverlayPresentation();
|
|
3655
3687
|
}
|
|
3656
3688
|
|
|
3657
3689
|
function mobileDropdownViewportHeight() {
|
|
@@ -3694,8 +3726,8 @@ function readStoredSidePanelCollapsed() {
|
|
|
3694
3726
|
}
|
|
3695
3727
|
}
|
|
3696
3728
|
|
|
3697
|
-
function
|
|
3698
|
-
return Array.from(
|
|
3729
|
+
function controlDeckSectionRecords() {
|
|
3730
|
+
return Array.from(document.querySelectorAll("[data-side-panel-section]"))
|
|
3699
3731
|
.map((section) => {
|
|
3700
3732
|
const id = section.dataset.sidePanelSection || "";
|
|
3701
3733
|
const button = section.querySelector("[data-side-panel-section-toggle]");
|
|
@@ -3706,6 +3738,157 @@ function sidePanelSectionRecords() {
|
|
|
3706
3738
|
.filter((record) => record.id && record.button && record.content);
|
|
3707
3739
|
}
|
|
3708
3740
|
|
|
3741
|
+
const sidePanelSectionRecords = controlDeckSectionRecords;
|
|
3742
|
+
|
|
3743
|
+
function isControlDeckSidebarPresentation() {
|
|
3744
|
+
return terminalTabsLayout === "left";
|
|
3745
|
+
}
|
|
3746
|
+
|
|
3747
|
+
function reconcileControlDeckPlacementConstraint() {
|
|
3748
|
+
const sidebarPresentation = isControlDeckSidebarPresentation();
|
|
3749
|
+
const bothOption = elements.controlDeckPlacementSelect?.querySelector('option[value="both"]');
|
|
3750
|
+
if (bothOption) bothOption.disabled = sidebarPresentation;
|
|
3751
|
+
const placement = normalizeControlDeckPlacement(controlDeckLayout.placement);
|
|
3752
|
+
if (!sidebarPresentation || placement !== "both") return placement;
|
|
3753
|
+
controlDeckLayout.placement = "right";
|
|
3754
|
+
cacheControlDeckLayout(controlDeckLayout, "placement");
|
|
3755
|
+
markDurableUiLayoutDirty("sidePanel", "placement");
|
|
3756
|
+
return "right";
|
|
3757
|
+
}
|
|
3758
|
+
|
|
3759
|
+
function isControlDeckOverlayPresentation() {
|
|
3760
|
+
if (document.body.classList.contains("embedded-split")) return false;
|
|
3761
|
+
if (sidePanelOverlayMedia?.matches) return true;
|
|
3762
|
+
const layout = document.querySelector(".layout");
|
|
3763
|
+
if (!layout) return false;
|
|
3764
|
+
const placement = normalizeControlDeckPlacement(controlDeckLayout.placement);
|
|
3765
|
+
const panelCount = placement === "both" ? 2 : 1;
|
|
3766
|
+
const splitCount = document.body.classList.contains("terminal-split-open") ? 1 : 0;
|
|
3767
|
+
const viewerCount = document.body.classList.contains("file-viewer-open") ? 1 : 0;
|
|
3768
|
+
const terminalRail = isControlDeckSidebarPresentation() ? Math.max(TERMINAL_TABS_SIDEBAR_WIDTH_MIN_PX, currentTerminalTabsSidebarWidth()) : 0;
|
|
3769
|
+
const centralMinimum = 320 + (splitCount * 320) + (viewerCount * FILE_VIEWER_WIDTH_MIN_PX) + terminalRail;
|
|
3770
|
+
const columnCount = panelCount + 1 + splitCount + viewerCount;
|
|
3771
|
+
const minimum = (panelCount * SIDE_PANEL_WIDTH_MIN_PX) + centralMinimum + (16 * Math.max(0, columnCount - 1)) + 32;
|
|
3772
|
+
return (layout.getBoundingClientRect?.().width || window.innerWidth || 0) < minimum;
|
|
3773
|
+
}
|
|
3774
|
+
|
|
3775
|
+
function effectiveControlDeckPresentation() {
|
|
3776
|
+
if (document.body.classList.contains("embedded-split")) return "embedded";
|
|
3777
|
+
if (isControlDeckOverlayPresentation()) return "overlay";
|
|
3778
|
+
return normalizeControlDeckPlacement(controlDeckLayout.placement);
|
|
3779
|
+
}
|
|
3780
|
+
|
|
3781
|
+
function controlDeckSectionSide(id) {
|
|
3782
|
+
return controlDeckLayout.sectionLayout?.leftSectionIds?.includes(id) ? "left" : "right";
|
|
3783
|
+
}
|
|
3784
|
+
|
|
3785
|
+
function reconcileControlDeckHosts() {
|
|
3786
|
+
const records = controlDeckSectionRecords();
|
|
3787
|
+
if (!records.length) return;
|
|
3788
|
+
const byId = new Map(records.map((record) => [record.id, record]));
|
|
3789
|
+
const known = records.map(({ id }) => id);
|
|
3790
|
+
const storedOrder = Array.isArray(controlDeckLayout.sectionLayout?.order) ? controlDeckLayout.sectionLayout.order : [];
|
|
3791
|
+
const completeOrder = [...storedOrder, ...known.filter((id) => !storedOrder.includes(id))];
|
|
3792
|
+
const order = completeOrder.filter((id) => byId.has(id));
|
|
3793
|
+
const storedLeftIds = Array.isArray(controlDeckLayout.sectionLayout?.leftSectionIds) ? controlDeckLayout.sectionLayout.leftSectionIds : [];
|
|
3794
|
+
controlDeckLayout.sectionLayout = { order: completeOrder, leftSectionIds: storedLeftIds.filter((id) => completeOrder.includes(id)) };
|
|
3795
|
+
const placement = reconcileControlDeckPlacementConstraint();
|
|
3796
|
+
const presentation = effectiveControlDeckPresentation();
|
|
3797
|
+
const leftIds = new Set(controlDeckLayout.sectionLayout.leftSectionIds);
|
|
3798
|
+
const leftBody = elements.sidePanelBodyLeft;
|
|
3799
|
+
const rightBody = elements.sidePanelBodyRight || elements.sidePanel?.querySelector(".side-panel-body");
|
|
3800
|
+
const targetBody = presentation === "left" || presentation === "sidebar" ? leftBody : rightBody;
|
|
3801
|
+
const desiredSectionsByBody = new Map();
|
|
3802
|
+
for (const id of order) {
|
|
3803
|
+
const record = byId.get(id);
|
|
3804
|
+
if (!record) continue;
|
|
3805
|
+
const body = presentation === "both" ? (leftIds.has(id) ? leftBody : rightBody) : targetBody;
|
|
3806
|
+
if (!body) continue;
|
|
3807
|
+
if (!desiredSectionsByBody.has(body)) desiredSectionsByBody.set(body, []);
|
|
3808
|
+
desiredSectionsByBody.get(body).push(record.section);
|
|
3809
|
+
}
|
|
3810
|
+
for (const [body, desiredSections] of desiredSectionsByBody) {
|
|
3811
|
+
const currentSections = [...body.children].filter((child) => child.matches?.("[data-side-panel-section]"));
|
|
3812
|
+
const alreadyReconciled = currentSections.length === desiredSections.length
|
|
3813
|
+
&& desiredSections.every((section, index) => currentSections[index] === section);
|
|
3814
|
+
if (!alreadyReconciled) desiredSections.forEach((section) => body.append(section));
|
|
3815
|
+
}
|
|
3816
|
+
const sidebarPresentation = isControlDeckSidebarPresentation();
|
|
3817
|
+
document.body.classList.toggle("control-deck-both", presentation === "both");
|
|
3818
|
+
document.body.classList.toggle("control-deck-sidebar", sidebarPresentation);
|
|
3819
|
+
document.body.classList.toggle("terminal-tabs-sidebar-start", sidebarPresentation && placement === "right");
|
|
3820
|
+
document.body.classList.toggle("control-deck-overlay", presentation === "overlay");
|
|
3821
|
+
document.body.classList.toggle("control-deck-left", presentation === "left");
|
|
3822
|
+
document.body.classList.toggle("control-deck-right", presentation === "right" || presentation === "both" || presentation === "overlay");
|
|
3823
|
+
if (elements.sidePanelLeft) elements.sidePanelLeft.hidden = presentation !== "both" && presentation !== "left";
|
|
3824
|
+
if (elements.sidePanel) elements.sidePanel.hidden = presentation === "embedded" || presentation === "left";
|
|
3825
|
+
const activeShell = presentation === "left" ? elements.sidePanelLeft : elements.sidePanel;
|
|
3826
|
+
activeShell?.setAttribute("aria-label", presentation === "overlay" ? "Control Deck" : activeShell === elements.sidePanelLeft ? "Left Control Deck" : "Right Control Deck");
|
|
3827
|
+
const sharedFooter = document.querySelector("[data-control-deck-shared-footer]");
|
|
3828
|
+
const footerHost = activeShell === elements.sidePanelLeft
|
|
3829
|
+
? elements.sidePanelLeft?.querySelector("[data-control-deck-footer-slot]")
|
|
3830
|
+
: elements.sidePanel;
|
|
3831
|
+
if (sharedFooter && footerHost && sharedFooter.parentElement !== footerHost) footerHost.append(sharedFooter);
|
|
3832
|
+
const versionRow = document.querySelector(".side-panel-version-row");
|
|
3833
|
+
const versionHost = activeShell === elements.sidePanelLeft
|
|
3834
|
+
? elements.sidePanelLeft?.querySelector("[data-control-deck-version-slot]")
|
|
3835
|
+
: elements.sidePanel?.querySelector(".side-panel-heading");
|
|
3836
|
+
if (versionRow && versionHost && versionRow.parentElement !== versionHost) versionHost.append(versionRow);
|
|
3837
|
+
const editButton = elements.sidePanelEditButton;
|
|
3838
|
+
const editHost = activeShell === elements.sidePanelLeft
|
|
3839
|
+
? elements.sidePanelLeft?.querySelector("[data-control-deck-edit-slot]")
|
|
3840
|
+
: elements.toggleSidePanelButton?.parentElement;
|
|
3841
|
+
if (editButton && editHost && editButton.parentElement !== editHost) editHost.prepend(editButton);
|
|
3842
|
+
editButton?.setAttribute("aria-controls", activeShell?.id || "sidePanel");
|
|
3843
|
+
if (elements.controlDeckPlacementSelect) elements.controlDeckPlacementSelect.value = placement;
|
|
3844
|
+
if (elements.controlDeckPlacementStatus) {
|
|
3845
|
+
const label = `${placement[0].toUpperCase()}${placement.slice(1)}`;
|
|
3846
|
+
const statusText = sidebarPresentation
|
|
3847
|
+
? placement === "right"
|
|
3848
|
+
? `${label} · Control Deck right, terminal/tabs left`
|
|
3849
|
+
: placement === "left"
|
|
3850
|
+
? `${label} · Control Deck left, terminal/tabs right`
|
|
3851
|
+
: `${label} · Control Deck on both sides, terminal/tabs right`
|
|
3852
|
+
: `${label} · saved in WebUI layout`;
|
|
3853
|
+
if (elements.controlDeckPlacementStatus.textContent !== statusText) elements.controlDeckPlacementStatus.textContent = statusText;
|
|
3854
|
+
}
|
|
3855
|
+
syncControlDeckCollapsedClasses();
|
|
3856
|
+
updateSidePanelResizeHandle(controlDeckLayout.panelWidths?.left || SIDE_PANEL_WIDTH_DEFAULT_PX, "left");
|
|
3857
|
+
updateSidePanelResizeHandle(controlDeckLayout.panelWidths?.right || readStoredSidePanelWidth() || SIDE_PANEL_WIDTH_DEFAULT_PX, "right");
|
|
3858
|
+
requestAnimationFrame(syncResizablePanelWidthsForViewport);
|
|
3859
|
+
for (const record of records) updateSidePanelSectionEditAffordance(record);
|
|
3860
|
+
}
|
|
3861
|
+
|
|
3862
|
+
function reconcileControlDeckPresentation() {
|
|
3863
|
+
if (controlDeckPresentationReconcileActive) return;
|
|
3864
|
+
controlDeckPresentationReconcileActive = true;
|
|
3865
|
+
try {
|
|
3866
|
+
const wasOverlay = document.body.classList.contains("control-deck-overlay");
|
|
3867
|
+
const willOverlay = isControlDeckOverlayPresentation();
|
|
3868
|
+
reconcileControlDeckHosts();
|
|
3869
|
+
if (willOverlay && !wasOverlay) {
|
|
3870
|
+
setSidePanelCollapsed(true, { persist: false });
|
|
3871
|
+
} else if (!willOverlay && wasOverlay) {
|
|
3872
|
+
restoreSidePanelState();
|
|
3873
|
+
} else {
|
|
3874
|
+
syncMobileSidePanelState(willOverlay ? document.body.classList.contains("side-panel-collapsed") : true);
|
|
3875
|
+
}
|
|
3876
|
+
if (willOverlay !== wasOverlay) updateTerminalSplitUi();
|
|
3877
|
+
updateTerminalSplitControls(Boolean(terminalSplitTab()) && !embeddedSplitMode && !willOverlay);
|
|
3878
|
+
syncResizablePanelWidthsForViewport();
|
|
3879
|
+
} finally {
|
|
3880
|
+
controlDeckPresentationReconcileActive = false;
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3883
|
+
|
|
3884
|
+
function scheduleControlDeckPresentationReconciliation() {
|
|
3885
|
+
if (controlDeckPresentationReconcileFrame !== null) return;
|
|
3886
|
+
controlDeckPresentationReconcileFrame = requestAnimationFrame(() => {
|
|
3887
|
+
controlDeckPresentationReconcileFrame = null;
|
|
3888
|
+
reconcileControlDeckPresentation();
|
|
3889
|
+
});
|
|
3890
|
+
}
|
|
3891
|
+
|
|
3709
3892
|
function readStoredSidePanelSectionOrder() {
|
|
3710
3893
|
try {
|
|
3711
3894
|
const parsed = JSON.parse(localStorage.getItem(SIDE_PANEL_SECTION_ORDER_STORAGE_KEY) || "[]");
|
|
@@ -3715,27 +3898,26 @@ function readStoredSidePanelSectionOrder() {
|
|
|
3715
3898
|
}
|
|
3716
3899
|
}
|
|
3717
3900
|
|
|
3901
|
+
function persistControlDeckSectionLayout() {
|
|
3902
|
+
const known = controlDeckSectionRecords().map(({ id }) => id);
|
|
3903
|
+
const previousOrder = Array.isArray(controlDeckLayout.sectionLayout?.order) ? controlDeckLayout.sectionLayout.order : [];
|
|
3904
|
+
const order = [...previousOrder.filter((id) => known.includes(id)), ...known.filter((id) => !previousOrder.includes(id))];
|
|
3905
|
+
const leftSectionIds = (controlDeckLayout.sectionLayout?.leftSectionIds || []).filter((id) => order.includes(id));
|
|
3906
|
+
controlDeckLayout.sectionLayout = { order, leftSectionIds };
|
|
3907
|
+
cacheControlDeckLayout(controlDeckLayout, "sectionLayout");
|
|
3908
|
+
try { localStorage.setItem(SIDE_PANEL_SECTION_ORDER_STORAGE_KEY, JSON.stringify(order)); } catch { /* cache is best effort */ }
|
|
3909
|
+
markDurableUiLayoutDirty("sidePanel", "sectionLayout");
|
|
3910
|
+
}
|
|
3911
|
+
|
|
3718
3912
|
function persistSidePanelSectionOrder() {
|
|
3719
|
-
|
|
3720
|
-
localStorage.setItem(SIDE_PANEL_SECTION_ORDER_STORAGE_KEY, JSON.stringify(sidePanelSectionRecords().map(({ id }) => id)));
|
|
3721
|
-
} catch {
|
|
3722
|
-
// Ignore storage failures; ordering should still work for this page load.
|
|
3723
|
-
}
|
|
3724
|
-
markDurableUiLayoutDirty("sidePanel", "sectionOrder");
|
|
3913
|
+
persistControlDeckSectionLayout();
|
|
3725
3914
|
}
|
|
3726
3915
|
|
|
3727
3916
|
function restoreSidePanelSectionOrder() {
|
|
3728
3917
|
if (sidePanelSectionPointerDrag?.active) return;
|
|
3729
|
-
const
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
const rank = new Map(readStoredSidePanelSectionOrder().map((id, index) => [id, index]));
|
|
3733
|
-
records.sort((a, b) => {
|
|
3734
|
-
const aRank = rank.has(a.id) ? rank.get(a.id) : Number.MAX_SAFE_INTEGER;
|
|
3735
|
-
const bRank = rank.has(b.id) ? rank.get(b.id) : Number.MAX_SAFE_INTEGER;
|
|
3736
|
-
return aRank - bRank;
|
|
3737
|
-
});
|
|
3738
|
-
for (const { section } of records) parent.append(section);
|
|
3918
|
+
const storedOrder = controlDeckLayout.sectionLayout?.order || readStoredSidePanelSectionOrder() || [];
|
|
3919
|
+
controlDeckLayout.sectionLayout = { order: storedOrder, leftSectionIds: controlDeckLayout.sectionLayout?.leftSectionIds || [] };
|
|
3920
|
+
reconcileControlDeckHosts();
|
|
3739
3921
|
}
|
|
3740
3922
|
|
|
3741
3923
|
function visibleSidePanelSectionRecords() {
|
|
@@ -3757,11 +3939,14 @@ function updateSidePanelSectionEditAffordance(record) {
|
|
|
3757
3939
|
const label = record.button.querySelector(".side-panel-section-label")?.textContent?.trim() || "side panel";
|
|
3758
3940
|
const action = `${collapsed ? "Expand" : "Collapse"} ${label} section`;
|
|
3759
3941
|
const reorderingEnabled = isSidePanelSectionReorderingEnabled();
|
|
3942
|
+
const horizontalEnabled = reorderingEnabled && effectiveControlDeckPresentation() === "both";
|
|
3760
3943
|
record.button.setAttribute("aria-label", action);
|
|
3761
3944
|
record.button.setAttribute("title", reorderingEnabled
|
|
3762
|
-
? `${action} · drag to reorder · Alt+↑/↓ moves`
|
|
3945
|
+
? `${action} · drag to reorder · ${horizontalEnabled ? "Alt+↑/↓ reorders · Alt+←/→ moves sides" : "Alt+↑/↓ moves"}`
|
|
3763
3946
|
: action);
|
|
3764
|
-
if (reorderingEnabled) record.button.setAttribute("aria-keyshortcuts",
|
|
3947
|
+
if (reorderingEnabled) record.button.setAttribute("aria-keyshortcuts", horizontalEnabled
|
|
3948
|
+
? "Alt+ArrowUp Alt+ArrowDown Alt+ArrowLeft Alt+ArrowRight"
|
|
3949
|
+
: "Alt+ArrowUp Alt+ArrowDown");
|
|
3765
3950
|
else record.button.removeAttribute("aria-keyshortcuts");
|
|
3766
3951
|
}
|
|
3767
3952
|
|
|
@@ -3774,6 +3959,7 @@ function cancelSidePanelSectionPointerDrag() {
|
|
|
3774
3959
|
sidePanelSectionRecords().find(({ id }) => id === drag.sectionId)?.section.classList.remove("dragging");
|
|
3775
3960
|
sidePanelSectionPointerDrag = null;
|
|
3776
3961
|
sidePanelSectionLastDragOverKey = "";
|
|
3962
|
+
document.body.classList.remove("control-deck-section-dragging");
|
|
3777
3963
|
clearSidePanelSectionDragMarkers();
|
|
3778
3964
|
}
|
|
3779
3965
|
|
|
@@ -3795,31 +3981,84 @@ function setSidePanelSectionEditMode(enabled) {
|
|
|
3795
3981
|
for (const record of sidePanelSectionRecords()) updateSidePanelSectionEditAffordance(record);
|
|
3796
3982
|
}
|
|
3797
3983
|
|
|
3798
|
-
function moveSidePanelSectionRelative(fromId, targetRecord, insertBefore) {
|
|
3984
|
+
function moveSidePanelSectionRelative(fromId, targetRecord, insertBefore, targetSide = null) {
|
|
3799
3985
|
if (!isSidePanelSectionReorderingEnabled()) return false;
|
|
3800
3986
|
const sourceRecord = sidePanelSectionRecords().find(({ id }) => id === fromId);
|
|
3801
3987
|
if (!sourceRecord || !targetRecord || sourceRecord.section === targetRecord.section) return false;
|
|
3802
|
-
const parent =
|
|
3803
|
-
if (!parent
|
|
3988
|
+
const parent = targetRecord.section.parentElement;
|
|
3989
|
+
if (!parent) return false;
|
|
3990
|
+
const side = targetSide || (parent === elements.sidePanelBodyLeft ? "left" : "right");
|
|
3804
3991
|
clearSidePanelSectionDragMarkers();
|
|
3805
3992
|
targetRecord.section.classList.add(insertBefore ? "drag-over-before" : "drag-over-after");
|
|
3806
|
-
sidePanelSectionLastDragOverKey = `${targetRecord.id}:${insertBefore ? "before" : "after"}`;
|
|
3993
|
+
sidePanelSectionLastDragOverKey = `${side}:${targetRecord.id}:${insertBefore ? "before" : "after"}`;
|
|
3807
3994
|
if (insertBefore) parent.insertBefore(sourceRecord.section, targetRecord.section);
|
|
3808
3995
|
else parent.insertBefore(sourceRecord.section, targetRecord.section.nextSibling);
|
|
3809
|
-
|
|
3996
|
+
controlDeckLayout.sectionLayout = controlDeckLayout.sectionLayout || { order: [], leftSectionIds: [] };
|
|
3997
|
+
const order = controlDeckLayout.sectionLayout.order.filter((id) => id !== fromId);
|
|
3998
|
+
const targetIndex = order.indexOf(targetRecord.id);
|
|
3999
|
+
order.splice(Math.max(0, targetIndex + (insertBefore ? 0 : 1)), 0, fromId);
|
|
4000
|
+
controlDeckLayout.sectionLayout.order = order;
|
|
4001
|
+
if (effectiveControlDeckPresentation() === "both" && controlDeckSectionSide(fromId) !== side) {
|
|
4002
|
+
const left = new Set(controlDeckLayout.sectionLayout.leftSectionIds || []);
|
|
4003
|
+
if (side === "left") left.add(fromId); else left.delete(fromId);
|
|
4004
|
+
controlDeckLayout.sectionLayout.leftSectionIds = [...left].filter((id) => order.includes(id));
|
|
4005
|
+
}
|
|
3810
4006
|
return true;
|
|
3811
4007
|
}
|
|
3812
4008
|
|
|
4009
|
+
function completeControlDeckSectionSideMove(record, side) {
|
|
4010
|
+
if (!record) return;
|
|
4011
|
+
if (!record.section.classList.contains("collapsed")) setOnlySidePanelSectionExpanded(record);
|
|
4012
|
+
const sideRecords = sidePanelSectionRecords()
|
|
4013
|
+
.filter(({ id, section }) => !section.hidden && controlDeckSectionSide(id) === side)
|
|
4014
|
+
.sort((a, b) => controlDeckLayout.sectionLayout.order.indexOf(a.id) - controlDeckLayout.sectionLayout.order.indexOf(b.id));
|
|
4015
|
+
const ordinal = Math.max(1, sideRecords.findIndex(({ id }) => id === record.id) + 1);
|
|
4016
|
+
const label = record.button.querySelector(".side-panel-section-label")?.textContent?.trim() || record.id;
|
|
4017
|
+
if (elements.controlDeckMovementAnnouncer) elements.controlDeckMovementAnnouncer.textContent = `${label} moved to the ${side} Control Deck, position ${ordinal} of ${sideRecords.length}.`;
|
|
4018
|
+
queueMicrotask(() => record.button.focus({ preventScroll: true }));
|
|
4019
|
+
}
|
|
4020
|
+
|
|
4021
|
+
function moveSidePanelSectionToSide(sectionId, side) {
|
|
4022
|
+
if (!isSidePanelSectionReorderingEnabled() || effectiveControlDeckPresentation() !== "both") return false;
|
|
4023
|
+
if (controlDeckSectionSide(sectionId) === side) return false;
|
|
4024
|
+
const record = sidePanelSectionRecords().find(({ id }) => id === sectionId);
|
|
4025
|
+
const body = side === "left" ? elements.sidePanelBodyLeft : elements.sidePanelBodyRight;
|
|
4026
|
+
if (!record || !body) return false;
|
|
4027
|
+
const targetSection = [...body.querySelectorAll(":scope > [data-side-panel-section]")].at(-1);
|
|
4028
|
+
let moved = false;
|
|
4029
|
+
if (targetSection) {
|
|
4030
|
+
const target = sidePanelSectionRecords().find(({ section }) => section === targetSection);
|
|
4031
|
+
if (target) moved = moveSidePanelSectionRelative(sectionId, target, false, side);
|
|
4032
|
+
} else {
|
|
4033
|
+
body.append(record.section);
|
|
4034
|
+
const order = controlDeckLayout.sectionLayout.order.filter((id) => id !== sectionId);
|
|
4035
|
+
order.push(sectionId);
|
|
4036
|
+
const left = new Set(controlDeckLayout.sectionLayout.leftSectionIds || []);
|
|
4037
|
+
if (side === "left") left.add(sectionId); else left.delete(sectionId);
|
|
4038
|
+
controlDeckLayout.sectionLayout = { order, leftSectionIds: [...left] };
|
|
4039
|
+
moved = true;
|
|
4040
|
+
}
|
|
4041
|
+
if (moved && !sidePanelSectionPointerDrag?.active) completeControlDeckSectionSideMove(record, side);
|
|
4042
|
+
return moved;
|
|
4043
|
+
}
|
|
4044
|
+
|
|
3813
4045
|
function moveSidePanelSectionByOffset(sectionId, offset) {
|
|
3814
4046
|
if (!isSidePanelSectionReorderingEnabled()) return false;
|
|
3815
|
-
const
|
|
4047
|
+
const sourceSide = controlDeckSectionSide(sectionId);
|
|
4048
|
+
const rank = new Map((controlDeckLayout.sectionLayout?.order || []).map((id, index) => [id, index]));
|
|
4049
|
+
const records = visibleSidePanelSectionRecords()
|
|
4050
|
+
.filter(({ id }) => controlDeckSectionSide(id) === sourceSide)
|
|
4051
|
+
.sort((a, b) => (rank.get(a.id) ?? Number.MAX_SAFE_INTEGER) - (rank.get(b.id) ?? Number.MAX_SAFE_INTEGER));
|
|
3816
4052
|
const fromIndex = records.findIndex(({ id }) => id === sectionId);
|
|
3817
4053
|
const toIndex = fromIndex + offset;
|
|
3818
4054
|
if (fromIndex < 0 || toIndex < 0 || toIndex >= records.length) return false;
|
|
3819
4055
|
const targetRecord = records[toIndex];
|
|
3820
4056
|
const moved = moveSidePanelSectionRelative(sectionId, targetRecord, offset < 0);
|
|
3821
4057
|
clearSidePanelSectionDragMarkers();
|
|
3822
|
-
if (moved)
|
|
4058
|
+
if (moved) {
|
|
4059
|
+
persistControlDeckSectionLayout();
|
|
4060
|
+
queueMicrotask(() => sidePanelSectionRecords().find(({ id }) => id === sectionId)?.button.focus({ preventScroll: true }));
|
|
4061
|
+
}
|
|
3823
4062
|
return moved;
|
|
3824
4063
|
}
|
|
3825
4064
|
|
|
@@ -3829,7 +4068,7 @@ function sidePanelSectionToggleFromPoint(clientX, clientY) {
|
|
|
3829
4068
|
|
|
3830
4069
|
function beginSidePanelSectionPointerDrag(event, sectionId) {
|
|
3831
4070
|
if (!isSidePanelSectionReorderingEnabled() || event.button !== 0 || !sectionId || sidePanelSectionPointerDrag) return;
|
|
3832
|
-
sidePanelSectionPointerDrag = { sectionId, pointerId: event.pointerId, startX: event.clientX, startY: event.clientY, active: false };
|
|
4071
|
+
sidePanelSectionPointerDrag = { sectionId, pointerId: event.pointerId, startX: event.clientX, startY: event.clientY, startSide: controlDeckSectionSide(sectionId), active: false };
|
|
3833
4072
|
window.addEventListener("pointermove", updateSidePanelSectionPointerDrag, { capture: true });
|
|
3834
4073
|
window.addEventListener("pointerup", endSidePanelSectionPointerDrag, { capture: true });
|
|
3835
4074
|
window.addEventListener("pointercancel", endSidePanelSectionPointerDrag, { capture: true });
|
|
@@ -3844,6 +4083,7 @@ function updateSidePanelSectionPointerDrag(event) {
|
|
|
3844
4083
|
if (!drag.active) {
|
|
3845
4084
|
drag.active = true;
|
|
3846
4085
|
sidePanelSectionLastDragOverKey = "";
|
|
4086
|
+
document.body.classList.add("control-deck-section-dragging");
|
|
3847
4087
|
clearTimeout(pointerActivationTimeout);
|
|
3848
4088
|
pointerActivationTimeout = null;
|
|
3849
4089
|
activePointerActivation = null;
|
|
@@ -3854,12 +4094,16 @@ function updateSidePanelSectionPointerDrag(event) {
|
|
|
3854
4094
|
const targetRecord = targetToggle
|
|
3855
4095
|
? sidePanelSectionRecords().find(({ button }) => button === targetToggle)
|
|
3856
4096
|
: null;
|
|
3857
|
-
if (
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
4097
|
+
if (targetRecord && targetRecord.id !== drag.sectionId && !targetRecord.section.hidden) {
|
|
4098
|
+
const rect = targetToggle.getBoundingClientRect();
|
|
4099
|
+
const insertBefore = event.clientY < rect.top + rect.height / 2;
|
|
4100
|
+
const targetSide = targetRecord.section.parentElement === elements.sidePanelBodyLeft ? "left" : "right";
|
|
4101
|
+
const markerKey = `${targetSide}:${targetRecord.id}:${insertBefore ? "before" : "after"}`;
|
|
4102
|
+
if (markerKey !== sidePanelSectionLastDragOverKey) moveSidePanelSectionRelative(drag.sectionId, targetRecord, insertBefore, targetSide);
|
|
4103
|
+
return;
|
|
4104
|
+
}
|
|
4105
|
+
const dropTarget = document.elementFromPoint(event.clientX, event.clientY)?.closest?.("[data-control-deck-drop-target]");
|
|
4106
|
+
if (dropTarget) moveSidePanelSectionToSide(drag.sectionId, dropTarget.dataset.controlDeckDropTarget);
|
|
3863
4107
|
}
|
|
3864
4108
|
|
|
3865
4109
|
function endSidePanelSectionPointerDrag(event) {
|
|
@@ -3871,11 +4115,14 @@ function endSidePanelSectionPointerDrag(event) {
|
|
|
3871
4115
|
const sourceRecord = sidePanelSectionRecords().find(({ id }) => id === drag.sectionId);
|
|
3872
4116
|
sidePanelSectionPointerDrag = null;
|
|
3873
4117
|
sidePanelSectionLastDragOverKey = "";
|
|
4118
|
+
document.body.classList.remove("control-deck-section-dragging");
|
|
3874
4119
|
clearSidePanelSectionDragMarkers();
|
|
3875
4120
|
sourceRecord?.section.classList.remove("dragging");
|
|
3876
4121
|
if (drag.active) {
|
|
3877
4122
|
sidePanelSectionSuppressClickUntil = Date.now() + 250;
|
|
3878
4123
|
event.preventDefault();
|
|
4124
|
+
const destinationSide = controlDeckSectionSide(drag.sectionId);
|
|
4125
|
+
if (destinationSide !== drag.startSide) completeControlDeckSectionSideMove(sourceRecord, destinationSide);
|
|
3879
4126
|
persistSidePanelSectionOrder();
|
|
3880
4127
|
queueMicrotask(() => sourceRecord?.button.focus({ preventScroll: true }));
|
|
3881
4128
|
}
|
|
@@ -3967,7 +4214,9 @@ function setSidePanelSectionCollapsed(record, collapsed, { persist = true } = {}
|
|
|
3967
4214
|
|
|
3968
4215
|
function setOnlySidePanelSectionExpanded(targetRecord, { persist = true } = {}) {
|
|
3969
4216
|
const targetId = targetRecord?.id || null;
|
|
4217
|
+
const targetSide = controlDeckSectionSide(targetId);
|
|
3970
4218
|
for (const record of sidePanelSectionRecords()) {
|
|
4219
|
+
if (controlDeckSectionSide(record.id) !== targetSide) continue;
|
|
3971
4220
|
setSidePanelSectionCollapsed(record, record.id !== targetId, { persist: false });
|
|
3972
4221
|
}
|
|
3973
4222
|
if (persist) persistSidePanelSectionState();
|
|
@@ -3976,10 +4225,15 @@ function setOnlySidePanelSectionExpanded(targetRecord, { persist = true } = {})
|
|
|
3976
4225
|
function restoreSidePanelSectionState() {
|
|
3977
4226
|
const records = sidePanelSectionRecords();
|
|
3978
4227
|
const collapsedIds = readStoredSidePanelSectionCollapsedIds();
|
|
3979
|
-
const
|
|
3980
|
-
|
|
4228
|
+
const expandedBySide = new Map();
|
|
4229
|
+
if (collapsedIds) {
|
|
4230
|
+
for (const record of records) {
|
|
4231
|
+
const side = controlDeckSectionSide(record.id);
|
|
4232
|
+
if (!collapsedIds.has(record.id) && !expandedBySide.has(side)) expandedBySide.set(side, record.id);
|
|
4233
|
+
}
|
|
4234
|
+
}
|
|
3981
4235
|
for (const record of records) {
|
|
3982
|
-
setSidePanelSectionCollapsed(record, record.id !==
|
|
4236
|
+
setSidePanelSectionCollapsed(record, expandedBySide.get(controlDeckSectionSide(record.id)) !== record.id, { persist: false });
|
|
3983
4237
|
}
|
|
3984
4238
|
}
|
|
3985
4239
|
|
|
@@ -4049,9 +4303,16 @@ function bindSidePanelSectionToggles() {
|
|
|
4049
4303
|
}
|
|
4050
4304
|
});
|
|
4051
4305
|
record.button.addEventListener("keydown", (event) => {
|
|
4052
|
-
if (!isSidePanelSectionReorderingEnabled() || !event.altKey ||
|
|
4053
|
-
event.
|
|
4054
|
-
|
|
4306
|
+
if (!isSidePanelSectionReorderingEnabled() || !event.altKey || !["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(event.key)) return;
|
|
4307
|
+
if ((event.key === "ArrowLeft" || event.key === "ArrowRight") && effectiveControlDeckPresentation() === "both") {
|
|
4308
|
+
event.preventDefault();
|
|
4309
|
+
if (moveSidePanelSectionToSide(record.id, event.key === "ArrowLeft" ? "left" : "right")) persistControlDeckSectionLayout();
|
|
4310
|
+
return;
|
|
4311
|
+
}
|
|
4312
|
+
if (event.key === "ArrowUp" || event.key === "ArrowDown") {
|
|
4313
|
+
event.preventDefault();
|
|
4314
|
+
moveSidePanelSectionByOffset(record.id, event.key === "ArrowUp" ? -1 : 1);
|
|
4315
|
+
}
|
|
4055
4316
|
});
|
|
4056
4317
|
record.button.addEventListener("pointerdown", (event) => beginSidePanelSectionPointerDrag(event, record.id));
|
|
4057
4318
|
}
|
|
@@ -4533,20 +4794,22 @@ function initializeComposerActionOrdering() {
|
|
|
4533
4794
|
}
|
|
4534
4795
|
|
|
4535
4796
|
function bindSidePanelContextMenu() {
|
|
4536
|
-
elements.
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4797
|
+
for (const shell of [elements.sidePanelLeft, elements.sidePanel]) {
|
|
4798
|
+
shell?.addEventListener("contextmenu", showSidePanelContextMenu);
|
|
4799
|
+
shell?.addEventListener("keydown", (event) => {
|
|
4800
|
+
if (event.key !== "ContextMenu" && !(event.shiftKey && event.key === "F10")) return;
|
|
4801
|
+
const trigger = event.target instanceof Element ? event.target : shell;
|
|
4802
|
+
const rect = trigger.getBoundingClientRect();
|
|
4803
|
+
showSidePanelContextMenu({
|
|
4804
|
+
preventDefault: () => event.preventDefault(),
|
|
4805
|
+
stopPropagation: () => event.stopPropagation(),
|
|
4806
|
+
clientX: rect.left + Math.min(rect.width, 24),
|
|
4807
|
+
clientY: rect.bottom,
|
|
4808
|
+
currentTarget: trigger,
|
|
4809
|
+
target: trigger,
|
|
4810
|
+
});
|
|
4548
4811
|
});
|
|
4549
|
-
}
|
|
4812
|
+
}
|
|
4550
4813
|
}
|
|
4551
4814
|
|
|
4552
4815
|
function readStoredAgentDoneNotificationsEnabled() {
|
|
@@ -4697,6 +4960,8 @@ function setTerminalTabsLayout(layout, { persist = true, announce = false } = {}
|
|
|
4697
4960
|
if (next === "left" && mobileTabsExpanded) setMobileTabsExpanded(false);
|
|
4698
4961
|
if (persist) persistTerminalTabsLayout(next);
|
|
4699
4962
|
renderTerminalTabsLayoutControl();
|
|
4963
|
+
reconcileControlDeckHosts?.();
|
|
4964
|
+
requestAnimationFrame(syncTerminalTabsSidebarWidthForViewport);
|
|
4700
4965
|
if (announce) addEvent(`terminal tabs layout changed to ${terminalTabsLayoutStatusText(next).toLowerCase()}`);
|
|
4701
4966
|
}
|
|
4702
4967
|
|
|
@@ -4704,6 +4969,133 @@ function restoreTerminalTabsLayoutSetting() {
|
|
|
4704
4969
|
setTerminalTabsLayout(readStoredTerminalTabsLayout(), { persist: false });
|
|
4705
4970
|
}
|
|
4706
4971
|
|
|
4972
|
+
function readStoredTerminalTabsSidebarWidth() {
|
|
4973
|
+
try {
|
|
4974
|
+
const width = Number.parseFloat(localStorage.getItem(TERMINAL_TABS_SIDEBAR_WIDTH_STORAGE_KEY) || "");
|
|
4975
|
+
return Number.isFinite(width) && width >= TERMINAL_TABS_SIDEBAR_WIDTH_MIN_PX && width <= TERMINAL_TABS_SIDEBAR_WIDTH_MAX_PX ? width : null;
|
|
4976
|
+
} catch {
|
|
4977
|
+
return null;
|
|
4978
|
+
}
|
|
4979
|
+
}
|
|
4980
|
+
|
|
4981
|
+
function persistTerminalTabsSidebarWidth(width) {
|
|
4982
|
+
try {
|
|
4983
|
+
localStorage.setItem(TERMINAL_TABS_SIDEBAR_WIDTH_STORAGE_KEY, String(Math.round(width)));
|
|
4984
|
+
} catch {
|
|
4985
|
+
// Browser storage is only the immediate fallback for durable layout state.
|
|
4986
|
+
}
|
|
4987
|
+
markDurableUiLayoutDirty("terminalTabs", "sidebarWidth");
|
|
4988
|
+
}
|
|
4989
|
+
|
|
4990
|
+
function terminalTabsSidebarResizeAvailable() {
|
|
4991
|
+
if (terminalTabsLayout !== "left" || isSidePanelOverlayView() || isMobileShellV2Active()) return false;
|
|
4992
|
+
return !!elements.terminalTabsShell && getComputedStyle(elements.terminalTabsShell).display !== "none";
|
|
4993
|
+
}
|
|
4994
|
+
|
|
4995
|
+
function terminalTabsSidebarMaxWidth() {
|
|
4996
|
+
const panel = elements.terminalTabsShell?.closest?.(".chat-panel");
|
|
4997
|
+
const panelWidth = panel?.getBoundingClientRect?.().width || window.innerWidth || TERMINAL_TABS_SIDEBAR_WIDTH_MIN_PX;
|
|
4998
|
+
const transcriptMinWidth = 320;
|
|
4999
|
+
return Math.max(
|
|
5000
|
+
TERMINAL_TABS_SIDEBAR_WIDTH_MIN_PX,
|
|
5001
|
+
Math.min(TERMINAL_TABS_SIDEBAR_WIDTH_MAX_PX, Math.floor(panelWidth * 0.72), Math.floor(panelWidth - transcriptMinWidth)),
|
|
5002
|
+
);
|
|
5003
|
+
}
|
|
5004
|
+
|
|
5005
|
+
function clampTerminalTabsSidebarWidth(width) {
|
|
5006
|
+
const number = Number(width);
|
|
5007
|
+
const fallback = readStoredTerminalTabsSidebarWidth() || elements.terminalTabsShell?.getBoundingClientRect?.().width || TERMINAL_TABS_SIDEBAR_WIDTH_MIN_PX;
|
|
5008
|
+
return Math.max(TERMINAL_TABS_SIDEBAR_WIDTH_MIN_PX, Math.min(terminalTabsSidebarMaxWidth(), Number.isFinite(number) ? number : fallback));
|
|
5009
|
+
}
|
|
5010
|
+
|
|
5011
|
+
function currentTerminalTabsSidebarWidth() {
|
|
5012
|
+
const width = elements.terminalTabsShell?.getBoundingClientRect?.().width;
|
|
5013
|
+
return Number.isFinite(width) && width > 0 ? width : readStoredTerminalTabsSidebarWidth() || TERMINAL_TABS_SIDEBAR_WIDTH_MIN_PX;
|
|
5014
|
+
}
|
|
5015
|
+
|
|
5016
|
+
function updateTerminalTabsSidebarResizeHandle(width = currentTerminalTabsSidebarWidth()) {
|
|
5017
|
+
const handle = elements.terminalTabsResizeHandle;
|
|
5018
|
+
if (!handle) return;
|
|
5019
|
+
const resizeAvailable = terminalTabsSidebarResizeAvailable();
|
|
5020
|
+
handle.hidden = !resizeAvailable;
|
|
5021
|
+
handle.setAttribute("aria-valuemin", String(TERMINAL_TABS_SIDEBAR_WIDTH_MIN_PX));
|
|
5022
|
+
handle.setAttribute("aria-valuemax", String(terminalTabsSidebarMaxWidth()));
|
|
5023
|
+
handle.setAttribute("aria-valuenow", String(Math.round(width)));
|
|
5024
|
+
handle.setAttribute("aria-valuetext", `${Math.round(width)} pixels wide`);
|
|
5025
|
+
}
|
|
5026
|
+
|
|
5027
|
+
function applyTerminalTabsSidebarWidth(width, { persist = false } = {}) {
|
|
5028
|
+
const clamped = clampTerminalTabsSidebarWidth(width);
|
|
5029
|
+
document.documentElement.style.setProperty("--terminal-tabs-sidebar-width", `${Math.round(clamped)}px`);
|
|
5030
|
+
updateTerminalTabsSidebarResizeHandle(clamped);
|
|
5031
|
+
if (persist) persistTerminalTabsSidebarWidth(clamped);
|
|
5032
|
+
return clamped;
|
|
5033
|
+
}
|
|
5034
|
+
|
|
5035
|
+
function restoreTerminalTabsSidebarWidthPreference() {
|
|
5036
|
+
const width = readStoredTerminalTabsSidebarWidth();
|
|
5037
|
+
if (width) document.documentElement.style.setProperty("--terminal-tabs-sidebar-width", `${Math.round(width)}px`);
|
|
5038
|
+
if (terminalTabsSidebarResizeAvailable()) applyTerminalTabsSidebarWidth(width || currentTerminalTabsSidebarWidth());
|
|
5039
|
+
else updateTerminalTabsSidebarResizeHandle(width || currentTerminalTabsSidebarWidth());
|
|
5040
|
+
}
|
|
5041
|
+
|
|
5042
|
+
function beginTerminalTabsSidebarResize(event) {
|
|
5043
|
+
if (!terminalTabsSidebarResizeAvailable()) return;
|
|
5044
|
+
if (event.button !== undefined && event.button !== 0) return;
|
|
5045
|
+
event.preventDefault();
|
|
5046
|
+
const startWidth = currentTerminalTabsSidebarWidth();
|
|
5047
|
+
terminalTabsResizeState = { pointerId: event.pointerId, startX: event.clientX, startWidth, width: startWidth };
|
|
5048
|
+
document.body.classList.add("terminal-tabs-resizing");
|
|
5049
|
+
elements.terminalTabsResizeHandle?.setPointerCapture?.(event.pointerId);
|
|
5050
|
+
window.addEventListener("pointermove", updateTerminalTabsSidebarResize, { passive: false });
|
|
5051
|
+
window.addEventListener("pointerup", finishTerminalTabsSidebarResize, { passive: false });
|
|
5052
|
+
window.addEventListener("pointercancel", finishTerminalTabsSidebarResize, { passive: false });
|
|
5053
|
+
}
|
|
5054
|
+
|
|
5055
|
+
function updateTerminalTabsSidebarResize(event) {
|
|
5056
|
+
const state = terminalTabsResizeState;
|
|
5057
|
+
if (!state || (event.pointerId !== undefined && event.pointerId !== state.pointerId)) return;
|
|
5058
|
+
event.preventDefault();
|
|
5059
|
+
const delta = event.clientX - state.startX;
|
|
5060
|
+
state.width = applyTerminalTabsSidebarWidth(state.startWidth + (document.body.classList.contains("terminal-tabs-sidebar-start") ? delta : -delta));
|
|
5061
|
+
}
|
|
5062
|
+
|
|
5063
|
+
function finishTerminalTabsSidebarResize(event) {
|
|
5064
|
+
const state = terminalTabsResizeState;
|
|
5065
|
+
if (!state || (event.pointerId !== undefined && event.pointerId !== state.pointerId)) return;
|
|
5066
|
+
event.preventDefault?.();
|
|
5067
|
+
elements.terminalTabsResizeHandle?.releasePointerCapture?.(state.pointerId);
|
|
5068
|
+
window.removeEventListener("pointermove", updateTerminalTabsSidebarResize);
|
|
5069
|
+
window.removeEventListener("pointerup", finishTerminalTabsSidebarResize);
|
|
5070
|
+
window.removeEventListener("pointercancel", finishTerminalTabsSidebarResize);
|
|
5071
|
+
document.body.classList.remove("terminal-tabs-resizing");
|
|
5072
|
+
applyTerminalTabsSidebarWidth(state.width, { persist: true });
|
|
5073
|
+
terminalTabsResizeState = null;
|
|
5074
|
+
}
|
|
5075
|
+
|
|
5076
|
+
function handleTerminalTabsSidebarResizeKeydown(event) {
|
|
5077
|
+
if (!terminalTabsSidebarResizeAvailable()) return;
|
|
5078
|
+
const step = event.shiftKey ? 80 : 24;
|
|
5079
|
+
const current = currentTerminalTabsSidebarWidth();
|
|
5080
|
+
let next = current;
|
|
5081
|
+
const sidebarAtStart = document.body.classList.contains("terminal-tabs-sidebar-start");
|
|
5082
|
+
if (event.key === "ArrowLeft") next = current + (sidebarAtStart ? -step : step);
|
|
5083
|
+
else if (event.key === "ArrowRight") next = current + (sidebarAtStart ? step : -step);
|
|
5084
|
+
else if (event.key === "Home") next = TERMINAL_TABS_SIDEBAR_WIDTH_MIN_PX;
|
|
5085
|
+
else if (event.key === "End") next = terminalTabsSidebarMaxWidth();
|
|
5086
|
+
else return;
|
|
5087
|
+
event.preventDefault();
|
|
5088
|
+
applyTerminalTabsSidebarWidth(next, { persist: true });
|
|
5089
|
+
}
|
|
5090
|
+
|
|
5091
|
+
function syncTerminalTabsSidebarWidthForViewport() {
|
|
5092
|
+
if (!terminalTabsSidebarResizeAvailable()) {
|
|
5093
|
+
updateTerminalTabsSidebarResizeHandle();
|
|
5094
|
+
return;
|
|
5095
|
+
}
|
|
5096
|
+
applyTerminalTabsSidebarWidth(readStoredTerminalTabsSidebarWidth() || currentTerminalTabsSidebarWidth());
|
|
5097
|
+
}
|
|
5098
|
+
|
|
4707
5099
|
function normalizeSubagentOpenMode(value) {
|
|
4708
5100
|
return SUBAGENT_OPEN_MODES.has(value) ? value : "overlay";
|
|
4709
5101
|
}
|
|
@@ -6695,50 +7087,82 @@ function deactivateDrawerModal(surface, { restoreFocus = true } = {}) {
|
|
|
6695
7087
|
}
|
|
6696
7088
|
|
|
6697
7089
|
function syncMobileSidePanelState(collapsed) {
|
|
6698
|
-
const
|
|
7090
|
+
const overlay = isControlDeckOverlayPresentation();
|
|
7091
|
+
const showBackdrop = !collapsed && overlay;
|
|
6699
7092
|
elements.sidePanelBackdrop.hidden = !showBackdrop;
|
|
6700
7093
|
if (showBackdrop) {
|
|
7094
|
+
mobileCanonicalUnmount();
|
|
6701
7095
|
activateDrawerModal(elements.sidePanel, elements.sidePanelExpandButton, {
|
|
6702
7096
|
close: () => setSidePanelCollapsed(true, { persist: false }),
|
|
6703
7097
|
});
|
|
6704
7098
|
} else {
|
|
6705
7099
|
deactivateDrawerModal(elements.sidePanel);
|
|
7100
|
+
if (collapsed && overlay && isMobileShellV2Active()) queueMicrotask(() => renderMobilePhoneExperience());
|
|
7101
|
+
}
|
|
7102
|
+
}
|
|
7103
|
+
|
|
7104
|
+
function syncControlDeckCollapsedClasses() {
|
|
7105
|
+
const presentation = effectiveControlDeckPresentation();
|
|
7106
|
+
const activeSide = presentation === "left" ? "left" : "right";
|
|
7107
|
+
if (presentation !== "overlay") {
|
|
7108
|
+
const singleCollapsed = presentation !== "both" && Boolean(controlDeckLayout.collapsedPanels?.[activeSide]);
|
|
7109
|
+
document.body.classList.toggle("side-panel-collapsed", singleCollapsed);
|
|
6706
7110
|
}
|
|
7111
|
+
const overlayClosed = presentation === "overlay" && document.body.classList.contains("side-panel-collapsed");
|
|
7112
|
+
const leftCollapsed = presentation !== "overlay" && Boolean(controlDeckLayout.collapsedPanels?.left);
|
|
7113
|
+
const rightCollapsed = presentation !== "overlay" && Boolean(controlDeckLayout.collapsedPanels?.right);
|
|
7114
|
+
document.body.classList.toggle("side-panel-left-collapsed", leftCollapsed);
|
|
7115
|
+
document.body.classList.toggle("side-panel-right-collapsed", rightCollapsed);
|
|
7116
|
+
elements.toggleSidePanelButton?.setAttribute("aria-expanded", rightCollapsed ? "false" : "true");
|
|
7117
|
+
elements.toggleSidePanelLeftButton?.setAttribute("aria-expanded", leftCollapsed ? "false" : "true");
|
|
7118
|
+
elements.sidePanelExpandButton?.setAttribute("aria-expanded", overlayClosed || rightCollapsed ? "false" : "true");
|
|
7119
|
+
elements.sidePanelLeftExpandButton?.setAttribute("aria-expanded", leftCollapsed ? "false" : "true");
|
|
6707
7120
|
}
|
|
6708
7121
|
|
|
6709
|
-
function setSidePanelCollapsed(collapsed, { persist = true, focusPanel = false } = {}) {
|
|
7122
|
+
function setSidePanelCollapsed(collapsed, { persist = true, focusPanel = false, side = null } = {}) {
|
|
6710
7123
|
if (collapsed) setSidePanelSectionEditMode(false);
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
7124
|
+
const presentation = effectiveControlDeckPresentation();
|
|
7125
|
+
const targetSide = side || (presentation === "left" ? "left" : "right");
|
|
7126
|
+
if (presentation === "overlay") {
|
|
7127
|
+
document.body.classList.toggle("side-panel-collapsed", collapsed);
|
|
7128
|
+
} else {
|
|
7129
|
+
controlDeckLayout.collapsedPanels = { ...controlDeckLayout.collapsedPanels, [targetSide]: collapsed };
|
|
7130
|
+
document.body.classList.toggle("side-panel-collapsed", collapsed && presentation !== "both");
|
|
7131
|
+
}
|
|
7132
|
+
syncControlDeckCollapsedClasses();
|
|
7133
|
+
elements.toggleSidePanelButton?.setAttribute("title", controlDeckLayout.collapsedPanels.right ? "Expand right Control Deck" : "Collapse right Control Deck");
|
|
7134
|
+
elements.toggleSidePanelButton?.setAttribute("aria-label", controlDeckLayout.collapsedPanels.right ? "Expand right Control Deck" : "Collapse right Control Deck");
|
|
7135
|
+
elements.toggleSidePanelLeftButton?.setAttribute("title", controlDeckLayout.collapsedPanels.left ? "Expand left Control Deck" : "Collapse left Control Deck");
|
|
7136
|
+
elements.toggleSidePanelLeftButton?.setAttribute("aria-label", controlDeckLayout.collapsedPanels.left ? "Expand left Control Deck" : "Collapse left Control Deck");
|
|
7137
|
+
syncMobileSidePanelState(presentation === "overlay" ? collapsed : true);
|
|
7138
|
+
updateSidePanelResizeHandle(currentSidePanelWidth(targetSide), targetSide);
|
|
7139
|
+
reconcileControlDeckHosts();
|
|
6718
7140
|
requestAnimationFrame(syncResizablePanelWidthsForViewport);
|
|
6719
7141
|
if (collapsed) closeSidePanelContextMenu({ returnFocus: false });
|
|
6720
|
-
|
|
6721
|
-
if (!
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
if (!persist || isSidePanelOverlayView()) return;
|
|
6726
|
-
try {
|
|
6727
|
-
localStorage.setItem(SIDE_PANEL_STORAGE_KEY, collapsed ? "1" : "0");
|
|
6728
|
-
} catch {
|
|
6729
|
-
// Ignore storage failures; the toggle should still work for this page load.
|
|
7142
|
+
if (focusPanel && !collapsed) (targetSide === "left" ? elements.toggleSidePanelLeftButton : elements.toggleSidePanelButton)?.focus?.({ preventScroll: true });
|
|
7143
|
+
if (!persist || presentation === "overlay") return;
|
|
7144
|
+
if (targetSide === "right") {
|
|
7145
|
+
try { localStorage.setItem(SIDE_PANEL_STORAGE_KEY, collapsed ? "1" : "0"); } catch { /* cache is best effort */ }
|
|
6730
7146
|
}
|
|
6731
|
-
|
|
7147
|
+
cacheControlDeckLayout(controlDeckLayout, "collapsedPanels");
|
|
7148
|
+
markDurableUiLayoutDirty("sidePanel", "collapsedPanels");
|
|
6732
7149
|
}
|
|
6733
7150
|
|
|
6734
7151
|
function restoreSidePanelState() {
|
|
6735
7152
|
if (isMobileShellV2Active()) return;
|
|
6736
|
-
if (
|
|
7153
|
+
if (isControlDeckOverlayPresentation()) {
|
|
6737
7154
|
setSidePanelCollapsed(true, { persist: false });
|
|
6738
7155
|
return;
|
|
6739
7156
|
}
|
|
6740
7157
|
const stored = readStoredSidePanelCollapsed();
|
|
6741
|
-
|
|
7158
|
+
const panels = controlDeckLayout.collapsedPanels || {};
|
|
7159
|
+
if (effectiveControlDeckPresentation() === "both") {
|
|
7160
|
+
setSidePanelCollapsed(Boolean(panels.right ?? stored ?? false), { persist: false, side: "right" });
|
|
7161
|
+
setSidePanelCollapsed(Boolean(panels.left ?? false), { persist: false, side: "left" });
|
|
7162
|
+
} else {
|
|
7163
|
+
const side = effectiveControlDeckPresentation() === "left" ? "left" : "right";
|
|
7164
|
+
setSidePanelCollapsed(Boolean(panels[side] ?? stored ?? false), { persist: false, side });
|
|
7165
|
+
}
|
|
6742
7166
|
}
|
|
6743
7167
|
|
|
6744
7168
|
function readStoredWorkspaceDashboardCollapsed() {
|
|
@@ -7922,20 +8346,56 @@ async function runPiUpdateAndRestart({ all = false } = {}) {
|
|
|
7922
8346
|
try {
|
|
7923
8347
|
plan = (await api("/api/update/plan", { method: "POST", body: { targets: all ? ["pi", "webui"] : ["pi"] }, scoped: false }))?.data?.plan;
|
|
7924
8348
|
} catch (error) {
|
|
7925
|
-
|
|
8349
|
+
const message = error.message || String(error);
|
|
8350
|
+
setServerActionStatus(message, "error");
|
|
8351
|
+
addEvent(message, "error");
|
|
8352
|
+
renderUpdateNotification(latestUpdateStatus, { force: true });
|
|
8353
|
+
return;
|
|
8354
|
+
}
|
|
8355
|
+
const planTargets = Array.isArray(plan?.targets) ? plan.targets : [];
|
|
8356
|
+
if (planTargets.length === 0) {
|
|
8357
|
+
const refused = Array.isArray(plan?.refusals) ? plan.refusals.map((item) => `${item.id}: ${item.guidance}`).join(" · ") : "";
|
|
8358
|
+
const message = refused ? `No update targets were accepted. ${refused}` : "No update targets were accepted; nothing was changed.";
|
|
8359
|
+
setServerActionStatus(message, "error");
|
|
8360
|
+
addEvent(message, "error");
|
|
8361
|
+
renderUpdateNotification(latestUpdateStatus, { force: true });
|
|
7926
8362
|
return;
|
|
7927
8363
|
}
|
|
7928
8364
|
if (!(await appConfirmText(piUpdateConfirmationText({ all, plan }), { affected: "Only targets accepted by the exact server-owned plan", confirmLabel: all ? "Apply exact update plan" : "Apply exact Pi plan" }))) return;
|
|
7929
8365
|
|
|
7930
8366
|
const updateLabel = all ? "Pi and Web UI exact updates" : "Pi exact update";
|
|
8367
|
+
const plannedRestart = planTargets.some((target) => target?.metadata?.managedRuntime === true);
|
|
8368
|
+
const progressMessage = plannedRestart
|
|
8369
|
+
? `Running ${updateLabel}. The server will restart after activation…`
|
|
8370
|
+
: `Running ${updateLabel}…`;
|
|
7931
8371
|
updateRequestInProgress = true;
|
|
7932
8372
|
hideUpdateNotification();
|
|
7933
8373
|
setServerActionBusy("Updating…");
|
|
7934
|
-
setServerActionStatus(
|
|
7935
|
-
setServerRestartOverlay(true,
|
|
8374
|
+
setServerActionStatus(progressMessage, "warn");
|
|
8375
|
+
if (plannedRestart) setServerRestartOverlay(true, progressMessage);
|
|
7936
8376
|
try {
|
|
7937
|
-
await api("/api/update/apply", { method: "POST", body: { transactionId: plan.transactionId, planDigest: plan.digest }, scoped: false });
|
|
7938
|
-
|
|
8377
|
+
const applyData = (await api("/api/update/apply", { method: "POST", body: { transactionId: plan.transactionId, planDigest: plan.digest }, scoped: false }))?.data || null;
|
|
8378
|
+
if (applyData?.state !== "activating") {
|
|
8379
|
+
updateRequestInProgress = false;
|
|
8380
|
+
setServerRestartOverlay(false);
|
|
8381
|
+
resetServerActionControls();
|
|
8382
|
+
const outcome = applyData?.outcome || applyData?.state || "failed";
|
|
8383
|
+
const succeeded = outcome === "success";
|
|
8384
|
+
const partial = outcome === "partial";
|
|
8385
|
+
const message = succeeded
|
|
8386
|
+
? `${updateLabel} completed without a Web UI restart.`
|
|
8387
|
+
: partial
|
|
8388
|
+
? `${updateLabel} completed partially; review the update receipts before retrying.`
|
|
8389
|
+
: `${updateLabel} did not complete; no Web UI restart was requested.`;
|
|
8390
|
+
const level = succeeded ? "success" : partial ? "warn" : "error";
|
|
8391
|
+
setServerActionStatus(message, level);
|
|
8392
|
+
addEvent(message, level === "success" ? "info" : level);
|
|
8393
|
+
if (succeeded) hideUpdateNotification({ remember: true });
|
|
8394
|
+
else renderUpdateNotification(latestUpdateStatus, { force: true });
|
|
8395
|
+
refreshUpdateStatus({ force: true, notify: false }).catch(() => {});
|
|
8396
|
+
return;
|
|
8397
|
+
}
|
|
8398
|
+
addEvent(`${updateLabel} verified; Pi Web UI server activation requested`, "warn");
|
|
7939
8399
|
} catch (error) {
|
|
7940
8400
|
if (!error?.backendOffline) {
|
|
7941
8401
|
updateRequestInProgress = false;
|
|
@@ -7947,10 +8407,10 @@ async function runPiUpdateAndRestart({ all = false } = {}) {
|
|
|
7947
8407
|
renderUpdateNotification(latestUpdateStatus, { force: true });
|
|
7948
8408
|
return;
|
|
7949
8409
|
}
|
|
7950
|
-
addEvent("Pi Web UI server connection dropped during update
|
|
8410
|
+
addEvent("Pi Web UI server connection dropped during update activation", "warn");
|
|
7951
8411
|
}
|
|
7952
8412
|
|
|
7953
|
-
setBackendOffline(true, new Error("update requested from side panel"));
|
|
8413
|
+
setBackendOffline(true, new Error("update activation requested from side panel"));
|
|
7954
8414
|
const restarted = await waitForServerRestart(serverBootIdentity);
|
|
7955
8415
|
updateRequestInProgress = false;
|
|
7956
8416
|
resetServerActionControls();
|
|
@@ -7961,8 +8421,8 @@ async function runPiUpdateAndRestart({ all = false } = {}) {
|
|
|
7961
8421
|
} else {
|
|
7962
8422
|
setServerRestartOverlay(false);
|
|
7963
8423
|
setBackendOffline(true, new Error("update restart reconnect timed out"));
|
|
7964
|
-
setServerActionStatus("Update
|
|
7965
|
-
addEvent("Pi Web UI server did not come back online after update
|
|
8424
|
+
setServerActionStatus("Update activation started, but the server did not reconnect automatically.", "error");
|
|
8425
|
+
addEvent("Pi Web UI server did not come back online after update activation", "error");
|
|
7966
8426
|
}
|
|
7967
8427
|
}
|
|
7968
8428
|
|
|
@@ -8849,6 +9309,8 @@ function loadDisabledOptionalFeatures() {
|
|
|
8849
9309
|
}
|
|
8850
9310
|
|
|
8851
9311
|
let disabledOptionalFeatures = new Set(loadDisabledOptionalFeatures());
|
|
9312
|
+
const optionalFeatureManagedAccessEnabled = new Map();
|
|
9313
|
+
const optionalFeatureAccessInProgress = new Set();
|
|
8852
9314
|
|
|
8853
9315
|
function storeDisabledOptionalFeatures() {
|
|
8854
9316
|
try {
|
|
@@ -8880,6 +9342,10 @@ function isOptionalFeatureDetected(featureId) {
|
|
|
8880
9342
|
}
|
|
8881
9343
|
|
|
8882
9344
|
function isOptionalFeatureDisabled(featureId) {
|
|
9345
|
+
const feature = OPTIONAL_FEATURE_BY_ID.get(featureId);
|
|
9346
|
+
if (feature?.manageWith === "tools" && optionalFeatureManagedAccessEnabled.has(featureId)) {
|
|
9347
|
+
return optionalFeatureManagedAccessEnabled.get(featureId) === false;
|
|
9348
|
+
}
|
|
8883
9349
|
return disabledOptionalFeatures.has(featureId);
|
|
8884
9350
|
}
|
|
8885
9351
|
|
|
@@ -10796,6 +11262,14 @@ function fileTreeGitStatusForEntry(entry = {}) {
|
|
|
10796
11262
|
return fileTreeState.gitStatusByPath.get(normalizeFileTreePath(entry.path || "")) || null;
|
|
10797
11263
|
}
|
|
10798
11264
|
|
|
11265
|
+
function fileTreeEntryGitIgnored(entry = {}) {
|
|
11266
|
+
return entry?.gitIgnored === true;
|
|
11267
|
+
}
|
|
11268
|
+
|
|
11269
|
+
function fileTreeGitIgnoredTitle(gitIgnored = false) {
|
|
11270
|
+
return gitIgnored ? "Ignored by Git" : "";
|
|
11271
|
+
}
|
|
11272
|
+
|
|
10799
11273
|
function fileTreeGitStatusClasses(status) {
|
|
10800
11274
|
const normalized = normalizeFileTreeGitStatus(status);
|
|
10801
11275
|
if (!normalized) return "";
|
|
@@ -10916,6 +11390,7 @@ function fileTreeEntryRenderSignature(entry = {}) {
|
|
|
10916
11390
|
entry.directory === true,
|
|
10917
11391
|
String(entry.extension || ""),
|
|
10918
11392
|
String(entry.error || ""),
|
|
11393
|
+
fileTreeEntryGitIgnored(entry),
|
|
10919
11394
|
];
|
|
10920
11395
|
}
|
|
10921
11396
|
|
|
@@ -11034,7 +11509,8 @@ function appendFileSearchEntry(parent, entry) {
|
|
|
11034
11509
|
const loading = isDirectory && fileTreeState.loading.has(path);
|
|
11035
11510
|
const gitStatus = fileTreeGitStatusForEntry(entry);
|
|
11036
11511
|
const gitStatusClasses = fileTreeGitStatusClasses(gitStatus);
|
|
11037
|
-
const
|
|
11512
|
+
const gitIgnored = fileTreeEntryGitIgnored(entry);
|
|
11513
|
+
const item = make("li", `file-tree-node file-tree-search-node ${entry.type || "file"}${gitStatusClasses ? ` ${gitStatusClasses}` : ""}${gitIgnored ? " git-ignored" : ""}${expanded ? " expanded" : ""}${fileTreeState.selectedPath === path ? " selected" : ""}`);
|
|
11038
11514
|
item.setAttribute("role", "none");
|
|
11039
11515
|
const button = make("button", "file-tree-item file-tree-search-item");
|
|
11040
11516
|
button.type = "button";
|
|
@@ -11047,7 +11523,7 @@ function appendFileSearchEntry(parent, entry) {
|
|
|
11047
11523
|
button.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
11048
11524
|
button.setAttribute("aria-label", `${expanded ? "Collapse" : "Expand"} ${entry.name || fileDisplayName(path)}`);
|
|
11049
11525
|
}
|
|
11050
|
-
button.title = [path || ".", fileTreeGitStatusTitle(gitStatus), entry.error || ""].filter(Boolean).join("\n");
|
|
11526
|
+
button.title = [path || ".", fileTreeGitIgnoredTitle(gitIgnored), fileTreeGitStatusTitle(gitStatus), entry.error || ""].filter(Boolean).join("\n");
|
|
11051
11527
|
const contextPath = fileParentPath(path) || ".";
|
|
11052
11528
|
const label = make("span", "file-tree-search-label");
|
|
11053
11529
|
label.append(
|
|
@@ -11113,7 +11589,8 @@ function appendFileTreeEntry(parent, entry, depth = 0) {
|
|
|
11113
11589
|
const loading = isDirectory && fileTreeState.loading.has(path);
|
|
11114
11590
|
const gitStatus = fileTreeGitStatusForEntry(entry);
|
|
11115
11591
|
const gitStatusClasses = fileTreeGitStatusClasses(gitStatus);
|
|
11116
|
-
const
|
|
11592
|
+
const gitIgnored = fileTreeEntryGitIgnored(entry);
|
|
11593
|
+
const item = make("li", `file-tree-node ${entry.type || "file"}${gitStatusClasses ? ` ${gitStatusClasses}` : ""}${gitIgnored ? " git-ignored" : ""}${expanded ? " expanded" : ""}${fileTreeState.selectedPath === path ? " selected" : ""}`);
|
|
11117
11594
|
item.setAttribute("role", "none");
|
|
11118
11595
|
const button = make("button", "file-tree-item");
|
|
11119
11596
|
button.type = "button";
|
|
@@ -11126,7 +11603,7 @@ function appendFileTreeEntry(parent, entry, depth = 0) {
|
|
|
11126
11603
|
button.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
11127
11604
|
button.setAttribute("aria-label", `${expanded ? "Collapse" : "Expand"} ${entry.name || fileDisplayName(path)}`);
|
|
11128
11605
|
}
|
|
11129
|
-
button.title = [path || ".", fileTreeGitStatusTitle(gitStatus), entry.error || ""].filter(Boolean).join("\n");
|
|
11606
|
+
button.title = [path || ".", fileTreeGitIgnoredTitle(gitIgnored), fileTreeGitStatusTitle(gitStatus), entry.error || ""].filter(Boolean).join("\n");
|
|
11130
11607
|
button.append(
|
|
11131
11608
|
isDirectory ? fileTreeExpander(expanded) : make("span", "file-tree-expander-spacer"),
|
|
11132
11609
|
make("span", `file-tree-icon ${isDirectory && expanded ? "expanded" : ""}`, loading ? "…" : fileEntryIcon(entry)),
|
|
@@ -11868,16 +12345,17 @@ async function moveFileTreeEntry(entry = fileContextMenuState?.entry) {
|
|
|
11868
12345
|
// per-user layout lives in the WebUI settings file behind
|
|
11869
12346
|
// GET/PUT /api/interface-preferences. Local writes always apply first; server
|
|
11870
12347
|
// reconciliation is non-blocking, coalesced, and revision guarded.
|
|
11871
|
-
const UI_LAYOUT_SCHEMA_VERSION =
|
|
12348
|
+
const UI_LAYOUT_SCHEMA_VERSION = 2;
|
|
11872
12349
|
const UI_LAYOUT_ENDPOINT = "/api/interface-preferences";
|
|
11873
12350
|
const UI_LAYOUT_SAVE_DEBOUNCE_MS = 250;
|
|
11874
12351
|
const UI_LAYOUT_MAX_CONFLICT_RETRIES = 1;
|
|
11875
12352
|
const UI_LAYOUT_FIELDS = ["sidePanel", "composerActions", "footerScopedModelOrder", "terminalTabs", "fileViewerWidth"];
|
|
11876
|
-
const UI_LAYOUT_SIDE_PANEL_FIELDS = ["
|
|
12353
|
+
const UI_LAYOUT_SIDE_PANEL_FIELDS = ["placement", "sectionLayout", "collapsedSectionIds", "hiddenSectionIds", "collapsedPanels", "panelWidths"];
|
|
11877
12354
|
const REMOVED_SIDE_PANEL_SECTION_HEIGHT_STORAGE_KEY = "pi-webui-side-panel-section-heights-v1";
|
|
11878
12355
|
const UI_LAYOUT_COMPOSER_FIELDS = ["order", "grid"];
|
|
11879
|
-
const UI_LAYOUT_TERMINAL_FIELDS = ["layout", "customGroups"];
|
|
11880
|
-
const UI_LAYOUT_PENDING_STORAGE_PREFIX = "pi-webui-ui-layout-pending-
|
|
12356
|
+
const UI_LAYOUT_TERMINAL_FIELDS = ["layout", "customGroups", "sidebarWidth"];
|
|
12357
|
+
const UI_LAYOUT_PENDING_STORAGE_PREFIX = "pi-webui-ui-layout-pending-v4:";
|
|
12358
|
+
const UI_LAYOUT_LEGACY_PENDING_STORAGE_PREFIX = "pi-webui-ui-layout-pending-v3:";
|
|
11881
12359
|
const UI_LAYOUT_PENDING_WRITER_ID = globalThis.crypto?.randomUUID?.() || `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
11882
12360
|
let durableLayoutPendingMutationSerial = 0;
|
|
11883
12361
|
const UI_LAYOUT_ID_MAX_LENGTH = 256;
|
|
@@ -11942,13 +12420,79 @@ function durableLayoutStoredIdList(key) {
|
|
|
11942
12420
|
}
|
|
11943
12421
|
}
|
|
11944
12422
|
|
|
11945
|
-
function
|
|
12423
|
+
function normalizeControlDeckPlacement(value) {
|
|
12424
|
+
return ["right", "left", "both"].includes(value) ? value : CONTROL_DECK_DEFAULT_PLACEMENT;
|
|
12425
|
+
}
|
|
12426
|
+
|
|
12427
|
+
function defaultControlDeckLayout() {
|
|
12428
|
+
return {
|
|
12429
|
+
placement: CONTROL_DECK_DEFAULT_PLACEMENT,
|
|
12430
|
+
sectionLayout: { order: null, leftSectionIds: [] },
|
|
12431
|
+
collapsedSectionIds: null,
|
|
12432
|
+
hiddenSectionIds: null,
|
|
12433
|
+
collapsedPanels: { left: false, right: false },
|
|
12434
|
+
panelWidths: { left: SIDE_PANEL_WIDTH_DEFAULT_PX, right: SIDE_PANEL_WIDTH_DEFAULT_PX },
|
|
12435
|
+
};
|
|
12436
|
+
}
|
|
12437
|
+
|
|
12438
|
+
function readStoredControlDeckLayout() {
|
|
12439
|
+
const fallback = defaultControlDeckLayout();
|
|
12440
|
+
try {
|
|
12441
|
+
const raw = localStorage.getItem(CONTROL_DECK_LAYOUT_STORAGE_KEY);
|
|
12442
|
+
if (raw) {
|
|
12443
|
+
const parsed = JSON.parse(raw);
|
|
12444
|
+
return {
|
|
12445
|
+
...fallback,
|
|
12446
|
+
...parsed,
|
|
12447
|
+
placement: normalizeControlDeckPlacement(parsed?.placement),
|
|
12448
|
+
sectionLayout: parsed?.sectionLayout || fallback.sectionLayout,
|
|
12449
|
+
collapsedPanels: { ...fallback.collapsedPanels, ...(parsed?.collapsedPanels || {}) },
|
|
12450
|
+
panelWidths: { ...fallback.panelWidths, ...(parsed?.panelWidths || {}) },
|
|
12451
|
+
};
|
|
12452
|
+
}
|
|
12453
|
+
} catch { /* fall through to legacy cache */ }
|
|
12454
|
+
const order = durableLayoutStoredIdList(SIDE_PANEL_SECTION_ORDER_STORAGE_KEY);
|
|
11946
12455
|
const collapsed = readStoredSidePanelCollapsed();
|
|
12456
|
+
const width = readStoredSidePanelWidth();
|
|
12457
|
+
const migrated = { ...fallback, sectionLayout: { order, leftSectionIds: [] } };
|
|
12458
|
+
if (typeof collapsed === "boolean") migrated.collapsedPanels.right = collapsed;
|
|
12459
|
+
if (width) migrated.panelWidths.right = width;
|
|
12460
|
+
return migrated;
|
|
12461
|
+
}
|
|
12462
|
+
|
|
12463
|
+
let controlDeckLayout = readStoredControlDeckLayout();
|
|
12464
|
+
|
|
12465
|
+
function normalizedControlDeckLayout(next = {}) {
|
|
12466
|
+
return {
|
|
12467
|
+
...defaultControlDeckLayout(),
|
|
12468
|
+
...next,
|
|
12469
|
+
placement: normalizeControlDeckPlacement(next?.placement),
|
|
12470
|
+
sectionLayout: next?.sectionLayout || { order: null, leftSectionIds: [] },
|
|
12471
|
+
collapsedPanels: { left: false, right: false, ...(next?.collapsedPanels || {}) },
|
|
12472
|
+
panelWidths: { left: SIDE_PANEL_WIDTH_DEFAULT_PX, right: SIDE_PANEL_WIDTH_DEFAULT_PX, ...(next?.panelWidths || {}) },
|
|
12473
|
+
};
|
|
12474
|
+
}
|
|
12475
|
+
|
|
12476
|
+
function cacheControlDeckLayout(next = controlDeckLayout, subfield = null) {
|
|
12477
|
+
const incoming = normalizedControlDeckLayout(next);
|
|
12478
|
+
const current = readStoredControlDeckLayout();
|
|
12479
|
+
const cached = subfield ? normalizedControlDeckLayout({ ...current, [subfield]: incoming[subfield] }) : incoming;
|
|
12480
|
+
writeDurableLayoutCache(CONTROL_DECK_LAYOUT_STORAGE_KEY, JSON.stringify(cached));
|
|
12481
|
+
controlDeckLayout = subfield ? normalizedControlDeckLayout({ ...incoming, [subfield]: cached[subfield] }) : cached;
|
|
12482
|
+
return controlDeckLayout;
|
|
12483
|
+
}
|
|
12484
|
+
|
|
12485
|
+
function collectDurableSidePanelLayout() {
|
|
12486
|
+
const records = typeof controlDeckSectionRecords === "function" ? controlDeckSectionRecords() : [];
|
|
12487
|
+
const order = controlDeckLayout.sectionLayout?.order || records.map(({ id }) => id);
|
|
12488
|
+
const left = controlDeckLayout.sectionLayout?.leftSectionIds || [];
|
|
11947
12489
|
return {
|
|
11948
|
-
|
|
12490
|
+
placement: normalizeControlDeckPlacement(controlDeckLayout.placement),
|
|
12491
|
+
sectionLayout: { order, leftSectionIds: left.filter((id) => order.includes(id)) },
|
|
11949
12492
|
collapsedSectionIds: durableLayoutStoredIdList(SIDE_PANEL_SECTION_STORAGE_KEY),
|
|
11950
12493
|
hiddenSectionIds: durableLayoutStoredIdList(SIDE_PANEL_SECTION_VISIBILITY_STORAGE_KEY),
|
|
11951
|
-
|
|
12494
|
+
collapsedPanels: controlDeckLayout.collapsedPanels,
|
|
12495
|
+
panelWidths: controlDeckLayout.panelWidths,
|
|
11952
12496
|
};
|
|
11953
12497
|
}
|
|
11954
12498
|
|
|
@@ -12005,7 +12549,11 @@ function collectDurableTerminalTabsLayout() {
|
|
|
12005
12549
|
}
|
|
12006
12550
|
customGroups = { version: 1, groups };
|
|
12007
12551
|
}
|
|
12008
|
-
return {
|
|
12552
|
+
return {
|
|
12553
|
+
layout: TERMINAL_TABS_LAYOUTS.has(rawLayout) ? rawLayout : null,
|
|
12554
|
+
customGroups,
|
|
12555
|
+
sidebarWidth: readStoredTerminalTabsSidebarWidth(),
|
|
12556
|
+
};
|
|
12009
12557
|
}
|
|
12010
12558
|
|
|
12011
12559
|
function collectDurableFileViewerWidth() {
|
|
@@ -12043,6 +12591,14 @@ function durableUiLayoutValuePresent(value) {
|
|
|
12043
12591
|
return value !== null && value !== undefined;
|
|
12044
12592
|
}
|
|
12045
12593
|
|
|
12594
|
+
function durableUiLayoutSubfieldValuePresent(field, subfield, value) {
|
|
12595
|
+
if (!durableUiLayoutValuePresent(value)) return false;
|
|
12596
|
+
if (field === "sidePanel" && subfield === "sectionLayout") return Array.isArray(value?.order) && Array.isArray(value?.leftSectionIds);
|
|
12597
|
+
if (field === "sidePanel" && subfield === "collapsedPanels") return typeof value?.left === "boolean" || typeof value?.right === "boolean";
|
|
12598
|
+
if (field === "sidePanel" && subfield === "panelWidths") return Number.isFinite(value?.left) || Number.isFinite(value?.right);
|
|
12599
|
+
return true;
|
|
12600
|
+
}
|
|
12601
|
+
|
|
12046
12602
|
function durableUiLayoutMutationValue(field, subfield = null) {
|
|
12047
12603
|
const value = collectDurableUiLayoutField(field);
|
|
12048
12604
|
return subfield ? value?.[subfield] ?? null : value;
|
|
@@ -12058,23 +12614,38 @@ function durableUiLayoutPendingMutationRecords() {
|
|
|
12058
12614
|
try {
|
|
12059
12615
|
for (let index = 0; index < localStorage.length; index += 1) {
|
|
12060
12616
|
const key = localStorage.key(index);
|
|
12061
|
-
if (!key?.startsWith(UI_LAYOUT_PENDING_STORAGE_PREFIX)) continue;
|
|
12617
|
+
if (!key?.startsWith(UI_LAYOUT_PENDING_STORAGE_PREFIX) && !key?.startsWith(UI_LAYOUT_LEGACY_PENDING_STORAGE_PREFIX)) continue;
|
|
12062
12618
|
let value;
|
|
12063
12619
|
try {
|
|
12064
12620
|
value = JSON.parse(localStorage.getItem(key) || "null");
|
|
12065
12621
|
} catch {
|
|
12066
12622
|
continue;
|
|
12067
12623
|
}
|
|
12068
|
-
if (!value || value.version
|
|
12624
|
+
if (!value || ![3, 4].includes(value.version) || !UI_LAYOUT_FIELDS.includes(value.field)) continue;
|
|
12069
12625
|
const allowedSubfields = durableUiLayoutSubFields(value.field);
|
|
12070
|
-
|
|
12626
|
+
let subfield = typeof value.subfield === "string" ? value.subfield : null;
|
|
12627
|
+
let mutationValue = value.value;
|
|
12628
|
+
// v3 journals written before schema v2 used the four legacy side-panel
|
|
12629
|
+
// identities below. Translate at read time and retain the old immutable
|
|
12630
|
+
// key until the corresponding v2 mutation is acknowledged.
|
|
12631
|
+
if (value.field === "sidePanel" && subfield === "sectionOrder") {
|
|
12632
|
+
subfield = "sectionLayout";
|
|
12633
|
+
mutationValue = { order: durableLayoutIdList(value.value), leftSectionIds: [] };
|
|
12634
|
+
} else if (value.field === "sidePanel" && subfield === "collapsedSectionIds") {
|
|
12635
|
+
mutationValue = durableLayoutIdList(value.value);
|
|
12636
|
+
} else if (value.field === "sidePanel" && subfield === "hiddenSectionIds") {
|
|
12637
|
+
mutationValue = durableLayoutIdList(value.value);
|
|
12638
|
+
} else if (value.field === "sidePanel" && subfield === "collapsed") {
|
|
12639
|
+
subfield = "collapsedPanels";
|
|
12640
|
+
mutationValue = { right: typeof value.value === "boolean" ? value.value : null };
|
|
12641
|
+
}
|
|
12071
12642
|
if (subfield && !allowedSubfields?.includes(subfield)) continue;
|
|
12072
12643
|
if (allowedSubfields && value.field !== "composerActions" && !subfield) continue;
|
|
12073
12644
|
records.push({
|
|
12074
12645
|
key,
|
|
12075
12646
|
field: value.field,
|
|
12076
12647
|
subfield,
|
|
12077
|
-
value:
|
|
12648
|
+
value: mutationValue,
|
|
12078
12649
|
updatedAt: Number(value.updatedAt) || 0,
|
|
12079
12650
|
});
|
|
12080
12651
|
}
|
|
@@ -12089,7 +12660,7 @@ function writeDurableUiLayoutPendingMutation(field, subfield, value) {
|
|
|
12089
12660
|
durableLayoutPendingMutationSerial += 1;
|
|
12090
12661
|
const key = `${UI_LAYOUT_PENDING_STORAGE_PREFIX}${UI_LAYOUT_PENDING_WRITER_ID}:${Date.now().toString(36)}:${durableLayoutPendingMutationSerial.toString(36)}`;
|
|
12091
12662
|
localStorage.setItem(key, JSON.stringify({
|
|
12092
|
-
version:
|
|
12663
|
+
version: 4,
|
|
12093
12664
|
field,
|
|
12094
12665
|
subfield,
|
|
12095
12666
|
value,
|
|
@@ -12171,9 +12742,13 @@ function restoreDurableUiLayoutPendingJournal() {
|
|
|
12171
12742
|
? new Map(fieldCandidates.map((candidate) => [candidate.subfield, candidate.key]))
|
|
12172
12743
|
: null;
|
|
12173
12744
|
durableLayoutGenerations.set(field, generation);
|
|
12745
|
+
const restoredValue = collectDurableUiLayoutField(field);
|
|
12746
|
+
if (subfields) {
|
|
12747
|
+
for (const candidate of fieldCandidates) restoredValue[candidate.subfield] = candidate.value;
|
|
12748
|
+
}
|
|
12174
12749
|
durableLayoutDirtyFields.set(field, {
|
|
12175
12750
|
generation,
|
|
12176
|
-
value:
|
|
12751
|
+
value: restoredValue,
|
|
12177
12752
|
subfields,
|
|
12178
12753
|
subfieldGenerations,
|
|
12179
12754
|
subfieldMutationIds,
|
|
@@ -12185,9 +12760,15 @@ function restoreDurableUiLayoutPendingJournal() {
|
|
|
12185
12760
|
|
|
12186
12761
|
function applyDurableSidePanelLayout(value) {
|
|
12187
12762
|
if (!value) return;
|
|
12188
|
-
|
|
12189
|
-
|
|
12190
|
-
|
|
12763
|
+
const adoptedSubfields = [];
|
|
12764
|
+
if (value.placement) {
|
|
12765
|
+
controlDeckLayout.placement = normalizeControlDeckPlacement(value.placement);
|
|
12766
|
+
adoptedSubfields.push("placement");
|
|
12767
|
+
}
|
|
12768
|
+
if (value.sectionLayout) {
|
|
12769
|
+
controlDeckLayout.sectionLayout = value.sectionLayout;
|
|
12770
|
+
if (Array.isArray(value.sectionLayout.order)) writeDurableLayoutCache(SIDE_PANEL_SECTION_ORDER_STORAGE_KEY, JSON.stringify(value.sectionLayout.order));
|
|
12771
|
+
adoptedSubfields.push("sectionLayout");
|
|
12191
12772
|
}
|
|
12192
12773
|
if (Array.isArray(value.hiddenSectionIds)) {
|
|
12193
12774
|
writeDurableLayoutCache(SIDE_PANEL_SECTION_VISIBILITY_STORAGE_KEY, JSON.stringify(value.hiddenSectionIds));
|
|
@@ -12197,10 +12778,18 @@ function applyDurableSidePanelLayout(value) {
|
|
|
12197
12778
|
writeDurableLayoutCache(SIDE_PANEL_SECTION_STORAGE_KEY, JSON.stringify(value.collapsedSectionIds));
|
|
12198
12779
|
restoreSidePanelSectionState();
|
|
12199
12780
|
}
|
|
12200
|
-
if (typeof value.
|
|
12201
|
-
|
|
12202
|
-
|
|
12781
|
+
if (value.collapsedPanels && typeof value.collapsedPanels === "object") {
|
|
12782
|
+
controlDeckLayout.collapsedPanels = { ...controlDeckLayout.collapsedPanels, ...value.collapsedPanels };
|
|
12783
|
+
adoptedSubfields.push("collapsedPanels");
|
|
12784
|
+
}
|
|
12785
|
+
if (value.panelWidths && typeof value.panelWidths === "object") {
|
|
12786
|
+
controlDeckLayout.panelWidths = { ...controlDeckLayout.panelWidths, ...value.panelWidths };
|
|
12787
|
+
adoptedSubfields.push("panelWidths");
|
|
12203
12788
|
}
|
|
12789
|
+
for (const subfield of adoptedSubfields) cacheControlDeckLayout(controlDeckLayout, subfield);
|
|
12790
|
+
restoreSidePanelSectionOrder();
|
|
12791
|
+
reconcileControlDeckHosts();
|
|
12792
|
+
restoreSidePanelState();
|
|
12204
12793
|
}
|
|
12205
12794
|
|
|
12206
12795
|
function applyDurableComposerActionsLayout(value) {
|
|
@@ -12231,6 +12820,10 @@ function applyDurableTerminalTabsLayout(value) {
|
|
|
12231
12820
|
writeDurableLayoutCache(TERMINAL_TABS_LAYOUT_STORAGE_KEY, value.layout);
|
|
12232
12821
|
setTerminalTabsLayout(value.layout, { persist: false });
|
|
12233
12822
|
}
|
|
12823
|
+
if (Number.isFinite(value.sidebarWidth) && value.sidebarWidth >= TERMINAL_TABS_SIDEBAR_WIDTH_MIN_PX) {
|
|
12824
|
+
writeDurableLayoutCache(TERMINAL_TABS_SIDEBAR_WIDTH_STORAGE_KEY, String(Math.round(value.sidebarWidth)));
|
|
12825
|
+
restoreTerminalTabsSidebarWidthPreference();
|
|
12826
|
+
}
|
|
12234
12827
|
if (value.customGroups && value.customGroups.version === 1) {
|
|
12235
12828
|
writeDurableLayoutCache(TERMINAL_CUSTOM_GROUPS_STORAGE_KEY, JSON.stringify(value.customGroups));
|
|
12236
12829
|
restoreTerminalCustomGroups();
|
|
@@ -12258,10 +12851,10 @@ function applyDurableUiLayoutField(field, value) {
|
|
|
12258
12851
|
|
|
12259
12852
|
function durableUiLayoutInteractionActive(field = null) {
|
|
12260
12853
|
const activeByField = {
|
|
12261
|
-
sidePanel: Boolean(sidePanelSectionPointerDrag?.active),
|
|
12854
|
+
sidePanel: Boolean(sidePanelSectionPointerDrag?.active || sidePanelResizeState),
|
|
12262
12855
|
composerActions: Boolean(composerActionPointerDrag?.active),
|
|
12263
12856
|
footerScopedModelOrder: Boolean(footerScopedModelPointerDrag?.active),
|
|
12264
|
-
terminalTabs: Boolean(terminalTabDragId),
|
|
12857
|
+
terminalTabs: Boolean(terminalTabDragId || terminalTabsResizeState),
|
|
12265
12858
|
fileViewerWidth: Boolean(fileViewerResizeState),
|
|
12266
12859
|
};
|
|
12267
12860
|
return field ? activeByField[field] === true : Object.values(activeByField).some(Boolean);
|
|
@@ -12346,20 +12939,23 @@ function applyDurableUiLayoutSnapshot(data, { generations = null, readEpoch = 0
|
|
|
12346
12939
|
const subfields = durableUiLayoutSubFields(field);
|
|
12347
12940
|
const dirtySubfields = dirtyEntry?.subfields;
|
|
12348
12941
|
|
|
12349
|
-
|
|
12350
|
-
|
|
12351
|
-
if (subfields && field !== "composerActions") {
|
|
12942
|
+
if (subfields && field !== "composerActions") {
|
|
12352
12943
|
const applicable = {};
|
|
12353
12944
|
let hasApplicable = false;
|
|
12354
12945
|
for (const subfield of subfields) {
|
|
12355
12946
|
const isDirty = dirtySubfields?.has(subfield) === true;
|
|
12947
|
+
const activelyManipulated = field === "sidePanel" && (
|
|
12948
|
+
(subfield === "sectionLayout" && Boolean(sidePanelSectionPointerDrag?.active))
|
|
12949
|
+
|| (subfield === "panelWidths" && Boolean(sidePanelResizeState))
|
|
12950
|
+
);
|
|
12356
12951
|
const remote = serverValue?.[subfield] ?? null;
|
|
12357
12952
|
const local = localValue?.[subfield] ?? null;
|
|
12358
|
-
|
|
12953
|
+
const remotePresent = durableUiLayoutSubfieldValuePresent(field, subfield, remote);
|
|
12954
|
+
if (!isDirty && !activelyManipulated && !generationChanged && remotePresent) {
|
|
12359
12955
|
applicable[subfield] = remote;
|
|
12360
12956
|
hasApplicable = true;
|
|
12361
12957
|
}
|
|
12362
|
-
if (!isDirty && !
|
|
12958
|
+
if (!isDirty && !remotePresent && durableUiLayoutValuePresent(local)) {
|
|
12363
12959
|
markDurableUiLayoutDirty(field, subfield);
|
|
12364
12960
|
}
|
|
12365
12961
|
}
|
|
@@ -12410,10 +13006,15 @@ async function flushDurableUiLayoutSave() {
|
|
|
12410
13006
|
}]));
|
|
12411
13007
|
const patch = { version: UI_LAYOUT_SCHEMA_VERSION };
|
|
12412
13008
|
for (const [field, entry] of snapshot) patch[field] = durableUiLayoutEntryPatch(field, entry);
|
|
13009
|
+
const mixedWidth = patch.sidePanel?.panelWidths?.right;
|
|
12413
13010
|
const response = await api(UI_LAYOUT_ENDPOINT, {
|
|
12414
13011
|
method: "PUT",
|
|
12415
13012
|
scoped: false,
|
|
12416
|
-
body: {
|
|
13013
|
+
body: {
|
|
13014
|
+
layout: patch,
|
|
13015
|
+
...(Number.isFinite(mixedWidth) ? { sidePanelWidth: mixedWidth } : {}),
|
|
13016
|
+
expectedLayoutRevision: durableLayoutRevision,
|
|
13017
|
+
},
|
|
12417
13018
|
});
|
|
12418
13019
|
// A successful write is newer than every GET that began before this
|
|
12419
13020
|
// acknowledgement, even if one of those reads completes afterward.
|
|
@@ -12484,18 +13085,16 @@ function cacheSidePanelWidth(width) {
|
|
|
12484
13085
|
}
|
|
12485
13086
|
}
|
|
12486
13087
|
|
|
12487
|
-
function persistSidePanelWidth(width) {
|
|
13088
|
+
function persistSidePanelWidth(width, side = "right") {
|
|
12488
13089
|
const rounded = Math.round(width);
|
|
12489
13090
|
sidePanelWidthPreferenceRevision += 1;
|
|
12490
|
-
cacheSidePanelWidth(rounded);
|
|
12491
|
-
|
|
12492
|
-
|
|
12493
|
-
|
|
12494
|
-
scoped: false,
|
|
12495
|
-
}).catch((error) => addEvent(`Could not save Control Deck width for this user: ${error.message || String(error)}`, "warn"));
|
|
13091
|
+
if (side === "right") cacheSidePanelWidth(rounded);
|
|
13092
|
+
controlDeckLayout.panelWidths = { ...controlDeckLayout.panelWidths, [side]: rounded };
|
|
13093
|
+
cacheControlDeckLayout(controlDeckLayout, "panelWidths");
|
|
13094
|
+
markDurableUiLayoutDirty("sidePanel", "panelWidths");
|
|
12496
13095
|
}
|
|
12497
13096
|
|
|
12498
|
-
function sidePanelMaxWidth() {
|
|
13097
|
+
function sidePanelMaxWidth(side = "right") {
|
|
12499
13098
|
const layout = document.querySelector(".layout");
|
|
12500
13099
|
const layoutRect = layout?.getBoundingClientRect?.();
|
|
12501
13100
|
const layoutWidth = layoutRect?.width || window.innerWidth || SIDE_PANEL_WIDTH_DEFAULT_PX;
|
|
@@ -12504,50 +13103,69 @@ function sidePanelMaxWidth() {
|
|
|
12504
13103
|
const horizontalPadding = (Number.parseFloat(layoutStyle?.paddingLeft || "0") || 0) + (Number.parseFloat(layoutStyle?.paddingRight || "0") || 0);
|
|
12505
13104
|
const contentWidth = Math.max(0, layoutWidth - horizontalPadding);
|
|
12506
13105
|
const fileViewerVisible = !!activeFileViewer && elements.fileViewerPane && getComputedStyle(elements.fileViewerPane).display !== "none";
|
|
12507
|
-
const fileViewerWidth = fileViewerVisible ? elements.fileViewerPane.getBoundingClientRect().width : 0;
|
|
13106
|
+
const fileViewerWidth = fileViewerVisible ? Math.max(FILE_VIEWER_WIDTH_MIN_PX, elements.fileViewerPane.getBoundingClientRect().width) : 0;
|
|
12508
13107
|
const splitOpen = document.body.classList.contains("terminal-split-open");
|
|
12509
|
-
const
|
|
12510
|
-
const
|
|
12511
|
-
const
|
|
13108
|
+
const terminalRailWidth = isControlDeckSidebarPresentation() ? Math.max(TERMINAL_TABS_SIDEBAR_WIDTH_MIN_PX, currentTerminalTabsSidebarWidth()) : 0;
|
|
13109
|
+
const centralMinimum = 320 + (splitOpen ? 320 : 0) + fileViewerWidth + terminalRailWidth;
|
|
13110
|
+
const otherSide = side === "left" ? "right" : "left";
|
|
13111
|
+
const otherPanelVisible = effectiveControlDeckPresentation() === "both" && !controlDeckLayout.collapsedPanels?.[otherSide];
|
|
13112
|
+
const otherPanelWidth = otherPanelVisible ? Math.max(SIDE_PANEL_WIDTH_MIN_PX, currentSidePanelWidth(otherSide)) : 0;
|
|
13113
|
+
const otherColumnCount = 1 + (splitOpen ? 1 : 0) + (fileViewerVisible ? 1 : 0) + (otherPanelVisible ? 1 : 0);
|
|
13114
|
+
const available = contentWidth - otherPanelWidth - centralMinimum - (gap * otherColumnCount);
|
|
12512
13115
|
return Math.max(SIDE_PANEL_WIDTH_MIN_PX, Math.min(Math.floor(contentWidth * 0.72), Math.floor(available)));
|
|
12513
13116
|
}
|
|
12514
13117
|
|
|
12515
|
-
function clampSidePanelWidth(width) {
|
|
13118
|
+
function clampSidePanelWidth(width, side = "right") {
|
|
12516
13119
|
const number = Number(width);
|
|
12517
|
-
const max = sidePanelMaxWidth();
|
|
12518
|
-
const fallback = readStoredSidePanelWidth() || SIDE_PANEL_WIDTH_DEFAULT_PX;
|
|
13120
|
+
const max = sidePanelMaxWidth(side);
|
|
13121
|
+
const fallback = controlDeckLayout.panelWidths?.[side] || (side === "right" ? readStoredSidePanelWidth() : null) || SIDE_PANEL_WIDTH_DEFAULT_PX;
|
|
12519
13122
|
return Math.max(SIDE_PANEL_WIDTH_MIN_PX, Math.min(max, Number.isFinite(number) ? number : fallback));
|
|
12520
13123
|
}
|
|
12521
13124
|
|
|
12522
|
-
function currentSidePanelWidth() {
|
|
12523
|
-
const
|
|
12524
|
-
|
|
13125
|
+
function currentSidePanelWidth(side = "right") {
|
|
13126
|
+
const shell = side === "left" ? elements.sidePanelLeft : elements.sidePanel;
|
|
13127
|
+
const width = shell?.getBoundingClientRect?.().width;
|
|
13128
|
+
return Number.isFinite(width) && width > 0 ? width : controlDeckLayout.panelWidths?.[side] || (side === "right" ? readStoredSidePanelWidth() : null) || SIDE_PANEL_WIDTH_DEFAULT_PX;
|
|
12525
13129
|
}
|
|
12526
13130
|
|
|
12527
|
-
function
|
|
12528
|
-
const
|
|
13131
|
+
function controlDeckSideResizeAvailable(side = "right") {
|
|
13132
|
+
const presentation = effectiveControlDeckPresentation();
|
|
13133
|
+
if (presentation === "overlay" || presentation === "embedded" || controlDeckLayout.collapsedPanels?.[side]) return false;
|
|
13134
|
+
return side === "left"
|
|
13135
|
+
? presentation === "left" || presentation === "both"
|
|
13136
|
+
: presentation === "right" || presentation === "both";
|
|
13137
|
+
}
|
|
13138
|
+
|
|
13139
|
+
function updateSidePanelResizeHandle(width = currentSidePanelWidth("right"), side = "right") {
|
|
13140
|
+
const handle = side === "left" ? elements.sidePanelResizeHandleLeft : elements.sidePanelResizeHandle;
|
|
12529
13141
|
if (!handle) return;
|
|
12530
|
-
|
|
12531
|
-
handle.hidden = !resizeAvailable;
|
|
13142
|
+
handle.hidden = !controlDeckSideResizeAvailable(side);
|
|
12532
13143
|
handle.setAttribute("aria-valuemin", String(SIDE_PANEL_WIDTH_MIN_PX));
|
|
12533
|
-
handle.setAttribute("aria-valuemax", String(sidePanelMaxWidth()));
|
|
13144
|
+
handle.setAttribute("aria-valuemax", String(sidePanelMaxWidth(side)));
|
|
12534
13145
|
handle.setAttribute("aria-valuenow", String(Math.round(width)));
|
|
12535
13146
|
handle.setAttribute("aria-valuetext", `${Math.round(width)} pixels wide`);
|
|
12536
13147
|
}
|
|
12537
13148
|
|
|
12538
|
-
function applySidePanelWidth(width, { persist = false } = {}) {
|
|
12539
|
-
const clamped = clampSidePanelWidth(width);
|
|
12540
|
-
|
|
12541
|
-
|
|
12542
|
-
if (
|
|
13149
|
+
function applySidePanelWidth(width, { persist = false, side = "right" } = {}) {
|
|
13150
|
+
const clamped = clampSidePanelWidth(width, side);
|
|
13151
|
+
const variable = side === "left" ? "--side-panel-left-width" : "--side-panel-right-width";
|
|
13152
|
+
document.documentElement.style.setProperty(variable, `${Math.round(clamped)}px`);
|
|
13153
|
+
if (side === "right") document.documentElement.style.setProperty("--side-panel-width", `${Math.round(clamped)}px`);
|
|
13154
|
+
updateSidePanelResizeHandle(clamped, side);
|
|
13155
|
+
if (persist) persistSidePanelWidth(clamped, side);
|
|
12543
13156
|
return clamped;
|
|
12544
13157
|
}
|
|
12545
13158
|
|
|
12546
13159
|
async function restoreSidePanelWidthPreference() {
|
|
12547
13160
|
const localWidth = readStoredSidePanelWidth();
|
|
12548
13161
|
if (localWidth) document.documentElement.style.setProperty("--side-panel-width", `${Math.round(localWidth)}px`);
|
|
12549
|
-
if (!isSidePanelOverlayView())
|
|
12550
|
-
|
|
13162
|
+
if (!isSidePanelOverlayView()) {
|
|
13163
|
+
applySidePanelWidth(controlDeckLayout.panelWidths?.left || SIDE_PANEL_WIDTH_DEFAULT_PX, { side: "left" });
|
|
13164
|
+
applySidePanelWidth(controlDeckLayout.panelWidths?.right || localWidth || SIDE_PANEL_WIDTH_DEFAULT_PX, { side: "right" });
|
|
13165
|
+
} else {
|
|
13166
|
+
updateSidePanelResizeHandle(currentSidePanelWidth("left"), "left");
|
|
13167
|
+
updateSidePanelResizeHandle(localWidth || currentSidePanelWidth("right"), "right");
|
|
13168
|
+
}
|
|
12551
13169
|
|
|
12552
13170
|
const restoreRevision = sidePanelWidthPreferenceRevision;
|
|
12553
13171
|
const layoutGenerations = new Map(UI_LAYOUT_FIELDS.map((field) => [field, durableUiLayoutGeneration(field)]));
|
|
@@ -12572,14 +13190,15 @@ async function restoreSidePanelWidthPreference() {
|
|
|
12572
13190
|
}
|
|
12573
13191
|
}
|
|
12574
13192
|
|
|
12575
|
-
function beginSidePanelResize(event) {
|
|
12576
|
-
|
|
13193
|
+
function beginSidePanelResize(event, forcedSide = null) {
|
|
13194
|
+
const side = forcedSide || (event.currentTarget === elements.sidePanelResizeHandleLeft ? "left" : "right");
|
|
13195
|
+
if (!controlDeckSideResizeAvailable(side)) return;
|
|
12577
13196
|
if (event.button !== undefined && event.button !== 0) return;
|
|
12578
13197
|
event.preventDefault();
|
|
12579
|
-
const startWidth = currentSidePanelWidth();
|
|
12580
|
-
sidePanelResizeState = { pointerId: event.pointerId, startX: event.clientX, startWidth, width: startWidth };
|
|
13198
|
+
const startWidth = currentSidePanelWidth(side);
|
|
13199
|
+
sidePanelResizeState = { side, pointerId: event.pointerId, startX: event.clientX, startWidth, width: startWidth };
|
|
12581
13200
|
document.body.classList.add("side-panel-resizing");
|
|
12582
|
-
elements.sidePanelResizeHandle?.setPointerCapture?.(event.pointerId);
|
|
13201
|
+
(side === "left" ? elements.sidePanelResizeHandleLeft : elements.sidePanelResizeHandle)?.setPointerCapture?.(event.pointerId);
|
|
12583
13202
|
window.addEventListener("pointermove", updateSidePanelResize, { passive: false });
|
|
12584
13203
|
window.addEventListener("pointerup", finishSidePanelResize, { passive: false });
|
|
12585
13204
|
window.addEventListener("pointercancel", finishSidePanelResize, { passive: false });
|
|
@@ -12589,45 +13208,49 @@ function updateSidePanelResize(event) {
|
|
|
12589
13208
|
const state = sidePanelResizeState;
|
|
12590
13209
|
if (!state || (event.pointerId !== undefined && event.pointerId !== state.pointerId)) return;
|
|
12591
13210
|
event.preventDefault();
|
|
12592
|
-
state.
|
|
13211
|
+
const delta = state.side === "left" ? event.clientX - state.startX : state.startX - event.clientX;
|
|
13212
|
+
state.width = applySidePanelWidth(state.startWidth + delta, { side: state.side });
|
|
12593
13213
|
}
|
|
12594
13214
|
|
|
12595
13215
|
function finishSidePanelResize(event) {
|
|
12596
13216
|
const state = sidePanelResizeState;
|
|
12597
13217
|
if (!state || (event.pointerId !== undefined && event.pointerId !== state.pointerId)) return;
|
|
12598
13218
|
event.preventDefault?.();
|
|
12599
|
-
elements.sidePanelResizeHandle?.releasePointerCapture?.(state.pointerId);
|
|
13219
|
+
(state.side === "left" ? elements.sidePanelResizeHandleLeft : elements.sidePanelResizeHandle)?.releasePointerCapture?.(state.pointerId);
|
|
12600
13220
|
window.removeEventListener("pointermove", updateSidePanelResize);
|
|
12601
13221
|
window.removeEventListener("pointerup", finishSidePanelResize);
|
|
12602
13222
|
window.removeEventListener("pointercancel", finishSidePanelResize);
|
|
12603
13223
|
document.body.classList.remove("side-panel-resizing");
|
|
12604
|
-
applySidePanelWidth(state.width, { persist: true });
|
|
13224
|
+
applySidePanelWidth(state.width, { persist: true, side: state.side });
|
|
12605
13225
|
sidePanelResizeState = null;
|
|
12606
13226
|
}
|
|
12607
13227
|
|
|
12608
13228
|
function handleSidePanelResizeKeydown(event) {
|
|
12609
|
-
|
|
13229
|
+
const side = event.currentTarget === elements.sidePanelResizeHandleLeft ? "left" : "right";
|
|
13230
|
+
if (!controlDeckSideResizeAvailable(side)) return;
|
|
12610
13231
|
const step = event.shiftKey ? 80 : 24;
|
|
12611
|
-
const current = currentSidePanelWidth();
|
|
13232
|
+
const current = currentSidePanelWidth(side);
|
|
12612
13233
|
let next = current;
|
|
12613
|
-
if (event.key === "ArrowLeft") next = current + step;
|
|
12614
|
-
else if (event.key === "ArrowRight") next = current - step;
|
|
13234
|
+
if (event.key === "ArrowLeft") next = side === "left" ? current - step : current + step;
|
|
13235
|
+
else if (event.key === "ArrowRight") next = side === "left" ? current + step : current - step;
|
|
12615
13236
|
else if (event.key === "Home") next = SIDE_PANEL_WIDTH_MIN_PX;
|
|
12616
|
-
else if (event.key === "End") next = sidePanelMaxWidth();
|
|
13237
|
+
else if (event.key === "End") next = sidePanelMaxWidth(side);
|
|
12617
13238
|
else return;
|
|
12618
13239
|
event.preventDefault();
|
|
12619
|
-
applySidePanelWidth(next, { persist: true });
|
|
13240
|
+
applySidePanelWidth(next, { persist: true, side });
|
|
12620
13241
|
}
|
|
12621
13242
|
|
|
12622
13243
|
function syncSidePanelWidthForViewport() {
|
|
12623
|
-
if (isSidePanelOverlayView()
|
|
12624
|
-
updateSidePanelResizeHandle();
|
|
13244
|
+
if (isSidePanelOverlayView()) {
|
|
13245
|
+
updateSidePanelResizeHandle(currentSidePanelWidth("left"), "left");
|
|
13246
|
+
updateSidePanelResizeHandle(currentSidePanelWidth("right"), "right");
|
|
12625
13247
|
return;
|
|
12626
13248
|
}
|
|
12627
|
-
// Keep viewport/layout reconciliation anchored to the durable
|
|
12628
|
-
// Reading
|
|
12629
|
-
// during hard-reset startup and permanently freeze
|
|
12630
|
-
applySidePanelWidth(
|
|
13249
|
+
// Keep viewport/layout reconciliation anchored to the durable preferences.
|
|
13250
|
+
// Reading rendered widths here can capture an in-progress CSS transition
|
|
13251
|
+
// during hard-reset startup and permanently freeze a panel below its saved width.
|
|
13252
|
+
applySidePanelWidth(controlDeckLayout.panelWidths?.left || currentSidePanelWidth("left"), { side: "left" });
|
|
13253
|
+
applySidePanelWidth(controlDeckLayout.panelWidths?.right || readStoredSidePanelWidth() || currentSidePanelWidth("right"), { side: "right" });
|
|
12631
13254
|
}
|
|
12632
13255
|
|
|
12633
13256
|
function readStoredFileViewerWidth() {
|
|
@@ -12762,6 +13385,7 @@ function syncFileViewerWidthForViewport() {
|
|
|
12762
13385
|
function syncResizablePanelWidthsForViewport() {
|
|
12763
13386
|
syncSidePanelWidthForViewport();
|
|
12764
13387
|
syncFileViewerWidthForViewport();
|
|
13388
|
+
syncTerminalTabsSidebarWidthForViewport();
|
|
12765
13389
|
}
|
|
12766
13390
|
|
|
12767
13391
|
async function openFileTreeEntryInWebui(entry = fileContextMenuState?.entry) {
|
|
@@ -12810,7 +13434,7 @@ function updateFileViewerUi() {
|
|
|
12810
13434
|
document.body.classList.toggle("file-viewer-open", open);
|
|
12811
13435
|
syncMobileShellInteractivity();
|
|
12812
13436
|
if (elements.fileViewerPane) elements.fileViewerPane.hidden = !open;
|
|
12813
|
-
|
|
13437
|
+
scheduleControlDeckPresentationReconciliation();
|
|
12814
13438
|
updateFileViewerResizeHandle();
|
|
12815
13439
|
if (!open) {
|
|
12816
13440
|
closeFileViewerSearch({ restoreFocus: false });
|
|
@@ -13321,7 +13945,7 @@ function resetFileViewerUi() {
|
|
|
13321
13945
|
syncMobileShellInteractivity();
|
|
13322
13946
|
updateFileViewerResizeHandle();
|
|
13323
13947
|
if (elements.fileViewerPane) elements.fileViewerPane.hidden = true;
|
|
13324
|
-
|
|
13948
|
+
scheduleControlDeckPresentationReconciliation();
|
|
13325
13949
|
if (elements.fileViewerOpenDefaultButton) elements.fileViewerOpenDefaultButton.dataset.path = "";
|
|
13326
13950
|
if (elements.fileViewerEditor) {
|
|
13327
13951
|
elements.fileViewerEditor.value = "";
|
|
@@ -13625,6 +14249,9 @@ function syncTabMetadata(nextTabs = []) {
|
|
|
13625
14249
|
if (voiceConversationTabId === tabId) stopVoiceConversationLoop();
|
|
13626
14250
|
clearGitWorkflowForTab(tabId);
|
|
13627
14251
|
commandCatalogsByTab.delete(tabId);
|
|
14252
|
+
tabStateCache.delete(tabId);
|
|
14253
|
+
tabStatsCache.delete(tabId);
|
|
14254
|
+
tabWorkspaceCache.delete(tabId);
|
|
13628
14255
|
sessionSummaryByTab.delete(tabId);
|
|
13629
14256
|
if (sessionSummaryOverlayTabId === tabId) closeSessionSummaryOverlay({ restoreFocus: false });
|
|
13630
14257
|
clearGitFooterPayloadState(tabId);
|
|
@@ -14035,23 +14662,37 @@ function clearWidgetsForTab(tabId = activeTabId) {
|
|
|
14035
14662
|
}
|
|
14036
14663
|
}
|
|
14037
14664
|
|
|
14665
|
+
function cachedStateForTabSwitch(tabId = activeTabId) {
|
|
14666
|
+
if (!tabId) return null;
|
|
14667
|
+
const cached = tabStateCache.get(tabId) || null;
|
|
14668
|
+
const activity = tabActivities.get(tabId);
|
|
14669
|
+
if (!activity) return cached;
|
|
14670
|
+
const isWorking = activity.isWorking === true;
|
|
14671
|
+
return {
|
|
14672
|
+
...(cached || {}),
|
|
14673
|
+
isStreaming: isWorking,
|
|
14674
|
+
isCompacting: isWorking && cached?.isCompacting === true,
|
|
14675
|
+
};
|
|
14676
|
+
}
|
|
14677
|
+
|
|
14038
14678
|
function resetActiveTabUi() {
|
|
14039
14679
|
clearRefreshTimers();
|
|
14040
14680
|
eventSource?.close();
|
|
14041
14681
|
eventSource = null;
|
|
14042
|
-
currentState =
|
|
14043
|
-
latestStats = null;
|
|
14682
|
+
currentState = cachedStateForTabSwitch(activeTabId);
|
|
14683
|
+
latestStats = activeTabId ? tabStatsCache.get(activeTabId) || null : null;
|
|
14044
14684
|
latestStatsOverlayPayload = null;
|
|
14045
14685
|
latestBtwWidgetPayload = null;
|
|
14046
14686
|
btwWidgetComposerOpen = false;
|
|
14047
14687
|
btwWidgetInputDraft = "";
|
|
14048
|
-
latestWorkspace = null;
|
|
14688
|
+
latestWorkspace = activeTabId ? tabWorkspaceCache.get(activeTabId) || null : null;
|
|
14049
14689
|
latestMessages = [];
|
|
14050
14690
|
latestMessagesSessionKey = "";
|
|
14051
14691
|
resetFileViewerUi();
|
|
14052
14692
|
resetFileTreeState();
|
|
14053
14693
|
restoreFileViewerForActiveTab();
|
|
14054
14694
|
clearRunIndicatorActivity({ render: false });
|
|
14695
|
+
if (currentState) syncRunIndicatorFromState(currentState);
|
|
14055
14696
|
statusEntries.clear();
|
|
14056
14697
|
restoreWidgetsForActiveTab();
|
|
14057
14698
|
transientMessages = [];
|
|
@@ -14061,6 +14702,7 @@ function resetActiveTabUi() {
|
|
|
14061
14702
|
availableCommands = commandCatalog?.available || [];
|
|
14062
14703
|
rawAvailableCommands = commandCatalog?.raw || [];
|
|
14063
14704
|
resetOptionalFeatureAvailability();
|
|
14705
|
+
if (commandCatalog) updateOptionalFeatureAvailability();
|
|
14064
14706
|
commandSuggestions = [];
|
|
14065
14707
|
pathSuggestions = [];
|
|
14066
14708
|
suggestionMode = "none";
|
|
@@ -14089,6 +14731,7 @@ function resetActiveTabUi() {
|
|
|
14089
14731
|
restoreCachedMessagesForActiveTab();
|
|
14090
14732
|
renderFooter();
|
|
14091
14733
|
renderFeedbackTray();
|
|
14734
|
+
restoreComposerActionSlotLayout();
|
|
14092
14735
|
}
|
|
14093
14736
|
|
|
14094
14737
|
function tabGroupStatusRank(state) {
|
|
@@ -15209,6 +15852,29 @@ function initializeTerminalHeaderTooltips() {
|
|
|
15209
15852
|
applyStyledTooltip(elements.closeAllTabsButton, "Close all terminal tabs", { ariaLabel: "Close all terminal tabs" });
|
|
15210
15853
|
}
|
|
15211
15854
|
|
|
15855
|
+
function initializeControlSettingTooltips() {
|
|
15856
|
+
document.querySelectorAll("#sidePanelSectionControls .control-row-label[data-tooltip]").forEach((label) => {
|
|
15857
|
+
bindStyledTooltipEvents(label);
|
|
15858
|
+
label.addEventListener("click", (event) => {
|
|
15859
|
+
const modelLabel = label.contains(elements.modelControlLabel);
|
|
15860
|
+
const themeLabel = label.contains(elements.themeControlLabel);
|
|
15861
|
+
showFooterTooltip(label);
|
|
15862
|
+
if (!modelLabel && !themeLabel) return;
|
|
15863
|
+
if (event.target === elements.modelControlLabel || event.target === elements.themeControlLabel) return;
|
|
15864
|
+
event.preventDefault();
|
|
15865
|
+
if (modelLabel) toggleModelSearchInput();
|
|
15866
|
+
else toggleThemeSearchInput();
|
|
15867
|
+
});
|
|
15868
|
+
label.addEventListener("keydown", (event) => {
|
|
15869
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
15870
|
+
event.preventDefault();
|
|
15871
|
+
showFooterTooltip(label);
|
|
15872
|
+
if (label.contains(elements.modelControlLabel)) toggleModelSearchInput();
|
|
15873
|
+
else if (label.contains(elements.themeControlLabel)) toggleThemeSearchInput();
|
|
15874
|
+
});
|
|
15875
|
+
});
|
|
15876
|
+
}
|
|
15877
|
+
|
|
15212
15878
|
function openNewTabMenu() {
|
|
15213
15879
|
setPublishMenuOpen(false);
|
|
15214
15880
|
setNativeCommandMenuOpen(false);
|
|
@@ -15332,17 +15998,81 @@ function prefetchInactiveTabCommandCatalogs() {
|
|
|
15332
15998
|
}
|
|
15333
15999
|
}
|
|
15334
16000
|
|
|
16001
|
+
function tabsSnapshotSignature(tabList = []) {
|
|
16002
|
+
try {
|
|
16003
|
+
return JSON.stringify(tabList);
|
|
16004
|
+
} catch {
|
|
16005
|
+
return "";
|
|
16006
|
+
}
|
|
16007
|
+
}
|
|
16008
|
+
|
|
16009
|
+
function tabsRenderSnapshotSignature(tabList = []) {
|
|
16010
|
+
return tabsSnapshotSignature(tabList.map((tab) => {
|
|
16011
|
+
const activity = normalizeTabActivity(tab?.activity || {});
|
|
16012
|
+
const runner = tab?.appRunner || null;
|
|
16013
|
+
const conversation = normalizeConversationModeState(tab?.conversationMode || {});
|
|
16014
|
+
const summary = tab?.sessionSummary || null;
|
|
16015
|
+
const pendingExtensionUiRequestCount = normalizePendingExtensionUiRequestCount(tab?.pendingExtensionUiRequestCount);
|
|
16016
|
+
const seenCompletionSerial = tabSeenCompletionSerials.get(tab?.id) ?? activity.completionSerial;
|
|
16017
|
+
const activityState = tab?.running && pendingExtensionUiRequestCount > 0
|
|
16018
|
+
? "blocked"
|
|
16019
|
+
: tab?.running && activity.isWorking
|
|
16020
|
+
? "working"
|
|
16021
|
+
: tab?.running && activity.completionSerial > seenCompletionSerial
|
|
16022
|
+
? "done"
|
|
16023
|
+
: tab?.running ? "idle" : "stopped";
|
|
16024
|
+
return {
|
|
16025
|
+
id: tab?.id || "",
|
|
16026
|
+
index: Number(tab?.index) || 0,
|
|
16027
|
+
title: tab?.title || "",
|
|
16028
|
+
titleSource: tab?.titleSource || "",
|
|
16029
|
+
running: tab?.running === true,
|
|
16030
|
+
cwd: tab?.cwd || "",
|
|
16031
|
+
gitWorkspace: tab?.gitWorkspace || null,
|
|
16032
|
+
pendingExtensionUiRequestCount,
|
|
16033
|
+
activityState,
|
|
16034
|
+
appRunner: runner ? {
|
|
16035
|
+
status: runner.status || "",
|
|
16036
|
+
stopping: runner.stopping === true,
|
|
16037
|
+
displayCommand: runner.displayCommand || runner.label || runner.command || "",
|
|
16038
|
+
} : null,
|
|
16039
|
+
conversationMode: {
|
|
16040
|
+
available: conversation.available,
|
|
16041
|
+
enabled: conversation.enabled,
|
|
16042
|
+
uiState: conversation.uiState,
|
|
16043
|
+
statusText: conversation.statusText,
|
|
16044
|
+
},
|
|
16045
|
+
sessionSummary: summary ? {
|
|
16046
|
+
status: summary.status || "",
|
|
16047
|
+
configured: summary.configured === true,
|
|
16048
|
+
enabled: summary.enabled === true,
|
|
16049
|
+
durable: summary.durable === true,
|
|
16050
|
+
hasSummary: Boolean(summary.summaryMarkdown),
|
|
16051
|
+
message: summary.message || "",
|
|
16052
|
+
} : null,
|
|
16053
|
+
};
|
|
16054
|
+
}));
|
|
16055
|
+
}
|
|
16056
|
+
|
|
15335
16057
|
async function refreshTabs({ selectStored = false } = {}) {
|
|
15336
16058
|
const previousTabs = tabs;
|
|
16059
|
+
const previousTabsSignature = tabsSnapshotSignature(previousTabs);
|
|
16060
|
+
const previousTabsRenderSignature = tabsRenderSnapshotSignature(previousTabs);
|
|
16061
|
+
const previousActiveTabId = activeTabId;
|
|
15337
16062
|
const response = await api("/api/tabs", { scoped: false });
|
|
15338
|
-
|
|
15339
|
-
|
|
15340
|
-
const
|
|
15341
|
-
|
|
15342
|
-
|
|
16063
|
+
const nextTabs = response.data?.tabs || [];
|
|
16064
|
+
const tabsChanged = previousTabsSignature !== tabsSnapshotSignature(nextTabs);
|
|
16065
|
+
const tabsRenderChanged = previousTabsRenderSignature !== tabsRenderSnapshotSignature(nextTabs);
|
|
16066
|
+
if (tabsChanged) {
|
|
16067
|
+
tabs = nextTabs;
|
|
16068
|
+
syncTabMetadata(tabs);
|
|
16069
|
+
const liveParentTabIds = new Set(tabs.map((tab) => tab.id));
|
|
16070
|
+
for (const view of [...subagentTerminalViews.values()]) {
|
|
16071
|
+
if (!liveParentTabIds.has(view.parentTabId)) removeSubagentTerminalViewsForParent(view.parentTabId);
|
|
16072
|
+
}
|
|
16073
|
+
syncBlockedTabNotificationsFromTabs(tabs, previousTabs);
|
|
16074
|
+
syncAgentDoneNotificationsFromTabs(tabs, previousTabs);
|
|
15343
16075
|
}
|
|
15344
|
-
syncBlockedTabNotificationsFromTabs(tabs, previousTabs);
|
|
15345
|
-
syncAgentDoneNotificationsFromTabs(tabs, previousTabs);
|
|
15346
16076
|
const requested = selectStored ? requestedTabIdFromUrl() : null;
|
|
15347
16077
|
const stored = selectStored ? restoreStoredTabId() : null;
|
|
15348
16078
|
if (!activeTabId || !tabs.some((tab) => tab.id === activeTabId)) {
|
|
@@ -15355,7 +16085,8 @@ async function refreshTabs({ selectStored = false } = {}) {
|
|
|
15355
16085
|
setWorkspaceDashboardCollapsed(false, { persist: false });
|
|
15356
16086
|
}
|
|
15357
16087
|
renderSessionSkillTags(activeTabId);
|
|
15358
|
-
renderTabs();
|
|
16088
|
+
if (tabsRenderChanged || activeTabId !== previousActiveTabId || selectStored) renderTabs();
|
|
16089
|
+
else syncTabPolling();
|
|
15359
16090
|
prefetchInactiveTabCommandCatalogs();
|
|
15360
16091
|
return tabs;
|
|
15361
16092
|
}
|
|
@@ -15387,6 +16118,9 @@ async function switchTab(tabId) {
|
|
|
15387
16118
|
cacheMessagesForTab(activeTabId);
|
|
15388
16119
|
cacheWidgetsForTab(activeTabId);
|
|
15389
16120
|
cacheActiveFileViewerForTab(activeTabId);
|
|
16121
|
+
if (activeTabId && currentState) tabStateCache.set(activeTabId, currentState);
|
|
16122
|
+
if (activeTabId && latestStats) tabStatsCache.set(activeTabId, latestStats);
|
|
16123
|
+
if (activeTabId && latestWorkspace) tabWorkspaceCache.set(activeTabId, latestWorkspace);
|
|
15390
16124
|
const tabContext = setActiveTabId(tabId, { remember: true });
|
|
15391
16125
|
if (voiceConversation && voiceConversationTabId !== tabId) stopVoiceConversationLoop();
|
|
15392
16126
|
resetActiveTabUi();
|
|
@@ -15437,10 +16171,11 @@ function updateTerminalSplitControls(canShowSplit, splitTab = terminalSplitTab()
|
|
|
15437
16171
|
|
|
15438
16172
|
function updateTerminalSplitUi() {
|
|
15439
16173
|
const tab = terminalSplitTab();
|
|
15440
|
-
const
|
|
16174
|
+
const overlayDrawerOpen = isControlDeckOverlayPresentation() && !document.body.classList.contains("side-panel-collapsed");
|
|
16175
|
+
const canShowSplit = !!tab && !embeddedSplitMode && !overlayDrawerOpen;
|
|
15441
16176
|
document.body.classList.toggle("terminal-split-open", canShowSplit);
|
|
15442
16177
|
if (elements.terminalSplitShell) elements.terminalSplitShell.hidden = !canShowSplit;
|
|
15443
|
-
|
|
16178
|
+
scheduleControlDeckPresentationReconciliation();
|
|
15444
16179
|
updateTerminalSplitControls(canShowSplit, tab);
|
|
15445
16180
|
if (!canShowSplit) return;
|
|
15446
16181
|
if (elements.terminalSplitTitle) elements.terminalSplitTitle.textContent = tab.title || "Split terminal";
|
|
@@ -16712,17 +17447,17 @@ function applyFooterContextUsage(node, contextUsage) {
|
|
|
16712
17447
|
return node;
|
|
16713
17448
|
}
|
|
16714
17449
|
|
|
16715
|
-
// Dedicated Usage visual apply path: sets
|
|
16716
|
-
// primary/first window, bottom = secondary/second window) plus a
|
|
16717
|
-
// active foreground/glow reusing the Context color interpolation.
|
|
16718
|
-
//
|
|
17450
|
+
// Dedicated Usage visual apply path: sets available independent lane widths
|
|
17451
|
+
// (top = primary/first window, bottom = secondary/second window) plus a
|
|
17452
|
+
// max-window active foreground/glow reusing the Context color interpolation.
|
|
17453
|
+
// Missing lanes remain empty; exact text and tooltip remain untouched.
|
|
16719
17454
|
function applyFooterUsageWindows(node, usageWindows) {
|
|
16720
17455
|
node.classList.add("footer-usage-card");
|
|
16721
17456
|
const primaryPercent = typeof usageWindows?.primaryPercent === "number" ? usageWindows.primaryPercent : Number.NaN;
|
|
16722
17457
|
const secondaryPercent = typeof usageWindows?.secondaryPercent === "number" ? usageWindows.secondaryPercent : Number.NaN;
|
|
16723
|
-
if (Number.isFinite(primaryPercent)
|
|
16724
|
-
const clampedPrimary = Math.min(100, Math.max(0, primaryPercent));
|
|
16725
|
-
const clampedSecondary = Math.min(100, Math.max(0, secondaryPercent));
|
|
17458
|
+
if (Number.isFinite(primaryPercent) || Number.isFinite(secondaryPercent)) {
|
|
17459
|
+
const clampedPrimary = Number.isFinite(primaryPercent) ? Math.min(100, Math.max(0, primaryPercent)) : 0;
|
|
17460
|
+
const clampedSecondary = Number.isFinite(secondaryPercent) ? Math.min(100, Math.max(0, secondaryPercent)) : 0;
|
|
16726
17461
|
const activeColor = contextUsageActiveColor(Math.max(clampedPrimary, clampedSecondary));
|
|
16727
17462
|
node.classList.add("has-usage-windows");
|
|
16728
17463
|
node.style.setProperty("--usage-primary", `${clampedPrimary.toFixed(1)}%`);
|
|
@@ -16820,7 +17555,7 @@ const GIT_FOOTER_TOOLTIP_COPY = {
|
|
|
16820
17555
|
speed: "Assistant streaming speed. Shows live output tokens for the current reply and current or last tokens per second.",
|
|
16821
17556
|
cost: "Estimated session cost. sub means subscription-backed provider; api means metered API usage.",
|
|
16822
17557
|
context: "Context window pressure. Shows percent used over the model limit; auto means auto-compaction is enabled.",
|
|
16823
|
-
usage: "Provider subscription usage. Shows the used share of
|
|
17558
|
+
usage: "Provider subscription usage. Shows the used share of every available provider-reported rate window.",
|
|
16824
17559
|
cwd: "Active working directory for this Web UI tab.",
|
|
16825
17560
|
git: "Current Git branch. detached means HEAD is not on a branch; no repo means the cwd is outside a Git work tree.",
|
|
16826
17561
|
"git-state": "Active Git operation or detached state. Finish or abort rebase/merge/cherry-pick/revert/bisect before normal commits.",
|
|
@@ -17262,8 +17997,11 @@ function normalizeFooterPayloadChip(value, index) {
|
|
|
17262
17997
|
if (value.usageWindows && typeof value.usageWindows === "object") {
|
|
17263
17998
|
const primaryPercent = typeof value.usageWindows.primaryPercent === "number" ? value.usageWindows.primaryPercent : Number.NaN;
|
|
17264
17999
|
const secondaryPercent = typeof value.usageWindows.secondaryPercent === "number" ? value.usageWindows.secondaryPercent : Number.NaN;
|
|
17265
|
-
if (Number.isFinite(primaryPercent)
|
|
17266
|
-
chip.usageWindows = {
|
|
18000
|
+
if (Number.isFinite(primaryPercent) || Number.isFinite(secondaryPercent)) {
|
|
18001
|
+
chip.usageWindows = {
|
|
18002
|
+
...(Number.isFinite(primaryPercent) ? { primaryPercent } : {}),
|
|
18003
|
+
...(Number.isFinite(secondaryPercent) ? { secondaryPercent } : {}),
|
|
18004
|
+
};
|
|
17267
18005
|
}
|
|
17268
18006
|
}
|
|
17269
18007
|
return chip;
|
|
@@ -22468,15 +23206,65 @@ function initializeClaudeUsage() {
|
|
|
22468
23206
|
claudeUsageRenderTimer = setInterval(renderClaudeUsage, CLAUDE_USAGE_RENDER_TICK_MS);
|
|
22469
23207
|
}
|
|
22470
23208
|
|
|
22471
|
-
|
|
22472
|
-
|
|
23209
|
+
const SUBAGENT_LAUNCHER_LABELS = Object.freeze({
|
|
23210
|
+
sdk: "SDK", "pi-rpc": "Pi RPC", "pi-json": "Pi JSON", "pi-print": "Pi print",
|
|
23211
|
+
interactive: "Pi session", tmux: "tmux", "pi-subagents": "pi-subagents",
|
|
23212
|
+
schedule: "scheduled", gate: "gate", workflow: "workflow", custom: "custom",
|
|
23213
|
+
});
|
|
23214
|
+
const SUBAGENT_LIFECYCLE_STATES = new Set(["queued", "running", "stale", "lost", "done", "failed", "cancelled"]);
|
|
23215
|
+
|
|
23216
|
+
function subagentLauncherLabel(value = "") {
|
|
23217
|
+
const launcher = String(value || "").trim();
|
|
23218
|
+
return SUBAGENT_LAUNCHER_LABELS[launcher] || launcher || "agent";
|
|
23219
|
+
}
|
|
23220
|
+
|
|
23221
|
+
function subagentAgentStatus(run = {}, agent = null) {
|
|
23222
|
+
const status = String(agent?.status || run?.status || "running").toLowerCase();
|
|
23223
|
+
return SUBAGENT_LIFECYCLE_STATES.has(status) ? status : status === "pending" ? "queued" : "running";
|
|
23224
|
+
}
|
|
23225
|
+
|
|
23226
|
+
function subagentCapabilities(run = {}, agent = null) {
|
|
23227
|
+
const agentCapabilities = agent?.capabilities && typeof agent.capabilities === "object" ? agent.capabilities : null;
|
|
23228
|
+
const runCapabilities = run?.capabilities && typeof run.capabilities === "object" ? run.capabilities : null;
|
|
23229
|
+
return agentCapabilities || runCapabilities || null;
|
|
23230
|
+
}
|
|
23231
|
+
|
|
23232
|
+
function subagentOverviewGroups(data = latestSubagents) {
|
|
23233
|
+
const serverNow = Number(data?.updatedAt);
|
|
22473
23234
|
const now = Number.isFinite(serverNow) ? serverNow : Date.now();
|
|
22474
|
-
|
|
22475
|
-
.map((tab) =>
|
|
22476
|
-
|
|
22477
|
-
const
|
|
22478
|
-
|
|
22479
|
-
|
|
23235
|
+
if (Number(data?.version) === 2 && Array.isArray(data?.groups)) {
|
|
23236
|
+
const legacyTabs = new Map((Array.isArray(data.tabs) ? data.tabs : []).map((tab) => [tab.tabId, tab]));
|
|
23237
|
+
return data.groups.map((group, index) => {
|
|
23238
|
+
const legacy = legacyTabs.get(group.tabId) || {};
|
|
23239
|
+
const gates = visibleSubagentGates({ ...legacy, gates: group.gates || legacy.gates || [] }, dismissedSubagentGateKeys, now);
|
|
23240
|
+
const runs = Array.isArray(group.runs) ? group.runs : [];
|
|
23241
|
+
return {
|
|
23242
|
+
...legacy,
|
|
23243
|
+
...group,
|
|
23244
|
+
groupId: group.id,
|
|
23245
|
+
groupKind: group.kind,
|
|
23246
|
+
tabId: group.tabId || activeTabId || "external",
|
|
23247
|
+
tabIndex: group.tabIndex || legacy.tabIndex || index + 1,
|
|
23248
|
+
tabTitle: group.title || legacy.tabTitle || (group.kind === "external" ? "External agents" : `Terminal ${index + 1}`),
|
|
23249
|
+
sessionName: group.cwdLabel || legacy.sessionName || "registered agents",
|
|
23250
|
+
available: true,
|
|
23251
|
+
gates,
|
|
23252
|
+
gateCount: gates.length,
|
|
23253
|
+
displayRuns: runs,
|
|
23254
|
+
agentCount: runs.reduce((count, run) => count + (Array.isArray(run.agents) ? run.agents.length : 0), 0),
|
|
23255
|
+
runningAgents: runs.reduce((count, run) => count + (Array.isArray(run.agents) ? run.agents.filter((agent) => subagentAgentStatus(run, agent) === "running").length : 0), 0),
|
|
23256
|
+
staleAgents: runs.reduce((count, run) => count + (Array.isArray(run.agents) ? run.agents.filter((agent) => subagentAgentStatus(run, agent) === "stale").length : 0), 0),
|
|
23257
|
+
};
|
|
23258
|
+
});
|
|
23259
|
+
}
|
|
23260
|
+
return (Array.isArray(data?.tabs) ? data.tabs : []).map((tab) => {
|
|
23261
|
+
const gates = visibleSubagentGates(tab, dismissedSubagentGateKeys, now);
|
|
23262
|
+
return { ...tab, groupId: `tab:${tab.tabId}`, groupKind: "tab", gates, gateCount: gates.length, displayRuns: ungatedSubagentRuns(tab) };
|
|
23263
|
+
});
|
|
23264
|
+
}
|
|
23265
|
+
|
|
23266
|
+
function subagentTabsWithRunningAgents() {
|
|
23267
|
+
return subagentOverviewGroups()
|
|
22480
23268
|
.filter((tab) => tab.displayRuns.length > 0 || Number(tab?.gateCount || 0) > 0)
|
|
22481
23269
|
.sort((a, b) => Number(a.tabIndex || 0) - Number(b.tabIndex || 0) || String(a.tabTitle || "").localeCompare(String(b.tabTitle || "")));
|
|
22482
23270
|
}
|
|
@@ -22498,9 +23286,14 @@ function subagentRunElapsed(run) {
|
|
|
22498
23286
|
}
|
|
22499
23287
|
|
|
22500
23288
|
function subagentSourceLabel(source = "") {
|
|
23289
|
+
if (source === "recovered") return "recovered active child";
|
|
22501
23290
|
return source === "foreground" || source === "workflow" ? source : "async";
|
|
22502
23291
|
}
|
|
22503
23292
|
|
|
23293
|
+
function subagentRunSupportsInteraction(run = {}) {
|
|
23294
|
+
return run?.source !== "recovered" && run?.provisional !== true && run?.controllable !== false;
|
|
23295
|
+
}
|
|
23296
|
+
|
|
22504
23297
|
function subagentExecutionValues(agent = {}) {
|
|
22505
23298
|
const thinking = String(agent?.thinking || "").trim();
|
|
22506
23299
|
let model = String(agent?.model || "").trim();
|
|
@@ -22527,20 +23320,45 @@ function subagentGateAttemptViewFacts(attempt) {
|
|
|
22527
23320
|
}
|
|
22528
23321
|
|
|
22529
23322
|
function subagentRunIsRunning(run = {}, agent = null) {
|
|
22530
|
-
|
|
22531
|
-
|
|
22532
|
-
|
|
23323
|
+
return ["queued", "running"].includes(subagentAgentStatus(run, agent));
|
|
23324
|
+
}
|
|
23325
|
+
|
|
23326
|
+
function subagentRunIsTerminal(run = {}, agent = null) {
|
|
23327
|
+
return ["done", "failed", "cancelled"].includes(subagentAgentStatus(run, agent));
|
|
23328
|
+
}
|
|
23329
|
+
|
|
23330
|
+
function subagentRunIsAttachedProjection(run = {}) {
|
|
23331
|
+
return run?.provider === "webui-registry"
|
|
23332
|
+
&& run?.source === "explicit-attach"
|
|
23333
|
+
&& ["stale", "lost"].includes(subagentAgentStatus(run));
|
|
23334
|
+
}
|
|
23335
|
+
|
|
23336
|
+
function subagentRunCanOpen(run = {}, agent = null) {
|
|
23337
|
+
const capabilities = subagentCapabilities(run, agent);
|
|
23338
|
+
return capabilities ? capabilities.open === true : subagentRunSupportsInteraction(run);
|
|
23339
|
+
}
|
|
23340
|
+
|
|
23341
|
+
function subagentRunCanRefresh(run = {}, agent = null) {
|
|
23342
|
+
const capabilities = subagentCapabilities(run, agent);
|
|
23343
|
+
return capabilities ? capabilities.refresh === true : subagentRunSupportsInteraction(run);
|
|
22533
23344
|
}
|
|
22534
23345
|
|
|
22535
23346
|
function subagentRunCanCancel(run = {}, agent = null) {
|
|
22536
|
-
|
|
23347
|
+
const capabilities = subagentCapabilities(run, agent);
|
|
23348
|
+
return capabilities ? capabilities.cancel === true && subagentRunIsRunning(run, agent) : subagentRunSupportsInteraction(run) && run?.source !== "workflow" && subagentRunIsRunning(run, agent);
|
|
23349
|
+
}
|
|
23350
|
+
|
|
23351
|
+
function subagentRunCanDismiss(run = {}) {
|
|
23352
|
+
if (subagentRunIsAttachedProjection(run)) return true;
|
|
23353
|
+
if (!subagentRunIsTerminal(run)) return false;
|
|
23354
|
+
if (run?.provider === "webui-registry") return true;
|
|
23355
|
+
const capabilities = subagentCapabilities(run);
|
|
23356
|
+
return capabilities ? capabilities.open === true && ["webui-helper", "pi-subagents"].includes(run.provider) : run?.source !== "workflow" && subagentRunSupportsInteraction(run);
|
|
22537
23357
|
}
|
|
22538
23358
|
|
|
22539
|
-
function subagentRunStateLabel(run = {}) {
|
|
22540
|
-
|
|
22541
|
-
|
|
22542
|
-
if (run?.status === "done") return "done";
|
|
22543
|
-
return "running";
|
|
23359
|
+
function subagentRunStateLabel(run = {}, agent = null) {
|
|
23360
|
+
const status = subagentAgentStatus(run, agent);
|
|
23361
|
+
return status === "cancelled" ? "cancelled" : status;
|
|
22544
23362
|
}
|
|
22545
23363
|
|
|
22546
23364
|
function setSubagentCancelStatus(message = "", level = "muted") {
|
|
@@ -22565,11 +23383,13 @@ function subagentCancelTargetLabel(selection = subagentCancelSelection) {
|
|
|
22565
23383
|
}
|
|
22566
23384
|
|
|
22567
23385
|
function openSubagentCancelDialog(tab, run, agent = null) {
|
|
22568
|
-
if (!tab?.
|
|
23386
|
+
if (!tab?.groupId || !run?.id || !subagentRunCanCancel(run, agent) || !elements.subagentCancelDialog) return;
|
|
22569
23387
|
const agentCount = Array.isArray(run.agents) ? run.agents.length : 0;
|
|
22570
23388
|
subagentCancelSelection = {
|
|
23389
|
+
groupId: tab.groupId,
|
|
22571
23390
|
tabId: tab.tabId,
|
|
22572
23391
|
runId: run.id,
|
|
23392
|
+
agentId: agent?.instanceId || agent?.id || "",
|
|
22573
23393
|
agentCount,
|
|
22574
23394
|
};
|
|
22575
23395
|
if (elements.subagentCancelDialogSubtitle) {
|
|
@@ -22601,8 +23421,9 @@ async function submitSubagentCancel() {
|
|
|
22601
23421
|
method: "POST",
|
|
22602
23422
|
scoped: false,
|
|
22603
23423
|
body: {
|
|
22604
|
-
|
|
23424
|
+
group: selection.groupId,
|
|
22605
23425
|
runId: selection.runId,
|
|
23426
|
+
...(selection.agentId ? { agentId: selection.agentId } : {}),
|
|
22606
23427
|
...(reason ? { reason } : {}),
|
|
22607
23428
|
...(note ? { note } : {}),
|
|
22608
23429
|
},
|
|
@@ -22621,14 +23442,15 @@ async function submitSubagentCancel() {
|
|
|
22621
23442
|
}
|
|
22622
23443
|
|
|
22623
23444
|
async function dismissSubagentRun(tab, run) {
|
|
22624
|
-
if (!tab?.
|
|
23445
|
+
if (!tab?.groupId || !run?.id || !subagentRunCanDismiss(run)) return;
|
|
23446
|
+
const attachedProjection = subagentRunIsAttachedProjection(run);
|
|
22625
23447
|
try {
|
|
22626
23448
|
await api("/api/subagents/dismiss", {
|
|
22627
23449
|
method: "POST",
|
|
22628
23450
|
scoped: false,
|
|
22629
|
-
body: {
|
|
23451
|
+
body: { group: tab.groupId, runId: run.id },
|
|
22630
23452
|
});
|
|
22631
|
-
addEvent(`dismissed finished subagent run ${run.id}`, "info");
|
|
23453
|
+
addEvent(attachedProjection ? `detached persisted session projection ${run.id}` : `dismissed finished subagent run ${run.id}`, "info");
|
|
22632
23454
|
await refreshSubagents();
|
|
22633
23455
|
scheduleRefreshSubagents();
|
|
22634
23456
|
} catch (error) {
|
|
@@ -22637,12 +23459,10 @@ async function dismissSubagentRun(tab, run) {
|
|
|
22637
23459
|
}
|
|
22638
23460
|
|
|
22639
23461
|
function finishedSubagentRunSelections(data = latestSubagents) {
|
|
22640
|
-
return (
|
|
22641
|
-
|
|
22642
|
-
|
|
22643
|
-
|
|
22644
|
-
.filter((selection) => selection.tabId && selection.runId)
|
|
22645
|
-
));
|
|
23462
|
+
return subagentOverviewGroups(data).flatMap((tab) => tab.displayRuns
|
|
23463
|
+
.filter((run) => subagentRunIsTerminal(run) && subagentRunCanDismiss(run))
|
|
23464
|
+
.map((run) => ({ groupId: tab.groupId, runId: run.id }))
|
|
23465
|
+
.filter((selection) => selection.groupId && selection.runId));
|
|
22646
23466
|
}
|
|
22647
23467
|
|
|
22648
23468
|
async function clearFinishedSubagentRuns({ automatic = false } = {}) {
|
|
@@ -22660,7 +23480,7 @@ async function clearFinishedSubagentRuns({ automatic = false } = {}) {
|
|
|
22660
23480
|
await api("/api/subagents/dismiss", {
|
|
22661
23481
|
method: "POST",
|
|
22662
23482
|
scoped: false,
|
|
22663
|
-
body: {
|
|
23483
|
+
body: { group: selection.groupId, runId: selection.runId },
|
|
22664
23484
|
});
|
|
22665
23485
|
dismissed += 1;
|
|
22666
23486
|
} catch (error) {
|
|
@@ -22870,7 +23690,7 @@ function renderSubagentOverlayWidget() {
|
|
|
22870
23690
|
const transcriptMessages = subagentOverlayTranscriptMessages(data);
|
|
22871
23691
|
const hasStructuredTranscript = transcriptMessages.length > 0;
|
|
22872
23692
|
const outputText = subagentOverlayOutputText(data);
|
|
22873
|
-
const fallbackText = outputText || (running && agent.currentTool ? "" : running ? "Waiting for the first agent activity…" : "No recent output was captured.");
|
|
23693
|
+
const fallbackText = outputText || agent.unavailableReason || (agent.unavailable ? "Output is unavailable for this registered agent." : running && agent.currentTool ? "" : running ? "Waiting for the first agent activity…" : "No recent output was captured.");
|
|
22874
23694
|
const shownLineCount = outputText ? outputText.split("\n").length : fallbackText ? fallbackText.split("\n").length : 0;
|
|
22875
23695
|
const widget = make("section", `widget release-npm-widget app-runner-widget subagent-overlay-widget${running ? " app-runner-live-widget" : " app-runner-log-widget"}`);
|
|
22876
23696
|
widget.setAttribute("aria-label", `Live output for subagent ${agent.name || "subagent"}`);
|
|
@@ -22912,11 +23732,13 @@ function renderSubagentOverlayWidget() {
|
|
|
22912
23732
|
}, "subagent-overlay-refresh-action");
|
|
22913
23733
|
refreshButton.disabled = subagentOverlayLoading || selection.finished;
|
|
22914
23734
|
if (subagentRunCanCancel(selection.run, agent)) {
|
|
22915
|
-
actions.append(appRunnerActionButton("Cancel…", () => openSubagentCancelDialog(tab, selection.run, agent), "subagent-overlay-cancel-action danger"));
|
|
23735
|
+
actions.append(appRunnerActionButton("Cancel…", () => openSubagentCancelDialog(selection.tab, selection.run, agent), "subagent-overlay-cancel-action danger"));
|
|
22916
23736
|
}
|
|
22917
|
-
actions.append(copyButton
|
|
23737
|
+
actions.append(copyButton);
|
|
23738
|
+
if (subagentRunCanRefresh(selection.run, agent)) actions.append(refreshButton);
|
|
23739
|
+
actions.append(appRunnerActionButton("Close", closeSubagentOverlay, "subagent-overlay-close-action"));
|
|
22918
23740
|
const details = [
|
|
22919
|
-
`${tab?.title || `Terminal ${selection.tabIndex || "?"}`} · run ${selection.runId}`,
|
|
23741
|
+
`${selection.tab?.tabTitle || tab?.title || `Terminal ${selection.tabIndex || "?"}`} · run ${selection.runId}`,
|
|
22920
23742
|
agent.currentPath ? `path: ${agent.currentPath}` : "",
|
|
22921
23743
|
agent.activityState ? `activity: ${agent.activityState}` : "",
|
|
22922
23744
|
agent.error ? `status warning: ${agent.error}` : "",
|
|
@@ -22947,7 +23769,7 @@ async function refreshSubagentOverlay() {
|
|
|
22947
23769
|
const previousSignature = subagentOverlayMeaningfulSignature();
|
|
22948
23770
|
subagentOverlayLoading = true;
|
|
22949
23771
|
try {
|
|
22950
|
-
const query = new URLSearchParams({
|
|
23772
|
+
const query = new URLSearchParams({ group: selection.groupId, run: selection.runId, agent: selection.agentId });
|
|
22951
23773
|
const response = await api(`/api/subagents/output?${query}`, { scoped: false });
|
|
22952
23774
|
if (requestSerial !== subagentOverlayRequestSerial || subagentOverlaySelection !== selection) return;
|
|
22953
23775
|
subagentOverlayData = response.data || null;
|
|
@@ -22967,11 +23789,12 @@ async function refreshSubagentOverlay() {
|
|
|
22967
23789
|
}
|
|
22968
23790
|
|
|
22969
23791
|
async function openSubagentOverlay(tab, run, agent) {
|
|
22970
|
-
if (!tab?.
|
|
23792
|
+
if (!tab?.groupId || !run?.id || !agent?.id || !subagentRunCanOpen(run, agent)) return;
|
|
22971
23793
|
if (activeSubagentTerminalId) deactivateSubagentTerminalView({ render: false });
|
|
22972
23794
|
try {
|
|
22973
23795
|
if (activeTabId !== tab.tabId) await switchTab(tab.tabId);
|
|
22974
23796
|
subagentOverlaySelection = {
|
|
23797
|
+
groupId: tab.groupId,
|
|
22975
23798
|
tabId: tab.tabId,
|
|
22976
23799
|
tabIndex: tab.tabIndex,
|
|
22977
23800
|
tab,
|
|
@@ -23049,6 +23872,7 @@ function updateSubagentTerminalRefreshState(view, { running = subagentTerminalVi
|
|
|
23049
23872
|
elements.subagentTerminalStatus.setAttribute("aria-live", view.error ? "polite" : "off");
|
|
23050
23873
|
elements.subagentTerminalStatus.textContent = status;
|
|
23051
23874
|
elements.subagentTerminalStatus.classList.toggle("warning", !!view.error);
|
|
23875
|
+
elements.subagentTerminalRefreshButton.hidden = !subagentRunCanRefresh(view.run, view.data?.agent || view.agent);
|
|
23052
23876
|
elements.subagentTerminalRefreshButton.disabled = view.loading || view.finished === true;
|
|
23053
23877
|
elements.subagentTerminalRefreshButton.textContent = view.loading ? "Refreshing…" : "Refresh";
|
|
23054
23878
|
}
|
|
@@ -23099,7 +23923,7 @@ function renderSubagentTerminalView() {
|
|
|
23099
23923
|
const transcriptMessages = subagentOverlayTranscriptMessages({ agent });
|
|
23100
23924
|
const hasStructuredTranscript = transcriptMessages.length > 0;
|
|
23101
23925
|
const outputText = subagentOverlayOutputText({ agent });
|
|
23102
|
-
const fallbackText = outputText || (running && agent.currentTool ? "" : running ? "Waiting for the first agent activity…" : "No recent output was captured.");
|
|
23926
|
+
const fallbackText = outputText || agent.unavailableReason || (agent.unavailable ? "Output is unavailable for this registered agent." : running && agent.currentTool ? "" : running ? "Waiting for the first agent activity…" : "No recent output was captured.");
|
|
23103
23927
|
const parent = tabs.find((tab) => tab.id === view.parentTabId);
|
|
23104
23928
|
const elapsed = subagentRunElapsed(view.run);
|
|
23105
23929
|
const facts = [
|
|
@@ -23137,6 +23961,7 @@ function renderSubagentTerminalView() {
|
|
|
23137
23961
|
if (running) appendSubagentRunIndicator(elements.subagentTerminalTranscript, { agent, run: view.run });
|
|
23138
23962
|
|
|
23139
23963
|
updateSubagentTerminalRefreshState(view, { running });
|
|
23964
|
+
elements.subagentTerminalCopyButton.hidden = !outputText;
|
|
23140
23965
|
elements.subagentTerminalCopyButton.disabled = !outputText;
|
|
23141
23966
|
if (elements.subagentTerminalCancelButton) {
|
|
23142
23967
|
const cancellable = subagentRunCanCancel(view.run, agent);
|
|
@@ -23165,7 +23990,7 @@ async function refreshSubagentTerminalView(viewId = activeSubagentTerminalId, {
|
|
|
23165
23990
|
view.loading = true;
|
|
23166
23991
|
if (showLoading) updateSubagentTerminalRefreshState(view);
|
|
23167
23992
|
try {
|
|
23168
|
-
const query = new URLSearchParams({
|
|
23993
|
+
const query = new URLSearchParams({ group: view.groupId, run: view.runId, agent: view.agentId });
|
|
23169
23994
|
const response = await api(`/api/subagents/output?${query}`, { scoped: false });
|
|
23170
23995
|
if (view.requestSerial !== requestSerial || !subagentTerminalViews.has(view.id)) return;
|
|
23171
23996
|
view.data = response.data || null;
|
|
@@ -23220,10 +24045,11 @@ async function activateSubagentTerminalView(viewId) {
|
|
|
23220
24045
|
}
|
|
23221
24046
|
|
|
23222
24047
|
function ensureSubagentTerminalView(tab, run, agent) {
|
|
23223
|
-
if (!tab?.tabId || !run?.id || !agent?.id) return null;
|
|
24048
|
+
if (!tab?.groupId || !tab?.tabId || !run?.id || !agent?.id || !subagentRunCanOpen(run, agent)) return null;
|
|
23224
24049
|
const id = subagentTerminalViewId(tab, run, agent);
|
|
23225
24050
|
const existing = subagentTerminalViews.get(id);
|
|
23226
24051
|
if (existing) {
|
|
24052
|
+
existing.groupId = tab.groupId;
|
|
23227
24053
|
existing.tab = tab;
|
|
23228
24054
|
existing.run = run;
|
|
23229
24055
|
existing.agent = agent;
|
|
@@ -23233,6 +24059,7 @@ function ensureSubagentTerminalView(tab, run, agent) {
|
|
|
23233
24059
|
}
|
|
23234
24060
|
const view = {
|
|
23235
24061
|
id,
|
|
24062
|
+
groupId: tab.groupId,
|
|
23236
24063
|
parentTabId: tab.tabId,
|
|
23237
24064
|
parentTitle: tab.tabTitle,
|
|
23238
24065
|
tabIndex: tab.tabIndex,
|
|
@@ -23254,6 +24081,7 @@ function ensureSubagentTerminalView(tab, run, agent) {
|
|
|
23254
24081
|
}
|
|
23255
24082
|
|
|
23256
24083
|
async function openSubagentTerminal(tab, run, agent) {
|
|
24084
|
+
if (!subagentRunCanOpen(run, agent)) return;
|
|
23257
24085
|
const view = ensureSubagentTerminalView(tab, run, agent);
|
|
23258
24086
|
if (!view) return;
|
|
23259
24087
|
try {
|
|
@@ -23315,10 +24143,17 @@ function removeSubagentTerminalViewsForParent(parentTabId) {
|
|
|
23315
24143
|
|
|
23316
24144
|
function syncSubagentTerminalViewsFromOverview() {
|
|
23317
24145
|
let changed = false;
|
|
23318
|
-
const overviewTabs =
|
|
23319
|
-
for (const view of subagentTerminalViews.values()) {
|
|
23320
|
-
const tab = overviewTabs.find((candidate) => candidate.
|
|
24146
|
+
const overviewTabs = subagentOverviewGroups();
|
|
24147
|
+
for (const view of [...subagentTerminalViews.values()]) {
|
|
24148
|
+
const tab = overviewTabs.find((candidate) => candidate.groupId === view.groupId);
|
|
23321
24149
|
const run = (Array.isArray(tab?.runs) ? tab.runs : []).find((candidate) => candidate.id === view.runId);
|
|
24150
|
+
if (run && !subagentRunCanOpen(run, (Array.isArray(run.agents) ? run.agents : []).find((candidate) => candidate.id === view.agentId))) {
|
|
24151
|
+
view.requestSerial += 1;
|
|
24152
|
+
subagentTerminalViews.delete(view.id);
|
|
24153
|
+
if (activeSubagentTerminalId === view.id) activeSubagentTerminalId = null;
|
|
24154
|
+
changed = true;
|
|
24155
|
+
continue;
|
|
24156
|
+
}
|
|
23322
24157
|
const agent = (Array.isArray(run?.agents) ? run.agents : []).find((candidate) => candidate.id === view.agentId);
|
|
23323
24158
|
if (tab) {
|
|
23324
24159
|
view.tab = tab;
|
|
@@ -23337,18 +24172,29 @@ function syncSubagentTerminalViewsFromOverview() {
|
|
|
23337
24172
|
}
|
|
23338
24173
|
const selection = subagentOverlaySelection;
|
|
23339
24174
|
if (selection) {
|
|
23340
|
-
const tab = overviewTabs.find((candidate) => candidate.
|
|
24175
|
+
const tab = overviewTabs.find((candidate) => candidate.groupId === selection.groupId);
|
|
23341
24176
|
const run = (Array.isArray(tab?.runs) ? tab.runs : []).find((candidate) => candidate.id === selection.runId);
|
|
23342
|
-
|
|
23343
|
-
|
|
23344
|
-
|
|
23345
|
-
|
|
23346
|
-
|
|
23347
|
-
|
|
23348
|
-
|
|
23349
|
-
|
|
23350
|
-
if (subagentOverlayData?.agent) subagentOverlayData = { ...subagentOverlayData, agent: { ...subagentOverlayData.agent, ...agent } };
|
|
24177
|
+
if (run && !subagentRunCanOpen(run, (Array.isArray(run.agents) ? run.agents : []).find((candidate) => candidate.id === selection.agentId))) {
|
|
24178
|
+
clearTimeout(subagentOverlayRefreshTimer);
|
|
24179
|
+
subagentOverlayRefreshTimer = null;
|
|
24180
|
+
subagentOverlayRequestSerial += 1;
|
|
24181
|
+
subagentOverlaySelection = null;
|
|
24182
|
+
subagentOverlayData = null;
|
|
24183
|
+
subagentOverlayError = "";
|
|
24184
|
+
subagentOverlayLoading = false;
|
|
23351
24185
|
changed = true;
|
|
24186
|
+
} else {
|
|
24187
|
+
const agent = (Array.isArray(run?.agents) ? run.agents : []).find((candidate) => candidate.id === selection.agentId);
|
|
24188
|
+
if (tab) selection.tab = tab;
|
|
24189
|
+
if (run) {
|
|
24190
|
+
selection.run = run;
|
|
24191
|
+
changed = true;
|
|
24192
|
+
}
|
|
24193
|
+
if (agent) {
|
|
24194
|
+
selection.agent = agent;
|
|
24195
|
+
if (subagentOverlayData?.agent) subagentOverlayData = { ...subagentOverlayData, agent: { ...subagentOverlayData.agent, ...agent } };
|
|
24196
|
+
changed = true;
|
|
24197
|
+
}
|
|
23352
24198
|
}
|
|
23353
24199
|
}
|
|
23354
24200
|
return changed;
|
|
@@ -23357,13 +24203,13 @@ function syncSubagentTerminalViewsFromOverview() {
|
|
|
23357
24203
|
function materializeRetainedSubagentTerminalViews() {
|
|
23358
24204
|
if (subagentOpenMode !== "tab") return false;
|
|
23359
24205
|
let materialized = false;
|
|
23360
|
-
for (const tab of
|
|
24206
|
+
for (const tab of subagentOverviewGroups()) {
|
|
23361
24207
|
if (tab?.available !== true || !tab?.tabId) continue;
|
|
23362
24208
|
const restoreKey = `${tab.tabId}\u0000${tab.sessionFile || ""}`;
|
|
23363
24209
|
if (subagentTerminalRestoredParentTabs.has(restoreKey)) continue;
|
|
23364
24210
|
subagentTerminalRestoredParentTabs.add(restoreKey);
|
|
23365
|
-
for (const run of
|
|
23366
|
-
if (
|
|
24211
|
+
for (const run of tab.displayRuns) {
|
|
24212
|
+
if (["queued", "running", "stale"].includes(subagentAgentStatus(run)) || run?.source === "workflow") continue;
|
|
23367
24213
|
for (const agent of Array.isArray(run.agents) ? run.agents : []) {
|
|
23368
24214
|
const id = subagentTerminalViewId(tab, run, agent);
|
|
23369
24215
|
if (subagentTerminalViews.has(id)) continue;
|
|
@@ -23501,30 +24347,41 @@ function renderSubagentTerminalTabGroup(group) {
|
|
|
23501
24347
|
}
|
|
23502
24348
|
|
|
23503
24349
|
function openSubagentOutput(tab, run, agent) {
|
|
24350
|
+
if (!subagentRunCanOpen(run, agent)) return;
|
|
23504
24351
|
return subagentOpenMode === "tab" ? openSubagentTerminal(tab, run, agent) : openSubagentOverlay(tab, run, agent);
|
|
23505
24352
|
}
|
|
23506
24353
|
|
|
23507
24354
|
function renderSubagentAgent(tab, run, agent) {
|
|
23508
|
-
const
|
|
24355
|
+
const status = subagentAgentStatus(run, agent);
|
|
24356
|
+
const running = ["queued", "running"].includes(status);
|
|
24357
|
+
const interactive = subagentRunCanOpen(run, agent);
|
|
23509
24358
|
const name = agent?.name || "subagent";
|
|
23510
24359
|
const [model, thinking] = subagentExecutionValues(agent);
|
|
23511
|
-
const
|
|
23512
|
-
row
|
|
24360
|
+
const launcher = subagentLauncherLabel(agent?.launcher || run?.launcher);
|
|
24361
|
+
const row = make(interactive ? "button" : "div", `subagent-agent-row state-${status}${agent?.nested ? " nested" : ""}${running ? " running" : " finished"}${interactive ? "" : " metadata-only"}`);
|
|
24362
|
+
if (interactive) row.type = "button";
|
|
23513
24363
|
row.dataset.subagentContinuityKey = `agent:${tab?.tabId || ""}:${run?.id || ""}:${agent?.id || ""}`;
|
|
23514
|
-
const dot = make("span",
|
|
24364
|
+
const dot = make("span", `subagent-state-dot ${status}`);
|
|
23515
24365
|
dot.setAttribute("aria-hidden", "true");
|
|
23516
24366
|
const identity = make("span", "subagent-agent-identity");
|
|
23517
24367
|
identity.append(
|
|
23518
24368
|
make("strong", "subagent-agent-name", name),
|
|
23519
|
-
make("span", "subagent-
|
|
24369
|
+
make("span", "subagent-source-badge", launcher),
|
|
24370
|
+
make("span", "subagent-agent-inline-meta", `· ${status} · ${model} · ${thinking}`),
|
|
23520
24371
|
);
|
|
23521
|
-
|
|
23522
|
-
|
|
23523
|
-
|
|
23524
|
-
|
|
23525
|
-
|
|
23526
|
-
|
|
23527
|
-
|
|
24372
|
+
row.append(dot, identity);
|
|
24373
|
+
if (interactive) {
|
|
24374
|
+
const open = make("span", "subagent-agent-open", "›");
|
|
24375
|
+
open.setAttribute("aria-hidden", "true");
|
|
24376
|
+
row.append(open);
|
|
24377
|
+
const destination = subagentOpenMode === "tab" ? "subagent tab" : "output overlay";
|
|
24378
|
+
row.title = `${name} · ${launcher} · ${status} · ${model} · ${thinking} · open ${destination}`;
|
|
24379
|
+
row.setAttribute("aria-label", `Open ${destination} for ${name}, launched by ${launcher}, ${status}, model ${model}, reasoning ${thinking}, in ${tab?.tabTitle || `Terminal ${tab?.tabIndex || "?"}`}`);
|
|
24380
|
+
row.addEventListener("click", () => openSubagentOutput(tab, run, agent));
|
|
24381
|
+
} else {
|
|
24382
|
+
row.title = `${name} · ${launcher} · ${status} · output is unavailable from this provider`;
|
|
24383
|
+
row.setAttribute("aria-label", `${name}, launched by ${launcher}, ${status}; output and controls are unavailable from this provider`);
|
|
24384
|
+
}
|
|
23528
24385
|
return row;
|
|
23529
24386
|
}
|
|
23530
24387
|
|
|
@@ -23548,11 +24405,12 @@ function renderSubagentRun(tab, run) {
|
|
|
23548
24405
|
applyStyledTooltip(cancel, "Cancel entire subagent run…", { ariaLabel: "Cancel entire subagent run" });
|
|
23549
24406
|
cancel.addEventListener("click", () => openSubagentCancelDialog(tab, run));
|
|
23550
24407
|
actions.append(cancel);
|
|
23551
|
-
} else if (
|
|
24408
|
+
} else if (subagentRunCanDismiss(run)) {
|
|
23552
24409
|
const dismiss = make("button", "subagent-run-dismiss", "×");
|
|
23553
24410
|
dismiss.type = "button";
|
|
23554
24411
|
dismiss.dataset.subagentContinuityKey = `run:${tab?.tabId || ""}:${run?.id || ""}:dismiss`;
|
|
23555
|
-
|
|
24412
|
+
const dismissLabel = subagentRunIsAttachedProjection(run) ? "Detach persisted session from WebUI" : "Dismiss finished run";
|
|
24413
|
+
applyStyledTooltip(dismiss, dismissLabel, { ariaLabel: dismissLabel });
|
|
23556
24414
|
dismiss.addEventListener("click", () => dismissSubagentRun(tab, run));
|
|
23557
24415
|
actions.append(dismiss);
|
|
23558
24416
|
}
|
|
@@ -23565,13 +24423,13 @@ function subagentGateStatusLabel(status) {
|
|
|
23565
24423
|
}
|
|
23566
24424
|
|
|
23567
24425
|
function subagentGateAttemptTarget(tab, attempt) {
|
|
23568
|
-
if (!tab?.
|
|
23569
|
-
const run = (Array.isArray(tab.
|
|
24426
|
+
if (!tab?.groupId || !attempt?.runId) return null;
|
|
24427
|
+
const run = (Array.isArray(tab.displayRuns) ? tab.displayRuns : []).find((candidate) => candidate?.id === attempt.runId);
|
|
23570
24428
|
if (!run) return null;
|
|
23571
24429
|
const agents = Array.isArray(run.agents) ? run.agents : [];
|
|
23572
|
-
let agent = agents.find((candidate) => candidate?.name === attempt.agent);
|
|
24430
|
+
let agent = agents.find((candidate) => candidate?.id === attempt.instanceId || candidate?.instanceId === attempt.instanceId || candidate?.name === attempt.agent);
|
|
23573
24431
|
if (!agent && agents.length === 1) [agent] = agents;
|
|
23574
|
-
return agent?.id ? { run, agent } : null;
|
|
24432
|
+
return agent?.id && subagentRunCanOpen(run, agent) ? { run, agent } : null;
|
|
23575
24433
|
}
|
|
23576
24434
|
|
|
23577
24435
|
function subagentGateAttemptExecutionValues(attempt = {}) {
|
|
@@ -23651,28 +24509,32 @@ function renderSubagentGate(tab, gate) {
|
|
|
23651
24509
|
}
|
|
23652
24510
|
|
|
23653
24511
|
function renderSubagentTabGroup(tab) {
|
|
23654
|
-
const
|
|
23655
|
-
const
|
|
23656
|
-
header
|
|
24512
|
+
const isExternal = tab.groupKind === "external";
|
|
24513
|
+
const group = make("section", `subagent-tab-group${isExternal ? " external" : ""}${tab.tabId === activeTabId && !isExternal ? " active" : ""}`);
|
|
24514
|
+
const header = make(isExternal ? "div" : "button", "subagent-tab-header");
|
|
24515
|
+
if (!isExternal) header.type = "button";
|
|
23657
24516
|
header.dataset.subagentContinuityKey = `tab:${tab?.tabId || ""}`;
|
|
23658
|
-
header.setAttribute("aria-label", `Open ${tab.tabTitle || `Terminal ${tab.tabIndex || ""}`}`);
|
|
24517
|
+
if (!isExternal) header.setAttribute("aria-label", `Open ${tab.tabTitle || `Terminal ${tab.tabIndex || ""}`}`);
|
|
23659
24518
|
const title = make("span", "subagent-tab-title");
|
|
23660
24519
|
title.append(
|
|
23661
24520
|
make("strong", undefined, tab.tabTitle || `Terminal ${tab.tabIndex || "?"}`),
|
|
23662
|
-
make("span", "subagent-tab-session", `Terminal ${tab.tabIndex || "?"} · ${subagentTabMeta(tab)}`),
|
|
24521
|
+
make("span", "subagent-tab-session", isExternal ? "Registered outside open WebUI tabs" : `Terminal ${tab.tabIndex || "?"} · ${subagentTabMeta(tab)}`),
|
|
23663
24522
|
);
|
|
23664
24523
|
const runs = (Array.isArray(tab.displayRuns) ? tab.displayRuns : ungatedSubagentRuns(tab))
|
|
23665
24524
|
.slice()
|
|
23666
24525
|
.sort((a, b) => Number(a.startedAt || 0) - Number(b.startedAt || 0) || String(a.id || "").localeCompare(String(b.id || "")));
|
|
23667
24526
|
const runningAgents = Number(tab.runningAgents || 0);
|
|
23668
|
-
const
|
|
24527
|
+
const staleAgents = Number(tab.staleAgents || 0);
|
|
24528
|
+
const retainedRuns = runs.filter((run) => !["queued", "running", "stale"].includes(subagentAgentStatus(run))).length;
|
|
23669
24529
|
const countLabel = [
|
|
23670
|
-
`${
|
|
24530
|
+
`${tab.agentCount || 0} total`,
|
|
24531
|
+
runningAgents ? `${runningAgents} running` : "",
|
|
24532
|
+
staleAgents ? `${staleAgents} stale` : "",
|
|
23671
24533
|
retainedRuns ? `${retainedRuns} retained` : "",
|
|
23672
24534
|
Number(tab.gateCount || 0) ? `${tab.gateCount} gates` : "",
|
|
23673
24535
|
].filter(Boolean).join(" · ");
|
|
23674
24536
|
header.append(title, make("span", "subagent-tab-count", countLabel));
|
|
23675
|
-
header.addEventListener("click", () => switchTab(tab.tabId));
|
|
24537
|
+
if (!isExternal) header.addEventListener("click", () => switchTab(tab.tabId));
|
|
23676
24538
|
group.append(header);
|
|
23677
24539
|
|
|
23678
24540
|
const list = make("div", "subagent-agent-list");
|
|
@@ -23697,7 +24559,9 @@ function renderSubagents() {
|
|
|
23697
24559
|
const restoreFocus = () => restoreScopedControlContinuity(box, continuityContextKey, focusSnapshot, (key) => [...box.querySelectorAll("[data-subagent-continuity-key]")].find((node) => subagentPanelControlKey(node) === key));
|
|
23698
24560
|
const activeTabs = subagentTabsWithRunningAgents();
|
|
23699
24561
|
const finishedRuns = finishedSubagentRunSelections();
|
|
23700
|
-
const totalAgents = Number(latestSubagents?.
|
|
24562
|
+
const totalAgents = Number(latestSubagents?.counts?.totalAgents ?? latestSubagents?.totalAgents ?? activeTabs.reduce((count, tab) => count + Number(tab.agentCount || 0), 0));
|
|
24563
|
+
const runningAgents = Number(latestSubagents?.counts?.runningAgents ?? latestSubagents?.runningAgents ?? activeTabs.reduce((count, tab) => count + Number(tab.runningAgents || 0), 0));
|
|
24564
|
+
const staleAgents = Number(latestSubagents?.counts?.staleAgents ?? activeTabs.reduce((count, tab) => count + Number(tab.staleAgents || 0), 0));
|
|
23701
24565
|
const totalRuns = activeTabs.reduce((count, tab) => count + tab.displayRuns.length, 0);
|
|
23702
24566
|
const runningRuns = activeTabs.reduce((count, tab) => count + tab.displayRuns.filter((run) => run?.status === "running").length, 0);
|
|
23703
24567
|
const retainedRuns = Math.max(0, totalRuns - runningRuns);
|
|
@@ -23723,7 +24587,7 @@ function renderSubagents() {
|
|
|
23723
24587
|
}
|
|
23724
24588
|
if (elements.subagentsStatus) {
|
|
23725
24589
|
elements.subagentsStatus.textContent = hasItems
|
|
23726
|
-
? [`${totalAgents} running`, retainedRuns ? `${retainedRuns} retained ${retainedRuns === 1 ? "run" : "runs"}` : "", totalGates ? `${totalGates} retry ${totalGates === 1 ? "gate" : "gates"}` : "", `across ${activeTabs.length} ${activeTabs.length === 1 ? "
|
|
24590
|
+
? [`${totalAgents} total`, `${runningAgents} running`, staleAgents ? `${staleAgents} stale` : "", Number(latestSubagents?.fleet?.omitted || 0) ? `${latestSubagents.fleet.omitted} active ${latestSubagents.fleet.omitted === 1 ? "child" : "children"} omitted upstream` : "", retainedRuns ? `${retainedRuns} retained ${retainedRuns === 1 ? "run" : "runs"}` : "", totalGates ? `${totalGates} retry ${totalGates === 1 ? "gate" : "gates"}` : "", `across ${activeTabs.length} ${activeTabs.length === 1 ? "group" : "groups"}`].filter(Boolean).join(" · ")
|
|
23727
24591
|
: subagentsLoading && !latestSubagents
|
|
23728
24592
|
? "Checking subagents and retry gates…"
|
|
23729
24593
|
: "No running subagents, retained runs, or retry gates.";
|
|
@@ -23733,7 +24597,7 @@ function renderSubagents() {
|
|
|
23733
24597
|
box.classList.toggle("muted", !hasItems);
|
|
23734
24598
|
box.classList.toggle("has-items", hasItems);
|
|
23735
24599
|
if (!hasItems) {
|
|
23736
|
-
box.append(make("div", "subagents-empty", subagentsError ? `Subagent status unavailable: ${subagentsError.message || subagentsError}` : "
|
|
24600
|
+
box.append(make("div", "subagents-empty", subagentsError ? `Subagent status unavailable: ${subagentsError.message || subagentsError}` : "Managed and registered Pi agent runs will appear here, grouped by terminal or under External agents."));
|
|
23737
24601
|
restoreFocus();
|
|
23738
24602
|
return;
|
|
23739
24603
|
}
|
|
@@ -23743,32 +24607,51 @@ function renderSubagents() {
|
|
|
23743
24607
|
}
|
|
23744
24608
|
|
|
23745
24609
|
async function refreshSubagents() {
|
|
23746
|
-
if (
|
|
24610
|
+
if (subagentsRefreshPromise) {
|
|
24611
|
+
subagentsRefreshQueued = true;
|
|
24612
|
+
return subagentsRefreshPromise;
|
|
24613
|
+
}
|
|
23747
24614
|
let refreshed = false;
|
|
23748
24615
|
let subagentViewsChanged = false;
|
|
23749
24616
|
let materializedTerminalViews = false;
|
|
23750
24617
|
subagentsLoading = true;
|
|
23751
24618
|
renderSubagents();
|
|
23752
|
-
|
|
23753
|
-
|
|
23754
|
-
|
|
23755
|
-
|
|
23756
|
-
|
|
23757
|
-
|
|
23758
|
-
|
|
23759
|
-
|
|
23760
|
-
|
|
23761
|
-
|
|
23762
|
-
|
|
23763
|
-
|
|
23764
|
-
|
|
23765
|
-
|
|
23766
|
-
|
|
23767
|
-
|
|
23768
|
-
|
|
24619
|
+
let settleRefresh;
|
|
24620
|
+
let rejectRefresh;
|
|
24621
|
+
const refreshPromise = new Promise((resolve, reject) => {
|
|
24622
|
+
settleRefresh = resolve;
|
|
24623
|
+
rejectRefresh = reject;
|
|
24624
|
+
});
|
|
24625
|
+
subagentsRefreshPromise = refreshPromise;
|
|
24626
|
+
(async () => {
|
|
24627
|
+
try {
|
|
24628
|
+
do {
|
|
24629
|
+
subagentsRefreshQueued = false;
|
|
24630
|
+
try {
|
|
24631
|
+
const response = await api("/api/subagents", { scoped: false });
|
|
24632
|
+
latestSubagents = response.data || null;
|
|
24633
|
+
pruneDismissedSubagentGateKeys(latestSubagents?.tabs, dismissedSubagentGateKeys);
|
|
24634
|
+
subagentViewsChanged = syncSubagentTerminalViewsFromOverview() || subagentViewsChanged;
|
|
24635
|
+
materializedTerminalViews = materializeRetainedSubagentTerminalViews() || materializedTerminalViews;
|
|
24636
|
+
subagentsError = null;
|
|
24637
|
+
refreshed = true;
|
|
24638
|
+
} catch (error) {
|
|
24639
|
+
subagentsError = error;
|
|
24640
|
+
}
|
|
24641
|
+
} while (subagentsRefreshQueued);
|
|
24642
|
+
} finally {
|
|
24643
|
+
if (subagentsRefreshPromise === refreshPromise) subagentsRefreshPromise = null;
|
|
24644
|
+
subagentsLoading = false;
|
|
24645
|
+
renderSubagents();
|
|
24646
|
+
if (subagentOverlaySelection?.tabId === activeTabId) renderWidgets();
|
|
24647
|
+
if (activeSubagentTerminalId) {
|
|
24648
|
+
renderSubagentTerminalView();
|
|
24649
|
+
scheduleSubagentTerminalRefresh();
|
|
24650
|
+
}
|
|
24651
|
+
if (subagentViewsChanged || materializedTerminalViews) renderTabs();
|
|
23769
24652
|
}
|
|
23770
|
-
|
|
23771
|
-
|
|
24653
|
+
})().then(settleRefresh, rejectRefresh);
|
|
24654
|
+
await refreshPromise;
|
|
23772
24655
|
if (refreshed && subagentAutoClearEnabled && finishedSubagentRunSelections().length) {
|
|
23773
24656
|
await clearFinishedSubagentRuns({ automatic: true });
|
|
23774
24657
|
}
|
|
@@ -33577,9 +34460,11 @@ function updateStickyUserPromptButton() {
|
|
|
33577
34460
|
const targets = userPromptTargets();
|
|
33578
34461
|
const target = findStickyUserPromptTarget(targets);
|
|
33579
34462
|
if (!target) {
|
|
34463
|
+
if (button.hidden && button.childElementCount === 0) return;
|
|
33580
34464
|
button.hidden = true;
|
|
33581
34465
|
button.removeAttribute("data-message-index");
|
|
33582
34466
|
button.removeAttribute("data-compacted");
|
|
34467
|
+
delete button.dataset.renderSignature;
|
|
33583
34468
|
button.replaceChildren();
|
|
33584
34469
|
return;
|
|
33585
34470
|
}
|
|
@@ -33588,12 +34473,16 @@ function updateStickyUserPromptButton() {
|
|
|
33588
34473
|
const isLatest = target.compacted || ordinal === targets.length;
|
|
33589
34474
|
const label = target.compacted ? "Last user prompt (compacted)" : isLatest ? "Last user prompt" : "Previous user prompt";
|
|
33590
34475
|
const meta = target.compacted ? "summary ↑" : `${ordinal}/${targets.length} ↑`;
|
|
34476
|
+
const messageIndex = Number.isInteger(target.index) && target.index >= 0 ? String(target.index) : "";
|
|
34477
|
+
const baseTitle = target.compacted ? `Prompt was compacted; jump to compaction summary: ${target.preview}` : `Jump to ${label.toLowerCase()}: ${target.preview}`;
|
|
34478
|
+
const baseAriaLabel = target.compacted ? `Prompt was compacted; jump to compaction summary: ${target.preview}` : `Jump to ${label.toLowerCase()} (${ordinal} of ${targets.length}): ${target.preview}`;
|
|
34479
|
+
const renderSignature = JSON.stringify([target.compacted === true, messageIndex, baseTitle, baseAriaLabel, label, target.preview, meta]);
|
|
34480
|
+
if (!button.hidden && button.dataset.renderSignature === renderSignature) return;
|
|
33591
34481
|
button.hidden = false;
|
|
34482
|
+
button.dataset.renderSignature = renderSignature;
|
|
33592
34483
|
button.dataset.compacted = target.compacted ? "true" : "false";
|
|
33593
|
-
if (
|
|
34484
|
+
if (messageIndex) button.dataset.messageIndex = messageIndex;
|
|
33594
34485
|
else button.removeAttribute("data-message-index");
|
|
33595
|
-
const baseTitle = target.compacted ? `Prompt was compacted; jump to compaction summary: ${target.preview}` : `Jump to ${label.toLowerCase()}: ${target.preview}`;
|
|
33596
|
-
const baseAriaLabel = target.compacted ? `Prompt was compacted; jump to compaction summary: ${target.preview}` : `Jump to ${label.toLowerCase()} (${ordinal} of ${targets.length}): ${target.preview}`;
|
|
33597
34486
|
button.title = baseTitle;
|
|
33598
34487
|
button.setAttribute("aria-label", baseAriaLabel);
|
|
33599
34488
|
const children = [
|
|
@@ -35791,6 +36680,7 @@ function scheduleChatFollowScroll({ settle = true } = {}) {
|
|
|
35791
36680
|
|
|
35792
36681
|
function resumeChatAutoFollow() {
|
|
35793
36682
|
chatUserScrollAwayIntentUntil = 0;
|
|
36683
|
+
chatPausedScrollRestoreUntil = 0;
|
|
35794
36684
|
autoFollowChat = true;
|
|
35795
36685
|
}
|
|
35796
36686
|
|
|
@@ -36296,6 +37186,7 @@ function setOptionalControlState(button, available, unavailableTitle) {
|
|
|
36296
37186
|
function resetOptionalFeatureAvailability() {
|
|
36297
37187
|
for (const key of Object.keys(optionalFeatureAvailability)) optionalFeatureAvailability[key] = false;
|
|
36298
37188
|
optionalFeatureAvailability.themeBundle = availableThemes.length > 0;
|
|
37189
|
+
optionalFeatureManagedAccessEnabled.clear();
|
|
36299
37190
|
renderOptionalFeatureControls();
|
|
36300
37191
|
if (activeTabId) queueMicrotask(() => refreshQuestionnaireFeatureAvailability());
|
|
36301
37192
|
}
|
|
@@ -36971,13 +37862,18 @@ async function refreshQuestionnaireFeatureAvailability(tabContext = activeTabCon
|
|
|
36971
37862
|
try {
|
|
36972
37863
|
const response = await api("/api/tools?scope=session", { tabId: tabContext.tabId });
|
|
36973
37864
|
if (!isCurrentTabContext(tabContext)) return false;
|
|
36974
|
-
|
|
36975
|
-
|
|
37865
|
+
const questionnaireTool = Array.isArray(response.data?.tools)
|
|
37866
|
+
? response.data.tools.find((tool) => tool?.name === "questionnaire")
|
|
37867
|
+
: null;
|
|
37868
|
+
optionalFeatureAvailability.questionnaire = !!questionnaireTool;
|
|
37869
|
+
if (questionnaireTool) optionalFeatureManagedAccessEnabled.set("questionnaire", questionnaireTool.enabled !== false);
|
|
37870
|
+
else optionalFeatureManagedAccessEnabled.delete("questionnaire");
|
|
36976
37871
|
renderOptionalFeatureControls();
|
|
36977
37872
|
return true;
|
|
36978
37873
|
} catch {
|
|
36979
37874
|
if (isCurrentTabContext(tabContext)) {
|
|
36980
37875
|
optionalFeatureAvailability.questionnaire = false;
|
|
37876
|
+
optionalFeatureManagedAccessEnabled.delete("questionnaire");
|
|
36981
37877
|
renderOptionalFeatureControls();
|
|
36982
37878
|
}
|
|
36983
37879
|
return false;
|
|
@@ -37109,7 +38005,7 @@ function optionalFeatureStatus(featureId) {
|
|
|
37109
38005
|
const feature = OPTIONAL_FEATURE_BY_ID.get(featureId);
|
|
37110
38006
|
const detected = isOptionalFeatureDetected(featureId);
|
|
37111
38007
|
const managedWithTools = feature?.manageWith === "tools";
|
|
37112
|
-
const disabled =
|
|
38008
|
+
const disabled = isOptionalFeatureDisabled(featureId);
|
|
37113
38009
|
const packageStatus = optionalFeaturePackageStatus(featureId);
|
|
37114
38010
|
const installMessage = optionalFeatureInstallMessages.get(featureId);
|
|
37115
38011
|
const installState = optionalFeatureInstallState(featureId);
|
|
@@ -37135,7 +38031,7 @@ function optionalFeatureStatus(featureId) {
|
|
|
37135
38031
|
};
|
|
37136
38032
|
}
|
|
37137
38033
|
const doneDetail = installState?.phase === "done" ? optionalFeatureInstallDetail(installState, installMessage) : "";
|
|
37138
|
-
if (disabled) return {
|
|
38034
|
+
if (disabled && !managedWithTools) return {
|
|
37139
38035
|
label: "Disabled",
|
|
37140
38036
|
className: "disabled",
|
|
37141
38037
|
detail: `Disabled in this browser and excluded from migration selection${versionSuffix}`,
|
|
@@ -37149,7 +38045,13 @@ function optionalFeatureStatus(featureId) {
|
|
|
37149
38045
|
hint: "Do not install again. Keep either the package entry or the extensions/skills/prompts/themes alias, not both.",
|
|
37150
38046
|
};
|
|
37151
38047
|
if (packageStatus?.updateAvailable) return { label: "Update available", className: "updating", detail: packageStatus.updateReason || `Installed package is older than the Web UI expects${versionSuffix}` };
|
|
37152
|
-
if (
|
|
38048
|
+
if (disabled && managedWithTools) return {
|
|
38049
|
+
label: "Disabled",
|
|
38050
|
+
className: "disabled",
|
|
38051
|
+
detail: `Tool access is disabled for the active Pi session${versionSuffix}`,
|
|
38052
|
+
hint: "Enable it here for this session, or use Setup to manage session and global tool defaults.",
|
|
38053
|
+
};
|
|
38054
|
+
if (detected && managedWithTools) return { label: "Enabled", className: "enabled", detail: doneDetail || `Tool access is enabled for the active Pi session${versionSuffix}`, hint: "Use Setup to manage session and global tool defaults.", command: installState?.command || "" };
|
|
37153
38055
|
if (detected && !disabled) return { label: "Enabled", className: "enabled", detail: doneDetail || `Detected and enabled in Web UI${versionSuffix}`, command: installState?.command || "" };
|
|
37154
38056
|
if (detected && disabled) return { label: "Disabled", className: "disabled", detail: `Detected, but disabled in Web UI${versionSuffix}` };
|
|
37155
38057
|
if (packageStatus?.locallyConfigured) return { label: "Available locally", className: "installed", detail: doneDetail || `Enabled as a top-level Pi resource; reload this tab if the capability is not detected yet${versionSuffix}` };
|
|
@@ -37305,9 +38207,64 @@ function renderOptionalFeatureSection(section, features) {
|
|
|
37305
38207
|
elements.optionalFeaturesBox.append(sectionNode);
|
|
37306
38208
|
}
|
|
37307
38209
|
|
|
38210
|
+
function optionalFeatureSetupAvailable(feature) {
|
|
38211
|
+
switch (feature?.setup) {
|
|
38212
|
+
case "git-workflow": return hasAvailableCommand("git-workflow-setup");
|
|
38213
|
+
case "workflows": return hasLoadedRpcCommand("workflow-setup");
|
|
38214
|
+
case "safety-guard": return hasAvailableCommand("safety-guard-setup");
|
|
38215
|
+
case "tools": return feature.manageWith !== "tools" || isOptionalFeatureDetected(feature.id);
|
|
38216
|
+
default: return false;
|
|
38217
|
+
}
|
|
38218
|
+
}
|
|
38219
|
+
|
|
38220
|
+
function openOptionalFeatureSetup(feature) {
|
|
38221
|
+
switch (feature?.setup) {
|
|
38222
|
+
case "git-workflow": return openNativeGitWorkflowSetupDialog();
|
|
38223
|
+
case "workflows": return openNativeWorkflowSetupDialog();
|
|
38224
|
+
case "safety-guard": return openNativeSafetyGuardSetupDialog();
|
|
38225
|
+
case "tools": return openNativeToolsSelector();
|
|
38226
|
+
default: return undefined;
|
|
38227
|
+
}
|
|
38228
|
+
}
|
|
38229
|
+
|
|
38230
|
+
async function setToolManagedOptionalFeatureEnabled(feature, enabled) {
|
|
38231
|
+
const toolName = feature?.manageWith === "tools" ? String(feature.managedToolName || feature.id) : "";
|
|
38232
|
+
const tabContext = activeTabContext();
|
|
38233
|
+
if (!toolName || !tabContext.tabId || optionalFeatureAccessInProgress.has(feature.id)) return;
|
|
38234
|
+
optionalFeatureAccessInProgress.add(feature.id);
|
|
38235
|
+
renderOptionalFeatureControls();
|
|
38236
|
+
try {
|
|
38237
|
+
const current = await api("/api/tools?scope=session", { tabId: tabContext.tabId });
|
|
38238
|
+
if (!isCurrentTabContext(tabContext)) return;
|
|
38239
|
+
const tools = Array.isArray(current.data?.tools) ? current.data.tools : [];
|
|
38240
|
+
if (!tools.some((tool) => tool?.name === toolName)) throw new Error(`${toolName} is not available in this Pi tab`);
|
|
38241
|
+
const enabledTools = new Set(tools.filter((tool) => tool?.enabled !== false).map((tool) => tool.name));
|
|
38242
|
+
if (enabled) enabledTools.add(toolName);
|
|
38243
|
+
else enabledTools.delete(toolName);
|
|
38244
|
+
const response = await api("/api/tools", {
|
|
38245
|
+
method: "POST",
|
|
38246
|
+
body: { enabledTools: [...enabledTools], scope: "session" },
|
|
38247
|
+
tabId: tabContext.tabId,
|
|
38248
|
+
});
|
|
38249
|
+
if (!isCurrentTabContext(tabContext)) return;
|
|
38250
|
+
const nextTools = Array.isArray(response.data?.tools) ? response.data.tools : [];
|
|
38251
|
+
const nextTool = nextTools.find((tool) => tool?.name === toolName);
|
|
38252
|
+
optionalFeatureAvailability[feature.id] = !!nextTool;
|
|
38253
|
+
if (nextTool) optionalFeatureManagedAccessEnabled.set(feature.id, nextTool.enabled !== false);
|
|
38254
|
+
else optionalFeatureManagedAccessEnabled.delete(feature.id);
|
|
38255
|
+
addEvent(`${feature.label} was ${enabled ? "enabled" : "disabled"} for this session.`, "success");
|
|
38256
|
+
} catch (error) {
|
|
38257
|
+
if (isCurrentTabContext(tabContext)) addEvent(`${feature.label} access was not changed: ${error.message || String(error)}`, "error");
|
|
38258
|
+
} finally {
|
|
38259
|
+
optionalFeatureAccessInProgress.delete(feature.id);
|
|
38260
|
+
if (isCurrentTabContext(tabContext)) renderOptionalFeatureControls();
|
|
38261
|
+
}
|
|
38262
|
+
}
|
|
38263
|
+
|
|
37308
38264
|
function renderOptionalFeatureRow(feature) {
|
|
37309
38265
|
const detected = isOptionalFeatureDetected(feature.id);
|
|
37310
38266
|
const enabled = isOptionalFeatureEnabled(feature.id);
|
|
38267
|
+
const accessChanging = optionalFeatureAccessInProgress.has(feature.id);
|
|
37311
38268
|
const installState = optionalFeatureInstallState(feature.id);
|
|
37312
38269
|
const installing = optionalFeatureInstallInProgress.has(feature.id) || optionalFeatureInstallIsActive(installState);
|
|
37313
38270
|
const failed = installState?.phase === "failed";
|
|
@@ -37317,7 +38274,7 @@ function renderOptionalFeatureRow(feature) {
|
|
|
37317
38274
|
const tooltip = optionalFeatureTooltip(feature, status);
|
|
37318
38275
|
row.dataset.tooltip = tooltip;
|
|
37319
38276
|
row.setAttribute("aria-label", tooltip.replace(/\s+/g, " "));
|
|
37320
|
-
if (installing) row.setAttribute("aria-busy", "true");
|
|
38277
|
+
if (installing || accessChanging) row.setAttribute("aria-busy", "true");
|
|
37321
38278
|
row.tabIndex = 0;
|
|
37322
38279
|
|
|
37323
38280
|
const main = make("div", "optional-feature-main");
|
|
@@ -37347,8 +38304,11 @@ function renderOptionalFeatureRow(feature) {
|
|
|
37347
38304
|
const actions = make("div", "optional-feature-actions");
|
|
37348
38305
|
const action = make("button", "optional-feature-action");
|
|
37349
38306
|
action.type = "button";
|
|
37350
|
-
action.disabled = installing || optionalFeatureBatchIsActive() || (!optionalFeaturePackageStatusesLoaded && !detected);
|
|
37351
|
-
if (
|
|
38307
|
+
action.disabled = accessChanging || installing || optionalFeatureBatchIsActive() || (!optionalFeaturePackageStatusesLoaded && !detected);
|
|
38308
|
+
if (accessChanging) {
|
|
38309
|
+
action.textContent = enabled ? "Disabling…" : "Enabling…";
|
|
38310
|
+
action.setAttribute("aria-busy", "true");
|
|
38311
|
+
} else if (installing) {
|
|
37352
38312
|
action.textContent = installState?.actionLabel === "Update" ? "Updating…" : "Installing…";
|
|
37353
38313
|
action.setAttribute("aria-busy", "true");
|
|
37354
38314
|
} else if (failed) {
|
|
@@ -37356,9 +38316,6 @@ function renderOptionalFeatureRow(feature) {
|
|
|
37356
38316
|
action.textContent = "Retry…";
|
|
37357
38317
|
action.classList.add(retryAsUpdate ? "update" : "install");
|
|
37358
38318
|
action.addEventListener("click", () => installOptionalFeature(feature.id, { update: retryAsUpdate }));
|
|
37359
|
-
} else if (isOptionalFeatureDisabled(feature.id)) {
|
|
37360
|
-
action.textContent = "Enable";
|
|
37361
|
-
action.addEventListener("click", () => setOptionalFeatureDisabled(feature.id, false));
|
|
37362
38319
|
} else if (packageStatus?.resourceConflict) {
|
|
37363
38320
|
action.textContent = "Conflict";
|
|
37364
38321
|
action.disabled = true;
|
|
@@ -37367,8 +38324,11 @@ function renderOptionalFeatureRow(feature) {
|
|
|
37367
38324
|
action.classList.add("update");
|
|
37368
38325
|
action.addEventListener("click", () => installOptionalFeature(feature.id, { update: true }));
|
|
37369
38326
|
} else if (detected && feature.manageWith === "tools") {
|
|
37370
|
-
action.textContent = "
|
|
37371
|
-
action.addEventListener("click", () =>
|
|
38327
|
+
action.textContent = enabled ? "Disable" : "Enable";
|
|
38328
|
+
action.addEventListener("click", () => setToolManagedOptionalFeatureEnabled(feature, !enabled));
|
|
38329
|
+
} else if (isOptionalFeatureDisabled(feature.id)) {
|
|
38330
|
+
action.textContent = "Enable";
|
|
38331
|
+
action.addEventListener("click", () => setOptionalFeatureDisabled(feature.id, false));
|
|
37372
38332
|
} else if (detected) {
|
|
37373
38333
|
action.textContent = enabled ? "Disable" : "Enable";
|
|
37374
38334
|
action.addEventListener("click", async () => {
|
|
@@ -37406,6 +38366,14 @@ function renderOptionalFeatureRow(feature) {
|
|
|
37406
38366
|
action.addEventListener("click", () => installOptionalFeature(feature.id));
|
|
37407
38367
|
}
|
|
37408
38368
|
actions.append(action);
|
|
38369
|
+
if (detected && feature.setup) {
|
|
38370
|
+
const setup = make("button", "optional-feature-action setup", "Setup");
|
|
38371
|
+
setup.type = "button";
|
|
38372
|
+
setup.disabled = accessChanging || installing || optionalFeatureBatchIsActive() || !optionalFeatureSetupAvailable(feature);
|
|
38373
|
+
setup.setAttribute("aria-label", `Set up ${feature.label}`);
|
|
38374
|
+
setup.addEventListener("click", () => openOptionalFeatureSetup(feature));
|
|
38375
|
+
actions.append(setup);
|
|
38376
|
+
}
|
|
37409
38377
|
if (failed) {
|
|
37410
38378
|
const retryFailed = make("button", "optional-feature-action install", "Retry failed");
|
|
37411
38379
|
retryFailed.type = "button";
|
|
@@ -38045,6 +39013,17 @@ function createTerminalTabSessionSummaryButton(tab) {
|
|
|
38045
39013
|
function renderSessionSummaryControls() {
|
|
38046
39014
|
const setupAvailable = !!activeTabId && hasAvailableCommand("summary-setup", { tabId: activeTabId });
|
|
38047
39015
|
if (elements.optionsSummarySetupButton) elements.optionsSummarySetupButton.hidden = !setupAvailable;
|
|
39016
|
+
const state = sessionSummaryStateForTab(activeTabId);
|
|
39017
|
+
const renderSignature = JSON.stringify([
|
|
39018
|
+
activeTabId || "",
|
|
39019
|
+
setupAvailable,
|
|
39020
|
+
!!activeTabId && hasAvailableCommand("summary", { tabId: activeTabId }),
|
|
39021
|
+
state?.status || "",
|
|
39022
|
+
Boolean(state?.summaryMarkdown),
|
|
39023
|
+
state?.message || "",
|
|
39024
|
+
]);
|
|
39025
|
+
if (renderSignature === sessionSummaryControlsRenderSignature) return;
|
|
39026
|
+
sessionSummaryControlsRenderSignature = renderSignature;
|
|
38048
39027
|
scheduleTabsRender();
|
|
38049
39028
|
}
|
|
38050
39029
|
|
|
@@ -38115,8 +39094,10 @@ function openSessionSummaryOverlay(tabId, { loading = false, focusReturnKey = ""
|
|
|
38115
39094
|
|
|
38116
39095
|
function updateSessionSummaryForTab(tabId, value, { resetProjection = false } = {}) {
|
|
38117
39096
|
if (!tabId) return null;
|
|
38118
|
-
const
|
|
39097
|
+
const previous = sessionSummaryByTab.get(tabId);
|
|
39098
|
+
const normalized = normalizeSessionSummaryClientState(value, previous, { resetProjection });
|
|
38119
39099
|
if (!normalized) return null;
|
|
39100
|
+
if (previous && tabsSnapshotSignature(previous) === tabsSnapshotSignature(normalized)) return previous;
|
|
38120
39101
|
sessionSummaryByTab.set(tabId, normalized);
|
|
38121
39102
|
renderSessionSummaryControls();
|
|
38122
39103
|
if (sessionSummaryOverlayTabId === tabId) renderSessionSummaryOverlay();
|
|
@@ -41070,6 +42051,8 @@ async function refreshState(tabContext = activeTabContext()) {
|
|
|
41070
42051
|
if (!isCurrentTabContext(tabContext)) return;
|
|
41071
42052
|
const previousState = currentState;
|
|
41072
42053
|
currentState = response.data || null;
|
|
42054
|
+
if (currentState) tabStateCache.set(tabContext.tabId, currentState);
|
|
42055
|
+
else tabStateCache.delete(tabContext.tabId);
|
|
41073
42056
|
if (latestMessages.length) {
|
|
41074
42057
|
latestMessagesSessionKey = resolveMessagesSessionKey(tabContext.tabId);
|
|
41075
42058
|
cacheMessagesForTab(tabContext.tabId, latestMessages, latestMessagesSessionKey);
|
|
@@ -41092,6 +42075,8 @@ async function refreshStats(tabContext = activeTabContext()) {
|
|
|
41092
42075
|
const response = await api("/api/stats", { tabId: tabContext.tabId });
|
|
41093
42076
|
if (!isCurrentTabContext(tabContext)) return;
|
|
41094
42077
|
latestStats = response.data || null;
|
|
42078
|
+
if (latestStats) tabStatsCache.set(tabContext.tabId, latestStats);
|
|
42079
|
+
else tabStatsCache.delete(tabContext.tabId);
|
|
41095
42080
|
renderFooter();
|
|
41096
42081
|
renderContextMeter();
|
|
41097
42082
|
renderWorkspaceDashboard();
|
|
@@ -41118,6 +42103,8 @@ async function refreshWorkspace(tabContext = activeTabContext()) {
|
|
|
41118
42103
|
}
|
|
41119
42104
|
if (!isCurrentTabContext(tabContext)) return;
|
|
41120
42105
|
latestWorkspace = nextWorkspace;
|
|
42106
|
+
if (latestWorkspace) tabWorkspaceCache.set(tabContext.tabId, latestWorkspace);
|
|
42107
|
+
else tabWorkspaceCache.delete(tabContext.tabId);
|
|
41121
42108
|
rememberServerStartCwd(nextWorkspace?.cwd);
|
|
41122
42109
|
renderFooter();
|
|
41123
42110
|
renderWorkspaceDashboard();
|
|
@@ -41183,6 +42170,8 @@ function renderNetworkStatus() {
|
|
|
41183
42170
|
const authDetail = make("div", "network-status-detail", authText);
|
|
41184
42171
|
|
|
41185
42172
|
elements.networkStatus.replaceChildren(heading, detail, list, authDetail);
|
|
42173
|
+
const remoteAuthRow = elements.remoteAuthToggle?.closest(".remote-auth-control-row");
|
|
42174
|
+
if (remoteAuthRow) remoteAuthRow.hidden = false;
|
|
41186
42175
|
elements.remoteAuthToggle.checked = !!auth.enabled;
|
|
41187
42176
|
elements.remoteAuthToggle.disabled = rebinding;
|
|
41188
42177
|
elements.remoteAuthStatus.textContent = auth.enabled
|
|
@@ -41293,6 +42282,7 @@ function restoreCachedMessagesForActiveTab() {
|
|
|
41293
42282
|
latestMessages = cached.messages;
|
|
41294
42283
|
latestMessagesSessionKey = cached.sessionKey || resolveMessagesSessionKey(activeTabId);
|
|
41295
42284
|
renderMessages(latestMessages);
|
|
42285
|
+
if (autoFollowChat) setChatScrollTopInstant(elements.chat.scrollHeight);
|
|
41296
42286
|
return true;
|
|
41297
42287
|
}
|
|
41298
42288
|
|
|
@@ -41456,19 +42446,23 @@ function populateModelSelect(models = availableModels, query = "") {
|
|
|
41456
42446
|
const previousValue = elements.modelSelect.value;
|
|
41457
42447
|
const normalizedQuery = String(query || "").trim().toLowerCase();
|
|
41458
42448
|
const matchingModels = models.filter((model) => !normalizedQuery || modelSelectOptionText(model).toLowerCase().includes(normalizedQuery));
|
|
41459
|
-
|
|
41460
|
-
|
|
41461
|
-
|
|
41462
|
-
|
|
41463
|
-
|
|
41464
|
-
|
|
41465
|
-
|
|
41466
|
-
|
|
41467
|
-
|
|
41468
|
-
|
|
41469
|
-
|
|
41470
|
-
|
|
41471
|
-
|
|
42449
|
+
const optionsSignature = JSON.stringify(matchingModels.map((model) => [modelSelectValue(model), modelSelectOptionText(model)]));
|
|
42450
|
+
if (elements.modelSelect.dataset.optionsSignature !== optionsSignature) {
|
|
42451
|
+
elements.modelSelect.dataset.optionsSignature = optionsSignature;
|
|
42452
|
+
elements.modelSelect.replaceChildren();
|
|
42453
|
+
for (const model of matchingModels) {
|
|
42454
|
+
const option = document.createElement("option");
|
|
42455
|
+
option.value = modelSelectValue(model);
|
|
42456
|
+
option.textContent = modelSelectOptionText(model);
|
|
42457
|
+
elements.modelSelect.append(option);
|
|
42458
|
+
}
|
|
42459
|
+
if (!matchingModels.length) {
|
|
42460
|
+
const option = document.createElement("option");
|
|
42461
|
+
option.value = "";
|
|
42462
|
+
option.textContent = "No models match the search";
|
|
42463
|
+
option.disabled = true;
|
|
42464
|
+
elements.modelSelect.append(option);
|
|
42465
|
+
}
|
|
41472
42466
|
}
|
|
41473
42467
|
if (previousValue && [...elements.modelSelect.options].some((option) => option.value === previousValue)) elements.modelSelect.value = previousValue;
|
|
41474
42468
|
renderModelSearchResults(matchingModels);
|
|
@@ -42151,8 +43145,9 @@ async function refreshCommands(tabContext = activeTabContext()) {
|
|
|
42151
43145
|
// Keep results for their originating tab even when the active tab changed
|
|
42152
43146
|
// while this request was in flight. Guided Git must never borrow another
|
|
42153
43147
|
// tab's extension availability or duplicate-command alias.
|
|
43148
|
+
const previousCatalog = commandCatalogsByTab.get(tabContext.tabId);
|
|
42154
43149
|
commandCatalogsByTab.set(tabContext.tabId, catalog);
|
|
42155
|
-
scheduleTabsRender();
|
|
43150
|
+
if (tabsSnapshotSignature(previousCatalog) !== tabsSnapshotSignature(catalog)) scheduleTabsRender();
|
|
42156
43151
|
if (!isCurrentTabContext(tabContext)) return;
|
|
42157
43152
|
rawAvailableCommands = catalog.raw;
|
|
42158
43153
|
availableCommands = catalog.available;
|
|
@@ -45071,6 +46066,16 @@ if (elements.terminalTabsLayoutSelect) {
|
|
|
45071
46066
|
setTerminalTabsLayout(elements.terminalTabsLayoutSelect.value, { announce: true });
|
|
45072
46067
|
});
|
|
45073
46068
|
}
|
|
46069
|
+
if (elements.controlDeckPlacementSelect) {
|
|
46070
|
+
elements.controlDeckPlacementSelect.addEventListener("change", () => {
|
|
46071
|
+
const placement = normalizeControlDeckPlacement(elements.controlDeckPlacementSelect.value);
|
|
46072
|
+
controlDeckLayout.placement = placement;
|
|
46073
|
+
cacheControlDeckLayout(controlDeckLayout, "placement");
|
|
46074
|
+
markDurableUiLayoutDirty("sidePanel", "placement");
|
|
46075
|
+
reconcileControlDeckHosts();
|
|
46076
|
+
addEvent(`Control Deck placement changed to ${placement}.`);
|
|
46077
|
+
});
|
|
46078
|
+
}
|
|
45074
46079
|
if (elements.subagentOpenModeSelect) {
|
|
45075
46080
|
elements.subagentOpenModeSelect.addEventListener("change", () => {
|
|
45076
46081
|
setSubagentOpenMode(elements.subagentOpenModeSelect.value, { announce: true });
|
|
@@ -45178,10 +46183,16 @@ elements.sidePanelEditButton?.addEventListener("click", () => {
|
|
|
45178
46183
|
setSidePanelSectionEditMode(!sidePanelSectionEditMode);
|
|
45179
46184
|
});
|
|
45180
46185
|
elements.toggleSidePanelButton.addEventListener("click", () => {
|
|
45181
|
-
setSidePanelCollapsed(true);
|
|
46186
|
+
setSidePanelCollapsed(true, { side: "right" });
|
|
46187
|
+
});
|
|
46188
|
+
elements.toggleSidePanelLeftButton?.addEventListener("click", () => {
|
|
46189
|
+
setSidePanelCollapsed(true, { side: "left" });
|
|
45182
46190
|
});
|
|
45183
46191
|
elements.sidePanelExpandButton.addEventListener("click", () => {
|
|
45184
|
-
setSidePanelCollapsed(false, { focusPanel: true });
|
|
46192
|
+
setSidePanelCollapsed(false, { focusPanel: true, side: "right" });
|
|
46193
|
+
});
|
|
46194
|
+
elements.sidePanelLeftExpandButton?.addEventListener("click", () => {
|
|
46195
|
+
setSidePanelCollapsed(false, { focusPanel: true, side: "left" });
|
|
45185
46196
|
});
|
|
45186
46197
|
elements.sidePanelBackdrop.addEventListener("click", () => {
|
|
45187
46198
|
setSidePanelCollapsed(true);
|
|
@@ -45519,24 +46530,45 @@ window.addEventListener("offline", () => {
|
|
|
45519
46530
|
});
|
|
45520
46531
|
window.addEventListener("beforeunload", persistMobileContinuityState);
|
|
45521
46532
|
window.addEventListener("storage", (event) => {
|
|
46533
|
+
const sidePanelDirty = durableLayoutDirtyFields.get("sidePanel")?.subfields || new Set();
|
|
46534
|
+
const hasControlDeckV2Cache = (() => {
|
|
46535
|
+
try { return localStorage.getItem(CONTROL_DECK_LAYOUT_STORAGE_KEY) !== null; } catch { return false; }
|
|
46536
|
+
})();
|
|
46537
|
+
const ignoreLegacySidePanelEvent = (subfield, active = false) => hasControlDeckV2Cache || sidePanelDirty.has(subfield) || active;
|
|
45522
46538
|
if (event.key === OPTIONAL_FEATURES_STORAGE_KEY) reconcileDisabledOptionalFeaturesFromStorage();
|
|
45523
46539
|
if (event.key === OPTIONAL_FEATURE_MIGRATION_DISMISS_STORAGE_KEY && optionalFeatureMigrationCompletionIsDismissed()) {
|
|
45524
46540
|
optionalFeatureRestartNotice = null;
|
|
45525
46541
|
renderOptionalFeatureMigrationSurface();
|
|
45526
46542
|
}
|
|
45527
|
-
if (event.key === SIDE_PANEL_SECTION_VISIBILITY_STORAGE_KEY) restoreSidePanelSectionVisibility();
|
|
45528
|
-
if (event.key === SIDE_PANEL_SECTION_ORDER_STORAGE_KEY
|
|
46543
|
+
if (event.key === SIDE_PANEL_SECTION_VISIBILITY_STORAGE_KEY && !ignoreLegacySidePanelEvent("hiddenSectionIds")) restoreSidePanelSectionVisibility();
|
|
46544
|
+
if (event.key === SIDE_PANEL_SECTION_ORDER_STORAGE_KEY && !ignoreLegacySidePanelEvent("sectionLayout", Boolean(sidePanelSectionPointerDrag?.active))) {
|
|
46545
|
+
controlDeckLayout.sectionLayout = { ...controlDeckLayout.sectionLayout, order: readStoredSidePanelSectionOrder() || [] };
|
|
46546
|
+
restoreSidePanelSectionOrder();
|
|
46547
|
+
}
|
|
46548
|
+
if (event.key === CONTROL_DECK_LAYOUT_STORAGE_KEY) {
|
|
46549
|
+
const incoming = readStoredControlDeckLayout();
|
|
46550
|
+
const dirty = sidePanelDirty;
|
|
46551
|
+
const sectionActive = Boolean(sidePanelSectionPointerDrag?.active);
|
|
46552
|
+
const widthActive = Boolean(sidePanelResizeState);
|
|
46553
|
+
const cleanSiblings = {};
|
|
46554
|
+
for (const subfield of UI_LAYOUT_SIDE_PANEL_FIELDS) {
|
|
46555
|
+
const activelyManipulated = (subfield === "sectionLayout" && sectionActive) || (subfield === "panelWidths" && widthActive);
|
|
46556
|
+
if (!dirty.has(subfield) && !activelyManipulated && durableUiLayoutValuePresent(incoming?.[subfield])) cleanSiblings[subfield] = incoming[subfield];
|
|
46557
|
+
}
|
|
46558
|
+
applyDurableSidePanelLayout(cleanSiblings);
|
|
46559
|
+
}
|
|
45529
46560
|
if (event.key === COMPOSER_ACTION_ORDER_STORAGE_KEY) restoreComposerActionOrder();
|
|
45530
46561
|
if (event.key === COMPOSER_ACTION_LAYOUT_STORAGE_KEY) restoreComposerActionSlotLayout();
|
|
45531
|
-
if (event.key === SIDE_PANEL_WIDTH_STORAGE_KEY) {
|
|
46562
|
+
if (event.key === SIDE_PANEL_WIDTH_STORAGE_KEY && !ignoreLegacySidePanelEvent("panelWidths", Boolean(sidePanelResizeState))) {
|
|
45532
46563
|
const width = readStoredSidePanelWidth();
|
|
45533
46564
|
if (width && !isSidePanelOverlayView()) applySidePanelWidth(width);
|
|
45534
46565
|
}
|
|
45535
46566
|
// Another same-origin tab already saved these durable fields, so receiving
|
|
45536
46567
|
// tabs only adopt the shared local cache without repeating the server write.
|
|
45537
|
-
if (event.key === SIDE_PANEL_SECTION_STORAGE_KEY) restoreSidePanelSectionState();
|
|
45538
|
-
if (event.key === SIDE_PANEL_STORAGE_KEY) restoreSidePanelState();
|
|
46568
|
+
if (event.key === SIDE_PANEL_SECTION_STORAGE_KEY && !ignoreLegacySidePanelEvent("collapsedSectionIds")) restoreSidePanelSectionState();
|
|
46569
|
+
if (event.key === SIDE_PANEL_STORAGE_KEY && !ignoreLegacySidePanelEvent("collapsedPanels")) restoreSidePanelState();
|
|
45539
46570
|
if (event.key === TERMINAL_TABS_LAYOUT_STORAGE_KEY) restoreTerminalTabsLayoutSetting();
|
|
46571
|
+
if (event.key === TERMINAL_TABS_SIDEBAR_WIDTH_STORAGE_KEY) restoreTerminalTabsSidebarWidthPreference();
|
|
45540
46572
|
if (event.key === TERMINAL_CUSTOM_GROUPS_STORAGE_KEY) {
|
|
45541
46573
|
restoreTerminalCustomGroups();
|
|
45542
46574
|
syncTerminalCustomGroupsWithTabs(tabs, { persist: false });
|
|
@@ -45556,7 +46588,7 @@ window.addEventListener("pageshow", () => reconcileDurableUiLayout());
|
|
|
45556
46588
|
document.addEventListener("visibilitychange", () => {
|
|
45557
46589
|
if (document.visibilityState === "visible") reconcileDurableUiLayout();
|
|
45558
46590
|
});
|
|
45559
|
-
window.addEventListener("resize",
|
|
46591
|
+
window.addEventListener("resize", scheduleControlDeckPresentationReconciliation, { passive: true });
|
|
45560
46592
|
window.addEventListener("keydown", (event) => {
|
|
45561
46593
|
if (event.key !== "Escape") return;
|
|
45562
46594
|
if (event.defaultPrevented) return;
|
|
@@ -45793,6 +46825,10 @@ elements.fileContextMenu?.addEventListener("click", (event) => {
|
|
|
45793
46825
|
elements.fileViewerOpenDefaultButton?.addEventListener("click", () => openPathInDefaultEditor(currentFileViewerPath()));
|
|
45794
46826
|
elements.sidePanelResizeHandle?.addEventListener("pointerdown", beginSidePanelResize);
|
|
45795
46827
|
elements.sidePanelResizeHandle?.addEventListener("keydown", handleSidePanelResizeKeydown);
|
|
46828
|
+
elements.sidePanelResizeHandleLeft?.addEventListener("pointerdown", (event) => beginSidePanelResize(event, "left"));
|
|
46829
|
+
elements.sidePanelResizeHandleLeft?.addEventListener("keydown", handleSidePanelResizeKeydown);
|
|
46830
|
+
elements.terminalTabsResizeHandle?.addEventListener("pointerdown", beginTerminalTabsSidebarResize);
|
|
46831
|
+
elements.terminalTabsResizeHandle?.addEventListener("keydown", handleTerminalTabsSidebarResizeKeydown);
|
|
45796
46832
|
elements.fileViewerResizeHandle?.addEventListener("pointerdown", beginFileViewerResize);
|
|
45797
46833
|
elements.fileViewerResizeHandle?.addEventListener("keydown", handleFileViewerResizeKeydown);
|
|
45798
46834
|
elements.fileViewerSaveButton?.addEventListener("click", () => saveActiveFileViewer());
|
|
@@ -45985,6 +47021,7 @@ clearRemovedSidePanelSectionHeightState();
|
|
|
45985
47021
|
restoreDurableUiLayoutPendingJournal();
|
|
45986
47022
|
restoreSidePanelWidthPreference();
|
|
45987
47023
|
restoreFileViewerWidthPreference();
|
|
47024
|
+
restoreTerminalTabsSidebarWidthPreference();
|
|
45988
47025
|
focusPromptInput({ defer: true });
|
|
45989
47026
|
restoreStoredSkillUsage();
|
|
45990
47027
|
restoreBusyPromptBehaviorSetting();
|
|
@@ -46016,10 +47053,12 @@ restoreToolOutputExpansionSetting();
|
|
|
46016
47053
|
restoreWorkspaceDashboardState();
|
|
46017
47054
|
restoreInterfaceDensity();
|
|
46018
47055
|
initializeTerminalHeaderTooltips();
|
|
47056
|
+
initializeControlSettingTooltips();
|
|
46019
47057
|
initializeComposerActionOrdering();
|
|
46020
47058
|
restoreSidePanelSectionOrder();
|
|
46021
47059
|
restoreSidePanelSectionVisibility();
|
|
46022
47060
|
restoreSidePanelSectionState();
|
|
47061
|
+
reconcileControlDeckHosts();
|
|
46023
47062
|
setSidePanelSectionEditMode(false);
|
|
46024
47063
|
bindSidePanelSectionToggles();
|
|
46025
47064
|
restoreSidePanelState();
|