@firstpick/pi-package-webui 0.7.4 → 0.7.5

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/public/app.js CHANGED
@@ -2,6 +2,7 @@ import { aurReviewSafePath as parsedAurReviewSafePath, parseAurReviewPayload as
2
2
  import { guidedGitReviewAvailableForTabCatalog, resolveCommandForTabCatalog, resolveRpcSlashCommandForTabCatalog } from "./guided-git-command-state.mjs";
3
3
  import { guidedGitReviewCanRequestStagedContent, guidedGitReviewHasApprovedBinding, guidedGitReviewProcessNavigationAllowed, guidedGitReviewProcessSelectionPatch, guidedGitReviewTransition, guidedGitReviewWidgetRemovalTransition } from "./guided-git-review-state.mjs";
4
4
  import { createFastOutputLiveState, createSustainedFlushScheduler, fastOutputLiveTextAndThinking, reduceFastOutputLiveEvent, seedFastOutputLiveState, shouldConsumeFastOutputLiveEvent } from "./fast-output-live.mjs";
5
+ import { addLaunchSlot, cloneLaunchSlotRoles, launchSlotRolesEqual, removeLaunchSlot, updateLaunchSlot } from "./subagent-launch-slot-state.mjs";
5
6
 
6
7
  const $ = (selector) => document.querySelector(selector);
7
8
 
@@ -102,7 +103,9 @@ const elements = {
102
103
  remoteMicStreamingConsentButton: $("#remoteMicStreamingConsentButton"),
103
104
  newSessionButton: $("#newSessionButton"),
104
105
  compactButton: $("#compactButton"),
106
+ workflowModeControls: $("#workflowModeControls"),
105
107
  workflowModeButton: $("#workflowModeButton"),
108
+ workflowOverlayOpenButton: $("#workflowOverlayOpenButton"),
106
109
  gitWorkflowButton: $("#gitWorkflowButton"),
107
110
  publishButton: $("#publishButton"),
108
111
  publishMenu: $("#publishMenu"),
@@ -231,6 +234,7 @@ const elements = {
231
234
  fileSelectionSendButton: $("#fileSelectionSendButton"),
232
235
  fileContextMenu: $("#fileContextMenu"),
233
236
  sidePanelContextMenu: $("#sidePanelContextMenu"),
237
+ sidePanelResizeHandle: $("#sidePanelResizeHandle"),
234
238
  toggleSidePanelButton: $("#toggleSidePanelButton"),
235
239
  sidePanelExpandButton: $("#sidePanelExpandButton"),
236
240
  sidePanelBackdrop: $("#sidePanelBackdrop"),
@@ -241,6 +245,20 @@ const elements = {
241
245
  subagentCountBadge: $("#subagentCountBadge"),
242
246
  subagentOpenModeSelect: $("#subagentOpenModeSelect"),
243
247
  subagentOpenModeStatus: $("#subagentOpenModeStatus"),
248
+ subagentLaunchSlots: $("#subagentLaunchSlots"),
249
+ subagentLaunchSlotsSummaryStatus: $("#subagentLaunchSlotsSummaryStatus"),
250
+ subagentLaunchSlotsRefresh: $("#subagentLaunchSlotsRefresh"),
251
+ subagentLaunchSlotScope: $("#subagentLaunchSlotScope"),
252
+ subagentLaunchSlotScopeStatus: $("#subagentLaunchSlotScopeStatus"),
253
+ subagentLaunchSlotsInherit: $("#subagentLaunchSlotsInherit"),
254
+ subagentLaunchSlotsStatus: $("#subagentLaunchSlotsStatus"),
255
+ subagentLaunchSlotRoles: $("#subagentLaunchSlotRoles"),
256
+ subagentLaunchSlotsSave: $("#subagentLaunchSlotsSave"),
257
+ subagentLaunchSlotsDirty: $("#subagentLaunchSlotsDirty"),
258
+ subagentLaunchSlotsReloadActions: $("#subagentLaunchSlotsReloadActions"),
259
+ subagentLaunchSlotsReload: $("#subagentLaunchSlotsReload"),
260
+ subagentLaunchSlotsLater: $("#subagentLaunchSlotsLater"),
261
+ subagentLaunchSlotsAnnouncer: $("#subagentLaunchSlotsAnnouncer"),
244
262
  queueBox: $("#queueBox"),
245
263
  queueCountBadge: $("#queueCountBadge"),
246
264
  createPromptListButton: $("#createPromptListButton"),
@@ -373,6 +391,7 @@ let fileContextMenuState = null;
373
391
  let sidePanelContextMenuState = null;
374
392
  let fileTreeDragState = null;
375
393
  let fileViewerResizeState = null;
394
+ let sidePanelResizeState = null;
376
395
  let fileTreeSearchTimer = null;
377
396
  let fileTreeSearchRequestSerial = 0;
378
397
  let tabActivities = new Map();
@@ -534,6 +553,17 @@ let subagentOpenMode = "overlay";
534
553
  const subagentTerminalViews = new Map();
535
554
  let activeSubagentTerminalId = null;
536
555
  let subagentTerminalRefreshTimer = null;
556
+ let subagentLaunchSlotConfig = null;
557
+ let subagentLaunchSlotConfigTabId = null;
558
+ let subagentLaunchSlotDraft = null;
559
+ let subagentLaunchSlotScope = "user";
560
+ let subagentLaunchSlotLoading = false;
561
+ let subagentLaunchSlotSaving = false;
562
+ let subagentLaunchSlotError = "";
563
+ let subagentLaunchSlotRequestSerial = 0;
564
+ let subagentLaunchSlotReloadRequired = false;
565
+ const subagentLaunchSlotReloadTabs = new Set();
566
+ let subagentLaunchSlotFocusTarget = null;
537
567
  let backendOffline = false;
538
568
  let serverRestartInProgress = false;
539
569
  let updateRequestInProgress = false;
@@ -592,6 +622,8 @@ let liveTodoProgressPendingText = "";
592
622
  let liveTodoProgressPendingTabId = null;
593
623
  let lastChatProgrammaticScrollAt = 0;
594
624
  let chatUserScrollIntentUntil = 0;
625
+ let chatUserScrollAwayIntentUntil = 0;
626
+ let chatLastTouchClientY = null;
595
627
  let mobileFooterExpanded = false;
596
628
  let footerModelPickerOpen = false;
597
629
  let footerThinkingPickerOpen = false;
@@ -758,6 +790,9 @@ const WORKSPACE_DASHBOARD_STORAGE_KEY = "pi-webui-workspace-dashboard-collapsed"
758
790
  const FILE_VIEWER_WIDTH_STORAGE_KEY = "pi-webui-file-viewer-width";
759
791
  const FILE_VIEWER_WIDTH_DEFAULT_PX = 520;
760
792
  const FILE_VIEWER_WIDTH_MIN_PX = 384;
793
+ const SIDE_PANEL_WIDTH_STORAGE_KEY = "pi-webui-side-panel-width";
794
+ const SIDE_PANEL_WIDTH_DEFAULT_PX = 384;
795
+ const SIDE_PANEL_WIDTH_MIN_PX = 320;
761
796
  const FILE_VIEWER_CONTEXT_RADIUS_LINES = 6;
762
797
  const FILE_TREE_ROOT_PATH = "";
763
798
  const FILE_TREE_DRAG_MIME = "application/x-pi-webui-file-path";
@@ -848,11 +883,13 @@ const featureCategoryByTab = new Map();
848
883
  const widgets = new Map();
849
884
  const widgetsByTab = new Map();
850
885
  const todoProgressWidgetExpandedByTab = new Map();
886
+ const compactThinkingDisclosureStateByTab = new Map();
851
887
  const todoProgressGoalByTab = new Map();
852
888
  const todoProgressSignatureByTab = new Map();
853
889
  const releaseNpmOutputExpandedByTab = new Map();
854
890
  const workflowTerminalScrollByTab = new Map();
855
891
  const workflowSubprocessMinimizedByTab = new Set();
892
+ const workflowOverlayMinimizedByTab = new Set();
856
893
  const appRunnerDataByTab = new Map();
857
894
  const conversationModeByTab = new Map();
858
895
  const workflowModeByTab = new Map();
@@ -3094,6 +3131,8 @@ function setSidePanelCollapsed(collapsed, { persist = true, focusPanel = false }
3094
3131
  elements.toggleSidePanelButton.setAttribute("aria-label", collapsed ? "Expand side panel" : "Collapse side panel");
3095
3132
  elements.sidePanelExpandButton.setAttribute("aria-expanded", collapsed ? "false" : "true");
3096
3133
  syncMobileSidePanelState(collapsed);
3134
+ updateSidePanelResizeHandle();
3135
+ requestAnimationFrame(syncResizablePanelWidthsForViewport);
3097
3136
  if (collapsed) closeSidePanelContextMenu({ returnFocus: false });
3098
3137
 
3099
3138
  if (!collapsed && focusPanel && isSidePanelOverlayView()) {
@@ -5071,6 +5110,42 @@ function workflowModeCommandName() {
5071
5110
  return resolveAvailableCommandName("workflow", { rpcOnly: true }) || "";
5072
5111
  }
5073
5112
 
5113
+ function workflowOverlayHasContent() {
5114
+ if (!isOptionalFeatureEnabled("workflows")) return false;
5115
+ const inspector = activeWorkflowInspectorPayload();
5116
+ if (inspector?.runs?.length) return true;
5117
+ return !!parseWorkflowSubprocessPayload(getWidgetLines("workflow:subprocess"));
5118
+ }
5119
+
5120
+ function workflowOverlayIsMinimized() {
5121
+ return Boolean(activeTabId && workflowOverlayMinimizedByTab.has(activeTabId));
5122
+ }
5123
+
5124
+ function renderWorkflowOverlayControls() {
5125
+ const openAvailable = workflowOverlayHasContent() && workflowOverlayIsMinimized();
5126
+ if (elements.workflowOverlayOpenButton) elements.workflowOverlayOpenButton.hidden = !openAvailable;
5127
+ if (elements.workflowModeControls) {
5128
+ elements.workflowModeControls.hidden = Boolean(elements.workflowModeButton?.hidden) && !openAvailable;
5129
+ elements.workflowModeControls.classList.toggle("has-open-control", openAvailable);
5130
+ }
5131
+ }
5132
+
5133
+ function setWorkflowOverlayMinimized(minimized) {
5134
+ if (!activeTabId || !workflowOverlayHasContent()) return;
5135
+ const tabId = activeTabId;
5136
+ if (minimized) workflowOverlayMinimizedByTab.add(tabId);
5137
+ else workflowOverlayMinimizedByTab.delete(tabId);
5138
+ renderWidgets();
5139
+ renderWorkflowModeControls();
5140
+ requestAnimationFrame(() => {
5141
+ if (activeTabId !== tabId) return;
5142
+ const focusTarget = minimized
5143
+ ? elements.workflowOverlayOpenButton
5144
+ : elements.widgetArea.querySelector(".workflow-overlay-close-button");
5145
+ focusTarget?.focus({ preventScroll: true });
5146
+ });
5147
+ }
5148
+
5074
5149
  function renderWorkflowModeControls() {
5075
5150
  const mode = activeWorkflowMode();
5076
5151
  const commandName = workflowModeCommandName();
@@ -5092,6 +5167,7 @@ function renderWorkflowModeControls() {
5092
5167
  : "Workflow Mode is unavailable because the /workflow command is not loaded.";
5093
5168
  applyStyledTooltip(elements.workflowModeButton, tooltip, { ariaLabel: true, align: "start" });
5094
5169
  }
5170
+ renderWorkflowOverlayControls();
5095
5171
 
5096
5172
  if (elements.workflowModeChip) {
5097
5173
  elements.workflowModeChip.hidden = !active;
@@ -6531,17 +6607,10 @@ function fileTreeOverflowButton(entry) {
6531
6607
  return button;
6532
6608
  }
6533
6609
 
6534
- function fileTreeExpander(entry, expanded = false, { search = false } = {}) {
6535
- const button = make("button", "file-tree-expander", expanded ? "▾" : "▸");
6536
- button.type = "button";
6537
- button.setAttribute("aria-label", `${expanded ? "Collapse" : "Expand"} ${entry.name || fileDisplayName(entry.path)}`);
6538
- button.setAttribute("aria-expanded", expanded ? "true" : "false");
6539
- button.addEventListener("click", (event) => {
6540
- event.stopPropagation();
6541
- if (search) revealFileTreeEntry(entry).catch((error) => addEvent(error.message || String(error), "error"));
6542
- else toggleFileTreeDirectory(entry.path).catch((error) => addEvent(error.message || String(error), "error"));
6543
- });
6544
- return button;
6610
+ function fileTreeExpander(expanded = false) {
6611
+ const arrow = make("span", "file-tree-expander", expanded ? "▾" : "▸");
6612
+ arrow.setAttribute("aria-hidden", "true");
6613
+ return arrow;
6545
6614
  }
6546
6615
 
6547
6616
  function appendFileSearchEntry(parent, entry) {
@@ -6558,6 +6627,10 @@ function appendFileSearchEntry(parent, entry) {
6558
6627
  button.style.setProperty("--file-tree-depth", "0");
6559
6628
  button.setAttribute("role", "treeitem");
6560
6629
  button.setAttribute("aria-selected", fileTreeState.selectedPath === path ? "true" : "false");
6630
+ if (isDirectory) {
6631
+ button.setAttribute("aria-expanded", "false");
6632
+ button.setAttribute("aria-label", `Expand ${entry.name || fileDisplayName(path)}`);
6633
+ }
6561
6634
  button.title = [path || ".", fileTreeGitStatusTitle(gitStatus), entry.error || ""].filter(Boolean).join("\n");
6562
6635
  const label = make("span", "file-tree-search-label");
6563
6636
  label.append(
@@ -6565,6 +6638,7 @@ function appendFileSearchEntry(parent, entry) {
6565
6638
  make("span", "file-tree-search-path", path || "."),
6566
6639
  );
6567
6640
  button.append(
6641
+ isDirectory ? fileTreeExpander(false) : make("span", "file-tree-expander-spacer"),
6568
6642
  make("span", "file-tree-icon", fileEntryIcon(entry)),
6569
6643
  label,
6570
6644
  );
@@ -6576,11 +6650,11 @@ function appendFileSearchEntry(parent, entry) {
6576
6650
  button.addEventListener("click", () => {
6577
6651
  fileTreeState.selectedPath = path;
6578
6652
  if (entry.type === "file") openFileInViewer(path);
6579
- else renderFileTree();
6653
+ else revealFileTreeEntry(entry).catch((error) => addEvent(error.message || String(error), "error"));
6580
6654
  });
6581
6655
  button.addEventListener("contextmenu", (event) => showFileContextMenu(event, entry));
6582
6656
  bindFileTreeDragAndDrop(button, item, entry);
6583
- item.append(isDirectory ? fileTreeExpander(entry, false, { search: true }) : make("span", "file-tree-expander-spacer"), button, fileTreeOverflowButton(entry));
6657
+ item.append(button, fileTreeOverflowButton(entry));
6584
6658
  parent.append(item);
6585
6659
  }
6586
6660
 
@@ -6623,9 +6697,13 @@ function appendFileTreeEntry(parent, entry, depth = 0) {
6623
6697
  button.style.setProperty("--file-tree-depth", String(depth));
6624
6698
  button.setAttribute("role", "treeitem");
6625
6699
  button.setAttribute("aria-selected", fileTreeState.selectedPath === path ? "true" : "false");
6626
- if (isDirectory) button.setAttribute("aria-expanded", expanded ? "true" : "false");
6700
+ if (isDirectory) {
6701
+ button.setAttribute("aria-expanded", expanded ? "true" : "false");
6702
+ button.setAttribute("aria-label", `${expanded ? "Collapse" : "Expand"} ${entry.name || fileDisplayName(path)}`);
6703
+ }
6627
6704
  button.title = [path || ".", fileTreeGitStatusTitle(gitStatus), entry.error || ""].filter(Boolean).join("\n");
6628
6705
  button.append(
6706
+ isDirectory ? fileTreeExpander(expanded) : make("span", "file-tree-expander-spacer"),
6629
6707
  make("span", `file-tree-icon ${isDirectory && expanded ? "expanded" : ""}`, loading ? "…" : fileEntryIcon(entry)),
6630
6708
  make("span", "file-tree-name", entry.name || fileDisplayName(path)),
6631
6709
  );
@@ -6636,11 +6714,11 @@ function appendFileTreeEntry(parent, entry, depth = 0) {
6636
6714
  button.addEventListener("click", () => {
6637
6715
  fileTreeState.selectedPath = path;
6638
6716
  if (entry.type === "file") openFileInViewer(path);
6639
- else renderFileTree();
6717
+ else toggleFileTreeDirectory(path).catch((error) => addEvent(error.message || String(error), "error"));
6640
6718
  });
6641
6719
  button.addEventListener("contextmenu", (event) => showFileContextMenu(event, entry));
6642
6720
  bindFileTreeDragAndDrop(button, item, entry);
6643
- item.append(isDirectory ? fileTreeExpander(entry, expanded) : make("span", "file-tree-expander-spacer"), button, fileTreeOverflowButton(entry));
6721
+ item.append(button, fileTreeOverflowButton(entry));
6644
6722
  if (isDirectory && expanded) {
6645
6723
  const children = fileTreeState.entriesByPath.get(path) || [];
6646
6724
  const childList = make("ul", "file-tree-list");
@@ -7243,6 +7321,133 @@ async function moveFileTreeEntry(entry = fileContextMenuState?.entry) {
7243
7321
  await moveFileTreeEntryToDestination(entry, destinationPath, { confirmMove: true });
7244
7322
  }
7245
7323
 
7324
+ function readStoredSidePanelWidth() {
7325
+ try {
7326
+ const width = Number.parseFloat(localStorage.getItem(SIDE_PANEL_WIDTH_STORAGE_KEY) || "");
7327
+ return Number.isFinite(width) && width >= SIDE_PANEL_WIDTH_MIN_PX ? width : null;
7328
+ } catch {
7329
+ return null;
7330
+ }
7331
+ }
7332
+
7333
+ function persistSidePanelWidth(width) {
7334
+ try {
7335
+ localStorage.setItem(SIDE_PANEL_WIDTH_STORAGE_KEY, String(Math.round(width)));
7336
+ } catch {
7337
+ // Ignore storage failures; resizing should still work for this page load.
7338
+ }
7339
+ }
7340
+
7341
+ function sidePanelMaxWidth() {
7342
+ const layout = document.querySelector(".layout");
7343
+ const layoutRect = layout?.getBoundingClientRect?.();
7344
+ const layoutWidth = layoutRect?.width || window.innerWidth || SIDE_PANEL_WIDTH_DEFAULT_PX;
7345
+ const layoutStyle = layout ? getComputedStyle(layout) : null;
7346
+ const gap = Number.parseFloat(layoutStyle?.columnGap || layoutStyle?.gap || "0") || 0;
7347
+ const horizontalPadding = (Number.parseFloat(layoutStyle?.paddingLeft || "0") || 0) + (Number.parseFloat(layoutStyle?.paddingRight || "0") || 0);
7348
+ const contentWidth = Math.max(0, layoutWidth - horizontalPadding);
7349
+ const fileViewerVisible = !!activeFileViewer && elements.fileViewerPane && getComputedStyle(elements.fileViewerPane).display !== "none";
7350
+ const fileViewerWidth = fileViewerVisible ? elements.fileViewerPane.getBoundingClientRect().width : 0;
7351
+ const splitOpen = document.body.classList.contains("terminal-split-open");
7352
+ const primaryMinWidth = splitOpen ? 560 : 320;
7353
+ const otherColumnCount = 1 + (splitOpen ? 1 : 0) + (fileViewerVisible ? 1 : 0);
7354
+ const available = contentWidth - fileViewerWidth - primaryMinWidth - (gap * otherColumnCount);
7355
+ return Math.max(SIDE_PANEL_WIDTH_MIN_PX, Math.min(Math.floor(contentWidth * 0.72), Math.floor(available)));
7356
+ }
7357
+
7358
+ function clampSidePanelWidth(width) {
7359
+ const number = Number(width);
7360
+ const max = sidePanelMaxWidth();
7361
+ const fallback = readStoredSidePanelWidth() || SIDE_PANEL_WIDTH_DEFAULT_PX;
7362
+ return Math.max(SIDE_PANEL_WIDTH_MIN_PX, Math.min(max, Number.isFinite(number) ? number : fallback));
7363
+ }
7364
+
7365
+ function currentSidePanelWidth() {
7366
+ const width = elements.sidePanel?.getBoundingClientRect?.().width;
7367
+ return Number.isFinite(width) && width > 0 ? width : readStoredSidePanelWidth() || SIDE_PANEL_WIDTH_DEFAULT_PX;
7368
+ }
7369
+
7370
+ function updateSidePanelResizeHandle(width = currentSidePanelWidth()) {
7371
+ const handle = elements.sidePanelResizeHandle;
7372
+ if (!handle) return;
7373
+ const resizeAvailable = !isSidePanelOverlayView() && !document.body.classList.contains("side-panel-collapsed");
7374
+ handle.hidden = !resizeAvailable;
7375
+ handle.setAttribute("aria-valuemin", String(SIDE_PANEL_WIDTH_MIN_PX));
7376
+ handle.setAttribute("aria-valuemax", String(sidePanelMaxWidth()));
7377
+ handle.setAttribute("aria-valuenow", String(Math.round(width)));
7378
+ handle.setAttribute("aria-valuetext", `${Math.round(width)} pixels wide`);
7379
+ }
7380
+
7381
+ function applySidePanelWidth(width, { persist = false } = {}) {
7382
+ const clamped = clampSidePanelWidth(width);
7383
+ document.documentElement.style.setProperty("--side-panel-width", `${Math.round(clamped)}px`);
7384
+ updateSidePanelResizeHandle(clamped);
7385
+ if (persist) persistSidePanelWidth(clamped);
7386
+ return clamped;
7387
+ }
7388
+
7389
+ function restoreSidePanelWidthPreference() {
7390
+ const width = readStoredSidePanelWidth();
7391
+ if (width) document.documentElement.style.setProperty("--side-panel-width", `${Math.round(width)}px`);
7392
+ if (!isSidePanelOverlayView()) applySidePanelWidth(width || SIDE_PANEL_WIDTH_DEFAULT_PX);
7393
+ else updateSidePanelResizeHandle(width || SIDE_PANEL_WIDTH_DEFAULT_PX);
7394
+ }
7395
+
7396
+ function beginSidePanelResize(event) {
7397
+ if (isSidePanelOverlayView() || document.body.classList.contains("side-panel-collapsed")) return;
7398
+ if (event.button !== undefined && event.button !== 0) return;
7399
+ event.preventDefault();
7400
+ const startWidth = currentSidePanelWidth();
7401
+ sidePanelResizeState = { pointerId: event.pointerId, startX: event.clientX, startWidth, width: startWidth };
7402
+ document.body.classList.add("side-panel-resizing");
7403
+ elements.sidePanelResizeHandle?.setPointerCapture?.(event.pointerId);
7404
+ window.addEventListener("pointermove", updateSidePanelResize, { passive: false });
7405
+ window.addEventListener("pointerup", finishSidePanelResize, { passive: false });
7406
+ window.addEventListener("pointercancel", finishSidePanelResize, { passive: false });
7407
+ }
7408
+
7409
+ function updateSidePanelResize(event) {
7410
+ const state = sidePanelResizeState;
7411
+ if (!state || (event.pointerId !== undefined && event.pointerId !== state.pointerId)) return;
7412
+ event.preventDefault();
7413
+ state.width = applySidePanelWidth(state.startWidth + (state.startX - event.clientX));
7414
+ }
7415
+
7416
+ function finishSidePanelResize(event) {
7417
+ const state = sidePanelResizeState;
7418
+ if (!state || (event.pointerId !== undefined && event.pointerId !== state.pointerId)) return;
7419
+ event.preventDefault?.();
7420
+ elements.sidePanelResizeHandle?.releasePointerCapture?.(state.pointerId);
7421
+ window.removeEventListener("pointermove", updateSidePanelResize);
7422
+ window.removeEventListener("pointerup", finishSidePanelResize);
7423
+ window.removeEventListener("pointercancel", finishSidePanelResize);
7424
+ document.body.classList.remove("side-panel-resizing");
7425
+ applySidePanelWidth(state.width, { persist: true });
7426
+ sidePanelResizeState = null;
7427
+ }
7428
+
7429
+ function handleSidePanelResizeKeydown(event) {
7430
+ if (isSidePanelOverlayView() || document.body.classList.contains("side-panel-collapsed")) return;
7431
+ const step = event.shiftKey ? 80 : 24;
7432
+ const current = currentSidePanelWidth();
7433
+ let next = current;
7434
+ if (event.key === "ArrowLeft") next = current + step;
7435
+ else if (event.key === "ArrowRight") next = current - step;
7436
+ else if (event.key === "Home") next = SIDE_PANEL_WIDTH_MIN_PX;
7437
+ else if (event.key === "End") next = sidePanelMaxWidth();
7438
+ else return;
7439
+ event.preventDefault();
7440
+ applySidePanelWidth(next, { persist: true });
7441
+ }
7442
+
7443
+ function syncSidePanelWidthForViewport() {
7444
+ if (isSidePanelOverlayView() || document.body.classList.contains("side-panel-collapsed")) {
7445
+ updateSidePanelResizeHandle();
7446
+ return;
7447
+ }
7448
+ applySidePanelWidth(currentSidePanelWidth());
7449
+ }
7450
+
7246
7451
  function readStoredFileViewerWidth() {
7247
7452
  try {
7248
7453
  const width = Number.parseFloat(localStorage.getItem(FILE_VIEWER_WIDTH_STORAGE_KEY) || "");
@@ -7371,6 +7576,11 @@ function syncFileViewerWidthForViewport() {
7371
7576
  applyFileViewerWidth(currentFileViewerWidth());
7372
7577
  }
7373
7578
 
7579
+ function syncResizablePanelWidthsForViewport() {
7580
+ syncSidePanelWidthForViewport();
7581
+ syncFileViewerWidthForViewport();
7582
+ }
7583
+
7374
7584
  async function openFileTreeEntryInWebui(entry = fileContextMenuState?.entry) {
7375
7585
  if (!entry) return;
7376
7586
  const path = normalizeFileTreePath(entry.path || "");
@@ -7401,6 +7611,7 @@ function updateFileViewerUi() {
7401
7611
  const open = !!activeFileViewer;
7402
7612
  document.body.classList.toggle("file-viewer-open", open);
7403
7613
  if (elements.fileViewerPane) elements.fileViewerPane.hidden = !open;
7614
+ requestAnimationFrame(syncResizablePanelWidthsForViewport);
7404
7615
  updateFileViewerResizeHandle();
7405
7616
  if (!open) return;
7406
7617
  if (!isSidePanelOverlayView()) applyFileViewerWidth(currentFileViewerWidth());
@@ -7567,6 +7778,7 @@ function closeFileViewer() {
7567
7778
  document.body.classList.remove("file-viewer-open");
7568
7779
  updateFileViewerResizeHandle();
7569
7780
  if (elements.fileViewerPane) elements.fileViewerPane.hidden = true;
7781
+ requestAnimationFrame(syncResizablePanelWidthsForViewport);
7570
7782
  if (elements.fileViewerOpenDefaultButton) elements.fileViewerOpenDefaultButton.dataset.path = "";
7571
7783
  if (elements.fileViewerEditor) {
7572
7784
  elements.fileViewerEditor.value = "";
@@ -7754,6 +7966,8 @@ function syncTabMetadata(nextTabs = []) {
7754
7966
  workflowInspectorSelectionByTab.delete(tabId);
7755
7967
  workflowInspectorMinimizedByTab.delete(tabId);
7756
7968
  workflowSubprocessMinimizedByTab.delete(tabId);
7969
+ workflowOverlayMinimizedByTab.delete(tabId);
7970
+ compactThinkingDisclosureStateByTab.delete(tabId);
7757
7971
  remoteMicConsentTabs.delete(tabId);
7758
7972
  if (voiceConversationTabId === tabId) stopVoiceConversationLoop();
7759
7973
  clearGitWorkflowForTab(tabId);
@@ -9291,6 +9505,11 @@ async function switchTab(tabId) {
9291
9505
  connectEvents(tabContext);
9292
9506
  await refreshAll(tabContext);
9293
9507
  if (isCurrentTabContext(tabContext)) markTabOutputSeen();
9508
+ if (!subagentLaunchSlotDraftIsDirty()) {
9509
+ loadSubagentLaunchSlotConfig({ tabId }).catch(() => {});
9510
+ } else {
9511
+ renderSubagentLaunchSlots();
9512
+ }
9294
9513
  }
9295
9514
 
9296
9515
  function currentDirectoryForNewTab() {
@@ -9313,6 +9532,7 @@ function updateTerminalSplitUi() {
9313
9532
  const canShowSplit = !!tab && !embeddedSplitMode && !isSidePanelOverlayView();
9314
9533
  document.body.classList.toggle("terminal-split-open", canShowSplit);
9315
9534
  if (elements.terminalSplitShell) elements.terminalSplitShell.hidden = !canShowSplit;
9535
+ requestAnimationFrame(syncResizablePanelWidthsForViewport);
9316
9536
  if (elements.splitTabButton) {
9317
9537
  elements.splitTabButton.disabled = embeddedSplitMode || isSidePanelOverlayView() || !activeTab();
9318
9538
  elements.splitTabButton.setAttribute("aria-pressed", canShowSplit ? "true" : "false");
@@ -9560,6 +9780,9 @@ async function initializeTabs() {
9560
9780
  if (activeTabId) {
9561
9781
  await refreshAll(tabContext);
9562
9782
  if (isCurrentTabContext(tabContext)) markTabOutputSeen();
9783
+ if (!subagentLaunchSlotDraftIsDirty() || subagentLaunchSlotConfigTabId !== activeTabId) {
9784
+ loadSubagentLaunchSlotConfig().catch(() => {});
9785
+ }
9563
9786
  }
9564
9787
  }
9565
9788
 
@@ -16139,6 +16362,417 @@ function initializeSubagents() {
16139
16362
  refreshSubagents().finally(() => scheduleRefreshSubagents());
16140
16363
  }
16141
16364
 
16365
+ function subagentLaunchSlotLimits() {
16366
+ return {
16367
+ slotsPerRole: Number(subagentLaunchSlotConfig?.limits?.slotsPerRole) || 8,
16368
+ totalSlots: Number(subagentLaunchSlotConfig?.limits?.totalSlots) || 32,
16369
+ };
16370
+ }
16371
+
16372
+ function subagentLaunchSlotDraftRoles() {
16373
+ return subagentLaunchSlotDraft || subagentLaunchSlotConfig?.roles || {};
16374
+ }
16375
+
16376
+ function subagentLaunchSlotDraftIsDirty() {
16377
+ return !!subagentLaunchSlotConfig && !!subagentLaunchSlotDraft
16378
+ && !launchSlotRolesEqual(subagentLaunchSlotDraft, subagentLaunchSlotConfig.roles || {});
16379
+ }
16380
+
16381
+ function subagentLaunchSlotModelKey(model) {
16382
+ return model?.provider && model?.id ? `${model.provider}/${model.id}` : "";
16383
+ }
16384
+
16385
+ function subagentLaunchSlotModelsByKey() {
16386
+ return new Map((Array.isArray(subagentLaunchSlotConfig?.models) ? subagentLaunchSlotConfig.models : [])
16387
+ .map((model) => [subagentLaunchSlotModelKey(model), model])
16388
+ .filter(([key]) => key));
16389
+ }
16390
+
16391
+ function subagentLaunchSlotThinkingForModel(model) {
16392
+ const levels = subagentLaunchSlotConfig?.modelThinkingLevels?.[model];
16393
+ return Array.isArray(levels) ? levels : [];
16394
+ }
16395
+
16396
+ function subagentLaunchSlotTotal(roles = subagentLaunchSlotDraftRoles()) {
16397
+ return Object.values(roles).reduce((total, slots) => total + (Array.isArray(slots) ? slots.length : 0), 0);
16398
+ }
16399
+
16400
+ function newSubagentLaunchSlotId(roles) {
16401
+ const used = new Set(Object.values(roles).flatMap((slots) => (Array.isArray(slots) ? slots : []).map((slot) => slot?.id)));
16402
+ for (let attempt = 0; attempt < 12; attempt++) {
16403
+ const token = globalThis.crypto?.randomUUID?.() || `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
16404
+ const id = `slot-${token}`;
16405
+ if (!used.has(id)) return id;
16406
+ }
16407
+ return "";
16408
+ }
16409
+
16410
+ function setSubagentLaunchSlotAnnouncement(message = "") {
16411
+ if (elements.subagentLaunchSlotsAnnouncer) elements.subagentLaunchSlotsAnnouncer.textContent = message;
16412
+ }
16413
+
16414
+ function focusSubagentLaunchSlotControl() {
16415
+ const target = subagentLaunchSlotFocusTarget;
16416
+ subagentLaunchSlotFocusTarget = null;
16417
+ if (!target || !elements.subagentLaunchSlotRoles) return;
16418
+ requestAnimationFrame(() => {
16419
+ const control = [...elements.subagentLaunchSlotRoles.querySelectorAll("select[data-launch-slot-role]")]
16420
+ .find((candidate) => candidate.dataset.launchSlotRole === target.roleId
16421
+ && candidate.dataset.launchSlotId === target.slotId
16422
+ && candidate.dataset.launchSlotControl === target.control);
16423
+ control?.focus();
16424
+ });
16425
+ }
16426
+
16427
+ function subagentLaunchSlotOption(value, text, { disabled = false } = {}) {
16428
+ const option = document.createElement("option");
16429
+ option.value = value || "";
16430
+ option.textContent = text;
16431
+ option.disabled = disabled;
16432
+ return option;
16433
+ }
16434
+
16435
+ function renderSubagentLaunchSlotCard(role, slots) {
16436
+ const limits = subagentLaunchSlotLimits();
16437
+ const modelsByKey = subagentLaunchSlotModelsByKey();
16438
+ const roleId = String(role?.id || "");
16439
+ const card = make("section", "subagent-launch-slot-role");
16440
+ card.setAttribute("aria-labelledby", `subagent-launch-slot-role-${roleId}`);
16441
+ const header = make("header", "subagent-launch-slot-role-header");
16442
+ const heading = make("div", "subagent-launch-slot-role-heading");
16443
+ heading.append(
16444
+ make("h4", undefined, role?.title || roleId),
16445
+ make("p", undefined, role?.purpose || "Configure launch-slot defaults for this role."),
16446
+ );
16447
+ heading.querySelector("h4")?.setAttribute("id", `subagent-launch-slot-role-${roleId}`);
16448
+ header.append(heading, make("span", "subagent-launch-slot-count", `${slots.length}/${limits.slotsPerRole} slots`));
16449
+ card.append(header);
16450
+
16451
+ const list = make("div", "subagent-launch-slot-list");
16452
+ for (const [index, slot] of slots.entries()) {
16453
+ const ordinal = index + 1;
16454
+ const slotLabel = `${role?.title || roleId} slot ${ordinal}`;
16455
+ const row = make("section", "subagent-launch-slot-row");
16456
+ row.setAttribute("aria-label", slotLabel);
16457
+ const rowHeader = make("div", "subagent-launch-slot-row-header");
16458
+ rowHeader.append(make("strong", undefined, `Slot ${ordinal}`), make("span", "subagent-launch-slot-id", slot.id));
16459
+ row.append(rowHeader);
16460
+
16461
+ const controls = make("div", "subagent-launch-slot-controls");
16462
+ const modelField = make("label", "subagent-launch-slot-field");
16463
+ const modelId = `subagent-launch-slot-model-${roleId}-${slot.id}`;
16464
+ modelField.append(make("span", undefined, "Model"));
16465
+ const modelSelect = document.createElement("select");
16466
+ modelSelect.id = modelId;
16467
+ modelSelect.dataset.launchSlotRole = roleId;
16468
+ modelSelect.dataset.launchSlotId = slot.id;
16469
+ modelSelect.dataset.launchSlotControl = "model";
16470
+ modelSelect.setAttribute("aria-label", `Model for ${slotLabel}`);
16471
+ modelSelect.append(subagentLaunchSlotOption("", "Default / inherit"));
16472
+ for (const [modelKey, model] of modelsByKey) {
16473
+ modelSelect.append(subagentLaunchSlotOption(modelKey, model?.name ? `${modelKey} · ${model.name}` : modelKey));
16474
+ }
16475
+ if (slot.model && !modelsByKey.has(slot.model)) {
16476
+ modelSelect.append(subagentLaunchSlotOption(slot.model, `Unavailable: ${slot.model}`, { disabled: true }));
16477
+ }
16478
+ modelSelect.value = slot.model || "";
16479
+ modelSelect.disabled = subagentLaunchSlotLoading || subagentLaunchSlotSaving;
16480
+ modelSelect.addEventListener("change", () => {
16481
+ const model = modelSelect.value || null;
16482
+ const thinking = model && subagentLaunchSlotThinkingForModel(model).includes(slot.thinking) ? slot.thinking : null;
16483
+ subagentLaunchSlotDraft = updateLaunchSlot(subagentLaunchSlotDraftRoles(), roleId, slot.id, { model, thinking });
16484
+ subagentLaunchSlotError = "";
16485
+ subagentLaunchSlotFocusTarget = { roleId, slotId: slot.id, control: "model" };
16486
+ renderSubagentLaunchSlots();
16487
+ });
16488
+ modelField.append(modelSelect);
16489
+
16490
+ const thinkingField = make("label", "subagent-launch-slot-field");
16491
+ const thinkingId = `subagent-launch-slot-thinking-${roleId}-${slot.id}`;
16492
+ thinkingField.append(make("span", undefined, "Thinking"));
16493
+ const thinkingSelect = document.createElement("select");
16494
+ thinkingSelect.id = thinkingId;
16495
+ thinkingSelect.dataset.launchSlotRole = roleId;
16496
+ thinkingSelect.dataset.launchSlotId = slot.id;
16497
+ thinkingSelect.dataset.launchSlotControl = "thinking";
16498
+ thinkingSelect.setAttribute("aria-label", `Thinking for ${slotLabel}`);
16499
+ thinkingSelect.append(subagentLaunchSlotOption("", "Default / inherit"));
16500
+ const supportedThinking = slot.model ? subagentLaunchSlotThinkingForModel(slot.model) : [];
16501
+ for (const thinking of supportedThinking) thinkingSelect.append(subagentLaunchSlotOption(thinking, thinking));
16502
+ if (slot.thinking && !supportedThinking.includes(slot.thinking)) {
16503
+ thinkingSelect.append(subagentLaunchSlotOption(slot.thinking, `Unavailable: ${slot.thinking}`, { disabled: true }));
16504
+ }
16505
+ thinkingSelect.value = slot.thinking || "";
16506
+ thinkingSelect.disabled = !slot.model || subagentLaunchSlotLoading || subagentLaunchSlotSaving || !modelsByKey.has(slot.model);
16507
+ thinkingSelect.addEventListener("change", () => {
16508
+ subagentLaunchSlotDraft = updateLaunchSlot(subagentLaunchSlotDraftRoles(), roleId, slot.id, { thinking: thinkingSelect.value || null });
16509
+ subagentLaunchSlotError = "";
16510
+ subagentLaunchSlotFocusTarget = { roleId, slotId: slot.id, control: "thinking" };
16511
+ renderSubagentLaunchSlots();
16512
+ });
16513
+ thinkingField.append(thinkingSelect);
16514
+ controls.append(modelField, thinkingField);
16515
+ row.append(controls);
16516
+ const metadata = slot.model
16517
+ ? `${slot.model}${slot.thinking ? ` · ${slot.thinking}` : " · thinking default"}`
16518
+ : "Inherits the model and thinking default.";
16519
+ row.append(make("p", "subagent-launch-slot-meta", metadata));
16520
+ if (slot.id !== `${roleId}:base`) {
16521
+ const remove = make("button", "subagent-launch-slot-remove", "Remove");
16522
+ remove.type = "button";
16523
+ remove.disabled = subagentLaunchSlotLoading || subagentLaunchSlotSaving;
16524
+ remove.setAttribute("aria-label", `Remove ${slotLabel}`);
16525
+ remove.addEventListener("click", () => {
16526
+ const removed = removeLaunchSlot(subagentLaunchSlotDraftRoles(), roleId, slot.id);
16527
+ if (!removed) return;
16528
+ subagentLaunchSlotDraft = removed.roles;
16529
+ subagentLaunchSlotError = "";
16530
+ subagentLaunchSlotFocusTarget = removed.focusSlotId ? { roleId, slotId: removed.focusSlotId, control: "model" } : null;
16531
+ setSubagentLaunchSlotAnnouncement(`Removed ${slotLabel}.`);
16532
+ renderSubagentLaunchSlots();
16533
+ });
16534
+ row.append(remove);
16535
+ }
16536
+ list.append(row);
16537
+ }
16538
+ card.append(list);
16539
+
16540
+ const add = make("button", "subagent-launch-slot-add", "Add slot");
16541
+ add.type = "button";
16542
+ const source = slots[slots.length - 1];
16543
+ const atRoleLimit = slots.length >= limits.slotsPerRole || subagentLaunchSlotTotal() >= limits.totalSlots;
16544
+ add.disabled = atRoleLimit || subagentLaunchSlotLoading || subagentLaunchSlotSaving;
16545
+ add.setAttribute("aria-label", `Add same ${role?.title || roleId} type from slot ${slots.length}`);
16546
+ add.addEventListener("click", () => {
16547
+ const slotId = newSubagentLaunchSlotId(subagentLaunchSlotDraftRoles());
16548
+ if (!slotId) {
16549
+ setSubagentLaunchSlotAnnouncement(`Could not generate a unique ${role?.title || roleId} slot identifier. Try again.`);
16550
+ return;
16551
+ }
16552
+ const added = addLaunchSlot(subagentLaunchSlotDraftRoles(), roleId, source?.id, {
16553
+ ...limits,
16554
+ createId: () => slotId,
16555
+ });
16556
+ if (!added) {
16557
+ setSubagentLaunchSlotAnnouncement(`Cannot add another ${role?.title || roleId} slot because the configured limit was reached.`);
16558
+ return;
16559
+ }
16560
+ subagentLaunchSlotDraft = added.roles;
16561
+ subagentLaunchSlotError = "";
16562
+ subagentLaunchSlotFocusTarget = { roleId, slotId: added.slot.id, control: "model" };
16563
+ setSubagentLaunchSlotAnnouncement(`Added ${role?.title || roleId} slot ${slots.length + 1}.`);
16564
+ renderSubagentLaunchSlots();
16565
+ });
16566
+ card.append(add);
16567
+ return card;
16568
+ }
16569
+
16570
+ function renderSubagentLaunchSlots() {
16571
+ if (!elements.subagentLaunchSlotRoles) return;
16572
+ const config = subagentLaunchSlotConfig;
16573
+ const dirty = subagentLaunchSlotDraftIsDirty();
16574
+ const activeConfigTab = !!subagentLaunchSlotConfigTabId && subagentLaunchSlotConfigTabId === activeTabId;
16575
+ if (elements.subagentLaunchSlotsSummaryStatus) {
16576
+ const roleCount = Array.isArray(config?.roleMetadata) ? config.roleMetadata.length : 8;
16577
+ elements.subagentLaunchSlotsSummaryStatus.textContent = subagentLaunchSlotError
16578
+ ? "Needs attention"
16579
+ : subagentLaunchSlotLoading
16580
+ ? "Loading launch presets…"
16581
+ : dirty
16582
+ ? "Unsaved changes"
16583
+ : subagentLaunchSlotReloadRequired && activeConfigTab
16584
+ ? "Saved · reload this tab"
16585
+ : config
16586
+ ? `${roleCount} roles · ${subagentLaunchSlotScope === "project" ? "project scope" : "user defaults"}`
16587
+ : "Select a running Pi tab";
16588
+ }
16589
+ if (elements.subagentLaunchSlots && (subagentLaunchSlotError || (subagentLaunchSlotReloadRequired && activeConfigTab))) {
16590
+ elements.subagentLaunchSlots.open = true;
16591
+ }
16592
+ if (elements.subagentLaunchSlotScope) {
16593
+ elements.subagentLaunchSlotScope.value = subagentLaunchSlotScope;
16594
+ elements.subagentLaunchSlotScope.disabled = subagentLaunchSlotLoading || subagentLaunchSlotSaving;
16595
+ }
16596
+ if (elements.subagentLaunchSlotsRefresh) elements.subagentLaunchSlotsRefresh.disabled = subagentLaunchSlotLoading || subagentLaunchSlotSaving;
16597
+ if (elements.subagentLaunchSlotScopeStatus) {
16598
+ elements.subagentLaunchSlotScopeStatus.textContent = config
16599
+ ? subagentLaunchSlotScope === "project"
16600
+ ? config.inherited
16601
+ ? `This project (${config.projectLabel || "current project"}) inherits your user defaults.`
16602
+ : `This project (${config.projectLabel || "current project"}) has its own launch-slot defaults.`
16603
+ : "User defaults apply to new projects unless that project has its own defaults."
16604
+ : "Select a running Pi tab to load its available models.";
16605
+ }
16606
+ if (elements.subagentLaunchSlotsInherit) {
16607
+ elements.subagentLaunchSlotsInherit.hidden = !(config && subagentLaunchSlotScope === "project" && !config.inherited);
16608
+ elements.subagentLaunchSlotsInherit.disabled = subagentLaunchSlotLoading || subagentLaunchSlotSaving || !activeConfigTab;
16609
+ }
16610
+ if (elements.subagentLaunchSlotsStatus) {
16611
+ const message = subagentLaunchSlotError || (subagentLaunchSlotLoading
16612
+ ? "Loading agent models…"
16613
+ : config
16614
+ ? !activeConfigTab
16615
+ ? "This unsaved draft belongs to a different tab. Switch back to save or reload it."
16616
+ : subagentLaunchSlotScope === "project" && config.inherited
16617
+ ? "This project currently inherits user-default launch slots."
16618
+ : "Model assignments are saved separately from the live monitor."
16619
+ : "Agent model configuration is unavailable.");
16620
+ elements.subagentLaunchSlotsStatus.textContent = message;
16621
+ elements.subagentLaunchSlotsStatus.classList.toggle("error", !!subagentLaunchSlotError);
16622
+ }
16623
+ if (elements.subagentLaunchSlotsSave) {
16624
+ elements.subagentLaunchSlotsSave.disabled = !config || !subagentLaunchSlotDraft || !dirty || subagentLaunchSlotLoading || subagentLaunchSlotSaving || !activeConfigTab;
16625
+ elements.subagentLaunchSlotsSave.textContent = subagentLaunchSlotSaving ? "Saving…" : "Save agent models";
16626
+ }
16627
+ if (elements.subagentLaunchSlotsDirty) {
16628
+ elements.subagentLaunchSlotsDirty.textContent = dirty ? "Unsaved changes" : "No unsaved changes";
16629
+ }
16630
+ if (elements.subagentLaunchSlotsReloadActions) {
16631
+ elements.subagentLaunchSlotsReloadActions.hidden = !(subagentLaunchSlotReloadRequired && activeConfigTab);
16632
+ }
16633
+ if (elements.subagentLaunchSlotsReload) elements.subagentLaunchSlotsReload.disabled = subagentLaunchSlotSaving || subagentLaunchSlotLoading;
16634
+ if (elements.subagentLaunchSlotsLater) elements.subagentLaunchSlotsLater.disabled = subagentLaunchSlotSaving || subagentLaunchSlotLoading;
16635
+
16636
+ elements.subagentLaunchSlotRoles.setAttribute("aria-busy", subagentLaunchSlotLoading ? "true" : "false");
16637
+ elements.subagentLaunchSlotRoles.replaceChildren();
16638
+ if (!config) {
16639
+ elements.subagentLaunchSlotRoles.append(make("p", "subagent-launch-slot-empty", subagentLaunchSlotLoading ? "Loading launch-slot defaults…" : "No agent-model configuration is loaded."));
16640
+ return;
16641
+ }
16642
+ const roles = subagentLaunchSlotDraftRoles();
16643
+ for (const role of Array.isArray(config.roleMetadata) ? config.roleMetadata : []) {
16644
+ const slots = Array.isArray(roles[role.id]) ? roles[role.id] : [];
16645
+ if (slots.length) elements.subagentLaunchSlotRoles.append(renderSubagentLaunchSlotCard(role, slots));
16646
+ }
16647
+ focusSubagentLaunchSlotControl();
16648
+ }
16649
+
16650
+ async function loadSubagentLaunchSlotConfig({ tabId = activeTabId, scope = subagentLaunchSlotScope } = {}) {
16651
+ if (!tabId) {
16652
+ renderSubagentLaunchSlots();
16653
+ return;
16654
+ }
16655
+ const requestSerial = ++subagentLaunchSlotRequestSerial;
16656
+ subagentLaunchSlotLoading = true;
16657
+ subagentLaunchSlotError = "";
16658
+ renderSubagentLaunchSlots();
16659
+ try {
16660
+ const query = new URLSearchParams({ tab: tabId, scope });
16661
+ const response = await api(`/api/subagents/config?${query}`, { scoped: false });
16662
+ if (requestSerial !== subagentLaunchSlotRequestSerial || tabId !== activeTabId || scope !== subagentLaunchSlotScope) return;
16663
+ subagentLaunchSlotConfig = response.data || null;
16664
+ subagentLaunchSlotConfigTabId = tabId;
16665
+ subagentLaunchSlotDraft = cloneLaunchSlotRoles(response.data?.roles || {});
16666
+ subagentLaunchSlotReloadRequired = subagentLaunchSlotReloadTabs.has(tabId);
16667
+ } catch (error) {
16668
+ if (requestSerial !== subagentLaunchSlotRequestSerial) return;
16669
+ subagentLaunchSlotError = `Could not load agent models: ${error.message || String(error)}`;
16670
+ } finally {
16671
+ if (requestSerial === subagentLaunchSlotRequestSerial) {
16672
+ subagentLaunchSlotLoading = false;
16673
+ renderSubagentLaunchSlots();
16674
+ }
16675
+ }
16676
+ }
16677
+
16678
+ async function confirmDiscardSubagentLaunchSlotDraft(action) {
16679
+ if (!subagentLaunchSlotDraftIsDirty()) return true;
16680
+ return appConfirm({
16681
+ title: "Discard unsaved agent models?",
16682
+ summary: `${action} replaces the current launch-slot draft with saved settings.`,
16683
+ affected: "Unsaved model and thinking assignments in this browser tab",
16684
+ undoable: false,
16685
+ confirmLabel: "Discard changes",
16686
+ });
16687
+ }
16688
+
16689
+ async function selectSubagentLaunchSlotScope(scope) {
16690
+ const nextScope = scope === "project" ? "project" : "user";
16691
+ if (nextScope === subagentLaunchSlotScope) return;
16692
+ if (!(await confirmDiscardSubagentLaunchSlotDraft("Changing scope"))) {
16693
+ renderSubagentLaunchSlots();
16694
+ return;
16695
+ }
16696
+ subagentLaunchSlotScope = nextScope;
16697
+ subagentLaunchSlotReloadRequired = false;
16698
+ await loadSubagentLaunchSlotConfig();
16699
+ }
16700
+
16701
+ async function reloadSubagentLaunchSlotConfig() {
16702
+ if (!(await confirmDiscardSubagentLaunchSlotDraft("Reloading configuration"))) return;
16703
+ subagentLaunchSlotReloadRequired = false;
16704
+ await loadSubagentLaunchSlotConfig();
16705
+ }
16706
+
16707
+ function applySavedSubagentLaunchSlotConfig(data) {
16708
+ subagentLaunchSlotConfig = data || null;
16709
+ subagentLaunchSlotConfigTabId = activeTabId;
16710
+ subagentLaunchSlotDraft = cloneLaunchSlotRoles(data?.roles || {});
16711
+ if (data?.changed === true && data?.reloadRequired === true && activeTabId) {
16712
+ subagentLaunchSlotReloadTabs.add(activeTabId);
16713
+ }
16714
+ subagentLaunchSlotReloadRequired = subagentLaunchSlotReloadTabs.has(activeTabId);
16715
+ }
16716
+
16717
+ async function saveSubagentLaunchSlotConfig({ inherit = false } = {}) {
16718
+ if (!subagentLaunchSlotConfig || !subagentLaunchSlotConfigTabId || subagentLaunchSlotConfigTabId !== activeTabId) {
16719
+ subagentLaunchSlotError = "Return to the tab that owns this launch-slot draft before saving.";
16720
+ renderSubagentLaunchSlots();
16721
+ return;
16722
+ }
16723
+ subagentLaunchSlotSaving = true;
16724
+ subagentLaunchSlotError = "";
16725
+ renderSubagentLaunchSlots();
16726
+ try {
16727
+ const body = {
16728
+ tab: activeTabId,
16729
+ scope: subagentLaunchSlotScope,
16730
+ revision: subagentLaunchSlotConfig.revision,
16731
+ };
16732
+ if (inherit) body.inherit = true;
16733
+ else body.roles = cloneLaunchSlotRoles(subagentLaunchSlotDraftRoles());
16734
+ const response = await api("/api/subagents/config", { method: "POST", body, scoped: false });
16735
+ applySavedSubagentLaunchSlotConfig(response.data);
16736
+ setSubagentLaunchSlotAnnouncement(inherit ? "This project now uses user-default agent models." : "Agent models saved.");
16737
+ } catch (error) {
16738
+ const conflict = error?.statusCode === 409;
16739
+ subagentLaunchSlotError = `${conflict ? "Conflict: reload configuration before saving." : "Could not save agent models:"} ${conflict ? "" : error.message || String(error)}`.trim();
16740
+ } finally {
16741
+ subagentLaunchSlotSaving = false;
16742
+ renderSubagentLaunchSlots();
16743
+ }
16744
+ }
16745
+
16746
+ async function resetSubagentLaunchSlotProjectScope() {
16747
+ if (subagentLaunchSlotScope !== "project" || !subagentLaunchSlotConfig || subagentLaunchSlotConfig.inherited) return;
16748
+ if (!(await confirmDiscardSubagentLaunchSlotDraft("Using user defaults"))) return;
16749
+ await saveSubagentLaunchSlotConfig({ inherit: true });
16750
+ }
16751
+
16752
+ async function reloadActiveTabForSubagentLaunchSlots() {
16753
+ if (!subagentLaunchSlotReloadRequired || subagentLaunchSlotConfigTabId !== activeTabId) return;
16754
+ subagentLaunchSlotSaving = true;
16755
+ subagentLaunchSlotError = "";
16756
+ renderSubagentLaunchSlots();
16757
+ try {
16758
+ await sendPrompt("prompt", "/reload", { targetTabId: activeTabId, throwOnError: true });
16759
+ subagentLaunchSlotReloadTabs.delete(activeTabId);
16760
+ subagentLaunchSlotReloadRequired = false;
16761
+ setSubagentLaunchSlotAnnouncement("Active tab reloaded. Agent model guidance now applies to future launches.");
16762
+ await loadSubagentLaunchSlotConfig();
16763
+ } catch (error) {
16764
+ subagentLaunchSlotError = `Could not reload the active tab: ${error.message || String(error)}`;
16765
+ } finally {
16766
+ subagentLaunchSlotSaving = false;
16767
+ renderSubagentLaunchSlots();
16768
+ }
16769
+ }
16770
+
16771
+ function initializeSubagentLaunchSlots() {
16772
+ renderSubagentLaunchSlots();
16773
+ if (activeTabId) loadSubagentLaunchSlotConfig().catch(() => {});
16774
+ }
16775
+
16142
16776
  function sessionCopyButton(label, value) {
16143
16777
  const button = make("button", "session-copy-button", "Copy");
16144
16778
  button.type = "button";
@@ -19114,6 +19748,24 @@ function mirrorRemoteWebuiWidgetToTranscript(widgetKey, lines = [], request = {}
19114
19748
  addTransientMessage({ role: "extension", title: "/remote", content, level: "info", widgetKey });
19115
19749
  }
19116
19750
 
19751
+ function workflowOverlayCloseButton() {
19752
+ const button = make("button", "release-npm-action workflow-overlay-close-button", "Close");
19753
+ button.type = "button";
19754
+ button.setAttribute("aria-controls", "widgetArea");
19755
+ button.setAttribute("aria-expanded", "true");
19756
+ button.setAttribute("aria-label", "Close and minimize workflow overlay");
19757
+ button.setAttribute("title", "Close and minimize workflow overlay");
19758
+ button.addEventListener("click", () => setWorkflowOverlayMinimized(true));
19759
+ return button;
19760
+ }
19761
+
19762
+ function attachWorkflowOverlayCloseButton(widget) {
19763
+ if (!widget) return;
19764
+ const header = widget.querySelector(":scope > .release-npm-header");
19765
+ const actions = header?.querySelector(".release-npm-actions") || header?.querySelector(".release-npm-meta");
19766
+ actions?.append(workflowOverlayCloseButton());
19767
+ }
19768
+
19117
19769
  function renderWidgets() {
19118
19770
  if (deferUiRenderDuringPointerActivation("widgets", renderWidgets)) return;
19119
19771
  const appRunnerInputFocus = captureAppRunnerInputFocus();
@@ -19128,10 +19780,14 @@ function renderWidgets() {
19128
19780
  if (releaseAurLog) elements.widgetArea.append(releaseAurLog);
19129
19781
  const aurReviewWidget = renderAurReviewWidget();
19130
19782
  if (aurReviewWidget) elements.widgetArea.append(aurReviewWidget);
19131
- const workflowInspectorWidget = renderWorkflowInspectorWidget();
19132
- if (workflowInspectorWidget) elements.widgetArea.append(workflowInspectorWidget);
19133
- const workflowSubprocessWidget = renderWorkflowSubprocessWidget();
19134
- if (workflowSubprocessWidget) elements.widgetArea.append(workflowSubprocessWidget);
19783
+ if (!workflowOverlayIsMinimized()) {
19784
+ const workflowInspectorWidget = renderWorkflowInspectorWidget();
19785
+ const workflowSubprocessWidget = renderWorkflowSubprocessWidget();
19786
+ attachWorkflowOverlayCloseButton(workflowInspectorWidget || workflowSubprocessWidget);
19787
+ if (workflowInspectorWidget) elements.widgetArea.append(workflowInspectorWidget);
19788
+ if (workflowSubprocessWidget) elements.widgetArea.append(workflowSubprocessWidget);
19789
+ }
19790
+ renderWorkflowOverlayControls();
19135
19791
  const appRunnerWidget = renderAppRunnerWidget();
19136
19792
  if (appRunnerWidget) elements.widgetArea.append(appRunnerWidget);
19137
19793
  const subagentWidget = renderSubagentOverlayWidgetSafely();
@@ -23861,7 +24517,7 @@ function captureReusableToolCards() {
23861
24517
  }
23862
24518
 
23863
24519
  function reuseToolExecutionBubble(reusableToolCards, message, { streaming = false, messageIndex = -1, transient = false } = {}) {
23864
- if (streaming || message?.role !== "toolExecution" || !message.toolCallId || !reusableToolCards) return null;
24520
+ if (compactOutputActive() || streaming || message?.role !== "toolExecution" || !message.toolCallId || !reusableToolCards) return null;
23865
24521
  const id = String(message.toolCallId);
23866
24522
  const bubble = reusableToolCards.get(id);
23867
24523
  if (!bubble) return null;
@@ -24017,10 +24673,50 @@ function jumpToStickyUserPrompt() {
24017
24673
  requestAnimationFrame(updateStickyUserPromptButton);
24018
24674
  }
24019
24675
 
24676
+ function renderCompactTranscriptBody(body, message) {
24677
+ if (message.role !== "assistant") return false;
24678
+ const output = stripTodoProgressLines(textFromContent(message.content));
24679
+ const block = appendMarkdown(body, output || "_[non-text output omitted in fast mode]_");
24680
+ block.classList.add("compact-transcript-text");
24681
+ return true;
24682
+ }
24683
+
24684
+ function compactThinkingDisclosureExpanded(key, defaultExpanded = false) {
24685
+ if (!key) return !!defaultExpanded;
24686
+ const disclosureState = compactThinkingDisclosureStateByTab.get(activeTabId || "default");
24687
+ return disclosureState?.has(key) ? disclosureState.get(key) === true : !!defaultExpanded;
24688
+ }
24689
+
24690
+ function setCompactThinkingDisclosureExpanded(key, expanded, defaultExpanded = false) {
24691
+ if (!key) return;
24692
+ const tabId = activeTabId || "default";
24693
+ let disclosureState = compactThinkingDisclosureStateByTab.get(tabId);
24694
+ if (expanded === defaultExpanded) {
24695
+ disclosureState?.delete(key);
24696
+ if (disclosureState?.size === 0) compactThinkingDisclosureStateByTab.delete(tabId);
24697
+ return;
24698
+ }
24699
+ if (!disclosureState) {
24700
+ disclosureState = new Map();
24701
+ compactThinkingDisclosureStateByTab.set(tabId, disclosureState);
24702
+ }
24703
+ disclosureState.set(key, !!expanded);
24704
+ }
24705
+
24706
+ function clearCompactThinkingDisclosureState(key) {
24707
+ if (!key) return;
24708
+ const tabId = activeTabId || "default";
24709
+ const disclosureState = compactThinkingDisclosureStateByTab.get(tabId);
24710
+ disclosureState?.delete(key);
24711
+ if (disclosureState?.size === 0) compactThinkingDisclosureStateByTab.delete(tabId);
24712
+ }
24713
+
24020
24714
  function createMessageBubble(message, { streaming = false, messageIndex = -1, transient = false, animateEntry = false, itemKey = "" } = {}) {
24021
24715
  const role = String(message.role || "message");
24022
24716
  const safeRole = role.replace(/[^a-z0-9_-]/gi, "");
24023
- const bubble = make("article", `message ${safeRole}${message.level ? ` ${message.level}` : ""}${streaming ? " streaming" : ""}${animateEntry ? " action-enter" : ""}`);
24717
+ const compactTranscript = compactOutputActive() && !streaming;
24718
+ const compactThinkingAggregate = compactOutputActive() && message.role === "thinking" && message.compactThinkingAggregate === true;
24719
+ const bubble = make("article", `message ${safeRole}${message.level ? ` ${message.level}` : ""}${streaming ? " streaming" : ""}${animateEntry ? " action-enter" : ""}${compactTranscript ? " compact-transcript-output" : ""}${compactThinkingAggregate ? " compact-thinking-aggregate" : ""}`);
24024
24720
  applyChatEventMetadata(bubble, message);
24025
24721
  if (message.role === "toolExecution") applyToolExecutionBubbleState(bubble, message);
24026
24722
  if (!transient && messageIndex >= 0) {
@@ -24028,7 +24724,7 @@ function createMessageBubble(message, { streaming = false, messageIndex = -1, tr
24028
24724
  if (role === "user") bubble.dataset.userPrompt = "true";
24029
24725
  }
24030
24726
  if (itemKey) bubble.dataset.itemKey = itemKey;
24031
- const isCollapsibleOutput = !streaming && (message.role === "toolResult" || message.role === "bashExecution" || message.role === "compactionSummary");
24727
+ const isCollapsibleOutput = compactThinkingAggregate || (!streaming && (message.role === "toolResult" || message.role === "bashExecution" || message.role === "compactionSummary"));
24032
24728
 
24033
24729
  const hideMessageHeader = message.role === "assistant" && !isCollapsibleOutput;
24034
24730
  if (hideMessageHeader) bubble.setAttribute("aria-label", messageTitle(message));
@@ -24037,7 +24733,9 @@ function createMessageBubble(message, { streaming = false, messageIndex = -1, tr
24037
24733
  header.append(make("span", "muted", formatDate(message.timestamp)));
24038
24734
  const body = make("div", "message-body");
24039
24735
 
24040
- if (message.role === "bashExecution") {
24736
+ if (compactTranscript && renderCompactTranscriptBody(body, message)) {
24737
+ // Fast mode preserves final Markdown while omitting reconciled tool history.
24738
+ } else if (message.role === "bashExecution") {
24041
24739
  appendText(body, `$ ${message.command || ""}\n\n${message.output || ""}`, "code-block");
24042
24740
  } else if (message.role === "compactionSummary") {
24043
24741
  appendText(body, message.summary || "Context was compacted.");
@@ -24055,12 +24753,16 @@ function createMessageBubble(message, { streaming = false, messageIndex = -1, tr
24055
24753
  } else if (message.role === "assistantEvent") {
24056
24754
  appendText(body, typeof message.content === "string" ? message.content : JSON.stringify(message.content ?? {}, null, 2), "code-block");
24057
24755
  } else {
24058
- renderContent(body, message.content, { markdown: message.role === "assistant" });
24756
+ renderContent(body, message.content, { markdown: message.role === "assistant" || message.role === "custom" });
24059
24757
  }
24060
24758
 
24061
24759
  if (isCollapsibleOutput) {
24062
- const details = make("details", "message-collapse");
24063
- if (shouldOpenMessageCollapseByDefault(message)) details.open = true;
24760
+ const details = make("details", `message-collapse${compactThinkingAggregate ? " compact-thinking-disclosure" : ""}`);
24761
+ if (compactThinkingAggregate) {
24762
+ const defaultExpanded = message.compactThinkingDefaultExpanded === true;
24763
+ details.open = compactThinkingDisclosureExpanded(message.compactThinkingKey, defaultExpanded);
24764
+ if (message.compactThinkingKey) details.addEventListener("toggle", () => setCompactThinkingDisclosureExpanded(message.compactThinkingKey, details.open, defaultExpanded));
24765
+ } else if (shouldOpenMessageCollapseByDefault(message)) details.open = true;
24064
24766
  details.append(header, body);
24065
24767
  bubble.append(details);
24066
24768
  if (message.role === "toolResult" && !message.isError) {
@@ -24103,6 +24805,7 @@ function appendTranscriptMessage(message, { streaming = false, messageIndex = -1
24103
24805
  }
24104
24806
 
24105
24807
  let finalOutput = null;
24808
+ const compactTranscript = compactOutputActive();
24106
24809
  const displayMessages = assistantDisplayMessages(message);
24107
24810
  displayMessages.forEach((displayMessage) => {
24108
24811
  let transcriptMessage = displayMessage;
@@ -24122,6 +24825,7 @@ function appendTranscriptMessage(message, { streaming = false, messageIndex = -1
24122
24825
  live: !!liveRun && !result,
24123
24826
  };
24124
24827
  }
24828
+ if (compactTranscript && transcriptMessage.role !== "assistant") return;
24125
24829
  if (transcriptMessage.role === "thinking" && !thinkingOutputVisible) return;
24126
24830
  const created = appendMessage(transcriptMessage, {
24127
24831
  streaming: false,
@@ -24398,11 +25102,84 @@ function rememberActionEntries(items) {
24398
25102
  actionEntryAnimationPrimedTabs.add(activeTabId);
24399
25103
  }
24400
25104
 
24401
- function orderedTranscriptItems() {
25105
+ function compactThinkingSegments(message) {
25106
+ if (!thinkingOutputVisible) return [];
25107
+ if (message?.role === "thinking") {
25108
+ const thinking = visibleThinkingText(message.thinking || textFromContent(message.content));
25109
+ return thinking ? [thinking] : [];
25110
+ }
25111
+ if (message?.role !== "assistant") return [];
25112
+ return assistantDisplayMessages(message)
25113
+ .filter((displayMessage) => displayMessage.role === "thinking")
25114
+ .map((displayMessage) => visibleThinkingText(displayMessage.thinking || textFromContent(displayMessage.content)))
25115
+ .filter(Boolean);
25116
+ }
25117
+
25118
+ function compactAssistantHasFinalOutput(message) {
25119
+ return message?.role === "assistant" && assistantDisplayMessages(message).some((displayMessage) => displayMessage.role === "assistant");
25120
+ }
25121
+
25122
+ function compactStoredTranscriptItems() {
24402
25123
  const items = [];
25124
+ let pendingThinking = null;
25125
+
25126
+ const flushThinking = () => {
25127
+ if (!pendingThinking?.segments.length) return;
25128
+ const segmentCount = pendingThinking.segments.length;
25129
+ const title = segmentCount === 1 ? "thinking" : `thinking (${segmentCount} segments)`;
25130
+ items.push({
25131
+ message: {
25132
+ role: "thinking",
25133
+ title,
25134
+ timestamp: pendingThinking.timestamp,
25135
+ content: pendingThinking.segments.join("\n\n"),
25136
+ thinking: pendingThinking.segments.join("\n\n"),
25137
+ compactThinkingAggregate: true,
25138
+ compactThinkingKey: `turn:${pendingThinking.firstIndex}`,
25139
+ },
25140
+ messageIndex: -1,
25141
+ transient: false,
25142
+ timestampMs: pendingThinking.timestampMs,
25143
+ order: pendingThinking.lastIndex - 0.5,
25144
+ transcriptKey: `compact-thinking:${pendingThinking.firstIndex}`,
25145
+ });
25146
+ pendingThinking = null;
25147
+ };
25148
+
25149
+ latestMessages.forEach((message, index) => {
25150
+ if (message?.role === "user") flushThinking();
25151
+
25152
+ const thinkingSegments = compactThinkingSegments(message);
25153
+ if (thinkingSegments.length) {
25154
+ if (!pendingThinking) {
25155
+ pendingThinking = {
25156
+ segments: [],
25157
+ firstIndex: index,
25158
+ lastIndex: index,
25159
+ timestamp: message.timestamp,
25160
+ timestampMs: messageTimestampMs(message),
25161
+ };
25162
+ }
25163
+ pendingThinking.segments.push(...thinkingSegments);
25164
+ pendingThinking.lastIndex = index;
25165
+ pendingThinking.timestamp = message.timestamp;
25166
+ pendingThinking.timestampMs = messageTimestampMs(message);
25167
+ }
25168
+
25169
+ if (message?.role === "thinking" || ["toolCall", "toolExecution", "toolResult", "assistantEvent"].includes(message?.role)) return;
25170
+ if (message?.role === "assistant" && !compactAssistantHasFinalOutput(message)) return;
25171
+ if (message?.role === "assistant") flushThinking();
25172
+ items.push({ message, messageIndex: index, transient: false, timestampMs: messageTimestampMs(message), order: index });
25173
+ });
25174
+ flushThinking();
25175
+ return items;
25176
+ }
25177
+
25178
+ function orderedTranscriptItems() {
25179
+ const items = compactOutputActive() ? compactStoredTranscriptItems() : [];
24403
25180
  const assistantToolCallIds = buildAssistantToolCallIdSet(latestMessages);
24404
25181
  const toolResults = buildToolResultMap(latestMessages);
24405
- latestMessages.forEach((message, index) => {
25182
+ if (!compactOutputActive()) latestMessages.forEach((message, index) => {
24406
25183
  const resultId = message?.role === "toolResult" ? toolResultCallId(message) : "";
24407
25184
  if (resultId && assistantToolCallIds.has(resultId)) return;
24408
25185
  items.push({ message, messageIndex: index, transient: false, timestampMs: messageTimestampMs(message), order: index });
@@ -24411,10 +25188,12 @@ function orderedTranscriptItems() {
24411
25188
  items.push({ message, messageIndex: index, transient: true, timestampMs: messageTimestampMs(message), order: latestMessages.length + index });
24412
25189
  });
24413
25190
  let liveOrder = latestMessages.length + transientMessages.length;
24414
- for (const [toolCallId, run] of liveToolRuns.entries()) {
24415
- if (assistantToolCallIds.has(toolCallId) || toolResults.has(toolCallId)) continue;
24416
- const message = liveToolRunMessage(run);
24417
- items.push({ message, messageIndex: -1, transient: true, timestampMs: messageTimestampMs(message), order: liveOrder++ });
25191
+ if (!compactOutputActive()) {
25192
+ for (const [toolCallId, run] of liveToolRuns.entries()) {
25193
+ if (assistantToolCallIds.has(toolCallId) || toolResults.has(toolCallId)) continue;
25194
+ const message = liveToolRunMessage(run);
25195
+ items.push({ message, messageIndex: -1, transient: true, timestampMs: messageTimestampMs(message), order: liveOrder++ });
25196
+ }
24418
25197
  }
24419
25198
  return items.sort((a, b) => a.timestampMs - b.timestampMs || a.order - b.order);
24420
25199
  }
@@ -24428,10 +25207,11 @@ function orderedTranscriptItems() {
24428
25207
  let renderedTranscriptState = { epoch: "", entries: [] };
24429
25208
 
24430
25209
  function transcriptRenderEpoch() {
24431
- return `${activeTabId || ""}|${thinkingOutputVisible ? 1 : 0}`;
25210
+ return `${activeTabId || ""}|${thinkingOutputVisible ? 1 : 0}|${compactOutputActive() ? "compact" : "normal"}`;
24432
25211
  }
24433
25212
 
24434
25213
  function transcriptItemKey(item) {
25214
+ if (item.transcriptKey) return item.transcriptKey;
24435
25215
  if (!item.transient) return `m:${item.messageIndex}`;
24436
25216
  if (item.messageIndex >= 0) return `t:${item.messageIndex}`;
24437
25217
  return `live:${item.message?.toolCallId || `o${item.order}`}`;
@@ -24724,18 +25504,51 @@ function isChatNearBottom() {
24724
25504
  }
24725
25505
 
24726
25506
  function updateJumpToLatestButton() {
24727
- elements.jumpToLatestButton.hidden = autoFollowChat || isChatNearBottom();
25507
+ elements.jumpToLatestButton.hidden = autoFollowChat;
25508
+ }
25509
+
25510
+ function noteChatTouchStart(event) {
25511
+ const clientY = Number(event?.touches?.[0]?.clientY);
25512
+ chatLastTouchClientY = Number.isFinite(clientY) ? clientY : null;
25513
+ }
25514
+
25515
+ function clearChatTouchIntent() {
25516
+ chatLastTouchClientY = null;
25517
+ }
25518
+
25519
+ function isChatScrollAwayIntent(event) {
25520
+ if (event?.type === "wheel") return event.deltaY < 0;
25521
+ if (event?.type === "touchmove") {
25522
+ const clientY = Number(event?.touches?.[0]?.clientY);
25523
+ const scrollAway = !Number.isFinite(clientY) || chatLastTouchClientY === null || clientY > chatLastTouchClientY;
25524
+ if (Number.isFinite(clientY)) chatLastTouchClientY = clientY;
25525
+ return scrollAway;
25526
+ }
25527
+ if (event?.type !== "keydown") return false;
25528
+ return event.key === "ArrowUp" || event.key === "Home" || event.key === "PageUp" || (event.key === " " && event.shiftKey);
24728
25529
  }
24729
25530
 
24730
25531
  function noteChatUserScrollIntent(event) {
24731
25532
  if (event?.type === "wheel" && event.deltaY >= 0 && autoFollowChat) return;
24732
- chatUserScrollIntentUntil = performance.now() + CHAT_USER_SCROLL_INTENT_MS;
25533
+ const now = performance.now();
25534
+ chatUserScrollIntentUntil = now + CHAT_USER_SCROLL_INTENT_MS;
25535
+ if (!isChatScrollAwayIntent(event)) {
25536
+ chatUserScrollAwayIntentUntil = 0;
25537
+ return;
25538
+ }
25539
+ chatUserScrollAwayIntentUntil = now + CHAT_USER_SCROLL_INTENT_MS;
25540
+ autoFollowChat = false;
25541
+ updateJumpToLatestButton();
24733
25542
  }
24734
25543
 
24735
25544
  function isChatUserScrollIntentActive() {
24736
25545
  return performance.now() <= chatUserScrollIntentUntil;
24737
25546
  }
24738
25547
 
25548
+ function isChatUserScrollAwayIntentActive() {
25549
+ return performance.now() <= chatUserScrollAwayIntentUntil;
25550
+ }
25551
+
24739
25552
  function setChatScrollTopInstant(top) {
24740
25553
  const previousBehavior = elements.chat.style.scrollBehavior;
24741
25554
  elements.chat.style.scrollBehavior = "auto";
@@ -24770,17 +25583,24 @@ function scheduleChatFollowScroll({ settle = true } = {}) {
24770
25583
  }, CHAT_FOLLOW_SETTLE_DELAY_MS);
24771
25584
  }
24772
25585
 
25586
+ function resumeChatAutoFollow() {
25587
+ chatUserScrollAwayIntentUntil = 0;
25588
+ autoFollowChat = true;
25589
+ }
25590
+
24773
25591
  function scrollChatToBottom({ force = false } = {}) {
24774
25592
  if (deferChatFollowScrollDuringPointerActivation({ force })) return;
24775
25593
  if (deferChatFollowScrollDuringInteractiveDropdown({ force })) return;
24776
- if (force) autoFollowChat = true;
25594
+ if (force) resumeChatAutoFollow();
24777
25595
  scheduleChatFollowScroll();
24778
25596
  }
24779
25597
 
24780
25598
  function syncAutoFollowFromChatScroll() {
24781
25599
  const nearBottom = isChatNearBottom();
24782
25600
  const recentProgrammaticScroll = performance.now() - lastChatProgrammaticScrollAt <= CHAT_PROGRAMMATIC_SCROLL_GRACE_MS;
24783
- if (nearBottom || isChatUserScrollIntentActive() || !autoFollowChat || !recentProgrammaticScroll) {
25601
+ if (isChatUserScrollAwayIntentActive()) {
25602
+ autoFollowChat = false;
25603
+ } else if (nearBottom || isChatUserScrollIntentActive() || !autoFollowChat || !recentProgrammaticScroll) {
24784
25604
  autoFollowChat = nearBottom;
24785
25605
  } else {
24786
25606
  scheduleChatFollowScroll();
@@ -24796,7 +25616,6 @@ function jumpToLatest() {
24796
25616
 
24797
25617
  function syncMobileChatToBottomForInput() {
24798
25618
  if (!isMobileView()) return;
24799
- autoFollowChat = true;
24800
25619
  scrollChatToBottom({ force: true });
24801
25620
  requestAnimationFrame(() => scrollChatToBottom({ force: true }));
24802
25621
  setTimeout(() => scrollChatToBottom({ force: true }), 140);
@@ -26070,7 +26889,7 @@ async function openNativeSettingsDialog() {
26070
26889
  autocompleteMax: nativeSettingSelect("Autocomplete max items", settings.autocompleteMaxVisible ?? autocompleteMaxVisible, SETTINGS_AUTOCOMPLETE_OPTIONS, "Maximum visible slash/path suggestions.", { label: "browser", tone: "browser" }),
26071
26890
  doubleEscape: nativeSettingSelect("Double-escape action", settings.doubleEscapeAction || doubleEscapeAction, SETTINGS_DOUBLE_ESCAPE_OPTIONS, "Action when pressing Escape twice with an empty composer.", { label: "browser", tone: "browser" }),
26072
26891
  treeFilter: nativeSettingSelect("Tree filter mode", settings.treeFilterMode || treeFilterMode, SETTINGS_TREE_FILTER_OPTIONS, "Default filter when opening /tree.", { label: "browser", tone: "browser" }),
26073
- outputMode: nativeSettingSelect("Output processing", outputModeMetadata.persistedDefault, SETTINGS_OUTPUT_MODE_OPTIONS, "Server default for new and auto-negotiated Web UI connections. Compact reduces local output-processing and live fidelity, restores rich final output, and does not change model inference or token generation. Changes use server barriers without restarting Pi.", { label: "server", tone: "startup" }),
26892
+ outputMode: nativeSettingSelect("Output processing", outputModeMetadata.persistedDefault, SETTINGS_OUTPUT_MODE_OPTIONS, "Server default for new and auto-negotiated Web UI connections. Fast mode preserves Markdown final output, keeps live thinking expanded, groups stored thinking in one collapsed disclosure per turn, shows only the current tool status transiently, and does not change model inference or token generation. Changes use server barriers without restarting Pi.", { label: "server", tone: "startup" }),
26074
26893
  autoResizeImages: nativeSettingToggle("Auto-resize images", settings.autoResizeImages !== false, "Resize large images to 2000x2000 max for better model compatibility.", { label: "reload", tone: "reload" }),
26075
26894
  blockImages: nativeSettingToggle("Block images", settings.blockImages === true, "Prevent images from being sent to LLM providers.", { label: "reload", tone: "reload" }),
26076
26895
  showImages: nativeSettingToggle("Show terminal images", settings.showImages !== false, "Native TUI inline image rendering preference.", { label: "TUI", tone: "tui" }),
@@ -27168,19 +27987,26 @@ function removeCompactLiveBubble(bubble) {
27168
27987
  bubble?.remove();
27169
27988
  }
27170
27989
 
27990
+ function clearCompactToolShells() {
27991
+ for (const shell of compactToolShells.values()) removeCompactLiveBubble(shell?.bubble);
27992
+ compactToolShells.clear();
27993
+ }
27994
+
27171
27995
  function resetCompactLiveOutput({ remove = true } = {}) {
27172
27996
  compactLiveScheduler.cancel();
27173
27997
  compactLiveState = createFastOutputLiveState();
27998
+ clearCompactThinkingDisclosureState("live");
27174
27999
  if (remove) {
27175
28000
  removeCompactLiveBubble(compactTextBubble);
27176
28001
  removeCompactLiveBubble(compactThinkingBubble);
27177
- for (const shell of compactToolShells.values()) removeCompactLiveBubble(shell?.bubble);
28002
+ clearCompactToolShells();
28003
+ } else {
28004
+ compactToolShells.clear();
27178
28005
  }
27179
28006
  compactTextBubble = null;
27180
28007
  compactTextNode = null;
27181
28008
  compactThinkingBubble = null;
27182
28009
  compactThinkingNode = null;
27183
- compactToolShells.clear();
27184
28010
  }
27185
28011
 
27186
28012
  function ensureCompactTextBubble() {
@@ -27196,10 +28022,10 @@ function ensureCompactTextBubble() {
27196
28022
  function ensureCompactThinkingBubble() {
27197
28023
  if (!thinkingOutputVisible) return false;
27198
28024
  if (compactThinkingBubble?.parentElement === elements.chat && compactThinkingNode) return true;
27199
- const created = appendMessage({ role: "thinking", title: "thinking", timestamp: Date.now(), content: "" }, { streaming: true });
28025
+ const created = appendMessage({ role: "thinking", title: "thinking (live)", timestamp: Date.now(), content: "", compactThinkingAggregate: true, compactThinkingKey: "live", compactThinkingDefaultExpanded: true }, { streaming: true });
27200
28026
  compactThinkingBubble = created.bubble;
27201
28027
  compactThinkingBubble.classList.add("compact-live-output");
27202
- compactThinkingNode = make("div", "compact-live-thinking");
28028
+ compactThinkingNode = make("div", "markdown-body thinking-text compact-live-thinking");
27203
28029
  created.body.append(compactThinkingNode);
27204
28030
  renderRunIndicator({ scroll: false });
27205
28031
  return true;
@@ -27214,6 +28040,7 @@ function renderCompactToolShell(event, { complete = false } = {}) {
27214
28040
  const id = compactToolShellId(event);
27215
28041
  let shell = compactToolShells.get(id);
27216
28042
  if (!shell) {
28043
+ clearCompactToolShells();
27217
28044
  const bubble = make("article", "message toolExecution compact-tool-shell streaming");
27218
28045
  const header = make("div", "message-header");
27219
28046
  const role = make("span", "message-role");
@@ -27231,8 +28058,8 @@ function renderCompactToolShell(event, { complete = false } = {}) {
27231
28058
  const name = String(event?.toolName || event?.name || "tool");
27232
28059
  shell.role.textContent = `tool: ${name}`;
27233
28060
  shell.status.textContent = complete
27234
- ? `${name} ${event?.isError ? "failed" : "finished"}; restoring final details…`
27235
- : `${name} running…`;
28061
+ ? event?.isError ? "failed" : "done"
28062
+ : "running";
27236
28063
  shell.bubble.classList.toggle("tool-error", !!event?.isError);
27237
28064
  shell.bubble.classList.toggle("tool-running", !complete);
27238
28065
  shell.bubble.classList.toggle("tool-success", complete && !event?.isError);
@@ -27245,7 +28072,7 @@ function flushCompactLiveOutput() {
27245
28072
  if (compactTextNode?.textContent !== compactLiveState.text) compactTextNode.textContent = compactLiveState.text;
27246
28073
  }
27247
28074
  if (compactLiveState.thinking && ensureCompactThinkingBubble()) {
27248
- if (compactThinkingNode?.textContent !== compactLiveState.thinking) compactThinkingNode.textContent = compactLiveState.thinking;
28075
+ if (compactThinkingNode?._rawThinkingText !== compactLiveState.thinking) renderThinkingMarkdown(compactThinkingNode, compactLiveState.thinking);
27249
28076
  }
27250
28077
  scheduleChatFollowScroll();
27251
28078
  }
@@ -27260,6 +28087,7 @@ function handleCompactMessageUpdate(event) {
27260
28087
  if (!shouldConsumeFastOutputLiveEvent(reduced)) return false;
27261
28088
  if (!reduced.changed) return true;
27262
28089
  compactLiveState = reduced.state;
28090
+ clearCompactToolShells();
27263
28091
  if (reduced.kind.startsWith("thinking")) setRunIndicatorActivity("Thinking…", { scroll: false });
27264
28092
  else if (reduced.kind.startsWith("toolcall")) setRunIndicatorActivity("Building tool call…", { scroll: false });
27265
28093
  else setRunIndicatorActivity("Writing response…", { scroll: false });
@@ -27272,6 +28100,7 @@ function acceptOutputModeAcknowledgement(event) {
27272
28100
  if (acknowledgement) {
27273
28101
  activeOutputMode = acknowledgement.activeMode;
27274
28102
  outputModeAcknowledged = true;
28103
+ if (!currentState?.isStreaming) renderAllMessages({ preserveScroll: true, forceRebuild: true });
27275
28104
  return true;
27276
28105
  }
27277
28106
  activeOutputMode = "normal";
@@ -27317,6 +28146,7 @@ function applyOutputModeControl(event, tabContext = activeTabContext()) {
27317
28146
  }
27318
28147
  activeOutputMode = event.activeMode;
27319
28148
  outputModeAcknowledged = true;
28149
+ if (!currentState?.isStreaming) renderAllMessages({ preserveScroll: true, forceRebuild: true });
27320
28150
  addEvent(`live output mode changed to ${event.activeMode}`, "info");
27321
28151
  return true;
27322
28152
  }
@@ -27534,10 +28364,31 @@ function resetStreamBubble() {
27534
28364
  streamProviderErrorText = "";
27535
28365
  }
27536
28366
 
28367
+ function compactLiveStreamRenderActive() {
28368
+ const messageOutputActive = streamMessageActive && Boolean(
28369
+ compactTextBubble
28370
+ || compactThinkingBubble
28371
+ || compactLiveState.text
28372
+ || compactLiveState.thinking
28373
+ || compactLiveState.toolCall?.arguments,
28374
+ );
28375
+ return compactOutputActive() && currentState?.isStreaming === true && Boolean(compactToolShells.size || messageOutputActive);
28376
+ }
28377
+
27537
28378
  function liveStreamRenderActive() {
27538
28379
  return streamMessageActive && currentState?.isStreaming === true && Boolean(streamBubble || streamThinkingBubble || streamToolCallBubble || streamRawText || streamToolCallRawArguments);
27539
28380
  }
27540
28381
 
28382
+ function restoreCompactLiveOutputAfterChatRebuild() {
28383
+ compactTextBubble = null;
28384
+ compactTextNode = null;
28385
+ compactThinkingBubble = null;
28386
+ compactThinkingNode = null;
28387
+ if (streamMessageActive) flushCompactLiveOutput();
28388
+ for (const shell of compactToolShells.values()) appendChatMessageBubble(shell.bubble);
28389
+ renderRunIndicator({ scroll: false });
28390
+ }
28391
+
27541
28392
  /**
27542
28393
  * The chat DOM was rebuilt while an assistant message is still streaming:
27543
28394
  * drop references to the detached nodes but keep stream text state, then
@@ -28051,10 +28902,12 @@ async function refreshMessages(tabContext = activeTabContext()) {
28051
28902
  latestMessages = nextMessages;
28052
28903
  latestMessagesSessionKey = sessionKey;
28053
28904
  cacheMessagesForTab(tabContext.tabId, latestMessages, latestMessagesSessionKey);
28054
- const preserveLiveStream = liveStreamRenderActive();
28055
- if (!preserveLiveStream) resetStreamBubble();
28905
+ const preserveCompactStream = compactLiveStreamRenderActive();
28906
+ const preserveNormalStream = !preserveCompactStream && liveStreamRenderActive();
28907
+ if (!preserveCompactStream && !preserveNormalStream) resetStreamBubble();
28056
28908
  renderMessages(latestMessages);
28057
- if (preserveLiveStream) restoreStreamRenderAfterChatRebuild();
28909
+ if (preserveCompactStream) restoreCompactLiveOutputAfterChatRebuild();
28910
+ else if (preserveNormalStream) restoreStreamRenderAfterChatRebuild();
28058
28911
  markTabOutputSeen();
28059
28912
  renderFooter();
28060
28913
  }
@@ -29382,7 +30235,7 @@ async function runUserBashCommand(parsed, { usesPromptInput = false, targetTabId
29382
30235
  if (!targetTabId || !parsed?.command) return;
29383
30236
  const tabContext = activeTabContext(targetTabId);
29384
30237
  const { command, excludeFromContext } = parsed;
29385
- autoFollowChat = true;
30238
+ resumeChatAutoFollow();
29386
30239
  setComposerActionsOpen(false);
29387
30240
  hideCommandSuggestions();
29388
30241
  userBashByTab.set(targetTabId, { command, excludeFromContext, startedAt: Date.now() });
@@ -29480,7 +30333,7 @@ async function sendPrompt(kind = "prompt", explicitMessage, { targetTabId = acti
29480
30333
  const targetWasBusy = targetWasStreaming || targetWasCompacting;
29481
30334
  const busyBehavior = normalizeBusyPromptBehavior(busyPromptBehavior);
29482
30335
  const startsRun = kind === "prompt" && !targetWasBusy;
29483
- autoFollowChat = true;
30336
+ resumeChatAutoFollow();
29484
30337
  updateJumpToLatestButton();
29485
30338
  setComposerActionsOpen(false);
29486
30339
  if (startsRun) {
@@ -30669,6 +31522,7 @@ elements.nativeSkillsButton.addEventListener("click", () => runNativeCommandMenu
30669
31522
  elements.nativeToolsButton.addEventListener("click", () => runNativeCommandMenu("/tools"));
30670
31523
  elements.optionsCommandPaletteButton.addEventListener("click", () => openCommandPalette());
30671
31524
  elements.workflowModeButton?.addEventListener("click", () => toggleWorkflowMode());
31525
+ elements.workflowOverlayOpenButton?.addEventListener("click", () => setWorkflowOverlayMinimized(false));
30672
31526
  elements.workflowModeChip?.addEventListener("click", () => setWorkflowModeEnabled(false));
30673
31527
  elements.optionsConversationModeButton?.addEventListener("click", () => toggleNaturalConversationMode());
30674
31528
  elements.conversationModeChip?.addEventListener("click", () => toggleVoiceConversationPaused());
@@ -31207,6 +32061,41 @@ if (elements.subagentOpenModeSelect) {
31207
32061
  setSubagentOpenMode(elements.subagentOpenModeSelect.value, { announce: true });
31208
32062
  });
31209
32063
  }
32064
+ elements.subagentLaunchSlotScope?.addEventListener("change", () => {
32065
+ selectSubagentLaunchSlotScope(elements.subagentLaunchSlotScope.value).catch((error) => {
32066
+ subagentLaunchSlotError = error.message || String(error);
32067
+ renderSubagentLaunchSlots();
32068
+ });
32069
+ });
32070
+ elements.subagentLaunchSlotsRefresh?.addEventListener("click", () => {
32071
+ reloadSubagentLaunchSlotConfig().catch((error) => {
32072
+ subagentLaunchSlotError = error.message || String(error);
32073
+ renderSubagentLaunchSlots();
32074
+ });
32075
+ });
32076
+ elements.subagentLaunchSlotsSave?.addEventListener("click", () => {
32077
+ saveSubagentLaunchSlotConfig().catch((error) => {
32078
+ subagentLaunchSlotError = error.message || String(error);
32079
+ renderSubagentLaunchSlots();
32080
+ });
32081
+ });
32082
+ elements.subagentLaunchSlotsInherit?.addEventListener("click", () => {
32083
+ resetSubagentLaunchSlotProjectScope().catch((error) => {
32084
+ subagentLaunchSlotError = error.message || String(error);
32085
+ renderSubagentLaunchSlots();
32086
+ });
32087
+ });
32088
+ elements.subagentLaunchSlotsReload?.addEventListener("click", () => {
32089
+ reloadActiveTabForSubagentLaunchSlots().catch((error) => {
32090
+ subagentLaunchSlotError = error.message || String(error);
32091
+ renderSubagentLaunchSlots();
32092
+ });
32093
+ });
32094
+ elements.subagentLaunchSlotsLater?.addEventListener("click", () => {
32095
+ subagentLaunchSlotReloadRequired = false;
32096
+ setSubagentLaunchSlotAnnouncement("Agent models are saved. Reload this tab later before relying on them for future launches.");
32097
+ renderSubagentLaunchSlots();
32098
+ });
31210
32099
  elements.subagentTerminalCopyButton?.addEventListener("click", () => copySubagentTerminalOutput());
31211
32100
  elements.subagentTerminalRefreshButton?.addEventListener("click", () => {
31212
32101
  refreshSubagentTerminalView(activeSubagentTerminalId, { showLoading: true }).finally(() => scheduleSubagentTerminalRefresh());
@@ -31231,7 +32120,10 @@ bindSidePanelContextMenu();
31231
32120
  elements.stickyUserPromptButton?.addEventListener("click", jumpToStickyUserPrompt);
31232
32121
  elements.jumpToLatestButton.addEventListener("click", jumpToLatest);
31233
32122
  elements.chat.addEventListener("wheel", noteChatUserScrollIntent, { passive: true });
32123
+ elements.chat.addEventListener("touchstart", noteChatTouchStart, { passive: true });
31234
32124
  elements.chat.addEventListener("touchmove", noteChatUserScrollIntent, { passive: true });
32125
+ elements.chat.addEventListener("touchend", clearChatTouchIntent, { passive: true });
32126
+ elements.chat.addEventListener("touchcancel", clearChatTouchIntent, { passive: true });
31235
32127
  elements.chat.addEventListener("keydown", (event) => {
31236
32128
  if (CHAT_SCROLL_KEYS.has(event.key)) noteChatUserScrollIntent(event);
31237
32129
  }, { passive: true });
@@ -31490,7 +32382,7 @@ window.addEventListener("storage", (event) => {
31490
32382
  if (event.key === OPTIONAL_FEATURES_STORAGE_KEY) reconcileDisabledOptionalFeaturesFromStorage();
31491
32383
  if (event.key === SIDE_PANEL_SECTION_VISIBILITY_STORAGE_KEY) restoreSidePanelSectionVisibility();
31492
32384
  });
31493
- window.addEventListener("resize", syncFileViewerWidthForViewport, { passive: true });
32385
+ window.addEventListener("resize", syncResizablePanelWidthsForViewport, { passive: true });
31494
32386
  window.addEventListener("keydown", (event) => {
31495
32387
  if (event.key !== "Escape") return;
31496
32388
  if (event.defaultPrevented) return;
@@ -31696,6 +32588,8 @@ elements.fileContextMenu?.addEventListener("click", (event) => {
31696
32588
  else if (action === "delete") deleteFileTreeEntry(entry).catch((error) => addEvent(error.message || String(error), "error"));
31697
32589
  });
31698
32590
  elements.fileViewerOpenDefaultButton?.addEventListener("click", () => openPathInDefaultEditor(currentFileViewerPath()));
32591
+ elements.sidePanelResizeHandle?.addEventListener("pointerdown", beginSidePanelResize);
32592
+ elements.sidePanelResizeHandle?.addEventListener("keydown", handleSidePanelResizeKeydown);
31699
32593
  elements.fileViewerResizeHandle?.addEventListener("pointerdown", beginFileViewerResize);
31700
32594
  elements.fileViewerResizeHandle?.addEventListener("keydown", handleFileViewerResizeKeydown);
31701
32595
  elements.fileViewerSaveButton?.addEventListener("click", () => saveActiveFileViewer());
@@ -31836,6 +32730,7 @@ elements.promptInput.addEventListener("blur", () => {
31836
32730
 
31837
32731
  installModalPrimitives();
31838
32732
  resizePromptInput();
32733
+ restoreSidePanelWidthPreference();
31839
32734
  restoreFileViewerWidthPreference();
31840
32735
  focusPromptInput({ defer: true });
31841
32736
  restoreStoredSkillUsage();
@@ -31871,6 +32766,7 @@ restoreSidePanelState();
31871
32766
  initializeCodexUsage();
31872
32767
  initializeClaudeUsage();
31873
32768
  initializeSubagents();
32769
+ initializeSubagentLaunchSlots();
31874
32770
  initializeUpdateNotifications();
31875
32771
  bindMobileViewChanges();
31876
32772
  bindSidePanelOverlayViewChanges();