@firstpick/pi-package-webui 0.7.7 → 0.7.8

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/public/app.js CHANGED
@@ -5,6 +5,8 @@ import { createFastOutputLiveState, createSustainedFlushScheduler, fastOutputLiv
5
5
  import { addLaunchSlot, cloneLaunchSlotRoles, launchSlotRolesEqual, removeLaunchSlot, updateLaunchSlot } from "./subagent-launch-slot-state.mjs";
6
6
  import { pruneDismissedSubagentGateKeys, subagentGateIsTerminal, subagentGateKey, visibleSubagentGates } from "./subagent-gate-visibility.mjs";
7
7
  import { groupConsecutiveWorkflowStatusItems, isCompletedWorkflowStatusExecution, workflowStatusSnapshot } from "./workflow-status-stack.mjs";
8
+ import { buildIssuePayload, createIssueWizardCatalog, createIssueWizardState, getCompatibleTemplates, isIssueWizardStepValid, issueClipboardText, reduceIssueWizardState } from "./issue-wizard-state.mjs";
9
+ import { createIssueBotClient, readIssueBotRuntimeConfig } from "./issue-bot-client.mjs";
8
10
 
9
11
  const $ = (selector) => document.querySelector(selector);
10
12
 
@@ -244,6 +246,24 @@ const elements = {
244
246
  sidePanelExpandButton: $("#sidePanelExpandButton"),
245
247
  sidePanelBackdrop: $("#sidePanelBackdrop"),
246
248
  sidePanel: $("#sidePanel"),
249
+ openIssueButton: $("#openIssueButton"),
250
+ issueWizardDialog: $("#issueWizardDialog"),
251
+ issueWizardPages: $("#issueWizardPages"),
252
+ issueWizardProgress: $("#issueWizardProgress"),
253
+ issueWizardStatus: $("#issueWizardStatus"),
254
+ issueWizardSubmissionStatus: $("#issueWizardSubmissionStatus"),
255
+ issueWizardSubmissionMessage: $("#issueWizardSubmissionMessage"),
256
+ issueWizardSubmissionLink: $("#issueWizardSubmissionLink"),
257
+ issueWizardRefreshButton: $("#issueWizardRefreshButton"),
258
+ issueWizardSecurityGuidance: $("#issueWizardSecurityGuidance"),
259
+ issueWizardSecurityLink: $("#issueWizardSecurityLink"),
260
+ issueWizardTurnstile: $("#issueWizardTurnstile"),
261
+ issueWizardCloseButton: $("#issueWizardCloseButton"),
262
+ issueWizardBackButton: $("#issueWizardBackButton"),
263
+ issueWizardContinueButton: $("#issueWizardContinueButton"),
264
+ issueWizardCopyButton: $("#issueWizardCopyButton"),
265
+ issueWizardBotButton: $("#issueWizardBotButton"),
266
+ issueWizardBotHint: $("#issueWizardBotHint"),
247
267
  stateDetails: $("#stateDetails"),
248
268
  subagentsStatus: $("#subagentsStatus"),
249
269
  subagentsBox: $("#subagentsBox"),
@@ -713,6 +733,8 @@ const GIT_FOOTER_WEBUI_STATUS_KEY = "git-footer-webui";
713
733
  const GIT_FOOTER_WEBUI_PAYLOAD_TYPE = "firstpick.git-footer-status.footer";
714
734
  const GIT_FOOTER_WEBUI_PAYLOAD_VERSION = 1;
715
735
  const GIT_FOOTER_WEBUI_PAYLOAD_CACHE_KEY = "pi-webui-git-footer-webui-payload-cache";
736
+ const GIT_FOOTER_PAYLOAD_REQUEST_TIMEOUT_MS = 10_000;
737
+ const GIT_FOOTER_PAYLOAD_SETTLEMENT_TIMEOUT_MS = 2_000;
716
738
  const GIT_FOOTER_STATUS_SETUP_STORAGE_KEY = "pi-webui-git-footer-status-setup";
717
739
  const GIT_FOOTER_WEBUI_VISIBILITY_DEFAULTS = Object.freeze({
718
740
  tokens: true,
@@ -1067,6 +1089,389 @@ const OPTIONAL_FEATURES = [
1067
1089
  },
1068
1090
  ];
1069
1091
  const OPTIONAL_FEATURE_BY_ID = new Map(OPTIONAL_FEATURES.map((feature) => [feature.id, feature]));
1092
+
1093
+ let issueWizardCatalog = null;
1094
+ let issueWizardState = createIssueWizardState();
1095
+ const issueBotRuntimeConfig = readIssueBotRuntimeConfig();
1096
+ let issueBotClient = null;
1097
+ let issueBotAbortController = null;
1098
+ let issueBotSubmissionHandle = null;
1099
+ let issueBotSubmissionResult = null;
1100
+ let issueBotRequestActive = false;
1101
+
1102
+ function setIssueWizardStatus(message) {
1103
+ if (elements.issueWizardStatus) elements.issueWizardStatus.textContent = message;
1104
+ }
1105
+
1106
+ function issueWizardPage(step) {
1107
+ return elements.issueWizardPages?.querySelector(`[data-issue-wizard-page="${step}"]`) || null;
1108
+ }
1109
+
1110
+ function issueWizardChoiceButton({ label, description = "", preview = "", selected, action, value, group }) {
1111
+ const button = make("button", "issue-wizard-choice");
1112
+ button.type = "button";
1113
+ button.dataset.issueWizardAction = action;
1114
+ button.dataset.issueWizardValue = value;
1115
+ button.dataset.issueWizardGroup = group;
1116
+ button.setAttribute("aria-pressed", selected ? "true" : "false");
1117
+ button.classList.toggle("selected", selected);
1118
+ button.append(make("strong", undefined, label));
1119
+ if (description) button.append(make("span", "issue-wizard-choice-description", description));
1120
+ if (preview) button.append(make("span", "issue-wizard-choice-preview", preview));
1121
+ return button;
1122
+ }
1123
+
1124
+ function focusIssueWizardChoice(action, value) {
1125
+ queueMicrotask(() => {
1126
+ const buttons = issueWizardPage(issueWizardState.step)?.querySelectorAll(`[data-issue-wizard-action="${action}"]`) || [];
1127
+ const target = Array.from(buttons).find((button) => button.dataset.issueWizardValue === value);
1128
+ target?.focus({ preventScroll: true });
1129
+ });
1130
+ }
1131
+
1132
+ function focusIssueWizardPage() {
1133
+ queueMicrotask(() => {
1134
+ const page = issueWizardPage(issueWizardState.step);
1135
+ const target = page?.querySelector('[aria-pressed="true"], button, select, textarea');
1136
+ target?.focus({ preventScroll: true });
1137
+ });
1138
+ }
1139
+
1140
+ function renderIssueWizardChoices(page, items, { selectedId, action, group, emptyMessage }) {
1141
+ const choices = make("div", "issue-wizard-choice-grid");
1142
+ choices.setAttribute("role", "group");
1143
+ choices.setAttribute("aria-label", group);
1144
+ if (!items.length) {
1145
+ choices.append(make("p", "issue-wizard-empty muted", emptyMessage));
1146
+ } else {
1147
+ for (const item of items) {
1148
+ const preview = action === "select-template" && item.fields?.length
1149
+ ? `Includes: ${item.fields.map((field) => field.label).join(" · ")}`
1150
+ : "";
1151
+ const button = issueWizardChoiceButton({ label: item.label, description: item.description, preview, selected: item.id === selectedId, action, value: item.id, group });
1152
+ button.addEventListener("click", () => {
1153
+ issueWizardState = reduceIssueWizardState(issueWizardState, { type: action, [`${action.split("-")[1]}Id`]: item.id }, issueWizardCatalog);
1154
+ renderIssueWizard();
1155
+ focusIssueWizardChoice(action, item.id);
1156
+ });
1157
+ choices.append(button);
1158
+ }
1159
+ }
1160
+ page.append(choices);
1161
+ }
1162
+
1163
+ function renderIssueWizardDetails(page) {
1164
+ const template = issueWizardCatalog.templates.find((item) => item.id === issueWizardState.templateId);
1165
+ if (!template) {
1166
+ page.append(make("p", "issue-wizard-empty muted", "Choose a compatible template before adding details."));
1167
+ return;
1168
+ }
1169
+ const summary = make("textarea", "issue-wizard-textarea");
1170
+ summary.id = "issueWizardSummary";
1171
+ summary.rows = 2;
1172
+ summary.maxLength = 160;
1173
+ summary.value = issueWizardState.summary;
1174
+ summary.placeholder = "Short summary";
1175
+ summary.setAttribute("aria-describedby", "issueWizardSummaryHint");
1176
+ summary.addEventListener("input", () => {
1177
+ issueWizardState = reduceIssueWizardState(issueWizardState, { type: "set-summary", summary: summary.value }, issueWizardCatalog);
1178
+ renderIssueWizardNavigation();
1179
+ });
1180
+ const summaryLabel = make("label", "issue-wizard-field");
1181
+ summaryLabel.htmlFor = summary.id;
1182
+ summaryLabel.append(make("span", "issue-wizard-field-label", "Short summary"), summary, make("small", "muted", "Required. This completes the GitHub issue title."));
1183
+ summaryLabel.lastElementChild.id = "issueWizardSummaryHint";
1184
+ page.append(summaryLabel);
1185
+
1186
+ for (const field of template.fields) {
1187
+ const fieldWrap = make("div", "issue-wizard-field");
1188
+ const label = make("span", "issue-wizard-field-label", field.label);
1189
+ label.id = `issueWizardFieldLabel-${field.id}`;
1190
+ fieldWrap.append(label);
1191
+ if (field.kind === "textarea") {
1192
+ const input = make("textarea", "issue-wizard-textarea");
1193
+ input.rows = 4;
1194
+ input.value = issueWizardState.fields[field.id] || "";
1195
+ input.setAttribute("aria-labelledby", label.id);
1196
+ input.addEventListener("input", () => {
1197
+ issueWizardState = reduceIssueWizardState(issueWizardState, { type: "set-field", fieldId: field.id, value: input.value }, issueWizardCatalog);
1198
+ renderIssueWizardNavigation();
1199
+ });
1200
+ fieldWrap.append(input);
1201
+ } else if (field.kind === "select") {
1202
+ const select = make("select", "issue-wizard-select");
1203
+ select.setAttribute("aria-labelledby", label.id);
1204
+ const placeholder = make("option", undefined, "Choose one…");
1205
+ placeholder.value = "";
1206
+ select.append(placeholder);
1207
+ for (const option of field.options || []) {
1208
+ const item = make("option", undefined, option.label);
1209
+ item.value = option.id;
1210
+ item.selected = issueWizardState.fields[field.id] === option.id;
1211
+ select.append(item);
1212
+ }
1213
+ select.addEventListener("change", () => {
1214
+ issueWizardState = reduceIssueWizardState(issueWizardState, { type: "set-field", fieldId: field.id, value: select.value }, issueWizardCatalog);
1215
+ renderIssueWizardNavigation();
1216
+ });
1217
+ fieldWrap.append(select);
1218
+ } else {
1219
+ const choices = make("div", "issue-wizard-inline-choices");
1220
+ choices.setAttribute("role", "group");
1221
+ choices.setAttribute("aria-labelledby", label.id);
1222
+ for (const option of field.options || []) {
1223
+ const button = issueWizardChoiceButton({ label: option.label, selected: issueWizardState.fields[field.id] === option.id, action: "set-field", value: option.id, group: field.label });
1224
+ button.addEventListener("click", () => {
1225
+ issueWizardState = reduceIssueWizardState(issueWizardState, { type: "set-field", fieldId: field.id, value: option.id }, issueWizardCatalog);
1226
+ renderIssueWizard();
1227
+ focusIssueWizardChoice("set-field", option.id);
1228
+ });
1229
+ choices.append(button);
1230
+ }
1231
+ fieldWrap.append(choices);
1232
+ }
1233
+ page.append(fieldWrap);
1234
+ }
1235
+ }
1236
+
1237
+ function renderIssueWizardReview(page) {
1238
+ let payload;
1239
+ try {
1240
+ payload = buildIssuePayload(issueWizardState, issueWizardCatalog);
1241
+ } catch {
1242
+ page.append(make("p", "issue-wizard-empty muted", "Complete the required details to preview the issue."));
1243
+ return;
1244
+ }
1245
+ const title = make("textarea", "issue-wizard-preview-title");
1246
+ title.readOnly = true;
1247
+ title.rows = 2;
1248
+ title.value = payload.title;
1249
+ title.setAttribute("aria-label", "GitHub issue title preview");
1250
+ const body = make("textarea", "issue-wizard-preview-body");
1251
+ body.readOnly = true;
1252
+ body.rows = 12;
1253
+ body.value = payload.body;
1254
+ body.setAttribute("aria-label", "GitHub issue Markdown body preview");
1255
+ const titleWrap = make("label", "issue-wizard-preview");
1256
+ titleWrap.append(make("span", "issue-wizard-field-label", "GitHub issue title"), title);
1257
+ const bodyWrap = make("label", "issue-wizard-preview");
1258
+ bodyWrap.append(make("span", "issue-wizard-field-label", "GitHub issue Markdown body"), body);
1259
+ page.append(titleWrap, bodyWrap);
1260
+ }
1261
+
1262
+ function issueBotMessage(result) {
1263
+ if (result?.phase === "admitting") return "Verifying bot protection and submitting the structured report…";
1264
+ switch (result?.status) {
1265
+ case "queued": return result.timedOut ? "The report is still queued. Refresh status when you are ready." : "The report is queued for automated checks…";
1266
+ case "checking": return result.timedOut ? "The report is still being checked. Refresh status when you are ready." : "The report is being checked…";
1267
+ case "created": return `GitHub issue #${result.issueNumber} was created.`;
1268
+ case "rejected": return "This report was not accepted for automated public issue creation. You can still copy it and create an issue manually.";
1269
+ case "review": return "This report needs manual review and was not published automatically. You can still copy it and create an issue manually.";
1270
+ case "unknown": return "The creation result is unknown; no further automatic issue creation will be attempted. You can copy the issue instead.";
1271
+ default: return "Automated submission is unavailable. You can still copy the complete issue.";
1272
+ }
1273
+ }
1274
+
1275
+ function renderIssueWizardSubmissionStatus() {
1276
+ const result = issueBotSubmissionResult;
1277
+ if (elements.issueWizardSubmissionStatus) elements.issueWizardSubmissionStatus.hidden = !result;
1278
+ if (elements.issueWizardSubmissionMessage) elements.issueWizardSubmissionMessage.textContent = result ? issueBotMessage(result) : "";
1279
+ const created = result?.status === "created" && typeof result.issueUrl === "string";
1280
+ if (elements.issueWizardSubmissionLink) {
1281
+ elements.issueWizardSubmissionLink.hidden = !created;
1282
+ elements.issueWizardSubmissionLink.href = created ? result.issueUrl : "";
1283
+ elements.issueWizardSubmissionLink.textContent = created ? "View confirmed GitHub issue" : "";
1284
+ }
1285
+ const showRefresh = !!result?.timedOut && !!issueBotSubmissionHandle;
1286
+ if (elements.issueWizardRefreshButton) {
1287
+ elements.issueWizardRefreshButton.hidden = !showRefresh;
1288
+ elements.issueWizardRefreshButton.disabled = issueBotRequestActive;
1289
+ }
1290
+ const sensitive = result?.reasonCode === "sensitive_content";
1291
+ const hasPrivateReportUrl = !!issueBotRuntimeConfig.privateSecurityReportUrl;
1292
+ if (elements.issueWizardSecurityGuidance) elements.issueWizardSecurityGuidance.hidden = !sensitive || !hasPrivateReportUrl;
1293
+ if (elements.issueWizardSecurityLink) {
1294
+ elements.issueWizardSecurityLink.hidden = !sensitive || !hasPrivateReportUrl;
1295
+ elements.issueWizardSecurityLink.href = sensitive && hasPrivateReportUrl ? issueBotRuntimeConfig.privateSecurityReportUrl : "";
1296
+ }
1297
+ }
1298
+
1299
+ function renderIssueWizardNavigation() {
1300
+ const step = issueWizardState.step;
1301
+ const botAvailable = !!issueBotClient?.available;
1302
+ if (elements.issueWizardProgress) elements.issueWizardProgress.textContent = `Step ${step} of 5`;
1303
+ if (elements.issueWizardBackButton) elements.issueWizardBackButton.disabled = step === 1 || issueBotRequestActive;
1304
+ if (elements.issueWizardContinueButton) {
1305
+ elements.issueWizardContinueButton.hidden = step === 5;
1306
+ elements.issueWizardContinueButton.disabled = issueBotRequestActive || !isIssueWizardStepValid(issueWizardState, issueWizardCatalog, step);
1307
+ elements.issueWizardContinueButton.textContent = step === 4 ? "Review issue" : "Continue";
1308
+ }
1309
+ if (elements.issueWizardCopyButton) elements.issueWizardCopyButton.hidden = step !== 5;
1310
+ if (elements.issueWizardBotButton) {
1311
+ elements.issueWizardBotButton.hidden = step !== 5;
1312
+ elements.issueWizardBotButton.disabled = !botAvailable || issueBotRequestActive;
1313
+ elements.issueWizardBotButton.textContent = issueBotRequestActive ? "Checking issue status…" : "Send";
1314
+ }
1315
+ if (elements.issueWizardBotHint) {
1316
+ elements.issueWizardBotHint.hidden = step !== 5;
1317
+ elements.issueWizardBotHint.textContent = botAvailable
1318
+ ? "The bot submits only the structured wizard state. Keep private security details out of public reports."
1319
+ : "Automated submission is not enabled. Copy the issue and create it manually instead.";
1320
+ }
1321
+ renderIssueWizardSubmissionStatus();
1322
+ setIssueWizardStatus(`Step ${step} of 5.`);
1323
+ }
1324
+
1325
+ function renderIssueWizard() {
1326
+ if (!issueWizardCatalog || !elements.issueWizardPages) return;
1327
+ for (let step = 1; step <= 5; step += 1) {
1328
+ const page = issueWizardPage(step);
1329
+ if (!page) continue;
1330
+ page.hidden = step !== issueWizardState.step;
1331
+ page.replaceChildren();
1332
+ }
1333
+ const page = issueWizardPage(issueWizardState.step);
1334
+ if (!page) return;
1335
+ if (issueWizardState.step === 1) {
1336
+ page.append(make("p", "issue-wizard-intro", "What kind of issue would you like to report?"));
1337
+ renderIssueWizardChoices(page, issueWizardCatalog.categories, { selectedId: issueWizardState.categoryId, action: "select-category", group: "Issue category", emptyMessage: "No categories are available." });
1338
+ } else if (issueWizardState.step === 2) {
1339
+ page.append(make("p", "issue-wizard-intro", "Which part of Pi Web UI is affected?"));
1340
+ renderIssueWizardChoices(page, issueWizardCatalog.components, { selectedId: issueWizardState.componentId, action: "select-component", group: "Affected component", emptyMessage: "No components are available." });
1341
+ } else if (issueWizardState.step === 3) {
1342
+ page.append(make("p", "issue-wizard-intro", "Choose the structured template that best matches this issue."));
1343
+ renderIssueWizardChoices(page, getCompatibleTemplates(issueWizardCatalog, issueWizardState.categoryId, issueWizardState.componentId), { selectedId: issueWizardState.templateId, action: "select-template", group: "Issue template", emptyMessage: "Choose a category and component first." });
1344
+ } else if (issueWizardState.step === 4) {
1345
+ page.append(make("p", "issue-wizard-intro", "Add the details needed for a clear, actionable issue."));
1346
+ renderIssueWizardDetails(page);
1347
+ } else {
1348
+ page.append(make("p", "issue-wizard-intro", "Review the exact GitHub title and Markdown body before copying or submitting."));
1349
+ renderIssueWizardReview(page);
1350
+ }
1351
+ renderIssueWizardNavigation();
1352
+ }
1353
+
1354
+ async function copyIssueWizardPayload() {
1355
+ try {
1356
+ const payload = buildIssuePayload(issueWizardState, issueWizardCatalog);
1357
+ await copyText(issueClipboardText(payload));
1358
+ setIssueWizardStatus("Complete issue copied. Paste it into a new GitHub issue.");
1359
+ } catch {
1360
+ setIssueWizardStatus("Could not copy the issue. Select the preview text and copy it manually.");
1361
+ }
1362
+ }
1363
+
1364
+ function structuredIssueWizardState() {
1365
+ return {
1366
+ categoryId: issueWizardState.categoryId,
1367
+ componentId: issueWizardState.componentId,
1368
+ templateId: issueWizardState.templateId,
1369
+ summary: issueWizardState.summary,
1370
+ fields: { ...issueWizardState.fields },
1371
+ };
1372
+ }
1373
+
1374
+ function reportIssueBotStatus(result) {
1375
+ issueBotSubmissionResult = result;
1376
+ renderIssueWizardSubmissionStatus();
1377
+ }
1378
+
1379
+ function clearIssueBotSubmission({ abort = false } = {}) {
1380
+ if (abort) issueBotAbortController?.abort();
1381
+ issueBotAbortController = null;
1382
+ issueBotSubmissionHandle = null;
1383
+ issueBotSubmissionResult = null;
1384
+ issueBotRequestActive = false;
1385
+ elements.issueWizardTurnstile?.replaceChildren();
1386
+ renderIssueWizardSubmissionStatus();
1387
+ }
1388
+
1389
+ async function sendIssueToGithubBot() {
1390
+ if (!issueBotClient?.available || issueBotRequestActive) return;
1391
+ try {
1392
+ // Preserve the existing canonical builder as the review/copy authority, but never send title/body to the gateway.
1393
+ buildIssuePayload(issueWizardState, issueWizardCatalog);
1394
+ } catch {
1395
+ setIssueWizardStatus("Complete the required wizard details before submitting.");
1396
+ return;
1397
+ }
1398
+ const controller = new AbortController();
1399
+ issueBotAbortController = controller;
1400
+ issueBotRequestActive = true;
1401
+ issueBotSubmissionHandle = null;
1402
+ reportIssueBotStatus(Object.freeze({ status: "checking", phase: "admitting" }));
1403
+ renderIssueWizardNavigation();
1404
+ try {
1405
+ const submission = await issueBotClient.submit({
1406
+ issue: structuredIssueWizardState(),
1407
+ signal: controller.signal,
1408
+ onStatus: reportIssueBotStatus,
1409
+ });
1410
+ if (controller.signal.aborted || issueBotAbortController !== controller) return;
1411
+ issueBotSubmissionHandle = submission.handle;
1412
+ reportIssueBotStatus(submission.result);
1413
+ } catch (error) {
1414
+ if (error?.name !== "AbortError" && issueBotAbortController === controller) {
1415
+ reportIssueBotStatus(Object.freeze({ ok: false, status: "unavailable", reasonCode: "unavailable" }));
1416
+ }
1417
+ } finally {
1418
+ if (issueBotAbortController !== controller) return;
1419
+ issueBotAbortController = null;
1420
+ issueBotRequestActive = false;
1421
+ renderIssueWizardNavigation();
1422
+ }
1423
+ }
1424
+
1425
+ async function refreshIssueBotStatus() {
1426
+ if (!issueBotSubmissionHandle || issueBotRequestActive) return;
1427
+ const controller = new AbortController();
1428
+ issueBotAbortController = controller;
1429
+ issueBotRequestActive = true;
1430
+ renderIssueWizardNavigation();
1431
+ try {
1432
+ const result = await issueBotSubmissionHandle.refresh({ signal: controller.signal, onStatus: reportIssueBotStatus });
1433
+ if (!controller.signal.aborted && issueBotAbortController === controller) reportIssueBotStatus(result);
1434
+ } catch (error) {
1435
+ if (error?.name !== "AbortError" && issueBotAbortController === controller) {
1436
+ reportIssueBotStatus(Object.freeze({ ok: false, status: "unavailable", reasonCode: "unavailable" }));
1437
+ }
1438
+ } finally {
1439
+ if (issueBotAbortController !== controller) return;
1440
+ issueBotAbortController = null;
1441
+ issueBotRequestActive = false;
1442
+ renderIssueWizardNavigation();
1443
+ }
1444
+ }
1445
+
1446
+ function initializeIssueWizard() {
1447
+ if (!elements.openIssueButton || !elements.issueWizardDialog) return;
1448
+ issueWizardCatalog = createIssueWizardCatalog(OPTIONAL_FEATURES.map((feature) => feature.label));
1449
+ issueBotClient = createIssueBotClient({ config: issueBotRuntimeConfig, turnstileContainer: elements.issueWizardTurnstile });
1450
+ elements.openIssueButton.addEventListener("click", () => {
1451
+ clearIssueBotSubmission({ abort: true });
1452
+ issueWizardState = createIssueWizardState();
1453
+ renderIssueWizard();
1454
+ if (!elements.issueWizardDialog.open) elements.issueWizardDialog.showModal();
1455
+ queueMicrotask(() => issueWizardPage(1)?.querySelector("button")?.focus({ preventScroll: true }));
1456
+ });
1457
+ elements.issueWizardCloseButton?.addEventListener("click", () => elements.issueWizardDialog.close());
1458
+ elements.issueWizardDialog.addEventListener("close", () => clearIssueBotSubmission({ abort: true }));
1459
+ elements.issueWizardBackButton?.addEventListener("click", () => {
1460
+ if (issueBotRequestActive) return;
1461
+ issueWizardState = reduceIssueWizardState(issueWizardState, { type: "back" }, issueWizardCatalog);
1462
+ renderIssueWizard();
1463
+ focusIssueWizardPage();
1464
+ });
1465
+ elements.issueWizardContinueButton?.addEventListener("click", () => {
1466
+ if (issueBotRequestActive) return;
1467
+ issueWizardState = reduceIssueWizardState(issueWizardState, { type: "next" }, issueWizardCatalog);
1468
+ renderIssueWizard();
1469
+ focusIssueWizardPage();
1470
+ });
1471
+ elements.issueWizardCopyButton?.addEventListener("click", () => copyIssueWizardPayload());
1472
+ elements.issueWizardBotButton?.addEventListener("click", () => sendIssueToGithubBot());
1473
+ elements.issueWizardRefreshButton?.addEventListener("click", () => refreshIssueBotStatus());
1474
+ }
1070
1475
  const OPTIONAL_FEATURE_SECTIONS = [
1071
1476
  {
1072
1477
  id: "composer-commands",
@@ -1162,6 +1567,9 @@ const optionalFeatureInstallStates = new Map();
1162
1567
  const optionalFeatureInstallProgressTimers = new Map();
1163
1568
  let optionalFeaturePackageStatusError = "";
1164
1569
  const gitFooterPayloadRefreshInFlightByTab = new Set();
1570
+ const gitFooterPayloadStateByTab = new Map();
1571
+ const gitFooterPayloadSettlementTimersByTab = new Map();
1572
+ const gitFooterPayloadRequestSerialByTab = new Map();
1165
1573
  const gitFooterSyncPushInFlightByTab = new Set();
1166
1574
  const gitFooterPiCalibrationInFlightByTab = new Set();
1167
1575
  let gitFooterVisibilityApplyInFlight = false;
@@ -3642,9 +4050,12 @@ function triggerNativeDownload(download) {
3642
4050
  anchor.rel = "noopener";
3643
4051
  anchor.hidden = true;
3644
4052
  document.body.append(anchor);
3645
- anchor.click();
3646
- anchor.remove();
3647
- return true;
4053
+ try {
4054
+ anchor.click();
4055
+ return true;
4056
+ } finally {
4057
+ anchor.remove();
4058
+ }
3648
4059
  }
3649
4060
 
3650
4061
  function isStandalonePwaWindow() {
@@ -3692,9 +4103,12 @@ function openNativeDownloadInBrowser(download) {
3692
4103
  anchor.rel = "noopener";
3693
4104
  anchor.hidden = true;
3694
4105
  document.body.append(anchor);
3695
- anchor.click();
3696
- anchor.remove();
3697
- return true;
4106
+ try {
4107
+ anchor.click();
4108
+ return true;
4109
+ } finally {
4110
+ anchor.remove();
4111
+ }
3698
4112
  }
3699
4113
 
3700
4114
  function openNativeExportDownloadPrompt(download, serverPath = "") {
@@ -5932,6 +6346,7 @@ function setOptionalFeatureDisabled(featureId, disabled) {
5932
6346
  if (featureId === "gitFooterStatus") {
5933
6347
  statusEntries.delete(GIT_FOOTER_WEBUI_STATUS_KEY);
5934
6348
  clearGitFooterWebuiPayloadCache();
6349
+ for (const tabId of new Set([...gitFooterPayloadStateByTab.keys(), ...gitFooterPayloadSettlementTimersByTab.keys(), ...gitFooterPayloadRefreshInFlightByTab])) clearGitFooterPayloadState(tabId);
5935
6350
  }
5936
6351
  if (featureId === "btwCommand") {
5937
6352
  statusEntries.delete(BTW_WEBUI_STATUS_KEY);
@@ -8104,6 +8519,7 @@ function normalizeTabActivity(activity = {}) {
8104
8519
  ...activity,
8105
8520
  status,
8106
8521
  isWorking: status === "working",
8522
+ runStarted: activity.runStarted === true,
8107
8523
  completionSerial: Number.isFinite(completionSerial) ? completionSerial : 0,
8108
8524
  };
8109
8525
  }
@@ -8135,7 +8551,7 @@ function decrementTabPendingBlockerCount(tabId) {
8135
8551
  }
8136
8552
 
8137
8553
  function tabActivityStateChanged(previous, next) {
8138
- return !previous || previous.status !== next.status || previous.isWorking !== next.isWorking || previous.completionSerial !== next.completionSerial;
8554
+ return !previous || previous.status !== next.status || previous.isWorking !== next.isWorking || previous.runStarted !== next.runStarted || previous.completionSerial !== next.completionSerial;
8139
8555
  }
8140
8556
 
8141
8557
  function setTabActivity(tabId, activity = {}) {
@@ -8184,6 +8600,8 @@ function syncTabMetadata(nextTabs = []) {
8184
8600
  if (voiceConversationTabId === tabId) stopVoiceConversationLoop();
8185
8601
  clearGitWorkflowForTab(tabId);
8186
8602
  commandCatalogsByTab.delete(tabId);
8603
+ clearGitFooterPayloadState(tabId);
8604
+ gitFooterPayloadRequestSerialByTab.delete(tabId);
8187
8605
  }
8188
8606
  }
8189
8607
  for (const tabId of tabMessagesCache.keys()) {
@@ -8277,12 +8695,20 @@ function syncTabPolling() {
8277
8695
  }
8278
8696
  }
8279
8697
 
8280
- function markTabWorkingLocally(tabId = activeTabId) {
8698
+ function markTabWorkingLocally(tabId = activeTabId, { runStarted = false } = {}) {
8281
8699
  const tab = tabs.find((item) => item.id === tabId);
8282
8700
  if (!tab) return false;
8701
+ suppressPendingAgentDoneNotificationsForTab(tabId);
8283
8702
  const previous = activityForTab(tab);
8284
8703
  const timestamp = new Date().toISOString();
8285
- const next = normalizeTabActivity({ ...previous, status: "working", isWorking: true, lastStartedAt: timestamp, lastChangedAt: timestamp });
8704
+ const next = normalizeTabActivity({
8705
+ ...previous,
8706
+ status: "working",
8707
+ isWorking: true,
8708
+ runStarted: previous.runStarted === true || runStarted === true,
8709
+ lastStartedAt: timestamp,
8710
+ lastChangedAt: timestamp,
8711
+ });
8286
8712
  tabActivities.set(tabId, next);
8287
8713
  if (tabActivityStateChanged(previous, next)) scheduleTabsRender();
8288
8714
  return true;
@@ -8292,7 +8718,7 @@ function markTabIdleLocally(tabId = activeTabId) {
8292
8718
  const tab = tabs.find((item) => item.id === tabId);
8293
8719
  if (!tab) return false;
8294
8720
  const previous = activityForTab(tab);
8295
- const next = normalizeTabActivity({ ...previous, status: "idle", isWorking: false });
8721
+ const next = normalizeTabActivity({ ...previous, status: "idle", isWorking: false, runStarted: false });
8296
8722
  tabActivities.set(tabId, next);
8297
8723
  if (tabActivityStateChanged(previous, next)) scheduleTabsRender();
8298
8724
  return true;
@@ -8303,10 +8729,12 @@ function markTabDoneLocally(tabId = activeTabId) {
8303
8729
  const tab = tabs.find((item) => item.id === tabId);
8304
8730
  if (!tab) return false;
8305
8731
  const previous = activityForTab(tab);
8732
+ if (!previous.runStarted) return markTabIdleLocally(tabId);
8306
8733
  const next = normalizeTabActivity({
8307
8734
  ...previous,
8308
8735
  status: "done",
8309
8736
  isWorking: false,
8737
+ runStarted: false,
8310
8738
  completionSerial: (Number(previous.completionSerial) || 0) + 1,
8311
8739
  lastCompletedAt: new Date().toISOString(),
8312
8740
  });
@@ -8333,7 +8761,9 @@ function syncActiveTabActivityFromState(state = currentState) {
8333
8761
  return false;
8334
8762
  }
8335
8763
  if (stateHasVisibleWork(state)) {
8336
- if (!activity.isWorking) return markTabWorkingLocally(tab.id);
8764
+ if (!activity.isWorking || (state.isStreaming && !activity.runStarted)) {
8765
+ return markTabWorkingLocally(tab.id, { runStarted: state.isStreaming === true });
8766
+ }
8337
8767
  return false;
8338
8768
  }
8339
8769
  if (activity.isWorking && !tabActivityRecentlyStarted(activity)) return markTabDoneLocally(tab.id);
@@ -8443,7 +8873,7 @@ function restoreActiveDraft() {
8443
8873
 
8444
8874
  function focusPromptInput({ defer = false } = {}) {
8445
8875
  const focus = () => {
8446
- 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;
8876
+ if (activeSubagentTerminalId || !elements.promptInput || elements.dialog.open || elements.issueWizardDialog?.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;
8447
8877
  try {
8448
8878
  elements.promptInput.focus({ preventScroll: true });
8449
8879
  } catch {
@@ -9162,6 +9592,26 @@ function gitPanelHistoryDate(value) {
9162
9592
  return Number.isNaN(date.getTime()) ? String(value || "") : date.toLocaleString();
9163
9593
  }
9164
9594
 
9595
+ function gitPanelDataRenderSignature(data) {
9596
+ if (!data) return null;
9597
+ return {
9598
+ branch: data.branch || "",
9599
+ changes: Array.isArray(data.changes) ? data.changes : [],
9600
+ history: Array.isArray(data.history) ? data.history : [],
9601
+ };
9602
+ }
9603
+
9604
+ function updateGitPanelRepositoryMeta(cards = gitPanelRepositoryCards()) {
9605
+ const sections = [...elements.gitPanelGroups?.querySelectorAll(".git-side-panel-repository[data-git-root]") || []];
9606
+ for (const card of cards) {
9607
+ const snapshot = gitPanelSnapshot(card.root);
9608
+ if (!snapshot?.data) continue;
9609
+ const section = sections.find((candidate) => candidate.dataset.gitRoot === card.root);
9610
+ const status = section?.querySelector(".git-side-panel-repository-updated");
9611
+ if (status) status.textContent = snapshot.loading ? "Refreshing…" : `Updated ${gitPanelHistoryDate(snapshot.data.generatedAt)}`;
9612
+ }
9613
+ }
9614
+
9165
9615
  function renderGitPanelHistory(card, data) {
9166
9616
  const wrapper = make("div", "git-side-panel-history");
9167
9617
  const history = Array.isArray(data?.history) ? data.history : [];
@@ -9233,7 +9683,7 @@ function renderGitPanelRepositoryContent(card, snapshot) {
9233
9683
  const meta = make("div", "git-side-panel-repository-meta");
9234
9684
  meta.append(
9235
9685
  make("strong", undefined, data.branch || "detached"),
9236
- make("span", undefined, snapshot.loading ? "Refreshing…" : `Updated ${gitPanelHistoryDate(data.generatedAt)}`),
9686
+ make("span", "git-side-panel-repository-updated", snapshot.loading ? "Refreshing…" : `Updated ${gitPanelHistoryDate(data.generatedAt)}`),
9237
9687
  );
9238
9688
  const changesPanel = renderGitPanelChanges(card, data);
9239
9689
  changesPanel.id = "git-side-panel-changes-panel";
@@ -9263,6 +9713,7 @@ function renderGitPanelRepositoryCard(card) {
9263
9713
  const snapshot = gitPanelSnapshot(card.root);
9264
9714
  const expanded = gitPanelState.expandedCardKey === card.key;
9265
9715
  const section = make("section", `git-side-panel-repository${expanded ? " expanded" : ""}`);
9716
+ section.dataset.gitRoot = card.root;
9266
9717
  const button = make("button", "git-side-panel-repository-toggle");
9267
9718
  button.type = "button";
9268
9719
  button.setAttribute("aria-expanded", expanded ? "true" : "false");
@@ -9309,12 +9760,13 @@ function renderGitPanel() {
9309
9760
  cards: cards.map((card) => {
9310
9761
  const snapshot = gitPanelSnapshot(card.root);
9311
9762
  const data = snapshot?.data;
9312
- return [card.key, card.root, card.cwd, card.tabId, snapshot?.loadedAt || 0, !!snapshot?.loading, snapshot?.error || "", gitPanelChangeCount(data), data?.history?.length || 0, data?.branch || "", data?.generatedAt || "", gitPanelState.activeViews.get(card.root) || "changes"];
9763
+ return [card.key, card.root, card.cwd, card.tabId, snapshot?.error || "", !data && !!snapshot?.loading, gitPanelDataRenderSignature(data), gitPanelState.activeViews.get(card.root) || "changes"];
9313
9764
  }),
9314
9765
  repositoryCount,
9315
9766
  discovering,
9316
9767
  });
9317
9768
  if (signature === gitPanelRenderSignature && elements.gitPanelGroups.childElementCount === cards.length) {
9769
+ updateGitPanelRepositoryMeta(cards);
9318
9770
  ensureGitPanelRepositoriesDiscovered();
9319
9771
  ensureGitPanelVisibleRepositoriesFresh(cards);
9320
9772
  return;
@@ -9358,10 +9810,6 @@ function terminalAppRunnerLabel(run) {
9358
9810
  return command && command !== "app runner" ? `app runner: ${command}` : "app runner running";
9359
9811
  }
9360
9812
 
9361
- function terminalAppRunnerTooltip(run) {
9362
- return appRunnerIsRunning(run) ? ` · ${terminalAppRunnerLabel(run)}` : "";
9363
- }
9364
-
9365
9813
  function tabConversationMode(tab) {
9366
9814
  if (!tab?.id) return normalizeConversationModeState(tab?.conversationMode || {});
9367
9815
  return normalizeConversationModeState(conversationModeByTab.get(tab.id) || tab.conversationMode || {});
@@ -9371,22 +9819,16 @@ function tabConversationModeActive(tab) {
9371
9819
  return tabConversationMode(tab).enabled === true;
9372
9820
  }
9373
9821
 
9374
- function terminalConversationModeTooltip(tab) {
9375
- const mode = tabConversationMode(tab);
9376
- return mode.enabled ? ` · natural conversation: ${mode.uiState || "listening"}` : "";
9377
- }
9378
-
9379
9822
  function tabWorkflowModeActive(tab) {
9380
9823
  return normalizeWorkflowModeState(workflowModeByTab.get(tab?.id) || {}).enabled === true;
9381
9824
  }
9382
9825
 
9383
- function terminalWorkflowTooltip(tab) {
9384
- const count = workflowRunningCountForTab(tab?.id);
9385
- return `${tabWorkflowModeActive(tab) ? " · workflow mode active" : ""}${count ? ` · ${count} workflow run${count === 1 ? "" : "s"} active` : ""}`;
9826
+ function terminalTabWorkspaceName(tab) {
9827
+ return tabGroupTitle(tab?.cwd, "workspace");
9386
9828
  }
9387
9829
 
9388
9830
  function terminalTabMeta(tab, indicator) {
9389
- const parts = [tab.running ? `${indicator.meta} · pid ${tab.pid || "…"}` : "stopped"];
9831
+ const parts = [tab.running ? `${indicator.meta} · ${terminalTabWorkspaceName(tab)}` : "stopped"];
9390
9832
  if (tabAppRunnerRunningRun(tab)) parts.push("app runner");
9391
9833
  if (tabConversationModeActive(tab)) parts.push("voice");
9392
9834
  if (tabWorkflowModeActive(tab)) parts.push("workflow mode");
@@ -9395,6 +9837,86 @@ function terminalTabMeta(tab, indicator) {
9395
9837
  return parts.join(" · ");
9396
9838
  }
9397
9839
 
9840
+ function terminalTabGitTooltip(tab) {
9841
+ const workspace = normalizeGitWorkspaceInfo(tab?.gitWorkspace);
9842
+ if (!workspace) return "";
9843
+ const checkout = workspace.worktreePath ? (workspace.isMainWorktree ? "main worktree" : "worktree") : "";
9844
+ return [workspace.branch || "detached", checkout].filter(Boolean).join(" · ");
9845
+ }
9846
+
9847
+ function terminalTabActiveTooltip(tab) {
9848
+ const active = [];
9849
+ const appRunnerRun = tabAppRunnerRunningRun(tab);
9850
+ if (appRunnerRun) active.push(terminalAppRunnerLabel(appRunnerRun));
9851
+ const conversationMode = tabConversationMode(tab);
9852
+ if (conversationMode.enabled) active.push(`voice: ${conversationMode.uiState || "listening"}`);
9853
+ const workflowCount = workflowRunningCountForTab(tab?.id);
9854
+ if (tabWorkflowModeActive(tab)) active.push(workflowCount ? `workflow: ${workflowCount} run${workflowCount === 1 ? "" : "s"}` : "workflow mode");
9855
+ else if (workflowCount) active.push(`workflow: ${workflowCount} run${workflowCount === 1 ? "" : "s"}`);
9856
+ return active.join(" · ");
9857
+ }
9858
+
9859
+ function terminalTabTooltip(tab) {
9860
+ const lines = [
9861
+ `${tab?.title || "Terminal tab"} · ${tabIndicator(tab).label}`,
9862
+ `Working folder: ${normalizeDisplayPath(tab?.cwd || "") || "Not set"}`,
9863
+ ];
9864
+ const git = terminalTabGitTooltip(tab);
9865
+ if (git) lines.push(`Git: ${git}`);
9866
+ const active = terminalTabActiveTooltip(tab);
9867
+ if (active) lines.push(`Active: ${active}`);
9868
+ lines.push("Click to switch · Drag to group");
9869
+ return lines.join("\n");
9870
+ }
9871
+
9872
+ function terminalTabGroupStatusTooltip(groupTabs = []) {
9873
+ const counts = { blocked: 0, working: 0, done: 0, idle: 0, stopped: 0 };
9874
+ for (const tab of groupTabs) {
9875
+ const state = tab?.running ? tabIndicator(tab).state : "stopped";
9876
+ counts[state] = (counts[state] || 0) + 1;
9877
+ }
9878
+ return ["blocked", "working", "done", "idle", "stopped"]
9879
+ .filter((state) => counts[state])
9880
+ .map((state) => `${counts[state]} ${state}`)
9881
+ .join(" · ");
9882
+ }
9883
+
9884
+ function terminalTabGroupWorkspaceTooltip(group) {
9885
+ const paths = [...new Set((group?.tabs || []).map((tab) => normalizeDisplayPath(tab?.cwd || "")).filter(Boolean))];
9886
+ if (!group?.custom || paths.length <= 1) return `Working folder: ${paths[0] || normalizeDisplayPath(group?.cwd || "") || "Not set"}`;
9887
+ const names = paths.map((path) => path.split("/").filter(Boolean).slice(-2).join("/") || path);
9888
+ const remainder = names.length - 2;
9889
+ return `Workspaces: ${names.slice(0, 2).join(", ")}${remainder > 0 ? ` +${remainder} more` : ""}`;
9890
+ }
9891
+
9892
+ function terminalTabGroupActiveTooltip(groupTabs = []) {
9893
+ const appRunners = groupTabs.filter(tabAppRunnerRunningRun).length;
9894
+ const voices = groupTabs.filter(tabConversationModeActive).length;
9895
+ const workflowTabs = groupTabs.filter(tabWorkflowModeActive).length;
9896
+ const workflowRuns = groupTabs.reduce((total, tab) => total + workflowRunningCountForTab(tab?.id), 0);
9897
+ return [
9898
+ appRunners ? `${appRunners} app runner${appRunners === 1 ? "" : "s"}` : "",
9899
+ voices ? `${voices} voice` : "",
9900
+ workflowTabs ? `${workflowTabs} workflow tab${workflowTabs === 1 ? "" : "s"}` : "",
9901
+ workflowRuns ? `${workflowRuns} workflow run${workflowRuns === 1 ? "" : "s"}` : "",
9902
+ ].filter(Boolean).join(" · ");
9903
+ }
9904
+
9905
+ function terminalTabGroupTooltip(group, groupTitle = terminalDisplayGroupTitle(group)) {
9906
+ const groupTabs = group?.tabs || [];
9907
+ const lines = [
9908
+ `${groupTitle} · ${groupTabs.length} tab${groupTabs.length === 1 ? "" : "s"}`,
9909
+ terminalTabGroupWorkspaceTooltip(group),
9910
+ `Status: ${terminalTabGroupStatusTooltip(groupTabs) || "No tabs"}`,
9911
+ ];
9912
+ const active = terminalTabGroupActiveTooltip(groupTabs);
9913
+ if (active) lines.push(`Active: ${active}`);
9914
+ lines.push("Click to switch · Drop tabs here to add");
9915
+ return lines.join("\n");
9916
+ }
9917
+
9918
+ let terminalTabGroupSummarySerial = 0;
9919
+
9398
9920
  function appendTerminalTabContent(button, { title, indicator, meta, count = null, appRunnerRun = null, conversationModeActive = false, workflowModeActive = false, workflowCount = 0, subagent = false }) {
9399
9921
  const titleRow = make("span", "terminal-tab-title-row");
9400
9922
  const indicatorDot = make("span", "terminal-tab-activity-indicator");
@@ -9426,8 +9948,7 @@ function renderTerminalTab(tab) {
9426
9948
  button.setAttribute("role", "tab");
9427
9949
  button.setAttribute("aria-selected", isActive ? "true" : "false");
9428
9950
  button.setAttribute("aria-label", `${tab.title}: ${indicator.label}${appRunnerLabel ? `, ${appRunnerLabel}` : ""}${conversationLabel}${workflowModeActive ? ", workflow mode active" : ""}${workflowCount ? `, ${workflowCount} workflow runs active` : ""}`);
9429
- const tooltip = `${tab.title} · ${indicator.label}${tab.running ? ` · pid ${tab.pid || "starting"}` : " · stopped"}${terminalAppRunnerTooltip(appRunnerRun)}${terminalConversationModeTooltip(tab)}${terminalWorkflowTooltip(tab)} · drag onto another tab or group to group`;
9430
- applyStyledTooltip(button, tooltip, { ariaLabel: false });
9951
+ applyStyledTooltip(button, terminalTabTooltip(tab), { ariaLabel: false, align: "start", description: true, variant: "workspace" });
9431
9952
  appendTerminalTabContent(button, { title: tab.title, indicator, meta: terminalTabMeta(tab, indicator), appRunnerRun, conversationModeActive, workflowModeActive, workflowCount });
9432
9953
  button.addEventListener("click", () => switchTab(tab.id));
9433
9954
  wrapper.append(button);
@@ -9466,8 +9987,7 @@ function renderTerminalTabGroupItem(tab, group) {
9466
9987
  button.setAttribute("role", "tab");
9467
9988
  button.setAttribute("aria-selected", isActive ? "true" : "false");
9468
9989
  button.setAttribute("aria-label", `${tab.title}: ${indicator.label}${appRunnerLabel ? `, ${appRunnerLabel}` : ""}${conversationLabel}${workflowModeActive ? ", workflow mode active" : ""}${workflowCount ? `, ${workflowCount} workflow runs active` : ""}`);
9469
- const tooltip = `${tab.title} · ${indicator.label}${tab.running ? ` · pid ${tab.pid || "starting"}` : " · stopped"}${terminalAppRunnerTooltip(appRunnerRun)}${terminalConversationModeTooltip(tab)}${terminalWorkflowTooltip(tab)} · drag onto another tab or group to group`;
9470
- applyStyledTooltip(button, tooltip, { ariaLabel: false });
9990
+ applyStyledTooltip(button, terminalTabTooltip(tab), { ariaLabel: false, align: "start", description: true, variant: "workspace" });
9471
9991
  appendTerminalTabContent(button, { title: tab.title, indicator, meta: terminalTabMeta(tab, indicator), appRunnerRun, conversationModeActive, workflowModeActive, workflowCount });
9472
9992
  button.addEventListener("click", (event) => {
9473
9993
  event.stopPropagation();
@@ -9510,7 +10030,6 @@ function renderTerminalTabGroup(group, groupCount = 1) {
9510
10030
  const workflowModeActive = groupTabs.some(tabWorkflowModeActive);
9511
10031
  const groupTitle = terminalDisplayGroupTitle(group, activeGroupTab?.title || "group");
9512
10032
  const activeTitle = activeGroupTab?.title || groupTitle;
9513
- const groupDetail = terminalDisplayGroupDetail(group, groupTitle);
9514
10033
  const wrapper = make("div", `terminal-tab terminal-tab-group${group.custom ? " terminal-tab-custom-group" : ""} activity-${indicator.state}${isActive ? " active" : ""}${isStopped ? " stopped" : ""}${appRunnerRun ? " app-runner-running" : ""}${workflowModeActive ? " workflow-mode-running" : ""}${workflowCount ? " workflow-run-running" : ""}`);
9515
10034
  wrapper.dataset.groupKey = group.key;
9516
10035
  if (group.customGroupId) wrapper.dataset.customGroupId = group.customGroupId;
@@ -9531,8 +10050,6 @@ function renderTerminalTabGroup(group, groupCount = 1) {
9531
10050
  button.setAttribute("aria-haspopup", "true");
9532
10051
  button.setAttribute("aria-expanded", group.key === openTerminalTabGroupKey ? "true" : "false");
9533
10052
  button.setAttribute("aria-label", `${groupTitle} ${group.custom ? "custom" : "cwd"} group: ${groupTabs.length} tabs, ${indicator.label}${appRunnerSummary ? `, ${appRunnerSummary}` : ""}${workflowModeActive ? ", workflow mode active" : ""}${workflowCount ? `, ${workflowCount} workflow runs active` : ""}. Active ${activeTitle}`);
9534
- const tooltip = `${activeTitle} · ${groupTitle} · ${groupDetail} · ${groupTabs.length} tabs · ${indicator.label}${appRunnerSummary ? ` · ${appRunnerSummary}` : ""}${workflowModeActive ? " · workflow mode active" : ""}${workflowCount ? ` · ${workflowCount} workflow runs active` : ""} · drop tabs here to add to group`;
9535
- applyStyledTooltip(button, tooltip, { ariaLabel: false });
9536
10053
  appendTerminalTabContent(button, { title: activeTitle, indicator, meta: `${groupTitle} · ${indicator.meta}${groupAppRunnerMeta ? ` · ${groupAppRunnerMeta}` : ""}${workflowModeActive ? " · workflow mode" : ""}${workflowCount ? ` · ${workflowCount} workflows` : ""}`, appRunnerRun, count: groupTabs.length, workflowModeActive, workflowCount });
9537
10054
  button.addEventListener("click", () => switchTab(activeGroupTab.id));
9538
10055
  wrapper.append(button);
@@ -9553,6 +10070,10 @@ function renderTerminalTabGroup(group, groupCount = 1) {
9553
10070
  const menu = make("div", "terminal-tab-group-menu");
9554
10071
  menu.setAttribute("role", "group");
9555
10072
  menu.setAttribute("aria-label", `${groupTitle} tabs`);
10073
+ const summary = make("div", "terminal-tab-group-summary", terminalTabGroupTooltip(group, groupTitle));
10074
+ summary.id = `terminalTabGroupSummary${++terminalTabGroupSummarySerial}`;
10075
+ button.setAttribute("aria-describedby", summary.id);
10076
+ menu.append(summary);
9556
10077
  for (const tab of groupTabs) menu.append(renderTerminalTabGroupItem(tab, group));
9557
10078
 
9558
10079
  const add = make("button", "terminal-tab-group-add", "+ Tab");
@@ -10297,7 +10818,8 @@ function queueAgentDoneBrowserNotification({ key, tabId, title, body }) {
10297
10818
  clearPendingAgentDoneNotification(key);
10298
10819
  const timer = setTimeout(() => {
10299
10820
  pendingAgentDoneNotificationTimers.delete(key);
10300
- if (isAutoRetryingTab(tabId)) return;
10821
+ const tab = tabs.find((item) => item.id === tabId);
10822
+ if (isAutoRetryingTab(tabId) || promptRoutingTabs.has(tabId) || activityForTab(tab).isWorking) return;
10301
10823
  showAgentDoneBrowserNotification({ tabId, title, body });
10302
10824
  }, AGENT_DONE_NOTIFICATION_RETRY_GRACE_MS);
10303
10825
  pendingAgentDoneNotificationTimers.set(key, { tabId, timer });
@@ -10808,6 +11330,8 @@ let footerTooltipPendingTarget = null;
10808
11330
  function ensureFooterTooltipNode() {
10809
11331
  if (!footerTooltipNode) {
10810
11332
  footerTooltipNode = make("div", "footer-floating-tooltip");
11333
+ footerTooltipNode.id = "footerFloatingTooltip";
11334
+ footerTooltipNode.setAttribute("role", "tooltip");
10811
11335
  footerTooltipNode.hidden = true;
10812
11336
  document.body.append(footerTooltipNode);
10813
11337
  }
@@ -10816,6 +11340,9 @@ function ensureFooterTooltipNode() {
10816
11340
  const update = () => positionFooterTooltip(footerTooltipTarget);
10817
11341
  window.addEventListener("resize", update, { passive: true });
10818
11342
  window.addEventListener("scroll", update, { passive: true, capture: true });
11343
+ document.addEventListener("keydown", (event) => {
11344
+ if (event.key === "Escape" && footerTooltipTarget) hideFooterTooltip(footerTooltipTarget);
11345
+ }, true);
10819
11346
  }
10820
11347
  return footerTooltipNode;
10821
11348
  }
@@ -10857,6 +11384,9 @@ function showFooterTooltip(target) {
10857
11384
  if (!text) return;
10858
11385
  footerTooltipTarget = target;
10859
11386
  const tooltip = ensureFooterTooltipNode();
11387
+ const variant = target.getAttribute("data-tooltip-variant");
11388
+ if (variant) tooltip.dataset.variant = variant;
11389
+ else delete tooltip.dataset.variant;
10860
11390
  tooltip.textContent = text;
10861
11391
  tooltip.hidden = false;
10862
11392
  tooltip.classList.add("visible");
@@ -10883,6 +11413,7 @@ function hideFooterTooltip(target) {
10883
11413
  if (!footerTooltipNode) return;
10884
11414
  footerTooltipNode.hidden = true;
10885
11415
  footerTooltipNode.classList.remove("visible");
11416
+ delete footerTooltipNode.dataset.variant;
10886
11417
  }
10887
11418
 
10888
11419
  function bindStyledTooltipEvents(node) {
@@ -10890,10 +11421,15 @@ function bindStyledTooltipEvents(node) {
10890
11421
  node._styledTooltipBound = true;
10891
11422
  node.addEventListener("mouseenter", () => scheduleFooterTooltip(node));
10892
11423
  node.addEventListener("mouseleave", () => hideFooterTooltip(node));
10893
- node.addEventListener("focus", () => showFooterTooltip(node));
11424
+ node.addEventListener("focus", () => {
11425
+ if (node.getAttribute("data-tooltip-variant") === "workspace" && !node.matches(":focus-visible")) return;
11426
+ showFooterTooltip(node);
11427
+ });
10894
11428
  node.addEventListener("blur", () => hideFooterTooltip(node));
10895
11429
  }
10896
11430
 
11431
+ let styledTooltipDescriptionSerial = 0;
11432
+
10897
11433
  function applyStyledTooltip(node, tooltip, options = {}) {
10898
11434
  if (!node) return node;
10899
11435
  const text = cleanTooltipText(tooltip);
@@ -10904,7 +11440,15 @@ function applyStyledTooltip(node, tooltip, options = {}) {
10904
11440
  const ariaLabel = typeof options.ariaLabel === "string" ? options.ariaLabel : text.replace(/\s+/g, " ");
10905
11441
  node.setAttribute("aria-label", ariaLabel);
10906
11442
  }
11443
+ if (options.description === true) {
11444
+ const description = make("span", "sr-only styled-tooltip-description", text);
11445
+ description.id = `styledTooltipDescription${++styledTooltipDescriptionSerial}`;
11446
+ node.append(description);
11447
+ const describedBy = [node.getAttribute("aria-describedby"), description.id].filter(Boolean).join(" ");
11448
+ node.setAttribute("aria-describedby", describedBy);
11449
+ }
10907
11450
  if (options.align) node.setAttribute("data-tooltip-align", options.align);
11451
+ if (options.variant) node.setAttribute("data-tooltip-variant", options.variant);
10908
11452
  if (options.floating !== false) bindStyledTooltipEvents(node);
10909
11453
  return node;
10910
11454
  }
@@ -13682,10 +14226,13 @@ function gitFooterFallbackMessage() {
13682
14226
  const tabContext = activeTabContext();
13683
14227
  const commandsStillLoading = availableCommands.length === 0 && rawAvailableCommands.length === 0;
13684
14228
  const footerRefreshPending = tabContext.tabId ? gitFooterPayloadRefreshInFlightByTab.has(tabContext.tabId) : false;
14229
+ const payloadState = tabContext.tabId ? gitFooterPayloadStateByTab.get(tabContext.tabId) : null;
13685
14230
  const extensionDetected = hasAvailableCommand("git-footer-refresh") || optionalFeatureAvailability.gitFooterStatus;
13686
- return commandsStillLoading || footerRefreshPending || extensionDetected
13687
- ? "Loading git footer status…"
13688
- : "Git footer status extension unavailable";
14231
+ if (commandsStillLoading || footerRefreshPending || payloadState?.phase === "waiting") return "Loading git footer status…";
14232
+ if (payloadState?.phase === "failed") return payloadState.error || "Git footer status was not received — refresh to retry";
14233
+ if (payloadState?.phase === "idle") return "Git footer status unavailable — refresh to retry";
14234
+ if (extensionDetected) return "Loading git footer status…";
14235
+ return "Git footer status extension unavailable";
13689
14236
  }
13690
14237
 
13691
14238
  function renderMinimalFooter() {
@@ -15398,7 +15945,12 @@ function closePathPicker(cwd) {
15398
15945
  }
15399
15946
 
15400
15947
  function pickCwd(tab, initialCwd, { title } = {}) {
15401
- if (pathPickerState) return Promise.resolve(null);
15948
+ if (pathPickerState) {
15949
+ addEvent("working-directory picker is already open", "warn");
15950
+ elements.pathPickerDialog.focus();
15951
+ elements.pathPickerSearchInput.focus({ preventScroll: true });
15952
+ return Promise.resolve(null);
15953
+ }
15402
15954
 
15403
15955
  return new Promise((resolve) => {
15404
15956
  const pickerTab = tab || { id: "path-picker", title: "tab" };
@@ -15439,27 +15991,46 @@ async function changeActiveTabCwd() {
15439
15991
  if (!(await appConfirmText(`Restart ${tab.title} in:\n${cwd}\n\nCurrent in-flight work in this tab will be stopped. The conversation continues in the new directory.`, { affected: tab.title, confirmLabel: "Change working folder" }))) return;
15440
15992
 
15441
15993
  saveActiveDraft();
15994
+ if (isCurrentTabContext(tabContext)) {
15995
+ addTransientMessage({
15996
+ role: "native",
15997
+ title: "Changing working folder…",
15998
+ content: `Restarting ${tab.title} in ${cwd}. This can take a few seconds.`,
15999
+ level: "info",
16000
+ });
16001
+ }
16002
+ let response;
15442
16003
  try {
15443
- const response = await api(`/api/tabs/${encodeURIComponent(tab.id)}`, { method: "PATCH", body: { cwd }, scoped: false });
15444
- tabs = response.data?.tabs || tabs;
15445
- syncTabMetadata(tabs);
15446
- if (!isCurrentTabContext(tabContext)) {
15447
- renderTabs();
15448
- return;
15449
- }
15450
- const nextContext = setActiveTabId(response.data?.tab?.id || activeTabId);
15451
- resetGitWorkflowForTab(nextContext.tabId);
15452
- resetActiveTabUi();
16004
+ response = await api(`/api/tabs/${encodeURIComponent(tab.id)}`, { method: "PATCH", body: { cwd }, scoped: false });
16005
+ } catch (error) {
16006
+ const message = `Could not change ${tab.title} to ${cwd}. The existing working folder was kept.\n\n${error.message || String(error)}`;
16007
+ if (isCurrentTabContext(tabContext)) surfaceRuntimeDiagnostic("Working folder change failed", message);
16008
+ else addEvent(`working folder change failed for ${tab.title}: ${error.message || String(error)}`, "error");
16009
+ return;
16010
+ }
16011
+
16012
+ tabs = response.data?.tabs || tabs;
16013
+ syncTabMetadata(tabs);
16014
+ const changedTabId = response.data?.tab?.id || tab.id;
16015
+ const changedCwd = response.data?.tab?.cwd || cwd;
16016
+ resetGitWorkflowForTab(changedTabId);
16017
+ clearGitFooterPayloadState(changedTabId);
16018
+ if (!isCurrentTabContext(tabContext)) {
15453
16019
  renderTabs();
15454
- restoreActiveDraft();
15455
- connectEvents(nextContext);
15456
- await refreshAll(nextContext);
15457
- if (!isCurrentTabContext(nextContext)) return;
15458
- const changedCwd = response.data?.tab?.cwd || cwd;
15459
16020
  addEvent(response.data?.changed === false ? `cwd unchanged: ${changedCwd}` : `changed ${tab.title} cwd to ${changedCwd}`, "info");
15460
- } catch (error) {
15461
- if (isCurrentTabContext(tabContext)) addEvent(error.message, "error");
16021
+ return;
15462
16022
  }
16023
+
16024
+ const nextContext = setActiveTabId(response.data?.tab?.id || activeTabId);
16025
+ resetActiveTabUi();
16026
+ renderTabs();
16027
+ restoreActiveDraft();
16028
+ connectEvents(nextContext);
16029
+ await refreshAll(nextContext);
16030
+ if (!isCurrentTabContext(nextContext)) return;
16031
+ const successMessage = response.data?.changed === false ? `cwd unchanged: ${changedCwd}` : `changed ${tab.title} cwd to ${changedCwd}`;
16032
+ addEvent(successMessage, "info");
16033
+ if (response.data?.changed !== false) addTransientMessage({ role: "native", title: "Working folder changed", content: `${tab.title} restarted in ${changedCwd}.`, level: "info" });
15463
16034
  }
15464
16035
 
15465
16036
  function renderFooter() {
@@ -26068,8 +26639,19 @@ function applyNativeSlashCommandEffects(response, message, tabContext = activeTa
26068
26639
  });
26069
26640
  }
26070
26641
 
26071
- if (data.download && handleNativeDownloadResponse(data.download, data.command, data.serverPath)) {
26072
- addEvent(data.command === "export" ? `export ready: ${data.download.fileName || data.download.url}` : `download started: ${data.download.fileName || data.download.url}`, "info");
26642
+ if (data.download) {
26643
+ const downloadLabel = data.download.fileName || data.download.url || "unnamed download";
26644
+ try {
26645
+ const opened = handleNativeDownloadResponse(data.download, data.command, data.serverPath);
26646
+ if (opened) {
26647
+ addEvent(data.command === "export" ? `export ready: ${downloadLabel}` : `download started: ${downloadLabel}`, "info");
26648
+ } else {
26649
+ addEvent(`could not open ${data.command === "export" ? "HTML export" : "download"}: missing or invalid browser URL (${downloadLabel})`, "error");
26650
+ }
26651
+ } catch (error) {
26652
+ const reason = error?.message || String(error);
26653
+ addEvent(`could not open ${data.command === "export" ? "HTML export" : "download"} ${downloadLabel}: ${reason}`, "error");
26654
+ }
26073
26655
  }
26074
26656
 
26075
26657
  const cards = Array.isArray(data.cards) && data.cards.length ? data.cards : null;
@@ -26583,23 +27165,85 @@ async function refreshOptionalFeaturePackageStatuses({ announce = false } = {})
26583
27165
  }
26584
27166
  }
26585
27167
 
27168
+ function clearGitFooterPayloadState(tabId) {
27169
+ if (!tabId) return;
27170
+ gitFooterPayloadRequestSerialByTab.set(tabId, (gitFooterPayloadRequestSerialByTab.get(tabId) || 0) + 1);
27171
+ clearTimeout(gitFooterPayloadSettlementTimersByTab.get(tabId));
27172
+ gitFooterPayloadSettlementTimersByTab.delete(tabId);
27173
+ gitFooterPayloadStateByTab.delete(tabId);
27174
+ gitFooterPayloadRefreshInFlightByTab.delete(tabId);
27175
+ }
27176
+
27177
+ function settleGitFooterPayload(tabId, phase, error = "") {
27178
+ if (!tabId) return;
27179
+ clearTimeout(gitFooterPayloadSettlementTimersByTab.get(tabId));
27180
+ gitFooterPayloadSettlementTimersByTab.delete(tabId);
27181
+ gitFooterPayloadStateByTab.set(tabId, { phase, error });
27182
+ }
27183
+
27184
+ function waitForGitFooterPayloadSettlement(tabContext, requestSerial) {
27185
+ clearTimeout(gitFooterPayloadSettlementTimersByTab.get(tabContext.tabId));
27186
+ const timer = setTimeout(() => {
27187
+ gitFooterPayloadSettlementTimersByTab.delete(tabContext.tabId);
27188
+ if (gitFooterPayloadRequestSerialByTab.get(tabContext.tabId) !== requestSerial) return;
27189
+ if (gitFooterPayloadStateByTab.get(tabContext.tabId)?.phase === "waiting") {
27190
+ settleGitFooterPayload(tabContext.tabId, "failed", "Git footer status was not received — refresh to retry");
27191
+ }
27192
+ if (isCurrentTabContext(tabContext)) renderFooter();
27193
+ }, GIT_FOOTER_PAYLOAD_SETTLEMENT_TIMEOUT_MS);
27194
+ gitFooterPayloadSettlementTimersByTab.set(tabContext.tabId, timer);
27195
+ }
27196
+
26586
27197
  function requestGitFooterWebuiPayload(tabContext = activeTabContext(), { force = false, silent = true, allowDuringRun = false } = {}) {
26587
27198
  if (!tabContext.tabId || isOptionalFeatureDisabled("gitFooterStatus")) return;
26588
27199
  if (!allowDuringRun && (currentState?.isStreaming || currentState?.isCompacting)) return;
26589
27200
  const refreshCommand = resolveAvailableCommandName("git-footer-refresh", { rpcOnly: true });
26590
- if (!refreshCommand || (!force && statusEntries.has(GIT_FOOTER_WEBUI_STATUS_KEY))) return;
27201
+ if (!refreshCommand) {
27202
+ if (hasAvailableCommand("git-footer-refresh") || optionalFeatureAvailability.gitFooterStatus) {
27203
+ gitFooterPayloadRefreshInFlightByTab.delete(tabContext.tabId);
27204
+ const requestSerial = (gitFooterPayloadRequestSerialByTab.get(tabContext.tabId) || 0) + 1;
27205
+ gitFooterPayloadRequestSerialByTab.set(tabContext.tabId, requestSerial);
27206
+ settleGitFooterPayload(tabContext.tabId, "waiting");
27207
+ const timer = setTimeout(() => {
27208
+ gitFooterPayloadSettlementTimersByTab.delete(tabContext.tabId);
27209
+ if (gitFooterPayloadRequestSerialByTab.get(tabContext.tabId) !== requestSerial) return;
27210
+ if (gitFooterPayloadStateByTab.get(tabContext.tabId)?.phase === "waiting") {
27211
+ settleGitFooterPayload(tabContext.tabId, "failed", "Git footer refresh command is unavailable — reload to retry");
27212
+ }
27213
+ if (isCurrentTabContext(tabContext)) renderFooter();
27214
+ }, GIT_FOOTER_PAYLOAD_SETTLEMENT_TIMEOUT_MS);
27215
+ gitFooterPayloadSettlementTimersByTab.set(tabContext.tabId, timer);
27216
+ if (isCurrentTabContext(tabContext)) renderFooter();
27217
+ }
27218
+ return;
27219
+ }
27220
+ if (!force && statusEntries.has(GIT_FOOTER_WEBUI_STATUS_KEY)) return;
26591
27221
  if (gitFooterPayloadRefreshInFlightByTab.has(tabContext.tabId)) return;
26592
27222
 
27223
+ const requestSerial = (gitFooterPayloadRequestSerialByTab.get(tabContext.tabId) || 0) + 1;
27224
+ gitFooterPayloadRequestSerialByTab.set(tabContext.tabId, requestSerial);
27225
+ settleGitFooterPayload(tabContext.tabId, "waiting");
26593
27226
  gitFooterPayloadRefreshInFlightByTab.add(tabContext.tabId);
26594
27227
  if (isCurrentTabContext(tabContext)) renderFooter();
26595
27228
  return api("/api/prompt", {
26596
27229
  method: "POST",
26597
27230
  body: { message: `/${refreshCommand}${silent ? " --webui-silent" : ""}`, streamingBehavior: "steer" },
26598
27231
  tabId: tabContext.tabId,
27232
+ signal: AbortSignal.timeout(GIT_FOOTER_PAYLOAD_REQUEST_TIMEOUT_MS),
27233
+ }).then(() => {
27234
+ if (gitFooterPayloadRequestSerialByTab.get(tabContext.tabId) !== requestSerial) return;
27235
+ if (gitFooterPayloadStateByTab.get(tabContext.tabId)?.phase === "waiting") waitForGitFooterPayloadSettlement(tabContext, requestSerial);
26599
27236
  }).catch((error) => {
26600
- if (isCurrentTabContext(tabContext)) addEvent(`git footer payload refresh failed: ${error.message || String(error)}`, "warn");
27237
+ if (gitFooterPayloadRequestSerialByTab.get(tabContext.tabId) !== requestSerial) return;
27238
+ const message = `Git footer refresh failed: ${error.message || String(error)}`;
27239
+ settleGitFooterPayload(tabContext.tabId, "failed", "Git footer refresh failed — refresh to retry");
27240
+ if (isCurrentTabContext(tabContext)) {
27241
+ if (silent) addEvent(message, "warn");
27242
+ else surfaceRuntimeDiagnostic("Git footer refresh failed", message, "warn");
27243
+ }
26601
27244
  }).finally(() => {
26602
27245
  gitFooterPayloadRefreshInFlightByTab.delete(tabContext.tabId);
27246
+ if (gitFooterPayloadRequestSerialByTab.get(tabContext.tabId) !== requestSerial) return;
26603
27247
  if (isCurrentTabContext(tabContext)) renderFooter();
26604
27248
  });
26605
27249
  }
@@ -31501,9 +32145,18 @@ function handleExtensionUiRequest(request) {
31501
32145
  }
31502
32146
  if (request.statusText) {
31503
32147
  statusEntries.set(statusKey, request.statusText);
31504
- if (statusKey === GIT_FOOTER_WEBUI_STATUS_KEY) cacheGitFooterWebuiPayload(request.statusText, request.tabId);
32148
+ if (statusKey === GIT_FOOTER_WEBUI_STATUS_KEY) {
32149
+ const validPayload = !!parseGitFooterWebuiPayloadRaw(request.statusText);
32150
+ cacheGitFooterWebuiPayload(request.statusText, request.tabId);
32151
+ settleGitFooterPayload(
32152
+ request.tabId || activeTabId,
32153
+ validPayload ? "ready" : "failed",
32154
+ validPayload ? "" : "Git footer returned invalid status data — refresh to retry",
32155
+ );
32156
+ }
31505
32157
  } else {
31506
32158
  statusEntries.delete(statusKey);
32159
+ if (statusKey === GIT_FOOTER_WEBUI_STATUS_KEY) settleGitFooterPayload(request.tabId || activeTabId, "idle");
31507
32160
  }
31508
32161
  if (statusKey === STATS_WEBUI_STATUS_KEY) handleStatsWebuiStatus(request.statusText);
31509
32162
  if (statusKey === BTW_WEBUI_STATUS_KEY) handleBtwWebuiStatus(request.statusText);
@@ -31981,7 +32634,7 @@ function handleInactiveTabEvent(event) {
31981
32634
  setWidgetForTab(event.tabId, AUR_REVIEW_RPC_WIDGET_KEY, event);
31982
32635
  updateOptionalFeatureAvailability();
31983
32636
  renderTabs();
31984
- } else if (event.type === "agent_end") {
32637
+ } else if (event.type === "agent_settled") {
31985
32638
  notifyAgentDone(event.tabId, { activity: event.tabActivity, tabTitle: event.tabTitle });
31986
32639
  }
31987
32640
  }
@@ -32163,6 +32816,7 @@ function handleEvent(event) {
32163
32816
  break;
32164
32817
  case "agent_start":
32165
32818
  assistantErrorSurfacedThisRun = false;
32819
+ markTabWorkingLocally(event.tabId || activeTabId, { runStarted: true });
32166
32820
  if (currentState) currentState = { ...currentState, isStreaming: true };
32167
32821
  if (voiceConversationActiveFor(event.tabId || activeTabId)) voiceConversation.setAssistantActivity({ streaming: true });
32168
32822
  setRunIndicatorActivity("Agent run started; waiting for first output or action…");
@@ -32181,34 +32835,11 @@ function handleEvent(event) {
32181
32835
  assistantErrorSurfacedThisRun = true;
32182
32836
  }
32183
32837
  }
32184
- addEvent("agent finished");
32185
- notifyAgentDone(event.tabId || activeTabId, { activity: event.tabActivity, tabTitle: event.tabTitle });
32186
- clearContextUsageUnknownAfterCompaction(event.tabId || activeTabId);
32187
- if (currentState) currentState = { ...currentState, isStreaming: false };
32188
- // handleAssistantTurnEnd resets the controller's streaming/tool flags and
32189
- // flushes queued interruptions itself; calling setAssistantActivity here
32190
- // first would flush the queue and then speak the interrupted answer.
32191
- if (voiceConversationActiveFor(event.tabId || activeTabId)) void handleVoiceConversationTurnEnd(tabContext);
32192
- clearRunIndicatorActivity();
32193
- markTabOutputSeen();
32194
- requestGitFooterWebuiPayload(tabContext, { force: true });
32195
- scheduleRefreshState();
32838
+ addEvent("agent run ended; waiting for settlement");
32839
+ if (runIndicatorIsActive()) setRunIndicatorActivity("Agent run ended; checking for retry or continuation…", { scroll: false });
32196
32840
  scheduleRefreshMessages();
32841
+ scheduleRefreshState();
32197
32842
  scheduleRefreshFooter();
32198
- scheduleRefreshCodexUsage(2200);
32199
- scheduleRefreshClaudeUsage(2200);
32200
- renderFeedbackTray();
32201
- {
32202
- const workflowTabId = event.tabId || activeTabId;
32203
- const workflow = gitWorkflowForTab(workflowTabId, { create: false });
32204
- if (workflow?.active && workflow.step === "generating") {
32205
- loadGitWorkflowMessage({ requireFresh: true, generationId: workflow.messageGenerationId, runId: workflow.runId, tabId: workflowTabId });
32206
- } else if (workflow?.active && workflow.step === "branchNaming") {
32207
- loadGitWorkflowBranchName({ requireFresh: true, retries: 3, runId: workflow.runId, tabId: workflowTabId });
32208
- } else if (workflow?.active && workflow.step === "prGenerating") {
32209
- loadGitWorkflowPr({ requireFresh: true, retries: 3, runId: workflow.runId, tabId: workflowTabId });
32210
- }
32211
- }
32212
32843
  break;
32213
32844
  case "message_start":
32214
32845
  if (event.message?.role === "assistant") {
@@ -32294,6 +32925,35 @@ function handleEvent(event) {
32294
32925
  break;
32295
32926
  case "agent_settled":
32296
32927
  if (compactOutputActive()) finishCompactLiveOutput(tabContext);
32928
+ streamMessageActive = false;
32929
+ addEvent("agent finished");
32930
+ notifyAgentDone(event.tabId || activeTabId, { activity: event.tabActivity, tabTitle: event.tabTitle });
32931
+ clearContextUsageUnknownAfterCompaction(event.tabId || activeTabId);
32932
+ if (currentState) currentState = { ...currentState, isStreaming: false };
32933
+ // handleAssistantTurnEnd resets the controller's streaming/tool flags and
32934
+ // flushes queued interruptions itself; calling setAssistantActivity here
32935
+ // first would flush the queue and then speak the interrupted answer.
32936
+ if (voiceConversationActiveFor(event.tabId || activeTabId)) void handleVoiceConversationTurnEnd(tabContext);
32937
+ clearRunIndicatorActivity();
32938
+ markTabOutputSeen();
32939
+ requestGitFooterWebuiPayload(tabContext, { force: true });
32940
+ scheduleRefreshState();
32941
+ scheduleRefreshMessages();
32942
+ scheduleRefreshFooter();
32943
+ scheduleRefreshCodexUsage(2200);
32944
+ scheduleRefreshClaudeUsage(2200);
32945
+ renderFeedbackTray();
32946
+ {
32947
+ const workflowTabId = event.tabId || activeTabId;
32948
+ const workflow = gitWorkflowForTab(workflowTabId, { create: false });
32949
+ if (workflow?.active && workflow.step === "generating") {
32950
+ loadGitWorkflowMessage({ requireFresh: true, generationId: workflow.messageGenerationId, runId: workflow.runId, tabId: workflowTabId });
32951
+ } else if (workflow?.active && workflow.step === "branchNaming") {
32952
+ loadGitWorkflowBranchName({ requireFresh: true, retries: 3, runId: workflow.runId, tabId: workflowTabId });
32953
+ } else if (workflow?.active && workflow.step === "prGenerating") {
32954
+ loadGitWorkflowPr({ requireFresh: true, retries: 3, runId: workflow.runId, tabId: workflowTabId });
32955
+ }
32956
+ }
32297
32957
  break;
32298
32958
  case "auto_retry_start": {
32299
32959
  const seconds = Math.max(0, Math.ceil(Number(event.delayMs || 0) / 1000));
@@ -33885,6 +34545,7 @@ elements.promptInput.addEventListener("blur", () => {
33885
34545
  });
33886
34546
 
33887
34547
  installModalPrimitives();
34548
+ initializeIssueWizard();
33888
34549
  resizePromptInput();
33889
34550
  restoreSidePanelWidthPreference();
33890
34551
  restoreFileViewerWidthPreference();