@firstpick/pi-package-webui 0.8.8 → 0.8.9

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.
Files changed (39) hide show
  1. package/README.md +5 -0
  2. package/bin/pi-webui-rpc-supervisor.mjs +4 -1
  3. package/bin/pi-webui.mjs +5 -1
  4. package/lib/rpc-supervisor-protocol.mjs +6 -1
  5. package/package.json +1 -1
  6. package/public/app.js +426 -101
  7. package/public/index.html +27 -13
  8. package/public/service-worker.js +1 -1
  9. package/public/styles.css +741 -16
  10. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  11. package/tests/browser/interaction-continuity.spec.mjs +58 -0
  12. package/tests/browser/mobile-foundation.spec.mjs +363 -5
  13. package/tests/browser/optimistic-prompt.spec.mjs +24 -10
  14. package/tests/browser/persistent-ui-layout.spec.mjs +2 -0
  15. package/tests/browser/side-panel-section-reorder.spec.mjs +16 -1
  16. package/tests/codex-fast-mode-static.test.mjs +2 -2
  17. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  18. package/tests/fast-mode-client-static.test.mjs +1 -1
  19. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  20. package/tests/file-tree-search-layout-static.test.mjs +261 -0
  21. package/tests/fixtures/fake-pi.mjs +4 -1
  22. package/tests/http-endpoints-harness.test.mjs +6 -2
  23. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  24. package/tests/mobile-compact-layout.test.mjs +60 -0
  25. package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
  26. package/tests/mobile-foundation-static.test.mjs +12 -12
  27. package/tests/mobile-phone-experience-static.test.mjs +2 -2
  28. package/tests/mobile-static.test.mjs +32 -18
  29. package/tests/open-issue-wizard-static.test.mjs +1 -1
  30. package/tests/persistent-ui-layout-static.test.mjs +3 -3
  31. package/tests/questionnaire-dialog.test.mjs +3 -3
  32. package/tests/rpc-supervisor-host.test.mjs +18 -1
  33. package/tests/rpc-supervisor-protocol.test.mjs +5 -0
  34. package/tests/session-sampling-ui-static.test.mjs +3 -3
  35. package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
  36. package/tests/side-panel-section-reorder-static.test.mjs +23 -10
  37. package/tests/streaming-ui-coupling.test.mjs +8 -0
  38. package/tests/terminal-tab-workspace-static.test.mjs +15 -1
  39. package/tests/theme-customizer-static.test.mjs +1 -1
