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