@firstpick/pi-package-webui 0.9.1 → 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 +21 -5
- package/bin/pi-webui-launcher.mjs +23 -12
- package/bin/pi-webui.mjs +479 -60
- 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/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 +1 -1
- package/public/app.js +1261 -314
- 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/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 +127 -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/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/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 +13 -3
- 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";
|
|
@@ -3655,7 +3683,7 @@ function isMobileView() {
|
|
|
3655
3683
|
}
|
|
3656
3684
|
|
|
3657
3685
|
function isSidePanelOverlayView() {
|
|
3658
|
-
return
|
|
3686
|
+
return isControlDeckOverlayPresentation();
|
|
3659
3687
|
}
|
|
3660
3688
|
|
|
3661
3689
|
function mobileDropdownViewportHeight() {
|
|
@@ -3698,8 +3726,8 @@ function readStoredSidePanelCollapsed() {
|
|
|
3698
3726
|
}
|
|
3699
3727
|
}
|
|
3700
3728
|
|
|
3701
|
-
function
|
|
3702
|
-
return Array.from(
|
|
3729
|
+
function controlDeckSectionRecords() {
|
|
3730
|
+
return Array.from(document.querySelectorAll("[data-side-panel-section]"))
|
|
3703
3731
|
.map((section) => {
|
|
3704
3732
|
const id = section.dataset.sidePanelSection || "";
|
|
3705
3733
|
const button = section.querySelector("[data-side-panel-section-toggle]");
|
|
@@ -3710,6 +3738,157 @@ function sidePanelSectionRecords() {
|
|
|
3710
3738
|
.filter((record) => record.id && record.button && record.content);
|
|
3711
3739
|
}
|
|
3712
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
|
+
|
|
3713
3892
|
function readStoredSidePanelSectionOrder() {
|
|
3714
3893
|
try {
|
|
3715
3894
|
const parsed = JSON.parse(localStorage.getItem(SIDE_PANEL_SECTION_ORDER_STORAGE_KEY) || "[]");
|
|
@@ -3719,27 +3898,26 @@ function readStoredSidePanelSectionOrder() {
|
|
|
3719
3898
|
}
|
|
3720
3899
|
}
|
|
3721
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
|
+
|
|
3722
3912
|
function persistSidePanelSectionOrder() {
|
|
3723
|
-
|
|
3724
|
-
localStorage.setItem(SIDE_PANEL_SECTION_ORDER_STORAGE_KEY, JSON.stringify(sidePanelSectionRecords().map(({ id }) => id)));
|
|
3725
|
-
} catch {
|
|
3726
|
-
// Ignore storage failures; ordering should still work for this page load.
|
|
3727
|
-
}
|
|
3728
|
-
markDurableUiLayoutDirty("sidePanel", "sectionOrder");
|
|
3913
|
+
persistControlDeckSectionLayout();
|
|
3729
3914
|
}
|
|
3730
3915
|
|
|
3731
3916
|
function restoreSidePanelSectionOrder() {
|
|
3732
3917
|
if (sidePanelSectionPointerDrag?.active) return;
|
|
3733
|
-
const
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
const rank = new Map(readStoredSidePanelSectionOrder().map((id, index) => [id, index]));
|
|
3737
|
-
records.sort((a, b) => {
|
|
3738
|
-
const aRank = rank.has(a.id) ? rank.get(a.id) : Number.MAX_SAFE_INTEGER;
|
|
3739
|
-
const bRank = rank.has(b.id) ? rank.get(b.id) : Number.MAX_SAFE_INTEGER;
|
|
3740
|
-
return aRank - bRank;
|
|
3741
|
-
});
|
|
3742
|
-
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();
|
|
3743
3921
|
}
|
|
3744
3922
|
|
|
3745
3923
|
function visibleSidePanelSectionRecords() {
|
|
@@ -3761,11 +3939,14 @@ function updateSidePanelSectionEditAffordance(record) {
|
|
|
3761
3939
|
const label = record.button.querySelector(".side-panel-section-label")?.textContent?.trim() || "side panel";
|
|
3762
3940
|
const action = `${collapsed ? "Expand" : "Collapse"} ${label} section`;
|
|
3763
3941
|
const reorderingEnabled = isSidePanelSectionReorderingEnabled();
|
|
3942
|
+
const horizontalEnabled = reorderingEnabled && effectiveControlDeckPresentation() === "both";
|
|
3764
3943
|
record.button.setAttribute("aria-label", action);
|
|
3765
3944
|
record.button.setAttribute("title", reorderingEnabled
|
|
3766
|
-
? `${action} · drag to reorder · Alt+↑/↓ moves`
|
|
3945
|
+
? `${action} · drag to reorder · ${horizontalEnabled ? "Alt+↑/↓ reorders · Alt+←/→ moves sides" : "Alt+↑/↓ moves"}`
|
|
3767
3946
|
: action);
|
|
3768
|
-
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");
|
|
3769
3950
|
else record.button.removeAttribute("aria-keyshortcuts");
|
|
3770
3951
|
}
|
|
3771
3952
|
|
|
@@ -3778,6 +3959,7 @@ function cancelSidePanelSectionPointerDrag() {
|
|
|
3778
3959
|
sidePanelSectionRecords().find(({ id }) => id === drag.sectionId)?.section.classList.remove("dragging");
|
|
3779
3960
|
sidePanelSectionPointerDrag = null;
|
|
3780
3961
|
sidePanelSectionLastDragOverKey = "";
|
|
3962
|
+
document.body.classList.remove("control-deck-section-dragging");
|
|
3781
3963
|
clearSidePanelSectionDragMarkers();
|
|
3782
3964
|
}
|
|
3783
3965
|
|
|
@@ -3799,31 +3981,84 @@ function setSidePanelSectionEditMode(enabled) {
|
|
|
3799
3981
|
for (const record of sidePanelSectionRecords()) updateSidePanelSectionEditAffordance(record);
|
|
3800
3982
|
}
|
|
3801
3983
|
|
|
3802
|
-
function moveSidePanelSectionRelative(fromId, targetRecord, insertBefore) {
|
|
3984
|
+
function moveSidePanelSectionRelative(fromId, targetRecord, insertBefore, targetSide = null) {
|
|
3803
3985
|
if (!isSidePanelSectionReorderingEnabled()) return false;
|
|
3804
3986
|
const sourceRecord = sidePanelSectionRecords().find(({ id }) => id === fromId);
|
|
3805
3987
|
if (!sourceRecord || !targetRecord || sourceRecord.section === targetRecord.section) return false;
|
|
3806
|
-
const parent =
|
|
3807
|
-
if (!parent
|
|
3988
|
+
const parent = targetRecord.section.parentElement;
|
|
3989
|
+
if (!parent) return false;
|
|
3990
|
+
const side = targetSide || (parent === elements.sidePanelBodyLeft ? "left" : "right");
|
|
3808
3991
|
clearSidePanelSectionDragMarkers();
|
|
3809
3992
|
targetRecord.section.classList.add(insertBefore ? "drag-over-before" : "drag-over-after");
|
|
3810
|
-
sidePanelSectionLastDragOverKey = `${targetRecord.id}:${insertBefore ? "before" : "after"}`;
|
|
3993
|
+
sidePanelSectionLastDragOverKey = `${side}:${targetRecord.id}:${insertBefore ? "before" : "after"}`;
|
|
3811
3994
|
if (insertBefore) parent.insertBefore(sourceRecord.section, targetRecord.section);
|
|
3812
3995
|
else parent.insertBefore(sourceRecord.section, targetRecord.section.nextSibling);
|
|
3813
|
-
|
|
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
|
+
}
|
|
3814
4006
|
return true;
|
|
3815
4007
|
}
|
|
3816
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
|
+
|
|
3817
4045
|
function moveSidePanelSectionByOffset(sectionId, offset) {
|
|
3818
4046
|
if (!isSidePanelSectionReorderingEnabled()) return false;
|
|
3819
|
-
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));
|
|
3820
4052
|
const fromIndex = records.findIndex(({ id }) => id === sectionId);
|
|
3821
4053
|
const toIndex = fromIndex + offset;
|
|
3822
4054
|
if (fromIndex < 0 || toIndex < 0 || toIndex >= records.length) return false;
|
|
3823
4055
|
const targetRecord = records[toIndex];
|
|
3824
4056
|
const moved = moveSidePanelSectionRelative(sectionId, targetRecord, offset < 0);
|
|
3825
4057
|
clearSidePanelSectionDragMarkers();
|
|
3826
|
-
if (moved)
|
|
4058
|
+
if (moved) {
|
|
4059
|
+
persistControlDeckSectionLayout();
|
|
4060
|
+
queueMicrotask(() => sidePanelSectionRecords().find(({ id }) => id === sectionId)?.button.focus({ preventScroll: true }));
|
|
4061
|
+
}
|
|
3827
4062
|
return moved;
|
|
3828
4063
|
}
|
|
3829
4064
|
|
|
@@ -3833,7 +4068,7 @@ function sidePanelSectionToggleFromPoint(clientX, clientY) {
|
|
|
3833
4068
|
|
|
3834
4069
|
function beginSidePanelSectionPointerDrag(event, sectionId) {
|
|
3835
4070
|
if (!isSidePanelSectionReorderingEnabled() || event.button !== 0 || !sectionId || sidePanelSectionPointerDrag) return;
|
|
3836
|
-
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 };
|
|
3837
4072
|
window.addEventListener("pointermove", updateSidePanelSectionPointerDrag, { capture: true });
|
|
3838
4073
|
window.addEventListener("pointerup", endSidePanelSectionPointerDrag, { capture: true });
|
|
3839
4074
|
window.addEventListener("pointercancel", endSidePanelSectionPointerDrag, { capture: true });
|
|
@@ -3848,6 +4083,7 @@ function updateSidePanelSectionPointerDrag(event) {
|
|
|
3848
4083
|
if (!drag.active) {
|
|
3849
4084
|
drag.active = true;
|
|
3850
4085
|
sidePanelSectionLastDragOverKey = "";
|
|
4086
|
+
document.body.classList.add("control-deck-section-dragging");
|
|
3851
4087
|
clearTimeout(pointerActivationTimeout);
|
|
3852
4088
|
pointerActivationTimeout = null;
|
|
3853
4089
|
activePointerActivation = null;
|
|
@@ -3858,12 +4094,16 @@ function updateSidePanelSectionPointerDrag(event) {
|
|
|
3858
4094
|
const targetRecord = targetToggle
|
|
3859
4095
|
? sidePanelSectionRecords().find(({ button }) => button === targetToggle)
|
|
3860
4096
|
: null;
|
|
3861
|
-
if (
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
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);
|
|
3867
4107
|
}
|
|
3868
4108
|
|
|
3869
4109
|
function endSidePanelSectionPointerDrag(event) {
|
|
@@ -3875,11 +4115,14 @@ function endSidePanelSectionPointerDrag(event) {
|
|
|
3875
4115
|
const sourceRecord = sidePanelSectionRecords().find(({ id }) => id === drag.sectionId);
|
|
3876
4116
|
sidePanelSectionPointerDrag = null;
|
|
3877
4117
|
sidePanelSectionLastDragOverKey = "";
|
|
4118
|
+
document.body.classList.remove("control-deck-section-dragging");
|
|
3878
4119
|
clearSidePanelSectionDragMarkers();
|
|
3879
4120
|
sourceRecord?.section.classList.remove("dragging");
|
|
3880
4121
|
if (drag.active) {
|
|
3881
4122
|
sidePanelSectionSuppressClickUntil = Date.now() + 250;
|
|
3882
4123
|
event.preventDefault();
|
|
4124
|
+
const destinationSide = controlDeckSectionSide(drag.sectionId);
|
|
4125
|
+
if (destinationSide !== drag.startSide) completeControlDeckSectionSideMove(sourceRecord, destinationSide);
|
|
3883
4126
|
persistSidePanelSectionOrder();
|
|
3884
4127
|
queueMicrotask(() => sourceRecord?.button.focus({ preventScroll: true }));
|
|
3885
4128
|
}
|
|
@@ -3971,7 +4214,9 @@ function setSidePanelSectionCollapsed(record, collapsed, { persist = true } = {}
|
|
|
3971
4214
|
|
|
3972
4215
|
function setOnlySidePanelSectionExpanded(targetRecord, { persist = true } = {}) {
|
|
3973
4216
|
const targetId = targetRecord?.id || null;
|
|
4217
|
+
const targetSide = controlDeckSectionSide(targetId);
|
|
3974
4218
|
for (const record of sidePanelSectionRecords()) {
|
|
4219
|
+
if (controlDeckSectionSide(record.id) !== targetSide) continue;
|
|
3975
4220
|
setSidePanelSectionCollapsed(record, record.id !== targetId, { persist: false });
|
|
3976
4221
|
}
|
|
3977
4222
|
if (persist) persistSidePanelSectionState();
|
|
@@ -3980,10 +4225,15 @@ function setOnlySidePanelSectionExpanded(targetRecord, { persist = true } = {})
|
|
|
3980
4225
|
function restoreSidePanelSectionState() {
|
|
3981
4226
|
const records = sidePanelSectionRecords();
|
|
3982
4227
|
const collapsedIds = readStoredSidePanelSectionCollapsedIds();
|
|
3983
|
-
const
|
|
3984
|
-
|
|
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
|
+
}
|
|
3985
4235
|
for (const record of records) {
|
|
3986
|
-
setSidePanelSectionCollapsed(record, record.id !==
|
|
4236
|
+
setSidePanelSectionCollapsed(record, expandedBySide.get(controlDeckSectionSide(record.id)) !== record.id, { persist: false });
|
|
3987
4237
|
}
|
|
3988
4238
|
}
|
|
3989
4239
|
|
|
@@ -4053,9 +4303,16 @@ function bindSidePanelSectionToggles() {
|
|
|
4053
4303
|
}
|
|
4054
4304
|
});
|
|
4055
4305
|
record.button.addEventListener("keydown", (event) => {
|
|
4056
|
-
if (!isSidePanelSectionReorderingEnabled() || !event.altKey ||
|
|
4057
|
-
event.
|
|
4058
|
-
|
|
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
|
+
}
|
|
4059
4316
|
});
|
|
4060
4317
|
record.button.addEventListener("pointerdown", (event) => beginSidePanelSectionPointerDrag(event, record.id));
|
|
4061
4318
|
}
|
|
@@ -4537,20 +4794,22 @@ function initializeComposerActionOrdering() {
|
|
|
4537
4794
|
}
|
|
4538
4795
|
|
|
4539
4796
|
function bindSidePanelContextMenu() {
|
|
4540
|
-
elements.
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
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
|
+
});
|
|
4552
4811
|
});
|
|
4553
|
-
}
|
|
4812
|
+
}
|
|
4554
4813
|
}
|
|
4555
4814
|
|
|
4556
4815
|
function readStoredAgentDoneNotificationsEnabled() {
|
|
@@ -4701,6 +4960,8 @@ function setTerminalTabsLayout(layout, { persist = true, announce = false } = {}
|
|
|
4701
4960
|
if (next === "left" && mobileTabsExpanded) setMobileTabsExpanded(false);
|
|
4702
4961
|
if (persist) persistTerminalTabsLayout(next);
|
|
4703
4962
|
renderTerminalTabsLayoutControl();
|
|
4963
|
+
reconcileControlDeckHosts?.();
|
|
4964
|
+
requestAnimationFrame(syncTerminalTabsSidebarWidthForViewport);
|
|
4704
4965
|
if (announce) addEvent(`terminal tabs layout changed to ${terminalTabsLayoutStatusText(next).toLowerCase()}`);
|
|
4705
4966
|
}
|
|
4706
4967
|
|
|
@@ -4708,6 +4969,133 @@ function restoreTerminalTabsLayoutSetting() {
|
|
|
4708
4969
|
setTerminalTabsLayout(readStoredTerminalTabsLayout(), { persist: false });
|
|
4709
4970
|
}
|
|
4710
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
|
+
|
|
4711
5099
|
function normalizeSubagentOpenMode(value) {
|
|
4712
5100
|
return SUBAGENT_OPEN_MODES.has(value) ? value : "overlay";
|
|
4713
5101
|
}
|
|
@@ -6699,50 +7087,82 @@ function deactivateDrawerModal(surface, { restoreFocus = true } = {}) {
|
|
|
6699
7087
|
}
|
|
6700
7088
|
|
|
6701
7089
|
function syncMobileSidePanelState(collapsed) {
|
|
6702
|
-
const
|
|
7090
|
+
const overlay = isControlDeckOverlayPresentation();
|
|
7091
|
+
const showBackdrop = !collapsed && overlay;
|
|
6703
7092
|
elements.sidePanelBackdrop.hidden = !showBackdrop;
|
|
6704
7093
|
if (showBackdrop) {
|
|
7094
|
+
mobileCanonicalUnmount();
|
|
6705
7095
|
activateDrawerModal(elements.sidePanel, elements.sidePanelExpandButton, {
|
|
6706
7096
|
close: () => setSidePanelCollapsed(true, { persist: false }),
|
|
6707
7097
|
});
|
|
6708
7098
|
} else {
|
|
6709
7099
|
deactivateDrawerModal(elements.sidePanel);
|
|
7100
|
+
if (collapsed && overlay && isMobileShellV2Active()) queueMicrotask(() => renderMobilePhoneExperience());
|
|
6710
7101
|
}
|
|
6711
7102
|
}
|
|
6712
7103
|
|
|
6713
|
-
function
|
|
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);
|
|
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");
|
|
7120
|
+
}
|
|
7121
|
+
|
|
7122
|
+
function setSidePanelCollapsed(collapsed, { persist = true, focusPanel = false, side = null } = {}) {
|
|
6714
7123
|
if (collapsed) setSidePanelSectionEditMode(false);
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
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();
|
|
6722
7140
|
requestAnimationFrame(syncResizablePanelWidthsForViewport);
|
|
6723
7141
|
if (collapsed) closeSidePanelContextMenu({ returnFocus: false });
|
|
6724
|
-
|
|
6725
|
-
if (!
|
|
6726
|
-
|
|
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 */ }
|
|
6727
7146
|
}
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
try {
|
|
6731
|
-
localStorage.setItem(SIDE_PANEL_STORAGE_KEY, collapsed ? "1" : "0");
|
|
6732
|
-
} catch {
|
|
6733
|
-
// Ignore storage failures; the toggle should still work for this page load.
|
|
6734
|
-
}
|
|
6735
|
-
markDurableUiLayoutDirty("sidePanel", "collapsed");
|
|
7147
|
+
cacheControlDeckLayout(controlDeckLayout, "collapsedPanels");
|
|
7148
|
+
markDurableUiLayoutDirty("sidePanel", "collapsedPanels");
|
|
6736
7149
|
}
|
|
6737
7150
|
|
|
6738
7151
|
function restoreSidePanelState() {
|
|
6739
7152
|
if (isMobileShellV2Active()) return;
|
|
6740
|
-
if (
|
|
7153
|
+
if (isControlDeckOverlayPresentation()) {
|
|
6741
7154
|
setSidePanelCollapsed(true, { persist: false });
|
|
6742
7155
|
return;
|
|
6743
7156
|
}
|
|
6744
7157
|
const stored = readStoredSidePanelCollapsed();
|
|
6745
|
-
|
|
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
|
+
}
|
|
6746
7166
|
}
|
|
6747
7167
|
|
|
6748
7168
|
function readStoredWorkspaceDashboardCollapsed() {
|
|
@@ -7926,20 +8346,56 @@ async function runPiUpdateAndRestart({ all = false } = {}) {
|
|
|
7926
8346
|
try {
|
|
7927
8347
|
plan = (await api("/api/update/plan", { method: "POST", body: { targets: all ? ["pi", "webui"] : ["pi"] }, scoped: false }))?.data?.plan;
|
|
7928
8348
|
} catch (error) {
|
|
7929
|
-
|
|
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 });
|
|
7930
8362
|
return;
|
|
7931
8363
|
}
|
|
7932
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;
|
|
7933
8365
|
|
|
7934
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}…`;
|
|
7935
8371
|
updateRequestInProgress = true;
|
|
7936
8372
|
hideUpdateNotification();
|
|
7937
8373
|
setServerActionBusy("Updating…");
|
|
7938
|
-
setServerActionStatus(
|
|
7939
|
-
setServerRestartOverlay(true,
|
|
8374
|
+
setServerActionStatus(progressMessage, "warn");
|
|
8375
|
+
if (plannedRestart) setServerRestartOverlay(true, progressMessage);
|
|
7940
8376
|
try {
|
|
7941
|
-
await api("/api/update/apply", { method: "POST", body: { transactionId: plan.transactionId, planDigest: plan.digest }, scoped: false });
|
|
7942
|
-
|
|
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");
|
|
7943
8399
|
} catch (error) {
|
|
7944
8400
|
if (!error?.backendOffline) {
|
|
7945
8401
|
updateRequestInProgress = false;
|
|
@@ -7951,10 +8407,10 @@ async function runPiUpdateAndRestart({ all = false } = {}) {
|
|
|
7951
8407
|
renderUpdateNotification(latestUpdateStatus, { force: true });
|
|
7952
8408
|
return;
|
|
7953
8409
|
}
|
|
7954
|
-
addEvent("Pi Web UI server connection dropped during update
|
|
8410
|
+
addEvent("Pi Web UI server connection dropped during update activation", "warn");
|
|
7955
8411
|
}
|
|
7956
8412
|
|
|
7957
|
-
setBackendOffline(true, new Error("update requested from side panel"));
|
|
8413
|
+
setBackendOffline(true, new Error("update activation requested from side panel"));
|
|
7958
8414
|
const restarted = await waitForServerRestart(serverBootIdentity);
|
|
7959
8415
|
updateRequestInProgress = false;
|
|
7960
8416
|
resetServerActionControls();
|
|
@@ -7965,8 +8421,8 @@ async function runPiUpdateAndRestart({ all = false } = {}) {
|
|
|
7965
8421
|
} else {
|
|
7966
8422
|
setServerRestartOverlay(false);
|
|
7967
8423
|
setBackendOffline(true, new Error("update restart reconnect timed out"));
|
|
7968
|
-
setServerActionStatus("Update
|
|
7969
|
-
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");
|
|
7970
8426
|
}
|
|
7971
8427
|
}
|
|
7972
8428
|
|
|
@@ -10806,6 +11262,14 @@ function fileTreeGitStatusForEntry(entry = {}) {
|
|
|
10806
11262
|
return fileTreeState.gitStatusByPath.get(normalizeFileTreePath(entry.path || "")) || null;
|
|
10807
11263
|
}
|
|
10808
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
|
+
|
|
10809
11273
|
function fileTreeGitStatusClasses(status) {
|
|
10810
11274
|
const normalized = normalizeFileTreeGitStatus(status);
|
|
10811
11275
|
if (!normalized) return "";
|
|
@@ -10926,6 +11390,7 @@ function fileTreeEntryRenderSignature(entry = {}) {
|
|
|
10926
11390
|
entry.directory === true,
|
|
10927
11391
|
String(entry.extension || ""),
|
|
10928
11392
|
String(entry.error || ""),
|
|
11393
|
+
fileTreeEntryGitIgnored(entry),
|
|
10929
11394
|
];
|
|
10930
11395
|
}
|
|
10931
11396
|
|
|
@@ -11044,7 +11509,8 @@ function appendFileSearchEntry(parent, entry) {
|
|
|
11044
11509
|
const loading = isDirectory && fileTreeState.loading.has(path);
|
|
11045
11510
|
const gitStatus = fileTreeGitStatusForEntry(entry);
|
|
11046
11511
|
const gitStatusClasses = fileTreeGitStatusClasses(gitStatus);
|
|
11047
|
-
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" : ""}`);
|
|
11048
11514
|
item.setAttribute("role", "none");
|
|
11049
11515
|
const button = make("button", "file-tree-item file-tree-search-item");
|
|
11050
11516
|
button.type = "button";
|
|
@@ -11057,7 +11523,7 @@ function appendFileSearchEntry(parent, entry) {
|
|
|
11057
11523
|
button.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
11058
11524
|
button.setAttribute("aria-label", `${expanded ? "Collapse" : "Expand"} ${entry.name || fileDisplayName(path)}`);
|
|
11059
11525
|
}
|
|
11060
|
-
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");
|
|
11061
11527
|
const contextPath = fileParentPath(path) || ".";
|
|
11062
11528
|
const label = make("span", "file-tree-search-label");
|
|
11063
11529
|
label.append(
|
|
@@ -11123,7 +11589,8 @@ function appendFileTreeEntry(parent, entry, depth = 0) {
|
|
|
11123
11589
|
const loading = isDirectory && fileTreeState.loading.has(path);
|
|
11124
11590
|
const gitStatus = fileTreeGitStatusForEntry(entry);
|
|
11125
11591
|
const gitStatusClasses = fileTreeGitStatusClasses(gitStatus);
|
|
11126
|
-
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" : ""}`);
|
|
11127
11594
|
item.setAttribute("role", "none");
|
|
11128
11595
|
const button = make("button", "file-tree-item");
|
|
11129
11596
|
button.type = "button";
|
|
@@ -11136,7 +11603,7 @@ function appendFileTreeEntry(parent, entry, depth = 0) {
|
|
|
11136
11603
|
button.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
11137
11604
|
button.setAttribute("aria-label", `${expanded ? "Collapse" : "Expand"} ${entry.name || fileDisplayName(path)}`);
|
|
11138
11605
|
}
|
|
11139
|
-
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");
|
|
11140
11607
|
button.append(
|
|
11141
11608
|
isDirectory ? fileTreeExpander(expanded) : make("span", "file-tree-expander-spacer"),
|
|
11142
11609
|
make("span", `file-tree-icon ${isDirectory && expanded ? "expanded" : ""}`, loading ? "…" : fileEntryIcon(entry)),
|
|
@@ -11878,16 +12345,17 @@ async function moveFileTreeEntry(entry = fileContextMenuState?.entry) {
|
|
|
11878
12345
|
// per-user layout lives in the WebUI settings file behind
|
|
11879
12346
|
// GET/PUT /api/interface-preferences. Local writes always apply first; server
|
|
11880
12347
|
// reconciliation is non-blocking, coalesced, and revision guarded.
|
|
11881
|
-
const UI_LAYOUT_SCHEMA_VERSION =
|
|
12348
|
+
const UI_LAYOUT_SCHEMA_VERSION = 2;
|
|
11882
12349
|
const UI_LAYOUT_ENDPOINT = "/api/interface-preferences";
|
|
11883
12350
|
const UI_LAYOUT_SAVE_DEBOUNCE_MS = 250;
|
|
11884
12351
|
const UI_LAYOUT_MAX_CONFLICT_RETRIES = 1;
|
|
11885
12352
|
const UI_LAYOUT_FIELDS = ["sidePanel", "composerActions", "footerScopedModelOrder", "terminalTabs", "fileViewerWidth"];
|
|
11886
|
-
const UI_LAYOUT_SIDE_PANEL_FIELDS = ["
|
|
12353
|
+
const UI_LAYOUT_SIDE_PANEL_FIELDS = ["placement", "sectionLayout", "collapsedSectionIds", "hiddenSectionIds", "collapsedPanels", "panelWidths"];
|
|
11887
12354
|
const REMOVED_SIDE_PANEL_SECTION_HEIGHT_STORAGE_KEY = "pi-webui-side-panel-section-heights-v1";
|
|
11888
12355
|
const UI_LAYOUT_COMPOSER_FIELDS = ["order", "grid"];
|
|
11889
|
-
const UI_LAYOUT_TERMINAL_FIELDS = ["layout", "customGroups"];
|
|
11890
|
-
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:";
|
|
11891
12359
|
const UI_LAYOUT_PENDING_WRITER_ID = globalThis.crypto?.randomUUID?.() || `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
11892
12360
|
let durableLayoutPendingMutationSerial = 0;
|
|
11893
12361
|
const UI_LAYOUT_ID_MAX_LENGTH = 256;
|
|
@@ -11952,13 +12420,79 @@ function durableLayoutStoredIdList(key) {
|
|
|
11952
12420
|
}
|
|
11953
12421
|
}
|
|
11954
12422
|
|
|
11955
|
-
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);
|
|
11956
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 || [];
|
|
11957
12489
|
return {
|
|
11958
|
-
|
|
12490
|
+
placement: normalizeControlDeckPlacement(controlDeckLayout.placement),
|
|
12491
|
+
sectionLayout: { order, leftSectionIds: left.filter((id) => order.includes(id)) },
|
|
11959
12492
|
collapsedSectionIds: durableLayoutStoredIdList(SIDE_PANEL_SECTION_STORAGE_KEY),
|
|
11960
12493
|
hiddenSectionIds: durableLayoutStoredIdList(SIDE_PANEL_SECTION_VISIBILITY_STORAGE_KEY),
|
|
11961
|
-
|
|
12494
|
+
collapsedPanels: controlDeckLayout.collapsedPanels,
|
|
12495
|
+
panelWidths: controlDeckLayout.panelWidths,
|
|
11962
12496
|
};
|
|
11963
12497
|
}
|
|
11964
12498
|
|
|
@@ -12015,7 +12549,11 @@ function collectDurableTerminalTabsLayout() {
|
|
|
12015
12549
|
}
|
|
12016
12550
|
customGroups = { version: 1, groups };
|
|
12017
12551
|
}
|
|
12018
|
-
return {
|
|
12552
|
+
return {
|
|
12553
|
+
layout: TERMINAL_TABS_LAYOUTS.has(rawLayout) ? rawLayout : null,
|
|
12554
|
+
customGroups,
|
|
12555
|
+
sidebarWidth: readStoredTerminalTabsSidebarWidth(),
|
|
12556
|
+
};
|
|
12019
12557
|
}
|
|
12020
12558
|
|
|
12021
12559
|
function collectDurableFileViewerWidth() {
|
|
@@ -12053,6 +12591,14 @@ function durableUiLayoutValuePresent(value) {
|
|
|
12053
12591
|
return value !== null && value !== undefined;
|
|
12054
12592
|
}
|
|
12055
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
|
+
|
|
12056
12602
|
function durableUiLayoutMutationValue(field, subfield = null) {
|
|
12057
12603
|
const value = collectDurableUiLayoutField(field);
|
|
12058
12604
|
return subfield ? value?.[subfield] ?? null : value;
|
|
@@ -12068,23 +12614,38 @@ function durableUiLayoutPendingMutationRecords() {
|
|
|
12068
12614
|
try {
|
|
12069
12615
|
for (let index = 0; index < localStorage.length; index += 1) {
|
|
12070
12616
|
const key = localStorage.key(index);
|
|
12071
|
-
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;
|
|
12072
12618
|
let value;
|
|
12073
12619
|
try {
|
|
12074
12620
|
value = JSON.parse(localStorage.getItem(key) || "null");
|
|
12075
12621
|
} catch {
|
|
12076
12622
|
continue;
|
|
12077
12623
|
}
|
|
12078
|
-
if (!value || value.version
|
|
12624
|
+
if (!value || ![3, 4].includes(value.version) || !UI_LAYOUT_FIELDS.includes(value.field)) continue;
|
|
12079
12625
|
const allowedSubfields = durableUiLayoutSubFields(value.field);
|
|
12080
|
-
|
|
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
|
+
}
|
|
12081
12642
|
if (subfield && !allowedSubfields?.includes(subfield)) continue;
|
|
12082
12643
|
if (allowedSubfields && value.field !== "composerActions" && !subfield) continue;
|
|
12083
12644
|
records.push({
|
|
12084
12645
|
key,
|
|
12085
12646
|
field: value.field,
|
|
12086
12647
|
subfield,
|
|
12087
|
-
value:
|
|
12648
|
+
value: mutationValue,
|
|
12088
12649
|
updatedAt: Number(value.updatedAt) || 0,
|
|
12089
12650
|
});
|
|
12090
12651
|
}
|
|
@@ -12099,7 +12660,7 @@ function writeDurableUiLayoutPendingMutation(field, subfield, value) {
|
|
|
12099
12660
|
durableLayoutPendingMutationSerial += 1;
|
|
12100
12661
|
const key = `${UI_LAYOUT_PENDING_STORAGE_PREFIX}${UI_LAYOUT_PENDING_WRITER_ID}:${Date.now().toString(36)}:${durableLayoutPendingMutationSerial.toString(36)}`;
|
|
12101
12662
|
localStorage.setItem(key, JSON.stringify({
|
|
12102
|
-
version:
|
|
12663
|
+
version: 4,
|
|
12103
12664
|
field,
|
|
12104
12665
|
subfield,
|
|
12105
12666
|
value,
|
|
@@ -12181,9 +12742,13 @@ function restoreDurableUiLayoutPendingJournal() {
|
|
|
12181
12742
|
? new Map(fieldCandidates.map((candidate) => [candidate.subfield, candidate.key]))
|
|
12182
12743
|
: null;
|
|
12183
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
|
+
}
|
|
12184
12749
|
durableLayoutDirtyFields.set(field, {
|
|
12185
12750
|
generation,
|
|
12186
|
-
value:
|
|
12751
|
+
value: restoredValue,
|
|
12187
12752
|
subfields,
|
|
12188
12753
|
subfieldGenerations,
|
|
12189
12754
|
subfieldMutationIds,
|
|
@@ -12195,9 +12760,15 @@ function restoreDurableUiLayoutPendingJournal() {
|
|
|
12195
12760
|
|
|
12196
12761
|
function applyDurableSidePanelLayout(value) {
|
|
12197
12762
|
if (!value) return;
|
|
12198
|
-
|
|
12199
|
-
|
|
12200
|
-
|
|
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");
|
|
12201
12772
|
}
|
|
12202
12773
|
if (Array.isArray(value.hiddenSectionIds)) {
|
|
12203
12774
|
writeDurableLayoutCache(SIDE_PANEL_SECTION_VISIBILITY_STORAGE_KEY, JSON.stringify(value.hiddenSectionIds));
|
|
@@ -12207,10 +12778,18 @@ function applyDurableSidePanelLayout(value) {
|
|
|
12207
12778
|
writeDurableLayoutCache(SIDE_PANEL_SECTION_STORAGE_KEY, JSON.stringify(value.collapsedSectionIds));
|
|
12208
12779
|
restoreSidePanelSectionState();
|
|
12209
12780
|
}
|
|
12210
|
-
if (typeof value.
|
|
12211
|
-
|
|
12212
|
-
|
|
12781
|
+
if (value.collapsedPanels && typeof value.collapsedPanels === "object") {
|
|
12782
|
+
controlDeckLayout.collapsedPanels = { ...controlDeckLayout.collapsedPanels, ...value.collapsedPanels };
|
|
12783
|
+
adoptedSubfields.push("collapsedPanels");
|
|
12213
12784
|
}
|
|
12785
|
+
if (value.panelWidths && typeof value.panelWidths === "object") {
|
|
12786
|
+
controlDeckLayout.panelWidths = { ...controlDeckLayout.panelWidths, ...value.panelWidths };
|
|
12787
|
+
adoptedSubfields.push("panelWidths");
|
|
12788
|
+
}
|
|
12789
|
+
for (const subfield of adoptedSubfields) cacheControlDeckLayout(controlDeckLayout, subfield);
|
|
12790
|
+
restoreSidePanelSectionOrder();
|
|
12791
|
+
reconcileControlDeckHosts();
|
|
12792
|
+
restoreSidePanelState();
|
|
12214
12793
|
}
|
|
12215
12794
|
|
|
12216
12795
|
function applyDurableComposerActionsLayout(value) {
|
|
@@ -12241,6 +12820,10 @@ function applyDurableTerminalTabsLayout(value) {
|
|
|
12241
12820
|
writeDurableLayoutCache(TERMINAL_TABS_LAYOUT_STORAGE_KEY, value.layout);
|
|
12242
12821
|
setTerminalTabsLayout(value.layout, { persist: false });
|
|
12243
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
|
+
}
|
|
12244
12827
|
if (value.customGroups && value.customGroups.version === 1) {
|
|
12245
12828
|
writeDurableLayoutCache(TERMINAL_CUSTOM_GROUPS_STORAGE_KEY, JSON.stringify(value.customGroups));
|
|
12246
12829
|
restoreTerminalCustomGroups();
|
|
@@ -12268,10 +12851,10 @@ function applyDurableUiLayoutField(field, value) {
|
|
|
12268
12851
|
|
|
12269
12852
|
function durableUiLayoutInteractionActive(field = null) {
|
|
12270
12853
|
const activeByField = {
|
|
12271
|
-
sidePanel: Boolean(sidePanelSectionPointerDrag?.active),
|
|
12854
|
+
sidePanel: Boolean(sidePanelSectionPointerDrag?.active || sidePanelResizeState),
|
|
12272
12855
|
composerActions: Boolean(composerActionPointerDrag?.active),
|
|
12273
12856
|
footerScopedModelOrder: Boolean(footerScopedModelPointerDrag?.active),
|
|
12274
|
-
terminalTabs: Boolean(terminalTabDragId),
|
|
12857
|
+
terminalTabs: Boolean(terminalTabDragId || terminalTabsResizeState),
|
|
12275
12858
|
fileViewerWidth: Boolean(fileViewerResizeState),
|
|
12276
12859
|
};
|
|
12277
12860
|
return field ? activeByField[field] === true : Object.values(activeByField).some(Boolean);
|
|
@@ -12356,20 +12939,23 @@ function applyDurableUiLayoutSnapshot(data, { generations = null, readEpoch = 0
|
|
|
12356
12939
|
const subfields = durableUiLayoutSubFields(field);
|
|
12357
12940
|
const dirtySubfields = dirtyEntry?.subfields;
|
|
12358
12941
|
|
|
12359
|
-
|
|
12360
|
-
|
|
12361
|
-
if (subfields && field !== "composerActions") {
|
|
12942
|
+
if (subfields && field !== "composerActions") {
|
|
12362
12943
|
const applicable = {};
|
|
12363
12944
|
let hasApplicable = false;
|
|
12364
12945
|
for (const subfield of subfields) {
|
|
12365
12946
|
const isDirty = dirtySubfields?.has(subfield) === true;
|
|
12947
|
+
const activelyManipulated = field === "sidePanel" && (
|
|
12948
|
+
(subfield === "sectionLayout" && Boolean(sidePanelSectionPointerDrag?.active))
|
|
12949
|
+
|| (subfield === "panelWidths" && Boolean(sidePanelResizeState))
|
|
12950
|
+
);
|
|
12366
12951
|
const remote = serverValue?.[subfield] ?? null;
|
|
12367
12952
|
const local = localValue?.[subfield] ?? null;
|
|
12368
|
-
|
|
12953
|
+
const remotePresent = durableUiLayoutSubfieldValuePresent(field, subfield, remote);
|
|
12954
|
+
if (!isDirty && !activelyManipulated && !generationChanged && remotePresent) {
|
|
12369
12955
|
applicable[subfield] = remote;
|
|
12370
12956
|
hasApplicable = true;
|
|
12371
12957
|
}
|
|
12372
|
-
if (!isDirty && !
|
|
12958
|
+
if (!isDirty && !remotePresent && durableUiLayoutValuePresent(local)) {
|
|
12373
12959
|
markDurableUiLayoutDirty(field, subfield);
|
|
12374
12960
|
}
|
|
12375
12961
|
}
|
|
@@ -12420,10 +13006,15 @@ async function flushDurableUiLayoutSave() {
|
|
|
12420
13006
|
}]));
|
|
12421
13007
|
const patch = { version: UI_LAYOUT_SCHEMA_VERSION };
|
|
12422
13008
|
for (const [field, entry] of snapshot) patch[field] = durableUiLayoutEntryPatch(field, entry);
|
|
13009
|
+
const mixedWidth = patch.sidePanel?.panelWidths?.right;
|
|
12423
13010
|
const response = await api(UI_LAYOUT_ENDPOINT, {
|
|
12424
13011
|
method: "PUT",
|
|
12425
13012
|
scoped: false,
|
|
12426
|
-
body: {
|
|
13013
|
+
body: {
|
|
13014
|
+
layout: patch,
|
|
13015
|
+
...(Number.isFinite(mixedWidth) ? { sidePanelWidth: mixedWidth } : {}),
|
|
13016
|
+
expectedLayoutRevision: durableLayoutRevision,
|
|
13017
|
+
},
|
|
12427
13018
|
});
|
|
12428
13019
|
// A successful write is newer than every GET that began before this
|
|
12429
13020
|
// acknowledgement, even if one of those reads completes afterward.
|
|
@@ -12494,18 +13085,16 @@ function cacheSidePanelWidth(width) {
|
|
|
12494
13085
|
}
|
|
12495
13086
|
}
|
|
12496
13087
|
|
|
12497
|
-
function persistSidePanelWidth(width) {
|
|
13088
|
+
function persistSidePanelWidth(width, side = "right") {
|
|
12498
13089
|
const rounded = Math.round(width);
|
|
12499
13090
|
sidePanelWidthPreferenceRevision += 1;
|
|
12500
|
-
cacheSidePanelWidth(rounded);
|
|
12501
|
-
|
|
12502
|
-
|
|
12503
|
-
|
|
12504
|
-
scoped: false,
|
|
12505
|
-
}).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");
|
|
12506
13095
|
}
|
|
12507
13096
|
|
|
12508
|
-
function sidePanelMaxWidth() {
|
|
13097
|
+
function sidePanelMaxWidth(side = "right") {
|
|
12509
13098
|
const layout = document.querySelector(".layout");
|
|
12510
13099
|
const layoutRect = layout?.getBoundingClientRect?.();
|
|
12511
13100
|
const layoutWidth = layoutRect?.width || window.innerWidth || SIDE_PANEL_WIDTH_DEFAULT_PX;
|
|
@@ -12514,50 +13103,69 @@ function sidePanelMaxWidth() {
|
|
|
12514
13103
|
const horizontalPadding = (Number.parseFloat(layoutStyle?.paddingLeft || "0") || 0) + (Number.parseFloat(layoutStyle?.paddingRight || "0") || 0);
|
|
12515
13104
|
const contentWidth = Math.max(0, layoutWidth - horizontalPadding);
|
|
12516
13105
|
const fileViewerVisible = !!activeFileViewer && elements.fileViewerPane && getComputedStyle(elements.fileViewerPane).display !== "none";
|
|
12517
|
-
const fileViewerWidth = fileViewerVisible ? elements.fileViewerPane.getBoundingClientRect().width : 0;
|
|
13106
|
+
const fileViewerWidth = fileViewerVisible ? Math.max(FILE_VIEWER_WIDTH_MIN_PX, elements.fileViewerPane.getBoundingClientRect().width) : 0;
|
|
12518
13107
|
const splitOpen = document.body.classList.contains("terminal-split-open");
|
|
12519
|
-
const
|
|
12520
|
-
const
|
|
12521
|
-
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);
|
|
12522
13115
|
return Math.max(SIDE_PANEL_WIDTH_MIN_PX, Math.min(Math.floor(contentWidth * 0.72), Math.floor(available)));
|
|
12523
13116
|
}
|
|
12524
13117
|
|
|
12525
|
-
function clampSidePanelWidth(width) {
|
|
13118
|
+
function clampSidePanelWidth(width, side = "right") {
|
|
12526
13119
|
const number = Number(width);
|
|
12527
|
-
const max = sidePanelMaxWidth();
|
|
12528
|
-
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;
|
|
12529
13122
|
return Math.max(SIDE_PANEL_WIDTH_MIN_PX, Math.min(max, Number.isFinite(number) ? number : fallback));
|
|
12530
13123
|
}
|
|
12531
13124
|
|
|
12532
|
-
function currentSidePanelWidth() {
|
|
12533
|
-
const
|
|
12534
|
-
|
|
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;
|
|
12535
13129
|
}
|
|
12536
13130
|
|
|
12537
|
-
function
|
|
12538
|
-
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;
|
|
12539
13141
|
if (!handle) return;
|
|
12540
|
-
|
|
12541
|
-
handle.hidden = !resizeAvailable;
|
|
13142
|
+
handle.hidden = !controlDeckSideResizeAvailable(side);
|
|
12542
13143
|
handle.setAttribute("aria-valuemin", String(SIDE_PANEL_WIDTH_MIN_PX));
|
|
12543
|
-
handle.setAttribute("aria-valuemax", String(sidePanelMaxWidth()));
|
|
13144
|
+
handle.setAttribute("aria-valuemax", String(sidePanelMaxWidth(side)));
|
|
12544
13145
|
handle.setAttribute("aria-valuenow", String(Math.round(width)));
|
|
12545
13146
|
handle.setAttribute("aria-valuetext", `${Math.round(width)} pixels wide`);
|
|
12546
13147
|
}
|
|
12547
13148
|
|
|
12548
|
-
function applySidePanelWidth(width, { persist = false } = {}) {
|
|
12549
|
-
const clamped = clampSidePanelWidth(width);
|
|
12550
|
-
|
|
12551
|
-
|
|
12552
|
-
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);
|
|
12553
13156
|
return clamped;
|
|
12554
13157
|
}
|
|
12555
13158
|
|
|
12556
13159
|
async function restoreSidePanelWidthPreference() {
|
|
12557
13160
|
const localWidth = readStoredSidePanelWidth();
|
|
12558
13161
|
if (localWidth) document.documentElement.style.setProperty("--side-panel-width", `${Math.round(localWidth)}px`);
|
|
12559
|
-
if (!isSidePanelOverlayView())
|
|
12560
|
-
|
|
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
|
+
}
|
|
12561
13169
|
|
|
12562
13170
|
const restoreRevision = sidePanelWidthPreferenceRevision;
|
|
12563
13171
|
const layoutGenerations = new Map(UI_LAYOUT_FIELDS.map((field) => [field, durableUiLayoutGeneration(field)]));
|
|
@@ -12582,14 +13190,15 @@ async function restoreSidePanelWidthPreference() {
|
|
|
12582
13190
|
}
|
|
12583
13191
|
}
|
|
12584
13192
|
|
|
12585
|
-
function beginSidePanelResize(event) {
|
|
12586
|
-
|
|
13193
|
+
function beginSidePanelResize(event, forcedSide = null) {
|
|
13194
|
+
const side = forcedSide || (event.currentTarget === elements.sidePanelResizeHandleLeft ? "left" : "right");
|
|
13195
|
+
if (!controlDeckSideResizeAvailable(side)) return;
|
|
12587
13196
|
if (event.button !== undefined && event.button !== 0) return;
|
|
12588
13197
|
event.preventDefault();
|
|
12589
|
-
const startWidth = currentSidePanelWidth();
|
|
12590
|
-
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 };
|
|
12591
13200
|
document.body.classList.add("side-panel-resizing");
|
|
12592
|
-
elements.sidePanelResizeHandle?.setPointerCapture?.(event.pointerId);
|
|
13201
|
+
(side === "left" ? elements.sidePanelResizeHandleLeft : elements.sidePanelResizeHandle)?.setPointerCapture?.(event.pointerId);
|
|
12593
13202
|
window.addEventListener("pointermove", updateSidePanelResize, { passive: false });
|
|
12594
13203
|
window.addEventListener("pointerup", finishSidePanelResize, { passive: false });
|
|
12595
13204
|
window.addEventListener("pointercancel", finishSidePanelResize, { passive: false });
|
|
@@ -12599,45 +13208,49 @@ function updateSidePanelResize(event) {
|
|
|
12599
13208
|
const state = sidePanelResizeState;
|
|
12600
13209
|
if (!state || (event.pointerId !== undefined && event.pointerId !== state.pointerId)) return;
|
|
12601
13210
|
event.preventDefault();
|
|
12602
|
-
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 });
|
|
12603
13213
|
}
|
|
12604
13214
|
|
|
12605
13215
|
function finishSidePanelResize(event) {
|
|
12606
13216
|
const state = sidePanelResizeState;
|
|
12607
13217
|
if (!state || (event.pointerId !== undefined && event.pointerId !== state.pointerId)) return;
|
|
12608
13218
|
event.preventDefault?.();
|
|
12609
|
-
elements.sidePanelResizeHandle?.releasePointerCapture?.(state.pointerId);
|
|
13219
|
+
(state.side === "left" ? elements.sidePanelResizeHandleLeft : elements.sidePanelResizeHandle)?.releasePointerCapture?.(state.pointerId);
|
|
12610
13220
|
window.removeEventListener("pointermove", updateSidePanelResize);
|
|
12611
13221
|
window.removeEventListener("pointerup", finishSidePanelResize);
|
|
12612
13222
|
window.removeEventListener("pointercancel", finishSidePanelResize);
|
|
12613
13223
|
document.body.classList.remove("side-panel-resizing");
|
|
12614
|
-
applySidePanelWidth(state.width, { persist: true });
|
|
13224
|
+
applySidePanelWidth(state.width, { persist: true, side: state.side });
|
|
12615
13225
|
sidePanelResizeState = null;
|
|
12616
13226
|
}
|
|
12617
13227
|
|
|
12618
13228
|
function handleSidePanelResizeKeydown(event) {
|
|
12619
|
-
|
|
13229
|
+
const side = event.currentTarget === elements.sidePanelResizeHandleLeft ? "left" : "right";
|
|
13230
|
+
if (!controlDeckSideResizeAvailable(side)) return;
|
|
12620
13231
|
const step = event.shiftKey ? 80 : 24;
|
|
12621
|
-
const current = currentSidePanelWidth();
|
|
13232
|
+
const current = currentSidePanelWidth(side);
|
|
12622
13233
|
let next = current;
|
|
12623
|
-
if (event.key === "ArrowLeft") next = current + step;
|
|
12624
|
-
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;
|
|
12625
13236
|
else if (event.key === "Home") next = SIDE_PANEL_WIDTH_MIN_PX;
|
|
12626
|
-
else if (event.key === "End") next = sidePanelMaxWidth();
|
|
13237
|
+
else if (event.key === "End") next = sidePanelMaxWidth(side);
|
|
12627
13238
|
else return;
|
|
12628
13239
|
event.preventDefault();
|
|
12629
|
-
applySidePanelWidth(next, { persist: true });
|
|
13240
|
+
applySidePanelWidth(next, { persist: true, side });
|
|
12630
13241
|
}
|
|
12631
13242
|
|
|
12632
13243
|
function syncSidePanelWidthForViewport() {
|
|
12633
|
-
if (isSidePanelOverlayView()
|
|
12634
|
-
updateSidePanelResizeHandle();
|
|
13244
|
+
if (isSidePanelOverlayView()) {
|
|
13245
|
+
updateSidePanelResizeHandle(currentSidePanelWidth("left"), "left");
|
|
13246
|
+
updateSidePanelResizeHandle(currentSidePanelWidth("right"), "right");
|
|
12635
13247
|
return;
|
|
12636
13248
|
}
|
|
12637
|
-
// Keep viewport/layout reconciliation anchored to the durable
|
|
12638
|
-
// Reading
|
|
12639
|
-
// during hard-reset startup and permanently freeze
|
|
12640
|
-
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" });
|
|
12641
13254
|
}
|
|
12642
13255
|
|
|
12643
13256
|
function readStoredFileViewerWidth() {
|
|
@@ -12772,6 +13385,7 @@ function syncFileViewerWidthForViewport() {
|
|
|
12772
13385
|
function syncResizablePanelWidthsForViewport() {
|
|
12773
13386
|
syncSidePanelWidthForViewport();
|
|
12774
13387
|
syncFileViewerWidthForViewport();
|
|
13388
|
+
syncTerminalTabsSidebarWidthForViewport();
|
|
12775
13389
|
}
|
|
12776
13390
|
|
|
12777
13391
|
async function openFileTreeEntryInWebui(entry = fileContextMenuState?.entry) {
|
|
@@ -12820,7 +13434,7 @@ function updateFileViewerUi() {
|
|
|
12820
13434
|
document.body.classList.toggle("file-viewer-open", open);
|
|
12821
13435
|
syncMobileShellInteractivity();
|
|
12822
13436
|
if (elements.fileViewerPane) elements.fileViewerPane.hidden = !open;
|
|
12823
|
-
|
|
13437
|
+
scheduleControlDeckPresentationReconciliation();
|
|
12824
13438
|
updateFileViewerResizeHandle();
|
|
12825
13439
|
if (!open) {
|
|
12826
13440
|
closeFileViewerSearch({ restoreFocus: false });
|
|
@@ -13331,7 +13945,7 @@ function resetFileViewerUi() {
|
|
|
13331
13945
|
syncMobileShellInteractivity();
|
|
13332
13946
|
updateFileViewerResizeHandle();
|
|
13333
13947
|
if (elements.fileViewerPane) elements.fileViewerPane.hidden = true;
|
|
13334
|
-
|
|
13948
|
+
scheduleControlDeckPresentationReconciliation();
|
|
13335
13949
|
if (elements.fileViewerOpenDefaultButton) elements.fileViewerOpenDefaultButton.dataset.path = "";
|
|
13336
13950
|
if (elements.fileViewerEditor) {
|
|
13337
13951
|
elements.fileViewerEditor.value = "";
|
|
@@ -13635,6 +14249,9 @@ function syncTabMetadata(nextTabs = []) {
|
|
|
13635
14249
|
if (voiceConversationTabId === tabId) stopVoiceConversationLoop();
|
|
13636
14250
|
clearGitWorkflowForTab(tabId);
|
|
13637
14251
|
commandCatalogsByTab.delete(tabId);
|
|
14252
|
+
tabStateCache.delete(tabId);
|
|
14253
|
+
tabStatsCache.delete(tabId);
|
|
14254
|
+
tabWorkspaceCache.delete(tabId);
|
|
13638
14255
|
sessionSummaryByTab.delete(tabId);
|
|
13639
14256
|
if (sessionSummaryOverlayTabId === tabId) closeSessionSummaryOverlay({ restoreFocus: false });
|
|
13640
14257
|
clearGitFooterPayloadState(tabId);
|
|
@@ -14045,23 +14662,37 @@ function clearWidgetsForTab(tabId = activeTabId) {
|
|
|
14045
14662
|
}
|
|
14046
14663
|
}
|
|
14047
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
|
+
|
|
14048
14678
|
function resetActiveTabUi() {
|
|
14049
14679
|
clearRefreshTimers();
|
|
14050
14680
|
eventSource?.close();
|
|
14051
14681
|
eventSource = null;
|
|
14052
|
-
currentState =
|
|
14053
|
-
latestStats = null;
|
|
14682
|
+
currentState = cachedStateForTabSwitch(activeTabId);
|
|
14683
|
+
latestStats = activeTabId ? tabStatsCache.get(activeTabId) || null : null;
|
|
14054
14684
|
latestStatsOverlayPayload = null;
|
|
14055
14685
|
latestBtwWidgetPayload = null;
|
|
14056
14686
|
btwWidgetComposerOpen = false;
|
|
14057
14687
|
btwWidgetInputDraft = "";
|
|
14058
|
-
latestWorkspace = null;
|
|
14688
|
+
latestWorkspace = activeTabId ? tabWorkspaceCache.get(activeTabId) || null : null;
|
|
14059
14689
|
latestMessages = [];
|
|
14060
14690
|
latestMessagesSessionKey = "";
|
|
14061
14691
|
resetFileViewerUi();
|
|
14062
14692
|
resetFileTreeState();
|
|
14063
14693
|
restoreFileViewerForActiveTab();
|
|
14064
14694
|
clearRunIndicatorActivity({ render: false });
|
|
14695
|
+
if (currentState) syncRunIndicatorFromState(currentState);
|
|
14065
14696
|
statusEntries.clear();
|
|
14066
14697
|
restoreWidgetsForActiveTab();
|
|
14067
14698
|
transientMessages = [];
|
|
@@ -14071,6 +14702,7 @@ function resetActiveTabUi() {
|
|
|
14071
14702
|
availableCommands = commandCatalog?.available || [];
|
|
14072
14703
|
rawAvailableCommands = commandCatalog?.raw || [];
|
|
14073
14704
|
resetOptionalFeatureAvailability();
|
|
14705
|
+
if (commandCatalog) updateOptionalFeatureAvailability();
|
|
14074
14706
|
commandSuggestions = [];
|
|
14075
14707
|
pathSuggestions = [];
|
|
14076
14708
|
suggestionMode = "none";
|
|
@@ -14099,6 +14731,7 @@ function resetActiveTabUi() {
|
|
|
14099
14731
|
restoreCachedMessagesForActiveTab();
|
|
14100
14732
|
renderFooter();
|
|
14101
14733
|
renderFeedbackTray();
|
|
14734
|
+
restoreComposerActionSlotLayout();
|
|
14102
14735
|
}
|
|
14103
14736
|
|
|
14104
14737
|
function tabGroupStatusRank(state) {
|
|
@@ -15219,6 +15852,29 @@ function initializeTerminalHeaderTooltips() {
|
|
|
15219
15852
|
applyStyledTooltip(elements.closeAllTabsButton, "Close all terminal tabs", { ariaLabel: "Close all terminal tabs" });
|
|
15220
15853
|
}
|
|
15221
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
|
+
|
|
15222
15878
|
function openNewTabMenu() {
|
|
15223
15879
|
setPublishMenuOpen(false);
|
|
15224
15880
|
setNativeCommandMenuOpen(false);
|
|
@@ -15342,17 +15998,81 @@ function prefetchInactiveTabCommandCatalogs() {
|
|
|
15342
15998
|
}
|
|
15343
15999
|
}
|
|
15344
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
|
+
|
|
15345
16057
|
async function refreshTabs({ selectStored = false } = {}) {
|
|
15346
16058
|
const previousTabs = tabs;
|
|
16059
|
+
const previousTabsSignature = tabsSnapshotSignature(previousTabs);
|
|
16060
|
+
const previousTabsRenderSignature = tabsRenderSnapshotSignature(previousTabs);
|
|
16061
|
+
const previousActiveTabId = activeTabId;
|
|
15347
16062
|
const response = await api("/api/tabs", { scoped: false });
|
|
15348
|
-
|
|
15349
|
-
|
|
15350
|
-
const
|
|
15351
|
-
|
|
15352
|
-
|
|
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);
|
|
15353
16075
|
}
|
|
15354
|
-
syncBlockedTabNotificationsFromTabs(tabs, previousTabs);
|
|
15355
|
-
syncAgentDoneNotificationsFromTabs(tabs, previousTabs);
|
|
15356
16076
|
const requested = selectStored ? requestedTabIdFromUrl() : null;
|
|
15357
16077
|
const stored = selectStored ? restoreStoredTabId() : null;
|
|
15358
16078
|
if (!activeTabId || !tabs.some((tab) => tab.id === activeTabId)) {
|
|
@@ -15365,7 +16085,8 @@ async function refreshTabs({ selectStored = false } = {}) {
|
|
|
15365
16085
|
setWorkspaceDashboardCollapsed(false, { persist: false });
|
|
15366
16086
|
}
|
|
15367
16087
|
renderSessionSkillTags(activeTabId);
|
|
15368
|
-
renderTabs();
|
|
16088
|
+
if (tabsRenderChanged || activeTabId !== previousActiveTabId || selectStored) renderTabs();
|
|
16089
|
+
else syncTabPolling();
|
|
15369
16090
|
prefetchInactiveTabCommandCatalogs();
|
|
15370
16091
|
return tabs;
|
|
15371
16092
|
}
|
|
@@ -15397,6 +16118,9 @@ async function switchTab(tabId) {
|
|
|
15397
16118
|
cacheMessagesForTab(activeTabId);
|
|
15398
16119
|
cacheWidgetsForTab(activeTabId);
|
|
15399
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);
|
|
15400
16124
|
const tabContext = setActiveTabId(tabId, { remember: true });
|
|
15401
16125
|
if (voiceConversation && voiceConversationTabId !== tabId) stopVoiceConversationLoop();
|
|
15402
16126
|
resetActiveTabUi();
|
|
@@ -15447,10 +16171,11 @@ function updateTerminalSplitControls(canShowSplit, splitTab = terminalSplitTab()
|
|
|
15447
16171
|
|
|
15448
16172
|
function updateTerminalSplitUi() {
|
|
15449
16173
|
const tab = terminalSplitTab();
|
|
15450
|
-
const
|
|
16174
|
+
const overlayDrawerOpen = isControlDeckOverlayPresentation() && !document.body.classList.contains("side-panel-collapsed");
|
|
16175
|
+
const canShowSplit = !!tab && !embeddedSplitMode && !overlayDrawerOpen;
|
|
15451
16176
|
document.body.classList.toggle("terminal-split-open", canShowSplit);
|
|
15452
16177
|
if (elements.terminalSplitShell) elements.terminalSplitShell.hidden = !canShowSplit;
|
|
15453
|
-
|
|
16178
|
+
scheduleControlDeckPresentationReconciliation();
|
|
15454
16179
|
updateTerminalSplitControls(canShowSplit, tab);
|
|
15455
16180
|
if (!canShowSplit) return;
|
|
15456
16181
|
if (elements.terminalSplitTitle) elements.terminalSplitTitle.textContent = tab.title || "Split terminal";
|
|
@@ -22481,15 +23206,65 @@ function initializeClaudeUsage() {
|
|
|
22481
23206
|
claudeUsageRenderTimer = setInterval(renderClaudeUsage, CLAUDE_USAGE_RENDER_TICK_MS);
|
|
22482
23207
|
}
|
|
22483
23208
|
|
|
22484
|
-
|
|
22485
|
-
|
|
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);
|
|
22486
23234
|
const now = Number.isFinite(serverNow) ? serverNow : Date.now();
|
|
22487
|
-
|
|
22488
|
-
.map((tab) =>
|
|
22489
|
-
|
|
22490
|
-
const
|
|
22491
|
-
|
|
22492
|
-
|
|
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()
|
|
22493
23268
|
.filter((tab) => tab.displayRuns.length > 0 || Number(tab?.gateCount || 0) > 0)
|
|
22494
23269
|
.sort((a, b) => Number(a.tabIndex || 0) - Number(b.tabIndex || 0) || String(a.tabTitle || "").localeCompare(String(b.tabTitle || "")));
|
|
22495
23270
|
}
|
|
@@ -22511,9 +23286,14 @@ function subagentRunElapsed(run) {
|
|
|
22511
23286
|
}
|
|
22512
23287
|
|
|
22513
23288
|
function subagentSourceLabel(source = "") {
|
|
23289
|
+
if (source === "recovered") return "recovered active child";
|
|
22514
23290
|
return source === "foreground" || source === "workflow" ? source : "async";
|
|
22515
23291
|
}
|
|
22516
23292
|
|
|
23293
|
+
function subagentRunSupportsInteraction(run = {}) {
|
|
23294
|
+
return run?.source !== "recovered" && run?.provisional !== true && run?.controllable !== false;
|
|
23295
|
+
}
|
|
23296
|
+
|
|
22517
23297
|
function subagentExecutionValues(agent = {}) {
|
|
22518
23298
|
const thinking = String(agent?.thinking || "").trim();
|
|
22519
23299
|
let model = String(agent?.model || "").trim();
|
|
@@ -22540,20 +23320,45 @@ function subagentGateAttemptViewFacts(attempt) {
|
|
|
22540
23320
|
}
|
|
22541
23321
|
|
|
22542
23322
|
function subagentRunIsRunning(run = {}, agent = null) {
|
|
22543
|
-
|
|
22544
|
-
|
|
22545
|
-
|
|
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);
|
|
22546
23344
|
}
|
|
22547
23345
|
|
|
22548
23346
|
function subagentRunCanCancel(run = {}, agent = null) {
|
|
22549
|
-
|
|
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);
|
|
22550
23357
|
}
|
|
22551
23358
|
|
|
22552
|
-
function subagentRunStateLabel(run = {}) {
|
|
22553
|
-
|
|
22554
|
-
|
|
22555
|
-
if (run?.status === "done") return "done";
|
|
22556
|
-
return "running";
|
|
23359
|
+
function subagentRunStateLabel(run = {}, agent = null) {
|
|
23360
|
+
const status = subagentAgentStatus(run, agent);
|
|
23361
|
+
return status === "cancelled" ? "cancelled" : status;
|
|
22557
23362
|
}
|
|
22558
23363
|
|
|
22559
23364
|
function setSubagentCancelStatus(message = "", level = "muted") {
|
|
@@ -22578,11 +23383,13 @@ function subagentCancelTargetLabel(selection = subagentCancelSelection) {
|
|
|
22578
23383
|
}
|
|
22579
23384
|
|
|
22580
23385
|
function openSubagentCancelDialog(tab, run, agent = null) {
|
|
22581
|
-
if (!tab?.
|
|
23386
|
+
if (!tab?.groupId || !run?.id || !subagentRunCanCancel(run, agent) || !elements.subagentCancelDialog) return;
|
|
22582
23387
|
const agentCount = Array.isArray(run.agents) ? run.agents.length : 0;
|
|
22583
23388
|
subagentCancelSelection = {
|
|
23389
|
+
groupId: tab.groupId,
|
|
22584
23390
|
tabId: tab.tabId,
|
|
22585
23391
|
runId: run.id,
|
|
23392
|
+
agentId: agent?.instanceId || agent?.id || "",
|
|
22586
23393
|
agentCount,
|
|
22587
23394
|
};
|
|
22588
23395
|
if (elements.subagentCancelDialogSubtitle) {
|
|
@@ -22614,8 +23421,9 @@ async function submitSubagentCancel() {
|
|
|
22614
23421
|
method: "POST",
|
|
22615
23422
|
scoped: false,
|
|
22616
23423
|
body: {
|
|
22617
|
-
|
|
23424
|
+
group: selection.groupId,
|
|
22618
23425
|
runId: selection.runId,
|
|
23426
|
+
...(selection.agentId ? { agentId: selection.agentId } : {}),
|
|
22619
23427
|
...(reason ? { reason } : {}),
|
|
22620
23428
|
...(note ? { note } : {}),
|
|
22621
23429
|
},
|
|
@@ -22634,14 +23442,15 @@ async function submitSubagentCancel() {
|
|
|
22634
23442
|
}
|
|
22635
23443
|
|
|
22636
23444
|
async function dismissSubagentRun(tab, run) {
|
|
22637
|
-
if (!tab?.
|
|
23445
|
+
if (!tab?.groupId || !run?.id || !subagentRunCanDismiss(run)) return;
|
|
23446
|
+
const attachedProjection = subagentRunIsAttachedProjection(run);
|
|
22638
23447
|
try {
|
|
22639
23448
|
await api("/api/subagents/dismiss", {
|
|
22640
23449
|
method: "POST",
|
|
22641
23450
|
scoped: false,
|
|
22642
|
-
body: {
|
|
23451
|
+
body: { group: tab.groupId, runId: run.id },
|
|
22643
23452
|
});
|
|
22644
|
-
addEvent(`dismissed finished subagent run ${run.id}`, "info");
|
|
23453
|
+
addEvent(attachedProjection ? `detached persisted session projection ${run.id}` : `dismissed finished subagent run ${run.id}`, "info");
|
|
22645
23454
|
await refreshSubagents();
|
|
22646
23455
|
scheduleRefreshSubagents();
|
|
22647
23456
|
} catch (error) {
|
|
@@ -22650,12 +23459,10 @@ async function dismissSubagentRun(tab, run) {
|
|
|
22650
23459
|
}
|
|
22651
23460
|
|
|
22652
23461
|
function finishedSubagentRunSelections(data = latestSubagents) {
|
|
22653
|
-
return (
|
|
22654
|
-
|
|
22655
|
-
|
|
22656
|
-
|
|
22657
|
-
.filter((selection) => selection.tabId && selection.runId)
|
|
22658
|
-
));
|
|
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));
|
|
22659
23466
|
}
|
|
22660
23467
|
|
|
22661
23468
|
async function clearFinishedSubagentRuns({ automatic = false } = {}) {
|
|
@@ -22673,7 +23480,7 @@ async function clearFinishedSubagentRuns({ automatic = false } = {}) {
|
|
|
22673
23480
|
await api("/api/subagents/dismiss", {
|
|
22674
23481
|
method: "POST",
|
|
22675
23482
|
scoped: false,
|
|
22676
|
-
body: {
|
|
23483
|
+
body: { group: selection.groupId, runId: selection.runId },
|
|
22677
23484
|
});
|
|
22678
23485
|
dismissed += 1;
|
|
22679
23486
|
} catch (error) {
|
|
@@ -22883,7 +23690,7 @@ function renderSubagentOverlayWidget() {
|
|
|
22883
23690
|
const transcriptMessages = subagentOverlayTranscriptMessages(data);
|
|
22884
23691
|
const hasStructuredTranscript = transcriptMessages.length > 0;
|
|
22885
23692
|
const outputText = subagentOverlayOutputText(data);
|
|
22886
|
-
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.");
|
|
22887
23694
|
const shownLineCount = outputText ? outputText.split("\n").length : fallbackText ? fallbackText.split("\n").length : 0;
|
|
22888
23695
|
const widget = make("section", `widget release-npm-widget app-runner-widget subagent-overlay-widget${running ? " app-runner-live-widget" : " app-runner-log-widget"}`);
|
|
22889
23696
|
widget.setAttribute("aria-label", `Live output for subagent ${agent.name || "subagent"}`);
|
|
@@ -22925,11 +23732,13 @@ function renderSubagentOverlayWidget() {
|
|
|
22925
23732
|
}, "subagent-overlay-refresh-action");
|
|
22926
23733
|
refreshButton.disabled = subagentOverlayLoading || selection.finished;
|
|
22927
23734
|
if (subagentRunCanCancel(selection.run, agent)) {
|
|
22928
|
-
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"));
|
|
22929
23736
|
}
|
|
22930
|
-
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"));
|
|
22931
23740
|
const details = [
|
|
22932
|
-
`${tab?.title || `Terminal ${selection.tabIndex || "?"}`} · run ${selection.runId}`,
|
|
23741
|
+
`${selection.tab?.tabTitle || tab?.title || `Terminal ${selection.tabIndex || "?"}`} · run ${selection.runId}`,
|
|
22933
23742
|
agent.currentPath ? `path: ${agent.currentPath}` : "",
|
|
22934
23743
|
agent.activityState ? `activity: ${agent.activityState}` : "",
|
|
22935
23744
|
agent.error ? `status warning: ${agent.error}` : "",
|
|
@@ -22960,7 +23769,7 @@ async function refreshSubagentOverlay() {
|
|
|
22960
23769
|
const previousSignature = subagentOverlayMeaningfulSignature();
|
|
22961
23770
|
subagentOverlayLoading = true;
|
|
22962
23771
|
try {
|
|
22963
|
-
const query = new URLSearchParams({
|
|
23772
|
+
const query = new URLSearchParams({ group: selection.groupId, run: selection.runId, agent: selection.agentId });
|
|
22964
23773
|
const response = await api(`/api/subagents/output?${query}`, { scoped: false });
|
|
22965
23774
|
if (requestSerial !== subagentOverlayRequestSerial || subagentOverlaySelection !== selection) return;
|
|
22966
23775
|
subagentOverlayData = response.data || null;
|
|
@@ -22980,11 +23789,12 @@ async function refreshSubagentOverlay() {
|
|
|
22980
23789
|
}
|
|
22981
23790
|
|
|
22982
23791
|
async function openSubagentOverlay(tab, run, agent) {
|
|
22983
|
-
if (!tab?.
|
|
23792
|
+
if (!tab?.groupId || !run?.id || !agent?.id || !subagentRunCanOpen(run, agent)) return;
|
|
22984
23793
|
if (activeSubagentTerminalId) deactivateSubagentTerminalView({ render: false });
|
|
22985
23794
|
try {
|
|
22986
23795
|
if (activeTabId !== tab.tabId) await switchTab(tab.tabId);
|
|
22987
23796
|
subagentOverlaySelection = {
|
|
23797
|
+
groupId: tab.groupId,
|
|
22988
23798
|
tabId: tab.tabId,
|
|
22989
23799
|
tabIndex: tab.tabIndex,
|
|
22990
23800
|
tab,
|
|
@@ -23062,6 +23872,7 @@ function updateSubagentTerminalRefreshState(view, { running = subagentTerminalVi
|
|
|
23062
23872
|
elements.subagentTerminalStatus.setAttribute("aria-live", view.error ? "polite" : "off");
|
|
23063
23873
|
elements.subagentTerminalStatus.textContent = status;
|
|
23064
23874
|
elements.subagentTerminalStatus.classList.toggle("warning", !!view.error);
|
|
23875
|
+
elements.subagentTerminalRefreshButton.hidden = !subagentRunCanRefresh(view.run, view.data?.agent || view.agent);
|
|
23065
23876
|
elements.subagentTerminalRefreshButton.disabled = view.loading || view.finished === true;
|
|
23066
23877
|
elements.subagentTerminalRefreshButton.textContent = view.loading ? "Refreshing…" : "Refresh";
|
|
23067
23878
|
}
|
|
@@ -23112,7 +23923,7 @@ function renderSubagentTerminalView() {
|
|
|
23112
23923
|
const transcriptMessages = subagentOverlayTranscriptMessages({ agent });
|
|
23113
23924
|
const hasStructuredTranscript = transcriptMessages.length > 0;
|
|
23114
23925
|
const outputText = subagentOverlayOutputText({ agent });
|
|
23115
|
-
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.");
|
|
23116
23927
|
const parent = tabs.find((tab) => tab.id === view.parentTabId);
|
|
23117
23928
|
const elapsed = subagentRunElapsed(view.run);
|
|
23118
23929
|
const facts = [
|
|
@@ -23150,6 +23961,7 @@ function renderSubagentTerminalView() {
|
|
|
23150
23961
|
if (running) appendSubagentRunIndicator(elements.subagentTerminalTranscript, { agent, run: view.run });
|
|
23151
23962
|
|
|
23152
23963
|
updateSubagentTerminalRefreshState(view, { running });
|
|
23964
|
+
elements.subagentTerminalCopyButton.hidden = !outputText;
|
|
23153
23965
|
elements.subagentTerminalCopyButton.disabled = !outputText;
|
|
23154
23966
|
if (elements.subagentTerminalCancelButton) {
|
|
23155
23967
|
const cancellable = subagentRunCanCancel(view.run, agent);
|
|
@@ -23178,7 +23990,7 @@ async function refreshSubagentTerminalView(viewId = activeSubagentTerminalId, {
|
|
|
23178
23990
|
view.loading = true;
|
|
23179
23991
|
if (showLoading) updateSubagentTerminalRefreshState(view);
|
|
23180
23992
|
try {
|
|
23181
|
-
const query = new URLSearchParams({
|
|
23993
|
+
const query = new URLSearchParams({ group: view.groupId, run: view.runId, agent: view.agentId });
|
|
23182
23994
|
const response = await api(`/api/subagents/output?${query}`, { scoped: false });
|
|
23183
23995
|
if (view.requestSerial !== requestSerial || !subagentTerminalViews.has(view.id)) return;
|
|
23184
23996
|
view.data = response.data || null;
|
|
@@ -23233,10 +24045,11 @@ async function activateSubagentTerminalView(viewId) {
|
|
|
23233
24045
|
}
|
|
23234
24046
|
|
|
23235
24047
|
function ensureSubagentTerminalView(tab, run, agent) {
|
|
23236
|
-
if (!tab?.tabId || !run?.id || !agent?.id) return null;
|
|
24048
|
+
if (!tab?.groupId || !tab?.tabId || !run?.id || !agent?.id || !subagentRunCanOpen(run, agent)) return null;
|
|
23237
24049
|
const id = subagentTerminalViewId(tab, run, agent);
|
|
23238
24050
|
const existing = subagentTerminalViews.get(id);
|
|
23239
24051
|
if (existing) {
|
|
24052
|
+
existing.groupId = tab.groupId;
|
|
23240
24053
|
existing.tab = tab;
|
|
23241
24054
|
existing.run = run;
|
|
23242
24055
|
existing.agent = agent;
|
|
@@ -23246,6 +24059,7 @@ function ensureSubagentTerminalView(tab, run, agent) {
|
|
|
23246
24059
|
}
|
|
23247
24060
|
const view = {
|
|
23248
24061
|
id,
|
|
24062
|
+
groupId: tab.groupId,
|
|
23249
24063
|
parentTabId: tab.tabId,
|
|
23250
24064
|
parentTitle: tab.tabTitle,
|
|
23251
24065
|
tabIndex: tab.tabIndex,
|
|
@@ -23267,6 +24081,7 @@ function ensureSubagentTerminalView(tab, run, agent) {
|
|
|
23267
24081
|
}
|
|
23268
24082
|
|
|
23269
24083
|
async function openSubagentTerminal(tab, run, agent) {
|
|
24084
|
+
if (!subagentRunCanOpen(run, agent)) return;
|
|
23270
24085
|
const view = ensureSubagentTerminalView(tab, run, agent);
|
|
23271
24086
|
if (!view) return;
|
|
23272
24087
|
try {
|
|
@@ -23328,10 +24143,17 @@ function removeSubagentTerminalViewsForParent(parentTabId) {
|
|
|
23328
24143
|
|
|
23329
24144
|
function syncSubagentTerminalViewsFromOverview() {
|
|
23330
24145
|
let changed = false;
|
|
23331
|
-
const overviewTabs =
|
|
23332
|
-
for (const view of subagentTerminalViews.values()) {
|
|
23333
|
-
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);
|
|
23334
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
|
+
}
|
|
23335
24157
|
const agent = (Array.isArray(run?.agents) ? run.agents : []).find((candidate) => candidate.id === view.agentId);
|
|
23336
24158
|
if (tab) {
|
|
23337
24159
|
view.tab = tab;
|
|
@@ -23350,18 +24172,29 @@ function syncSubagentTerminalViewsFromOverview() {
|
|
|
23350
24172
|
}
|
|
23351
24173
|
const selection = subagentOverlaySelection;
|
|
23352
24174
|
if (selection) {
|
|
23353
|
-
const tab = overviewTabs.find((candidate) => candidate.
|
|
24175
|
+
const tab = overviewTabs.find((candidate) => candidate.groupId === selection.groupId);
|
|
23354
24176
|
const run = (Array.isArray(tab?.runs) ? tab.runs : []).find((candidate) => candidate.id === selection.runId);
|
|
23355
|
-
|
|
23356
|
-
|
|
23357
|
-
|
|
23358
|
-
|
|
23359
|
-
|
|
23360
|
-
|
|
23361
|
-
|
|
23362
|
-
|
|
23363
|
-
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;
|
|
23364
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
|
+
}
|
|
23365
24198
|
}
|
|
23366
24199
|
}
|
|
23367
24200
|
return changed;
|
|
@@ -23370,13 +24203,13 @@ function syncSubagentTerminalViewsFromOverview() {
|
|
|
23370
24203
|
function materializeRetainedSubagentTerminalViews() {
|
|
23371
24204
|
if (subagentOpenMode !== "tab") return false;
|
|
23372
24205
|
let materialized = false;
|
|
23373
|
-
for (const tab of
|
|
24206
|
+
for (const tab of subagentOverviewGroups()) {
|
|
23374
24207
|
if (tab?.available !== true || !tab?.tabId) continue;
|
|
23375
24208
|
const restoreKey = `${tab.tabId}\u0000${tab.sessionFile || ""}`;
|
|
23376
24209
|
if (subagentTerminalRestoredParentTabs.has(restoreKey)) continue;
|
|
23377
24210
|
subagentTerminalRestoredParentTabs.add(restoreKey);
|
|
23378
|
-
for (const run of
|
|
23379
|
-
if (
|
|
24211
|
+
for (const run of tab.displayRuns) {
|
|
24212
|
+
if (["queued", "running", "stale"].includes(subagentAgentStatus(run)) || run?.source === "workflow") continue;
|
|
23380
24213
|
for (const agent of Array.isArray(run.agents) ? run.agents : []) {
|
|
23381
24214
|
const id = subagentTerminalViewId(tab, run, agent);
|
|
23382
24215
|
if (subagentTerminalViews.has(id)) continue;
|
|
@@ -23514,30 +24347,41 @@ function renderSubagentTerminalTabGroup(group) {
|
|
|
23514
24347
|
}
|
|
23515
24348
|
|
|
23516
24349
|
function openSubagentOutput(tab, run, agent) {
|
|
24350
|
+
if (!subagentRunCanOpen(run, agent)) return;
|
|
23517
24351
|
return subagentOpenMode === "tab" ? openSubagentTerminal(tab, run, agent) : openSubagentOverlay(tab, run, agent);
|
|
23518
24352
|
}
|
|
23519
24353
|
|
|
23520
24354
|
function renderSubagentAgent(tab, run, agent) {
|
|
23521
|
-
const
|
|
24355
|
+
const status = subagentAgentStatus(run, agent);
|
|
24356
|
+
const running = ["queued", "running"].includes(status);
|
|
24357
|
+
const interactive = subagentRunCanOpen(run, agent);
|
|
23522
24358
|
const name = agent?.name || "subagent";
|
|
23523
24359
|
const [model, thinking] = subagentExecutionValues(agent);
|
|
23524
|
-
const
|
|
23525
|
-
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";
|
|
23526
24363
|
row.dataset.subagentContinuityKey = `agent:${tab?.tabId || ""}:${run?.id || ""}:${agent?.id || ""}`;
|
|
23527
|
-
const dot = make("span",
|
|
24364
|
+
const dot = make("span", `subagent-state-dot ${status}`);
|
|
23528
24365
|
dot.setAttribute("aria-hidden", "true");
|
|
23529
24366
|
const identity = make("span", "subagent-agent-identity");
|
|
23530
24367
|
identity.append(
|
|
23531
24368
|
make("strong", "subagent-agent-name", name),
|
|
23532
|
-
make("span", "subagent-
|
|
24369
|
+
make("span", "subagent-source-badge", launcher),
|
|
24370
|
+
make("span", "subagent-agent-inline-meta", `· ${status} · ${model} · ${thinking}`),
|
|
23533
24371
|
);
|
|
23534
|
-
|
|
23535
|
-
|
|
23536
|
-
|
|
23537
|
-
|
|
23538
|
-
|
|
23539
|
-
|
|
23540
|
-
|
|
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
|
+
}
|
|
23541
24385
|
return row;
|
|
23542
24386
|
}
|
|
23543
24387
|
|
|
@@ -23561,11 +24405,12 @@ function renderSubagentRun(tab, run) {
|
|
|
23561
24405
|
applyStyledTooltip(cancel, "Cancel entire subagent run…", { ariaLabel: "Cancel entire subagent run" });
|
|
23562
24406
|
cancel.addEventListener("click", () => openSubagentCancelDialog(tab, run));
|
|
23563
24407
|
actions.append(cancel);
|
|
23564
|
-
} else if (
|
|
24408
|
+
} else if (subagentRunCanDismiss(run)) {
|
|
23565
24409
|
const dismiss = make("button", "subagent-run-dismiss", "×");
|
|
23566
24410
|
dismiss.type = "button";
|
|
23567
24411
|
dismiss.dataset.subagentContinuityKey = `run:${tab?.tabId || ""}:${run?.id || ""}:dismiss`;
|
|
23568
|
-
|
|
24412
|
+
const dismissLabel = subagentRunIsAttachedProjection(run) ? "Detach persisted session from WebUI" : "Dismiss finished run";
|
|
24413
|
+
applyStyledTooltip(dismiss, dismissLabel, { ariaLabel: dismissLabel });
|
|
23569
24414
|
dismiss.addEventListener("click", () => dismissSubagentRun(tab, run));
|
|
23570
24415
|
actions.append(dismiss);
|
|
23571
24416
|
}
|
|
@@ -23578,13 +24423,13 @@ function subagentGateStatusLabel(status) {
|
|
|
23578
24423
|
}
|
|
23579
24424
|
|
|
23580
24425
|
function subagentGateAttemptTarget(tab, attempt) {
|
|
23581
|
-
if (!tab?.
|
|
23582
|
-
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);
|
|
23583
24428
|
if (!run) return null;
|
|
23584
24429
|
const agents = Array.isArray(run.agents) ? run.agents : [];
|
|
23585
|
-
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);
|
|
23586
24431
|
if (!agent && agents.length === 1) [agent] = agents;
|
|
23587
|
-
return agent?.id ? { run, agent } : null;
|
|
24432
|
+
return agent?.id && subagentRunCanOpen(run, agent) ? { run, agent } : null;
|
|
23588
24433
|
}
|
|
23589
24434
|
|
|
23590
24435
|
function subagentGateAttemptExecutionValues(attempt = {}) {
|
|
@@ -23664,28 +24509,32 @@ function renderSubagentGate(tab, gate) {
|
|
|
23664
24509
|
}
|
|
23665
24510
|
|
|
23666
24511
|
function renderSubagentTabGroup(tab) {
|
|
23667
|
-
const
|
|
23668
|
-
const
|
|
23669
|
-
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";
|
|
23670
24516
|
header.dataset.subagentContinuityKey = `tab:${tab?.tabId || ""}`;
|
|
23671
|
-
header.setAttribute("aria-label", `Open ${tab.tabTitle || `Terminal ${tab.tabIndex || ""}`}`);
|
|
24517
|
+
if (!isExternal) header.setAttribute("aria-label", `Open ${tab.tabTitle || `Terminal ${tab.tabIndex || ""}`}`);
|
|
23672
24518
|
const title = make("span", "subagent-tab-title");
|
|
23673
24519
|
title.append(
|
|
23674
24520
|
make("strong", undefined, tab.tabTitle || `Terminal ${tab.tabIndex || "?"}`),
|
|
23675
|
-
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)}`),
|
|
23676
24522
|
);
|
|
23677
24523
|
const runs = (Array.isArray(tab.displayRuns) ? tab.displayRuns : ungatedSubagentRuns(tab))
|
|
23678
24524
|
.slice()
|
|
23679
24525
|
.sort((a, b) => Number(a.startedAt || 0) - Number(b.startedAt || 0) || String(a.id || "").localeCompare(String(b.id || "")));
|
|
23680
24526
|
const runningAgents = Number(tab.runningAgents || 0);
|
|
23681
|
-
const
|
|
24527
|
+
const staleAgents = Number(tab.staleAgents || 0);
|
|
24528
|
+
const retainedRuns = runs.filter((run) => !["queued", "running", "stale"].includes(subagentAgentStatus(run))).length;
|
|
23682
24529
|
const countLabel = [
|
|
23683
|
-
`${
|
|
24530
|
+
`${tab.agentCount || 0} total`,
|
|
24531
|
+
runningAgents ? `${runningAgents} running` : "",
|
|
24532
|
+
staleAgents ? `${staleAgents} stale` : "",
|
|
23684
24533
|
retainedRuns ? `${retainedRuns} retained` : "",
|
|
23685
24534
|
Number(tab.gateCount || 0) ? `${tab.gateCount} gates` : "",
|
|
23686
24535
|
].filter(Boolean).join(" · ");
|
|
23687
24536
|
header.append(title, make("span", "subagent-tab-count", countLabel));
|
|
23688
|
-
header.addEventListener("click", () => switchTab(tab.tabId));
|
|
24537
|
+
if (!isExternal) header.addEventListener("click", () => switchTab(tab.tabId));
|
|
23689
24538
|
group.append(header);
|
|
23690
24539
|
|
|
23691
24540
|
const list = make("div", "subagent-agent-list");
|
|
@@ -23710,7 +24559,9 @@ function renderSubagents() {
|
|
|
23710
24559
|
const restoreFocus = () => restoreScopedControlContinuity(box, continuityContextKey, focusSnapshot, (key) => [...box.querySelectorAll("[data-subagent-continuity-key]")].find((node) => subagentPanelControlKey(node) === key));
|
|
23711
24560
|
const activeTabs = subagentTabsWithRunningAgents();
|
|
23712
24561
|
const finishedRuns = finishedSubagentRunSelections();
|
|
23713
|
-
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));
|
|
23714
24565
|
const totalRuns = activeTabs.reduce((count, tab) => count + tab.displayRuns.length, 0);
|
|
23715
24566
|
const runningRuns = activeTabs.reduce((count, tab) => count + tab.displayRuns.filter((run) => run?.status === "running").length, 0);
|
|
23716
24567
|
const retainedRuns = Math.max(0, totalRuns - runningRuns);
|
|
@@ -23736,7 +24587,7 @@ function renderSubagents() {
|
|
|
23736
24587
|
}
|
|
23737
24588
|
if (elements.subagentsStatus) {
|
|
23738
24589
|
elements.subagentsStatus.textContent = hasItems
|
|
23739
|
-
? [`${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(" · ")
|
|
23740
24591
|
: subagentsLoading && !latestSubagents
|
|
23741
24592
|
? "Checking subagents and retry gates…"
|
|
23742
24593
|
: "No running subagents, retained runs, or retry gates.";
|
|
@@ -23746,7 +24597,7 @@ function renderSubagents() {
|
|
|
23746
24597
|
box.classList.toggle("muted", !hasItems);
|
|
23747
24598
|
box.classList.toggle("has-items", hasItems);
|
|
23748
24599
|
if (!hasItems) {
|
|
23749
|
-
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."));
|
|
23750
24601
|
restoreFocus();
|
|
23751
24602
|
return;
|
|
23752
24603
|
}
|
|
@@ -23756,32 +24607,51 @@ function renderSubagents() {
|
|
|
23756
24607
|
}
|
|
23757
24608
|
|
|
23758
24609
|
async function refreshSubagents() {
|
|
23759
|
-
if (
|
|
24610
|
+
if (subagentsRefreshPromise) {
|
|
24611
|
+
subagentsRefreshQueued = true;
|
|
24612
|
+
return subagentsRefreshPromise;
|
|
24613
|
+
}
|
|
23760
24614
|
let refreshed = false;
|
|
23761
24615
|
let subagentViewsChanged = false;
|
|
23762
24616
|
let materializedTerminalViews = false;
|
|
23763
24617
|
subagentsLoading = true;
|
|
23764
24618
|
renderSubagents();
|
|
23765
|
-
|
|
23766
|
-
|
|
23767
|
-
|
|
23768
|
-
|
|
23769
|
-
|
|
23770
|
-
|
|
23771
|
-
|
|
23772
|
-
|
|
23773
|
-
|
|
23774
|
-
|
|
23775
|
-
|
|
23776
|
-
|
|
23777
|
-
|
|
23778
|
-
|
|
23779
|
-
|
|
23780
|
-
|
|
23781
|
-
|
|
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();
|
|
23782
24652
|
}
|
|
23783
|
-
|
|
23784
|
-
|
|
24653
|
+
})().then(settleRefresh, rejectRefresh);
|
|
24654
|
+
await refreshPromise;
|
|
23785
24655
|
if (refreshed && subagentAutoClearEnabled && finishedSubagentRunSelections().length) {
|
|
23786
24656
|
await clearFinishedSubagentRuns({ automatic: true });
|
|
23787
24657
|
}
|
|
@@ -33590,9 +34460,11 @@ function updateStickyUserPromptButton() {
|
|
|
33590
34460
|
const targets = userPromptTargets();
|
|
33591
34461
|
const target = findStickyUserPromptTarget(targets);
|
|
33592
34462
|
if (!target) {
|
|
34463
|
+
if (button.hidden && button.childElementCount === 0) return;
|
|
33593
34464
|
button.hidden = true;
|
|
33594
34465
|
button.removeAttribute("data-message-index");
|
|
33595
34466
|
button.removeAttribute("data-compacted");
|
|
34467
|
+
delete button.dataset.renderSignature;
|
|
33596
34468
|
button.replaceChildren();
|
|
33597
34469
|
return;
|
|
33598
34470
|
}
|
|
@@ -33601,12 +34473,16 @@ function updateStickyUserPromptButton() {
|
|
|
33601
34473
|
const isLatest = target.compacted || ordinal === targets.length;
|
|
33602
34474
|
const label = target.compacted ? "Last user prompt (compacted)" : isLatest ? "Last user prompt" : "Previous user prompt";
|
|
33603
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;
|
|
33604
34481
|
button.hidden = false;
|
|
34482
|
+
button.dataset.renderSignature = renderSignature;
|
|
33605
34483
|
button.dataset.compacted = target.compacted ? "true" : "false";
|
|
33606
|
-
if (
|
|
34484
|
+
if (messageIndex) button.dataset.messageIndex = messageIndex;
|
|
33607
34485
|
else button.removeAttribute("data-message-index");
|
|
33608
|
-
const baseTitle = target.compacted ? `Prompt was compacted; jump to compaction summary: ${target.preview}` : `Jump to ${label.toLowerCase()}: ${target.preview}`;
|
|
33609
|
-
const baseAriaLabel = target.compacted ? `Prompt was compacted; jump to compaction summary: ${target.preview}` : `Jump to ${label.toLowerCase()} (${ordinal} of ${targets.length}): ${target.preview}`;
|
|
33610
34486
|
button.title = baseTitle;
|
|
33611
34487
|
button.setAttribute("aria-label", baseAriaLabel);
|
|
33612
34488
|
const children = [
|
|
@@ -38137,6 +39013,17 @@ function createTerminalTabSessionSummaryButton(tab) {
|
|
|
38137
39013
|
function renderSessionSummaryControls() {
|
|
38138
39014
|
const setupAvailable = !!activeTabId && hasAvailableCommand("summary-setup", { tabId: activeTabId });
|
|
38139
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;
|
|
38140
39027
|
scheduleTabsRender();
|
|
38141
39028
|
}
|
|
38142
39029
|
|
|
@@ -38207,8 +39094,10 @@ function openSessionSummaryOverlay(tabId, { loading = false, focusReturnKey = ""
|
|
|
38207
39094
|
|
|
38208
39095
|
function updateSessionSummaryForTab(tabId, value, { resetProjection = false } = {}) {
|
|
38209
39096
|
if (!tabId) return null;
|
|
38210
|
-
const
|
|
39097
|
+
const previous = sessionSummaryByTab.get(tabId);
|
|
39098
|
+
const normalized = normalizeSessionSummaryClientState(value, previous, { resetProjection });
|
|
38211
39099
|
if (!normalized) return null;
|
|
39100
|
+
if (previous && tabsSnapshotSignature(previous) === tabsSnapshotSignature(normalized)) return previous;
|
|
38212
39101
|
sessionSummaryByTab.set(tabId, normalized);
|
|
38213
39102
|
renderSessionSummaryControls();
|
|
38214
39103
|
if (sessionSummaryOverlayTabId === tabId) renderSessionSummaryOverlay();
|
|
@@ -41162,6 +42051,8 @@ async function refreshState(tabContext = activeTabContext()) {
|
|
|
41162
42051
|
if (!isCurrentTabContext(tabContext)) return;
|
|
41163
42052
|
const previousState = currentState;
|
|
41164
42053
|
currentState = response.data || null;
|
|
42054
|
+
if (currentState) tabStateCache.set(tabContext.tabId, currentState);
|
|
42055
|
+
else tabStateCache.delete(tabContext.tabId);
|
|
41165
42056
|
if (latestMessages.length) {
|
|
41166
42057
|
latestMessagesSessionKey = resolveMessagesSessionKey(tabContext.tabId);
|
|
41167
42058
|
cacheMessagesForTab(tabContext.tabId, latestMessages, latestMessagesSessionKey);
|
|
@@ -41184,6 +42075,8 @@ async function refreshStats(tabContext = activeTabContext()) {
|
|
|
41184
42075
|
const response = await api("/api/stats", { tabId: tabContext.tabId });
|
|
41185
42076
|
if (!isCurrentTabContext(tabContext)) return;
|
|
41186
42077
|
latestStats = response.data || null;
|
|
42078
|
+
if (latestStats) tabStatsCache.set(tabContext.tabId, latestStats);
|
|
42079
|
+
else tabStatsCache.delete(tabContext.tabId);
|
|
41187
42080
|
renderFooter();
|
|
41188
42081
|
renderContextMeter();
|
|
41189
42082
|
renderWorkspaceDashboard();
|
|
@@ -41210,6 +42103,8 @@ async function refreshWorkspace(tabContext = activeTabContext()) {
|
|
|
41210
42103
|
}
|
|
41211
42104
|
if (!isCurrentTabContext(tabContext)) return;
|
|
41212
42105
|
latestWorkspace = nextWorkspace;
|
|
42106
|
+
if (latestWorkspace) tabWorkspaceCache.set(tabContext.tabId, latestWorkspace);
|
|
42107
|
+
else tabWorkspaceCache.delete(tabContext.tabId);
|
|
41213
42108
|
rememberServerStartCwd(nextWorkspace?.cwd);
|
|
41214
42109
|
renderFooter();
|
|
41215
42110
|
renderWorkspaceDashboard();
|
|
@@ -41275,6 +42170,8 @@ function renderNetworkStatus() {
|
|
|
41275
42170
|
const authDetail = make("div", "network-status-detail", authText);
|
|
41276
42171
|
|
|
41277
42172
|
elements.networkStatus.replaceChildren(heading, detail, list, authDetail);
|
|
42173
|
+
const remoteAuthRow = elements.remoteAuthToggle?.closest(".remote-auth-control-row");
|
|
42174
|
+
if (remoteAuthRow) remoteAuthRow.hidden = false;
|
|
41278
42175
|
elements.remoteAuthToggle.checked = !!auth.enabled;
|
|
41279
42176
|
elements.remoteAuthToggle.disabled = rebinding;
|
|
41280
42177
|
elements.remoteAuthStatus.textContent = auth.enabled
|
|
@@ -41385,6 +42282,7 @@ function restoreCachedMessagesForActiveTab() {
|
|
|
41385
42282
|
latestMessages = cached.messages;
|
|
41386
42283
|
latestMessagesSessionKey = cached.sessionKey || resolveMessagesSessionKey(activeTabId);
|
|
41387
42284
|
renderMessages(latestMessages);
|
|
42285
|
+
if (autoFollowChat) setChatScrollTopInstant(elements.chat.scrollHeight);
|
|
41388
42286
|
return true;
|
|
41389
42287
|
}
|
|
41390
42288
|
|
|
@@ -41548,19 +42446,23 @@ function populateModelSelect(models = availableModels, query = "") {
|
|
|
41548
42446
|
const previousValue = elements.modelSelect.value;
|
|
41549
42447
|
const normalizedQuery = String(query || "").trim().toLowerCase();
|
|
41550
42448
|
const matchingModels = models.filter((model) => !normalizedQuery || modelSelectOptionText(model).toLowerCase().includes(normalizedQuery));
|
|
41551
|
-
|
|
41552
|
-
|
|
41553
|
-
|
|
41554
|
-
|
|
41555
|
-
|
|
41556
|
-
|
|
41557
|
-
|
|
41558
|
-
|
|
41559
|
-
|
|
41560
|
-
|
|
41561
|
-
|
|
41562
|
-
|
|
41563
|
-
|
|
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
|
+
}
|
|
41564
42466
|
}
|
|
41565
42467
|
if (previousValue && [...elements.modelSelect.options].some((option) => option.value === previousValue)) elements.modelSelect.value = previousValue;
|
|
41566
42468
|
renderModelSearchResults(matchingModels);
|
|
@@ -42243,8 +43145,9 @@ async function refreshCommands(tabContext = activeTabContext()) {
|
|
|
42243
43145
|
// Keep results for their originating tab even when the active tab changed
|
|
42244
43146
|
// while this request was in flight. Guided Git must never borrow another
|
|
42245
43147
|
// tab's extension availability or duplicate-command alias.
|
|
43148
|
+
const previousCatalog = commandCatalogsByTab.get(tabContext.tabId);
|
|
42246
43149
|
commandCatalogsByTab.set(tabContext.tabId, catalog);
|
|
42247
|
-
scheduleTabsRender();
|
|
43150
|
+
if (tabsSnapshotSignature(previousCatalog) !== tabsSnapshotSignature(catalog)) scheduleTabsRender();
|
|
42248
43151
|
if (!isCurrentTabContext(tabContext)) return;
|
|
42249
43152
|
rawAvailableCommands = catalog.raw;
|
|
42250
43153
|
availableCommands = catalog.available;
|
|
@@ -45163,6 +46066,16 @@ if (elements.terminalTabsLayoutSelect) {
|
|
|
45163
46066
|
setTerminalTabsLayout(elements.terminalTabsLayoutSelect.value, { announce: true });
|
|
45164
46067
|
});
|
|
45165
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
|
+
}
|
|
45166
46079
|
if (elements.subagentOpenModeSelect) {
|
|
45167
46080
|
elements.subagentOpenModeSelect.addEventListener("change", () => {
|
|
45168
46081
|
setSubagentOpenMode(elements.subagentOpenModeSelect.value, { announce: true });
|
|
@@ -45270,10 +46183,16 @@ elements.sidePanelEditButton?.addEventListener("click", () => {
|
|
|
45270
46183
|
setSidePanelSectionEditMode(!sidePanelSectionEditMode);
|
|
45271
46184
|
});
|
|
45272
46185
|
elements.toggleSidePanelButton.addEventListener("click", () => {
|
|
45273
|
-
setSidePanelCollapsed(true);
|
|
46186
|
+
setSidePanelCollapsed(true, { side: "right" });
|
|
46187
|
+
});
|
|
46188
|
+
elements.toggleSidePanelLeftButton?.addEventListener("click", () => {
|
|
46189
|
+
setSidePanelCollapsed(true, { side: "left" });
|
|
45274
46190
|
});
|
|
45275
46191
|
elements.sidePanelExpandButton.addEventListener("click", () => {
|
|
45276
|
-
setSidePanelCollapsed(false, { focusPanel: true });
|
|
46192
|
+
setSidePanelCollapsed(false, { focusPanel: true, side: "right" });
|
|
46193
|
+
});
|
|
46194
|
+
elements.sidePanelLeftExpandButton?.addEventListener("click", () => {
|
|
46195
|
+
setSidePanelCollapsed(false, { focusPanel: true, side: "left" });
|
|
45277
46196
|
});
|
|
45278
46197
|
elements.sidePanelBackdrop.addEventListener("click", () => {
|
|
45279
46198
|
setSidePanelCollapsed(true);
|
|
@@ -45611,24 +46530,45 @@ window.addEventListener("offline", () => {
|
|
|
45611
46530
|
});
|
|
45612
46531
|
window.addEventListener("beforeunload", persistMobileContinuityState);
|
|
45613
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;
|
|
45614
46538
|
if (event.key === OPTIONAL_FEATURES_STORAGE_KEY) reconcileDisabledOptionalFeaturesFromStorage();
|
|
45615
46539
|
if (event.key === OPTIONAL_FEATURE_MIGRATION_DISMISS_STORAGE_KEY && optionalFeatureMigrationCompletionIsDismissed()) {
|
|
45616
46540
|
optionalFeatureRestartNotice = null;
|
|
45617
46541
|
renderOptionalFeatureMigrationSurface();
|
|
45618
46542
|
}
|
|
45619
|
-
if (event.key === SIDE_PANEL_SECTION_VISIBILITY_STORAGE_KEY) restoreSidePanelSectionVisibility();
|
|
45620
|
-
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
|
+
}
|
|
45621
46560
|
if (event.key === COMPOSER_ACTION_ORDER_STORAGE_KEY) restoreComposerActionOrder();
|
|
45622
46561
|
if (event.key === COMPOSER_ACTION_LAYOUT_STORAGE_KEY) restoreComposerActionSlotLayout();
|
|
45623
|
-
if (event.key === SIDE_PANEL_WIDTH_STORAGE_KEY) {
|
|
46562
|
+
if (event.key === SIDE_PANEL_WIDTH_STORAGE_KEY && !ignoreLegacySidePanelEvent("panelWidths", Boolean(sidePanelResizeState))) {
|
|
45624
46563
|
const width = readStoredSidePanelWidth();
|
|
45625
46564
|
if (width && !isSidePanelOverlayView()) applySidePanelWidth(width);
|
|
45626
46565
|
}
|
|
45627
46566
|
// Another same-origin tab already saved these durable fields, so receiving
|
|
45628
46567
|
// tabs only adopt the shared local cache without repeating the server write.
|
|
45629
|
-
if (event.key === SIDE_PANEL_SECTION_STORAGE_KEY) restoreSidePanelSectionState();
|
|
45630
|
-
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();
|
|
45631
46570
|
if (event.key === TERMINAL_TABS_LAYOUT_STORAGE_KEY) restoreTerminalTabsLayoutSetting();
|
|
46571
|
+
if (event.key === TERMINAL_TABS_SIDEBAR_WIDTH_STORAGE_KEY) restoreTerminalTabsSidebarWidthPreference();
|
|
45632
46572
|
if (event.key === TERMINAL_CUSTOM_GROUPS_STORAGE_KEY) {
|
|
45633
46573
|
restoreTerminalCustomGroups();
|
|
45634
46574
|
syncTerminalCustomGroupsWithTabs(tabs, { persist: false });
|
|
@@ -45648,7 +46588,7 @@ window.addEventListener("pageshow", () => reconcileDurableUiLayout());
|
|
|
45648
46588
|
document.addEventListener("visibilitychange", () => {
|
|
45649
46589
|
if (document.visibilityState === "visible") reconcileDurableUiLayout();
|
|
45650
46590
|
});
|
|
45651
|
-
window.addEventListener("resize",
|
|
46591
|
+
window.addEventListener("resize", scheduleControlDeckPresentationReconciliation, { passive: true });
|
|
45652
46592
|
window.addEventListener("keydown", (event) => {
|
|
45653
46593
|
if (event.key !== "Escape") return;
|
|
45654
46594
|
if (event.defaultPrevented) return;
|
|
@@ -45885,6 +46825,10 @@ elements.fileContextMenu?.addEventListener("click", (event) => {
|
|
|
45885
46825
|
elements.fileViewerOpenDefaultButton?.addEventListener("click", () => openPathInDefaultEditor(currentFileViewerPath()));
|
|
45886
46826
|
elements.sidePanelResizeHandle?.addEventListener("pointerdown", beginSidePanelResize);
|
|
45887
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);
|
|
45888
46832
|
elements.fileViewerResizeHandle?.addEventListener("pointerdown", beginFileViewerResize);
|
|
45889
46833
|
elements.fileViewerResizeHandle?.addEventListener("keydown", handleFileViewerResizeKeydown);
|
|
45890
46834
|
elements.fileViewerSaveButton?.addEventListener("click", () => saveActiveFileViewer());
|
|
@@ -46077,6 +47021,7 @@ clearRemovedSidePanelSectionHeightState();
|
|
|
46077
47021
|
restoreDurableUiLayoutPendingJournal();
|
|
46078
47022
|
restoreSidePanelWidthPreference();
|
|
46079
47023
|
restoreFileViewerWidthPreference();
|
|
47024
|
+
restoreTerminalTabsSidebarWidthPreference();
|
|
46080
47025
|
focusPromptInput({ defer: true });
|
|
46081
47026
|
restoreStoredSkillUsage();
|
|
46082
47027
|
restoreBusyPromptBehaviorSetting();
|
|
@@ -46108,10 +47053,12 @@ restoreToolOutputExpansionSetting();
|
|
|
46108
47053
|
restoreWorkspaceDashboardState();
|
|
46109
47054
|
restoreInterfaceDensity();
|
|
46110
47055
|
initializeTerminalHeaderTooltips();
|
|
47056
|
+
initializeControlSettingTooltips();
|
|
46111
47057
|
initializeComposerActionOrdering();
|
|
46112
47058
|
restoreSidePanelSectionOrder();
|
|
46113
47059
|
restoreSidePanelSectionVisibility();
|
|
46114
47060
|
restoreSidePanelSectionState();
|
|
47061
|
+
reconcileControlDeckHosts();
|
|
46115
47062
|
setSidePanelSectionEditMode(false);
|
|
46116
47063
|
bindSidePanelSectionToggles();
|
|
46117
47064
|
restoreSidePanelState();
|