package/public/app.js CHANGED
@@ -32,6 +32,9 @@ const elements = {
32
32
  webuiDevBadge: $("#webuiDevBadge"),
33
33
  tabBar: $("#tabBar"),
34
34
  terminalTabsToggleButton: $("#terminalTabsToggleButton"),
35
+ terminalTabsShell: $(".terminal-tabs-shell"),
36
+ terminalTabsDrawerContent: $("#terminalTabsDrawerContent"),
37
+ terminalTabsBackdrop: $("#terminalTabsBackdrop"),
35
38
  workspaceSaveButton: $("#workspaceSaveButton"),
36
39
  newTabMenu: $("#newTabMenu"),
37
40
  newTabButton: $("#newTabButton"),
@@ -90,6 +93,7 @@ const elements = {
90
93
  subagentCancelSubmitButton: $("#subagentCancelSubmitButton"),
91
94
  stickyUserPromptButton: $("#stickyUserPromptButton"),
92
95
  chat: $("#chat"),
96
+ runIndicatorHost: $("#runIndicatorHost"),
93
97
  chatSearchBar: $("#chatSearchBar"),
94
98
  chatSearchInput: $("#chatSearchInput"),
95
99
  chatSearchCount: $("#chatSearchCount"),
@@ -101,6 +105,8 @@ const elements = {
101
105
  sendFeedbackButton: $("#sendFeedbackButton"),
102
106
  jumpToLatestButton: $("#jumpToLatestButton"),
103
107
  composer: $("#composer"),
108
+ composerInputRow: $(".composer-input-row"),
109
+ composerContextTags: $(".composer-context-tags"),
104
110
  composerRow: $(".composer-row"),
105
111
  composerActionsButton: $("#composerActionsButton"),
106
112
  composerActionsPanel: $("#composerActionsPanel"),
@@ -329,6 +335,8 @@ const elements = {
329
335
  sidePanelContextMenu: $("#sidePanelContextMenu"),
330
336
  gitFooterContextMenu: $("#gitFooterContextMenu"),
331
337
  sidePanelResizeHandle: $("#sidePanelResizeHandle"),
338
+ sidePanelEditButton: $("#sidePanelEditButton"),
339
+ sidePanelEditHint: $("#sidePanelEditHint"),
332
340
  toggleSidePanelButton: $("#toggleSidePanelButton"),
333
341
  sidePanelExpandButton: $("#sidePanelExpandButton"),
334
342
  sidePanelBackdrop: $("#sidePanelBackdrop"),
@@ -570,6 +578,7 @@ let fileViewerSearchHighlightElement = null;
570
578
  let fileContextMenuState = null;
571
579
  let sidePanelContextMenuState = null;
572
580
  let gitFooterContextMenuState = null;
581
+ let sidePanelSectionEditMode = false;
573
582
  let sidePanelSectionPointerDrag = null;
574
583
  let sidePanelSectionLastDragOverKey = "";
575
584
  let sidePanelSectionSuppressClickUntil = 0;
@@ -718,9 +727,9 @@ let runIndicatorRenderFrame = null;
718
727
  let runIndicatorRenderScroll = false;
719
728
  let runIndicatorGraceCheckTimer = null;
720
729
  let runIndicatorLastStateCheckAt = 0;
721
- // Lifecycle ownership is deliberately separate from the transcript-owned
722
- // activity label: the transcript ticker only repaints its own elapsed-time
723
- // node, while this watchdog owns the low-frequency canonical state recheck.
730
+ // Lifecycle ownership is deliberately separate from the status-host-owned
731
+ // activity label: the status ticker only repaints its own elapsed-time node,
732
+ // while this watchdog owns the low-frequency canonical state recheck.
724
733
  let lifecycleStateWatchdogTimer = null;
725
734
  let lifecycleComposerSignature = null;
726
735
  // Bounded dedupe of semantic tool-boundary records (skill tags, event log),
@@ -796,9 +805,13 @@ let pathFastPicks = [];
796
805
  let pathFastPicksReady = false;
797
806
  let pathFastPicksLoadPromise = null;
798
807
  let mobileTabsExpanded = false;
808
+ let mobileTabsFocusReturn = null;
809
+ let composerActionsFocusReturn = null;
810
+ const mobileComposerOriginalPositions = new Map();
799
811
  let openTerminalTabGroupKey = null;
800
812
  let terminalCustomGroups = new Map();
801
813
  let terminalCustomGroupSerial = 1;
814
+ let terminalTabGroupMenuSerial = 0;
802
815
  let savedWorkspaces = [];
803
816
  let savedWorkspacesLoaded = false;
804
817
  let savedWorkspacesLoading = false;
@@ -2307,6 +2320,9 @@ function applyMobileShellViewport() {
2307
2320
  const wasActive = isMobileShellV2Active();
2308
2321
  applyMobileShellEvent({ type: "viewport", viewport: mobileShellViewport() });
2309
2322
  if (wasActive !== isMobileShellV2Active() && isMobileShellV2Active()) {
2323
+ mobileFooterExpanded = false;
2324
+ elements.statusBar.removeAttribute("aria-label");
2325
+ deactivateDrawerModal(elements.statusBar, { restoreFocus: false });
2310
2326
  document.body.classList.remove("composer-actions-open", "footer-details-expanded", "mobile-tabs-expanded", "mobile-keyboard-open");
2311
2327
  }
2312
2328
  }
@@ -3726,7 +3742,55 @@ function clearSidePanelSectionDragMarkers() {
3726
3742
  }
3727
3743
  }
3728
3744
 
3745
+ function isSidePanelSectionReorderingEnabled() {
3746
+ return !isMobileView() || sidePanelSectionEditMode;
3747
+ }
3748
+
3749
+ function updateSidePanelSectionEditAffordance(record) {
3750
+ const collapsed = record.section.classList.contains("collapsed");
3751
+ const label = record.button.querySelector(".side-panel-section-label")?.textContent?.trim() || "side panel";
3752
+ const action = `${collapsed ? "Expand" : "Collapse"} ${label} section`;
3753
+ const reorderingEnabled = isSidePanelSectionReorderingEnabled();
3754
+ record.button.setAttribute("aria-label", action);
3755
+ record.button.setAttribute("title", reorderingEnabled
3756
+ ? `${action} · drag to reorder · Alt+↑/↓ moves`
3757
+ : action);
3758
+ if (reorderingEnabled) record.button.setAttribute("aria-keyshortcuts", "Alt+ArrowUp Alt+ArrowDown");
3759
+ else record.button.removeAttribute("aria-keyshortcuts");
3760
+ }
3761
+
3762
+ function cancelSidePanelSectionPointerDrag() {
3763
+ const drag = sidePanelSectionPointerDrag;
3764
+ if (!drag) return;
3765
+ window.removeEventListener("pointermove", updateSidePanelSectionPointerDrag, { capture: true });
3766
+ window.removeEventListener("pointerup", endSidePanelSectionPointerDrag, { capture: true });
3767
+ window.removeEventListener("pointercancel", endSidePanelSectionPointerDrag, { capture: true });
3768
+ sidePanelSectionRecords().find(({ id }) => id === drag.sectionId)?.section.classList.remove("dragging");
3769
+ sidePanelSectionPointerDrag = null;
3770
+ sidePanelSectionLastDragOverKey = "";
3771
+ clearSidePanelSectionDragMarkers();
3772
+ }
3773
+
3774
+ function setSidePanelSectionEditMode(enabled) {
3775
+ if (!enabled) cancelSidePanelSectionPointerDrag();
3776
+ const next = isMobileView() && !!enabled;
3777
+ const reorderingEnabled = !isMobileView() || next;
3778
+ if (sidePanelSectionEditMode === next && elements.sidePanel?.classList.contains("section-edit-mode") === reorderingEnabled) return;
3779
+ sidePanelSectionEditMode = next;
3780
+ elements.sidePanel?.classList.toggle("section-edit-mode", reorderingEnabled);
3781
+ if (elements.sidePanelEditButton) {
3782
+ elements.sidePanelEditButton.setAttribute("aria-pressed", next ? "true" : "false");
3783
+ elements.sidePanelEditButton.setAttribute("aria-label", next ? "Finish editing Control Deck section order" : "Edit Control Deck section order");
3784
+ elements.sidePanelEditButton.setAttribute("title", next ? "Finish editing Control Deck section order" : "Edit Control Deck section order");
3785
+ const label = elements.sidePanelEditButton.querySelector(".side-panel-edit-button-label");
3786
+ if (label) label.textContent = next ? "Done" : "Edit";
3787
+ }
3788
+ if (elements.sidePanelEditHint) elements.sidePanelEditHint.hidden = !next;
3789
+ for (const record of sidePanelSectionRecords()) updateSidePanelSectionEditAffordance(record);
3790
+ }
3791
+
3729
3792
  function moveSidePanelSectionRelative(fromId, targetRecord, insertBefore) {
3793
+ if (!isSidePanelSectionReorderingEnabled()) return false;
3730
3794
  const sourceRecord = sidePanelSectionRecords().find(({ id }) => id === fromId);
3731
3795
  if (!sourceRecord || !targetRecord || sourceRecord.section === targetRecord.section) return false;
3732
3796
  const parent = sourceRecord.section.parentElement;
@@ -3741,6 +3805,7 @@ function moveSidePanelSectionRelative(fromId, targetRecord, insertBefore) {
3741
3805
  }
3742
3806
 
3743
3807
  function moveSidePanelSectionByOffset(sectionId, offset) {
3808
+ if (!isSidePanelSectionReorderingEnabled()) return false;
3744
3809
  const records = visibleSidePanelSectionRecords();
3745
3810
  const fromIndex = records.findIndex(({ id }) => id === sectionId);
3746
3811
  const toIndex = fromIndex + offset;
@@ -3757,7 +3822,7 @@ function sidePanelSectionToggleFromPoint(clientX, clientY) {
3757
3822
  }
3758
3823
 
3759
3824
  function beginSidePanelSectionPointerDrag(event, sectionId) {
3760
- if (event.button !== 0 || !sectionId || sidePanelSectionPointerDrag) return;
3825
+ if (!isSidePanelSectionReorderingEnabled() || event.button !== 0 || !sectionId || sidePanelSectionPointerDrag) return;
3761
3826
  sidePanelSectionPointerDrag = { sectionId, pointerId: event.pointerId, startX: event.clientX, startY: event.clientY, active: false };
3762
3827
  window.addEventListener("pointermove", updateSidePanelSectionPointerDrag, { capture: true });
3763
3828
  window.addEventListener("pointerup", endSidePanelSectionPointerDrag, { capture: true });
@@ -3878,12 +3943,10 @@ function restoreSidePanelSectionVisibility() {
3878
3943
  }
3879
3944
 
3880
3945
  function setSidePanelSectionCollapsed(record, collapsed, { persist = true } = {}) {
3881
- const label = record.button.querySelector(".side-panel-section-label")?.textContent?.trim() || "side panel";
3882
3946
  record.section.classList.toggle("collapsed", collapsed);
3883
3947
  record.content.hidden = collapsed;
3884
3948
  record.button.setAttribute("aria-expanded", collapsed ? "false" : "true");
3885
- record.button.setAttribute("aria-label", `${collapsed ? "Expand" : "Collapse"} ${label} section`);
3886
- record.button.setAttribute("title", `${collapsed ? "Expand" : "Collapse"} ${label} section · drag to reorder · Alt+↑/↓ moves`);
3949
+ updateSidePanelSectionEditAffordance(record);
3887
3950
  if (!collapsed && record.id === "git" && !record.section.hidden) {
3888
3951
  queueMicrotask(() => {
3889
3952
  renderGitPanel();
@@ -3980,7 +4043,7 @@ function bindSidePanelSectionToggles() {
3980
4043
  }
3981
4044
  });
3982
4045
  record.button.addEventListener("keydown", (event) => {
3983
- if (!event.altKey || (event.key !== "ArrowUp" && event.key !== "ArrowDown")) return;
4046
+ if (!isSidePanelSectionReorderingEnabled() || !event.altKey || (event.key !== "ArrowUp" && event.key !== "ArrowDown")) return;
3984
4047
  event.preventDefault();
3985
4048
  moveSidePanelSectionByOffset(record.id, event.key === "ArrowUp" ? -1 : 1);
3986
4049
  });
@@ -6114,18 +6177,70 @@ async function refreshNativeSettings(tabContext = activeTabContext()) {
6114
6177
  applyNativeSettingsForBrowser(response.data?.settings || {});
6115
6178
  }
6116
6179
 
6117
- function setComposerActionsOpen(open) {
6180
+ function mobileComposerSecondaryNodes() {
6181
+ return [
6182
+ elements.workflowModeControls,
6183
+ elements.composerContextTags,
6184
+ elements.busyPromptBehaviorMenu,
6185
+ elements.followUpQueueTrigger,
6186
+ elements.btwButton,
6187
+ elements.conversationVoiceMenu,
6188
+ elements.conversationModeEndButton,
6189
+ ].filter(Boolean);
6190
+ }
6191
+
6192
+ function rememberMobileComposerOriginalPositions() {
6193
+ for (const node of mobileComposerSecondaryNodes()) {
6194
+ if (!mobileComposerOriginalPositions.has(node)) {
6195
+ mobileComposerOriginalPositions.set(node, { parent: node.parentNode, nextSibling: node.nextSibling });
6196
+ }
6197
+ }
6198
+ }
6199
+
6200
+ function restoreMobileComposerOriginalPositions() {
6201
+ for (const [node, { parent, nextSibling }] of mobileComposerOriginalPositions) {
6202
+ if (!parent) continue;
6203
+ if (nextSibling?.parentNode === parent) parent.insertBefore(node, nextSibling);
6204
+ else parent.append(node);
6205
+ }
6206
+ }
6207
+
6208
+ function syncMobileComposerDisclosureLayout() {
6209
+ rememberMobileComposerOriginalPositions();
6210
+ const useMobileDisclosure = isMobileView() && !isMobileShellV2Active();
6211
+ document.body.classList.toggle("mobile-composer-disclosure", useMobileDisclosure);
6212
+ if (!useMobileDisclosure) {
6213
+ restoreMobileComposerOriginalPositions();
6214
+ return;
6215
+ }
6216
+ for (const node of mobileComposerSecondaryNodes()) elements.composerActionsPanel.append(node);
6217
+ }
6218
+
6219
+ function setComposerActionsOpen(open, { restoreFocus = false } = {}) {
6118
6220
  if (isMobileShellV2Active()) return;
6221
+ syncMobileComposerDisclosureLayout();
6119
6222
  const shouldOpen = open && isMobileView();
6120
- if (shouldOpen && followUpQueueOpen) setFollowUpQueueOpen(false);
6223
+ if (shouldOpen) {
6224
+ composerActionsFocusReturn = document.activeElement instanceof HTMLElement ? document.activeElement : elements.composerActionsButton;
6225
+ if (followUpQueueOpen) setFollowUpQueueOpen(false);
6226
+ setMobileTabsExpanded(false);
6227
+ setMobileFooterExpanded(false);
6228
+ }
6121
6229
  document.body.classList.toggle("composer-actions-open", shouldOpen);
6122
6230
  elements.composerActionsButton.setAttribute("aria-expanded", shouldOpen ? "true" : "false");
6231
+ elements.composerActionsButton.textContent = shouldOpen ? "−" : "More";
6232
+ elements.composerActionsButton.setAttribute("aria-label", shouldOpen ? "Minimize more composer actions" : "Show more composer actions");
6233
+ elements.composerActionsButton.title = shouldOpen ? "Minimize more composer actions" : "Show more composer actions";
6234
+ elements.composerActionsPanel.setAttribute("aria-hidden", shouldOpen || !isMobileView() ? "false" : "true");
6123
6235
  if (!shouldOpen) {
6124
6236
  setPublishMenuOpen(false);
6125
6237
  setNativeCommandMenuOpen(false);
6126
6238
  setAppRunnerMenuOpen(false);
6127
6239
  setOptionsMenuOpen(false);
6128
6240
  setBusyPromptBehaviorMenuOpen(false);
6241
+ const focusReturn = restoreFocus ? composerActionsFocusReturn : null;
6242
+ composerActionsFocusReturn = null;
6243
+ if (focusReturn?.isConnected) requestAnimationFrame(() => focusReturn.focus({ preventScroll: true }));
6129
6244
  }
6130
6245
  scheduleMobileDropdownScrollBoundsUpdate();
6131
6246
  if (!shouldOpen) scheduleDeferredUiFlushAfterDropdownClose();
@@ -6275,30 +6390,71 @@ function updateFooterModelPickerPosition() {
6275
6390
  document.documentElement.style.setProperty("--footer-model-picker-right", "auto");
6276
6391
  }
6277
6392
 
6278
- function setMobileFooterExpanded(expanded) {
6393
+ function setMobileFooterExpanded(expanded, { restoreFocus = false } = {}) {
6279
6394
  if (isMobileShellV2Active()) return;
6280
6395
  mobileFooterExpanded = expanded && isMobileView();
6281
- if (mobileFooterExpanded && isFooterPickerOpen()) {
6282
- footerModelPickerOpen = false;
6283
- footerThinkingPickerOpen = false;
6284
- footerBranchPickerOpen = false;
6285
- document.body.classList.remove("footer-model-picker-open");
6286
- elements.statusBar.querySelectorAll(".footer-model-picker").forEach((node) => node.remove());
6396
+ if (mobileFooterExpanded) {
6397
+ setComposerActionsOpen(false);
6398
+ setMobileTabsExpanded(false);
6399
+ if (isFooterPickerOpen()) {
6400
+ footerModelPickerOpen = false;
6401
+ footerThinkingPickerOpen = false;
6402
+ footerBranchPickerOpen = false;
6403
+ document.body.classList.remove("footer-model-picker-open");
6404
+ elements.statusBar.querySelectorAll(".footer-model-picker").forEach((node) => node.remove());
6405
+ }
6287
6406
  }
6288
6407
  document.body.classList.toggle("footer-details-expanded", mobileFooterExpanded);
6289
6408
  const button = elements.statusBar.querySelector(".footer-details-toggle");
6290
6409
  if (button) {
6291
- button.textContent = mobileFooterExpanded ? "Less" : "Details";
6410
+ button.textContent = mobileFooterExpanded ? "−" : "Details";
6411
+ button.setAttribute("aria-label", mobileFooterExpanded ? "Minimize Git footer details" : "Show Git footer details");
6412
+ button.setAttribute("title", mobileFooterExpanded ? "Minimize Git footer details" : "Show Git footer details");
6292
6413
  button.setAttribute("aria-expanded", mobileFooterExpanded ? "true" : "false");
6293
6414
  }
6415
+ if (mobileFooterExpanded && button) {
6416
+ elements.statusBar.setAttribute("aria-label", "Git footer details");
6417
+ activateDrawerModal(elements.statusBar, button, {
6418
+ close: () => setMobileFooterExpanded(false, { restoreFocus: true }),
6419
+ });
6420
+ } else {
6421
+ elements.statusBar.removeAttribute("aria-label");
6422
+ deactivateDrawerModal(elements.statusBar, { restoreFocus });
6423
+ }
6294
6424
  updateFooterModelPickerPosition();
6295
6425
  }
6296
6426
 
6297
- function setMobileTabsExpanded(expanded) {
6427
+ function setMobileTabsExpanded(expanded, { restoreFocus = false } = {}) {
6298
6428
  if (isMobileShellV2Active()) return;
6299
- mobileTabsExpanded = expanded && isMobileView();
6429
+ const shouldExpand = expanded && isMobileView();
6430
+ if (shouldExpand) {
6431
+ mobileTabsFocusReturn = elements.terminalTabsToggleButton;
6432
+ setComposerActionsOpen(false);
6433
+ setMobileFooterExpanded(false);
6434
+ }
6435
+ mobileTabsExpanded = shouldExpand;
6300
6436
  document.body.classList.toggle("mobile-tabs-expanded", mobileTabsExpanded);
6301
6437
  elements.terminalTabsToggleButton.setAttribute("aria-expanded", mobileTabsExpanded ? "true" : "false");
6438
+ if (mobileTabsExpanded) {
6439
+ activateDrawerModal(elements.terminalTabsShell, elements.terminalTabsToggleButton, {
6440
+ close: () => {
6441
+ setNewTabMenuOpen(false);
6442
+ setMobileTabsExpanded(false, { restoreFocus: true });
6443
+ },
6444
+ });
6445
+ } else {
6446
+ deactivateDrawerModal(elements.terminalTabsShell, { restoreFocus: false });
6447
+ }
6448
+ if (elements.terminalTabsBackdrop) elements.terminalTabsBackdrop.hidden = !mobileTabsExpanded;
6449
+ if (elements.terminalTabsDrawerContent) {
6450
+ if (isMobileView()) elements.terminalTabsDrawerContent.setAttribute("aria-hidden", mobileTabsExpanded ? "false" : "true");
6451
+ else elements.terminalTabsDrawerContent.removeAttribute("aria-hidden");
6452
+ }
6453
+ if (!mobileTabsExpanded) {
6454
+ const focusReturn = restoreFocus ? mobileTabsFocusReturn : null;
6455
+ mobileTabsFocusReturn = null;
6456
+ if (focusReturn?.isConnected) requestAnimationFrame(() => focusReturn.focus({ preventScroll: true }));
6457
+ }
6302
6458
  }
6303
6459
 
6304
6460
  function modalFocusableElements(surface) {
@@ -6463,8 +6619,17 @@ function chooseGitWorktreeBase(branch) {
6463
6619
  function handleDrawerModalKeydown(event) {
6464
6620
  if (!activeDrawerModal || event.defaultPrevented) return;
6465
6621
  if (event.key === "Escape") {
6622
+ if (activeDrawerModal.surface === elements.terminalTabsShell && openTerminalTabGroupKey) {
6623
+ event.preventDefault();
6624
+ event.stopPropagation();
6625
+ const openGroup = [...elements.tabBar.querySelectorAll(".terminal-tab-group")]
6626
+ .find((group) => group.dataset.groupKey === openTerminalTabGroupKey);
6627
+ clearOpenTerminalTabGroup(openTerminalTabGroupKey, { force: true });
6628
+ openGroup?.querySelector(".terminal-tab-group-button")?.focus({ preventScroll: true });
6629
+ return;
6630
+ }
6466
6631
  event.preventDefault();
6467
- setSidePanelCollapsed(true, { persist: false });
6632
+ activeDrawerModal.close?.();
6468
6633
  return;
6469
6634
  }
6470
6635
  if (event.key !== "Tab") return;
@@ -6476,7 +6641,10 @@ function handleDrawerModalKeydown(event) {
6476
6641
  }
6477
6642
  const first = focusable[0];
6478
6643
  const last = focusable[focusable.length - 1];
6479
- if (event.shiftKey && document.activeElement === first) {
6644
+ if (!activeDrawerModal.surface.contains(document.activeElement)) {
6645
+ event.preventDefault();
6646
+ (event.shiftKey ? last : first).focus({ preventScroll: true });
6647
+ } else if (event.shiftKey && document.activeElement === first) {
6480
6648
  event.preventDefault();
6481
6649
  last.focus({ preventScroll: true });
6482
6650
  } else if (!event.shiftKey && document.activeElement === last) {
@@ -6485,34 +6653,55 @@ function handleDrawerModalKeydown(event) {
6485
6653
  }
6486
6654
  }
6487
6655
 
6488
- function activateDrawerModal(surface, trigger) {
6489
- if (activeDrawerModal?.surface === surface) return;
6490
- activeDrawerModal = { surface, trigger };
6656
+ function activateDrawerModal(surface, trigger, { close } = {}) {
6657
+ if (activeDrawerModal?.surface === surface) {
6658
+ activeDrawerModal.trigger = trigger;
6659
+ activeDrawerModal.close = close;
6660
+ return;
6661
+ }
6662
+ activeDrawerModal = {
6663
+ surface,
6664
+ trigger,
6665
+ close,
6666
+ previousRole: surface.getAttribute("role"),
6667
+ previousTabindex: surface.getAttribute("tabindex"),
6668
+ };
6669
+ surface.setAttribute("role", "dialog");
6491
6670
  surface.setAttribute("aria-modal", "true");
6492
6671
  surface.setAttribute("tabindex", "-1");
6493
6672
  document.addEventListener("keydown", handleDrawerModalKeydown, true);
6494
6673
  }
6495
6674
 
6496
- function deactivateDrawerModal(surface) {
6675
+ function deactivateDrawerModal(surface, { restoreFocus = true } = {}) {
6497
6676
  if (activeDrawerModal?.surface !== surface) {
6498
6677
  surface?.removeAttribute("aria-modal");
6499
6678
  return;
6500
6679
  }
6501
- const trigger = activeDrawerModal.trigger;
6680
+ const { trigger, previousRole, previousTabindex } = activeDrawerModal;
6502
6681
  activeDrawerModal = null;
6503
6682
  surface.removeAttribute("aria-modal");
6683
+ if (previousRole === null) surface.removeAttribute("role");
6684
+ else surface.setAttribute("role", previousRole);
6685
+ if (previousTabindex === null) surface.removeAttribute("tabindex");
6686
+ else surface.setAttribute("tabindex", previousTabindex);
6504
6687
  document.removeEventListener("keydown", handleDrawerModalKeydown, true);
6505
- if (trigger?.isConnected) queueMicrotask(() => trigger.focus({ preventScroll: true }));
6688
+ if (restoreFocus && trigger?.isConnected) queueMicrotask(() => trigger.focus({ preventScroll: true }));
6506
6689
  }
6507
6690
 
6508
6691
  function syncMobileSidePanelState(collapsed) {
6509
6692
  const showBackdrop = !collapsed && isSidePanelOverlayView();
6510
6693
  elements.sidePanelBackdrop.hidden = !showBackdrop;
6511
- if (showBackdrop) activateDrawerModal(elements.sidePanel, elements.sidePanelExpandButton);
6512
- else deactivateDrawerModal(elements.sidePanel);
6694
+ if (showBackdrop) {
6695
+ activateDrawerModal(elements.sidePanel, elements.sidePanelExpandButton, {
6696
+ close: () => setSidePanelCollapsed(true, { persist: false }),
6697
+ });
6698
+ } else {
6699
+ deactivateDrawerModal(elements.sidePanel);
6700
+ }
6513
6701
  }
6514
6702
 
6515
6703
  function setSidePanelCollapsed(collapsed, { persist = true, focusPanel = false } = {}) {
6704
+ if (collapsed) setSidePanelSectionEditMode(false);
6516
6705
  document.body.classList.toggle("side-panel-collapsed", collapsed);
6517
6706
  elements.toggleSidePanelButton.setAttribute("aria-expanded", collapsed ? "false" : "true");
6518
6707
  elements.toggleSidePanelButton.setAttribute("title", collapsed ? "Expand side panel" : "Collapse side panel");
@@ -6612,6 +6801,8 @@ function bindMobileViewChanges() {
6612
6801
  const syncForViewport = (event) => {
6613
6802
  applyMobileShellViewport();
6614
6803
  syncComposerActionGridAvailability();
6804
+ syncMobileComposerDisclosureLayout();
6805
+ setSidePanelSectionEditMode(false);
6615
6806
  if (isMobileShellV2Active()) return;
6616
6807
  setComposerActionsOpen(false);
6617
6808
  setMobileFooterExpanded(false);
@@ -10833,9 +11024,11 @@ function fileTreeExpander(expanded = false) {
10833
11024
  function appendFileSearchEntry(parent, entry) {
10834
11025
  const path = normalizeFileTreePath(entry.path);
10835
11026
  const isDirectory = entry.type === "directory" || entry.directory === true;
11027
+ const expanded = isDirectory && fileTreeState.expanded.has(path);
11028
+ const loading = isDirectory && fileTreeState.loading.has(path);
10836
11029
  const gitStatus = fileTreeGitStatusForEntry(entry);
10837
11030
  const gitStatusClasses = fileTreeGitStatusClasses(gitStatus);
10838
- const item = make("li", `file-tree-node file-tree-search-node ${entry.type || "file"}${gitStatusClasses ? ` ${gitStatusClasses}` : ""}${fileTreeState.selectedPath === path ? " selected" : ""}`);
11031
+ const item = make("li", `file-tree-node file-tree-search-node ${entry.type || "file"}${gitStatusClasses ? ` ${gitStatusClasses}` : ""}${expanded ? " expanded" : ""}${fileTreeState.selectedPath === path ? " selected" : ""}`);
10839
11032
  item.setAttribute("role", "none");
10840
11033
  const button = make("button", "file-tree-item file-tree-search-item");
10841
11034
  button.type = "button";
@@ -10845,18 +11038,19 @@ function appendFileSearchEntry(parent, entry) {
10845
11038
  button.setAttribute("role", "treeitem");
10846
11039
  button.setAttribute("aria-selected", fileTreeState.selectedPath === path ? "true" : "false");
10847
11040
  if (isDirectory) {
10848
- button.setAttribute("aria-expanded", "false");
10849
- button.setAttribute("aria-label", `Expand ${entry.name || fileDisplayName(path)}`);
11041
+ button.setAttribute("aria-expanded", expanded ? "true" : "false");
11042
+ button.setAttribute("aria-label", `${expanded ? "Collapse" : "Expand"} ${entry.name || fileDisplayName(path)}`);
10850
11043
  }
10851
11044
  button.title = [path || ".", fileTreeGitStatusTitle(gitStatus), entry.error || ""].filter(Boolean).join("\n");
11045
+ const contextPath = fileParentPath(path) || ".";
10852
11046
  const label = make("span", "file-tree-search-label");
10853
11047
  label.append(
10854
11048
  make("span", "file-tree-name", entry.name || fileDisplayName(path)),
10855
- make("span", "file-tree-search-path", path || "."),
11049
+ make("span", "file-tree-search-path", contextPath),
10856
11050
  );
10857
11051
  button.append(
10858
- isDirectory ? fileTreeExpander(false) : make("span", "file-tree-expander-spacer"),
10859
- make("span", "file-tree-icon", fileEntryIcon(entry)),
11052
+ isDirectory ? fileTreeExpander(expanded) : make("span", "file-tree-expander-spacer"),
11053
+ make("span", "file-tree-icon", loading ? "…" : fileEntryIcon(entry)),
10860
11054
  label,
10861
11055
  );
10862
11056
  const gitBadge = fileTreeGitStatusBadge(gitStatus);
@@ -10867,20 +11061,28 @@ function appendFileSearchEntry(parent, entry) {
10867
11061
  button.addEventListener("click", () => {
10868
11062
  fileTreeState.selectedPath = path;
10869
11063
  if (entry.type === "file") openFileInViewer(path);
10870
- else revealFileTreeEntry(entry).catch((error) => addEvent(error.message || String(error), "error"));
11064
+ else toggleFileTreeDirectory(path).catch((error) => addEvent(error.message || String(error), "error"));
10871
11065
  });
10872
11066
  button.addEventListener("contextmenu", (event) => showFileContextMenu(event, entry));
10873
11067
  bindFileTreeDragAndDrop(button, item, entry);
10874
11068
  item.append(button, fileTreeOverflowButton(entry));
11069
+ if (isDirectory && expanded) {
11070
+ const children = fileTreeState.entriesByPath.get(path) || [];
11071
+ const childList = make("ul", "file-tree-list");
11072
+ childList.setAttribute("role", "group");
11073
+ if (loading) childList.append(make("li", "file-tree-loading muted", "Loading…"));
11074
+ else if (!children.length) childList.append(make("li", "file-tree-empty muted", "Empty"));
11075
+ else for (const child of children) appendFileTreeEntry(childList, child, 1);
11076
+ item.append(childList);
11077
+ }
10875
11078
  parent.append(item);
10876
11079
  }
10877
11080
 
10878
- async function revealFileTreeEntry(entry = {}) {
11081
+ async function revealFileTreeEntry(entry = {}, { expandTarget = true } = {}) {
10879
11082
  const targetPath = normalizeFileTreePath(entry.path || "");
10880
11083
  if (!targetPath && targetPath !== FILE_TREE_ROOT_PATH) return;
10881
11084
  const isDirectory = entry.type === "directory" || entry.directory === true;
10882
- const parentPath = isDirectory ? targetPath : fileParentPath(targetPath);
10883
- clearFileTreeSearch();
11085
+ const parentPath = fileParentPath(targetPath);
10884
11086
  fileTreeState.selectedPath = targetPath;
10885
11087
  await loadFileTreeDirectory(FILE_TREE_ROOT_PATH);
10886
11088
  let currentPath = "";
@@ -10890,7 +11092,7 @@ async function revealFileTreeEntry(entry = {}) {
10890
11092
  renderFileTree();
10891
11093
  await loadFileTreeDirectory(currentPath);
10892
11094
  }
10893
- if (isDirectory) {
11095
+ if (isDirectory && expandTarget) {
10894
11096
  fileTreeState.expanded.add(targetPath);
10895
11097
  await loadFileTreeDirectory(targetPath);
10896
11098
  }
@@ -10988,21 +11190,49 @@ async function loadFileTreeDirectory(path = FILE_TREE_ROOT_PATH, { force = false
10988
11190
  }
10989
11191
  }
10990
11192
 
11193
+ function focusVisibleFileTreeSelection(path = fileTreeState.selectedPath) {
11194
+ const normalized = normalizeFileTreePath(path);
11195
+ if (!normalized) return false;
11196
+ const selected = visibleFileTreeItems().find((item) => normalizeFileTreePath(item.dataset.path) === normalized);
11197
+ if (!selected) return false;
11198
+ selected.focus({ preventScroll: true });
11199
+ selected.scrollIntoView?.({ block: "nearest" });
11200
+ return true;
11201
+ }
11202
+
10991
11203
  function clearFileTreeSearch({ focus = false } = {}) {
10992
11204
  clearTimeout(fileTreeSearchTimer);
10993
11205
  fileTreeSearchTimer = null;
10994
11206
  fileTreeSearchRequestSerial += 1;
11207
+ const serial = fileTreeSearchRequestSerial;
11208
+ const selectedPath = normalizeFileTreePath(fileTreeState.selectedPath || "");
11209
+ const selectedEntry = fileTreeState.searchEntries.find((entry) => normalizeFileTreePath(entry.path) === selectedPath) || fileEntryByPath(selectedPath);
11210
+ const selectedDirectoryExpanded = fileTreeState.expanded.has(selectedPath);
10995
11211
  if (elements.fileTreeSearchInput) elements.fileTreeSearchInput.value = "";
10996
- fileTreeState.searchQuery = "";
10997
- fileTreeState.searchEntries = [];
10998
- fileTreeState.searchLoading = false;
10999
- fileTreeState.searchTruncated = false;
11000
- fileTreeState.searchTotal = 0;
11001
11212
  updateFileTreeSearchControls();
11002
- const rootEntries = fileTreeState.entriesByPath.get(FILE_TREE_ROOT_PATH) || [];
11003
- setFileTreeStatus(rootEntries.length ? fileTreeEntriesStatus(rootEntries) : "");
11004
- renderFileTree();
11005
- if (focus) elements.fileTreeSearchInput?.focus();
11213
+
11214
+ const commitClear = () => {
11215
+ if (serial !== fileTreeSearchRequestSerial || fileTreeSearchQueryText()) return;
11216
+ fileTreeState.searchQuery = "";
11217
+ fileTreeState.searchEntries = [];
11218
+ fileTreeState.searchLoading = false;
11219
+ fileTreeState.searchTruncated = false;
11220
+ fileTreeState.searchTotal = 0;
11221
+ const rootEntries = fileTreeState.entriesByPath.get(FILE_TREE_ROOT_PATH) || [];
11222
+ setFileTreeStatus(rootEntries.length ? fileTreeEntriesStatus(rootEntries) : "");
11223
+ renderFileTree();
11224
+ if (selectedPath && focusVisibleFileTreeSelection(selectedPath)) return;
11225
+ if (focus) elements.fileTreeSearchInput?.focus();
11226
+ };
11227
+
11228
+ if (!selectedPath || !selectedEntry) {
11229
+ commitClear();
11230
+ return;
11231
+ }
11232
+ revealFileTreeEntry(selectedEntry, { expandTarget: selectedDirectoryExpanded }).then(commitClear).catch((error) => {
11233
+ addEvent(error.message || String(error), "error");
11234
+ commitClear();
11235
+ });
11006
11236
  }
11007
11237
 
11008
11238
  async function runFileTreeSearch({ background = false } = {}) {
@@ -14680,11 +14910,11 @@ function terminalTabGroupTooltip(group, groupTitle = terminalDisplayGroupTitle(g
14680
14910
  ];
14681
14911
  const active = terminalTabGroupActiveTooltip(groupTabs);
14682
14912
  if (active) lines.push(`Active: ${active}`);
14683
- lines.push("Click to switch · Drop tabs here to add");
14913
+ lines.push(isMobileView() ? "Tap to open group terminals" : "Click to switch · Drop tabs here to add");
14684
14914
  return lines.join("\n");
14685
14915
  }
14686
14916
 
14687
- function appendTerminalTabContent(button, { title, indicator, meta, count = null, appRunnerRun = null, conversationModeActive = false, workflowModeActive = false, workflowCount = 0, subagent = false }) {
14917
+ function appendTerminalTabContent(button, { title, indicator, meta, count = null, appRunnerRun = null, conversationModeActive = false, workflowModeActive = false, workflowCount = 0, subagent = false, dropdown = false }) {
14688
14918
  const titleRow = make("span", "terminal-tab-title-row");
14689
14919
  const indicatorDot = make("span", "terminal-tab-activity-indicator");
14690
14920
  indicatorDot.setAttribute("aria-hidden", "true");
@@ -14694,6 +14924,11 @@ function appendTerminalTabContent(button, { title, indicator, meta, count = null
14694
14924
  if (conversationModeActive) titleRow.append(make("span", "terminal-tab-conversation-indicator", "voice"));
14695
14925
  if (workflowModeActive || workflowCount) titleRow.append(make("span", "terminal-tab-workflow-indicator", workflowCount ? `wf ${workflowCount}` : "wf"));
14696
14926
  if (count !== null) titleRow.append(make("span", "terminal-tab-group-count", String(count)));
14927
+ if (dropdown) {
14928
+ const disclosure = make("span", "terminal-tab-group-dropdown-indicator", "⌄");
14929
+ disclosure.setAttribute("aria-hidden", "true");
14930
+ titleRow.append(disclosure);
14931
+ }
14697
14932
  button.append(titleRow, make("span", "terminal-tab-meta", meta));
14698
14933
  }
14699
14934
 
@@ -14801,10 +15036,19 @@ function renderTerminalTabGroup(group, groupCount = 1) {
14801
15036
  wrapper.dataset.groupKey = group.key;
14802
15037
  if (group.customGroupId) wrapper.dataset.customGroupId = group.customGroupId;
14803
15038
  bindTerminalTabDragAndDrop(wrapper, { sourceTabId: activeGroupTab?.id || "", target: { type: "group", group } });
14804
- wrapper.addEventListener("pointerenter", () => setOpenTerminalTabGroup(group.key));
14805
- wrapper.addEventListener("pointerleave", () => clearOpenTerminalTabGroup(group.key));
14806
- wrapper.addEventListener("focusin", () => setOpenTerminalTabGroup(group.key));
15039
+ wrapper.addEventListener("pointerenter", (event) => {
15040
+ if (event.pointerType === "touch") return;
15041
+ setOpenTerminalTabGroup(group.key);
15042
+ });
15043
+ wrapper.addEventListener("pointerleave", (event) => {
15044
+ if (event.pointerType === "touch") return;
15045
+ clearOpenTerminalTabGroup(group.key);
15046
+ });
15047
+ wrapper.addEventListener("focusin", () => {
15048
+ if (!isMobileView()) setOpenTerminalTabGroup(group.key);
15049
+ });
14807
15050
  wrapper.addEventListener("focusout", () => {
15051
+ if (isMobileView()) return;
14808
15052
  setTimeout(() => {
14809
15053
  if (!wrapper.contains(document.activeElement)) clearOpenTerminalTabGroup(group.key);
14810
15054
  }, 0);
@@ -14816,10 +15060,16 @@ function renderTerminalTabGroup(group, groupCount = 1) {
14816
15060
  button.setAttribute("aria-selected", isActive ? "true" : "false");
14817
15061
  button.setAttribute("aria-haspopup", "true");
14818
15062
  button.setAttribute("aria-expanded", group.key === openTerminalTabGroupKey ? "true" : "false");
14819
- button.setAttribute("aria-label", `${groupTitle} ${group.custom ? "custom" : "cwd"} group: ${groupTabs.length} tabs, ${indicator.label}${appRunnerSummary ? `, ${appRunnerSummary}` : ""}${workflowModeActive ? ", workflow mode active" : ""}${workflowCount ? `, ${workflowCount} workflow runs active` : ""}. Active ${activeTitle}`);
15063
+ button.setAttribute("aria-label", `${groupTitle} ${group.custom ? "custom" : "cwd"} group: ${groupTabs.length} tabs, ${indicator.label}${appRunnerSummary ? `, ${appRunnerSummary}` : ""}${workflowModeActive ? ", workflow mode active" : ""}${workflowCount ? `, ${workflowCount} workflow runs active` : ""}. Active ${activeTitle}. ${isMobileView() ? "Toggle group terminal list" : "Switch to the active group terminal"}`);
14820
15064
  applyStyledTooltip(button, terminalTabGroupTooltip(group, groupTitle), { ariaLabel: false, description: true, placement: "right", variant: "workspace", targetKey: `terminal-group:${group.key}:switch` });
14821
- appendTerminalTabContent(button, { title: activeTitle, indicator, meta: `${groupTitle} · ${indicator.meta}${groupAppRunnerMeta ? ` · ${groupAppRunnerMeta}` : ""}${workflowModeActive ? " · workflow mode" : ""}${workflowCount ? ` · ${workflowCount} workflows` : ""}`, appRunnerRun, count: groupTabs.length, workflowModeActive, workflowCount });
14822
- button.addEventListener("click", () => switchTab(activeGroupTab.id));
15065
+ appendTerminalTabContent(button, { title: activeTitle, indicator, meta: `${groupTitle} · ${indicator.meta}${groupAppRunnerMeta ? ` · ${groupAppRunnerMeta}` : ""}${workflowModeActive ? " · workflow mode" : ""}${workflowCount ? ` · ${workflowCount} workflows` : ""}`, appRunnerRun, count: groupTabs.length, workflowModeActive, workflowCount, dropdown: true });
15066
+ button.addEventListener("click", () => {
15067
+ if (isMobileView()) {
15068
+ toggleOpenTerminalTabGroup(group.key);
15069
+ return;
15070
+ }
15071
+ switchTab(activeGroupTab.id);
15072
+ });
14823
15073
  wrapper.append(button);
14824
15074
 
14825
15075
  if (groupCount > 1 || group.custom) {
@@ -14836,8 +15086,10 @@ function renderTerminalTabGroup(group, groupCount = 1) {
14836
15086
  }
14837
15087
 
14838
15088
  const menu = make("div", "terminal-tab-group-menu");
15089
+ menu.id = `terminalTabGroupMenu${++terminalTabGroupMenuSerial}`;
14839
15090
  menu.setAttribute("role", "group");
14840
15091
  menu.setAttribute("aria-label", `${groupTitle} tabs`);
15092
+ button.setAttribute("aria-controls", menu.id);
14841
15093
  for (const tab of groupTabs) menu.append(renderTerminalTabGroupItem(tab, group));
14842
15094
 
14843
15095
  const add = make("button", "terminal-tab-group-add", "+ Tab");
@@ -14868,6 +15120,12 @@ function setOpenTerminalTabGroup(groupKey) {
14868
15120
  updateTerminalTabGroupOpenState();
14869
15121
  }
14870
15122
 
15123
+ function toggleOpenTerminalTabGroup(groupKey) {
15124
+ if (!groupKey) return;
15125
+ if (openTerminalTabGroupKey === groupKey) clearOpenTerminalTabGroup(groupKey);
15126
+ else setOpenTerminalTabGroup(groupKey);
15127
+ }
15128
+
14871
15129
  function clearOpenTerminalTabGroup(groupKey, { force = false } = {}) {
14872
15130
  if (!openTerminalTabGroupKey || (!force && openTerminalTabGroupKey !== groupKey)) return;
14873
15131
  openTerminalTabGroupKey = null;
@@ -15043,6 +15301,8 @@ async function refreshTabs({ selectStored = false } = {}) {
15043
15301
  async function switchTab(tabId) {
15044
15302
  if (!tabId || !tabs.some((tab) => tab.id === tabId)) return;
15045
15303
  if (tabId === activeTabId) {
15304
+ clearOpenTerminalTabGroup(null, { force: true });
15305
+ setMobileTabsExpanded(false);
15046
15306
  if (activeSubagentTerminalId) deactivateSubagentTerminalView({ focusParent: true });
15047
15307
  return;
15048
15308
  }
@@ -16292,10 +16552,13 @@ function hideFooterTooltip(target) {
16292
16552
  function bindStyledTooltipEvents(node) {
16293
16553
  if (!node || node._styledTooltipBound) return;
16294
16554
  node._styledTooltipBound = true;
16295
- node.addEventListener("mouseenter", () => scheduleFooterTooltip(node));
16296
- node.addEventListener("mouseleave", () => hideFooterTooltip(node));
16555
+ node.addEventListener("pointerenter", (event) => {
16556
+ if (event.pointerType === "touch") return;
16557
+ scheduleFooterTooltip(node);
16558
+ });
16559
+ node.addEventListener("pointerleave", () => hideFooterTooltip(node));
16297
16560
  node.addEventListener("focus", () => {
16298
- if (node.getAttribute("data-tooltip-variant") === "workspace" && !node.matches(":focus-visible")) return;
16561
+ if (!node.matches(":focus-visible")) return;
16299
16562
  showFooterTooltip(node);
16300
16563
  });
16301
16564
  node.addEventListener("blur", () => hideFooterTooltip(node));
@@ -16334,12 +16597,17 @@ function applyFooterTooltip(node, tooltip, options = {}) {
16334
16597
  return applyStyledTooltip(node, tooltip, options);
16335
16598
  }
16336
16599
 
16600
+ function runFooterControlAction(action, event) {
16601
+ if (mobileFooterExpanded) setMobileFooterExpanded(false, { restoreFocus: false });
16602
+ return action(event);
16603
+ }
16604
+
16337
16605
  function footerMetric(icon, label, value, tone = "", options = {}) {
16338
16606
  const isAction = typeof options.onClick === "function";
16339
16607
  const node = make(isAction ? "button" : "span", ["footer-metric", tone, isAction ? "footer-metric-action" : ""].filter(Boolean).join(" "));
16340
16608
  if (isAction) {
16341
16609
  node.type = "button";
16342
- node.addEventListener("click", options.onClick);
16610
+ node.addEventListener("click", (event) => runFooterControlAction(options.onClick, event));
16343
16611
  if (options.ariaPressed !== undefined) node.setAttribute("aria-pressed", options.ariaPressed ? "true" : "false");
16344
16612
  if (options.ariaBusy) node.setAttribute("aria-busy", "true");
16345
16613
  }
@@ -16445,7 +16713,7 @@ function footerMeta(label, value, className = "", options = {}) {
16445
16713
  const node = make(isAction ? "button" : "span", ["footer-meta", className, isAction ? "footer-meta-action" : ""].filter(Boolean).join(" "));
16446
16714
  if (isAction) {
16447
16715
  node.type = "button";
16448
- node.addEventListener("click", options.onClick);
16716
+ node.addEventListener("click", (event) => runFooterControlAction(options.onClick, event));
16449
16717
  if (options.ariaPressed !== undefined) node.setAttribute("aria-pressed", options.ariaPressed ? "true" : "false");
16450
16718
  if (options.ariaBusy) node.setAttribute("aria-busy", "true");
16451
16719
  if (options.disabled) {
@@ -17738,10 +18006,12 @@ function renderGitFooterPayload(payload) {
17738
18006
  const row2 = make("div", "footer-line footer-line-meta");
17739
18007
  const row2Children = [...metaNodes];
17740
18008
  if (gitFooterPayloadVisible(payload, "webui-details-button")) {
17741
- const footerToggle = make("button", "footer-details-toggle", mobileFooterExpanded ? "Less" : "Details");
18009
+ const footerToggle = make("button", "footer-details-toggle", mobileFooterExpanded ? "−" : "Details");
17742
18010
  footerToggle.type = "button";
18011
+ footerToggle.setAttribute("aria-label", mobileFooterExpanded ? "Minimize Git footer details" : "Show Git footer details");
18012
+ footerToggle.setAttribute("title", mobileFooterExpanded ? "Minimize Git footer details" : "Show Git footer details");
17743
18013
  footerToggle.setAttribute("aria-expanded", mobileFooterExpanded ? "true" : "false");
17744
- footerToggle.addEventListener("click", () => setMobileFooterExpanded(!mobileFooterExpanded));
18014
+ footerToggle.addEventListener("click", () => setMobileFooterExpanded(!mobileFooterExpanded, { restoreFocus: true }));
17745
18015
  row2Children.push(footerToggle);
17746
18016
  }
17747
18017
  row2.append(...row2Children);
@@ -20160,7 +20430,8 @@ async function confirmFooterGitWorktreeAction(branch, { path = "", create = fals
20160
20430
  ...(trackedRemoteRef ? [`Remote ref: ${trackedRemoteRef}`, `Creates local branch ${branchName} tracking ${trackedRemoteRef}.`] : []),
20161
20431
  targetPath ? `Worktree: ${targetPath}` : `Default location: ${footerBranchPickerState.defaultWorktreesRoot || "repo sibling .worktrees directory"}`,
20162
20432
  "",
20163
- "This opens a separate checkout in a separate Pi tab and does not switch this tab's branch.",
20433
+ "This creates a separate checkout without changing this tab's branch.",
20434
+ "After creation, you can choose whether to open it in a separate Pi tab and switch to it.",
20164
20435
  "Ignored dependencies such as node_modules or .venv are not copied; bootstrap them manually if needed.",
20165
20436
  "",
20166
20437
  "Continue?",
@@ -20242,7 +20513,7 @@ function footerBranchCreateTooltip(branchName = footerBranchCreateName(), state
20242
20513
  "",
20243
20514
  "What happens:",
20244
20515
  "• asks whether to base the new branch on origin/main (default) or this workspace's current HEAD",
20245
- "• opens a separate Pi tab rooted at that worktree",
20516
+ "• creates the worktree, then asks whether to open and switch to it in a separate Pi tab",
20246
20517
  "• does not switch this tab's branch, commit, push, or delete anything",
20247
20518
  "",
20248
20519
  "Tip: ignored dependencies such as node_modules or .venv are not copied.",
@@ -20260,7 +20531,7 @@ async function createFooterGitBranch(branch = footerBranchCreateName()) {
20260
20531
  await applyFooterGitBranch(branchName, { create: true, tabContext, skipConfirm: true });
20261
20532
  }
20262
20533
 
20263
- async function openWorktreeResponseTab(response, { branchName = "", action = "open" } = {}) {
20534
+ async function openWorktreeResponseTab(response, { branchName = "", action = "open", announce = true } = {}) {
20264
20535
  if (!response.ok) throw new Error(response.error || `Failed to ${action} branch worktree`);
20265
20536
  const payload = response.data || {};
20266
20537
  if (Array.isArray(payload.tabs)) {
@@ -20277,12 +20548,27 @@ async function openWorktreeResponseTab(response, { branchName = "", action = "op
20277
20548
  const branch = cleanStatusText(payload.worktree?.branch || payload.branch || branchName || targetTab?.gitWorkspace?.branch || "");
20278
20549
  const where = payload.worktree?.path || payload.path || targetTab?.cwd || "worktree";
20279
20550
  const prefix = payload.created ? "Created" : payload.openedExisting || payload.openedExistingTab ? "Opened existing" : "Opened";
20280
- addEvent(`${prefix} branch worktree${branch ? ` ${branch}` : ""} at ${normalizeDisplayPath(where)}.`, "success");
20551
+ if (announce) addEvent(`${prefix} branch worktree${branch ? ` ${branch}` : ""} at ${normalizeDisplayPath(where)}.`, "success");
20281
20552
  if (payload.session?.warning) addEvent(payload.session.warning, "warn");
20282
20553
  if (payload.dependencyHint) addEvent(payload.dependencyHint, "info");
20283
20554
  requestGitFooterWebuiPayload(activeTabContext(), { force: true });
20284
20555
  }
20285
20556
 
20557
+ async function confirmSwitchToCreatedFooterGitWorktree(payload = {}, branchName = "") {
20558
+ if (payload.created !== true) return false;
20559
+ const branch = cleanStatusText(payload.worktree?.branch || payload.branch || branchName);
20560
+ const worktreePath = cleanFooterPayloadText(payload.worktree?.path || payload.path, "", 4000);
20561
+ if (!worktreePath) return false;
20562
+ return appConfirm({
20563
+ title: "Switch to new worktree?",
20564
+ summary: `The${branch ? ` ${branch}` : ""} worktree was created. Open it in a separate Pi tab and switch to it now? The worktree remains available if you stay here.`,
20565
+ affected: normalizeDisplayPath(worktreePath),
20566
+ undoable: true,
20567
+ confirmLabel: "Switch to worktree",
20568
+ danger: false,
20569
+ });
20570
+ }
20571
+
20286
20572
  async function createFooterGitBranchWorktree(branch = footerBranchCreateName(), { tabContext = activeTabContext(), skipConfirm = false, chooseBase = true, remoteRef = "", switchingLabel = "", switchingKey = "" } = {}) {
20287
20573
  const branchName = cleanStatusText(branch);
20288
20574
  if (!branchName) {
@@ -20300,9 +20586,20 @@ async function createFooterGitBranchWorktree(branch = footerBranchCreateName(),
20300
20586
  // Remote-only creation submits the exact advertised remote ref instead of a
20301
20587
  // base ref; the server re-verifies it and creates a local tracking branch.
20302
20588
  const response = trackedRemoteRef
20303
- ? await api("/api/git-worktrees", { method: "POST", body: { branchName, remoteRef: trackedRemoteRef, sessionMode: "fork-current", openTab: true }, tabId })
20304
- : await api("/api/git-worktrees", { method: "POST", body: { branchName, baseRef, sessionMode: "fork-current", openTab: true }, tabId });
20305
- await openWorktreeResponseTab(response, { branchName, action: "create" });
20589
+ ? await api("/api/git-worktrees", { method: "POST", body: { branchName, remoteRef: trackedRemoteRef, sessionMode: "fork-current", openTab: false }, tabId })
20590
+ : await api("/api/git-worktrees", { method: "POST", body: { branchName, baseRef, sessionMode: "fork-current", openTab: false }, tabId });
20591
+ if (!response.ok) throw new Error(response.error || "Failed to create branch worktree");
20592
+ const payload = response.data || {};
20593
+ const worktreePath = cleanFooterPayloadText(payload.worktree?.path || payload.path, "", 4000);
20594
+ if (!worktreePath) throw new Error("Git worktree creation did not return a path");
20595
+ if (payload.created) {
20596
+ await openWorktreeResponseTab(response, { branchName, action: "create" });
20597
+ if (await confirmSwitchToCreatedFooterGitWorktree(payload, branchName)) {
20598
+ await openFooterGitWorktree(worktreePath, { branchName, tabContext, skipConfirm: true, announce: false });
20599
+ }
20600
+ } else {
20601
+ await openFooterGitWorktree(worktreePath, { branchName, tabContext, skipConfirm: true });
20602
+ }
20306
20603
  } catch (error) {
20307
20604
  if (isCurrentTabContext(tabContext)) {
20308
20605
  footerBranchPickerState = { ...footerBranchPickerState, loading: false, switching: "", switchingKey: "", error: error.message || String(error) };
@@ -20313,7 +20610,7 @@ async function createFooterGitBranchWorktree(branch = footerBranchCreateName(),
20313
20610
  }
20314
20611
  }
20315
20612
 
20316
- async function openFooterGitWorktree(path, { branchName = "", tabContext = activeTabContext(), skipConfirm = false, switchingKey = "" } = {}) {
20613
+ async function openFooterGitWorktree(path, { branchName = "", tabContext = activeTabContext(), skipConfirm = false, switchingKey = "", announce = true } = {}) {
20317
20614
  const worktreePath = cleanFooterPayloadText(path, "", 4000);
20318
20615
  if (!worktreePath) return;
20319
20616
  if (!skipConfirm && !(await confirmFooterGitWorktreeAction(branchName, { path: worktreePath, requireConfirm: false }))) return;
@@ -20322,7 +20619,7 @@ async function openFooterGitWorktree(path, { branchName = "", tabContext = activ
20322
20619
  footerBranchPickerState = { ...footerBranchPickerState, loading: true, error: "", switching: branchName || worktreePath, switchingKey, tabId };
20323
20620
  renderFooter();
20324
20621
  const response = await api("/api/git-worktrees/open", { method: "POST", body: { path: worktreePath, sessionMode: "fork-current", openTab: true }, tabId });
20325
- await openWorktreeResponseTab(response, { branchName, action: "open" });
20622
+ await openWorktreeResponseTab(response, { branchName, action: "open", announce });
20326
20623
  } catch (error) {
20327
20624
  if (isCurrentTabContext(tabContext)) {
20328
20625
  footerBranchPickerState = { ...footerBranchPickerState, loading: false, switching: "", switchingKey: "", error: error.message || String(error) };
@@ -22847,6 +23144,8 @@ function deactivateSubagentTerminalView({ render = true, focusParent = false } =
22847
23144
  async function activateSubagentTerminalView(viewId) {
22848
23145
  const view = subagentTerminalViews.get(viewId);
22849
23146
  if (!view) return;
23147
+ clearOpenTerminalTabGroup(null, { force: true });
23148
+ setMobileTabsExpanded(false);
22850
23149
  if (activeTabId !== view.parentTabId) await switchTab(view.parentTabId);
22851
23150
  closeSubagentOverlay();
22852
23151
  activeSubagentTerminalId = view.id;
@@ -23077,10 +23376,19 @@ function renderSubagentTerminalTabGroup(group) {
23077
23376
  const groupTitle = group.parentTitle || "workspace";
23078
23377
  const wrapper = make("div", `terminal-tab terminal-tab-group terminal-tab-subagent terminal-tab-subagent-group ${stateClass}${active ? " active" : ""}`);
23079
23378
  wrapper.dataset.groupKey = group.key;
23080
- wrapper.addEventListener("pointerenter", () => setOpenTerminalTabGroup(group.key));
23081
- wrapper.addEventListener("pointerleave", () => clearOpenTerminalTabGroup(group.key));
23082
- wrapper.addEventListener("focusin", () => setOpenTerminalTabGroup(group.key));
23379
+ wrapper.addEventListener("pointerenter", (event) => {
23380
+ if (event.pointerType === "touch") return;
23381
+ setOpenTerminalTabGroup(group.key);
23382
+ });
23383
+ wrapper.addEventListener("pointerleave", (event) => {
23384
+ if (event.pointerType === "touch") return;
23385
+ clearOpenTerminalTabGroup(group.key);
23386
+ });
23387
+ wrapper.addEventListener("focusin", () => {
23388
+ if (!isMobileView()) setOpenTerminalTabGroup(group.key);
23389
+ });
23083
23390
  wrapper.addEventListener("focusout", () => {
23391
+ if (isMobileView()) return;
23084
23392
  setTimeout(() => {
23085
23393
  if (!wrapper.contains(document.activeElement)) clearOpenTerminalTabGroup(group.key);
23086
23394
  }, 0);
@@ -23092,7 +23400,7 @@ function renderSubagentTerminalTabGroup(group) {
23092
23400
  button.setAttribute("aria-selected", active ? "true" : "false");
23093
23401
  button.setAttribute("aria-haspopup", "true");
23094
23402
  button.setAttribute("aria-expanded", group.key === openTerminalTabGroupKey ? "true" : "false");
23095
- button.setAttribute("aria-label", `${groupTitle} workspace subagents: ${groupViews.length} views, ${runningCount} running. Active ${subagentTerminalViewTitle(activeView)}`);
23403
+ button.setAttribute("aria-label", `${groupTitle} workspace subagents: ${groupViews.length} views, ${runningCount} running. Active ${subagentTerminalViewTitle(activeView)}. ${isMobileView() ? "Toggle subagent view list" : "Switch to the active subagent view"}`);
23096
23404
  applyStyledTooltip(button, `${groupTitle} · ${groupViews.length} subagent views\n${runningCount ? `${runningCount} running` : "All finished"}\nActive: ${subagentTerminalViewTitle(activeView)}`, { ariaLabel: false, description: true, placement: "right", variant: "workspace" });
23097
23405
  appendTerminalTabContent(button, {
23098
23406
  title: groupTitle,
@@ -23100,8 +23408,15 @@ function renderSubagentTerminalTabGroup(group) {
23100
23408
  meta: `${groupViews.length} subagents · ${runningCount ? `${runningCount} running` : "finished"}`,
23101
23409
  count: groupViews.length,
23102
23410
  subagent: true,
23411
+ dropdown: true,
23412
+ });
23413
+ button.addEventListener("click", () => {
23414
+ if (isMobileView()) {
23415
+ toggleOpenTerminalTabGroup(group.key);
23416
+ return;
23417
+ }
23418
+ activateSubagentTerminalView(activeView.id);
23103
23419
  });
23104
- button.addEventListener("click", () => activateSubagentTerminalView(activeView.id));
23105
23420
  wrapper.append(button);
23106
23421
 
23107
23422
  const close = make("button", "terminal-tab-close terminal-tab-group-close", "×");
@@ -23114,8 +23429,10 @@ function renderSubagentTerminalTabGroup(group) {
23114
23429
  wrapper.append(close);
23115
23430
 
23116
23431
  const menu = make("div", "terminal-tab-group-menu");
23432
+ menu.id = `terminalTabGroupMenu${++terminalTabGroupMenuSerial}`;
23117
23433
  menu.setAttribute("role", "group");
23118
23434
  menu.setAttribute("aria-label", `${groupTitle} subagent views`);
23435
+ button.setAttribute("aria-controls", menu.id);
23119
23436
  for (const view of groupViews) menu.append(renderSubagentTerminalTab(view, { groupItem: true }));
23120
23437
  wrapper.append(menu);
23121
23438
  return wrapper;
@@ -33038,14 +33355,14 @@ function resetChatOutput() {
33038
33355
  renderedTranscriptState = { epoch: "", entries: [] };
33039
33356
  const liveBubbles = standaloneLiveTranscriptBubbles();
33040
33357
  const preservedNodes = [...elements.chat.children]
33041
- .filter((child) => child === elements.stickyUserPromptButton || child === runIndicatorBubble || liveBubbles.has(child));
33358
+ .filter((child) => child === elements.stickyUserPromptButton || liveBubbles.has(child));
33042
33359
  transcriptRenderer.replaceChildren(elements.chat, ...preservedNodes);
33043
33360
  }
33044
33361
 
33045
33362
  function appendChatMessageBubble(bubble, { liveTail = false } = {}) {
33046
33363
  const liveBubbles = standaloneLiveTranscriptBubbles();
33047
33364
  const tailAnchor = [...elements.chat.children]
33048
- .find((child) => child !== bubble && (child === runIndicatorBubble || (!liveTail && liveBubbles.has(child))));
33365
+ .find((child) => child !== bubble && !liveTail && liveBubbles.has(child));
33049
33366
  if (tailAnchor) elements.chat.insertBefore(bubble, tailAnchor);
33050
33367
  else elements.chat.append(bubble);
33051
33368
  }
@@ -34289,7 +34606,9 @@ function appendOptimisticUserPrompt(message, attachmentCount = 0) {
34289
34606
  });
34290
34607
  if (transientMessages.length > 80) transientMessages.splice(0, transientMessages.length - 80);
34291
34608
  renderAllMessages();
34292
- if (autoFollowChat || isChatNearBottom()) scrollChatToBottom({ force: true });
34609
+ // Sending a prompt is an explicit request to follow the new turn, even when
34610
+ // the reader had previously paused auto-follow higher in the transcript.
34611
+ scrollChatToBottom({ force: true });
34293
34612
  return optimisticPromptId;
34294
34613
  }
34295
34614
 
@@ -34402,9 +34721,9 @@ function runIndicatorDetail() {
34402
34721
  return "Waiting for output or action…";
34403
34722
  }
34404
34723
 
34405
- // Transcript-owned ticker: it may only repaint the run-indicator bubble's own
34724
+ // Status-host-owned ticker: it may only repaint the run-indicator bubble's own
34406
34725
  // stable text nodes. Canonical state reconciliation belongs to the separate
34407
- // lifecycle watchdog below, so transcript rendering never issues network work.
34726
+ // lifecycle watchdog below, so status rendering never issues network work.
34408
34727
  function startRunIndicatorTicker() {
34409
34728
  startLifecycleStateWatchdog();
34410
34729
  if (runIndicatorTimer) return;
@@ -34444,8 +34763,8 @@ function stopLifecycleStateWatchdog() {
34444
34763
 
34445
34764
  function createRunIndicatorBubble() {
34446
34765
  runIndicatorBubble = make("article", "message runIndicator run-indicator-message streaming");
34447
- // Stable transcript-owned activity root: streaming activity updates rewrite
34448
- // only this bubble's own text nodes, never composer or chrome surfaces.
34766
+ // Stable status-host activity root: streaming activity updates rewrite only
34767
+ // this bubble's own text nodes, never transcript, composer, or chrome surfaces.
34449
34768
  runIndicatorBubble.dataset.streamOwned = "run-indicator";
34450
34769
  runIndicatorBubble.setAttribute("aria-live", "polite");
34451
34770
  runIndicatorBubble.setAttribute("aria-label", "Agent is running:");
@@ -34463,7 +34782,7 @@ function createRunIndicatorBubble() {
34463
34782
 
34464
34783
  function ensureRunIndicatorBubble() {
34465
34784
  if (!runIndicatorBubble || !runIndicatorText || !runIndicatorMeta) createRunIndicatorBubble();
34466
- if (elements.chat.lastElementChild !== runIndicatorBubble) elements.chat.append(runIndicatorBubble);
34785
+ if (runIndicatorBubble.parentElement !== elements.runIndicatorHost) elements.runIndicatorHost.replaceChildren(runIndicatorBubble);
34467
34786
  }
34468
34787
 
34469
34788
  function updateRunIndicatorBubble() {
@@ -34487,7 +34806,7 @@ function removeRunIndicatorBubble() {
34487
34806
 
34488
34807
  function renderRunIndicator({ scroll = false } = {}) {
34489
34808
  if (!runIndicatorIsActive()) {
34490
- if (runIndicatorRemovalDeferred && runIndicatorBubble?.parentElement === elements.chat) return;
34809
+ if (runIndicatorRemovalDeferred && runIndicatorBubble?.parentElement === elements.runIndicatorHost) return;
34491
34810
  removeRunIndicatorBubble();
34492
34811
  return;
34493
34812
  }
@@ -34513,7 +34832,7 @@ function scheduleRunIndicatorRender({ scroll = false } = {}) {
34513
34832
  function setRunIndicatorActivity(activity, { active = true, scroll = true } = {}) {
34514
34833
  const wasLocallyActive = runIndicatorLocallyActive;
34515
34834
  const previousActivity = runIndicatorActivity;
34516
- const hadRunIndicatorBubble = runIndicatorBubble?.parentElement === elements.chat;
34835
+ const hadRunIndicatorBubble = runIndicatorBubble?.parentElement === elements.runIndicatorHost;
34517
34836
  if (active) {
34518
34837
  runIndicatorLocallyActive = true;
34519
34838
  runIndicatorRemovalDeferred = false;
@@ -34523,7 +34842,7 @@ function setRunIndicatorActivity(activity, { active = true, scroll = true } = {}
34523
34842
  const needsRender = scroll || !hadRunIndicatorBubble || wasLocallyActive !== runIndicatorLocallyActive || previousActivity !== runIndicatorActivity;
34524
34843
  if (needsRender) scheduleRunIndicatorRender({ scroll });
34525
34844
  else if (runIndicatorIsActive()) startRunIndicatorTicker();
34526
- // Activity wording is transcript-owned. Composer/Stop chrome is reconciled
34845
+ // Activity wording is status-host-owned. Composer/Stop chrome is reconciled
34527
34846
  // only when the lifecycle enum itself changes, so wording updates can never
34528
34847
  // reparent Steer/Follow-up controls or rewrite the run-active body class.
34529
34848
  syncLifecycleComposerState();
@@ -34554,7 +34873,7 @@ function clearRunIndicatorActivity({ render = true, deferRemoval = false } = {})
34554
34873
  runIndicatorLocallyActive = false;
34555
34874
  runIndicatorStartedAt = null;
34556
34875
  runIndicatorActivity = "Waiting for output or action…";
34557
- runIndicatorRemovalDeferred = deferRemoval && runIndicatorBubble?.parentElement === elements.chat;
34876
+ runIndicatorRemovalDeferred = deferRemoval && runIndicatorBubble?.parentElement === elements.runIndicatorHost;
34558
34877
  if (runIndicatorRemovalDeferred) stopRunIndicatorTicker();
34559
34878
  else if (render) renderRunIndicator();
34560
34879
  stopLifecycleStateWatchdog();
@@ -35089,7 +35408,7 @@ function restoreChatTextSelection(snapshot) {
35089
35408
  function removeChatBubblesAfterPrefix(keptKeys) {
35090
35409
  const liveBubbles = standaloneLiveTranscriptBubbles();
35091
35410
  for (const child of [...elements.chat.children]) {
35092
- if (child === elements.stickyUserPromptButton || child === runIndicatorBubble || liveBubbles.has(child)) continue;
35411
+ if (child === elements.stickyUserPromptButton || liveBubbles.has(child)) continue;
35093
35412
  const key = child.dataset?.itemKey || child.dataset?.transcriptMessageKey;
35094
35413
  if (key && keptKeys.has(key)) continue;
35095
35414
  child.remove();
@@ -35129,7 +35448,7 @@ function renderAllMessages({ preserveScroll = false, forceRebuild = false } = {}
35129
35448
  const affectedSurfaces = prefixLength === 0 && adoptedKeys.size === 0
35130
35449
  ? [elements.chat]
35131
35450
  : [...elements.chat.children].filter((child) => {
35132
- if (child === elements.stickyUserPromptButton || child === runIndicatorBubble || liveBubbles.has(child)) return false;
35451
+ if (child === elements.stickyUserPromptButton || liveBubbles.has(child)) return false;
35133
35452
  const key = child.dataset?.itemKey || child.dataset?.transcriptMessageKey;
35134
35453
  return !prefixKeys.has(key) && !adoptedKeys.has(key);
35135
35454
  });
@@ -40822,7 +41141,7 @@ function renderNetworkStatus() {
40822
41141
  if (elements.showRemoteQrButton) {
40823
41142
  elements.showRemoteQrButton.hidden = !open;
40824
41143
  elements.showRemoteQrButton.disabled = rebinding || !open;
40825
- elements.showRemoteQrButton.textContent = "Show QR code";
41144
+ elements.showRemoteQrButton.textContent = "Open QR-Code";
40826
41145
  }
40827
41146
  }
40828
41147
 
@@ -43737,7 +44056,7 @@ elements.followUpQueueTrigger?.addEventListener("click", () => {
43737
44056
  });
43738
44057
  elements.followUpQueueCloseButton?.addEventListener("click", () => setFollowUpQueueOpen(false, { restoreFocus: true }));
43739
44058
  elements.composerActionsButton.addEventListener("click", () => {
43740
- setComposerActionsOpen(!document.body.classList.contains("composer-actions-open"));
44059
+ setComposerActionsOpen(!document.body.classList.contains("composer-actions-open"), { restoreFocus: true });
43741
44060
  });
43742
44061
  elements.busyPromptBehaviorTag?.addEventListener("click", (event) => {
43743
44062
  event.preventDefault();
@@ -43746,7 +44065,7 @@ elements.busyPromptBehaviorTag?.addEventListener("click", (event) => {
43746
44065
  setNativeCommandMenuOpen(false);
43747
44066
  setAppRunnerMenuOpen(false);
43748
44067
  setOptionsMenuOpen(false);
43749
- setComposerActionsOpen(false);
44068
+ if (!document.body.classList.contains("mobile-composer-disclosure")) setComposerActionsOpen(false);
43750
44069
  setBusyPromptBehaviorMenuOpen(nextOpen);
43751
44070
  });
43752
44071
  elements.busyPromptBehaviorTag?.addEventListener("keydown", (event) => {
@@ -43793,7 +44112,7 @@ elements.steerButton.addEventListener("click", () => sendPromptFromModeButton("s
43793
44112
  elements.followUpButton.addEventListener("click", () => sendPromptFromModeButton("follow-up", elements.followUpButton));
43794
44113
  elements.btwButton?.addEventListener("click", () => sendBtwPromptFromButton());
43795
44114
  elements.terminalTabsToggleButton.addEventListener("click", () => {
43796
- setMobileTabsExpanded(!document.body.classList.contains("mobile-tabs-expanded"));
44115
+ setMobileTabsExpanded(!document.body.classList.contains("mobile-tabs-expanded"), { restoreFocus: true });
43797
44116
  });
43798
44117
  elements.newTabButton.addEventListener("click", (event) => {
43799
44118
  event.stopPropagation();
@@ -44721,6 +45040,10 @@ elements.webuiPackageNpmButton?.addEventListener("click", () => {
44721
45040
  });
44722
45041
  elements.webuiPackageCloseButton?.addEventListener("click", () => elements.webuiPackageDialog?.close());
44723
45042
  elements.piReleaseNotesCloseButton?.addEventListener("click", () => elements.piReleaseNotesDialog?.close());
45043
+ elements.sidePanelEditButton?.addEventListener("click", () => {
45044
+ if (!isMobileView()) return;
45045
+ setSidePanelSectionEditMode(!sidePanelSectionEditMode);
45046
+ });
44724
45047
  elements.toggleSidePanelButton.addEventListener("click", () => {
44725
45048
  setSidePanelCollapsed(true);
44726
45049
  });
@@ -44781,9 +45104,9 @@ document.addEventListener("pointerdown", (event) => {
44781
45104
  if (busyPromptBehaviorMenuOpen && !event.target?.closest?.(".composer-context-tags, .composer-busy-mode-menu")) {
44782
45105
  setBusyPromptBehaviorMenuOpen(false);
44783
45106
  }
44784
- if (document.body.classList.contains("mobile-tabs-expanded") && !elements.tabBar.contains(event.target) && !elements.terminalTabsToggleButton.contains(event.target)) {
45107
+ if (document.body.classList.contains("mobile-tabs-expanded") && !elements.terminalTabsDrawerContent?.contains(event.target) && !elements.terminalTabsToggleButton.contains(event.target)) {
44785
45108
  setNewTabMenuOpen(false);
44786
- setMobileTabsExpanded(false);
45109
+ setMobileTabsExpanded(false, { restoreFocus: true });
44787
45110
  }
44788
45111
  if (isFooterPickerOpen() && !elements.statusBar.contains(event.target)) {
44789
45112
  setFooterModelPickerOpen(false);
@@ -45090,12 +45413,12 @@ window.addEventListener("keydown", (event) => {
45090
45413
  return;
45091
45414
  }
45092
45415
  if (document.body.classList.contains("composer-actions-open")) {
45093
- setComposerActionsOpen(false);
45416
+ setComposerActionsOpen(false, { restoreFocus: true });
45094
45417
  return;
45095
45418
  }
45096
45419
  if (document.body.classList.contains("mobile-tabs-expanded")) {
45097
45420
  setNewTabMenuOpen(false);
45098
- setMobileTabsExpanded(false);
45421
+ setMobileTabsExpanded(false, { restoreFocus: true });
45099
45422
  return;
45100
45423
  }
45101
45424
  if (isFooterPickerOpen()) {
@@ -45481,6 +45804,7 @@ restoreFileViewerWidthPreference();
45481
45804
  focusPromptInput({ defer: true });
45482
45805
  restoreStoredSkillUsage();
45483
45806
  restoreBusyPromptBehaviorSetting();
45807
+ syncMobileComposerDisclosureLayout();
45484
45808
  updateComposerModeButtons();
45485
45809
  installSessionSkillTagResizeHandling();
45486
45810
  updateOptionalFeatureAvailability();
@@ -45512,6 +45836,7 @@ initializeComposerActionOrdering();
45512
45836
  restoreSidePanelSectionOrder();
45513
45837
  restoreSidePanelSectionVisibility();
45514
45838
  restoreSidePanelSectionState();
45839
+ setSidePanelSectionEditMode(false);
45515
45840
  bindSidePanelSectionToggles();
45516
45841
  restoreSidePanelState();
45517
45842
  initializeCodexUsage();