@firstpick/pi-package-webui 0.7.3 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -20
- package/bin/pi-webui.mjs +332 -39
- package/index.ts +10 -1
- package/lib/git-workflow-preferences.mjs +91 -22
- package/lib/subagent-launch-slots.mjs +304 -0
- package/lib/trust-boundaries.mjs +1 -0
- package/lib/webui-output-mode.mjs +97 -0
- package/package.json +22 -22
- package/public/app.js +1629 -69
- package/public/fast-output-live.mjs +179 -0
- package/public/index.html +86 -12
- package/public/service-worker.js +3 -1
- package/public/styles.css +769 -37
- package/public/subagent-launch-slot-state.mjs +64 -0
- package/tests/chat-scroll-intent-static.test.mjs +59 -0
- package/tests/custom-message-markdown-static.test.mjs +15 -0
- package/tests/fast-mode-client-static.test.mjs +169 -0
- package/tests/fast-mode-output-work.test.mjs +69 -0
- package/tests/fast-mode-sse-harness.test.mjs +204 -0
- package/tests/fast-output-live.test.mjs +106 -0
- package/tests/fixtures/fake-pi.mjs +58 -0
- package/tests/fixtures/fast-mode-output-events.mjs +50 -0
- package/tests/footer-middle-truncation.test.mjs +2 -2
- package/tests/git-workflow-preferences.test.mjs +8 -2
- package/tests/http-endpoints-harness.test.mjs +74 -0
- package/tests/mobile-static.test.mjs +86 -15
- package/tests/remote-auth-settings-harness.test.mjs +1 -1
- 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 +46 -0
- package/tests/webui-output-mode.test.mjs +73 -0
- package/webui-rpc-helper.mjs +37 -9
package/public/app.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { aurReviewSafePath as parsedAurReviewSafePath, parseAurReviewPayload as parseValidatedAurReviewPayload } from "./aur-review-payload.mjs";
|
|
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
|
+
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";
|
|
4
6
|
|
|
5
7
|
const $ = (selector) => document.querySelector(selector);
|
|
6
8
|
|
|
@@ -72,6 +74,7 @@ const elements = {
|
|
|
72
74
|
busyPromptBehaviorTag: $("#busyPromptBehaviorTag"),
|
|
73
75
|
busyPromptBehaviorMenu: $("#busyPromptBehaviorMenu"),
|
|
74
76
|
sessionSkillTags: $("#sessionSkillTags"),
|
|
77
|
+
featureCategoryTag: $("#featureCategoryTag"),
|
|
75
78
|
conversationModeChip: $("#conversationModeChip"),
|
|
76
79
|
workflowModeChip: $("#workflowModeChip"),
|
|
77
80
|
skillEditorDialog: $("#skillEditorDialog"),
|
|
@@ -100,7 +103,9 @@ const elements = {
|
|
|
100
103
|
remoteMicStreamingConsentButton: $("#remoteMicStreamingConsentButton"),
|
|
101
104
|
newSessionButton: $("#newSessionButton"),
|
|
102
105
|
compactButton: $("#compactButton"),
|
|
106
|
+
workflowModeControls: $("#workflowModeControls"),
|
|
103
107
|
workflowModeButton: $("#workflowModeButton"),
|
|
108
|
+
workflowOverlayOpenButton: $("#workflowOverlayOpenButton"),
|
|
104
109
|
gitWorkflowButton: $("#gitWorkflowButton"),
|
|
105
110
|
publishButton: $("#publishButton"),
|
|
106
111
|
publishMenu: $("#publishMenu"),
|
|
@@ -163,6 +168,9 @@ const elements = {
|
|
|
163
168
|
setThinkingButton: $("#setThinkingButton"),
|
|
164
169
|
thinkingVisibilityToggle: $("#thinkingVisibilityToggle"),
|
|
165
170
|
thinkingVisibilityStatus: $("#thinkingVisibilityStatus"),
|
|
171
|
+
fastOutputModeSelect: $("#fastOutputModeSelect"),
|
|
172
|
+
setFastOutputModeButton: $("#setFastOutputModeButton"),
|
|
173
|
+
fastOutputModeStatus: $("#fastOutputModeStatus"),
|
|
166
174
|
terminalTabsLayoutSelect: $("#terminalTabsLayoutSelect"),
|
|
167
175
|
terminalTabsLayoutStatus: $("#terminalTabsLayoutStatus"),
|
|
168
176
|
themeControlLabel: $("#themeControlLabel"),
|
|
@@ -226,6 +234,7 @@ const elements = {
|
|
|
226
234
|
fileSelectionSendButton: $("#fileSelectionSendButton"),
|
|
227
235
|
fileContextMenu: $("#fileContextMenu"),
|
|
228
236
|
sidePanelContextMenu: $("#sidePanelContextMenu"),
|
|
237
|
+
sidePanelResizeHandle: $("#sidePanelResizeHandle"),
|
|
229
238
|
toggleSidePanelButton: $("#toggleSidePanelButton"),
|
|
230
239
|
sidePanelExpandButton: $("#sidePanelExpandButton"),
|
|
231
240
|
sidePanelBackdrop: $("#sidePanelBackdrop"),
|
|
@@ -236,6 +245,20 @@ const elements = {
|
|
|
236
245
|
subagentCountBadge: $("#subagentCountBadge"),
|
|
237
246
|
subagentOpenModeSelect: $("#subagentOpenModeSelect"),
|
|
238
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"),
|
|
239
262
|
queueBox: $("#queueBox"),
|
|
240
263
|
queueCountBadge: $("#queueCountBadge"),
|
|
241
264
|
createPromptListButton: $("#createPromptListButton"),
|
|
@@ -368,6 +391,7 @@ let fileContextMenuState = null;
|
|
|
368
391
|
let sidePanelContextMenuState = null;
|
|
369
392
|
let fileTreeDragState = null;
|
|
370
393
|
let fileViewerResizeState = null;
|
|
394
|
+
let sidePanelResizeState = null;
|
|
371
395
|
let fileTreeSearchTimer = null;
|
|
372
396
|
let fileTreeSearchRequestSerial = 0;
|
|
373
397
|
let tabActivities = new Map();
|
|
@@ -393,6 +417,17 @@ let streamThinkingBubble = null;
|
|
|
393
417
|
let streamThinking = null;
|
|
394
418
|
let streamMessageActive = false;
|
|
395
419
|
let streamProviderErrorText = "";
|
|
420
|
+
let compactLiveState = createFastOutputLiveState();
|
|
421
|
+
let compactTextBubble = null;
|
|
422
|
+
let compactTextNode = null;
|
|
423
|
+
let compactThinkingBubble = null;
|
|
424
|
+
let compactThinkingNode = null;
|
|
425
|
+
const compactToolShells = new Map();
|
|
426
|
+
let activeOutputMode = "normal";
|
|
427
|
+
let outputModeAcknowledged = false;
|
|
428
|
+
let eventSourceOutputModeRequest = "auto";
|
|
429
|
+
let eventSourceOutputModeFallbackAttempted = false;
|
|
430
|
+
const compactLiveScheduler = createSustainedFlushScheduler({ flush: () => flushCompactLiveOutput() });
|
|
396
431
|
let assistantErrorSurfacedThisRun = false;
|
|
397
432
|
let runIndicatorBubble = null;
|
|
398
433
|
let runIndicatorText = null;
|
|
@@ -518,6 +553,17 @@ let subagentOpenMode = "overlay";
|
|
|
518
553
|
const subagentTerminalViews = new Map();
|
|
519
554
|
let activeSubagentTerminalId = null;
|
|
520
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;
|
|
521
567
|
let backendOffline = false;
|
|
522
568
|
let serverRestartInProgress = false;
|
|
523
569
|
let updateRequestInProgress = false;
|
|
@@ -576,6 +622,8 @@ let liveTodoProgressPendingText = "";
|
|
|
576
622
|
let liveTodoProgressPendingTabId = null;
|
|
577
623
|
let lastChatProgrammaticScrollAt = 0;
|
|
578
624
|
let chatUserScrollIntentUntil = 0;
|
|
625
|
+
let chatUserScrollAwayIntentUntil = 0;
|
|
626
|
+
let chatLastTouchClientY = null;
|
|
579
627
|
let mobileFooterExpanded = false;
|
|
580
628
|
let footerModelPickerOpen = false;
|
|
581
629
|
let footerThinkingPickerOpen = false;
|
|
@@ -723,6 +771,7 @@ const WORKFLOW_INSPECTOR_PAYLOAD_PREFIX = "WORKFLOW_RPC_PAYLOAD ";
|
|
|
723
771
|
const WORKFLOW_INSPECTOR_PAYLOAD_TYPE = "firstpick.pi-extension-workflows.inspector";
|
|
724
772
|
const WORKFLOW_INSPECTOR_PAYLOAD_VERSION = 1;
|
|
725
773
|
const WORKFLOW_MODE_STATUS_KEY = "workflow-mode";
|
|
774
|
+
const FEATURE_CATEGORY_STATUS_KEY = "feature-category";
|
|
726
775
|
const WORKFLOW_MODE_RPC_WIDGET_KEY = "workflow-mode:rpc";
|
|
727
776
|
const WORKFLOW_MODE_RPC_PAYLOAD_PREFIX = "WORKFLOW_MODE_RPC_PAYLOAD ";
|
|
728
777
|
const WORKFLOW_MODE_RPC_PAYLOAD_TYPE = "firstpick.pi-extension-workflows.mode";
|
|
@@ -741,6 +790,9 @@ const WORKSPACE_DASHBOARD_STORAGE_KEY = "pi-webui-workspace-dashboard-collapsed"
|
|
|
741
790
|
const FILE_VIEWER_WIDTH_STORAGE_KEY = "pi-webui-file-viewer-width";
|
|
742
791
|
const FILE_VIEWER_WIDTH_DEFAULT_PX = 520;
|
|
743
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;
|
|
744
796
|
const FILE_VIEWER_CONTEXT_RADIUS_LINES = 6;
|
|
745
797
|
const FILE_TREE_ROOT_PATH = "";
|
|
746
798
|
const FILE_TREE_DRAG_MIME = "application/x-pi-webui-file-path";
|
|
@@ -827,12 +879,17 @@ const initialUrlParams = new URLSearchParams(window.location.search);
|
|
|
827
879
|
const embeddedSplitMode = initialUrlParams.get("embed") === "split";
|
|
828
880
|
document.body.classList.toggle("embedded-split", embeddedSplitMode);
|
|
829
881
|
const statusEntries = new Map();
|
|
882
|
+
const featureCategoryByTab = new Map();
|
|
830
883
|
const widgets = new Map();
|
|
831
884
|
const widgetsByTab = new Map();
|
|
832
885
|
const todoProgressWidgetExpandedByTab = new Map();
|
|
886
|
+
const compactThinkingDisclosureStateByTab = new Map();
|
|
833
887
|
const todoProgressGoalByTab = new Map();
|
|
834
888
|
const todoProgressSignatureByTab = new Map();
|
|
835
889
|
const releaseNpmOutputExpandedByTab = new Map();
|
|
890
|
+
const workflowTerminalScrollByTab = new Map();
|
|
891
|
+
const workflowSubprocessMinimizedByTab = new Set();
|
|
892
|
+
const workflowOverlayMinimizedByTab = new Set();
|
|
836
893
|
const appRunnerDataByTab = new Map();
|
|
837
894
|
const conversationModeByTab = new Map();
|
|
838
895
|
const workflowModeByTab = new Map();
|
|
@@ -1072,6 +1129,10 @@ const SETTINGS_DOUBLE_ESCAPE_OPTIONS = [
|
|
|
1072
1129
|
{ value: "none", label: "do nothing" },
|
|
1073
1130
|
];
|
|
1074
1131
|
const SETTINGS_TREE_FILTER_OPTIONS = ["default", "no-tools", "user-only", "labeled-only", "all"];
|
|
1132
|
+
const SETTINGS_OUTPUT_MODE_OPTIONS = [
|
|
1133
|
+
{ value: "normal", label: "normal" },
|
|
1134
|
+
{ value: "compact-v1", label: "compact-v1" },
|
|
1135
|
+
];
|
|
1075
1136
|
const SETTINGS_IMAGE_WIDTH_OPTIONS = ["60", "80", "120"];
|
|
1076
1137
|
const SETTINGS_EDITOR_PADDING_OPTIONS = ["0", "1", "2", "3"];
|
|
1077
1138
|
const SETTINGS_AUTOCOMPLETE_OPTIONS = ["3", "5", "7", "10", "15", "20"];
|
|
@@ -2363,6 +2424,28 @@ function renderSessionSkillTags(tabId = activeTabId) {
|
|
|
2363
2424
|
container.hidden = false;
|
|
2364
2425
|
}
|
|
2365
2426
|
|
|
2427
|
+
function normalizeFeatureCategory(value) {
|
|
2428
|
+
return value === "lightweight-feature" || value === "complex-feature" ? value : "";
|
|
2429
|
+
}
|
|
2430
|
+
|
|
2431
|
+
function renderFeatureCategoryTag(tabId = activeTabId) {
|
|
2432
|
+
const tag = elements.featureCategoryTag;
|
|
2433
|
+
if (!tag) return;
|
|
2434
|
+
const category = normalizeFeatureCategory(featureCategoryByTab.get(tabId));
|
|
2435
|
+
tag.hidden = !category;
|
|
2436
|
+
tag.textContent = category;
|
|
2437
|
+
tag.classList.toggle("lightweight-feature", category === "lightweight-feature");
|
|
2438
|
+
tag.classList.toggle("complex-feature", category === "complex-feature");
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2441
|
+
function handleFeatureCategoryStatus(statusText, tabId = activeTabId) {
|
|
2442
|
+
if (!tabId) return;
|
|
2443
|
+
const category = normalizeFeatureCategory(statusText);
|
|
2444
|
+
if (category) featureCategoryByTab.set(tabId, category);
|
|
2445
|
+
else featureCategoryByTab.delete(tabId);
|
|
2446
|
+
if (tabId === activeTabId) renderFeatureCategoryTag(tabId);
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2366
2449
|
function trackSkillUsage(tabId, skillName, kind = "used", source = "", details = {}) {
|
|
2367
2450
|
const name = normalizeSkillName(skillName);
|
|
2368
2451
|
if (!tabId || !name) return;
|
|
@@ -3048,6 +3131,8 @@ function setSidePanelCollapsed(collapsed, { persist = true, focusPanel = false }
|
|
|
3048
3131
|
elements.toggleSidePanelButton.setAttribute("aria-label", collapsed ? "Expand side panel" : "Collapse side panel");
|
|
3049
3132
|
elements.sidePanelExpandButton.setAttribute("aria-expanded", collapsed ? "false" : "true");
|
|
3050
3133
|
syncMobileSidePanelState(collapsed);
|
|
3134
|
+
updateSidePanelResizeHandle();
|
|
3135
|
+
requestAnimationFrame(syncResizablePanelWidthsForViewport);
|
|
3051
3136
|
if (collapsed) closeSidePanelContextMenu({ returnFocus: false });
|
|
3052
3137
|
|
|
3053
3138
|
if (!collapsed && focusPanel && isSidePanelOverlayView()) {
|
|
@@ -5025,6 +5110,42 @@ function workflowModeCommandName() {
|
|
|
5025
5110
|
return resolveAvailableCommandName("workflow", { rpcOnly: true }) || "";
|
|
5026
5111
|
}
|
|
5027
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
|
+
|
|
5028
5149
|
function renderWorkflowModeControls() {
|
|
5029
5150
|
const mode = activeWorkflowMode();
|
|
5030
5151
|
const commandName = workflowModeCommandName();
|
|
@@ -5046,6 +5167,7 @@ function renderWorkflowModeControls() {
|
|
|
5046
5167
|
: "Workflow Mode is unavailable because the /workflow command is not loaded.";
|
|
5047
5168
|
applyStyledTooltip(elements.workflowModeButton, tooltip, { ariaLabel: true, align: "start" });
|
|
5048
5169
|
}
|
|
5170
|
+
renderWorkflowOverlayControls();
|
|
5049
5171
|
|
|
5050
5172
|
if (elements.workflowModeChip) {
|
|
5051
5173
|
elements.workflowModeChip.hidden = !active;
|
|
@@ -6258,6 +6380,7 @@ function setActiveTabId(tabId, { remember = false } = {}) {
|
|
|
6258
6380
|
if (nextTabId !== activeTabId) activeTabGeneration += 1;
|
|
6259
6381
|
activeTabId = nextTabId;
|
|
6260
6382
|
bindGitWorkflowToActiveTab();
|
|
6383
|
+
renderFeatureCategoryTag(nextTabId);
|
|
6261
6384
|
if (remember) rememberActiveTab();
|
|
6262
6385
|
return activeTabContext(nextTabId);
|
|
6263
6386
|
}
|
|
@@ -6484,17 +6607,10 @@ function fileTreeOverflowButton(entry) {
|
|
|
6484
6607
|
return button;
|
|
6485
6608
|
}
|
|
6486
6609
|
|
|
6487
|
-
function fileTreeExpander(
|
|
6488
|
-
const
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
button.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
6492
|
-
button.addEventListener("click", (event) => {
|
|
6493
|
-
event.stopPropagation();
|
|
6494
|
-
if (search) revealFileTreeEntry(entry).catch((error) => addEvent(error.message || String(error), "error"));
|
|
6495
|
-
else toggleFileTreeDirectory(entry.path).catch((error) => addEvent(error.message || String(error), "error"));
|
|
6496
|
-
});
|
|
6497
|
-
return button;
|
|
6610
|
+
function fileTreeExpander(expanded = false) {
|
|
6611
|
+
const arrow = make("span", "file-tree-expander", expanded ? "▾" : "▸");
|
|
6612
|
+
arrow.setAttribute("aria-hidden", "true");
|
|
6613
|
+
return arrow;
|
|
6498
6614
|
}
|
|
6499
6615
|
|
|
6500
6616
|
function appendFileSearchEntry(parent, entry) {
|
|
@@ -6511,6 +6627,10 @@ function appendFileSearchEntry(parent, entry) {
|
|
|
6511
6627
|
button.style.setProperty("--file-tree-depth", "0");
|
|
6512
6628
|
button.setAttribute("role", "treeitem");
|
|
6513
6629
|
button.setAttribute("aria-selected", fileTreeState.selectedPath === path ? "true" : "false");
|
|
6630
|
+
if (isDirectory) {
|
|
6631
|
+
button.setAttribute("aria-expanded", "false");
|
|
6632
|
+
button.setAttribute("aria-label", `Expand ${entry.name || fileDisplayName(path)}`);
|
|
6633
|
+
}
|
|
6514
6634
|
button.title = [path || ".", fileTreeGitStatusTitle(gitStatus), entry.error || ""].filter(Boolean).join("\n");
|
|
6515
6635
|
const label = make("span", "file-tree-search-label");
|
|
6516
6636
|
label.append(
|
|
@@ -6518,6 +6638,7 @@ function appendFileSearchEntry(parent, entry) {
|
|
|
6518
6638
|
make("span", "file-tree-search-path", path || "."),
|
|
6519
6639
|
);
|
|
6520
6640
|
button.append(
|
|
6641
|
+
isDirectory ? fileTreeExpander(false) : make("span", "file-tree-expander-spacer"),
|
|
6521
6642
|
make("span", "file-tree-icon", fileEntryIcon(entry)),
|
|
6522
6643
|
label,
|
|
6523
6644
|
);
|
|
@@ -6529,11 +6650,11 @@ function appendFileSearchEntry(parent, entry) {
|
|
|
6529
6650
|
button.addEventListener("click", () => {
|
|
6530
6651
|
fileTreeState.selectedPath = path;
|
|
6531
6652
|
if (entry.type === "file") openFileInViewer(path);
|
|
6532
|
-
else
|
|
6653
|
+
else revealFileTreeEntry(entry).catch((error) => addEvent(error.message || String(error), "error"));
|
|
6533
6654
|
});
|
|
6534
6655
|
button.addEventListener("contextmenu", (event) => showFileContextMenu(event, entry));
|
|
6535
6656
|
bindFileTreeDragAndDrop(button, item, entry);
|
|
6536
|
-
item.append(
|
|
6657
|
+
item.append(button, fileTreeOverflowButton(entry));
|
|
6537
6658
|
parent.append(item);
|
|
6538
6659
|
}
|
|
6539
6660
|
|
|
@@ -6576,9 +6697,13 @@ function appendFileTreeEntry(parent, entry, depth = 0) {
|
|
|
6576
6697
|
button.style.setProperty("--file-tree-depth", String(depth));
|
|
6577
6698
|
button.setAttribute("role", "treeitem");
|
|
6578
6699
|
button.setAttribute("aria-selected", fileTreeState.selectedPath === path ? "true" : "false");
|
|
6579
|
-
if (isDirectory)
|
|
6700
|
+
if (isDirectory) {
|
|
6701
|
+
button.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
6702
|
+
button.setAttribute("aria-label", `${expanded ? "Collapse" : "Expand"} ${entry.name || fileDisplayName(path)}`);
|
|
6703
|
+
}
|
|
6580
6704
|
button.title = [path || ".", fileTreeGitStatusTitle(gitStatus), entry.error || ""].filter(Boolean).join("\n");
|
|
6581
6705
|
button.append(
|
|
6706
|
+
isDirectory ? fileTreeExpander(expanded) : make("span", "file-tree-expander-spacer"),
|
|
6582
6707
|
make("span", `file-tree-icon ${isDirectory && expanded ? "expanded" : ""}`, loading ? "…" : fileEntryIcon(entry)),
|
|
6583
6708
|
make("span", "file-tree-name", entry.name || fileDisplayName(path)),
|
|
6584
6709
|
);
|
|
@@ -6589,11 +6714,11 @@ function appendFileTreeEntry(parent, entry, depth = 0) {
|
|
|
6589
6714
|
button.addEventListener("click", () => {
|
|
6590
6715
|
fileTreeState.selectedPath = path;
|
|
6591
6716
|
if (entry.type === "file") openFileInViewer(path);
|
|
6592
|
-
else
|
|
6717
|
+
else toggleFileTreeDirectory(path).catch((error) => addEvent(error.message || String(error), "error"));
|
|
6593
6718
|
});
|
|
6594
6719
|
button.addEventListener("contextmenu", (event) => showFileContextMenu(event, entry));
|
|
6595
6720
|
bindFileTreeDragAndDrop(button, item, entry);
|
|
6596
|
-
item.append(
|
|
6721
|
+
item.append(button, fileTreeOverflowButton(entry));
|
|
6597
6722
|
if (isDirectory && expanded) {
|
|
6598
6723
|
const children = fileTreeState.entriesByPath.get(path) || [];
|
|
6599
6724
|
const childList = make("ul", "file-tree-list");
|
|
@@ -7196,6 +7321,133 @@ async function moveFileTreeEntry(entry = fileContextMenuState?.entry) {
|
|
|
7196
7321
|
await moveFileTreeEntryToDestination(entry, destinationPath, { confirmMove: true });
|
|
7197
7322
|
}
|
|
7198
7323
|
|
|
7324
|
+
function readStoredSidePanelWidth() {
|
|
7325
|
+
try {
|
|
7326
|
+
const width = Number.parseFloat(localStorage.getItem(SIDE_PANEL_WIDTH_STORAGE_KEY) || "");
|
|
7327
|
+
return Number.isFinite(width) && width >= SIDE_PANEL_WIDTH_MIN_PX ? width : null;
|
|
7328
|
+
} catch {
|
|
7329
|
+
return null;
|
|
7330
|
+
}
|
|
7331
|
+
}
|
|
7332
|
+
|
|
7333
|
+
function persistSidePanelWidth(width) {
|
|
7334
|
+
try {
|
|
7335
|
+
localStorage.setItem(SIDE_PANEL_WIDTH_STORAGE_KEY, String(Math.round(width)));
|
|
7336
|
+
} catch {
|
|
7337
|
+
// Ignore storage failures; resizing should still work for this page load.
|
|
7338
|
+
}
|
|
7339
|
+
}
|
|
7340
|
+
|
|
7341
|
+
function sidePanelMaxWidth() {
|
|
7342
|
+
const layout = document.querySelector(".layout");
|
|
7343
|
+
const layoutRect = layout?.getBoundingClientRect?.();
|
|
7344
|
+
const layoutWidth = layoutRect?.width || window.innerWidth || SIDE_PANEL_WIDTH_DEFAULT_PX;
|
|
7345
|
+
const layoutStyle = layout ? getComputedStyle(layout) : null;
|
|
7346
|
+
const gap = Number.parseFloat(layoutStyle?.columnGap || layoutStyle?.gap || "0") || 0;
|
|
7347
|
+
const horizontalPadding = (Number.parseFloat(layoutStyle?.paddingLeft || "0") || 0) + (Number.parseFloat(layoutStyle?.paddingRight || "0") || 0);
|
|
7348
|
+
const contentWidth = Math.max(0, layoutWidth - horizontalPadding);
|
|
7349
|
+
const fileViewerVisible = !!activeFileViewer && elements.fileViewerPane && getComputedStyle(elements.fileViewerPane).display !== "none";
|
|
7350
|
+
const fileViewerWidth = fileViewerVisible ? elements.fileViewerPane.getBoundingClientRect().width : 0;
|
|
7351
|
+
const splitOpen = document.body.classList.contains("terminal-split-open");
|
|
7352
|
+
const primaryMinWidth = splitOpen ? 560 : 320;
|
|
7353
|
+
const otherColumnCount = 1 + (splitOpen ? 1 : 0) + (fileViewerVisible ? 1 : 0);
|
|
7354
|
+
const available = contentWidth - fileViewerWidth - primaryMinWidth - (gap * otherColumnCount);
|
|
7355
|
+
return Math.max(SIDE_PANEL_WIDTH_MIN_PX, Math.min(Math.floor(contentWidth * 0.72), Math.floor(available)));
|
|
7356
|
+
}
|
|
7357
|
+
|
|
7358
|
+
function clampSidePanelWidth(width) {
|
|
7359
|
+
const number = Number(width);
|
|
7360
|
+
const max = sidePanelMaxWidth();
|
|
7361
|
+
const fallback = readStoredSidePanelWidth() || SIDE_PANEL_WIDTH_DEFAULT_PX;
|
|
7362
|
+
return Math.max(SIDE_PANEL_WIDTH_MIN_PX, Math.min(max, Number.isFinite(number) ? number : fallback));
|
|
7363
|
+
}
|
|
7364
|
+
|
|
7365
|
+
function currentSidePanelWidth() {
|
|
7366
|
+
const width = elements.sidePanel?.getBoundingClientRect?.().width;
|
|
7367
|
+
return Number.isFinite(width) && width > 0 ? width : readStoredSidePanelWidth() || SIDE_PANEL_WIDTH_DEFAULT_PX;
|
|
7368
|
+
}
|
|
7369
|
+
|
|
7370
|
+
function updateSidePanelResizeHandle(width = currentSidePanelWidth()) {
|
|
7371
|
+
const handle = elements.sidePanelResizeHandle;
|
|
7372
|
+
if (!handle) return;
|
|
7373
|
+
const resizeAvailable = !isSidePanelOverlayView() && !document.body.classList.contains("side-panel-collapsed");
|
|
7374
|
+
handle.hidden = !resizeAvailable;
|
|
7375
|
+
handle.setAttribute("aria-valuemin", String(SIDE_PANEL_WIDTH_MIN_PX));
|
|
7376
|
+
handle.setAttribute("aria-valuemax", String(sidePanelMaxWidth()));
|
|
7377
|
+
handle.setAttribute("aria-valuenow", String(Math.round(width)));
|
|
7378
|
+
handle.setAttribute("aria-valuetext", `${Math.round(width)} pixels wide`);
|
|
7379
|
+
}
|
|
7380
|
+
|
|
7381
|
+
function applySidePanelWidth(width, { persist = false } = {}) {
|
|
7382
|
+
const clamped = clampSidePanelWidth(width);
|
|
7383
|
+
document.documentElement.style.setProperty("--side-panel-width", `${Math.round(clamped)}px`);
|
|
7384
|
+
updateSidePanelResizeHandle(clamped);
|
|
7385
|
+
if (persist) persistSidePanelWidth(clamped);
|
|
7386
|
+
return clamped;
|
|
7387
|
+
}
|
|
7388
|
+
|
|
7389
|
+
function restoreSidePanelWidthPreference() {
|
|
7390
|
+
const width = readStoredSidePanelWidth();
|
|
7391
|
+
if (width) document.documentElement.style.setProperty("--side-panel-width", `${Math.round(width)}px`);
|
|
7392
|
+
if (!isSidePanelOverlayView()) applySidePanelWidth(width || SIDE_PANEL_WIDTH_DEFAULT_PX);
|
|
7393
|
+
else updateSidePanelResizeHandle(width || SIDE_PANEL_WIDTH_DEFAULT_PX);
|
|
7394
|
+
}
|
|
7395
|
+
|
|
7396
|
+
function beginSidePanelResize(event) {
|
|
7397
|
+
if (isSidePanelOverlayView() || document.body.classList.contains("side-panel-collapsed")) return;
|
|
7398
|
+
if (event.button !== undefined && event.button !== 0) return;
|
|
7399
|
+
event.preventDefault();
|
|
7400
|
+
const startWidth = currentSidePanelWidth();
|
|
7401
|
+
sidePanelResizeState = { pointerId: event.pointerId, startX: event.clientX, startWidth, width: startWidth };
|
|
7402
|
+
document.body.classList.add("side-panel-resizing");
|
|
7403
|
+
elements.sidePanelResizeHandle?.setPointerCapture?.(event.pointerId);
|
|
7404
|
+
window.addEventListener("pointermove", updateSidePanelResize, { passive: false });
|
|
7405
|
+
window.addEventListener("pointerup", finishSidePanelResize, { passive: false });
|
|
7406
|
+
window.addEventListener("pointercancel", finishSidePanelResize, { passive: false });
|
|
7407
|
+
}
|
|
7408
|
+
|
|
7409
|
+
function updateSidePanelResize(event) {
|
|
7410
|
+
const state = sidePanelResizeState;
|
|
7411
|
+
if (!state || (event.pointerId !== undefined && event.pointerId !== state.pointerId)) return;
|
|
7412
|
+
event.preventDefault();
|
|
7413
|
+
state.width = applySidePanelWidth(state.startWidth + (state.startX - event.clientX));
|
|
7414
|
+
}
|
|
7415
|
+
|
|
7416
|
+
function finishSidePanelResize(event) {
|
|
7417
|
+
const state = sidePanelResizeState;
|
|
7418
|
+
if (!state || (event.pointerId !== undefined && event.pointerId !== state.pointerId)) return;
|
|
7419
|
+
event.preventDefault?.();
|
|
7420
|
+
elements.sidePanelResizeHandle?.releasePointerCapture?.(state.pointerId);
|
|
7421
|
+
window.removeEventListener("pointermove", updateSidePanelResize);
|
|
7422
|
+
window.removeEventListener("pointerup", finishSidePanelResize);
|
|
7423
|
+
window.removeEventListener("pointercancel", finishSidePanelResize);
|
|
7424
|
+
document.body.classList.remove("side-panel-resizing");
|
|
7425
|
+
applySidePanelWidth(state.width, { persist: true });
|
|
7426
|
+
sidePanelResizeState = null;
|
|
7427
|
+
}
|
|
7428
|
+
|
|
7429
|
+
function handleSidePanelResizeKeydown(event) {
|
|
7430
|
+
if (isSidePanelOverlayView() || document.body.classList.contains("side-panel-collapsed")) return;
|
|
7431
|
+
const step = event.shiftKey ? 80 : 24;
|
|
7432
|
+
const current = currentSidePanelWidth();
|
|
7433
|
+
let next = current;
|
|
7434
|
+
if (event.key === "ArrowLeft") next = current + step;
|
|
7435
|
+
else if (event.key === "ArrowRight") next = current - step;
|
|
7436
|
+
else if (event.key === "Home") next = SIDE_PANEL_WIDTH_MIN_PX;
|
|
7437
|
+
else if (event.key === "End") next = sidePanelMaxWidth();
|
|
7438
|
+
else return;
|
|
7439
|
+
event.preventDefault();
|
|
7440
|
+
applySidePanelWidth(next, { persist: true });
|
|
7441
|
+
}
|
|
7442
|
+
|
|
7443
|
+
function syncSidePanelWidthForViewport() {
|
|
7444
|
+
if (isSidePanelOverlayView() || document.body.classList.contains("side-panel-collapsed")) {
|
|
7445
|
+
updateSidePanelResizeHandle();
|
|
7446
|
+
return;
|
|
7447
|
+
}
|
|
7448
|
+
applySidePanelWidth(currentSidePanelWidth());
|
|
7449
|
+
}
|
|
7450
|
+
|
|
7199
7451
|
function readStoredFileViewerWidth() {
|
|
7200
7452
|
try {
|
|
7201
7453
|
const width = Number.parseFloat(localStorage.getItem(FILE_VIEWER_WIDTH_STORAGE_KEY) || "");
|
|
@@ -7324,6 +7576,11 @@ function syncFileViewerWidthForViewport() {
|
|
|
7324
7576
|
applyFileViewerWidth(currentFileViewerWidth());
|
|
7325
7577
|
}
|
|
7326
7578
|
|
|
7579
|
+
function syncResizablePanelWidthsForViewport() {
|
|
7580
|
+
syncSidePanelWidthForViewport();
|
|
7581
|
+
syncFileViewerWidthForViewport();
|
|
7582
|
+
}
|
|
7583
|
+
|
|
7327
7584
|
async function openFileTreeEntryInWebui(entry = fileContextMenuState?.entry) {
|
|
7328
7585
|
if (!entry) return;
|
|
7329
7586
|
const path = normalizeFileTreePath(entry.path || "");
|
|
@@ -7354,6 +7611,7 @@ function updateFileViewerUi() {
|
|
|
7354
7611
|
const open = !!activeFileViewer;
|
|
7355
7612
|
document.body.classList.toggle("file-viewer-open", open);
|
|
7356
7613
|
if (elements.fileViewerPane) elements.fileViewerPane.hidden = !open;
|
|
7614
|
+
requestAnimationFrame(syncResizablePanelWidthsForViewport);
|
|
7357
7615
|
updateFileViewerResizeHandle();
|
|
7358
7616
|
if (!open) return;
|
|
7359
7617
|
if (!isSidePanelOverlayView()) applyFileViewerWidth(currentFileViewerWidth());
|
|
@@ -7520,6 +7778,7 @@ function closeFileViewer() {
|
|
|
7520
7778
|
document.body.classList.remove("file-viewer-open");
|
|
7521
7779
|
updateFileViewerResizeHandle();
|
|
7522
7780
|
if (elements.fileViewerPane) elements.fileViewerPane.hidden = true;
|
|
7781
|
+
requestAnimationFrame(syncResizablePanelWidthsForViewport);
|
|
7523
7782
|
if (elements.fileViewerOpenDefaultButton) elements.fileViewerOpenDefaultButton.dataset.path = "";
|
|
7524
7783
|
if (elements.fileViewerEditor) {
|
|
7525
7784
|
elements.fileViewerEditor.value = "";
|
|
@@ -7696,6 +7955,7 @@ function syncTabMetadata(nextTabs = []) {
|
|
|
7696
7955
|
suppressPendingAgentDoneNotificationsForTab(tabId, { markSeen: false });
|
|
7697
7956
|
actionFeedbackByTab.delete(tabId);
|
|
7698
7957
|
skillUsageByTab.delete(tabId);
|
|
7958
|
+
featureCategoryByTab.delete(tabId);
|
|
7699
7959
|
tabMessagesCache.delete(tabId);
|
|
7700
7960
|
widgetsByTab.delete(tabId);
|
|
7701
7961
|
appRunnerDataByTab.delete(tabId);
|
|
@@ -7705,6 +7965,9 @@ function syncTabMetadata(nextTabs = []) {
|
|
|
7705
7965
|
workflowInspectorByTab.delete(tabId);
|
|
7706
7966
|
workflowInspectorSelectionByTab.delete(tabId);
|
|
7707
7967
|
workflowInspectorMinimizedByTab.delete(tabId);
|
|
7968
|
+
workflowSubprocessMinimizedByTab.delete(tabId);
|
|
7969
|
+
workflowOverlayMinimizedByTab.delete(tabId);
|
|
7970
|
+
compactThinkingDisclosureStateByTab.delete(tabId);
|
|
7708
7971
|
remoteMicConsentTabs.delete(tabId);
|
|
7709
7972
|
if (voiceConversationTabId === tabId) stopVoiceConversationLoop();
|
|
7710
7973
|
clearGitWorkflowForTab(tabId);
|
|
@@ -9242,6 +9505,11 @@ async function switchTab(tabId) {
|
|
|
9242
9505
|
connectEvents(tabContext);
|
|
9243
9506
|
await refreshAll(tabContext);
|
|
9244
9507
|
if (isCurrentTabContext(tabContext)) markTabOutputSeen();
|
|
9508
|
+
if (!subagentLaunchSlotDraftIsDirty()) {
|
|
9509
|
+
loadSubagentLaunchSlotConfig({ tabId }).catch(() => {});
|
|
9510
|
+
} else {
|
|
9511
|
+
renderSubagentLaunchSlots();
|
|
9512
|
+
}
|
|
9245
9513
|
}
|
|
9246
9514
|
|
|
9247
9515
|
function currentDirectoryForNewTab() {
|
|
@@ -9264,6 +9532,7 @@ function updateTerminalSplitUi() {
|
|
|
9264
9532
|
const canShowSplit = !!tab && !embeddedSplitMode && !isSidePanelOverlayView();
|
|
9265
9533
|
document.body.classList.toggle("terminal-split-open", canShowSplit);
|
|
9266
9534
|
if (elements.terminalSplitShell) elements.terminalSplitShell.hidden = !canShowSplit;
|
|
9535
|
+
requestAnimationFrame(syncResizablePanelWidthsForViewport);
|
|
9267
9536
|
if (elements.splitTabButton) {
|
|
9268
9537
|
elements.splitTabButton.disabled = embeddedSplitMode || isSidePanelOverlayView() || !activeTab();
|
|
9269
9538
|
elements.splitTabButton.setAttribute("aria-pressed", canShowSplit ? "true" : "false");
|
|
@@ -9448,6 +9717,7 @@ async function closeTerminalTabs(tabIds, { label = "selected terminal tabs" } =
|
|
|
9448
9717
|
tabDrafts.delete(id);
|
|
9449
9718
|
clearAttachments(id);
|
|
9450
9719
|
clearGitWorkflowForTab(id);
|
|
9720
|
+
featureCategoryByTab.delete(id);
|
|
9451
9721
|
commandCatalogsByTab.delete(id);
|
|
9452
9722
|
appRunnerDataByTab.delete(id);
|
|
9453
9723
|
tabMessagesCache.delete(id);
|
|
@@ -9510,6 +9780,9 @@ async function initializeTabs() {
|
|
|
9510
9780
|
if (activeTabId) {
|
|
9511
9781
|
await refreshAll(tabContext);
|
|
9512
9782
|
if (isCurrentTabContext(tabContext)) markTabOutputSeen();
|
|
9783
|
+
if (!subagentLaunchSlotDraftIsDirty() || subagentLaunchSlotConfigTabId !== activeTabId) {
|
|
9784
|
+
loadSubagentLaunchSlotConfig().catch(() => {});
|
|
9785
|
+
}
|
|
9513
9786
|
}
|
|
9514
9787
|
}
|
|
9515
9788
|
|
|
@@ -16089,6 +16362,417 @@ function initializeSubagents() {
|
|
|
16089
16362
|
refreshSubagents().finally(() => scheduleRefreshSubagents());
|
|
16090
16363
|
}
|
|
16091
16364
|
|
|
16365
|
+
function subagentLaunchSlotLimits() {
|
|
16366
|
+
return {
|
|
16367
|
+
slotsPerRole: Number(subagentLaunchSlotConfig?.limits?.slotsPerRole) || 8,
|
|
16368
|
+
totalSlots: Number(subagentLaunchSlotConfig?.limits?.totalSlots) || 32,
|
|
16369
|
+
};
|
|
16370
|
+
}
|
|
16371
|
+
|
|
16372
|
+
function subagentLaunchSlotDraftRoles() {
|
|
16373
|
+
return subagentLaunchSlotDraft || subagentLaunchSlotConfig?.roles || {};
|
|
16374
|
+
}
|
|
16375
|
+
|
|
16376
|
+
function subagentLaunchSlotDraftIsDirty() {
|
|
16377
|
+
return !!subagentLaunchSlotConfig && !!subagentLaunchSlotDraft
|
|
16378
|
+
&& !launchSlotRolesEqual(subagentLaunchSlotDraft, subagentLaunchSlotConfig.roles || {});
|
|
16379
|
+
}
|
|
16380
|
+
|
|
16381
|
+
function subagentLaunchSlotModelKey(model) {
|
|
16382
|
+
return model?.provider && model?.id ? `${model.provider}/${model.id}` : "";
|
|
16383
|
+
}
|
|
16384
|
+
|
|
16385
|
+
function subagentLaunchSlotModelsByKey() {
|
|
16386
|
+
return new Map((Array.isArray(subagentLaunchSlotConfig?.models) ? subagentLaunchSlotConfig.models : [])
|
|
16387
|
+
.map((model) => [subagentLaunchSlotModelKey(model), model])
|
|
16388
|
+
.filter(([key]) => key));
|
|
16389
|
+
}
|
|
16390
|
+
|
|
16391
|
+
function subagentLaunchSlotThinkingForModel(model) {
|
|
16392
|
+
const levels = subagentLaunchSlotConfig?.modelThinkingLevels?.[model];
|
|
16393
|
+
return Array.isArray(levels) ? levels : [];
|
|
16394
|
+
}
|
|
16395
|
+
|
|
16396
|
+
function subagentLaunchSlotTotal(roles = subagentLaunchSlotDraftRoles()) {
|
|
16397
|
+
return Object.values(roles).reduce((total, slots) => total + (Array.isArray(slots) ? slots.length : 0), 0);
|
|
16398
|
+
}
|
|
16399
|
+
|
|
16400
|
+
function newSubagentLaunchSlotId(roles) {
|
|
16401
|
+
const used = new Set(Object.values(roles).flatMap((slots) => (Array.isArray(slots) ? slots : []).map((slot) => slot?.id)));
|
|
16402
|
+
for (let attempt = 0; attempt < 12; attempt++) {
|
|
16403
|
+
const token = globalThis.crypto?.randomUUID?.() || `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
16404
|
+
const id = `slot-${token}`;
|
|
16405
|
+
if (!used.has(id)) return id;
|
|
16406
|
+
}
|
|
16407
|
+
return "";
|
|
16408
|
+
}
|
|
16409
|
+
|
|
16410
|
+
function setSubagentLaunchSlotAnnouncement(message = "") {
|
|
16411
|
+
if (elements.subagentLaunchSlotsAnnouncer) elements.subagentLaunchSlotsAnnouncer.textContent = message;
|
|
16412
|
+
}
|
|
16413
|
+
|
|
16414
|
+
function focusSubagentLaunchSlotControl() {
|
|
16415
|
+
const target = subagentLaunchSlotFocusTarget;
|
|
16416
|
+
subagentLaunchSlotFocusTarget = null;
|
|
16417
|
+
if (!target || !elements.subagentLaunchSlotRoles) return;
|
|
16418
|
+
requestAnimationFrame(() => {
|
|
16419
|
+
const control = [...elements.subagentLaunchSlotRoles.querySelectorAll("select[data-launch-slot-role]")]
|
|
16420
|
+
.find((candidate) => candidate.dataset.launchSlotRole === target.roleId
|
|
16421
|
+
&& candidate.dataset.launchSlotId === target.slotId
|
|
16422
|
+
&& candidate.dataset.launchSlotControl === target.control);
|
|
16423
|
+
control?.focus();
|
|
16424
|
+
});
|
|
16425
|
+
}
|
|
16426
|
+
|
|
16427
|
+
function subagentLaunchSlotOption(value, text, { disabled = false } = {}) {
|
|
16428
|
+
const option = document.createElement("option");
|
|
16429
|
+
option.value = value || "";
|
|
16430
|
+
option.textContent = text;
|
|
16431
|
+
option.disabled = disabled;
|
|
16432
|
+
return option;
|
|
16433
|
+
}
|
|
16434
|
+
|
|
16435
|
+
function renderSubagentLaunchSlotCard(role, slots) {
|
|
16436
|
+
const limits = subagentLaunchSlotLimits();
|
|
16437
|
+
const modelsByKey = subagentLaunchSlotModelsByKey();
|
|
16438
|
+
const roleId = String(role?.id || "");
|
|
16439
|
+
const card = make("section", "subagent-launch-slot-role");
|
|
16440
|
+
card.setAttribute("aria-labelledby", `subagent-launch-slot-role-${roleId}`);
|
|
16441
|
+
const header = make("header", "subagent-launch-slot-role-header");
|
|
16442
|
+
const heading = make("div", "subagent-launch-slot-role-heading");
|
|
16443
|
+
heading.append(
|
|
16444
|
+
make("h4", undefined, role?.title || roleId),
|
|
16445
|
+
make("p", undefined, role?.purpose || "Configure launch-slot defaults for this role."),
|
|
16446
|
+
);
|
|
16447
|
+
heading.querySelector("h4")?.setAttribute("id", `subagent-launch-slot-role-${roleId}`);
|
|
16448
|
+
header.append(heading, make("span", "subagent-launch-slot-count", `${slots.length}/${limits.slotsPerRole} slots`));
|
|
16449
|
+
card.append(header);
|
|
16450
|
+
|
|
16451
|
+
const list = make("div", "subagent-launch-slot-list");
|
|
16452
|
+
for (const [index, slot] of slots.entries()) {
|
|
16453
|
+
const ordinal = index + 1;
|
|
16454
|
+
const slotLabel = `${role?.title || roleId} slot ${ordinal}`;
|
|
16455
|
+
const row = make("section", "subagent-launch-slot-row");
|
|
16456
|
+
row.setAttribute("aria-label", slotLabel);
|
|
16457
|
+
const rowHeader = make("div", "subagent-launch-slot-row-header");
|
|
16458
|
+
rowHeader.append(make("strong", undefined, `Slot ${ordinal}`), make("span", "subagent-launch-slot-id", slot.id));
|
|
16459
|
+
row.append(rowHeader);
|
|
16460
|
+
|
|
16461
|
+
const controls = make("div", "subagent-launch-slot-controls");
|
|
16462
|
+
const modelField = make("label", "subagent-launch-slot-field");
|
|
16463
|
+
const modelId = `subagent-launch-slot-model-${roleId}-${slot.id}`;
|
|
16464
|
+
modelField.append(make("span", undefined, "Model"));
|
|
16465
|
+
const modelSelect = document.createElement("select");
|
|
16466
|
+
modelSelect.id = modelId;
|
|
16467
|
+
modelSelect.dataset.launchSlotRole = roleId;
|
|
16468
|
+
modelSelect.dataset.launchSlotId = slot.id;
|
|
16469
|
+
modelSelect.dataset.launchSlotControl = "model";
|
|
16470
|
+
modelSelect.setAttribute("aria-label", `Model for ${slotLabel}`);
|
|
16471
|
+
modelSelect.append(subagentLaunchSlotOption("", "Default / inherit"));
|
|
16472
|
+
for (const [modelKey, model] of modelsByKey) {
|
|
16473
|
+
modelSelect.append(subagentLaunchSlotOption(modelKey, model?.name ? `${modelKey} · ${model.name}` : modelKey));
|
|
16474
|
+
}
|
|
16475
|
+
if (slot.model && !modelsByKey.has(slot.model)) {
|
|
16476
|
+
modelSelect.append(subagentLaunchSlotOption(slot.model, `Unavailable: ${slot.model}`, { disabled: true }));
|
|
16477
|
+
}
|
|
16478
|
+
modelSelect.value = slot.model || "";
|
|
16479
|
+
modelSelect.disabled = subagentLaunchSlotLoading || subagentLaunchSlotSaving;
|
|
16480
|
+
modelSelect.addEventListener("change", () => {
|
|
16481
|
+
const model = modelSelect.value || null;
|
|
16482
|
+
const thinking = model && subagentLaunchSlotThinkingForModel(model).includes(slot.thinking) ? slot.thinking : null;
|
|
16483
|
+
subagentLaunchSlotDraft = updateLaunchSlot(subagentLaunchSlotDraftRoles(), roleId, slot.id, { model, thinking });
|
|
16484
|
+
subagentLaunchSlotError = "";
|
|
16485
|
+
subagentLaunchSlotFocusTarget = { roleId, slotId: slot.id, control: "model" };
|
|
16486
|
+
renderSubagentLaunchSlots();
|
|
16487
|
+
});
|
|
16488
|
+
modelField.append(modelSelect);
|
|
16489
|
+
|
|
16490
|
+
const thinkingField = make("label", "subagent-launch-slot-field");
|
|
16491
|
+
const thinkingId = `subagent-launch-slot-thinking-${roleId}-${slot.id}`;
|
|
16492
|
+
thinkingField.append(make("span", undefined, "Thinking"));
|
|
16493
|
+
const thinkingSelect = document.createElement("select");
|
|
16494
|
+
thinkingSelect.id = thinkingId;
|
|
16495
|
+
thinkingSelect.dataset.launchSlotRole = roleId;
|
|
16496
|
+
thinkingSelect.dataset.launchSlotId = slot.id;
|
|
16497
|
+
thinkingSelect.dataset.launchSlotControl = "thinking";
|
|
16498
|
+
thinkingSelect.setAttribute("aria-label", `Thinking for ${slotLabel}`);
|
|
16499
|
+
thinkingSelect.append(subagentLaunchSlotOption("", "Default / inherit"));
|
|
16500
|
+
const supportedThinking = slot.model ? subagentLaunchSlotThinkingForModel(slot.model) : [];
|
|
16501
|
+
for (const thinking of supportedThinking) thinkingSelect.append(subagentLaunchSlotOption(thinking, thinking));
|
|
16502
|
+
if (slot.thinking && !supportedThinking.includes(slot.thinking)) {
|
|
16503
|
+
thinkingSelect.append(subagentLaunchSlotOption(slot.thinking, `Unavailable: ${slot.thinking}`, { disabled: true }));
|
|
16504
|
+
}
|
|
16505
|
+
thinkingSelect.value = slot.thinking || "";
|
|
16506
|
+
thinkingSelect.disabled = !slot.model || subagentLaunchSlotLoading || subagentLaunchSlotSaving || !modelsByKey.has(slot.model);
|
|
16507
|
+
thinkingSelect.addEventListener("change", () => {
|
|
16508
|
+
subagentLaunchSlotDraft = updateLaunchSlot(subagentLaunchSlotDraftRoles(), roleId, slot.id, { thinking: thinkingSelect.value || null });
|
|
16509
|
+
subagentLaunchSlotError = "";
|
|
16510
|
+
subagentLaunchSlotFocusTarget = { roleId, slotId: slot.id, control: "thinking" };
|
|
16511
|
+
renderSubagentLaunchSlots();
|
|
16512
|
+
});
|
|
16513
|
+
thinkingField.append(thinkingSelect);
|
|
16514
|
+
controls.append(modelField, thinkingField);
|
|
16515
|
+
row.append(controls);
|
|
16516
|
+
const metadata = slot.model
|
|
16517
|
+
? `${slot.model}${slot.thinking ? ` · ${slot.thinking}` : " · thinking default"}`
|
|
16518
|
+
: "Inherits the model and thinking default.";
|
|
16519
|
+
row.append(make("p", "subagent-launch-slot-meta", metadata));
|
|
16520
|
+
if (slot.id !== `${roleId}:base`) {
|
|
16521
|
+
const remove = make("button", "subagent-launch-slot-remove", "Remove");
|
|
16522
|
+
remove.type = "button";
|
|
16523
|
+
remove.disabled = subagentLaunchSlotLoading || subagentLaunchSlotSaving;
|
|
16524
|
+
remove.setAttribute("aria-label", `Remove ${slotLabel}`);
|
|
16525
|
+
remove.addEventListener("click", () => {
|
|
16526
|
+
const removed = removeLaunchSlot(subagentLaunchSlotDraftRoles(), roleId, slot.id);
|
|
16527
|
+
if (!removed) return;
|
|
16528
|
+
subagentLaunchSlotDraft = removed.roles;
|
|
16529
|
+
subagentLaunchSlotError = "";
|
|
16530
|
+
subagentLaunchSlotFocusTarget = removed.focusSlotId ? { roleId, slotId: removed.focusSlotId, control: "model" } : null;
|
|
16531
|
+
setSubagentLaunchSlotAnnouncement(`Removed ${slotLabel}.`);
|
|
16532
|
+
renderSubagentLaunchSlots();
|
|
16533
|
+
});
|
|
16534
|
+
row.append(remove);
|
|
16535
|
+
}
|
|
16536
|
+
list.append(row);
|
|
16537
|
+
}
|
|
16538
|
+
card.append(list);
|
|
16539
|
+
|
|
16540
|
+
const add = make("button", "subagent-launch-slot-add", "Add slot");
|
|
16541
|
+
add.type = "button";
|
|
16542
|
+
const source = slots[slots.length - 1];
|
|
16543
|
+
const atRoleLimit = slots.length >= limits.slotsPerRole || subagentLaunchSlotTotal() >= limits.totalSlots;
|
|
16544
|
+
add.disabled = atRoleLimit || subagentLaunchSlotLoading || subagentLaunchSlotSaving;
|
|
16545
|
+
add.setAttribute("aria-label", `Add same ${role?.title || roleId} type from slot ${slots.length}`);
|
|
16546
|
+
add.addEventListener("click", () => {
|
|
16547
|
+
const slotId = newSubagentLaunchSlotId(subagentLaunchSlotDraftRoles());
|
|
16548
|
+
if (!slotId) {
|
|
16549
|
+
setSubagentLaunchSlotAnnouncement(`Could not generate a unique ${role?.title || roleId} slot identifier. Try again.`);
|
|
16550
|
+
return;
|
|
16551
|
+
}
|
|
16552
|
+
const added = addLaunchSlot(subagentLaunchSlotDraftRoles(), roleId, source?.id, {
|
|
16553
|
+
...limits,
|
|
16554
|
+
createId: () => slotId,
|
|
16555
|
+
});
|
|
16556
|
+
if (!added) {
|
|
16557
|
+
setSubagentLaunchSlotAnnouncement(`Cannot add another ${role?.title || roleId} slot because the configured limit was reached.`);
|
|
16558
|
+
return;
|
|
16559
|
+
}
|
|
16560
|
+
subagentLaunchSlotDraft = added.roles;
|
|
16561
|
+
subagentLaunchSlotError = "";
|
|
16562
|
+
subagentLaunchSlotFocusTarget = { roleId, slotId: added.slot.id, control: "model" };
|
|
16563
|
+
setSubagentLaunchSlotAnnouncement(`Added ${role?.title || roleId} slot ${slots.length + 1}.`);
|
|
16564
|
+
renderSubagentLaunchSlots();
|
|
16565
|
+
});
|
|
16566
|
+
card.append(add);
|
|
16567
|
+
return card;
|
|
16568
|
+
}
|
|
16569
|
+
|
|
16570
|
+
function renderSubagentLaunchSlots() {
|
|
16571
|
+
if (!elements.subagentLaunchSlotRoles) return;
|
|
16572
|
+
const config = subagentLaunchSlotConfig;
|
|
16573
|
+
const dirty = subagentLaunchSlotDraftIsDirty();
|
|
16574
|
+
const activeConfigTab = !!subagentLaunchSlotConfigTabId && subagentLaunchSlotConfigTabId === activeTabId;
|
|
16575
|
+
if (elements.subagentLaunchSlotsSummaryStatus) {
|
|
16576
|
+
const roleCount = Array.isArray(config?.roleMetadata) ? config.roleMetadata.length : 8;
|
|
16577
|
+
elements.subagentLaunchSlotsSummaryStatus.textContent = subagentLaunchSlotError
|
|
16578
|
+
? "Needs attention"
|
|
16579
|
+
: subagentLaunchSlotLoading
|
|
16580
|
+
? "Loading launch presets…"
|
|
16581
|
+
: dirty
|
|
16582
|
+
? "Unsaved changes"
|
|
16583
|
+
: subagentLaunchSlotReloadRequired && activeConfigTab
|
|
16584
|
+
? "Saved · reload this tab"
|
|
16585
|
+
: config
|
|
16586
|
+
? `${roleCount} roles · ${subagentLaunchSlotScope === "project" ? "project scope" : "user defaults"}`
|
|
16587
|
+
: "Select a running Pi tab";
|
|
16588
|
+
}
|
|
16589
|
+
if (elements.subagentLaunchSlots && (subagentLaunchSlotError || (subagentLaunchSlotReloadRequired && activeConfigTab))) {
|
|
16590
|
+
elements.subagentLaunchSlots.open = true;
|
|
16591
|
+
}
|
|
16592
|
+
if (elements.subagentLaunchSlotScope) {
|
|
16593
|
+
elements.subagentLaunchSlotScope.value = subagentLaunchSlotScope;
|
|
16594
|
+
elements.subagentLaunchSlotScope.disabled = subagentLaunchSlotLoading || subagentLaunchSlotSaving;
|
|
16595
|
+
}
|
|
16596
|
+
if (elements.subagentLaunchSlotsRefresh) elements.subagentLaunchSlotsRefresh.disabled = subagentLaunchSlotLoading || subagentLaunchSlotSaving;
|
|
16597
|
+
if (elements.subagentLaunchSlotScopeStatus) {
|
|
16598
|
+
elements.subagentLaunchSlotScopeStatus.textContent = config
|
|
16599
|
+
? subagentLaunchSlotScope === "project"
|
|
16600
|
+
? config.inherited
|
|
16601
|
+
? `This project (${config.projectLabel || "current project"}) inherits your user defaults.`
|
|
16602
|
+
: `This project (${config.projectLabel || "current project"}) has its own launch-slot defaults.`
|
|
16603
|
+
: "User defaults apply to new projects unless that project has its own defaults."
|
|
16604
|
+
: "Select a running Pi tab to load its available models.";
|
|
16605
|
+
}
|
|
16606
|
+
if (elements.subagentLaunchSlotsInherit) {
|
|
16607
|
+
elements.subagentLaunchSlotsInherit.hidden = !(config && subagentLaunchSlotScope === "project" && !config.inherited);
|
|
16608
|
+
elements.subagentLaunchSlotsInherit.disabled = subagentLaunchSlotLoading || subagentLaunchSlotSaving || !activeConfigTab;
|
|
16609
|
+
}
|
|
16610
|
+
if (elements.subagentLaunchSlotsStatus) {
|
|
16611
|
+
const message = subagentLaunchSlotError || (subagentLaunchSlotLoading
|
|
16612
|
+
? "Loading agent models…"
|
|
16613
|
+
: config
|
|
16614
|
+
? !activeConfigTab
|
|
16615
|
+
? "This unsaved draft belongs to a different tab. Switch back to save or reload it."
|
|
16616
|
+
: subagentLaunchSlotScope === "project" && config.inherited
|
|
16617
|
+
? "This project currently inherits user-default launch slots."
|
|
16618
|
+
: "Model assignments are saved separately from the live monitor."
|
|
16619
|
+
: "Agent model configuration is unavailable.");
|
|
16620
|
+
elements.subagentLaunchSlotsStatus.textContent = message;
|
|
16621
|
+
elements.subagentLaunchSlotsStatus.classList.toggle("error", !!subagentLaunchSlotError);
|
|
16622
|
+
}
|
|
16623
|
+
if (elements.subagentLaunchSlotsSave) {
|
|
16624
|
+
elements.subagentLaunchSlotsSave.disabled = !config || !subagentLaunchSlotDraft || !dirty || subagentLaunchSlotLoading || subagentLaunchSlotSaving || !activeConfigTab;
|
|
16625
|
+
elements.subagentLaunchSlotsSave.textContent = subagentLaunchSlotSaving ? "Saving…" : "Save agent models";
|
|
16626
|
+
}
|
|
16627
|
+
if (elements.subagentLaunchSlotsDirty) {
|
|
16628
|
+
elements.subagentLaunchSlotsDirty.textContent = dirty ? "Unsaved changes" : "No unsaved changes";
|
|
16629
|
+
}
|
|
16630
|
+
if (elements.subagentLaunchSlotsReloadActions) {
|
|
16631
|
+
elements.subagentLaunchSlotsReloadActions.hidden = !(subagentLaunchSlotReloadRequired && activeConfigTab);
|
|
16632
|
+
}
|
|
16633
|
+
if (elements.subagentLaunchSlotsReload) elements.subagentLaunchSlotsReload.disabled = subagentLaunchSlotSaving || subagentLaunchSlotLoading;
|
|
16634
|
+
if (elements.subagentLaunchSlotsLater) elements.subagentLaunchSlotsLater.disabled = subagentLaunchSlotSaving || subagentLaunchSlotLoading;
|
|
16635
|
+
|
|
16636
|
+
elements.subagentLaunchSlotRoles.setAttribute("aria-busy", subagentLaunchSlotLoading ? "true" : "false");
|
|
16637
|
+
elements.subagentLaunchSlotRoles.replaceChildren();
|
|
16638
|
+
if (!config) {
|
|
16639
|
+
elements.subagentLaunchSlotRoles.append(make("p", "subagent-launch-slot-empty", subagentLaunchSlotLoading ? "Loading launch-slot defaults…" : "No agent-model configuration is loaded."));
|
|
16640
|
+
return;
|
|
16641
|
+
}
|
|
16642
|
+
const roles = subagentLaunchSlotDraftRoles();
|
|
16643
|
+
for (const role of Array.isArray(config.roleMetadata) ? config.roleMetadata : []) {
|
|
16644
|
+
const slots = Array.isArray(roles[role.id]) ? roles[role.id] : [];
|
|
16645
|
+
if (slots.length) elements.subagentLaunchSlotRoles.append(renderSubagentLaunchSlotCard(role, slots));
|
|
16646
|
+
}
|
|
16647
|
+
focusSubagentLaunchSlotControl();
|
|
16648
|
+
}
|
|
16649
|
+
|
|
16650
|
+
async function loadSubagentLaunchSlotConfig({ tabId = activeTabId, scope = subagentLaunchSlotScope } = {}) {
|
|
16651
|
+
if (!tabId) {
|
|
16652
|
+
renderSubagentLaunchSlots();
|
|
16653
|
+
return;
|
|
16654
|
+
}
|
|
16655
|
+
const requestSerial = ++subagentLaunchSlotRequestSerial;
|
|
16656
|
+
subagentLaunchSlotLoading = true;
|
|
16657
|
+
subagentLaunchSlotError = "";
|
|
16658
|
+
renderSubagentLaunchSlots();
|
|
16659
|
+
try {
|
|
16660
|
+
const query = new URLSearchParams({ tab: tabId, scope });
|
|
16661
|
+
const response = await api(`/api/subagents/config?${query}`, { scoped: false });
|
|
16662
|
+
if (requestSerial !== subagentLaunchSlotRequestSerial || tabId !== activeTabId || scope !== subagentLaunchSlotScope) return;
|
|
16663
|
+
subagentLaunchSlotConfig = response.data || null;
|
|
16664
|
+
subagentLaunchSlotConfigTabId = tabId;
|
|
16665
|
+
subagentLaunchSlotDraft = cloneLaunchSlotRoles(response.data?.roles || {});
|
|
16666
|
+
subagentLaunchSlotReloadRequired = subagentLaunchSlotReloadTabs.has(tabId);
|
|
16667
|
+
} catch (error) {
|
|
16668
|
+
if (requestSerial !== subagentLaunchSlotRequestSerial) return;
|
|
16669
|
+
subagentLaunchSlotError = `Could not load agent models: ${error.message || String(error)}`;
|
|
16670
|
+
} finally {
|
|
16671
|
+
if (requestSerial === subagentLaunchSlotRequestSerial) {
|
|
16672
|
+
subagentLaunchSlotLoading = false;
|
|
16673
|
+
renderSubagentLaunchSlots();
|
|
16674
|
+
}
|
|
16675
|
+
}
|
|
16676
|
+
}
|
|
16677
|
+
|
|
16678
|
+
async function confirmDiscardSubagentLaunchSlotDraft(action) {
|
|
16679
|
+
if (!subagentLaunchSlotDraftIsDirty()) return true;
|
|
16680
|
+
return appConfirm({
|
|
16681
|
+
title: "Discard unsaved agent models?",
|
|
16682
|
+
summary: `${action} replaces the current launch-slot draft with saved settings.`,
|
|
16683
|
+
affected: "Unsaved model and thinking assignments in this browser tab",
|
|
16684
|
+
undoable: false,
|
|
16685
|
+
confirmLabel: "Discard changes",
|
|
16686
|
+
});
|
|
16687
|
+
}
|
|
16688
|
+
|
|
16689
|
+
async function selectSubagentLaunchSlotScope(scope) {
|
|
16690
|
+
const nextScope = scope === "project" ? "project" : "user";
|
|
16691
|
+
if (nextScope === subagentLaunchSlotScope) return;
|
|
16692
|
+
if (!(await confirmDiscardSubagentLaunchSlotDraft("Changing scope"))) {
|
|
16693
|
+
renderSubagentLaunchSlots();
|
|
16694
|
+
return;
|
|
16695
|
+
}
|
|
16696
|
+
subagentLaunchSlotScope = nextScope;
|
|
16697
|
+
subagentLaunchSlotReloadRequired = false;
|
|
16698
|
+
await loadSubagentLaunchSlotConfig();
|
|
16699
|
+
}
|
|
16700
|
+
|
|
16701
|
+
async function reloadSubagentLaunchSlotConfig() {
|
|
16702
|
+
if (!(await confirmDiscardSubagentLaunchSlotDraft("Reloading configuration"))) return;
|
|
16703
|
+
subagentLaunchSlotReloadRequired = false;
|
|
16704
|
+
await loadSubagentLaunchSlotConfig();
|
|
16705
|
+
}
|
|
16706
|
+
|
|
16707
|
+
function applySavedSubagentLaunchSlotConfig(data) {
|
|
16708
|
+
subagentLaunchSlotConfig = data || null;
|
|
16709
|
+
subagentLaunchSlotConfigTabId = activeTabId;
|
|
16710
|
+
subagentLaunchSlotDraft = cloneLaunchSlotRoles(data?.roles || {});
|
|
16711
|
+
if (data?.changed === true && data?.reloadRequired === true && activeTabId) {
|
|
16712
|
+
subagentLaunchSlotReloadTabs.add(activeTabId);
|
|
16713
|
+
}
|
|
16714
|
+
subagentLaunchSlotReloadRequired = subagentLaunchSlotReloadTabs.has(activeTabId);
|
|
16715
|
+
}
|
|
16716
|
+
|
|
16717
|
+
async function saveSubagentLaunchSlotConfig({ inherit = false } = {}) {
|
|
16718
|
+
if (!subagentLaunchSlotConfig || !subagentLaunchSlotConfigTabId || subagentLaunchSlotConfigTabId !== activeTabId) {
|
|
16719
|
+
subagentLaunchSlotError = "Return to the tab that owns this launch-slot draft before saving.";
|
|
16720
|
+
renderSubagentLaunchSlots();
|
|
16721
|
+
return;
|
|
16722
|
+
}
|
|
16723
|
+
subagentLaunchSlotSaving = true;
|
|
16724
|
+
subagentLaunchSlotError = "";
|
|
16725
|
+
renderSubagentLaunchSlots();
|
|
16726
|
+
try {
|
|
16727
|
+
const body = {
|
|
16728
|
+
tab: activeTabId,
|
|
16729
|
+
scope: subagentLaunchSlotScope,
|
|
16730
|
+
revision: subagentLaunchSlotConfig.revision,
|
|
16731
|
+
};
|
|
16732
|
+
if (inherit) body.inherit = true;
|
|
16733
|
+
else body.roles = cloneLaunchSlotRoles(subagentLaunchSlotDraftRoles());
|
|
16734
|
+
const response = await api("/api/subagents/config", { method: "POST", body, scoped: false });
|
|
16735
|
+
applySavedSubagentLaunchSlotConfig(response.data);
|
|
16736
|
+
setSubagentLaunchSlotAnnouncement(inherit ? "This project now uses user-default agent models." : "Agent models saved.");
|
|
16737
|
+
} catch (error) {
|
|
16738
|
+
const conflict = error?.statusCode === 409;
|
|
16739
|
+
subagentLaunchSlotError = `${conflict ? "Conflict: reload configuration before saving." : "Could not save agent models:"} ${conflict ? "" : error.message || String(error)}`.trim();
|
|
16740
|
+
} finally {
|
|
16741
|
+
subagentLaunchSlotSaving = false;
|
|
16742
|
+
renderSubagentLaunchSlots();
|
|
16743
|
+
}
|
|
16744
|
+
}
|
|
16745
|
+
|
|
16746
|
+
async function resetSubagentLaunchSlotProjectScope() {
|
|
16747
|
+
if (subagentLaunchSlotScope !== "project" || !subagentLaunchSlotConfig || subagentLaunchSlotConfig.inherited) return;
|
|
16748
|
+
if (!(await confirmDiscardSubagentLaunchSlotDraft("Using user defaults"))) return;
|
|
16749
|
+
await saveSubagentLaunchSlotConfig({ inherit: true });
|
|
16750
|
+
}
|
|
16751
|
+
|
|
16752
|
+
async function reloadActiveTabForSubagentLaunchSlots() {
|
|
16753
|
+
if (!subagentLaunchSlotReloadRequired || subagentLaunchSlotConfigTabId !== activeTabId) return;
|
|
16754
|
+
subagentLaunchSlotSaving = true;
|
|
16755
|
+
subagentLaunchSlotError = "";
|
|
16756
|
+
renderSubagentLaunchSlots();
|
|
16757
|
+
try {
|
|
16758
|
+
await sendPrompt("prompt", "/reload", { targetTabId: activeTabId, throwOnError: true });
|
|
16759
|
+
subagentLaunchSlotReloadTabs.delete(activeTabId);
|
|
16760
|
+
subagentLaunchSlotReloadRequired = false;
|
|
16761
|
+
setSubagentLaunchSlotAnnouncement("Active tab reloaded. Agent model guidance now applies to future launches.");
|
|
16762
|
+
await loadSubagentLaunchSlotConfig();
|
|
16763
|
+
} catch (error) {
|
|
16764
|
+
subagentLaunchSlotError = `Could not reload the active tab: ${error.message || String(error)}`;
|
|
16765
|
+
} finally {
|
|
16766
|
+
subagentLaunchSlotSaving = false;
|
|
16767
|
+
renderSubagentLaunchSlots();
|
|
16768
|
+
}
|
|
16769
|
+
}
|
|
16770
|
+
|
|
16771
|
+
function initializeSubagentLaunchSlots() {
|
|
16772
|
+
renderSubagentLaunchSlots();
|
|
16773
|
+
if (activeTabId) loadSubagentLaunchSlotConfig().catch(() => {});
|
|
16774
|
+
}
|
|
16775
|
+
|
|
16092
16776
|
function sessionCopyButton(label, value) {
|
|
16093
16777
|
const button = make("button", "session-copy-button", "Copy");
|
|
16094
16778
|
button.type = "button";
|
|
@@ -16588,7 +17272,9 @@ function renderReleaseNpmOutputDetails(key, streamHeader, terminal, controls = n
|
|
|
16588
17272
|
node.open = releaseNpmOutputExpandedByTab.get(stateKey) !== false;
|
|
16589
17273
|
node.addEventListener("toggle", () => {
|
|
16590
17274
|
releaseNpmOutputExpandedByTab.set(stateKey, node.open);
|
|
16591
|
-
if (node.open
|
|
17275
|
+
if (node.open && terminal.dataset.preserveScrollOnToggle !== "true") {
|
|
17276
|
+
requestAnimationFrame(() => { terminal.scrollTop = terminal.scrollHeight; });
|
|
17277
|
+
}
|
|
16592
17278
|
});
|
|
16593
17279
|
|
|
16594
17280
|
const summary = make("summary", "release-npm-output-summary");
|
|
@@ -17076,14 +17762,72 @@ function workflowTaskCountLabel(payload) {
|
|
|
17076
17762
|
return `${done}/${total} done${failed ? ` · ${failed} failed` : ""}${cancelled ? ` · ${cancelled} cancelled` : ""}`;
|
|
17077
17763
|
}
|
|
17078
17764
|
|
|
17765
|
+
function workflowMetaItem(label, value, className = "", description = "") {
|
|
17766
|
+
const item = make("span", `workflow-meta-item ${className}`.trim());
|
|
17767
|
+
item.append(
|
|
17768
|
+
make("span", "workflow-meta-label", label),
|
|
17769
|
+
make("strong", "workflow-meta-value", value),
|
|
17770
|
+
);
|
|
17771
|
+
if (description) item.append(make("span", "workflow-meta-description", description));
|
|
17772
|
+
return item;
|
|
17773
|
+
}
|
|
17774
|
+
|
|
17775
|
+
function bindWorkflowTerminalScroll(terminal, outputDetails, followStatus, { live = false, runId = "unknown" } = {}) {
|
|
17776
|
+
const statePrefix = `${activeTabId || "default"}:workflow:subprocess:`;
|
|
17777
|
+
const stateKey = `${statePrefix}${runId}`;
|
|
17778
|
+
for (const key of workflowTerminalScrollByTab.keys()) {
|
|
17779
|
+
if (key.startsWith(statePrefix) && key !== stateKey) workflowTerminalScrollByTab.delete(key);
|
|
17780
|
+
}
|
|
17781
|
+
const state = workflowTerminalScrollByTab.get(stateKey) || { following: true, scrollTop: 0 };
|
|
17782
|
+
const updateFollowStatus = () => {
|
|
17783
|
+
followStatus.textContent = live
|
|
17784
|
+
? (state.following ? "Following live output · scroll up to pause" : "Auto-follow paused · scroll to the bottom to resume")
|
|
17785
|
+
: "Output complete · scroll position is preserved";
|
|
17786
|
+
followStatus.classList.toggle("paused", live && !state.following);
|
|
17787
|
+
};
|
|
17788
|
+
const restorePosition = () => {
|
|
17789
|
+
if (!outputDetails.open) return;
|
|
17790
|
+
const maxScrollTop = Math.max(0, terminal.scrollHeight - terminal.clientHeight);
|
|
17791
|
+
terminal.scrollTop = state.following ? maxScrollTop : Math.min(state.scrollTop, maxScrollTop);
|
|
17792
|
+
};
|
|
17793
|
+
terminal.addEventListener("scroll", () => {
|
|
17794
|
+
const distanceFromBottom = terminal.scrollHeight - terminal.clientHeight - terminal.scrollTop;
|
|
17795
|
+
state.following = distanceFromBottom <= 24;
|
|
17796
|
+
state.scrollTop = terminal.scrollTop;
|
|
17797
|
+
workflowTerminalScrollByTab.set(stateKey, state);
|
|
17798
|
+
updateFollowStatus();
|
|
17799
|
+
}, { passive: true });
|
|
17800
|
+
outputDetails.addEventListener("toggle", () => {
|
|
17801
|
+
if (outputDetails.open) requestAnimationFrame(restorePosition);
|
|
17802
|
+
});
|
|
17803
|
+
updateFollowStatus();
|
|
17804
|
+
requestAnimationFrame(restorePosition);
|
|
17805
|
+
}
|
|
17806
|
+
|
|
17807
|
+
function workflowSubprocessSetMinimized(minimized) {
|
|
17808
|
+
if (!activeTabId) return;
|
|
17809
|
+
const tabId = activeTabId;
|
|
17810
|
+
if (minimized) workflowSubprocessMinimizedByTab.add(tabId);
|
|
17811
|
+
else workflowSubprocessMinimizedByTab.delete(tabId);
|
|
17812
|
+
renderWidgets();
|
|
17813
|
+
requestAnimationFrame(() => {
|
|
17814
|
+
if (activeTabId !== tabId) return;
|
|
17815
|
+
elements.widgetArea.querySelector(".workflow-subprocess-minimize-button")?.focus({ preventScroll: true });
|
|
17816
|
+
});
|
|
17817
|
+
}
|
|
17818
|
+
|
|
17079
17819
|
function renderWorkflowSubprocessWidget() {
|
|
17080
17820
|
if (!isOptionalFeatureEnabled("workflows")) return null;
|
|
17081
17821
|
const payload = parseWorkflowSubprocessPayload(getWidgetLines("workflow:subprocess"));
|
|
17082
17822
|
if (!payload) return null;
|
|
17083
17823
|
|
|
17084
17824
|
const live = workflowSubprocessIsLive(payload);
|
|
17085
|
-
const
|
|
17825
|
+
const minimized = Boolean(activeTabId && workflowSubprocessMinimizedByTab.has(activeTabId));
|
|
17826
|
+
const node = make("section", `widget release-npm-widget workflow-widget workflow-subprocess-widget ${live ? "workflow-live-widget" : "workflow-log-widget"}${minimized ? " minimized" : ""}`);
|
|
17086
17827
|
node.setAttribute("aria-label", "workflow subprocess output");
|
|
17828
|
+
const body = make("div", "workflow-subprocess-body");
|
|
17829
|
+
body.id = "workflowSubprocessBody";
|
|
17830
|
+
body.hidden = minimized;
|
|
17087
17831
|
|
|
17088
17832
|
const header = make("div", "release-npm-header");
|
|
17089
17833
|
const titleWrap = make("div", "release-npm-title-wrap");
|
|
@@ -17092,29 +17836,56 @@ function renderWorkflowSubprocessWidget() {
|
|
|
17092
17836
|
make("strong", "release-npm-title", payload.workflowName || payload.workflowKey || "workflow"),
|
|
17093
17837
|
);
|
|
17094
17838
|
|
|
17095
|
-
const meta = make("div", "release-npm-meta");
|
|
17096
|
-
meta.
|
|
17097
|
-
|
|
17098
|
-
meta.append(
|
|
17099
|
-
if (payload.
|
|
17839
|
+
const meta = make("div", "release-npm-meta workflow-meta");
|
|
17840
|
+
meta.setAttribute("role", "group");
|
|
17841
|
+
meta.setAttribute("aria-label", "Workflow run summary");
|
|
17842
|
+
meta.append(workflowMetaItem("Run", payload.status || "unknown", `workflow-status ${payload.status || "unknown"}`));
|
|
17843
|
+
if (payload.activePhase) meta.append(workflowMetaItem("Phase", String(payload.activePhase).replace(/^phases?(?::|\s)+/i, "")));
|
|
17844
|
+
meta.append(workflowMetaItem("Tasks", workflowTaskCountLabel(payload), "workflow-tasks"));
|
|
17845
|
+
if (payload.truncated) {
|
|
17846
|
+
meta.append(workflowMetaItem(
|
|
17847
|
+
"Output",
|
|
17848
|
+
"Limited history",
|
|
17849
|
+
"workflow-truncated",
|
|
17850
|
+
"Older output omitted from this view.",
|
|
17851
|
+
));
|
|
17852
|
+
}
|
|
17100
17853
|
|
|
17101
17854
|
const actions = make("div", "release-npm-actions");
|
|
17102
17855
|
actions.append(releaseNpmActionButton("Status", "/workflow status"));
|
|
17103
17856
|
if (live) actions.append(releaseNpmActionButton("Abort", "/workflow abort", "danger"));
|
|
17104
17857
|
actions.append(releaseNpmActionButton("Clear", "/workflow-clear"));
|
|
17858
|
+
const minimizeButton = make("button", "release-npm-action workflow-subprocess-minimize-button", minimized ? "Restore" : "Minimize");
|
|
17859
|
+
minimizeButton.type = "button";
|
|
17860
|
+
minimizeButton.setAttribute("aria-controls", body.id);
|
|
17861
|
+
minimizeButton.setAttribute("aria-expanded", minimized ? "false" : "true");
|
|
17862
|
+
minimizeButton.setAttribute("aria-label", minimized ? "Restore workflow subprocess output" : "Minimize workflow subprocess output");
|
|
17863
|
+
minimizeButton.setAttribute("title", minimized ? "Restore workflow subprocess output" : "Minimize workflow subprocess output");
|
|
17864
|
+
minimizeButton.addEventListener("click", () => workflowSubprocessSetMinimized(!minimized));
|
|
17865
|
+
actions.append(minimizeButton);
|
|
17105
17866
|
header.append(titleWrap, meta, actions);
|
|
17867
|
+
node.append(header, body);
|
|
17868
|
+
if (minimized) return node;
|
|
17106
17869
|
|
|
17107
17870
|
const lines = Array.isArray(payload.lines) && payload.lines.length ? payload.lines : ["Waiting for workflow subprocess output..."];
|
|
17108
17871
|
const streamHeader = releaseNpmStreamHeader(live ? "Live subprocess output" : "Subprocess output", lines.length, { live });
|
|
17109
17872
|
const terminal = make("div", "release-npm-terminal");
|
|
17873
|
+
terminal.dataset.preserveScrollOnToggle = "true";
|
|
17110
17874
|
terminal.setAttribute("role", "log");
|
|
17111
17875
|
terminal.setAttribute("aria-live", live ? "polite" : "off");
|
|
17112
17876
|
for (const line of lines) appendReleaseNpmTerminalLine(terminal, line);
|
|
17113
17877
|
|
|
17114
|
-
const controls = make("div", "release-npm-controls
|
|
17878
|
+
const controls = make("div", "release-npm-controls workflow-output-controls");
|
|
17879
|
+
const followStatus = make("span", "workflow-follow-status");
|
|
17880
|
+
followStatus.setAttribute("role", "status");
|
|
17881
|
+
followStatus.setAttribute("aria-live", "polite");
|
|
17882
|
+
controls.append(
|
|
17883
|
+
followStatus,
|
|
17884
|
+
make("span", "workflow-output-help", live ? "Use /workflow abort to stop the active run." : "The subprocess run has finished."),
|
|
17885
|
+
);
|
|
17115
17886
|
const outputDetails = renderReleaseNpmOutputDetails("workflow:subprocess", streamHeader, terminal, controls);
|
|
17116
|
-
|
|
17117
|
-
|
|
17887
|
+
body.append(outputDetails);
|
|
17888
|
+
bindWorkflowTerminalScroll(terminal, outputDetails, followStatus, { live, runId: payload.runId });
|
|
17118
17889
|
return node;
|
|
17119
17890
|
}
|
|
17120
17891
|
|
|
@@ -18977,6 +19748,24 @@ function mirrorRemoteWebuiWidgetToTranscript(widgetKey, lines = [], request = {}
|
|
|
18977
19748
|
addTransientMessage({ role: "extension", title: "/remote", content, level: "info", widgetKey });
|
|
18978
19749
|
}
|
|
18979
19750
|
|
|
19751
|
+
function workflowOverlayCloseButton() {
|
|
19752
|
+
const button = make("button", "release-npm-action workflow-overlay-close-button", "Close");
|
|
19753
|
+
button.type = "button";
|
|
19754
|
+
button.setAttribute("aria-controls", "widgetArea");
|
|
19755
|
+
button.setAttribute("aria-expanded", "true");
|
|
19756
|
+
button.setAttribute("aria-label", "Close and minimize workflow overlay");
|
|
19757
|
+
button.setAttribute("title", "Close and minimize workflow overlay");
|
|
19758
|
+
button.addEventListener("click", () => setWorkflowOverlayMinimized(true));
|
|
19759
|
+
return button;
|
|
19760
|
+
}
|
|
19761
|
+
|
|
19762
|
+
function attachWorkflowOverlayCloseButton(widget) {
|
|
19763
|
+
if (!widget) return;
|
|
19764
|
+
const header = widget.querySelector(":scope > .release-npm-header");
|
|
19765
|
+
const actions = header?.querySelector(".release-npm-actions") || header?.querySelector(".release-npm-meta");
|
|
19766
|
+
actions?.append(workflowOverlayCloseButton());
|
|
19767
|
+
}
|
|
19768
|
+
|
|
18980
19769
|
function renderWidgets() {
|
|
18981
19770
|
if (deferUiRenderDuringPointerActivation("widgets", renderWidgets)) return;
|
|
18982
19771
|
const appRunnerInputFocus = captureAppRunnerInputFocus();
|
|
@@ -18991,10 +19780,14 @@ function renderWidgets() {
|
|
|
18991
19780
|
if (releaseAurLog) elements.widgetArea.append(releaseAurLog);
|
|
18992
19781
|
const aurReviewWidget = renderAurReviewWidget();
|
|
18993
19782
|
if (aurReviewWidget) elements.widgetArea.append(aurReviewWidget);
|
|
18994
|
-
|
|
18995
|
-
|
|
18996
|
-
|
|
18997
|
-
|
|
19783
|
+
if (!workflowOverlayIsMinimized()) {
|
|
19784
|
+
const workflowInspectorWidget = renderWorkflowInspectorWidget();
|
|
19785
|
+
const workflowSubprocessWidget = renderWorkflowSubprocessWidget();
|
|
19786
|
+
attachWorkflowOverlayCloseButton(workflowInspectorWidget || workflowSubprocessWidget);
|
|
19787
|
+
if (workflowInspectorWidget) elements.widgetArea.append(workflowInspectorWidget);
|
|
19788
|
+
if (workflowSubprocessWidget) elements.widgetArea.append(workflowSubprocessWidget);
|
|
19789
|
+
}
|
|
19790
|
+
renderWorkflowOverlayControls();
|
|
18998
19791
|
const appRunnerWidget = renderAppRunnerWidget();
|
|
18999
19792
|
if (appRunnerWidget) elements.widgetArea.append(appRunnerWidget);
|
|
19000
19793
|
const subagentWidget = renderSubagentOverlayWidgetSafely();
|
|
@@ -23724,7 +24517,7 @@ function captureReusableToolCards() {
|
|
|
23724
24517
|
}
|
|
23725
24518
|
|
|
23726
24519
|
function reuseToolExecutionBubble(reusableToolCards, message, { streaming = false, messageIndex = -1, transient = false } = {}) {
|
|
23727
|
-
if (streaming || message?.role !== "toolExecution" || !message.toolCallId || !reusableToolCards) return null;
|
|
24520
|
+
if (compactOutputActive() || streaming || message?.role !== "toolExecution" || !message.toolCallId || !reusableToolCards) return null;
|
|
23728
24521
|
const id = String(message.toolCallId);
|
|
23729
24522
|
const bubble = reusableToolCards.get(id);
|
|
23730
24523
|
if (!bubble) return null;
|
|
@@ -23880,10 +24673,50 @@ function jumpToStickyUserPrompt() {
|
|
|
23880
24673
|
requestAnimationFrame(updateStickyUserPromptButton);
|
|
23881
24674
|
}
|
|
23882
24675
|
|
|
24676
|
+
function renderCompactTranscriptBody(body, message) {
|
|
24677
|
+
if (message.role !== "assistant") return false;
|
|
24678
|
+
const output = stripTodoProgressLines(textFromContent(message.content));
|
|
24679
|
+
const block = appendMarkdown(body, output || "_[non-text output omitted in fast mode]_");
|
|
24680
|
+
block.classList.add("compact-transcript-text");
|
|
24681
|
+
return true;
|
|
24682
|
+
}
|
|
24683
|
+
|
|
24684
|
+
function compactThinkingDisclosureExpanded(key, defaultExpanded = false) {
|
|
24685
|
+
if (!key) return !!defaultExpanded;
|
|
24686
|
+
const disclosureState = compactThinkingDisclosureStateByTab.get(activeTabId || "default");
|
|
24687
|
+
return disclosureState?.has(key) ? disclosureState.get(key) === true : !!defaultExpanded;
|
|
24688
|
+
}
|
|
24689
|
+
|
|
24690
|
+
function setCompactThinkingDisclosureExpanded(key, expanded, defaultExpanded = false) {
|
|
24691
|
+
if (!key) return;
|
|
24692
|
+
const tabId = activeTabId || "default";
|
|
24693
|
+
let disclosureState = compactThinkingDisclosureStateByTab.get(tabId);
|
|
24694
|
+
if (expanded === defaultExpanded) {
|
|
24695
|
+
disclosureState?.delete(key);
|
|
24696
|
+
if (disclosureState?.size === 0) compactThinkingDisclosureStateByTab.delete(tabId);
|
|
24697
|
+
return;
|
|
24698
|
+
}
|
|
24699
|
+
if (!disclosureState) {
|
|
24700
|
+
disclosureState = new Map();
|
|
24701
|
+
compactThinkingDisclosureStateByTab.set(tabId, disclosureState);
|
|
24702
|
+
}
|
|
24703
|
+
disclosureState.set(key, !!expanded);
|
|
24704
|
+
}
|
|
24705
|
+
|
|
24706
|
+
function clearCompactThinkingDisclosureState(key) {
|
|
24707
|
+
if (!key) return;
|
|
24708
|
+
const tabId = activeTabId || "default";
|
|
24709
|
+
const disclosureState = compactThinkingDisclosureStateByTab.get(tabId);
|
|
24710
|
+
disclosureState?.delete(key);
|
|
24711
|
+
if (disclosureState?.size === 0) compactThinkingDisclosureStateByTab.delete(tabId);
|
|
24712
|
+
}
|
|
24713
|
+
|
|
23883
24714
|
function createMessageBubble(message, { streaming = false, messageIndex = -1, transient = false, animateEntry = false, itemKey = "" } = {}) {
|
|
23884
24715
|
const role = String(message.role || "message");
|
|
23885
24716
|
const safeRole = role.replace(/[^a-z0-9_-]/gi, "");
|
|
23886
|
-
const
|
|
24717
|
+
const compactTranscript = compactOutputActive() && !streaming;
|
|
24718
|
+
const compactThinkingAggregate = compactOutputActive() && message.role === "thinking" && message.compactThinkingAggregate === true;
|
|
24719
|
+
const bubble = make("article", `message ${safeRole}${message.level ? ` ${message.level}` : ""}${streaming ? " streaming" : ""}${animateEntry ? " action-enter" : ""}${compactTranscript ? " compact-transcript-output" : ""}${compactThinkingAggregate ? " compact-thinking-aggregate" : ""}`);
|
|
23887
24720
|
applyChatEventMetadata(bubble, message);
|
|
23888
24721
|
if (message.role === "toolExecution") applyToolExecutionBubbleState(bubble, message);
|
|
23889
24722
|
if (!transient && messageIndex >= 0) {
|
|
@@ -23891,7 +24724,7 @@ function createMessageBubble(message, { streaming = false, messageIndex = -1, tr
|
|
|
23891
24724
|
if (role === "user") bubble.dataset.userPrompt = "true";
|
|
23892
24725
|
}
|
|
23893
24726
|
if (itemKey) bubble.dataset.itemKey = itemKey;
|
|
23894
|
-
const isCollapsibleOutput = !streaming && (message.role === "toolResult" || message.role === "bashExecution" || message.role === "compactionSummary");
|
|
24727
|
+
const isCollapsibleOutput = compactThinkingAggregate || (!streaming && (message.role === "toolResult" || message.role === "bashExecution" || message.role === "compactionSummary"));
|
|
23895
24728
|
|
|
23896
24729
|
const hideMessageHeader = message.role === "assistant" && !isCollapsibleOutput;
|
|
23897
24730
|
if (hideMessageHeader) bubble.setAttribute("aria-label", messageTitle(message));
|
|
@@ -23900,7 +24733,9 @@ function createMessageBubble(message, { streaming = false, messageIndex = -1, tr
|
|
|
23900
24733
|
header.append(make("span", "muted", formatDate(message.timestamp)));
|
|
23901
24734
|
const body = make("div", "message-body");
|
|
23902
24735
|
|
|
23903
|
-
if (
|
|
24736
|
+
if (compactTranscript && renderCompactTranscriptBody(body, message)) {
|
|
24737
|
+
// Fast mode preserves final Markdown while omitting reconciled tool history.
|
|
24738
|
+
} else if (message.role === "bashExecution") {
|
|
23904
24739
|
appendText(body, `$ ${message.command || ""}\n\n${message.output || ""}`, "code-block");
|
|
23905
24740
|
} else if (message.role === "compactionSummary") {
|
|
23906
24741
|
appendText(body, message.summary || "Context was compacted.");
|
|
@@ -23918,12 +24753,16 @@ function createMessageBubble(message, { streaming = false, messageIndex = -1, tr
|
|
|
23918
24753
|
} else if (message.role === "assistantEvent") {
|
|
23919
24754
|
appendText(body, typeof message.content === "string" ? message.content : JSON.stringify(message.content ?? {}, null, 2), "code-block");
|
|
23920
24755
|
} else {
|
|
23921
|
-
renderContent(body, message.content, { markdown: message.role === "assistant" });
|
|
24756
|
+
renderContent(body, message.content, { markdown: message.role === "assistant" || message.role === "custom" });
|
|
23922
24757
|
}
|
|
23923
24758
|
|
|
23924
24759
|
if (isCollapsibleOutput) {
|
|
23925
|
-
const details = make("details",
|
|
23926
|
-
if (
|
|
24760
|
+
const details = make("details", `message-collapse${compactThinkingAggregate ? " compact-thinking-disclosure" : ""}`);
|
|
24761
|
+
if (compactThinkingAggregate) {
|
|
24762
|
+
const defaultExpanded = message.compactThinkingDefaultExpanded === true;
|
|
24763
|
+
details.open = compactThinkingDisclosureExpanded(message.compactThinkingKey, defaultExpanded);
|
|
24764
|
+
if (message.compactThinkingKey) details.addEventListener("toggle", () => setCompactThinkingDisclosureExpanded(message.compactThinkingKey, details.open, defaultExpanded));
|
|
24765
|
+
} else if (shouldOpenMessageCollapseByDefault(message)) details.open = true;
|
|
23927
24766
|
details.append(header, body);
|
|
23928
24767
|
bubble.append(details);
|
|
23929
24768
|
if (message.role === "toolResult" && !message.isError) {
|
|
@@ -23966,6 +24805,7 @@ function appendTranscriptMessage(message, { streaming = false, messageIndex = -1
|
|
|
23966
24805
|
}
|
|
23967
24806
|
|
|
23968
24807
|
let finalOutput = null;
|
|
24808
|
+
const compactTranscript = compactOutputActive();
|
|
23969
24809
|
const displayMessages = assistantDisplayMessages(message);
|
|
23970
24810
|
displayMessages.forEach((displayMessage) => {
|
|
23971
24811
|
let transcriptMessage = displayMessage;
|
|
@@ -23985,6 +24825,7 @@ function appendTranscriptMessage(message, { streaming = false, messageIndex = -1
|
|
|
23985
24825
|
live: !!liveRun && !result,
|
|
23986
24826
|
};
|
|
23987
24827
|
}
|
|
24828
|
+
if (compactTranscript && transcriptMessage.role !== "assistant") return;
|
|
23988
24829
|
if (transcriptMessage.role === "thinking" && !thinkingOutputVisible) return;
|
|
23989
24830
|
const created = appendMessage(transcriptMessage, {
|
|
23990
24831
|
streaming: false,
|
|
@@ -24261,11 +25102,84 @@ function rememberActionEntries(items) {
|
|
|
24261
25102
|
actionEntryAnimationPrimedTabs.add(activeTabId);
|
|
24262
25103
|
}
|
|
24263
25104
|
|
|
24264
|
-
function
|
|
25105
|
+
function compactThinkingSegments(message) {
|
|
25106
|
+
if (!thinkingOutputVisible) return [];
|
|
25107
|
+
if (message?.role === "thinking") {
|
|
25108
|
+
const thinking = visibleThinkingText(message.thinking || textFromContent(message.content));
|
|
25109
|
+
return thinking ? [thinking] : [];
|
|
25110
|
+
}
|
|
25111
|
+
if (message?.role !== "assistant") return [];
|
|
25112
|
+
return assistantDisplayMessages(message)
|
|
25113
|
+
.filter((displayMessage) => displayMessage.role === "thinking")
|
|
25114
|
+
.map((displayMessage) => visibleThinkingText(displayMessage.thinking || textFromContent(displayMessage.content)))
|
|
25115
|
+
.filter(Boolean);
|
|
25116
|
+
}
|
|
25117
|
+
|
|
25118
|
+
function compactAssistantHasFinalOutput(message) {
|
|
25119
|
+
return message?.role === "assistant" && assistantDisplayMessages(message).some((displayMessage) => displayMessage.role === "assistant");
|
|
25120
|
+
}
|
|
25121
|
+
|
|
25122
|
+
function compactStoredTranscriptItems() {
|
|
24265
25123
|
const items = [];
|
|
25124
|
+
let pendingThinking = null;
|
|
25125
|
+
|
|
25126
|
+
const flushThinking = () => {
|
|
25127
|
+
if (!pendingThinking?.segments.length) return;
|
|
25128
|
+
const segmentCount = pendingThinking.segments.length;
|
|
25129
|
+
const title = segmentCount === 1 ? "thinking" : `thinking (${segmentCount} segments)`;
|
|
25130
|
+
items.push({
|
|
25131
|
+
message: {
|
|
25132
|
+
role: "thinking",
|
|
25133
|
+
title,
|
|
25134
|
+
timestamp: pendingThinking.timestamp,
|
|
25135
|
+
content: pendingThinking.segments.join("\n\n"),
|
|
25136
|
+
thinking: pendingThinking.segments.join("\n\n"),
|
|
25137
|
+
compactThinkingAggregate: true,
|
|
25138
|
+
compactThinkingKey: `turn:${pendingThinking.firstIndex}`,
|
|
25139
|
+
},
|
|
25140
|
+
messageIndex: -1,
|
|
25141
|
+
transient: false,
|
|
25142
|
+
timestampMs: pendingThinking.timestampMs,
|
|
25143
|
+
order: pendingThinking.lastIndex - 0.5,
|
|
25144
|
+
transcriptKey: `compact-thinking:${pendingThinking.firstIndex}`,
|
|
25145
|
+
});
|
|
25146
|
+
pendingThinking = null;
|
|
25147
|
+
};
|
|
25148
|
+
|
|
25149
|
+
latestMessages.forEach((message, index) => {
|
|
25150
|
+
if (message?.role === "user") flushThinking();
|
|
25151
|
+
|
|
25152
|
+
const thinkingSegments = compactThinkingSegments(message);
|
|
25153
|
+
if (thinkingSegments.length) {
|
|
25154
|
+
if (!pendingThinking) {
|
|
25155
|
+
pendingThinking = {
|
|
25156
|
+
segments: [],
|
|
25157
|
+
firstIndex: index,
|
|
25158
|
+
lastIndex: index,
|
|
25159
|
+
timestamp: message.timestamp,
|
|
25160
|
+
timestampMs: messageTimestampMs(message),
|
|
25161
|
+
};
|
|
25162
|
+
}
|
|
25163
|
+
pendingThinking.segments.push(...thinkingSegments);
|
|
25164
|
+
pendingThinking.lastIndex = index;
|
|
25165
|
+
pendingThinking.timestamp = message.timestamp;
|
|
25166
|
+
pendingThinking.timestampMs = messageTimestampMs(message);
|
|
25167
|
+
}
|
|
25168
|
+
|
|
25169
|
+
if (message?.role === "thinking" || ["toolCall", "toolExecution", "toolResult", "assistantEvent"].includes(message?.role)) return;
|
|
25170
|
+
if (message?.role === "assistant" && !compactAssistantHasFinalOutput(message)) return;
|
|
25171
|
+
if (message?.role === "assistant") flushThinking();
|
|
25172
|
+
items.push({ message, messageIndex: index, transient: false, timestampMs: messageTimestampMs(message), order: index });
|
|
25173
|
+
});
|
|
25174
|
+
flushThinking();
|
|
25175
|
+
return items;
|
|
25176
|
+
}
|
|
25177
|
+
|
|
25178
|
+
function orderedTranscriptItems() {
|
|
25179
|
+
const items = compactOutputActive() ? compactStoredTranscriptItems() : [];
|
|
24266
25180
|
const assistantToolCallIds = buildAssistantToolCallIdSet(latestMessages);
|
|
24267
25181
|
const toolResults = buildToolResultMap(latestMessages);
|
|
24268
|
-
latestMessages.forEach((message, index) => {
|
|
25182
|
+
if (!compactOutputActive()) latestMessages.forEach((message, index) => {
|
|
24269
25183
|
const resultId = message?.role === "toolResult" ? toolResultCallId(message) : "";
|
|
24270
25184
|
if (resultId && assistantToolCallIds.has(resultId)) return;
|
|
24271
25185
|
items.push({ message, messageIndex: index, transient: false, timestampMs: messageTimestampMs(message), order: index });
|
|
@@ -24274,10 +25188,12 @@ function orderedTranscriptItems() {
|
|
|
24274
25188
|
items.push({ message, messageIndex: index, transient: true, timestampMs: messageTimestampMs(message), order: latestMessages.length + index });
|
|
24275
25189
|
});
|
|
24276
25190
|
let liveOrder = latestMessages.length + transientMessages.length;
|
|
24277
|
-
|
|
24278
|
-
|
|
24279
|
-
|
|
24280
|
-
|
|
25191
|
+
if (!compactOutputActive()) {
|
|
25192
|
+
for (const [toolCallId, run] of liveToolRuns.entries()) {
|
|
25193
|
+
if (assistantToolCallIds.has(toolCallId) || toolResults.has(toolCallId)) continue;
|
|
25194
|
+
const message = liveToolRunMessage(run);
|
|
25195
|
+
items.push({ message, messageIndex: -1, transient: true, timestampMs: messageTimestampMs(message), order: liveOrder++ });
|
|
25196
|
+
}
|
|
24281
25197
|
}
|
|
24282
25198
|
return items.sort((a, b) => a.timestampMs - b.timestampMs || a.order - b.order);
|
|
24283
25199
|
}
|
|
@@ -24291,10 +25207,11 @@ function orderedTranscriptItems() {
|
|
|
24291
25207
|
let renderedTranscriptState = { epoch: "", entries: [] };
|
|
24292
25208
|
|
|
24293
25209
|
function transcriptRenderEpoch() {
|
|
24294
|
-
return `${activeTabId || ""}|${thinkingOutputVisible ? 1 : 0}`;
|
|
25210
|
+
return `${activeTabId || ""}|${thinkingOutputVisible ? 1 : 0}|${compactOutputActive() ? "compact" : "normal"}`;
|
|
24295
25211
|
}
|
|
24296
25212
|
|
|
24297
25213
|
function transcriptItemKey(item) {
|
|
25214
|
+
if (item.transcriptKey) return item.transcriptKey;
|
|
24298
25215
|
if (!item.transient) return `m:${item.messageIndex}`;
|
|
24299
25216
|
if (item.messageIndex >= 0) return `t:${item.messageIndex}`;
|
|
24300
25217
|
return `live:${item.message?.toolCallId || `o${item.order}`}`;
|
|
@@ -24587,18 +25504,51 @@ function isChatNearBottom() {
|
|
|
24587
25504
|
}
|
|
24588
25505
|
|
|
24589
25506
|
function updateJumpToLatestButton() {
|
|
24590
|
-
elements.jumpToLatestButton.hidden = autoFollowChat
|
|
25507
|
+
elements.jumpToLatestButton.hidden = autoFollowChat;
|
|
25508
|
+
}
|
|
25509
|
+
|
|
25510
|
+
function noteChatTouchStart(event) {
|
|
25511
|
+
const clientY = Number(event?.touches?.[0]?.clientY);
|
|
25512
|
+
chatLastTouchClientY = Number.isFinite(clientY) ? clientY : null;
|
|
25513
|
+
}
|
|
25514
|
+
|
|
25515
|
+
function clearChatTouchIntent() {
|
|
25516
|
+
chatLastTouchClientY = null;
|
|
25517
|
+
}
|
|
25518
|
+
|
|
25519
|
+
function isChatScrollAwayIntent(event) {
|
|
25520
|
+
if (event?.type === "wheel") return event.deltaY < 0;
|
|
25521
|
+
if (event?.type === "touchmove") {
|
|
25522
|
+
const clientY = Number(event?.touches?.[0]?.clientY);
|
|
25523
|
+
const scrollAway = !Number.isFinite(clientY) || chatLastTouchClientY === null || clientY > chatLastTouchClientY;
|
|
25524
|
+
if (Number.isFinite(clientY)) chatLastTouchClientY = clientY;
|
|
25525
|
+
return scrollAway;
|
|
25526
|
+
}
|
|
25527
|
+
if (event?.type !== "keydown") return false;
|
|
25528
|
+
return event.key === "ArrowUp" || event.key === "Home" || event.key === "PageUp" || (event.key === " " && event.shiftKey);
|
|
24591
25529
|
}
|
|
24592
25530
|
|
|
24593
25531
|
function noteChatUserScrollIntent(event) {
|
|
24594
25532
|
if (event?.type === "wheel" && event.deltaY >= 0 && autoFollowChat) return;
|
|
24595
|
-
|
|
25533
|
+
const now = performance.now();
|
|
25534
|
+
chatUserScrollIntentUntil = now + CHAT_USER_SCROLL_INTENT_MS;
|
|
25535
|
+
if (!isChatScrollAwayIntent(event)) {
|
|
25536
|
+
chatUserScrollAwayIntentUntil = 0;
|
|
25537
|
+
return;
|
|
25538
|
+
}
|
|
25539
|
+
chatUserScrollAwayIntentUntil = now + CHAT_USER_SCROLL_INTENT_MS;
|
|
25540
|
+
autoFollowChat = false;
|
|
25541
|
+
updateJumpToLatestButton();
|
|
24596
25542
|
}
|
|
24597
25543
|
|
|
24598
25544
|
function isChatUserScrollIntentActive() {
|
|
24599
25545
|
return performance.now() <= chatUserScrollIntentUntil;
|
|
24600
25546
|
}
|
|
24601
25547
|
|
|
25548
|
+
function isChatUserScrollAwayIntentActive() {
|
|
25549
|
+
return performance.now() <= chatUserScrollAwayIntentUntil;
|
|
25550
|
+
}
|
|
25551
|
+
|
|
24602
25552
|
function setChatScrollTopInstant(top) {
|
|
24603
25553
|
const previousBehavior = elements.chat.style.scrollBehavior;
|
|
24604
25554
|
elements.chat.style.scrollBehavior = "auto";
|
|
@@ -24633,17 +25583,24 @@ function scheduleChatFollowScroll({ settle = true } = {}) {
|
|
|
24633
25583
|
}, CHAT_FOLLOW_SETTLE_DELAY_MS);
|
|
24634
25584
|
}
|
|
24635
25585
|
|
|
25586
|
+
function resumeChatAutoFollow() {
|
|
25587
|
+
chatUserScrollAwayIntentUntil = 0;
|
|
25588
|
+
autoFollowChat = true;
|
|
25589
|
+
}
|
|
25590
|
+
|
|
24636
25591
|
function scrollChatToBottom({ force = false } = {}) {
|
|
24637
25592
|
if (deferChatFollowScrollDuringPointerActivation({ force })) return;
|
|
24638
25593
|
if (deferChatFollowScrollDuringInteractiveDropdown({ force })) return;
|
|
24639
|
-
if (force)
|
|
25594
|
+
if (force) resumeChatAutoFollow();
|
|
24640
25595
|
scheduleChatFollowScroll();
|
|
24641
25596
|
}
|
|
24642
25597
|
|
|
24643
25598
|
function syncAutoFollowFromChatScroll() {
|
|
24644
25599
|
const nearBottom = isChatNearBottom();
|
|
24645
25600
|
const recentProgrammaticScroll = performance.now() - lastChatProgrammaticScrollAt <= CHAT_PROGRAMMATIC_SCROLL_GRACE_MS;
|
|
24646
|
-
if (
|
|
25601
|
+
if (isChatUserScrollAwayIntentActive()) {
|
|
25602
|
+
autoFollowChat = false;
|
|
25603
|
+
} else if (nearBottom || isChatUserScrollIntentActive() || !autoFollowChat || !recentProgrammaticScroll) {
|
|
24647
25604
|
autoFollowChat = nearBottom;
|
|
24648
25605
|
} else {
|
|
24649
25606
|
scheduleChatFollowScroll();
|
|
@@ -24659,7 +25616,6 @@ function jumpToLatest() {
|
|
|
24659
25616
|
|
|
24660
25617
|
function syncMobileChatToBottomForInput() {
|
|
24661
25618
|
if (!isMobileView()) return;
|
|
24662
|
-
autoFollowChat = true;
|
|
24663
25619
|
scrollChatToBottom({ force: true });
|
|
24664
25620
|
requestAnimationFrame(() => scrollChatToBottom({ force: true }));
|
|
24665
25621
|
setTimeout(() => scrollChatToBottom({ force: true }), 140);
|
|
@@ -25761,6 +26717,93 @@ function httpIdleTimeoutOptions(settings) {
|
|
|
25761
26717
|
return [{ value: current, label }, ...SETTINGS_HTTP_IDLE_TIMEOUT_OPTIONS];
|
|
25762
26718
|
}
|
|
25763
26719
|
|
|
26720
|
+
function normalizeWebuiOutputModeMetadata(metadata = {}) {
|
|
26721
|
+
const modes = new Set(["normal", "compact-v1"]);
|
|
26722
|
+
const sources = new Set(["cli", "env", "persisted", "normal"]);
|
|
26723
|
+
return {
|
|
26724
|
+
persistedDefault: modes.has(metadata.persistedDefault) ? metadata.persistedDefault : "normal",
|
|
26725
|
+
effectiveDefault: modes.has(metadata.effectiveDefault) ? metadata.effectiveDefault : "normal",
|
|
26726
|
+
source: sources.has(metadata.source) ? metadata.source : "normal",
|
|
26727
|
+
overridden: metadata.overridden === true && (metadata.source === "cli" || metadata.source === "env"),
|
|
26728
|
+
};
|
|
26729
|
+
}
|
|
26730
|
+
|
|
26731
|
+
function webuiOutputModeMetadataText(metadata) {
|
|
26732
|
+
const sourceLabel = { cli: "CLI", env: "environment", persisted: "persisted setting", normal: "normal default" }[metadata.source] || "normal default";
|
|
26733
|
+
const overridden = metadata.overridden ? ` ${sourceLabel} overrides the persisted setting.` : "";
|
|
26734
|
+
return `Persisted default: ${metadata.persistedDefault}. Effective mode: ${metadata.effectiveDefault}. Source: ${sourceLabel}.${overridden}`;
|
|
26735
|
+
}
|
|
26736
|
+
|
|
26737
|
+
let sidebarOutputModeMetadata = normalizeWebuiOutputModeMetadata();
|
|
26738
|
+
let sidebarOutputModeDiagnostic = "";
|
|
26739
|
+
let sidebarOutputModeNotice = "";
|
|
26740
|
+
let sidebarOutputModeLoaded = false;
|
|
26741
|
+
let sidebarOutputModeBusy = false;
|
|
26742
|
+
|
|
26743
|
+
function updateSidebarOutputModeApplyState() {
|
|
26744
|
+
if (!elements.fastOutputModeSelect || !elements.setFastOutputModeButton) return;
|
|
26745
|
+
const unavailable = !sidebarOutputModeLoaded || !!sidebarOutputModeDiagnostic;
|
|
26746
|
+
elements.fastOutputModeSelect.disabled = unavailable || sidebarOutputModeBusy;
|
|
26747
|
+
elements.setFastOutputModeButton.disabled = unavailable
|
|
26748
|
+
|| sidebarOutputModeBusy
|
|
26749
|
+
|| elements.fastOutputModeSelect.value === sidebarOutputModeMetadata.persistedDefault;
|
|
26750
|
+
elements.setFastOutputModeButton.textContent = sidebarOutputModeBusy ? "Applying…" : "Apply";
|
|
26751
|
+
}
|
|
26752
|
+
|
|
26753
|
+
function renderSidebarOutputModeControl({ syncSelection = true } = {}) {
|
|
26754
|
+
if (!elements.fastOutputModeSelect || !elements.fastOutputModeStatus) return;
|
|
26755
|
+
if (syncSelection) elements.fastOutputModeSelect.value = sidebarOutputModeMetadata.persistedDefault;
|
|
26756
|
+
elements.fastOutputModeStatus.textContent = sidebarOutputModeDiagnostic
|
|
26757
|
+
|| sidebarOutputModeNotice
|
|
26758
|
+
|| webuiOutputModeMetadataText(sidebarOutputModeMetadata);
|
|
26759
|
+
elements.fastOutputModeStatus.classList.toggle("warning", !!sidebarOutputModeDiagnostic || !!sidebarOutputModeNotice);
|
|
26760
|
+
updateSidebarOutputModeApplyState();
|
|
26761
|
+
}
|
|
26762
|
+
|
|
26763
|
+
async function refreshSidebarOutputMode() {
|
|
26764
|
+
if (!elements.fastOutputModeSelect) return sidebarOutputModeMetadata;
|
|
26765
|
+
sidebarOutputModeLoaded = false;
|
|
26766
|
+
sidebarOutputModeDiagnostic = "";
|
|
26767
|
+
sidebarOutputModeNotice = "";
|
|
26768
|
+
renderSidebarOutputModeControl();
|
|
26769
|
+
try {
|
|
26770
|
+
const response = await api("/api/webui-output-mode", { scoped: false });
|
|
26771
|
+
sidebarOutputModeMetadata = normalizeWebuiOutputModeMetadata(response.data);
|
|
26772
|
+
} catch (error) {
|
|
26773
|
+
sidebarOutputModeMetadata = normalizeWebuiOutputModeMetadata();
|
|
26774
|
+
sidebarOutputModeDiagnostic = `Fast-mode control unavailable: ${error.message || String(error)}. Using the normal default.`;
|
|
26775
|
+
} finally {
|
|
26776
|
+
sidebarOutputModeLoaded = true;
|
|
26777
|
+
renderSidebarOutputModeControl();
|
|
26778
|
+
}
|
|
26779
|
+
return sidebarOutputModeMetadata;
|
|
26780
|
+
}
|
|
26781
|
+
|
|
26782
|
+
async function applySidebarOutputMode() {
|
|
26783
|
+
if (!elements.fastOutputModeSelect || sidebarOutputModeBusy) return;
|
|
26784
|
+
const outputModeDefault = elements.fastOutputModeSelect.value === "compact-v1" ? "compact-v1" : "normal";
|
|
26785
|
+
if (outputModeDefault === sidebarOutputModeMetadata.persistedDefault) return;
|
|
26786
|
+
sidebarOutputModeBusy = true;
|
|
26787
|
+
updateSidebarOutputModeApplyState();
|
|
26788
|
+
try {
|
|
26789
|
+
await api("/api/webui-output-mode", {
|
|
26790
|
+
method: "PUT",
|
|
26791
|
+
body: { outputModeDefault },
|
|
26792
|
+
scoped: false,
|
|
26793
|
+
});
|
|
26794
|
+
await refreshSidebarOutputMode();
|
|
26795
|
+
addEvent(outputModeDefault === "compact-v1" ? "Fast output mode enabled for auto-negotiated Web UI connections." : "Normal output processing restored for auto-negotiated Web UI connections.", "info");
|
|
26796
|
+
} catch (error) {
|
|
26797
|
+
sidebarOutputModeDiagnostic = "";
|
|
26798
|
+
sidebarOutputModeNotice = `Failed to update fast mode: ${error.message || String(error)}. You can retry.`;
|
|
26799
|
+
sidebarOutputModeLoaded = true;
|
|
26800
|
+
addEvent(sidebarOutputModeNotice, "error");
|
|
26801
|
+
} finally {
|
|
26802
|
+
sidebarOutputModeBusy = false;
|
|
26803
|
+
renderSidebarOutputModeControl();
|
|
26804
|
+
}
|
|
26805
|
+
}
|
|
26806
|
+
|
|
25764
26807
|
function collectNativeSettingsPayload(controls) {
|
|
25765
26808
|
return {
|
|
25766
26809
|
transport: controls.transport.select.value,
|
|
@@ -25807,6 +26850,15 @@ async function openNativeSettingsDialog() {
|
|
|
25807
26850
|
return;
|
|
25808
26851
|
}
|
|
25809
26852
|
|
|
26853
|
+
let outputModeMetadata = normalizeWebuiOutputModeMetadata();
|
|
26854
|
+
let outputModeApiDiagnostic = "";
|
|
26855
|
+
try {
|
|
26856
|
+
const response = await api("/api/webui-output-mode", { scoped: false });
|
|
26857
|
+
outputModeMetadata = normalizeWebuiOutputModeMetadata(response.data);
|
|
26858
|
+
} catch (error) {
|
|
26859
|
+
outputModeApiDiagnostic = `Output-mode API unavailable: ${error.message || String(error)}. Showing the normal default; other settings can still be applied.`;
|
|
26860
|
+
}
|
|
26861
|
+
|
|
25810
26862
|
const state = currentState || {};
|
|
25811
26863
|
const settings = settingsData.settings || {};
|
|
25812
26864
|
applyNativeSettingsForBrowser(settings);
|
|
@@ -25837,6 +26889,7 @@ async function openNativeSettingsDialog() {
|
|
|
25837
26889
|
autocompleteMax: nativeSettingSelect("Autocomplete max items", settings.autocompleteMaxVisible ?? autocompleteMaxVisible, SETTINGS_AUTOCOMPLETE_OPTIONS, "Maximum visible slash/path suggestions.", { label: "browser", tone: "browser" }),
|
|
25838
26890
|
doubleEscape: nativeSettingSelect("Double-escape action", settings.doubleEscapeAction || doubleEscapeAction, SETTINGS_DOUBLE_ESCAPE_OPTIONS, "Action when pressing Escape twice with an empty composer.", { label: "browser", tone: "browser" }),
|
|
25839
26891
|
treeFilter: nativeSettingSelect("Tree filter mode", settings.treeFilterMode || treeFilterMode, SETTINGS_TREE_FILTER_OPTIONS, "Default filter when opening /tree.", { label: "browser", tone: "browser" }),
|
|
26892
|
+
outputMode: nativeSettingSelect("Output processing", outputModeMetadata.persistedDefault, SETTINGS_OUTPUT_MODE_OPTIONS, "Server default for new and auto-negotiated Web UI connections. Fast mode preserves Markdown final output, keeps live thinking expanded, groups stored thinking in one collapsed disclosure per turn, shows only the current tool status transiently, and does not change model inference or token generation. Changes use server barriers without restarting Pi.", { label: "server", tone: "startup" }),
|
|
25840
26893
|
autoResizeImages: nativeSettingToggle("Auto-resize images", settings.autoResizeImages !== false, "Resize large images to 2000x2000 max for better model compatibility.", { label: "reload", tone: "reload" }),
|
|
25841
26894
|
blockImages: nativeSettingToggle("Block images", settings.blockImages === true, "Prevent images from being sent to LLM providers.", { label: "reload", tone: "reload" }),
|
|
25842
26895
|
showImages: nativeSettingToggle("Show terminal images", settings.showImages !== false, "Native TUI inline image rendering preference.", { label: "TUI", tone: "tui" }),
|
|
@@ -25851,6 +26904,14 @@ async function openNativeSettingsDialog() {
|
|
|
25851
26904
|
clearOnShrink: nativeSettingToggle("Clear on shrink", settings.clearOnShrink === true, "Native TUI row clearing when content shrinks; may flicker.", { label: "TUI", tone: "tui" }),
|
|
25852
26905
|
terminalProgress: nativeSettingToggle("Terminal progress", settings.showTerminalProgress === true, "Native TUI OSC 9;4 terminal progress indicators.", { label: "TUI", tone: "tui" }),
|
|
25853
26906
|
};
|
|
26907
|
+
const outputModeStatus = make("span", "native-settings-hint");
|
|
26908
|
+
controls.outputMode.field.append(outputModeStatus);
|
|
26909
|
+
const renderOutputModeMetadata = () => {
|
|
26910
|
+
controls.outputMode.select.value = outputModeMetadata.persistedDefault;
|
|
26911
|
+
controls.outputMode.select.disabled = !!outputModeApiDiagnostic;
|
|
26912
|
+
outputModeStatus.textContent = outputModeApiDiagnostic || webuiOutputModeMetadataText(outputModeMetadata);
|
|
26913
|
+
};
|
|
26914
|
+
renderOutputModeMetadata();
|
|
25854
26915
|
|
|
25855
26916
|
const remoteAccessSection = make("details", "native-settings-section native-settings-remote-access");
|
|
25856
26917
|
remoteAccessSection.open = false;
|
|
@@ -25892,7 +26953,7 @@ async function openNativeSettingsDialog() {
|
|
|
25892
26953
|
nativeSettingsNote("Scopes", "Each field says whether it affects this tab, this browser, global Pi settings, or the native TUI."),
|
|
25893
26954
|
remoteAccessSection,
|
|
25894
26955
|
nativeSettingsSection("Runtime", "Model behavior and request transport.", [controls.thinking, controls.autoCompact, controls.steering, controls.followUp, controls.transport, controls.httpIdleTimeout], { open: true }),
|
|
25895
|
-
nativeSettingsSection("Browser workflow", "Local Web UI behavior
|
|
26956
|
+
nativeSettingsSection("Browser workflow", "Local Web UI behavior, shared composer defaults, and server output processing.", [controls.busyBehavior, controls.density, controls.thinkingOutput, controls.doneNotifications, controls.autocompleteMax, controls.doubleEscape, controls.treeFilter, controls.outputMode], { open: true }),
|
|
25896
26957
|
nativeSettingsSection("Images", "Provider image policy and native terminal image display.", [controls.autoResizeImages, controls.blockImages, controls.showImages, controls.imageWidth], { open: true }),
|
|
25897
26958
|
nativeSettingsSection("Startup & safety", "Command registration, warnings, update/startup behavior.", [controls.skillCommands, controls.anthropicWarning, controls.collapseChangelog, controls.quietStartup, controls.installTelemetry], { open: false }),
|
|
25898
26959
|
nativeSettingsSection("Native TUI advanced", "Saved for the terminal UI; mostly informational in the browser.", [controls.hardwareCursor, controls.editorPadding, controls.clearOnShrink, controls.terminalProgress], { open: false })
|
|
@@ -25904,6 +26965,7 @@ async function openNativeSettingsDialog() {
|
|
|
25904
26965
|
addNativeCommandAction("Cancel", () => closeNativeCommandDialog());
|
|
25905
26966
|
|
|
25906
26967
|
const initialPayload = collectNativeSettingsPayload(controls);
|
|
26968
|
+
const initialOutputModeDefault = controls.outputMode.select.value;
|
|
25907
26969
|
const initialRuntime = JSON.stringify({
|
|
25908
26970
|
thinking: state.thinkingLevel || "off",
|
|
25909
26971
|
autoCompact: state.autoCompactionEnabled !== false,
|
|
@@ -25929,7 +26991,9 @@ async function openNativeSettingsDialog() {
|
|
|
25929
26991
|
});
|
|
25930
26992
|
let applyButton;
|
|
25931
26993
|
const updateDirtyState = () => {
|
|
25932
|
-
nativeSettingsDirty = currentRuntime() !== initialRuntime
|
|
26994
|
+
nativeSettingsDirty = currentRuntime() !== initialRuntime
|
|
26995
|
+
|| JSON.stringify(collectNativeSettingsPayload(controls)) !== JSON.stringify(initialPayload)
|
|
26996
|
+
|| controls.outputMode.select.value !== initialOutputModeDefault;
|
|
25933
26997
|
if (applyButton) {
|
|
25934
26998
|
applyButton.disabled = !nativeSettingsDirty;
|
|
25935
26999
|
applyButton.textContent = reloadNeeded() ? "Apply and reload" : "Apply";
|
|
@@ -25945,6 +27009,7 @@ async function openNativeSettingsDialog() {
|
|
|
25945
27009
|
try {
|
|
25946
27010
|
const requests = [];
|
|
25947
27011
|
const thinkingLevelChanged = controls.thinking.select.value !== (state.thinkingLevel || "off");
|
|
27012
|
+
const outputModeChanged = controls.outputMode.select.value !== initialOutputModeDefault;
|
|
25948
27013
|
if (thinkingLevelChanged) requests.push(nativeCommandApi("/api/thinking", { method: "POST", body: { level: controls.thinking.select.value } }));
|
|
25949
27014
|
if (controls.steering.select.value !== (state.steeringMode || "one-at-a-time")) requests.push(nativeCommandApi("/api/steering-mode", { method: "POST", body: { mode: controls.steering.select.value } }));
|
|
25950
27015
|
if (controls.followUp.select.value !== (state.followUpMode || "one-at-a-time")) requests.push(nativeCommandApi("/api/follow-up-mode", { method: "POST", body: { mode: controls.followUp.select.value } }));
|
|
@@ -25958,8 +27023,32 @@ async function openNativeSettingsDialog() {
|
|
|
25958
27023
|
const response = await nativeCommandApi("/api/settings", { method: "POST", body: { settings: payload, reload } });
|
|
25959
27024
|
applyResponseTab(response);
|
|
25960
27025
|
applyNativeSettingsForBrowser(response.data?.settings || payload);
|
|
27026
|
+
if (outputModeChanged) {
|
|
27027
|
+
try {
|
|
27028
|
+
await api("/api/webui-output-mode", {
|
|
27029
|
+
method: "PUT",
|
|
27030
|
+
body: { outputModeDefault: controls.outputMode.select.value },
|
|
27031
|
+
scoped: false,
|
|
27032
|
+
});
|
|
27033
|
+
const refreshedOutputMode = await api("/api/webui-output-mode", { scoped: false });
|
|
27034
|
+
outputModeMetadata = normalizeWebuiOutputModeMetadata(refreshedOutputMode.data);
|
|
27035
|
+
outputModeApiDiagnostic = "";
|
|
27036
|
+
sidebarOutputModeMetadata = outputModeMetadata;
|
|
27037
|
+
sidebarOutputModeDiagnostic = "";
|
|
27038
|
+
sidebarOutputModeNotice = "";
|
|
27039
|
+
sidebarOutputModeLoaded = true;
|
|
27040
|
+
renderSidebarOutputModeControl();
|
|
27041
|
+
} catch (error) {
|
|
27042
|
+
outputModeApiDiagnostic = `Output-mode API unavailable after saving: ${error.message || String(error)}. Showing the normal default; other settings can still be applied.`;
|
|
27043
|
+
outputModeMetadata = normalizeWebuiOutputModeMetadata();
|
|
27044
|
+
renderOutputModeMetadata();
|
|
27045
|
+
throw error;
|
|
27046
|
+
}
|
|
27047
|
+
renderOutputModeMetadata();
|
|
27048
|
+
}
|
|
25961
27049
|
if (thinkingLevelChanged) requestGitFooterWebuiPayload(activeTabContext(), { force: true });
|
|
25962
|
-
|
|
27050
|
+
const outputModeMessage = outputModeChanged ? ` ${webuiOutputModeMetadataText(outputModeMetadata)}` : "";
|
|
27051
|
+
addTransientMessage({ role: "native", title: "/settings", content: `${nativeSettingsChangedMessage(response, reload)}${outputModeMessage}`, level: response.data?.reloadRecommended?.length && !response.data?.reloaded ? "warn" : "info" });
|
|
25963
27052
|
nativeSettingsDirty = false;
|
|
25964
27053
|
closeNativeCommandDialog({ force: true });
|
|
25965
27054
|
await refreshAll();
|
|
@@ -26884,6 +27973,184 @@ function cancelStreamBubbleHide() {
|
|
|
26884
27973
|
streamBubbleHideTimer = null;
|
|
26885
27974
|
}
|
|
26886
27975
|
|
|
27976
|
+
function compactOutputActive() {
|
|
27977
|
+
return outputModeAcknowledged && activeOutputMode === "compact-v1";
|
|
27978
|
+
}
|
|
27979
|
+
|
|
27980
|
+
function outputModeAcknowledgement(event) {
|
|
27981
|
+
const outputMode = event?.outputMode;
|
|
27982
|
+
if (outputMode?.protocolVersion !== 1 || !["normal", "compact-v1"].includes(outputMode.activeMode)) return null;
|
|
27983
|
+
return outputMode;
|
|
27984
|
+
}
|
|
27985
|
+
|
|
27986
|
+
function removeCompactLiveBubble(bubble) {
|
|
27987
|
+
bubble?.remove();
|
|
27988
|
+
}
|
|
27989
|
+
|
|
27990
|
+
function clearCompactToolShells() {
|
|
27991
|
+
for (const shell of compactToolShells.values()) removeCompactLiveBubble(shell?.bubble);
|
|
27992
|
+
compactToolShells.clear();
|
|
27993
|
+
}
|
|
27994
|
+
|
|
27995
|
+
function resetCompactLiveOutput({ remove = true } = {}) {
|
|
27996
|
+
compactLiveScheduler.cancel();
|
|
27997
|
+
compactLiveState = createFastOutputLiveState();
|
|
27998
|
+
clearCompactThinkingDisclosureState("live");
|
|
27999
|
+
if (remove) {
|
|
28000
|
+
removeCompactLiveBubble(compactTextBubble);
|
|
28001
|
+
removeCompactLiveBubble(compactThinkingBubble);
|
|
28002
|
+
clearCompactToolShells();
|
|
28003
|
+
} else {
|
|
28004
|
+
compactToolShells.clear();
|
|
28005
|
+
}
|
|
28006
|
+
compactTextBubble = null;
|
|
28007
|
+
compactTextNode = null;
|
|
28008
|
+
compactThinkingBubble = null;
|
|
28009
|
+
compactThinkingNode = null;
|
|
28010
|
+
}
|
|
28011
|
+
|
|
28012
|
+
function ensureCompactTextBubble() {
|
|
28013
|
+
if (compactTextBubble?.parentElement === elements.chat && compactTextNode) return;
|
|
28014
|
+
const created = appendMessage({ role: "assistant", title: "final output", timestamp: Date.now(), content: "" }, { streaming: true });
|
|
28015
|
+
compactTextBubble = created.bubble;
|
|
28016
|
+
compactTextBubble.classList.add("compact-live-output");
|
|
28017
|
+
compactTextNode = make("div", "compact-live-text");
|
|
28018
|
+
created.body.append(compactTextNode);
|
|
28019
|
+
renderRunIndicator({ scroll: false });
|
|
28020
|
+
}
|
|
28021
|
+
|
|
28022
|
+
function ensureCompactThinkingBubble() {
|
|
28023
|
+
if (!thinkingOutputVisible) return false;
|
|
28024
|
+
if (compactThinkingBubble?.parentElement === elements.chat && compactThinkingNode) return true;
|
|
28025
|
+
const created = appendMessage({ role: "thinking", title: "thinking (live)", timestamp: Date.now(), content: "", compactThinkingAggregate: true, compactThinkingKey: "live", compactThinkingDefaultExpanded: true }, { streaming: true });
|
|
28026
|
+
compactThinkingBubble = created.bubble;
|
|
28027
|
+
compactThinkingBubble.classList.add("compact-live-output");
|
|
28028
|
+
compactThinkingNode = make("div", "markdown-body thinking-text compact-live-thinking");
|
|
28029
|
+
created.body.append(compactThinkingNode);
|
|
28030
|
+
renderRunIndicator({ scroll: false });
|
|
28031
|
+
return true;
|
|
28032
|
+
}
|
|
28033
|
+
|
|
28034
|
+
function compactToolShellId(event) {
|
|
28035
|
+
const direct = String(event?.toolCallId || event?.id || "").trim();
|
|
28036
|
+
return direct || `compact-tool-${compactToolShells.size + 1}`;
|
|
28037
|
+
}
|
|
28038
|
+
|
|
28039
|
+
function renderCompactToolShell(event, { complete = false } = {}) {
|
|
28040
|
+
const id = compactToolShellId(event);
|
|
28041
|
+
let shell = compactToolShells.get(id);
|
|
28042
|
+
if (!shell) {
|
|
28043
|
+
clearCompactToolShells();
|
|
28044
|
+
const bubble = make("article", "message toolExecution compact-tool-shell streaming");
|
|
28045
|
+
const header = make("div", "message-header");
|
|
28046
|
+
const role = make("span", "message-role");
|
|
28047
|
+
const timestamp = make("span", "muted", formatDate(Date.now()));
|
|
28048
|
+
const body = make("div", "message-body");
|
|
28049
|
+
const status = make("div", "compact-tool-status");
|
|
28050
|
+
header.append(role, timestamp);
|
|
28051
|
+
body.append(status);
|
|
28052
|
+
bubble.append(header, body);
|
|
28053
|
+
bubble.dataset.toolCallId = id;
|
|
28054
|
+
appendChatMessageBubble(bubble);
|
|
28055
|
+
shell = { bubble, role, status };
|
|
28056
|
+
compactToolShells.set(id, shell);
|
|
28057
|
+
}
|
|
28058
|
+
const name = String(event?.toolName || event?.name || "tool");
|
|
28059
|
+
shell.role.textContent = `tool: ${name}`;
|
|
28060
|
+
shell.status.textContent = complete
|
|
28061
|
+
? event?.isError ? "failed" : "done"
|
|
28062
|
+
: "running";
|
|
28063
|
+
shell.bubble.classList.toggle("tool-error", !!event?.isError);
|
|
28064
|
+
shell.bubble.classList.toggle("tool-running", !complete);
|
|
28065
|
+
shell.bubble.classList.toggle("tool-success", complete && !event?.isError);
|
|
28066
|
+
return shell;
|
|
28067
|
+
}
|
|
28068
|
+
|
|
28069
|
+
function flushCompactLiveOutput() {
|
|
28070
|
+
if (compactLiveState.text) {
|
|
28071
|
+
ensureCompactTextBubble();
|
|
28072
|
+
if (compactTextNode?.textContent !== compactLiveState.text) compactTextNode.textContent = compactLiveState.text;
|
|
28073
|
+
}
|
|
28074
|
+
if (compactLiveState.thinking && ensureCompactThinkingBubble()) {
|
|
28075
|
+
if (compactThinkingNode?._rawThinkingText !== compactLiveState.thinking) renderThinkingMarkdown(compactThinkingNode, compactLiveState.thinking);
|
|
28076
|
+
}
|
|
28077
|
+
scheduleChatFollowScroll();
|
|
28078
|
+
}
|
|
28079
|
+
|
|
28080
|
+
function finishCompactLiveOutput(tabContext = activeTabContext()) {
|
|
28081
|
+
compactLiveScheduler.flushNow();
|
|
28082
|
+
scheduleRefreshMessages(0, tabContext);
|
|
28083
|
+
}
|
|
28084
|
+
|
|
28085
|
+
function handleCompactMessageUpdate(event) {
|
|
28086
|
+
const reduced = reduceFastOutputLiveEvent(compactLiveState, event);
|
|
28087
|
+
if (!shouldConsumeFastOutputLiveEvent(reduced)) return false;
|
|
28088
|
+
if (!reduced.changed) return true;
|
|
28089
|
+
compactLiveState = reduced.state;
|
|
28090
|
+
clearCompactToolShells();
|
|
28091
|
+
if (reduced.kind.startsWith("thinking")) setRunIndicatorActivity("Thinking…", { scroll: false });
|
|
28092
|
+
else if (reduced.kind.startsWith("toolcall")) setRunIndicatorActivity("Building tool call…", { scroll: false });
|
|
28093
|
+
else setRunIndicatorActivity("Writing response…", { scroll: false });
|
|
28094
|
+
compactLiveScheduler.request();
|
|
28095
|
+
return true;
|
|
28096
|
+
}
|
|
28097
|
+
|
|
28098
|
+
function acceptOutputModeAcknowledgement(event) {
|
|
28099
|
+
const acknowledgement = outputModeAcknowledgement(event);
|
|
28100
|
+
if (acknowledgement) {
|
|
28101
|
+
activeOutputMode = acknowledgement.activeMode;
|
|
28102
|
+
outputModeAcknowledged = true;
|
|
28103
|
+
if (!currentState?.isStreaming) renderAllMessages({ preserveScroll: true, forceRebuild: true });
|
|
28104
|
+
return true;
|
|
28105
|
+
}
|
|
28106
|
+
activeOutputMode = "normal";
|
|
28107
|
+
outputModeAcknowledged = false;
|
|
28108
|
+
if (!eventSourceOutputModeFallbackAttempted) {
|
|
28109
|
+
eventSourceOutputModeFallbackAttempted = true;
|
|
28110
|
+
queueMicrotask(() => connectEvents(activeTabContext(), { requestedMode: "normal", fallbackAttempted: true }));
|
|
28111
|
+
}
|
|
28112
|
+
return false;
|
|
28113
|
+
}
|
|
28114
|
+
|
|
28115
|
+
function transitionNormalLiveOutputToCompact() {
|
|
28116
|
+
compactLiveState = seedFastOutputLiveState({ text: streamRawText, thinking: streamThinkingRawText });
|
|
28117
|
+
setStreamRawText("");
|
|
28118
|
+
setStreamThinkingRawText("");
|
|
28119
|
+
removeStreamBubble();
|
|
28120
|
+
removeStreamingThinkingBubble();
|
|
28121
|
+
flushCompactLiveOutput();
|
|
28122
|
+
}
|
|
28123
|
+
|
|
28124
|
+
function transitionCompactLiveOutputToNormal(tabContext = activeTabContext()) {
|
|
28125
|
+
finishCompactLiveOutput(tabContext);
|
|
28126
|
+
const live = fastOutputLiveTextAndThinking(compactLiveState);
|
|
28127
|
+
resetCompactLiveOutput();
|
|
28128
|
+
setStreamRawText(live.text);
|
|
28129
|
+
setStreamThinkingRawText(live.thinking);
|
|
28130
|
+
if (live.thinking) setStreamingThinkingText(live.thinking);
|
|
28131
|
+
if (live.text) renderStreamingAssistantText();
|
|
28132
|
+
}
|
|
28133
|
+
|
|
28134
|
+
function applyOutputModeControl(event, tabContext = activeTabContext()) {
|
|
28135
|
+
if (event?.protocolVersion !== 1 || !["normal", "compact-v1"].includes(event.activeMode)) return false;
|
|
28136
|
+
const previousMode = activeOutputMode;
|
|
28137
|
+
if (previousMode === "normal" && event.activeMode === "compact-v1") {
|
|
28138
|
+
transitionNormalLiveOutputToCompact();
|
|
28139
|
+
} else if (previousMode === "compact-v1" && event.activeMode === "normal") {
|
|
28140
|
+
transitionCompactLiveOutputToNormal(tabContext);
|
|
28141
|
+
} else if (previousMode === "compact-v1") {
|
|
28142
|
+
finishCompactLiveOutput(tabContext);
|
|
28143
|
+
resetCompactLiveOutput();
|
|
28144
|
+
} else if (event.activeMode === "normal") {
|
|
28145
|
+
resetCompactLiveOutput();
|
|
28146
|
+
}
|
|
28147
|
+
activeOutputMode = event.activeMode;
|
|
28148
|
+
outputModeAcknowledged = true;
|
|
28149
|
+
if (!currentState?.isStreaming) renderAllMessages({ preserveScroll: true, forceRebuild: true });
|
|
28150
|
+
addEvent(`live output mode changed to ${event.activeMode}`, "info");
|
|
28151
|
+
return true;
|
|
28152
|
+
}
|
|
28153
|
+
|
|
26887
28154
|
function cancelStreamingAssistantTextRender() {
|
|
26888
28155
|
clearTimeout(streamTextRenderTimer);
|
|
26889
28156
|
streamTextRenderTimer = null;
|
|
@@ -27079,6 +28346,7 @@ function showStreamingThinking(initialText = "") {
|
|
|
27079
28346
|
}
|
|
27080
28347
|
|
|
27081
28348
|
function resetStreamBubble() {
|
|
28349
|
+
resetCompactLiveOutput();
|
|
27082
28350
|
cancelStreamingAssistantTextRender();
|
|
27083
28351
|
cancelStreamBubbleHide();
|
|
27084
28352
|
streamBubble = null;
|
|
@@ -27096,10 +28364,31 @@ function resetStreamBubble() {
|
|
|
27096
28364
|
streamProviderErrorText = "";
|
|
27097
28365
|
}
|
|
27098
28366
|
|
|
28367
|
+
function compactLiveStreamRenderActive() {
|
|
28368
|
+
const messageOutputActive = streamMessageActive && Boolean(
|
|
28369
|
+
compactTextBubble
|
|
28370
|
+
|| compactThinkingBubble
|
|
28371
|
+
|| compactLiveState.text
|
|
28372
|
+
|| compactLiveState.thinking
|
|
28373
|
+
|| compactLiveState.toolCall?.arguments,
|
|
28374
|
+
);
|
|
28375
|
+
return compactOutputActive() && currentState?.isStreaming === true && Boolean(compactToolShells.size || messageOutputActive);
|
|
28376
|
+
}
|
|
28377
|
+
|
|
27099
28378
|
function liveStreamRenderActive() {
|
|
27100
28379
|
return streamMessageActive && currentState?.isStreaming === true && Boolean(streamBubble || streamThinkingBubble || streamToolCallBubble || streamRawText || streamToolCallRawArguments);
|
|
27101
28380
|
}
|
|
27102
28381
|
|
|
28382
|
+
function restoreCompactLiveOutputAfterChatRebuild() {
|
|
28383
|
+
compactTextBubble = null;
|
|
28384
|
+
compactTextNode = null;
|
|
28385
|
+
compactThinkingBubble = null;
|
|
28386
|
+
compactThinkingNode = null;
|
|
28387
|
+
if (streamMessageActive) flushCompactLiveOutput();
|
|
28388
|
+
for (const shell of compactToolShells.values()) appendChatMessageBubble(shell.bubble);
|
|
28389
|
+
renderRunIndicator({ scroll: false });
|
|
28390
|
+
}
|
|
28391
|
+
|
|
27103
28392
|
/**
|
|
27104
28393
|
* The chat DOM was rebuilt while an assistant message is still streaming:
|
|
27105
28394
|
* drop references to the detached nodes but keep stream text state, then
|
|
@@ -27282,6 +28571,7 @@ function assistantStreamErrorMessage(event, update = event?.assistantMessageEven
|
|
|
27282
28571
|
}
|
|
27283
28572
|
|
|
27284
28573
|
function handleMessageUpdate(event) {
|
|
28574
|
+
if (compactOutputActive() && handleCompactMessageUpdate(event)) return;
|
|
27285
28575
|
const update = event.assistantMessageEvent || {};
|
|
27286
28576
|
if (update.type === "thinking_start") {
|
|
27287
28577
|
setRunIndicatorActivity("Thinking…", { scroll: false });
|
|
@@ -27612,10 +28902,12 @@ async function refreshMessages(tabContext = activeTabContext()) {
|
|
|
27612
28902
|
latestMessages = nextMessages;
|
|
27613
28903
|
latestMessagesSessionKey = sessionKey;
|
|
27614
28904
|
cacheMessagesForTab(tabContext.tabId, latestMessages, latestMessagesSessionKey);
|
|
27615
|
-
const
|
|
27616
|
-
|
|
28905
|
+
const preserveCompactStream = compactLiveStreamRenderActive();
|
|
28906
|
+
const preserveNormalStream = !preserveCompactStream && liveStreamRenderActive();
|
|
28907
|
+
if (!preserveCompactStream && !preserveNormalStream) resetStreamBubble();
|
|
27617
28908
|
renderMessages(latestMessages);
|
|
27618
|
-
if (
|
|
28909
|
+
if (preserveCompactStream) restoreCompactLiveOutputAfterChatRebuild();
|
|
28910
|
+
else if (preserveNormalStream) restoreStreamRenderAfterChatRebuild();
|
|
27619
28911
|
markTabOutputSeen();
|
|
27620
28912
|
renderFooter();
|
|
27621
28913
|
}
|
|
@@ -28943,7 +30235,7 @@ async function runUserBashCommand(parsed, { usesPromptInput = false, targetTabId
|
|
|
28943
30235
|
if (!targetTabId || !parsed?.command) return;
|
|
28944
30236
|
const tabContext = activeTabContext(targetTabId);
|
|
28945
30237
|
const { command, excludeFromContext } = parsed;
|
|
28946
|
-
|
|
30238
|
+
resumeChatAutoFollow();
|
|
28947
30239
|
setComposerActionsOpen(false);
|
|
28948
30240
|
hideCommandSuggestions();
|
|
28949
30241
|
userBashByTab.set(targetTabId, { command, excludeFromContext, startedAt: Date.now() });
|
|
@@ -29041,7 +30333,7 @@ async function sendPrompt(kind = "prompt", explicitMessage, { targetTabId = acti
|
|
|
29041
30333
|
const targetWasBusy = targetWasStreaming || targetWasCompacting;
|
|
29042
30334
|
const busyBehavior = normalizeBusyPromptBehavior(busyPromptBehavior);
|
|
29043
30335
|
const startsRun = kind === "prompt" && !targetWasBusy;
|
|
29044
|
-
|
|
30336
|
+
resumeChatAutoFollow();
|
|
29045
30337
|
updateJumpToLatestButton();
|
|
29046
30338
|
setComposerActionsOpen(false);
|
|
29047
30339
|
if (startsRun) {
|
|
@@ -29152,6 +30444,10 @@ function handleExtensionUiRequest(request) {
|
|
|
29152
30444
|
}
|
|
29153
30445
|
case "setStatus": {
|
|
29154
30446
|
const statusKey = request.statusKey || "extension";
|
|
30447
|
+
if (statusKey === FEATURE_CATEGORY_STATUS_KEY) {
|
|
30448
|
+
handleFeatureCategoryStatus(request.statusText, request.tabId || activeTabId);
|
|
30449
|
+
return;
|
|
30450
|
+
}
|
|
29155
30451
|
if (request.statusText) {
|
|
29156
30452
|
statusEntries.set(statusKey, request.statusText);
|
|
29157
30453
|
if (statusKey === GIT_FOOTER_WEBUI_STATUS_KEY) cacheGitFooterWebuiPayload(request.statusText, request.tabId);
|
|
@@ -29276,6 +30572,180 @@ function addDialogButton(label, handler, className) {
|
|
|
29276
30572
|
return button;
|
|
29277
30573
|
}
|
|
29278
30574
|
|
|
30575
|
+
const WORKFLOW_SCRIPT_TOKEN_PATTERN = /\/\/.*$|\/\*.*?\*\/|`(?:\\.|[^`])*`|"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\b(?:abstract|any|as|asserts|async|await|boolean|break|case|catch|class|const|continue|declare|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|is|keyof|let|namespace|never|new|null|number|of|private|protected|public|readonly|return|satisfies|set|static|string|super|switch|symbol|this|throw|true|try|type|typeof|undefined|unknown|using|var|void|while|yield)\b|\b\d+(?:\.\d+)?\b/g;
|
|
30576
|
+
|
|
30577
|
+
function isWorkflowScriptPreviewRequest(request, prompt) {
|
|
30578
|
+
const title = String(prompt?.title || "");
|
|
30579
|
+
return request?.method === "editor"
|
|
30580
|
+
&& title.startsWith("Raw workflow script")
|
|
30581
|
+
&& /\binspection only;\s*edits are ignored\b/i.test(title);
|
|
30582
|
+
}
|
|
30583
|
+
|
|
30584
|
+
function workflowScriptTokenClass(token) {
|
|
30585
|
+
if (/^\/\//.test(token) || /^\/\*/.test(token)) return "comment";
|
|
30586
|
+
if (/^[`"']/.test(token)) return "string";
|
|
30587
|
+
if (/^\d/.test(token)) return "number";
|
|
30588
|
+
return "keyword";
|
|
30589
|
+
}
|
|
30590
|
+
|
|
30591
|
+
function appendWorkflowScriptTokens(parent, line) {
|
|
30592
|
+
let start = 0;
|
|
30593
|
+
WORKFLOW_SCRIPT_TOKEN_PATTERN.lastIndex = 0;
|
|
30594
|
+
for (let match = WORKFLOW_SCRIPT_TOKEN_PATTERN.exec(line); match; match = WORKFLOW_SCRIPT_TOKEN_PATTERN.exec(line)) {
|
|
30595
|
+
if (match.index > start) parent.append(document.createTextNode(line.slice(start, match.index)));
|
|
30596
|
+
parent.append(make("span", `workflow-script-token workflow-script-token-${workflowScriptTokenClass(match[0])}`, match[0]));
|
|
30597
|
+
start = match.index + match[0].length;
|
|
30598
|
+
}
|
|
30599
|
+
if (start < line.length) parent.append(document.createTextNode(line.slice(start)));
|
|
30600
|
+
}
|
|
30601
|
+
|
|
30602
|
+
function renderWorkflowScriptPreview(request) {
|
|
30603
|
+
const source = request.prefill ?? "";
|
|
30604
|
+
const sourceLines = source.split("\n");
|
|
30605
|
+
const searchableLines = sourceLines.map((line) => line.toLocaleLowerCase());
|
|
30606
|
+
const preview = make("section", "workflow-script-preview");
|
|
30607
|
+
preview.setAttribute("aria-label", "Read-only TypeScript workflow script");
|
|
30608
|
+
|
|
30609
|
+
const metadata = make("div", "workflow-script-meta");
|
|
30610
|
+
metadata.append(
|
|
30611
|
+
make("span", "workflow-script-language", "TypeScript · read-only"),
|
|
30612
|
+
make("span", "workflow-script-source-stats", `${sourceLines.length.toLocaleString()} ${sourceLines.length === 1 ? "line" : "lines"} · ${source.length.toLocaleString()} characters`),
|
|
30613
|
+
);
|
|
30614
|
+
|
|
30615
|
+
const toolbar = make("div", "workflow-script-toolbar");
|
|
30616
|
+
const search = make("input", "workflow-script-search");
|
|
30617
|
+
search.type = "search";
|
|
30618
|
+
search.placeholder = "Search source";
|
|
30619
|
+
search.setAttribute("aria-label", "Search workflow source");
|
|
30620
|
+
|
|
30621
|
+
const previous = make("button", "workflow-script-search-button", "Previous match");
|
|
30622
|
+
previous.type = "button";
|
|
30623
|
+
previous.title = "Previous search match";
|
|
30624
|
+
previous.setAttribute("aria-label", "Previous search match");
|
|
30625
|
+
previous.disabled = true;
|
|
30626
|
+
|
|
30627
|
+
const next = make("button", "workflow-script-search-button", "Next match");
|
|
30628
|
+
next.type = "button";
|
|
30629
|
+
next.title = "Next search match";
|
|
30630
|
+
next.setAttribute("aria-label", "Next search match");
|
|
30631
|
+
next.disabled = true;
|
|
30632
|
+
|
|
30633
|
+
const wrap = make("button", "workflow-script-wrap-button", "Wrap lines");
|
|
30634
|
+
wrap.type = "button";
|
|
30635
|
+
wrap.title = "Wrap long lines";
|
|
30636
|
+
wrap.setAttribute("aria-label", "Wrap long lines");
|
|
30637
|
+
wrap.setAttribute("aria-pressed", "false");
|
|
30638
|
+
|
|
30639
|
+
const copy = make("button", "workflow-script-copy-button", "Copy source");
|
|
30640
|
+
copy.type = "button";
|
|
30641
|
+
copy.title = "Copy workflow source";
|
|
30642
|
+
copy.setAttribute("aria-label", "Copy workflow source");
|
|
30643
|
+
|
|
30644
|
+
const searchStatus = make("span", "workflow-script-search-status", "Search source.");
|
|
30645
|
+
searchStatus.setAttribute("role", "status");
|
|
30646
|
+
searchStatus.setAttribute("aria-live", "polite");
|
|
30647
|
+
const copyStatus = make("span", "workflow-script-copy-status");
|
|
30648
|
+
copyStatus.setAttribute("role", "status");
|
|
30649
|
+
copyStatus.setAttribute("aria-live", "polite");
|
|
30650
|
+
toolbar.append(search, previous, next, wrap, copy, searchStatus, copyStatus);
|
|
30651
|
+
|
|
30652
|
+
const codeViewer = make("div", "workflow-script-code");
|
|
30653
|
+
codeViewer.id = "workflowScriptViewer";
|
|
30654
|
+
codeViewer.tabIndex = 0;
|
|
30655
|
+
codeViewer.setAttribute("role", "region");
|
|
30656
|
+
codeViewer.setAttribute("aria-label", "Read-only workflow source with line numbers");
|
|
30657
|
+
search.setAttribute("aria-controls", codeViewer.id);
|
|
30658
|
+
|
|
30659
|
+
const lineRows = sourceLines.map((line, index) => {
|
|
30660
|
+
const row = make("div", "workflow-script-line");
|
|
30661
|
+
row.dataset.line = String(index + 1);
|
|
30662
|
+
const number = make("span", "workflow-script-line-number", String(index + 1));
|
|
30663
|
+
number.setAttribute("aria-hidden", "true");
|
|
30664
|
+
const text = make("code", "workflow-script-line-text");
|
|
30665
|
+
appendWorkflowScriptTokens(text, line);
|
|
30666
|
+
row.append(number, text);
|
|
30667
|
+
codeViewer.append(row);
|
|
30668
|
+
return row;
|
|
30669
|
+
});
|
|
30670
|
+
|
|
30671
|
+
let matchingLineIndexes = [];
|
|
30672
|
+
let activeMatchIndex = -1;
|
|
30673
|
+
const setActiveMatch = (index, { scroll = true } = {}) => {
|
|
30674
|
+
if (matchingLineIndexes.length === 0) return;
|
|
30675
|
+
activeMatchIndex = (index + matchingLineIndexes.length) % matchingLineIndexes.length;
|
|
30676
|
+
const activeLine = matchingLineIndexes[activeMatchIndex];
|
|
30677
|
+
lineRows.forEach((row, lineIndex) => {
|
|
30678
|
+
const active = lineIndex === activeLine;
|
|
30679
|
+
row.classList.toggle("is-active-match", active);
|
|
30680
|
+
if (active) row.setAttribute("aria-current", "true");
|
|
30681
|
+
else row.removeAttribute("aria-current");
|
|
30682
|
+
});
|
|
30683
|
+
searchStatus.textContent = `${activeMatchIndex + 1} of ${matchingLineIndexes.length} matching ${matchingLineIndexes.length === 1 ? "line" : "lines"}.`;
|
|
30684
|
+
if (scroll) lineRows[activeLine].scrollIntoView({ block: "center" });
|
|
30685
|
+
};
|
|
30686
|
+
const updateMatches = () => {
|
|
30687
|
+
const query = search.value.toLocaleLowerCase();
|
|
30688
|
+
matchingLineIndexes = [];
|
|
30689
|
+
if (query) {
|
|
30690
|
+
searchableLines.forEach((line, index) => {
|
|
30691
|
+
if (line.includes(query)) matchingLineIndexes.push(index);
|
|
30692
|
+
});
|
|
30693
|
+
}
|
|
30694
|
+
const matchingLineSet = new Set(matchingLineIndexes);
|
|
30695
|
+
lineRows.forEach((row, index) => {
|
|
30696
|
+
const matched = matchingLineSet.has(index);
|
|
30697
|
+
row.classList.toggle("is-search-match", matched);
|
|
30698
|
+
row.classList.remove("is-active-match");
|
|
30699
|
+
row.removeAttribute("aria-current");
|
|
30700
|
+
});
|
|
30701
|
+
activeMatchIndex = -1;
|
|
30702
|
+
previous.disabled = matchingLineIndexes.length === 0;
|
|
30703
|
+
next.disabled = matchingLineIndexes.length === 0;
|
|
30704
|
+
if (matchingLineIndexes.length > 0) setActiveMatch(0);
|
|
30705
|
+
else searchStatus.textContent = query ? "No matching lines." : "Search source.";
|
|
30706
|
+
};
|
|
30707
|
+
|
|
30708
|
+
search.addEventListener("input", updateMatches);
|
|
30709
|
+
search.addEventListener("keydown", (event) => {
|
|
30710
|
+
if (event.key !== "Enter") return;
|
|
30711
|
+
event.preventDefault();
|
|
30712
|
+
if (matchingLineIndexes.length === 0) return;
|
|
30713
|
+
setActiveMatch(activeMatchIndex + (event.shiftKey ? -1 : 1));
|
|
30714
|
+
});
|
|
30715
|
+
previous.addEventListener("click", () => setActiveMatch(activeMatchIndex - 1));
|
|
30716
|
+
next.addEventListener("click", () => setActiveMatch(activeMatchIndex + 1));
|
|
30717
|
+
wrap.addEventListener("click", () => {
|
|
30718
|
+
const wrapped = codeViewer.classList.toggle("is-wrapped");
|
|
30719
|
+
wrap.textContent = wrapped ? "Unwrap lines" : "Wrap lines";
|
|
30720
|
+
wrap.title = wrapped ? "Do not wrap long lines" : "Wrap long lines";
|
|
30721
|
+
wrap.setAttribute("aria-label", wrap.title);
|
|
30722
|
+
wrap.setAttribute("aria-pressed", String(wrapped));
|
|
30723
|
+
});
|
|
30724
|
+
copy.addEventListener("click", async () => {
|
|
30725
|
+
copy.disabled = true;
|
|
30726
|
+
try {
|
|
30727
|
+
await copyText(source);
|
|
30728
|
+
copy.textContent = "Copied";
|
|
30729
|
+
copyStatus.textContent = "Workflow source copied.";
|
|
30730
|
+
} catch (error) {
|
|
30731
|
+
copy.textContent = "Copy failed";
|
|
30732
|
+
copyStatus.textContent = "Could not copy workflow source.";
|
|
30733
|
+
} finally {
|
|
30734
|
+
window.setTimeout(() => {
|
|
30735
|
+
if (!copy.isConnected) return;
|
|
30736
|
+
copy.textContent = "Copy source";
|
|
30737
|
+
copy.disabled = false;
|
|
30738
|
+
}, 1600);
|
|
30739
|
+
}
|
|
30740
|
+
});
|
|
30741
|
+
|
|
30742
|
+
preview.append(metadata, toolbar, codeViewer);
|
|
30743
|
+
elements.dialogBody.append(preview);
|
|
30744
|
+
addDialogButton("Cancel workflow", () => sendDialogResponse({ type: "extension_ui_response", id: request.id, cancelled: true, tabId: request.tabId }));
|
|
30745
|
+
addDialogButton("Back to approval", () => sendDialogResponse({ type: "extension_ui_response", id: request.id, value: request.prefill, tabId: request.tabId }), "primary");
|
|
30746
|
+
setTimeout(() => codeViewer.focus(), 0);
|
|
30747
|
+
}
|
|
30748
|
+
|
|
29279
30749
|
function showNextDialog() {
|
|
29280
30750
|
if (activeDialog || dialogQueue.length === 0) return;
|
|
29281
30751
|
activeDialog = dialogQueue.shift();
|
|
@@ -29287,8 +30757,10 @@ function showNextDialog() {
|
|
|
29287
30757
|
const displayPrompt = releasePrompt || prompt;
|
|
29288
30758
|
const isGuardrailDialog = isGuardrailDialogPrompt(displayPrompt);
|
|
29289
30759
|
const isReleaseDialog = !!releasePrompt;
|
|
30760
|
+
const isWorkflowScriptPreview = isWorkflowScriptPreviewRequest(request, prompt);
|
|
29290
30761
|
elements.dialog.classList.toggle("guardrail-dialog", isGuardrailDialog);
|
|
29291
30762
|
elements.dialog.classList.toggle("release-dialog", isReleaseDialog);
|
|
30763
|
+
elements.dialog.classList.toggle("workflow-script-dialog", isWorkflowScriptPreview);
|
|
29292
30764
|
elements.dialogTitle.textContent = displayPrompt.title;
|
|
29293
30765
|
if (isReleaseDialog) renderReleaseDialogMessage(elements.dialogMessage, displayPrompt.message);
|
|
29294
30766
|
else renderAnsiText(elements.dialogMessage, displayPrompt.message);
|
|
@@ -29328,6 +30800,8 @@ function showNextDialog() {
|
|
|
29328
30800
|
addDialogButton("Cancel", cancel);
|
|
29329
30801
|
addDialogButton("Submit", () => sendDialogResponse({ type: "extension_ui_response", id: request.id, value: input.value, tabId: request.tabId }), "primary");
|
|
29330
30802
|
setTimeout(() => input.focus(), 0);
|
|
30803
|
+
} else if (isWorkflowScriptPreview) {
|
|
30804
|
+
renderWorkflowScriptPreview(request);
|
|
29331
30805
|
} else if (request.method === "editor") {
|
|
29332
30806
|
const textarea = make("textarea", "dialog-editor");
|
|
29333
30807
|
textarea.value = request.prefill || "";
|
|
@@ -29378,7 +30852,11 @@ function handleEvent(event) {
|
|
|
29378
30852
|
}
|
|
29379
30853
|
const tabContext = activeTabContext(event.tabId || activeTabId);
|
|
29380
30854
|
switch (event.type) {
|
|
29381
|
-
case "webui_connected":
|
|
30855
|
+
case "webui_connected": {
|
|
30856
|
+
const connectedTabId = event.tabId || activeTabId;
|
|
30857
|
+
featureCategoryByTab.delete(connectedTabId);
|
|
30858
|
+
if (connectedTabId === activeTabId) renderFeatureCategoryTag(connectedTabId);
|
|
30859
|
+
acceptOutputModeAcknowledgement(event);
|
|
29382
30860
|
setWebuiVersion(event.version);
|
|
29383
30861
|
setPiVersion(event.piVersion);
|
|
29384
30862
|
setWebuiDevServer(isWebuiDevMetadata(event));
|
|
@@ -29390,6 +30868,10 @@ function handleEvent(event) {
|
|
|
29390
30868
|
addEvent(`connected to ${event.tabTitle || "terminal"} for ${event.cwd}`);
|
|
29391
30869
|
scheduleForegroundReconcile("event stream reconnect", 0);
|
|
29392
30870
|
break;
|
|
30871
|
+
}
|
|
30872
|
+
case "webui_output_mode":
|
|
30873
|
+
applyOutputModeControl(event, tabContext);
|
|
30874
|
+
break;
|
|
29393
30875
|
case "webui_tab_renamed":
|
|
29394
30876
|
applyTabMetadata(event.tab || { id: event.tabId, title: event.tabTitle, activity: event.tabActivity });
|
|
29395
30877
|
addEvent(`${event.previousTabTitle || "terminal"} renamed to ${event.tabTitle || "terminal"}`);
|
|
@@ -29485,11 +30967,13 @@ function handleEvent(event) {
|
|
|
29485
30967
|
renderNetworkStatus();
|
|
29486
30968
|
break;
|
|
29487
30969
|
case "pi_process_exit":
|
|
30970
|
+
if (compactOutputActive()) compactLiveScheduler.flushNow();
|
|
29488
30971
|
surfaceRuntimeDiagnostic("Pi process exited", `Pi RPC exited (${event.code ?? event.signal ?? "unknown"}).`);
|
|
29489
30972
|
clearRunIndicatorActivity();
|
|
29490
30973
|
refreshTabs().catch((error) => addEvent(error.message, "error"));
|
|
29491
30974
|
break;
|
|
29492
30975
|
case "pi_process_error":
|
|
30976
|
+
if (compactOutputActive()) compactLiveScheduler.flushNow();
|
|
29493
30977
|
surfaceRuntimeDiagnostic("Pi process error", event.error || "Pi RPC process error.");
|
|
29494
30978
|
clearRunIndicatorActivity();
|
|
29495
30979
|
refreshTabs().catch((error) => addEvent(error.message, "error"));
|
|
@@ -29536,6 +31020,7 @@ function handleEvent(event) {
|
|
|
29536
31020
|
renderFeedbackTray();
|
|
29537
31021
|
break;
|
|
29538
31022
|
case "agent_end":
|
|
31023
|
+
if (compactOutputActive()) finishCompactLiveOutput(tabContext);
|
|
29539
31024
|
streamMessageActive = false;
|
|
29540
31025
|
if (!assistantErrorSurfacedThisRun && event.willRetry !== true) {
|
|
29541
31026
|
const message = assistantErrorFromAgentEnd(event);
|
|
@@ -29584,6 +31069,7 @@ function handleEvent(event) {
|
|
|
29584
31069
|
handleMessageUpdate(event);
|
|
29585
31070
|
break;
|
|
29586
31071
|
case "message_end": {
|
|
31072
|
+
if (compactOutputActive()) finishCompactLiveOutput(tabContext);
|
|
29587
31073
|
streamMessageActive = false;
|
|
29588
31074
|
if (event.message?.role === "assistant" && event.message.stopReason === "error") {
|
|
29589
31075
|
const message = String(event.message.errorMessage || streamProviderErrorText || "The assistant request failed without an error message.").trim();
|
|
@@ -29600,26 +31086,36 @@ function handleEvent(event) {
|
|
|
29600
31086
|
case "tool_execution_start":
|
|
29601
31087
|
streamToolCallSeen = true;
|
|
29602
31088
|
if (voiceConversationActiveFor(event.tabId || activeTabId)) voiceConversation.setAssistantActivity({ toolRunning: true });
|
|
29603
|
-
|
|
29604
|
-
|
|
29605
|
-
|
|
31089
|
+
if (compactOutputActive()) {
|
|
31090
|
+
compactLiveScheduler.flushNow();
|
|
31091
|
+
renderCompactToolShell(event);
|
|
31092
|
+
} else {
|
|
31093
|
+
suppressStreamingAssistantTextBeforeToolCall();
|
|
31094
|
+
removeStreamingToolCallCard();
|
|
31095
|
+
handleToolExecutionStart(event);
|
|
31096
|
+
}
|
|
29606
31097
|
setRunIndicatorActivity(`Running tool: ${runIndicatorToolName(event.toolName)}…`);
|
|
29607
31098
|
addEvent(`tool ${event.toolName} started`, "info", { toolCallId: event.toolCallId });
|
|
29608
31099
|
break;
|
|
29609
31100
|
case "tool_execution_update":
|
|
29610
|
-
handleToolExecutionUpdate(event);
|
|
31101
|
+
if (!compactOutputActive()) handleToolExecutionUpdate(event);
|
|
29611
31102
|
setRunIndicatorActivity(`Running tool: ${runIndicatorToolName(event.toolName)}…`, { scroll: false });
|
|
29612
31103
|
break;
|
|
29613
31104
|
case "tool_execution_end": {
|
|
29614
31105
|
if (voiceConversationActiveFor(event.tabId || activeTabId)) voiceConversation.setAssistantActivity({ toolRunning: false });
|
|
29615
31106
|
const imagePayloadError = toolImagePayloadError(event);
|
|
29616
31107
|
if (imagePayloadError) surfaceRuntimeDiagnostic("Tool image payload error", imagePayloadError);
|
|
29617
|
-
|
|
31108
|
+
if (compactOutputActive()) {
|
|
31109
|
+
compactLiveScheduler.flushNow();
|
|
31110
|
+
renderCompactToolShell(event, { complete: true });
|
|
31111
|
+
finishCompactLiveOutput(tabContext);
|
|
31112
|
+
} else {
|
|
31113
|
+
handleToolExecutionEnd(event);
|
|
31114
|
+
}
|
|
29618
31115
|
setRunIndicatorActivity(`Tool ${runIndicatorToolName(event.toolName)} ${event.isError ? "failed" : "finished"}; waiting for the agent's next step…`);
|
|
29619
31116
|
addEvent(`tool ${event.toolName} ${event.isError ? "failed" : "finished"}`, event.isError ? "error" : "info", { toolCallId: event.toolCallId });
|
|
29620
|
-
//
|
|
29621
|
-
//
|
|
29622
|
-
// transcript. This avoids one fetch+render per tool call.
|
|
31117
|
+
// Compact tool shells deliberately defer rich body construction to the
|
|
31118
|
+
// final transcript reconciliation; normal mode retains its live card.
|
|
29623
31119
|
scheduleRefreshFooter();
|
|
29624
31120
|
break;
|
|
29625
31121
|
}
|
|
@@ -29631,6 +31127,7 @@ function handleEvent(event) {
|
|
|
29631
31127
|
renderStatus();
|
|
29632
31128
|
break;
|
|
29633
31129
|
case "compaction_end":
|
|
31130
|
+
if (compactOutputActive()) finishCompactLiveOutput(tabContext);
|
|
29634
31131
|
if (currentState) currentState = { ...currentState, isCompacting: false };
|
|
29635
31132
|
if (event.aborted) clearContextUsageUnknownAfterCompaction(event.tabId || activeTabId);
|
|
29636
31133
|
else markContextUsageUnknownAfterCompaction(event.tabId || activeTabId);
|
|
@@ -29643,6 +31140,9 @@ function handleEvent(event) {
|
|
|
29643
31140
|
scheduleRefreshMessages();
|
|
29644
31141
|
scheduleRefreshFooter();
|
|
29645
31142
|
break;
|
|
31143
|
+
case "agent_settled":
|
|
31144
|
+
if (compactOutputActive()) finishCompactLiveOutput(tabContext);
|
|
31145
|
+
break;
|
|
29646
31146
|
case "auto_retry_start": {
|
|
29647
31147
|
const seconds = Math.max(0, Math.ceil(Number(event.delayMs || 0) / 1000));
|
|
29648
31148
|
const retryText = `Retrying (${event.attempt || "?"}/${event.maxAttempts || "?"}) in ${seconds}s after: ${event.errorMessage || "model/provider error"}`;
|
|
@@ -29699,11 +31199,21 @@ function handleEvent(event) {
|
|
|
29699
31199
|
}
|
|
29700
31200
|
}
|
|
29701
31201
|
|
|
29702
|
-
function connectEvents(tabContext = activeTabContext()) {
|
|
31202
|
+
function connectEvents(tabContext = activeTabContext(), { requestedMode = "auto", fallbackAttempted = false } = {}) {
|
|
29703
31203
|
eventSource?.close();
|
|
29704
31204
|
eventSource = null;
|
|
31205
|
+
resetCompactLiveOutput();
|
|
31206
|
+
activeOutputMode = "normal";
|
|
31207
|
+
outputModeAcknowledged = false;
|
|
31208
|
+
eventSourceOutputModeRequest = requestedMode === "normal" ? "normal" : "auto";
|
|
31209
|
+
eventSourceOutputModeFallbackAttempted = !!fallbackAttempted;
|
|
29705
31210
|
if (!tabContext.tabId || !isCurrentTabContext(tabContext)) return;
|
|
29706
|
-
const
|
|
31211
|
+
const parameters = new URLSearchParams({
|
|
31212
|
+
tab: tabContext.tabId,
|
|
31213
|
+
outputMode: eventSourceOutputModeRequest,
|
|
31214
|
+
outputModeProtocol: "1",
|
|
31215
|
+
});
|
|
31216
|
+
const source = new EventSource(`/api/events?${parameters.toString()}`);
|
|
29707
31217
|
eventSource = source;
|
|
29708
31218
|
source.onmessage = (message) => {
|
|
29709
31219
|
if (eventSource !== source || !isCurrentTabContext(tabContext)) return;
|
|
@@ -29715,6 +31225,7 @@ function connectEvents(tabContext = activeTabContext()) {
|
|
|
29715
31225
|
};
|
|
29716
31226
|
source.onerror = () => {
|
|
29717
31227
|
if (eventSource !== source || !isCurrentTabContext(tabContext)) return;
|
|
31228
|
+
if (compactOutputActive()) compactLiveScheduler.flushNow();
|
|
29718
31229
|
addEvent("event stream disconnected; browser will retry", "warn");
|
|
29719
31230
|
fetch("/api/health", { cache: "no-store" }).catch((error) => setBackendOffline(true, error));
|
|
29720
31231
|
};
|
|
@@ -30011,6 +31522,7 @@ elements.nativeSkillsButton.addEventListener("click", () => runNativeCommandMenu
|
|
|
30011
31522
|
elements.nativeToolsButton.addEventListener("click", () => runNativeCommandMenu("/tools"));
|
|
30012
31523
|
elements.optionsCommandPaletteButton.addEventListener("click", () => openCommandPalette());
|
|
30013
31524
|
elements.workflowModeButton?.addEventListener("click", () => toggleWorkflowMode());
|
|
31525
|
+
elements.workflowOverlayOpenButton?.addEventListener("click", () => setWorkflowOverlayMinimized(false));
|
|
30014
31526
|
elements.workflowModeChip?.addEventListener("click", () => setWorkflowModeEnabled(false));
|
|
30015
31527
|
elements.optionsConversationModeButton?.addEventListener("click", () => toggleNaturalConversationMode());
|
|
30016
31528
|
elements.conversationModeChip?.addEventListener("click", () => toggleVoiceConversationPaused());
|
|
@@ -30534,6 +32046,11 @@ if (elements.thinkingVisibilityToggle) {
|
|
|
30534
32046
|
setThinkingOutputVisible(elements.thinkingVisibilityToggle.checked, { announce: true });
|
|
30535
32047
|
});
|
|
30536
32048
|
}
|
|
32049
|
+
elements.fastOutputModeSelect?.addEventListener("change", () => {
|
|
32050
|
+
sidebarOutputModeNotice = "";
|
|
32051
|
+
renderSidebarOutputModeControl({ syncSelection: false });
|
|
32052
|
+
});
|
|
32053
|
+
elements.setFastOutputModeButton?.addEventListener("click", () => applySidebarOutputMode().catch((error) => addEvent(error.message || String(error), "error")));
|
|
30537
32054
|
if (elements.terminalTabsLayoutSelect) {
|
|
30538
32055
|
elements.terminalTabsLayoutSelect.addEventListener("change", () => {
|
|
30539
32056
|
setTerminalTabsLayout(elements.terminalTabsLayoutSelect.value, { announce: true });
|
|
@@ -30544,6 +32061,41 @@ if (elements.subagentOpenModeSelect) {
|
|
|
30544
32061
|
setSubagentOpenMode(elements.subagentOpenModeSelect.value, { announce: true });
|
|
30545
32062
|
});
|
|
30546
32063
|
}
|
|
32064
|
+
elements.subagentLaunchSlotScope?.addEventListener("change", () => {
|
|
32065
|
+
selectSubagentLaunchSlotScope(elements.subagentLaunchSlotScope.value).catch((error) => {
|
|
32066
|
+
subagentLaunchSlotError = error.message || String(error);
|
|
32067
|
+
renderSubagentLaunchSlots();
|
|
32068
|
+
});
|
|
32069
|
+
});
|
|
32070
|
+
elements.subagentLaunchSlotsRefresh?.addEventListener("click", () => {
|
|
32071
|
+
reloadSubagentLaunchSlotConfig().catch((error) => {
|
|
32072
|
+
subagentLaunchSlotError = error.message || String(error);
|
|
32073
|
+
renderSubagentLaunchSlots();
|
|
32074
|
+
});
|
|
32075
|
+
});
|
|
32076
|
+
elements.subagentLaunchSlotsSave?.addEventListener("click", () => {
|
|
32077
|
+
saveSubagentLaunchSlotConfig().catch((error) => {
|
|
32078
|
+
subagentLaunchSlotError = error.message || String(error);
|
|
32079
|
+
renderSubagentLaunchSlots();
|
|
32080
|
+
});
|
|
32081
|
+
});
|
|
32082
|
+
elements.subagentLaunchSlotsInherit?.addEventListener("click", () => {
|
|
32083
|
+
resetSubagentLaunchSlotProjectScope().catch((error) => {
|
|
32084
|
+
subagentLaunchSlotError = error.message || String(error);
|
|
32085
|
+
renderSubagentLaunchSlots();
|
|
32086
|
+
});
|
|
32087
|
+
});
|
|
32088
|
+
elements.subagentLaunchSlotsReload?.addEventListener("click", () => {
|
|
32089
|
+
reloadActiveTabForSubagentLaunchSlots().catch((error) => {
|
|
32090
|
+
subagentLaunchSlotError = error.message || String(error);
|
|
32091
|
+
renderSubagentLaunchSlots();
|
|
32092
|
+
});
|
|
32093
|
+
});
|
|
32094
|
+
elements.subagentLaunchSlotsLater?.addEventListener("click", () => {
|
|
32095
|
+
subagentLaunchSlotReloadRequired = false;
|
|
32096
|
+
setSubagentLaunchSlotAnnouncement("Agent models are saved. Reload this tab later before relying on them for future launches.");
|
|
32097
|
+
renderSubagentLaunchSlots();
|
|
32098
|
+
});
|
|
30547
32099
|
elements.subagentTerminalCopyButton?.addEventListener("click", () => copySubagentTerminalOutput());
|
|
30548
32100
|
elements.subagentTerminalRefreshButton?.addEventListener("click", () => {
|
|
30549
32101
|
refreshSubagentTerminalView(activeSubagentTerminalId, { showLoading: true }).finally(() => scheduleSubagentTerminalRefresh());
|
|
@@ -30568,7 +32120,10 @@ bindSidePanelContextMenu();
|
|
|
30568
32120
|
elements.stickyUserPromptButton?.addEventListener("click", jumpToStickyUserPrompt);
|
|
30569
32121
|
elements.jumpToLatestButton.addEventListener("click", jumpToLatest);
|
|
30570
32122
|
elements.chat.addEventListener("wheel", noteChatUserScrollIntent, { passive: true });
|
|
32123
|
+
elements.chat.addEventListener("touchstart", noteChatTouchStart, { passive: true });
|
|
30571
32124
|
elements.chat.addEventListener("touchmove", noteChatUserScrollIntent, { passive: true });
|
|
32125
|
+
elements.chat.addEventListener("touchend", clearChatTouchIntent, { passive: true });
|
|
32126
|
+
elements.chat.addEventListener("touchcancel", clearChatTouchIntent, { passive: true });
|
|
30572
32127
|
elements.chat.addEventListener("keydown", (event) => {
|
|
30573
32128
|
if (CHAT_SCROLL_KEYS.has(event.key)) noteChatUserScrollIntent(event);
|
|
30574
32129
|
}, { passive: true });
|
|
@@ -30827,7 +32382,7 @@ window.addEventListener("storage", (event) => {
|
|
|
30827
32382
|
if (event.key === OPTIONAL_FEATURES_STORAGE_KEY) reconcileDisabledOptionalFeaturesFromStorage();
|
|
30828
32383
|
if (event.key === SIDE_PANEL_SECTION_VISIBILITY_STORAGE_KEY) restoreSidePanelSectionVisibility();
|
|
30829
32384
|
});
|
|
30830
|
-
window.addEventListener("resize",
|
|
32385
|
+
window.addEventListener("resize", syncResizablePanelWidthsForViewport, { passive: true });
|
|
30831
32386
|
window.addEventListener("keydown", (event) => {
|
|
30832
32387
|
if (event.key !== "Escape") return;
|
|
30833
32388
|
if (event.defaultPrevented) return;
|
|
@@ -31033,6 +32588,8 @@ elements.fileContextMenu?.addEventListener("click", (event) => {
|
|
|
31033
32588
|
else if (action === "delete") deleteFileTreeEntry(entry).catch((error) => addEvent(error.message || String(error), "error"));
|
|
31034
32589
|
});
|
|
31035
32590
|
elements.fileViewerOpenDefaultButton?.addEventListener("click", () => openPathInDefaultEditor(currentFileViewerPath()));
|
|
32591
|
+
elements.sidePanelResizeHandle?.addEventListener("pointerdown", beginSidePanelResize);
|
|
32592
|
+
elements.sidePanelResizeHandle?.addEventListener("keydown", handleSidePanelResizeKeydown);
|
|
31036
32593
|
elements.fileViewerResizeHandle?.addEventListener("pointerdown", beginFileViewerResize);
|
|
31037
32594
|
elements.fileViewerResizeHandle?.addEventListener("keydown", handleFileViewerResizeKeydown);
|
|
31038
32595
|
elements.fileViewerSaveButton?.addEventListener("click", () => saveActiveFileViewer());
|
|
@@ -31173,6 +32730,7 @@ elements.promptInput.addEventListener("blur", () => {
|
|
|
31173
32730
|
|
|
31174
32731
|
installModalPrimitives();
|
|
31175
32732
|
resizePromptInput();
|
|
32733
|
+
restoreSidePanelWidthPreference();
|
|
31176
32734
|
restoreFileViewerWidthPreference();
|
|
31177
32735
|
focusPromptInput({ defer: true });
|
|
31178
32736
|
restoreStoredSkillUsage();
|
|
@@ -31208,9 +32766,11 @@ restoreSidePanelState();
|
|
|
31208
32766
|
initializeCodexUsage();
|
|
31209
32767
|
initializeClaudeUsage();
|
|
31210
32768
|
initializeSubagents();
|
|
32769
|
+
initializeSubagentLaunchSlots();
|
|
31211
32770
|
initializeUpdateNotifications();
|
|
31212
32771
|
bindMobileViewChanges();
|
|
31213
32772
|
bindSidePanelOverlayViewChanges();
|
|
31214
32773
|
registerPwaServiceWorker();
|
|
31215
32774
|
renderServerOfflinePanel();
|
|
32775
|
+
refreshSidebarOutputMode().catch((error) => addEvent(error.message || String(error), "error"));
|
|
31216
32776
|
initializeTabs().catch((error) => addEvent(error.message, "error"));
|