@firstpick/pi-package-webui 0.7.7 → 0.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/bin/pi-webui-rpc-supervisor.mjs +115 -21
- package/bin/pi-webui.mjs +67 -32
- package/lib/rpc-supervisor-client.mjs +18 -2
- package/lib/rpc-supervisor-protocol.mjs +11 -2
- package/package.json +4 -4
- package/public/app.js +750 -89
- package/public/index.html +56 -2
- package/public/issue-bot-client.mjs +344 -0
- package/public/issue-wizard-state.mjs +443 -0
- package/public/service-worker.js +3 -1
- package/public/styles.css +212 -0
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/completion-signal-contract.test.mjs +156 -0
- package/tests/cwd-footer-reliability-static.test.mjs +107 -0
- package/tests/durable-rpc-supervisor-harness.test.mjs +25 -2
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/fixtures/compacting-pi.mjs +0 -0
- package/tests/fixtures/fake-pi.mjs +11 -6
- package/tests/footer-context-contrast-static.test.mjs +10 -0
- package/tests/git-panel-render-stability-static.test.mjs +11 -1
- package/tests/issue-bot-client.test.mjs +135 -0
- package/tests/issue-wizard-state.test.mjs +126 -0
- package/tests/mobile-static.test.mjs +5 -4
- package/tests/native-parity.test.mjs +2 -2
- package/tests/open-issue-wizard-static.test.mjs +75 -0
- package/tests/prompt-routing-tab-status.test.mjs +5 -0
- package/tests/rpc-supervisor-host.test.mjs +135 -2
- package/tests/rpc-supervisor-protocol.test.mjs +26 -0
- package/tests/streaming-ui-coupling.test.mjs +3 -2
- package/tests/terminal-tab-workspace-static.test.mjs +99 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import {
|
|
3
|
+
ISSUE_WIZARD_STEP_COUNT,
|
|
4
|
+
IssueWizardValidationError,
|
|
5
|
+
buildIssuePayload,
|
|
6
|
+
createIssueWizardCatalog,
|
|
7
|
+
createIssueWizardState,
|
|
8
|
+
getCompatibleTemplates,
|
|
9
|
+
isIssueWizardStepValid,
|
|
10
|
+
issueClipboardText,
|
|
11
|
+
normalizeIssueText,
|
|
12
|
+
reduceIssueWizardState,
|
|
13
|
+
serializeIssuePayload,
|
|
14
|
+
submitIssueToGithubBot,
|
|
15
|
+
validateIssueWizardState,
|
|
16
|
+
} from "../public/issue-wizard-state.mjs";
|
|
17
|
+
|
|
18
|
+
const catalog = createIssueWizardCatalog([
|
|
19
|
+
"Guided Git workflow",
|
|
20
|
+
"NPM Release",
|
|
21
|
+
"Guided Git workflow",
|
|
22
|
+
"WebUI",
|
|
23
|
+
" Theme bundle ",
|
|
24
|
+
"",
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
assert.deepEqual(
|
|
28
|
+
catalog.categories.map((category) => category.label),
|
|
29
|
+
["Feature", "Bug", "UX", "Documentation", "Performance", "Compatibility", "Other"],
|
|
30
|
+
"the approved category catalog should be deterministic and omit Security",
|
|
31
|
+
);
|
|
32
|
+
assert.deepEqual(
|
|
33
|
+
catalog.components.map((component) => component.label),
|
|
34
|
+
["WebUI", "Guided Git workflow", "NPM Release", "Theme bundle"],
|
|
35
|
+
"optional component labels should come only from caller input and be normalized/deduplicated",
|
|
36
|
+
);
|
|
37
|
+
assert.equal(catalog.components[0].id, "webui");
|
|
38
|
+
assert.ok(Object.isFrozen(catalog), "the generated catalog should not be mutable by a caller");
|
|
39
|
+
assert.ok(catalog.templates.every((template) => template.fields.some((field) => field.kind === "choices" || field.kind === "select")), "every template should prefer a structured choice or dropdown field");
|
|
40
|
+
|
|
41
|
+
const featureTemplates = getCompatibleTemplates(catalog, "feature", "webui");
|
|
42
|
+
assert.deepEqual(featureTemplates.map((template) => template.id), ["feature-new-capability"], "template choices should be filtered by category and component");
|
|
43
|
+
assert.deepEqual(getCompatibleTemplates(catalog, "feature", "missing"), [], "an unknown component must not expose templates");
|
|
44
|
+
assert.deepEqual(getCompatibleTemplates(catalog, "bug", "webui").map((template) => template.id), ["bug-defect-report"]);
|
|
45
|
+
|
|
46
|
+
let state = createIssueWizardState();
|
|
47
|
+
assert.equal(state.step, 1);
|
|
48
|
+
assert.equal(isIssueWizardStepValid(state, catalog), false, "the first page requires a category");
|
|
49
|
+
state = reduceIssueWizardState(state, { type: "next" }, catalog);
|
|
50
|
+
assert.equal(state.step, 1, "next must not advance an invalid step");
|
|
51
|
+
state = reduceIssueWizardState(state, { type: "select-category", categoryId: "bug" }, catalog);
|
|
52
|
+
assert.equal(state.categoryId, "bug");
|
|
53
|
+
assert.equal(state.templateId, "", "choosing a category resets its dependent template state");
|
|
54
|
+
state = reduceIssueWizardState(state, { type: "next" }, catalog);
|
|
55
|
+
assert.equal(state.step, 2);
|
|
56
|
+
state = reduceIssueWizardState(state, { type: "select-component", componentId: "webui" }, catalog);
|
|
57
|
+
state = reduceIssueWizardState(state, { type: "next" }, catalog);
|
|
58
|
+
assert.equal(state.step, 3);
|
|
59
|
+
state = reduceIssueWizardState(state, { type: "select-template", templateId: "feature-new-capability" }, catalog);
|
|
60
|
+
assert.equal(state.templateId, "", "an incompatible template action must preserve the current state");
|
|
61
|
+
state = reduceIssueWizardState(state, { type: "select-template", templateId: "bug-defect-report" }, catalog);
|
|
62
|
+
assert.equal(state.templateId, "bug-defect-report");
|
|
63
|
+
state = reduceIssueWizardState(state, { type: "next" }, catalog);
|
|
64
|
+
assert.equal(state.step, 4);
|
|
65
|
+
state = reduceIssueWizardState(state, { type: "set-summary", summary: "Panel fails to open" }, catalog);
|
|
66
|
+
state = reduceIssueWizardState(state, { type: "set-field", fieldId: "severity", value: "high" }, catalog);
|
|
67
|
+
state = reduceIssueWizardState(state, { type: "set-field", fieldId: "expectedBehavior", value: "The panel opens." }, catalog);
|
|
68
|
+
state = reduceIssueWizardState(state, { type: "set-field", fieldId: "actualBehavior", value: "Nothing appears." }, catalog);
|
|
69
|
+
state = reduceIssueWizardState(state, { type: "set-field", fieldId: "reproductionSteps", value: "1. Open the deck\n2. Select the panel" }, catalog);
|
|
70
|
+
assert.equal(isIssueWizardStepValid(state, catalog), true, "a completed form should validate at the details step");
|
|
71
|
+
state = reduceIssueWizardState(state, { type: "next" }, catalog);
|
|
72
|
+
assert.equal(state.step, ISSUE_WIZARD_STEP_COUNT, "a valid details form should advance to review");
|
|
73
|
+
state = reduceIssueWizardState(state, { type: "back" }, catalog);
|
|
74
|
+
assert.equal(state.step, 4, "back should preserve prior selections and answers");
|
|
75
|
+
state = reduceIssueWizardState(state, { type: "select-component", componentId: "feature-npm-release" }, catalog);
|
|
76
|
+
assert.equal(state.templateId, "", "changing component resets template and field answers");
|
|
77
|
+
assert.deepEqual(state.fields, {});
|
|
78
|
+
assert.equal(state.summary, "Panel fails to open", "changing a dependent selection must retain the independent summary");
|
|
79
|
+
|
|
80
|
+
const incomplete = createIssueWizardState();
|
|
81
|
+
const incompleteValidation = validateIssueWizardState(incomplete, catalog);
|
|
82
|
+
assert.equal(incompleteValidation.valid, false);
|
|
83
|
+
assert.deepEqual(Object.keys(incompleteValidation.errors).sort(), ["categoryId", "componentId", "summary"], "validation should expose field-specific errors without inventing a template error before selections exist");
|
|
84
|
+
|
|
85
|
+
const payloadState = {
|
|
86
|
+
step: 5,
|
|
87
|
+
categoryId: "bug",
|
|
88
|
+
componentId: "webui",
|
|
89
|
+
templateId: "bug-defect-report",
|
|
90
|
+
summary: " Preview [breaks]\n on launch ",
|
|
91
|
+
fields: {
|
|
92
|
+
severity: "high",
|
|
93
|
+
expectedBehavior: "A preview appears.",
|
|
94
|
+
actualBehavior: "# heading\n- fake list\n[untrusted](https://example.test)",
|
|
95
|
+
reproductionSteps: "1. Open preview\r\n2. Observe failure\u0000",
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
const payload = buildIssuePayload(payloadState, catalog);
|
|
99
|
+
assert.equal(payload.title, "[Bug] [WebUI] [Defect report] Preview breaks on launch", "titles must use the approved category/component/template prefix and a normalized summary");
|
|
100
|
+
assert.match(payload.body, /^## Defect report/m);
|
|
101
|
+
assert.match(payload.body, /### Actual behavior\n\\# heading\n\\- fake list\n\\\[untrusted\\\]\\\(https:\/\/example\.test\\\)/, "prose must be escaped so it cannot introduce user-controlled Markdown structure");
|
|
102
|
+
assert.match(payload.body, /\\1\. Open preview\n\\2\. Observe failure/, "multiline prose should normalize CRLF and remove controls");
|
|
103
|
+
assert.deepEqual(JSON.parse(serializeIssuePayload(payload)), payload, "serialization should contain the exact complete title/body payload");
|
|
104
|
+
assert.equal(issueClipboardText(payload), `${payload.title}\n\n${payload.body}`, "copy output should include both title and body");
|
|
105
|
+
assert.equal(normalizeIssueText(" a\r\nb\u0000 "), "a\nb", "normalization should trim surrounding whitespace while removing controls");
|
|
106
|
+
|
|
107
|
+
assert.equal(
|
|
108
|
+
validateIssueWizardState({ ...payloadState, summary: "[ ]" }, catalog).valid,
|
|
109
|
+
false,
|
|
110
|
+
"a bracket-only summary must not pass when brackets are removed from the generated title",
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
assert.throws(
|
|
114
|
+
() => buildIssuePayload({ ...payloadState, fields: { ...payloadState.fields, severity: "critical" } }, catalog),
|
|
115
|
+
(error) => error instanceof IssueWizardValidationError && Boolean(error.errors.severity),
|
|
116
|
+
"unknown choice values must be rejected before payload generation",
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const submission = await submitIssueToGithubBot(payload);
|
|
120
|
+
assert.deepEqual(submission, {
|
|
121
|
+
ok: false,
|
|
122
|
+
status: "unavailable",
|
|
123
|
+
message: "Automatic submission is coming soon. Copy the issue instead.",
|
|
124
|
+
}, "the future submission seam must explicitly remain unavailable");
|
|
125
|
+
|
|
126
|
+
console.log("issue-wizard-state.test.mjs passed");
|
|
@@ -1178,7 +1178,7 @@ assert.match(app, /async function startVoiceConversationLoop\(tabId = activeTabI
|
|
|
1178
1178
|
assert.match(app, /function isLocalhostWebui\(\)[\s\S]*127\.0\.0\.1/, "remote-consent detection should treat localhost as implicitly consented");
|
|
1179
1179
|
assert.match(app, /function latestAssistantSpokenText\(\)[\s\S]*assistantDisplayMessages\(message\)\.find\(\(item\) => item\?\.title === "final output"\)/, "spoken text must come from final output only, never thinking or tool payloads");
|
|
1180
1180
|
assert.match(app, /function speakableTextFromMarkdown\(text\)[\s\S]*Code block omitted/, "spoken text should strip code blocks and markdown syntax");
|
|
1181
|
-
assert.match(app, /case "
|
|
1181
|
+
assert.match(app, /case "agent_settled":[\s\S]*handleVoiceConversationTurnEnd\(tabContext\)/, "agent_settled should hand the fully finished turn to the voice loop");
|
|
1182
1182
|
assert.match(app, /case "tool_execution_start":[\s\S]*setAssistantActivity\(\{ toolRunning: true \}\)/, "tool execution start should mark the voice loop tool phase");
|
|
1183
1183
|
assert.match(app, /case "tool_execution_end":[\s\S]*setAssistantActivity\(\{ toolRunning: false \}\)/, "tool execution end should clear the voice loop tool phase");
|
|
1184
1184
|
assert.match(html, /id="remoteMicStreamingConsentButton"[^>]*disabled>Allow remote microphone streaming</, "remote mic consent button should exist, start disabled, and use action-specific copy");
|
|
@@ -1418,14 +1418,15 @@ assert.match(app, /case "tool_execution_update":[\s\S]*?handleToolExecutionUpdat
|
|
|
1418
1418
|
assert.match(app, /case "auto_retry_start":[\s\S]*?addTransientMessage\(\{ role: "warn", title: "auto retry"/, "auto-retry starts should be transcript-visible warnings");
|
|
1419
1419
|
assert.match(app, /function trackAutoRetryStateFromEvent\(event\)[\s\S]*?event\.type === "auto_retry_start"[\s\S]*?autoRetryingTabs\.add\(tabId\)[\s\S]*?suppressPendingAgentDoneNotificationsForTab\(tabId\)[\s\S]*?markTabWorkingLocally\(tabId\)/, "auto-retry starts should suppress misleading done notifications and keep the tab working");
|
|
1420
1420
|
assert.match(app, /function notifyAgentDone[\s\S]*?agentDoneNotificationKeys\.add\(key\);\n\s+if \(isAutoRetryingTab\(tabId\)\) return;/, "agent-done notifications should be ignored while a tab is auto-retrying");
|
|
1421
|
-
assert.match(app, /function queueAgentDoneBrowserNotification[\s\S]*?setTimeout\([\s\S]*?
|
|
1421
|
+
assert.match(app, /function queueAgentDoneBrowserNotification[\s\S]*?setTimeout\([\s\S]*?isAutoRetryingTab\(tabId\)[\s\S]*?promptRoutingTabs\.has\(tabId\)[\s\S]*?activityForTab\(tab\)\.isWorking[\s\S]*?AGENT_DONE_NOTIFICATION_RETRY_GRACE_MS/, "agent-done notifications should wait briefly and suppress stale alerts when retry or new work starts");
|
|
1422
1422
|
assert.match(app, /case "extension_error":[\s\S]*?addTransientMessage\(\{ role: "error", title: "extension error"/, "extension errors should be transcript-visible error cards");
|
|
1423
1423
|
assert.match(app, /setRunIndicatorActivity\("Requesting context compaction…"\);\n\s+scrollChatToBottom\(\{ force: true \}\);/, "manual compaction should force-follow the transcript to the bottom status card");
|
|
1424
1424
|
assert.match(app, /function markContextUsageUnknownAfterCompaction\(/, "compaction should have a dedicated context-usage invalidation helper");
|
|
1425
1425
|
assert.match(app, /case "compaction_end":[\s\S]*?markContextUsageUnknownAfterCompaction\(event\.tabId \|\| activeTabId\)/, "finished compaction should make footer context usage unknown instead of showing stale pressure");
|
|
1426
1426
|
assert.match(app, /function footerStatsContextDisplay[\s\S]*?contextUsageUnknownAfterCompaction\(\)[\s\S]*?unknownFooterContextText/, "fallback footer context should show an unknown value after compaction invalidates usage");
|
|
1427
|
-
assert.match(app, /case "
|
|
1428
|
-
assert.match(app, /case "
|
|
1427
|
+
assert.match(app, /case "agent_settled":[\s\S]*?clearRunIndicatorActivity\(\)/, "agent settlement should remove the active agent transcript indicator");
|
|
1428
|
+
assert.match(app, /case "agent_settled":[\s\S]*?notifyAgentDone\(event\.tabId \|\| activeTabId/, "agent settlement should trigger optional done notifications");
|
|
1429
|
+
assert.doesNotMatch(app.match(/case "agent_end":[\s\S]*?case "message_start":/)?.[0] || "", /notifyAgentDone\(/, "an intermediate low-level agent end must not trigger a done notification");
|
|
1429
1430
|
assert.match(app, /function getPathTrigger\(\)/, "prompt composer should detect @ file\/path reference triggers");
|
|
1430
1431
|
assert.match(app, /api\(`\/api\/path-suggestions\?query=\$\{encodeURIComponent\(trigger\.query\)\}`/, "@ reference suggestions should load from the server as the user types");
|
|
1431
1432
|
assert.match(app, /async function api\([\s\S]*?if \(signal\?\.aborted \|\| error\?\.name === "AbortError"\) throw error;[\s\S]*?setBackendOffline\(true, offlineError\)/, "cancelled @ autocomplete requests should not mark the server offline");
|
|
@@ -172,9 +172,9 @@ assert.match(server, /nativeExportDownloadPayload\(\{[\s\S]*localRequest: isLoca
|
|
|
172
172
|
assert.match(server, /openUrl: record\.contentType === MIME_TYPES\.get\("\.html"\)/, "HTML native downloads should expose a browser-open URL");
|
|
173
173
|
assert.match(server, /url\.searchParams\.get\("disposition"\) === "inline"/, "native download endpoint should support inline HTML rendering");
|
|
174
174
|
assert.match(server, /copyFile\(sessionFile, targetPath\)/, "explicit .jsonl /export should copy the active session file");
|
|
175
|
-
assert.match(app, /function triggerNativeDownload\(download\)/, "frontend should
|
|
175
|
+
assert.match(app, /function triggerNativeDownload\(download\)[\s\S]*try \{[\s\S]*anchor\.click\(\)[\s\S]*finally \{[\s\S]*anchor\.remove\(\)/, "frontend should clean up download anchors even when browser opening throws");
|
|
176
176
|
assert.match(app, /function applyNativeSlashCommandEffects\(response, message, tabContext/, "frontend should apply centralized native slash-command adapter effects");
|
|
177
|
-
assert.match(app, /data\.download
|
|
177
|
+
assert.match(app, /if \(data\.download\) \{[\s\S]*handleNativeDownloadResponse\(data\.download, data\.command, data\.serverPath\)[\s\S]*could not open \$\{data\.command === "export" \? "HTML export" : "download"\}/, "frontend should catch and surface native HTML/download open failures");
|
|
178
178
|
assert.match(app, /function openNativeExportDownloadPrompt\(download, serverPath = ""\)[\s\S]*Saved to:\\n[\s\S]*Copy path[\s\S]*copyText\(savedPath\)[\s\S]*Open in browser/, "frontend should show and copy the saved /export HTML path before offering browser open");
|
|
179
179
|
assert.match(app, /function alternateLoopbackBrowserUrl\(value\)[\s\S]*hostname === "localhost"[\s\S]*127\.0\.0\.1/, "PWA export opens should escape same-origin app scope via alternate loopback host");
|
|
180
180
|
assert.match(app, /for \(const warning of response\.warnings/, "frontend should surface remote bash trust warnings");
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
|
|
4
|
+
const [app, html, css, stateModule, botClient, server, serviceWorker, packageJson] = await Promise.all([
|
|
5
|
+
readFile(new URL("../public/app.js", import.meta.url), "utf8"),
|
|
6
|
+
readFile(new URL("../public/index.html", import.meta.url), "utf8"),
|
|
7
|
+
readFile(new URL("../public/styles.css", import.meta.url), "utf8"),
|
|
8
|
+
readFile(new URL("../public/issue-wizard-state.mjs", import.meta.url), "utf8"),
|
|
9
|
+
readFile(new URL("../public/issue-bot-client.mjs", import.meta.url), "utf8"),
|
|
10
|
+
readFile(new URL("../bin/pi-webui.mjs", import.meta.url), "utf8"),
|
|
11
|
+
readFile(new URL("../public/service-worker.js", import.meta.url), "utf8"),
|
|
12
|
+
readFile(new URL("../package.json", import.meta.url), "utf8"),
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
assert.match(app, /from "\.\/issue-wizard-state\.mjs"/, "the browser controller must import the approved pure wizard module");
|
|
16
|
+
assert.match(app, /from "\.\/issue-bot-client\.mjs"/, "network behavior must live in a separate issue-bot client module");
|
|
17
|
+
assert.match(app, /createIssueWizardCatalog\(OPTIONAL_FEATURES\.map\(\(feature\) => feature\.label\)\)/, "optional feature labels must come from the existing catalog");
|
|
18
|
+
assert.match(app, /page\.hidden = step !== issueWizardState\.step/, "the controller must expose exactly one wizard page at a time");
|
|
19
|
+
assert.match(app, /action === "select-template"[\s\S]*item\.fields\.map\(\(field\) => field\.label\)/, "template choices must preview structured fields");
|
|
20
|
+
assert.match(app, /function focusIssueWizardChoice\([\s\S]*target\?\.focus/, "rerendered selections must preserve keyboard focus");
|
|
21
|
+
assert.match(app, /button\.setAttribute\("aria-pressed", selected \? "true" : "false"\)/, "selection buttons must keep toggle semantics");
|
|
22
|
+
assert.doesNotMatch(app, /setAttribute\("role", "radio(?:group)?"\)/, "the wizard must not advertise unimplemented radio keyboard semantics");
|
|
23
|
+
assert.match(app, /structuredIssueWizardState\(\)[\s\S]*?categoryId:[\s\S]*?fields:/, "the adapter must submit structured wizard state");
|
|
24
|
+
assert.match(app, /buildIssuePayload\(issueWizardState, issueWizardCatalog\)[\s\S]*?never send title\/body to the gateway/, "the canonical builder remains the review authority without becoming a network payload");
|
|
25
|
+
assert.doesNotMatch(app.match(/function structuredIssueWizardState\(\)[\s\S]*?\n}/)?.[0] || "", /\btitle\b|\bbody\b/, "structured submission must not add editable title/body fields");
|
|
26
|
+
assert.match(app, /new AbortController\(\)/, "submission and refresh calls must support cancellation");
|
|
27
|
+
assert.match(app, /issueWizardDialog\.addEventListener\("close", \(\) => clearIssueBotSubmission\(\{ abort: true \}\)\)/, "closing the dialog must abort the active request");
|
|
28
|
+
assert.match(app, /issueBotRequestActive/, "the wizard must prevent duplicate in-flight submissions");
|
|
29
|
+
assert.match(app, /issueBotSubmissionHandle\.refresh/, "bounded polling must retain an in-memory manual refresh path");
|
|
30
|
+
assert.match(app, /reasonCode === "sensitive_content"/, "sensitive outcomes must route to private guidance without reading submitted prose");
|
|
31
|
+
assert.doesNotMatch(app, /submitIssueToGithubBot/, "the old unavailable state-module seam must not handle browser network submission");
|
|
32
|
+
assert.match(stateModule, /export async function submitIssueToGithubBot[\s\S]*?status: "unavailable"/, "the pure state-module fallback remains offline by default");
|
|
33
|
+
assert.match(stateModule, /description: "[^"]+"[\s\S]*?fields:/, "template definitions must retain preview descriptions");
|
|
34
|
+
assert.match(app, /issueClipboardText\(payload\)/, "copy must include the complete title and body payload");
|
|
35
|
+
assert.doesNotMatch(stateModule.match(/export async function submitIssueToGithubBot[\s\S]*?\n}/)?.[0] || "", /\bfetch\s*\(/, "the pure fallback must perform no network I/O");
|
|
36
|
+
|
|
37
|
+
assert.match(botClient, /ISSUE_BOT_DEFAULT_RUNTIME_CONFIG[\s\S]*?enabled: false/, "public runtime configuration must be disabled by default");
|
|
38
|
+
assert.match(botClient, /schemaVersion: 1, idempotencyKey, turnstileToken, issue/, "admission must use the exact versioned structured envelope");
|
|
39
|
+
assert.match(botClient, /credentials: "omit"/, "browser requests must not send ambient credentials");
|
|
40
|
+
assert.match(botClient, /authorization: `Bearer \$\{statusToken\}`/, "only the status capability may authorize polling");
|
|
41
|
+
assert.match(botClient, /maxPollDurationMs = DEFAULT_MAX_POLL_DURATION_MS/, "polling must have a documented bounded duration");
|
|
42
|
+
assert.match(botClient, /Math\.min\(MAX_POLL_AFTER_MS, Math\.max\(delayMs \* 2/, "polling must apply bounded exponential backoff");
|
|
43
|
+
assert.match(botClient, /STATUS_TOKEN/, "the capability token must be shape-validated before use");
|
|
44
|
+
assert.doesNotMatch(botClient, /localStorage|sessionStorage|document\.cookie/, "the client must not persist drafts or capability tokens");
|
|
45
|
+
assert.doesNotMatch(botClient, /OPENAI_API_KEY|GITHUB_APP_|PRIVATE_KEY/, "the browser client must not contain service credentials");
|
|
46
|
+
|
|
47
|
+
assert.match(html, /__PI_WEBUI_ISSUE_BOT_CONFIG__[\s\S]*?enabled: false/, "the page must expose only disabled-by-default public runtime configuration");
|
|
48
|
+
assert.match(html, /id="openIssueButton"[\s\S]*?aria-controls="issueWizardDialog"/, "the persistent Control Deck action must target the dialog");
|
|
49
|
+
assert.match(html, /<footer class="side-panel-footer">[\s\S]*?id="openIssueButton"/, "the action must stay outside scrolling Control Deck content");
|
|
50
|
+
assert.match(html, /<dialog id="issueWizardDialog"[\s\S]*?aria-labelledby="issueWizardTitle"[\s\S]*?aria-describedby="issueWizardDescription"/, "the dialog must have an accessible name and description");
|
|
51
|
+
for (const step of [1, 2, 3, 4, 5]) assert.match(html, new RegExp(`data-issue-wizard-page="${step}"`), `step ${step} markup must exist`);
|
|
52
|
+
assert.match(html, /id="issueWizardStatus"[^>]*role="status"[^>]*aria-live="polite"/, "wizard progress must retain its accessible live region");
|
|
53
|
+
assert.doesNotMatch(html, /id="issueWizardProgress"[^>]*aria-live/, "the progress label must not duplicate live announcements");
|
|
54
|
+
assert.match(html, /id="issueWizardSubmissionStatus"[^>]*role="status"[^>]*aria-live="polite"/, "submission state needs a persistent dialog live region");
|
|
55
|
+
assert.match(html, /id="issueWizardSubmissionLink"[^>]*target="_blank"[^>]*rel="noopener noreferrer"/, "confirmed issue links must prevent opener access");
|
|
56
|
+
assert.match(html, /id="issueWizardSecurityLink"[^>]*target="_blank"[^>]*rel="noopener noreferrer"/, "private security guidance links must be safe");
|
|
57
|
+
assert.match(html, /id="issueWizardBotButton"[^>]*disabled[^>]*>Send</, "the bot control must be disabled until safe runtime configuration enables it");
|
|
58
|
+
assert.match(html, /id="issueWizardCopyButton"[^>]*>Copy complete issue</, "copy fallback must remain available");
|
|
59
|
+
|
|
60
|
+
assert.match(css, /\.side-panel-footer\s*\{[\s\S]*justify-content:\s*flex-end/, "the Control Deck action must anchor at the footer's right edge");
|
|
61
|
+
assert.match(css, /\.issue-wizard-dialog\s*\{[\s\S]*max-height:/, "the dialog must bound its height");
|
|
62
|
+
assert.match(css, /\.issue-wizard-pages\s*\{[\s\S]*overflow:\s*auto/, "wizard page content must remain scrollable");
|
|
63
|
+
assert.match(css, /\.issue-wizard-choice-description,[\s\S]*\.issue-wizard-choice-preview/, "template descriptions and field previews need dedicated styling");
|
|
64
|
+
assert.match(css, /\.issue-wizard-submission-status\s*\{/, "persistent bot status needs dedicated styling");
|
|
65
|
+
assert.match(css, /@media \(max-width: 720px\)[\s\S]*\.issue-wizard-choice-grid/, "wizard choices must adapt for mobile");
|
|
66
|
+
|
|
67
|
+
assert.match(server, /"issue-wizard-state\.mjs"/, "the static allowlist must continue serving the pure wizard module");
|
|
68
|
+
assert.match(server, /"issue-bot-client\.mjs"/, "the static allowlist must serve the browser client module");
|
|
69
|
+
assert.match(serviceWorker, /"\/issue-wizard-state\.mjs"/, "the PWA shell must keep caching the pure wizard module");
|
|
70
|
+
assert.match(serviceWorker, /"\/issue-bot-client\.mjs"/, "the PWA shell must cache the browser client module");
|
|
71
|
+
assert.match(serviceWorker, /pi-webui-pwa-v48/, "the PWA cache name must change with the new static module");
|
|
72
|
+
assert.match(packageJson, /node --check public\/issue-wizard-state\.mjs/, "the package check must keep syntax-checking the pure wizard module");
|
|
73
|
+
assert.match(packageJson, /node --check public\/issue-bot-client\.mjs/, "the package check must syntax-check the browser client module");
|
|
74
|
+
|
|
75
|
+
console.log("open-issue-wizard-static.test.mjs passed");
|
|
@@ -32,12 +32,14 @@ vm.runInContext(`
|
|
|
32
32
|
const promptRoutingTabs = new Set();
|
|
33
33
|
let tabSeenCompletionSerials = new Map();
|
|
34
34
|
function scheduleTabsRender() {}
|
|
35
|
+
function suppressPendingAgentDoneNotificationsForTab() {}
|
|
35
36
|
|
|
36
37
|
${functionSource("normalizeTabActivity")}
|
|
37
38
|
${functionSource("tabActivityStateChanged")}
|
|
38
39
|
${functionSource("setTabActivity")}
|
|
39
40
|
${functionSource("activityForTab")}
|
|
40
41
|
${functionSource("markTabWorkingLocally")}
|
|
42
|
+
${functionSource("markTabIdleLocally")}
|
|
41
43
|
${functionSource("markTabDoneLocally")}
|
|
42
44
|
|
|
43
45
|
globalThis.activityApi = {
|
|
@@ -86,6 +88,9 @@ assert.equal(api.markDone(), false, "idle state reconciliation must not synthesi
|
|
|
86
88
|
assert.equal(api.current().completionSerial, 2, "routing must not create a false completion serial");
|
|
87
89
|
|
|
88
90
|
api.finishRouting();
|
|
91
|
+
assert.equal(api.markDone(), true, "idle reconciliation should leave a submitted-but-never-started prompt idle");
|
|
92
|
+
assert.equal(api.current().status, "idle");
|
|
93
|
+
assert.equal(api.current().completionSerial, 2, "a prompt that never emitted agent_start must not synthesize completion");
|
|
89
94
|
assert.equal(api.ingest(staleDone).status, "done", "authoritative completion remains accepted after routing finishes");
|
|
90
95
|
|
|
91
96
|
const sendSource = functionSource("sendPrompt");
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { createConnection, createServer } from "node:net";
|
|
3
|
-
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { setTimeout as delay } from "node:timers/promises";
|
|
8
8
|
import {
|
|
9
|
+
RPC_SUPERVISOR_CHILD_ARG_LIMIT,
|
|
9
10
|
RPC_SUPERVISOR_EVENT_RING_MAX_BYTES,
|
|
10
11
|
RPC_SUPERVISOR_REQUEST_DEDUPE_LIMIT,
|
|
11
12
|
} from "../lib/rpc-supervisor-protocol.mjs";
|
|
@@ -39,7 +40,13 @@ const rawPiScript = String.raw`
|
|
|
39
40
|
setTimeout(() => process.exit(0), 2500).unref();
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
42
|
-
if (command.type === "
|
|
43
|
+
if (command.type === "pause_stdin") {
|
|
44
|
+
send({ type: "response", id: command.id, data: { paused: true } });
|
|
45
|
+
setInterval(() => {}, 1000);
|
|
46
|
+
process.stdin.pause();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (command.type === "no_response" || command.type === "extension_ui_response") return;
|
|
43
50
|
if (command.type === "flood") {
|
|
44
51
|
send({ type: "response", id: command.id, data: { accepted: true } });
|
|
45
52
|
for (let index = 0; index < 80; index += 1) send({ type: "large_event", index, tokens: { keep: index }, body: "r".repeat(72 * 1024) });
|
|
@@ -90,6 +97,16 @@ async function waitFor(label, predicate, timeoutMs = 5_000) {
|
|
|
90
97
|
throw new Error(`${label} did not happen within ${timeoutMs}ms`);
|
|
91
98
|
}
|
|
92
99
|
|
|
100
|
+
function pidIsAlive(pid) {
|
|
101
|
+
if (!Number.isInteger(pid) || pid < 1) return false;
|
|
102
|
+
try {
|
|
103
|
+
process.kill(pid, 0);
|
|
104
|
+
return true;
|
|
105
|
+
} catch (error) {
|
|
106
|
+
return error?.code === "EPERM";
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
93
110
|
let client;
|
|
94
111
|
let replacement;
|
|
95
112
|
let replayClient;
|
|
@@ -112,6 +129,18 @@ try {
|
|
|
112
129
|
metadata: { title: "Raw", index: 1, cwd: work, sessionFile: path.join(work, "raw.jsonl") },
|
|
113
130
|
child: { command: process.execPath, args: ["-e", rawPiScript], cwd: work },
|
|
114
131
|
});
|
|
132
|
+
await assert.rejects(
|
|
133
|
+
Promise.race([
|
|
134
|
+
client.createTab({
|
|
135
|
+
tabId: "invalid-arg-tab",
|
|
136
|
+
metadata: { title: "Invalid", index: 2, cwd: work },
|
|
137
|
+
child: { command: process.execPath, args: Array.from({ length: RPC_SUPERVISOR_CHILD_ARG_LIMIT + 1 }, () => "x"), cwd: work },
|
|
138
|
+
}),
|
|
139
|
+
delay(1_000).then(() => { throw new Error("validation failure was not correlated to the create request"); }),
|
|
140
|
+
]),
|
|
141
|
+
/at most 1024 entries/,
|
|
142
|
+
"invalid create frames must reject their matching client request instead of hanging",
|
|
143
|
+
);
|
|
115
144
|
|
|
116
145
|
const response = await Promise.all([
|
|
117
146
|
client.command("tab-1", { type: "prompt", message: "dedupe me" }, { requestId: "prompt-once" }),
|
|
@@ -142,6 +171,95 @@ try {
|
|
|
142
171
|
const written = await waitFor("raw write log", async () => (await rawLines()).find((line) => line.type === "extension_ui_response"));
|
|
143
172
|
assert.deepEqual(written, rawWrite, "fire-and-forget writes must reach Pi unchanged and without an injected request ID");
|
|
144
173
|
|
|
174
|
+
const pendingCommand = client.command("raw-tab", { type: "no_response" }, { requestId: "pending-before-ui-write", timeoutMs: 700 });
|
|
175
|
+
await waitFor("pending command admission", async () => (await rawLines()).some((line) => line.type === "no_response"));
|
|
176
|
+
const queuedProbe = await Promise.race([
|
|
177
|
+
client.command("raw-tab", { type: "queued_behind_pending_response" }, { requestId: "queued-behind-pending-response", timeoutMs: 500 }),
|
|
178
|
+
delay(300).then(() => { throw new Error("a pending Pi response held the supervisor admission queue"); }),
|
|
179
|
+
]);
|
|
180
|
+
assert.equal(queuedProbe.data.type, "queued_behind_pending_response", "later commands should be admitted without waiting for an earlier Pi response");
|
|
181
|
+
await Promise.race([
|
|
182
|
+
client.write("raw-tab", { type: "extension_ui_response", id: "ui-behind-pending-command" }, { requestId: "ui-behind-pending-command" }),
|
|
183
|
+
delay(300).then(() => { throw new Error("extension UI response deadlocked behind a pending Pi command"); }),
|
|
184
|
+
]);
|
|
185
|
+
await waitFor("extension UI response behind pending command", async () => (await rawLines()).some((line) => line.id === "ui-behind-pending-command"));
|
|
186
|
+
await assert.rejects(pendingCommand, /Timed out waiting for RPC response/, "the deliberately unanswered command should retain its own response timeout");
|
|
187
|
+
|
|
188
|
+
const metadataUpdates = [];
|
|
189
|
+
let metadataSerial = 0;
|
|
190
|
+
const metadataFlood = setInterval(() => {
|
|
191
|
+
metadataSerial += 1;
|
|
192
|
+
metadataUpdates.push(client.updateTab("raw-tab", {
|
|
193
|
+
title: `Raw ${metadataSerial}`,
|
|
194
|
+
index: 1,
|
|
195
|
+
cwd: work,
|
|
196
|
+
sessionFile: path.join(work, "raw.jsonl"),
|
|
197
|
+
}));
|
|
198
|
+
}, 1);
|
|
199
|
+
try {
|
|
200
|
+
await delay(40);
|
|
201
|
+
const starvationProbe = await Promise.race([
|
|
202
|
+
client.command("raw-tab", { type: "metadata_starvation_probe" }, { requestId: "metadata-starvation-probe" }),
|
|
203
|
+
delay(3_000).then(() => { throw new Error("RPC command starved behind continuous metadata updates"); }),
|
|
204
|
+
]);
|
|
205
|
+
assert.equal(starvationProbe.data.type, "metadata_starvation_probe", "commands should take a FIFO admission position instead of chasing a continuously moving metadata tail");
|
|
206
|
+
} finally {
|
|
207
|
+
clearInterval(metadataFlood);
|
|
208
|
+
const updateResults = await Promise.allSettled(metadataUpdates);
|
|
209
|
+
assert.ok(updateResults.length > 0 && updateResults.every((result) => result.status === "fulfilled"), "metadata flood must consist of successful updates");
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const replacementCwd = path.join(work, "replacement-cwd");
|
|
213
|
+
await mkdir(replacementCwd);
|
|
214
|
+
const originalRawPid = client.snapshot.tabs.find((tab) => tab.id === "raw-tab")?.pid;
|
|
215
|
+
const paused = await client.command("raw-tab", { type: "pause_stdin" }, { requestId: "pause-stdin-before-replace" });
|
|
216
|
+
assert.equal(paused.data.paused, true);
|
|
217
|
+
const blockedWriteResult = client.write("raw-tab", {
|
|
218
|
+
type: "extension_ui_response",
|
|
219
|
+
id: "backpressured-before-replace",
|
|
220
|
+
body: "x".repeat(2 * 1024 * 1024),
|
|
221
|
+
}, { requestId: "backpressured-before-replace" }).then(
|
|
222
|
+
() => ({ status: "fulfilled" }),
|
|
223
|
+
(error) => ({ status: "rejected", error }),
|
|
224
|
+
);
|
|
225
|
+
const replacedRawTab = await Promise.race([
|
|
226
|
+
client.replaceTab({
|
|
227
|
+
tabId: "raw-tab",
|
|
228
|
+
metadata: { title: "Raw", index: 1, cwd: replacementCwd, sessionFile: path.join(work, "raw.jsonl") },
|
|
229
|
+
child: { command: process.execPath, args: ["-e", rawPiScript], cwd: replacementCwd },
|
|
230
|
+
}),
|
|
231
|
+
delay(5_000).then(() => { throw new Error("replacement remained blocked behind a backpressured one-way write"); }),
|
|
232
|
+
]);
|
|
233
|
+
const blockedWrite = await blockedWriteResult;
|
|
234
|
+
assert.equal(blockedWrite.status, "rejected", "a backpressured one-way write must fail within a bounded interval");
|
|
235
|
+
assert.match(blockedWrite.error?.message || "", /Timed out flushing a one-way Pi RPC write/, "the bounded write failure should explain the queue blockage");
|
|
236
|
+
assert.equal(replacedRawTab.metadata.cwd, replacementCwd, "successful replacement should publish the child cwd atomically");
|
|
237
|
+
assert.notEqual(replacedRawTab.pid, originalRawPid, "successful replacement should expose the replacement child PID");
|
|
238
|
+
const replacedRawResponse = await client.command("raw-tab", { type: "replacement_probe" }, { requestId: "replacement-probe" });
|
|
239
|
+
assert.equal(replacedRawResponse.data.type, "replacement_probe", "replacement child should accept RPC commands after replace resolves");
|
|
240
|
+
|
|
241
|
+
const concurrentCwdA = path.join(work, "concurrent-cwd-a");
|
|
242
|
+
const concurrentCwdB = path.join(work, "concurrent-cwd-b");
|
|
243
|
+
await Promise.all([mkdir(concurrentCwdA), mkdir(concurrentCwdB)]);
|
|
244
|
+
const [concurrentA, concurrentB] = await Promise.all([
|
|
245
|
+
client.replaceTab({
|
|
246
|
+
tabId: "raw-tab",
|
|
247
|
+
metadata: { title: "Raw A", index: 1, cwd: concurrentCwdA, sessionFile: path.join(work, "raw.jsonl") },
|
|
248
|
+
child: { command: process.execPath, args: ["-e", rawPiScript], cwd: concurrentCwdA },
|
|
249
|
+
}),
|
|
250
|
+
client.replaceTab({
|
|
251
|
+
tabId: "raw-tab",
|
|
252
|
+
metadata: { title: "Raw B", index: 1, cwd: concurrentCwdB, sessionFile: path.join(work, "raw.jsonl") },
|
|
253
|
+
child: { command: process.execPath, args: ["-e", rawPiScript], cwd: concurrentCwdB },
|
|
254
|
+
}),
|
|
255
|
+
]);
|
|
256
|
+
assert.equal(concurrentA.metadata.cwd, concurrentCwdA, "first queued replacement should resolve with its own committed cwd");
|
|
257
|
+
assert.equal(concurrentB.metadata.cwd, concurrentCwdB, "second queued replacement should resolve with its own committed cwd");
|
|
258
|
+
assert.notEqual(concurrentA.pid, concurrentB.pid, "serialized replacements should use distinct child processes");
|
|
259
|
+
await waitFor("superseded replacement child exit", () => !pidIsAlive(concurrentA.pid));
|
|
260
|
+
const concurrentProbe = await client.command("raw-tab", { type: "concurrent_replacement_probe" }, { requestId: "concurrent-replacement-probe" });
|
|
261
|
+
assert.equal(concurrentProbe.data.type, "concurrent_replacement_probe", "commands arriving after queued replacements should reach the final child");
|
|
262
|
+
|
|
145
263
|
const deliveredStartupEvents = [];
|
|
146
264
|
const unsubscribe = client.onEvent((event) => deliveredStartupEvents.push(event));
|
|
147
265
|
await client.command("raw-tab", { type: "emit_one" }, { requestId: "startup-buffer-event" });
|
|
@@ -157,6 +275,21 @@ try {
|
|
|
157
275
|
assert.equal(state.tabs.length, 2);
|
|
158
276
|
assert.equal(state.tabs.find((tab) => tab.id === "tab-1").metadata.apiToken, undefined, "private metadata fields must not reach the state snapshot");
|
|
159
277
|
|
|
278
|
+
const failedReplacementCwd = path.join(work, "failed-replacement-cwd");
|
|
279
|
+
await mkdir(failedReplacementCwd);
|
|
280
|
+
await assert.rejects(
|
|
281
|
+
client.replaceTab({
|
|
282
|
+
tabId: "tab-1",
|
|
283
|
+
metadata: { title: "One", index: 0, cwd: failedReplacementCwd, sessionFile: path.join(work, "one.jsonl") },
|
|
284
|
+
child: { command: path.join(work, "missing-pi-executable"), args: [], cwd: failedReplacementCwd },
|
|
285
|
+
}),
|
|
286
|
+
/ENOENT|spawn/i,
|
|
287
|
+
"replace should reject when the replacement child cannot spawn",
|
|
288
|
+
);
|
|
289
|
+
await delay(50);
|
|
290
|
+
const stateAfterFailedReplacement = await readSupervisorState(paths);
|
|
291
|
+
assert.equal(stateAfterFailedReplacement.tabs.find((tab) => tab.id === "tab-1").metadata.cwd, work, "failed replacement must not persist the requested cwd");
|
|
292
|
+
|
|
160
293
|
replacement = await discoverStartAttachRpcSupervisor({ agentDir, port, controllerId: "replacement-controller", startupTimeoutMs: 5_000 });
|
|
161
294
|
await assert.rejects(client.command("tab-1", { type: "get_state" }), /fenced|closed|not attached/i, "newer attachment must fence prior controller writes");
|
|
162
295
|
assert.equal(replacement.snapshot.tabs.find((tab) => tab.id === "tab-1").id, "tab-1");
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import {
|
|
3
3
|
PI_RPC_JSONL_LINE_MAX_BYTES,
|
|
4
|
+
RPC_SUPERVISOR_CHILD_ARG_LIMIT,
|
|
4
5
|
RPC_SUPERVISOR_MAX_FRAME_BYTES,
|
|
5
6
|
RPC_SUPERVISOR_PROTOCOL,
|
|
6
7
|
RpcSupervisorProtocolError,
|
|
7
8
|
constantTimeTokenEqual,
|
|
8
9
|
encodeFrame,
|
|
9
10
|
frameReader,
|
|
11
|
+
protocolCompatible,
|
|
12
|
+
protocolCurrent,
|
|
10
13
|
sanitizeSupervisorData,
|
|
11
14
|
validateClientFrame,
|
|
12
15
|
} from "../lib/rpc-supervisor-protocol.mjs";
|
|
@@ -17,6 +20,29 @@ const attach = validateClientFrame({
|
|
|
17
20
|
assert.equal(attach.token, "private-token", "attach validation must retain the private token for authentication");
|
|
18
21
|
assert.equal(constantTimeTokenEqual("same", "same"), true);
|
|
19
22
|
assert.equal(constantTimeTokenEqual("same", "different"), false);
|
|
23
|
+
assert.equal(protocolCompatible({ major: RPC_SUPERVISOR_PROTOCOL.major, minor: 0 }), true, "older minor versions remain attach-compatible for actionable recovery");
|
|
24
|
+
assert.equal(protocolCurrent({ major: RPC_SUPERVISOR_PROTOCOL.major, minor: 0 }), false, "older detached supervisors must be detectable after a server-only restart");
|
|
25
|
+
assert.equal(protocolCurrent(RPC_SUPERVISOR_PROTOCOL), true);
|
|
26
|
+
|
|
27
|
+
const resumedChildArgs = Array.from({ length: 257 }, (_, index) => index % 2 === 0 ? "--extension" : `/tmp/resource-${index}`);
|
|
28
|
+
const resumedChild = validateClientFrame({
|
|
29
|
+
type: "create",
|
|
30
|
+
requestId: "create-resumed-tab",
|
|
31
|
+
tabId: "resumed-tab",
|
|
32
|
+
metadata: {},
|
|
33
|
+
child: { command: "pi", args: resumedChildArgs, cwd: "/tmp" },
|
|
34
|
+
});
|
|
35
|
+
assert.equal(resumedChild.child.args.length, 257, "resource-heavy resumed tabs must fit the supervisor launch contract");
|
|
36
|
+
assert.throws(
|
|
37
|
+
() => validateClientFrame({
|
|
38
|
+
type: "create",
|
|
39
|
+
requestId: "create-too-many-args",
|
|
40
|
+
tabId: "oversized-tab",
|
|
41
|
+
metadata: {},
|
|
42
|
+
child: { command: "pi", args: Array.from({ length: RPC_SUPERVISOR_CHILD_ARG_LIMIT + 1 }, () => "x"), cwd: "/tmp" },
|
|
43
|
+
}),
|
|
44
|
+
/at most 1024 entries/,
|
|
45
|
+
);
|
|
20
46
|
|
|
21
47
|
const rawPiCommand = {
|
|
22
48
|
type: "prompt",
|
|
@@ -178,7 +178,7 @@ futureInvariant("theory #6: output-seen tab refresh should remain out of the mes
|
|
|
178
178
|
futureInvariant("theory #6: event-end output-seen refresh should not synchronously rebuild all tabs", () => {
|
|
179
179
|
assert.doesNotMatch(markTabOutputSeen, /renderTabs\(\)/, "output-seen serial changes should schedule/coalesce tab chrome updates");
|
|
180
180
|
});
|
|
181
|
-
assert.match(findCaseBody(handleEvent, "
|
|
181
|
+
assert.match(findCaseBody(handleEvent, "agent_settled"), /markTabOutputSeen\(\)/, "theory #6: output-seen marking should happen only when a logical run settles");
|
|
182
182
|
assert.match(findCaseBody(handleEvent, "compaction_end"), /markTabOutputSeen\(\)/, "theory #6: output-seen marking should still happen when compaction ends");
|
|
183
183
|
|
|
184
184
|
futureInvariant("theory #7: skill tracking must not inspect every message_update event", () => {
|
|
@@ -192,7 +192,8 @@ assert.match(trackAutoRetryStateFromEvent, /event\.type === "auto_retry_start"/,
|
|
|
192
192
|
// Theory #8 is a correctness guard: the current design still uses a steer prompt,
|
|
193
193
|
// but it must never run while the agent is active.
|
|
194
194
|
assert.match(requestGitFooterWebuiPayload, /currentState\?\.isStreaming \|\| currentState\?\.isCompacting/, "theory #8: git-footer steer refresh must remain guarded during active streaming/compaction");
|
|
195
|
-
assert.match(findCaseBody(handleEvent, "
|
|
195
|
+
assert.match(findCaseBody(handleEvent, "agent_settled"), /currentState\) currentState = \{ \.\.\.currentState, isStreaming: false \};[\s\S]*?requestGitFooterWebuiPayload\(tabContext, \{ force: true \}\)/, "theory #8: forced git-footer refresh should only happen after agent settlement clears streaming state");
|
|
196
|
+
assert.doesNotMatch(findCaseBody(handleEvent, "agent_end"), /isStreaming: false|requestGitFooterWebuiPayload/, "theory #8: low-level agent_end must not expose an idle window before retry or continuation");
|
|
196
197
|
|
|
197
198
|
if (futureFailures.length) {
|
|
198
199
|
assert.fail(`streaming/UI coupling invariants still failing (${futureFailures.length}):\n\n${futureFailures.map((failure, index) => `${index + 1}. ${failure}`).join("\n\n")}`);
|