@firstpick/pi-package-webui 0.7.0 → 0.7.2
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 +3 -0
- package/bin/pi-webui.mjs +243 -1
- package/index.ts +4 -0
- package/lib/subagent-gate.mjs +618 -0
- package/package.json +10 -9
- package/public/app.js +1250 -81
- package/public/index.html +72 -1
- package/public/styles.css +586 -18
- package/tests/fixtures/fake-pi.mjs +21 -4
- package/tests/git-panel-render-stability-static.test.mjs +43 -0
- package/tests/http-endpoints-harness.test.mjs +77 -1
- package/tests/mobile-static.test.mjs +119 -12
- package/tests/subagent-gate.test.mjs +300 -0
- package/tests/subagents-helper.test.mjs +34 -3
- package/webui-rpc-helper.mjs +165 -11
|
@@ -259,6 +259,8 @@ function handleWebuiHelperPrompt(command, base) {
|
|
|
259
259
|
status: "running",
|
|
260
260
|
currentTool: "read",
|
|
261
261
|
currentToolArgs: "README.md",
|
|
262
|
+
model: "anthropic/claude-opus-4-8:high",
|
|
263
|
+
thinking: "high",
|
|
262
264
|
recentTools: [{ tool: "grep", args: "Subagents", endMs: Date.now() - 200 }],
|
|
263
265
|
recentOutput: ["Inspecting current implementation", "Waiting for the next tool result"],
|
|
264
266
|
transcript: [
|
|
@@ -333,15 +335,30 @@ function handleTransportFixturePrompt(command, base) {
|
|
|
333
335
|
function handleSubagentFixturePrompt(command, base) {
|
|
334
336
|
const message = String(command.message || "").trim();
|
|
335
337
|
if (message !== "fixture subagents running" && message !== "fixture subagents clear") return false;
|
|
336
|
-
const
|
|
338
|
+
const clearing = message.endsWith("clear");
|
|
339
|
+
const runs = clearing ? [] : [{
|
|
337
340
|
id: "fixture-run",
|
|
338
341
|
source: "async",
|
|
339
342
|
mode: "parallel",
|
|
340
343
|
status: "running",
|
|
341
344
|
startedAt: Date.now() - 2500,
|
|
342
345
|
agents: [
|
|
343
|
-
{ id: "fixture-run:0", name: "reviewer", status: "running", index: 0, currentTool: "read", nested: false },
|
|
344
|
-
{ id: "fixture-run:1", name: "scout", status: "running", index: 1, nested: false },
|
|
346
|
+
{ id: "fixture-run:0", name: "reviewer", status: "running", index: 0, currentTool: "read", model: "anthropic/claude-opus-4-8:high", thinking: "high", nested: false },
|
|
347
|
+
{ id: "fixture-run:1", name: "scout", status: "running", index: 1, model: "openai-codex/gpt-5.6-sol", thinking: "high", nested: false },
|
|
348
|
+
],
|
|
349
|
+
}];
|
|
350
|
+
const gates = clearing ? [] : [{
|
|
351
|
+
version: 1,
|
|
352
|
+
id: "fixture-gate",
|
|
353
|
+
status: "running",
|
|
354
|
+
requiredSuccesses: 2,
|
|
355
|
+
qualifyingSuccesses: 1,
|
|
356
|
+
requireDistinctProviders: true,
|
|
357
|
+
startedAt: Date.now() - 3000,
|
|
358
|
+
updatedAt: Date.now(),
|
|
359
|
+
attempts: [
|
|
360
|
+
{ id: "fixture-gate:0:1", taskIndex: 0, attempt: 1, maxAttempts: 2, agent: "reviewer", retrySafety: "read-only", runId: "fixture-review-1", model: "anthropic/claude-opus-4-8", provider: "anthropic", status: "succeeded" },
|
|
361
|
+
{ id: "fixture-gate:1:1", taskIndex: 1, attempt: 1, maxAttempts: 2, agent: "reviewer", retrySafety: "read-only", runId: "fixture-review-2", model: "openrouter/moonshotai/kimi-k3", provider: "openrouter", status: "failed", failureKind: "transient-provider", error: "provider overloaded" },
|
|
345
362
|
],
|
|
346
363
|
}];
|
|
347
364
|
respond({ ...base, data: { output: "fake subagent status emitted" } });
|
|
@@ -350,7 +367,7 @@ function handleSubagentFixturePrompt(command, base) {
|
|
|
350
367
|
id: randomUUID(),
|
|
351
368
|
method: "setStatus",
|
|
352
369
|
statusKey: "webui-subagents",
|
|
353
|
-
statusText: `PI_WEBUI_SUBAGENTS_V1 ${JSON.stringify({ version: 1, available: true, updatedAt: Date.now(), runs })}`,
|
|
370
|
+
statusText: `PI_WEBUI_SUBAGENTS_V1 ${JSON.stringify({ version: 1, available: true, updatedAt: Date.now(), runs, gates })}`,
|
|
354
371
|
});
|
|
355
372
|
return true;
|
|
356
373
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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(name) {
|
|
10
|
+
const start = app.indexOf(`function ${name}(`);
|
|
11
|
+
assert.notEqual(start, -1, `${name} should be defined`);
|
|
12
|
+
const next = app.indexOf("\nfunction ", start + 1);
|
|
13
|
+
return app.slice(start, next === -1 ? app.length : next);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const renderGitPanel = functionBody("renderGitPanel");
|
|
17
|
+
const renderGitPanelFolder = functionBody("renderGitPanelFolder");
|
|
18
|
+
const renderContextMeter = functionBody("renderContextMeter");
|
|
19
|
+
const renderWorkspaceDashboard = functionBody("renderWorkspaceDashboard");
|
|
20
|
+
|
|
21
|
+
assert.match(app, /openFolders: new Map\(\)/, "Git panel state should persist folder toggles");
|
|
22
|
+
assert.match(renderGitPanelFolder, /const defaultOpen = depth === 0;/, "folder rendering should retain depth-based defaults");
|
|
23
|
+
assert.match(renderGitPanelFolder, /details\.open = gitPanelState\.openFolders\.has\(folderKey\) \? gitPanelState\.openFolders\.get\(folderKey\) : defaultOpen;/, "folder rendering should prefer a stored override over its default");
|
|
24
|
+
assert.match(renderGitPanelFolder, /if \(details\.open === defaultOpen\) gitPanelState\.openFolders\.delete\(folderKey\);/, "folder toggles back to the default should remove the override");
|
|
25
|
+
assert.match(renderGitPanelFolder, /else gitPanelState\.openFolders\.set\(folderKey, details\.open\);/, "folder toggles away from the default should store an override");
|
|
26
|
+
assert.match(renderGitPanel, /gitPanelState\.openFolders\.keys\(\)/, "folder state for removed roots should be pruned");
|
|
27
|
+
assert.doesNotMatch(renderGitPanel, /\bsectionExpanded\b/, "Git panel signature should not include the always-true section state");
|
|
28
|
+
|
|
29
|
+
const gitGuard = renderGitPanel.indexOf("signature === gitPanelRenderSignature");
|
|
30
|
+
const gitRebuild = renderGitPanel.indexOf("elements.gitPanelGroups.replaceChildren");
|
|
31
|
+
assert.ok(gitGuard > 0 && gitGuard < gitRebuild, "Git panel signature guard should precede its DOM rebuild");
|
|
32
|
+
assert.match(renderGitPanel, /snapshot\?\.loadedAt/, "Git panel signature should include repository snapshot versions");
|
|
33
|
+
assert.match(renderGitPanel, /gitPanelState\.activeViews\.get/, "Git panel signature should include active repository views");
|
|
34
|
+
|
|
35
|
+
const contextGuard = renderContextMeter.indexOf("signature === contextMeterSignature");
|
|
36
|
+
const contextRebuild = renderContextMeter.lastIndexOf("root.replaceChildren");
|
|
37
|
+
assert.ok(contextGuard > 0 && contextGuard < contextRebuild, "context meter signature guard should precede its DOM rebuild");
|
|
38
|
+
|
|
39
|
+
const dashboardGuard = renderWorkspaceDashboard.indexOf("signature === workspaceDashboardSignature");
|
|
40
|
+
const dashboardRebuild = renderWorkspaceDashboard.indexOf("root.replaceChildren");
|
|
41
|
+
assert.ok(dashboardGuard > 0 && dashboardGuard < dashboardRebuild, "workspace dashboard signature guard should precede its DOM rebuild");
|
|
42
|
+
|
|
43
|
+
console.log("git-panel-render-stability-static.test.mjs passed");
|
|
@@ -425,11 +425,17 @@ try {
|
|
|
425
425
|
assert.equal(subagentsResponse.body?.data?.totalAgents, 2, "subagent overview should count all running agents");
|
|
426
426
|
assert.equal(subagentsResponse.body?.data?.tabs?.[0]?.tabId, tabId, "subagent overview should group agents under their terminal tab");
|
|
427
427
|
assert.deepEqual(subagentsResponse.body?.data?.tabs?.[0]?.runs?.[0]?.agents?.map((agent) => agent.name), ["reviewer", "scout"], "subagent overview should preserve agent order within the session run");
|
|
428
|
+
assert.deepEqual(subagentsResponse.body?.data?.tabs?.[0]?.runs?.[0]?.agents?.map((agent) => [agent.model, agent.thinking]), [["anthropic/claude-opus-4-8:high", "high"], ["openai-codex/gpt-5.6-sol", "high"]], "subagent overview should preserve bounded model and reasoning metadata");
|
|
429
|
+
assert.equal(subagentsResponse.body?.data?.totalGates, 1, "subagent overview should expose retry gates independently from running children");
|
|
430
|
+
assert.equal(subagentsResponse.body?.data?.tabs?.[0]?.gates?.[0]?.qualifyingSuccesses, 1, "retry gate quorum should be normalized");
|
|
431
|
+
assert.deepEqual(subagentsResponse.body?.data?.tabs?.[0]?.gates?.[0]?.attempts?.map((attempt) => [attempt.status, attempt.failureKind]), [["succeeded", undefined], ["failed", "transient-provider"]], "retry gate attempts should preserve bounded status and failure classification");
|
|
428
432
|
const subagentOutputResponse = await request("127.0.0.1", `/api/subagents/output?tab=${encodeURIComponent(tabId)}&run=${encodeURIComponent("fixture-run")}&agent=${encodeURIComponent("fixture-run:0")}`);
|
|
429
433
|
assert.equal(subagentOutputResponse.status, 200, "running subagent output endpoint should respond");
|
|
430
434
|
assert.equal(subagentOutputResponse.body?.data?.agent?.name, "reviewer", "subagent output should target the selected child agent");
|
|
431
435
|
assert.deepEqual(subagentOutputResponse.body?.data?.agent?.recentOutput, ["Inspecting current implementation", "Waiting for the next tool result"], "subagent output should preserve bounded live output lines");
|
|
432
436
|
assert.equal(subagentOutputResponse.body?.data?.agent?.currentToolArgs, "README.md", "subagent output should include current tool state");
|
|
437
|
+
assert.equal(subagentOutputResponse.body?.data?.agent?.model, "anthropic/claude-opus-4-8:high", "subagent output should preserve the effective model");
|
|
438
|
+
assert.equal(subagentOutputResponse.body?.data?.agent?.thinking, "high", "subagent output should preserve the effective reasoning effort");
|
|
433
439
|
assert.deepEqual(subagentOutputResponse.body?.data?.agent?.transcript, [
|
|
434
440
|
{
|
|
435
441
|
role: "assistant",
|
|
@@ -459,6 +465,7 @@ try {
|
|
|
459
465
|
await delay(50);
|
|
460
466
|
}
|
|
461
467
|
assert.equal(subagentsResponse.body?.data?.totalAgents, 0, "completed subagents should disappear from the running overview");
|
|
468
|
+
assert.equal(subagentsResponse.body?.data?.totalGates, 0, "cleared retry gates should disappear from the overview");
|
|
462
469
|
|
|
463
470
|
const state = await request("127.0.0.1", `/api/state?tab=${encodeURIComponent(tabId)}`);
|
|
464
471
|
assert.equal(state.status, 200);
|
|
@@ -555,6 +562,30 @@ try {
|
|
|
555
562
|
assert.equal(initialWorktrees.body?.ok, true, "worktree list endpoint should return data for a git repository");
|
|
556
563
|
assert.ok(initialWorktrees.body?.data?.worktrees?.some((worktree) => worktree.isMainWorktree && worktree.current), "worktree list should include the current main worktree");
|
|
557
564
|
|
|
565
|
+
const originMainBase = runGitFixture(["rev-parse", "HEAD"], cwd, "origin/main base fixture should resolve current HEAD");
|
|
566
|
+
runGitFixture(["update-ref", "refs/remotes/origin/main", originMainBase], cwd, "origin/main base fixture should create a remote-tracking ref");
|
|
567
|
+
await writeFile(path.join(cwd, "workspace-head.txt"), "current workspace only\n");
|
|
568
|
+
runGitFixture(["add", "workspace-head.txt"], cwd, "workspace HEAD fixture should stage its marker");
|
|
569
|
+
runGitFixture(["commit", "-m", "test: advance workspace head"], cwd, "workspace HEAD fixture should advance main beyond origin/main");
|
|
570
|
+
const workspaceHead = runGitFixture(["rev-parse", "HEAD"], cwd, "workspace HEAD fixture should resolve advanced HEAD");
|
|
571
|
+
assert.notEqual(workspaceHead, originMainBase, "workspace HEAD should differ from origin/main for base selection coverage");
|
|
572
|
+
|
|
573
|
+
const originBasedBranch = "feat/origin-main-base";
|
|
574
|
+
const originBasedWorktree = await request("127.0.0.1", "/api/git-worktrees", {
|
|
575
|
+
method: "POST",
|
|
576
|
+
body: { tab: tabId, branchName: originBasedBranch, baseRef: "origin/main", sessionMode: "empty", openTab: true },
|
|
577
|
+
timeoutMs: 20_000,
|
|
578
|
+
});
|
|
579
|
+
assert.equal(originBasedWorktree.status, 200);
|
|
580
|
+
assert.equal(originBasedWorktree.body?.ok, true, `origin/main-based worktree should be created: ${originBasedWorktree.body?.error || ""}`);
|
|
581
|
+
const originBasedWorktreePath = originBasedWorktree.body?.data?.worktree?.path || originBasedWorktree.body?.data?.path;
|
|
582
|
+
const originBasedWorktreeTabId = originBasedWorktree.body?.data?.tab?.id;
|
|
583
|
+
assert.equal(runGitFixture(["rev-parse", "HEAD"], originBasedWorktreePath, "origin/main-based worktree should resolve its HEAD"), originMainBase, "explicit baseRef should create the branch from origin/main rather than the current workspace HEAD");
|
|
584
|
+
const closeOriginBasedTab = await request("127.0.0.1", "/api/tabs/close", { method: "POST", body: { ids: [originBasedWorktreeTabId] }, timeoutMs: 10_000 });
|
|
585
|
+
assert.equal(closeOriginBasedTab.body?.ok, true, "origin/main-based worktree tab should close before cleanup");
|
|
586
|
+
const removeOriginBasedWorktree = await request("127.0.0.1", "/api/git-worktrees", { method: "DELETE", body: { tab: tabId, path: originBasedWorktreePath, confirmed: true }, timeoutMs: 20_000 });
|
|
587
|
+
assert.equal(removeOriginBasedWorktree.body?.ok, true, "origin/main-based worktree should be removable after the tab closes");
|
|
588
|
+
|
|
558
589
|
await writeFile(path.join(cwd, "guided.txt"), "guided worktree flow\n");
|
|
559
590
|
runGitFixture(["add", "guided.txt"], cwd, "source checkout should stage guided workflow changes");
|
|
560
591
|
await mkdir(path.join(cwd, "dev", "COMMIT"), { recursive: true });
|
|
@@ -597,7 +628,7 @@ try {
|
|
|
597
628
|
const worktreeBranch = "feat/http-worktree";
|
|
598
629
|
const createWorktree = await request("127.0.0.1", "/api/git-worktrees", {
|
|
599
630
|
method: "POST",
|
|
600
|
-
body: { tab: tabId, branchName: worktreeBranch, sessionMode: "empty", openTab: true },
|
|
631
|
+
body: { tab: tabId, branchName: worktreeBranch, baseRef: "HEAD", sessionMode: "empty", openTab: true },
|
|
601
632
|
timeoutMs: 20_000,
|
|
602
633
|
});
|
|
603
634
|
assert.equal(createWorktree.status, 200);
|
|
@@ -611,6 +642,7 @@ try {
|
|
|
611
642
|
assert.equal(createWorktree.body?.data?.tab?.cwd, worktreePath, "opened worktree tab should be rooted at the worktree path");
|
|
612
643
|
assert.equal(createWorktree.body?.data?.tab?.gitWorkspace?.branch, worktreeBranch, "opened tab metadata should record the worktree branch");
|
|
613
644
|
assert.equal(createWorktree.body?.data?.tab?.gitWorkspace?.worktreePath, worktreePath, "opened tab metadata should record the worktree path");
|
|
645
|
+
assert.equal(runGitFixture(["rev-parse", "HEAD"], worktreePath, "current-HEAD-based worktree should resolve its HEAD"), workspaceHead, "explicit HEAD baseRef should create the branch from the active workspace commit");
|
|
614
646
|
|
|
615
647
|
const branchesWithWorktree = await request("127.0.0.1", `/api/git-branches?tab=${encodeURIComponent(tabId)}`);
|
|
616
648
|
assert.equal(branchesWithWorktree.status, 200);
|
|
@@ -811,11 +843,55 @@ try {
|
|
|
811
843
|
await writeFile(path.join(stagingRepo, "file.txt"), "modified\n");
|
|
812
844
|
await writeFile(path.join(stagingRepo, "loose.txt"), "loose\n");
|
|
813
845
|
|
|
846
|
+
const gitRoot = await request("127.0.0.1", `/api/git-root?tab=${encodeURIComponent(stagingTab)}`);
|
|
847
|
+
assert.equal(gitRoot.body?.ok, true, "git-root endpoint should discover the tab repository");
|
|
848
|
+
assert.equal(gitRoot.body?.data?.root, stagingRepo, "git-root should return the canonical fixture root");
|
|
849
|
+
|
|
850
|
+
const gitPanel = await request("127.0.0.1", `/api/git-panel?tab=${encodeURIComponent(stagingTab)}`);
|
|
851
|
+
assert.equal(gitPanel.body?.ok, true, "git-panel endpoint should return compact local status and history");
|
|
852
|
+
assert.equal(gitPanel.body?.data?.root, stagingRepo);
|
|
853
|
+
assert.equal(gitPanel.body?.data?.history?.length, 1, "git-panel should include the bounded recent commit history");
|
|
854
|
+
assert.equal(gitPanel.body?.data?.history?.[0]?.subject, "base");
|
|
855
|
+
const modifiedPanelEntry = gitPanel.body?.data?.changes?.find((entry) => entry.path === "file.txt");
|
|
856
|
+
assert.equal(modifiedPanelEntry?.unstaged, true, "git-panel should classify modified tracked files");
|
|
857
|
+
assert.equal(modifiedPanelEntry?.additions, 1, "git-panel should report unstaged additions from numstat");
|
|
858
|
+
assert.equal(modifiedPanelEntry?.deletions, 1, "git-panel should report unstaged deletions from numstat");
|
|
859
|
+
assert.equal(gitPanel.body?.data?.changes?.find((entry) => entry.path === "loose.txt")?.untracked, true, "git-panel should classify untracked files");
|
|
860
|
+
assert.equal(Object.prototype.hasOwnProperty.call(gitPanel.body?.data?.changes?.[0] || {}, "content"), false, "compact git-panel entries must not include file contents");
|
|
861
|
+
|
|
862
|
+
const fixtureHead = runGitFixture(["rev-parse", "HEAD"], stagingRepo, "staging fixture should expose its full HEAD hash");
|
|
863
|
+
const gitPanelCommit = await request("127.0.0.1", `/api/git-commit?tab=${encodeURIComponent(stagingTab)}&hash=${encodeURIComponent(fixtureHead)}`);
|
|
864
|
+
assert.equal(gitPanelCommit.body?.ok, true, "git-commit endpoint should return a bounded read-only commit diff");
|
|
865
|
+
assert.equal(gitPanelCommit.body?.data?.commit?.hash, fixtureHead);
|
|
866
|
+
assert.match(gitPanelCommit.body?.data?.sections?.[0]?.diff || "", /diff --git a\/file\.txt b\/file\.txt/, "git-commit should include the selected commit patch");
|
|
867
|
+
const invalidCommit = await request("127.0.0.1", `/api/git-commit?tab=${encodeURIComponent(stagingTab)}&hash=HEAD`);
|
|
868
|
+
assert.equal(invalidCommit.status, 400, "git-commit should reject symbolic or abbreviated revisions");
|
|
869
|
+
|
|
870
|
+
const stageAll = await request("127.0.0.1", "/api/git-changes/stage-all", { method: "POST", body: { tab: stagingTab } });
|
|
871
|
+
assert.equal(stageAll.body?.ok, true, "stage-all endpoint should stage the selected repository");
|
|
872
|
+
const stagedPanel = await request("127.0.0.1", `/api/git-panel?tab=${encodeURIComponent(stagingTab)}`);
|
|
873
|
+
assert.equal(stagedPanel.body?.data?.summary?.staged, 2, "stage-all should stage tracked and untracked changes");
|
|
874
|
+
const unstageAll = await request("127.0.0.1", "/api/git-changes/unstage-all", { method: "POST", body: { tab: stagingTab } });
|
|
875
|
+
assert.equal(unstageAll.body?.ok, true, "unstage-all endpoint should clear the selected repository index");
|
|
876
|
+
const unstagedPanel = await request("127.0.0.1", `/api/git-panel?tab=${encodeURIComponent(stagingTab)}`);
|
|
877
|
+
assert.equal(unstagedPanel.body?.data?.summary?.staged, 0, "unstage-all should leave no staged changes");
|
|
878
|
+
assert.equal(unstagedPanel.body?.data?.changes?.find((entry) => entry.path === "loose.txt")?.untracked, true, "unstage-all should restore newly added files to untracked state");
|
|
879
|
+
|
|
814
880
|
const stageFile = await request("127.0.0.1", "/api/git-changes/stage-file", { method: "POST", body: { tab: stagingTab, path: "file.txt" } });
|
|
815
881
|
assert.equal(stageFile.status, 200);
|
|
816
882
|
assert.equal(stageFile.body?.ok, true, "stage-file endpoint should stage a modified file");
|
|
817
883
|
assert.equal(stageFile.body?.data?.changes?.summary?.staged, 1, "stage-file should report one staged file afterwards");
|
|
818
884
|
|
|
885
|
+
await writeFile(path.join(stagingRepo, "file.txt"), "modified again\n");
|
|
886
|
+
const mixedPanel = await request("127.0.0.1", `/api/git-panel?tab=${encodeURIComponent(stagingTab)}`);
|
|
887
|
+
const mixedEntry = mixedPanel.body?.data?.changes?.find((entry) => entry.path === "file.txt");
|
|
888
|
+
assert.equal(mixedEntry?.staged, true, "mixed index/worktree files should remain staged");
|
|
889
|
+
assert.equal(mixedEntry?.unstaged, true, "mixed index/worktree files should also remain unstaged");
|
|
890
|
+
assert.equal(mixedEntry?.stagedAdditions, 1, "Git panel should preserve staged additions separately");
|
|
891
|
+
assert.equal(mixedEntry?.stagedDeletions, 1, "Git panel should preserve staged deletions separately");
|
|
892
|
+
assert.equal(mixedEntry?.unstagedAdditions, 1, "Git panel should preserve unstaged additions separately");
|
|
893
|
+
assert.equal(mixedEntry?.unstagedDeletions, 1, "Git panel should preserve unstaged deletions separately");
|
|
894
|
+
|
|
819
895
|
const unstageFile = await request("127.0.0.1", "/api/git-changes/unstage-file", { method: "POST", body: { tab: stagingTab, path: "file.txt" } });
|
|
820
896
|
assert.equal(unstageFile.status, 200);
|
|
821
897
|
assert.equal(unstageFile.body?.ok, true, "unstage-file endpoint should unstage the file");
|
|
@@ -107,12 +107,51 @@ assert.match(html, /id="pathPickerSearchInput"[^>]*type="search"[^>]*placeholder
|
|
|
107
107
|
assert.match(html, /id="pathPickerClearSearchButton"[^>]*hidden[^>]*>Clear<\/button>/, "cwd picker should expose a clear-search action");
|
|
108
108
|
assert.match(app, /function fileTreeGitStatusForEntry\(entry = \{\}\) \{\s+return fileTreeState\.gitStatusByPath\.get\(normalizeFileTreePath\(entry\.path \|\| ""\)\) \|\| null;\s+\}/, "file tree rendering should use the refreshed Git-status snapshot instead of stale status embedded in cached entries");
|
|
109
109
|
assert.match(app, /confirmLabel: activeAgentTabs\.length \? "Close and stop work" : count === 1 \? "Close tab" : "Close tabs"/, "single-tab confirmation should use singular close wording");
|
|
110
|
+
assert.match(html, /data-side-panel-section="git"[\s\S]*class="side-panel-section-label">Git<[\s\S]*id="gitPanelCountBadge"[\s\S]*id="gitPanelGroups"[\s\S]*aria-label="Git repositories"[\s\S]*id="gitPanelContextMenu"[\s\S]*role="menu"/, "side panel should expose a collapsed, globally deduplicated Git repository list with a count and dedicated action menu");
|
|
111
|
+
assert.match(app, /const GIT_PANEL_CACHE_MAX_AGE_MS = 5 \* 60 \* 1000/, "Git panel should use the approved five-minute page-local freshness window");
|
|
112
|
+
assert.match(app, /function gitPanelTerminalGroups\(\)[\s\S]*tabCwdGroups\(\)[\s\S]*shouldRenderTerminalTabGroup[\s\S]*key: `tab:\$\{tab\.id\}`[\s\S]*title: tabGroupTitle\(tab\.cwd, "Working directory"\)/, "Git panel discovery should mirror visible terminal groups while cwd—not session title—defines ungrouped labels");
|
|
113
|
+
assert.match(app, /function gitPanelCandidates\(groups = gitPanelTerminalGroups\(\)\)[\s\S]*const byCwd = new Map\(\)[\s\S]*key: `cwd:\$\{cwd\}`/, "Git panel discovery should deduplicate repeated cwd candidates globally across terminal groups");
|
|
114
|
+
assert.match(app, /function gitPanelRepositoryCards\(groups = gitPanelTerminalGroups\(\)\)[\s\S]*const identity = root \? `root:\$\{root\}` : candidate\.key[\s\S]*byIdentity/, "Git panel cards should deduplicate discovered repositories globally by canonical Git root");
|
|
115
|
+
assert.match(app, /const cards = gitPanelRepositoryCards\(groups\)/, "Git panel rendering should consume the globally deduplicated repository card list");
|
|
116
|
+
const gitPanelCandidatesSource = appFunctionSource("gitPanelCandidates", "gitPanelRepositoryCards");
|
|
117
|
+
const gitPanelRepositoryCardsSource = appFunctionSource("gitPanelRepositoryCards", "gitPanelRootLabel");
|
|
118
|
+
const gitPanelDeduplication = JSON.parse(vm.runInNewContext(`${gitPanelCandidatesSource}\n${gitPanelRepositoryCardsSource}\nJSON.stringify((() => {\n const groups = [\n { key: "group-a", tabs: [{ id: "tab-1", cwd: "/repo" }, { id: "tab-2", cwd: "/repo" }] },\n { key: "group-b", tabs: [{ id: "tab-3", cwd: "/repo" }, { id: "tab-4", cwd: "/repo/subdir" }] },\n ];\n gitPanelState.discovery.set("cwd:/repo", { root: "/repo", resolved: true });\n gitPanelState.discovery.set("cwd:/repo/subdir", { root: "/repo", resolved: true });\n return { candidates: gitPanelCandidates(groups), cards: gitPanelRepositoryCards(groups) };\n})())`, {
|
|
119
|
+
gitPanelState: { discovery: new Map() },
|
|
120
|
+
gitPanelTerminalGroups: () => [],
|
|
121
|
+
tabGroupTitle: (cwd) => cwd.split("/").filter(Boolean).pop() || "Working directory",
|
|
122
|
+
}));
|
|
123
|
+
assert.equal(gitPanelDeduplication.candidates.length, 2, "repeated cwd tabs across terminal groups should create one discovery candidate per cwd");
|
|
124
|
+
assert.equal(gitPanelDeduplication.cards.length, 1, "different cwd candidates in the same canonical repository should render one card globally");
|
|
125
|
+
assert.equal(gitPanelDeduplication.cards[0].key, "root:/repo", "the global repository card key should be based only on the canonical Git root");
|
|
126
|
+
assert.match(app, /function toggleGitPanelRepository\(card\)[\s\S]*gitPanelState\.expandedCardKey === card\.key[\s\S]*gitPanelState\.expandedCardKey = card\.key/, "only one Git repository card should be expanded at a time");
|
|
127
|
+
assert.match(app, /function loadGitPanelRepository\(card, \{ force = false \} = \{\}\)[\s\S]*!force && gitPanelSnapshotFresh\(existing\)[\s\S]*api\("\/api\/git-panel"/, "repository expansion should reuse fresh cache and otherwise load local status on demand");
|
|
128
|
+
assert.match(app, /ensureGitPanelRepositoriesDiscovered\(\{ retryUnavailable: true \}\)[\s\S]*function ensureGitPanelRepositoriesDiscovered\(\{ retryUnavailable = false \} = \{\}\)[\s\S]*discoverGitPanelCandidate\(candidate, \{ force: true \}\)/, "reopening the Git section should rediscover cwd entries that were previously not repositories");
|
|
129
|
+
assert.match(app, /function renderGitPanel\(\) \{\s+if \(!elements\.gitPanelGroups \|\| !gitPanelSectionExpanded\(\)\) return;/, "tab polling should not rebuild the Git panel while its top-level section is collapsed");
|
|
130
|
+
assert.doesNotMatch(app, /make\("div", "git-side-panel-tree"[\s\S]{0,180}setAttribute\("role", "tree"\)/, "Git file disclosures should use native details semantics instead of an incomplete ARIA tree");
|
|
131
|
+
assert.match(app, /function gitPanelStatsText\(entry = \{\}, category = ""\)[\s\S]*category === "staged"[\s\S]*category === "changes"/, "mixed index/worktree files should display category-specific numstat values");
|
|
132
|
+
assert.match(app, /function renderGitPanelChanges\(card, data\)[\s\S]*"Conflicts"[\s\S]*"Staged"[\s\S]*"Changes"[\s\S]*"Untracked"/, "Git panel should render every requested change category");
|
|
133
|
+
assert.match(app, /function runGitPanelAction\(card, action, path = ""\)[\s\S]*"stage-all"[\s\S]*"unstage-all"[\s\S]*confirm:[\s\S]*git restore --[\s\S]*Delete untracked file/, "Git panel actions should cover staging plus confirmed destructive discard/delete flows");
|
|
134
|
+
assert.match(app, /function renderGitPanelHistory\(card, data\)[\s\S]*openGitCommitDialog\(card\.tabId, commit\)/, "Git History should open bounded commit diffs from the selected repository");
|
|
135
|
+
assert.match(app, /elements\.gitPanelGroups\.replaceChildren\(\.\.\.cards\.map\(renderGitPanelRepositoryCard\)\)/, "Git repositories should render directly without a redundant terminal/session disclosure");
|
|
136
|
+
assert.doesNotMatch(app, /function renderGitPanelGroup\(/, "Git panel should not render terminal/session parent dropdowns");
|
|
137
|
+
assert.match(app, /function gitPanelContextMenuItems\(context\)[\s\S]*kind === "repository"[\s\S]*"View Diff"[\s\S]*"Stage All"[\s\S]*"Unstage All"[\s\S]*"Discard changes…"[\s\S]*"Delete file…"/, "repository and path actions should be provided by the Git context menu");
|
|
138
|
+
assert.match(app, /function bindGitPanelContextMenu\(trigger, context\)[\s\S]*"contextmenu"[\s\S]*"ContextMenu"[\s\S]*event\.shiftKey && event\.key === "F10"/, "Git context actions should support right click and keyboard-equivalent invocation");
|
|
139
|
+
assert.doesNotMatch(app, /git-side-panel-file-actions|git-side-panel-toolbar-actions|git-side-panel-stage-select|gitPanelSmallButton/, "Git rows should not render the removed inline action controls");
|
|
140
|
+
assert.match(app, /function renderGitPanelFolder\(node, card, category, depth = 0\)[\s\S]*const defaultOpen = depth === 0[\s\S]*details\.open =[\s\S]*git-side-panel-folder-chevron[\s\S]*aria-hidden/, "Git folders should render an explicit decorative disclosure arrow");
|
|
141
|
+
assert.match(css, /\.git-side-panel-folder-chevron[\s\S]*transform: rotate\(0deg\)[\s\S]*\.git-side-panel-folder\[open\][\s\S]*transform: rotate\(90deg\)/, "Git folder arrows should indicate collapsed and expanded states");
|
|
142
|
+
assert.match(css, /\.git-side-panel-repository[\s\S]*\.git-side-panel-file[\s\S]*grid-template-columns: 1\.3rem minmax\(5rem, 1fr\) auto[\s\S]*\.git-side-panel-context-menu[\s\S]*\.git-side-panel-commit/, "Git side panel should prioritize filename width and style repository, context-menu, and history surfaces");
|
|
143
|
+
assert.match(server, /async function readGitPanel\(cwd\)[\s\S]*GIT_PANEL_HISTORY_LIMIT[\s\S]*"status", "--porcelain=v1", "-z"[\s\S]*"--numstat", "-z"/, "server should build compact bounded local Git snapshots without full file contents");
|
|
144
|
+
assert.match(server, /async function readGitCommit\(cwd, requestedHash\)[\s\S]*\^\[a-f0-9\][\s\S]*"show", "--format="/, "commit inspection should require a full hash and use a bounded read-only Git show");
|
|
145
|
+
assert.match(server, /"\/api\/git-changes\/stage-all"[\s\S]*stageAllGitChanges[\s\S]*"\/api\/git-changes\/unstage-all"[\s\S]*unstageAllGitChanges/, "server should expose repository-wide stage and unstage mutations");
|
|
146
|
+
assert.match(readme, /side-panel \*\*Git\*\* section[\s\S]*five-minute cache window[\s\S]*confirmed discard\/delete actions[\s\S]*latest 30 commits/, "README should document Git panel grouping, refresh, actions, and history behavior");
|
|
110
147
|
assert.match(html, /id="optionalFeaturesBox"/, "side panel should expose optional feature status and controls");
|
|
111
148
|
assert.match(html, /class="optional-features-description[\s\S]*href="https:\/\/github\.com\/Firstp1ck\/npm-packages\/issues\/new"[\s\S]*open a GitHub issue/, "optional features should link users to GitHub issues for additional feature requests");
|
|
112
149
|
assert.doesNotMatch(html, /id="btwOverlayDialog"/, "/btw should not use a blocking modal overlay");
|
|
113
150
|
assert.match(html, /id="codexUsageBox"/, "side panel should expose Codex subscription usage status");
|
|
114
151
|
assert.match(html, /data-side-panel-section="codex-usage"/, "Codex usage should live in a collapsible side-panel section");
|
|
115
|
-
assert.match(html, /data-side-panel-section="subagents"[\s\S]*class="side-panel-section-label">Subagents<\/span>[\s\S]*id="subagentCountBadge"[\s\S]*class="subagents-help"[\s\S]*<code>subagent<\/code>[\s\S]*
|
|
152
|
+
assert.match(html, /data-side-panel-section="subagents"[\s\S]*class="side-panel-section-label">Subagents<\/span>[\s\S]*id="subagentCountBadge"[\s\S]*class="subagents-help"[\s\S]*<code>subagent<\/code>[\s\S]*<code>subagent_gate<\/code>[\s\S]*bounded retries or a success quorum[\s\S]*id="subagentsBox"/, "side panel should explain ordinary delegation and retry-gate workflows with a live count");
|
|
153
|
+
assert.match(html, /id="subagentOpenModeSelect"[\s\S]*<option value="overlay">Overlay<\/option>[\s\S]*<option value="tab">Tab \/ terminal<\/option>[\s\S]*id="subagentOpenModeStatus"/, "Subagents should offer a browser-persisted overlay or terminal-tab opening choice");
|
|
154
|
+
assert.match(html, /id="subagentTerminalView"[\s\S]*Subagent · view only[\s\S]*id="subagentTerminalTranscript"[\s\S]*id="subagentTerminalStatus"[^>]*aria-live="off"[\s\S]*id="subagentTerminalInput"[^>]*placeholder="View only — send messages from the parent terminal"[^>]*disabled[\s\S]*Use its parent terminal to interact with the run/, "dedicated subagent tabs should expose a view-only transcript, non-announcing routine status, and disabled input");
|
|
116
155
|
assert.doesNotMatch(html, /id="subagentOverlayDialog"/, "subagent output should not use a blocking modal dialog");
|
|
117
156
|
assert.match(html, /data-side-panel-section="session"[\s\S]*data-side-panel-section="subagents"[\s\S]*data-side-panel-section="queue"/, "Subagents should appear between Session and Queue in the side panel");
|
|
118
157
|
assert.match(html, /data-side-panel-section="queue"[\s\S]*id="createPromptListButton"[\s\S]*>Create prompt list<\/button>/, "Queue section should expose prompt-list creation");
|
|
@@ -348,9 +387,13 @@ assert.match(css, /\.side-panel-section\.collapsed \.side-panel-section-content,
|
|
|
348
387
|
assert.match(css, /\.side-panel-section:not\(\.collapsed\) \.side-panel-section-chevron/, "expanded side panel sections should rotate the chevron");
|
|
349
388
|
assert.match(css, /\.subagents-help \{[\s\S]*border-left:[\s\S]*font-size:\s*0\.7rem;[\s\S]*\.subagents-help code/, "subagent invocation guidance should render as a compact informational callout");
|
|
350
389
|
assert.match(css, /\.subagents-box\.has-items[\s\S]*\.subagent-tab-group[\s\S]*\.subagent-agent-row/, "running subagents should render as grouped terminal/session cards");
|
|
390
|
+
assert.match(css, /\.subagent-gate-card[\s\S]*\.subagent-gate-status[\s\S]*\.subagent-gate-attempt[\s\S]*\.subagent-gate-attempt-error/, "retry gates should render quorum, attempt status, and failure details");
|
|
351
391
|
assert.match(css, /\.subagent-agent-row:hover,[\s\S]*\.subagent-agent-row:focus-visible/, "subagent rows should expose clickable hover and keyboard focus states");
|
|
352
392
|
assert.match(css, /\.subagent-overlay-widget[\s\S]*\.subagent-overlay-transcript[\s\S]*\.subagent-overlay-message[\s\S]*\.subagent-overlay-close-action/, "subagent output should combine the non-blocking widget shell with the main transcript message styling");
|
|
353
|
-
assert.match(css, /\.subagent-
|
|
393
|
+
assert.match(css, /\.terminal-tab-subagent-indicator[\s\S]*\.terminal-tab-subagent[\s\S]*\.subagent-terminal-view[\s\S]*\.subagent-terminal-composer textarea:disabled/, "subagent terminal tabs should be visibly marked and retain an explicit disabled composer");
|
|
394
|
+
assert.match(css, /body\.subagent-terminal-active \.workspace-dashboard,[\s\S]*body\.subagent-terminal-active \.composer[\s\S]*display: none !important/, "the dedicated child view should replace parent terminal content without mutating it");
|
|
395
|
+
assert.match(css, /\.subagent-run-indicator[\s\S]*\.subagent-run-indicator \.run-indicator-meta/, "subagent output should reuse the main live run-indicator treatment with wrapping activity metadata");
|
|
396
|
+
assert.match(css, /\.subagent-terminal-transcript > \.message \{[\s\S]*width: 100%;[\s\S]*max-width: none;/, "dedicated subagent transcript cards should fill the available tab width");
|
|
354
397
|
assert.doesNotMatch(css, /\.extension-dialog\.subagent-overlay-dialog/, "subagent output should not retain blocking dialog styles");
|
|
355
398
|
assert.match(css, /@keyframes subagent-running-pulse/, "running subagents should expose a live activity indicator");
|
|
356
399
|
assert.match(css, /\.optional-feature-pill\.enabled/, "optional features should visually distinguish enabled state");
|
|
@@ -713,11 +756,69 @@ assert.match(
|
|
|
713
756
|
"side-panel section toggles should expand at most one section at a time",
|
|
714
757
|
);
|
|
715
758
|
assert.match(app, /function renderCodexUsage\(\)/, "frontend should render Codex usage buckets in the side panel");
|
|
716
|
-
assert.match(app, /function renderSubagents\(\)[\s\S]*subagentTabsWithRunningAgents\(\)[\s\S]*renderSubagentTabGroup\(tab\)/, "frontend should group running subagents by terminal and session");
|
|
717
|
-
assert.match(app, /function
|
|
759
|
+
assert.match(app, /function renderSubagents\(\)[\s\S]*subagentTabsWithRunningAgents\(\)[\s\S]*totalGates[\s\S]*renderSubagentTabGroup\(tab\)/, "frontend should group running subagents and retained retry gates by terminal and session");
|
|
760
|
+
assert.match(app, /function renderSubagentGateAttempt\(attempt\)[\s\S]*failureKind[\s\S]*function renderSubagentGate\(gate\)[\s\S]*qualifyingSuccesses/, "frontend should render failure-classified attempts and gate quorum");
|
|
761
|
+
assert.match(helper, /async function enrichAsyncSubagentAgent\(run, agent, statusByDir\)[\s\S]*status\.json[\s\S]*agent\.model = subagentModel\(step\.model\)[\s\S]*agent\.thinking = subagentThinking\(step\.thinking\)/, "WebUI helper should enrich async children from effective lifecycle model and reasoning metadata");
|
|
762
|
+
assert.match(helper, /SUBAGENT_GATE_UPDATE_EVENT[\s\S]*function publicSubagentGates\(\)[\s\S]*failureKind[\s\S]*gates = publicSubagentGates\(\)/, "WebUI helper should publish bounded retry-gate lifecycle data");
|
|
763
|
+
assert.match(extension, /registerSubagentGate\(pi\)[\s\S]*session_shutdown[\s\S]*subagentGate\.dispose\(\)/, "the WebUI package extension should own the retry-gate tool lifecycle without another extension package");
|
|
764
|
+
assert.match(server, /function normalizeWebuiSubagentPayload\(value\)[\s\S]*model: normalizeWebuiSubagentText\(rawAgent\.model, 240\)[\s\S]*thinking: normalizeWebuiSubagentText\(rawAgent\.thinking, 40\)/, "server should bound model and reasoning metadata in the cross-tab overview");
|
|
765
|
+
assert.match(server, /WEBUI_SUBAGENT_GATE_LIMIT[\s\S]*rawGate\.attempts[\s\S]*failureKind: normalizeWebuiSubagentText\(rawAttempt\.failureKind, 80\)[\s\S]*totalGates/, "server should bound retry gates and expose their cross-tab total");
|
|
766
|
+
assert.match(server, /function normalizeWebuiSubagentOutput\(value, selection\)[\s\S]*model: normalizeWebuiSubagentText\(rawAgent\.model, 240\)[\s\S]*thinking: normalizeWebuiSubagentText\(rawAgent\.thinking, 40\)/, "server should preserve model and reasoning metadata in selected child output");
|
|
767
|
+
assert.match(app, /function subagentExecutionFacts\(agent = \{\}\)[\s\S]*model \$\{model \|\| "unknown"\}[\s\S]*reasoning \$\{thinking \|\| "unknown"\}/, "subagent metadata should use one honest model/reasoning formatter with unknown fallbacks");
|
|
768
|
+
assert.match(app, /function renderSubagentAgent\(tab, run, agent\)[\s\S]*\.\.\.subagentExecutionFacts\(agent\)/, "Subagents side-panel rows should show model and reasoning effort");
|
|
769
|
+
assert.match(app, /function subagentOverlayStateFacts\(data = subagentOverlayData\)[\s\S]*\.\.\.subagentExecutionFacts\(agent\)/, "subagent overlays should show model and reasoning effort");
|
|
770
|
+
assert.match(app, /function renderSubagentTerminalView\(\)[\s\S]*\.\.\.subagentExecutionFacts\(agent\)/, "dedicated subagent terminal views should show model and reasoning effort");
|
|
771
|
+
assert.match(app, /SUBAGENT_OPEN_MODE_STORAGE_KEY = "pi-webui-subagent-open-mode"[\s\S]*function normalizeSubagentOpenMode\(value\)[\s\S]*function restoreSubagentOpenModeSetting\(\)/, "subagent opening mode should default safely and persist in this browser");
|
|
772
|
+
assert.match(app, /function openSubagentOutput\(tab, run, agent\) \{[\s\S]*subagentOpenMode === "tab" \? openSubagentTerminal\(tab, run, agent\) : openSubagentOverlay\(tab, run, agent\)/, "clicking an agent should dispatch to the selected overlay or terminal-tab view");
|
|
773
|
+
assert.match(app, /function openSubagentOverlay\(tab, run, agent\)[\s\S]*activeSubagentTerminalId[\s\S]*deactivateSubagentTerminalView\(\{ render: false \}\)[\s\S]*activeTabId !== tab\.tabId[\s\S]*await switchTab\(tab\.tabId\)[\s\S]*renderWidgets\(\)/, "opening an overlay should first leave any virtual child tab, then switch to its owning terminal before rendering the widget");
|
|
718
774
|
assert.match(app, /function renderWidgets\(\)[\s\S]*renderAppRunnerWidget\(\)[\s\S]*renderSubagentOverlayWidgetSafely\(\)/, "subagent output should render in the shared non-blocking top widget area after App Runner");
|
|
719
775
|
assert.doesNotMatch(app, /subagentOverlayDialog\.showModal|elements\.subagentOverlayDialog/, "subagent output should not open or depend on a modal dialog");
|
|
720
776
|
assert.match(app, /api\(`\/api\/subagents\/output\?\$\{query\}`, \{ scoped: false \}\)/, "subagent overlay should fetch selected live output from the owning tab");
|
|
777
|
+
assert.match(app, /function subagentRunIndicatorActivity\(agent = \{\}\)[\s\S]*currentToolArgs[\s\S]*activityState[\s\S]*function appendSubagentRunIndicator\(parent,[\s\S]*run-indicator-pulse[\s\S]*Agent is running:[\s\S]*subagent-run-indicator-elapsed[\s\S]*updateSubagentRunIndicatorElapsed\(parent, run\)/, "running child output should show the main-style pulse, current tool or activity, and separately refreshed elapsed runtime");
|
|
778
|
+
assert.match(app, /const facts = \[[\s\S]*view\.finished \? "finished" : running \? "running"/, "retained completed child views should not keep contradictory running header metadata");
|
|
779
|
+
assert.match(app, /function renderSubagentTerminalView\(\)[\s\S]*if \(running\) appendSubagentRunIndicator\(elements\.subagentTerminalTranscript, \{ agent, run: view\.run \}\)/, "the dedicated child tab should append a live run indicator whenever the selected child is running");
|
|
780
|
+
const subagentTerminalSignatureSource = appFunctionSource("subagentTerminalViewMeaningfulSignature", "updateSubagentTerminalRefreshState");
|
|
781
|
+
const subagentTerminalRefreshSource = appFunctionSource("refreshSubagentTerminalView", "deactivateSubagentTerminalView");
|
|
782
|
+
assert.ok(subagentTerminalRefreshSource.includes("tab: view.parentTabId, run: view.runId, agent: view.agentId"), "subagent terminal refresh should stay scoped to the child and its owning parent terminal");
|
|
783
|
+
assert.ok(subagentTerminalRefreshSource.includes("view.finished = true"), "an open child tab should retain its last snapshot after the run is no longer tracked");
|
|
784
|
+
assert.ok(subagentTerminalRefreshSource.includes("previousSignature !== subagentTerminalViewMeaningfulSignature(view)"), "automatic child polling should compare meaningful snapshots before rebuilding the transcript");
|
|
785
|
+
let unchangedSubagentRenderCount = 0;
|
|
786
|
+
let unchangedSubagentTabRenderCount = 0;
|
|
787
|
+
let unchangedSubagentElapsedUpdateCount = 0;
|
|
788
|
+
const unchangedSubagentView = {
|
|
789
|
+
id: "child-view",
|
|
790
|
+
parentTabId: "parent-tab",
|
|
791
|
+
runId: "run-1",
|
|
792
|
+
agentId: "agent-1",
|
|
793
|
+
data: { updatedAt: 1, agent: { id: "agent-1", status: "running", currentTool: "read" } },
|
|
794
|
+
error: "",
|
|
795
|
+
finished: false,
|
|
796
|
+
loading: false,
|
|
797
|
+
requestSerial: 0,
|
|
798
|
+
};
|
|
799
|
+
await vm.runInNewContext(`${subagentTerminalSignatureSource}\nasync ${subagentTerminalRefreshSource}\nrefreshSubagentTerminalView("child-view");`, {
|
|
800
|
+
activeSubagentTerminalId: "child-view",
|
|
801
|
+
elements: { subagentTerminalTranscript: {} },
|
|
802
|
+
subagentTerminalViews: new Map([["child-view", unchangedSubagentView]]),
|
|
803
|
+
URLSearchParams,
|
|
804
|
+
api: async () => ({ data: { updatedAt: 2, agent: { id: "agent-1", status: "running", currentTool: "read" } } }),
|
|
805
|
+
renderSubagentTerminalView() { unchangedSubagentRenderCount += 1; },
|
|
806
|
+
renderTabs() { unchangedSubagentTabRenderCount += 1; },
|
|
807
|
+
updateSubagentRunIndicatorElapsed() { unchangedSubagentElapsedUpdateCount += 1; },
|
|
808
|
+
updateSubagentTerminalRefreshState() { throw new Error("background polls must not announce routine loading state"); },
|
|
809
|
+
});
|
|
810
|
+
assert.equal(unchangedSubagentRenderCount, 0, "an unchanged background poll should preserve the existing transcript DOM");
|
|
811
|
+
assert.equal(unchangedSubagentTabRenderCount, 0, "an unchanged background poll should not rebuild terminal tabs");
|
|
812
|
+
assert.equal(unchangedSubagentElapsedUpdateCount, 1, "an unchanged background poll should refresh only the existing visual elapsed-time node");
|
|
813
|
+
assert.equal(unchangedSubagentView.loading, false, "an unchanged background poll should still clear its internal loading flag");
|
|
814
|
+
const subagentTerminalCloseStart = app.indexOf("function closeSubagentTerminalTab(");
|
|
815
|
+
const subagentTerminalCloseEnd = app.indexOf("\nasync function copySubagentTerminalOutput(", subagentTerminalCloseStart);
|
|
816
|
+
assert.ok(subagentTerminalCloseStart >= 0 && subagentTerminalCloseEnd > subagentTerminalCloseStart, "closeSubagentTerminalTab should remain a standalone frontend helper");
|
|
817
|
+
const subagentTerminalCloseSource = app.slice(subagentTerminalCloseStart, subagentTerminalCloseEnd);
|
|
818
|
+
assert.ok(subagentTerminalCloseSource.includes("subagentTerminalViews.delete(viewId)"), "closing a subagent tab should remove only its client-side view record");
|
|
819
|
+
assert.doesNotMatch(subagentTerminalCloseSource, /\bapi\(|closeTerminalTabs\(|closeSubagentOverlay\(/, "closing a subagent tab must not call backend terminal or subagent lifecycle APIs");
|
|
820
|
+
assert.match(app, /function renderSubagentTerminalTab\(view\)[\s\S]*terminal-tab-subagent[\s\S]*subagent: true[\s\S]*closeSubagentTerminalTab\(view\.id\)/, "virtual tabs should be marked as subagents and have a view-only close action");
|
|
821
|
+
assert.match(app, /function subagentTerminalViewId\(tab, run, agent\)[\s\S]*JSON\.stringify\(\[tab\?\.tabId[\s\S]*run\?\.id[\s\S]*agent\?\.id/, "virtual child tabs should be uniquely keyed by parent terminal, run, and child agent");
|
|
721
822
|
assert.match(app, /SUBAGENT_OVERLAY_REFRESH_MS = 1000/, "subagent overlay should poll selected live output at a fast cadence");
|
|
722
823
|
assert.match(app, /function createMessageBubble\(message,[\s\S]*renderContent\(body, message\.content, \{ markdown: message\.role === "assistant" \}\)[\s\S]*function appendMessage\(message, options = \{\}\)[\s\S]*createMessageBubble\(message, options\)/, "main transcript output should use the reusable message bubble renderer");
|
|
723
824
|
const subagentTranscriptMessagesSource = appFunctionSource("subagentOverlayTranscriptMessages", "subagentOverlayToolArguments");
|
|
@@ -733,12 +834,13 @@ const subagentAppendSource = appFunctionSource("appendSubagentOverlayTranscript"
|
|
|
733
834
|
assert.ok(subagentAppendSource.includes("subagentOverlayTranscriptDisplayMessages(messages)"), "subagent bubbles should use the paired structured display sequence");
|
|
734
835
|
assert.ok(subagentAppendSource.includes("createMessageBubble(displayMessage, { transient: true })"), "subagent bubbles should reuse the main message renderer");
|
|
735
836
|
const thinkingVisibilitySource = appFunctionSource("setThinkingOutputVisible", "applyToolOutputExpansionToDom");
|
|
736
|
-
assert.ok(thinkingVisibilitySource.includes("if (subagentOverlaySelection?.tabId === activeTabId) renderWidgets();"), "changing thinking visibility should rerender an open subagent transcript, including finished agents");
|
|
837
|
+
assert.ok(thinkingVisibilitySource.includes("if (subagentOverlaySelection?.tabId === activeTabId) renderWidgets();"), "changing thinking visibility should rerender an open subagent overlay transcript, including finished agents");
|
|
838
|
+
assert.ok(thinkingVisibilitySource.includes("if (activeSubagentTerminalId) renderSubagentTerminalView();"), "changing thinking visibility should rerender an open subagent terminal transcript, including finished agents");
|
|
737
839
|
const subagentCopySource = appFunctionSource("subagentOverlayTranscriptOutputLines", "subagentOverlayOutputLines");
|
|
738
840
|
assert.ok(subagentCopySource.includes("messageCopyText(message)"), "global subagent copy should derive from the same structured bubble messages");
|
|
739
841
|
const subagentOutputSource = appFunctionSource("subagentOverlayOutputLines", "subagentOverlayOutputText");
|
|
740
842
|
assert.ok(subagentOutputSource.includes("if (transcriptMessages.length) return subagentOverlayTranscriptOutputLines(data);"), "global subagent copy should prefer structured transcript content over flattened recent output");
|
|
741
|
-
const subagentEmptySource = appFunctionSource("subagentOverlayEmptyTranscriptText", "
|
|
843
|
+
const subagentEmptySource = appFunctionSource("subagentOverlayEmptyTranscriptText", "appendSubagentRunIndicator");
|
|
742
844
|
assert.ok(subagentEmptySource.includes("No visible output was captured."), "hidden or non-renderable structured output should have explicit fallback text");
|
|
743
845
|
const subagentRenderErrorSource = appFunctionSource("renderSubagentOverlayErrorWidget", "renderSubagentOverlayWidgetSafely");
|
|
744
846
|
assert.ok(subagentRenderErrorSource.includes("Subagent output unavailable"), "a failed subagent renderer should show a minimal recoverable widget");
|
|
@@ -755,7 +857,7 @@ assert.equal(rendererContainmentResult, rendererFallbackSentinel, "subagent rend
|
|
|
755
857
|
const subagentWidgetSource = appFunctionSource("renderSubagentOverlayWidget", "scheduleSubagentOverlayRefresh");
|
|
756
858
|
assert.ok(subagentWidgetSource.includes("const visibleFallbackText = !hasStructuredTranscript ? fallbackText : emptyTranscriptFallback;"), "the widget should render a fallback instead of leaving structured-but-hidden output blank");
|
|
757
859
|
assert.ok(subagentWidgetSource.includes("if (visibleFallbackText) {"), "the widget should append the nonblank fallback bubble");
|
|
758
|
-
assert.ok(subagentWidgetSource.includes("if (running
|
|
860
|
+
assert.ok(subagentWidgetSource.includes("if (running) appendSubagentRunIndicator(output, { agent, run: selection.run });"), "running subagent widgets should append the shared live activity indicator");
|
|
759
861
|
assert.match(app, /api\("\/api\/subagents", \{ scoped: false \}\)/, "frontend should refresh the cross-tab subagent overview");
|
|
760
862
|
assert.match(app, /SUBAGENTS_ACTIVE_REFRESH_MS = 1500/, "running subagents should receive a fast live refresh cadence");
|
|
761
863
|
assert.match(server, /url\.pathname === "\/api\/subagents" && req\.method === "GET"[\s\S]*webuiSubagentsData\(\)/, "server should expose a cross-tab running-subagent endpoint");
|
|
@@ -814,8 +916,11 @@ assert.match(app, /function renderFooterBranchCreateForm\(state = footerBranchPi
|
|
|
814
916
|
assert.match(app, /let footerBranchCreateDraft = \{ type: "", name: "" \}/, "new branch creation should not default the editable type prefix to feat");
|
|
815
917
|
assert.match(app, /function footerBranchCreateType\(value = footerBranchCreateDraft\.type\) \{\n\s+return slugifyGitBranchPart\(value\);\n\}/, "branch type suggestions should not restrict or default custom user-entered prefixes");
|
|
816
918
|
assert.match(app, /const slash = make\("span", "footer-branch-create-slash", "\/"\)/, "branch creation should visibly separate the prefix and user input with a slash");
|
|
817
|
-
assert.match(app, /function gitWorktreeCreateCommandDisplay\(branch, state = footerBranchPickerState\)[\s\S]*git worktree add -b[\s\S]*preview\.textContent = gitWorktreeCreateCommandDisplay\(branchName \|\| footerBranchCreatePreviewName\(\), state\)/, "branch worktree creation should
|
|
818
|
-
assert.match(app, /function footerBranchCreateTooltip\(branchName = footerBranchCreateName\(\), state = footerBranchPickerState\)[\s\S]*A branch worktree is a separate checkout for parallel changes\.[\s\S]*does not switch this tab's branch, commit, push, or delete anything[\s\S]*ignored dependencies such as node_modules or \.venv are not copied/, "create worktree button should
|
|
919
|
+
assert.match(app, /function gitWorktreeCreateCommandDisplay\(branch, state = footerBranchPickerState, baseRef = "origin\/main"\)[\s\S]*git worktree add -b[\s\S]*preview\.textContent = gitWorktreeCreateCommandDisplay\(branchName \|\| footerBranchCreatePreviewName\(\), state\)/, "branch worktree creation should preview the default origin/main start point");
|
|
920
|
+
assert.match(app, /function footerBranchCreateTooltip\(branchName = footerBranchCreateName\(\), state = footerBranchPickerState\)[\s\S]*A branch worktree is a separate checkout for parallel changes\.[\s\S]*origin\/main \(default\)[\s\S]*does not switch this tab's branch, commit, push, or delete anything[\s\S]*ignored dependencies such as node_modules or \.venv are not copied/, "create worktree button should explain the base choice and worktree behavior");
|
|
921
|
+
assert.match(html, /id="gitWorktreeBaseDialog"[\s\S]*id="gitWorktreeBaseOriginMain"[^>]*value="origin\/main" checked[\s\S]*id="gitWorktreeBaseCurrentHead"[^>]*value="HEAD"[\s\S]*id="gitWorktreeBaseCreateButton"/, "worktree creation should present an origin/main-default base picker with a current-HEAD alternative");
|
|
922
|
+
assert.match(app, /function chooseGitWorktreeBase\(branch\)[\s\S]*gitWorktreeBaseOriginMain\.checked = true[\s\S]*gitWorktreeBaseCurrentHead\.checked = false/, "the worktree base picker should reset to origin/main for every creation");
|
|
923
|
+
assert.match(css, /\.git-worktree-base-option:has\(input:checked\)[\s\S]*border-color:/, "the selected worktree base should be visibly highlighted");
|
|
819
924
|
assert.match(app, /submitButton\.dataset\.tooltip = footerBranchCreateTooltip\(branchName\);[\s\S]*submitButton\.removeAttribute\("title"\)/, "create branch button should use the styled tooltip instead of a native title tooltip");
|
|
820
925
|
assert.match(css, /\.footer-branch-create-submit\[data-tooltip\]::after \{[\s\S]*?content:\s*attr\(data-tooltip\);[\s\S]*?white-space:\s*pre-wrap;[\s\S]*?overflow-wrap:\s*anywhere;/, "create branch button tooltip should be styled and support detailed multiline copy");
|
|
821
926
|
assert.match(app, /submitButton\.disabled = false;[\s\S]*submitButton\.classList\.toggle\("footer-branch-create-submit-disabled", submitDisabled\);[\s\S]*submitButton\.setAttribute\("aria-disabled", submitDisabled \? "true" : "false"\)/, "branch creation should use aria-disabled styling so the tooltip is not dimmed by disabled button opacity");
|
|
@@ -827,7 +932,7 @@ assert.match(css, /\.footer-branch-option-row \{[\s\S]*?grid-template-columns:\s
|
|
|
827
932
|
assert.match(css, /\.footer-branch-advanced-action:disabled \{[\s\S]*?cursor:\s*not-allowed/, "advanced branch switch action should visibly disable occupied branches");
|
|
828
933
|
assert.match(css, /\.footer-worktree \.footer-meta-value,[\s\S]*?\.footer-tui-worktree \{[\s\S]*?color:\s*var\(--ctp-green\)/, "worktree footer chips should have distinct green styling");
|
|
829
934
|
assert.match(css, /\.workspace-dashboard-action\.worktree \{[\s\S]*?color:\s*var\(--ctp-green\)/, "workspace dashboard should style the branch worktree action distinctly");
|
|
830
|
-
assert.match(app, /async function createFooterGitBranchWorktree\(branch = footerBranchCreateName\(\)[\s\S]*api\("\/api\/git-worktrees", \{ method: "POST", body: \{ branchName, sessionMode: "fork-current", openTab: true \}/, "branch
|
|
935
|
+
assert.match(app, /async function createFooterGitBranchWorktree\(branch = footerBranchCreateName\(\)[\s\S]*chooseGitWorktreeBase\(branchName\)[\s\S]*api\("\/api\/git-worktrees", \{ method: "POST", body: \{ branchName, baseRef, sessionMode: "fork-current", openTab: true \}/, "new footer branch worktrees should ask for and submit the selected base ref");
|
|
831
936
|
assert.match(app, /async function openFooterGitWorktree\(path,[\s\S]*api\("\/api\/git-worktrees\/open", \{ method: "POST", body: \{ path: worktreePath, sessionMode: "fork-current", openTab: true \}/, "existing worktree actions should call the worktree open endpoint");
|
|
832
937
|
assert.match(app, /elements\.newTabWorktreeButton\?\.addEventListener\("click", \(\) => openBranchWorktreePicker\(\)\)/, "new-tab menu branch worktree item should open the picker");
|
|
833
938
|
assert.match(app, /\{ kind: "Git", label: "Branch worktree"[\s\S]*openBranchWorktreePicker\(\)/, "command palette should include branch worktree actions");
|
|
@@ -989,7 +1094,7 @@ assert.match(css, /\.git-workflow-message-input-row \{[\s\S]*flex:\s*1 1 100%/,
|
|
|
989
1094
|
assert.match(css, /\.git-workflow-actions button\[data-tooltip\]::after \{[\s\S]*content:\s*attr\(data-tooltip\)[\s\S]*white-space:\s*pre-line/, "guided git workflow action tooltips should render multiline step lists");
|
|
990
1095
|
assert.match(app, /function gitBranchNamePromptMessage\(\)[\s\S]*hasAvailableCommand\("git-branch-name"\)[\s\S]*return "\/git-branch-name"/, "guided git workflow should ask the agent to generate PR branch names when the prompt is available");
|
|
991
1096
|
assert.match(app, /async function loadGitWorkflowBranchName\([\s\S]*gitWorkflowRequest\("\/api\/git-workflow\/branch-name"/, "guided git workflow should load generated agent branch names before branch creation");
|
|
992
|
-
assert.match(app, /async function createGitPrBranchWithSuggestion\([\s\S]*prompt\("New PR branch worktree name[\s\S]*assertGuidedGitStagedContentBinding\(tabId, "PR worktree creation"\)[\s\S]*gitWorkflowRequest\("\/api\/git-workflow\/branch", \{ body: \{ branch, sessionMode: "fork-current", openTab: true, [\s\S]*expectedStagedContentHash/, "guided git
|
|
1097
|
+
assert.match(app, /async function createGitPrBranchWithSuggestion\([\s\S]*prompt\("New PR branch worktree name[\s\S]*chooseGitWorktreeBase\(branch\)[\s\S]*assertGuidedGitStagedContentBinding\(tabId, "PR worktree creation"\)[\s\S]*gitWorkflowRequest\("\/api\/git-workflow\/branch", \{ body: \{ branch, baseRef, sessionMode: "fork-current", openTab: true, [\s\S]*expectedStagedContentHash/, "guided git worktrees should ask for a base ref before verifying and carrying staged content");
|
|
993
1098
|
assert.match(app, /function syncGitWorkflowWorktreeTabs\(result\)[\s\S]*Array\.isArray\(result\?\.tabs\)[\s\S]*applyTabMetadata\(result\.tab\)/, "guided git workflow should merge worktree tab metadata returned by the branch endpoint");
|
|
994
1099
|
assert.match(app, /const targetTabId = result\.tab\?\.id[\s\S]*setGitWorkflow\(nextState, \{ tabId: targetTabId \}\)[\s\S]*switchTab\(targetTabId\)/, "guided git workflow should transfer PR state to the opened worktree tab");
|
|
995
1100
|
assert.match(app, /addGitWorkflowAction\("Push and Create PR", \(\) => pushAndCreatePrGitWorkflow\(\), "primary", false\)/, "guided git workflow should replace push with Push and Create PR in PR mode");
|
|
@@ -1340,7 +1445,7 @@ assert.match(css, /@media \(max-width: 720px\), \(max-device-width: 720px\), \(p
|
|
|
1340
1445
|
assert.match(css, /@media \(max-width: 720px\), \(max-device-width: 720px\), \(pointer: coarse\) and \(hover: none\) \{[\s\S]*?\.terminal-tab-group-menu \{[\s\S]*?grid-column:\s*1 \/ -1;[\s\S]*?margin:\s*0\.34rem 0 0;/, "mobile terminal tab group menus should not add horizontal margins that overflow and distort the tab card");
|
|
1341
1446
|
assert.match(app, /let openTerminalTabGroupKey = null/, "frontend should track the open terminal tab group across tab bar rerenders");
|
|
1342
1447
|
assert.match(app, /function updateTerminalTabGroupOpenState\(\)/, "frontend should be able to reapply open terminal tab group state after rerenders");
|
|
1343
|
-
assert.match(app, /classList\.toggle\("terminal-tabs-dense",
|
|
1448
|
+
assert.match(app, /const totalTabCount = tabs\.length \+ subagentTerminalViews\.size;[\s\S]*classList\.toggle\("terminal-tabs-dense", totalTabCount >= 10\)/, "frontend should include virtual subagent tabs when enabling dense tab layout");
|
|
1344
1449
|
assert.match(app, /appendTerminalTabContent\(button, \{ title: activeTitle,[\s\S]*?count: groupTabs\.length,[^}]*\}\)/, "group buttons should show the active terminal name instead of only the cwd label");
|
|
1345
1450
|
assert.match(app, /wrapper\.addEventListener\("pointerenter", \(\) => setOpenTerminalTabGroup\(group\.key\)\)/, "terminal tab groups should mark themselves open while hovered");
|
|
1346
1451
|
assert.match(app, /if \(openTerminalTabGroupKey\) \{\n\s+scheduleRefreshTabs\(600\);/, "tab polling should defer full tab refreshes while a group menu is open");
|
|
@@ -1354,6 +1459,8 @@ assert.match(app, /function closeAllTerminalTabs\(\)[\s\S]*?closeTerminalTabs\(t
|
|
|
1354
1459
|
assert.match(app, /WARNING: \$\{activeAgentTabs\.length\}[\s\S]*?still running or waiting for input/, "tab close confirmations should warn when agents are still running");
|
|
1355
1460
|
assert.match(app, /elements\.closeAllTabsButton\.addEventListener\("click", \(\) => closeAllTerminalTabs\(\)\)/, "close-all tabs button should be wired in JS");
|
|
1356
1461
|
assert.match(app, /const groups = tabCwdGroups\(\);[\s\S]*?for \(const group of groups\) \{\n\s+if \(shouldRenderTerminalTabGroup\(group, groups\.length\)\)[\s\S]*?renderTerminalTabGroup\(group, groups\.length\)[\s\S]*?for \(const tab of group\.tabs\) elements\.tabBar\.append\(renderTerminalTab\(tab\)\);/, "terminal tabs should render groups with group count and ungrouped tabs when grouping is skipped");
|
|
1462
|
+
assert.match(app, /for \(const view of \[\.\.\.subagentTerminalViews\.values\(\)\][\s\S]*renderSubagentTerminalTab\(view\)/, "open subagent views should render as first-class virtual terminal tabs");
|
|
1463
|
+
assert.match(readme, /Tracked subagent output[\s\S]*dedicated \*\*Subagent\*\* terminal tab[\s\S]*view-only[\s\S]*close without stopping or interrupting/, "README should document the selectable view-only child terminal behavior");
|
|
1357
1464
|
assert.match(app, /let tabSeenCompletionSerials = new Map\(\)/, "frontend should track which tab completions have been seen");
|
|
1358
1465
|
assert.match(app, /let activeTabGeneration = 0/, "frontend should version active-tab UI state to reject stale async work");
|
|
1359
1466
|
assert.match(app, /function isCurrentTabContext\(context\)/, "frontend should identify stale active-tab refresh contexts");
|