@firstpick/pi-package-webui 0.6.9 → 0.7.1
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 +7 -2
- package/bin/pi-webui.mjs +407 -31
- package/index.ts +7 -91
- package/package.json +8 -7
- package/public/app.js +1140 -100
- package/public/aur-review-payload.mjs +108 -0
- package/public/guided-git-command-state.mjs +34 -0
- package/public/guided-git-review-state.mjs +137 -0
- package/public/index.html +54 -1
- package/public/styles.css +290 -20
- package/tests/aur-review-payload.test.mjs +57 -0
- package/tests/aur-review-widget-static.test.mjs +38 -0
- package/tests/compaction-resume-harness.test.mjs +55 -3
- package/tests/compaction-static.test.mjs +3 -3
- package/tests/fixtures/compacting-pi.mjs +10 -5
- package/tests/fixtures/fake-pi.mjs +46 -0
- package/tests/guided-git-aur-review.test.mjs +183 -0
- package/tests/http-endpoints-harness.test.mjs +118 -1
- package/tests/mobile-static.test.mjs +123 -12
- package/tests/staged-content-hash-contract.test.mjs +174 -0
- package/tests/subagents-helper.test.mjs +83 -4
- package/tests/transport-hardening-harness.test.mjs +157 -0
- package/webui-rpc-helper.mjs +108 -25
package/public/app.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { aurReviewSafePath as parsedAurReviewSafePath, parseAurReviewPayload as parseValidatedAurReviewPayload } from "./aur-review-payload.mjs";
|
|
2
|
+
import { guidedGitReviewAvailableForTabCatalog, resolveCommandForTabCatalog, resolveRpcSlashCommandForTabCatalog } from "./guided-git-command-state.mjs";
|
|
3
|
+
import { guidedGitReviewCanRequestStagedContent, guidedGitReviewHasApprovedBinding, guidedGitReviewProcessNavigationAllowed, guidedGitReviewProcessSelectionPatch, guidedGitReviewTransition, guidedGitReviewWidgetRemovalTransition } from "./guided-git-review-state.mjs";
|
|
4
|
+
|
|
1
5
|
const $ = (selector) => document.querySelector(selector);
|
|
2
6
|
|
|
3
7
|
const elements = {
|
|
@@ -40,6 +44,14 @@ const elements = {
|
|
|
40
44
|
copyServerCommandButton: $("#copyServerCommandButton"),
|
|
41
45
|
retryServerConnectionButton: $("#retryServerConnectionButton"),
|
|
42
46
|
widgetArea: $("#widgetArea"),
|
|
47
|
+
subagentTerminalView: $("#subagentTerminalView"),
|
|
48
|
+
subagentTerminalTitle: $("#subagentTerminalTitle"),
|
|
49
|
+
subagentTerminalMeta: $("#subagentTerminalMeta"),
|
|
50
|
+
subagentTerminalTranscript: $("#subagentTerminalTranscript"),
|
|
51
|
+
subagentTerminalStatus: $("#subagentTerminalStatus"),
|
|
52
|
+
subagentTerminalCopyButton: $("#subagentTerminalCopyButton"),
|
|
53
|
+
subagentTerminalRefreshButton: $("#subagentTerminalRefreshButton"),
|
|
54
|
+
subagentTerminalInput: $("#subagentTerminalInput"),
|
|
43
55
|
stickyUserPromptButton: $("#stickyUserPromptButton"),
|
|
44
56
|
chat: $("#chat"),
|
|
45
57
|
chatSearchBar: $("#chatSearchBar"),
|
|
@@ -217,6 +229,8 @@ const elements = {
|
|
|
217
229
|
subagentsStatus: $("#subagentsStatus"),
|
|
218
230
|
subagentsBox: $("#subagentsBox"),
|
|
219
231
|
subagentCountBadge: $("#subagentCountBadge"),
|
|
232
|
+
subagentOpenModeSelect: $("#subagentOpenModeSelect"),
|
|
233
|
+
subagentOpenModeStatus: $("#subagentOpenModeStatus"),
|
|
220
234
|
queueBox: $("#queueBox"),
|
|
221
235
|
queueCountBadge: $("#queueCountBadge"),
|
|
222
236
|
createPromptListButton: $("#createPromptListButton"),
|
|
@@ -259,6 +273,12 @@ const elements = {
|
|
|
259
273
|
confirmationUndo: $("#confirmationUndo"),
|
|
260
274
|
confirmationCancelButton: $("#confirmationCancelButton"),
|
|
261
275
|
confirmationConfirmButton: $("#confirmationConfirmButton"),
|
|
276
|
+
gitWorktreeBaseDialog: $("#gitWorktreeBaseDialog"),
|
|
277
|
+
gitWorktreeBaseBranch: $("#gitWorktreeBaseBranch"),
|
|
278
|
+
gitWorktreeBaseOriginMain: $("#gitWorktreeBaseOriginMain"),
|
|
279
|
+
gitWorktreeBaseCurrentHead: $("#gitWorktreeBaseCurrentHead"),
|
|
280
|
+
gitWorktreeBaseCancelButton: $("#gitWorktreeBaseCancelButton"),
|
|
281
|
+
gitWorktreeBaseCreateButton: $("#gitWorktreeBaseCreateButton"),
|
|
262
282
|
piReleaseNotesDialog: $("#piReleaseNotesDialog"),
|
|
263
283
|
piReleaseNotesTitle: $("#piReleaseNotesTitle"),
|
|
264
284
|
piReleaseNotesStatus: $("#piReleaseNotesStatus"),
|
|
@@ -386,6 +406,7 @@ let foregroundReconcileTimer = null;
|
|
|
386
406
|
let eventSource = null;
|
|
387
407
|
let activeDialog = null;
|
|
388
408
|
let activeConfirmationResolve = null;
|
|
409
|
+
let activeGitWorktreeBaseResolve = null;
|
|
389
410
|
let activeUndoAction = null;
|
|
390
411
|
let undoToastTimer = null;
|
|
391
412
|
let undoToastFocusReturn = null;
|
|
@@ -420,6 +441,7 @@ let appRunnerFileBrowserState = { open: false, loading: false, path: "", data: n
|
|
|
420
441
|
let optionsMenuOpen = false;
|
|
421
442
|
let availableCommands = [];
|
|
422
443
|
let rawAvailableCommands = [];
|
|
444
|
+
const commandCatalogsByTab = new Map();
|
|
423
445
|
let commandSuggestions = [];
|
|
424
446
|
let pathSuggestions = [];
|
|
425
447
|
let bangSuggestions = [];
|
|
@@ -473,6 +495,10 @@ let subagentOverlayError = "";
|
|
|
473
495
|
let subagentOverlayLoading = false;
|
|
474
496
|
let subagentOverlayRefreshTimer = null;
|
|
475
497
|
let subagentOverlayRequestSerial = 0;
|
|
498
|
+
let subagentOpenMode = "overlay";
|
|
499
|
+
const subagentTerminalViews = new Map();
|
|
500
|
+
let activeSubagentTerminalId = null;
|
|
501
|
+
let subagentTerminalRefreshTimer = null;
|
|
476
502
|
let backendOffline = false;
|
|
477
503
|
let serverRestartInProgress = false;
|
|
478
504
|
let updateRequestInProgress = false;
|
|
@@ -582,6 +608,7 @@ const THINKING_VISIBILITY_STORAGE_KEY = "pi-webui-thinking-visible";
|
|
|
582
608
|
const BUSY_PROMPT_BEHAVIOR_STORAGE_KEY = "pi-webui-busy-prompt-behavior";
|
|
583
609
|
const SKILL_USAGE_STORAGE_KEY = "pi-webui-skill-usage-v1";
|
|
584
610
|
const TERMINAL_TABS_LAYOUT_STORAGE_KEY = "pi-webui-terminal-tabs-layout";
|
|
611
|
+
const SUBAGENT_OPEN_MODE_STORAGE_KEY = "pi-webui-subagent-open-mode";
|
|
585
612
|
const TERMINAL_CUSTOM_GROUPS_STORAGE_KEY = "pi-webui-terminal-custom-groups-v1";
|
|
586
613
|
const TERMINAL_TAB_DRAG_MIME = "application/x-pi-terminal-tab-id";
|
|
587
614
|
const FOOTER_SCOPED_MODEL_ORDER_STORAGE_KEY = "pi-webui-footer-scoped-model-order-v1";
|
|
@@ -680,6 +707,10 @@ const WORKFLOW_MODE_RPC_WIDGET_KEY = "workflow-mode:rpc";
|
|
|
680
707
|
const WORKFLOW_MODE_RPC_PAYLOAD_PREFIX = "WORKFLOW_MODE_RPC_PAYLOAD ";
|
|
681
708
|
const WORKFLOW_MODE_RPC_PAYLOAD_TYPE = "firstpick.pi-extension-workflows.mode";
|
|
682
709
|
const WORKFLOW_MODE_RPC_PAYLOAD_VERSION = 1;
|
|
710
|
+
const AUR_REVIEW_RPC_WIDGET_KEY = "aur-review:rpc";
|
|
711
|
+
const AUR_REVIEW_RPC_PAYLOAD_PREFIX = "AUR_REVIEW_RPC_PAYLOAD ";
|
|
712
|
+
const AUR_REVIEW_RPC_PAYLOAD_TYPE = "firstpick.pi-extension-aur-review.review";
|
|
713
|
+
const AUR_REVIEW_RPC_PAYLOAD_VERSION = 3;
|
|
683
714
|
const GIT_CHANGES_RENDER_ROW_LIMIT = 4000;
|
|
684
715
|
const GIT_PULL_RESULT_FILE_LIMIT = 48;
|
|
685
716
|
const LAST_USER_PROMPT_STORAGE_KEY = "pi-webui-last-user-prompts";
|
|
@@ -718,6 +749,8 @@ const THEME_SCHEME_MODES = new Set(["light", "dark", "auto"]);
|
|
|
718
749
|
let themeSchemeMode = "light"; // "light" | "dark" | "auto"; finalized in initializeThemes
|
|
719
750
|
const TERMINAL_TABS_LAYOUTS = new Set(["top", "left"]);
|
|
720
751
|
const TERMINAL_TABS_LAYOUT_LABELS = { top: "Top bar", left: "Left sidebar" };
|
|
752
|
+
const SUBAGENT_OPEN_MODES = new Set(["overlay", "tab"]);
|
|
753
|
+
const SUBAGENT_OPEN_MODE_LABELS = { overlay: "Overlay", tab: "Tab / terminal" };
|
|
721
754
|
const BUSY_PROMPT_BEHAVIOR_VALUES = new Set(["followUp", "steer"]);
|
|
722
755
|
const BUSY_PROMPT_BEHAVIOR_LABELS = { followUp: "Follow-up", steer: "Steer" };
|
|
723
756
|
const SKILL_TAG_MAX_VISIBLE = 6;
|
|
@@ -801,6 +834,7 @@ const optionalFeatureAvailability = {
|
|
|
801
834
|
gitWorkflow: false,
|
|
802
835
|
releaseNpm: false,
|
|
803
836
|
releaseAur: false,
|
|
837
|
+
aurReview: false,
|
|
804
838
|
workflows: false,
|
|
805
839
|
safetyGuard: false,
|
|
806
840
|
statsCommand: false,
|
|
@@ -857,6 +891,13 @@ const OPTIONAL_FEATURES = [
|
|
|
857
891
|
capabilityLabel: "/release-aur",
|
|
858
892
|
description: "Publish menu action, setup helpers, skills, and AUR release widgets.",
|
|
859
893
|
},
|
|
894
|
+
{
|
|
895
|
+
id: "aurReview",
|
|
896
|
+
label: "Manual repository review",
|
|
897
|
+
packageName: "@firstpick/pi-extension-aur-review",
|
|
898
|
+
capabilityLabel: "/aur-review or aur-review:rpc widget event",
|
|
899
|
+
description: "Manual repository/Git review bound to an exact working-tree or staged snapshot.",
|
|
900
|
+
},
|
|
860
901
|
{
|
|
861
902
|
id: "workflows",
|
|
862
903
|
label: "Workflows",
|
|
@@ -940,7 +981,7 @@ const OPTIONAL_FEATURE_SECTIONS = [
|
|
|
940
981
|
id: "workflows-releases",
|
|
941
982
|
label: "Workflows & releases",
|
|
942
983
|
description: "Guided workflows, task runners, and publishing actions with visible execution state.",
|
|
943
|
-
featureIds: ["gitWorkflow", "workflows", "releaseNpm", "releaseAur"],
|
|
984
|
+
featureIds: ["gitWorkflow", "workflows", "releaseNpm", "releaseAur", "aurReview"],
|
|
944
985
|
},
|
|
945
986
|
{
|
|
946
987
|
id: "safety-access",
|
|
@@ -973,6 +1014,7 @@ const OPTIONAL_COMMAND_FEATURES = new Map([
|
|
|
973
1014
|
["pr", "gitWorkflow"],
|
|
974
1015
|
["release-npm", "releaseNpm"],
|
|
975
1016
|
["release-aur", "releaseAur"],
|
|
1017
|
+
["aur-review", "aurReview"],
|
|
976
1018
|
["workflow", "workflows"],
|
|
977
1019
|
["workflow-clear", "workflows"],
|
|
978
1020
|
["safety-guard", "safetyGuard"],
|
|
@@ -1058,6 +1100,17 @@ function resetGitWorkflowManualCommitDefaultPatch() {
|
|
|
1058
1100
|
};
|
|
1059
1101
|
}
|
|
1060
1102
|
|
|
1103
|
+
function resetGuidedGitReviewPatch({ retainDeclinedStagedContentHash = true } = {}) {
|
|
1104
|
+
return {
|
|
1105
|
+
guidedReviewStatus: "",
|
|
1106
|
+
guidedReviewFingerprint: "",
|
|
1107
|
+
guidedReviewRepoRoot: "",
|
|
1108
|
+
guidedReviewStagedContentHash: "",
|
|
1109
|
+
guidedReviewRequestedAt: 0,
|
|
1110
|
+
...(retainDeclinedStagedContentHash ? {} : { guidedReviewDeclinedStagedContentHash: "" }),
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1061
1114
|
function gitWorkflowManualCommitInputMessage(workflow) {
|
|
1062
1115
|
return String(workflow?.manualCommitMessage || "").trim() || String(workflow?.manualCommitMessageDefault || "").trim();
|
|
1063
1116
|
}
|
|
@@ -1090,6 +1143,8 @@ function createGitWorkflowState() {
|
|
|
1090
1143
|
prBranch: "",
|
|
1091
1144
|
pr: null,
|
|
1092
1145
|
prRequestedAt: 0,
|
|
1146
|
+
...resetGuidedGitReviewPatch({ retainDeclinedStagedContentHash: false }),
|
|
1147
|
+
guidedReviewRequired: false,
|
|
1093
1148
|
preferences: null,
|
|
1094
1149
|
verificationConfirmed: false,
|
|
1095
1150
|
};
|
|
@@ -1138,6 +1193,7 @@ function clearGitWorkflowForTab(tabId) {
|
|
|
1138
1193
|
|
|
1139
1194
|
const GIT_WORKFLOW_PROCESSES = [
|
|
1140
1195
|
{ value: "stage", label: "Stage" },
|
|
1196
|
+
{ value: "review", label: "Review" },
|
|
1141
1197
|
{ value: "message", label: "Message" },
|
|
1142
1198
|
{ value: "commit", label: "Commit" },
|
|
1143
1199
|
{ value: "push", label: "Push" },
|
|
@@ -1161,18 +1217,20 @@ const ACTION_FEEDBACK_REACTIONS = {
|
|
|
1161
1217
|
const ACTION_FEEDBACK_SNIPPET_LIMIT = 1200;
|
|
1162
1218
|
const GIT_WORKFLOW_ACTIVE_INDEX = {
|
|
1163
1219
|
add: 0,
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1220
|
+
reviewRequesting: 1,
|
|
1221
|
+
review: 1,
|
|
1222
|
+
generate: 2,
|
|
1223
|
+
generating: 2,
|
|
1224
|
+
message: 3,
|
|
1225
|
+
branchNaming: 3,
|
|
1226
|
+
branching: 3,
|
|
1227
|
+
committing: 3,
|
|
1228
|
+
push: 4,
|
|
1229
|
+
pushing: 4,
|
|
1230
|
+
prGenerating: 4,
|
|
1231
|
+
prReview: 4,
|
|
1232
|
+
prCreating: 4,
|
|
1233
|
+
done: 5,
|
|
1176
1234
|
};
|
|
1177
1235
|
const GIT_INIT_WORKFLOW_ACTIVE_INDEX = {
|
|
1178
1236
|
initSetup: 0,
|
|
@@ -1647,6 +1705,44 @@ function restoreTerminalTabsLayoutSetting() {
|
|
|
1647
1705
|
setTerminalTabsLayout(readStoredTerminalTabsLayout(), { persist: false });
|
|
1648
1706
|
}
|
|
1649
1707
|
|
|
1708
|
+
function normalizeSubagentOpenMode(value) {
|
|
1709
|
+
return SUBAGENT_OPEN_MODES.has(value) ? value : "overlay";
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
function readStoredSubagentOpenMode() {
|
|
1713
|
+
try {
|
|
1714
|
+
return normalizeSubagentOpenMode(localStorage.getItem(SUBAGENT_OPEN_MODE_STORAGE_KEY));
|
|
1715
|
+
} catch {
|
|
1716
|
+
return "overlay";
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
function persistSubagentOpenMode(mode) {
|
|
1721
|
+
try {
|
|
1722
|
+
localStorage.setItem(SUBAGENT_OPEN_MODE_STORAGE_KEY, normalizeSubagentOpenMode(mode));
|
|
1723
|
+
} catch {
|
|
1724
|
+
// Ignore storage failures; the opening mode still applies for this page load.
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
function renderSubagentOpenModeControl() {
|
|
1729
|
+
const mode = normalizeSubagentOpenMode(subagentOpenMode);
|
|
1730
|
+
if (elements.subagentOpenModeSelect) elements.subagentOpenModeSelect.value = mode;
|
|
1731
|
+
if (elements.subagentOpenModeStatus) elements.subagentOpenModeStatus.textContent = `${SUBAGENT_OPEN_MODE_LABELS[mode]} · saved in this browser`;
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
function setSubagentOpenMode(mode, { persist = true, announce = false } = {}) {
|
|
1735
|
+
subagentOpenMode = normalizeSubagentOpenMode(mode);
|
|
1736
|
+
if (persist) persistSubagentOpenMode(subagentOpenMode);
|
|
1737
|
+
renderSubagentOpenModeControl();
|
|
1738
|
+
renderSubagents();
|
|
1739
|
+
if (announce) addEvent(`subagents now open in ${SUBAGENT_OPEN_MODE_LABELS[subagentOpenMode].toLowerCase()}`);
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
function restoreSubagentOpenModeSetting() {
|
|
1743
|
+
setSubagentOpenMode(readStoredSubagentOpenMode(), { persist: false });
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1650
1746
|
function normalizeTerminalCustomGroupTitle(value, fallback = "Custom group") {
|
|
1651
1747
|
const title = String(value || "").replace(/\s+/g, " ").trim();
|
|
1652
1748
|
return (title || fallback).slice(0, 40);
|
|
@@ -1906,6 +2002,8 @@ function setThinkingOutputVisible(visible, { announce = false } = {}) {
|
|
|
1906
2002
|
renderThinkingVisibilityToggle();
|
|
1907
2003
|
if (!thinkingOutputVisible) removeStreamingThinkingBubble();
|
|
1908
2004
|
renderAllMessages({ preserveScroll: true });
|
|
2005
|
+
if (subagentOverlaySelection?.tabId === activeTabId) renderWidgets();
|
|
2006
|
+
if (activeSubagentTerminalId) renderSubagentTerminalView();
|
|
1909
2007
|
if (announce) addEvent(thinkingOutputVisible ? "thinking output shown" : "thinking output hidden", thinkingOutputVisible ? "info" : "warn");
|
|
1910
2008
|
}
|
|
1911
2009
|
|
|
@@ -2727,6 +2825,31 @@ function appConfirmText(message, options = {}) {
|
|
|
2727
2825
|
});
|
|
2728
2826
|
}
|
|
2729
2827
|
|
|
2828
|
+
function finishGitWorktreeBaseChoice(baseRef = null) {
|
|
2829
|
+
const resolve = activeGitWorktreeBaseResolve;
|
|
2830
|
+
activeGitWorktreeBaseResolve = null;
|
|
2831
|
+
if (elements.gitWorktreeBaseDialog?.open) elements.gitWorktreeBaseDialog.close();
|
|
2832
|
+
resolve?.(baseRef);
|
|
2833
|
+
}
|
|
2834
|
+
|
|
2835
|
+
function chooseGitWorktreeBase(branch) {
|
|
2836
|
+
const branchName = cleanStatusText(branch) || "the new branch";
|
|
2837
|
+
if (!elements.gitWorktreeBaseDialog?.showModal) {
|
|
2838
|
+
const choice = window.prompt(`Create ${branchName} from:\n1. origin/main (default)\n2. Current workspace HEAD\n\nEnter 1 or 2. Cancel to abort.`, "1");
|
|
2839
|
+
if (choice === null) return Promise.resolve(null);
|
|
2840
|
+
return Promise.resolve(String(choice).trim() === "2" ? "HEAD" : "origin/main");
|
|
2841
|
+
}
|
|
2842
|
+
if (activeGitWorktreeBaseResolve) finishGitWorktreeBaseChoice(null);
|
|
2843
|
+
elements.gitWorktreeBaseBranch.textContent = branchName;
|
|
2844
|
+
elements.gitWorktreeBaseOriginMain.checked = true;
|
|
2845
|
+
elements.gitWorktreeBaseCurrentHead.checked = false;
|
|
2846
|
+
return new Promise((resolve) => {
|
|
2847
|
+
activeGitWorktreeBaseResolve = resolve;
|
|
2848
|
+
elements.gitWorktreeBaseDialog.showModal();
|
|
2849
|
+
queueMicrotask(() => elements.gitWorktreeBaseOriginMain?.focus());
|
|
2850
|
+
});
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2730
2853
|
function handleDrawerModalKeydown(event) {
|
|
2731
2854
|
if (!activeDrawerModal || event.defaultPrevented) return;
|
|
2732
2855
|
if (event.key === "Escape") {
|
|
@@ -7076,7 +7199,7 @@ function setFileViewerMode(mode = "source") {
|
|
|
7076
7199
|
}
|
|
7077
7200
|
|
|
7078
7201
|
function setFileViewerDirty(dirty) {
|
|
7079
|
-
if (!activeFileViewer) return;
|
|
7202
|
+
if (!activeFileViewer || activeFileViewer.readOnly) return;
|
|
7080
7203
|
activeFileViewer.dirty = !!dirty;
|
|
7081
7204
|
if (elements.fileViewerSaveButton) elements.fileViewerSaveButton.disabled = !activeFileViewer.dirty;
|
|
7082
7205
|
if (activeFileViewer.dirty) setFileViewerStatus("Unsaved file edits.", "warn");
|
|
@@ -7110,17 +7233,18 @@ function updateFileViewerUi() {
|
|
|
7110
7233
|
}
|
|
7111
7234
|
if (elements.fileViewerEditor) {
|
|
7112
7235
|
elements.fileViewerEditor.hidden = mode !== "source";
|
|
7236
|
+
elements.fileViewerEditor.readOnly = viewer.readOnly === true;
|
|
7113
7237
|
if (elements.fileViewerEditor.value !== viewer.content) elements.fileViewerEditor.value = viewer.content || "";
|
|
7114
7238
|
}
|
|
7115
7239
|
if (elements.fileViewerPreview) {
|
|
7116
7240
|
elements.fileViewerPreview.hidden = mode !== "preview";
|
|
7117
7241
|
if (mode === "preview") renderMarkdown(elements.fileViewerPreview, viewer.content || "");
|
|
7118
7242
|
}
|
|
7119
|
-
if (elements.fileViewerSaveButton) elements.fileViewerSaveButton.disabled = !viewer.dirty;
|
|
7243
|
+
if (elements.fileViewerSaveButton) elements.fileViewerSaveButton.disabled = viewer.readOnly === true || !viewer.dirty;
|
|
7120
7244
|
if (elements.fileViewerOpenDefaultButton) {
|
|
7121
7245
|
const viewerPath = normalizeFileTreePath(viewer.path || "");
|
|
7122
7246
|
elements.fileViewerOpenDefaultButton.dataset.path = viewerPath;
|
|
7123
|
-
elements.fileViewerOpenDefaultButton.disabled = !viewerPath;
|
|
7247
|
+
elements.fileViewerOpenDefaultButton.disabled = viewer.readOnly === true || !viewerPath;
|
|
7124
7248
|
}
|
|
7125
7249
|
renderFileViewerSelectionBar();
|
|
7126
7250
|
}
|
|
@@ -7252,7 +7376,10 @@ function closeFileViewer() {
|
|
|
7252
7376
|
updateFileViewerResizeHandle();
|
|
7253
7377
|
if (elements.fileViewerPane) elements.fileViewerPane.hidden = true;
|
|
7254
7378
|
if (elements.fileViewerOpenDefaultButton) elements.fileViewerOpenDefaultButton.dataset.path = "";
|
|
7255
|
-
if (elements.fileViewerEditor)
|
|
7379
|
+
if (elements.fileViewerEditor) {
|
|
7380
|
+
elements.fileViewerEditor.value = "";
|
|
7381
|
+
elements.fileViewerEditor.readOnly = false;
|
|
7382
|
+
}
|
|
7256
7383
|
if (elements.fileViewerPreview) elements.fileViewerPreview.replaceChildren();
|
|
7257
7384
|
setFileViewerStatus("");
|
|
7258
7385
|
}
|
|
@@ -7278,6 +7405,7 @@ async function openFileInViewer(path = "") {
|
|
|
7278
7405
|
language: data.language || "text",
|
|
7279
7406
|
mode: data.language === "markdown" ? "preview" : "source",
|
|
7280
7407
|
dirty: false,
|
|
7408
|
+
readOnly: false,
|
|
7281
7409
|
};
|
|
7282
7410
|
if (elements.fileViewerEditor) elements.fileViewerEditor.value = activeFileViewer.content;
|
|
7283
7411
|
clearFileViewerSelection();
|
|
@@ -7291,8 +7419,47 @@ async function openFileInViewer(path = "") {
|
|
|
7291
7419
|
}
|
|
7292
7420
|
}
|
|
7293
7421
|
|
|
7422
|
+
async function openAurReviewReportInViewer(path = "", repoRoot = "") {
|
|
7423
|
+
const normalized = aurReviewSafePath(path);
|
|
7424
|
+
const expectedRepoRoot = String(repoRoot || "");
|
|
7425
|
+
if (!normalized || !expectedRepoRoot) return;
|
|
7426
|
+
const tabContext = activeTabContext();
|
|
7427
|
+
setFileViewerStatus(`Opening ${normalized}…`);
|
|
7428
|
+
try {
|
|
7429
|
+
const params = new URLSearchParams({ path: normalized, repoRoot: expectedRepoRoot });
|
|
7430
|
+
const response = await api(`/api/aur-review/report-content?${params.toString()}`, { tabId: tabContext.tabId });
|
|
7431
|
+
if (!isCurrentTabContext(tabContext)) return;
|
|
7432
|
+
const data = response.data || {};
|
|
7433
|
+
activeFileViewer = {
|
|
7434
|
+
path: normalizeFileTreePath(data.path || normalized),
|
|
7435
|
+
name: data.name || fileDisplayName(normalized),
|
|
7436
|
+
content: String(data.content || ""),
|
|
7437
|
+
size: Number(data.size) || 0,
|
|
7438
|
+
mtimeMs: Number(data.mtimeMs) || 0,
|
|
7439
|
+
extension: data.extension || "",
|
|
7440
|
+
language: data.language || "text",
|
|
7441
|
+
mode: data.language === "markdown" ? "preview" : "source",
|
|
7442
|
+
dirty: false,
|
|
7443
|
+
readOnly: true,
|
|
7444
|
+
};
|
|
7445
|
+
if (elements.fileViewerEditor) elements.fileViewerEditor.value = activeFileViewer.content;
|
|
7446
|
+
clearFileViewerSelection();
|
|
7447
|
+
updateFileViewerUi();
|
|
7448
|
+
setFileViewerStatus("Report opened in WebUI (read-only).", "success");
|
|
7449
|
+
} catch (error) {
|
|
7450
|
+
if (isCurrentTabContext(tabContext)) {
|
|
7451
|
+
setFileViewerStatus(error.message || String(error), "error");
|
|
7452
|
+
addEvent(`review report open failed: ${error.message || String(error)}`, "error");
|
|
7453
|
+
}
|
|
7454
|
+
}
|
|
7455
|
+
}
|
|
7456
|
+
|
|
7294
7457
|
async function saveActiveFileViewer() {
|
|
7295
7458
|
if (!activeFileViewer || !elements.fileViewerEditor) return;
|
|
7459
|
+
if (activeFileViewer.readOnly) {
|
|
7460
|
+
setFileViewerStatus("This report is read-only.", "info");
|
|
7461
|
+
return;
|
|
7462
|
+
}
|
|
7296
7463
|
const tabContext = activeTabContext();
|
|
7297
7464
|
const content = elements.fileViewerEditor.value || "";
|
|
7298
7465
|
if (elements.fileViewerSaveButton) elements.fileViewerSaveButton.disabled = true;
|
|
@@ -7395,6 +7562,7 @@ function syncTabMetadata(nextTabs = []) {
|
|
|
7395
7562
|
remoteMicConsentTabs.delete(tabId);
|
|
7396
7563
|
if (voiceConversationTabId === tabId) stopVoiceConversationLoop();
|
|
7397
7564
|
clearGitWorkflowForTab(tabId);
|
|
7565
|
+
commandCatalogsByTab.delete(tabId);
|
|
7398
7566
|
}
|
|
7399
7567
|
}
|
|
7400
7568
|
for (const tabId of tabMessagesCache.keys()) {
|
|
@@ -7629,6 +7797,11 @@ function requestedTabIdFromUrl() {
|
|
|
7629
7797
|
}
|
|
7630
7798
|
|
|
7631
7799
|
function updateDocumentTitle() {
|
|
7800
|
+
const subagentView = activeSubagentTerminalView();
|
|
7801
|
+
if (subagentView) {
|
|
7802
|
+
document.title = `Pi Web UI · ${subagentTerminalViewTitle(subagentView)} · Subagent`;
|
|
7803
|
+
return;
|
|
7804
|
+
}
|
|
7632
7805
|
const tab = activeTab();
|
|
7633
7806
|
document.title = tab ? `Pi Web UI · ${tab.title}` : "Pi Web UI";
|
|
7634
7807
|
}
|
|
@@ -7647,7 +7820,7 @@ function restoreActiveDraft() {
|
|
|
7647
7820
|
|
|
7648
7821
|
function focusPromptInput({ defer = false } = {}) {
|
|
7649
7822
|
const focus = () => {
|
|
7650
|
-
if (!elements.promptInput || elements.dialog.open || elements.pathPickerDialog.open || elements.gitChangesDialog?.open || elements.commandPaletteDialog?.open || elements.editRetryDialog?.open || elements.nativeCommandDialog.open || elements.remoteQrDialog?.open || elements.appRunnerInfoDialog?.open || elements.gitFooterVisibilityDialog?.open || elements.statsOverlayDialog?.open || elements.promptListDialog?.open || elements.attachmentTextDialog?.open || elements.skillEditorDialog?.open || document.visibilityState === "hidden") return;
|
|
7823
|
+
if (activeSubagentTerminalId || !elements.promptInput || elements.dialog.open || elements.pathPickerDialog.open || elements.gitChangesDialog?.open || elements.commandPaletteDialog?.open || elements.editRetryDialog?.open || elements.nativeCommandDialog.open || elements.remoteQrDialog?.open || elements.appRunnerInfoDialog?.open || elements.gitFooterVisibilityDialog?.open || elements.statsOverlayDialog?.open || elements.promptListDialog?.open || elements.attachmentTextDialog?.open || elements.skillEditorDialog?.open || document.visibilityState === "hidden") return;
|
|
7651
7824
|
try {
|
|
7652
7825
|
elements.promptInput.focus({ preventScroll: true });
|
|
7653
7826
|
} catch {
|
|
@@ -7799,8 +7972,9 @@ function resetActiveTabUi() {
|
|
|
7799
7972
|
transientMessages = [];
|
|
7800
7973
|
liveToolRuns.clear();
|
|
7801
7974
|
liveToolCards.clear();
|
|
7802
|
-
|
|
7803
|
-
|
|
7975
|
+
const commandCatalog = commandCatalogsByTab.get(activeTabId);
|
|
7976
|
+
availableCommands = commandCatalog?.available || [];
|
|
7977
|
+
rawAvailableCommands = commandCatalog?.raw || [];
|
|
7804
7978
|
resetOptionalFeatureAvailability();
|
|
7805
7979
|
commandSuggestions = [];
|
|
7806
7980
|
pathSuggestions = [];
|
|
@@ -7974,11 +8148,12 @@ function terminalTabMeta(tab, indicator) {
|
|
|
7974
8148
|
return parts.join(" · ");
|
|
7975
8149
|
}
|
|
7976
8150
|
|
|
7977
|
-
function appendTerminalTabContent(button, { title, indicator, meta, count = null, appRunnerRun = null, conversationModeActive = false, workflowModeActive = false, workflowCount = 0 }) {
|
|
8151
|
+
function appendTerminalTabContent(button, { title, indicator, meta, count = null, appRunnerRun = null, conversationModeActive = false, workflowModeActive = false, workflowCount = 0, subagent = false }) {
|
|
7978
8152
|
const titleRow = make("span", "terminal-tab-title-row");
|
|
7979
8153
|
const indicatorDot = make("span", "terminal-tab-activity-indicator");
|
|
7980
8154
|
indicatorDot.setAttribute("aria-hidden", "true");
|
|
7981
8155
|
titleRow.append(indicatorDot, make("span", "terminal-tab-title", title));
|
|
8156
|
+
if (subagent) titleRow.append(make("span", "terminal-tab-subagent-indicator", "subagent"));
|
|
7982
8157
|
if (appRunnerIsRunning(appRunnerRun)) titleRow.append(make("span", "terminal-tab-app-runner-indicator", "app"));
|
|
7983
8158
|
if (conversationModeActive) titleRow.append(make("span", "terminal-tab-conversation-indicator", "voice"));
|
|
7984
8159
|
if (workflowModeActive || workflowCount) titleRow.append(make("span", "terminal-tab-workflow-indicator", workflowCount ? `wf ${workflowCount}` : "wf"));
|
|
@@ -7987,7 +8162,7 @@ function appendTerminalTabContent(button, { title, indicator, meta, count = null
|
|
|
7987
8162
|
}
|
|
7988
8163
|
|
|
7989
8164
|
function renderTerminalTab(tab) {
|
|
7990
|
-
const isActive = tab.id === activeTabId;
|
|
8165
|
+
const isActive = tab.id === activeTabId && !activeSubagentTerminalId;
|
|
7991
8166
|
const indicator = tabIndicator(tab);
|
|
7992
8167
|
const appRunnerRun = tabAppRunnerRunningRun(tab);
|
|
7993
8168
|
const appRunnerLabel = appRunnerRun ? terminalAppRunnerLabel(appRunnerRun) : "";
|
|
@@ -8027,7 +8202,7 @@ function renderTerminalTab(tab) {
|
|
|
8027
8202
|
}
|
|
8028
8203
|
|
|
8029
8204
|
function renderTerminalTabGroupItem(tab, group) {
|
|
8030
|
-
const isActive = tab.id === activeTabId;
|
|
8205
|
+
const isActive = tab.id === activeTabId && !activeSubagentTerminalId;
|
|
8031
8206
|
const indicator = tabIndicator(tab);
|
|
8032
8207
|
const appRunnerRun = tabAppRunnerRunningRun(tab);
|
|
8033
8208
|
const appRunnerLabel = appRunnerRun ? terminalAppRunnerLabel(appRunnerRun) : "";
|
|
@@ -8077,7 +8252,7 @@ function shouldRenderTerminalTabGroup(group, groupCount) {
|
|
|
8077
8252
|
function renderTerminalTabGroup(group, groupCount = 1) {
|
|
8078
8253
|
const groupTabs = group.tabs;
|
|
8079
8254
|
const activeGroupTab = groupTabs.find((tab) => tab.id === activeTabId) || groupTabs[0];
|
|
8080
|
-
const isActive = groupTabs.some((tab) => tab.id === activeTabId);
|
|
8255
|
+
const isActive = !activeSubagentTerminalId && groupTabs.some((tab) => tab.id === activeTabId);
|
|
8081
8256
|
const isStopped = groupTabs.every((tab) => !tab.running);
|
|
8082
8257
|
const indicator = tabGroupIndicator(groupTabs);
|
|
8083
8258
|
const appRunnerRun = tabGroupAppRunnerRunningRun(groupTabs);
|
|
@@ -8220,15 +8395,18 @@ function scheduleTabsRender() {
|
|
|
8220
8395
|
|
|
8221
8396
|
function renderTabs() {
|
|
8222
8397
|
if (deferUiRenderDuringPointerActivation("tabs", renderTabs)) return;
|
|
8223
|
-
const
|
|
8224
|
-
const
|
|
8225
|
-
|
|
8226
|
-
const
|
|
8398
|
+
const activeSubagent = activeSubagentTerminalView();
|
|
8399
|
+
const active = activeSubagent || activeTab();
|
|
8400
|
+
const activeIndicator = activeSubagent ? { glyph: "◉", label: "Subagent view" } : active ? tabIndicator(active) : null;
|
|
8401
|
+
const activeTitle = activeSubagent ? subagentTerminalViewTitle(activeSubagent) : active?.title;
|
|
8402
|
+
const totalTabCount = tabs.length + subagentTerminalViews.size;
|
|
8403
|
+
elements.terminalTabsToggleButton.textContent = active ? `${activeIndicator.glyph} ${activeTitle}${totalTabCount > 1 ? ` · ${totalTabCount}` : ""}` : "Tabs";
|
|
8404
|
+
const toggleTooltip = active ? `Show terminal tabs · active: ${activeTitle} · ${activeIndicator.label}` : "Show terminal tabs";
|
|
8227
8405
|
applyStyledTooltip(elements.terminalTabsToggleButton, toggleTooltip, { ariaLabel: toggleTooltip });
|
|
8228
8406
|
if (footerTooltipTarget && elements.tabBar.contains(footerTooltipTarget)) hideFooterTooltip();
|
|
8229
8407
|
elements.tabBar.replaceChildren();
|
|
8230
|
-
elements.tabBar.dataset.tabCount = String(
|
|
8231
|
-
elements.tabBar.classList.toggle("terminal-tabs-dense",
|
|
8408
|
+
elements.tabBar.dataset.tabCount = String(totalTabCount);
|
|
8409
|
+
elements.tabBar.classList.toggle("terminal-tabs-dense", totalTabCount >= 10);
|
|
8232
8410
|
const groups = tabCwdGroups();
|
|
8233
8411
|
const renderedGroupKeys = new Set(groups.filter((group) => shouldRenderTerminalTabGroup(group, groups.length)).map((group) => group.key));
|
|
8234
8412
|
if (openTerminalTabGroupKey && !renderedGroupKeys.has(openTerminalTabGroupKey)) openTerminalTabGroupKey = null;
|
|
@@ -8239,6 +8417,9 @@ function renderTabs() {
|
|
|
8239
8417
|
for (const tab of group.tabs) elements.tabBar.append(renderTerminalTab(tab));
|
|
8240
8418
|
}
|
|
8241
8419
|
}
|
|
8420
|
+
for (const view of [...subagentTerminalViews.values()].sort((a, b) => a.openedAt - b.openedAt)) {
|
|
8421
|
+
elements.tabBar.append(renderSubagentTerminalTab(view));
|
|
8422
|
+
}
|
|
8242
8423
|
elements.tabBar.append(elements.newTabMenu);
|
|
8243
8424
|
elements.closeAllTabsButton.disabled = tabs.length === 0;
|
|
8244
8425
|
updateTerminalTabGroupOpenState();
|
|
@@ -8256,6 +8437,10 @@ async function refreshTabs({ selectStored = false } = {}) {
|
|
|
8256
8437
|
const response = await api("/api/tabs", { scoped: false });
|
|
8257
8438
|
tabs = response.data?.tabs || [];
|
|
8258
8439
|
syncTabMetadata(tabs);
|
|
8440
|
+
const liveParentTabIds = new Set(tabs.map((tab) => tab.id));
|
|
8441
|
+
for (const view of [...subagentTerminalViews.values()]) {
|
|
8442
|
+
if (!liveParentTabIds.has(view.parentTabId)) removeSubagentTerminalViewsForParent(view.parentTabId);
|
|
8443
|
+
}
|
|
8259
8444
|
syncBlockedTabNotificationsFromTabs(tabs, previousTabs);
|
|
8260
8445
|
syncAgentDoneNotificationsFromTabs(tabs, previousTabs);
|
|
8261
8446
|
const requested = selectStored ? requestedTabIdFromUrl() : null;
|
|
@@ -8270,7 +8455,12 @@ async function refreshTabs({ selectStored = false } = {}) {
|
|
|
8270
8455
|
}
|
|
8271
8456
|
|
|
8272
8457
|
async function switchTab(tabId) {
|
|
8273
|
-
if (!tabId ||
|
|
8458
|
+
if (!tabId || !tabs.some((tab) => tab.id === tabId)) return;
|
|
8459
|
+
if (tabId === activeTabId) {
|
|
8460
|
+
if (activeSubagentTerminalId) deactivateSubagentTerminalView({ focusParent: true });
|
|
8461
|
+
return;
|
|
8462
|
+
}
|
|
8463
|
+
if (activeSubagentTerminalId) deactivateSubagentTerminalView({ render: false });
|
|
8274
8464
|
clearOpenTerminalTabGroup(null, { force: true });
|
|
8275
8465
|
setMobileTabsExpanded(false);
|
|
8276
8466
|
footerModelPickerOpen = false;
|
|
@@ -8496,9 +8686,11 @@ async function closeTerminalTabs(tabIds, { label = "selected terminal tabs" } =
|
|
|
8496
8686
|
tabDrafts.delete(id);
|
|
8497
8687
|
clearAttachments(id);
|
|
8498
8688
|
clearGitWorkflowForTab(id);
|
|
8689
|
+
commandCatalogsByTab.delete(id);
|
|
8499
8690
|
appRunnerDataByTab.delete(id);
|
|
8500
8691
|
tabMessagesCache.delete(id);
|
|
8501
8692
|
btwWidgetDismissedIdsByTab.delete(id);
|
|
8693
|
+
removeSubagentTerminalViewsForParent(id);
|
|
8502
8694
|
}
|
|
8503
8695
|
syncTerminalCustomGroupsWithTabs(tabs);
|
|
8504
8696
|
clearOpenTerminalTabGroup(null, { force: true });
|
|
@@ -12769,8 +12961,8 @@ function footerBranchCreateWorktreePathPreview(branch = footerBranchCreateName()
|
|
|
12769
12961
|
return `${root.replace(/\/+$/, "")}/${slugifyWorktreePathPart(branch || footerBranchCreatePreviewName())}`;
|
|
12770
12962
|
}
|
|
12771
12963
|
|
|
12772
|
-
function gitWorktreeCreateCommandDisplay(branch, state = footerBranchPickerState) {
|
|
12773
|
-
return `git worktree add -b ${quoteGitBranchForDisplay(branch)} ${quoteGitBranchForDisplay(footerBranchCreateWorktreePathPreview(branch, state))}`;
|
|
12964
|
+
function gitWorktreeCreateCommandDisplay(branch, state = footerBranchPickerState, baseRef = "origin/main") {
|
|
12965
|
+
return `git worktree add -b ${quoteGitBranchForDisplay(branch)} ${quoteGitBranchForDisplay(footerBranchCreateWorktreePathPreview(branch, state))} ${quoteGitBranchForDisplay(baseRef)}`;
|
|
12774
12966
|
}
|
|
12775
12967
|
|
|
12776
12968
|
function gitWorktreeOpenCommandDisplay(path) {
|
|
@@ -12786,7 +12978,7 @@ function footerBranchCreateTooltip(branchName = footerBranchCreateName(), state
|
|
|
12786
12978
|
`This will run roughly: ${command}`,
|
|
12787
12979
|
"",
|
|
12788
12980
|
"What happens:",
|
|
12789
|
-
"•
|
|
12981
|
+
"• asks whether to base the new branch on origin/main (default) or this workspace's current HEAD",
|
|
12790
12982
|
"• opens a separate Pi tab rooted at that worktree",
|
|
12791
12983
|
"• does not switch this tab's branch, commit, push, or delete anything",
|
|
12792
12984
|
"",
|
|
@@ -12828,18 +13020,20 @@ async function openWorktreeResponseTab(response, { branchName = "", action = "op
|
|
|
12828
13020
|
requestGitFooterWebuiPayload(activeTabContext(), { force: true });
|
|
12829
13021
|
}
|
|
12830
13022
|
|
|
12831
|
-
async function createFooterGitBranchWorktree(branch = footerBranchCreateName(), { tabContext = activeTabContext(), skipConfirm = false } = {}) {
|
|
13023
|
+
async function createFooterGitBranchWorktree(branch = footerBranchCreateName(), { tabContext = activeTabContext(), skipConfirm = false, chooseBase = true } = {}) {
|
|
12832
13024
|
const branchName = cleanStatusText(branch);
|
|
12833
13025
|
if (!branchName) {
|
|
12834
13026
|
addEvent("Enter a branch name before creating a branch worktree.", "warn");
|
|
12835
13027
|
return;
|
|
12836
13028
|
}
|
|
12837
13029
|
if (!skipConfirm && !(await confirmFooterGitWorktreeAction(branchName, { create: true, requireConfirm: true }))) return;
|
|
13030
|
+
const baseRef = chooseBase ? await chooseGitWorktreeBase(branchName) : "HEAD";
|
|
13031
|
+
if (baseRef === null) return;
|
|
12838
13032
|
const tabId = tabContext.tabId || activeTabId;
|
|
12839
13033
|
try {
|
|
12840
13034
|
footerBranchPickerState = { ...footerBranchPickerState, loading: true, error: "", switching: branchName, tabId };
|
|
12841
13035
|
renderFooter();
|
|
12842
|
-
const response = await api("/api/git-worktrees", { method: "POST", body: { branchName, sessionMode: "fork-current", openTab: true }, tabId });
|
|
13036
|
+
const response = await api("/api/git-worktrees", { method: "POST", body: { branchName, baseRef, sessionMode: "fork-current", openTab: true }, tabId });
|
|
12843
13037
|
await openWorktreeResponseTab(response, { branchName, action: "create" });
|
|
12844
13038
|
} catch (error) {
|
|
12845
13039
|
if (isCurrentTabContext(tabContext)) {
|
|
@@ -13038,7 +13232,7 @@ function footerBranchOptionDetail(branch, state, { selected, worktreePath } = {}
|
|
|
13038
13232
|
function openFooterBranchOption(branch, state = footerBranchPickerState) {
|
|
13039
13233
|
const worktreePath = footerBranchWorktreePath(branch, state);
|
|
13040
13234
|
if (worktreePath && !branch.worktreeCurrent) return openFooterGitWorktree(worktreePath, { branchName: branch.name, skipConfirm: true });
|
|
13041
|
-
return createFooterGitBranchWorktree(branch.name, { skipConfirm: true });
|
|
13235
|
+
return createFooterGitBranchWorktree(branch.name, { skipConfirm: true, chooseBase: false });
|
|
13042
13236
|
}
|
|
13043
13237
|
|
|
13044
13238
|
function renderFooterBranchOption(branch, state = footerBranchPickerState) {
|
|
@@ -13193,7 +13387,7 @@ function renderFooterBranchPicker() {
|
|
|
13193
13387
|
const hasOtherBranches = state.branches.some((branch) => !branch.current && branch.name !== state.current);
|
|
13194
13388
|
if (!state.loading && !hasOtherBranches) {
|
|
13195
13389
|
const empty = make("div", "footer-model-picker-empty muted");
|
|
13196
|
-
empty.append(make("strong", undefined, "No other local branches available."), make("span", undefined, " Create a branch worktree from the current HEAD to continue."));
|
|
13390
|
+
empty.append(make("strong", undefined, "No other local branches available."), make("span", undefined, " Create a branch worktree from origin/main or the current workspace HEAD to continue."));
|
|
13197
13391
|
picker.append(empty);
|
|
13198
13392
|
}
|
|
13199
13393
|
|
|
@@ -14253,8 +14447,62 @@ function subagentRunElapsed(run) {
|
|
|
14253
14447
|
return Number.isFinite(startedAt) ? formatDuration(Math.max(0, Date.now() - startedAt)) : "";
|
|
14254
14448
|
}
|
|
14255
14449
|
|
|
14450
|
+
function subagentOverlayTranscriptMessages(data = subagentOverlayData) {
|
|
14451
|
+
const agent = data?.agent || subagentOverlaySelection?.agent || {};
|
|
14452
|
+
return (Array.isArray(agent.transcript) ? agent.transcript : [])
|
|
14453
|
+
.filter((message) => message && (message.role === "assistant" || message.role === "toolResult"));
|
|
14454
|
+
}
|
|
14455
|
+
|
|
14456
|
+
function subagentOverlayToolArguments(value) {
|
|
14457
|
+
if (typeof value !== "string") return value;
|
|
14458
|
+
try {
|
|
14459
|
+
const parsed = JSON.parse(value);
|
|
14460
|
+
return parsed && typeof parsed === "object" ? parsed : value;
|
|
14461
|
+
} catch {
|
|
14462
|
+
return value;
|
|
14463
|
+
}
|
|
14464
|
+
}
|
|
14465
|
+
|
|
14466
|
+
function subagentOverlayTranscriptDisplayMessages(messages, { includeThinking = thinkingOutputVisible } = {}) {
|
|
14467
|
+
const toolResults = buildToolResultMap(messages);
|
|
14468
|
+
const pairedToolCallIds = buildAssistantToolCallIdSet(messages);
|
|
14469
|
+
const displayMessages = [];
|
|
14470
|
+
for (const message of messages) {
|
|
14471
|
+
if (message.role === "toolResult") {
|
|
14472
|
+
if (pairedToolCallIds.has(toolResultCallId(message))) continue;
|
|
14473
|
+
displayMessages.push(message);
|
|
14474
|
+
continue;
|
|
14475
|
+
}
|
|
14476
|
+
for (const displayMessage of assistantDisplayMessages(message)) {
|
|
14477
|
+
if (displayMessage.role === "thinking" && !includeThinking) continue;
|
|
14478
|
+
if (displayMessage.role === "toolCall" && displayMessage.toolCallId) {
|
|
14479
|
+
const result = toolResults.get(displayMessage.toolCallId) || null;
|
|
14480
|
+
displayMessages.push({
|
|
14481
|
+
...displayMessage,
|
|
14482
|
+
role: "toolExecution",
|
|
14483
|
+
title: `tool: ${displayMessage.toolName || "unknown"}`,
|
|
14484
|
+
arguments: subagentOverlayToolArguments(displayMessage.arguments),
|
|
14485
|
+
result,
|
|
14486
|
+
isError: !!result?.isError,
|
|
14487
|
+
});
|
|
14488
|
+
} else {
|
|
14489
|
+
displayMessages.push(displayMessage);
|
|
14490
|
+
}
|
|
14491
|
+
}
|
|
14492
|
+
}
|
|
14493
|
+
return displayMessages;
|
|
14494
|
+
}
|
|
14495
|
+
|
|
14496
|
+
function subagentOverlayTranscriptOutputLines(data = subagentOverlayData) {
|
|
14497
|
+
return subagentOverlayTranscriptDisplayMessages(subagentOverlayTranscriptMessages(data)).flatMap((message) => stripAnsi(
|
|
14498
|
+
messageCopyText(message),
|
|
14499
|
+
).replace(/\r/g, "").split("\n"));
|
|
14500
|
+
}
|
|
14501
|
+
|
|
14256
14502
|
function subagentOverlayOutputLines(data = subagentOverlayData) {
|
|
14257
14503
|
const agent = data?.agent || subagentOverlaySelection?.agent || {};
|
|
14504
|
+
const transcriptMessages = subagentOverlayTranscriptMessages(data);
|
|
14505
|
+
if (transcriptMessages.length) return subagentOverlayTranscriptOutputLines(data);
|
|
14258
14506
|
const output = (Array.isArray(agent.recentOutput) ? agent.recentOutput : [])
|
|
14259
14507
|
.flatMap((line) => stripAnsi(String(line ?? "")).replace(/\r/g, "").split("\n"));
|
|
14260
14508
|
if (output.length) return output;
|
|
@@ -14268,20 +14516,61 @@ function subagentOverlayOutputText(data = subagentOverlayData) {
|
|
|
14268
14516
|
return subagentOverlayOutputLines(data).join("\n").trimEnd();
|
|
14269
14517
|
}
|
|
14270
14518
|
|
|
14271
|
-
function
|
|
14272
|
-
const
|
|
14519
|
+
function subagentOverlayEmptyTranscriptText(messages) {
|
|
14520
|
+
const hasThinking = messages.some((message) => message.role === "assistant" && assistantDisplayMessages(message)
|
|
14521
|
+
.some((displayMessage) => displayMessage.role === "thinking"));
|
|
14522
|
+
return hasThinking && !thinkingOutputVisible
|
|
14523
|
+
? "Thinking output is hidden. Enable thinking output to view the captured transcript."
|
|
14524
|
+
: "No visible output was captured.";
|
|
14525
|
+
}
|
|
14526
|
+
|
|
14527
|
+
function subagentRunIndicatorActivity(agent = {}) {
|
|
14528
|
+
const currentTool = cleanStatusText(agent.currentTool || "");
|
|
14529
|
+
const currentToolArgs = cleanStatusText(agent.currentToolArgs || "");
|
|
14530
|
+
const activityState = cleanStatusText(agent.activityState || "");
|
|
14531
|
+
return currentTool
|
|
14532
|
+
? `${currentTool}${currentToolArgs ? ` · ${currentToolArgs}` : ""}`
|
|
14533
|
+
: activityState || "Waiting for output or action…";
|
|
14534
|
+
}
|
|
14535
|
+
|
|
14536
|
+
function updateSubagentRunIndicatorElapsed(parent, run) {
|
|
14537
|
+
const elapsedNode = parent?.querySelector?.(".subagent-run-indicator-elapsed");
|
|
14538
|
+
if (!elapsedNode) return false;
|
|
14539
|
+
const elapsed = subagentRunElapsed(run);
|
|
14540
|
+
const text = elapsed ? `· run time ${elapsed}` : "";
|
|
14541
|
+
if (elapsedNode.textContent !== text) elapsedNode.textContent = text;
|
|
14542
|
+
return true;
|
|
14543
|
+
}
|
|
14544
|
+
|
|
14545
|
+
function appendSubagentRunIndicator(parent, { agent = {}, run } = {}) {
|
|
14546
|
+
const bubble = make("article", "message runIndicator run-indicator-message streaming subagent-run-indicator");
|
|
14273
14547
|
bubble.setAttribute("role", "status");
|
|
14274
|
-
bubble.setAttribute("aria-
|
|
14548
|
+
bubble.setAttribute("aria-live", "polite");
|
|
14549
|
+
bubble.setAttribute("aria-label", "Agent is running:");
|
|
14275
14550
|
const body = make("div", "message-body");
|
|
14276
14551
|
const row = make("div", "run-indicator-row");
|
|
14277
|
-
|
|
14278
|
-
|
|
14279
|
-
|
|
14280
|
-
|
|
14281
|
-
);
|
|
14552
|
+
const pulse = make("span", "run-indicator-pulse");
|
|
14553
|
+
pulse.setAttribute("aria-hidden", "true");
|
|
14554
|
+
const headline = make("span", "run-indicator-text", "Agent is running:");
|
|
14555
|
+
const activity = make("span", "run-indicator-meta", subagentRunIndicatorActivity(agent));
|
|
14556
|
+
const elapsed = make("span", "run-indicator-meta subagent-run-indicator-elapsed");
|
|
14557
|
+
elapsed.setAttribute("aria-hidden", "true");
|
|
14558
|
+
row.append(pulse, headline, activity, elapsed);
|
|
14282
14559
|
body.append(row);
|
|
14283
14560
|
bubble.append(body);
|
|
14284
14561
|
parent.append(bubble);
|
|
14562
|
+
updateSubagentRunIndicatorElapsed(parent, run);
|
|
14563
|
+
}
|
|
14564
|
+
|
|
14565
|
+
function appendSubagentOverlayTranscript(parent, messages) {
|
|
14566
|
+
let rendered = 0;
|
|
14567
|
+
for (const displayMessage of subagentOverlayTranscriptDisplayMessages(messages)) {
|
|
14568
|
+
const { bubble } = createMessageBubble(displayMessage, { transient: true });
|
|
14569
|
+
bubble.classList.add("subagent-overlay-message");
|
|
14570
|
+
parent.append(bubble);
|
|
14571
|
+
rendered += 1;
|
|
14572
|
+
}
|
|
14573
|
+
return rendered;
|
|
14285
14574
|
}
|
|
14286
14575
|
|
|
14287
14576
|
function subagentOverlayStateFacts(data = subagentOverlayData) {
|
|
@@ -14311,6 +14600,33 @@ function subagentOverlayMeaningfulSignature() {
|
|
|
14311
14600
|
});
|
|
14312
14601
|
}
|
|
14313
14602
|
|
|
14603
|
+
function renderSubagentOverlayErrorWidget() {
|
|
14604
|
+
const widget = make("section", "widget release-npm-widget app-runner-widget subagent-overlay-widget app-runner-log-widget");
|
|
14605
|
+
widget.setAttribute("aria-label", "Subagent output rendering error");
|
|
14606
|
+
const header = make("div", "release-npm-header");
|
|
14607
|
+
const titleWrap = make("div", "release-npm-title-wrap");
|
|
14608
|
+
titleWrap.append(make("strong", "release-npm-title", "Subagent output unavailable"));
|
|
14609
|
+
header.append(titleWrap);
|
|
14610
|
+
const body = make("div", "message-body");
|
|
14611
|
+
appendText(body, "The live subagent output could not be rendered. Close this panel and reopen it to retry.");
|
|
14612
|
+
const controls = make("div", "release-npm-controls subagent-overlay-output-controls");
|
|
14613
|
+
const actions = make("div", "app-runner-output-actions");
|
|
14614
|
+
actions.append(appRunnerActionButton("Close", closeSubagentOverlay, "subagent-overlay-close-action"));
|
|
14615
|
+
controls.append(actions);
|
|
14616
|
+
widget.append(header, body, controls);
|
|
14617
|
+
return widget;
|
|
14618
|
+
}
|
|
14619
|
+
|
|
14620
|
+
function renderSubagentOverlayWidgetSafely() {
|
|
14621
|
+
try {
|
|
14622
|
+
return renderSubagentOverlayWidget();
|
|
14623
|
+
} catch {
|
|
14624
|
+
// Keep a faulty child transcript from preventing all other widgets from
|
|
14625
|
+
// rendering. The recoverable panel below replaces repeated event logging.
|
|
14626
|
+
return renderSubagentOverlayErrorWidget();
|
|
14627
|
+
}
|
|
14628
|
+
}
|
|
14629
|
+
|
|
14314
14630
|
function renderSubagentOverlayWidget() {
|
|
14315
14631
|
const selection = subagentOverlaySelection;
|
|
14316
14632
|
if (!selection || selection.tabId !== activeTabId) return null;
|
|
@@ -14318,9 +14634,11 @@ function renderSubagentOverlayWidget() {
|
|
|
14318
14634
|
const agent = data?.agent || selection.agent || {};
|
|
14319
14635
|
const tab = tabs.find((item) => item.id === selection.tabId) || selection.tab;
|
|
14320
14636
|
const running = !selection.finished && (agent.status === "running" || agent.status === "queued" || agent.status === "pending" || !agent.status);
|
|
14637
|
+
const transcriptMessages = subagentOverlayTranscriptMessages(data);
|
|
14638
|
+
const hasStructuredTranscript = transcriptMessages.length > 0;
|
|
14321
14639
|
const outputText = subagentOverlayOutputText(data);
|
|
14322
|
-
const
|
|
14323
|
-
const shownLineCount =
|
|
14640
|
+
const fallbackText = outputText || (running && agent.currentTool ? "" : running ? "Waiting for the first agent activity…" : "No recent output was captured.");
|
|
14641
|
+
const shownLineCount = outputText ? outputText.split("\n").length : fallbackText ? fallbackText.split("\n").length : 0;
|
|
14324
14642
|
const widget = make("section", `widget release-npm-widget app-runner-widget subagent-overlay-widget${running ? " app-runner-live-widget" : " app-runner-log-widget"}`);
|
|
14325
14643
|
widget.setAttribute("aria-label", `Live output for subagent ${agent.name || "subagent"}`);
|
|
14326
14644
|
|
|
@@ -14335,17 +14653,22 @@ function renderSubagentOverlayWidget() {
|
|
|
14335
14653
|
const output = make("div", "subagent-overlay-transcript");
|
|
14336
14654
|
output.setAttribute("role", "log");
|
|
14337
14655
|
output.setAttribute("aria-live", running ? "polite" : "off");
|
|
14338
|
-
|
|
14656
|
+
const renderedTranscriptMessages = appendSubagentOverlayTranscript(output, transcriptMessages);
|
|
14657
|
+
const emptyTranscriptFallback = hasStructuredTranscript && renderedTranscriptMessages === 0
|
|
14658
|
+
? subagentOverlayEmptyTranscriptText(transcriptMessages)
|
|
14659
|
+
: "";
|
|
14660
|
+
const visibleFallbackText = !hasStructuredTranscript ? fallbackText : emptyTranscriptFallback;
|
|
14661
|
+
if (visibleFallbackText) {
|
|
14339
14662
|
const { bubble } = createMessageBubble({
|
|
14340
14663
|
role: "assistant",
|
|
14341
14664
|
title: "final output",
|
|
14342
14665
|
timestamp: data?.updatedAt || Date.now(),
|
|
14343
|
-
content:
|
|
14344
|
-
}, { streaming: running, transient: true });
|
|
14345
|
-
bubble.classList.add("subagent-overlay-message");
|
|
14666
|
+
content: visibleFallbackText,
|
|
14667
|
+
}, { streaming: running && !hasStructuredTranscript, transient: true });
|
|
14668
|
+
bubble.classList.add("subagent-overlay-message", "subagent-overlay-empty-fallback");
|
|
14346
14669
|
output.append(bubble);
|
|
14347
14670
|
}
|
|
14348
|
-
if (running
|
|
14671
|
+
if (running) appendSubagentRunIndicator(output, { agent, run: selection.run });
|
|
14349
14672
|
|
|
14350
14673
|
const controls = make("div", "release-npm-controls subagent-overlay-output-controls");
|
|
14351
14674
|
const actions = make("div", "app-runner-output-actions");
|
|
@@ -14406,6 +14729,7 @@ async function refreshSubagentOverlay() {
|
|
|
14406
14729
|
|
|
14407
14730
|
async function openSubagentOverlay(tab, run, agent) {
|
|
14408
14731
|
if (!tab?.tabId || !run?.id || !agent?.id) return;
|
|
14732
|
+
if (activeSubagentTerminalId) deactivateSubagentTerminalView({ render: false });
|
|
14409
14733
|
try {
|
|
14410
14734
|
if (activeTabId !== tab.tabId) await switchTab(tab.tabId);
|
|
14411
14735
|
subagentOverlaySelection = {
|
|
@@ -14454,6 +14778,275 @@ async function copySubagentOverlayOutput() {
|
|
|
14454
14778
|
}
|
|
14455
14779
|
}
|
|
14456
14780
|
|
|
14781
|
+
function subagentTerminalViewId(tab, run, agent) {
|
|
14782
|
+
return JSON.stringify([tab?.tabId || "", run?.id || "", agent?.id || ""]);
|
|
14783
|
+
}
|
|
14784
|
+
|
|
14785
|
+
function activeSubagentTerminalView() {
|
|
14786
|
+
return activeSubagentTerminalId ? subagentTerminalViews.get(activeSubagentTerminalId) || null : null;
|
|
14787
|
+
}
|
|
14788
|
+
|
|
14789
|
+
function subagentTerminalViewTitle(view) {
|
|
14790
|
+
return String(view?.data?.agent?.name || view?.agent?.name || "subagent").trim() || "subagent";
|
|
14791
|
+
}
|
|
14792
|
+
|
|
14793
|
+
function subagentTerminalViewIsRunning(view) {
|
|
14794
|
+
const status = view?.data?.agent?.status || view?.agent?.status || "running";
|
|
14795
|
+
return view?.finished !== true && ["running", "queued", "pending"].includes(status);
|
|
14796
|
+
}
|
|
14797
|
+
|
|
14798
|
+
function subagentTerminalViewMeaningfulSignature(view) {
|
|
14799
|
+
const data = view?.data ? { ...view.data, updatedAt: undefined } : null;
|
|
14800
|
+
return JSON.stringify({ data, error: view?.error || "", finished: view?.finished === true });
|
|
14801
|
+
}
|
|
14802
|
+
|
|
14803
|
+
function updateSubagentTerminalRefreshState(view, { running = subagentTerminalViewIsRunning(view) } = {}) {
|
|
14804
|
+
if (!view || view.id !== activeSubagentTerminalId) return;
|
|
14805
|
+
const status = [
|
|
14806
|
+
view.loading ? "Refreshing…" : running ? "Live view · refreshes automatically" : "View retained after the child stopped being tracked",
|
|
14807
|
+
view.error,
|
|
14808
|
+
].filter(Boolean).join(" · ");
|
|
14809
|
+
elements.subagentTerminalStatus.setAttribute("aria-live", view.error ? "polite" : "off");
|
|
14810
|
+
elements.subagentTerminalStatus.textContent = status;
|
|
14811
|
+
elements.subagentTerminalStatus.classList.toggle("warning", !!view.error);
|
|
14812
|
+
elements.subagentTerminalRefreshButton.disabled = view.loading || view.finished === true;
|
|
14813
|
+
elements.subagentTerminalRefreshButton.textContent = view.loading ? "Refreshing…" : "Refresh";
|
|
14814
|
+
}
|
|
14815
|
+
|
|
14816
|
+
function renderSubagentTerminalView() {
|
|
14817
|
+
const view = activeSubagentTerminalView();
|
|
14818
|
+
const active = !!view;
|
|
14819
|
+
document.body.classList.toggle("subagent-terminal-active", active);
|
|
14820
|
+
if (!elements.subagentTerminalView) return;
|
|
14821
|
+
elements.subagentTerminalView.hidden = !active;
|
|
14822
|
+
if (!view) return;
|
|
14823
|
+
|
|
14824
|
+
const agent = view.data?.agent || view.agent || {};
|
|
14825
|
+
const running = subagentTerminalViewIsRunning(view);
|
|
14826
|
+
const transcriptMessages = subagentOverlayTranscriptMessages({ agent });
|
|
14827
|
+
const hasStructuredTranscript = transcriptMessages.length > 0;
|
|
14828
|
+
const outputText = subagentOverlayOutputText({ agent });
|
|
14829
|
+
const fallbackText = outputText || (running && agent.currentTool ? "" : running ? "Waiting for the first agent activity…" : "No recent output was captured.");
|
|
14830
|
+
const parent = tabs.find((tab) => tab.id === view.parentTabId);
|
|
14831
|
+
const facts = [
|
|
14832
|
+
view.finished ? "finished" : running ? "running" : agent.status || "finished",
|
|
14833
|
+
view.run?.mode,
|
|
14834
|
+
view.run?.source === "foreground" ? "foreground" : "async",
|
|
14835
|
+
agent.nested ? "nested" : "",
|
|
14836
|
+
agent.currentTool ? `tool ${agent.currentTool}` : "",
|
|
14837
|
+
].filter(Boolean);
|
|
14838
|
+
|
|
14839
|
+
elements.subagentTerminalTitle.textContent = subagentTerminalViewTitle(view);
|
|
14840
|
+
elements.subagentTerminalMeta.textContent = `${facts.join(" · ")} · parent ${parent?.title || view.parentTitle || "terminal"} · run ${view.runId}`;
|
|
14841
|
+
const shouldFollowOutput = elements.subagentTerminalTranscript.scrollHeight - elements.subagentTerminalTranscript.clientHeight - elements.subagentTerminalTranscript.scrollTop < CHAT_BOTTOM_THRESHOLD_PX;
|
|
14842
|
+
elements.subagentTerminalTranscript.replaceChildren();
|
|
14843
|
+
elements.subagentTerminalTranscript.setAttribute("aria-live", running ? "polite" : "off");
|
|
14844
|
+
const rendered = appendSubagentOverlayTranscript(elements.subagentTerminalTranscript, transcriptMessages);
|
|
14845
|
+
const emptyTranscriptFallback = hasStructuredTranscript && rendered === 0 ? subagentOverlayEmptyTranscriptText(transcriptMessages) : "";
|
|
14846
|
+
const visibleFallbackText = !hasStructuredTranscript ? fallbackText : emptyTranscriptFallback;
|
|
14847
|
+
if (visibleFallbackText) {
|
|
14848
|
+
const { bubble } = createMessageBubble({
|
|
14849
|
+
role: "assistant",
|
|
14850
|
+
title: "subagent output",
|
|
14851
|
+
timestamp: view.data?.updatedAt || Date.now(),
|
|
14852
|
+
content: visibleFallbackText,
|
|
14853
|
+
}, { streaming: running && !hasStructuredTranscript, transient: true });
|
|
14854
|
+
bubble.classList.add("subagent-overlay-message", "subagent-overlay-empty-fallback");
|
|
14855
|
+
elements.subagentTerminalTranscript.append(bubble);
|
|
14856
|
+
}
|
|
14857
|
+
if (running) appendSubagentRunIndicator(elements.subagentTerminalTranscript, { agent, run: view.run });
|
|
14858
|
+
|
|
14859
|
+
updateSubagentTerminalRefreshState(view, { running });
|
|
14860
|
+
elements.subagentTerminalCopyButton.disabled = !outputText;
|
|
14861
|
+
if (shouldFollowOutput) requestAnimationFrame(() => { elements.subagentTerminalTranscript.scrollTop = elements.subagentTerminalTranscript.scrollHeight; });
|
|
14862
|
+
}
|
|
14863
|
+
|
|
14864
|
+
function scheduleSubagentTerminalRefresh(delay = SUBAGENT_OVERLAY_REFRESH_MS) {
|
|
14865
|
+
clearTimeout(subagentTerminalRefreshTimer);
|
|
14866
|
+
const view = activeSubagentTerminalView();
|
|
14867
|
+
if (!view || view.finished) return;
|
|
14868
|
+
subagentTerminalRefreshTimer = setTimeout(() => {
|
|
14869
|
+
refreshSubagentTerminalView(view.id).finally(() => scheduleSubagentTerminalRefresh());
|
|
14870
|
+
}, delay);
|
|
14871
|
+
}
|
|
14872
|
+
|
|
14873
|
+
async function refreshSubagentTerminalView(viewId = activeSubagentTerminalId, { showLoading = false } = {}) {
|
|
14874
|
+
const view = viewId ? subagentTerminalViews.get(viewId) : null;
|
|
14875
|
+
if (!view || view.loading || view.finished) return;
|
|
14876
|
+
const requestSerial = (view.requestSerial || 0) + 1;
|
|
14877
|
+
const previousSignature = subagentTerminalViewMeaningfulSignature(view);
|
|
14878
|
+
view.requestSerial = requestSerial;
|
|
14879
|
+
view.loading = true;
|
|
14880
|
+
if (showLoading) updateSubagentTerminalRefreshState(view);
|
|
14881
|
+
try {
|
|
14882
|
+
const query = new URLSearchParams({ tab: view.parentTabId, run: view.runId, agent: view.agentId });
|
|
14883
|
+
const response = await api(`/api/subagents/output?${query}`, { scoped: false });
|
|
14884
|
+
if (view.requestSerial !== requestSerial || !subagentTerminalViews.has(view.id)) return;
|
|
14885
|
+
view.data = response.data || null;
|
|
14886
|
+
view.error = "";
|
|
14887
|
+
} catch (error) {
|
|
14888
|
+
if (view.requestSerial !== requestSerial || !subagentTerminalViews.has(view.id)) return;
|
|
14889
|
+
if (error?.statusCode === 404) view.finished = true;
|
|
14890
|
+
view.error = error?.statusCode === 404
|
|
14891
|
+
? "This subagent has finished or is no longer tracked. Showing the last captured output."
|
|
14892
|
+
: `Subagent output refresh failed: ${error.message || String(error)}`;
|
|
14893
|
+
} finally {
|
|
14894
|
+
if (view.requestSerial === requestSerial && subagentTerminalViews.has(view.id)) {
|
|
14895
|
+
view.loading = false;
|
|
14896
|
+
const meaningfulChange = previousSignature !== subagentTerminalViewMeaningfulSignature(view);
|
|
14897
|
+
if (view.id === activeSubagentTerminalId) {
|
|
14898
|
+
if (meaningfulChange) {
|
|
14899
|
+
renderSubagentTerminalView();
|
|
14900
|
+
renderTabs();
|
|
14901
|
+
} else {
|
|
14902
|
+
if (showLoading) updateSubagentTerminalRefreshState(view);
|
|
14903
|
+
updateSubagentRunIndicatorElapsed(elements.subagentTerminalTranscript, view.run);
|
|
14904
|
+
}
|
|
14905
|
+
}
|
|
14906
|
+
}
|
|
14907
|
+
}
|
|
14908
|
+
}
|
|
14909
|
+
|
|
14910
|
+
function deactivateSubagentTerminalView({ render = true, focusParent = false } = {}) {
|
|
14911
|
+
clearTimeout(subagentTerminalRefreshTimer);
|
|
14912
|
+
subagentTerminalRefreshTimer = null;
|
|
14913
|
+
activeSubagentTerminalId = null;
|
|
14914
|
+
renderSubagentTerminalView();
|
|
14915
|
+
if (render) renderTabs();
|
|
14916
|
+
updateDocumentTitle();
|
|
14917
|
+
if (focusParent) focusPromptInput({ defer: true });
|
|
14918
|
+
}
|
|
14919
|
+
|
|
14920
|
+
async function activateSubagentTerminalView(viewId) {
|
|
14921
|
+
const view = subagentTerminalViews.get(viewId);
|
|
14922
|
+
if (!view) return;
|
|
14923
|
+
if (activeTabId !== view.parentTabId) await switchTab(view.parentTabId);
|
|
14924
|
+
closeSubagentOverlay();
|
|
14925
|
+
activeSubagentTerminalId = view.id;
|
|
14926
|
+
renderSubagentTerminalView();
|
|
14927
|
+
renderTabs();
|
|
14928
|
+
updateDocumentTitle();
|
|
14929
|
+
if (isSidePanelOverlayView()) setSidePanelCollapsed(true, { persist: false });
|
|
14930
|
+
await refreshSubagentTerminalView(view.id);
|
|
14931
|
+
scheduleSubagentTerminalRefresh();
|
|
14932
|
+
}
|
|
14933
|
+
|
|
14934
|
+
async function openSubagentTerminal(tab, run, agent) {
|
|
14935
|
+
if (!tab?.tabId || !run?.id || !agent?.id) return;
|
|
14936
|
+
const id = subagentTerminalViewId(tab, run, agent);
|
|
14937
|
+
const existing = subagentTerminalViews.get(id);
|
|
14938
|
+
if (existing) {
|
|
14939
|
+
existing.tab = tab;
|
|
14940
|
+
existing.run = run;
|
|
14941
|
+
existing.agent = agent;
|
|
14942
|
+
existing.parentTitle = tab.tabTitle;
|
|
14943
|
+
} else {
|
|
14944
|
+
subagentTerminalViews.set(id, {
|
|
14945
|
+
id,
|
|
14946
|
+
parentTabId: tab.tabId,
|
|
14947
|
+
parentTitle: tab.tabTitle,
|
|
14948
|
+
tabIndex: tab.tabIndex,
|
|
14949
|
+
tab,
|
|
14950
|
+
run,
|
|
14951
|
+
agent,
|
|
14952
|
+
runId: run.id,
|
|
14953
|
+
agentId: agent.id,
|
|
14954
|
+
data: null,
|
|
14955
|
+
error: "",
|
|
14956
|
+
loading: false,
|
|
14957
|
+
finished: false,
|
|
14958
|
+
requestSerial: 0,
|
|
14959
|
+
openedAt: Date.now(),
|
|
14960
|
+
});
|
|
14961
|
+
}
|
|
14962
|
+
try {
|
|
14963
|
+
await activateSubagentTerminalView(id);
|
|
14964
|
+
} catch (error) {
|
|
14965
|
+
addEvent(`could not open subagent terminal: ${error.message || String(error)}`, "error");
|
|
14966
|
+
}
|
|
14967
|
+
}
|
|
14968
|
+
|
|
14969
|
+
function closeSubagentTerminalTab(viewId) {
|
|
14970
|
+
const view = subagentTerminalViews.get(viewId);
|
|
14971
|
+
if (!view) return;
|
|
14972
|
+
view.requestSerial += 1;
|
|
14973
|
+
subagentTerminalViews.delete(viewId);
|
|
14974
|
+
if (activeSubagentTerminalId === viewId) deactivateSubagentTerminalView({ render: false, focusParent: true });
|
|
14975
|
+
renderTabs();
|
|
14976
|
+
addEvent(`closed subagent view for ${subagentTerminalViewTitle(view)}; the child run was not stopped`, "info");
|
|
14977
|
+
}
|
|
14978
|
+
|
|
14979
|
+
async function copySubagentTerminalOutput() {
|
|
14980
|
+
const view = activeSubagentTerminalView();
|
|
14981
|
+
const text = view ? subagentOverlayOutputText(view.data || { agent: view.agent }) : "";
|
|
14982
|
+
if (!text) {
|
|
14983
|
+
addEvent("subagent output is empty", "warn");
|
|
14984
|
+
return;
|
|
14985
|
+
}
|
|
14986
|
+
try {
|
|
14987
|
+
await copyText(text);
|
|
14988
|
+
addEvent("copied subagent output", "info");
|
|
14989
|
+
} catch (error) {
|
|
14990
|
+
addEvent(`subagent output copy failed: ${error.message || String(error)}`, "warn");
|
|
14991
|
+
}
|
|
14992
|
+
}
|
|
14993
|
+
|
|
14994
|
+
function removeSubagentTerminalViewsForParent(parentTabId) {
|
|
14995
|
+
for (const [viewId, view] of subagentTerminalViews) {
|
|
14996
|
+
if (view.parentTabId !== parentTabId) continue;
|
|
14997
|
+
view.requestSerial += 1;
|
|
14998
|
+
subagentTerminalViews.delete(viewId);
|
|
14999
|
+
if (activeSubagentTerminalId === viewId) deactivateSubagentTerminalView({ render: false });
|
|
15000
|
+
}
|
|
15001
|
+
}
|
|
15002
|
+
|
|
15003
|
+
function syncSubagentTerminalViewsFromOverview() {
|
|
15004
|
+
for (const view of subagentTerminalViews.values()) {
|
|
15005
|
+
const tab = (Array.isArray(latestSubagents?.tabs) ? latestSubagents.tabs : []).find((candidate) => candidate.tabId === view.parentTabId);
|
|
15006
|
+
const run = (Array.isArray(tab?.runs) ? tab.runs : []).find((candidate) => candidate.id === view.runId);
|
|
15007
|
+
const agent = (Array.isArray(run?.agents) ? run.agents : []).find((candidate) => candidate.id === view.agentId);
|
|
15008
|
+
if (tab) {
|
|
15009
|
+
view.tab = tab;
|
|
15010
|
+
view.parentTitle = tab.tabTitle;
|
|
15011
|
+
}
|
|
15012
|
+
if (run) view.run = run;
|
|
15013
|
+
if (agent) view.agent = agent;
|
|
15014
|
+
}
|
|
15015
|
+
}
|
|
15016
|
+
|
|
15017
|
+
function renderSubagentTerminalTab(view) {
|
|
15018
|
+
const active = view.id === activeSubagentTerminalId;
|
|
15019
|
+
const running = subagentTerminalViewIsRunning(view);
|
|
15020
|
+
const stateClass = running ? "activity-working" : view.error && !view.data ? "stopped" : "activity-done";
|
|
15021
|
+
const wrapper = make("div", `terminal-tab terminal-tab-subagent ${stateClass}${active ? " active" : ""}`);
|
|
15022
|
+
wrapper.dataset.subagentViewId = view.id;
|
|
15023
|
+
const button = make("button", "terminal-tab-button");
|
|
15024
|
+
button.type = "button";
|
|
15025
|
+
button.setAttribute("role", "tab");
|
|
15026
|
+
button.setAttribute("aria-selected", active ? "true" : "false");
|
|
15027
|
+
button.setAttribute("aria-label", `${subagentTerminalViewTitle(view)} subagent view, parent ${view.parentTitle || "terminal"}`);
|
|
15028
|
+
appendTerminalTabContent(button, {
|
|
15029
|
+
title: subagentTerminalViewTitle(view),
|
|
15030
|
+
indicator: { state: running ? "working" : "done" },
|
|
15031
|
+
meta: `Subagent · ${view.parentTitle || "parent terminal"}`,
|
|
15032
|
+
subagent: true,
|
|
15033
|
+
});
|
|
15034
|
+
button.addEventListener("click", () => activateSubagentTerminalView(view.id));
|
|
15035
|
+
const close = make("button", "terminal-tab-close", "×");
|
|
15036
|
+
close.type = "button";
|
|
15037
|
+
applyStyledTooltip(close, `Close ${subagentTerminalViewTitle(view)} view without stopping the subagent`, { ariaLabel: `Close ${subagentTerminalViewTitle(view)} subagent view` });
|
|
15038
|
+
close.addEventListener("click", (event) => {
|
|
15039
|
+
event.stopPropagation();
|
|
15040
|
+
closeSubagentTerminalTab(view.id);
|
|
15041
|
+
});
|
|
15042
|
+
wrapper.append(button, close);
|
|
15043
|
+
return wrapper;
|
|
15044
|
+
}
|
|
15045
|
+
|
|
15046
|
+
function openSubagentOutput(tab, run, agent) {
|
|
15047
|
+
return subagentOpenMode === "tab" ? openSubagentTerminal(tab, run, agent) : openSubagentOverlay(tab, run, agent);
|
|
15048
|
+
}
|
|
15049
|
+
|
|
14457
15050
|
function renderSubagentAgent(tab, run, agent) {
|
|
14458
15051
|
const row = make("button", `subagent-agent-row${agent?.nested ? " nested" : ""}`);
|
|
14459
15052
|
row.type = "button";
|
|
@@ -14471,9 +15064,10 @@ function renderSubagentAgent(tab, run, agent) {
|
|
|
14471
15064
|
].filter(Boolean);
|
|
14472
15065
|
content.append(make("span", "subagent-agent-meta", facts.join(" · ")));
|
|
14473
15066
|
row.append(dot, content);
|
|
14474
|
-
|
|
14475
|
-
row.
|
|
14476
|
-
row.
|
|
15067
|
+
const destination = subagentOpenMode === "tab" ? "subagent tab" : "live output overlay";
|
|
15068
|
+
row.title = `${agent?.name || "subagent"} · ${facts.join(" · ")} · run ${run?.id || "unknown"} · open ${destination}`;
|
|
15069
|
+
row.setAttribute("aria-label", `Open ${destination} for ${agent?.name || "subagent"} in ${tab?.tabTitle || `Terminal ${tab?.tabIndex || "?"}`}`);
|
|
15070
|
+
row.addEventListener("click", () => openSubagentOutput(tab, run, agent));
|
|
14477
15071
|
return row;
|
|
14478
15072
|
}
|
|
14479
15073
|
|
|
@@ -14540,6 +15134,7 @@ async function refreshSubagents() {
|
|
|
14540
15134
|
try {
|
|
14541
15135
|
const response = await api("/api/subagents", { scoped: false });
|
|
14542
15136
|
latestSubagents = response.data || null;
|
|
15137
|
+
syncSubagentTerminalViewsFromOverview();
|
|
14543
15138
|
subagentsError = null;
|
|
14544
15139
|
} catch (error) {
|
|
14545
15140
|
subagentsError = error;
|
|
@@ -15219,6 +15814,100 @@ function renderReleaseAurLogWidget() {
|
|
|
15219
15814
|
return node;
|
|
15220
15815
|
}
|
|
15221
15816
|
|
|
15817
|
+
function aurReviewSafePath(value) {
|
|
15818
|
+
return parsedAurReviewSafePath(value);
|
|
15819
|
+
}
|
|
15820
|
+
|
|
15821
|
+
function parseAurReviewPayload(lines) {
|
|
15822
|
+
return parseValidatedAurReviewPayload(lines, {
|
|
15823
|
+
prefix: AUR_REVIEW_RPC_PAYLOAD_PREFIX,
|
|
15824
|
+
type: AUR_REVIEW_RPC_PAYLOAD_TYPE,
|
|
15825
|
+
version: AUR_REVIEW_RPC_PAYLOAD_VERSION,
|
|
15826
|
+
});
|
|
15827
|
+
}
|
|
15828
|
+
|
|
15829
|
+
function aurReviewActionButton(label, action, className = "") {
|
|
15830
|
+
const button = make("button", `aur-review-action ${className}`.trim(), label);
|
|
15831
|
+
button.type = "button";
|
|
15832
|
+
button.addEventListener("click", async () => {
|
|
15833
|
+
if (action === "review") {
|
|
15834
|
+
openGitChangesDialog();
|
|
15835
|
+
return;
|
|
15836
|
+
}
|
|
15837
|
+
const command = `/aur-review ${action}`;
|
|
15838
|
+
const tabContext = activeTabContext();
|
|
15839
|
+
try {
|
|
15840
|
+
await api("/api/prompt", { method: "POST", body: { message: resolveRpcSlashCommandMessage(command, { tabId: tabContext.tabId }) }, tabId: tabContext.tabId });
|
|
15841
|
+
if (isCurrentTabContext(tabContext)) addEvent(`${command} sent`, "info");
|
|
15842
|
+
} catch (error) {
|
|
15843
|
+
if (isCurrentTabContext(tabContext)) addEvent(error.message || String(error), "error");
|
|
15844
|
+
}
|
|
15845
|
+
});
|
|
15846
|
+
return button;
|
|
15847
|
+
}
|
|
15848
|
+
|
|
15849
|
+
function aurReviewFileLabel(file) {
|
|
15850
|
+
const path = aurReviewSafePath(file?.path);
|
|
15851
|
+
const oldPath = aurReviewSafePath(file?.oldPath);
|
|
15852
|
+
const flags = [file?.staged && "staged", file?.unstaged && "unstaged", file?.untracked && "untracked", file?.deleted && "deleted", file?.renamed && "renamed"].filter(Boolean);
|
|
15853
|
+
return `${oldPath ? `${oldPath} → ` : ""}${path}${flags.length ? ` · ${flags.join(", ")}` : ""}`;
|
|
15854
|
+
}
|
|
15855
|
+
|
|
15856
|
+
function renderAurReviewWidget() {
|
|
15857
|
+
if (!isOptionalFeatureEnabled("aurReview")) return null;
|
|
15858
|
+
const payload = parseAurReviewPayload(getWidgetLines(AUR_REVIEW_RPC_WIDGET_KEY));
|
|
15859
|
+
if (!payload || payload.decision.state === "closed") return null;
|
|
15860
|
+
|
|
15861
|
+
const node = make("section", "widget aur-review-widget");
|
|
15862
|
+
node.setAttribute("aria-label", "Manual repository review");
|
|
15863
|
+
const header = make("div", "aur-review-header");
|
|
15864
|
+
const title = make("div", "aur-review-title-wrap");
|
|
15865
|
+
title.append(
|
|
15866
|
+
make("span", "aur-review-kicker", `manual ${payload.scope} repository review`),
|
|
15867
|
+
make("strong", "aur-review-title", payload.decision.state === "pending" ? "Review required" : `Review ${payload.decision.state}`),
|
|
15868
|
+
);
|
|
15869
|
+
const actions = make("div", "aur-review-actions");
|
|
15870
|
+
actions.append(
|
|
15871
|
+
aurReviewActionButton("Review changes", "review"),
|
|
15872
|
+
aurReviewActionButton("Refresh", "refresh"),
|
|
15873
|
+
aurReviewActionButton("Approve", "approve", "primary"),
|
|
15874
|
+
aurReviewActionButton("Decline", "decline", "danger"),
|
|
15875
|
+
aurReviewActionButton("Close", "close"),
|
|
15876
|
+
);
|
|
15877
|
+
header.append(title, actions);
|
|
15878
|
+
|
|
15879
|
+
const fingerprint = make("code", "aur-review-fingerprint", payload.fingerprint);
|
|
15880
|
+
const summary = make("div", "aur-review-summary");
|
|
15881
|
+
summary.append(
|
|
15882
|
+
make("span", "aur-review-status", `Status: ${payload.decision.state}`),
|
|
15883
|
+
make("span", "aur-review-count", `${payload.changedFileTotal} ${payload.scope} changed file${payload.changedFileTotal === 1 ? "" : "s"}`),
|
|
15884
|
+
make("span", "aur-review-root", `${payload.origin} · ${payload.repoRoot}`),
|
|
15885
|
+
fingerprint,
|
|
15886
|
+
);
|
|
15887
|
+
|
|
15888
|
+
const files = make("details", "aur-review-files");
|
|
15889
|
+
files.open = true;
|
|
15890
|
+
files.append(make("summary", undefined, payload.changedFilesTruncated ? `Changed files (showing ${payload.changedFiles.length} of ${payload.changedFileTotal})` : `Changed files (${payload.changedFiles.length})`));
|
|
15891
|
+
const list = make("ul", "aur-review-file-list");
|
|
15892
|
+
for (const file of payload.changedFiles) list.append(make("li", undefined, aurReviewFileLabel(file)));
|
|
15893
|
+
files.append(list);
|
|
15894
|
+
|
|
15895
|
+
const reports = make("div", "aur-review-reports");
|
|
15896
|
+
reports.append(make("strong", undefined, "Reports"));
|
|
15897
|
+
if (payload.reports.length === 0) reports.append(make("span", "muted", "No safe report files were found."));
|
|
15898
|
+
for (const report of payload.reports) {
|
|
15899
|
+
const reportPath = aurReviewSafePath(report.path);
|
|
15900
|
+
if (!reportPath) continue;
|
|
15901
|
+
const button = make("button", "aur-review-report", `Open ${reportPath}`);
|
|
15902
|
+
button.type = "button";
|
|
15903
|
+
button.addEventListener("click", () => openAurReviewReportInViewer(reportPath, payload.repoRoot));
|
|
15904
|
+
reports.append(button);
|
|
15905
|
+
}
|
|
15906
|
+
|
|
15907
|
+
node.append(header, summary, files, reports);
|
|
15908
|
+
return node;
|
|
15909
|
+
}
|
|
15910
|
+
|
|
15222
15911
|
function parseWorkflowInspectorPayload(lines) {
|
|
15223
15912
|
const raw = String(lines?.[0] || "").trim();
|
|
15224
15913
|
if (!raw.startsWith(WORKFLOW_INSPECTOR_PAYLOAD_PREFIX)) return null;
|
|
@@ -17343,13 +18032,15 @@ function renderWidgets() {
|
|
|
17343
18032
|
if (releaseAurOutput) elements.widgetArea.append(releaseAurOutput);
|
|
17344
18033
|
const releaseAurLog = renderReleaseAurLogWidget();
|
|
17345
18034
|
if (releaseAurLog) elements.widgetArea.append(releaseAurLog);
|
|
18035
|
+
const aurReviewWidget = renderAurReviewWidget();
|
|
18036
|
+
if (aurReviewWidget) elements.widgetArea.append(aurReviewWidget);
|
|
17346
18037
|
const workflowInspectorWidget = renderWorkflowInspectorWidget();
|
|
17347
18038
|
if (workflowInspectorWidget) elements.widgetArea.append(workflowInspectorWidget);
|
|
17348
18039
|
const workflowSubprocessWidget = renderWorkflowSubprocessWidget();
|
|
17349
18040
|
if (workflowSubprocessWidget) elements.widgetArea.append(workflowSubprocessWidget);
|
|
17350
18041
|
const appRunnerWidget = renderAppRunnerWidget();
|
|
17351
18042
|
if (appRunnerWidget) elements.widgetArea.append(appRunnerWidget);
|
|
17352
|
-
const subagentWidget =
|
|
18043
|
+
const subagentWidget = renderSubagentOverlayWidgetSafely();
|
|
17353
18044
|
if (subagentWidget) elements.widgetArea.append(subagentWidget);
|
|
17354
18045
|
const btwWidget = renderBtwOutputWidget();
|
|
17355
18046
|
if (btwWidget) elements.widgetArea.append(btwWidget);
|
|
@@ -17772,6 +18463,9 @@ function gitWorkflowProcessForStep(step = gitWorkflow.step, fallback = gitWorkfl
|
|
|
17772
18463
|
case "initialPush":
|
|
17773
18464
|
case "initialPushing":
|
|
17774
18465
|
return "push";
|
|
18466
|
+
case "reviewRequesting":
|
|
18467
|
+
case "review":
|
|
18468
|
+
return "review";
|
|
17775
18469
|
case "generate":
|
|
17776
18470
|
case "generating":
|
|
17777
18471
|
return "message";
|
|
@@ -17828,6 +18522,7 @@ function selectGitInitWorkflowProcess(processValue, tabId, workflow) {
|
|
|
17828
18522
|
prBranch: "",
|
|
17829
18523
|
pr: null,
|
|
17830
18524
|
prRequestedAt: 0,
|
|
18525
|
+
...resetGuidedGitReviewPatch(),
|
|
17831
18526
|
};
|
|
17832
18527
|
|
|
17833
18528
|
if (process === "init") {
|
|
@@ -17865,14 +18560,23 @@ function selectGitWorkflowProcess(processValue, tabId = gitWorkflowActionTabId()
|
|
|
17865
18560
|
return;
|
|
17866
18561
|
}
|
|
17867
18562
|
const process = GIT_WORKFLOW_PROCESS_VALUES.has(processValue) ? processValue : "stage";
|
|
18563
|
+
// This repeats the disabled-button rule at the transition boundary. Later
|
|
18564
|
+
// processes retain a matching approval; Stage/Review deliberately clear it
|
|
18565
|
+
// and re-arm the requirement for a new staged snapshot.
|
|
18566
|
+
const guidedReviewPatch = guidedGitReviewProcessSelectionPatch(workflow, process);
|
|
18567
|
+
if (!guidedReviewPatch) return;
|
|
17868
18568
|
workflow.runId += 1;
|
|
17869
18569
|
const runId = workflow.runId;
|
|
17870
|
-
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 };
|
|
18570
|
+
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 };
|
|
17871
18571
|
|
|
17872
18572
|
if (process === "stage") {
|
|
17873
18573
|
setGitWorkflow({ ...base, step: "add", message: null, output: "Ready to stage all changes with git add ." }, { tabId });
|
|
17874
18574
|
return;
|
|
17875
18575
|
}
|
|
18576
|
+
if (process === "review") {
|
|
18577
|
+
setGitWorkflow({ ...base, step: "review", message: null, output: "Ready to request a staged manual repository review from Guided Git." }, { tabId });
|
|
18578
|
+
return;
|
|
18579
|
+
}
|
|
17876
18580
|
if (process === "message") {
|
|
17877
18581
|
setGitWorkflow({ ...base, step: "generate", message: null, output: "Ready to generate a commit message from the currently staged changes, or type one and commit it directly." }, { tabId });
|
|
17878
18582
|
return;
|
|
@@ -17904,6 +18608,8 @@ function gitWorkflowTitle() {
|
|
|
17904
18608
|
case "initialPush": return "Push main upstream";
|
|
17905
18609
|
case "initialPushing": return "Pushing main";
|
|
17906
18610
|
case "add": return (gitWorkflow.preferences || gitWorkflowPreferences)?.stagingPolicy === "all" ? "Stage all changes" : "Review staged changes";
|
|
18611
|
+
case "reviewRequesting": return "Requesting staged manual review";
|
|
18612
|
+
case "review": return "Manual staged review";
|
|
17907
18613
|
case "generate": return "Generate staged commit message";
|
|
17908
18614
|
case "generating": return "Waiting for /git-staged-msg";
|
|
17909
18615
|
case "message": return gitWorkflow.prMode ? "Choose PR branch commit message" : "Choose commit message";
|
|
@@ -17943,7 +18649,9 @@ function gitWorkflowHint() {
|
|
|
17943
18649
|
case "add": return (gitWorkflow.preferences || gitWorkflowPreferences)?.stagingPolicy === "all"
|
|
17944
18650
|
? "Step 1: explicitly stage all changes with git add ."
|
|
17945
18651
|
: "Step 1: review changes, stage only intended files, then accept the current staged set.";
|
|
17946
|
-
case "
|
|
18652
|
+
case "reviewRequesting": return "Step 2: requesting a staged manual repository review in this tab. Cancel will request Pi abort.";
|
|
18653
|
+
case "review": return "Step 2: inspect the staged Git diff and use the manual review card to approve or decline. Approval alone advances to commit-message generation.";
|
|
18654
|
+
case "generate": return "Step 3: run /git-staged-msg, or type a commit message and use Commit input.";
|
|
17947
18655
|
case "generating": return "Pi is generating dev/COMMIT/staged-commit-short.txt and staged-commit-long.txt.";
|
|
17948
18656
|
case "message": return gitWorkflow.prMode ? `Worktree branch ${gitWorkflow.prBranch || "created"}: choose short, long, or typed input before opening a PR.` : "Step 3/4: preview the native g-msg output, type a commit message if needed, commit here, or create a PR branch worktree first.";
|
|
17949
18657
|
case "branchNaming": return "Pi is generating dev/COMMIT/staged-branch-name.txt for a PR branch worktree. Cancel will request Pi abort.";
|
|
@@ -18033,15 +18741,21 @@ function renderGitWorkflow() {
|
|
|
18033
18741
|
elements.gitWorkflowSteps.replaceChildren();
|
|
18034
18742
|
elements.gitWorkflowActions.replaceChildren();
|
|
18035
18743
|
|
|
18036
|
-
|
|
18744
|
+
// Once a flow required manual review, keep its recovery step visible even
|
|
18745
|
+
// if the extension was disabled or disappeared. Hiding it would suggest a
|
|
18746
|
+
// legacy fallback that is no longer authorized for this flow.
|
|
18747
|
+
const reviewStepAvailable = guidedGitReviewAvailable(activeTabId) || gitWorkflow.guidedReviewRequired === true;
|
|
18748
|
+
const standardProcesses = reviewStepAvailable ? GIT_WORKFLOW_PROCESSES : GIT_WORKFLOW_PROCESSES.filter((process) => process.value !== "review");
|
|
18749
|
+
const processes = gitWorkflow.mode === "initRepo" ? GIT_INIT_WORKFLOW_PROCESSES : standardProcesses;
|
|
18037
18750
|
const activeIndexMap = gitWorkflow.mode === "initRepo" ? GIT_INIT_WORKFLOW_ACTIVE_INDEX : GIT_WORKFLOW_ACTIVE_INDEX;
|
|
18038
|
-
const
|
|
18751
|
+
const reviewOffset = gitWorkflow.mode === "standard" && !reviewStepAvailable && (activeIndexMap[gitWorkflow.step] ?? 0) >= 2 ? 1 : 0;
|
|
18752
|
+
const activeIndex = Math.max(0, (activeIndexMap[gitWorkflow.step] ?? 0) - reviewOffset);
|
|
18039
18753
|
const activeProcess = gitWorkflowProcessForStep(gitWorkflow.step, gitWorkflow.process);
|
|
18040
18754
|
for (const [index, process] of processes.entries()) {
|
|
18041
18755
|
const item = make("button", "git-workflow-step", process.label);
|
|
18042
18756
|
item.type = "button";
|
|
18043
18757
|
item.dataset.gitWorkflowProcess = process.value;
|
|
18044
|
-
item.disabled = !!gitWorkflow.busy;
|
|
18758
|
+
item.disabled = !!gitWorkflow.busy || !guidedGitReviewProcessNavigationAllowed(gitWorkflow, process.value);
|
|
18045
18759
|
item.setAttribute("aria-pressed", String(process.value === activeProcess));
|
|
18046
18760
|
if (gitWorkflowActionDone(gitWorkflow, process.value)) item.classList.add("done");
|
|
18047
18761
|
if (index === activeIndex && !["done", "cancelled", "error"].includes(gitWorkflow.step)) item.classList.add("active");
|
|
@@ -18067,6 +18781,16 @@ function renderGitWorkflow() {
|
|
|
18067
18781
|
addGitWorkflowAction("Review/select changes", () => openGitChangesDialog(), "primary", false);
|
|
18068
18782
|
addGitWorkflowAction("Use current staged set", () => acceptCurrentGitStaging(), "", false);
|
|
18069
18783
|
}
|
|
18784
|
+
} else if (gitWorkflow.step === "reviewRequesting") {
|
|
18785
|
+
addGitWorkflowAction("Requesting manual review…", () => {}, "primary", true);
|
|
18786
|
+
} else if (gitWorkflow.step === "review") {
|
|
18787
|
+
if (gitWorkflow.guidedReviewStatus === "pending") {
|
|
18788
|
+
addGitWorkflowAction("Manual review pending", () => {}, "primary", true);
|
|
18789
|
+
addGitWorkflowAction("Review staged changes", () => openGitChangesDialog(), "", false);
|
|
18790
|
+
} else {
|
|
18791
|
+
addGitWorkflowAction("Request staged manual review", () => requestGuidedGitReview(), "primary", false);
|
|
18792
|
+
addGitWorkflowAction("Review/select changes", () => openGitChangesDialog(), "", false);
|
|
18793
|
+
}
|
|
18070
18794
|
} else if (gitWorkflow.step === "generate") {
|
|
18071
18795
|
const commitInputButton = renderGitWorkflowManualCommitInput({ appendCommitButton: false });
|
|
18072
18796
|
addGitWorkflowAction("Run /git-staged-msg", () => runGitMessagePrompt(), "primary", false);
|
|
@@ -18155,6 +18879,208 @@ function gitWorkflowStagingReadyMessage(preferences) {
|
|
|
18155
18879
|
}
|
|
18156
18880
|
}
|
|
18157
18881
|
|
|
18882
|
+
function guidedGitReviewAvailable(tabId = activeTabId) {
|
|
18883
|
+
return guidedGitReviewAvailableForTabCatalog(commandCatalogForTab(tabId)) && !isOptionalFeatureDisabled("aurReview");
|
|
18884
|
+
}
|
|
18885
|
+
|
|
18886
|
+
function guidedGitReviewUnavailableMessage() {
|
|
18887
|
+
return "Manual staged review is still required, but aur-review is unavailable or disabled. Re-enable/install @firstpick/pi-extension-aur-review and reload this Pi/WebUI tab, then request a new review. No message, commit, worktree, or push action was performed.";
|
|
18888
|
+
}
|
|
18889
|
+
|
|
18890
|
+
function guidedGitReviewCommand() {
|
|
18891
|
+
return "/aur-review start --scope staged --origin guided-git";
|
|
18892
|
+
}
|
|
18893
|
+
|
|
18894
|
+
function validGuidedGitStagedContentHash(value) {
|
|
18895
|
+
return typeof value === "string" && /^[a-f0-9]{64}$/i.test(value);
|
|
18896
|
+
}
|
|
18897
|
+
|
|
18898
|
+
async function readGuidedGitStagedContent(tabId) {
|
|
18899
|
+
const response = await api("/api/git-workflow/staged-content", { tabId, signal: AbortSignal.timeout(12_000) });
|
|
18900
|
+
if (!response?.ok) throw new Error(response?.error || "Could not determine the current staged content. Reload Pi Web UI and try again.");
|
|
18901
|
+
const staged = response.data || {};
|
|
18902
|
+
if (typeof staged.hasStagedChanges !== "boolean") throw new Error("The staged-content check returned an invalid response. Reload Pi Web UI and try again.");
|
|
18903
|
+
if (staged.hasStagedChanges && !validGuidedGitStagedContentHash(staged.stagedContentHash)) {
|
|
18904
|
+
throw new Error("The staged-content check returned an invalid hash. Reload Pi Web UI and try again.");
|
|
18905
|
+
}
|
|
18906
|
+
if (!staged.hasStagedChanges && staged.stagedContentHash !== null) {
|
|
18907
|
+
throw new Error("The staged-content check returned an invalid empty-state hash. Reload Pi Web UI and try again.");
|
|
18908
|
+
}
|
|
18909
|
+
return staged;
|
|
18910
|
+
}
|
|
18911
|
+
|
|
18912
|
+
function resetGuidedGitReviewForRecovery(tabId, workflow, output, { declinedStagedContentHash } = {}) {
|
|
18913
|
+
resetGuidedGitReviewToStaging(tabId, workflow, output);
|
|
18914
|
+
if (declinedStagedContentHash !== undefined) {
|
|
18915
|
+
setGitWorkflow({ guidedReviewDeclinedStagedContentHash: declinedStagedContentHash || "" }, { tabId });
|
|
18916
|
+
}
|
|
18917
|
+
}
|
|
18918
|
+
|
|
18919
|
+
async function assertGuidedGitStagedContentBinding(tabId, action) {
|
|
18920
|
+
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
18921
|
+
if (!workflow) return "";
|
|
18922
|
+
if (workflow.guidedReviewRequired === true || !guidedGitReviewHasApprovedBinding(workflow)) {
|
|
18923
|
+
if (workflow.guidedReviewRequired === true || workflow.guidedReviewStatus === "approved") {
|
|
18924
|
+
resetGuidedGitReviewForRecovery(tabId, workflow, `Manual staged review is required before ${action}. Request a new review from Stage.`, {});
|
|
18925
|
+
throw new Error(`Manual staged review is required before ${action}.`);
|
|
18926
|
+
}
|
|
18927
|
+
return ""; // Legacy flow started without a required review gate.
|
|
18928
|
+
}
|
|
18929
|
+
const approvedHash = workflow.guidedReviewStagedContentHash;
|
|
18930
|
+
try {
|
|
18931
|
+
const staged = await readGuidedGitStagedContent(tabId);
|
|
18932
|
+
if (!staged.hasStagedChanges || staged.stagedContentHash !== approvedHash) {
|
|
18933
|
+
resetGuidedGitReviewForRecovery(tabId, workflow, `The staged content changed after manual approval. ${action} was blocked; review and approve the exact current staged content again.`, {});
|
|
18934
|
+
throw new Error(`The staged content changed after manual approval. ${action} was blocked.`);
|
|
18935
|
+
}
|
|
18936
|
+
return approvedHash;
|
|
18937
|
+
} catch (error) {
|
|
18938
|
+
if (isCurrentGitWorkflowRun(workflow.runId, tabId) && gitWorkflowForTab(tabId, { create: false })?.guidedReviewStagedContentHash === approvedHash) {
|
|
18939
|
+
resetGuidedGitReviewForRecovery(tabId, workflow, `Could not verify the approved staged content before ${action}. ${action} was blocked; reload Pi Web UI if this persists, then request a new review.`, {});
|
|
18940
|
+
}
|
|
18941
|
+
throw error;
|
|
18942
|
+
}
|
|
18943
|
+
}
|
|
18944
|
+
|
|
18945
|
+
async function requestGuidedGitReview(tabId = gitWorkflowActionTabId(), { output = "Staged changes are ready for manual review." } = {}) {
|
|
18946
|
+
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
18947
|
+
if (!workflow) return false;
|
|
18948
|
+
if (!guidedGitReviewAvailable(tabId)) {
|
|
18949
|
+
if (workflow.guidedReviewRequired === true) resetGuidedGitReviewForRecovery(tabId, workflow, guidedGitReviewUnavailableMessage());
|
|
18950
|
+
return false;
|
|
18951
|
+
}
|
|
18952
|
+
|
|
18953
|
+
let staged;
|
|
18954
|
+
try {
|
|
18955
|
+
staged = await readGuidedGitStagedContent(tabId);
|
|
18956
|
+
} catch (error) {
|
|
18957
|
+
resetGuidedGitReviewForRecovery(tabId, workflow, `Could not verify staged content before requesting manual review. Reload Pi Web UI and try again. ${error?.message || String(error)}`);
|
|
18958
|
+
return false;
|
|
18959
|
+
}
|
|
18960
|
+
if (!staged.hasStagedChanges) {
|
|
18961
|
+
setGitWorkflow({
|
|
18962
|
+
step: "add",
|
|
18963
|
+
process: "stage",
|
|
18964
|
+
busy: false,
|
|
18965
|
+
error: "",
|
|
18966
|
+
...resetGuidedGitReviewPatch(),
|
|
18967
|
+
guidedReviewRequired: workflow.guidedReviewRequired === true,
|
|
18968
|
+
output: "git add . produced no substantive staged changes. Guided Git returned to Stage; select or edit changes before requesting manual review.",
|
|
18969
|
+
}, { tabId });
|
|
18970
|
+
return false;
|
|
18971
|
+
}
|
|
18972
|
+
if (!guidedGitReviewCanRequestStagedContent(workflow, staged.stagedContentHash)) {
|
|
18973
|
+
resetGuidedGitReviewForRecovery(tabId, workflow, "The staged content is unchanged from the declined review. Make and restage the requested corrections before requesting another manual review.");
|
|
18974
|
+
return false;
|
|
18975
|
+
}
|
|
18976
|
+
|
|
18977
|
+
const runId = workflow.runId;
|
|
18978
|
+
const requestedAt = Date.now();
|
|
18979
|
+
setGitWorkflow({
|
|
18980
|
+
step: "reviewRequesting",
|
|
18981
|
+
process: "review",
|
|
18982
|
+
busy: true,
|
|
18983
|
+
error: "",
|
|
18984
|
+
...resetGitWorkflowManualCommitDefaultPatch(),
|
|
18985
|
+
...resetGuidedGitReviewPatch(),
|
|
18986
|
+
guidedReviewRequired: true,
|
|
18987
|
+
guidedReviewStatus: "requesting",
|
|
18988
|
+
guidedReviewRequestedAt: requestedAt,
|
|
18989
|
+
...gitWorkflowActionDonePatch(workflow, "stage"),
|
|
18990
|
+
output: `${output}\n\nRequesting a staged manual repository review in this tab…`,
|
|
18991
|
+
}, { tabId });
|
|
18992
|
+
try {
|
|
18993
|
+
await api("/api/prompt", { method: "POST", body: { message: resolveRpcSlashCommandMessage(guidedGitReviewCommand(), { tabId }) }, tabId, signal: AbortSignal.timeout(12_000) });
|
|
18994
|
+
const current = gitWorkflowForTab(tabId, { create: false });
|
|
18995
|
+
if (!current || !isCurrentGitWorkflowRun(runId, tabId) || current.guidedReviewStatus !== "requesting") return true;
|
|
18996
|
+
setGitWorkflow({
|
|
18997
|
+
step: "review",
|
|
18998
|
+
busy: false,
|
|
18999
|
+
output: `${output}\n\nManual staged review requested. Waiting for the review card; approve or decline it there.`,
|
|
19000
|
+
}, { tabId });
|
|
19001
|
+
// The extension reports command failures through its own UI, so a prompt
|
|
19002
|
+
// acknowledgement is not enough evidence that a card exists. Time out
|
|
19003
|
+
// the request state instead of allowing an invisible gate to hang forever.
|
|
19004
|
+
setTimeout(() => {
|
|
19005
|
+
const waiting = gitWorkflowForTab(tabId, { create: false });
|
|
19006
|
+
if (waiting && isCurrentGitWorkflowRun(runId, tabId) && waiting.guidedReviewStatus === "requesting") {
|
|
19007
|
+
resetGuidedGitReviewForRecovery(tabId, waiting, "Manual review did not produce a review card in time. Reload or enable aur-review, then request a new review. No message or commit was performed.");
|
|
19008
|
+
}
|
|
19009
|
+
}, 15_000);
|
|
19010
|
+
return true;
|
|
19011
|
+
} catch (error) {
|
|
19012
|
+
if (isCurrentGitWorkflowRun(runId, tabId)) {
|
|
19013
|
+
resetGuidedGitReviewForRecovery(tabId, workflow, `Manual review request failed or timed out. Reload or enable aur-review, then request a new review. ${error?.message || String(error)}`);
|
|
19014
|
+
}
|
|
19015
|
+
return false;
|
|
19016
|
+
}
|
|
19017
|
+
}
|
|
19018
|
+
|
|
19019
|
+
function resetGuidedGitReviewToStaging(tabId, workflow, output) {
|
|
19020
|
+
setGitWorkflow({
|
|
19021
|
+
step: "add",
|
|
19022
|
+
process: "stage",
|
|
19023
|
+
busy: false,
|
|
19024
|
+
error: "",
|
|
19025
|
+
...resetGuidedGitReviewPatch(),
|
|
19026
|
+
guidedReviewRequired: true,
|
|
19027
|
+
actionsDone: createGitWorkflowActionsDone({ ...workflow.actionsDone, stage: false }),
|
|
19028
|
+
output,
|
|
19029
|
+
}, { tabId });
|
|
19030
|
+
}
|
|
19031
|
+
|
|
19032
|
+
function reconcileGuidedGitReviewPayload(tabId, payload) {
|
|
19033
|
+
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
19034
|
+
const transition = guidedGitReviewTransition(workflow, payload);
|
|
19035
|
+
if (transition === "ignore") return false;
|
|
19036
|
+
if (transition === "pending") {
|
|
19037
|
+
if (workflow.guidedReviewDeclinedStagedContentHash && payload.stagedContentHash === workflow.guidedReviewDeclinedStagedContentHash) {
|
|
19038
|
+
resetGuidedGitReviewForRecovery(tabId, workflow, "The review extension reported the same staged content that was declined. Make and restage the requested corrections before requesting another manual review.");
|
|
19039
|
+
return true;
|
|
19040
|
+
}
|
|
19041
|
+
setGitWorkflow({
|
|
19042
|
+
step: "review",
|
|
19043
|
+
process: "review",
|
|
19044
|
+
busy: false,
|
|
19045
|
+
error: "",
|
|
19046
|
+
guidedReviewStatus: "pending",
|
|
19047
|
+
guidedReviewRequired: true,
|
|
19048
|
+
guidedReviewFingerprint: payload.fingerprint,
|
|
19049
|
+
guidedReviewRepoRoot: payload.repoRoot,
|
|
19050
|
+
guidedReviewStagedContentHash: payload.stagedContentHash,
|
|
19051
|
+
output: `Staged manual repository review pending for ${payload.changedFileTotal} file${payload.changedFileTotal === 1 ? "" : "s"}. Inspect the staged Git diff, then approve or decline in the review card.`,
|
|
19052
|
+
}, { tabId });
|
|
19053
|
+
return true;
|
|
19054
|
+
}
|
|
19055
|
+
if (transition === "approved") {
|
|
19056
|
+
setGitWorkflow({
|
|
19057
|
+
step: "generate",
|
|
19058
|
+
process: "message",
|
|
19059
|
+
busy: false,
|
|
19060
|
+
error: "",
|
|
19061
|
+
guidedReviewStatus: "approved",
|
|
19062
|
+
guidedReviewRequired: false,
|
|
19063
|
+
guidedReviewDeclinedStagedContentHash: "",
|
|
19064
|
+
output: "Manual staged repository review approved for the exact staged snapshot. Its exact staged content will be verified again before every message, worktree, and commit action.",
|
|
19065
|
+
}, { tabId });
|
|
19066
|
+
loadGitWorkflowDefaultCommitMessage({ runId: workflow.runId, tabId });
|
|
19067
|
+
return true;
|
|
19068
|
+
}
|
|
19069
|
+
if (transition === "closed") {
|
|
19070
|
+
resetGuidedGitReviewToStaging(tabId, workflow, "Manual staged repository review was closed. It did not approve the staged changes. Review/select and restage before requesting a new staged manual review.");
|
|
19071
|
+
return true;
|
|
19072
|
+
}
|
|
19073
|
+
resetGuidedGitReviewForRecovery(tabId, workflow, "Manual staged repository review was declined. Make only the requested edits, then use Guided Git to review/select and restage the corrected files before requesting a new staged manual review. The unchanged declined staged content cannot be requested again. No commit or push was performed.", { declinedStagedContentHash: payload.stagedContentHash });
|
|
19074
|
+
return true;
|
|
19075
|
+
}
|
|
19076
|
+
|
|
19077
|
+
function reconcileGuidedGitReviewWidgetRemoval(tabId) {
|
|
19078
|
+
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
19079
|
+
if (guidedGitReviewWidgetRemovalTransition(workflow) !== "closed") return false;
|
|
19080
|
+
resetGuidedGitReviewToStaging(tabId, workflow, "Manual staged repository review card was cleared. It did not approve the staged changes. Review/select and restage before requesting a new staged manual review.");
|
|
19081
|
+
return true;
|
|
19082
|
+
}
|
|
19083
|
+
|
|
18158
19084
|
async function startGitWorkflow(tabId = activeTabId, { skipSetup = false } = {}) {
|
|
18159
19085
|
if (!tabId) return;
|
|
18160
19086
|
if (!isOptionalFeatureEnabled("gitWorkflow")) {
|
|
@@ -18215,6 +19141,11 @@ async function startGitWorkflow(tabId = activeTabId, { skipSetup = false } = {})
|
|
|
18215
19141
|
prBranch: "",
|
|
18216
19142
|
pr: null,
|
|
18217
19143
|
prRequestedAt: 0,
|
|
19144
|
+
...resetGuidedGitReviewPatch({ retainDeclinedStagedContentHash: false }),
|
|
19145
|
+
// Availability at the moment this new standard flow begins determines
|
|
19146
|
+
// whether it is a required-review flow; later extension loss cannot turn
|
|
19147
|
+
// an already-required flow into the legacy path.
|
|
19148
|
+
guidedReviewRequired: guidedGitReviewAvailable(tabId),
|
|
18218
19149
|
preferences,
|
|
18219
19150
|
verificationConfirmed: false,
|
|
18220
19151
|
}, { tabId });
|
|
@@ -18257,6 +19188,7 @@ async function startGitInitWorkflow(tabId = activeTabId) {
|
|
|
18257
19188
|
prBranch: "",
|
|
18258
19189
|
pr: null,
|
|
18259
19190
|
prRequestedAt: 0,
|
|
19191
|
+
...resetGuidedGitReviewPatch(),
|
|
18260
19192
|
}, { tabId });
|
|
18261
19193
|
}
|
|
18262
19194
|
|
|
@@ -18522,7 +19454,7 @@ async function cancelGitWorkflow(tabId = gitWorkflowActionTabId()) {
|
|
|
18522
19454
|
const tabContext = activeTabContext(tabId);
|
|
18523
19455
|
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
18524
19456
|
if (!workflow?.active) return;
|
|
18525
|
-
const shouldAbortPi = workflow.step === "generating" || workflow.step === "branchNaming" || workflow.step === "prGenerating" || workflow.step === "readmeGenerating" || workflow.step === "gitignoreGenerating";
|
|
19457
|
+
const shouldAbortPi = workflow.step === "reviewRequesting" || workflow.step === "generating" || workflow.step === "branchNaming" || workflow.step === "prGenerating" || workflow.step === "readmeGenerating" || workflow.step === "gitignoreGenerating";
|
|
18526
19458
|
if (activeGitPrDialogResolve) resolveGitPrDialog(null);
|
|
18527
19459
|
workflow.runId += 1;
|
|
18528
19460
|
setGitWorkflow({ step: "cancelled", busy: false, error: "", output: `${workflow.output || ""}${workflow.output ? "\n\n" : ""}Cancelled by user.` }, { tabId });
|
|
@@ -18543,7 +19475,14 @@ async function runGitAdd(tabId = gitWorkflowActionTabId()) {
|
|
|
18543
19475
|
try {
|
|
18544
19476
|
const result = await gitWorkflowRequest("/api/git-workflow/add", { runId, tabId });
|
|
18545
19477
|
if (!result) return;
|
|
18546
|
-
|
|
19478
|
+
const output = `${formatGitCommandResult(result)}\n\nStaged.`;
|
|
19479
|
+
if (guidedGitReviewAvailable(tabId) || workflow.guidedReviewRequired === true) {
|
|
19480
|
+
// A required gate never falls through to the legacy message flow just
|
|
19481
|
+
// because its extension was disabled or disappeared after staging.
|
|
19482
|
+
await requestGuidedGitReview(tabId, { output });
|
|
19483
|
+
} else {
|
|
19484
|
+
setGitWorkflow({ step: "generate", busy: false, ...resetGitWorkflowManualCommitDefaultPatch(), ...gitWorkflowActionDonePatch(workflow, "stage"), output: `${output} Next: run /git-staged-msg.` }, { tabId });
|
|
19485
|
+
}
|
|
18547
19486
|
if (isCurrentTabContext(tabContext)) scheduleRefreshFooter();
|
|
18548
19487
|
} catch (error) {
|
|
18549
19488
|
if (isCurrentGitWorkflowRun(runId, tabId)) failGitWorkflow(error, "add", { tabId });
|
|
@@ -18560,15 +19499,20 @@ async function acceptCurrentGitStaging(tabId = gitWorkflowActionTabId()) {
|
|
|
18560
19499
|
const response = await api("/api/git-changes", { tabId });
|
|
18561
19500
|
const staged = Number(response.data?.summary?.staged || 0);
|
|
18562
19501
|
if (staged <= 0) throw new Error("No staged files are available. Use Review/select changes to stage the intended files first.");
|
|
18563
|
-
|
|
18564
|
-
|
|
18565
|
-
|
|
18566
|
-
|
|
18567
|
-
|
|
18568
|
-
|
|
18569
|
-
|
|
18570
|
-
|
|
18571
|
-
|
|
19502
|
+
const output = `Using the current staged set (${staged} file${staged === 1 ? "" : "s"}).`;
|
|
19503
|
+
if (guidedGitReviewAvailable(tabId) || workflow.guidedReviewRequired === true) {
|
|
19504
|
+
await requestGuidedGitReview(tabId, { output });
|
|
19505
|
+
} else {
|
|
19506
|
+
setGitWorkflow({
|
|
19507
|
+
step: "generate",
|
|
19508
|
+
process: "message",
|
|
19509
|
+
busy: false,
|
|
19510
|
+
...resetGitWorkflowManualCommitDefaultPatch(),
|
|
19511
|
+
...gitWorkflowActionDonePatch(workflow, "stage"),
|
|
19512
|
+
output: `${output} Review the staged diff, then generate or type a commit message.`,
|
|
19513
|
+
}, { tabId });
|
|
19514
|
+
loadGitWorkflowDefaultCommitMessage({ runId, tabId });
|
|
19515
|
+
}
|
|
18572
19516
|
if (isCurrentTabContext(tabContext)) scheduleRefreshFooter();
|
|
18573
19517
|
} catch (error) {
|
|
18574
19518
|
if (isCurrentGitWorkflowRun(runId, tabId)) failGitWorkflow(error, "add", { tabId });
|
|
@@ -18615,6 +19559,13 @@ async function runGitMessagePrompt(tabId = gitWorkflowActionTabId()) {
|
|
|
18615
19559
|
}
|
|
18616
19560
|
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
18617
19561
|
if (!workflow) return;
|
|
19562
|
+
let expectedStagedContentHash;
|
|
19563
|
+
try {
|
|
19564
|
+
expectedStagedContentHash = await assertGuidedGitStagedContentBinding(tabId, "commit-message generation");
|
|
19565
|
+
} catch (error) {
|
|
19566
|
+
failGitWorkflow(error, "add", { tabId });
|
|
19567
|
+
return;
|
|
19568
|
+
}
|
|
18618
19569
|
const runId = workflow.runId;
|
|
18619
19570
|
const requestedAt = Date.now();
|
|
18620
19571
|
setGitWorkflow({
|
|
@@ -18626,7 +19577,7 @@ async function runGitMessagePrompt(tabId = gitWorkflowActionTabId()) {
|
|
|
18626
19577
|
}, { tabId });
|
|
18627
19578
|
if (isCurrentTabContext(tabContext)) setRunIndicatorActivity("Sending /git-staged-msg to Pi…");
|
|
18628
19579
|
try {
|
|
18629
|
-
const generation = await gitWorkflowRequest("/api/git-workflow/generate", { body: { kind: "commit" }, runId, tabId });
|
|
19580
|
+
const generation = await gitWorkflowRequest("/api/git-workflow/generate", { body: { kind: "commit", ...(expectedStagedContentHash ? { expectedStagedContentHash } : {}) }, runId, tabId });
|
|
18630
19581
|
if (!generation || !isCurrentGitWorkflowRun(runId, tabId)) return;
|
|
18631
19582
|
appendGitWorkflowOutput(`/git-staged-msg accepted with ${generation.generation.provider}/${generation.generation.modelId} at ${generation.generation.thinkingLevel} effort. Waiting for agent_end, then the message files will be loaded.`, { tabId });
|
|
18632
19583
|
if (isCurrentTabContext(tabContext)) scheduleRefreshState(120, tabContext);
|
|
@@ -18711,6 +19662,13 @@ async function runGitBranchNamePrompt(tabId = gitWorkflowActionTabId()) {
|
|
|
18711
19662
|
}
|
|
18712
19663
|
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
18713
19664
|
if (!workflow) return;
|
|
19665
|
+
let expectedStagedContentHash;
|
|
19666
|
+
try {
|
|
19667
|
+
expectedStagedContentHash = await assertGuidedGitStagedContentBinding(tabId, "PR branch-name generation");
|
|
19668
|
+
} catch (error) {
|
|
19669
|
+
failGitWorkflow(error, "add", { tabId });
|
|
19670
|
+
return;
|
|
19671
|
+
}
|
|
18714
19672
|
const runId = workflow.runId;
|
|
18715
19673
|
const requestedAt = Date.now();
|
|
18716
19674
|
setGitWorkflow({
|
|
@@ -18722,7 +19680,7 @@ async function runGitBranchNamePrompt(tabId = gitWorkflowActionTabId()) {
|
|
|
18722
19680
|
}, { tabId });
|
|
18723
19681
|
if (isCurrentTabContext(tabContext)) setRunIndicatorActivity("Sending branch-name request to Pi…");
|
|
18724
19682
|
try {
|
|
18725
|
-
const generation = await gitWorkflowRequest("/api/git-workflow/generate", { body: { kind: "branch" }, runId, tabId });
|
|
19683
|
+
const generation = await gitWorkflowRequest("/api/git-workflow/generate", { body: { kind: "branch", ...(expectedStagedContentHash ? { expectedStagedContentHash } : {}) }, runId, tabId });
|
|
18726
19684
|
if (!generation || !isCurrentGitWorkflowRun(runId, tabId)) return;
|
|
18727
19685
|
appendGitWorkflowOutput(`Branch-name request accepted with ${generation.generation.provider}/${generation.generation.modelId} at ${generation.generation.thinkingLevel} effort. Waiting for agent_end, then the branch name will be loaded.`, { tabId });
|
|
18728
19686
|
if (isCurrentTabContext(tabContext)) scheduleRefreshState(120, tabContext);
|
|
@@ -18807,10 +19765,22 @@ async function createGitPrBranchWithSuggestion(suggestion, tabId = gitWorkflowAc
|
|
|
18807
19765
|
failGitWorkflow(new Error("Branch name is required to create a PR branch worktree."), "message", { tabId });
|
|
18808
19766
|
return;
|
|
18809
19767
|
}
|
|
19768
|
+
const baseRef = await chooseGitWorktreeBase(branch);
|
|
19769
|
+
if (baseRef === null) {
|
|
19770
|
+
setGitWorkflow({ step: "message", busy: false, output: `${formatCommitMessagePreview(sourceWorkflow.message)}\n\nPR branch worktree creation cancelled before choosing a base.` }, { tabId });
|
|
19771
|
+
return;
|
|
19772
|
+
}
|
|
19773
|
+
let expectedStagedContentHash;
|
|
19774
|
+
try {
|
|
19775
|
+
expectedStagedContentHash = await assertGuidedGitStagedContentBinding(tabId, "PR worktree creation");
|
|
19776
|
+
} catch (error) {
|
|
19777
|
+
failGitWorkflow(error, "add", { tabId });
|
|
19778
|
+
return;
|
|
19779
|
+
}
|
|
18810
19780
|
const runId = workflow.runId;
|
|
18811
19781
|
setGitWorkflow({ step: "branching", prMode: true, prBranch: branch, branchName: branch, busy: true, error: "", output: `${formatCommitMessagePreview(sourceWorkflow.message)}\n\nCreating or opening branch worktree ${branch}…` }, { tabId });
|
|
18812
19782
|
try {
|
|
18813
|
-
const result = await gitWorkflowRequest("/api/git-workflow/branch", { body: { branch, sessionMode: "fork-current", openTab: true }, runId, tabId });
|
|
19783
|
+
const result = await gitWorkflowRequest("/api/git-workflow/branch", { body: { branch, baseRef, sessionMode: "fork-current", openTab: true, ...(expectedStagedContentHash ? { expectedStagedContentHash } : {}) }, runId, tabId });
|
|
18814
19784
|
if (!result) return;
|
|
18815
19785
|
syncGitWorkflowWorktreeTabs(result);
|
|
18816
19786
|
const targetTabId = result.tab?.id && tabs.some((tab) => tab.id === result.tab.id) ? result.tab.id : tabId;
|
|
@@ -18848,6 +19818,17 @@ async function createGitPrBranchWithSuggestion(suggestion, tabId = gitWorkflowAc
|
|
|
18848
19818
|
prBranch: prBranch || branch,
|
|
18849
19819
|
pr: null,
|
|
18850
19820
|
prRequestedAt: 0,
|
|
19821
|
+
...(expectedStagedContentHash
|
|
19822
|
+
? {
|
|
19823
|
+
guidedReviewStatus: "approved",
|
|
19824
|
+
guidedReviewFingerprint: sourceWorkflow.guidedReviewFingerprint,
|
|
19825
|
+
guidedReviewRepoRoot: sourceWorkflow.guidedReviewRepoRoot,
|
|
19826
|
+
guidedReviewStagedContentHash: expectedStagedContentHash,
|
|
19827
|
+
guidedReviewDeclinedStagedContentHash: "",
|
|
19828
|
+
guidedReviewRequestedAt: 0,
|
|
19829
|
+
guidedReviewRequired: false,
|
|
19830
|
+
}
|
|
19831
|
+
: resetGuidedGitReviewPatch()),
|
|
18851
19832
|
preferences: sourceWorkflow.preferences || gitWorkflowPreferences,
|
|
18852
19833
|
verificationConfirmed: false,
|
|
18853
19834
|
};
|
|
@@ -18869,8 +19850,15 @@ async function commitGitWorkflow(variant, tabId = gitWorkflowActionTabId()) {
|
|
|
18869
19850
|
const tabContext = activeTabContext(tabId);
|
|
18870
19851
|
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
18871
19852
|
if (!workflow) return;
|
|
18872
|
-
const runId = workflow.runId;
|
|
18873
19853
|
const failureStep = variant === "input" && workflow.step === "generate" ? "generate" : "message";
|
|
19854
|
+
let expectedStagedContentHash;
|
|
19855
|
+
try {
|
|
19856
|
+
expectedStagedContentHash = await assertGuidedGitStagedContentBinding(tabId, "commit");
|
|
19857
|
+
} catch (error) {
|
|
19858
|
+
failGitWorkflow(error, "add", { tabId });
|
|
19859
|
+
return;
|
|
19860
|
+
}
|
|
19861
|
+
const runId = workflow.runId;
|
|
18874
19862
|
const inputMessage = variant === "input" ? gitWorkflowManualCommitInputMessage(workflow) : "";
|
|
18875
19863
|
if (workflow.preferences?.verificationPolicy === "ask" && !workflow.verificationConfirmed) {
|
|
18876
19864
|
const proceed = await appConfirmText([
|
|
@@ -18891,7 +19879,9 @@ async function commitGitWorkflow(variant, tabId = gitWorkflowActionTabId()) {
|
|
|
18891
19879
|
const preview = variant === "input" ? formatInputCommitMessagePreview(inputMessage) : formatCommitMessagePreview(workflow.message);
|
|
18892
19880
|
setGitWorkflow({ step: "committing", busy: true, error: "", output: `${preview}\n\nRunning native ${variant} commit…` }, { tabId });
|
|
18893
19881
|
try {
|
|
18894
|
-
const body = variant === "input"
|
|
19882
|
+
const body = variant === "input"
|
|
19883
|
+
? { variant, message: inputMessage, ...(expectedStagedContentHash ? { expectedStagedContentHash } : {}) }
|
|
19884
|
+
: { variant, ...(expectedStagedContentHash ? { expectedStagedContentHash } : {}) };
|
|
18895
19885
|
const result = await gitWorkflowRequest("/api/git-workflow/commit", { body, runId, tabId });
|
|
18896
19886
|
if (!result) return;
|
|
18897
19887
|
const nextAction = workflow.prMode ? "Push and Create PR." : "git push.";
|
|
@@ -22712,6 +23702,10 @@ function isCommandVisible(command) {
|
|
|
22712
23702
|
return !featureId || isOptionalFeatureEnabled(featureId);
|
|
22713
23703
|
}
|
|
22714
23704
|
|
|
23705
|
+
function commandCatalogForTab(tabId = activeTabId) {
|
|
23706
|
+
return tabId ? commandCatalogsByTab.get(tabId) || { raw: [], available: [] } : { raw: [], available: [] };
|
|
23707
|
+
}
|
|
23708
|
+
|
|
22715
23709
|
function visibleCommands() {
|
|
22716
23710
|
return availableCommands.filter(isCommandVisible);
|
|
22717
23711
|
}
|
|
@@ -22733,34 +23727,24 @@ function canUseCommandBaseAlias(name) {
|
|
|
22733
23727
|
return availableCommands.some((command) => commandBaseName(command.name) === name && command.invokeName && command.duplicateCount > 1);
|
|
22734
23728
|
}
|
|
22735
23729
|
|
|
22736
|
-
function resolveAvailableCommand(name, { rpcOnly = false } = {}) {
|
|
22737
|
-
|
|
22738
|
-
if (!requested) return null;
|
|
22739
|
-
const commands = (rpcOnly ? rawAvailableCommands : availableCommands).filter((command) => !rpcOnly || command.source !== "native");
|
|
22740
|
-
const exact = commands.find((command) => command.name === requested || command.invokeName === requested || command.duplicateNames?.includes(requested));
|
|
22741
|
-
if (exact) return exact;
|
|
22742
|
-
if (!canUseCommandBaseAlias(requested)) return null;
|
|
22743
|
-
return commands.find((command) => commandNameMatches(command?.name, requested)) || null;
|
|
23730
|
+
function resolveAvailableCommand(name, { rpcOnly = false, tabId = activeTabId } = {}) {
|
|
23731
|
+
return resolveCommandForTabCatalog(commandCatalogForTab(tabId), name, { rpcOnly });
|
|
22744
23732
|
}
|
|
22745
23733
|
|
|
22746
23734
|
function resolveAvailableCommandName(name, options = {}) {
|
|
22747
23735
|
return resolveAvailableCommand(name, options)?.name || "";
|
|
22748
23736
|
}
|
|
22749
23737
|
|
|
22750
|
-
function resolveRpcSlashCommandMessage(message) {
|
|
22751
|
-
|
|
22752
|
-
const match = text.match(/^\/([^\s]+)([\s\S]*)$/);
|
|
22753
|
-
if (!match) return text;
|
|
22754
|
-
const resolvedName = resolveAvailableCommandName(match[1], { rpcOnly: true });
|
|
22755
|
-
return resolvedName && resolvedName !== match[1] ? `/${resolvedName}${match[2]}` : text;
|
|
23738
|
+
function resolveRpcSlashCommandMessage(message, { tabId = activeTabId } = {}) {
|
|
23739
|
+
return resolveRpcSlashCommandForTabCatalog(commandCatalogForTab(tabId), message);
|
|
22756
23740
|
}
|
|
22757
23741
|
|
|
22758
|
-
function hasAvailableCommand(name) {
|
|
22759
|
-
return !!resolveAvailableCommand(name);
|
|
23742
|
+
function hasAvailableCommand(name, options = {}) {
|
|
23743
|
+
return !!resolveAvailableCommand(name, options);
|
|
22760
23744
|
}
|
|
22761
23745
|
|
|
22762
|
-
function hasLoadedRpcCommand(name) {
|
|
22763
|
-
return !!resolveAvailableCommand(name, { rpcOnly: true });
|
|
23746
|
+
function hasLoadedRpcCommand(name, options = {}) {
|
|
23747
|
+
return !!resolveAvailableCommand(name, { ...options, rpcOnly: true });
|
|
22764
23748
|
}
|
|
22765
23749
|
|
|
22766
23750
|
function optionalFeatureUnavailableMessage(featureId) {
|
|
@@ -22936,6 +23920,7 @@ function updateOptionalFeatureAvailability() {
|
|
|
22936
23920
|
optionalFeatureAvailability.gitWorkflow = hasAvailableCommand("git-staged-msg");
|
|
22937
23921
|
optionalFeatureAvailability.releaseNpm = hasAvailableCommand("release-npm");
|
|
22938
23922
|
optionalFeatureAvailability.releaseAur = hasAvailableCommand("release-aur");
|
|
23923
|
+
optionalFeatureAvailability.aurReview = hasAvailableCommand("aur-review") || optionalFeatureAvailability.aurReview || widgets.has(AUR_REVIEW_RPC_WIDGET_KEY);
|
|
22939
23924
|
optionalFeatureAvailability.workflows = hasAvailableCommand("workflow") || hasAvailableCommand("workflow-clear") || optionalFeatureAvailability.workflows || widgets.has("workflow") || widgets.has("workflow:subprocess");
|
|
22940
23925
|
optionalFeatureAvailability.safetyGuard = hasAvailableCommand("safety-guard") || hasAvailableCommand("safety-guard-setup") || optionalFeatureAvailability.safetyGuard || statusEntries.has("safety-guard");
|
|
22941
23926
|
optionalFeatureAvailability.statsCommand = hasAvailableCommand("stats");
|
|
@@ -23004,6 +23989,7 @@ function optionalFeatureWidgetFeatureId(key) {
|
|
|
23004
23989
|
if (key.startsWith("btw:")) return "btwCommand";
|
|
23005
23990
|
if (key.startsWith("release-npm:")) return "releaseNpm";
|
|
23006
23991
|
if (key.startsWith("release-aur:")) return "releaseAur";
|
|
23992
|
+
if (key === AUR_REVIEW_RPC_WIDGET_KEY) return "aurReview";
|
|
23007
23993
|
if (key === "workflow" || key.startsWith("workflow:")) return "workflows";
|
|
23008
23994
|
if (key === "todo-progress") return "todoProgressWidget";
|
|
23009
23995
|
if (key === "pi-remote-webui") return "remoteWebui";
|
|
@@ -23011,7 +23997,7 @@ function optionalFeatureWidgetFeatureId(key) {
|
|
|
23011
23997
|
}
|
|
23012
23998
|
|
|
23013
23999
|
function optionalFeatureWidgetHasSpecializedRenderer(key) {
|
|
23014
|
-
return key.startsWith("btw:") || key.startsWith("release-npm:") || key.startsWith("release-aur:") || key === "workflow:subprocess" || key === WORKFLOW_INSPECTOR_WIDGET_KEY;
|
|
24000
|
+
return key.startsWith("btw:") || key.startsWith("release-npm:") || key.startsWith("release-aur:") || key === AUR_REVIEW_RPC_WIDGET_KEY || key === "workflow:subprocess" || key === WORKFLOW_INSPECTOR_WIDGET_KEY;
|
|
23015
24001
|
}
|
|
23016
24002
|
|
|
23017
24003
|
function renderOptionalFeaturePanel() {
|
|
@@ -26336,9 +27322,17 @@ function renderCommands() {
|
|
|
26336
27322
|
async function refreshCommands(tabContext = activeTabContext()) {
|
|
26337
27323
|
if (!tabContext.tabId) return;
|
|
26338
27324
|
const response = await api("/api/commands", { tabId: tabContext.tabId });
|
|
27325
|
+
const catalog = {
|
|
27326
|
+
raw: normalizeCommands(response.data?.commands || [], { dedupe: false }),
|
|
27327
|
+
available: normalizeCommands(response.data?.commands || []),
|
|
27328
|
+
};
|
|
27329
|
+
// Keep results for their originating tab even when the active tab changed
|
|
27330
|
+
// while this request was in flight. Guided Git must never borrow another
|
|
27331
|
+
// tab's extension availability or duplicate-command alias.
|
|
27332
|
+
commandCatalogsByTab.set(tabContext.tabId, catalog);
|
|
26339
27333
|
if (!isCurrentTabContext(tabContext)) return;
|
|
26340
|
-
rawAvailableCommands =
|
|
26341
|
-
availableCommands =
|
|
27334
|
+
rawAvailableCommands = catalog.raw;
|
|
27335
|
+
availableCommands = catalog.available;
|
|
26342
27336
|
updateOptionalFeatureAvailability();
|
|
26343
27337
|
renderCommands();
|
|
26344
27338
|
if (elements.commandPaletteDialog?.open) renderCommandPalette({ preserveScroll: true });
|
|
@@ -26979,7 +27973,9 @@ async function sendPrompt(kind = "prompt", explicitMessage, { targetTabId = acti
|
|
|
26979
27973
|
try {
|
|
26980
27974
|
const prepared = attachments.length ? await prepareAttachmentsForPrompt(attachments, targetTabId) : { images: [], uploadedFiles: [], inlineImageIds: new Set() };
|
|
26981
27975
|
message = composeMessageWithAttachments(originalMessage, prepared.uploadedFiles, prepared.inlineImageIds);
|
|
26982
|
-
|
|
27976
|
+
// Dispatch against the captured target tab, never the tab that happened
|
|
27977
|
+
// to become active while attachments/requests were resolving.
|
|
27978
|
+
if (kind === "prompt" && attachments.length === 0) message = resolveRpcSlashCommandMessage(message, { tabId: targetTabId });
|
|
26983
27979
|
const bodyBase = { message };
|
|
26984
27980
|
if (prepared.images.length) bodyBase.images = prepared.images;
|
|
26985
27981
|
if (!message.startsWith("/")) {
|
|
@@ -27118,6 +28114,16 @@ function handleExtensionUiRequest(request) {
|
|
|
27118
28114
|
renderWidgets();
|
|
27119
28115
|
return;
|
|
27120
28116
|
}
|
|
28117
|
+
if (widgetKey === AUR_REVIEW_RPC_WIDGET_KEY) {
|
|
28118
|
+
const payload = parseAurReviewPayload(request.widgetLines);
|
|
28119
|
+
if (payload) reconcileGuidedGitReviewPayload(requestTabId, payload);
|
|
28120
|
+
else if (!Array.isArray(request.widgetLines)) reconcileGuidedGitReviewWidgetRemoval(requestTabId);
|
|
28121
|
+
if (!setWidgetForTab(requestTabId, widgetKey, request)) return;
|
|
28122
|
+
updateOptionalFeatureAvailability();
|
|
28123
|
+
renderTabs();
|
|
28124
|
+
renderWidgets();
|
|
28125
|
+
return;
|
|
28126
|
+
}
|
|
27121
28127
|
if (widgetKey === "pi-remote-webui") {
|
|
27122
28128
|
setWidgetForTab(requestTabId, widgetKey, { ...request, widgetLines: undefined });
|
|
27123
28129
|
if (Array.isArray(request.widgetLines)) {
|
|
@@ -27270,6 +28276,13 @@ function handleInactiveTabEvent(event) {
|
|
|
27270
28276
|
if (inspector) updateWorkflowInspectorForTab(event.tabId, inspector);
|
|
27271
28277
|
setWidgetForTab(event.tabId, WORKFLOW_INSPECTOR_WIDGET_KEY, event);
|
|
27272
28278
|
renderTabs();
|
|
28279
|
+
} else if (event.type === "extension_ui_request" && event.method === "setWidget" && (event.widgetKey || event.id) === AUR_REVIEW_RPC_WIDGET_KEY) {
|
|
28280
|
+
const payload = parseAurReviewPayload(event.widgetLines);
|
|
28281
|
+
if (payload) reconcileGuidedGitReviewPayload(event.tabId, payload);
|
|
28282
|
+
else if (!Array.isArray(event.widgetLines)) reconcileGuidedGitReviewWidgetRemoval(event.tabId);
|
|
28283
|
+
setWidgetForTab(event.tabId, AUR_REVIEW_RPC_WIDGET_KEY, event);
|
|
28284
|
+
updateOptionalFeatureAvailability();
|
|
28285
|
+
renderTabs();
|
|
27273
28286
|
} else if (event.type === "agent_end") {
|
|
27274
28287
|
notifyAgentDone(event.tabId, { activity: event.tabActivity, tabTitle: event.tabTitle });
|
|
27275
28288
|
}
|
|
@@ -27401,6 +28414,10 @@ function handleEvent(event) {
|
|
|
27401
28414
|
case "pi_stderr":
|
|
27402
28415
|
addEvent(event.text.trim(), "warn");
|
|
27403
28416
|
break;
|
|
28417
|
+
case "pi_stderr_sink_error":
|
|
28418
|
+
case "pi_stdout_line_too_large":
|
|
28419
|
+
addEvent(event.error || "Pi RPC transport diagnostic", "error");
|
|
28420
|
+
break;
|
|
27404
28421
|
case "queue_update":
|
|
27405
28422
|
renderQueue(event);
|
|
27406
28423
|
scheduleRefreshState();
|
|
@@ -28000,6 +29017,19 @@ elements.confirmationDialog?.addEventListener("cancel", (event) => {
|
|
|
28000
29017
|
elements.confirmationDialog?.addEventListener("close", () => {
|
|
28001
29018
|
if (activeConfirmationResolve) finishApplicationConfirmation(false);
|
|
28002
29019
|
});
|
|
29020
|
+
elements.gitWorktreeBaseCancelButton?.addEventListener("click", () => finishGitWorktreeBaseChoice(null));
|
|
29021
|
+
elements.gitWorktreeBaseCreateButton?.addEventListener("click", () => finishGitWorktreeBaseChoice(elements.gitWorktreeBaseCurrentHead?.checked ? "HEAD" : "origin/main"));
|
|
29022
|
+
elements.gitWorktreeBaseDialog?.querySelector("form")?.addEventListener("submit", (event) => {
|
|
29023
|
+
event.preventDefault();
|
|
29024
|
+
finishGitWorktreeBaseChoice(elements.gitWorktreeBaseCurrentHead?.checked ? "HEAD" : "origin/main");
|
|
29025
|
+
});
|
|
29026
|
+
elements.gitWorktreeBaseDialog?.addEventListener("cancel", (event) => {
|
|
29027
|
+
event.preventDefault();
|
|
29028
|
+
finishGitWorktreeBaseChoice(null);
|
|
29029
|
+
});
|
|
29030
|
+
elements.gitWorktreeBaseDialog?.addEventListener("close", () => {
|
|
29031
|
+
if (activeGitWorktreeBaseResolve) finishGitWorktreeBaseChoice(null);
|
|
29032
|
+
});
|
|
28003
29033
|
elements.commandPaletteDialog?.querySelector("form")?.addEventListener("submit", (event) => event.preventDefault());
|
|
28004
29034
|
elements.commandPaletteDialog?.addEventListener("cancel", (event) => {
|
|
28005
29035
|
event.preventDefault();
|
|
@@ -28404,6 +29434,15 @@ if (elements.terminalTabsLayoutSelect) {
|
|
|
28404
29434
|
setTerminalTabsLayout(elements.terminalTabsLayoutSelect.value, { announce: true });
|
|
28405
29435
|
});
|
|
28406
29436
|
}
|
|
29437
|
+
if (elements.subagentOpenModeSelect) {
|
|
29438
|
+
elements.subagentOpenModeSelect.addEventListener("change", () => {
|
|
29439
|
+
setSubagentOpenMode(elements.subagentOpenModeSelect.value, { announce: true });
|
|
29440
|
+
});
|
|
29441
|
+
}
|
|
29442
|
+
elements.subagentTerminalCopyButton?.addEventListener("click", () => copySubagentTerminalOutput());
|
|
29443
|
+
elements.subagentTerminalRefreshButton?.addEventListener("click", () => {
|
|
29444
|
+
refreshSubagentTerminalView(activeSubagentTerminalId, { showLoading: true }).finally(() => scheduleSubagentTerminalRefresh());
|
|
29445
|
+
});
|
|
28407
29446
|
elements.piVersionButton?.addEventListener("click", () => {
|
|
28408
29447
|
openPiReleaseNotes().catch((error) => addEvent(error.message || String(error), "error"));
|
|
28409
29448
|
});
|
|
@@ -29013,6 +30052,7 @@ initializeFastPicks().catch((error) => addEvent(`failed to initialize path fast
|
|
|
29013
30052
|
restoreAgentDoneNotificationsSetting();
|
|
29014
30053
|
restoreThinkingVisibilitySetting();
|
|
29015
30054
|
restoreTerminalTabsLayoutSetting();
|
|
30055
|
+
restoreSubagentOpenModeSetting();
|
|
29016
30056
|
restoreTerminalCustomGroups();
|
|
29017
30057
|
restoreToolOutputExpansionSetting();
|
|
29018
30058
|
restoreWorkspaceDashboardState();
|