@firstpick/pi-package-webui 0.8.9 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/bin/pi-webui.mjs +10 -2
- package/package.json +1 -1
- package/public/app.js +233 -49
- package/public/index.html +1 -0
- package/public/styles.css +48 -7
- package/tests/browser/interaction-continuity.spec.mjs +62 -0
- package/tests/browser/search-match-highlighting.spec.mjs +104 -0
- package/tests/file-viewer-search-static.test.mjs +7 -2
- package/tests/foreground-transcript-catch-up-static.test.mjs +91 -0
- package/tests/http-endpoints-harness.test.mjs +29 -0
- package/tests/mobile-static.test.mjs +7 -2
- package/tests/search-match-highlighting-static.test.mjs +27 -0
- package/tests/stream-output-isolation-static.test.mjs +1 -1
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ Use Pi from a local browser with tabs, streaming responses, uploads, model contr
|
|
|
9
9
|
- Work in several Pi sessions at once.
|
|
10
10
|
- Change models and thinking effort without leaving the browser.
|
|
11
11
|
- Upload files and images, use slash-command suggestions, and manage follow-up prompts.
|
|
12
|
+
- Search files, transcripts, and live agent output with every match highlighted.
|
|
12
13
|
- Resume sessions, switch projects, and use guided Git helpers.
|
|
13
14
|
- Keep phone sessions compact with expandable terminal navigation and secondary composer actions.
|
|
14
15
|
- Add optional themes, statistics, remote access, voice features, and other companion packages.
|
|
@@ -31,6 +32,10 @@ Inside Pi, run:
|
|
|
31
32
|
|
|
32
33
|
Open the printed address, usually <http://127.0.0.1:31415/>. Check a running server with `/webui-status`.
|
|
33
34
|
|
|
35
|
+
Press `Ctrl/Cmd+F` while a file, transcript, or subagent output view is active to highlight every match; use `Enter` and `Shift+Enter` to move between matches.
|
|
36
|
+
|
|
37
|
+
You can leave the Web UI on another desktop workspace while Pi runs. When you return, it replaces hidden live-output updates with one current transcript snapshot so the page does not replay every intermediate render.
|
|
38
|
+
|
|
34
39
|
You can also install the standalone launcher:
|
|
35
40
|
|
|
36
41
|
```bash
|
|
@@ -42,6 +47,8 @@ If no working directory is supplied, the browser asks which project to open firs
|
|
|
42
47
|
|
|
43
48
|
To create a parallel checkout, click the Git branch box in the footer and use **Create branch worktree**. After the worktree is created, the browser asks whether to open it in a separate Pi tab and switch there; choosing **Cancel** keeps the current tab active and leaves the new worktree available for later.
|
|
44
49
|
|
|
50
|
+
Pushes started from the Git footer or Guided Git target the active tab's currently checked-out branch on the remote and track that same-named remote branch as its upstream, replacing a mismatched upstream such as `origin/main`.
|
|
51
|
+
|
|
45
52
|
On a phone, tap the current terminal name to open full-screen terminal navigation. Grouped terminals use their title as a dropdown; open the group, then choose an individual terminal. The composer keeps the prompt, attachment, Send, and active-run controls visible; tap **More** to open session, workflow, command, and mode controls in a full-screen overlay, then use the top `−` control or `Escape` to minimize it. Todo progress stays on one line until you tap it to expand the full goal, progress bar, and checklist. Git footer **Details** opens full-screen with refresh inside and a top `−` button to minimize it; session metrics and workspace, Git, and runtime details use compact grouped grids instead of stretched rows. Phone layouts use balanced compact text, spacing, cards, and 40-pixel controls so more content remains visible. Hover-only tooltips stay hidden on touch controls. In the **Control Deck**, desktop section dragging and `Alt+Arrow` movement are always available. On a phone, tap **Edit** to enable reordering, then tap **Done** to lock the order again.
|
|
46
53
|
|
|
47
54
|
## Keep it private
|
package/bin/pi-webui.mjs
CHANGED
|
@@ -8339,12 +8339,20 @@ async function handleGitWorkflowRequest(pathname, body = {}, tabOrCwd = options.
|
|
|
8339
8339
|
// clobber remote commits we have not seen, and requires confirmation.
|
|
8340
8340
|
const forceWithLease = body.forceWithLease === true;
|
|
8341
8341
|
if (forceWithLease) requireConfirmed(body, `Force-pushing ${currentBranch} (--force-with-lease) rewrites the remote branch and`);
|
|
8342
|
-
const
|
|
8343
|
-
const
|
|
8342
|
+
const remotes = await gitRemoteNames(root);
|
|
8343
|
+
const remote = remotes.includes("origin") ? "origin" : remotes[0];
|
|
8344
|
+
const args = remote
|
|
8345
|
+
? ["push", "-u", ...(forceWithLease ? ["--force-with-lease"] : []), remote, "HEAD"]
|
|
8346
|
+
: ["push", ...(forceWithLease ? ["--force-with-lease"] : [])];
|
|
8347
|
+
const label = remote
|
|
8348
|
+
? `git push -u${forceWithLease ? " --force-with-lease" : ""} ${remote} HEAD`
|
|
8349
|
+
: undefined;
|
|
8350
|
+
const payload = await runGuardedGitMutation(args, { cwd: root, label, timeoutMs: 15 * 60 * 1000 });
|
|
8344
8351
|
if (payload.data) {
|
|
8345
8352
|
payload.data.branch = currentBranch;
|
|
8346
8353
|
payload.data.protectedBranch = protectedBranch;
|
|
8347
8354
|
payload.data.forceWithLease = forceWithLease;
|
|
8355
|
+
if (remote) payload.data.remote = remote;
|
|
8348
8356
|
}
|
|
8349
8357
|
return applyGitSyncFailure(payload, { push: true });
|
|
8350
8358
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firstpick/pi-package-webui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
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
|
@@ -9,7 +9,7 @@ import { buildIssuePayload, createIssueWizardCatalog, createIssueWizardState, ge
|
|
|
9
9
|
import { createIssueBotClient, readIssueBotRuntimeConfig } from "./issue-bot-client.mjs";
|
|
10
10
|
import { MOBILE_SHELL_STORAGE_KEY, TABLET_SHELL_STORAGE_KEY, createMobileShellState, isMobileShellV2Enabled, mobileNavigationTargetFromSearch, normalizeMobileNavigationTarget, reduceMobileShellState, resolveMobileShellFeatureMode, resolveTabletShellFeatureMode } from "./mobile-shell-state.mjs";
|
|
11
11
|
import { createTranscriptRenderer } from "./transcript-renderer.mjs";
|
|
12
|
-
import { createStreamOutputController } from "./stream-output-controller.mjs";
|
|
12
|
+
import { classifyTranscriptStreamEvent, createStreamOutputController } from "./stream-output-controller.mjs";
|
|
13
13
|
import { installMiddleButtonDragScroll } from "./middle-button-drag-scroll.mjs";
|
|
14
14
|
import { PI_THEME_EXPORT_FIELDS, THEME_TOKEN_GROUPS, canonicalizeTheme, serializeTheme, themeColorToRgb, validateTheme } from "./theme-contract.mjs";
|
|
15
15
|
import {
|
|
@@ -318,6 +318,7 @@ const elements = {
|
|
|
318
318
|
fileViewerSourceModeButton: $("#fileViewerSourceModeButton"),
|
|
319
319
|
fileViewerPreviewModeButton: $("#fileViewerPreviewModeButton"),
|
|
320
320
|
fileViewerEditor: $("#fileViewerEditor"),
|
|
321
|
+
fileViewerSearchOverlay: $("#fileViewerSearchOverlay"),
|
|
321
322
|
fileViewerPreview: $("#fileViewerPreview"),
|
|
322
323
|
fileViewerChanges: $("#fileViewerChanges"),
|
|
323
324
|
fileViewerStatus: $("#fileViewerStatus"),
|
|
@@ -574,7 +575,6 @@ let fileViewerSearchMatches = [];
|
|
|
574
575
|
let fileViewerSearchIndex = -1;
|
|
575
576
|
let fileViewerSearchTruncated = false;
|
|
576
577
|
let fileViewerSearchTimer = null;
|
|
577
|
-
let fileViewerSearchHighlightElement = null;
|
|
578
578
|
let fileContextMenuState = null;
|
|
579
579
|
let sidePanelContextMenuState = null;
|
|
580
580
|
let gitFooterContextMenuState = null;
|
|
@@ -760,6 +760,12 @@ let refreshFooterTimer = null;
|
|
|
760
760
|
let refreshTabsTimer = null;
|
|
761
761
|
let tabsRenderFrame = null;
|
|
762
762
|
let foregroundReconcileTimer = null;
|
|
763
|
+
let foregroundSupplementalRefreshCancel = null;
|
|
764
|
+
let foregroundTranscriptCatchUpRequired = document.visibilityState === "hidden";
|
|
765
|
+
let foregroundTranscriptSuppressedEvents = 0;
|
|
766
|
+
let eventStreamPausedForBackground = false;
|
|
767
|
+
let backgroundReconnectSnapshotFresh = false;
|
|
768
|
+
let foregroundReconnectSnapshotFreshUntil = 0;
|
|
763
769
|
let eventSource = null;
|
|
764
770
|
const supervisorEventCursors = new Map();
|
|
765
771
|
const supervisorRetiredEpochs = new Map();
|
|
@@ -12926,16 +12932,84 @@ function textOffsetPosition(root, offset) {
|
|
|
12926
12932
|
return null;
|
|
12927
12933
|
}
|
|
12928
12934
|
|
|
12935
|
+
function textOffsetRange(root, match) {
|
|
12936
|
+
const start = textOffsetPosition(root, match.start);
|
|
12937
|
+
const end = textOffsetPosition(root, match.end);
|
|
12938
|
+
if (!start || !end) return null;
|
|
12939
|
+
const range = document.createRange();
|
|
12940
|
+
range.setStart(start.node, start.offset);
|
|
12941
|
+
range.setEnd(end.node, end.offset);
|
|
12942
|
+
return range;
|
|
12943
|
+
}
|
|
12944
|
+
|
|
12945
|
+
function syncFileViewerSearchOverlayScroll() {
|
|
12946
|
+
const editor = elements.fileViewerEditor;
|
|
12947
|
+
const overlay = elements.fileViewerSearchOverlay;
|
|
12948
|
+
if (!editor || !overlay || overlay.hidden) return;
|
|
12949
|
+
overlay.scrollTop = editor.scrollTop;
|
|
12950
|
+
overlay.scrollLeft = editor.scrollLeft;
|
|
12951
|
+
}
|
|
12952
|
+
|
|
12929
12953
|
function clearFileViewerSearchHighlight() {
|
|
12954
|
+
globalThis.CSS?.highlights?.delete("file-viewer-search-match");
|
|
12930
12955
|
globalThis.CSS?.highlights?.delete("file-viewer-search-current");
|
|
12931
|
-
|
|
12932
|
-
|
|
12956
|
+
for (const surface of [elements.fileViewerPreview, elements.fileViewerChanges]) {
|
|
12957
|
+
for (const node of surface?.querySelectorAll(".file-viewer-search-match-fallback, .file-viewer-search-current-fallback") || []) {
|
|
12958
|
+
node.classList.remove("file-viewer-search-match-fallback", "file-viewer-search-current-fallback");
|
|
12959
|
+
}
|
|
12960
|
+
}
|
|
12961
|
+
const overlay = elements.fileViewerSearchOverlay;
|
|
12962
|
+
if (overlay) {
|
|
12963
|
+
overlay.hidden = true;
|
|
12964
|
+
overlay.replaceChildren();
|
|
12965
|
+
}
|
|
12966
|
+
elements.fileViewerEditor?.closest(".file-viewer-content")?.classList.remove("search-highlights-source");
|
|
12967
|
+
}
|
|
12968
|
+
|
|
12969
|
+
function renderFileViewerSourceSearchHighlights() {
|
|
12970
|
+
const editor = elements.fileViewerEditor;
|
|
12971
|
+
const overlay = elements.fileViewerSearchOverlay;
|
|
12972
|
+
if (!editor || !overlay || !fileViewerSearchMatches.length) return;
|
|
12973
|
+
const text = fileViewerSearchText();
|
|
12974
|
+
const fragment = document.createDocumentFragment();
|
|
12975
|
+
let offset = 0;
|
|
12976
|
+
fileViewerSearchMatches.forEach((match, index) => {
|
|
12977
|
+
if (match.start > offset) fragment.append(document.createTextNode(text.slice(offset, match.start)));
|
|
12978
|
+
const mark = make("mark", `file-viewer-search-match${index === fileViewerSearchIndex ? " current" : ""}`, text.slice(match.start, match.end));
|
|
12979
|
+
fragment.append(mark);
|
|
12980
|
+
offset = match.end;
|
|
12981
|
+
});
|
|
12982
|
+
if (offset < text.length) fragment.append(document.createTextNode(text.slice(offset)));
|
|
12983
|
+
overlay.replaceChildren(fragment);
|
|
12984
|
+
overlay.hidden = false;
|
|
12985
|
+
editor.closest(".file-viewer-content")?.classList.add("search-highlights-source");
|
|
12986
|
+
syncFileViewerSearchOverlayScroll();
|
|
12987
|
+
}
|
|
12988
|
+
|
|
12989
|
+
function renderFileViewerSearchHighlights() {
|
|
12990
|
+
clearFileViewerSearchHighlight();
|
|
12991
|
+
const surface = fileViewerSearchSurface();
|
|
12992
|
+
if (!surface || !fileViewerSearchMatches.length) return;
|
|
12993
|
+
if (surface === elements.fileViewerEditor) {
|
|
12994
|
+
renderFileViewerSourceSearchHighlights();
|
|
12995
|
+
return;
|
|
12996
|
+
}
|
|
12997
|
+
const ranges = fileViewerSearchMatches.map((match) => textOffsetRange(surface, match)).filter(Boolean);
|
|
12998
|
+
const currentRange = textOffsetRange(surface, fileViewerSearchMatches[fileViewerSearchIndex]);
|
|
12999
|
+
const HighlightConstructor = globalThis.Highlight;
|
|
13000
|
+
if (globalThis.CSS?.highlights && typeof HighlightConstructor === "function") {
|
|
13001
|
+
if (ranges.length) globalThis.CSS.highlights.set("file-viewer-search-match", new HighlightConstructor(...ranges));
|
|
13002
|
+
if (currentRange) globalThis.CSS.highlights.set("file-viewer-search-current", new HighlightConstructor(currentRange));
|
|
13003
|
+
return;
|
|
13004
|
+
}
|
|
13005
|
+
for (const match of fileViewerSearchMatches) textOffsetPosition(surface, match.start)?.node.parentElement?.classList.add("file-viewer-search-match-fallback");
|
|
13006
|
+
textOffsetPosition(surface, fileViewerSearchMatches[fileViewerSearchIndex]?.start)?.node.parentElement?.classList.add("file-viewer-search-current-fallback");
|
|
12933
13007
|
}
|
|
12934
13008
|
|
|
12935
13009
|
function focusFileViewerSearchMatch() {
|
|
12936
13010
|
const match = fileViewerSearchMatches[fileViewerSearchIndex];
|
|
12937
13011
|
const surface = fileViewerSearchSurface();
|
|
12938
|
-
|
|
13012
|
+
renderFileViewerSearchHighlights();
|
|
12939
13013
|
if (!match || !surface) return;
|
|
12940
13014
|
if (surface === elements.fileViewerEditor) {
|
|
12941
13015
|
surface.setSelectionRange(match.start, match.end);
|
|
@@ -12945,22 +13019,9 @@ function focusFileViewerSearchMatch() {
|
|
|
12945
13019
|
const fontSize = Number.parseFloat(computedStyle.fontSize) || 14;
|
|
12946
13020
|
const lineHeight = !parsedLineHeight ? fontSize * 1.45 : parsedLineHeight < 8 ? parsedLineHeight * fontSize : parsedLineHeight;
|
|
12947
13021
|
surface.scrollTop = Math.max(0, (lineIndex * lineHeight) - (surface.clientHeight / 2));
|
|
13022
|
+
syncFileViewerSearchOverlayScroll();
|
|
12948
13023
|
} else {
|
|
12949
|
-
|
|
12950
|
-
const end = textOffsetPosition(surface, match.end);
|
|
12951
|
-
if (start && end) {
|
|
12952
|
-
const range = document.createRange();
|
|
12953
|
-
range.setStart(start.node, start.offset);
|
|
12954
|
-
range.setEnd(end.node, end.offset);
|
|
12955
|
-
const HighlightConstructor = globalThis.Highlight;
|
|
12956
|
-
if (globalThis.CSS?.highlights && typeof HighlightConstructor === "function") {
|
|
12957
|
-
globalThis.CSS.highlights.set("file-viewer-search-current", new HighlightConstructor(range));
|
|
12958
|
-
} else {
|
|
12959
|
-
fileViewerSearchHighlightElement = start.node.parentElement;
|
|
12960
|
-
fileViewerSearchHighlightElement?.classList.add("file-viewer-search-current-fallback");
|
|
12961
|
-
}
|
|
12962
|
-
start.node.parentElement?.scrollIntoView({ block: "center", behavior: "instant" });
|
|
12963
|
-
}
|
|
13024
|
+
textOffsetPosition(surface, match.start)?.node.parentElement?.scrollIntoView({ block: "center", behavior: "instant" });
|
|
12964
13025
|
}
|
|
12965
13026
|
elements.fileViewerSearchInput?.focus({ preventScroll: true });
|
|
12966
13027
|
updateFileViewerSearchCount();
|
|
@@ -12976,6 +13037,7 @@ function runFileViewerSearch({ navigate = false } = {}) {
|
|
|
12976
13037
|
else if (fileViewerSearchIndex < 0 || fileViewerSearchIndex >= fileViewerSearchMatches.length) fileViewerSearchIndex = 0;
|
|
12977
13038
|
updateFileViewerSearchCount();
|
|
12978
13039
|
if (navigate) focusFileViewerSearchMatch();
|
|
13040
|
+
else renderFileViewerSearchHighlights();
|
|
12979
13041
|
}
|
|
12980
13042
|
|
|
12981
13043
|
function stepFileViewerSearch(step) {
|
|
@@ -30890,7 +30952,7 @@ async function pushGitWorkflow(tabId = gitWorkflowActionTabId()) {
|
|
|
30890
30952
|
const tabContext = activeTabContext(tabId);
|
|
30891
30953
|
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
30892
30954
|
if (!workflow) return;
|
|
30893
|
-
if (!(await appConfirmText("Push the committed changes to the
|
|
30955
|
+
if (!(await appConfirmText("Push the committed changes from the current checked-out branch to the same-named remote branch and track it as the upstream?\n\nGuided Git never force-pushes automatically.", { affected: "The same-named remote Git branch and local upstream tracking", confirmLabel: "Push commits" }))) return;
|
|
30894
30956
|
const runId = workflow.runId;
|
|
30895
30957
|
setGitWorkflow({ step: "pushing", busy: true, error: "", output: "Running git push…" }, { tabId });
|
|
30896
30958
|
try {
|
|
@@ -42269,11 +42331,8 @@ async function executeCommandPaletteItem(item = commandPaletteItems[commandPalet
|
|
|
42269
42331
|
}
|
|
42270
42332
|
}
|
|
42271
42333
|
|
|
42272
|
-
|
|
42273
|
-
|
|
42274
|
-
const results = await Promise.allSettled([
|
|
42275
|
-
refreshState(tabContext),
|
|
42276
|
-
refreshMessages(tabContext),
|
|
42334
|
+
function supplementalRefreshRequests(tabContext) {
|
|
42335
|
+
return [
|
|
42277
42336
|
refreshModels(tabContext),
|
|
42278
42337
|
refreshCommands(tabContext),
|
|
42279
42338
|
refreshNaturalConversationMode(tabContext),
|
|
@@ -42285,14 +42344,47 @@ async function refreshAll(tabContext = activeTabContext()) {
|
|
|
42285
42344
|
refreshNativeSettings(tabContext),
|
|
42286
42345
|
refreshNetworkStatus(),
|
|
42287
42346
|
refreshWebuiVersion(),
|
|
42288
|
-
]
|
|
42289
|
-
|
|
42347
|
+
];
|
|
42348
|
+
}
|
|
42349
|
+
|
|
42350
|
+
function reportRefreshFailures(results, prefix = "") {
|
|
42290
42351
|
for (const result of results) {
|
|
42291
|
-
if (result.status
|
|
42352
|
+
if (result.status !== "rejected") continue;
|
|
42353
|
+
addEvent(`${prefix}${result.reason?.message || String(result.reason)}`, "error");
|
|
42292
42354
|
}
|
|
42355
|
+
}
|
|
42356
|
+
|
|
42357
|
+
async function refreshAll(tabContext = activeTabContext()) {
|
|
42358
|
+
if (!tabContext.tabId) return;
|
|
42359
|
+
const results = await Promise.allSettled([
|
|
42360
|
+
refreshState(tabContext),
|
|
42361
|
+
refreshMessages(tabContext),
|
|
42362
|
+
...supplementalRefreshRequests(tabContext),
|
|
42363
|
+
]);
|
|
42364
|
+
if (!isCurrentTabContext(tabContext)) return;
|
|
42365
|
+
reportRefreshFailures(results);
|
|
42293
42366
|
resumeGitWorkflowForActiveTab(tabContext);
|
|
42294
42367
|
}
|
|
42295
42368
|
|
|
42369
|
+
function scheduleForegroundSupplementalRefresh(tabContext) {
|
|
42370
|
+
foregroundSupplementalRefreshCancel?.();
|
|
42371
|
+
const run = async () => {
|
|
42372
|
+
foregroundSupplementalRefreshCancel = null;
|
|
42373
|
+
if (document.visibilityState === "hidden" || !isCurrentTabContext(tabContext)) return;
|
|
42374
|
+
const results = await Promise.allSettled(supplementalRefreshRequests(tabContext));
|
|
42375
|
+
if (!isCurrentTabContext(tabContext)) return;
|
|
42376
|
+
reportRefreshFailures(results, "foreground refresh failed: ");
|
|
42377
|
+
resumeGitWorkflowForActiveTab(tabContext);
|
|
42378
|
+
};
|
|
42379
|
+
if (typeof globalThis.requestIdleCallback === "function") {
|
|
42380
|
+
const handle = globalThis.requestIdleCallback(run, { timeout: 1_200 });
|
|
42381
|
+
foregroundSupplementalRefreshCancel = () => globalThis.cancelIdleCallback?.(handle);
|
|
42382
|
+
} else {
|
|
42383
|
+
const handle = setTimeout(run, 250);
|
|
42384
|
+
foregroundSupplementalRefreshCancel = () => clearTimeout(handle);
|
|
42385
|
+
}
|
|
42386
|
+
}
|
|
42387
|
+
|
|
42296
42388
|
function ensureActiveEventStream(tabContext = activeTabContext()) {
|
|
42297
42389
|
if (!tabContext.tabId || !isCurrentTabContext(tabContext)) return;
|
|
42298
42390
|
if (!eventSource || eventSource.readyState === EventSource.CLOSED) connectEvents(tabContext);
|
|
@@ -42302,16 +42394,35 @@ async function reconcileForegroundState(reason = "resume") {
|
|
|
42302
42394
|
if (document.visibilityState === "hidden") return;
|
|
42303
42395
|
|
|
42304
42396
|
const wasAway = mobileConnectionState === "away";
|
|
42397
|
+
const transcriptCatchUpRequired = foregroundTranscriptCatchUpRequired;
|
|
42305
42398
|
mobileConnectionState = navigator.onLine === false ? "offline" : "reconnecting";
|
|
42306
42399
|
mobileConnectionLabel = mobileConnectionState === "offline" ? "Paused/offline" : "Reconnecting";
|
|
42307
42400
|
recordMobileDiagnostic("foreground reconcile", reason);
|
|
42308
42401
|
renderMobilePhoneExperience();
|
|
42309
42402
|
const tabResult = await Promise.allSettled([refreshTabs()]);
|
|
42310
42403
|
const tabContext = activeTabContext();
|
|
42311
|
-
ensureActiveEventStream(tabContext);
|
|
42312
42404
|
|
|
42313
42405
|
const results = [...tabResult];
|
|
42314
|
-
if (tabContext.tabId
|
|
42406
|
+
if (tabContext.tabId && transcriptCatchUpRequired) {
|
|
42407
|
+
const criticalResults = await Promise.allSettled([
|
|
42408
|
+
refreshState(tabContext),
|
|
42409
|
+
refreshMessages(tabContext, { authoritative: true }),
|
|
42410
|
+
]);
|
|
42411
|
+
results.push(...criticalResults);
|
|
42412
|
+
if (isCurrentTabContext(tabContext)) {
|
|
42413
|
+
if (foregroundTranscriptSuppressedEvents > 0) {
|
|
42414
|
+
recordMobileDiagnostic("foreground output coalesced", `${foregroundTranscriptSuppressedEvents} raw transcript updates replaced by one authoritative snapshot`);
|
|
42415
|
+
}
|
|
42416
|
+
backgroundReconnectSnapshotFresh = ![...tabResult, ...criticalResults].some((result) => result.status === "rejected");
|
|
42417
|
+
foregroundTranscriptCatchUpRequired = false;
|
|
42418
|
+
foregroundTranscriptSuppressedEvents = 0;
|
|
42419
|
+
ensureActiveEventStream(tabContext);
|
|
42420
|
+
scheduleForegroundSupplementalRefresh(tabContext);
|
|
42421
|
+
}
|
|
42422
|
+
} else if (tabContext.tabId) {
|
|
42423
|
+
ensureActiveEventStream(tabContext);
|
|
42424
|
+
results.push(...(await Promise.allSettled([refreshAll(tabContext)])));
|
|
42425
|
+
}
|
|
42315
42426
|
if (!isCurrentTabContext(tabContext)) return;
|
|
42316
42427
|
|
|
42317
42428
|
const failed = results.some((result) => result.status === "rejected");
|
|
@@ -43547,7 +43658,25 @@ const TRANSCRIPT_STREAM_BARRIER_EVENT_TYPES = new Set([
|
|
|
43547
43658
|
"pi_process_error",
|
|
43548
43659
|
]);
|
|
43549
43660
|
|
|
43661
|
+
function beginForegroundTranscriptCatchUp() {
|
|
43662
|
+
foregroundTranscriptCatchUpRequired = true;
|
|
43663
|
+
backgroundReconnectSnapshotFresh = false;
|
|
43664
|
+
streamOutputController.cancel();
|
|
43665
|
+
if (!eventSource) return;
|
|
43666
|
+
eventStreamPausedForBackground = true;
|
|
43667
|
+
const source = eventSource;
|
|
43668
|
+
eventSource = null;
|
|
43669
|
+
source.close();
|
|
43670
|
+
}
|
|
43671
|
+
|
|
43550
43672
|
function dispatchTranscriptStreamEvent(event) {
|
|
43673
|
+
const classification = classifyTranscriptStreamEvent(event);
|
|
43674
|
+
if (classification && (document.visibilityState === "hidden" || foregroundTranscriptCatchUpRequired)) {
|
|
43675
|
+
foregroundTranscriptCatchUpRequired = true;
|
|
43676
|
+
foregroundTranscriptSuppressedEvents += 1;
|
|
43677
|
+
streamOutputController.cancel();
|
|
43678
|
+
return true;
|
|
43679
|
+
}
|
|
43551
43680
|
return streamOutputController.dispatch(event, {
|
|
43552
43681
|
owner: transcriptStreamOwner(event?.tabId || activeTabId),
|
|
43553
43682
|
});
|
|
@@ -43598,6 +43727,10 @@ function handleEvent(event) {
|
|
|
43598
43727
|
switch (event.type) {
|
|
43599
43728
|
case "webui_connected": {
|
|
43600
43729
|
const connectedTabId = event.tabId || activeTabId;
|
|
43730
|
+
const resumedWithFreshSnapshot = eventStreamPausedForBackground && backgroundReconnectSnapshotFresh;
|
|
43731
|
+
eventStreamPausedForBackground = false;
|
|
43732
|
+
backgroundReconnectSnapshotFresh = false;
|
|
43733
|
+
if (resumedWithFreshSnapshot) foregroundReconnectSnapshotFreshUntil = performance.now() + 2_000;
|
|
43601
43734
|
clearFeatureDecisionStateForTab(connectedTabId, { render: true });
|
|
43602
43735
|
acceptOutputModeAcknowledgement(event);
|
|
43603
43736
|
setWebuiVersion(event.version);
|
|
@@ -43609,16 +43742,16 @@ function handleEvent(event) {
|
|
|
43609
43742
|
renderWidgets();
|
|
43610
43743
|
}
|
|
43611
43744
|
addEvent(`connected to ${event.tabTitle || "terminal"} for ${event.cwd}`);
|
|
43612
|
-
if (event.supervisorReplayGap === true) scheduleSupervisorContinuityRefresh(event, { gap: true });
|
|
43613
|
-
scheduleForegroundReconcile("event stream reconnect", 0);
|
|
43745
|
+
if (event.supervisorReplayGap === true && !resumedWithFreshSnapshot) scheduleSupervisorContinuityRefresh(event, { gap: true });
|
|
43746
|
+
if (!resumedWithFreshSnapshot) scheduleForegroundReconcile("event stream reconnect", 0);
|
|
43614
43747
|
break;
|
|
43615
43748
|
}
|
|
43616
43749
|
case "webui_supervisor_reconnected":
|
|
43617
43750
|
addEvent("reconnected to the running Pi session");
|
|
43618
|
-
scheduleSupervisorContinuityRefresh(event);
|
|
43751
|
+
if (performance.now() > foregroundReconnectSnapshotFreshUntil) scheduleSupervisorContinuityRefresh(event);
|
|
43619
43752
|
break;
|
|
43620
43753
|
case "webui_supervisor_replay_gap":
|
|
43621
|
-
scheduleSupervisorContinuityRefresh(event, { gap: true });
|
|
43754
|
+
if (performance.now() > foregroundReconnectSnapshotFreshUntil) scheduleSupervisorContinuityRefresh(event, { gap: true });
|
|
43622
43755
|
break;
|
|
43623
43756
|
case "webui_output_mode":
|
|
43624
43757
|
applyOutputModeControl(event, tabContext);
|
|
@@ -43964,7 +44097,7 @@ function connectEvents(tabContext = activeTabContext(), { requestedMode = "auto"
|
|
|
43964
44097
|
eventSource = source;
|
|
43965
44098
|
source.onopen = () => {
|
|
43966
44099
|
if (eventSource !== source || !isCurrentTabContext(tabContext)) return;
|
|
43967
|
-
refreshOptionalFeaturePackageStatuses().catch(() => {});
|
|
44100
|
+
if (!eventStreamPausedForBackground) refreshOptionalFeaturePackageStatuses().catch(() => {});
|
|
43968
44101
|
};
|
|
43969
44102
|
source.onmessage = (message) => {
|
|
43970
44103
|
if (eventSource !== source || !isCurrentTabContext(tabContext)) return;
|
|
@@ -45196,27 +45329,60 @@ function handleNativeAppShortcut(event) {
|
|
|
45196
45329
|
}
|
|
45197
45330
|
}
|
|
45198
45331
|
|
|
45199
|
-
// --- Transcript search (Ctrl/Cmd+F) ---
|
|
45332
|
+
// --- Transcript and live agent-output search (Ctrl/Cmd+F) ---
|
|
45333
|
+
const CHAT_SEARCH_MATCH_LIMIT = 10_000;
|
|
45200
45334
|
let chatSearchMatches = [];
|
|
45201
45335
|
let chatSearchIndex = -1;
|
|
45202
45336
|
let chatSearchTimer = null;
|
|
45337
|
+
let chatSearchRefreshTimer = null;
|
|
45203
45338
|
|
|
45204
45339
|
function chatSearchQueryText() {
|
|
45205
45340
|
return (elements.chatSearchInput?.value || "").trim().toLowerCase();
|
|
45206
45341
|
}
|
|
45207
45342
|
|
|
45343
|
+
function chatSearchRoot() {
|
|
45344
|
+
return elements.subagentTerminalView?.hidden === false ? elements.subagentTerminalTranscript : elements.chat;
|
|
45345
|
+
}
|
|
45346
|
+
|
|
45208
45347
|
function collectChatSearchMatches(query) {
|
|
45209
45348
|
if (!query) return [];
|
|
45210
45349
|
const matches = [];
|
|
45211
|
-
for (const bubble of
|
|
45350
|
+
for (const bubble of chatSearchRoot()?.querySelectorAll(".message") || []) {
|
|
45212
45351
|
if (bubble === runIndicatorBubble || bubble.classList.contains("runIndicator")) continue;
|
|
45213
|
-
|
|
45352
|
+
const text = (bubble.textContent || "").toLowerCase();
|
|
45353
|
+
let offset = 0;
|
|
45354
|
+
while (matches.length < CHAT_SEARCH_MATCH_LIMIT) {
|
|
45355
|
+
const start = text.indexOf(query, offset);
|
|
45356
|
+
if (start < 0) break;
|
|
45357
|
+
matches.push({ bubble, start, end: start + query.length });
|
|
45358
|
+
offset = start + query.length;
|
|
45359
|
+
}
|
|
45360
|
+
if (matches.length >= CHAT_SEARCH_MATCH_LIMIT) break;
|
|
45214
45361
|
}
|
|
45215
45362
|
return matches;
|
|
45216
45363
|
}
|
|
45217
45364
|
|
|
45218
45365
|
function clearChatSearchHighlights() {
|
|
45219
|
-
|
|
45366
|
+
globalThis.CSS?.highlights?.delete("chat-search-match");
|
|
45367
|
+
globalThis.CSS?.highlights?.delete("chat-search-current");
|
|
45368
|
+
for (const root of [elements.chat, elements.subagentTerminalTranscript]) {
|
|
45369
|
+
for (const bubble of root?.querySelectorAll(".message.search-match, .message.search-current") || []) bubble.classList.remove("search-match", "search-current");
|
|
45370
|
+
}
|
|
45371
|
+
}
|
|
45372
|
+
|
|
45373
|
+
function renderChatSearchHighlights() {
|
|
45374
|
+
clearChatSearchHighlights();
|
|
45375
|
+
const ranges = chatSearchMatches.map((match) => textOffsetRange(match.bubble, match)).filter(Boolean);
|
|
45376
|
+
const current = chatSearchMatches[chatSearchIndex];
|
|
45377
|
+
const currentRange = current ? textOffsetRange(current.bubble, current) : null;
|
|
45378
|
+
const HighlightConstructor = globalThis.Highlight;
|
|
45379
|
+
if (globalThis.CSS?.highlights && typeof HighlightConstructor === "function") {
|
|
45380
|
+
if (ranges.length) globalThis.CSS.highlights.set("chat-search-match", new HighlightConstructor(...ranges));
|
|
45381
|
+
if (currentRange) globalThis.CSS.highlights.set("chat-search-current", new HighlightConstructor(currentRange));
|
|
45382
|
+
return;
|
|
45383
|
+
}
|
|
45384
|
+
for (const match of chatSearchMatches) match.bubble.classList.add("search-match");
|
|
45385
|
+
current?.bubble.classList.add("search-current");
|
|
45220
45386
|
}
|
|
45221
45387
|
|
|
45222
45388
|
function updateChatSearchCount() {
|
|
@@ -45226,36 +45392,39 @@ function updateChatSearchCount() {
|
|
|
45226
45392
|
}
|
|
45227
45393
|
|
|
45228
45394
|
function focusChatSearchMatch() {
|
|
45229
|
-
const
|
|
45395
|
+
const match = chatSearchMatches[chatSearchIndex];
|
|
45396
|
+
const bubble = match?.bubble;
|
|
45230
45397
|
if (!bubble) return;
|
|
45231
45398
|
if (!bubble.isConnected) {
|
|
45232
45399
|
runChatSearch({ navigate: false });
|
|
45233
45400
|
return;
|
|
45234
45401
|
}
|
|
45235
|
-
clearChatSearchHighlights();
|
|
45236
|
-
bubble.classList.add("search-current");
|
|
45237
45402
|
const query = chatSearchQueryText();
|
|
45238
45403
|
for (const details of bubble.querySelectorAll("details")) {
|
|
45239
45404
|
if (!details.open && (details.textContent || "").toLowerCase().includes(query)) details.open = true;
|
|
45240
45405
|
}
|
|
45241
|
-
|
|
45242
|
-
|
|
45406
|
+
renderChatSearchHighlights();
|
|
45407
|
+
if (chatSearchRoot() === elements.chat) {
|
|
45408
|
+
autoFollowChat = false;
|
|
45409
|
+
lastChatProgrammaticScrollAt = performance.now();
|
|
45410
|
+
updateJumpToLatestButton();
|
|
45411
|
+
}
|
|
45243
45412
|
bubble.scrollIntoView({ block: "center", behavior: "instant" });
|
|
45244
|
-
updateJumpToLatestButton();
|
|
45245
45413
|
updateChatSearchCount();
|
|
45246
45414
|
}
|
|
45247
45415
|
|
|
45248
45416
|
function runChatSearch({ navigate = false } = {}) {
|
|
45249
45417
|
const query = chatSearchQueryText();
|
|
45250
|
-
clearChatSearchHighlights();
|
|
45251
45418
|
chatSearchMatches = collectChatSearchMatches(query);
|
|
45252
|
-
if (
|
|
45419
|
+
if (!chatSearchMatches.length) chatSearchIndex = -1;
|
|
45420
|
+
else if (chatSearchIndex >= chatSearchMatches.length || chatSearchIndex < 0) chatSearchIndex = chatSearchMatches.length - 1;
|
|
45253
45421
|
updateChatSearchCount();
|
|
45254
45422
|
if (navigate) focusChatSearchMatch();
|
|
45423
|
+
else renderChatSearchHighlights();
|
|
45255
45424
|
}
|
|
45256
45425
|
|
|
45257
45426
|
function stepChatSearch(step) {
|
|
45258
|
-
if (chatSearchMatches.some((
|
|
45427
|
+
if (chatSearchMatches.some((match) => !match.bubble.isConnected)) runChatSearch();
|
|
45259
45428
|
if (!chatSearchMatches.length) {
|
|
45260
45429
|
runChatSearch();
|
|
45261
45430
|
if (!chatSearchMatches.length) return;
|
|
@@ -45267,6 +45436,10 @@ function stepChatSearch(step) {
|
|
|
45267
45436
|
function openChatSearch() {
|
|
45268
45437
|
if (!elements.chatSearchBar) return;
|
|
45269
45438
|
closeFileViewerSearch({ restoreFocus: false });
|
|
45439
|
+
const searchesAgentOutput = chatSearchRoot() === elements.subagentTerminalTranscript;
|
|
45440
|
+
elements.chatSearchInput.placeholder = searchesAgentOutput ? "Search agent output…" : "Search transcript…";
|
|
45441
|
+
elements.chatSearchInput.setAttribute("aria-label", searchesAgentOutput ? "Search agent output" : "Search transcript");
|
|
45442
|
+
if (chatSearchRoot()?.id) elements.chatSearchInput.setAttribute("aria-controls", chatSearchRoot().id);
|
|
45270
45443
|
elements.chatSearchBar.hidden = false;
|
|
45271
45444
|
elements.chatSearchInput?.focus();
|
|
45272
45445
|
elements.chatSearchInput?.select();
|
|
@@ -45282,6 +45455,15 @@ function closeChatSearch() {
|
|
|
45282
45455
|
updateChatSearchCount();
|
|
45283
45456
|
}
|
|
45284
45457
|
|
|
45458
|
+
const chatSearchObserver = typeof MutationObserver === "function" ? new MutationObserver(() => {
|
|
45459
|
+
if (elements.chatSearchBar?.hidden || !chatSearchQueryText()) return;
|
|
45460
|
+
clearTimeout(chatSearchRefreshTimer);
|
|
45461
|
+
chatSearchRefreshTimer = setTimeout(() => runChatSearch({ navigate: false }), 50);
|
|
45462
|
+
}) : null;
|
|
45463
|
+
for (const root of [elements.chat, elements.subagentTerminalTranscript]) {
|
|
45464
|
+
if (root && chatSearchObserver) chatSearchObserver.observe(root, { childList: true, subtree: true, characterData: true });
|
|
45465
|
+
}
|
|
45466
|
+
|
|
45285
45467
|
elements.chatSearchInput?.addEventListener("input", () => {
|
|
45286
45468
|
clearTimeout(chatSearchTimer);
|
|
45287
45469
|
chatSearchTimer = setTimeout(() => {
|
|
@@ -45316,6 +45498,7 @@ document.addEventListener("visibilitychange", () => {
|
|
|
45316
45498
|
scheduleForegroundReconcile("visibility resume", 0);
|
|
45317
45499
|
refreshSubagents().finally(() => scheduleRefreshSubagents());
|
|
45318
45500
|
} else {
|
|
45501
|
+
beginForegroundTranscriptCatchUp();
|
|
45319
45502
|
mobileConnectionState = "away";
|
|
45320
45503
|
mobileConnectionLabel = "Backgrounded · run state unverified";
|
|
45321
45504
|
persistMobileContinuityState();
|
|
@@ -45637,6 +45820,7 @@ elements.fileViewerSearchInput?.addEventListener("keydown", (event) => {
|
|
|
45637
45820
|
elements.fileViewerSearchPrevButton?.addEventListener("click", () => stepFileViewerSearch(-1));
|
|
45638
45821
|
elements.fileViewerSearchNextButton?.addEventListener("click", () => stepFileViewerSearch(1));
|
|
45639
45822
|
elements.fileViewerSearchCloseButton?.addEventListener("click", () => closeFileViewerSearch());
|
|
45823
|
+
elements.fileViewerEditor?.addEventListener("scroll", syncFileViewerSearchOverlayScroll);
|
|
45640
45824
|
elements.fileViewerEditor?.addEventListener("input", () => {
|
|
45641
45825
|
if (!activeFileViewer) return;
|
|
45642
45826
|
activeFileViewer.content = elements.fileViewerEditor.value || "";
|
package/public/index.html
CHANGED
|
@@ -678,6 +678,7 @@
|
|
|
678
678
|
</div>
|
|
679
679
|
</div>
|
|
680
680
|
<div class="file-viewer-content">
|
|
681
|
+
<pre id="fileViewerSearchOverlay" class="file-viewer-search-overlay" aria-hidden="true" hidden></pre>
|
|
681
682
|
<textarea id="fileViewerEditor" class="file-viewer-editor" wrap="soft" spellcheck="false" aria-label="File contents"></textarea>
|
|
682
683
|
<div id="fileViewerPreview" class="file-viewer-preview markdown-body" tabindex="0" hidden></div>
|
|
683
684
|
<div id="fileViewerChanges" class="file-viewer-changes" tabindex="0" aria-label="Git changes for this file" hidden></div>
|
package/public/styles.css
CHANGED
|
@@ -940,6 +940,7 @@ body.side-panel-resizing * {
|
|
|
940
940
|
.file-viewer-editor,
|
|
941
941
|
.file-viewer-preview,
|
|
942
942
|
.file-viewer-changes {
|
|
943
|
+
grid-area: 1 / 1;
|
|
943
944
|
width: 100%;
|
|
944
945
|
height: 100%;
|
|
945
946
|
min-width: 0;
|
|
@@ -950,6 +951,8 @@ body.side-panel-resizing * {
|
|
|
950
951
|
background: rgba(var(--ctp-crust-rgb), 0.64);
|
|
951
952
|
}
|
|
952
953
|
.file-viewer-editor {
|
|
954
|
+
position: relative;
|
|
955
|
+
z-index: 1;
|
|
953
956
|
resize: none;
|
|
954
957
|
padding: 0.72rem;
|
|
955
958
|
overflow-x: hidden;
|
|
@@ -960,6 +963,37 @@ body.side-panel-resizing * {
|
|
|
960
963
|
line-height: 1.45;
|
|
961
964
|
white-space: pre-wrap;
|
|
962
965
|
}
|
|
966
|
+
.file-viewer-search-overlay {
|
|
967
|
+
grid-area: 1 / 1;
|
|
968
|
+
z-index: 0;
|
|
969
|
+
box-sizing: border-box;
|
|
970
|
+
width: 100%;
|
|
971
|
+
height: 100%;
|
|
972
|
+
min-width: 0;
|
|
973
|
+
min-height: 0;
|
|
974
|
+
margin: 0;
|
|
975
|
+
padding: 0.72rem;
|
|
976
|
+
overflow: auto;
|
|
977
|
+
border: 1px solid rgba(180, 190, 254, 0.16);
|
|
978
|
+
border-radius: 0.86rem;
|
|
979
|
+
background: rgba(var(--ctp-crust-rgb), 0.64);
|
|
980
|
+
color: transparent;
|
|
981
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
|
|
982
|
+
font-size: 0.82rem;
|
|
983
|
+
line-height: 1.45;
|
|
984
|
+
overflow-wrap: anywhere;
|
|
985
|
+
pointer-events: none;
|
|
986
|
+
scrollbar-width: none;
|
|
987
|
+
white-space: pre-wrap;
|
|
988
|
+
}
|
|
989
|
+
.file-viewer-search-overlay::-webkit-scrollbar { display: none; }
|
|
990
|
+
.file-viewer-content.search-highlights-source .file-viewer-editor { background: transparent; }
|
|
991
|
+
.file-viewer-search-match {
|
|
992
|
+
border-radius: 0.12rem;
|
|
993
|
+
background: rgba(249, 226, 175, 0.48);
|
|
994
|
+
color: transparent;
|
|
995
|
+
}
|
|
996
|
+
.file-viewer-search-match.current { background: rgba(250, 179, 135, 0.78); }
|
|
963
997
|
.file-viewer-preview {
|
|
964
998
|
padding: 0.85rem;
|
|
965
999
|
line-height: 1.55;
|
|
@@ -11825,7 +11859,6 @@ body:not(.mobile-keyboard-open) .composer-input-row:has(.composer-workflow-mode-
|
|
|
11825
11859
|
}
|
|
11826
11860
|
body.subagent-terminal-active .workspace-dashboard,
|
|
11827
11861
|
body.subagent-terminal-active .widget-area,
|
|
11828
|
-
body.subagent-terminal-active .chat-search-bar,
|
|
11829
11862
|
body.subagent-terminal-active .chat,
|
|
11830
11863
|
body.subagent-terminal-active .feedback-tray,
|
|
11831
11864
|
body.subagent-terminal-active .jump-to-latest-button,
|
|
@@ -15167,16 +15200,24 @@ button.git-workflow-step { min-height: 1.9rem; }
|
|
|
15167
15200
|
}
|
|
15168
15201
|
.chat-search-button:hover,
|
|
15169
15202
|
.file-viewer-search-button:hover { background: var(--panel); }
|
|
15170
|
-
::highlight(file-viewer-search-
|
|
15203
|
+
::highlight(file-viewer-search-match),
|
|
15204
|
+
::highlight(chat-search-match) {
|
|
15205
|
+
color: inherit;
|
|
15206
|
+
background: rgba(249, 226, 175, 0.48);
|
|
15207
|
+
}
|
|
15208
|
+
::highlight(file-viewer-search-current),
|
|
15209
|
+
::highlight(chat-search-current) {
|
|
15171
15210
|
color: var(--button-primary-text);
|
|
15172
|
-
background: var(--ctp-
|
|
15211
|
+
background: var(--ctp-peach);
|
|
15173
15212
|
}
|
|
15174
|
-
.file-viewer-search-
|
|
15175
|
-
|
|
15176
|
-
outline
|
|
15213
|
+
.file-viewer-search-match-fallback,
|
|
15214
|
+
.message.search-match {
|
|
15215
|
+
outline: 1px solid rgba(249, 226, 175, 0.72);
|
|
15216
|
+
outline-offset: 1px;
|
|
15177
15217
|
}
|
|
15218
|
+
.file-viewer-search-current-fallback,
|
|
15178
15219
|
.message.search-current {
|
|
15179
|
-
outline: 2px solid var(--
|
|
15220
|
+
outline: 2px solid var(--ctp-peach);
|
|
15180
15221
|
outline-offset: 2px;
|
|
15181
15222
|
}
|
|
15182
15223
|
|
|
@@ -45,6 +45,11 @@ async function activeTabId(page) {
|
|
|
45
45
|
return page.locator("#tabBar [role=\"tab\"][aria-selected=\"true\"]").evaluate((node) => node.closest("[data-tab-id]")?.dataset.tabId || "");
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
async function tabClientCount(page, tabId) {
|
|
49
|
+
const payload = await api(page, "/api/tabs");
|
|
50
|
+
return Number(payload.data?.tabs?.find((tab) => tab.id === tabId)?.clientCount || 0);
|
|
51
|
+
}
|
|
52
|
+
|
|
48
53
|
async function startContinuityRunner(page) {
|
|
49
54
|
const tabId = await activeTabId(page) || (await tabIds(page))[0];
|
|
50
55
|
const configured = await api(page, "/api/app-runner-config", {
|
|
@@ -205,6 +210,63 @@ test.afterAll(async () => {
|
|
|
205
210
|
await rm(tempRoot, { recursive: true, force: true });
|
|
206
211
|
});
|
|
207
212
|
|
|
213
|
+
test("only hidden pages disconnect live events and resume from one authoritative snapshot", async ({ page }) => {
|
|
214
|
+
await page.setViewportSize({ width: 1280, height: 800 });
|
|
215
|
+
await page.goto(baseURL);
|
|
216
|
+
const tabId = await activeTabId(page) || (await tabIds(page))[0];
|
|
217
|
+
assert.ok(tabId, "the background catch-up fixture requires an active tab");
|
|
218
|
+
await expect.poll(() => tabClientCount(page, tabId)).toBe(1);
|
|
219
|
+
|
|
220
|
+
await page.evaluate(() => {
|
|
221
|
+
window.__backgroundStreamProof = { closeCalls: 0, constructions: 0 };
|
|
222
|
+
const NativeEventSource = window.EventSource;
|
|
223
|
+
const nativeClose = NativeEventSource.prototype.close;
|
|
224
|
+
NativeEventSource.prototype.close = function (...args) {
|
|
225
|
+
window.__backgroundStreamProof.closeCalls += 1;
|
|
226
|
+
return nativeClose.apply(this, args);
|
|
227
|
+
};
|
|
228
|
+
window.EventSource = new Proxy(NativeEventSource, {
|
|
229
|
+
construct(target, args, receiver) {
|
|
230
|
+
window.__backgroundStreamProof.constructions += 1;
|
|
231
|
+
return Reflect.construct(target, args, receiver);
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
window.dispatchEvent(new Event("blur"));
|
|
235
|
+
});
|
|
236
|
+
await expect.poll(() => tabClientCount(page, tabId)).toBe(1);
|
|
237
|
+
await expect.poll(() => page.evaluate(() => window.__backgroundStreamProof.closeCalls)).toBe(0);
|
|
238
|
+
|
|
239
|
+
await page.evaluate(() => {
|
|
240
|
+
window.__backgroundVisibilityState = "hidden";
|
|
241
|
+
Object.defineProperty(document, "visibilityState", {
|
|
242
|
+
configurable: true,
|
|
243
|
+
get: () => window.__backgroundVisibilityState,
|
|
244
|
+
});
|
|
245
|
+
document.dispatchEvent(new Event("visibilitychange"));
|
|
246
|
+
});
|
|
247
|
+
await expect.poll(() => tabClientCount(page, tabId)).toBe(0);
|
|
248
|
+
await expect.poll(() => page.evaluate(() => window.__backgroundStreamProof.closeCalls)).toBe(1);
|
|
249
|
+
|
|
250
|
+
const completedBefore = await page.locator("#chat .message.assistant", { hasText: "continuity stream complete" }).count();
|
|
251
|
+
await api(page, `/api/prompt?tab=${encodeURIComponent(tabId)}`, {
|
|
252
|
+
method: "POST",
|
|
253
|
+
data: { message: "fixture continuity delayed stream", requestId: `background-catch-up-${Date.now()}` },
|
|
254
|
+
});
|
|
255
|
+
await waitForFixtureSettlement(page, tabId);
|
|
256
|
+
await expect(page.locator("#chat .message.assistant", { hasText: "continuity stream complete" })).toHaveCount(completedBefore);
|
|
257
|
+
|
|
258
|
+
const resumedAt = Date.now();
|
|
259
|
+
await page.evaluate(() => {
|
|
260
|
+
window.__backgroundVisibilityState = "visible";
|
|
261
|
+
document.dispatchEvent(new Event("visibilitychange"));
|
|
262
|
+
});
|
|
263
|
+
await expect.poll(() => tabClientCount(page, tabId)).toBe(1);
|
|
264
|
+
await expect(page.locator("#chat .message.assistant", { hasText: "continuity stream complete" })).toHaveCount(completedBefore + 1);
|
|
265
|
+
const proof = await page.evaluate(() => window.__backgroundStreamProof);
|
|
266
|
+
assert.equal(proof.constructions, 1, "foreground catch-up should create exactly one replacement EventSource");
|
|
267
|
+
assert.ok(Date.now() - resumedAt < 4_000, "the bounded snapshot resume should complete without replaying the hidden stream duration");
|
|
268
|
+
});
|
|
269
|
+
|
|
208
270
|
test("autosizing the main input does not move settled agent output", async ({ page }) => {
|
|
209
271
|
await page.setViewportSize({ width: 1280, height: 800 });
|
|
210
272
|
await page.goto(baseURL);
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { createServer } from "node:net";
|
|
4
|
+
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { dirname, join } from "node:path";
|
|
7
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
import { expect, test } from "@playwright/test";
|
|
10
|
+
|
|
11
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
12
|
+
const serverScript = join(root, "bin", "pi-webui.mjs");
|
|
13
|
+
const fakePi = join(root, "tests", "fixtures", "fake-pi.mjs");
|
|
14
|
+
|
|
15
|
+
async function freePort() {
|
|
16
|
+
const server = createServer();
|
|
17
|
+
await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
|
|
18
|
+
const { port } = server.address();
|
|
19
|
+
await new Promise((resolve) => server.close(resolve));
|
|
20
|
+
return port;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let child;
|
|
24
|
+
let baseURL;
|
|
25
|
+
let tempRoot;
|
|
26
|
+
let output = "";
|
|
27
|
+
|
|
28
|
+
test.beforeAll(async () => {
|
|
29
|
+
const port = await freePort();
|
|
30
|
+
tempRoot = await mkdtemp(join(tmpdir(), "pi-webui-search-highlights-"));
|
|
31
|
+
await writeFile(join(tempRoot, "search-sample.txt"), "Alpha beta alpha\nplain text\nALPHA final\n");
|
|
32
|
+
baseURL = `http://127.0.0.1:${port}`;
|
|
33
|
+
child = spawn(process.execPath, [serverScript, "--cwd", tempRoot, "--host", "127.0.0.1", "--port", String(port), "--pi", fakePi], {
|
|
34
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
35
|
+
env: {
|
|
36
|
+
...process.env,
|
|
37
|
+
PI_WEBUI_RPC_SUPERVISOR: "0",
|
|
38
|
+
PI_CODING_AGENT_DIR: join(tempRoot, "agent"),
|
|
39
|
+
PI_WEBUI_SETTINGS_FILE: join(tempRoot, "settings.json"),
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
child.stdout.on("data", (chunk) => { output += String(chunk); });
|
|
43
|
+
child.stderr.on("data", (chunk) => { output += String(chunk); });
|
|
44
|
+
for (let attempt = 0; attempt < 80; attempt += 1) {
|
|
45
|
+
if (child.exitCode !== null) break;
|
|
46
|
+
try {
|
|
47
|
+
const response = await fetch(`${baseURL}/api/health`, { signal: AbortSignal.timeout(500) });
|
|
48
|
+
if (response.ok) return;
|
|
49
|
+
} catch {
|
|
50
|
+
// Poll only until the package server and fake Pi fixture are ready.
|
|
51
|
+
}
|
|
52
|
+
await delay(100);
|
|
53
|
+
}
|
|
54
|
+
throw new Error(`Pi Web UI did not start:\n${output}`);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test.afterAll(async () => {
|
|
58
|
+
if (child?.exitCode === null) {
|
|
59
|
+
await fetch(`${baseURL}/api/shutdown`, { method: "POST", signal: AbortSignal.timeout(1_000) }).catch(() => undefined);
|
|
60
|
+
await new Promise((resolve) => child.once("exit", resolve));
|
|
61
|
+
}
|
|
62
|
+
await rm(tempRoot, { recursive: true, force: true });
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("highlights every transcript and source-file match while retaining current-match navigation", async ({ page }) => {
|
|
66
|
+
await page.setViewportSize({ width: 1440, height: 900 });
|
|
67
|
+
await page.goto(baseURL);
|
|
68
|
+
await expect(page.locator("#chat .message")).toHaveCount(3);
|
|
69
|
+
|
|
70
|
+
await page.keyboard.press("Control+F");
|
|
71
|
+
await page.locator("#chatSearchInput").fill("fake");
|
|
72
|
+
await expect(page.locator("#chatSearchCount")).toHaveText("3/3");
|
|
73
|
+
const transcriptHighlightSizes = await page.evaluate(() => ({
|
|
74
|
+
all: CSS.highlights.get("chat-search-match")?.size || 0,
|
|
75
|
+
current: CSS.highlights.get("chat-search-current")?.size || 0,
|
|
76
|
+
}));
|
|
77
|
+
assert.deepEqual(transcriptHighlightSizes, { all: 3, current: 1 });
|
|
78
|
+
|
|
79
|
+
await page.keyboard.press("Escape");
|
|
80
|
+
await page.locator("#sidePanelSectionToggleFiles").click();
|
|
81
|
+
await page.locator("#fileTreeSearchInput").fill("search-sample.txt");
|
|
82
|
+
const fileResult = page.locator(".file-tree-search-item", { hasText: "search-sample.txt" });
|
|
83
|
+
await expect(fileResult).toBeVisible();
|
|
84
|
+
await fileResult.click();
|
|
85
|
+
await expect(page.locator("#fileViewerPane")).toBeVisible();
|
|
86
|
+
|
|
87
|
+
const editor = page.locator("#fileViewerEditor");
|
|
88
|
+
await editor.focus();
|
|
89
|
+
await page.keyboard.press("Control+F");
|
|
90
|
+
await page.locator("#fileViewerSearchInput").fill("alpha");
|
|
91
|
+
await expect(page.locator("#fileViewerSearchCount")).toHaveText("1/3");
|
|
92
|
+
await expect(page.locator("#fileViewerSearchOverlay .file-viewer-search-match")).toHaveCount(3);
|
|
93
|
+
await expect(page.locator("#fileViewerSearchOverlay .file-viewer-search-match.current")).toHaveCount(1);
|
|
94
|
+
|
|
95
|
+
const synchronizedScroll = await editor.evaluate((node) => {
|
|
96
|
+
node.scrollTop = 12;
|
|
97
|
+
node.dispatchEvent(new Event("scroll"));
|
|
98
|
+
return {
|
|
99
|
+
editor: node.scrollTop,
|
|
100
|
+
overlay: document.querySelector("#fileViewerSearchOverlay")?.scrollTop || 0,
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
assert.equal(synchronizedScroll.overlay, synchronizedScroll.editor);
|
|
104
|
+
});
|
|
@@ -17,7 +17,9 @@ assert.match(
|
|
|
17
17
|
"the file viewer should expose an accessible in-file search bar with match navigation",
|
|
18
18
|
);
|
|
19
19
|
assert.match(html, /id="fileViewerSearchInput"[^>]*aria-controls="fileViewerEditor"/, "the in-file search input should identify the source editor it searches");
|
|
20
|
+
assert.match(html, /id="fileViewerSearchOverlay"[^>]*aria-hidden="true"[^>]*hidden/, "source search should provide a non-interactive highlight overlay");
|
|
20
21
|
assert.match(app, /fileViewerSearchInput: \$\("#fileViewerSearchInput"\)/, "file search controls should be registered in the element map");
|
|
22
|
+
assert.match(app, /fileViewerSearchOverlay: \$\("#fileViewerSearchOverlay"\)/, "the source highlight overlay should be registered in the element map");
|
|
21
23
|
assert.match(app, /const FILE_VIEWER_SEARCH_MATCH_LIMIT = 10_000;/, "in-file search should bound match collection for large files");
|
|
22
24
|
assert.match(app, /function collectFileViewerSearchMatches\([\s\S]*fileViewerSearchText\(\)\.toLowerCase\(\)[\s\S]*haystack\.indexOf\(needle, offset\)/, "in-file search should collect case-insensitive matches from the active viewer surface");
|
|
23
25
|
|
|
@@ -45,7 +47,9 @@ const truncatedMatches = JSON.parse(vm.runInNewContext(`${helperSource}\nJSON.st
|
|
|
45
47
|
assert.equal(truncatedMatches.matches.length, 10_000, "large-file match collection should stop at the declared bound");
|
|
46
48
|
assert.equal(truncatedMatches.truncated, true, "large-file match collection should disclose additional matches beyond the bound");
|
|
47
49
|
assert.match(app, /function fileViewerSearchSurface\(\)[\s\S]*mode === "preview"[\s\S]*mode === "changes"[\s\S]*fileViewerEditor/, "search should stay scoped to the current Source, Preview, or Changes surface");
|
|
48
|
-
assert.match(app, /function
|
|
50
|
+
assert.match(app, /function renderFileViewerSourceSearchHighlights\(\)[\s\S]*fileViewerSearchMatches\.forEach[\s\S]*make\("mark", `file-viewer-search-match/, "source search should render every collected match into the synchronized overlay");
|
|
51
|
+
assert.match(app, /function renderFileViewerSearchHighlights\(\)[\s\S]*new HighlightConstructor\(\.\.\.ranges\)[\s\S]*file-viewer-search-match[\s\S]*file-viewer-search-current/, "rendered file surfaces should highlight all exact ranges and distinguish the current range");
|
|
52
|
+
assert.match(app, /function focusFileViewerSearchMatch\(\)[\s\S]*setSelectionRange\(match\.start, match\.end\)[\s\S]*syncFileViewerSearchOverlayScroll\(\)[\s\S]*textOffsetPosition\(surface, match\.start\)[\s\S]*scrollIntoView/, "match navigation should select and center source or rendered matches without mutating document selection");
|
|
49
53
|
assert.doesNotMatch(app.slice(app.indexOf("function focusFileViewerSearchMatch("), app.indexOf("\nfunction runFileViewerSearch(", app.indexOf("function focusFileViewerSearchMatch("))), /getSelection|addRange|removeAllRanges/, "rendered file search must not overwrite selections used by the Send to Pi workflow");
|
|
50
54
|
assert.match(app, /function runFileViewerSearch\([\s\S]*setAttribute\("aria-controls", surface\.id\)/, "the search input should identify the active Source, Preview, or Changes surface");
|
|
51
55
|
assert.match(app, /function setFileViewerMode\([\s\S]*updateFileViewerUi\(\);[\s\S]*runFileViewerSearch\(\{ navigate: true \}\)/, "an explicit mode switch should reveal the first match on the new surface");
|
|
@@ -60,6 +64,7 @@ assert.match(
|
|
|
60
64
|
assert.match(app, /function openChatSearch\(\)[\s\S]*closeFileViewerSearch\(\{ restoreFocus: false \}\)/, "opening transcript search should close any stale in-file search bar");
|
|
61
65
|
assert.match(css, /\.chat-search-bar,\s*\.file-viewer-search-bar \{/, "file search should reuse the transcript search layout conventions");
|
|
62
66
|
assert.match(css, /\.file-viewer-search-bar\[hidden\] \{ display: none; \}/, "the hidden file search bar should not consume viewer space");
|
|
63
|
-
assert.match(css,
|
|
67
|
+
assert.match(css, /\.file-viewer-search-overlay[\s\S]*\.file-viewer-content\.search-highlights-source[\s\S]*\.file-viewer-search-match\.current/, "source matches should use a scroll-synchronized visual overlay with a distinct current match");
|
|
68
|
+
assert.match(css, /::highlight\(file-viewer-search-match\)[\s\S]*::highlight\(file-viewer-search-current\)[\s\S]*\.file-viewer-search-match-fallback/, "rendered matches should highlight all exact ranges with a non-destructive fallback affordance");
|
|
64
69
|
|
|
65
70
|
console.log("file viewer focused search static tests passed");
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
|
+
const app = await readFile(join(root, "public", "app.js"), "utf8");
|
|
8
|
+
|
|
9
|
+
function functionBody(source, name) {
|
|
10
|
+
const match = new RegExp(`function\\s+${name}\\s*\\(`).exec(source);
|
|
11
|
+
assert.ok(match, `${name} should be defined`);
|
|
12
|
+
let parens = 0;
|
|
13
|
+
let open = -1;
|
|
14
|
+
for (let index = match.index + match[0].length - 1; index < source.length; index += 1) {
|
|
15
|
+
if (source[index] === "(") parens += 1;
|
|
16
|
+
else if (source[index] === ")") parens -= 1;
|
|
17
|
+
else if (source[index] === "{" && parens === 0) {
|
|
18
|
+
open = index;
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
assert.notEqual(open, -1, `${name} should open`);
|
|
23
|
+
let depth = 0;
|
|
24
|
+
for (let index = open; index < source.length; index += 1) {
|
|
25
|
+
if (source[index] === "{") depth += 1;
|
|
26
|
+
else if (source[index] === "}" && --depth === 0) return source.slice(open + 1, index);
|
|
27
|
+
}
|
|
28
|
+
assert.fail(`${name} should close`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
assert.match(app, /import \{ classifyTranscriptStreamEvent, createStreamOutputController \} from "\.\/stream-output-controller\.mjs";/);
|
|
32
|
+
assert.match(app, /let foregroundTranscriptCatchUpRequired = document\.visibilityState === "hidden";/);
|
|
33
|
+
|
|
34
|
+
const beginCatchUp = functionBody(app, "beginForegroundTranscriptCatchUp");
|
|
35
|
+
assert.match(beginCatchUp, /foregroundTranscriptCatchUpRequired = true/);
|
|
36
|
+
assert.match(beginCatchUp, /streamOutputController\.cancel\(\)/, "backgrounding should discard pending frame work rather than replaying it later");
|
|
37
|
+
assert.match(beginCatchUp, /eventStreamPausedForBackground = true[\s\S]*?eventSource = null[\s\S]*?source\.close\(\)/, "backgrounding should close the EventSource so Chromium cannot retain and replay an SSE backlog");
|
|
38
|
+
|
|
39
|
+
const dispatch = functionBody(app, "dispatchTranscriptStreamEvent");
|
|
40
|
+
assert.match(dispatch, /classifyTranscriptStreamEvent\(event\)/);
|
|
41
|
+
assert.match(dispatch, /document\.visibilityState === "hidden" \|\| foregroundTranscriptCatchUpRequired/);
|
|
42
|
+
assert.ok(
|
|
43
|
+
dispatch.indexOf("return true;") < dispatch.indexOf("streamOutputController.dispatch(event"),
|
|
44
|
+
"hidden transcript updates should be consumed without entering DOM render queues",
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const reconcile = functionBody(app, "reconcileForegroundState");
|
|
48
|
+
const authoritativeRefresh = reconcile.indexOf("refreshMessages(tabContext, { authoritative: true })");
|
|
49
|
+
const resumeLiveRendering = reconcile.indexOf("foregroundTranscriptCatchUpRequired = false");
|
|
50
|
+
const resumeEventStream = reconcile.indexOf("ensureActiveEventStream(tabContext)");
|
|
51
|
+
const supplementalRefresh = reconcile.indexOf("scheduleForegroundSupplementalRefresh(tabContext)");
|
|
52
|
+
assert.ok(authoritativeRefresh >= 0, "foreground catch-up should fetch one authoritative transcript snapshot");
|
|
53
|
+
assert.ok(authoritativeRefresh < resumeLiveRendering, "live transcript rendering must resume only after the authoritative snapshot settles");
|
|
54
|
+
assert.ok(resumeLiveRendering < resumeEventStream, "the event stream must reconnect only after authoritative transcript rendering resumes");
|
|
55
|
+
assert.ok(resumeEventStream < supplementalRefresh, "nonessential refresh work should be staged after transcript catch-up");
|
|
56
|
+
assert.match(reconcile, /backgroundReconnectSnapshotFresh = !\[\.\.\.tabResult, \.\.\.criticalResults\]\.some/, "a failed snapshot must not suppress reconnect recovery");
|
|
57
|
+
|
|
58
|
+
const supplemental = functionBody(app, "scheduleForegroundSupplementalRefresh");
|
|
59
|
+
assert.match(supplemental, /requestIdleCallback\(run, \{ timeout: 1_200 \}\)/, "supplemental panels should refresh during idle time when supported");
|
|
60
|
+
assert.match(supplemental, /setTimeout\(run, 250\)/, "browsers without idle callbacks should still yield before supplemental refreshes");
|
|
61
|
+
|
|
62
|
+
assert.doesNotMatch(app, /window\.addEventListener\("blur", beginForegroundTranscriptCatchUp\)/, "a visible but unfocused window must keep live streaming");
|
|
63
|
+
assert.match(
|
|
64
|
+
app,
|
|
65
|
+
/document\.addEventListener\("visibilitychange"[\s\S]*?beginForegroundTranscriptCatchUp\(\)[\s\S]*?mobileConnectionState = "away"/,
|
|
66
|
+
"the hidden transition should enter catch-up mode before background state rendering",
|
|
67
|
+
);
|
|
68
|
+
assert.match(app, /case "webui_connected":[\s\S]*?resumedWithFreshSnapshot[\s\S]*?if \(!resumedWithFreshSnapshot\) scheduleForegroundReconcile/, "the deliberate reconnect must not immediately trigger a second full refresh");
|
|
69
|
+
assert.match(app, /case "webui_supervisor_reconnected":[\s\S]*?foregroundReconnectSnapshotFreshUntil/, "initial supervisor replay must reuse the fresh foreground snapshot");
|
|
70
|
+
|
|
71
|
+
const executeBeginCatchUp = new Function("eventSource", "streamOutputController", `
|
|
72
|
+
let foregroundTranscriptCatchUpRequired = false;
|
|
73
|
+
let backgroundReconnectSnapshotFresh = true;
|
|
74
|
+
let eventStreamPausedForBackground = false;
|
|
75
|
+
${beginCatchUp}
|
|
76
|
+
return { foregroundTranscriptCatchUpRequired, backgroundReconnectSnapshotFresh, eventStreamPausedForBackground, eventSource };
|
|
77
|
+
`);
|
|
78
|
+
let closeCount = 0;
|
|
79
|
+
let cancelCount = 0;
|
|
80
|
+
const pausedState = executeBeginCatchUp(
|
|
81
|
+
{ close() { closeCount += 1; } },
|
|
82
|
+
{ cancel() { cancelCount += 1; } },
|
|
83
|
+
);
|
|
84
|
+
assert.equal(cancelCount, 1, "backgrounding should cancel pending transcript work exactly once");
|
|
85
|
+
assert.equal(closeCount, 1, "backgrounding should close the active EventSource exactly once");
|
|
86
|
+
assert.equal(pausedState.eventSource, null, "the closed EventSource must be detached so no queued message handler remains current");
|
|
87
|
+
assert.equal(pausedState.eventStreamPausedForBackground, true);
|
|
88
|
+
assert.equal(pausedState.backgroundReconnectSnapshotFresh, false);
|
|
89
|
+
assert.equal(pausedState.foregroundTranscriptCatchUpRequired, true);
|
|
90
|
+
|
|
91
|
+
console.log("foreground-transcript-catch-up-static.test.mjs passed");
|
|
@@ -2679,6 +2679,35 @@ try {
|
|
|
2679
2679
|
assert.equal(stashDrop.body?.ok, true, "confirmed stash drop should succeed");
|
|
2680
2680
|
assert.equal(stashDrop.body?.data?.stashes?.length, 0, "dropping the only stash should empty the list");
|
|
2681
2681
|
|
|
2682
|
+
// Both footer Sync and Guided Git use this push endpoint. Even when a
|
|
2683
|
+
// feature branch mistakenly tracks origin/main, push its current HEAD to
|
|
2684
|
+
// the same-named remote branch without changing remote main.
|
|
2685
|
+
const mismatchedPushBranch = "feature/current-branch-push";
|
|
2686
|
+
const remoteMainBeforeCurrentBranchPush = runGitFixture(["rev-parse", "refs/heads/main"], remoteBare, "current-branch push fixture should record remote main");
|
|
2687
|
+
runGitFixture(["switch", "-c", mismatchedPushBranch], localRepo, "current-branch push fixture should create its feature branch");
|
|
2688
|
+
runGitFixture(["config", `branch.${mismatchedPushBranch}.remote`, "origin"], localRepo, "current-branch push fixture should configure the upstream remote");
|
|
2689
|
+
runGitFixture(["config", `branch.${mismatchedPushBranch}.merge`, "refs/heads/main"], localRepo, "current-branch push fixture should reproduce the mismatched upstream branch");
|
|
2690
|
+
await writeFile(path.join(localRepo, "current-branch-push.txt"), "feature branch only\n");
|
|
2691
|
+
runGitFixture(["add", "current-branch-push.txt"], localRepo, "current-branch push fixture should stage its marker");
|
|
2692
|
+
runGitFixture(["commit", "-m", "current branch push fixture"], localRepo, "current-branch push fixture should commit its marker");
|
|
2693
|
+
const currentBranchHead = runGitFixture(["rev-parse", "HEAD"], localRepo, "current-branch push fixture should record feature HEAD");
|
|
2694
|
+
|
|
2695
|
+
const pushCurrentBranch = await request("127.0.0.1", "/api/git-workflow/push", { method: "POST", body: { tab: remoteTabId }, timeoutMs: 30_000 });
|
|
2696
|
+
assert.equal(pushCurrentBranch.body?.ok, true, `push should target the checked-out branch despite a mismatched upstream: ${pushCurrentBranch.body?.error || ""}`);
|
|
2697
|
+
assert.equal(pushCurrentBranch.body?.data?.branch, mismatchedPushBranch);
|
|
2698
|
+
assert.equal(pushCurrentBranch.body?.data?.remote, "origin");
|
|
2699
|
+
assert.equal(runGitFixture(["rev-parse", `refs/heads/${mismatchedPushBranch}`], remoteBare, "current-branch push fixture should create the same-named remote branch"), currentBranchHead);
|
|
2700
|
+
assert.equal(runGitFixture(["rev-parse", "refs/heads/main"], remoteBare, "current-branch push fixture should leave remote main unchanged"), remoteMainBeforeCurrentBranchPush);
|
|
2701
|
+
assert.equal(
|
|
2702
|
+
runGitFixture(["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{upstream}"], localRepo, "current-branch push fixture should read the repaired upstream"),
|
|
2703
|
+
`origin/${mismatchedPushBranch}`,
|
|
2704
|
+
"push should replace origin/main tracking with the same-named remote feature branch",
|
|
2705
|
+
);
|
|
2706
|
+
const currentBranchStatus = runGitFixture(["status", "--porcelain=v2", "--branch"], localRepo, "current-branch push fixture should read synchronized status");
|
|
2707
|
+
assert.match(currentBranchStatus, new RegExp(`^# branch\\.upstream origin/${mismatchedPushBranch}$`, "m"));
|
|
2708
|
+
assert.match(currentBranchStatus, /^# branch\.ab \+0 -0$/m, "the repaired upstream should leave no phantom outgoing Sync count");
|
|
2709
|
+
runGitFixture(["switch", "main"], localRepo, "current-branch push fixture should restore main");
|
|
2710
|
+
|
|
2682
2711
|
// Fetch, divergence classification, integrate, push classification
|
|
2683
2712
|
await writeFile(path.join(remoteWork, "incoming.txt"), "base\nremote one\nremote two\nremote three\n");
|
|
2684
2713
|
runGitFixture(["commit", "-am", "remote three"], remoteWork, "remote worktree should commit third incoming change");
|
|
@@ -2516,9 +2516,14 @@ assert.match(app, /case "message_end": \{(?:(?!case ")[\s\S])*?scheduleSemanticR
|
|
|
2516
2516
|
assert.match(html, /id="chatSearchBar"[\s\S]*?id="chatSearchInput"[\s\S]*?id="chatSearchPrevButton"[\s\S]*?id="chatSearchNextButton"[\s\S]*?id="chatSearchCloseButton"/, "transcript search bar markup should exist with navigation controls");
|
|
2517
2517
|
assert.match(app, /function openChatSearch\(\)[\s\S]*?elements\.chatSearchInput\?\.focus\(\)/, "opening transcript search should focus the input");
|
|
2518
2518
|
assert.match(app, /\(event\.ctrlKey \|\| event\.metaKey\) && !event\.altKey && !event\.shiftKey && event\.key\.toLowerCase\(\) === "f"/, "Ctrl\/Cmd+F should open the transcript search");
|
|
2519
|
+
assert.match(app, /function chatSearchRoot\(\)[\s\S]*subagentTerminalTranscript[\s\S]*elements\.chat/, "transcript search should target the active main or subagent output stream");
|
|
2520
|
+
assert.match(app, /function collectChatSearchMatches\(query\)[\s\S]*while \(matches\.length < CHAT_SEARCH_MATCH_LIMIT\)[\s\S]*matches\.push\(\{ bubble, start, end:/, "transcript search should collect every matching occurrence instead of only matching bubbles");
|
|
2521
|
+
assert.match(app, /function renderChatSearchHighlights\(\)[\s\S]*chat-search-match[\s\S]*new HighlightConstructor\(\.\.\.ranges\)[\s\S]*chat-search-current/, "transcript search should highlight all exact ranges and distinguish the current one");
|
|
2519
2522
|
assert.match(app, /function focusChatSearchMatch\(\)[\s\S]*?details\.open = true;[\s\S]*?scrollIntoView/, "navigating to a search match should expand collapsed tool output and scroll to the bubble");
|
|
2520
|
-
assert.match(app, /autoFollowChat = false;\n
|
|
2521
|
-
assert.match(
|
|
2523
|
+
assert.match(app, /autoFollowChat = false;\n lastChatProgrammaticScrollAt = performance\.now\(\);/, "main-transcript search navigation must not fight chat auto-follow");
|
|
2524
|
+
assert.match(app, /new MutationObserver\([\s\S]*runChatSearch\(\{ navigate: false \}\)[\s\S]*characterData: true/, "open searches should re-highlight refreshed live output without stealing navigation focus");
|
|
2525
|
+
assert.match(css, /::highlight\(chat-search-match\)[\s\S]*::highlight\(chat-search-current\)/, "all transcript matches and the current match should have distinct highlight styles");
|
|
2526
|
+
assert.doesNotMatch(css, /body\.subagent-terminal-active \.chat-search-bar/, "the search bar must remain visible while viewing a subagent output stream");
|
|
2522
2527
|
assert.match(css, /\.chat \{[^}]*overflow:\s*auto;[^}]*overflow-anchor:\s*none;/, "the transcript should disable browser scroll anchoring because paused-reader position is controlled explicitly during live growth");
|
|
2523
2528
|
assert.match(css, /\.chat-search-bar,\n\.file-viewer-search-bar \{/, "transcript search bar should be styled");
|
|
2524
2529
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
|
+
const [app, css, html] = await Promise.all([
|
|
8
|
+
readFile(join(root, "public", "app.js"), "utf8"),
|
|
9
|
+
readFile(join(root, "public", "styles.css"), "utf8"),
|
|
10
|
+
readFile(join(root, "public", "index.html"), "utf8"),
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
assert.match(html, /id="fileViewerSearchOverlay"[^>]*aria-hidden="true"[^>]*hidden/, "source search should expose a non-interactive highlight overlay");
|
|
14
|
+
assert.match(app, /function renderFileViewerSourceSearchHighlights\(\)[\s\S]*fileViewerSearchMatches\.forEach[\s\S]*make\("mark", `file-viewer-search-match/, "source search should render every match into its synchronized overlay");
|
|
15
|
+
assert.match(app, /function renderFileViewerSearchHighlights\(\)[\s\S]*new HighlightConstructor\(\.\.\.ranges\)[\s\S]*file-viewer-search-match[\s\S]*file-viewer-search-current/, "Preview and Changes should use exact all-match and current-match highlights");
|
|
16
|
+
assert.match(app, /fileViewerEditor\?\.addEventListener\("scroll", syncFileViewerSearchOverlayScroll\)/, "source highlights should track editor scrolling");
|
|
17
|
+
|
|
18
|
+
assert.match(app, /function chatSearchRoot\(\)[\s\S]*subagentTerminalTranscript[\s\S]*elements\.chat/, "output search should select the active main or subagent transcript");
|
|
19
|
+
assert.match(app, /function collectChatSearchMatches\(query\)[\s\S]*while \(matches\.length < CHAT_SEARCH_MATCH_LIMIT\)[\s\S]*matches\.push\(\{ bubble, start, end:/, "output search should collect every occurrence instead of one result per message");
|
|
20
|
+
assert.match(app, /function renderChatSearchHighlights\(\)[\s\S]*chat-search-match[\s\S]*new HighlightConstructor\(\.\.\.ranges\)[\s\S]*chat-search-current/, "output search should render exact all-match and current-match highlights");
|
|
21
|
+
assert.match(app, /new MutationObserver\([\s\S]*runChatSearch\(\{ navigate: false \}\)[\s\S]*characterData: true/, "live stream refreshes should reapply open search highlights");
|
|
22
|
+
assert.doesNotMatch(css, /body\.subagent-terminal-active \.chat-search-bar/, "the search bar should remain visible in a subagent output view");
|
|
23
|
+
|
|
24
|
+
assert.match(css, /::highlight\(file-viewer-search-match\),\s*::highlight\(chat-search-match\)/, "file and output searches should share an all-match highlight style");
|
|
25
|
+
assert.match(css, /::highlight\(file-viewer-search-current\),\s*::highlight\(chat-search-current\)/, "file and output searches should share a distinct current-match style");
|
|
26
|
+
|
|
27
|
+
console.log("search match highlighting static tests passed");
|
|
@@ -37,7 +37,7 @@ const forbiddenSinks = [
|
|
|
37
37
|
".focus(", "scrollIntoView", "fetch(", "api(",
|
|
38
38
|
];
|
|
39
39
|
|
|
40
|
-
assert.match(app, /import \{ createStreamOutputController \} from "\.\/stream-output-controller\.mjs";/);
|
|
40
|
+
assert.match(app, /import \{ classifyTranscriptStreamEvent, createStreamOutputController \} from "\.\/stream-output-controller\.mjs";/);
|
|
41
41
|
assert.match(controller, /export function classifyTranscriptStreamEvent/);
|
|
42
42
|
assert.match(controller, /export function createStreamOutputController/);
|
|
43
43
|
assert.match(controller, /let frameHandle = null;[\s\S]*?let pending = \[\];[\s\S]*?let pendingBytes = 0;/, "controller should retain one cancellable bounded queue");
|