@firstpick/pi-package-webui 0.7.2 → 0.7.3
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 +5 -5
- package/bin/pi-webui.mjs +266 -67
- package/lib/git-live-watcher.mjs +135 -0
- package/lib/git-message-artifacts.mjs +103 -0
- package/lib/process-tree.mjs +3 -1
- package/package.json +4 -3
- package/public/app.js +482 -73
- package/public/index.html +3 -2
- package/public/styles.css +92 -5
- package/tests/app-runner-windows-conpty-harness.test.mjs +140 -0
- package/tests/danger-button-contrast-static.test.mjs +32 -0
- package/tests/fixtures/fake-pi.mjs +1 -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/guided-git-message-reliability-static.test.mjs +38 -0
- package/tests/http-endpoints-harness.test.mjs +52 -5
- package/tests/image-payload-hardening-harness.test.mjs +115 -0
- package/tests/mobile-static.test.mjs +24 -9
- package/tests/pi-footer-calibration-static.test.mjs +55 -0
- package/tests/runtime-error-visibility.test.mjs +63 -0
- package/tests/side-panel-context-menu-static.test.mjs +74 -0
package/public/app.js
CHANGED
|
@@ -225,6 +225,7 @@ const elements = {
|
|
|
225
225
|
fileSelectionCommentInput: $("#fileSelectionCommentInput"),
|
|
226
226
|
fileSelectionSendButton: $("#fileSelectionSendButton"),
|
|
227
227
|
fileContextMenu: $("#fileContextMenu"),
|
|
228
|
+
sidePanelContextMenu: $("#sidePanelContextMenu"),
|
|
228
229
|
toggleSidePanelButton: $("#toggleSidePanelButton"),
|
|
229
230
|
sidePanelExpandButton: $("#sidePanelExpandButton"),
|
|
230
231
|
sidePanelBackdrop: $("#sidePanelBackdrop"),
|
|
@@ -364,6 +365,7 @@ let fileTreeState = { root: "", entriesByPath: new Map(), expanded: new Set(), l
|
|
|
364
365
|
let activeFileViewer = null;
|
|
365
366
|
let fileViewerSelection = null;
|
|
366
367
|
let fileContextMenuState = null;
|
|
368
|
+
let sidePanelContextMenuState = null;
|
|
367
369
|
let fileTreeDragState = null;
|
|
368
370
|
let fileViewerResizeState = null;
|
|
369
371
|
let fileTreeSearchTimer = null;
|
|
@@ -390,6 +392,8 @@ let streamToolCallComplete = false;
|
|
|
390
392
|
let streamThinkingBubble = null;
|
|
391
393
|
let streamThinking = null;
|
|
392
394
|
let streamMessageActive = false;
|
|
395
|
+
let streamProviderErrorText = "";
|
|
396
|
+
let assistantErrorSurfacedThisRun = false;
|
|
393
397
|
let runIndicatorBubble = null;
|
|
394
398
|
let runIndicatorText = null;
|
|
395
399
|
let runIndicatorMeta = null;
|
|
@@ -615,6 +619,7 @@ const dialogQueue = [];
|
|
|
615
619
|
const SIDE_PANEL_STORAGE_KEY = "pi-webui-side-panel-collapsed";
|
|
616
620
|
const INTERFACE_DENSITY_STORAGE_KEY = "pi-webui-interface-density";
|
|
617
621
|
const SIDE_PANEL_SECTION_STORAGE_KEY = "pi-webui-side-panel-sections-collapsed";
|
|
622
|
+
const SIDE_PANEL_SECTION_VISIBILITY_STORAGE_KEY = "pi-webui-side-panel-sections-hidden";
|
|
618
623
|
const TAB_STORAGE_KEY = "pi-webui-active-tab";
|
|
619
624
|
const PATH_FAST_PICKS_STORAGE_KEY = "pi-webui-path-fast-picks";
|
|
620
625
|
const AGENT_DONE_NOTIFICATIONS_STORAGE_KEY = "pi-webui-agent-done-notifications";
|
|
@@ -834,6 +839,7 @@ const workflowModeByTab = new Map();
|
|
|
834
839
|
const workflowModeTogglePendingByTab = new Set();
|
|
835
840
|
const workflowInspectorByTab = new Map();
|
|
836
841
|
const workflowInspectorSelectionByTab = new Map();
|
|
842
|
+
const workflowInspectorMinimizedByTab = new Set();
|
|
837
843
|
const appRunnerInputDraftByRun = new Map();
|
|
838
844
|
const appRunnerContextLineDraftByRun = new Map();
|
|
839
845
|
const liveToolRuns = new Map();
|
|
@@ -1152,6 +1158,7 @@ function createGitWorkflowState() {
|
|
|
1152
1158
|
manualCommitMessage: "",
|
|
1153
1159
|
...resetGitWorkflowManualCommitDefaultPatch(),
|
|
1154
1160
|
messageRequestedAt: 0,
|
|
1161
|
+
messageGenerationId: "",
|
|
1155
1162
|
branchName: "",
|
|
1156
1163
|
branchNameRequestedAt: 0,
|
|
1157
1164
|
actionsDone: createGitWorkflowActionsDone(),
|
|
@@ -1167,6 +1174,7 @@ function createGitWorkflowState() {
|
|
|
1167
1174
|
}
|
|
1168
1175
|
|
|
1169
1176
|
const gitWorkflowsByTab = new Map();
|
|
1177
|
+
const gitWorkflowMessageLoadsByTab = new Map();
|
|
1170
1178
|
let gitWorkflow = createGitWorkflowState();
|
|
1171
1179
|
let gitWorkflowPreferences = null;
|
|
1172
1180
|
|
|
@@ -1527,6 +1535,46 @@ function persistSidePanelSectionState() {
|
|
|
1527
1535
|
}
|
|
1528
1536
|
}
|
|
1529
1537
|
|
|
1538
|
+
function readStoredSidePanelSectionHiddenIds() {
|
|
1539
|
+
try {
|
|
1540
|
+
const stored = localStorage.getItem(SIDE_PANEL_SECTION_VISIBILITY_STORAGE_KEY);
|
|
1541
|
+
if (stored === null) return new Set();
|
|
1542
|
+
const parsed = JSON.parse(stored);
|
|
1543
|
+
return new Set(Array.isArray(parsed) ? parsed.filter((value) => typeof value === "string") : []);
|
|
1544
|
+
} catch {
|
|
1545
|
+
return new Set();
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
function persistSidePanelSectionVisibility() {
|
|
1550
|
+
try {
|
|
1551
|
+
const hidden = sidePanelSectionRecords()
|
|
1552
|
+
.filter(({ section }) => section.hidden)
|
|
1553
|
+
.map(({ id }) => id);
|
|
1554
|
+
localStorage.setItem(SIDE_PANEL_SECTION_VISIBILITY_STORAGE_KEY, JSON.stringify(hidden));
|
|
1555
|
+
} catch {
|
|
1556
|
+
// Ignore storage failures; visibility toggles should still work for this page load.
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
function setSidePanelSectionVisible(record, visible, { persist = true } = {}) {
|
|
1561
|
+
record.section.hidden = !visible;
|
|
1562
|
+
if (visible && record.id === "git" && !record.section.classList.contains("collapsed")) {
|
|
1563
|
+
queueMicrotask(() => {
|
|
1564
|
+
renderGitPanel();
|
|
1565
|
+
ensureGitPanelRepositoriesDiscovered({ retryUnavailable: true });
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1568
|
+
if (persist) persistSidePanelSectionVisibility();
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
function restoreSidePanelSectionVisibility() {
|
|
1572
|
+
const hiddenIds = readStoredSidePanelSectionHiddenIds();
|
|
1573
|
+
for (const record of sidePanelSectionRecords()) {
|
|
1574
|
+
setSidePanelSectionVisible(record, !hiddenIds.has(record.id), { persist: false });
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1530
1578
|
function setSidePanelSectionCollapsed(record, collapsed, { persist = true } = {}) {
|
|
1531
1579
|
const label = record.button.querySelector(".side-panel-section-label")?.textContent?.trim() || "side panel";
|
|
1532
1580
|
record.section.classList.toggle("collapsed", collapsed);
|
|
@@ -1534,7 +1582,7 @@ function setSidePanelSectionCollapsed(record, collapsed, { persist = true } = {}
|
|
|
1534
1582
|
record.button.setAttribute("aria-expanded", collapsed ? "false" : "true");
|
|
1535
1583
|
record.button.setAttribute("aria-label", `${collapsed ? "Expand" : "Collapse"} ${label} section`);
|
|
1536
1584
|
record.button.setAttribute("title", `${collapsed ? "Expand" : "Collapse"} ${label} section`);
|
|
1537
|
-
if (!collapsed && record.id === "git") {
|
|
1585
|
+
if (!collapsed && record.id === "git" && !record.section.hidden) {
|
|
1538
1586
|
queueMicrotask(() => {
|
|
1539
1587
|
renderGitPanel();
|
|
1540
1588
|
ensureGitPanelRepositoriesDiscovered({ retryUnavailable: true });
|
|
@@ -1561,6 +1609,58 @@ function restoreSidePanelSectionState() {
|
|
|
1561
1609
|
}
|
|
1562
1610
|
}
|
|
1563
1611
|
|
|
1612
|
+
function closeSidePanelContextMenu({ returnFocus = true } = {}) {
|
|
1613
|
+
const trigger = sidePanelContextMenuState?.trigger;
|
|
1614
|
+
sidePanelContextMenuState = null;
|
|
1615
|
+
if (elements.sidePanelContextMenu) elements.sidePanelContextMenu.hidden = true;
|
|
1616
|
+
if (!returnFocus) return;
|
|
1617
|
+
const focusTarget = trigger?.isConnected && !trigger.closest?.("[data-side-panel-section][hidden]")
|
|
1618
|
+
? trigger
|
|
1619
|
+
: elements.toggleSidePanelButton;
|
|
1620
|
+
if (focusTarget?.isConnected) queueMicrotask(() => focusTarget.focus?.({ preventScroll: true }));
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
function showSidePanelContextMenu(event) {
|
|
1624
|
+
if (!elements.sidePanelContextMenu) return;
|
|
1625
|
+
if (event.target?.closest?.("a, input, textarea, select, [contenteditable='true']")) return;
|
|
1626
|
+
event.preventDefault();
|
|
1627
|
+
event.stopPropagation();
|
|
1628
|
+
closeFileContextMenu({ returnFocus: false });
|
|
1629
|
+
closeGitPanelContextMenu({ returnFocus: false });
|
|
1630
|
+
closeSidePanelContextMenu({ returnFocus: false });
|
|
1631
|
+
|
|
1632
|
+
const menu = elements.sidePanelContextMenu;
|
|
1633
|
+
const eventTrigger = event.currentTarget;
|
|
1634
|
+
const trigger = eventTrigger && eventTrigger !== elements.sidePanel ? eventTrigger : document.activeElement;
|
|
1635
|
+
sidePanelContextMenuState = { trigger: trigger?.focus ? trigger : elements.toggleSidePanelButton };
|
|
1636
|
+
const label = make("div", "side-panel-context-menu-label", "Show sections");
|
|
1637
|
+
label.setAttribute("role", "presentation");
|
|
1638
|
+
label.setAttribute("aria-hidden", "true");
|
|
1639
|
+
const items = sidePanelSectionRecords().map((record) => {
|
|
1640
|
+
const sectionLabel = record.button.querySelector(".side-panel-section-label")?.textContent?.trim() || record.id;
|
|
1641
|
+
const button = make("button", "side-panel-context-menu-item", sectionLabel);
|
|
1642
|
+
const visible = !record.section.hidden;
|
|
1643
|
+
button.type = "button";
|
|
1644
|
+
button.setAttribute("role", "menuitemcheckbox");
|
|
1645
|
+
button.setAttribute("aria-checked", visible ? "true" : "false");
|
|
1646
|
+
button.dataset.sidePanelSectionVisibility = record.id;
|
|
1647
|
+
button.addEventListener("click", () => {
|
|
1648
|
+
const nextVisible = record.section.hidden;
|
|
1649
|
+
setSidePanelSectionVisible(record, nextVisible);
|
|
1650
|
+
button.setAttribute("aria-checked", nextVisible ? "true" : "false");
|
|
1651
|
+
});
|
|
1652
|
+
return button;
|
|
1653
|
+
});
|
|
1654
|
+
menu.replaceChildren(label, ...items);
|
|
1655
|
+
menu.hidden = false;
|
|
1656
|
+
const rect = menu.getBoundingClientRect();
|
|
1657
|
+
const left = Math.min(event.clientX, Math.max(8, window.innerWidth - rect.width - 8));
|
|
1658
|
+
const top = Math.min(event.clientY, Math.max(8, window.innerHeight - rect.height - 8));
|
|
1659
|
+
menu.style.left = `${Math.max(8, left)}px`;
|
|
1660
|
+
menu.style.top = `${Math.max(8, top)}px`;
|
|
1661
|
+
menu.querySelector('[role="menuitemcheckbox"]')?.focus({ preventScroll: true });
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1564
1664
|
function bindSidePanelSectionToggles() {
|
|
1565
1665
|
for (const record of sidePanelSectionRecords()) {
|
|
1566
1666
|
record.button.addEventListener("click", () => {
|
|
@@ -1573,6 +1673,23 @@ function bindSidePanelSectionToggles() {
|
|
|
1573
1673
|
}
|
|
1574
1674
|
}
|
|
1575
1675
|
|
|
1676
|
+
function bindSidePanelContextMenu() {
|
|
1677
|
+
elements.sidePanel?.addEventListener("contextmenu", showSidePanelContextMenu);
|
|
1678
|
+
elements.sidePanel?.addEventListener("keydown", (event) => {
|
|
1679
|
+
if (event.key !== "ContextMenu" && !(event.shiftKey && event.key === "F10")) return;
|
|
1680
|
+
const trigger = event.target instanceof Element ? event.target : elements.sidePanel;
|
|
1681
|
+
const rect = trigger.getBoundingClientRect();
|
|
1682
|
+
showSidePanelContextMenu({
|
|
1683
|
+
preventDefault: () => event.preventDefault(),
|
|
1684
|
+
stopPropagation: () => event.stopPropagation(),
|
|
1685
|
+
clientX: rect.left + Math.min(rect.width, 24),
|
|
1686
|
+
clientY: rect.bottom,
|
|
1687
|
+
currentTarget: trigger,
|
|
1688
|
+
target: trigger,
|
|
1689
|
+
});
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1576
1693
|
function readStoredAgentDoneNotificationsEnabled() {
|
|
1577
1694
|
try {
|
|
1578
1695
|
return localStorage.getItem(AGENT_DONE_NOTIFICATIONS_STORAGE_KEY) === "1";
|
|
@@ -2931,6 +3048,7 @@ function setSidePanelCollapsed(collapsed, { persist = true, focusPanel = false }
|
|
|
2931
3048
|
elements.toggleSidePanelButton.setAttribute("aria-label", collapsed ? "Expand side panel" : "Collapse side panel");
|
|
2932
3049
|
elements.sidePanelExpandButton.setAttribute("aria-expanded", collapsed ? "false" : "true");
|
|
2933
3050
|
syncMobileSidePanelState(collapsed);
|
|
3051
|
+
if (collapsed) closeSidePanelContextMenu({ returnFocus: false });
|
|
2934
3052
|
|
|
2935
3053
|
if (!collapsed && focusPanel && isSidePanelOverlayView()) {
|
|
2936
3054
|
requestAnimationFrame(() => elements.toggleSidePanelButton.focus());
|
|
@@ -3571,6 +3689,9 @@ async function api(path, { method = "GET", body, tabId = activeTabId, scoped = t
|
|
|
3571
3689
|
signal,
|
|
3572
3690
|
});
|
|
3573
3691
|
} catch (error) {
|
|
3692
|
+
// Aborted autocomplete requests are expected while the user keeps typing;
|
|
3693
|
+
// they do not indicate that the Web UI backend became unreachable.
|
|
3694
|
+
if (signal?.aborted || error?.name === "AbortError") throw error;
|
|
3574
3695
|
const offlineError = error instanceof Error ? error : new Error(String(error));
|
|
3575
3696
|
offlineError.backendOffline = true;
|
|
3576
3697
|
setBackendOffline(true, offlineError);
|
|
@@ -6634,6 +6755,7 @@ function showFileContextMenu(event, entry) {
|
|
|
6634
6755
|
event.preventDefault();
|
|
6635
6756
|
event.stopPropagation();
|
|
6636
6757
|
closeGitPanelContextMenu({ returnFocus: false });
|
|
6758
|
+
closeSidePanelContextMenu({ returnFocus: false });
|
|
6637
6759
|
const path = normalizeFileTreePath(entry?.path || "");
|
|
6638
6760
|
fileContextMenuState = { entry: { ...entry, path }, trigger: event.currentTarget || document.activeElement };
|
|
6639
6761
|
const menu = elements.fileContextMenu;
|
|
@@ -7582,6 +7704,7 @@ function syncTabMetadata(nextTabs = []) {
|
|
|
7582
7704
|
workflowModeTogglePendingByTab.delete(tabId);
|
|
7583
7705
|
workflowInspectorByTab.delete(tabId);
|
|
7584
7706
|
workflowInspectorSelectionByTab.delete(tabId);
|
|
7707
|
+
workflowInspectorMinimizedByTab.delete(tabId);
|
|
7585
7708
|
remoteMicConsentTabs.delete(tabId);
|
|
7586
7709
|
if (voiceConversationTabId === tabId) stopVoiceConversationLoop();
|
|
7587
7710
|
clearGitWorkflowForTab(tabId);
|
|
@@ -8114,7 +8237,7 @@ function terminalDisplayGroupDetail(group, fallback = "group") {
|
|
|
8114
8237
|
|
|
8115
8238
|
function gitPanelSectionExpanded() {
|
|
8116
8239
|
const section = elements.sidePanel?.querySelector('[data-side-panel-section="git"]');
|
|
8117
|
-
return Boolean(section && !section.classList.contains("collapsed"));
|
|
8240
|
+
return Boolean(section && !section.hidden && !section.classList.contains("collapsed"));
|
|
8118
8241
|
}
|
|
8119
8242
|
|
|
8120
8243
|
function gitPanelTerminalGroups() {
|
|
@@ -8229,33 +8352,68 @@ async function loadGitPanelRepository(card, { force = false } = {}) {
|
|
|
8229
8352
|
if (!card?.root || !card.tabId) return;
|
|
8230
8353
|
const existing = gitPanelSnapshot(card.root);
|
|
8231
8354
|
if (!force && gitPanelSnapshotFresh(existing)) return;
|
|
8232
|
-
if (existing?.loading)
|
|
8355
|
+
if (existing?.loading) {
|
|
8356
|
+
if (force && !existing.refreshPending) {
|
|
8357
|
+
gitPanelState.repositories.set(card.root, { ...existing, refreshPending: true });
|
|
8358
|
+
}
|
|
8359
|
+
return;
|
|
8360
|
+
}
|
|
8233
8361
|
const requestSerial = ++gitPanelState.requestSerial;
|
|
8234
|
-
gitPanelState.repositories.set(card.root, { ...existing, loading: true, error: "", requestSerial });
|
|
8362
|
+
gitPanelState.repositories.set(card.root, { ...existing, loading: true, error: "", requestSerial, refreshPending: false });
|
|
8235
8363
|
renderGitPanel();
|
|
8364
|
+
let refreshAgain = false;
|
|
8236
8365
|
try {
|
|
8237
8366
|
const response = await api("/api/git-panel", { tabId: card.tabId });
|
|
8238
8367
|
const latest = gitPanelSnapshot(card.root);
|
|
8239
8368
|
if (latest?.requestSerial !== requestSerial) return;
|
|
8369
|
+
refreshAgain = latest.refreshPending === true;
|
|
8240
8370
|
if (!response.ok || !response.data?.root) throw new Error(response.error || "Failed to load Git repository");
|
|
8241
8371
|
gitPanelState.repositories.set(card.root, {
|
|
8242
8372
|
loading: false,
|
|
8243
8373
|
error: "",
|
|
8244
8374
|
requestSerial,
|
|
8245
8375
|
loadedAt: Date.now(),
|
|
8376
|
+
refreshPending: false,
|
|
8246
8377
|
data: response.data,
|
|
8247
8378
|
});
|
|
8248
8379
|
} catch (error) {
|
|
8249
8380
|
const latest = gitPanelSnapshot(card.root);
|
|
8250
8381
|
if (latest?.requestSerial !== requestSerial) return;
|
|
8382
|
+
refreshAgain = refreshAgain || latest.refreshPending === true;
|
|
8251
8383
|
gitPanelState.repositories.set(card.root, {
|
|
8252
8384
|
...latest,
|
|
8253
8385
|
loading: false,
|
|
8254
8386
|
error: error.message || String(error),
|
|
8255
8387
|
requestSerial,
|
|
8388
|
+
refreshPending: false,
|
|
8256
8389
|
});
|
|
8257
8390
|
}
|
|
8258
8391
|
renderGitPanel();
|
|
8392
|
+
if (refreshAgain) queueMicrotask(() => loadGitPanelRepository(card, { force: true }));
|
|
8393
|
+
}
|
|
8394
|
+
|
|
8395
|
+
function invalidateGitPanelRepository(root) {
|
|
8396
|
+
const repositoryRoot = String(root || "");
|
|
8397
|
+
const snapshot = gitPanelSnapshot(repositoryRoot);
|
|
8398
|
+
if (!snapshot) return;
|
|
8399
|
+
gitPanelState.repositories.set(repositoryRoot, {
|
|
8400
|
+
...snapshot,
|
|
8401
|
+
error: "",
|
|
8402
|
+
loadedAt: 0,
|
|
8403
|
+
refreshPending: snapshot.loading === true,
|
|
8404
|
+
});
|
|
8405
|
+
if (!gitPanelSectionExpanded()) return;
|
|
8406
|
+
const card = gitPanelRepositoryCards().find((candidate) => candidate.root === repositoryRoot);
|
|
8407
|
+
if (card) void loadGitPanelRepository(card, { force: true });
|
|
8408
|
+
}
|
|
8409
|
+
|
|
8410
|
+
function ensureGitPanelVisibleRepositoriesFresh(cards = gitPanelRepositoryCards()) {
|
|
8411
|
+
for (const card of cards) {
|
|
8412
|
+
const snapshot = gitPanelSnapshot(card.root);
|
|
8413
|
+
const expanded = gitPanelState.expandedCardKey === card.key;
|
|
8414
|
+
if (snapshot?.loading || snapshot?.error || (!snapshot?.data && !expanded) || gitPanelSnapshotFresh(snapshot)) continue;
|
|
8415
|
+
void loadGitPanelRepository(card);
|
|
8416
|
+
}
|
|
8259
8417
|
}
|
|
8260
8418
|
|
|
8261
8419
|
function toggleGitPanelRepository(card) {
|
|
@@ -8343,6 +8501,7 @@ function showGitPanelContextMenu(event, context) {
|
|
|
8343
8501
|
event.stopPropagation();
|
|
8344
8502
|
closeFileContextMenu({ returnFocus: false });
|
|
8345
8503
|
closeGitPanelContextMenu({ returnFocus: false });
|
|
8504
|
+
closeSidePanelContextMenu({ returnFocus: false });
|
|
8346
8505
|
const menu = elements.gitPanelContextMenu;
|
|
8347
8506
|
const items = gitPanelContextMenuItems(context);
|
|
8348
8507
|
if (!items.length) return;
|
|
@@ -8437,7 +8596,7 @@ async function runGitPanelAction(card, action, path = "") {
|
|
|
8437
8596
|
function renderGitPanelFolder(node, card, category, depth = 0) {
|
|
8438
8597
|
const details = make("details", "git-side-panel-folder");
|
|
8439
8598
|
const folderKey = `${card.root}\u0000${category}\u0000${node.path}`;
|
|
8440
|
-
const defaultOpen =
|
|
8599
|
+
const defaultOpen = true;
|
|
8441
8600
|
details.open = gitPanelState.openFolders.has(folderKey) ? gitPanelState.openFolders.get(folderKey) : defaultOpen;
|
|
8442
8601
|
details.addEventListener("toggle", () => {
|
|
8443
8602
|
if (details.open === defaultOpen) gitPanelState.openFolders.delete(folderKey);
|
|
@@ -8671,6 +8830,7 @@ function renderGitPanel() {
|
|
|
8671
8830
|
});
|
|
8672
8831
|
if (signature === gitPanelRenderSignature && elements.gitPanelGroups.childElementCount === cards.length) {
|
|
8673
8832
|
ensureGitPanelRepositoriesDiscovered();
|
|
8833
|
+
ensureGitPanelVisibleRepositoriesFresh(cards);
|
|
8674
8834
|
return;
|
|
8675
8835
|
}
|
|
8676
8836
|
gitPanelRenderSignature = signature;
|
|
@@ -8687,6 +8847,7 @@ function renderGitPanel() {
|
|
|
8687
8847
|
: `${repositoryCount} Git ${repositoryCount === 1 ? "repository" : "repositories"} · Right-click for actions`;
|
|
8688
8848
|
}
|
|
8689
8849
|
ensureGitPanelRepositoriesDiscovered();
|
|
8850
|
+
ensureGitPanelVisibleRepositoriesFresh(cards);
|
|
8690
8851
|
}
|
|
8691
8852
|
|
|
8692
8853
|
function tabAppRunnerRun(tab) {
|
|
@@ -10027,7 +10188,7 @@ async function toggleFooterAutoCompaction(tabContext = activeTabContext()) {
|
|
|
10027
10188
|
}
|
|
10028
10189
|
}
|
|
10029
10190
|
|
|
10030
|
-
function scheduleGitFooterPiCalibrationRefresh(tabContext, delays = [
|
|
10191
|
+
function scheduleGitFooterPiCalibrationRefresh(tabContext, delays = [5000, 14000, 30000]) {
|
|
10031
10192
|
for (const delayMs of delays) {
|
|
10032
10193
|
setTimeout(() => {
|
|
10033
10194
|
if (isCurrentTabContext(tabContext)) requestGitFooterWebuiPayload(tabContext, { force: true });
|
|
@@ -10035,7 +10196,8 @@ function scheduleGitFooterPiCalibrationRefresh(tabContext, delays = [600, 1600])
|
|
|
10035
10196
|
}
|
|
10036
10197
|
}
|
|
10037
10198
|
|
|
10038
|
-
|
|
10199
|
+
|
|
10200
|
+
async function runGitFooterPiCalibration(tabContext = activeTabContext()) {
|
|
10039
10201
|
if (!tabContext.tabId) return;
|
|
10040
10202
|
if (gitFooterPiCalibrationInFlightByTab.has(tabContext.tabId)) return;
|
|
10041
10203
|
if (currentState?.isStreaming || currentState?.isCompacting) {
|
|
@@ -10048,16 +10210,14 @@ async function runGitFooterPiCalibration(mode = "current", tabContext = activeTa
|
|
|
10048
10210
|
addEvent("PI calibration unavailable: /calibrate is not loaded in this Pi tab.", "warn");
|
|
10049
10211
|
return;
|
|
10050
10212
|
}
|
|
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
10213
|
|
|
10053
|
-
const command = mode === "probe" ? `/${commandName}` : `/${commandName} current`;
|
|
10054
10214
|
gitFooterPiCalibrationInFlightByTab.add(tabContext.tabId);
|
|
10055
10215
|
renderFooter();
|
|
10056
10216
|
try {
|
|
10057
|
-
await sendPrompt("prompt",
|
|
10217
|
+
await sendPrompt("prompt", `/${commandName}`, { targetTabId: tabContext.tabId, throwOnError: true });
|
|
10218
|
+
scheduleGitFooterPiCalibrationRefresh(tabContext);
|
|
10058
10219
|
if (!isCurrentTabContext(tabContext)) return;
|
|
10059
|
-
addEvent(
|
|
10060
|
-
scheduleGitFooterPiCalibrationRefresh(tabContext, mode === "probe" ? [5000, 14000] : [600, 1600]);
|
|
10220
|
+
addEvent("PI calibration started in the background; refreshing the footer value after it records…", "info");
|
|
10061
10221
|
} catch (error) {
|
|
10062
10222
|
if (isCurrentTabContext(tabContext)) addEvent(error.message || String(error), "error");
|
|
10063
10223
|
} finally {
|
|
@@ -10067,16 +10227,16 @@ async function runGitFooterPiCalibration(mode = "current", tabContext = activeTa
|
|
|
10067
10227
|
}
|
|
10068
10228
|
|
|
10069
10229
|
function applyGitFooterPiCalibrationOptions(chip, options) {
|
|
10070
|
-
if (chip?.key !== "pi"
|
|
10230
|
+
if (chip?.key !== "pi") return "";
|
|
10071
10231
|
const tabContext = activeTabContext();
|
|
10072
10232
|
const busy = !!tabContext.tabId && gitFooterPiCalibrationInFlightByTab.has(tabContext.tabId);
|
|
10073
|
-
|
|
10074
|
-
|
|
10233
|
+
options.onClick = () => {
|
|
10234
|
+
void runGitFooterPiCalibration();
|
|
10235
|
+
};
|
|
10075
10236
|
if (busy) options.ariaBusy = true;
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
|
|
10079
|
-
: "Click to calibrate this uncalibrated PI estimate from the current session, then refresh this value.";
|
|
10237
|
+
return busy
|
|
10238
|
+
? "Calibrating PI estimate in the background and refreshing this value…"
|
|
10239
|
+
: "Click to run /calibrate in the background and refresh this PI token count.";
|
|
10080
10240
|
}
|
|
10081
10241
|
|
|
10082
10242
|
function applyGitFooterContextToggleOptions(chip, options) {
|
|
@@ -10305,6 +10465,43 @@ function applyFooterContextUsage(node, contextUsage) {
|
|
|
10305
10465
|
return node;
|
|
10306
10466
|
}
|
|
10307
10467
|
|
|
10468
|
+
const FOOTER_MIDDLE_TRUNCATION_END_CHARS = 16;
|
|
10469
|
+
const FOOTER_MIDDLE_TRUNCATION_MIN_START_CHARS = 6;
|
|
10470
|
+
|
|
10471
|
+
function splitMiddleTruncationText(value, endChars = FOOTER_MIDDLE_TRUNCATION_END_CHARS) {
|
|
10472
|
+
const characters = Array.from(String(value ?? ""));
|
|
10473
|
+
const minimumSuffixLength = Math.max(0, Math.min(Math.trunc(Number(endChars) || 0), characters.length));
|
|
10474
|
+
if (!minimumSuffixLength) return { start: characters.join(""), end: "" };
|
|
10475
|
+
let componentEnd = characters.length - 1;
|
|
10476
|
+
while (componentEnd >= 0 && (characters[componentEnd] === "/" || characters[componentEnd] === "\\")) componentEnd -= 1;
|
|
10477
|
+
let separatorIndex = -1;
|
|
10478
|
+
for (let index = componentEnd; index >= 0; index -= 1) {
|
|
10479
|
+
if (characters[index] === "/" || characters[index] === "\\") {
|
|
10480
|
+
separatorIndex = index;
|
|
10481
|
+
break;
|
|
10482
|
+
}
|
|
10483
|
+
}
|
|
10484
|
+
const componentSuffixLength = separatorIndex >= 0 ? characters.length - separatorIndex : 0;
|
|
10485
|
+
const suffixLength = Math.min(characters.length, Math.max(minimumSuffixLength, componentSuffixLength));
|
|
10486
|
+
if (!suffixLength || characters.length <= suffixLength + FOOTER_MIDDLE_TRUNCATION_MIN_START_CHARS) return { start: characters.join(""), end: "" };
|
|
10487
|
+
return { start: characters.slice(0, -suffixLength).join(""), end: characters.slice(-suffixLength).join("") };
|
|
10488
|
+
}
|
|
10489
|
+
|
|
10490
|
+
function setMiddleTruncatedText(node, value, endChars = FOOTER_MIDDLE_TRUNCATION_END_CHARS) {
|
|
10491
|
+
const parts = splitMiddleTruncationText(value, endChars);
|
|
10492
|
+
if (!parts.end) {
|
|
10493
|
+
node.classList.remove("middle-truncate-value");
|
|
10494
|
+
node.textContent = parts.start;
|
|
10495
|
+
return node;
|
|
10496
|
+
}
|
|
10497
|
+
node.classList.add("middle-truncate-value");
|
|
10498
|
+
node.replaceChildren(
|
|
10499
|
+
make("span", "middle-truncate-start", parts.start),
|
|
10500
|
+
make("span", "middle-truncate-end", parts.end),
|
|
10501
|
+
);
|
|
10502
|
+
return node;
|
|
10503
|
+
}
|
|
10504
|
+
|
|
10308
10505
|
function footerMeta(label, value, className = "", options = {}) {
|
|
10309
10506
|
const isAction = typeof options.onClick === "function";
|
|
10310
10507
|
const node = make(isAction ? "button" : "span", ["footer-meta", className, isAction ? "footer-meta-action" : ""].filter(Boolean).join(" "));
|
|
@@ -10318,7 +10515,10 @@ function footerMeta(label, value, className = "", options = {}) {
|
|
|
10318
10515
|
node.setAttribute("aria-disabled", "true");
|
|
10319
10516
|
}
|
|
10320
10517
|
}
|
|
10321
|
-
|
|
10518
|
+
const valueNode = make("span", "footer-meta-value");
|
|
10519
|
+
if (options.middleTruncate) setMiddleTruncatedText(valueNode, value);
|
|
10520
|
+
else valueNode.textContent = String(value ?? "");
|
|
10521
|
+
node.append(make("span", "footer-meta-label", label), valueNode);
|
|
10322
10522
|
return applyFooterTooltip(node, options.title || `${label}: ${value}`, { align: options.tooltipAlign });
|
|
10323
10523
|
}
|
|
10324
10524
|
|
|
@@ -10924,7 +11124,9 @@ function gitFooterTooltipAlign(chip) {
|
|
|
10924
11124
|
function footerTuiItem(value, className = "", options = {}) {
|
|
10925
11125
|
const text = cleanStatusText(value);
|
|
10926
11126
|
const isAction = typeof options.onClick === "function";
|
|
10927
|
-
const node = make(isAction ? "button" : "span", `footer-tui-item ${className}${isAction ? " footer-tui-action" : ""}`.trim()
|
|
11127
|
+
const node = make(isAction ? "button" : "span", `footer-tui-item ${className}${isAction ? " footer-tui-action" : ""}`.trim());
|
|
11128
|
+
if (options.middleTruncate) setMiddleTruncatedText(node, text);
|
|
11129
|
+
else node.textContent = text;
|
|
10928
11130
|
if (isAction) {
|
|
10929
11131
|
node.type = "button";
|
|
10930
11132
|
node.addEventListener("click", options.onClick);
|
|
@@ -10941,7 +11143,8 @@ function renderTuiFooterLine({ cwd, cwdTitle, message = "", stats = [], model =
|
|
|
10941
11143
|
line.append(footerTuiItem(cwd || "loading…", "footer-tui-cwd", tab ? {
|
|
10942
11144
|
onClick: changeActiveTabCwd,
|
|
10943
11145
|
title: cwdTitle || `Change cwd for ${tab.title}: ${cwd}`,
|
|
10944
|
-
|
|
11146
|
+
middleTruncate: true,
|
|
11147
|
+
} : { title: cwdTitle, middleTruncate: true }));
|
|
10945
11148
|
if (worktreeLabel) line.append(footerTuiItem(worktreeLabel, "footer-tui-worktree", { title: workspace?.worktreePath || worktreeLabel }));
|
|
10946
11149
|
if (message) line.append(footerTuiItem(message, "footer-tui-status"));
|
|
10947
11150
|
for (const stat of stats.filter(Boolean)) line.append(footerTuiItem(stat, "footer-tui-stat"));
|
|
@@ -11132,10 +11335,10 @@ function renderGitFooterPayloadMeta(chip, tab, payload) {
|
|
|
11132
11335
|
options.disabled = inFlight;
|
|
11133
11336
|
action = inFlight ? "Pushing local commits to the configured remote." : "Click to push local commits to the configured remote.";
|
|
11134
11337
|
} else if (chip.key === "changes" && visible("webui-changes-modal")) {
|
|
11135
|
-
options.onClick = openGitChangesDialog;
|
|
11338
|
+
options.onClick = () => openGitChangesDialog(tab?.id || activeTabId);
|
|
11136
11339
|
action = "Click to view the current git diff.";
|
|
11137
11340
|
} else if (chip.key === "git-state" && visible("webui-changes-modal")) {
|
|
11138
|
-
options.onClick = openGitChangesDialog;
|
|
11341
|
+
options.onClick = () => openGitChangesDialog(tab?.id || activeTabId);
|
|
11139
11342
|
action = "Click to open the conflicts and operation panel with continue/abort actions.";
|
|
11140
11343
|
} else if (chip.key === "git-extra" && visible("webui-git-tools-modal")) {
|
|
11141
11344
|
const toolsSection = gitToolsSectionForExtraChip(chip.value);
|
|
@@ -11151,6 +11354,7 @@ function renderGitFooterPayloadMeta(chip, tab, payload) {
|
|
|
11151
11354
|
action = (visible("webui-context-auto-compaction") ? applyGitFooterContextToggleOptions(chip, options) : "") || action;
|
|
11152
11355
|
options.title = gitFooterPayloadTooltip(chip, { action });
|
|
11153
11356
|
options.tooltipAlign = gitFooterTooltipAlign(chip);
|
|
11357
|
+
options.middleTruncate = chip.key === "cwd";
|
|
11154
11358
|
const node = footerMeta(chip.label, chip.value, footerMetaClassForPayload(chip), options);
|
|
11155
11359
|
applyFooterChangedFilesDropdown(node, chip, payload);
|
|
11156
11360
|
if (["git", "worktree"].includes(chip.key) && options.onClick && cleanFooterPayloadText(chip.value, "").toLowerCase() !== "no repo") {
|
|
@@ -11180,14 +11384,24 @@ function gitFooterPickerStateKey(payload) {
|
|
|
11180
11384
|
const tabContext = activeTabContext();
|
|
11181
11385
|
const refreshInFlight = tabContext.tabId ? gitFooterPayloadRefreshInFlightByTab.has(tabContext.tabId) : false;
|
|
11182
11386
|
const syncPushInFlight = tabContext.tabId ? gitFooterSyncPushInFlightByTab.has(tabContext.tabId) : false;
|
|
11387
|
+
const piCalibrationInFlight = tabContext.tabId ? gitFooterPiCalibrationInFlightByTab.has(tabContext.tabId) : false;
|
|
11183
11388
|
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)}`;
|
|
11389
|
+
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
11390
|
}
|
|
11186
11391
|
|
|
11187
11392
|
function updateGitFooterChipNodeValue(node, chip, valueSelector) {
|
|
11188
11393
|
if (!node) return;
|
|
11189
11394
|
const valueNode = node.querySelector(valueSelector);
|
|
11190
|
-
|
|
11395
|
+
const nextValue = String(chip.value ?? "");
|
|
11396
|
+
const middleTruncate = chip.key === "cwd";
|
|
11397
|
+
const middleTruncateActive = middleTruncate && !!splitMiddleTruncationText(nextValue).end;
|
|
11398
|
+
if (valueNode && (valueNode.textContent !== nextValue || valueNode.classList.contains("middle-truncate-value") !== middleTruncateActive)) {
|
|
11399
|
+
if (middleTruncate) setMiddleTruncatedText(valueNode, nextValue);
|
|
11400
|
+
else {
|
|
11401
|
+
valueNode.classList.remove("middle-truncate-value");
|
|
11402
|
+
valueNode.textContent = nextValue;
|
|
11403
|
+
}
|
|
11404
|
+
}
|
|
11191
11405
|
if (chip.contextUsage) applyFooterContextUsage(node, chip.contextUsage);
|
|
11192
11406
|
}
|
|
11193
11407
|
|
|
@@ -12066,8 +12280,8 @@ async function loadGitChangesDialog(tabContext = activeTabContext()) {
|
|
|
12066
12280
|
function openGitChangesDialog(requestedTabId = activeTabId) {
|
|
12067
12281
|
if (!elements.gitChangesDialog) return;
|
|
12068
12282
|
hideFooterTooltip();
|
|
12069
|
-
const
|
|
12070
|
-
const
|
|
12283
|
+
const tabId = typeof requestedTabId === "string" && requestedTabId ? requestedTabId : activeTabId;
|
|
12284
|
+
const tabContext = activeTabContext(tabId);
|
|
12071
12285
|
if (gitToolsState.tabId !== tabId) resetGitToolsState(tabId);
|
|
12072
12286
|
gitChangesState = {
|
|
12073
12287
|
...gitChangesState,
|
|
@@ -16681,6 +16895,18 @@ function workflowInspectorSetSelection(patch) {
|
|
|
16681
16895
|
renderWidgets();
|
|
16682
16896
|
}
|
|
16683
16897
|
|
|
16898
|
+
function workflowInspectorSetMinimized(minimized) {
|
|
16899
|
+
if (!activeTabId) return;
|
|
16900
|
+
const tabId = activeTabId;
|
|
16901
|
+
if (minimized) workflowInspectorMinimizedByTab.add(tabId);
|
|
16902
|
+
else workflowInspectorMinimizedByTab.delete(tabId);
|
|
16903
|
+
renderWidgets();
|
|
16904
|
+
requestAnimationFrame(() => {
|
|
16905
|
+
if (activeTabId !== tabId) return;
|
|
16906
|
+
elements.widgetArea.querySelector(".workflow-inspector-minimize-button")?.focus({ preventScroll: true });
|
|
16907
|
+
});
|
|
16908
|
+
}
|
|
16909
|
+
|
|
16684
16910
|
function workflowInspectorJson(value) {
|
|
16685
16911
|
if (value === undefined) return "—";
|
|
16686
16912
|
if (typeof value === "string") return value;
|
|
@@ -16744,9 +16970,13 @@ function renderWorkflowInspectorWidget() {
|
|
|
16744
16970
|
if (!payload?.runs?.length) return null;
|
|
16745
16971
|
const { run, phase } = workflowInspectorSelection(payload);
|
|
16746
16972
|
if (!run) return null;
|
|
16973
|
+
const minimized = Boolean(activeTabId && workflowInspectorMinimizedByTab.has(activeTabId));
|
|
16747
16974
|
|
|
16748
|
-
const node = make("section",
|
|
16975
|
+
const node = make("section", `widget release-npm-widget workflow-widget workflow-inspector-widget${minimized ? " minimized" : ""}`);
|
|
16749
16976
|
node.setAttribute("aria-label", "workflow run inspector");
|
|
16977
|
+
const body = make("div", "workflow-inspector-body");
|
|
16978
|
+
body.id = "workflowInspectorBody";
|
|
16979
|
+
body.hidden = minimized;
|
|
16750
16980
|
const header = make("div", "release-npm-header");
|
|
16751
16981
|
const titleWrap = make("div", "release-npm-title-wrap");
|
|
16752
16982
|
titleWrap.append(make("span", "release-npm-kicker", "workflows"), make("strong", "release-npm-title", `${payload.runs.length} run${payload.runs.length === 1 ? "" : "s"}`));
|
|
@@ -16754,7 +16984,17 @@ function renderWorkflowInspectorWidget() {
|
|
|
16754
16984
|
meta.append(make("span", "release-npm-pill", payload.mode?.enabled ? `mode ${payload.mode.phase}` : "mode off"));
|
|
16755
16985
|
const liveCount = payload.runs.filter(workflowRunIsLive).length;
|
|
16756
16986
|
if (liveCount) meta.append(make("span", "release-npm-pill workflow-status running", `${liveCount} active`));
|
|
16987
|
+
const minimizeButton = make("button", "release-npm-action workflow-inspector-minimize-button", minimized ? "Restore" : "Minimize");
|
|
16988
|
+
minimizeButton.type = "button";
|
|
16989
|
+
minimizeButton.setAttribute("aria-controls", body.id);
|
|
16990
|
+
minimizeButton.setAttribute("aria-expanded", minimized ? "false" : "true");
|
|
16991
|
+
minimizeButton.setAttribute("aria-label", minimized ? "Restore workflow inspector" : "Minimize workflow inspector");
|
|
16992
|
+
minimizeButton.setAttribute("title", minimized ? "Restore workflow inspector" : "Minimize workflow inspector");
|
|
16993
|
+
minimizeButton.addEventListener("click", () => workflowInspectorSetMinimized(!minimized));
|
|
16994
|
+
meta.append(minimizeButton);
|
|
16757
16995
|
header.append(titleWrap, meta);
|
|
16996
|
+
node.append(header, body);
|
|
16997
|
+
if (minimized) return node;
|
|
16758
16998
|
|
|
16759
16999
|
const layout = make("div", "workflow-inspector-layout");
|
|
16760
17000
|
const runList = make("nav", "workflow-inspector-run-list");
|
|
@@ -16806,7 +17046,7 @@ function renderWorkflowInspectorWidget() {
|
|
|
16806
17046
|
detail.append(raw);
|
|
16807
17047
|
}
|
|
16808
17048
|
layout.append(runList, detail);
|
|
16809
|
-
|
|
17049
|
+
body.append(layout);
|
|
16810
17050
|
return node;
|
|
16811
17051
|
}
|
|
16812
17052
|
|
|
@@ -19233,6 +19473,7 @@ function selectGitInitWorkflowProcess(processValue, tabId, workflow) {
|
|
|
19233
19473
|
manualCommitMessage: "",
|
|
19234
19474
|
...resetGitWorkflowManualCommitDefaultPatch(),
|
|
19235
19475
|
messageRequestedAt: 0,
|
|
19476
|
+
messageGenerationId: "",
|
|
19236
19477
|
branchName: "",
|
|
19237
19478
|
branchNameRequestedAt: 0,
|
|
19238
19479
|
prMode: false,
|
|
@@ -19284,7 +19525,7 @@ function selectGitWorkflowProcess(processValue, tabId = gitWorkflowActionTabId()
|
|
|
19284
19525
|
if (!guidedReviewPatch) return;
|
|
19285
19526
|
workflow.runId += 1;
|
|
19286
19527
|
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 };
|
|
19528
|
+
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
19529
|
|
|
19289
19530
|
if (process === "stage") {
|
|
19290
19531
|
setGitWorkflow({ ...base, step: "add", message: null, output: "Ready to stage all changes with git add ." }, { tabId });
|
|
@@ -19514,7 +19755,11 @@ function renderGitWorkflow() {
|
|
|
19514
19755
|
addGitWorkflowAction("Preview current message files", () => loadGitWorkflowMessage({ requireFresh: false }), "", false);
|
|
19515
19756
|
elements.gitWorkflowActions.append(commitInputButton);
|
|
19516
19757
|
} else if (gitWorkflow.step === "generating") {
|
|
19517
|
-
|
|
19758
|
+
if (gitWorkflow.messageGenerationId) {
|
|
19759
|
+
addGitWorkflowAction("Refresh message preview", () => loadGitWorkflowMessage({ requireFresh: true }), "", false);
|
|
19760
|
+
} else {
|
|
19761
|
+
addGitWorkflowAction("Starting message generation…", () => {}, "", true);
|
|
19762
|
+
}
|
|
19518
19763
|
} else if (gitWorkflow.step === "message") {
|
|
19519
19764
|
const deliveryMode = preferences.deliveryMode || "ask";
|
|
19520
19765
|
const preferredVariant = preferences.commit?.defaultVariant || "short";
|
|
@@ -19851,6 +20096,7 @@ async function startGitWorkflow(tabId = activeTabId, { skipSetup = false } = {})
|
|
|
19851
20096
|
manualCommitMessage: "",
|
|
19852
20097
|
...resetGitWorkflowManualCommitDefaultPatch(),
|
|
19853
20098
|
messageRequestedAt: 0,
|
|
20099
|
+
messageGenerationId: "",
|
|
19854
20100
|
branchName: "",
|
|
19855
20101
|
branchNameRequestedAt: 0,
|
|
19856
20102
|
actionsDone: createGitWorkflowActionsDone(),
|
|
@@ -19898,6 +20144,7 @@ async function startGitInitWorkflow(tabId = activeTabId) {
|
|
|
19898
20144
|
manualCommitMessage: "",
|
|
19899
20145
|
...resetGitWorkflowManualCommitDefaultPatch(),
|
|
19900
20146
|
messageRequestedAt: 0,
|
|
20147
|
+
messageGenerationId: "",
|
|
19901
20148
|
branchName: "",
|
|
19902
20149
|
branchNameRequestedAt: 0,
|
|
19903
20150
|
actionsDone: createGitWorkflowActionsDone(),
|
|
@@ -20290,19 +20537,24 @@ async function runGitMessagePrompt(tabId = gitWorkflowActionTabId()) {
|
|
|
20290
20537
|
busy: true,
|
|
20291
20538
|
error: "",
|
|
20292
20539
|
messageRequestedAt: requestedAt,
|
|
20540
|
+
messageGenerationId: "",
|
|
20293
20541
|
output: "Sending /git-staged-msg to Pi.\n\nCancel will request Pi abort.",
|
|
20294
20542
|
}, { tabId });
|
|
20295
20543
|
if (isCurrentTabContext(tabContext)) setRunIndicatorActivity("Sending /git-staged-msg to Pi…");
|
|
20296
20544
|
try {
|
|
20297
20545
|
const generation = await gitWorkflowRequest("/api/git-workflow/generate", { body: { kind: "commit", ...(expectedStagedContentHash ? { expectedStagedContentHash } : {}) }, runId, tabId });
|
|
20298
20546
|
if (!generation || !isCurrentGitWorkflowRun(runId, tabId)) return;
|
|
20299
|
-
|
|
20547
|
+
const generationId = String(generation.generationId || "").trim();
|
|
20548
|
+
if (!generationId) throw new Error("The WebUI server did not return a commit-message generation ID. Restart Pi Web UI and regenerate.");
|
|
20549
|
+
setGitWorkflow({ messageGenerationId: generationId }, { tabId });
|
|
20550
|
+
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
20551
|
if (isCurrentTabContext(tabContext)) scheduleRefreshState(120, tabContext);
|
|
20301
20552
|
setTimeout(() => {
|
|
20302
20553
|
const currentWorkflow = gitWorkflowForTab(tabId, { create: false });
|
|
20303
|
-
const
|
|
20304
|
-
|
|
20305
|
-
|
|
20554
|
+
const targetTab = tabs.find((tab) => tab.id === tabId);
|
|
20555
|
+
const targetStillBusy = tabId === activeTabId ? !!currentState?.isStreaming : activityForTab(targetTab).isWorking;
|
|
20556
|
+
if (isCurrentGitWorkflowRun(runId, tabId) && currentWorkflow?.step === "generating" && currentWorkflow.messageGenerationId === generationId && !targetStillBusy) {
|
|
20557
|
+
loadGitWorkflowMessage({ requireFresh: true, generationId, runId, tabId });
|
|
20306
20558
|
}
|
|
20307
20559
|
}, 2500);
|
|
20308
20560
|
} catch (error) {
|
|
@@ -20313,35 +20565,93 @@ async function runGitMessagePrompt(tabId = gitWorkflowActionTabId()) {
|
|
|
20313
20565
|
}
|
|
20314
20566
|
}
|
|
20315
20567
|
|
|
20316
|
-
|
|
20568
|
+
const GIT_WORKFLOW_MESSAGE_POLL_TIMEOUT_MS = 30_000;
|
|
20569
|
+
const GIT_WORKFLOW_MESSAGE_POLL_DELAYS_MS = [250, 500, 800, 1200];
|
|
20570
|
+
|
|
20571
|
+
function gitWorkflowMessageLoadIsCurrent(tabId, runId, generationId = "") {
|
|
20572
|
+
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
20573
|
+
return !!workflow
|
|
20574
|
+
&& isCurrentGitWorkflowRun(runId, tabId)
|
|
20575
|
+
&& (!generationId || workflow.messageGenerationId === generationId);
|
|
20576
|
+
}
|
|
20577
|
+
|
|
20578
|
+
function waitForGitWorkflowMessagePoll(attempt) {
|
|
20579
|
+
const delayMs = GIT_WORKFLOW_MESSAGE_POLL_DELAYS_MS[Math.min(attempt, GIT_WORKFLOW_MESSAGE_POLL_DELAYS_MS.length - 1)];
|
|
20580
|
+
return new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
20581
|
+
}
|
|
20582
|
+
|
|
20583
|
+
async function loadGitWorkflowMessage({ requireFresh = false, generationId, runId, tabId = activeTabId } = {}) {
|
|
20317
20584
|
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
20318
20585
|
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
|
-
|
|
20586
|
+
const expectedGenerationId = requireFresh ? String(generationId ?? workflow?.messageGenerationId ?? "").trim() : "";
|
|
20587
|
+
if (!workflow || expectedRunId === undefined) return;
|
|
20588
|
+
if (requireFresh && !expectedGenerationId) {
|
|
20589
|
+
// The generation POST can be accepted just before its correlation ID is
|
|
20590
|
+
// returned to the browser. Timer/event wakeups in that narrow window are
|
|
20591
|
+
// harmless; the accepted-request continuation and fallback timer retry.
|
|
20592
|
+
if (workflow.step === "generating") return;
|
|
20593
|
+
failGitWorkflow(new Error("No correlated commit-message generation is active. Run /git-staged-msg again."), "generate", { tabId });
|
|
20594
|
+
return;
|
|
20595
|
+
}
|
|
20596
|
+
|
|
20597
|
+
const loadKey = `${expectedRunId}:${expectedGenerationId || "preview"}`;
|
|
20598
|
+
const existing = gitWorkflowMessageLoadsByTab.get(tabId);
|
|
20599
|
+
if (existing?.key === loadKey) return existing.promise;
|
|
20600
|
+
|
|
20601
|
+
const promise = (async () => {
|
|
20602
|
+
const deadline = Date.now() + (requireFresh ? GIT_WORKFLOW_MESSAGE_POLL_TIMEOUT_MS : 0);
|
|
20603
|
+
const baseOutput = workflow.output || "Waiting for generated commit message files…";
|
|
20604
|
+
let attempt = 0;
|
|
20605
|
+
while (gitWorkflowMessageLoadIsCurrent(tabId, expectedRunId, expectedGenerationId)) {
|
|
20606
|
+
try {
|
|
20607
|
+
const query = expectedGenerationId ? `?generationId=${encodeURIComponent(expectedGenerationId)}` : "";
|
|
20608
|
+
const message = await gitWorkflowRequest(`/api/git-workflow/message${query}`, { method: "GET", runId: expectedRunId, tabId });
|
|
20609
|
+
if (!message || !gitWorkflowMessageLoadIsCurrent(tabId, expectedRunId, expectedGenerationId)) return;
|
|
20610
|
+
if (message.ready === false) {
|
|
20611
|
+
if (message.expired) throw new Error(message.reason || "This commit-message generation has expired. Regenerate the message files.");
|
|
20612
|
+
if (!requireFresh || Date.now() >= deadline) {
|
|
20613
|
+
throw new Error(`${message.reason || "Generated commit message files are not ready."} Regenerate, or use Preview current message files after verifying both files.`);
|
|
20614
|
+
}
|
|
20615
|
+
const currentWorkflow = gitWorkflowForTab(tabId, { create: false });
|
|
20616
|
+
const reason = message.reason || "Waiting for both correlated commit message files…";
|
|
20617
|
+
if (currentWorkflow?.output !== `${baseOutput}\n\n${reason}`) {
|
|
20618
|
+
setGitWorkflow({ busy: true, error: "", output: `${baseOutput}\n\n${reason}` }, { tabId });
|
|
20619
|
+
}
|
|
20620
|
+
await waitForGitWorkflowMessagePoll(attempt++);
|
|
20621
|
+
continue;
|
|
20622
|
+
}
|
|
20623
|
+
const currentWorkflow = gitWorkflowForTab(tabId, { create: false });
|
|
20624
|
+
if (!currentWorkflow || !gitWorkflowMessageLoadIsCurrent(tabId, expectedRunId, expectedGenerationId)) return;
|
|
20625
|
+
setGitWorkflow({
|
|
20626
|
+
step: "message",
|
|
20627
|
+
busy: false,
|
|
20628
|
+
error: "",
|
|
20629
|
+
message,
|
|
20630
|
+
...(requireFresh ? gitWorkflowActionDonePatch(currentWorkflow, "message") : {}),
|
|
20631
|
+
output: formatCommitMessagePreview(message),
|
|
20632
|
+
}, { tabId });
|
|
20633
|
+
return;
|
|
20634
|
+
} catch (error) {
|
|
20635
|
+
if (!gitWorkflowMessageLoadIsCurrent(tabId, expectedRunId, expectedGenerationId)) return;
|
|
20636
|
+
if (!requireFresh || Date.now() >= deadline || /expired|no longer active/i.test(error?.message || "")) throw error;
|
|
20637
|
+
const reason = error?.message || String(error);
|
|
20638
|
+
const currentWorkflow = gitWorkflowForTab(tabId, { create: false });
|
|
20639
|
+
if (currentWorkflow?.output !== `${baseOutput}\n\nWaiting for both correlated message files. ${reason}`) {
|
|
20640
|
+
setGitWorkflow({ busy: true, error: "", output: `${baseOutput}\n\nWaiting for both correlated message files. ${reason}` }, { tabId });
|
|
20641
|
+
}
|
|
20642
|
+
await waitForGitWorkflowMessagePoll(attempt++);
|
|
20643
|
+
}
|
|
20341
20644
|
}
|
|
20645
|
+
})().catch((error) => {
|
|
20646
|
+
if (!gitWorkflowMessageLoadIsCurrent(tabId, expectedRunId, expectedGenerationId)) return;
|
|
20342
20647
|
const currentWorkflow = gitWorkflowForTab(tabId, { create: false });
|
|
20343
20648
|
failGitWorkflow(error, currentWorkflow?.step === "generating" ? "generate" : currentWorkflow?.step, { tabId });
|
|
20344
|
-
}
|
|
20649
|
+
}).finally(() => {
|
|
20650
|
+
if (gitWorkflowMessageLoadsByTab.get(tabId)?.key === loadKey) gitWorkflowMessageLoadsByTab.delete(tabId);
|
|
20651
|
+
});
|
|
20652
|
+
|
|
20653
|
+
gitWorkflowMessageLoadsByTab.set(tabId, { key: loadKey, promise });
|
|
20654
|
+
return promise;
|
|
20345
20655
|
}
|
|
20346
20656
|
|
|
20347
20657
|
function gitBranchNamePromptMessage() {
|
|
@@ -20528,6 +20838,7 @@ async function createGitPrBranchWithSuggestion(suggestion, tabId = gitWorkflowAc
|
|
|
20528
20838
|
manualCommitMessageDefaultRequestedAt: sourceWorkflow.manualCommitMessageDefaultRequestedAt || 0,
|
|
20529
20839
|
manualCommitMessageDefaultLoading: false,
|
|
20530
20840
|
messageRequestedAt: sourceWorkflow.messageRequestedAt || 0,
|
|
20841
|
+
messageGenerationId: sourceWorkflow.messageGenerationId || "",
|
|
20531
20842
|
branchName: prBranch || branch,
|
|
20532
20843
|
branchNameRequestedAt: sourceWorkflow.branchNameRequestedAt || 0,
|
|
20533
20844
|
actionsDone: createGitWorkflowActionsDone({ ...sourceWorkflow.actionsDone, branch: true }),
|
|
@@ -20757,7 +21068,7 @@ function resumeGitWorkflowForActiveTab(tabContext = activeTabContext()) {
|
|
|
20757
21068
|
setTimeout(() => resumeGitWorkflowForActiveTab(tabContext), retryDelayMs);
|
|
20758
21069
|
return;
|
|
20759
21070
|
}
|
|
20760
|
-
loadGitWorkflowMessage({ requireFresh: true,
|
|
21071
|
+
loadGitWorkflowMessage({ requireFresh: true, generationId: gitWorkflow.messageGenerationId, runId: gitWorkflow.runId, tabId: workflowTabId });
|
|
20761
21072
|
}
|
|
20762
21073
|
if (workflowTabId === tabContext.tabId && gitWorkflow.active && gitWorkflow.step === "branchNaming" && !currentState?.isStreaming) {
|
|
20763
21074
|
const retryDelayMs = Math.max(0, 2500 - (Date.now() - (gitWorkflow.branchNameRequestedAt || 0)));
|
|
@@ -24216,6 +24527,45 @@ function addTransientMessage({ role = "notice", title, content, level = "info",
|
|
|
24216
24527
|
renderAllMessages();
|
|
24217
24528
|
}
|
|
24218
24529
|
|
|
24530
|
+
function surfaceRuntimeDiagnostic(title, content, level = "error") {
|
|
24531
|
+
const message = String(content || "").trim();
|
|
24532
|
+
if (!message) return;
|
|
24533
|
+
addEvent(message, level);
|
|
24534
|
+
addTransientMessage({ role: level === "error" ? "error" : "warn", title, content: message, level });
|
|
24535
|
+
}
|
|
24536
|
+
|
|
24537
|
+
function stderrDiagnosticLevel(content) {
|
|
24538
|
+
return /(?:^|\b)(?:error|failed|failure|fatal|exception|invalid)(?:\b|:)/i.test(String(content || "")) ? "error" : "warn";
|
|
24539
|
+
}
|
|
24540
|
+
|
|
24541
|
+
function toolImagePayloadError(event) {
|
|
24542
|
+
const blocks = Array.isArray(event?.result?.content) ? event.result.content : [];
|
|
24543
|
+
for (const [index, block] of blocks.entries()) {
|
|
24544
|
+
if (block?.type !== "image") continue;
|
|
24545
|
+
const data = typeof block.data === "string" ? block.data.replace(/\s+/g, "") : "";
|
|
24546
|
+
let canonical = data.length > 0 && data.length % 4 === 0 && /^[A-Za-z0-9+/]+={0,2}$/.test(data);
|
|
24547
|
+
if (canonical) {
|
|
24548
|
+
try {
|
|
24549
|
+
canonical = btoa(atob(data)) === data;
|
|
24550
|
+
} catch {
|
|
24551
|
+
canonical = false;
|
|
24552
|
+
}
|
|
24553
|
+
}
|
|
24554
|
+
if (!canonical) {
|
|
24555
|
+
const toolName = String(event.toolName || "Tool");
|
|
24556
|
+
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.`;
|
|
24557
|
+
}
|
|
24558
|
+
}
|
|
24559
|
+
return "";
|
|
24560
|
+
}
|
|
24561
|
+
|
|
24562
|
+
function assistantErrorFromAgentEnd(event) {
|
|
24563
|
+
const messages = Array.isArray(event?.messages) ? event.messages : [];
|
|
24564
|
+
const message = messages.findLast((item) => item?.role === "assistant");
|
|
24565
|
+
if (message?.stopReason !== "error") return "";
|
|
24566
|
+
return String(message.errorMessage || "The assistant request failed without an error message.").trim();
|
|
24567
|
+
}
|
|
24568
|
+
|
|
24219
24569
|
function addAbortTranscriptNotice({ activeRun = false, errorMessage = "" } = {}) {
|
|
24220
24570
|
if (errorMessage) {
|
|
24221
24571
|
addTransientMessage({ role: "error", title: "Abort failed", content: `Abort request failed: ${errorMessage}`, level: "error" });
|
|
@@ -24618,7 +24968,7 @@ function requestGitFooterWebuiPayload(tabContext = activeTabContext(), { force =
|
|
|
24618
24968
|
|
|
24619
24969
|
gitFooterPayloadRefreshInFlightByTab.add(tabContext.tabId);
|
|
24620
24970
|
if (isCurrentTabContext(tabContext)) renderFooter();
|
|
24621
|
-
api("/api/prompt", {
|
|
24971
|
+
return api("/api/prompt", {
|
|
24622
24972
|
method: "POST",
|
|
24623
24973
|
body: { message: `/${refreshCommand}${silent ? " --webui-silent" : ""}`, streamingBehavior: "steer" },
|
|
24624
24974
|
tabId: tabContext.tabId,
|
|
@@ -26743,6 +27093,7 @@ function resetStreamBubble() {
|
|
|
26743
27093
|
streamThinkingBubble = null;
|
|
26744
27094
|
streamThinking = null;
|
|
26745
27095
|
streamMessageActive = false;
|
|
27096
|
+
streamProviderErrorText = "";
|
|
26746
27097
|
}
|
|
26747
27098
|
|
|
26748
27099
|
function liveStreamRenderActive() {
|
|
@@ -26919,6 +27270,17 @@ function syncStreamingThinkingFromUpdate(event, update, { placeholder = "" } = {
|
|
|
26919
27270
|
return setStreamingThinkingText(streamThinkingRawText || placeholder);
|
|
26920
27271
|
}
|
|
26921
27272
|
|
|
27273
|
+
function assistantStreamErrorMessage(event, update = event?.assistantMessageEvent || {}) {
|
|
27274
|
+
return String(
|
|
27275
|
+
update.error?.errorMessage ||
|
|
27276
|
+
update.errorMessage ||
|
|
27277
|
+
update.partial?.errorMessage ||
|
|
27278
|
+
event?.message?.errorMessage ||
|
|
27279
|
+
update.reason ||
|
|
27280
|
+
"assistant error"
|
|
27281
|
+
).trim();
|
|
27282
|
+
}
|
|
27283
|
+
|
|
26922
27284
|
function handleMessageUpdate(event) {
|
|
26923
27285
|
const update = event.assistantMessageEvent || {};
|
|
26924
27286
|
if (update.type === "thinking_start") {
|
|
@@ -26963,8 +27325,9 @@ function handleMessageUpdate(event) {
|
|
|
26963
27325
|
const name = updateStreamingToolCallFromEvent(event, { complete: true, scroll: true });
|
|
26964
27326
|
setRunIndicatorActivity(`Tool call ready: ${name}; waiting to run…`, { scroll: false });
|
|
26965
27327
|
} else if (update.type === "error") {
|
|
27328
|
+
streamProviderErrorText = assistantStreamErrorMessage(event, update);
|
|
26966
27329
|
setRunIndicatorActivity("Assistant stream reported an error…");
|
|
26967
|
-
appendMessage({ role: "error", title: "assistant error", timestamp: Date.now(), content:
|
|
27330
|
+
appendMessage({ role: "error", title: "assistant error", timestamp: Date.now(), content: streamProviderErrorText, level: "error" }, { streaming: true });
|
|
26968
27331
|
renderRunIndicator({ scroll: false });
|
|
26969
27332
|
scheduleChatFollowScroll();
|
|
26970
27333
|
}
|
|
@@ -29087,6 +29450,9 @@ function handleEvent(event) {
|
|
|
29087
29450
|
renderWidgets();
|
|
29088
29451
|
renderTabs();
|
|
29089
29452
|
break;
|
|
29453
|
+
case "webui_git_changed":
|
|
29454
|
+
invalidateGitPanelRepository(event.root);
|
|
29455
|
+
break;
|
|
29090
29456
|
case "webui_cwd_changed":
|
|
29091
29457
|
addEvent(`${event.tabTitle || "terminal"} cwd changed to ${event.cwd}`);
|
|
29092
29458
|
setAppRunnerData(event.tabId || activeTabId, { cwd: event.cwd, activeRun: null, runners: [] });
|
|
@@ -29119,21 +29485,24 @@ function handleEvent(event) {
|
|
|
29119
29485
|
renderNetworkStatus();
|
|
29120
29486
|
break;
|
|
29121
29487
|
case "pi_process_exit":
|
|
29122
|
-
|
|
29488
|
+
surfaceRuntimeDiagnostic("Pi process exited", `Pi RPC exited (${event.code ?? event.signal ?? "unknown"}).`);
|
|
29123
29489
|
clearRunIndicatorActivity();
|
|
29124
29490
|
refreshTabs().catch((error) => addEvent(error.message, "error"));
|
|
29125
29491
|
break;
|
|
29126
29492
|
case "pi_process_error":
|
|
29127
|
-
|
|
29493
|
+
surfaceRuntimeDiagnostic("Pi process error", event.error || "Pi RPC process error.");
|
|
29128
29494
|
clearRunIndicatorActivity();
|
|
29129
29495
|
refreshTabs().catch((error) => addEvent(error.message, "error"));
|
|
29130
29496
|
break;
|
|
29131
|
-
case "pi_stderr":
|
|
29132
|
-
|
|
29497
|
+
case "pi_stderr": {
|
|
29498
|
+
const message = String(event.text || "").trim();
|
|
29499
|
+
if (message) surfaceRuntimeDiagnostic("Pi runtime diagnostic", message, stderrDiagnosticLevel(message));
|
|
29133
29500
|
break;
|
|
29501
|
+
}
|
|
29134
29502
|
case "pi_stderr_sink_error":
|
|
29135
29503
|
case "pi_stdout_line_too_large":
|
|
29136
|
-
|
|
29504
|
+
case "pi_stdout_parse_error":
|
|
29505
|
+
surfaceRuntimeDiagnostic("Pi RPC transport error", event.error || "Pi RPC transport diagnostic.");
|
|
29137
29506
|
break;
|
|
29138
29507
|
case "queue_update":
|
|
29139
29508
|
renderQueue(event);
|
|
@@ -29157,6 +29526,7 @@ function handleEvent(event) {
|
|
|
29157
29526
|
scheduleRefreshState();
|
|
29158
29527
|
break;
|
|
29159
29528
|
case "agent_start":
|
|
29529
|
+
assistantErrorSurfacedThisRun = false;
|
|
29160
29530
|
if (currentState) currentState = { ...currentState, isStreaming: true };
|
|
29161
29531
|
if (voiceConversationActiveFor(event.tabId || activeTabId)) voiceConversation.setAssistantActivity({ streaming: true });
|
|
29162
29532
|
setRunIndicatorActivity("Agent run started; waiting for first output or action…");
|
|
@@ -29167,6 +29537,13 @@ function handleEvent(event) {
|
|
|
29167
29537
|
break;
|
|
29168
29538
|
case "agent_end":
|
|
29169
29539
|
streamMessageActive = false;
|
|
29540
|
+
if (!assistantErrorSurfacedThisRun && event.willRetry !== true) {
|
|
29541
|
+
const message = assistantErrorFromAgentEnd(event);
|
|
29542
|
+
if (message) {
|
|
29543
|
+
surfaceRuntimeDiagnostic("Assistant error", message);
|
|
29544
|
+
assistantErrorSurfacedThisRun = true;
|
|
29545
|
+
}
|
|
29546
|
+
}
|
|
29170
29547
|
addEvent("agent finished");
|
|
29171
29548
|
notifyAgentDone(event.tabId || activeTabId, { activity: event.tabActivity, tabTitle: event.tabTitle });
|
|
29172
29549
|
clearContextUsageUnknownAfterCompaction(event.tabId || activeTabId);
|
|
@@ -29188,7 +29565,7 @@ function handleEvent(event) {
|
|
|
29188
29565
|
const workflowTabId = event.tabId || activeTabId;
|
|
29189
29566
|
const workflow = gitWorkflowForTab(workflowTabId, { create: false });
|
|
29190
29567
|
if (workflow?.active && workflow.step === "generating") {
|
|
29191
|
-
loadGitWorkflowMessage({ requireFresh: true,
|
|
29568
|
+
loadGitWorkflowMessage({ requireFresh: true, generationId: workflow.messageGenerationId, runId: workflow.runId, tabId: workflowTabId });
|
|
29192
29569
|
} else if (workflow?.active && workflow.step === "branchNaming") {
|
|
29193
29570
|
loadGitWorkflowBranchName({ requireFresh: true, retries: 3, runId: workflow.runId, tabId: workflowTabId });
|
|
29194
29571
|
} else if (workflow?.active && workflow.step === "prGenerating") {
|
|
@@ -29206,13 +29583,20 @@ function handleEvent(event) {
|
|
|
29206
29583
|
case "message_update":
|
|
29207
29584
|
handleMessageUpdate(event);
|
|
29208
29585
|
break;
|
|
29209
|
-
case "message_end":
|
|
29586
|
+
case "message_end": {
|
|
29210
29587
|
streamMessageActive = false;
|
|
29588
|
+
if (event.message?.role === "assistant" && event.message.stopReason === "error") {
|
|
29589
|
+
const message = String(event.message.errorMessage || streamProviderErrorText || "The assistant request failed without an error message.").trim();
|
|
29590
|
+
surfaceRuntimeDiagnostic("Assistant error", message);
|
|
29591
|
+
assistantErrorSurfacedThisRun = true;
|
|
29592
|
+
}
|
|
29593
|
+
streamProviderErrorText = "";
|
|
29211
29594
|
if (runIndicatorIsActive()) setRunIndicatorActivity("Assistant message finished; waiting for the next step…", { scroll: false });
|
|
29212
29595
|
scheduleRefreshMessages();
|
|
29213
29596
|
scheduleRefreshState();
|
|
29214
29597
|
scheduleRefreshFooter();
|
|
29215
29598
|
break;
|
|
29599
|
+
}
|
|
29216
29600
|
case "tool_execution_start":
|
|
29217
29601
|
streamToolCallSeen = true;
|
|
29218
29602
|
if (voiceConversationActiveFor(event.tabId || activeTabId)) voiceConversation.setAssistantActivity({ toolRunning: true });
|
|
@@ -29226,8 +29610,10 @@ function handleEvent(event) {
|
|
|
29226
29610
|
handleToolExecutionUpdate(event);
|
|
29227
29611
|
setRunIndicatorActivity(`Running tool: ${runIndicatorToolName(event.toolName)}…`, { scroll: false });
|
|
29228
29612
|
break;
|
|
29229
|
-
case "tool_execution_end":
|
|
29613
|
+
case "tool_execution_end": {
|
|
29230
29614
|
if (voiceConversationActiveFor(event.tabId || activeTabId)) voiceConversation.setAssistantActivity({ toolRunning: false });
|
|
29615
|
+
const imagePayloadError = toolImagePayloadError(event);
|
|
29616
|
+
if (imagePayloadError) surfaceRuntimeDiagnostic("Tool image payload error", imagePayloadError);
|
|
29231
29617
|
handleToolExecutionEnd(event);
|
|
29232
29618
|
setRunIndicatorActivity(`Tool ${runIndicatorToolName(event.toolName)} ${event.isError ? "failed" : "finished"}; waiting for the agent's next step…`);
|
|
29233
29619
|
addEvent(`tool ${event.toolName} ${event.isError ? "failed" : "finished"}`, event.isError ? "error" : "info", { toolCallId: event.toolCallId });
|
|
@@ -29236,6 +29622,7 @@ function handleEvent(event) {
|
|
|
29236
29622
|
// transcript. This avoids one fetch+render per tool call.
|
|
29237
29623
|
scheduleRefreshFooter();
|
|
29238
29624
|
break;
|
|
29625
|
+
}
|
|
29239
29626
|
case "compaction_start":
|
|
29240
29627
|
if (currentState) currentState = { ...currentState, isCompacting: true };
|
|
29241
29628
|
markContextUsageUnknownAfterCompaction(event.tabId || activeTabId);
|
|
@@ -29247,7 +29634,8 @@ function handleEvent(event) {
|
|
|
29247
29634
|
if (currentState) currentState = { ...currentState, isCompacting: false };
|
|
29248
29635
|
if (event.aborted) clearContextUsageUnknownAfterCompaction(event.tabId || activeTabId);
|
|
29249
29636
|
else markContextUsageUnknownAfterCompaction(event.tabId || activeTabId);
|
|
29250
|
-
|
|
29637
|
+
if (event.errorMessage) surfaceRuntimeDiagnostic("Compaction error", event.errorMessage);
|
|
29638
|
+
else addEvent(`compaction ${event.aborted ? "aborted" : "finished"}`);
|
|
29251
29639
|
if (!currentState?.isStreaming) clearRunIndicatorActivity();
|
|
29252
29640
|
markTabOutputSeen();
|
|
29253
29641
|
renderStatus();
|
|
@@ -29282,7 +29670,7 @@ function handleEvent(event) {
|
|
|
29282
29670
|
handleExtensionUiRequest(event);
|
|
29283
29671
|
break;
|
|
29284
29672
|
case "response":
|
|
29285
|
-
if (event.success === false)
|
|
29673
|
+
if (event.success === false) surfaceRuntimeDiagnostic(`${event.command || "Pi command"} failed`, event.error || "Unknown RPC command error.");
|
|
29286
29674
|
else if (event.command === "get_state" && event.tabId === activeTabId) {
|
|
29287
29675
|
currentState = event.data || currentState;
|
|
29288
29676
|
syncActiveTabActivityFromState(currentState);
|
|
@@ -30176,6 +30564,7 @@ elements.sidePanelExpandButton.addEventListener("click", () => {
|
|
|
30176
30564
|
elements.sidePanelBackdrop.addEventListener("click", () => {
|
|
30177
30565
|
setSidePanelCollapsed(true);
|
|
30178
30566
|
});
|
|
30567
|
+
bindSidePanelContextMenu();
|
|
30179
30568
|
elements.stickyUserPromptButton?.addEventListener("click", jumpToStickyUserPrompt);
|
|
30180
30569
|
elements.jumpToLatestButton.addEventListener("click", jumpToLatest);
|
|
30181
30570
|
elements.chat.addEventListener("wheel", noteChatUserScrollIntent, { passive: true });
|
|
@@ -30235,6 +30624,9 @@ document.addEventListener("pointerdown", (event) => {
|
|
|
30235
30624
|
if (elements.gitPanelContextMenu && !elements.gitPanelContextMenu.hidden && !event.target?.closest?.(".git-side-panel-context-menu")) {
|
|
30236
30625
|
closeGitPanelContextMenu();
|
|
30237
30626
|
}
|
|
30627
|
+
if (elements.sidePanelContextMenu && !elements.sidePanelContextMenu.hidden && !event.target?.closest?.(".side-panel-context-menu")) {
|
|
30628
|
+
closeSidePanelContextMenu();
|
|
30629
|
+
}
|
|
30238
30630
|
}, { passive: true });
|
|
30239
30631
|
document.addEventListener("pointermove", (event) => {
|
|
30240
30632
|
if (openTerminalTabGroupKey && !event.target?.closest?.(".terminal-tab-group")) {
|
|
@@ -30433,6 +30825,7 @@ window.addEventListener("focus", () => scheduleForegroundReconcile("window focus
|
|
|
30433
30825
|
window.addEventListener("online", () => scheduleForegroundReconcile("network online", 0));
|
|
30434
30826
|
window.addEventListener("storage", (event) => {
|
|
30435
30827
|
if (event.key === OPTIONAL_FEATURES_STORAGE_KEY) reconcileDisabledOptionalFeaturesFromStorage();
|
|
30828
|
+
if (event.key === SIDE_PANEL_SECTION_VISIBILITY_STORAGE_KEY) restoreSidePanelSectionVisibility();
|
|
30436
30829
|
});
|
|
30437
30830
|
window.addEventListener("resize", syncFileViewerWidthForViewport, { passive: true });
|
|
30438
30831
|
window.addEventListener("keydown", (event) => {
|
|
@@ -30612,6 +31005,21 @@ elements.gitPanelContextMenu?.addEventListener("keydown", (event) => {
|
|
|
30612
31005
|
items[event.key === "Home" ? 0 : items.length - 1]?.focus({ preventScroll: true });
|
|
30613
31006
|
}
|
|
30614
31007
|
});
|
|
31008
|
+
elements.sidePanelContextMenu?.addEventListener("keydown", (event) => {
|
|
31009
|
+
const items = [...elements.sidePanelContextMenu.querySelectorAll('[role="menuitemcheckbox"]')];
|
|
31010
|
+
const index = items.indexOf(document.activeElement);
|
|
31011
|
+
if (event.key === "Escape") {
|
|
31012
|
+
event.preventDefault();
|
|
31013
|
+
closeSidePanelContextMenu();
|
|
31014
|
+
} else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
31015
|
+
event.preventDefault();
|
|
31016
|
+
const direction = event.key === "ArrowDown" ? 1 : -1;
|
|
31017
|
+
items[(Math.max(0, index) + direction + items.length) % items.length]?.focus({ preventScroll: true });
|
|
31018
|
+
} else if (event.key === "Home" || event.key === "End") {
|
|
31019
|
+
event.preventDefault();
|
|
31020
|
+
items[event.key === "Home" ? 0 : items.length - 1]?.focus({ preventScroll: true });
|
|
31021
|
+
}
|
|
31022
|
+
});
|
|
30615
31023
|
elements.fileContextMenu?.addEventListener("click", (event) => {
|
|
30616
31024
|
const button = event.target?.closest?.("[data-file-menu-action]");
|
|
30617
31025
|
if (!button) return;
|
|
@@ -30793,6 +31201,7 @@ restoreToolOutputExpansionSetting();
|
|
|
30793
31201
|
restoreWorkspaceDashboardState();
|
|
30794
31202
|
restoreInterfaceDensity();
|
|
30795
31203
|
initializeTerminalHeaderTooltips();
|
|
31204
|
+
restoreSidePanelSectionVisibility();
|
|
30796
31205
|
restoreSidePanelSectionState();
|
|
30797
31206
|
bindSidePanelSectionToggles();
|
|
30798
31207
|
restoreSidePanelState();
|