@firstpick/pi-package-webui 0.9.2 → 0.9.3
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 +13 -7
- package/bin/pi-webui.mjs +256 -39
- package/index.ts +266 -1
- package/lib/git-workflow-preferences.mjs +8 -25
- package/lib/intercom-conversations.mjs +491 -0
- package/lib/intercom-transcript-filter.mjs +99 -0
- package/lib/resource-selection.mjs +140 -0
- package/package.json +2 -2
- package/public/app.js +1025 -115
- package/public/index.html +31 -6
- package/public/service-worker.js +2 -1
- package/public/stream-output-controller.mjs +15 -0
- package/public/styles.css +394 -0
- package/public/syntax-highlight.mjs +622 -0
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/interaction-continuity.spec.mjs +34 -0
- package/tests/browser/intercom-conversation-viewer.spec.mjs +355 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +61 -0
- package/tests/browser/resource-profiles.spec.mjs +200 -0
- package/tests/browser/subagent-observability.spec.mjs +29 -0
- package/tests/codex-fast-mode-static.test.mjs +7 -6
- package/tests/common-options-submenus-interaction-static.test.mjs +2 -0
- package/tests/common-options-submenus-markup-static.test.mjs +1 -0
- package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
- package/tests/composer-skill-tag-layout.test.mjs +32 -2
- package/tests/control-deck-component-updates-static.test.mjs +4 -0
- package/tests/controls-layout-static.test.mjs +3 -3
- package/tests/fast-mode-client-static.test.mjs +2 -2
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/feature-system-prompt-optional-feature-static.test.mjs +5 -5
- package/tests/file-viewer-image-static.test.mjs +69 -0
- package/tests/fixtures/fake-pi.mjs +105 -6
- package/tests/foreground-transcript-catch-up-static.test.mjs +1 -1
- package/tests/git-panel-file-preview-static.test.mjs +5 -5
- package/tests/git-panel-live-updates-static.test.mjs +3 -3
- package/tests/git-workflow-preferences.test.mjs +4 -4
- package/tests/http-endpoints-harness.test.mjs +124 -2
- package/tests/intercom-conversation-viewer-static.test.mjs +105 -0
- package/tests/intercom-conversations-http.test.mjs +252 -0
- package/tests/intercom-conversations.test.mjs +374 -0
- package/tests/intercom-main-transcript-suppression-static.test.mjs +52 -0
- package/tests/intercom-tag-layout-static.test.mjs +46 -0
- package/tests/intercom-transcript-filter.test.mjs +98 -0
- package/tests/main-output-loading-static.test.mjs +59 -0
- package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
- package/tests/mobile-compact-layout.test.mjs +2 -3
- package/tests/mobile-continuity-tablet-static.test.mjs +6 -6
- package/tests/mobile-foundation-static.test.mjs +3 -3
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +63 -39
- package/tests/native-parity.test.mjs +8 -7
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/optional-feature-migration-frontend.test.mjs +5 -5
- package/tests/optional-feature-resource-setup-static.test.mjs +29 -0
- package/tests/persistent-ui-layout-static.test.mjs +3 -3
- package/tests/questionnaire-dialog.test.mjs +3 -3
- package/tests/remote-auth-settings-harness.test.mjs +1 -1
- package/tests/resource-defaults-helper.test.mjs +60 -6
- package/tests/resource-selection.test.mjs +114 -0
- package/tests/resource-tui-extension.test.mjs +23 -0
- package/tests/session-sampling-ui-static.test.mjs +3 -3
- package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
- package/tests/stream-output-controller.test.mjs +8 -0
- package/tests/stream-output-isolation-static.test.mjs +2 -2
- package/tests/streaming-ui-coupling.test.mjs +5 -0
- package/tests/subagent-gate-visibility.test.mjs +1 -1
- package/tests/subagent-launch-slots.test.mjs +1 -1
- package/tests/subagent-observability-static.test.mjs +3 -3
- package/tests/subagent-reliability-integration.test.mjs +23 -1
- package/tests/subagent-workflow-section-static.test.mjs +67 -0
- package/tests/subagents-helper.test.mjs +204 -1
- package/tests/syntax-highlight.test.mjs +235 -0
- package/tests/syntax-highlighting-static.test.mjs +84 -0
- package/tests/theme-customizer-static.test.mjs +5 -5
- package/tests/thinking-format-parser.test.mjs +64 -0
- package/tests/webui-settings-locking.test.mjs +1 -1
- package/webui-rpc-helper.mjs +291 -69
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import {
|
|
6
|
+
branchResourceDirective,
|
|
7
|
+
normalizeResourceDefaults,
|
|
8
|
+
preserveUnavailableResourceNames,
|
|
9
|
+
resolveResourceSelection,
|
|
10
|
+
setExactModelProfile,
|
|
11
|
+
} from "../lib/resource-selection.mjs";
|
|
12
|
+
import { normalizeWebuiSettings, readWebuiSettings, writeWebuiSettings } from "../lib/git-workflow-preferences.mjs";
|
|
13
|
+
|
|
14
|
+
const normalized = normalizeWebuiSettings({
|
|
15
|
+
version: 8,
|
|
16
|
+
retained: { ok: true },
|
|
17
|
+
resourceDefaults: {
|
|
18
|
+
tools: { enabledTools: ["read", "read", ""] },
|
|
19
|
+
skills: { enabledSkills: null },
|
|
20
|
+
modelProfiles: [
|
|
21
|
+
{ provider: "p", modelId: "m/one", tools: { enabledTools: ["bash"] }, skills: { enabledSkills: null } },
|
|
22
|
+
{ provider: "p", modelId: "m/one", tools: { enabledTools: [] }, skills: { enabledSkills: ["skill-a"] } },
|
|
23
|
+
{ provider: "", modelId: "bad", tools: { enabledTools: ["write"] } },
|
|
24
|
+
{ provider: "p", modelId: "empty", tools: { enabledTools: null }, skills: { enabledSkills: null } },
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
assert.equal(normalized.version, 8);
|
|
29
|
+
assert.deepEqual(normalized.retained, { ok: true });
|
|
30
|
+
assert.deepEqual(normalized.resourceDefaults.tools.enabledTools, ["read"]);
|
|
31
|
+
assert.equal(normalized.resourceDefaults.modelProfiles.length, 1);
|
|
32
|
+
assert.deepEqual(resolveResourceSelection(normalized.resourceDefaults, "tools", "p", "m/one", ["runtime"]), { names: [], source: "model" });
|
|
33
|
+
assert.deepEqual(resolveResourceSelection(normalized.resourceDefaults, "skills", "p", "m/one", null), { names: ["skill-a"], source: "model" });
|
|
34
|
+
assert.deepEqual(resolveResourceSelection(normalized.resourceDefaults, "skills", "p", "other", null), { names: null, source: "runtime" });
|
|
35
|
+
|
|
36
|
+
const legacyWithProfiles = normalizeWebuiSettings({
|
|
37
|
+
version: 7,
|
|
38
|
+
resourceDefaults: {
|
|
39
|
+
tools: { enabledTools: ["global"] },
|
|
40
|
+
modelProfiles: [{ provider: "p", modelId: "legacy", tools: { enabledTools: ["bash"] } }],
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
assert.deepEqual(legacyWithProfiles.resourceDefaults.modelProfiles, [], "version-7 settings must ignore model profiles");
|
|
44
|
+
assert.deepEqual(resolveResourceSelection(legacyWithProfiles.resourceDefaults, "tools", "p", "legacy", ["runtime"]), { names: ["global"], source: "global" });
|
|
45
|
+
|
|
46
|
+
const future = normalizeWebuiSettings({
|
|
47
|
+
version: 9,
|
|
48
|
+
resourceDefaults: {
|
|
49
|
+
futurePolicy: { keep: true },
|
|
50
|
+
tools: { enabledTools: ["read"], futureToolField: "keep" },
|
|
51
|
+
skills: { enabledSkills: null, futureSkillField: 3 },
|
|
52
|
+
modelProfiles: [{
|
|
53
|
+
provider: "p",
|
|
54
|
+
modelId: "future",
|
|
55
|
+
futureProfileField: ["keep"],
|
|
56
|
+
tools: { enabledTools: ["bash"], futureSelectionField: true },
|
|
57
|
+
skills: { enabledSkills: null },
|
|
58
|
+
}],
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
assert.deepEqual(future.resourceDefaults.futurePolicy, { keep: true });
|
|
62
|
+
assert.equal(future.resourceDefaults.tools.futureToolField, "keep");
|
|
63
|
+
assert.equal(future.resourceDefaults.skills.futureSkillField, 3);
|
|
64
|
+
assert.deepEqual(future.resourceDefaults.modelProfiles[0].futureProfileField, ["keep"]);
|
|
65
|
+
assert.equal(future.resourceDefaults.modelProfiles[0].tools.futureSelectionField, true);
|
|
66
|
+
|
|
67
|
+
const defaults = normalizeResourceDefaults({
|
|
68
|
+
tools: { enabledTools: ["global"] },
|
|
69
|
+
skills: { enabledSkills: ["global-skill"] },
|
|
70
|
+
modelProfiles: [],
|
|
71
|
+
});
|
|
72
|
+
let profiles = setExactModelProfile(defaults, "provider", "model/id", "tools", ["read"]);
|
|
73
|
+
profiles = setExactModelProfile({ ...defaults, modelProfiles: profiles }, "provider", "model/id", "skills", []);
|
|
74
|
+
assert.deepEqual(profiles[0], {
|
|
75
|
+
provider: "provider",
|
|
76
|
+
modelId: "model/id",
|
|
77
|
+
tools: { enabledTools: ["read"] },
|
|
78
|
+
skills: { enabledSkills: [] },
|
|
79
|
+
});
|
|
80
|
+
profiles = setExactModelProfile({ ...defaults, modelProfiles: profiles }, "provider", "model/id", "tools", null);
|
|
81
|
+
assert.equal(profiles.length, 1, "independent skill selection should retain the profile");
|
|
82
|
+
profiles = setExactModelProfile({ ...defaults, modelProfiles: profiles }, "provider", "model/id", "skills", null);
|
|
83
|
+
assert.deepEqual(profiles, [], "both inherited resources should remove the profile");
|
|
84
|
+
|
|
85
|
+
assert.deepEqual(branchResourceDirective({ enabledTools: ["read"] }, "tools"), { pinned: true, names: ["read"], legacyDisabledNames: null });
|
|
86
|
+
assert.deepEqual(branchResourceDirective({ disabledSkills: ["a"] }, "skills"), { pinned: true, names: null, legacyDisabledNames: ["a"] });
|
|
87
|
+
assert.deepEqual(branchResourceDirective({ version: 2, mode: "inherit" }, "tools"), { pinned: false, names: null, legacyDisabledNames: null });
|
|
88
|
+
assert.deepEqual(preserveUnavailableResourceNames(["read", "missing"], ["read", "bash"], ["bash"]), ["bash", "missing"]);
|
|
89
|
+
|
|
90
|
+
const root = await mkdtemp(path.join(tmpdir(), "pi-resource-settings-"));
|
|
91
|
+
try {
|
|
92
|
+
const file = path.join(root, "settings.json");
|
|
93
|
+
await writeFile(file, `${JSON.stringify({ version: 7, retained: { ok: true }, resourceDefaults: { tools: { enabledTools: ["read"] } } })}\n`);
|
|
94
|
+
const read = await readWebuiSettings(file);
|
|
95
|
+
assert.equal(read.version, 8, "legacy settings should normalize to v8 in memory");
|
|
96
|
+
assert.equal(JSON.parse(await readFile(file, "utf8")).version, 7, "reading should not eagerly rewrite legacy settings");
|
|
97
|
+
await writeWebuiSettings({ resourceDefaults: { skills: { enabledSkills: [] } } }, file);
|
|
98
|
+
const persisted = JSON.parse(await readFile(file, "utf8"));
|
|
99
|
+
assert.equal(persisted.version, 8, "the next normal write should persist v8");
|
|
100
|
+
assert.deepEqual(persisted.retained, { ok: true }, "migration writes should preserve unrelated fields");
|
|
101
|
+
assert.deepEqual(persisted.resourceDefaults.tools.enabledTools, ["read"]);
|
|
102
|
+
|
|
103
|
+
await writeFile(file, `${JSON.stringify({ version: 9, resourceDefaults: future.resourceDefaults })}\n`);
|
|
104
|
+
await writeWebuiSettings({ remoteAuthEnabled: true }, file);
|
|
105
|
+
const futurePersisted = JSON.parse(await readFile(file, "utf8"));
|
|
106
|
+
assert.deepEqual(futurePersisted.resourceDefaults.futurePolicy, { keep: true }, "future resource-default fields must survive writes");
|
|
107
|
+
assert.equal(futurePersisted.resourceDefaults.tools.futureToolField, "keep");
|
|
108
|
+
assert.equal(futurePersisted.resourceDefaults.modelProfiles[0].futureProfileField[0], "keep");
|
|
109
|
+
assert.equal(futurePersisted.resourceDefaults.modelProfiles[0].tools.futureSelectionField, true);
|
|
110
|
+
} finally {
|
|
111
|
+
await rm(root, { recursive: true, force: true });
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
console.log("resource-selection.test.mjs passed");
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
|
|
4
|
+
const source = await readFile(new URL("../index.ts", import.meta.url), "utf8");
|
|
5
|
+
assert.match(source, /pi\.registerCommand\("tools"/);
|
|
6
|
+
assert.match(source, /pi\.registerCommand\("skills"/);
|
|
7
|
+
assert.doesNotMatch(
|
|
8
|
+
source,
|
|
9
|
+
/const runtimeToolBaseline\s*=\s*normalizeResourceNameList\(pi\.getActiveTools\(\)\)/,
|
|
10
|
+
"extension action methods must not run while the extension factory is loading",
|
|
11
|
+
);
|
|
12
|
+
assert.match(source, /const runtimeTools = \(\): string\[\] => runtimeToolBaseline \?\?=/, "the tool baseline should be captured lazily after runtime binding");
|
|
13
|
+
assert.match(source, /ctx\.mode !== "tui"/);
|
|
14
|
+
assert.match(source, /pi\.on\("model_select"/);
|
|
15
|
+
assert.match(source, /await recompute\(ctx, event\.model\)/, "model selection should immediately recompute exact-model resources");
|
|
16
|
+
assert.match(source, /"Session only", "Global default", "Model default"/);
|
|
17
|
+
assert.match(source, /"Use inherited defaults"/);
|
|
18
|
+
assert.match(source, /ctx\.ui\.select\(/, "resource lists should use Pi's native selector");
|
|
19
|
+
assert.match(source, /preserveUnavailableResourceNames\(/);
|
|
20
|
+
assert.match(source, /setExactModelProfile\(/);
|
|
21
|
+
assert.match(source, /skill\.disableModelInvocation !== true/);
|
|
22
|
+
|
|
23
|
+
console.log("resource-tui-extension.test.mjs passed");
|
|
@@ -57,10 +57,10 @@ assert.match(css, /\.sampling-parameter-control\.unsupported:hover:not\(\.sampli
|
|
|
57
57
|
assert.match(css, /\.sampling-parameter-control\.unsupported:focus-visible:not\(\.sampling-tooltip-dismissed\) > \.sampling-parameter-unsupported-tooltip/, "keyboard focus should reveal dismissible unsupported reasons");
|
|
58
58
|
assert.match(css, /\.sampling-parameter-unsupported-tooltip\.sampling-tooltip-below/, "bounded placement should support flipping below top-edge rows");
|
|
59
59
|
assert.match(css, /pointer-events: auto;/, "a visible unsupported tooltip should remain pointer-hoverable");
|
|
60
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
60
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "native-control assets should advance the cache identity");
|
|
61
61
|
assert.match(serviceWorker, /"\/sampling-parameter-controls\.mjs"/, "the pure sampling module should be part of the offline app shell");
|
|
62
|
-
assert.match(html, /styles\.css\?v=
|
|
63
|
-
assert.match(html, /app\.js\?v=
|
|
62
|
+
assert.match(html, /styles\.css\?v=123/, "the changed stylesheet should have a new revision");
|
|
63
|
+
assert.match(html, /app\.js\?v=146/, "the changed app module should have a new revision");
|
|
64
64
|
|
|
65
65
|
// --- Browser state behavior -------------------------------------------------
|
|
66
66
|
|
|
@@ -27,8 +27,8 @@ assert.doesNotMatch(layout, /sectionHeightMin|sectionHeightMax|validateSectionHe
|
|
|
27
27
|
assert.match(app, /const UI_LAYOUT_SIDE_PANEL_FIELDS = \["placement", "sectionLayout", "collapsedSectionIds", "hiddenSectionIds", "collapsedPanels", "panelWidths"\];/, "the browser durable layout field list should omit section heights");
|
|
28
28
|
assert.match(app, /function clearRemovedSidePanelSectionHeightState\(\)[\s\S]*localStorage\.removeItem\(REMOVED_SIDE_PANEL_SECTION_HEIGHT_STORAGE_KEY\)[\s\S]*record\.field === "sidePanel" && record\.subfield === "sectionHeights"/, "startup should remove the retired cache and pending mutations");
|
|
29
29
|
assert.match(app, /clearRemovedSidePanelSectionHeightState\(\);\s*restoreDurableUiLayoutPendingJournal\(\);/, "retired height state should be cleared before pending layout restoration");
|
|
30
|
-
assert.match(html, /styles\.css\?v=
|
|
31
|
-
assert.match(html, /app\.js\?v=
|
|
32
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
30
|
+
assert.match(html, /styles\.css\?v=123/, "removing section resize styles should advance the stylesheet revision");
|
|
31
|
+
assert.match(html, /app\.js\?v=146/, "removing section resize behavior should advance the app revision");
|
|
32
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "removing browser assets should advance the PWA cache identity");
|
|
33
33
|
|
|
34
34
|
console.log("side-panel-section-height-removal-static.test.mjs passed");
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
TRANSCRIPT_STREAM_MESSAGE_UPDATE_TYPES,
|
|
6
6
|
classifyTranscriptStreamEvent,
|
|
7
7
|
createStreamOutputController,
|
|
8
|
+
reconcileTranscriptThinkingSnapshot,
|
|
8
9
|
} from "../public/stream-output-controller.mjs";
|
|
9
10
|
|
|
10
11
|
function messageUpdate(type, delta = "", extra = {}) {
|
|
@@ -53,6 +54,13 @@ assert.deepEqual(classifyTranscriptStreamEvent(messageUpdate("future_delta")), {
|
|
|
53
54
|
assert.equal(classifyTranscriptStreamEvent({ type: "agent_start" }), null);
|
|
54
55
|
assert.equal(DEFAULT_STREAM_PENDING_ENTRY_LIMIT, 128);
|
|
55
56
|
assert.equal(DEFAULT_STREAM_PENDING_BYTE_LIMIT, 256 * 1024);
|
|
57
|
+
assert.equal(
|
|
58
|
+
reconcileTranscriptThinkingSnapshot("first\n\nsecond\n\nthird\n\nfourth", "first\n\nsecond\n\nthird"),
|
|
59
|
+
"first\n\nsecond\n\nthird\n\nfourth",
|
|
60
|
+
"a regressive final thinking snapshot must not remove an already-rendered tail",
|
|
61
|
+
);
|
|
62
|
+
assert.equal(reconcileTranscriptThinkingSnapshot("short", "shorter complete"), "shorter complete", "a longer compatible final snapshot should win");
|
|
63
|
+
assert.equal(reconcileTranscriptThinkingSnapshot("draft reasoning", "provider correction"), "provider correction", "divergent provider corrections must remain authoritative");
|
|
56
64
|
|
|
57
65
|
// Adjacent compatible deltas coalesce, while kind changes retain exact order.
|
|
58
66
|
{
|
|
@@ -37,7 +37,7 @@ const forbiddenSinks = [
|
|
|
37
37
|
".focus(", "scrollIntoView", "fetch(", "api(",
|
|
38
38
|
];
|
|
39
39
|
|
|
40
|
-
assert.match(app, /import \{
|
|
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");
|
|
@@ -70,7 +70,7 @@ assert.doesNotMatch(rawMessageHandler, /setRunIndicatorActivity|scheduleLiveTodo
|
|
|
70
70
|
assert.match(rawMessageHandler, /compactOutputActive\(\) && handleCompactMessageUpdate\(event\)/, "normal and compact modes should share the isolated controller sink");
|
|
71
71
|
assert.match(toolUpdate, /renderLiveToolRun\(run, \{ scroll: false \}\)/, "isolated tool updates should render in the controller frame rather than queue another tool frame");
|
|
72
72
|
assert.doesNotMatch(toolUpdate, /scheduleLiveToolRunRender/, "isolated tool updates must not create a parallel render queue");
|
|
73
|
-
assert.match(app, /applyToolExecutionUpdate: \(event\) => \{\s+if \(!compactOutputActive\(\)\) applyTranscriptToolExecutionUpdate\(event\);/, "raw tool execution updates should use only the transcript sink");
|
|
73
|
+
assert.match(app, /applyToolExecutionUpdate: \(event\) => \{\s+if \(!compactOutputActive\(\) && !isIntercomTransportToolName\(event\?\.toolName\)\) applyTranscriptToolExecutionUpdate\(event\);/, "raw non-Intercom tool execution updates should use only the transcript sink");
|
|
74
74
|
assert.doesNotMatch(app.slice(app.indexOf("const streamOutputController"), app.indexOf("let assistantErrorSurfacedThisRun")), /renderWidgets|renderFooter|renderTabs|renderStatus|renderFeedbackTray|setRunIndicatorActivity|scheduleLiveTodoProgressWidgetSync|addEvent|fetch\(|api\(/, "controller integration must inject transcript-only sinks");
|
|
75
75
|
const connectEvents = functionBody(app, "connectEvents");
|
|
76
76
|
assert.match(connectEvents, /streamOutputController\.cancel\(\);[\s\S]*?resetCompactLiveOutput\(\);/, "reconnect and tab switches should cancel retained raw frames before resetting live output");
|
|
@@ -92,6 +92,8 @@ const scrollChatToBottom = findFunctionBody(app, "scrollChatToBottom");
|
|
|
92
92
|
const stripTodoProgressLines = findFunctionBody(app, "stripTodoProgressLines");
|
|
93
93
|
const liveTodoProgressWidgetLinesFromText = findFunctionBody(app, "liveTodoProgressWidgetLinesFromText");
|
|
94
94
|
const syncStreamingThinkingFormat = findFunctionBody(app, "syncStreamingThinkingFormat");
|
|
95
|
+
const setStreamThinkingRawText = findFunctionBody(app, "setStreamThinkingRawText");
|
|
96
|
+
const syncStreamingThinkingFromUpdate = findFunctionBody(app, "syncStreamingThinkingFromUpdate");
|
|
95
97
|
const renderStreamingAssistantText = findFunctionBody(app, "renderStreamingAssistantText");
|
|
96
98
|
const renderStreamingMarkdown = findFunctionBody(app, "renderStreamingMarkdown");
|
|
97
99
|
const setRunIndicatorActivity = findFunctionBody(app, "setRunIndicatorActivity");
|
|
@@ -133,6 +135,9 @@ assert.match(styles, /\.chat > \.message:first-of-type \{ margin-top:\s*0; \}/,
|
|
|
133
135
|
assert.doesNotMatch(styles, /\.chat > \.message:first-of-type \{ margin-top:\s*auto; \}/, "short transcripts must not follow the moving composer edge while the user types");
|
|
134
136
|
assert.match(appendOptimisticUserPrompt, /renderAllMessages\(\);[\s\S]*?scrollChatToBottom\(\{ force:\s*true \}\);/, "submitting a prompt should explicitly resume bottom-follow for the new turn");
|
|
135
137
|
assert.doesNotMatch(appendOptimisticUserPrompt, /if \(autoFollowChat \|\| isChatNearBottom\(\)\)/, "a paused reader position should not leave a newly submitted turn off-screen");
|
|
138
|
+
assert.match(app, /import \{[^}]*reconcileTranscriptThinkingSnapshot[^}]*\} from "\.\/stream-output-controller\.mjs";/, "the browser should import the tested thinking-snapshot reconciler");
|
|
139
|
+
assert.match(setStreamThinkingRawText, /reconcile\s*\?\s*reconcileTranscriptThinkingSnapshot\(streamThinkingRawText, snapshot\)/, "thinking state should support prefix-safe snapshot reconciliation");
|
|
140
|
+
assert.match(syncStreamingThinkingFromUpdate, /update\.type === "thinking_end"[\s\S]*?setStreamThinkingRawText\(delta, \{ reconcile: true \}\)[\s\S]*?setStreamThinkingRawText\(fallback, \{ reconcile: true \}\)/, "thinking_end snapshots and fallbacks must not cut off an already-rendered compatible tail");
|
|
136
141
|
|
|
137
142
|
futureInvariant("theory #1: message_update streaming hot path must not call immediate scroll/layout work", () => {
|
|
138
143
|
assert.doesNotMatch(handleMessageUpdate, /scrollChatToBottom\s*\(/, "handleMessageUpdate should schedule/coalesce follow-scroll instead of calling scrollChatToBottom() directly");
|
|
@@ -72,7 +72,7 @@ const pkg = JSON.parse(pkgRaw);
|
|
|
72
72
|
|
|
73
73
|
assert.match(app, /from "\.\/subagent-gate-visibility\.mjs"/, "the browser should load the retry-gate visibility policy");
|
|
74
74
|
assert.match(app, /function subagentOverviewGroups[\s\S]*Number\(data\?\.version\) === 2[\s\S]*displayRuns: runs/, "the side panel should render canonical v2 runs without recounting gate references");
|
|
75
|
-
assert.match(app, /const gates = visibleSubagentGates\(tab, dismissedSubagentGateKeys, now\);[\s\S]*displayRuns
|
|
75
|
+
assert.match(app, /const gates = visibleSubagentGates\(tab, dismissedSubagentGateKeys, now\);[\s\S]*const displayRuns = ungatedSubagentRuns\(tab\);[\s\S]*displayRuns,/, "the v1 fallback should retain gate-owned run filtering before deriving count-neutral workflow totals");
|
|
76
76
|
assert.match(app, /function renderSubagentGate\(tab, gate\)[\s\S]*subagentGateIsTerminal\(gate\)[\s\S]*Hide finished retry gate[\s\S]*dismissedSubagentGateKeys\.add\(key\)[\s\S]*renderSubagents\(\)[\s\S]*event\.detail === 0[\s\S]*focusTarget\?\.focus/, "terminal gate cards should expose an accessible hide button and preserve keyboard focus after rerendering");
|
|
77
77
|
assert.match(app, /pruneDismissedSubagentGateKeys\(latestSubagents\?\.tabs, dismissedSubagentGateKeys\)/, "polling should prune stale dismissal keys");
|
|
78
78
|
assert.match(css, /\.subagent-gate-actions[\s\S]*\.subagent-gate-close[\s\S]*min-width:\s*1\.45rem[\s\S]*background:\s*transparent[\s\S]*\.subagent-gate-close:hover,[\s\S]*\.subagent-gate-close:focus-visible/, "the close control should remain minimal, compact, and keyboard-visible");
|
|
@@ -125,7 +125,7 @@ try {
|
|
|
125
125
|
await writeFile(settingsFile, `${JSON.stringify({ version: 4, unrelated: { preserve: true }, remoteAuthEnabled: true }, null, 2)}\n`, "utf8");
|
|
126
126
|
await writeWebuiSettings({ subagentLaunchSlots: config }, settingsFile);
|
|
127
127
|
const persisted = JSON.parse(await readFile(settingsFile, "utf8"));
|
|
128
|
-
assert.equal(persisted.version,
|
|
128
|
+
assert.equal(persisted.version, 8, "persisted launch-slot settings must retain the current version-8 envelope");
|
|
129
129
|
assert.deepEqual(persisted.unrelated, { preserve: true }, "launch-slot saves must preserve unrelated WebUI settings");
|
|
130
130
|
assert.deepEqual((await readWebuiSettings(settingsFile)).subagentLaunchSlots.projects[projectKey].roles, defaultRoles);
|
|
131
131
|
|
|
@@ -17,7 +17,7 @@ for (const state of ["queued", "running", "stale", "lost", "done", "failed", "ca
|
|
|
17
17
|
assert.ok(app.includes(`"${state}"`), `lifecycle ${state} should be normalized`);
|
|
18
18
|
assert.match(css, new RegExp(`\\.subagent-state-dot\\.${state}`), `lifecycle ${state} should have a distinct CSS state`);
|
|
19
19
|
}
|
|
20
|
-
assert.match(app, /
|
|
20
|
+
assert.match(app, /function subagentRunAgentCounts[\s\S]*function renderSubagents\(\)[\s\S]*activeTabs\.reduce\(\(count, tab\) => count \+ Number\(tab\.agentCount \|\| 0\), 0\)[\s\S]*activeTabs\.reduce\(\(count, tab\) => count \+ Number\(tab\.runningAgents \|\| 0\), 0\)[\s\S]*activeTabs\.reduce\(\(count, tab\) => count \+ Number\(tab\.staleAgents \|\| 0\), 0\)/, "visible retained-inclusive agent totals should exclude count-neutral workflow controllers while preserving running and stale breakdowns");
|
|
21
21
|
assert.match(app, /URLSearchParams\(\{ group: selection\.groupId, run: selection\.runId, agent: selection\.agentId \}\)/, "overlay should use the unified group/run/agent output query");
|
|
22
22
|
assert.match(app, /URLSearchParams\(\{ group: view\.groupId, run: view\.runId, agent: view\.agentId \}\)/, "view-only tab should use the unified group/run/agent output query");
|
|
23
23
|
assert.match(app, /subagentRunCanRefresh[\s\S]*subagentRunCanCancel[\s\S]*subagentRunCanDismiss/, "controls should be capability-aware");
|
|
@@ -26,7 +26,7 @@ assert.match(app, /function finishedSubagentRunSelections[\s\S]*subagentRunIsTer
|
|
|
26
26
|
assert.match(app, /agent\.unavailableReason[\s\S]*Output is unavailable for this registered agent/, "output views should show truthful unavailable evidence");
|
|
27
27
|
assert.match(css, /\.subagent-source-badge[\s\S]*text-overflow: ellipsis[\s\S]*@media \(max-width: 720px\)/, "source badges should remain compact and responsive");
|
|
28
28
|
assert.match(html, /Managed and registered Pi agent runs[\s\S]*External agents/, "help should explain managed, registered, and external groups");
|
|
29
|
-
assert.match(html, /styles\.css\?v=
|
|
30
|
-
assert.match(worker, /pi-webui-pwa-
|
|
29
|
+
assert.match(html, /styles\.css\?v=123[\s\S]*app\.js\?v=146/, "browser assets should use the WS-D revisions");
|
|
30
|
+
assert.match(worker, /pi-webui-pwa-v108/, "PWA cache identity should advance with WS-D browser assets");
|
|
31
31
|
|
|
32
32
|
console.log("subagent-observability-static.test.mjs passed");
|
|
@@ -29,7 +29,7 @@ const normalizationContext = {
|
|
|
29
29
|
WEBUI_SUBAGENT_GATE_LIMIT: 32,
|
|
30
30
|
WEBUI_SUBAGENT_GATE_ATTEMPT_LIMIT: 100,
|
|
31
31
|
};
|
|
32
|
-
vm.runInNewContext(`${normalizationSource}\nthis.normalizePayload = normalizeWebuiSubagentPayload;`, normalizationContext);
|
|
32
|
+
vm.runInNewContext(`${normalizationSource}\nthis.normalizePayload = normalizeWebuiSubagentPayload; this.filterStartup = filterStartupInactiveRows;`, normalizationContext);
|
|
33
33
|
const normalized = normalizationContext.normalizePayload({
|
|
34
34
|
version: 1,
|
|
35
35
|
available: true,
|
|
@@ -60,6 +60,26 @@ const ordinary = normalizationContext.normalizePayload({
|
|
|
60
60
|
});
|
|
61
61
|
assert.equal(Object.hasOwn(ordinary.runs[0], "provisional"), false, "ordinary payload v1 rows should not gain recovery-only provisional metadata");
|
|
62
62
|
assert.equal(Object.hasOwn(ordinary.runs[0], "controllable"), false, "ordinary payload v1 rows should not gain recovery-only control metadata");
|
|
63
|
+
const startupTab = {};
|
|
64
|
+
const firstStartupSnapshot = normalizationContext.filterStartup(startupTab, {
|
|
65
|
+
runs: [
|
|
66
|
+
{ id: "active-before-start", status: "running" },
|
|
67
|
+
{ id: "done-before-start", status: "done" },
|
|
68
|
+
],
|
|
69
|
+
}, { rowsKey: "runs", stateKey: "fixtureStartup" });
|
|
70
|
+
assert.deepEqual(Array.from(firstStartupSnapshot.runs, (run) => run.id), ["active-before-start"], "the first helper snapshot should suppress pre-existing inactive runs");
|
|
71
|
+
const currentGenerationSnapshot = normalizationContext.filterStartup(startupTab, {
|
|
72
|
+
runs: [
|
|
73
|
+
{ id: "done-before-start", status: "done" },
|
|
74
|
+
{ id: "done-after-start", status: "done" },
|
|
75
|
+
],
|
|
76
|
+
}, { rowsKey: "runs", stateKey: "fixtureStartup" });
|
|
77
|
+
assert.deepEqual(Array.from(currentGenerationSnapshot.runs, (run) => run.id), ["done-after-start"], "later terminal runs should remain visible while startup-suppressed identities stay hidden");
|
|
78
|
+
const reactivatedSnapshot = normalizationContext.filterStartup(startupTab, {
|
|
79
|
+
runs: [{ id: "done-before-start", status: "running" }],
|
|
80
|
+
}, { rowsKey: "runs", stateKey: "fixtureStartup" });
|
|
81
|
+
assert.deepEqual(Array.from(reactivatedSnapshot.runs, (run) => run.id), ["done-before-start"], "an active transition should release startup suppression");
|
|
82
|
+
assert.match(server, /filterStartupInactiveRows\(tab, payload,[\s\S]*rowsKey: "instances"[\s\S]*filterStartupInactiveRows\(tab, payload,[\s\S]*rowsKey: "runs"[\s\S]*startupSuppressedAgentRunProjectionKeys\.has\(key\)[\s\S]*!agentRunIsActive\(record\.instance\)/, "helper snapshots and startup registry records should both exclude pre-existing inactive rows");
|
|
63
83
|
assert.deepEqual(JSON.parse(JSON.stringify(normalized.runs[0])), {
|
|
64
84
|
id: "fleet:opaque",
|
|
65
85
|
source: "recovered",
|
|
@@ -87,6 +107,8 @@ const canonicalProjectionSource = sourceBetween(
|
|
|
87
107
|
);
|
|
88
108
|
assert.match(canonicalProjectionSource, /Number\.isFinite\(run\.endedAt\) \? run\.endedAt : startedAt/, "a terminal run without endedAt should use one stable fallback timestamp");
|
|
89
109
|
assert.doesNotMatch(canonicalProjectionSource, /endedAt[^\n]*Date\.now\(\)/, "terminal projection timestamps must not change on every status poll");
|
|
110
|
+
assert.match(canonicalProjectionSource, /open: true,[\s\S]*refresh: true,[\s\S]*cancel: status === "running" && !workflow && !recovered[\s\S]*outputRef: \{ kind: "helper"/, "recovered fleet rows should expose a read-only helper output view while lifecycle control remains blocked");
|
|
111
|
+
assert.match(server, /unavailable: rawAgent\.unavailable === true[\s\S]*unavailableReason: rawAgent\.unavailable === true/, "server normalization should preserve truthful recovered-output unavailability metadata");
|
|
90
112
|
|
|
91
113
|
const interactionSource = sourceBetween(
|
|
92
114
|
server,
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
import vm from "node:vm";
|
|
6
|
+
|
|
7
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
8
|
+
const [app, css, readme, technical] = await Promise.all([
|
|
9
|
+
readFile(join(root, "public", "app.js"), "utf8"),
|
|
10
|
+
readFile(join(root, "public", "styles.css"), "utf8"),
|
|
11
|
+
readFile(join(root, "README.md"), "utf8"),
|
|
12
|
+
readFile(join(root, "TECHNICAL.md"), "utf8"),
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
function appFunctionSource(name, nextName) {
|
|
16
|
+
const start = app.indexOf(`function ${name}(`);
|
|
17
|
+
const nextStarts = [
|
|
18
|
+
app.indexOf(`\nfunction ${nextName}(`, start),
|
|
19
|
+
app.indexOf(`\nasync function ${nextName}(`, start),
|
|
20
|
+
].filter((index) => index > start);
|
|
21
|
+
const end = nextStarts.length ? Math.min(...nextStarts) : -1;
|
|
22
|
+
assert.ok(start >= 0 && end > start, `${name} should remain a standalone frontend helper`);
|
|
23
|
+
return app.slice(start, end);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const workflowControllerSource = appFunctionSource("subagentIsWorkflowController", "subagentCapabilities");
|
|
27
|
+
const workflowRenderSource = appFunctionSource("renderSubagentWorkflow", "renderSubagentAgent");
|
|
28
|
+
const renderRunSource = appFunctionSource("renderSubagentRun", "subagentGateStatusLabel");
|
|
29
|
+
const renderOverviewSource = appFunctionSource("renderSubagents", "refreshSubagents");
|
|
30
|
+
const retainedMaterializationSource = appFunctionSource("materializeRetainedSubagentTerminalViews", "subagentTerminalViewGroups");
|
|
31
|
+
|
|
32
|
+
assert.match(workflowControllerSource, /launcher === "pi-subagents"[\s\S]*function subagentRunAgents[\s\S]*function subagentRunAgentCounts/, "pi-subagents workflow controllers should be separated from model-powered child agents");
|
|
33
|
+
const workflowCountContext = {
|
|
34
|
+
subagentAgentStatus(run, agent) { return String(agent?.status || run?.status || "running").toLowerCase(); },
|
|
35
|
+
};
|
|
36
|
+
vm.runInNewContext(`${workflowControllerSource}\nthis.isWorkflowController = subagentIsWorkflowController; this.workflowAgents = subagentRunAgents; this.workflowCounts = subagentRunAgentCounts; this.runPresentations = subagentRunPresentations; this.workflowStatus = subagentWorkflowPresentationStatus;`, workflowCountContext);
|
|
37
|
+
const syntheticWorkflowRun = {
|
|
38
|
+
launcher: "pi-subagents",
|
|
39
|
+
status: "running",
|
|
40
|
+
agents: [
|
|
41
|
+
{ id: "run:workflow", name: "workflow", status: "running" },
|
|
42
|
+
{ id: "run:worker", name: "worker", status: "running", model: "openai-codex/gpt-5.6-sol", thinking: "high" },
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
assert.equal(workflowCountContext.isWorkflowController(syntheticWorkflowRun, syntheticWorkflowRun.agents[0]), true);
|
|
46
|
+
assert.deepEqual(JSON.parse(JSON.stringify(workflowCountContext.workflowAgents(syntheticWorkflowRun).map((agent) => agent.name))), ["worker"]);
|
|
47
|
+
assert.deepEqual(JSON.parse(JSON.stringify(workflowCountContext.workflowCounts([syntheticWorkflowRun]))), { total: 1, running: 1, stale: 0 });
|
|
48
|
+
assert.equal(workflowCountContext.isWorkflowController(syntheticWorkflowRun, { name: "workflow", launcher: "pi-subagents", model: "provider/real-model", thinking: "high" }), false, "a real model-powered agent named workflow must remain an agent row");
|
|
49
|
+
|
|
50
|
+
const recoveredWorkflowRuns = [
|
|
51
|
+
{ id: "fleet:23", source: "recovered", launcher: "pi-subagents", status: "done", agents: [{ id: "fleet:23:agent", name: "workflow", status: "done" }] },
|
|
52
|
+
{ id: "fleet:24", source: "recovered", launcher: "pi-subagents", status: "running", agents: [{ id: "fleet:24:agent", name: "worker", status: "running", model: "openai-codex/gpt-5.6-sol", thinking: "high" }] },
|
|
53
|
+
];
|
|
54
|
+
const recoveredPresentations = workflowCountContext.runPresentations(recoveredWorkflowRuns);
|
|
55
|
+
assert.equal(recoveredPresentations.length, 1, "adjacent recovered workflow controller and worker runs should form one presentation section");
|
|
56
|
+
assert.equal(recoveredPresentations[0].agents[0].run.id, "fleet:24", "nested recovered workers should retain their original run for output selection");
|
|
57
|
+
assert.equal(workflowCountContext.workflowStatus(recoveredPresentations[0].run, recoveredPresentations[0].agents), "running", "a running recovered worker should keep its workflow section running");
|
|
58
|
+
|
|
59
|
+
assert.match(workflowRenderSource, /const status = subagentWorkflowPresentationStatus\(run, agents\);[\s\S]*make\("details", `subagent-workflow[\s\S]*details\.open = !collapsedSubagentWorkflowRunKeys\.has\(key\)[\s\S]*make\("summary", "subagent-workflow-header"\)[\s\S]*renderSubagentAgent\(tab, entry\.run, entry\.agent\)/, "workflow controllers should render as native disclosures using the aggregate presentation lifecycle while preserving each child run");
|
|
60
|
+
assert.match(renderRunSource, /subagentWorkflowController\(run\)[\s\S]*subagentRunAgents\(run\)[\s\S]*renderSubagentWorkflow\(tab, run, controller, presentedAgents\)/, "workflow runs should route through the hierarchical renderer");
|
|
61
|
+
assert.match(renderOverviewSource, /activeTabs\.reduce\(\(count, tab\) => count \+ Number\(tab\.agentCount \|\| 0\), 0\)[\s\S]*activeTabs\.reduce\(\(count, tab\) => count \+ Number\(tab\.runningAgents \|\| 0\), 0\)/, "overview totals should use count-neutral workflow projections");
|
|
62
|
+
assert.match(retainedMaterializationSource, /for \(const agent of subagentRunAgents\(run\)\)/, "retained terminal views should materialize child agents without creating a view for the workflow controller");
|
|
63
|
+
assert.match(css, /\.subagent-workflow \{[\s\S]*\.subagent-workflow-header \{[\s\S]*list-style: none;[\s\S]*\.subagent-workflow:not\(\[open\]\)[\s\S]*\.subagent-workflow-agents \{[\s\S]*border-left:/, "workflow disclosures should have a distinct header and nested child-agent rail");
|
|
64
|
+
assert.match(readme, /workflow[^\n]*collapsible/i, "the user guide should explain collapsible workflow groups");
|
|
65
|
+
assert.match(technical, /workflow controller[^\n]*count/i, "the technical reference should explain count-neutral workflow controllers");
|
|
66
|
+
|
|
67
|
+
console.log("subagent workflow section static tests passed");
|
|
@@ -121,6 +121,21 @@ await writeFile(asyncStatusFile, JSON.stringify({
|
|
|
121
121
|
{ agent: "reviewer", status: "running", model: "openai-codex/gpt-5.6-sol", thinking: "high" },
|
|
122
122
|
],
|
|
123
123
|
}));
|
|
124
|
+
const gateAsyncRunDir = await mkdtemp(path.join(asyncRunDir, "gate-"));
|
|
125
|
+
const gateSessionFile = path.join(gateAsyncRunDir, "scout-session.jsonl");
|
|
126
|
+
await writeFile(gateSessionFile, `${JSON.stringify({
|
|
127
|
+
type: "message",
|
|
128
|
+
timestamp: "2026-07-19T12:00:10.000Z",
|
|
129
|
+
message: { role: "assistant", content: [{ type: "text", text: "Gate child output is live." }] },
|
|
130
|
+
})}\n`);
|
|
131
|
+
await writeFile(path.join(gateAsyncRunDir, "status.json"), JSON.stringify({
|
|
132
|
+
runId: "recovered-gate-run",
|
|
133
|
+
mode: "single",
|
|
134
|
+
state: "running",
|
|
135
|
+
startedAt: Date.now() - 500,
|
|
136
|
+
lastUpdate: Date.now(),
|
|
137
|
+
steps: [{ agent: "scout", status: "running", sessionFile: gateSessionFile, currentTool: "read", model: "openai-codex/gpt-5.6-terra:xhigh", thinking: "xhigh" }],
|
|
138
|
+
}));
|
|
124
139
|
|
|
125
140
|
const statusText = `Active async runs: 2
|
|
126
141
|
|
|
@@ -139,7 +154,9 @@ const unsubscribeRpc = bus.on("subagents:rpc:v1:request", (request) => {
|
|
|
139
154
|
subagentStatusRequestCount += 1;
|
|
140
155
|
const text = request.params?.id === "run-a"
|
|
141
156
|
? `Run: run-a\nState: running\nMode: parallel\nDir: ${asyncRunDir}`
|
|
142
|
-
:
|
|
157
|
+
: request.params?.id === "recovered-gate-run"
|
|
158
|
+
? `Run: recovered-gate-run\nState: running\nMode: single\nDir: ${gateAsyncRunDir}`
|
|
159
|
+
: statusText;
|
|
143
160
|
if (subagentRpcReplyHook?.(request) === true) return;
|
|
144
161
|
bus.emit(`subagents:rpc:v1:reply:${request.requestId}`, {
|
|
145
162
|
version: 1,
|
|
@@ -261,6 +278,13 @@ assert.deepEqual(recoveredFleetRun && {
|
|
|
261
278
|
controllable: false,
|
|
262
279
|
agents: [["Recovery scout", "openai-codex/gpt-5.6-terra:xhigh", "xhigh"]],
|
|
263
280
|
}, "unmatched authoritative fleet children should publish a bounded non-controllable provisional row");
|
|
281
|
+
const recoveredCanonical = latestCanonicalPayload().instances.find((instance) => instance.runId === "fleet:fleet-recovered");
|
|
282
|
+
assert.deepEqual(recoveredCanonical && {
|
|
283
|
+
open: recoveredCanonical.capabilities.open,
|
|
284
|
+
refresh: recoveredCanonical.capabilities.refresh,
|
|
285
|
+
cancel: recoveredCanonical.capabilities.cancel,
|
|
286
|
+
outputKind: recoveredCanonical.outputRef.kind,
|
|
287
|
+
}, { open: true, refresh: true, cancel: false, outputKind: "helper" }, "recovered pi-subagents rows should expose a read-only helper-owned output view without lifecycle controls");
|
|
264
288
|
assert.deepEqual(payload.fleet, { version: 1, totalActive: 5, omitted: 0 }, "fleet recovery should publish only bounded aggregate recovery metadata");
|
|
265
289
|
|
|
266
290
|
subagentRpcReplyHook = (request) => {
|
|
@@ -382,6 +406,142 @@ assert.ok(payload.runs.some((run) => run.id === workflowRunId), "pi-subagents po
|
|
|
382
406
|
|
|
383
407
|
const helperCommand = registeredCommands.get("webui-helper");
|
|
384
408
|
assert.ok(helperCommand?.handler, "Web UI helper command should be registered");
|
|
409
|
+
await helperCommand.handler(JSON.stringify({
|
|
410
|
+
requestId: "recovered-subagent-output-test",
|
|
411
|
+
action: "subagent-output",
|
|
412
|
+
payload: { outputId: recoveredCanonical.outputRef.id },
|
|
413
|
+
}), ctx);
|
|
414
|
+
const recoveredOutputResponse = helperResponse("recovered-subagent-output-test");
|
|
415
|
+
assert.equal(recoveredOutputResponse.ok, true, "a recovered fleet row should open through its opaque helper handle");
|
|
416
|
+
assert.equal(recoveredOutputResponse.data.source, "recovered");
|
|
417
|
+
assert.equal(recoveredOutputResponse.data.agent.unavailable, true);
|
|
418
|
+
assert.match(recoveredOutputResponse.data.agent.unavailableReason, /recovered from aggregate fleet metadata/, "the read-only recovered view should explain why detailed output is not yet available");
|
|
419
|
+
|
|
420
|
+
for (const handler of extensionHandlers.get("tool_execution_update") || []) {
|
|
421
|
+
handler({
|
|
422
|
+
type: "tool_execution_update",
|
|
423
|
+
toolCallId: "recovered-foreground-call",
|
|
424
|
+
toolName: "subagent",
|
|
425
|
+
partialResult: {
|
|
426
|
+
details: {
|
|
427
|
+
runId: "recovered-foreground-run",
|
|
428
|
+
mode: "single",
|
|
429
|
+
progress: [{
|
|
430
|
+
index: 0,
|
|
431
|
+
agent: "scout",
|
|
432
|
+
status: "running",
|
|
433
|
+
currentTool: "read",
|
|
434
|
+
recentOutput: ["Recovered child output is live again"],
|
|
435
|
+
}],
|
|
436
|
+
},
|
|
437
|
+
},
|
|
438
|
+
}, ctx);
|
|
439
|
+
}
|
|
440
|
+
payload = latestPayload();
|
|
441
|
+
assert.equal(payload.runs.some((run) => run.id === "fleet:fleet-recovered"), false, "a recovered fleet placeholder should be replaced when its live tool update arrives");
|
|
442
|
+
const recoveredForegroundRun = payload.runs.find((run) => run.id === "recovered-foreground-run");
|
|
443
|
+
assert.deepEqual(recoveredForegroundRun && {
|
|
444
|
+
source: recoveredForegroundRun.source,
|
|
445
|
+
controllable: recoveredForegroundRun.controllable,
|
|
446
|
+
agents: recoveredForegroundRun.agents.map((agent) => [agent.name, agent.model, agent.thinking]),
|
|
447
|
+
}, {
|
|
448
|
+
source: "foreground",
|
|
449
|
+
controllable: undefined,
|
|
450
|
+
agents: [["scout", "openai-codex/gpt-5.6-terra:xhigh", "xhigh"]],
|
|
451
|
+
}, "a live update without a preceding start event should promote recovered metadata into a normal foreground run even when the fleet display role differs from the agent identity");
|
|
452
|
+
const recoveredForegroundCanonical = latestCanonicalPayload().instances.find((instance) => instance.runId === "recovered-foreground-run");
|
|
453
|
+
await helperCommand.handler(JSON.stringify({
|
|
454
|
+
requestId: "recovered-foreground-live-output-test",
|
|
455
|
+
action: "subagent-output",
|
|
456
|
+
payload: { outputId: recoveredForegroundCanonical.outputRef.id },
|
|
457
|
+
}), ctx);
|
|
458
|
+
const recoveredForegroundOutput = helperResponse("recovered-foreground-live-output-test");
|
|
459
|
+
assert.equal(recoveredForegroundOutput.ok, true);
|
|
460
|
+
assert.equal(recoveredForegroundOutput.data.source, "foreground");
|
|
461
|
+
assert.equal(recoveredForegroundOutput.data.agent.unavailable, undefined);
|
|
462
|
+
assert.deepEqual(recoveredForegroundOutput.data.agent.recentOutput, ["Recovered child output is live again"], "promoted recovered runs should expose subsequent live output");
|
|
463
|
+
for (const handler of extensionHandlers.get("tool_execution_end") || []) {
|
|
464
|
+
handler({ type: "tool_execution_end", toolCallId: "recovered-foreground-call", toolName: "subagent" }, ctx);
|
|
465
|
+
}
|
|
466
|
+
await helperCommand.handler(JSON.stringify({
|
|
467
|
+
requestId: "dismiss-recovered-foreground-run",
|
|
468
|
+
action: "subagent-dismiss",
|
|
469
|
+
payload: { runId: "recovered-foreground-run" },
|
|
470
|
+
}), ctx);
|
|
471
|
+
assert.equal(helperResponse("dismiss-recovered-foreground-run").ok, true, "a promoted recovered run should follow the normal foreground completion lifecycle");
|
|
472
|
+
|
|
473
|
+
const gateRecoveredStartedAt = Date.now() - 500;
|
|
474
|
+
subagentRpcReplyHook = (request) => {
|
|
475
|
+
if (request.method !== "status" || Object.keys(request.params || {}).length) return false;
|
|
476
|
+
subagentRpcReplyHook = null;
|
|
477
|
+
bus.emit(`subagents:rpc:v1:reply:${request.requestId}`, {
|
|
478
|
+
version: 1,
|
|
479
|
+
requestId: request.requestId,
|
|
480
|
+
method: request.method,
|
|
481
|
+
success: true,
|
|
482
|
+
data: {
|
|
483
|
+
text: statusText,
|
|
484
|
+
details: { mode: "single", results: [] },
|
|
485
|
+
fleet: {
|
|
486
|
+
version: 1,
|
|
487
|
+
entries: [{
|
|
488
|
+
key: "fleet-gate-recovered",
|
|
489
|
+
agent: "scout",
|
|
490
|
+
role: "Gate recovery scout",
|
|
491
|
+
model: "openai-codex/gpt-5.6-terra:xhigh",
|
|
492
|
+
effort: "xhigh",
|
|
493
|
+
startedAt: gateRecoveredStartedAt,
|
|
494
|
+
tokens: { input: 0, output: 0, total: 0 },
|
|
495
|
+
}],
|
|
496
|
+
totalActive: 1,
|
|
497
|
+
omitted: 0,
|
|
498
|
+
},
|
|
499
|
+
},
|
|
500
|
+
});
|
|
501
|
+
return true;
|
|
502
|
+
};
|
|
503
|
+
bus.emit("subagents:rpc:v1:ready", { version: 1 });
|
|
504
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
505
|
+
assert.ok(latestPayload().runs.some((run) => run.id === "fleet:fleet-gate-recovered"), "an unmatched gate child should begin as an aggregate fleet placeholder");
|
|
506
|
+
bus.emit("webui:subagent-gate:v1:update", {
|
|
507
|
+
version: 1,
|
|
508
|
+
id: "gate-live-output",
|
|
509
|
+
status: "running",
|
|
510
|
+
requiredSuccesses: 1,
|
|
511
|
+
qualifyingSuccesses: 0,
|
|
512
|
+
requireDistinctProviders: false,
|
|
513
|
+
startedAt: gateRecoveredStartedAt,
|
|
514
|
+
updatedAt: Date.now(),
|
|
515
|
+
attempts: [{
|
|
516
|
+
id: "gate-live-output:0:1",
|
|
517
|
+
taskIndex: 0,
|
|
518
|
+
attempt: 1,
|
|
519
|
+
maxAttempts: 1,
|
|
520
|
+
agent: "scout",
|
|
521
|
+
label: "Gate recovery scout",
|
|
522
|
+
retrySafety: "read-only",
|
|
523
|
+
runId: "recovered-gate-run",
|
|
524
|
+
model: "openai-codex/gpt-5.6-terra:xhigh",
|
|
525
|
+
provider: "openai-codex",
|
|
526
|
+
status: "running",
|
|
527
|
+
startedAt: gateRecoveredStartedAt,
|
|
528
|
+
}],
|
|
529
|
+
});
|
|
530
|
+
assert.equal(latestPayload().runs.some((run) => run.id === "fleet:fleet-gate-recovered"), false, "a running gate attempt with a real run id should replace its aggregate fleet placeholder");
|
|
531
|
+
const gateTrackedRun = latestPayload().runs.find((run) => run.id === "recovered-gate-run");
|
|
532
|
+
assert.equal(gateTrackedRun?.source, "async", "gate-owned children should become normal output-capable async runs");
|
|
533
|
+
const gateTrackedCanonical = latestCanonicalPayload().instances.find((instance) => instance.runId === "recovered-gate-run");
|
|
534
|
+
await helperCommand.handler(JSON.stringify({
|
|
535
|
+
requestId: "recovered-gate-live-output-test",
|
|
536
|
+
action: "subagent-output",
|
|
537
|
+
payload: { outputId: gateTrackedCanonical.outputRef.id },
|
|
538
|
+
}), ctx);
|
|
539
|
+
const recoveredGateOutput = helperResponse("recovered-gate-live-output-test");
|
|
540
|
+
assert.equal(recoveredGateOutput.ok, true);
|
|
541
|
+
assert.equal(recoveredGateOutput.data.source, "async");
|
|
542
|
+
assert.equal(recoveredGateOutput.data.agent.unavailable, undefined, "a gate child with a run locator must not retain the aggregate-fleet warning");
|
|
543
|
+
assert.deepEqual(recoveredGateOutput.data.agent.recentOutput, ["Gate child output is live."], "a recovered gate child should resolve its session transcript through the real run locator");
|
|
544
|
+
|
|
385
545
|
const requestsBeforeWorkflowOutput = subagentStatusRequestCount;
|
|
386
546
|
await helperCommand.handler(JSON.stringify({
|
|
387
547
|
requestId: "workflow-subagent-output-test",
|
|
@@ -1138,6 +1298,49 @@ assert.ok(Number.isSafeInteger(retainedCanonical.endedAt), "terminal instances c
|
|
|
1138
1298
|
assert.equal(retainedCanonical.capabilities.cancel, false, "a finished run stops advertising cancel");
|
|
1139
1299
|
assert.equal(retainedCanonical.capabilities.open, true, "retained rows stay openable");
|
|
1140
1300
|
|
|
1301
|
+
bus.emit("firstpick:webui-agent-runs:v1", {
|
|
1302
|
+
version: 1,
|
|
1303
|
+
producerId: "custom-duplicate",
|
|
1304
|
+
complete: true,
|
|
1305
|
+
instances: [providerInstance({
|
|
1306
|
+
instanceId: canonicalAgent.instanceId,
|
|
1307
|
+
runId: canonicalAgent.runId,
|
|
1308
|
+
launcher: "custom",
|
|
1309
|
+
provider: "custom-duplicate",
|
|
1310
|
+
status: "done",
|
|
1311
|
+
updatedAt: retainedCanonical.endedAt,
|
|
1312
|
+
endedAt: retainedCanonical.endedAt,
|
|
1313
|
+
capabilities: { open: true, refresh: true, cancel: false, steer: false },
|
|
1314
|
+
})],
|
|
1315
|
+
});
|
|
1316
|
+
await helperCommand.handler(JSON.stringify({
|
|
1317
|
+
requestId: "dismiss-terminal-duplicate-projection",
|
|
1318
|
+
action: "subagent-dismiss",
|
|
1319
|
+
payload: { runId: "canon-run" },
|
|
1320
|
+
}), ctx);
|
|
1321
|
+
assert.equal(helperResponse("dismiss-terminal-duplicate-projection").ok, true, "the terminal owning run should accept dismissal");
|
|
1322
|
+
canonical = latestCanonicalPayload();
|
|
1323
|
+
assert.equal(canonical.instances.some((instance) => instance.instanceId === canonicalAgent.instanceId), false, "dismissal should suppress a terminal run still present in a duplicate provider snapshot");
|
|
1324
|
+
|
|
1325
|
+
bus.emit("firstpick:webui-agent-runs:v1", {
|
|
1326
|
+
version: 1,
|
|
1327
|
+
producerId: "custom-duplicate",
|
|
1328
|
+
complete: true,
|
|
1329
|
+
instances: [providerInstance({
|
|
1330
|
+
instanceId: canonicalAgent.instanceId,
|
|
1331
|
+
runId: canonicalAgent.runId,
|
|
1332
|
+
launcher: "custom",
|
|
1333
|
+
provider: "custom-duplicate",
|
|
1334
|
+
status: "running",
|
|
1335
|
+
startedAt: retainedCanonical.endedAt + 1,
|
|
1336
|
+
updatedAt: retainedCanonical.endedAt + 1,
|
|
1337
|
+
endedAt: null,
|
|
1338
|
+
})],
|
|
1339
|
+
});
|
|
1340
|
+
canonical = latestCanonicalPayload();
|
|
1341
|
+
assert.equal(canonical.instances.find((instance) => instance.instanceId === canonicalAgent.instanceId)?.status, "running", "a newer provider lifecycle should release the local dismissal tombstone");
|
|
1342
|
+
bus.emit("firstpick:webui-agent-runs:v1", { version: 1, producerId: "custom-duplicate", complete: true, instances: [] });
|
|
1343
|
+
|
|
1141
1344
|
for (const handler of extensionHandlers.get("session_shutdown") || []) await handler({ reason: "quit" }, ctx);
|
|
1142
1345
|
unsubscribeRpc();
|
|
1143
1346
|
delete process.env.PI_WEBUI_SETTINGS_FILE;
|