@firstpick/pi-package-webui 0.7.2 → 0.7.4
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 +38 -25
- package/bin/pi-webui.mjs +469 -106
- package/index.ts +10 -1
- package/lib/git-live-watcher.mjs +135 -0
- package/lib/git-message-artifacts.mjs +103 -0
- package/lib/git-workflow-preferences.mjs +10 -3
- package/lib/process-tree.mjs +3 -1
- package/lib/webui-output-mode.mjs +97 -0
- package/package.json +7 -6
- package/public/app.js +1170 -97
- package/public/fast-output-live.mjs +179 -0
- package/public/index.html +31 -5
- package/public/service-worker.js +2 -1
- package/public/styles.css +474 -12
- package/tests/app-runner-windows-conpty-harness.test.mjs +140 -0
- package/tests/danger-button-contrast-static.test.mjs +32 -0
- package/tests/fast-mode-client-static.test.mjs +121 -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 +59 -0
- package/tests/fixtures/fast-mode-output-events.mjs +50 -0
- package/tests/footer-middle-truncation.test.mjs +118 -0
- package/tests/git-live-watcher.test.mjs +93 -0
- package/tests/git-message-artifacts.test.mjs +59 -0
- package/tests/git-panel-live-updates-static.test.mjs +54 -0
- package/tests/git-panel-render-stability-static.test.mjs +1 -1
- package/tests/git-workflow-preferences.test.mjs +8 -2
- package/tests/guided-git-message-reliability-static.test.mjs +38 -0
- package/tests/http-endpoints-harness.test.mjs +61 -5
- package/tests/image-payload-hardening-harness.test.mjs +115 -0
- package/tests/mobile-static.test.mjs +79 -20
- package/tests/pi-footer-calibration-static.test.mjs +55 -0
- package/tests/remote-auth-settings-harness.test.mjs +1 -1
- package/tests/runtime-error-visibility.test.mjs +63 -0
- package/tests/side-panel-context-menu-static.test.mjs +74 -0
- package/tests/webui-output-mode.test.mjs +73 -0
package/public/app.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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";
|
|
4
5
|
|
|
5
6
|
const $ = (selector) => document.querySelector(selector);
|
|
6
7
|
|
|
@@ -72,6 +73,7 @@ const elements = {
|
|
|
72
73
|
busyPromptBehaviorTag: $("#busyPromptBehaviorTag"),
|
|
73
74
|
busyPromptBehaviorMenu: $("#busyPromptBehaviorMenu"),
|
|
74
75
|
sessionSkillTags: $("#sessionSkillTags"),
|
|
76
|
+
featureCategoryTag: $("#featureCategoryTag"),
|
|
75
77
|
conversationModeChip: $("#conversationModeChip"),
|
|
76
78
|
workflowModeChip: $("#workflowModeChip"),
|
|
77
79
|
skillEditorDialog: $("#skillEditorDialog"),
|
|
@@ -163,6 +165,9 @@ const elements = {
|
|
|
163
165
|
setThinkingButton: $("#setThinkingButton"),
|
|
164
166
|
thinkingVisibilityToggle: $("#thinkingVisibilityToggle"),
|
|
165
167
|
thinkingVisibilityStatus: $("#thinkingVisibilityStatus"),
|
|
168
|
+
fastOutputModeSelect: $("#fastOutputModeSelect"),
|
|
169
|
+
setFastOutputModeButton: $("#setFastOutputModeButton"),
|
|
170
|
+
fastOutputModeStatus: $("#fastOutputModeStatus"),
|
|
166
171
|
terminalTabsLayoutSelect: $("#terminalTabsLayoutSelect"),
|
|
167
172
|
terminalTabsLayoutStatus: $("#terminalTabsLayoutStatus"),
|
|
168
173
|
themeControlLabel: $("#themeControlLabel"),
|
|
@@ -225,6 +230,7 @@ const elements = {
|
|
|
225
230
|
fileSelectionCommentInput: $("#fileSelectionCommentInput"),
|
|
226
231
|
fileSelectionSendButton: $("#fileSelectionSendButton"),
|
|
227
232
|
fileContextMenu: $("#fileContextMenu"),
|
|
233
|
+
sidePanelContextMenu: $("#sidePanelContextMenu"),
|
|
228
234
|
toggleSidePanelButton: $("#toggleSidePanelButton"),
|
|
229
235
|
sidePanelExpandButton: $("#sidePanelExpandButton"),
|
|
230
236
|
sidePanelBackdrop: $("#sidePanelBackdrop"),
|
|
@@ -364,6 +370,7 @@ let fileTreeState = { root: "", entriesByPath: new Map(), expanded: new Set(), l
|
|
|
364
370
|
let activeFileViewer = null;
|
|
365
371
|
let fileViewerSelection = null;
|
|
366
372
|
let fileContextMenuState = null;
|
|
373
|
+
let sidePanelContextMenuState = null;
|
|
367
374
|
let fileTreeDragState = null;
|
|
368
375
|
let fileViewerResizeState = null;
|
|
369
376
|
let fileTreeSearchTimer = null;
|
|
@@ -390,6 +397,19 @@ let streamToolCallComplete = false;
|
|
|
390
397
|
let streamThinkingBubble = null;
|
|
391
398
|
let streamThinking = null;
|
|
392
399
|
let streamMessageActive = false;
|
|
400
|
+
let streamProviderErrorText = "";
|
|
401
|
+
let compactLiveState = createFastOutputLiveState();
|
|
402
|
+
let compactTextBubble = null;
|
|
403
|
+
let compactTextNode = null;
|
|
404
|
+
let compactThinkingBubble = null;
|
|
405
|
+
let compactThinkingNode = null;
|
|
406
|
+
const compactToolShells = new Map();
|
|
407
|
+
let activeOutputMode = "normal";
|
|
408
|
+
let outputModeAcknowledged = false;
|
|
409
|
+
let eventSourceOutputModeRequest = "auto";
|
|
410
|
+
let eventSourceOutputModeFallbackAttempted = false;
|
|
411
|
+
const compactLiveScheduler = createSustainedFlushScheduler({ flush: () => flushCompactLiveOutput() });
|
|
412
|
+
let assistantErrorSurfacedThisRun = false;
|
|
393
413
|
let runIndicatorBubble = null;
|
|
394
414
|
let runIndicatorText = null;
|
|
395
415
|
let runIndicatorMeta = null;
|
|
@@ -615,6 +635,7 @@ const dialogQueue = [];
|
|
|
615
635
|
const SIDE_PANEL_STORAGE_KEY = "pi-webui-side-panel-collapsed";
|
|
616
636
|
const INTERFACE_DENSITY_STORAGE_KEY = "pi-webui-interface-density";
|
|
617
637
|
const SIDE_PANEL_SECTION_STORAGE_KEY = "pi-webui-side-panel-sections-collapsed";
|
|
638
|
+
const SIDE_PANEL_SECTION_VISIBILITY_STORAGE_KEY = "pi-webui-side-panel-sections-hidden";
|
|
618
639
|
const TAB_STORAGE_KEY = "pi-webui-active-tab";
|
|
619
640
|
const PATH_FAST_PICKS_STORAGE_KEY = "pi-webui-path-fast-picks";
|
|
620
641
|
const AGENT_DONE_NOTIFICATIONS_STORAGE_KEY = "pi-webui-agent-done-notifications";
|
|
@@ -718,6 +739,7 @@ const WORKFLOW_INSPECTOR_PAYLOAD_PREFIX = "WORKFLOW_RPC_PAYLOAD ";
|
|
|
718
739
|
const WORKFLOW_INSPECTOR_PAYLOAD_TYPE = "firstpick.pi-extension-workflows.inspector";
|
|
719
740
|
const WORKFLOW_INSPECTOR_PAYLOAD_VERSION = 1;
|
|
720
741
|
const WORKFLOW_MODE_STATUS_KEY = "workflow-mode";
|
|
742
|
+
const FEATURE_CATEGORY_STATUS_KEY = "feature-category";
|
|
721
743
|
const WORKFLOW_MODE_RPC_WIDGET_KEY = "workflow-mode:rpc";
|
|
722
744
|
const WORKFLOW_MODE_RPC_PAYLOAD_PREFIX = "WORKFLOW_MODE_RPC_PAYLOAD ";
|
|
723
745
|
const WORKFLOW_MODE_RPC_PAYLOAD_TYPE = "firstpick.pi-extension-workflows.mode";
|
|
@@ -822,18 +844,22 @@ const initialUrlParams = new URLSearchParams(window.location.search);
|
|
|
822
844
|
const embeddedSplitMode = initialUrlParams.get("embed") === "split";
|
|
823
845
|
document.body.classList.toggle("embedded-split", embeddedSplitMode);
|
|
824
846
|
const statusEntries = new Map();
|
|
847
|
+
const featureCategoryByTab = new Map();
|
|
825
848
|
const widgets = new Map();
|
|
826
849
|
const widgetsByTab = new Map();
|
|
827
850
|
const todoProgressWidgetExpandedByTab = new Map();
|
|
828
851
|
const todoProgressGoalByTab = new Map();
|
|
829
852
|
const todoProgressSignatureByTab = new Map();
|
|
830
853
|
const releaseNpmOutputExpandedByTab = new Map();
|
|
854
|
+
const workflowTerminalScrollByTab = new Map();
|
|
855
|
+
const workflowSubprocessMinimizedByTab = new Set();
|
|
831
856
|
const appRunnerDataByTab = new Map();
|
|
832
857
|
const conversationModeByTab = new Map();
|
|
833
858
|
const workflowModeByTab = new Map();
|
|
834
859
|
const workflowModeTogglePendingByTab = new Set();
|
|
835
860
|
const workflowInspectorByTab = new Map();
|
|
836
861
|
const workflowInspectorSelectionByTab = new Map();
|
|
862
|
+
const workflowInspectorMinimizedByTab = new Set();
|
|
837
863
|
const appRunnerInputDraftByRun = new Map();
|
|
838
864
|
const appRunnerContextLineDraftByRun = new Map();
|
|
839
865
|
const liveToolRuns = new Map();
|
|
@@ -1066,6 +1092,10 @@ const SETTINGS_DOUBLE_ESCAPE_OPTIONS = [
|
|
|
1066
1092
|
{ value: "none", label: "do nothing" },
|
|
1067
1093
|
];
|
|
1068
1094
|
const SETTINGS_TREE_FILTER_OPTIONS = ["default", "no-tools", "user-only", "labeled-only", "all"];
|
|
1095
|
+
const SETTINGS_OUTPUT_MODE_OPTIONS = [
|
|
1096
|
+
{ value: "normal", label: "normal" },
|
|
1097
|
+
{ value: "compact-v1", label: "compact-v1" },
|
|
1098
|
+
];
|
|
1069
1099
|
const SETTINGS_IMAGE_WIDTH_OPTIONS = ["60", "80", "120"];
|
|
1070
1100
|
const SETTINGS_EDITOR_PADDING_OPTIONS = ["0", "1", "2", "3"];
|
|
1071
1101
|
const SETTINGS_AUTOCOMPLETE_OPTIONS = ["3", "5", "7", "10", "15", "20"];
|
|
@@ -1152,6 +1182,7 @@ function createGitWorkflowState() {
|
|
|
1152
1182
|
manualCommitMessage: "",
|
|
1153
1183
|
...resetGitWorkflowManualCommitDefaultPatch(),
|
|
1154
1184
|
messageRequestedAt: 0,
|
|
1185
|
+
messageGenerationId: "",
|
|
1155
1186
|
branchName: "",
|
|
1156
1187
|
branchNameRequestedAt: 0,
|
|
1157
1188
|
actionsDone: createGitWorkflowActionsDone(),
|
|
@@ -1167,6 +1198,7 @@ function createGitWorkflowState() {
|
|
|
1167
1198
|
}
|
|
1168
1199
|
|
|
1169
1200
|
const gitWorkflowsByTab = new Map();
|
|
1201
|
+
const gitWorkflowMessageLoadsByTab = new Map();
|
|
1170
1202
|
let gitWorkflow = createGitWorkflowState();
|
|
1171
1203
|
let gitWorkflowPreferences = null;
|
|
1172
1204
|
|
|
@@ -1527,6 +1559,46 @@ function persistSidePanelSectionState() {
|
|
|
1527
1559
|
}
|
|
1528
1560
|
}
|
|
1529
1561
|
|
|
1562
|
+
function readStoredSidePanelSectionHiddenIds() {
|
|
1563
|
+
try {
|
|
1564
|
+
const stored = localStorage.getItem(SIDE_PANEL_SECTION_VISIBILITY_STORAGE_KEY);
|
|
1565
|
+
if (stored === null) return new Set();
|
|
1566
|
+
const parsed = JSON.parse(stored);
|
|
1567
|
+
return new Set(Array.isArray(parsed) ? parsed.filter((value) => typeof value === "string") : []);
|
|
1568
|
+
} catch {
|
|
1569
|
+
return new Set();
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
function persistSidePanelSectionVisibility() {
|
|
1574
|
+
try {
|
|
1575
|
+
const hidden = sidePanelSectionRecords()
|
|
1576
|
+
.filter(({ section }) => section.hidden)
|
|
1577
|
+
.map(({ id }) => id);
|
|
1578
|
+
localStorage.setItem(SIDE_PANEL_SECTION_VISIBILITY_STORAGE_KEY, JSON.stringify(hidden));
|
|
1579
|
+
} catch {
|
|
1580
|
+
// Ignore storage failures; visibility toggles should still work for this page load.
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
function setSidePanelSectionVisible(record, visible, { persist = true } = {}) {
|
|
1585
|
+
record.section.hidden = !visible;
|
|
1586
|
+
if (visible && record.id === "git" && !record.section.classList.contains("collapsed")) {
|
|
1587
|
+
queueMicrotask(() => {
|
|
1588
|
+
renderGitPanel();
|
|
1589
|
+
ensureGitPanelRepositoriesDiscovered({ retryUnavailable: true });
|
|
1590
|
+
});
|
|
1591
|
+
}
|
|
1592
|
+
if (persist) persistSidePanelSectionVisibility();
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
function restoreSidePanelSectionVisibility() {
|
|
1596
|
+
const hiddenIds = readStoredSidePanelSectionHiddenIds();
|
|
1597
|
+
for (const record of sidePanelSectionRecords()) {
|
|
1598
|
+
setSidePanelSectionVisible(record, !hiddenIds.has(record.id), { persist: false });
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1530
1602
|
function setSidePanelSectionCollapsed(record, collapsed, { persist = true } = {}) {
|
|
1531
1603
|
const label = record.button.querySelector(".side-panel-section-label")?.textContent?.trim() || "side panel";
|
|
1532
1604
|
record.section.classList.toggle("collapsed", collapsed);
|
|
@@ -1534,7 +1606,7 @@ function setSidePanelSectionCollapsed(record, collapsed, { persist = true } = {}
|
|
|
1534
1606
|
record.button.setAttribute("aria-expanded", collapsed ? "false" : "true");
|
|
1535
1607
|
record.button.setAttribute("aria-label", `${collapsed ? "Expand" : "Collapse"} ${label} section`);
|
|
1536
1608
|
record.button.setAttribute("title", `${collapsed ? "Expand" : "Collapse"} ${label} section`);
|
|
1537
|
-
if (!collapsed && record.id === "git") {
|
|
1609
|
+
if (!collapsed && record.id === "git" && !record.section.hidden) {
|
|
1538
1610
|
queueMicrotask(() => {
|
|
1539
1611
|
renderGitPanel();
|
|
1540
1612
|
ensureGitPanelRepositoriesDiscovered({ retryUnavailable: true });
|
|
@@ -1561,6 +1633,58 @@ function restoreSidePanelSectionState() {
|
|
|
1561
1633
|
}
|
|
1562
1634
|
}
|
|
1563
1635
|
|
|
1636
|
+
function closeSidePanelContextMenu({ returnFocus = true } = {}) {
|
|
1637
|
+
const trigger = sidePanelContextMenuState?.trigger;
|
|
1638
|
+
sidePanelContextMenuState = null;
|
|
1639
|
+
if (elements.sidePanelContextMenu) elements.sidePanelContextMenu.hidden = true;
|
|
1640
|
+
if (!returnFocus) return;
|
|
1641
|
+
const focusTarget = trigger?.isConnected && !trigger.closest?.("[data-side-panel-section][hidden]")
|
|
1642
|
+
? trigger
|
|
1643
|
+
: elements.toggleSidePanelButton;
|
|
1644
|
+
if (focusTarget?.isConnected) queueMicrotask(() => focusTarget.focus?.({ preventScroll: true }));
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
function showSidePanelContextMenu(event) {
|
|
1648
|
+
if (!elements.sidePanelContextMenu) return;
|
|
1649
|
+
if (event.target?.closest?.("a, input, textarea, select, [contenteditable='true']")) return;
|
|
1650
|
+
event.preventDefault();
|
|
1651
|
+
event.stopPropagation();
|
|
1652
|
+
closeFileContextMenu({ returnFocus: false });
|
|
1653
|
+
closeGitPanelContextMenu({ returnFocus: false });
|
|
1654
|
+
closeSidePanelContextMenu({ returnFocus: false });
|
|
1655
|
+
|
|
1656
|
+
const menu = elements.sidePanelContextMenu;
|
|
1657
|
+
const eventTrigger = event.currentTarget;
|
|
1658
|
+
const trigger = eventTrigger && eventTrigger !== elements.sidePanel ? eventTrigger : document.activeElement;
|
|
1659
|
+
sidePanelContextMenuState = { trigger: trigger?.focus ? trigger : elements.toggleSidePanelButton };
|
|
1660
|
+
const label = make("div", "side-panel-context-menu-label", "Show sections");
|
|
1661
|
+
label.setAttribute("role", "presentation");
|
|
1662
|
+
label.setAttribute("aria-hidden", "true");
|
|
1663
|
+
const items = sidePanelSectionRecords().map((record) => {
|
|
1664
|
+
const sectionLabel = record.button.querySelector(".side-panel-section-label")?.textContent?.trim() || record.id;
|
|
1665
|
+
const button = make("button", "side-panel-context-menu-item", sectionLabel);
|
|
1666
|
+
const visible = !record.section.hidden;
|
|
1667
|
+
button.type = "button";
|
|
1668
|
+
button.setAttribute("role", "menuitemcheckbox");
|
|
1669
|
+
button.setAttribute("aria-checked", visible ? "true" : "false");
|
|
1670
|
+
button.dataset.sidePanelSectionVisibility = record.id;
|
|
1671
|
+
button.addEventListener("click", () => {
|
|
1672
|
+
const nextVisible = record.section.hidden;
|
|
1673
|
+
setSidePanelSectionVisible(record, nextVisible);
|
|
1674
|
+
button.setAttribute("aria-checked", nextVisible ? "true" : "false");
|
|
1675
|
+
});
|
|
1676
|
+
return button;
|
|
1677
|
+
});
|
|
1678
|
+
menu.replaceChildren(label, ...items);
|
|
1679
|
+
menu.hidden = false;
|
|
1680
|
+
const rect = menu.getBoundingClientRect();
|
|
1681
|
+
const left = Math.min(event.clientX, Math.max(8, window.innerWidth - rect.width - 8));
|
|
1682
|
+
const top = Math.min(event.clientY, Math.max(8, window.innerHeight - rect.height - 8));
|
|
1683
|
+
menu.style.left = `${Math.max(8, left)}px`;
|
|
1684
|
+
menu.style.top = `${Math.max(8, top)}px`;
|
|
1685
|
+
menu.querySelector('[role="menuitemcheckbox"]')?.focus({ preventScroll: true });
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1564
1688
|
function bindSidePanelSectionToggles() {
|
|
1565
1689
|
for (const record of sidePanelSectionRecords()) {
|
|
1566
1690
|
record.button.addEventListener("click", () => {
|
|
@@ -1573,6 +1697,23 @@ function bindSidePanelSectionToggles() {
|
|
|
1573
1697
|
}
|
|
1574
1698
|
}
|
|
1575
1699
|
|
|
1700
|
+
function bindSidePanelContextMenu() {
|
|
1701
|
+
elements.sidePanel?.addEventListener("contextmenu", showSidePanelContextMenu);
|
|
1702
|
+
elements.sidePanel?.addEventListener("keydown", (event) => {
|
|
1703
|
+
if (event.key !== "ContextMenu" && !(event.shiftKey && event.key === "F10")) return;
|
|
1704
|
+
const trigger = event.target instanceof Element ? event.target : elements.sidePanel;
|
|
1705
|
+
const rect = trigger.getBoundingClientRect();
|
|
1706
|
+
showSidePanelContextMenu({
|
|
1707
|
+
preventDefault: () => event.preventDefault(),
|
|
1708
|
+
stopPropagation: () => event.stopPropagation(),
|
|
1709
|
+
clientX: rect.left + Math.min(rect.width, 24),
|
|
1710
|
+
clientY: rect.bottom,
|
|
1711
|
+
currentTarget: trigger,
|
|
1712
|
+
target: trigger,
|
|
1713
|
+
});
|
|
1714
|
+
});
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1576
1717
|
function readStoredAgentDoneNotificationsEnabled() {
|
|
1577
1718
|
try {
|
|
1578
1719
|
return localStorage.getItem(AGENT_DONE_NOTIFICATIONS_STORAGE_KEY) === "1";
|
|
@@ -2246,6 +2387,28 @@ function renderSessionSkillTags(tabId = activeTabId) {
|
|
|
2246
2387
|
container.hidden = false;
|
|
2247
2388
|
}
|
|
2248
2389
|
|
|
2390
|
+
function normalizeFeatureCategory(value) {
|
|
2391
|
+
return value === "lightweight-feature" || value === "complex-feature" ? value : "";
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
function renderFeatureCategoryTag(tabId = activeTabId) {
|
|
2395
|
+
const tag = elements.featureCategoryTag;
|
|
2396
|
+
if (!tag) return;
|
|
2397
|
+
const category = normalizeFeatureCategory(featureCategoryByTab.get(tabId));
|
|
2398
|
+
tag.hidden = !category;
|
|
2399
|
+
tag.textContent = category;
|
|
2400
|
+
tag.classList.toggle("lightweight-feature", category === "lightweight-feature");
|
|
2401
|
+
tag.classList.toggle("complex-feature", category === "complex-feature");
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
function handleFeatureCategoryStatus(statusText, tabId = activeTabId) {
|
|
2405
|
+
if (!tabId) return;
|
|
2406
|
+
const category = normalizeFeatureCategory(statusText);
|
|
2407
|
+
if (category) featureCategoryByTab.set(tabId, category);
|
|
2408
|
+
else featureCategoryByTab.delete(tabId);
|
|
2409
|
+
if (tabId === activeTabId) renderFeatureCategoryTag(tabId);
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2249
2412
|
function trackSkillUsage(tabId, skillName, kind = "used", source = "", details = {}) {
|
|
2250
2413
|
const name = normalizeSkillName(skillName);
|
|
2251
2414
|
if (!tabId || !name) return;
|
|
@@ -2931,6 +3094,7 @@ function setSidePanelCollapsed(collapsed, { persist = true, focusPanel = false }
|
|
|
2931
3094
|
elements.toggleSidePanelButton.setAttribute("aria-label", collapsed ? "Expand side panel" : "Collapse side panel");
|
|
2932
3095
|
elements.sidePanelExpandButton.setAttribute("aria-expanded", collapsed ? "false" : "true");
|
|
2933
3096
|
syncMobileSidePanelState(collapsed);
|
|
3097
|
+
if (collapsed) closeSidePanelContextMenu({ returnFocus: false });
|
|
2934
3098
|
|
|
2935
3099
|
if (!collapsed && focusPanel && isSidePanelOverlayView()) {
|
|
2936
3100
|
requestAnimationFrame(() => elements.toggleSidePanelButton.focus());
|
|
@@ -3571,6 +3735,9 @@ async function api(path, { method = "GET", body, tabId = activeTabId, scoped = t
|
|
|
3571
3735
|
signal,
|
|
3572
3736
|
});
|
|
3573
3737
|
} catch (error) {
|
|
3738
|
+
// Aborted autocomplete requests are expected while the user keeps typing;
|
|
3739
|
+
// they do not indicate that the Web UI backend became unreachable.
|
|
3740
|
+
if (signal?.aborted || error?.name === "AbortError") throw error;
|
|
3574
3741
|
const offlineError = error instanceof Error ? error : new Error(String(error));
|
|
3575
3742
|
offlineError.backendOffline = true;
|
|
3576
3743
|
setBackendOffline(true, offlineError);
|
|
@@ -6137,6 +6304,7 @@ function setActiveTabId(tabId, { remember = false } = {}) {
|
|
|
6137
6304
|
if (nextTabId !== activeTabId) activeTabGeneration += 1;
|
|
6138
6305
|
activeTabId = nextTabId;
|
|
6139
6306
|
bindGitWorkflowToActiveTab();
|
|
6307
|
+
renderFeatureCategoryTag(nextTabId);
|
|
6140
6308
|
if (remember) rememberActiveTab();
|
|
6141
6309
|
return activeTabContext(nextTabId);
|
|
6142
6310
|
}
|
|
@@ -6634,6 +6802,7 @@ function showFileContextMenu(event, entry) {
|
|
|
6634
6802
|
event.preventDefault();
|
|
6635
6803
|
event.stopPropagation();
|
|
6636
6804
|
closeGitPanelContextMenu({ returnFocus: false });
|
|
6805
|
+
closeSidePanelContextMenu({ returnFocus: false });
|
|
6637
6806
|
const path = normalizeFileTreePath(entry?.path || "");
|
|
6638
6807
|
fileContextMenuState = { entry: { ...entry, path }, trigger: event.currentTarget || document.activeElement };
|
|
6639
6808
|
const menu = elements.fileContextMenu;
|
|
@@ -7574,6 +7743,7 @@ function syncTabMetadata(nextTabs = []) {
|
|
|
7574
7743
|
suppressPendingAgentDoneNotificationsForTab(tabId, { markSeen: false });
|
|
7575
7744
|
actionFeedbackByTab.delete(tabId);
|
|
7576
7745
|
skillUsageByTab.delete(tabId);
|
|
7746
|
+
featureCategoryByTab.delete(tabId);
|
|
7577
7747
|
tabMessagesCache.delete(tabId);
|
|
7578
7748
|
widgetsByTab.delete(tabId);
|
|
7579
7749
|
appRunnerDataByTab.delete(tabId);
|
|
@@ -7582,6 +7752,8 @@ function syncTabMetadata(nextTabs = []) {
|
|
|
7582
7752
|
workflowModeTogglePendingByTab.delete(tabId);
|
|
7583
7753
|
workflowInspectorByTab.delete(tabId);
|
|
7584
7754
|
workflowInspectorSelectionByTab.delete(tabId);
|
|
7755
|
+
workflowInspectorMinimizedByTab.delete(tabId);
|
|
7756
|
+
workflowSubprocessMinimizedByTab.delete(tabId);
|
|
7585
7757
|
remoteMicConsentTabs.delete(tabId);
|
|
7586
7758
|
if (voiceConversationTabId === tabId) stopVoiceConversationLoop();
|
|
7587
7759
|
clearGitWorkflowForTab(tabId);
|
|
@@ -8114,7 +8286,7 @@ function terminalDisplayGroupDetail(group, fallback = "group") {
|
|
|
8114
8286
|
|
|
8115
8287
|
function gitPanelSectionExpanded() {
|
|
8116
8288
|
const section = elements.sidePanel?.querySelector('[data-side-panel-section="git"]');
|
|
8117
|
-
return Boolean(section && !section.classList.contains("collapsed"));
|
|
8289
|
+
return Boolean(section && !section.hidden && !section.classList.contains("collapsed"));
|
|
8118
8290
|
}
|
|
8119
8291
|
|
|
8120
8292
|
function gitPanelTerminalGroups() {
|
|
@@ -8229,33 +8401,68 @@ async function loadGitPanelRepository(card, { force = false } = {}) {
|
|
|
8229
8401
|
if (!card?.root || !card.tabId) return;
|
|
8230
8402
|
const existing = gitPanelSnapshot(card.root);
|
|
8231
8403
|
if (!force && gitPanelSnapshotFresh(existing)) return;
|
|
8232
|
-
if (existing?.loading)
|
|
8404
|
+
if (existing?.loading) {
|
|
8405
|
+
if (force && !existing.refreshPending) {
|
|
8406
|
+
gitPanelState.repositories.set(card.root, { ...existing, refreshPending: true });
|
|
8407
|
+
}
|
|
8408
|
+
return;
|
|
8409
|
+
}
|
|
8233
8410
|
const requestSerial = ++gitPanelState.requestSerial;
|
|
8234
|
-
gitPanelState.repositories.set(card.root, { ...existing, loading: true, error: "", requestSerial });
|
|
8411
|
+
gitPanelState.repositories.set(card.root, { ...existing, loading: true, error: "", requestSerial, refreshPending: false });
|
|
8235
8412
|
renderGitPanel();
|
|
8413
|
+
let refreshAgain = false;
|
|
8236
8414
|
try {
|
|
8237
8415
|
const response = await api("/api/git-panel", { tabId: card.tabId });
|
|
8238
8416
|
const latest = gitPanelSnapshot(card.root);
|
|
8239
8417
|
if (latest?.requestSerial !== requestSerial) return;
|
|
8418
|
+
refreshAgain = latest.refreshPending === true;
|
|
8240
8419
|
if (!response.ok || !response.data?.root) throw new Error(response.error || "Failed to load Git repository");
|
|
8241
8420
|
gitPanelState.repositories.set(card.root, {
|
|
8242
8421
|
loading: false,
|
|
8243
8422
|
error: "",
|
|
8244
8423
|
requestSerial,
|
|
8245
8424
|
loadedAt: Date.now(),
|
|
8425
|
+
refreshPending: false,
|
|
8246
8426
|
data: response.data,
|
|
8247
8427
|
});
|
|
8248
8428
|
} catch (error) {
|
|
8249
8429
|
const latest = gitPanelSnapshot(card.root);
|
|
8250
8430
|
if (latest?.requestSerial !== requestSerial) return;
|
|
8431
|
+
refreshAgain = refreshAgain || latest.refreshPending === true;
|
|
8251
8432
|
gitPanelState.repositories.set(card.root, {
|
|
8252
8433
|
...latest,
|
|
8253
8434
|
loading: false,
|
|
8254
8435
|
error: error.message || String(error),
|
|
8255
8436
|
requestSerial,
|
|
8437
|
+
refreshPending: false,
|
|
8256
8438
|
});
|
|
8257
8439
|
}
|
|
8258
8440
|
renderGitPanel();
|
|
8441
|
+
if (refreshAgain) queueMicrotask(() => loadGitPanelRepository(card, { force: true }));
|
|
8442
|
+
}
|
|
8443
|
+
|
|
8444
|
+
function invalidateGitPanelRepository(root) {
|
|
8445
|
+
const repositoryRoot = String(root || "");
|
|
8446
|
+
const snapshot = gitPanelSnapshot(repositoryRoot);
|
|
8447
|
+
if (!snapshot) return;
|
|
8448
|
+
gitPanelState.repositories.set(repositoryRoot, {
|
|
8449
|
+
...snapshot,
|
|
8450
|
+
error: "",
|
|
8451
|
+
loadedAt: 0,
|
|
8452
|
+
refreshPending: snapshot.loading === true,
|
|
8453
|
+
});
|
|
8454
|
+
if (!gitPanelSectionExpanded()) return;
|
|
8455
|
+
const card = gitPanelRepositoryCards().find((candidate) => candidate.root === repositoryRoot);
|
|
8456
|
+
if (card) void loadGitPanelRepository(card, { force: true });
|
|
8457
|
+
}
|
|
8458
|
+
|
|
8459
|
+
function ensureGitPanelVisibleRepositoriesFresh(cards = gitPanelRepositoryCards()) {
|
|
8460
|
+
for (const card of cards) {
|
|
8461
|
+
const snapshot = gitPanelSnapshot(card.root);
|
|
8462
|
+
const expanded = gitPanelState.expandedCardKey === card.key;
|
|
8463
|
+
if (snapshot?.loading || snapshot?.error || (!snapshot?.data && !expanded) || gitPanelSnapshotFresh(snapshot)) continue;
|
|
8464
|
+
void loadGitPanelRepository(card);
|
|
8465
|
+
}
|
|
8259
8466
|
}
|
|
8260
8467
|
|
|
8261
8468
|
function toggleGitPanelRepository(card) {
|
|
@@ -8343,6 +8550,7 @@ function showGitPanelContextMenu(event, context) {
|
|
|
8343
8550
|
event.stopPropagation();
|
|
8344
8551
|
closeFileContextMenu({ returnFocus: false });
|
|
8345
8552
|
closeGitPanelContextMenu({ returnFocus: false });
|
|
8553
|
+
closeSidePanelContextMenu({ returnFocus: false });
|
|
8346
8554
|
const menu = elements.gitPanelContextMenu;
|
|
8347
8555
|
const items = gitPanelContextMenuItems(context);
|
|
8348
8556
|
if (!items.length) return;
|
|
@@ -8437,7 +8645,7 @@ async function runGitPanelAction(card, action, path = "") {
|
|
|
8437
8645
|
function renderGitPanelFolder(node, card, category, depth = 0) {
|
|
8438
8646
|
const details = make("details", "git-side-panel-folder");
|
|
8439
8647
|
const folderKey = `${card.root}\u0000${category}\u0000${node.path}`;
|
|
8440
|
-
const defaultOpen =
|
|
8648
|
+
const defaultOpen = true;
|
|
8441
8649
|
details.open = gitPanelState.openFolders.has(folderKey) ? gitPanelState.openFolders.get(folderKey) : defaultOpen;
|
|
8442
8650
|
details.addEventListener("toggle", () => {
|
|
8443
8651
|
if (details.open === defaultOpen) gitPanelState.openFolders.delete(folderKey);
|
|
@@ -8671,6 +8879,7 @@ function renderGitPanel() {
|
|
|
8671
8879
|
});
|
|
8672
8880
|
if (signature === gitPanelRenderSignature && elements.gitPanelGroups.childElementCount === cards.length) {
|
|
8673
8881
|
ensureGitPanelRepositoriesDiscovered();
|
|
8882
|
+
ensureGitPanelVisibleRepositoriesFresh(cards);
|
|
8674
8883
|
return;
|
|
8675
8884
|
}
|
|
8676
8885
|
gitPanelRenderSignature = signature;
|
|
@@ -8687,6 +8896,7 @@ function renderGitPanel() {
|
|
|
8687
8896
|
: `${repositoryCount} Git ${repositoryCount === 1 ? "repository" : "repositories"} · Right-click for actions`;
|
|
8688
8897
|
}
|
|
8689
8898
|
ensureGitPanelRepositoriesDiscovered();
|
|
8899
|
+
ensureGitPanelVisibleRepositoriesFresh(cards);
|
|
8690
8900
|
}
|
|
8691
8901
|
|
|
8692
8902
|
function tabAppRunnerRun(tab) {
|
|
@@ -9287,6 +9497,7 @@ async function closeTerminalTabs(tabIds, { label = "selected terminal tabs" } =
|
|
|
9287
9497
|
tabDrafts.delete(id);
|
|
9288
9498
|
clearAttachments(id);
|
|
9289
9499
|
clearGitWorkflowForTab(id);
|
|
9500
|
+
featureCategoryByTab.delete(id);
|
|
9290
9501
|
commandCatalogsByTab.delete(id);
|
|
9291
9502
|
appRunnerDataByTab.delete(id);
|
|
9292
9503
|
tabMessagesCache.delete(id);
|
|
@@ -10027,7 +10238,7 @@ async function toggleFooterAutoCompaction(tabContext = activeTabContext()) {
|
|
|
10027
10238
|
}
|
|
10028
10239
|
}
|
|
10029
10240
|
|
|
10030
|
-
function scheduleGitFooterPiCalibrationRefresh(tabContext, delays = [
|
|
10241
|
+
function scheduleGitFooterPiCalibrationRefresh(tabContext, delays = [5000, 14000, 30000]) {
|
|
10031
10242
|
for (const delayMs of delays) {
|
|
10032
10243
|
setTimeout(() => {
|
|
10033
10244
|
if (isCurrentTabContext(tabContext)) requestGitFooterWebuiPayload(tabContext, { force: true });
|
|
@@ -10035,7 +10246,8 @@ function scheduleGitFooterPiCalibrationRefresh(tabContext, delays = [600, 1600])
|
|
|
10035
10246
|
}
|
|
10036
10247
|
}
|
|
10037
10248
|
|
|
10038
|
-
|
|
10249
|
+
|
|
10250
|
+
async function runGitFooterPiCalibration(tabContext = activeTabContext()) {
|
|
10039
10251
|
if (!tabContext.tabId) return;
|
|
10040
10252
|
if (gitFooterPiCalibrationInFlightByTab.has(tabContext.tabId)) return;
|
|
10041
10253
|
if (currentState?.isStreaming || currentState?.isCompacting) {
|
|
@@ -10048,16 +10260,14 @@ async function runGitFooterPiCalibration(mode = "current", tabContext = activeTa
|
|
|
10048
10260
|
addEvent("PI calibration unavailable: /calibrate is not loaded in this Pi tab.", "warn");
|
|
10049
10261
|
return;
|
|
10050
10262
|
}
|
|
10051
|
-
if (mode === "probe" && !(await appConfirmText("Start an isolated PI calibration probe? This sends one tiny model request and may incur provider token usage.", { affected: "Provider token allowance and this tab's calibration result", confirmLabel: "Start probe", danger: false }))) return;
|
|
10052
10263
|
|
|
10053
|
-
const command = mode === "probe" ? `/${commandName}` : `/${commandName} current`;
|
|
10054
10264
|
gitFooterPiCalibrationInFlightByTab.add(tabContext.tabId);
|
|
10055
10265
|
renderFooter();
|
|
10056
10266
|
try {
|
|
10057
|
-
await sendPrompt("prompt",
|
|
10267
|
+
await sendPrompt("prompt", `/${commandName}`, { targetTabId: tabContext.tabId, throwOnError: true });
|
|
10268
|
+
scheduleGitFooterPiCalibrationRefresh(tabContext);
|
|
10058
10269
|
if (!isCurrentTabContext(tabContext)) return;
|
|
10059
|
-
addEvent(
|
|
10060
|
-
scheduleGitFooterPiCalibrationRefresh(tabContext, mode === "probe" ? [5000, 14000] : [600, 1600]);
|
|
10270
|
+
addEvent("PI calibration started in the background; refreshing the footer value after it records…", "info");
|
|
10061
10271
|
} catch (error) {
|
|
10062
10272
|
if (isCurrentTabContext(tabContext)) addEvent(error.message || String(error), "error");
|
|
10063
10273
|
} finally {
|
|
@@ -10067,16 +10277,16 @@ async function runGitFooterPiCalibration(mode = "current", tabContext = activeTa
|
|
|
10067
10277
|
}
|
|
10068
10278
|
|
|
10069
10279
|
function applyGitFooterPiCalibrationOptions(chip, options) {
|
|
10070
|
-
if (chip?.key !== "pi"
|
|
10280
|
+
if (chip?.key !== "pi") return "";
|
|
10071
10281
|
const tabContext = activeTabContext();
|
|
10072
10282
|
const busy = !!tabContext.tabId && gitFooterPiCalibrationInFlightByTab.has(tabContext.tabId);
|
|
10073
|
-
|
|
10074
|
-
|
|
10283
|
+
options.onClick = () => {
|
|
10284
|
+
void runGitFooterPiCalibration();
|
|
10285
|
+
};
|
|
10075
10286
|
if (busy) options.ariaBusy = true;
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
|
|
10079
|
-
: "Click to calibrate this uncalibrated PI estimate from the current session, then refresh this value.";
|
|
10287
|
+
return busy
|
|
10288
|
+
? "Calibrating PI estimate in the background and refreshing this value…"
|
|
10289
|
+
: "Click to run /calibrate in the background and refresh this PI token count.";
|
|
10080
10290
|
}
|
|
10081
10291
|
|
|
10082
10292
|
function applyGitFooterContextToggleOptions(chip, options) {
|
|
@@ -10305,6 +10515,43 @@ function applyFooterContextUsage(node, contextUsage) {
|
|
|
10305
10515
|
return node;
|
|
10306
10516
|
}
|
|
10307
10517
|
|
|
10518
|
+
const FOOTER_MIDDLE_TRUNCATION_END_CHARS = 16;
|
|
10519
|
+
const FOOTER_MIDDLE_TRUNCATION_MIN_START_CHARS = 6;
|
|
10520
|
+
|
|
10521
|
+
function splitMiddleTruncationText(value, endChars = FOOTER_MIDDLE_TRUNCATION_END_CHARS) {
|
|
10522
|
+
const characters = Array.from(String(value ?? ""));
|
|
10523
|
+
const minimumSuffixLength = Math.max(0, Math.min(Math.trunc(Number(endChars) || 0), characters.length));
|
|
10524
|
+
if (!minimumSuffixLength) return { start: characters.join(""), end: "" };
|
|
10525
|
+
let componentEnd = characters.length - 1;
|
|
10526
|
+
while (componentEnd >= 0 && (characters[componentEnd] === "/" || characters[componentEnd] === "\\")) componentEnd -= 1;
|
|
10527
|
+
let separatorIndex = -1;
|
|
10528
|
+
for (let index = componentEnd; index >= 0; index -= 1) {
|
|
10529
|
+
if (characters[index] === "/" || characters[index] === "\\") {
|
|
10530
|
+
separatorIndex = index;
|
|
10531
|
+
break;
|
|
10532
|
+
}
|
|
10533
|
+
}
|
|
10534
|
+
const componentSuffixLength = separatorIndex >= 0 ? characters.length - separatorIndex : 0;
|
|
10535
|
+
const suffixLength = Math.min(characters.length, Math.max(minimumSuffixLength, componentSuffixLength));
|
|
10536
|
+
if (!suffixLength || characters.length <= suffixLength + FOOTER_MIDDLE_TRUNCATION_MIN_START_CHARS) return { start: characters.join(""), end: "" };
|
|
10537
|
+
return { start: characters.slice(0, -suffixLength).join(""), end: characters.slice(-suffixLength).join("") };
|
|
10538
|
+
}
|
|
10539
|
+
|
|
10540
|
+
function setMiddleTruncatedText(node, value, endChars = FOOTER_MIDDLE_TRUNCATION_END_CHARS) {
|
|
10541
|
+
const parts = splitMiddleTruncationText(value, endChars);
|
|
10542
|
+
if (!parts.end) {
|
|
10543
|
+
node.classList.remove("middle-truncate-value");
|
|
10544
|
+
node.textContent = parts.start;
|
|
10545
|
+
return node;
|
|
10546
|
+
}
|
|
10547
|
+
node.classList.add("middle-truncate-value");
|
|
10548
|
+
node.replaceChildren(
|
|
10549
|
+
make("span", "middle-truncate-start", parts.start),
|
|
10550
|
+
make("span", "middle-truncate-end", parts.end),
|
|
10551
|
+
);
|
|
10552
|
+
return node;
|
|
10553
|
+
}
|
|
10554
|
+
|
|
10308
10555
|
function footerMeta(label, value, className = "", options = {}) {
|
|
10309
10556
|
const isAction = typeof options.onClick === "function";
|
|
10310
10557
|
const node = make(isAction ? "button" : "span", ["footer-meta", className, isAction ? "footer-meta-action" : ""].filter(Boolean).join(" "));
|
|
@@ -10318,7 +10565,10 @@ function footerMeta(label, value, className = "", options = {}) {
|
|
|
10318
10565
|
node.setAttribute("aria-disabled", "true");
|
|
10319
10566
|
}
|
|
10320
10567
|
}
|
|
10321
|
-
|
|
10568
|
+
const valueNode = make("span", "footer-meta-value");
|
|
10569
|
+
if (options.middleTruncate) setMiddleTruncatedText(valueNode, value);
|
|
10570
|
+
else valueNode.textContent = String(value ?? "");
|
|
10571
|
+
node.append(make("span", "footer-meta-label", label), valueNode);
|
|
10322
10572
|
return applyFooterTooltip(node, options.title || `${label}: ${value}`, { align: options.tooltipAlign });
|
|
10323
10573
|
}
|
|
10324
10574
|
|
|
@@ -10924,7 +11174,9 @@ function gitFooterTooltipAlign(chip) {
|
|
|
10924
11174
|
function footerTuiItem(value, className = "", options = {}) {
|
|
10925
11175
|
const text = cleanStatusText(value);
|
|
10926
11176
|
const isAction = typeof options.onClick === "function";
|
|
10927
|
-
const node = make(isAction ? "button" : "span", `footer-tui-item ${className}${isAction ? " footer-tui-action" : ""}`.trim()
|
|
11177
|
+
const node = make(isAction ? "button" : "span", `footer-tui-item ${className}${isAction ? " footer-tui-action" : ""}`.trim());
|
|
11178
|
+
if (options.middleTruncate) setMiddleTruncatedText(node, text);
|
|
11179
|
+
else node.textContent = text;
|
|
10928
11180
|
if (isAction) {
|
|
10929
11181
|
node.type = "button";
|
|
10930
11182
|
node.addEventListener("click", options.onClick);
|
|
@@ -10941,7 +11193,8 @@ function renderTuiFooterLine({ cwd, cwdTitle, message = "", stats = [], model =
|
|
|
10941
11193
|
line.append(footerTuiItem(cwd || "loading…", "footer-tui-cwd", tab ? {
|
|
10942
11194
|
onClick: changeActiveTabCwd,
|
|
10943
11195
|
title: cwdTitle || `Change cwd for ${tab.title}: ${cwd}`,
|
|
10944
|
-
|
|
11196
|
+
middleTruncate: true,
|
|
11197
|
+
} : { title: cwdTitle, middleTruncate: true }));
|
|
10945
11198
|
if (worktreeLabel) line.append(footerTuiItem(worktreeLabel, "footer-tui-worktree", { title: workspace?.worktreePath || worktreeLabel }));
|
|
10946
11199
|
if (message) line.append(footerTuiItem(message, "footer-tui-status"));
|
|
10947
11200
|
for (const stat of stats.filter(Boolean)) line.append(footerTuiItem(stat, "footer-tui-stat"));
|
|
@@ -11132,10 +11385,10 @@ function renderGitFooterPayloadMeta(chip, tab, payload) {
|
|
|
11132
11385
|
options.disabled = inFlight;
|
|
11133
11386
|
action = inFlight ? "Pushing local commits to the configured remote." : "Click to push local commits to the configured remote.";
|
|
11134
11387
|
} else if (chip.key === "changes" && visible("webui-changes-modal")) {
|
|
11135
|
-
options.onClick = openGitChangesDialog;
|
|
11388
|
+
options.onClick = () => openGitChangesDialog(tab?.id || activeTabId);
|
|
11136
11389
|
action = "Click to view the current git diff.";
|
|
11137
11390
|
} else if (chip.key === "git-state" && visible("webui-changes-modal")) {
|
|
11138
|
-
options.onClick = openGitChangesDialog;
|
|
11391
|
+
options.onClick = () => openGitChangesDialog(tab?.id || activeTabId);
|
|
11139
11392
|
action = "Click to open the conflicts and operation panel with continue/abort actions.";
|
|
11140
11393
|
} else if (chip.key === "git-extra" && visible("webui-git-tools-modal")) {
|
|
11141
11394
|
const toolsSection = gitToolsSectionForExtraChip(chip.value);
|
|
@@ -11151,6 +11404,7 @@ function renderGitFooterPayloadMeta(chip, tab, payload) {
|
|
|
11151
11404
|
action = (visible("webui-context-auto-compaction") ? applyGitFooterContextToggleOptions(chip, options) : "") || action;
|
|
11152
11405
|
options.title = gitFooterPayloadTooltip(chip, { action });
|
|
11153
11406
|
options.tooltipAlign = gitFooterTooltipAlign(chip);
|
|
11407
|
+
options.middleTruncate = chip.key === "cwd";
|
|
11154
11408
|
const node = footerMeta(chip.label, chip.value, footerMetaClassForPayload(chip), options);
|
|
11155
11409
|
applyFooterChangedFilesDropdown(node, chip, payload);
|
|
11156
11410
|
if (["git", "worktree"].includes(chip.key) && options.onClick && cleanFooterPayloadText(chip.value, "").toLowerCase() !== "no repo") {
|
|
@@ -11180,14 +11434,24 @@ function gitFooterPickerStateKey(payload) {
|
|
|
11180
11434
|
const tabContext = activeTabContext();
|
|
11181
11435
|
const refreshInFlight = tabContext.tabId ? gitFooterPayloadRefreshInFlightByTab.has(tabContext.tabId) : false;
|
|
11182
11436
|
const syncPushInFlight = tabContext.tabId ? gitFooterSyncPushInFlightByTab.has(tabContext.tabId) : false;
|
|
11437
|
+
const piCalibrationInFlight = tabContext.tabId ? gitFooterPiCalibrationInFlightByTab.has(tabContext.tabId) : false;
|
|
11183
11438
|
const refreshAvailable = hasLoadedRpcCommand("git-footer-refresh");
|
|
11184
|
-
return `${footerModelPickerOpen ? 1 : 0}|${footerThinkingPickerOpen ? 1 : 0}|${footerBranchPickerOpen ? 1 : 0}|${mobileFooterExpanded ? 1 : 0}|${refreshInFlight ? 1 : 0}|${syncPushInFlight ? 1 : 0}|${refreshAvailable ? 1 : 0}|${gitFooterPayloadVisibilityKey(payload)}`;
|
|
11439
|
+
return `${footerModelPickerOpen ? 1 : 0}|${footerThinkingPickerOpen ? 1 : 0}|${footerBranchPickerOpen ? 1 : 0}|${mobileFooterExpanded ? 1 : 0}|${refreshInFlight ? 1 : 0}|${syncPushInFlight ? 1 : 0}|${piCalibrationInFlight ? 1 : 0}|${refreshAvailable ? 1 : 0}|${gitFooterPayloadVisibilityKey(payload)}`;
|
|
11185
11440
|
}
|
|
11186
11441
|
|
|
11187
11442
|
function updateGitFooterChipNodeValue(node, chip, valueSelector) {
|
|
11188
11443
|
if (!node) return;
|
|
11189
11444
|
const valueNode = node.querySelector(valueSelector);
|
|
11190
|
-
|
|
11445
|
+
const nextValue = String(chip.value ?? "");
|
|
11446
|
+
const middleTruncate = chip.key === "cwd";
|
|
11447
|
+
const middleTruncateActive = middleTruncate && !!splitMiddleTruncationText(nextValue).end;
|
|
11448
|
+
if (valueNode && (valueNode.textContent !== nextValue || valueNode.classList.contains("middle-truncate-value") !== middleTruncateActive)) {
|
|
11449
|
+
if (middleTruncate) setMiddleTruncatedText(valueNode, nextValue);
|
|
11450
|
+
else {
|
|
11451
|
+
valueNode.classList.remove("middle-truncate-value");
|
|
11452
|
+
valueNode.textContent = nextValue;
|
|
11453
|
+
}
|
|
11454
|
+
}
|
|
11191
11455
|
if (chip.contextUsage) applyFooterContextUsage(node, chip.contextUsage);
|
|
11192
11456
|
}
|
|
11193
11457
|
|
|
@@ -12066,8 +12330,8 @@ async function loadGitChangesDialog(tabContext = activeTabContext()) {
|
|
|
12066
12330
|
function openGitChangesDialog(requestedTabId = activeTabId) {
|
|
12067
12331
|
if (!elements.gitChangesDialog) return;
|
|
12068
12332
|
hideFooterTooltip();
|
|
12069
|
-
const
|
|
12070
|
-
const
|
|
12333
|
+
const tabId = typeof requestedTabId === "string" && requestedTabId ? requestedTabId : activeTabId;
|
|
12334
|
+
const tabContext = activeTabContext(tabId);
|
|
12071
12335
|
if (gitToolsState.tabId !== tabId) resetGitToolsState(tabId);
|
|
12072
12336
|
gitChangesState = {
|
|
12073
12337
|
...gitChangesState,
|
|
@@ -16374,7 +16638,9 @@ function renderReleaseNpmOutputDetails(key, streamHeader, terminal, controls = n
|
|
|
16374
16638
|
node.open = releaseNpmOutputExpandedByTab.get(stateKey) !== false;
|
|
16375
16639
|
node.addEventListener("toggle", () => {
|
|
16376
16640
|
releaseNpmOutputExpandedByTab.set(stateKey, node.open);
|
|
16377
|
-
if (node.open
|
|
16641
|
+
if (node.open && terminal.dataset.preserveScrollOnToggle !== "true") {
|
|
16642
|
+
requestAnimationFrame(() => { terminal.scrollTop = terminal.scrollHeight; });
|
|
16643
|
+
}
|
|
16378
16644
|
});
|
|
16379
16645
|
|
|
16380
16646
|
const summary = make("summary", "release-npm-output-summary");
|
|
@@ -16681,6 +16947,18 @@ function workflowInspectorSetSelection(patch) {
|
|
|
16681
16947
|
renderWidgets();
|
|
16682
16948
|
}
|
|
16683
16949
|
|
|
16950
|
+
function workflowInspectorSetMinimized(minimized) {
|
|
16951
|
+
if (!activeTabId) return;
|
|
16952
|
+
const tabId = activeTabId;
|
|
16953
|
+
if (minimized) workflowInspectorMinimizedByTab.add(tabId);
|
|
16954
|
+
else workflowInspectorMinimizedByTab.delete(tabId);
|
|
16955
|
+
renderWidgets();
|
|
16956
|
+
requestAnimationFrame(() => {
|
|
16957
|
+
if (activeTabId !== tabId) return;
|
|
16958
|
+
elements.widgetArea.querySelector(".workflow-inspector-minimize-button")?.focus({ preventScroll: true });
|
|
16959
|
+
});
|
|
16960
|
+
}
|
|
16961
|
+
|
|
16684
16962
|
function workflowInspectorJson(value) {
|
|
16685
16963
|
if (value === undefined) return "—";
|
|
16686
16964
|
if (typeof value === "string") return value;
|
|
@@ -16744,9 +17022,13 @@ function renderWorkflowInspectorWidget() {
|
|
|
16744
17022
|
if (!payload?.runs?.length) return null;
|
|
16745
17023
|
const { run, phase } = workflowInspectorSelection(payload);
|
|
16746
17024
|
if (!run) return null;
|
|
17025
|
+
const minimized = Boolean(activeTabId && workflowInspectorMinimizedByTab.has(activeTabId));
|
|
16747
17026
|
|
|
16748
|
-
const node = make("section",
|
|
17027
|
+
const node = make("section", `widget release-npm-widget workflow-widget workflow-inspector-widget${minimized ? " minimized" : ""}`);
|
|
16749
17028
|
node.setAttribute("aria-label", "workflow run inspector");
|
|
17029
|
+
const body = make("div", "workflow-inspector-body");
|
|
17030
|
+
body.id = "workflowInspectorBody";
|
|
17031
|
+
body.hidden = minimized;
|
|
16750
17032
|
const header = make("div", "release-npm-header");
|
|
16751
17033
|
const titleWrap = make("div", "release-npm-title-wrap");
|
|
16752
17034
|
titleWrap.append(make("span", "release-npm-kicker", "workflows"), make("strong", "release-npm-title", `${payload.runs.length} run${payload.runs.length === 1 ? "" : "s"}`));
|
|
@@ -16754,7 +17036,17 @@ function renderWorkflowInspectorWidget() {
|
|
|
16754
17036
|
meta.append(make("span", "release-npm-pill", payload.mode?.enabled ? `mode ${payload.mode.phase}` : "mode off"));
|
|
16755
17037
|
const liveCount = payload.runs.filter(workflowRunIsLive).length;
|
|
16756
17038
|
if (liveCount) meta.append(make("span", "release-npm-pill workflow-status running", `${liveCount} active`));
|
|
17039
|
+
const minimizeButton = make("button", "release-npm-action workflow-inspector-minimize-button", minimized ? "Restore" : "Minimize");
|
|
17040
|
+
minimizeButton.type = "button";
|
|
17041
|
+
minimizeButton.setAttribute("aria-controls", body.id);
|
|
17042
|
+
minimizeButton.setAttribute("aria-expanded", minimized ? "false" : "true");
|
|
17043
|
+
minimizeButton.setAttribute("aria-label", minimized ? "Restore workflow inspector" : "Minimize workflow inspector");
|
|
17044
|
+
minimizeButton.setAttribute("title", minimized ? "Restore workflow inspector" : "Minimize workflow inspector");
|
|
17045
|
+
minimizeButton.addEventListener("click", () => workflowInspectorSetMinimized(!minimized));
|
|
17046
|
+
meta.append(minimizeButton);
|
|
16757
17047
|
header.append(titleWrap, meta);
|
|
17048
|
+
node.append(header, body);
|
|
17049
|
+
if (minimized) return node;
|
|
16758
17050
|
|
|
16759
17051
|
const layout = make("div", "workflow-inspector-layout");
|
|
16760
17052
|
const runList = make("nav", "workflow-inspector-run-list");
|
|
@@ -16806,7 +17098,7 @@ function renderWorkflowInspectorWidget() {
|
|
|
16806
17098
|
detail.append(raw);
|
|
16807
17099
|
}
|
|
16808
17100
|
layout.append(runList, detail);
|
|
16809
|
-
|
|
17101
|
+
body.append(layout);
|
|
16810
17102
|
return node;
|
|
16811
17103
|
}
|
|
16812
17104
|
|
|
@@ -16836,14 +17128,72 @@ function workflowTaskCountLabel(payload) {
|
|
|
16836
17128
|
return `${done}/${total} done${failed ? ` · ${failed} failed` : ""}${cancelled ? ` · ${cancelled} cancelled` : ""}`;
|
|
16837
17129
|
}
|
|
16838
17130
|
|
|
17131
|
+
function workflowMetaItem(label, value, className = "", description = "") {
|
|
17132
|
+
const item = make("span", `workflow-meta-item ${className}`.trim());
|
|
17133
|
+
item.append(
|
|
17134
|
+
make("span", "workflow-meta-label", label),
|
|
17135
|
+
make("strong", "workflow-meta-value", value),
|
|
17136
|
+
);
|
|
17137
|
+
if (description) item.append(make("span", "workflow-meta-description", description));
|
|
17138
|
+
return item;
|
|
17139
|
+
}
|
|
17140
|
+
|
|
17141
|
+
function bindWorkflowTerminalScroll(terminal, outputDetails, followStatus, { live = false, runId = "unknown" } = {}) {
|
|
17142
|
+
const statePrefix = `${activeTabId || "default"}:workflow:subprocess:`;
|
|
17143
|
+
const stateKey = `${statePrefix}${runId}`;
|
|
17144
|
+
for (const key of workflowTerminalScrollByTab.keys()) {
|
|
17145
|
+
if (key.startsWith(statePrefix) && key !== stateKey) workflowTerminalScrollByTab.delete(key);
|
|
17146
|
+
}
|
|
17147
|
+
const state = workflowTerminalScrollByTab.get(stateKey) || { following: true, scrollTop: 0 };
|
|
17148
|
+
const updateFollowStatus = () => {
|
|
17149
|
+
followStatus.textContent = live
|
|
17150
|
+
? (state.following ? "Following live output · scroll up to pause" : "Auto-follow paused · scroll to the bottom to resume")
|
|
17151
|
+
: "Output complete · scroll position is preserved";
|
|
17152
|
+
followStatus.classList.toggle("paused", live && !state.following);
|
|
17153
|
+
};
|
|
17154
|
+
const restorePosition = () => {
|
|
17155
|
+
if (!outputDetails.open) return;
|
|
17156
|
+
const maxScrollTop = Math.max(0, terminal.scrollHeight - terminal.clientHeight);
|
|
17157
|
+
terminal.scrollTop = state.following ? maxScrollTop : Math.min(state.scrollTop, maxScrollTop);
|
|
17158
|
+
};
|
|
17159
|
+
terminal.addEventListener("scroll", () => {
|
|
17160
|
+
const distanceFromBottom = terminal.scrollHeight - terminal.clientHeight - terminal.scrollTop;
|
|
17161
|
+
state.following = distanceFromBottom <= 24;
|
|
17162
|
+
state.scrollTop = terminal.scrollTop;
|
|
17163
|
+
workflowTerminalScrollByTab.set(stateKey, state);
|
|
17164
|
+
updateFollowStatus();
|
|
17165
|
+
}, { passive: true });
|
|
17166
|
+
outputDetails.addEventListener("toggle", () => {
|
|
17167
|
+
if (outputDetails.open) requestAnimationFrame(restorePosition);
|
|
17168
|
+
});
|
|
17169
|
+
updateFollowStatus();
|
|
17170
|
+
requestAnimationFrame(restorePosition);
|
|
17171
|
+
}
|
|
17172
|
+
|
|
17173
|
+
function workflowSubprocessSetMinimized(minimized) {
|
|
17174
|
+
if (!activeTabId) return;
|
|
17175
|
+
const tabId = activeTabId;
|
|
17176
|
+
if (minimized) workflowSubprocessMinimizedByTab.add(tabId);
|
|
17177
|
+
else workflowSubprocessMinimizedByTab.delete(tabId);
|
|
17178
|
+
renderWidgets();
|
|
17179
|
+
requestAnimationFrame(() => {
|
|
17180
|
+
if (activeTabId !== tabId) return;
|
|
17181
|
+
elements.widgetArea.querySelector(".workflow-subprocess-minimize-button")?.focus({ preventScroll: true });
|
|
17182
|
+
});
|
|
17183
|
+
}
|
|
17184
|
+
|
|
16839
17185
|
function renderWorkflowSubprocessWidget() {
|
|
16840
17186
|
if (!isOptionalFeatureEnabled("workflows")) return null;
|
|
16841
17187
|
const payload = parseWorkflowSubprocessPayload(getWidgetLines("workflow:subprocess"));
|
|
16842
17188
|
if (!payload) return null;
|
|
16843
17189
|
|
|
16844
17190
|
const live = workflowSubprocessIsLive(payload);
|
|
16845
|
-
const
|
|
17191
|
+
const minimized = Boolean(activeTabId && workflowSubprocessMinimizedByTab.has(activeTabId));
|
|
17192
|
+
const node = make("section", `widget release-npm-widget workflow-widget workflow-subprocess-widget ${live ? "workflow-live-widget" : "workflow-log-widget"}${minimized ? " minimized" : ""}`);
|
|
16846
17193
|
node.setAttribute("aria-label", "workflow subprocess output");
|
|
17194
|
+
const body = make("div", "workflow-subprocess-body");
|
|
17195
|
+
body.id = "workflowSubprocessBody";
|
|
17196
|
+
body.hidden = minimized;
|
|
16847
17197
|
|
|
16848
17198
|
const header = make("div", "release-npm-header");
|
|
16849
17199
|
const titleWrap = make("div", "release-npm-title-wrap");
|
|
@@ -16852,29 +17202,56 @@ function renderWorkflowSubprocessWidget() {
|
|
|
16852
17202
|
make("strong", "release-npm-title", payload.workflowName || payload.workflowKey || "workflow"),
|
|
16853
17203
|
);
|
|
16854
17204
|
|
|
16855
|
-
const meta = make("div", "release-npm-meta");
|
|
16856
|
-
meta.
|
|
16857
|
-
|
|
16858
|
-
meta.append(
|
|
16859
|
-
if (payload.
|
|
17205
|
+
const meta = make("div", "release-npm-meta workflow-meta");
|
|
17206
|
+
meta.setAttribute("role", "group");
|
|
17207
|
+
meta.setAttribute("aria-label", "Workflow run summary");
|
|
17208
|
+
meta.append(workflowMetaItem("Run", payload.status || "unknown", `workflow-status ${payload.status || "unknown"}`));
|
|
17209
|
+
if (payload.activePhase) meta.append(workflowMetaItem("Phase", String(payload.activePhase).replace(/^phases?(?::|\s)+/i, "")));
|
|
17210
|
+
meta.append(workflowMetaItem("Tasks", workflowTaskCountLabel(payload), "workflow-tasks"));
|
|
17211
|
+
if (payload.truncated) {
|
|
17212
|
+
meta.append(workflowMetaItem(
|
|
17213
|
+
"Output",
|
|
17214
|
+
"Limited history",
|
|
17215
|
+
"workflow-truncated",
|
|
17216
|
+
"Older output omitted from this view.",
|
|
17217
|
+
));
|
|
17218
|
+
}
|
|
16860
17219
|
|
|
16861
17220
|
const actions = make("div", "release-npm-actions");
|
|
16862
17221
|
actions.append(releaseNpmActionButton("Status", "/workflow status"));
|
|
16863
17222
|
if (live) actions.append(releaseNpmActionButton("Abort", "/workflow abort", "danger"));
|
|
16864
17223
|
actions.append(releaseNpmActionButton("Clear", "/workflow-clear"));
|
|
17224
|
+
const minimizeButton = make("button", "release-npm-action workflow-subprocess-minimize-button", minimized ? "Restore" : "Minimize");
|
|
17225
|
+
minimizeButton.type = "button";
|
|
17226
|
+
minimizeButton.setAttribute("aria-controls", body.id);
|
|
17227
|
+
minimizeButton.setAttribute("aria-expanded", minimized ? "false" : "true");
|
|
17228
|
+
minimizeButton.setAttribute("aria-label", minimized ? "Restore workflow subprocess output" : "Minimize workflow subprocess output");
|
|
17229
|
+
minimizeButton.setAttribute("title", minimized ? "Restore workflow subprocess output" : "Minimize workflow subprocess output");
|
|
17230
|
+
minimizeButton.addEventListener("click", () => workflowSubprocessSetMinimized(!minimized));
|
|
17231
|
+
actions.append(minimizeButton);
|
|
16865
17232
|
header.append(titleWrap, meta, actions);
|
|
17233
|
+
node.append(header, body);
|
|
17234
|
+
if (minimized) return node;
|
|
16866
17235
|
|
|
16867
17236
|
const lines = Array.isArray(payload.lines) && payload.lines.length ? payload.lines : ["Waiting for workflow subprocess output..."];
|
|
16868
17237
|
const streamHeader = releaseNpmStreamHeader(live ? "Live subprocess output" : "Subprocess output", lines.length, { live });
|
|
16869
17238
|
const terminal = make("div", "release-npm-terminal");
|
|
17239
|
+
terminal.dataset.preserveScrollOnToggle = "true";
|
|
16870
17240
|
terminal.setAttribute("role", "log");
|
|
16871
17241
|
terminal.setAttribute("aria-live", live ? "polite" : "off");
|
|
16872
17242
|
for (const line of lines) appendReleaseNpmTerminalLine(terminal, line);
|
|
16873
17243
|
|
|
16874
|
-
const controls = make("div", "release-npm-controls
|
|
17244
|
+
const controls = make("div", "release-npm-controls workflow-output-controls");
|
|
17245
|
+
const followStatus = make("span", "workflow-follow-status");
|
|
17246
|
+
followStatus.setAttribute("role", "status");
|
|
17247
|
+
followStatus.setAttribute("aria-live", "polite");
|
|
17248
|
+
controls.append(
|
|
17249
|
+
followStatus,
|
|
17250
|
+
make("span", "workflow-output-help", live ? "Use /workflow abort to stop the active run." : "The subprocess run has finished."),
|
|
17251
|
+
);
|
|
16875
17252
|
const outputDetails = renderReleaseNpmOutputDetails("workflow:subprocess", streamHeader, terminal, controls);
|
|
16876
|
-
|
|
16877
|
-
|
|
17253
|
+
body.append(outputDetails);
|
|
17254
|
+
bindWorkflowTerminalScroll(terminal, outputDetails, followStatus, { live, runId: payload.runId });
|
|
16878
17255
|
return node;
|
|
16879
17256
|
}
|
|
16880
17257
|
|
|
@@ -19233,6 +19610,7 @@ function selectGitInitWorkflowProcess(processValue, tabId, workflow) {
|
|
|
19233
19610
|
manualCommitMessage: "",
|
|
19234
19611
|
...resetGitWorkflowManualCommitDefaultPatch(),
|
|
19235
19612
|
messageRequestedAt: 0,
|
|
19613
|
+
messageGenerationId: "",
|
|
19236
19614
|
branchName: "",
|
|
19237
19615
|
branchNameRequestedAt: 0,
|
|
19238
19616
|
prMode: false,
|
|
@@ -19284,7 +19662,7 @@ function selectGitWorkflowProcess(processValue, tabId = gitWorkflowActionTabId()
|
|
|
19284
19662
|
if (!guidedReviewPatch) return;
|
|
19285
19663
|
workflow.runId += 1;
|
|
19286
19664
|
const runId = workflow.runId;
|
|
19287
|
-
const base = { mode: "standard", active: true, process, busy: false, error: "", githubUsername: "", repoName: "", remoteUrl: "", stack: "", readmeRequestedAt: 0, gitignoreRequestedAt: 0, initFilesStatus: null, manualCommitMessage: "", ...resetGitWorkflowManualCommitDefaultPatch(), messageRequestedAt: 0, branchName: "", branchNameRequestedAt: 0, prMode: false, prBranch: "", pr: null, prRequestedAt: 0, ...guidedReviewPatch };
|
|
19665
|
+
const base = { mode: "standard", active: true, process, busy: false, error: "", githubUsername: "", repoName: "", remoteUrl: "", stack: "", readmeRequestedAt: 0, gitignoreRequestedAt: 0, initFilesStatus: null, manualCommitMessage: "", ...resetGitWorkflowManualCommitDefaultPatch(), messageRequestedAt: 0, messageGenerationId: "", branchName: "", branchNameRequestedAt: 0, prMode: false, prBranch: "", pr: null, prRequestedAt: 0, ...guidedReviewPatch };
|
|
19288
19666
|
|
|
19289
19667
|
if (process === "stage") {
|
|
19290
19668
|
setGitWorkflow({ ...base, step: "add", message: null, output: "Ready to stage all changes with git add ." }, { tabId });
|
|
@@ -19514,7 +19892,11 @@ function renderGitWorkflow() {
|
|
|
19514
19892
|
addGitWorkflowAction("Preview current message files", () => loadGitWorkflowMessage({ requireFresh: false }), "", false);
|
|
19515
19893
|
elements.gitWorkflowActions.append(commitInputButton);
|
|
19516
19894
|
} else if (gitWorkflow.step === "generating") {
|
|
19517
|
-
|
|
19895
|
+
if (gitWorkflow.messageGenerationId) {
|
|
19896
|
+
addGitWorkflowAction("Refresh message preview", () => loadGitWorkflowMessage({ requireFresh: true }), "", false);
|
|
19897
|
+
} else {
|
|
19898
|
+
addGitWorkflowAction("Starting message generation…", () => {}, "", true);
|
|
19899
|
+
}
|
|
19518
19900
|
} else if (gitWorkflow.step === "message") {
|
|
19519
19901
|
const deliveryMode = preferences.deliveryMode || "ask";
|
|
19520
19902
|
const preferredVariant = preferences.commit?.defaultVariant || "short";
|
|
@@ -19851,6 +20233,7 @@ async function startGitWorkflow(tabId = activeTabId, { skipSetup = false } = {})
|
|
|
19851
20233
|
manualCommitMessage: "",
|
|
19852
20234
|
...resetGitWorkflowManualCommitDefaultPatch(),
|
|
19853
20235
|
messageRequestedAt: 0,
|
|
20236
|
+
messageGenerationId: "",
|
|
19854
20237
|
branchName: "",
|
|
19855
20238
|
branchNameRequestedAt: 0,
|
|
19856
20239
|
actionsDone: createGitWorkflowActionsDone(),
|
|
@@ -19898,6 +20281,7 @@ async function startGitInitWorkflow(tabId = activeTabId) {
|
|
|
19898
20281
|
manualCommitMessage: "",
|
|
19899
20282
|
...resetGitWorkflowManualCommitDefaultPatch(),
|
|
19900
20283
|
messageRequestedAt: 0,
|
|
20284
|
+
messageGenerationId: "",
|
|
19901
20285
|
branchName: "",
|
|
19902
20286
|
branchNameRequestedAt: 0,
|
|
19903
20287
|
actionsDone: createGitWorkflowActionsDone(),
|
|
@@ -20290,19 +20674,24 @@ async function runGitMessagePrompt(tabId = gitWorkflowActionTabId()) {
|
|
|
20290
20674
|
busy: true,
|
|
20291
20675
|
error: "",
|
|
20292
20676
|
messageRequestedAt: requestedAt,
|
|
20677
|
+
messageGenerationId: "",
|
|
20293
20678
|
output: "Sending /git-staged-msg to Pi.\n\nCancel will request Pi abort.",
|
|
20294
20679
|
}, { tabId });
|
|
20295
20680
|
if (isCurrentTabContext(tabContext)) setRunIndicatorActivity("Sending /git-staged-msg to Pi…");
|
|
20296
20681
|
try {
|
|
20297
20682
|
const generation = await gitWorkflowRequest("/api/git-workflow/generate", { body: { kind: "commit", ...(expectedStagedContentHash ? { expectedStagedContentHash } : {}) }, runId, tabId });
|
|
20298
20683
|
if (!generation || !isCurrentGitWorkflowRun(runId, tabId)) return;
|
|
20299
|
-
|
|
20684
|
+
const generationId = String(generation.generationId || "").trim();
|
|
20685
|
+
if (!generationId) throw new Error("The WebUI server did not return a commit-message generation ID. Restart Pi Web UI and regenerate.");
|
|
20686
|
+
setGitWorkflow({ messageGenerationId: generationId }, { tabId });
|
|
20687
|
+
appendGitWorkflowOutput(`/git-staged-msg accepted with ${generation.generation.provider}/${generation.generation.modelId} at ${generation.generation.thinkingLevel} effort. Waiting for agent_end, then both correlated message files will be loaded.`, { tabId });
|
|
20300
20688
|
if (isCurrentTabContext(tabContext)) scheduleRefreshState(120, tabContext);
|
|
20301
20689
|
setTimeout(() => {
|
|
20302
20690
|
const currentWorkflow = gitWorkflowForTab(tabId, { create: false });
|
|
20303
|
-
const
|
|
20304
|
-
|
|
20305
|
-
|
|
20691
|
+
const targetTab = tabs.find((tab) => tab.id === tabId);
|
|
20692
|
+
const targetStillBusy = tabId === activeTabId ? !!currentState?.isStreaming : activityForTab(targetTab).isWorking;
|
|
20693
|
+
if (isCurrentGitWorkflowRun(runId, tabId) && currentWorkflow?.step === "generating" && currentWorkflow.messageGenerationId === generationId && !targetStillBusy) {
|
|
20694
|
+
loadGitWorkflowMessage({ requireFresh: true, generationId, runId, tabId });
|
|
20306
20695
|
}
|
|
20307
20696
|
}, 2500);
|
|
20308
20697
|
} catch (error) {
|
|
@@ -20313,35 +20702,93 @@ async function runGitMessagePrompt(tabId = gitWorkflowActionTabId()) {
|
|
|
20313
20702
|
}
|
|
20314
20703
|
}
|
|
20315
20704
|
|
|
20316
|
-
|
|
20705
|
+
const GIT_WORKFLOW_MESSAGE_POLL_TIMEOUT_MS = 30_000;
|
|
20706
|
+
const GIT_WORKFLOW_MESSAGE_POLL_DELAYS_MS = [250, 500, 800, 1200];
|
|
20707
|
+
|
|
20708
|
+
function gitWorkflowMessageLoadIsCurrent(tabId, runId, generationId = "") {
|
|
20709
|
+
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
20710
|
+
return !!workflow
|
|
20711
|
+
&& isCurrentGitWorkflowRun(runId, tabId)
|
|
20712
|
+
&& (!generationId || workflow.messageGenerationId === generationId);
|
|
20713
|
+
}
|
|
20714
|
+
|
|
20715
|
+
function waitForGitWorkflowMessagePoll(attempt) {
|
|
20716
|
+
const delayMs = GIT_WORKFLOW_MESSAGE_POLL_DELAYS_MS[Math.min(attempt, GIT_WORKFLOW_MESSAGE_POLL_DELAYS_MS.length - 1)];
|
|
20717
|
+
return new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
20718
|
+
}
|
|
20719
|
+
|
|
20720
|
+
async function loadGitWorkflowMessage({ requireFresh = false, generationId, runId, tabId = activeTabId } = {}) {
|
|
20317
20721
|
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
20318
20722
|
const expectedRunId = runId ?? workflow?.runId;
|
|
20319
|
-
|
|
20320
|
-
|
|
20321
|
-
|
|
20322
|
-
|
|
20323
|
-
|
|
20324
|
-
|
|
20325
|
-
if (
|
|
20326
|
-
|
|
20327
|
-
|
|
20328
|
-
|
|
20329
|
-
|
|
20330
|
-
|
|
20331
|
-
|
|
20332
|
-
|
|
20333
|
-
|
|
20334
|
-
|
|
20335
|
-
|
|
20336
|
-
|
|
20337
|
-
|
|
20338
|
-
|
|
20339
|
-
|
|
20340
|
-
|
|
20723
|
+
const expectedGenerationId = requireFresh ? String(generationId ?? workflow?.messageGenerationId ?? "").trim() : "";
|
|
20724
|
+
if (!workflow || expectedRunId === undefined) return;
|
|
20725
|
+
if (requireFresh && !expectedGenerationId) {
|
|
20726
|
+
// The generation POST can be accepted just before its correlation ID is
|
|
20727
|
+
// returned to the browser. Timer/event wakeups in that narrow window are
|
|
20728
|
+
// harmless; the accepted-request continuation and fallback timer retry.
|
|
20729
|
+
if (workflow.step === "generating") return;
|
|
20730
|
+
failGitWorkflow(new Error("No correlated commit-message generation is active. Run /git-staged-msg again."), "generate", { tabId });
|
|
20731
|
+
return;
|
|
20732
|
+
}
|
|
20733
|
+
|
|
20734
|
+
const loadKey = `${expectedRunId}:${expectedGenerationId || "preview"}`;
|
|
20735
|
+
const existing = gitWorkflowMessageLoadsByTab.get(tabId);
|
|
20736
|
+
if (existing?.key === loadKey) return existing.promise;
|
|
20737
|
+
|
|
20738
|
+
const promise = (async () => {
|
|
20739
|
+
const deadline = Date.now() + (requireFresh ? GIT_WORKFLOW_MESSAGE_POLL_TIMEOUT_MS : 0);
|
|
20740
|
+
const baseOutput = workflow.output || "Waiting for generated commit message files…";
|
|
20741
|
+
let attempt = 0;
|
|
20742
|
+
while (gitWorkflowMessageLoadIsCurrent(tabId, expectedRunId, expectedGenerationId)) {
|
|
20743
|
+
try {
|
|
20744
|
+
const query = expectedGenerationId ? `?generationId=${encodeURIComponent(expectedGenerationId)}` : "";
|
|
20745
|
+
const message = await gitWorkflowRequest(`/api/git-workflow/message${query}`, { method: "GET", runId: expectedRunId, tabId });
|
|
20746
|
+
if (!message || !gitWorkflowMessageLoadIsCurrent(tabId, expectedRunId, expectedGenerationId)) return;
|
|
20747
|
+
if (message.ready === false) {
|
|
20748
|
+
if (message.expired) throw new Error(message.reason || "This commit-message generation has expired. Regenerate the message files.");
|
|
20749
|
+
if (!requireFresh || Date.now() >= deadline) {
|
|
20750
|
+
throw new Error(`${message.reason || "Generated commit message files are not ready."} Regenerate, or use Preview current message files after verifying both files.`);
|
|
20751
|
+
}
|
|
20752
|
+
const currentWorkflow = gitWorkflowForTab(tabId, { create: false });
|
|
20753
|
+
const reason = message.reason || "Waiting for both correlated commit message files…";
|
|
20754
|
+
if (currentWorkflow?.output !== `${baseOutput}\n\n${reason}`) {
|
|
20755
|
+
setGitWorkflow({ busy: true, error: "", output: `${baseOutput}\n\n${reason}` }, { tabId });
|
|
20756
|
+
}
|
|
20757
|
+
await waitForGitWorkflowMessagePoll(attempt++);
|
|
20758
|
+
continue;
|
|
20759
|
+
}
|
|
20760
|
+
const currentWorkflow = gitWorkflowForTab(tabId, { create: false });
|
|
20761
|
+
if (!currentWorkflow || !gitWorkflowMessageLoadIsCurrent(tabId, expectedRunId, expectedGenerationId)) return;
|
|
20762
|
+
setGitWorkflow({
|
|
20763
|
+
step: "message",
|
|
20764
|
+
busy: false,
|
|
20765
|
+
error: "",
|
|
20766
|
+
message,
|
|
20767
|
+
...(requireFresh ? gitWorkflowActionDonePatch(currentWorkflow, "message") : {}),
|
|
20768
|
+
output: formatCommitMessagePreview(message),
|
|
20769
|
+
}, { tabId });
|
|
20770
|
+
return;
|
|
20771
|
+
} catch (error) {
|
|
20772
|
+
if (!gitWorkflowMessageLoadIsCurrent(tabId, expectedRunId, expectedGenerationId)) return;
|
|
20773
|
+
if (!requireFresh || Date.now() >= deadline || /expired|no longer active/i.test(error?.message || "")) throw error;
|
|
20774
|
+
const reason = error?.message || String(error);
|
|
20775
|
+
const currentWorkflow = gitWorkflowForTab(tabId, { create: false });
|
|
20776
|
+
if (currentWorkflow?.output !== `${baseOutput}\n\nWaiting for both correlated message files. ${reason}`) {
|
|
20777
|
+
setGitWorkflow({ busy: true, error: "", output: `${baseOutput}\n\nWaiting for both correlated message files. ${reason}` }, { tabId });
|
|
20778
|
+
}
|
|
20779
|
+
await waitForGitWorkflowMessagePoll(attempt++);
|
|
20780
|
+
}
|
|
20341
20781
|
}
|
|
20782
|
+
})().catch((error) => {
|
|
20783
|
+
if (!gitWorkflowMessageLoadIsCurrent(tabId, expectedRunId, expectedGenerationId)) return;
|
|
20342
20784
|
const currentWorkflow = gitWorkflowForTab(tabId, { create: false });
|
|
20343
20785
|
failGitWorkflow(error, currentWorkflow?.step === "generating" ? "generate" : currentWorkflow?.step, { tabId });
|
|
20344
|
-
}
|
|
20786
|
+
}).finally(() => {
|
|
20787
|
+
if (gitWorkflowMessageLoadsByTab.get(tabId)?.key === loadKey) gitWorkflowMessageLoadsByTab.delete(tabId);
|
|
20788
|
+
});
|
|
20789
|
+
|
|
20790
|
+
gitWorkflowMessageLoadsByTab.set(tabId, { key: loadKey, promise });
|
|
20791
|
+
return promise;
|
|
20345
20792
|
}
|
|
20346
20793
|
|
|
20347
20794
|
function gitBranchNamePromptMessage() {
|
|
@@ -20528,6 +20975,7 @@ async function createGitPrBranchWithSuggestion(suggestion, tabId = gitWorkflowAc
|
|
|
20528
20975
|
manualCommitMessageDefaultRequestedAt: sourceWorkflow.manualCommitMessageDefaultRequestedAt || 0,
|
|
20529
20976
|
manualCommitMessageDefaultLoading: false,
|
|
20530
20977
|
messageRequestedAt: sourceWorkflow.messageRequestedAt || 0,
|
|
20978
|
+
messageGenerationId: sourceWorkflow.messageGenerationId || "",
|
|
20531
20979
|
branchName: prBranch || branch,
|
|
20532
20980
|
branchNameRequestedAt: sourceWorkflow.branchNameRequestedAt || 0,
|
|
20533
20981
|
actionsDone: createGitWorkflowActionsDone({ ...sourceWorkflow.actionsDone, branch: true }),
|
|
@@ -20757,7 +21205,7 @@ function resumeGitWorkflowForActiveTab(tabContext = activeTabContext()) {
|
|
|
20757
21205
|
setTimeout(() => resumeGitWorkflowForActiveTab(tabContext), retryDelayMs);
|
|
20758
21206
|
return;
|
|
20759
21207
|
}
|
|
20760
|
-
loadGitWorkflowMessage({ requireFresh: true,
|
|
21208
|
+
loadGitWorkflowMessage({ requireFresh: true, generationId: gitWorkflow.messageGenerationId, runId: gitWorkflow.runId, tabId: workflowTabId });
|
|
20761
21209
|
}
|
|
20762
21210
|
if (workflowTabId === tabContext.tabId && gitWorkflow.active && gitWorkflow.step === "branchNaming" && !currentState?.isStreaming) {
|
|
20763
21211
|
const retryDelayMs = Math.max(0, 2500 - (Date.now() - (gitWorkflow.branchNameRequestedAt || 0)));
|
|
@@ -24216,6 +24664,45 @@ function addTransientMessage({ role = "notice", title, content, level = "info",
|
|
|
24216
24664
|
renderAllMessages();
|
|
24217
24665
|
}
|
|
24218
24666
|
|
|
24667
|
+
function surfaceRuntimeDiagnostic(title, content, level = "error") {
|
|
24668
|
+
const message = String(content || "").trim();
|
|
24669
|
+
if (!message) return;
|
|
24670
|
+
addEvent(message, level);
|
|
24671
|
+
addTransientMessage({ role: level === "error" ? "error" : "warn", title, content: message, level });
|
|
24672
|
+
}
|
|
24673
|
+
|
|
24674
|
+
function stderrDiagnosticLevel(content) {
|
|
24675
|
+
return /(?:^|\b)(?:error|failed|failure|fatal|exception|invalid)(?:\b|:)/i.test(String(content || "")) ? "error" : "warn";
|
|
24676
|
+
}
|
|
24677
|
+
|
|
24678
|
+
function toolImagePayloadError(event) {
|
|
24679
|
+
const blocks = Array.isArray(event?.result?.content) ? event.result.content : [];
|
|
24680
|
+
for (const [index, block] of blocks.entries()) {
|
|
24681
|
+
if (block?.type !== "image") continue;
|
|
24682
|
+
const data = typeof block.data === "string" ? block.data.replace(/\s+/g, "") : "";
|
|
24683
|
+
let canonical = data.length > 0 && data.length % 4 === 0 && /^[A-Za-z0-9+/]+={0,2}$/.test(data);
|
|
24684
|
+
if (canonical) {
|
|
24685
|
+
try {
|
|
24686
|
+
canonical = btoa(atob(data)) === data;
|
|
24687
|
+
} catch {
|
|
24688
|
+
canonical = false;
|
|
24689
|
+
}
|
|
24690
|
+
}
|
|
24691
|
+
if (!canonical) {
|
|
24692
|
+
const toolName = String(event.toolName || "Tool");
|
|
24693
|
+
return `${toolName} returned image output ${index + 1} with invalid base64 data. The next model request may fail. Upgrade or fix the tool, then start a new session or fork before this tool result to remove it from context.`;
|
|
24694
|
+
}
|
|
24695
|
+
}
|
|
24696
|
+
return "";
|
|
24697
|
+
}
|
|
24698
|
+
|
|
24699
|
+
function assistantErrorFromAgentEnd(event) {
|
|
24700
|
+
const messages = Array.isArray(event?.messages) ? event.messages : [];
|
|
24701
|
+
const message = messages.findLast((item) => item?.role === "assistant");
|
|
24702
|
+
if (message?.stopReason !== "error") return "";
|
|
24703
|
+
return String(message.errorMessage || "The assistant request failed without an error message.").trim();
|
|
24704
|
+
}
|
|
24705
|
+
|
|
24219
24706
|
function addAbortTranscriptNotice({ activeRun = false, errorMessage = "" } = {}) {
|
|
24220
24707
|
if (errorMessage) {
|
|
24221
24708
|
addTransientMessage({ role: "error", title: "Abort failed", content: `Abort request failed: ${errorMessage}`, level: "error" });
|
|
@@ -24618,7 +25105,7 @@ function requestGitFooterWebuiPayload(tabContext = activeTabContext(), { force =
|
|
|
24618
25105
|
|
|
24619
25106
|
gitFooterPayloadRefreshInFlightByTab.add(tabContext.tabId);
|
|
24620
25107
|
if (isCurrentTabContext(tabContext)) renderFooter();
|
|
24621
|
-
api("/api/prompt", {
|
|
25108
|
+
return api("/api/prompt", {
|
|
24622
25109
|
method: "POST",
|
|
24623
25110
|
body: { message: `/${refreshCommand}${silent ? " --webui-silent" : ""}`, streamingBehavior: "steer" },
|
|
24624
25111
|
tabId: tabContext.tabId,
|
|
@@ -25411,6 +25898,93 @@ function httpIdleTimeoutOptions(settings) {
|
|
|
25411
25898
|
return [{ value: current, label }, ...SETTINGS_HTTP_IDLE_TIMEOUT_OPTIONS];
|
|
25412
25899
|
}
|
|
25413
25900
|
|
|
25901
|
+
function normalizeWebuiOutputModeMetadata(metadata = {}) {
|
|
25902
|
+
const modes = new Set(["normal", "compact-v1"]);
|
|
25903
|
+
const sources = new Set(["cli", "env", "persisted", "normal"]);
|
|
25904
|
+
return {
|
|
25905
|
+
persistedDefault: modes.has(metadata.persistedDefault) ? metadata.persistedDefault : "normal",
|
|
25906
|
+
effectiveDefault: modes.has(metadata.effectiveDefault) ? metadata.effectiveDefault : "normal",
|
|
25907
|
+
source: sources.has(metadata.source) ? metadata.source : "normal",
|
|
25908
|
+
overridden: metadata.overridden === true && (metadata.source === "cli" || metadata.source === "env"),
|
|
25909
|
+
};
|
|
25910
|
+
}
|
|
25911
|
+
|
|
25912
|
+
function webuiOutputModeMetadataText(metadata) {
|
|
25913
|
+
const sourceLabel = { cli: "CLI", env: "environment", persisted: "persisted setting", normal: "normal default" }[metadata.source] || "normal default";
|
|
25914
|
+
const overridden = metadata.overridden ? ` ${sourceLabel} overrides the persisted setting.` : "";
|
|
25915
|
+
return `Persisted default: ${metadata.persistedDefault}. Effective mode: ${metadata.effectiveDefault}. Source: ${sourceLabel}.${overridden}`;
|
|
25916
|
+
}
|
|
25917
|
+
|
|
25918
|
+
let sidebarOutputModeMetadata = normalizeWebuiOutputModeMetadata();
|
|
25919
|
+
let sidebarOutputModeDiagnostic = "";
|
|
25920
|
+
let sidebarOutputModeNotice = "";
|
|
25921
|
+
let sidebarOutputModeLoaded = false;
|
|
25922
|
+
let sidebarOutputModeBusy = false;
|
|
25923
|
+
|
|
25924
|
+
function updateSidebarOutputModeApplyState() {
|
|
25925
|
+
if (!elements.fastOutputModeSelect || !elements.setFastOutputModeButton) return;
|
|
25926
|
+
const unavailable = !sidebarOutputModeLoaded || !!sidebarOutputModeDiagnostic;
|
|
25927
|
+
elements.fastOutputModeSelect.disabled = unavailable || sidebarOutputModeBusy;
|
|
25928
|
+
elements.setFastOutputModeButton.disabled = unavailable
|
|
25929
|
+
|| sidebarOutputModeBusy
|
|
25930
|
+
|| elements.fastOutputModeSelect.value === sidebarOutputModeMetadata.persistedDefault;
|
|
25931
|
+
elements.setFastOutputModeButton.textContent = sidebarOutputModeBusy ? "Applying…" : "Apply";
|
|
25932
|
+
}
|
|
25933
|
+
|
|
25934
|
+
function renderSidebarOutputModeControl({ syncSelection = true } = {}) {
|
|
25935
|
+
if (!elements.fastOutputModeSelect || !elements.fastOutputModeStatus) return;
|
|
25936
|
+
if (syncSelection) elements.fastOutputModeSelect.value = sidebarOutputModeMetadata.persistedDefault;
|
|
25937
|
+
elements.fastOutputModeStatus.textContent = sidebarOutputModeDiagnostic
|
|
25938
|
+
|| sidebarOutputModeNotice
|
|
25939
|
+
|| webuiOutputModeMetadataText(sidebarOutputModeMetadata);
|
|
25940
|
+
elements.fastOutputModeStatus.classList.toggle("warning", !!sidebarOutputModeDiagnostic || !!sidebarOutputModeNotice);
|
|
25941
|
+
updateSidebarOutputModeApplyState();
|
|
25942
|
+
}
|
|
25943
|
+
|
|
25944
|
+
async function refreshSidebarOutputMode() {
|
|
25945
|
+
if (!elements.fastOutputModeSelect) return sidebarOutputModeMetadata;
|
|
25946
|
+
sidebarOutputModeLoaded = false;
|
|
25947
|
+
sidebarOutputModeDiagnostic = "";
|
|
25948
|
+
sidebarOutputModeNotice = "";
|
|
25949
|
+
renderSidebarOutputModeControl();
|
|
25950
|
+
try {
|
|
25951
|
+
const response = await api("/api/webui-output-mode", { scoped: false });
|
|
25952
|
+
sidebarOutputModeMetadata = normalizeWebuiOutputModeMetadata(response.data);
|
|
25953
|
+
} catch (error) {
|
|
25954
|
+
sidebarOutputModeMetadata = normalizeWebuiOutputModeMetadata();
|
|
25955
|
+
sidebarOutputModeDiagnostic = `Fast-mode control unavailable: ${error.message || String(error)}. Using the normal default.`;
|
|
25956
|
+
} finally {
|
|
25957
|
+
sidebarOutputModeLoaded = true;
|
|
25958
|
+
renderSidebarOutputModeControl();
|
|
25959
|
+
}
|
|
25960
|
+
return sidebarOutputModeMetadata;
|
|
25961
|
+
}
|
|
25962
|
+
|
|
25963
|
+
async function applySidebarOutputMode() {
|
|
25964
|
+
if (!elements.fastOutputModeSelect || sidebarOutputModeBusy) return;
|
|
25965
|
+
const outputModeDefault = elements.fastOutputModeSelect.value === "compact-v1" ? "compact-v1" : "normal";
|
|
25966
|
+
if (outputModeDefault === sidebarOutputModeMetadata.persistedDefault) return;
|
|
25967
|
+
sidebarOutputModeBusy = true;
|
|
25968
|
+
updateSidebarOutputModeApplyState();
|
|
25969
|
+
try {
|
|
25970
|
+
await api("/api/webui-output-mode", {
|
|
25971
|
+
method: "PUT",
|
|
25972
|
+
body: { outputModeDefault },
|
|
25973
|
+
scoped: false,
|
|
25974
|
+
});
|
|
25975
|
+
await refreshSidebarOutputMode();
|
|
25976
|
+
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");
|
|
25977
|
+
} catch (error) {
|
|
25978
|
+
sidebarOutputModeDiagnostic = "";
|
|
25979
|
+
sidebarOutputModeNotice = `Failed to update fast mode: ${error.message || String(error)}. You can retry.`;
|
|
25980
|
+
sidebarOutputModeLoaded = true;
|
|
25981
|
+
addEvent(sidebarOutputModeNotice, "error");
|
|
25982
|
+
} finally {
|
|
25983
|
+
sidebarOutputModeBusy = false;
|
|
25984
|
+
renderSidebarOutputModeControl();
|
|
25985
|
+
}
|
|
25986
|
+
}
|
|
25987
|
+
|
|
25414
25988
|
function collectNativeSettingsPayload(controls) {
|
|
25415
25989
|
return {
|
|
25416
25990
|
transport: controls.transport.select.value,
|
|
@@ -25457,6 +26031,15 @@ async function openNativeSettingsDialog() {
|
|
|
25457
26031
|
return;
|
|
25458
26032
|
}
|
|
25459
26033
|
|
|
26034
|
+
let outputModeMetadata = normalizeWebuiOutputModeMetadata();
|
|
26035
|
+
let outputModeApiDiagnostic = "";
|
|
26036
|
+
try {
|
|
26037
|
+
const response = await api("/api/webui-output-mode", { scoped: false });
|
|
26038
|
+
outputModeMetadata = normalizeWebuiOutputModeMetadata(response.data);
|
|
26039
|
+
} catch (error) {
|
|
26040
|
+
outputModeApiDiagnostic = `Output-mode API unavailable: ${error.message || String(error)}. Showing the normal default; other settings can still be applied.`;
|
|
26041
|
+
}
|
|
26042
|
+
|
|
25460
26043
|
const state = currentState || {};
|
|
25461
26044
|
const settings = settingsData.settings || {};
|
|
25462
26045
|
applyNativeSettingsForBrowser(settings);
|
|
@@ -25487,6 +26070,7 @@ async function openNativeSettingsDialog() {
|
|
|
25487
26070
|
autocompleteMax: nativeSettingSelect("Autocomplete max items", settings.autocompleteMaxVisible ?? autocompleteMaxVisible, SETTINGS_AUTOCOMPLETE_OPTIONS, "Maximum visible slash/path suggestions.", { label: "browser", tone: "browser" }),
|
|
25488
26071
|
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" }),
|
|
25489
26072
|
treeFilter: nativeSettingSelect("Tree filter mode", settings.treeFilterMode || treeFilterMode, SETTINGS_TREE_FILTER_OPTIONS, "Default filter when opening /tree.", { label: "browser", tone: "browser" }),
|
|
26073
|
+
outputMode: nativeSettingSelect("Output processing", outputModeMetadata.persistedDefault, SETTINGS_OUTPUT_MODE_OPTIONS, "Server default for new and auto-negotiated Web UI connections. Compact reduces local output-processing and live fidelity, restores rich final output, and does not change model inference or token generation. Changes use server barriers without restarting Pi.", { label: "server", tone: "startup" }),
|
|
25490
26074
|
autoResizeImages: nativeSettingToggle("Auto-resize images", settings.autoResizeImages !== false, "Resize large images to 2000x2000 max for better model compatibility.", { label: "reload", tone: "reload" }),
|
|
25491
26075
|
blockImages: nativeSettingToggle("Block images", settings.blockImages === true, "Prevent images from being sent to LLM providers.", { label: "reload", tone: "reload" }),
|
|
25492
26076
|
showImages: nativeSettingToggle("Show terminal images", settings.showImages !== false, "Native TUI inline image rendering preference.", { label: "TUI", tone: "tui" }),
|
|
@@ -25501,6 +26085,14 @@ async function openNativeSettingsDialog() {
|
|
|
25501
26085
|
clearOnShrink: nativeSettingToggle("Clear on shrink", settings.clearOnShrink === true, "Native TUI row clearing when content shrinks; may flicker.", { label: "TUI", tone: "tui" }),
|
|
25502
26086
|
terminalProgress: nativeSettingToggle("Terminal progress", settings.showTerminalProgress === true, "Native TUI OSC 9;4 terminal progress indicators.", { label: "TUI", tone: "tui" }),
|
|
25503
26087
|
};
|
|
26088
|
+
const outputModeStatus = make("span", "native-settings-hint");
|
|
26089
|
+
controls.outputMode.field.append(outputModeStatus);
|
|
26090
|
+
const renderOutputModeMetadata = () => {
|
|
26091
|
+
controls.outputMode.select.value = outputModeMetadata.persistedDefault;
|
|
26092
|
+
controls.outputMode.select.disabled = !!outputModeApiDiagnostic;
|
|
26093
|
+
outputModeStatus.textContent = outputModeApiDiagnostic || webuiOutputModeMetadataText(outputModeMetadata);
|
|
26094
|
+
};
|
|
26095
|
+
renderOutputModeMetadata();
|
|
25504
26096
|
|
|
25505
26097
|
const remoteAccessSection = make("details", "native-settings-section native-settings-remote-access");
|
|
25506
26098
|
remoteAccessSection.open = false;
|
|
@@ -25542,7 +26134,7 @@ async function openNativeSettingsDialog() {
|
|
|
25542
26134
|
nativeSettingsNote("Scopes", "Each field says whether it affects this tab, this browser, global Pi settings, or the native TUI."),
|
|
25543
26135
|
remoteAccessSection,
|
|
25544
26136
|
nativeSettingsSection("Runtime", "Model behavior and request transport.", [controls.thinking, controls.autoCompact, controls.steering, controls.followUp, controls.transport, controls.httpIdleTimeout], { open: true }),
|
|
25545
|
-
nativeSettingsSection("Browser workflow", "Local Web UI behavior
|
|
26137
|
+
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 }),
|
|
25546
26138
|
nativeSettingsSection("Images", "Provider image policy and native terminal image display.", [controls.autoResizeImages, controls.blockImages, controls.showImages, controls.imageWidth], { open: true }),
|
|
25547
26139
|
nativeSettingsSection("Startup & safety", "Command registration, warnings, update/startup behavior.", [controls.skillCommands, controls.anthropicWarning, controls.collapseChangelog, controls.quietStartup, controls.installTelemetry], { open: false }),
|
|
25548
26140
|
nativeSettingsSection("Native TUI advanced", "Saved for the terminal UI; mostly informational in the browser.", [controls.hardwareCursor, controls.editorPadding, controls.clearOnShrink, controls.terminalProgress], { open: false })
|
|
@@ -25554,6 +26146,7 @@ async function openNativeSettingsDialog() {
|
|
|
25554
26146
|
addNativeCommandAction("Cancel", () => closeNativeCommandDialog());
|
|
25555
26147
|
|
|
25556
26148
|
const initialPayload = collectNativeSettingsPayload(controls);
|
|
26149
|
+
const initialOutputModeDefault = controls.outputMode.select.value;
|
|
25557
26150
|
const initialRuntime = JSON.stringify({
|
|
25558
26151
|
thinking: state.thinkingLevel || "off",
|
|
25559
26152
|
autoCompact: state.autoCompactionEnabled !== false,
|
|
@@ -25579,7 +26172,9 @@ async function openNativeSettingsDialog() {
|
|
|
25579
26172
|
});
|
|
25580
26173
|
let applyButton;
|
|
25581
26174
|
const updateDirtyState = () => {
|
|
25582
|
-
nativeSettingsDirty = currentRuntime() !== initialRuntime
|
|
26175
|
+
nativeSettingsDirty = currentRuntime() !== initialRuntime
|
|
26176
|
+
|| JSON.stringify(collectNativeSettingsPayload(controls)) !== JSON.stringify(initialPayload)
|
|
26177
|
+
|| controls.outputMode.select.value !== initialOutputModeDefault;
|
|
25583
26178
|
if (applyButton) {
|
|
25584
26179
|
applyButton.disabled = !nativeSettingsDirty;
|
|
25585
26180
|
applyButton.textContent = reloadNeeded() ? "Apply and reload" : "Apply";
|
|
@@ -25595,6 +26190,7 @@ async function openNativeSettingsDialog() {
|
|
|
25595
26190
|
try {
|
|
25596
26191
|
const requests = [];
|
|
25597
26192
|
const thinkingLevelChanged = controls.thinking.select.value !== (state.thinkingLevel || "off");
|
|
26193
|
+
const outputModeChanged = controls.outputMode.select.value !== initialOutputModeDefault;
|
|
25598
26194
|
if (thinkingLevelChanged) requests.push(nativeCommandApi("/api/thinking", { method: "POST", body: { level: controls.thinking.select.value } }));
|
|
25599
26195
|
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 } }));
|
|
25600
26196
|
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 } }));
|
|
@@ -25608,8 +26204,32 @@ async function openNativeSettingsDialog() {
|
|
|
25608
26204
|
const response = await nativeCommandApi("/api/settings", { method: "POST", body: { settings: payload, reload } });
|
|
25609
26205
|
applyResponseTab(response);
|
|
25610
26206
|
applyNativeSettingsForBrowser(response.data?.settings || payload);
|
|
26207
|
+
if (outputModeChanged) {
|
|
26208
|
+
try {
|
|
26209
|
+
await api("/api/webui-output-mode", {
|
|
26210
|
+
method: "PUT",
|
|
26211
|
+
body: { outputModeDefault: controls.outputMode.select.value },
|
|
26212
|
+
scoped: false,
|
|
26213
|
+
});
|
|
26214
|
+
const refreshedOutputMode = await api("/api/webui-output-mode", { scoped: false });
|
|
26215
|
+
outputModeMetadata = normalizeWebuiOutputModeMetadata(refreshedOutputMode.data);
|
|
26216
|
+
outputModeApiDiagnostic = "";
|
|
26217
|
+
sidebarOutputModeMetadata = outputModeMetadata;
|
|
26218
|
+
sidebarOutputModeDiagnostic = "";
|
|
26219
|
+
sidebarOutputModeNotice = "";
|
|
26220
|
+
sidebarOutputModeLoaded = true;
|
|
26221
|
+
renderSidebarOutputModeControl();
|
|
26222
|
+
} catch (error) {
|
|
26223
|
+
outputModeApiDiagnostic = `Output-mode API unavailable after saving: ${error.message || String(error)}. Showing the normal default; other settings can still be applied.`;
|
|
26224
|
+
outputModeMetadata = normalizeWebuiOutputModeMetadata();
|
|
26225
|
+
renderOutputModeMetadata();
|
|
26226
|
+
throw error;
|
|
26227
|
+
}
|
|
26228
|
+
renderOutputModeMetadata();
|
|
26229
|
+
}
|
|
25611
26230
|
if (thinkingLevelChanged) requestGitFooterWebuiPayload(activeTabContext(), { force: true });
|
|
25612
|
-
|
|
26231
|
+
const outputModeMessage = outputModeChanged ? ` ${webuiOutputModeMetadataText(outputModeMetadata)}` : "";
|
|
26232
|
+
addTransientMessage({ role: "native", title: "/settings", content: `${nativeSettingsChangedMessage(response, reload)}${outputModeMessage}`, level: response.data?.reloadRecommended?.length && !response.data?.reloaded ? "warn" : "info" });
|
|
25613
26233
|
nativeSettingsDirty = false;
|
|
25614
26234
|
closeNativeCommandDialog({ force: true });
|
|
25615
26235
|
await refreshAll();
|
|
@@ -26534,6 +27154,173 @@ function cancelStreamBubbleHide() {
|
|
|
26534
27154
|
streamBubbleHideTimer = null;
|
|
26535
27155
|
}
|
|
26536
27156
|
|
|
27157
|
+
function compactOutputActive() {
|
|
27158
|
+
return outputModeAcknowledged && activeOutputMode === "compact-v1";
|
|
27159
|
+
}
|
|
27160
|
+
|
|
27161
|
+
function outputModeAcknowledgement(event) {
|
|
27162
|
+
const outputMode = event?.outputMode;
|
|
27163
|
+
if (outputMode?.protocolVersion !== 1 || !["normal", "compact-v1"].includes(outputMode.activeMode)) return null;
|
|
27164
|
+
return outputMode;
|
|
27165
|
+
}
|
|
27166
|
+
|
|
27167
|
+
function removeCompactLiveBubble(bubble) {
|
|
27168
|
+
bubble?.remove();
|
|
27169
|
+
}
|
|
27170
|
+
|
|
27171
|
+
function resetCompactLiveOutput({ remove = true } = {}) {
|
|
27172
|
+
compactLiveScheduler.cancel();
|
|
27173
|
+
compactLiveState = createFastOutputLiveState();
|
|
27174
|
+
if (remove) {
|
|
27175
|
+
removeCompactLiveBubble(compactTextBubble);
|
|
27176
|
+
removeCompactLiveBubble(compactThinkingBubble);
|
|
27177
|
+
for (const shell of compactToolShells.values()) removeCompactLiveBubble(shell?.bubble);
|
|
27178
|
+
}
|
|
27179
|
+
compactTextBubble = null;
|
|
27180
|
+
compactTextNode = null;
|
|
27181
|
+
compactThinkingBubble = null;
|
|
27182
|
+
compactThinkingNode = null;
|
|
27183
|
+
compactToolShells.clear();
|
|
27184
|
+
}
|
|
27185
|
+
|
|
27186
|
+
function ensureCompactTextBubble() {
|
|
27187
|
+
if (compactTextBubble?.parentElement === elements.chat && compactTextNode) return;
|
|
27188
|
+
const created = appendMessage({ role: "assistant", title: "final output", timestamp: Date.now(), content: "" }, { streaming: true });
|
|
27189
|
+
compactTextBubble = created.bubble;
|
|
27190
|
+
compactTextBubble.classList.add("compact-live-output");
|
|
27191
|
+
compactTextNode = make("div", "compact-live-text");
|
|
27192
|
+
created.body.append(compactTextNode);
|
|
27193
|
+
renderRunIndicator({ scroll: false });
|
|
27194
|
+
}
|
|
27195
|
+
|
|
27196
|
+
function ensureCompactThinkingBubble() {
|
|
27197
|
+
if (!thinkingOutputVisible) return false;
|
|
27198
|
+
if (compactThinkingBubble?.parentElement === elements.chat && compactThinkingNode) return true;
|
|
27199
|
+
const created = appendMessage({ role: "thinking", title: "thinking", timestamp: Date.now(), content: "" }, { streaming: true });
|
|
27200
|
+
compactThinkingBubble = created.bubble;
|
|
27201
|
+
compactThinkingBubble.classList.add("compact-live-output");
|
|
27202
|
+
compactThinkingNode = make("div", "compact-live-thinking");
|
|
27203
|
+
created.body.append(compactThinkingNode);
|
|
27204
|
+
renderRunIndicator({ scroll: false });
|
|
27205
|
+
return true;
|
|
27206
|
+
}
|
|
27207
|
+
|
|
27208
|
+
function compactToolShellId(event) {
|
|
27209
|
+
const direct = String(event?.toolCallId || event?.id || "").trim();
|
|
27210
|
+
return direct || `compact-tool-${compactToolShells.size + 1}`;
|
|
27211
|
+
}
|
|
27212
|
+
|
|
27213
|
+
function renderCompactToolShell(event, { complete = false } = {}) {
|
|
27214
|
+
const id = compactToolShellId(event);
|
|
27215
|
+
let shell = compactToolShells.get(id);
|
|
27216
|
+
if (!shell) {
|
|
27217
|
+
const bubble = make("article", "message toolExecution compact-tool-shell streaming");
|
|
27218
|
+
const header = make("div", "message-header");
|
|
27219
|
+
const role = make("span", "message-role");
|
|
27220
|
+
const timestamp = make("span", "muted", formatDate(Date.now()));
|
|
27221
|
+
const body = make("div", "message-body");
|
|
27222
|
+
const status = make("div", "compact-tool-status");
|
|
27223
|
+
header.append(role, timestamp);
|
|
27224
|
+
body.append(status);
|
|
27225
|
+
bubble.append(header, body);
|
|
27226
|
+
bubble.dataset.toolCallId = id;
|
|
27227
|
+
appendChatMessageBubble(bubble);
|
|
27228
|
+
shell = { bubble, role, status };
|
|
27229
|
+
compactToolShells.set(id, shell);
|
|
27230
|
+
}
|
|
27231
|
+
const name = String(event?.toolName || event?.name || "tool");
|
|
27232
|
+
shell.role.textContent = `tool: ${name}`;
|
|
27233
|
+
shell.status.textContent = complete
|
|
27234
|
+
? `${name} ${event?.isError ? "failed" : "finished"}; restoring final details…`
|
|
27235
|
+
: `${name} running…`;
|
|
27236
|
+
shell.bubble.classList.toggle("tool-error", !!event?.isError);
|
|
27237
|
+
shell.bubble.classList.toggle("tool-running", !complete);
|
|
27238
|
+
shell.bubble.classList.toggle("tool-success", complete && !event?.isError);
|
|
27239
|
+
return shell;
|
|
27240
|
+
}
|
|
27241
|
+
|
|
27242
|
+
function flushCompactLiveOutput() {
|
|
27243
|
+
if (compactLiveState.text) {
|
|
27244
|
+
ensureCompactTextBubble();
|
|
27245
|
+
if (compactTextNode?.textContent !== compactLiveState.text) compactTextNode.textContent = compactLiveState.text;
|
|
27246
|
+
}
|
|
27247
|
+
if (compactLiveState.thinking && ensureCompactThinkingBubble()) {
|
|
27248
|
+
if (compactThinkingNode?.textContent !== compactLiveState.thinking) compactThinkingNode.textContent = compactLiveState.thinking;
|
|
27249
|
+
}
|
|
27250
|
+
scheduleChatFollowScroll();
|
|
27251
|
+
}
|
|
27252
|
+
|
|
27253
|
+
function finishCompactLiveOutput(tabContext = activeTabContext()) {
|
|
27254
|
+
compactLiveScheduler.flushNow();
|
|
27255
|
+
scheduleRefreshMessages(0, tabContext);
|
|
27256
|
+
}
|
|
27257
|
+
|
|
27258
|
+
function handleCompactMessageUpdate(event) {
|
|
27259
|
+
const reduced = reduceFastOutputLiveEvent(compactLiveState, event);
|
|
27260
|
+
if (!shouldConsumeFastOutputLiveEvent(reduced)) return false;
|
|
27261
|
+
if (!reduced.changed) return true;
|
|
27262
|
+
compactLiveState = reduced.state;
|
|
27263
|
+
if (reduced.kind.startsWith("thinking")) setRunIndicatorActivity("Thinking…", { scroll: false });
|
|
27264
|
+
else if (reduced.kind.startsWith("toolcall")) setRunIndicatorActivity("Building tool call…", { scroll: false });
|
|
27265
|
+
else setRunIndicatorActivity("Writing response…", { scroll: false });
|
|
27266
|
+
compactLiveScheduler.request();
|
|
27267
|
+
return true;
|
|
27268
|
+
}
|
|
27269
|
+
|
|
27270
|
+
function acceptOutputModeAcknowledgement(event) {
|
|
27271
|
+
const acknowledgement = outputModeAcknowledgement(event);
|
|
27272
|
+
if (acknowledgement) {
|
|
27273
|
+
activeOutputMode = acknowledgement.activeMode;
|
|
27274
|
+
outputModeAcknowledged = true;
|
|
27275
|
+
return true;
|
|
27276
|
+
}
|
|
27277
|
+
activeOutputMode = "normal";
|
|
27278
|
+
outputModeAcknowledged = false;
|
|
27279
|
+
if (!eventSourceOutputModeFallbackAttempted) {
|
|
27280
|
+
eventSourceOutputModeFallbackAttempted = true;
|
|
27281
|
+
queueMicrotask(() => connectEvents(activeTabContext(), { requestedMode: "normal", fallbackAttempted: true }));
|
|
27282
|
+
}
|
|
27283
|
+
return false;
|
|
27284
|
+
}
|
|
27285
|
+
|
|
27286
|
+
function transitionNormalLiveOutputToCompact() {
|
|
27287
|
+
compactLiveState = seedFastOutputLiveState({ text: streamRawText, thinking: streamThinkingRawText });
|
|
27288
|
+
setStreamRawText("");
|
|
27289
|
+
setStreamThinkingRawText("");
|
|
27290
|
+
removeStreamBubble();
|
|
27291
|
+
removeStreamingThinkingBubble();
|
|
27292
|
+
flushCompactLiveOutput();
|
|
27293
|
+
}
|
|
27294
|
+
|
|
27295
|
+
function transitionCompactLiveOutputToNormal(tabContext = activeTabContext()) {
|
|
27296
|
+
finishCompactLiveOutput(tabContext);
|
|
27297
|
+
const live = fastOutputLiveTextAndThinking(compactLiveState);
|
|
27298
|
+
resetCompactLiveOutput();
|
|
27299
|
+
setStreamRawText(live.text);
|
|
27300
|
+
setStreamThinkingRawText(live.thinking);
|
|
27301
|
+
if (live.thinking) setStreamingThinkingText(live.thinking);
|
|
27302
|
+
if (live.text) renderStreamingAssistantText();
|
|
27303
|
+
}
|
|
27304
|
+
|
|
27305
|
+
function applyOutputModeControl(event, tabContext = activeTabContext()) {
|
|
27306
|
+
if (event?.protocolVersion !== 1 || !["normal", "compact-v1"].includes(event.activeMode)) return false;
|
|
27307
|
+
const previousMode = activeOutputMode;
|
|
27308
|
+
if (previousMode === "normal" && event.activeMode === "compact-v1") {
|
|
27309
|
+
transitionNormalLiveOutputToCompact();
|
|
27310
|
+
} else if (previousMode === "compact-v1" && event.activeMode === "normal") {
|
|
27311
|
+
transitionCompactLiveOutputToNormal(tabContext);
|
|
27312
|
+
} else if (previousMode === "compact-v1") {
|
|
27313
|
+
finishCompactLiveOutput(tabContext);
|
|
27314
|
+
resetCompactLiveOutput();
|
|
27315
|
+
} else if (event.activeMode === "normal") {
|
|
27316
|
+
resetCompactLiveOutput();
|
|
27317
|
+
}
|
|
27318
|
+
activeOutputMode = event.activeMode;
|
|
27319
|
+
outputModeAcknowledged = true;
|
|
27320
|
+
addEvent(`live output mode changed to ${event.activeMode}`, "info");
|
|
27321
|
+
return true;
|
|
27322
|
+
}
|
|
27323
|
+
|
|
26537
27324
|
function cancelStreamingAssistantTextRender() {
|
|
26538
27325
|
clearTimeout(streamTextRenderTimer);
|
|
26539
27326
|
streamTextRenderTimer = null;
|
|
@@ -26729,6 +27516,7 @@ function showStreamingThinking(initialText = "") {
|
|
|
26729
27516
|
}
|
|
26730
27517
|
|
|
26731
27518
|
function resetStreamBubble() {
|
|
27519
|
+
resetCompactLiveOutput();
|
|
26732
27520
|
cancelStreamingAssistantTextRender();
|
|
26733
27521
|
cancelStreamBubbleHide();
|
|
26734
27522
|
streamBubble = null;
|
|
@@ -26743,6 +27531,7 @@ function resetStreamBubble() {
|
|
|
26743
27531
|
streamThinkingBubble = null;
|
|
26744
27532
|
streamThinking = null;
|
|
26745
27533
|
streamMessageActive = false;
|
|
27534
|
+
streamProviderErrorText = "";
|
|
26746
27535
|
}
|
|
26747
27536
|
|
|
26748
27537
|
function liveStreamRenderActive() {
|
|
@@ -26919,7 +27708,19 @@ function syncStreamingThinkingFromUpdate(event, update, { placeholder = "" } = {
|
|
|
26919
27708
|
return setStreamingThinkingText(streamThinkingRawText || placeholder);
|
|
26920
27709
|
}
|
|
26921
27710
|
|
|
27711
|
+
function assistantStreamErrorMessage(event, update = event?.assistantMessageEvent || {}) {
|
|
27712
|
+
return String(
|
|
27713
|
+
update.error?.errorMessage ||
|
|
27714
|
+
update.errorMessage ||
|
|
27715
|
+
update.partial?.errorMessage ||
|
|
27716
|
+
event?.message?.errorMessage ||
|
|
27717
|
+
update.reason ||
|
|
27718
|
+
"assistant error"
|
|
27719
|
+
).trim();
|
|
27720
|
+
}
|
|
27721
|
+
|
|
26922
27722
|
function handleMessageUpdate(event) {
|
|
27723
|
+
if (compactOutputActive() && handleCompactMessageUpdate(event)) return;
|
|
26923
27724
|
const update = event.assistantMessageEvent || {};
|
|
26924
27725
|
if (update.type === "thinking_start") {
|
|
26925
27726
|
setRunIndicatorActivity("Thinking…", { scroll: false });
|
|
@@ -26963,8 +27764,9 @@ function handleMessageUpdate(event) {
|
|
|
26963
27764
|
const name = updateStreamingToolCallFromEvent(event, { complete: true, scroll: true });
|
|
26964
27765
|
setRunIndicatorActivity(`Tool call ready: ${name}; waiting to run…`, { scroll: false });
|
|
26965
27766
|
} else if (update.type === "error") {
|
|
27767
|
+
streamProviderErrorText = assistantStreamErrorMessage(event, update);
|
|
26966
27768
|
setRunIndicatorActivity("Assistant stream reported an error…");
|
|
26967
|
-
appendMessage({ role: "error", title: "assistant error", timestamp: Date.now(), content:
|
|
27769
|
+
appendMessage({ role: "error", title: "assistant error", timestamp: Date.now(), content: streamProviderErrorText, level: "error" }, { streaming: true });
|
|
26968
27770
|
renderRunIndicator({ scroll: false });
|
|
26969
27771
|
scheduleChatFollowScroll();
|
|
26970
27772
|
}
|
|
@@ -28789,6 +29591,10 @@ function handleExtensionUiRequest(request) {
|
|
|
28789
29591
|
}
|
|
28790
29592
|
case "setStatus": {
|
|
28791
29593
|
const statusKey = request.statusKey || "extension";
|
|
29594
|
+
if (statusKey === FEATURE_CATEGORY_STATUS_KEY) {
|
|
29595
|
+
handleFeatureCategoryStatus(request.statusText, request.tabId || activeTabId);
|
|
29596
|
+
return;
|
|
29597
|
+
}
|
|
28792
29598
|
if (request.statusText) {
|
|
28793
29599
|
statusEntries.set(statusKey, request.statusText);
|
|
28794
29600
|
if (statusKey === GIT_FOOTER_WEBUI_STATUS_KEY) cacheGitFooterWebuiPayload(request.statusText, request.tabId);
|
|
@@ -28913,6 +29719,180 @@ function addDialogButton(label, handler, className) {
|
|
|
28913
29719
|
return button;
|
|
28914
29720
|
}
|
|
28915
29721
|
|
|
29722
|
+
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;
|
|
29723
|
+
|
|
29724
|
+
function isWorkflowScriptPreviewRequest(request, prompt) {
|
|
29725
|
+
const title = String(prompt?.title || "");
|
|
29726
|
+
return request?.method === "editor"
|
|
29727
|
+
&& title.startsWith("Raw workflow script")
|
|
29728
|
+
&& /\binspection only;\s*edits are ignored\b/i.test(title);
|
|
29729
|
+
}
|
|
29730
|
+
|
|
29731
|
+
function workflowScriptTokenClass(token) {
|
|
29732
|
+
if (/^\/\//.test(token) || /^\/\*/.test(token)) return "comment";
|
|
29733
|
+
if (/^[`"']/.test(token)) return "string";
|
|
29734
|
+
if (/^\d/.test(token)) return "number";
|
|
29735
|
+
return "keyword";
|
|
29736
|
+
}
|
|
29737
|
+
|
|
29738
|
+
function appendWorkflowScriptTokens(parent, line) {
|
|
29739
|
+
let start = 0;
|
|
29740
|
+
WORKFLOW_SCRIPT_TOKEN_PATTERN.lastIndex = 0;
|
|
29741
|
+
for (let match = WORKFLOW_SCRIPT_TOKEN_PATTERN.exec(line); match; match = WORKFLOW_SCRIPT_TOKEN_PATTERN.exec(line)) {
|
|
29742
|
+
if (match.index > start) parent.append(document.createTextNode(line.slice(start, match.index)));
|
|
29743
|
+
parent.append(make("span", `workflow-script-token workflow-script-token-${workflowScriptTokenClass(match[0])}`, match[0]));
|
|
29744
|
+
start = match.index + match[0].length;
|
|
29745
|
+
}
|
|
29746
|
+
if (start < line.length) parent.append(document.createTextNode(line.slice(start)));
|
|
29747
|
+
}
|
|
29748
|
+
|
|
29749
|
+
function renderWorkflowScriptPreview(request) {
|
|
29750
|
+
const source = request.prefill ?? "";
|
|
29751
|
+
const sourceLines = source.split("\n");
|
|
29752
|
+
const searchableLines = sourceLines.map((line) => line.toLocaleLowerCase());
|
|
29753
|
+
const preview = make("section", "workflow-script-preview");
|
|
29754
|
+
preview.setAttribute("aria-label", "Read-only TypeScript workflow script");
|
|
29755
|
+
|
|
29756
|
+
const metadata = make("div", "workflow-script-meta");
|
|
29757
|
+
metadata.append(
|
|
29758
|
+
make("span", "workflow-script-language", "TypeScript · read-only"),
|
|
29759
|
+
make("span", "workflow-script-source-stats", `${sourceLines.length.toLocaleString()} ${sourceLines.length === 1 ? "line" : "lines"} · ${source.length.toLocaleString()} characters`),
|
|
29760
|
+
);
|
|
29761
|
+
|
|
29762
|
+
const toolbar = make("div", "workflow-script-toolbar");
|
|
29763
|
+
const search = make("input", "workflow-script-search");
|
|
29764
|
+
search.type = "search";
|
|
29765
|
+
search.placeholder = "Search source";
|
|
29766
|
+
search.setAttribute("aria-label", "Search workflow source");
|
|
29767
|
+
|
|
29768
|
+
const previous = make("button", "workflow-script-search-button", "Previous match");
|
|
29769
|
+
previous.type = "button";
|
|
29770
|
+
previous.title = "Previous search match";
|
|
29771
|
+
previous.setAttribute("aria-label", "Previous search match");
|
|
29772
|
+
previous.disabled = true;
|
|
29773
|
+
|
|
29774
|
+
const next = make("button", "workflow-script-search-button", "Next match");
|
|
29775
|
+
next.type = "button";
|
|
29776
|
+
next.title = "Next search match";
|
|
29777
|
+
next.setAttribute("aria-label", "Next search match");
|
|
29778
|
+
next.disabled = true;
|
|
29779
|
+
|
|
29780
|
+
const wrap = make("button", "workflow-script-wrap-button", "Wrap lines");
|
|
29781
|
+
wrap.type = "button";
|
|
29782
|
+
wrap.title = "Wrap long lines";
|
|
29783
|
+
wrap.setAttribute("aria-label", "Wrap long lines");
|
|
29784
|
+
wrap.setAttribute("aria-pressed", "false");
|
|
29785
|
+
|
|
29786
|
+
const copy = make("button", "workflow-script-copy-button", "Copy source");
|
|
29787
|
+
copy.type = "button";
|
|
29788
|
+
copy.title = "Copy workflow source";
|
|
29789
|
+
copy.setAttribute("aria-label", "Copy workflow source");
|
|
29790
|
+
|
|
29791
|
+
const searchStatus = make("span", "workflow-script-search-status", "Search source.");
|
|
29792
|
+
searchStatus.setAttribute("role", "status");
|
|
29793
|
+
searchStatus.setAttribute("aria-live", "polite");
|
|
29794
|
+
const copyStatus = make("span", "workflow-script-copy-status");
|
|
29795
|
+
copyStatus.setAttribute("role", "status");
|
|
29796
|
+
copyStatus.setAttribute("aria-live", "polite");
|
|
29797
|
+
toolbar.append(search, previous, next, wrap, copy, searchStatus, copyStatus);
|
|
29798
|
+
|
|
29799
|
+
const codeViewer = make("div", "workflow-script-code");
|
|
29800
|
+
codeViewer.id = "workflowScriptViewer";
|
|
29801
|
+
codeViewer.tabIndex = 0;
|
|
29802
|
+
codeViewer.setAttribute("role", "region");
|
|
29803
|
+
codeViewer.setAttribute("aria-label", "Read-only workflow source with line numbers");
|
|
29804
|
+
search.setAttribute("aria-controls", codeViewer.id);
|
|
29805
|
+
|
|
29806
|
+
const lineRows = sourceLines.map((line, index) => {
|
|
29807
|
+
const row = make("div", "workflow-script-line");
|
|
29808
|
+
row.dataset.line = String(index + 1);
|
|
29809
|
+
const number = make("span", "workflow-script-line-number", String(index + 1));
|
|
29810
|
+
number.setAttribute("aria-hidden", "true");
|
|
29811
|
+
const text = make("code", "workflow-script-line-text");
|
|
29812
|
+
appendWorkflowScriptTokens(text, line);
|
|
29813
|
+
row.append(number, text);
|
|
29814
|
+
codeViewer.append(row);
|
|
29815
|
+
return row;
|
|
29816
|
+
});
|
|
29817
|
+
|
|
29818
|
+
let matchingLineIndexes = [];
|
|
29819
|
+
let activeMatchIndex = -1;
|
|
29820
|
+
const setActiveMatch = (index, { scroll = true } = {}) => {
|
|
29821
|
+
if (matchingLineIndexes.length === 0) return;
|
|
29822
|
+
activeMatchIndex = (index + matchingLineIndexes.length) % matchingLineIndexes.length;
|
|
29823
|
+
const activeLine = matchingLineIndexes[activeMatchIndex];
|
|
29824
|
+
lineRows.forEach((row, lineIndex) => {
|
|
29825
|
+
const active = lineIndex === activeLine;
|
|
29826
|
+
row.classList.toggle("is-active-match", active);
|
|
29827
|
+
if (active) row.setAttribute("aria-current", "true");
|
|
29828
|
+
else row.removeAttribute("aria-current");
|
|
29829
|
+
});
|
|
29830
|
+
searchStatus.textContent = `${activeMatchIndex + 1} of ${matchingLineIndexes.length} matching ${matchingLineIndexes.length === 1 ? "line" : "lines"}.`;
|
|
29831
|
+
if (scroll) lineRows[activeLine].scrollIntoView({ block: "center" });
|
|
29832
|
+
};
|
|
29833
|
+
const updateMatches = () => {
|
|
29834
|
+
const query = search.value.toLocaleLowerCase();
|
|
29835
|
+
matchingLineIndexes = [];
|
|
29836
|
+
if (query) {
|
|
29837
|
+
searchableLines.forEach((line, index) => {
|
|
29838
|
+
if (line.includes(query)) matchingLineIndexes.push(index);
|
|
29839
|
+
});
|
|
29840
|
+
}
|
|
29841
|
+
const matchingLineSet = new Set(matchingLineIndexes);
|
|
29842
|
+
lineRows.forEach((row, index) => {
|
|
29843
|
+
const matched = matchingLineSet.has(index);
|
|
29844
|
+
row.classList.toggle("is-search-match", matched);
|
|
29845
|
+
row.classList.remove("is-active-match");
|
|
29846
|
+
row.removeAttribute("aria-current");
|
|
29847
|
+
});
|
|
29848
|
+
activeMatchIndex = -1;
|
|
29849
|
+
previous.disabled = matchingLineIndexes.length === 0;
|
|
29850
|
+
next.disabled = matchingLineIndexes.length === 0;
|
|
29851
|
+
if (matchingLineIndexes.length > 0) setActiveMatch(0);
|
|
29852
|
+
else searchStatus.textContent = query ? "No matching lines." : "Search source.";
|
|
29853
|
+
};
|
|
29854
|
+
|
|
29855
|
+
search.addEventListener("input", updateMatches);
|
|
29856
|
+
search.addEventListener("keydown", (event) => {
|
|
29857
|
+
if (event.key !== "Enter") return;
|
|
29858
|
+
event.preventDefault();
|
|
29859
|
+
if (matchingLineIndexes.length === 0) return;
|
|
29860
|
+
setActiveMatch(activeMatchIndex + (event.shiftKey ? -1 : 1));
|
|
29861
|
+
});
|
|
29862
|
+
previous.addEventListener("click", () => setActiveMatch(activeMatchIndex - 1));
|
|
29863
|
+
next.addEventListener("click", () => setActiveMatch(activeMatchIndex + 1));
|
|
29864
|
+
wrap.addEventListener("click", () => {
|
|
29865
|
+
const wrapped = codeViewer.classList.toggle("is-wrapped");
|
|
29866
|
+
wrap.textContent = wrapped ? "Unwrap lines" : "Wrap lines";
|
|
29867
|
+
wrap.title = wrapped ? "Do not wrap long lines" : "Wrap long lines";
|
|
29868
|
+
wrap.setAttribute("aria-label", wrap.title);
|
|
29869
|
+
wrap.setAttribute("aria-pressed", String(wrapped));
|
|
29870
|
+
});
|
|
29871
|
+
copy.addEventListener("click", async () => {
|
|
29872
|
+
copy.disabled = true;
|
|
29873
|
+
try {
|
|
29874
|
+
await copyText(source);
|
|
29875
|
+
copy.textContent = "Copied";
|
|
29876
|
+
copyStatus.textContent = "Workflow source copied.";
|
|
29877
|
+
} catch (error) {
|
|
29878
|
+
copy.textContent = "Copy failed";
|
|
29879
|
+
copyStatus.textContent = "Could not copy workflow source.";
|
|
29880
|
+
} finally {
|
|
29881
|
+
window.setTimeout(() => {
|
|
29882
|
+
if (!copy.isConnected) return;
|
|
29883
|
+
copy.textContent = "Copy source";
|
|
29884
|
+
copy.disabled = false;
|
|
29885
|
+
}, 1600);
|
|
29886
|
+
}
|
|
29887
|
+
});
|
|
29888
|
+
|
|
29889
|
+
preview.append(metadata, toolbar, codeViewer);
|
|
29890
|
+
elements.dialogBody.append(preview);
|
|
29891
|
+
addDialogButton("Cancel workflow", () => sendDialogResponse({ type: "extension_ui_response", id: request.id, cancelled: true, tabId: request.tabId }));
|
|
29892
|
+
addDialogButton("Back to approval", () => sendDialogResponse({ type: "extension_ui_response", id: request.id, value: request.prefill, tabId: request.tabId }), "primary");
|
|
29893
|
+
setTimeout(() => codeViewer.focus(), 0);
|
|
29894
|
+
}
|
|
29895
|
+
|
|
28916
29896
|
function showNextDialog() {
|
|
28917
29897
|
if (activeDialog || dialogQueue.length === 0) return;
|
|
28918
29898
|
activeDialog = dialogQueue.shift();
|
|
@@ -28924,8 +29904,10 @@ function showNextDialog() {
|
|
|
28924
29904
|
const displayPrompt = releasePrompt || prompt;
|
|
28925
29905
|
const isGuardrailDialog = isGuardrailDialogPrompt(displayPrompt);
|
|
28926
29906
|
const isReleaseDialog = !!releasePrompt;
|
|
29907
|
+
const isWorkflowScriptPreview = isWorkflowScriptPreviewRequest(request, prompt);
|
|
28927
29908
|
elements.dialog.classList.toggle("guardrail-dialog", isGuardrailDialog);
|
|
28928
29909
|
elements.dialog.classList.toggle("release-dialog", isReleaseDialog);
|
|
29910
|
+
elements.dialog.classList.toggle("workflow-script-dialog", isWorkflowScriptPreview);
|
|
28929
29911
|
elements.dialogTitle.textContent = displayPrompt.title;
|
|
28930
29912
|
if (isReleaseDialog) renderReleaseDialogMessage(elements.dialogMessage, displayPrompt.message);
|
|
28931
29913
|
else renderAnsiText(elements.dialogMessage, displayPrompt.message);
|
|
@@ -28965,6 +29947,8 @@ function showNextDialog() {
|
|
|
28965
29947
|
addDialogButton("Cancel", cancel);
|
|
28966
29948
|
addDialogButton("Submit", () => sendDialogResponse({ type: "extension_ui_response", id: request.id, value: input.value, tabId: request.tabId }), "primary");
|
|
28967
29949
|
setTimeout(() => input.focus(), 0);
|
|
29950
|
+
} else if (isWorkflowScriptPreview) {
|
|
29951
|
+
renderWorkflowScriptPreview(request);
|
|
28968
29952
|
} else if (request.method === "editor") {
|
|
28969
29953
|
const textarea = make("textarea", "dialog-editor");
|
|
28970
29954
|
textarea.value = request.prefill || "";
|
|
@@ -29015,7 +29999,11 @@ function handleEvent(event) {
|
|
|
29015
29999
|
}
|
|
29016
30000
|
const tabContext = activeTabContext(event.tabId || activeTabId);
|
|
29017
30001
|
switch (event.type) {
|
|
29018
|
-
case "webui_connected":
|
|
30002
|
+
case "webui_connected": {
|
|
30003
|
+
const connectedTabId = event.tabId || activeTabId;
|
|
30004
|
+
featureCategoryByTab.delete(connectedTabId);
|
|
30005
|
+
if (connectedTabId === activeTabId) renderFeatureCategoryTag(connectedTabId);
|
|
30006
|
+
acceptOutputModeAcknowledgement(event);
|
|
29019
30007
|
setWebuiVersion(event.version);
|
|
29020
30008
|
setPiVersion(event.piVersion);
|
|
29021
30009
|
setWebuiDevServer(isWebuiDevMetadata(event));
|
|
@@ -29027,6 +30015,10 @@ function handleEvent(event) {
|
|
|
29027
30015
|
addEvent(`connected to ${event.tabTitle || "terminal"} for ${event.cwd}`);
|
|
29028
30016
|
scheduleForegroundReconcile("event stream reconnect", 0);
|
|
29029
30017
|
break;
|
|
30018
|
+
}
|
|
30019
|
+
case "webui_output_mode":
|
|
30020
|
+
applyOutputModeControl(event, tabContext);
|
|
30021
|
+
break;
|
|
29030
30022
|
case "webui_tab_renamed":
|
|
29031
30023
|
applyTabMetadata(event.tab || { id: event.tabId, title: event.tabTitle, activity: event.tabActivity });
|
|
29032
30024
|
addEvent(`${event.previousTabTitle || "terminal"} renamed to ${event.tabTitle || "terminal"}`);
|
|
@@ -29087,6 +30079,9 @@ function handleEvent(event) {
|
|
|
29087
30079
|
renderWidgets();
|
|
29088
30080
|
renderTabs();
|
|
29089
30081
|
break;
|
|
30082
|
+
case "webui_git_changed":
|
|
30083
|
+
invalidateGitPanelRepository(event.root);
|
|
30084
|
+
break;
|
|
29090
30085
|
case "webui_cwd_changed":
|
|
29091
30086
|
addEvent(`${event.tabTitle || "terminal"} cwd changed to ${event.cwd}`);
|
|
29092
30087
|
setAppRunnerData(event.tabId || activeTabId, { cwd: event.cwd, activeRun: null, runners: [] });
|
|
@@ -29119,21 +30114,26 @@ function handleEvent(event) {
|
|
|
29119
30114
|
renderNetworkStatus();
|
|
29120
30115
|
break;
|
|
29121
30116
|
case "pi_process_exit":
|
|
29122
|
-
|
|
30117
|
+
if (compactOutputActive()) compactLiveScheduler.flushNow();
|
|
30118
|
+
surfaceRuntimeDiagnostic("Pi process exited", `Pi RPC exited (${event.code ?? event.signal ?? "unknown"}).`);
|
|
29123
30119
|
clearRunIndicatorActivity();
|
|
29124
30120
|
refreshTabs().catch((error) => addEvent(error.message, "error"));
|
|
29125
30121
|
break;
|
|
29126
30122
|
case "pi_process_error":
|
|
29127
|
-
|
|
30123
|
+
if (compactOutputActive()) compactLiveScheduler.flushNow();
|
|
30124
|
+
surfaceRuntimeDiagnostic("Pi process error", event.error || "Pi RPC process error.");
|
|
29128
30125
|
clearRunIndicatorActivity();
|
|
29129
30126
|
refreshTabs().catch((error) => addEvent(error.message, "error"));
|
|
29130
30127
|
break;
|
|
29131
|
-
case "pi_stderr":
|
|
29132
|
-
|
|
30128
|
+
case "pi_stderr": {
|
|
30129
|
+
const message = String(event.text || "").trim();
|
|
30130
|
+
if (message) surfaceRuntimeDiagnostic("Pi runtime diagnostic", message, stderrDiagnosticLevel(message));
|
|
29133
30131
|
break;
|
|
30132
|
+
}
|
|
29134
30133
|
case "pi_stderr_sink_error":
|
|
29135
30134
|
case "pi_stdout_line_too_large":
|
|
29136
|
-
|
|
30135
|
+
case "pi_stdout_parse_error":
|
|
30136
|
+
surfaceRuntimeDiagnostic("Pi RPC transport error", event.error || "Pi RPC transport diagnostic.");
|
|
29137
30137
|
break;
|
|
29138
30138
|
case "queue_update":
|
|
29139
30139
|
renderQueue(event);
|
|
@@ -29157,6 +30157,7 @@ function handleEvent(event) {
|
|
|
29157
30157
|
scheduleRefreshState();
|
|
29158
30158
|
break;
|
|
29159
30159
|
case "agent_start":
|
|
30160
|
+
assistantErrorSurfacedThisRun = false;
|
|
29160
30161
|
if (currentState) currentState = { ...currentState, isStreaming: true };
|
|
29161
30162
|
if (voiceConversationActiveFor(event.tabId || activeTabId)) voiceConversation.setAssistantActivity({ streaming: true });
|
|
29162
30163
|
setRunIndicatorActivity("Agent run started; waiting for first output or action…");
|
|
@@ -29166,7 +30167,15 @@ function handleEvent(event) {
|
|
|
29166
30167
|
renderFeedbackTray();
|
|
29167
30168
|
break;
|
|
29168
30169
|
case "agent_end":
|
|
30170
|
+
if (compactOutputActive()) finishCompactLiveOutput(tabContext);
|
|
29169
30171
|
streamMessageActive = false;
|
|
30172
|
+
if (!assistantErrorSurfacedThisRun && event.willRetry !== true) {
|
|
30173
|
+
const message = assistantErrorFromAgentEnd(event);
|
|
30174
|
+
if (message) {
|
|
30175
|
+
surfaceRuntimeDiagnostic("Assistant error", message);
|
|
30176
|
+
assistantErrorSurfacedThisRun = true;
|
|
30177
|
+
}
|
|
30178
|
+
}
|
|
29170
30179
|
addEvent("agent finished");
|
|
29171
30180
|
notifyAgentDone(event.tabId || activeTabId, { activity: event.tabActivity, tabTitle: event.tabTitle });
|
|
29172
30181
|
clearContextUsageUnknownAfterCompaction(event.tabId || activeTabId);
|
|
@@ -29188,7 +30197,7 @@ function handleEvent(event) {
|
|
|
29188
30197
|
const workflowTabId = event.tabId || activeTabId;
|
|
29189
30198
|
const workflow = gitWorkflowForTab(workflowTabId, { create: false });
|
|
29190
30199
|
if (workflow?.active && workflow.step === "generating") {
|
|
29191
|
-
loadGitWorkflowMessage({ requireFresh: true,
|
|
30200
|
+
loadGitWorkflowMessage({ requireFresh: true, generationId: workflow.messageGenerationId, runId: workflow.runId, tabId: workflowTabId });
|
|
29192
30201
|
} else if (workflow?.active && workflow.step === "branchNaming") {
|
|
29193
30202
|
loadGitWorkflowBranchName({ requireFresh: true, retries: 3, runId: workflow.runId, tabId: workflowTabId });
|
|
29194
30203
|
} else if (workflow?.active && workflow.step === "prGenerating") {
|
|
@@ -29206,36 +30215,57 @@ function handleEvent(event) {
|
|
|
29206
30215
|
case "message_update":
|
|
29207
30216
|
handleMessageUpdate(event);
|
|
29208
30217
|
break;
|
|
29209
|
-
case "message_end":
|
|
30218
|
+
case "message_end": {
|
|
30219
|
+
if (compactOutputActive()) finishCompactLiveOutput(tabContext);
|
|
29210
30220
|
streamMessageActive = false;
|
|
30221
|
+
if (event.message?.role === "assistant" && event.message.stopReason === "error") {
|
|
30222
|
+
const message = String(event.message.errorMessage || streamProviderErrorText || "The assistant request failed without an error message.").trim();
|
|
30223
|
+
surfaceRuntimeDiagnostic("Assistant error", message);
|
|
30224
|
+
assistantErrorSurfacedThisRun = true;
|
|
30225
|
+
}
|
|
30226
|
+
streamProviderErrorText = "";
|
|
29211
30227
|
if (runIndicatorIsActive()) setRunIndicatorActivity("Assistant message finished; waiting for the next step…", { scroll: false });
|
|
29212
30228
|
scheduleRefreshMessages();
|
|
29213
30229
|
scheduleRefreshState();
|
|
29214
30230
|
scheduleRefreshFooter();
|
|
29215
30231
|
break;
|
|
30232
|
+
}
|
|
29216
30233
|
case "tool_execution_start":
|
|
29217
30234
|
streamToolCallSeen = true;
|
|
29218
30235
|
if (voiceConversationActiveFor(event.tabId || activeTabId)) voiceConversation.setAssistantActivity({ toolRunning: true });
|
|
29219
|
-
|
|
29220
|
-
|
|
29221
|
-
|
|
30236
|
+
if (compactOutputActive()) {
|
|
30237
|
+
compactLiveScheduler.flushNow();
|
|
30238
|
+
renderCompactToolShell(event);
|
|
30239
|
+
} else {
|
|
30240
|
+
suppressStreamingAssistantTextBeforeToolCall();
|
|
30241
|
+
removeStreamingToolCallCard();
|
|
30242
|
+
handleToolExecutionStart(event);
|
|
30243
|
+
}
|
|
29222
30244
|
setRunIndicatorActivity(`Running tool: ${runIndicatorToolName(event.toolName)}…`);
|
|
29223
30245
|
addEvent(`tool ${event.toolName} started`, "info", { toolCallId: event.toolCallId });
|
|
29224
30246
|
break;
|
|
29225
30247
|
case "tool_execution_update":
|
|
29226
|
-
handleToolExecutionUpdate(event);
|
|
30248
|
+
if (!compactOutputActive()) handleToolExecutionUpdate(event);
|
|
29227
30249
|
setRunIndicatorActivity(`Running tool: ${runIndicatorToolName(event.toolName)}…`, { scroll: false });
|
|
29228
30250
|
break;
|
|
29229
|
-
case "tool_execution_end":
|
|
30251
|
+
case "tool_execution_end": {
|
|
29230
30252
|
if (voiceConversationActiveFor(event.tabId || activeTabId)) voiceConversation.setAssistantActivity({ toolRunning: false });
|
|
29231
|
-
|
|
30253
|
+
const imagePayloadError = toolImagePayloadError(event);
|
|
30254
|
+
if (imagePayloadError) surfaceRuntimeDiagnostic("Tool image payload error", imagePayloadError);
|
|
30255
|
+
if (compactOutputActive()) {
|
|
30256
|
+
compactLiveScheduler.flushNow();
|
|
30257
|
+
renderCompactToolShell(event, { complete: true });
|
|
30258
|
+
finishCompactLiveOutput(tabContext);
|
|
30259
|
+
} else {
|
|
30260
|
+
handleToolExecutionEnd(event);
|
|
30261
|
+
}
|
|
29232
30262
|
setRunIndicatorActivity(`Tool ${runIndicatorToolName(event.toolName)} ${event.isError ? "failed" : "finished"}; waiting for the agent's next step…`);
|
|
29233
30263
|
addEvent(`tool ${event.toolName} ${event.isError ? "failed" : "finished"}`, event.isError ? "error" : "info", { toolCallId: event.toolCallId });
|
|
29234
|
-
//
|
|
29235
|
-
//
|
|
29236
|
-
// transcript. This avoids one fetch+render per tool call.
|
|
30264
|
+
// Compact tool shells deliberately defer rich body construction to the
|
|
30265
|
+
// final transcript reconciliation; normal mode retains its live card.
|
|
29237
30266
|
scheduleRefreshFooter();
|
|
29238
30267
|
break;
|
|
30268
|
+
}
|
|
29239
30269
|
case "compaction_start":
|
|
29240
30270
|
if (currentState) currentState = { ...currentState, isCompacting: true };
|
|
29241
30271
|
markContextUsageUnknownAfterCompaction(event.tabId || activeTabId);
|
|
@@ -29244,10 +30274,12 @@ function handleEvent(event) {
|
|
|
29244
30274
|
renderStatus();
|
|
29245
30275
|
break;
|
|
29246
30276
|
case "compaction_end":
|
|
30277
|
+
if (compactOutputActive()) finishCompactLiveOutput(tabContext);
|
|
29247
30278
|
if (currentState) currentState = { ...currentState, isCompacting: false };
|
|
29248
30279
|
if (event.aborted) clearContextUsageUnknownAfterCompaction(event.tabId || activeTabId);
|
|
29249
30280
|
else markContextUsageUnknownAfterCompaction(event.tabId || activeTabId);
|
|
29250
|
-
|
|
30281
|
+
if (event.errorMessage) surfaceRuntimeDiagnostic("Compaction error", event.errorMessage);
|
|
30282
|
+
else addEvent(`compaction ${event.aborted ? "aborted" : "finished"}`);
|
|
29251
30283
|
if (!currentState?.isStreaming) clearRunIndicatorActivity();
|
|
29252
30284
|
markTabOutputSeen();
|
|
29253
30285
|
renderStatus();
|
|
@@ -29255,6 +30287,9 @@ function handleEvent(event) {
|
|
|
29255
30287
|
scheduleRefreshMessages();
|
|
29256
30288
|
scheduleRefreshFooter();
|
|
29257
30289
|
break;
|
|
30290
|
+
case "agent_settled":
|
|
30291
|
+
if (compactOutputActive()) finishCompactLiveOutput(tabContext);
|
|
30292
|
+
break;
|
|
29258
30293
|
case "auto_retry_start": {
|
|
29259
30294
|
const seconds = Math.max(0, Math.ceil(Number(event.delayMs || 0) / 1000));
|
|
29260
30295
|
const retryText = `Retrying (${event.attempt || "?"}/${event.maxAttempts || "?"}) in ${seconds}s after: ${event.errorMessage || "model/provider error"}`;
|
|
@@ -29282,7 +30317,7 @@ function handleEvent(event) {
|
|
|
29282
30317
|
handleExtensionUiRequest(event);
|
|
29283
30318
|
break;
|
|
29284
30319
|
case "response":
|
|
29285
|
-
if (event.success === false)
|
|
30320
|
+
if (event.success === false) surfaceRuntimeDiagnostic(`${event.command || "Pi command"} failed`, event.error || "Unknown RPC command error.");
|
|
29286
30321
|
else if (event.command === "get_state" && event.tabId === activeTabId) {
|
|
29287
30322
|
currentState = event.data || currentState;
|
|
29288
30323
|
syncActiveTabActivityFromState(currentState);
|
|
@@ -29311,11 +30346,21 @@ function handleEvent(event) {
|
|
|
29311
30346
|
}
|
|
29312
30347
|
}
|
|
29313
30348
|
|
|
29314
|
-
function connectEvents(tabContext = activeTabContext()) {
|
|
30349
|
+
function connectEvents(tabContext = activeTabContext(), { requestedMode = "auto", fallbackAttempted = false } = {}) {
|
|
29315
30350
|
eventSource?.close();
|
|
29316
30351
|
eventSource = null;
|
|
30352
|
+
resetCompactLiveOutput();
|
|
30353
|
+
activeOutputMode = "normal";
|
|
30354
|
+
outputModeAcknowledged = false;
|
|
30355
|
+
eventSourceOutputModeRequest = requestedMode === "normal" ? "normal" : "auto";
|
|
30356
|
+
eventSourceOutputModeFallbackAttempted = !!fallbackAttempted;
|
|
29317
30357
|
if (!tabContext.tabId || !isCurrentTabContext(tabContext)) return;
|
|
29318
|
-
const
|
|
30358
|
+
const parameters = new URLSearchParams({
|
|
30359
|
+
tab: tabContext.tabId,
|
|
30360
|
+
outputMode: eventSourceOutputModeRequest,
|
|
30361
|
+
outputModeProtocol: "1",
|
|
30362
|
+
});
|
|
30363
|
+
const source = new EventSource(`/api/events?${parameters.toString()}`);
|
|
29319
30364
|
eventSource = source;
|
|
29320
30365
|
source.onmessage = (message) => {
|
|
29321
30366
|
if (eventSource !== source || !isCurrentTabContext(tabContext)) return;
|
|
@@ -29327,6 +30372,7 @@ function connectEvents(tabContext = activeTabContext()) {
|
|
|
29327
30372
|
};
|
|
29328
30373
|
source.onerror = () => {
|
|
29329
30374
|
if (eventSource !== source || !isCurrentTabContext(tabContext)) return;
|
|
30375
|
+
if (compactOutputActive()) compactLiveScheduler.flushNow();
|
|
29330
30376
|
addEvent("event stream disconnected; browser will retry", "warn");
|
|
29331
30377
|
fetch("/api/health", { cache: "no-store" }).catch((error) => setBackendOffline(true, error));
|
|
29332
30378
|
};
|
|
@@ -30146,6 +31192,11 @@ if (elements.thinkingVisibilityToggle) {
|
|
|
30146
31192
|
setThinkingOutputVisible(elements.thinkingVisibilityToggle.checked, { announce: true });
|
|
30147
31193
|
});
|
|
30148
31194
|
}
|
|
31195
|
+
elements.fastOutputModeSelect?.addEventListener("change", () => {
|
|
31196
|
+
sidebarOutputModeNotice = "";
|
|
31197
|
+
renderSidebarOutputModeControl({ syncSelection: false });
|
|
31198
|
+
});
|
|
31199
|
+
elements.setFastOutputModeButton?.addEventListener("click", () => applySidebarOutputMode().catch((error) => addEvent(error.message || String(error), "error")));
|
|
30149
31200
|
if (elements.terminalTabsLayoutSelect) {
|
|
30150
31201
|
elements.terminalTabsLayoutSelect.addEventListener("change", () => {
|
|
30151
31202
|
setTerminalTabsLayout(elements.terminalTabsLayoutSelect.value, { announce: true });
|
|
@@ -30176,6 +31227,7 @@ elements.sidePanelExpandButton.addEventListener("click", () => {
|
|
|
30176
31227
|
elements.sidePanelBackdrop.addEventListener("click", () => {
|
|
30177
31228
|
setSidePanelCollapsed(true);
|
|
30178
31229
|
});
|
|
31230
|
+
bindSidePanelContextMenu();
|
|
30179
31231
|
elements.stickyUserPromptButton?.addEventListener("click", jumpToStickyUserPrompt);
|
|
30180
31232
|
elements.jumpToLatestButton.addEventListener("click", jumpToLatest);
|
|
30181
31233
|
elements.chat.addEventListener("wheel", noteChatUserScrollIntent, { passive: true });
|
|
@@ -30235,6 +31287,9 @@ document.addEventListener("pointerdown", (event) => {
|
|
|
30235
31287
|
if (elements.gitPanelContextMenu && !elements.gitPanelContextMenu.hidden && !event.target?.closest?.(".git-side-panel-context-menu")) {
|
|
30236
31288
|
closeGitPanelContextMenu();
|
|
30237
31289
|
}
|
|
31290
|
+
if (elements.sidePanelContextMenu && !elements.sidePanelContextMenu.hidden && !event.target?.closest?.(".side-panel-context-menu")) {
|
|
31291
|
+
closeSidePanelContextMenu();
|
|
31292
|
+
}
|
|
30238
31293
|
}, { passive: true });
|
|
30239
31294
|
document.addEventListener("pointermove", (event) => {
|
|
30240
31295
|
if (openTerminalTabGroupKey && !event.target?.closest?.(".terminal-tab-group")) {
|
|
@@ -30433,6 +31488,7 @@ window.addEventListener("focus", () => scheduleForegroundReconcile("window focus
|
|
|
30433
31488
|
window.addEventListener("online", () => scheduleForegroundReconcile("network online", 0));
|
|
30434
31489
|
window.addEventListener("storage", (event) => {
|
|
30435
31490
|
if (event.key === OPTIONAL_FEATURES_STORAGE_KEY) reconcileDisabledOptionalFeaturesFromStorage();
|
|
31491
|
+
if (event.key === SIDE_PANEL_SECTION_VISIBILITY_STORAGE_KEY) restoreSidePanelSectionVisibility();
|
|
30436
31492
|
});
|
|
30437
31493
|
window.addEventListener("resize", syncFileViewerWidthForViewport, { passive: true });
|
|
30438
31494
|
window.addEventListener("keydown", (event) => {
|
|
@@ -30612,6 +31668,21 @@ elements.gitPanelContextMenu?.addEventListener("keydown", (event) => {
|
|
|
30612
31668
|
items[event.key === "Home" ? 0 : items.length - 1]?.focus({ preventScroll: true });
|
|
30613
31669
|
}
|
|
30614
31670
|
});
|
|
31671
|
+
elements.sidePanelContextMenu?.addEventListener("keydown", (event) => {
|
|
31672
|
+
const items = [...elements.sidePanelContextMenu.querySelectorAll('[role="menuitemcheckbox"]')];
|
|
31673
|
+
const index = items.indexOf(document.activeElement);
|
|
31674
|
+
if (event.key === "Escape") {
|
|
31675
|
+
event.preventDefault();
|
|
31676
|
+
closeSidePanelContextMenu();
|
|
31677
|
+
} else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
31678
|
+
event.preventDefault();
|
|
31679
|
+
const direction = event.key === "ArrowDown" ? 1 : -1;
|
|
31680
|
+
items[(Math.max(0, index) + direction + items.length) % items.length]?.focus({ preventScroll: true });
|
|
31681
|
+
} else if (event.key === "Home" || event.key === "End") {
|
|
31682
|
+
event.preventDefault();
|
|
31683
|
+
items[event.key === "Home" ? 0 : items.length - 1]?.focus({ preventScroll: true });
|
|
31684
|
+
}
|
|
31685
|
+
});
|
|
30615
31686
|
elements.fileContextMenu?.addEventListener("click", (event) => {
|
|
30616
31687
|
const button = event.target?.closest?.("[data-file-menu-action]");
|
|
30617
31688
|
if (!button) return;
|
|
@@ -30793,6 +31864,7 @@ restoreToolOutputExpansionSetting();
|
|
|
30793
31864
|
restoreWorkspaceDashboardState();
|
|
30794
31865
|
restoreInterfaceDensity();
|
|
30795
31866
|
initializeTerminalHeaderTooltips();
|
|
31867
|
+
restoreSidePanelSectionVisibility();
|
|
30796
31868
|
restoreSidePanelSectionState();
|
|
30797
31869
|
bindSidePanelSectionToggles();
|
|
30798
31870
|
restoreSidePanelState();
|
|
@@ -30804,4 +31876,5 @@ bindMobileViewChanges();
|
|
|
30804
31876
|
bindSidePanelOverlayViewChanges();
|
|
30805
31877
|
registerPwaServiceWorker();
|
|
30806
31878
|
renderServerOfflinePanel();
|
|
31879
|
+
refreshSidebarOutputMode().catch((error) => addEvent(error.message || String(error), "error"));
|
|
30807
31880
|
initializeTabs().catch((error) => addEvent(error.message, "error"));
|