@firstpick/pi-package-webui 0.8.7 → 0.8.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/bin/pi-webui.mjs +4 -0
- package/package.json +1 -1
- package/public/app.js +253 -27
- package/public/index.html +22 -0
- package/public/styles.css +95 -0
- package/tests/fixtures/fake-pi.mjs +2 -1
- package/tests/mobile-static.test.mjs +194 -3
- package/tests/optional-feature-migration-frontend.test.mjs +4 -0
- package/tests/prompt-routing-tab-status.test.mjs +8 -0
package/bin/pi-webui.mjs
CHANGED
|
@@ -1896,6 +1896,10 @@ function nodeModulesParentForPackageRoot(root = packageRoot) {
|
|
|
1896
1896
|
return root;
|
|
1897
1897
|
}
|
|
1898
1898
|
|
|
1899
|
+
function packageNodeModulesPath(nodeModulesRoot, packageName) {
|
|
1900
|
+
return path.join(nodeModulesRoot, ...String(packageName).split("/").filter(Boolean));
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1899
1903
|
function prependNodePathEntries(entries) {
|
|
1900
1904
|
const existing = String(process.env.NODE_PATH || "").split(path.delimiter).filter(Boolean);
|
|
1901
1905
|
const seen = new Set();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firstpick/pi-package-webui",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.8",
|
|
4
4
|
"description": "Pi Web UI companion package with a local browser UI CLI plus /webui-start and /webui-status commands.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/Firstp1ck/pi-coding-agent-forge/tree/main/pi-package-webui#readme",
|
package/public/app.js
CHANGED
|
@@ -430,6 +430,17 @@ const elements = {
|
|
|
430
430
|
confirmationUndo: $("#confirmationUndo"),
|
|
431
431
|
confirmationCancelButton: $("#confirmationCancelButton"),
|
|
432
432
|
confirmationConfirmButton: $("#confirmationConfirmButton"),
|
|
433
|
+
gitPullErrorDialog: $("#gitPullErrorDialog"),
|
|
434
|
+
gitPullErrorDialogTitle: $("#gitPullErrorDialogTitle"),
|
|
435
|
+
gitPullErrorDialogDescription: $("#gitPullErrorDialogDescription"),
|
|
436
|
+
gitPullErrorOutput: $("#gitPullErrorOutput"),
|
|
437
|
+
gitPullErrorStatus: $("#gitPullErrorStatus"),
|
|
438
|
+
gitPullErrorRecovery: $("#gitPullErrorRecovery"),
|
|
439
|
+
gitPullErrorMergeButton: $("#gitPullErrorMergeButton"),
|
|
440
|
+
gitPullErrorRebaseButton: $("#gitPullErrorRebaseButton"),
|
|
441
|
+
gitPullErrorReviewButton: $("#gitPullErrorReviewButton"),
|
|
442
|
+
gitPullErrorCopyButton: $("#gitPullErrorCopyButton"),
|
|
443
|
+
gitPullErrorCloseButton: $("#gitPullErrorCloseButton"),
|
|
433
444
|
workspaceLoadDialog: $("#workspaceLoadDialog"),
|
|
434
445
|
workspaceLoadDialogCloseButton: $("#workspaceLoadDialogCloseButton"),
|
|
435
446
|
workspaceLoadDialogStatus: $("#workspaceLoadDialogStatus"),
|
|
@@ -3060,6 +3071,7 @@ let optionalFeatureMigrationReadyDismissTimer = null;
|
|
|
3060
3071
|
let optionalFeatureMigrationPendingReadyDismissKey = "";
|
|
3061
3072
|
let optionalFeatureMigrationDismissedReadyKey = "";
|
|
3062
3073
|
let optionalFeatureMigrationDismissedCompletionKey = "";
|
|
3074
|
+
let optionalFeatureMigrationDismissedNoticeKey = "";
|
|
3063
3075
|
let optionalFeatureMigrationDialogState = null;
|
|
3064
3076
|
let optionalFeatureMigrationLastPhase = "";
|
|
3065
3077
|
let optionalFeatureMigrationCompletionFocusKey = "";
|
|
@@ -3071,6 +3083,8 @@ const gitFooterPayloadStateByTab = new Map();
|
|
|
3071
3083
|
const gitFooterPayloadSettlementTimersByTab = new Map();
|
|
3072
3084
|
const gitFooterPayloadRequestSerialByTab = new Map();
|
|
3073
3085
|
const gitFooterSyncInFlightByTab = new Set();
|
|
3086
|
+
let gitPullErrorText = "";
|
|
3087
|
+
let gitPullErrorContext = { code: "", tabId: null, syncValue: "", busy: false, requestId: 0 };
|
|
3074
3088
|
const gitFooterPiCalibrationInFlightByTab = new Set();
|
|
3075
3089
|
let gitFooterVisibilityApplyInFlight = false;
|
|
3076
3090
|
let gitFooterVisibilityDirty = false;
|
|
@@ -17242,7 +17256,8 @@ function gitFooterSyncCounts(value) {
|
|
|
17242
17256
|
function gitFooterSyncAction(chip) {
|
|
17243
17257
|
if (chip?.key !== "sync") return "";
|
|
17244
17258
|
const { ahead, behind } = gitFooterSyncCounts(chip.value);
|
|
17245
|
-
if (behind > 0 && ahead
|
|
17259
|
+
if (behind > 0 && ahead > 0) return "pull-push";
|
|
17260
|
+
if (behind > 0) return "pull";
|
|
17246
17261
|
if (ahead > 0) return "push";
|
|
17247
17262
|
return "";
|
|
17248
17263
|
}
|
|
@@ -17253,8 +17268,172 @@ function gitFooterCurrentBranch() {
|
|
|
17253
17268
|
return value && value !== "no repo" ? cleanFooterPayloadText(gitChip.value, "") : "";
|
|
17254
17269
|
}
|
|
17255
17270
|
|
|
17256
|
-
|
|
17257
|
-
|
|
17271
|
+
function gitFailureDisplayText(response, fallback = "Git operation failed") {
|
|
17272
|
+
const errorText = String(response?.error || "").trim();
|
|
17273
|
+
const hintText = String(response?.hint || "").trim();
|
|
17274
|
+
const result = response?.data && typeof response.data === "object" ? { ...response.data } : null;
|
|
17275
|
+
if (result && errorText) {
|
|
17276
|
+
if (String(result.stderr || "").trim() === errorText) result.stderr = "";
|
|
17277
|
+
if (String(result.stdout || "").trim() === errorText) result.stdout = "";
|
|
17278
|
+
}
|
|
17279
|
+
const parts = [errorText || fallback, hintText, formatGitCommandResult(result)].map((part) => String(part || "").trim()).filter(Boolean);
|
|
17280
|
+
const seen = new Set();
|
|
17281
|
+
return parts.filter((part) => {
|
|
17282
|
+
const key = part.replace(/\r\n/g, "\n");
|
|
17283
|
+
if (seen.has(key)) return false;
|
|
17284
|
+
seen.add(key);
|
|
17285
|
+
return true;
|
|
17286
|
+
}).join("\n\n");
|
|
17287
|
+
}
|
|
17288
|
+
|
|
17289
|
+
function setGitPullErrorBusy(busy) {
|
|
17290
|
+
gitPullErrorContext = { ...gitPullErrorContext, busy: !!busy };
|
|
17291
|
+
for (const button of [elements.gitPullErrorMergeButton, elements.gitPullErrorRebaseButton, elements.gitPullErrorReviewButton, elements.gitPullErrorCloseButton]) {
|
|
17292
|
+
if (button) button.disabled = !!busy;
|
|
17293
|
+
}
|
|
17294
|
+
if (elements.gitPullErrorDialog) elements.gitPullErrorDialog.setAttribute("aria-busy", busy ? "true" : "false");
|
|
17295
|
+
}
|
|
17296
|
+
|
|
17297
|
+
function closeGitPullErrorDialog() {
|
|
17298
|
+
if (gitPullErrorContext.busy) return;
|
|
17299
|
+
if (elements.gitPullErrorDialog?.open) elements.gitPullErrorDialog.close();
|
|
17300
|
+
}
|
|
17301
|
+
|
|
17302
|
+
function openGitPullErrorDialog(message, { code = "", tabId = null, syncValue = "" } = {}) {
|
|
17303
|
+
const text = String(message || "git pull from origin failed").trim();
|
|
17304
|
+
const diverged = code === "DIVERGED";
|
|
17305
|
+
gitPullErrorText = text;
|
|
17306
|
+
gitPullErrorContext = {
|
|
17307
|
+
code,
|
|
17308
|
+
tabId: typeof tabId === "string" && tabId ? tabId : null,
|
|
17309
|
+
syncValue: String(syncValue || ""),
|
|
17310
|
+
busy: false,
|
|
17311
|
+
requestId: gitPullErrorContext.requestId + 1,
|
|
17312
|
+
};
|
|
17313
|
+
if (!elements.gitPullErrorDialog?.showModal || !elements.gitPullErrorOutput) {
|
|
17314
|
+
window.alert(`${diverged ? "Branches diverged" : "Git pull failed"}\n\n${text}`);
|
|
17315
|
+
return;
|
|
17316
|
+
}
|
|
17317
|
+
if (elements.gitPullErrorDialogTitle) elements.gitPullErrorDialogTitle.textContent = diverged ? "Branches diverged" : "Git pull failed";
|
|
17318
|
+
if (elements.gitPullErrorDialogDescription) {
|
|
17319
|
+
elements.gitPullErrorDialogDescription.textContent = diverged
|
|
17320
|
+
? "Local and remote contain unique commits. This does not mean conflicts exist; conflicts are known only after a merge or rebase is attempted."
|
|
17321
|
+
: "The repository was not changed by the failed pull. Review or copy the complete error output below.";
|
|
17322
|
+
}
|
|
17323
|
+
elements.gitPullErrorOutput.textContent = text;
|
|
17324
|
+
if (elements.gitPullErrorRecovery) elements.gitPullErrorRecovery.hidden = !diverged;
|
|
17325
|
+
elements.gitPullErrorCloseButton?.classList.toggle("primary", !diverged);
|
|
17326
|
+
if (elements.gitPullErrorStatus) {
|
|
17327
|
+
elements.gitPullErrorStatus.textContent = diverged
|
|
17328
|
+
? "Review the incoming changes, merge them, or rebase your local commits. No integration runs without confirmation."
|
|
17329
|
+
: "Select the output or use Copy error output.";
|
|
17330
|
+
elements.gitPullErrorStatus.classList.remove("error", "success");
|
|
17331
|
+
}
|
|
17332
|
+
setGitPullErrorBusy(false);
|
|
17333
|
+
if (!elements.gitPullErrorDialog.open) elements.gitPullErrorDialog.showModal();
|
|
17334
|
+
queueMicrotask(() => (diverged ? elements.gitPullErrorReviewButton : elements.gitPullErrorCopyButton)?.focus({ preventScroll: true }));
|
|
17335
|
+
}
|
|
17336
|
+
|
|
17337
|
+
async function copyGitPullErrorOutput() {
|
|
17338
|
+
if (!gitPullErrorText) return;
|
|
17339
|
+
if (elements.gitPullErrorCopyButton) elements.gitPullErrorCopyButton.disabled = true;
|
|
17340
|
+
try {
|
|
17341
|
+
await copyText(gitPullErrorText);
|
|
17342
|
+
if (elements.gitPullErrorStatus) {
|
|
17343
|
+
elements.gitPullErrorStatus.textContent = "Error output copied to the clipboard.";
|
|
17344
|
+
elements.gitPullErrorStatus.classList.add("success");
|
|
17345
|
+
elements.gitPullErrorStatus.classList.remove("error");
|
|
17346
|
+
}
|
|
17347
|
+
addEvent("copied Git pull error output", "info");
|
|
17348
|
+
} catch (error) {
|
|
17349
|
+
const message = `Copy failed: ${error.message || String(error)}`;
|
|
17350
|
+
if (elements.gitPullErrorStatus) {
|
|
17351
|
+
elements.gitPullErrorStatus.textContent = message;
|
|
17352
|
+
elements.gitPullErrorStatus.classList.add("error");
|
|
17353
|
+
elements.gitPullErrorStatus.classList.remove("success");
|
|
17354
|
+
}
|
|
17355
|
+
addEvent(`Git pull error output copy failed: ${error.message || String(error)}`, "error");
|
|
17356
|
+
} finally {
|
|
17357
|
+
if (elements.gitPullErrorCopyButton) elements.gitPullErrorCopyButton.disabled = false;
|
|
17358
|
+
}
|
|
17359
|
+
}
|
|
17360
|
+
|
|
17361
|
+
function reviewGitPullDivergence() {
|
|
17362
|
+
if (gitPullErrorContext.code !== "DIVERGED" || !gitPullErrorContext.tabId || gitPullErrorContext.busy) return;
|
|
17363
|
+
const tabId = gitPullErrorContext.tabId;
|
|
17364
|
+
closeGitPullErrorDialog();
|
|
17365
|
+
openGitChangesDialog(tabId);
|
|
17366
|
+
}
|
|
17367
|
+
|
|
17368
|
+
async function integrateGitPullDivergence(mode) {
|
|
17369
|
+
if (!["merge", "rebase"].includes(mode) || gitPullErrorContext.code !== "DIVERGED" || !gitPullErrorContext.tabId || gitPullErrorContext.busy) return false;
|
|
17370
|
+
const { tabId, syncValue, requestId } = gitPullErrorContext;
|
|
17371
|
+
const targetTab = tabs.find((tab) => tab.id === tabId);
|
|
17372
|
+
const activeBranch = tabId === activeTabId ? gitFooterCurrentBranch() : "";
|
|
17373
|
+
const target = activeBranch || targetTab?.title || targetTab?.cwd || "the selected branch";
|
|
17374
|
+
const merge = mode === "merge";
|
|
17375
|
+
const confirmed = await appConfirmText([
|
|
17376
|
+
`${merge ? "Merge upstream changes into" : "Rebase local commits onto the upstream of"} ${target}?`,
|
|
17377
|
+
"",
|
|
17378
|
+
merge
|
|
17379
|
+
? "This preserves both histories and may create a merge commit. Conflicts are possible but are not currently known."
|
|
17380
|
+
: "This replays local commits on top of upstream and rewrites their commit IDs. Conflicts are possible but are not currently known.",
|
|
17381
|
+
].join("\n"), {
|
|
17382
|
+
affected: `Git history for ${target}`,
|
|
17383
|
+
confirmLabel: merge ? "Merge changes" : "Rebase commits",
|
|
17384
|
+
danger: !merge,
|
|
17385
|
+
});
|
|
17386
|
+
if (!confirmed || gitPullErrorContext.requestId !== requestId) return false;
|
|
17387
|
+
|
|
17388
|
+
const tabContext = activeTabContext(tabId);
|
|
17389
|
+
let pushSyncValue = "";
|
|
17390
|
+
setGitPullErrorBusy(true);
|
|
17391
|
+
gitFooterSyncInFlightByTab.add(tabId);
|
|
17392
|
+
if (isCurrentTabContext(tabContext)) renderFooter();
|
|
17393
|
+
if (elements.gitPullErrorStatus) elements.gitPullErrorStatus.textContent = merge ? "Merging upstream changes…" : "Rebasing local commits…";
|
|
17394
|
+
try {
|
|
17395
|
+
const response = await api("/api/git-changes/integrate", { method: "POST", body: { mode, confirmed: true }, tabId });
|
|
17396
|
+
if (gitPullErrorContext.requestId !== requestId) return false;
|
|
17397
|
+
if (!response.ok) {
|
|
17398
|
+
const message = gitFailureDisplayText(response, `git ${mode} failed`);
|
|
17399
|
+
addEvent(message, "error");
|
|
17400
|
+
setGitPullErrorBusy(false);
|
|
17401
|
+
if (response.code === "CONFLICTS") {
|
|
17402
|
+
closeGitPullErrorDialog();
|
|
17403
|
+
openGitChangesDialog(tabId);
|
|
17404
|
+
return false;
|
|
17405
|
+
}
|
|
17406
|
+
openGitPullErrorDialog(message, { code: response.code || "", tabId, syncValue });
|
|
17407
|
+
return false;
|
|
17408
|
+
}
|
|
17409
|
+
setGitPullErrorBusy(false);
|
|
17410
|
+
closeGitPullErrorDialog();
|
|
17411
|
+
addEvent(`${merge ? "Merged" : "Rebased"} upstream changes.`, "success");
|
|
17412
|
+
requestGitFooterWebuiPayload(tabContext, { force: true });
|
|
17413
|
+
const freshAheadValue = response.data?.changes?.summary?.ahead;
|
|
17414
|
+
const freshAhead = Number(freshAheadValue);
|
|
17415
|
+
if (freshAheadValue !== undefined) {
|
|
17416
|
+
if (Number.isFinite(freshAhead) && freshAhead > 0) pushSyncValue = `⇡${freshAhead}`;
|
|
17417
|
+
} else if (gitFooterSyncCounts(syncValue).ahead > 0) {
|
|
17418
|
+
pushSyncValue = syncValue;
|
|
17419
|
+
}
|
|
17420
|
+
} catch (error) {
|
|
17421
|
+
if (gitPullErrorContext.requestId !== requestId) return false;
|
|
17422
|
+
const message = error.message || String(error);
|
|
17423
|
+
addEvent(message, "error");
|
|
17424
|
+
setGitPullErrorBusy(false);
|
|
17425
|
+
openGitPullErrorDialog(message, { tabId, syncValue });
|
|
17426
|
+
return false;
|
|
17427
|
+
} finally {
|
|
17428
|
+
gitFooterSyncInFlightByTab.delete(tabId);
|
|
17429
|
+
if (isCurrentTabContext(tabContext)) renderFooter();
|
|
17430
|
+
}
|
|
17431
|
+
if (pushSyncValue) await pushGitFooterSync(tabId, pushSyncValue);
|
|
17432
|
+
return true;
|
|
17433
|
+
}
|
|
17434
|
+
|
|
17435
|
+
async function pullGitFooterSync(tabId = activeTabId, { syncValue = "" } = {}) {
|
|
17436
|
+
if (!tabId || gitFooterSyncInFlightByTab.has(tabId)) return false;
|
|
17258
17437
|
const tabContext = activeTabContext(tabId);
|
|
17259
17438
|
hideFooterTooltip();
|
|
17260
17439
|
gitFooterSyncInFlightByTab.add(tabId);
|
|
@@ -17262,23 +17441,36 @@ async function pullGitFooterSync(tabId = activeTabId) {
|
|
|
17262
17441
|
try {
|
|
17263
17442
|
const response = await api("/api/git-changes/pull", { method: "POST", body: { remote: "origin" }, tabId });
|
|
17264
17443
|
if (!response.ok) {
|
|
17265
|
-
const
|
|
17266
|
-
|
|
17444
|
+
const message = gitFailureDisplayText(response, "git pull from origin failed");
|
|
17445
|
+
addEvent(message, "error");
|
|
17446
|
+
openGitPullErrorDialog(message, { code: response.code || "", tabId, syncValue });
|
|
17447
|
+
return false;
|
|
17267
17448
|
}
|
|
17268
17449
|
addEvent("Pulled Git changes from origin.", "success");
|
|
17269
17450
|
requestGitFooterWebuiPayload(tabContext, { force: true });
|
|
17451
|
+
return true;
|
|
17270
17452
|
} catch (error) {
|
|
17271
|
-
|
|
17453
|
+
const message = error.message || String(error);
|
|
17454
|
+
addEvent(message, "error");
|
|
17455
|
+
openGitPullErrorDialog(message, { code: error?.code || "", tabId, syncValue });
|
|
17456
|
+
return false;
|
|
17272
17457
|
} finally {
|
|
17273
17458
|
gitFooterSyncInFlightByTab.delete(tabId);
|
|
17274
17459
|
if (isCurrentTabContext(tabContext)) renderFooter();
|
|
17275
17460
|
}
|
|
17276
17461
|
}
|
|
17277
17462
|
|
|
17463
|
+
async function pullThenPushGitFooterSync(tabId = activeTabId, syncValue = "") {
|
|
17464
|
+
const pulled = await pullGitFooterSync(tabId, { syncValue });
|
|
17465
|
+
if (!pulled) return;
|
|
17466
|
+
await pushGitFooterSync(tabId, syncValue);
|
|
17467
|
+
}
|
|
17468
|
+
|
|
17278
17469
|
async function pushGitFooterSync(tabId = activeTabId, syncValue = "") {
|
|
17279
17470
|
if (!tabId || gitFooterSyncInFlightByTab.has(tabId)) return;
|
|
17280
17471
|
const outgoing = gitFooterSyncCounts(syncValue).ahead;
|
|
17281
17472
|
if (outgoing <= 0) return;
|
|
17473
|
+
let recoverWithPullFirst = false;
|
|
17282
17474
|
const tabContext = activeTabContext(tabId);
|
|
17283
17475
|
const tab = tabs.find((item) => item.id === tabId);
|
|
17284
17476
|
const target = tab?.title || tab?.cwd || "this tab";
|
|
@@ -17306,34 +17498,25 @@ async function pushGitFooterSync(tabId = activeTabId, syncValue = "") {
|
|
|
17306
17498
|
throw new Error([response.error, response.hint].filter(Boolean).join("\n"));
|
|
17307
17499
|
}
|
|
17308
17500
|
if (response.code === "NON_FAST_FORWARD") {
|
|
17309
|
-
|
|
17310
|
-
|
|
17311
|
-
|
|
17312
|
-
|
|
17313
|
-
"",
|
|
17314
|
-
"Recommended: open the Git Changes dialog, fetch, and review the incoming diff first.",
|
|
17315
|
-
`DANGER: force-push ${branch || "the current branch"} with --force-with-lease instead? This rewrites the remote branch (but still refuses if the remote moved past what you fetched).`,
|
|
17316
|
-
].join("\n"));
|
|
17317
|
-
if (forcePush) {
|
|
17318
|
-
const forceResponse = await api("/api/git-workflow/push", { method: "POST", body: { forceWithLease: true, confirmed: true }, tabId });
|
|
17319
|
-
if (!forceResponse.ok) throw new Error([forceResponse.error, forceResponse.hint].filter(Boolean).join("\n"));
|
|
17320
|
-
addEvent("Force-pushed with --force-with-lease.", "success");
|
|
17321
|
-
requestGitFooterWebuiPayload(tabContext, { force: true });
|
|
17322
|
-
return;
|
|
17323
|
-
}
|
|
17324
|
-
throw new Error([response.error, response.hint].filter(Boolean).join("\n"));
|
|
17501
|
+
recoverWithPullFirst = true;
|
|
17502
|
+
} else {
|
|
17503
|
+
const detail = [response.error, response.hint, formatGitCommandResult(response.data)].filter(Boolean).join("\n\n").trim();
|
|
17504
|
+
throw new Error(detail || "git push failed");
|
|
17325
17505
|
}
|
|
17326
|
-
|
|
17327
|
-
|
|
17506
|
+
} else {
|
|
17507
|
+
addEvent(`Pushed ${outgoing} outgoing commit${outgoing === 1 ? "" : "s"}.`, "success");
|
|
17508
|
+
requestGitFooterWebuiPayload(tabContext, { force: true });
|
|
17328
17509
|
}
|
|
17329
|
-
addEvent(`Pushed ${outgoing} outgoing commit${outgoing === 1 ? "" : "s"}.`, "success");
|
|
17330
|
-
requestGitFooterWebuiPayload(tabContext, { force: true });
|
|
17331
17510
|
} catch (error) {
|
|
17332
17511
|
addEvent(error.message || String(error), "error");
|
|
17333
17512
|
} finally {
|
|
17334
17513
|
gitFooterSyncInFlightByTab.delete(tabId);
|
|
17335
17514
|
if (isCurrentTabContext(tabContext)) renderFooter();
|
|
17336
17515
|
}
|
|
17516
|
+
if (recoverWithPullFirst) {
|
|
17517
|
+
addEvent("Push found incoming commits. Starting pull-first recovery.", "info");
|
|
17518
|
+
await pullThenPushGitFooterSync(tabId, syncValue);
|
|
17519
|
+
}
|
|
17337
17520
|
}
|
|
17338
17521
|
|
|
17339
17522
|
function renderGitFooterPayloadMeta(chip, tab, payload) {
|
|
@@ -17359,6 +17542,9 @@ function renderGitFooterPayloadMeta(chip, tab, payload) {
|
|
|
17359
17542
|
if (syncAction === "pull") {
|
|
17360
17543
|
options.onClick = () => pullGitFooterSync(tabId);
|
|
17361
17544
|
action = inFlight ? "Pulling from origin." : "Click to pull from origin with fast-forward only.";
|
|
17545
|
+
} else if (syncAction === "pull-push") {
|
|
17546
|
+
options.onClick = () => pullThenPushGitFooterSync(tabId, chip.value);
|
|
17547
|
+
action = inFlight ? "Pulling from origin before pushing local commits." : "Click to pull from origin with fast-forward only, then push if the pull succeeds.";
|
|
17362
17548
|
} else if (syncAction === "push") {
|
|
17363
17549
|
options.onClick = () => pushGitFooterSync(tabId, chip.value);
|
|
17364
17550
|
action = inFlight ? "Pushing local commits to the configured remote." : "Click to push local commits to the configured remote.";
|
|
@@ -36031,6 +36217,11 @@ function optionalFeatureMigrationCompletionKey(snapshot = optionalFeatureMigrati
|
|
|
36031
36217
|
return completedAt ? `${snapshot.revision || "pending"}:${completedAt}` : "";
|
|
36032
36218
|
}
|
|
36033
36219
|
|
|
36220
|
+
function optionalFeatureMigrationNoticeDismissKey(snapshot = optionalFeatureMigrationSnapshot) {
|
|
36221
|
+
if (snapshot.phase !== "degraded") return "";
|
|
36222
|
+
return JSON.stringify([snapshot.revision || "pending", snapshot.diagnostic?.message || ""]);
|
|
36223
|
+
}
|
|
36224
|
+
|
|
36034
36225
|
function storedDismissedOptionalFeatureMigrationKey() {
|
|
36035
36226
|
try {
|
|
36036
36227
|
return localStorage.getItem(OPTIONAL_FEATURE_MIGRATION_DISMISS_STORAGE_KEY) || "";
|
|
@@ -36060,6 +36251,14 @@ function dismissOptionalFeatureMigrationCompletion() {
|
|
|
36060
36251
|
renderOptionalFeatureMigrationSurface();
|
|
36061
36252
|
}
|
|
36062
36253
|
|
|
36254
|
+
function dismissOptionalFeatureMigrationNotice() {
|
|
36255
|
+
const key = optionalFeatureMigrationNoticeDismissKey();
|
|
36256
|
+
if (!key) return;
|
|
36257
|
+
optionalFeatureMigrationDismissedNoticeKey = key;
|
|
36258
|
+
clearOptionalFeatureReadyDismissTimer();
|
|
36259
|
+
renderOptionalFeatureMigrationSurface();
|
|
36260
|
+
}
|
|
36261
|
+
|
|
36063
36262
|
function scheduleOptionalFeatureReadyDismiss(key) {
|
|
36064
36263
|
if (!key) {
|
|
36065
36264
|
clearOptionalFeatureReadyDismissTimer();
|
|
@@ -36135,6 +36334,7 @@ function renderOptionalFeatureMigrationSurface() {
|
|
|
36135
36334
|
const conflicts = (snapshot.features || []).filter((feature) => feature.state === "conflict");
|
|
36136
36335
|
const progress = snapshot.progress;
|
|
36137
36336
|
const readyDismissKey = optionalFeatureReadyDismissKey(snapshot);
|
|
36337
|
+
const noticeDismissKey = optionalFeatureMigrationNoticeDismissKey(snapshot);
|
|
36138
36338
|
const readyCanAutoDismiss = Boolean(readyDismissKey && !optionalFeatureRestartNotice);
|
|
36139
36339
|
if (optionalFeatureMigrationCompletionIsDismissed(snapshot)) {
|
|
36140
36340
|
clearOptionalFeatureReadyDismissTimer();
|
|
@@ -36150,6 +36350,12 @@ function renderOptionalFeatureMigrationSurface() {
|
|
|
36150
36350
|
ensureOptionalFeatureMigrationRenderTimer();
|
|
36151
36351
|
return;
|
|
36152
36352
|
}
|
|
36353
|
+
if (noticeDismissKey && optionalFeatureMigrationDismissedNoticeKey === noticeDismissKey) {
|
|
36354
|
+
surface.replaceChildren();
|
|
36355
|
+
surface.hidden = true;
|
|
36356
|
+
ensureOptionalFeatureMigrationRenderTimer();
|
|
36357
|
+
return;
|
|
36358
|
+
}
|
|
36153
36359
|
const card = make("div", `optional-feature-migration-card phase-${snapshot.phase}`);
|
|
36154
36360
|
const copy = make("div", "optional-feature-migration-copy");
|
|
36155
36361
|
const title = make("strong", "optional-feature-migration-title");
|
|
@@ -36198,6 +36404,12 @@ function renderOptionalFeatureMigrationSurface() {
|
|
|
36198
36404
|
copy.append(title, detail);
|
|
36199
36405
|
card.append(copy);
|
|
36200
36406
|
if (actions.childElementCount) card.append(actions);
|
|
36407
|
+
if (noticeDismissKey) {
|
|
36408
|
+
const dismissButton = optionalFeatureMigrationAction("×", dismissOptionalFeatureMigrationNotice, "optional-feature-migration-dismiss");
|
|
36409
|
+
dismissButton.setAttribute("aria-label", "Close optional feature startup notice");
|
|
36410
|
+
dismissButton.title = "Close";
|
|
36411
|
+
card.append(dismissButton);
|
|
36412
|
+
}
|
|
36201
36413
|
|
|
36202
36414
|
if (conflicts.length) {
|
|
36203
36415
|
const alert = make("div", "optional-feature-migration-alert sr-only", "Optional feature conflict detected; duplicate top-level resources were safely excluded.");
|
|
@@ -42343,10 +42555,13 @@ async function sendPrompt(kind = "prompt", explicitMessage, { targetTabId = acti
|
|
|
42343
42555
|
response = await api("/api/prompt", { method: "POST", body, tabId: targetTabId });
|
|
42344
42556
|
}
|
|
42345
42557
|
applyResponseTab(response);
|
|
42558
|
+
// A successful RPC response ends prompt-routing ownership even when an
|
|
42559
|
+
// extension command handled the input without starting an agent turn.
|
|
42560
|
+
// Canonical streaming state keeps real agent runs active after this handoff.
|
|
42561
|
+
if (startsRun) promptRoutingTabs.delete(targetTabId);
|
|
42346
42562
|
if (response?.command === "native_slash_command" && /^\/new(?:\s|$)/.test(message)) forgetLastUserPrompt(targetTabId);
|
|
42347
42563
|
const targetStillActive = isCurrentTabContext(tabContext);
|
|
42348
42564
|
if (startsRun && response?.command === "native_slash_command") {
|
|
42349
|
-
promptRoutingTabs.delete(targetTabId);
|
|
42350
42565
|
discardOptimisticUserPrompt(optimisticPromptId);
|
|
42351
42566
|
markTabIdleLocally(targetTabId);
|
|
42352
42567
|
if (targetStillActive) clearRunIndicatorActivity();
|
|
@@ -43906,6 +44121,14 @@ elements.undoToastButton?.addEventListener("click", () => runOfferedUndo());
|
|
|
43906
44121
|
elements.undoToastDismissButton?.addEventListener("click", dismissUndoToast);
|
|
43907
44122
|
elements.confirmationCancelButton?.addEventListener("click", () => finishApplicationConfirmation(false));
|
|
43908
44123
|
elements.confirmationConfirmButton?.addEventListener("click", () => finishApplicationConfirmation(true));
|
|
44124
|
+
elements.gitPullErrorMergeButton?.addEventListener("click", () => integrateGitPullDivergence("merge"));
|
|
44125
|
+
elements.gitPullErrorRebaseButton?.addEventListener("click", () => integrateGitPullDivergence("rebase"));
|
|
44126
|
+
elements.gitPullErrorReviewButton?.addEventListener("click", reviewGitPullDivergence);
|
|
44127
|
+
elements.gitPullErrorCopyButton?.addEventListener("click", () => copyGitPullErrorOutput());
|
|
44128
|
+
elements.gitPullErrorCloseButton?.addEventListener("click", closeGitPullErrorDialog);
|
|
44129
|
+
elements.gitPullErrorDialog?.addEventListener("cancel", (event) => {
|
|
44130
|
+
if (gitPullErrorContext.busy) event.preventDefault();
|
|
44131
|
+
});
|
|
43909
44132
|
elements.confirmationDialog?.addEventListener("cancel", (event) => {
|
|
43910
44133
|
event.preventDefault();
|
|
43911
44134
|
finishApplicationConfirmation(false);
|
|
@@ -44129,6 +44352,9 @@ async function abortActiveRun({ source = "button" } = {}) {
|
|
|
44129
44352
|
}
|
|
44130
44353
|
if (hadActiveRun) setRunIndicatorActivity(`Abort requested${source === "escape" ? " from Esc" : source === "long-press" ? " from long-press" : ""}; checking whether Pi stopped…`);
|
|
44131
44354
|
await api("/api/abort", { method: "POST", body: {}, tabId: tabContext.tabId });
|
|
44355
|
+
// Abort also terminates an in-flight local routing handoff. Without this,
|
|
44356
|
+
// canonical idle state cannot clear a stale extension-command indicator.
|
|
44357
|
+
promptRoutingTabs.delete(tabContext.tabId);
|
|
44132
44358
|
if (!isCurrentTabContext(tabContext)) return;
|
|
44133
44359
|
addAbortTranscriptNotice({ activeRun: hadActiveRun });
|
|
44134
44360
|
scheduleAbortStateChecks(tabContext);
|
package/public/index.html
CHANGED
|
@@ -1345,6 +1345,28 @@
|
|
|
1345
1345
|
</form>
|
|
1346
1346
|
</dialog>
|
|
1347
1347
|
|
|
1348
|
+
<dialog id="gitPullErrorDialog" class="extension-dialog git-pull-error-dialog" aria-labelledby="gitPullErrorDialogTitle" aria-describedby="gitPullErrorDialogDescription gitPullErrorOutput">
|
|
1349
|
+
<form method="dialog">
|
|
1350
|
+
<h2 id="gitPullErrorDialogTitle">Git pull failed</h2>
|
|
1351
|
+
<p id="gitPullErrorDialogDescription" class="muted">The repository was not changed by the failed pull. Review or copy the complete error output below.</p>
|
|
1352
|
+
<pre id="gitPullErrorOutput" class="git-pull-error-output" tabindex="0"></pre>
|
|
1353
|
+
<section id="gitPullErrorRecovery" class="git-pull-error-recovery" aria-labelledby="gitPullErrorRecoveryTitle" hidden>
|
|
1354
|
+
<strong id="gitPullErrorRecoveryTitle">Choose how to integrate the histories</strong>
|
|
1355
|
+
<p>Merge preserves both histories and is the default. Rebase rewrites local commit IDs. Neither action runs without confirmation.</p>
|
|
1356
|
+
<div class="git-pull-error-recovery-actions">
|
|
1357
|
+
<button id="gitPullErrorReviewButton" type="button">Review changes</button>
|
|
1358
|
+
<button id="gitPullErrorRebaseButton" type="button">Rebase commits</button>
|
|
1359
|
+
<button id="gitPullErrorMergeButton" class="primary" type="button">Merge changes</button>
|
|
1360
|
+
</div>
|
|
1361
|
+
</section>
|
|
1362
|
+
<p id="gitPullErrorStatus" class="git-pull-error-status muted" role="status" aria-live="polite" aria-atomic="true"></p>
|
|
1363
|
+
<menu>
|
|
1364
|
+
<button id="gitPullErrorCopyButton" type="button">Copy error output</button>
|
|
1365
|
+
<button id="gitPullErrorCloseButton" type="button">Close</button>
|
|
1366
|
+
</menu>
|
|
1367
|
+
</form>
|
|
1368
|
+
</dialog>
|
|
1369
|
+
|
|
1348
1370
|
<dialog id="workspaceLoadDialog" class="extension-dialog workspace-load-dialog" aria-labelledby="workspaceLoadDialogTitle" aria-describedby="workspaceLoadDialogDescription">
|
|
1349
1371
|
<form method="dialog">
|
|
1350
1372
|
<header class="workspace-load-dialog-header">
|
package/public/styles.css
CHANGED
|
@@ -3552,6 +3552,7 @@ button.subagent-gate-attempt:focus-visible {
|
|
|
3552
3552
|
pointer-events: none;
|
|
3553
3553
|
}
|
|
3554
3554
|
.optional-feature-migration-card {
|
|
3555
|
+
position: relative;
|
|
3555
3556
|
display: grid;
|
|
3556
3557
|
grid-template-columns: minmax(0, 1fr) auto;
|
|
3557
3558
|
gap: 0.65rem;
|
|
@@ -3571,6 +3572,9 @@ button.subagent-gate-attempt:focus-visible {
|
|
|
3571
3572
|
.optional-feature-migration-card.phase-partial {
|
|
3572
3573
|
border-color: rgba(249, 226, 175, 0.48);
|
|
3573
3574
|
}
|
|
3575
|
+
.optional-feature-migration-card.phase-degraded {
|
|
3576
|
+
padding-right: 3.35rem;
|
|
3577
|
+
}
|
|
3574
3578
|
.optional-feature-migration-card.phase-complete {
|
|
3575
3579
|
border-color: rgba(166, 227, 161, 0.46);
|
|
3576
3580
|
}
|
|
@@ -3606,6 +3610,29 @@ button.subagent-gate-attempt:focus-visible {
|
|
|
3606
3610
|
font-size: var(--text-xs);
|
|
3607
3611
|
font-weight: 850;
|
|
3608
3612
|
}
|
|
3613
|
+
.optional-feature-migration-dismiss {
|
|
3614
|
+
position: absolute;
|
|
3615
|
+
top: 0.48rem;
|
|
3616
|
+
right: 0.48rem;
|
|
3617
|
+
display: inline-grid;
|
|
3618
|
+
place-items: center;
|
|
3619
|
+
min-width: 2rem;
|
|
3620
|
+
min-height: 2rem;
|
|
3621
|
+
padding: 0;
|
|
3622
|
+
border-color: rgba(180, 190, 254, 0.28);
|
|
3623
|
+
border-radius: 0.58rem;
|
|
3624
|
+
color: rgba(var(--ctp-subtext-rgb), 0.86);
|
|
3625
|
+
background: rgba(var(--ctp-surface-rgb), 0.36);
|
|
3626
|
+
font-size: 1.1rem;
|
|
3627
|
+
font-weight: 900;
|
|
3628
|
+
line-height: 1;
|
|
3629
|
+
}
|
|
3630
|
+
.optional-feature-migration-dismiss:hover,
|
|
3631
|
+
.optional-feature-migration-dismiss:focus-visible {
|
|
3632
|
+
border-color: rgba(148, 226, 213, 0.58);
|
|
3633
|
+
color: var(--ctp-text);
|
|
3634
|
+
background: rgba(148, 226, 213, 0.16);
|
|
3635
|
+
}
|
|
3609
3636
|
.optional-feature-migration-output {
|
|
3610
3637
|
grid-column: 1 / -1;
|
|
3611
3638
|
max-height: 7rem;
|
|
@@ -4212,6 +4239,10 @@ button.subagent-gate-attempt:focus-visible {
|
|
|
4212
4239
|
grid-template-columns: 1fr;
|
|
4213
4240
|
max-height: min(52vh, 25rem);
|
|
4214
4241
|
}
|
|
4242
|
+
.optional-feature-migration-dismiss {
|
|
4243
|
+
min-width: 2.75rem;
|
|
4244
|
+
min-height: 2.75rem;
|
|
4245
|
+
}
|
|
4215
4246
|
.optional-feature-migration-actions,
|
|
4216
4247
|
.optional-feature-batch-actions,
|
|
4217
4248
|
.optional-feature-migration-dialog menu { justify-content: stretch; }
|
|
@@ -10856,6 +10887,70 @@ body:not(.mobile-keyboard-open) .composer-input-row:has(.composer-workflow-mode-
|
|
|
10856
10887
|
color: var(--text);
|
|
10857
10888
|
box-shadow: 0 2rem 5rem var(--shadow), 0 0 2rem var(--glow-mauve);
|
|
10858
10889
|
}
|
|
10890
|
+
.extension-dialog.git-pull-error-dialog {
|
|
10891
|
+
width: min(46rem, calc(100vw - 2rem));
|
|
10892
|
+
border-color: rgba(243, 139, 168, 0.52);
|
|
10893
|
+
box-shadow: 0 2rem 5rem var(--shadow), 0 0 2rem rgba(243, 139, 168, 0.18);
|
|
10894
|
+
}
|
|
10895
|
+
.git-pull-error-dialog h2 {
|
|
10896
|
+
margin: 0;
|
|
10897
|
+
color: var(--ctp-red);
|
|
10898
|
+
}
|
|
10899
|
+
.git-pull-error-output {
|
|
10900
|
+
max-height: min(24rem, 48vh);
|
|
10901
|
+
margin: 0.9rem 0 0;
|
|
10902
|
+
padding: 0.9rem;
|
|
10903
|
+
overflow: auto;
|
|
10904
|
+
border: 1px solid rgba(243, 139, 168, 0.34);
|
|
10905
|
+
border-radius: 0.72rem;
|
|
10906
|
+
color: var(--ctp-text);
|
|
10907
|
+
background: rgba(var(--ctp-crust-rgb), 0.86);
|
|
10908
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
|
|
10909
|
+
font-size: 0.9rem;
|
|
10910
|
+
line-height: 1.45;
|
|
10911
|
+
overflow-wrap: anywhere;
|
|
10912
|
+
user-select: text;
|
|
10913
|
+
white-space: pre-wrap;
|
|
10914
|
+
}
|
|
10915
|
+
.git-pull-error-recovery {
|
|
10916
|
+
margin-top: 0.9rem;
|
|
10917
|
+
padding: 0.9rem;
|
|
10918
|
+
border: 1px solid rgba(249, 226, 175, 0.38);
|
|
10919
|
+
border-radius: 0.72rem;
|
|
10920
|
+
background: rgba(249, 226, 175, 0.08);
|
|
10921
|
+
}
|
|
10922
|
+
.git-pull-error-recovery[hidden] { display: none; }
|
|
10923
|
+
.git-pull-error-recovery > strong { color: var(--ctp-yellow); }
|
|
10924
|
+
.git-pull-error-recovery > p {
|
|
10925
|
+
margin: 0.4rem 0 0;
|
|
10926
|
+
color: var(--ctp-subtext1);
|
|
10927
|
+
}
|
|
10928
|
+
.git-pull-error-recovery-actions {
|
|
10929
|
+
display: flex;
|
|
10930
|
+
flex-wrap: wrap;
|
|
10931
|
+
justify-content: flex-end;
|
|
10932
|
+
gap: 0.55rem;
|
|
10933
|
+
margin-top: 0.75rem;
|
|
10934
|
+
}
|
|
10935
|
+
.git-pull-error-dialog[aria-busy="true"] .git-pull-error-recovery {
|
|
10936
|
+
opacity: 0.72;
|
|
10937
|
+
}
|
|
10938
|
+
.git-pull-error-status {
|
|
10939
|
+
min-height: 1.3rem;
|
|
10940
|
+
margin: 0.65rem 0 0;
|
|
10941
|
+
}
|
|
10942
|
+
.git-pull-error-status.success { color: var(--ctp-green); }
|
|
10943
|
+
.git-pull-error-status.error { color: var(--ctp-red); }
|
|
10944
|
+
@media (max-width: 34rem) {
|
|
10945
|
+
.git-pull-error-recovery-actions,
|
|
10946
|
+
.git-pull-error-dialog menu {
|
|
10947
|
+
display: grid;
|
|
10948
|
+
grid-template-columns: 1fr;
|
|
10949
|
+
}
|
|
10950
|
+
.git-pull-error-recovery-actions button,
|
|
10951
|
+
.git-pull-error-dialog menu button { width: 100%; }
|
|
10952
|
+
}
|
|
10953
|
+
|
|
10859
10954
|
.extension-dialog.feature-decision-dialog {
|
|
10860
10955
|
width: min(30rem, calc(100vw - 2rem));
|
|
10861
10956
|
}
|
|
@@ -487,7 +487,8 @@ function handleTranscriptContinuityPrompt(command, base) {
|
|
|
487
487
|
function handleMobileBlockerPrompt(command, base) {
|
|
488
488
|
if (String(command.message || "").trim() !== "fixture mobile blocker") return false;
|
|
489
489
|
respond({ ...base, data: { output: "mobile blocker fixture accepted" } });
|
|
490
|
-
|
|
490
|
+
// Model a handled extension command: it opens a dialog without starting an
|
|
491
|
+
// agent turn, so the browser must settle from the accepted prompt response.
|
|
491
492
|
emitEvent({
|
|
492
493
|
type: "extension_ui_request",
|
|
493
494
|
id: "fixture_blocker_12345678",
|
|
@@ -707,8 +707,182 @@ assert.match(server, /"\/api\/git-operation\/resolve-with-agent"[\s\S]*openGitCo
|
|
|
707
707
|
assert.match(app, /async function pullGitChangesDialog\(\)[\s\S]*api\("\/api\/git-changes\/pull", \{ method: "POST"/, "git changes modal should post to the pull endpoint from the Pull button");
|
|
708
708
|
assert.match(app, /async function pullGitFooterSync\(tabId = activeTabId\)[\s\S]*api\("\/api\/git-changes\/pull", \{ method: "POST", body: \{ remote: "origin" \}, tabId \}\)[\s\S]*requestGitFooterWebuiPayload\(tabContext, \{ force: true \}\)/, "incoming-only footer Sync should pull directly from origin and refresh the footer payload");
|
|
709
709
|
assert.doesNotMatch(app.match(/async function pullGitFooterSync[\s\S]*?\n\}/)?.[0] || "", /git-workflow\/push|appConfirmText/, "the direct footer pull path should neither push nor open a confirmation");
|
|
710
|
-
assert.match(
|
|
711
|
-
assert.match(
|
|
710
|
+
assert.match(html, /id="gitPullErrorDialog"[\s\S]*aria-labelledby="gitPullErrorDialogTitle"[\s\S]*id="gitPullErrorOutput"[\s\S]*id="gitPullErrorRecovery"[^>]*hidden[\s\S]*id="gitPullErrorReviewButton"[\s\S]*id="gitPullErrorRebaseButton"[\s\S]*id="gitPullErrorMergeButton"[\s\S]*id="gitPullErrorCopyButton"[\s\S]*id="gitPullErrorCloseButton"/, "footer pull failures should use a labelled native dialog with review, rebase, merge, copy, and close actions");
|
|
711
|
+
assert.match(css, /\.extension-dialog\.git-pull-error-dialog[\s\S]*\.git-pull-error-output \{[\s\S]*user-select: text;[\s\S]*white-space: pre-wrap;[\s\S]*\.git-pull-error-recovery-actions \{[\s\S]*flex-wrap: wrap;/, "Git pull error output and recovery actions should remain readable, selectable, and responsive");
|
|
712
|
+
assert.match(app, /function gitFailureDisplayText\(response[\s\S]*result\.stderr = ""[\s\S]*formatGitCommandResult\(result\)[\s\S]*seen\.has\(key\)/, "Git pull error formatting should remove exact duplicate stderr while retaining unique command details");
|
|
713
|
+
assert.match(app, /function openGitPullErrorDialog\(message, \{ code = "", tabId = null, syncValue = "" \} = \{\}\)[\s\S]*code === "DIVERGED"[\s\S]*This does not mean conflicts exist[\s\S]*gitPullErrorRecovery\.hidden = !diverged[\s\S]*gitPullErrorCloseButton\?\.classList\.toggle\("primary", !diverged\)[\s\S]*gitPullErrorDialog\.showModal\(\)/, "DIVERGED pull errors should explain conflict uncertainty and expose native recovery actions while standard errors retain a primary Close action");
|
|
714
|
+
assert.match(app, /async function integrateGitPullDivergence\(mode\)[\s\S]*appConfirmText[\s\S]*danger: !merge[\s\S]*gitFooterSyncInFlightByTab\.add\(tabId\)[\s\S]*\/api\/git-changes\/integrate[\s\S]*body: \{ mode, confirmed: true \}[\s\S]*gitPullErrorContext\.requestId !== requestId[\s\S]*response\.code === "CONFLICTS"[\s\S]*openGitChangesDialog\(tabId\)[\s\S]*freshAheadValue[\s\S]*gitFooterSyncInFlightByTab\.delete\(tabId\)/, "merge and rebase recovery should require confirmation, reject stale responses, serialize per-tab mutations, use fresh ahead counts, and route actual conflicts to Git Changes");
|
|
715
|
+
assert.match(app, /function reviewGitPullDivergence\(\)[\s\S]*closeGitPullErrorDialog\(\)[\s\S]*openGitChangesDialog\(tabId\)/, "review recovery should open Git Changes without integrating");
|
|
716
|
+
assert.match(app, /async function copyGitPullErrorOutput\(\)[\s\S]*copyText\(gitPullErrorText\)[\s\S]*Error output copied to the clipboard/, "Git pull error dialog should copy the complete displayed output");
|
|
717
|
+
assert.match(app, /async function pullGitFooterSync[\s\S]*if \(!response\.ok\)[\s\S]*gitFailureDisplayText\(response[\s\S]*openGitPullErrorDialog\(message, \{ code: response\.code \|\| "", tabId, syncValue \}\)/, "footer pull failures should route structured, deduplicated details into the native dialog");
|
|
718
|
+
|
|
719
|
+
const gitFailureDisplayStart = app.indexOf("function gitFailureDisplayText(");
|
|
720
|
+
const gitFailureDisplayEnd = app.indexOf("\nfunction setGitPullErrorBusy(", gitFailureDisplayStart);
|
|
721
|
+
assert.ok(gitFailureDisplayStart >= 0 && gitFailureDisplayEnd > gitFailureDisplayStart, "Git failure display formatter should remain a standalone helper");
|
|
722
|
+
const gitFailureDisplayContext = {
|
|
723
|
+
formatGitCommandResult(result) {
|
|
724
|
+
const lines = [`$ ${result?.command || "git"}`];
|
|
725
|
+
if (result?.stdout?.trim()) lines.push("", result.stdout.trim());
|
|
726
|
+
if (result?.stderr?.trim()) lines.push("", result.stderr.trim());
|
|
727
|
+
if (result?.exitCode !== 0) lines.push("", `[exit: ${result?.exitCode}]`);
|
|
728
|
+
return lines.join("\n");
|
|
729
|
+
},
|
|
730
|
+
};
|
|
731
|
+
vm.runInNewContext(`${app.slice(gitFailureDisplayStart, gitFailureDisplayEnd)}\nthis.formatFailure = gitFailureDisplayText;`, gitFailureDisplayContext);
|
|
732
|
+
const repeatedStderr = "fatal: Not possible to fast-forward, aborting.";
|
|
733
|
+
const deduplicatedPullError = gitFailureDisplayContext.formatFailure({
|
|
734
|
+
error: repeatedStderr,
|
|
735
|
+
hint: "Local and remote branches have diverged.",
|
|
736
|
+
data: { command: "git pull --ff-only origin", stderr: repeatedStderr, stdout: "", exitCode: 128 },
|
|
737
|
+
});
|
|
738
|
+
assert.equal(deduplicatedPullError.split(repeatedStderr).length - 1, 1, "identical pull stderr should appear exactly once");
|
|
739
|
+
assert.match(deduplicatedPullError, /git pull --ff-only origin[\s\S]*\[exit: 128\]/, "deduplication should preserve command and exit details");
|
|
740
|
+
|
|
741
|
+
const gitPullErrorDialogStart = app.indexOf("function setGitPullErrorBusy(");
|
|
742
|
+
const gitPullErrorDialogEnd = app.indexOf("\nasync function pullGitFooterSync(", gitPullErrorDialogStart);
|
|
743
|
+
assert.ok(gitPullErrorDialogStart >= 0 && gitPullErrorDialogEnd > gitPullErrorDialogStart, "Git pull error dialog helpers should remain isolated from the pull request helper");
|
|
744
|
+
const copiedPullErrors = [];
|
|
745
|
+
const integrationRequests = [];
|
|
746
|
+
const integrationConfirmations = [];
|
|
747
|
+
const reviewedPullTabs = [];
|
|
748
|
+
const refreshedPullTabs = [];
|
|
749
|
+
const resumedPushes = [];
|
|
750
|
+
let integrationResponse = { ok: true, data: { changes: { summary: { ahead: 2 } } } };
|
|
751
|
+
const nativePullErrorDialog = { open: false, showModal() { this.open = true; }, close() { this.open = false; }, setAttribute() {} };
|
|
752
|
+
const nativePullErrorTitle = { textContent: "" };
|
|
753
|
+
const nativePullErrorDescription = { textContent: "" };
|
|
754
|
+
const nativePullErrorOutput = { textContent: "" };
|
|
755
|
+
const nativePullErrorStatus = { textContent: "", classList: { add() {}, remove() {} } };
|
|
756
|
+
const nativePullErrorRecovery = { hidden: true };
|
|
757
|
+
const nativePullErrorButton = () => ({ disabled: false, focus() {}, classList: { toggle() {} } });
|
|
758
|
+
const nativePullErrorMergeButton = nativePullErrorButton();
|
|
759
|
+
const nativePullErrorRebaseButton = nativePullErrorButton();
|
|
760
|
+
const nativePullErrorReviewButton = nativePullErrorButton();
|
|
761
|
+
const nativePullErrorCopyButton = nativePullErrorButton();
|
|
762
|
+
const nativePullErrorCloseButton = nativePullErrorButton();
|
|
763
|
+
const gitPullErrorDialogContext = {
|
|
764
|
+
gitPullErrorText: "",
|
|
765
|
+
gitPullErrorContext: { code: "", tabId: null, syncValue: "", busy: false, requestId: 0 },
|
|
766
|
+
activeTabId: "tab-pull",
|
|
767
|
+
tabs: [{ id: "tab-pull", title: "feature/sync" }, { id: "tab-rebase", title: "feature/rebase" }],
|
|
768
|
+
gitFooterSyncInFlightByTab: new Set(),
|
|
769
|
+
elements: {
|
|
770
|
+
gitPullErrorDialog: nativePullErrorDialog,
|
|
771
|
+
gitPullErrorDialogTitle: nativePullErrorTitle,
|
|
772
|
+
gitPullErrorDialogDescription: nativePullErrorDescription,
|
|
773
|
+
gitPullErrorOutput: nativePullErrorOutput,
|
|
774
|
+
gitPullErrorStatus: nativePullErrorStatus,
|
|
775
|
+
gitPullErrorRecovery: nativePullErrorRecovery,
|
|
776
|
+
gitPullErrorMergeButton: nativePullErrorMergeButton,
|
|
777
|
+
gitPullErrorRebaseButton: nativePullErrorRebaseButton,
|
|
778
|
+
gitPullErrorReviewButton: nativePullErrorReviewButton,
|
|
779
|
+
gitPullErrorCopyButton: nativePullErrorCopyButton,
|
|
780
|
+
gitPullErrorCloseButton: nativePullErrorCloseButton,
|
|
781
|
+
},
|
|
782
|
+
window: { alert() { throw new Error("native dialog should avoid alert fallback"); } },
|
|
783
|
+
queueMicrotask: (callback) => callback(),
|
|
784
|
+
copyText: async (text) => copiedPullErrors.push(text),
|
|
785
|
+
addEvent() {},
|
|
786
|
+
gitFooterCurrentBranch: () => "feature/sync",
|
|
787
|
+
appConfirmText: async (message, options) => { integrationConfirmations.push({ message, options }); return true; },
|
|
788
|
+
api: async (path, options) => { integrationRequests.push({ path, options }); return integrationResponse; },
|
|
789
|
+
gitFailureDisplayText: () => "integration conflict output",
|
|
790
|
+
openGitChangesDialog: (tabId) => reviewedPullTabs.push(tabId),
|
|
791
|
+
activeTabContext: (tabId) => ({ tabId }),
|
|
792
|
+
isCurrentTabContext: () => false,
|
|
793
|
+
renderFooter() {},
|
|
794
|
+
requestGitFooterWebuiPayload: (context) => refreshedPullTabs.push(context.tabId),
|
|
795
|
+
gitFooterSyncCounts: () => ({ ahead: 1, behind: 0 }),
|
|
796
|
+
pushGitFooterSync: async (tabId, value) => resumedPushes.push({ tabId, value }),
|
|
797
|
+
};
|
|
798
|
+
vm.runInNewContext(`${app.slice(gitPullErrorDialogStart, gitPullErrorDialogEnd)}\nthis.openPullError = openGitPullErrorDialog; this.copyPullError = copyGitPullErrorOutput; this.reviewPullError = reviewGitPullDivergence; this.integratePullError = integrateGitPullDivergence;`, gitPullErrorDialogContext);
|
|
799
|
+
gitPullErrorDialogContext.openPullError("network unavailable\n\ncheck the connection", { code: "DIVERGED", tabId: "tab-pull", syncValue: "⇡1 · ⇣2" });
|
|
800
|
+
assert.equal(nativePullErrorDialog.open, true, "Git pull error dialog should open natively");
|
|
801
|
+
assert.equal(nativePullErrorTitle.textContent, "Branches diverged", "DIVERGED popup should use a specific title");
|
|
802
|
+
assert.match(nativePullErrorDescription.textContent, /does not mean conflicts exist/, "DIVERGED popup should distinguish divergence from conflicts");
|
|
803
|
+
assert.equal(nativePullErrorRecovery.hidden, false, "DIVERGED popup should reveal recovery actions");
|
|
804
|
+
assert.equal(integrationRequests.length, 0, "opening divergence recovery must not mutate Git state");
|
|
805
|
+
assert.equal(nativePullErrorOutput.textContent, "network unavailable\n\ncheck the connection", "Git pull error dialog should display complete output");
|
|
806
|
+
await gitPullErrorDialogContext.copyPullError();
|
|
807
|
+
assert.deepEqual(copiedPullErrors, ["network unavailable\n\ncheck the connection"], "Git pull error copy action should preserve the complete output");
|
|
808
|
+
assert.equal(nativePullErrorStatus.textContent, "Error output copied to the clipboard.", "Git pull error dialog should announce copy success");
|
|
809
|
+
gitPullErrorDialogContext.reviewPullError();
|
|
810
|
+
assert.deepEqual(reviewedPullTabs, ["tab-pull"], "Review changes should open Git Changes for the originating tab");
|
|
811
|
+
assert.equal(integrationRequests.length, 0, "Review changes must remain non-mutating");
|
|
812
|
+
|
|
813
|
+
gitPullErrorDialogContext.openPullError("diverged", { code: "DIVERGED", tabId: "tab-pull", syncValue: "⇡1 · ⇣2" });
|
|
814
|
+
assert.equal(await gitPullErrorDialogContext.integratePullError("merge"), true, "confirmed merge recovery should succeed");
|
|
815
|
+
assert.deepEqual(JSON.parse(JSON.stringify(integrationRequests[0])), { path: "/api/git-changes/integrate", options: { method: "POST", body: { mode: "merge", confirmed: true }, tabId: "tab-pull" } }, "merge recovery should use the confirmed integration contract");
|
|
816
|
+
assert.equal(integrationConfirmations[0].options.confirmLabel, "Merge changes", "merge recovery should be the primary confirmed action");
|
|
817
|
+
assert.equal(integrationConfirmations[0].options.danger, false, "merge confirmation should use the normal primary style");
|
|
818
|
+
assert.deepEqual(refreshedPullTabs, ["tab-pull"], "successful integration should refresh the originating footer");
|
|
819
|
+
assert.deepEqual(resumedPushes, [{ tabId: "tab-pull", value: "⇡2" }], "successful integration should resume the existing confirmed push flow with the fresh outgoing count");
|
|
820
|
+
|
|
821
|
+
integrationResponse = { ok: false, code: "CONFLICTS", error: "conflicts created", data: { command: "git rebase @{upstream}", exitCode: 1 } };
|
|
822
|
+
gitPullErrorDialogContext.openPullError("diverged", { code: "DIVERGED", tabId: "tab-rebase", syncValue: "⇡2 · ⇣1" });
|
|
823
|
+
assert.equal(await gitPullErrorDialogContext.integratePullError("rebase"), false, "conflicted rebase recovery should stop");
|
|
824
|
+
assert.deepEqual(JSON.parse(JSON.stringify(integrationRequests[1].options.body)), { mode: "rebase", confirmed: true }, "rebase recovery should use the confirmed integration contract");
|
|
825
|
+
assert.equal(integrationConfirmations[1].options.confirmLabel, "Rebase commits", "rebase should remain an explicit alternative");
|
|
826
|
+
assert.equal(integrationConfirmations[1].options.danger, true, "rebase confirmation should warn that local commit IDs will be rewritten");
|
|
827
|
+
assert.deepEqual(reviewedPullTabs, ["tab-pull", "tab-rebase"], "actual conflicts should open the existing Git Changes panel");
|
|
828
|
+
assert.equal(resumedPushes.length, 1, "conflicted integration must not continue to push");
|
|
829
|
+
|
|
830
|
+
const pullGitFooterSyncStart = app.indexOf("async function pullGitFooterSync(");
|
|
831
|
+
const pullGitFooterSyncEnd = app.indexOf("\nasync function pullThenPushGitFooterSync(", pullGitFooterSyncStart);
|
|
832
|
+
assert.ok(pullGitFooterSyncStart >= 0 && pullGitFooterSyncEnd > pullGitFooterSyncStart, "footer pull should remain a standalone async frontend helper");
|
|
833
|
+
const pullGitFooterSyncSource = app.slice(pullGitFooterSyncStart, pullGitFooterSyncEnd);
|
|
834
|
+
const pullFailureEvents = [];
|
|
835
|
+
const pullFailureDialogs = [];
|
|
836
|
+
const pullFailureContext = {
|
|
837
|
+
gitFooterSyncInFlightByTab: new Set(),
|
|
838
|
+
activeTabContext: (tabId) => ({ tabId }),
|
|
839
|
+
hideFooterTooltip() {},
|
|
840
|
+
isCurrentTabContext: () => false,
|
|
841
|
+
renderFooter() {},
|
|
842
|
+
api: async () => ({ ok: false, code: "DIVERGED", error: "duplicated raw error", hint: "diverged", data: {} }),
|
|
843
|
+
gitFailureDisplayText: () => "deduplicated pull error",
|
|
844
|
+
addEvent: (message, level) => pullFailureEvents.push({ message, level }),
|
|
845
|
+
requestGitFooterWebuiPayload() {},
|
|
846
|
+
openGitPullErrorDialog: (message, options) => pullFailureDialogs.push({ message, options }),
|
|
847
|
+
};
|
|
848
|
+
vm.runInNewContext(`${pullGitFooterSyncSource}\nthis.runPullGitFooterSync = pullGitFooterSync;`, pullFailureContext);
|
|
849
|
+
assert.equal(await pullFailureContext.runPullGitFooterSync("tab-pull", { syncValue: "⇡1 · ⇣2" }), false, "failed footer pull should report failure to ordered Sync");
|
|
850
|
+
assert.deepEqual(pullFailureEvents, [{ message: "deduplicated pull error", level: "error" }], "failed footer pull should keep only deduplicated output in the event log");
|
|
851
|
+
assert.deepEqual(JSON.parse(JSON.stringify(pullFailureDialogs)), [{ message: "deduplicated pull error", options: { code: "DIVERGED", tabId: "tab-pull", syncValue: "⇡1 · ⇣2" } }], "failed footer pull should preserve structured recovery context");
|
|
852
|
+
assert.match(app, /async function pushGitFooterSync\(tabId = activeTabId, syncValue = ""\)[\s\S]*api\("\/api\/git-workflow\/push", \{ method: "POST", body: \{\}, tabId \}\)[\s\S]*response\.code === "NON_FAST_FORWARD"[\s\S]*recoverWithPullFirst = true[\s\S]*gitFooterSyncInFlightByTab\.delete\(tabId\)[\s\S]*pullThenPushGitFooterSync\(tabId, syncValue\)/, "non-fast-forward footer pushes should release their mutation lock before entering pull-first recovery");
|
|
853
|
+
const pushGitFooterSyncStart = app.indexOf("async function pushGitFooterSync(");
|
|
854
|
+
const pushGitFooterSyncEnd = app.indexOf("\nfunction renderGitFooterPayloadMeta(", pushGitFooterSyncStart);
|
|
855
|
+
assert.ok(pushGitFooterSyncStart >= 0 && pushGitFooterSyncEnd > pushGitFooterSyncStart, "footer push should remain a standalone async frontend helper");
|
|
856
|
+
const pushRecoveryRequests = [];
|
|
857
|
+
const pushRecoveryEvents = [];
|
|
858
|
+
const pushRecoveryCalls = [];
|
|
859
|
+
const pushRecoveryInFlight = new Set();
|
|
860
|
+
const pushRecoveryContext = {
|
|
861
|
+
activeTabId: "tab-push",
|
|
862
|
+
gitFooterSyncInFlightByTab: pushRecoveryInFlight,
|
|
863
|
+
gitFooterSyncCounts: () => ({ ahead: 2, behind: 0 }),
|
|
864
|
+
activeTabContext: (tabId) => ({ tabId }),
|
|
865
|
+
tabs: [{ id: "tab-push", title: "feature/push-recovery" }],
|
|
866
|
+
hideFooterTooltip() {},
|
|
867
|
+
gitFooterCurrentBranch: () => "feature/push-recovery",
|
|
868
|
+
appConfirmText: async () => true,
|
|
869
|
+
isCurrentTabContext: () => false,
|
|
870
|
+
renderFooter() {},
|
|
871
|
+
api: async (path, options) => {
|
|
872
|
+
pushRecoveryRequests.push({ path, options });
|
|
873
|
+
return { ok: false, code: "NON_FAST_FORWARD", error: "remote contains new commits" };
|
|
874
|
+
},
|
|
875
|
+
addEvent: (message, level) => pushRecoveryEvents.push({ message, level }),
|
|
876
|
+
requestGitFooterWebuiPayload() {},
|
|
877
|
+
formatGitCommandResult: () => "",
|
|
878
|
+
pullThenPushGitFooterSync: async (tabId, value) => pushRecoveryCalls.push({ tabId, value, locked: pushRecoveryInFlight.has(tabId) }),
|
|
879
|
+
};
|
|
880
|
+
vm.runInNewContext(`${app.slice(pushGitFooterSyncStart, pushGitFooterSyncEnd)}\nthis.runPushGitFooterSync = pushGitFooterSync;`, pushRecoveryContext);
|
|
881
|
+
await pushRecoveryContext.runPushGitFooterSync("tab-push", "⇡2");
|
|
882
|
+
assert.deepEqual(JSON.parse(JSON.stringify(pushRecoveryRequests)), [{ path: "/api/git-workflow/push", options: { method: "POST", body: {}, tabId: "tab-push" } }], "footer Push should not offer or attempt force-with-lease after a non-fast-forward rejection");
|
|
883
|
+
assert.deepEqual(JSON.parse(JSON.stringify(pushRecoveryCalls)), [{ tabId: "tab-push", value: "⇡2", locked: false }], "footer Push should hand non-fast-forward recovery to the existing pull-then-push workflow after unlocking the tab");
|
|
884
|
+
assert.deepEqual(pushRecoveryEvents, [{ message: "Push found incoming commits. Starting pull-first recovery.", level: "info" }], "footer Push should explain the switch to pull-first recovery");
|
|
885
|
+
assert.match(app, /chip\.key === "sync" && visible\("webui-sync-push"\)[\s\S]*syncAction === "pull"[\s\S]*pullGitFooterSync\(tabId\)[\s\S]*syncAction === "pull-push"[\s\S]*pullThenPushGitFooterSync\(tabId, chip\.value\)[\s\S]*syncAction === "push"[\s\S]*pushGitFooterSync\(tabId, chip\.value\)/, "footer Sync should route incoming, diverged, and outgoing states to their respective actions");
|
|
712
886
|
const gitFooterSyncRoutingSource = appFunctionSource("gitFooterSyncCounts", "gitFooterCurrentBranch");
|
|
713
887
|
const gitFooterSyncRouting = JSON.parse(vm.runInNewContext(`${gitFooterSyncRoutingSource}\nJSON.stringify({
|
|
714
888
|
incoming: gitFooterSyncAction({ key: "sync", value: "⇣2" }),
|
|
@@ -717,7 +891,23 @@ const gitFooterSyncRouting = JSON.parse(vm.runInNewContext(`${gitFooterSyncRouti
|
|
|
717
891
|
unavailable: gitFooterSyncAction({ key: "sync", value: "no upstream" }),
|
|
718
892
|
other: gitFooterSyncAction({ key: "changes", value: "⇣2" }),
|
|
719
893
|
})`));
|
|
720
|
-
assert.deepEqual(gitFooterSyncRouting, { incoming: "pull", outgoing: "push", diverged: "push", unavailable: "", other: "" }, "Sync routing should pull
|
|
894
|
+
assert.deepEqual(gitFooterSyncRouting, { incoming: "pull", outgoing: "push", diverged: "pull-push", unavailable: "", other: "" }, "Sync routing should pull before pushing whenever incoming and outgoing commits both exist");
|
|
895
|
+
const pullThenPushGitFooterSyncStart = app.indexOf("async function pullThenPushGitFooterSync(");
|
|
896
|
+
const pullThenPushGitFooterSyncEnd = app.indexOf("\nasync function pushGitFooterSync(", pullThenPushGitFooterSyncStart);
|
|
897
|
+
assert.ok(pullThenPushGitFooterSyncStart >= 0 && pullThenPushGitFooterSyncEnd > pullThenPushGitFooterSyncStart, "pull-then-push Sync should remain a standalone async frontend helper");
|
|
898
|
+
const pullThenPushGitFooterSyncSource = app.slice(pullThenPushGitFooterSyncStart, pullThenPushGitFooterSyncEnd);
|
|
899
|
+
const orderedSyncCalls = [];
|
|
900
|
+
const orderedSyncContext = {
|
|
901
|
+
pullGitFooterSync: async (tabId) => { orderedSyncCalls.push(`pull:${tabId}`); return true; },
|
|
902
|
+
pushGitFooterSync: async (tabId, value) => { orderedSyncCalls.push(`push:${tabId}:${value}`); },
|
|
903
|
+
};
|
|
904
|
+
vm.runInNewContext(`${pullThenPushGitFooterSyncSource}\nthis.runPullThenPushGitFooterSync = pullThenPushGitFooterSync;`, orderedSyncContext);
|
|
905
|
+
await orderedSyncContext.runPullThenPushGitFooterSync("tab-sync", "⇡1 · ⇣2");
|
|
906
|
+
assert.deepEqual(orderedSyncCalls, ["pull:tab-sync", "push:tab-sync:⇡1 · ⇣2"], "combined Sync should await pull before push");
|
|
907
|
+
orderedSyncCalls.length = 0;
|
|
908
|
+
orderedSyncContext.pullGitFooterSync = async (tabId) => { orderedSyncCalls.push(`pull:${tabId}`); return false; };
|
|
909
|
+
await orderedSyncContext.runPullThenPushGitFooterSync("tab-sync", "⇡1 · ⇣2");
|
|
910
|
+
assert.deepEqual(orderedSyncCalls, ["pull:tab-sync"], "combined Sync should skip push when pull fails or cannot start");
|
|
721
911
|
assert.match(app, /function gitDiffDisplayLine\(row, side\)[\s\S]*`-\$\{text\}`[\s\S]*`\+\$\{text\}`/, "git changes modal should render changed lines with +/- prefixes");
|
|
722
912
|
assert.match(app, /function gitUntrackedEntryToDiffFile\(entry\)[\s\S]*?renderRowLimit:\s*Number\.POSITIVE_INFINITY[\s\S]*?type: "added"/, "untracked files should render as complete added-file diffs without the row preview cap");
|
|
723
913
|
assert.match(app, /async function loadMissingGitUntrackedContent\(entry[\s\S]*?\/api\/git-changes\/untracked-file\?path=/, "untracked path-only payloads should fetch complete file contents instead of rendering as empty files");
|
|
@@ -2195,6 +2385,7 @@ assert.match(server, /function optionalFeaturePackageStatus\(featureId, cwd = op
|
|
|
2195
2385
|
assert.match(server, /if \(beforeStatus\.locallyConfigured\)[\s\S]*load it twice[\s\S]*local-resource-conflict/, "server should block npm registration when a top-level resource already owns the optional feature");
|
|
2196
2386
|
assert.match(server, /function installOptionalFeaturePackage\(featureId, cwd = options\.cwd\)[\s\S]*const source = `npm:\$\{packageName\}`[\s\S]*resolvePiCommand\(\["install", source\]\)/, "server should install and update optional features through the selected Pi CLI");
|
|
2197
2387
|
assert.match(server, /function configuredAgentNpmRoot\(\)/, "status discovery should consider Pi's agent npm root for legacy or hoisted packages");
|
|
2388
|
+
assert.match(server, /function packageNodeModulesPath\(nodeModulesRoot, packageName\)[\s\S]*path\.join\(nodeModulesRoot,[\s\S]*split\("\/"\)/, "status discovery should map scoped npm package names into node_modules paths");
|
|
2198
2389
|
assert.match(server, /resolveInstalledPackageSubpath\(nodeModulesRef\.packageName, nodeModulesRef\.subpath\)/, "started Web UI resource resolution should support configured package resources");
|
|
2199
2390
|
assert.match(server, /url\.pathname === "\/api\/optional-features" && req\.method === "GET"/, "server should expose optional feature package status endpoint");
|
|
2200
2391
|
assert.match(server, /url\.pathname === "\/api\/optional-feature-install" && req\.method === "POST"/, "server should preserve the optional feature single-install endpoint");
|
|
@@ -31,6 +31,9 @@ assert.match(surfaceSource, /Checking optional features…[\s\S]*elapsed[\s\S]*C
|
|
|
31
31
|
assert.match(surfaceSource, /Previous optional features need migration[\s\S]*Migrate…[\s\S]*Later/, "action-required migration should expose Migrate and persisted Later actions");
|
|
32
32
|
assert.match(surfaceSource, /safely excluded[\s\S]*Copy recommended fix[\s\S]*Recheck/, "conflicts should explain safe exclusion using a recommended path-free fix and recheck");
|
|
33
33
|
assert.match(surfaceSource, /started safely without optional companions[\s\S]*Recheck/, "degraded startup should remain core-safe and recheckable");
|
|
34
|
+
assert.match(surfaceSource, /noticeDismissKey[\s\S]*optionalFeatureMigrationDismissedNoticeKey === noticeDismissKey[\s\S]*surface\.hidden = true/, "a dismissed degraded snapshot should stay hidden for the current page lifetime");
|
|
35
|
+
assert.match(surfaceSource, /optional-feature-migration-dismiss[\s\S]*aria-label", "Close optional feature startup notice"/, "degraded startup should expose an accessible dismiss button");
|
|
36
|
+
assert.match(app, /function dismissOptionalFeatureMigrationNotice\(\)[\s\S]*optionalFeatureMigrationDismissedNoticeKey = key[\s\S]*renderOptionalFeatureMigrationSurface\(\)/, "the degraded dismiss action should hide the current snapshot through the existing renderer");
|
|
34
37
|
assert.match(surfaceSource, /Migrating optional features[\s\S]*Retry failed[\s\S]*Copy commands[\s\S]*Restart tab/, "progress and recovery should expose the required sequential/retry/copy/deferred-restart actions");
|
|
35
38
|
assert.match(surfaceSource, /if \(optionalFeatureRestartNotice\.restartDeferred\)[\s\S]*Restart tab[\s\S]*else[\s\S]*Dismiss/, "a deferred restart action must remain persistent until restart succeeds");
|
|
36
39
|
assert.match(surfaceSource, /optionalFeatureMigrationCompletionIsDismissed\(snapshot\)[\s\S]*surface\.hidden = true[\s\S]*phase === "complete"[\s\S]*dismissOptionalFeatureMigrationCompletion/, "dismissing a completed migration should hide the complete surface, not only its restart notice");
|
|
@@ -71,6 +74,7 @@ assert.match(surfaceSource, /readyCanAutoDismiss[\s\S]*scheduleOptionalFeatureRe
|
|
|
71
74
|
|
|
72
75
|
assert.match(css, /\.optional-feature-migration-surface[\s\S]*\.optional-feature-migration-dialog[\s\S]*@media \(max-width: 34rem\)/, "migration surfaces should have desktop and responsive styling");
|
|
73
76
|
assert.match(css, /\.optional-feature-migration-card:focus-visible/, "focused completion summary should have a visible focus treatment");
|
|
77
|
+
assert.match(css, /\.optional-feature-migration-card\.phase-degraded[\s\S]*padding-right:[^;]+;[\s\S]*\.optional-feature-migration-dismiss \{[\s\S]*position: absolute;[\s\S]*top:[^;]+;[\s\S]*right:[^;]+;/, "the degraded popup should reserve space for a top-right dismiss button");
|
|
74
78
|
|
|
75
79
|
assert.match(readme, /read-only startup audit/i, "README should document startup auditing");
|
|
76
80
|
assert.match(readme, /--migrate-optional-features[\s\S]*--migration-dry-run/, "README should document explicit unattended migration and dry-run flags");
|
|
@@ -98,11 +98,19 @@ const routingAdd = sendSource.indexOf("promptRoutingTabs.add(targetTabId);");
|
|
|
98
98
|
const workingMark = sendSource.indexOf("markTabWorkingLocally(targetTabId);");
|
|
99
99
|
const responseApply = sendSource.indexOf("applyResponseTab(response);");
|
|
100
100
|
const successDelete = sendSource.indexOf("promptRoutingTabs.delete(targetTabId);", responseApply);
|
|
101
|
+
const nativeResponseBranch = sendSource.indexOf('if (response?.command === "native_slash_command"', responseApply);
|
|
101
102
|
const catchStart = sendSource.indexOf("} catch (error)", successDelete);
|
|
102
103
|
const failureDelete = sendSource.indexOf("promptRoutingTabs.delete(targetTabId);", catchStart);
|
|
103
104
|
const idleMark = sendSource.indexOf("markTabIdleLocally(targetTabId);", catchStart);
|
|
104
105
|
assert.ok(routingAdd >= 0 && routingAdd < workingMark, "fresh prompts should enter routing protection before rendering working state");
|
|
105
106
|
assert.ok(responseApply >= 0 && successDelete > responseApply && successDelete < catchStart, "successful routing protection should end only after applying the server handoff response");
|
|
107
|
+
assert.ok(successDelete < nativeResponseBranch, "all accepted prompts, including extension commands, should release routing ownership before native-command special cases");
|
|
106
108
|
assert.ok(failureDelete > catchStart && failureDelete < idleMark, "failed routing should clear protection before restoring idle state");
|
|
107
109
|
|
|
110
|
+
const abortSource = functionSource("abortActiveRun");
|
|
111
|
+
const abortRequest = abortSource.indexOf('await api("/api/abort"');
|
|
112
|
+
const abortRoutingDelete = abortSource.indexOf("promptRoutingTabs.delete(tabContext.tabId);", abortRequest);
|
|
113
|
+
const abortStateChecks = abortSource.indexOf("scheduleAbortStateChecks(tabContext);", abortRoutingDelete);
|
|
114
|
+
assert.ok(abortRequest >= 0 && abortRoutingDelete > abortRequest && abortRoutingDelete < abortStateChecks, "a successful abort should release local routing ownership before canonical state checks");
|
|
115
|
+
|
|
108
116
|
console.log("prompt routing tab-status checks passed");
|