@firstpick/pi-package-webui 0.7.6 → 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.
Files changed (48) hide show
  1. package/README.md +60 -4
  2. package/bin/pi-webui-rpc-supervisor.mjs +612 -0
  3. package/bin/pi-webui.mjs +1051 -95
  4. package/lib/WEBUI_TUI_NATIVE_PARITY.json +13 -0
  5. package/lib/rpc-supervisor-client.mjs +317 -0
  6. package/lib/rpc-supervisor-protocol.mjs +245 -0
  7. package/lib/rpc-supervisor-state.mjs +165 -0
  8. package/lib/trust-boundaries.mjs +1 -0
  9. package/package.json +4 -4
  10. package/public/app.js +1986 -170
  11. package/public/index.html +388 -25
  12. package/public/issue-bot-client.mjs +344 -0
  13. package/public/issue-wizard-state.mjs +443 -0
  14. package/public/service-worker.js +8 -1
  15. package/public/styles.css +578 -52
  16. package/public/subagent-gate-visibility.mjs +36 -0
  17. package/public/workflow-status-stack.mjs +69 -0
  18. package/tests/app-runner-process-tree-harness.test.mjs +37 -3
  19. package/tests/boot-failure-diagnostics.test.mjs +180 -0
  20. package/tests/completion-signal-contract.test.mjs +156 -0
  21. package/tests/cwd-footer-reliability-static.test.mjs +107 -0
  22. package/tests/durable-rpc-supervisor-harness.test.mjs +275 -0
  23. package/tests/fast-mode-client-static.test.mjs +2 -2
  24. package/tests/fixtures/fake-pi.mjs +90 -6
  25. package/tests/footer-context-contrast-static.test.mjs +10 -0
  26. package/tests/git-panel-file-preview-static.test.mjs +221 -0
  27. package/tests/git-panel-render-stability-static.test.mjs +11 -1
  28. package/tests/http-endpoints-harness.test.mjs +458 -33
  29. package/tests/issue-bot-client.test.mjs +135 -0
  30. package/tests/issue-wizard-state.test.mjs +126 -0
  31. package/tests/mobile-static.test.mjs +79 -16
  32. package/tests/native-parity-harness.test.mjs +2 -1
  33. package/tests/native-parity.test.mjs +13 -2
  34. package/tests/numpad-decimal-input-static.test.mjs +128 -0
  35. package/tests/open-issue-wizard-static.test.mjs +75 -0
  36. package/tests/prompt-routing-input-clear-static.test.mjs +34 -0
  37. package/tests/prompt-routing-tab-status.test.mjs +108 -0
  38. package/tests/rpc-supervisor-host.test.mjs +408 -0
  39. package/tests/rpc-supervisor-protocol.test.mjs +93 -0
  40. package/tests/rpc-supervisor-state.test.mjs +62 -0
  41. package/tests/run-all.mjs +4 -1
  42. package/tests/streaming-ui-coupling.test.mjs +18 -2
  43. package/tests/subagent-gate-visibility.test.mjs +66 -0
  44. package/tests/subagent-launch-slots-static.test.mjs +1 -1
  45. package/tests/subagents-helper.test.mjs +136 -0
  46. package/tests/terminal-tab-workspace-static.test.mjs +99 -0
  47. package/tests/workflow-status-stack.test.mjs +87 -0
  48. package/webui-rpc-helper.mjs +160 -2
@@ -0,0 +1,135 @@
1
+ import assert from "node:assert/strict";
2
+ import { createIssueBotClient, readIssueBotRuntimeConfig } from "../public/issue-bot-client.mjs";
3
+
4
+ const submissionId = "AbCdEfGhIjKlMnOpQrStUv";
5
+ const statusToken = "a".repeat(43);
6
+ const uuid = "123e4567-e89b-42d3-a456-426614174000";
7
+ const issue = Object.freeze({
8
+ categoryId: "bug",
9
+ componentId: "webui",
10
+ templateId: "bug-defect-report",
11
+ summary: "Panel fails to open",
12
+ fields: Object.freeze({
13
+ severity: "high",
14
+ expectedBehavior: "The panel opens.",
15
+ actualBehavior: "Nothing appears.",
16
+ reproductionSteps: "1. Open the deck\n2. Select the panel",
17
+ }),
18
+ });
19
+
20
+ const config = Object.freeze({
21
+ enabled: true,
22
+ gatewayBaseUrl: "https://issue-intake.example.test/",
23
+ turnstileSiteKey: "1x00000000000000000000AA",
24
+ privateSecurityReportUrl: "https://github.com/Firstp1ck/pi-coding-agent-forge/security/advisories/new",
25
+ });
26
+
27
+ assert.deepEqual(readIssueBotRuntimeConfig(), {
28
+ enabled: false,
29
+ gatewayBaseUrl: "",
30
+ turnstileSiteKey: "",
31
+ privateSecurityReportUrl: "",
32
+ }, "missing public runtime configuration must leave the bot disabled");
33
+ assert.equal(readIssueBotRuntimeConfig({ ...config, gatewayBaseUrl: "http://localhost:8787" }).enabled, false, "non-HTTPS gateway configuration must fail closed");
34
+ assert.equal(readIssueBotRuntimeConfig({ ...config, turnstileSiteKey: "contains whitespace" }).enabled, false, "invalid public Turnstile configuration must fail closed");
35
+
36
+ let disabledFetches = 0;
37
+ const disabled = createIssueBotClient({ config: readIssueBotRuntimeConfig(), fetchImpl: async () => { disabledFetches += 1; } });
38
+ const disabledResult = await disabled.submit({ issue });
39
+ assert.equal(disabled.available, false);
40
+ assert.equal(disabledResult.result.status, "unavailable");
41
+ assert.equal(disabledFetches, 0, "disabled configuration must not contact an arbitrary endpoint");
42
+
43
+ const calls = [];
44
+ const statuses = [];
45
+ const client = createIssueBotClient({
46
+ config,
47
+ uuidFactory: () => uuid,
48
+ getTurnstileToken: async ({ siteKey, idempotencyKey }) => {
49
+ assert.equal(siteKey, config.turnstileSiteKey);
50
+ assert.equal(idempotencyKey, uuid, "Turnstile cData must bind the challenge to the admission UUID");
51
+ return "fresh-turnstile-token";
52
+ },
53
+ sleep: async () => {},
54
+ fetchImpl: async (url, options) => {
55
+ calls.push({ url, options });
56
+ if (options.method === "POST") {
57
+ return new Response(JSON.stringify({
58
+ ok: true,
59
+ status: "queued",
60
+ submissionId,
61
+ statusToken,
62
+ pollAfterMs: 2_500,
63
+ }), { status: 202, headers: { "content-type": "application/json" } });
64
+ }
65
+ return new Response(JSON.stringify({
66
+ ok: true,
67
+ status: "created",
68
+ submissionId,
69
+ issueUrl: "https://github.com/Firstp1ck/pi-coding-agent-forge/issues/42",
70
+ issueNumber: 42,
71
+ }), { headers: { "content-type": "application/json" } });
72
+ },
73
+ });
74
+ const completed = await client.submit({ issue, onStatus: (status) => statuses.push(status.status) });
75
+ assert.equal(completed.result.status, "created");
76
+ assert.equal(completed.result.issueNumber, 42);
77
+ assert.equal(completed.handle.refresh instanceof Function, true, "the in-memory opaque refresh handle must support manual polling");
78
+ assert.deepEqual(Object.keys(completed.handle), ["refresh"], "the refresh handle must not expose a status capability");
79
+ assert.deepEqual(statuses, ["queued", "queued", "created"], "admission and every safe poll state should be observable without raw upstream data");
80
+ assert.equal(calls.length, 2);
81
+ assert.equal(calls[0].url, "https://issue-intake.example.test/v1/submissions");
82
+ assert.equal(calls[0].options.credentials, "omit");
83
+ const sent = JSON.parse(calls[0].options.body);
84
+ assert.deepEqual(Object.keys(sent).sort(), ["idempotencyKey", "issue", "schemaVersion", "turnstileToken"]);
85
+ assert.equal(sent.idempotencyKey, uuid, "each admission uses the injected fresh UUID-v4 source");
86
+ assert.deepEqual(sent.issue, issue, "the adapter sends structured wizard state, not canonical title/body fields");
87
+ assert.equal("title" in sent.issue, false);
88
+ assert.equal("body" in sent.issue, false);
89
+ assert.equal(calls[1].options.headers.authorization, `Bearer ${statusToken}`, "only the in-memory capability authorizes status polling");
90
+
91
+ let timeoutClock = 0;
92
+ const timeoutClient = createIssueBotClient({
93
+ config,
94
+ uuidFactory: () => uuid,
95
+ getTurnstileToken: async () => "fresh-turnstile-token",
96
+ sleep: async () => { timeoutClock += 500; },
97
+ now: () => timeoutClock,
98
+ maxPollDurationMs: 500,
99
+ fetchImpl: async (_url, options) => new Response(JSON.stringify(options.method === "POST" ? {
100
+ ok: true, status: "queued", submissionId, statusToken, pollAfterMs: 2_500,
101
+ } : {
102
+ ok: true, status: "checking", submissionId, pollAfterMs: 2_500,
103
+ }), { status: options.method === "POST" ? 202 : 200, headers: { "content-type": "application/json" } }),
104
+ });
105
+ const timedOut = await timeoutClient.submit({ issue });
106
+ assert.equal(timedOut.result.status, "checking");
107
+ assert.equal(timedOut.result.timedOut, true, "polling must stop after its bounded duration and retain a manual refresh handle");
108
+ assert.equal(typeof timedOut.handle.refresh, "function");
109
+
110
+ const invalidEnvelopeClient = createIssueBotClient({
111
+ config,
112
+ uuidFactory: () => uuid,
113
+ getTurnstileToken: async () => "fresh-turnstile-token",
114
+ sleep: async () => {},
115
+ fetchImpl: async (_url, options) => new Response(JSON.stringify(options.method === "POST" ? {
116
+ ok: true, status: "queued", submissionId, statusToken, pollAfterMs: 2_500,
117
+ } : {
118
+ ok: true, status: "created", submissionId,
119
+ issueUrl: "https://github.com/Firstp1ck/pi-coding-agent-forge/issues/43", issueNumber: 43, unexpected: true,
120
+ }), { status: options.method === "POST" ? 202 : 200, headers: { "content-type": "application/json" } }),
121
+ });
122
+ assert.equal((await invalidEnvelopeClient.submit({ issue })).result.status, "unavailable", "unknown response properties must fail closed");
123
+
124
+ const abortController = new AbortController();
125
+ const abortClient = createIssueBotClient({
126
+ config,
127
+ uuidFactory: () => uuid,
128
+ getTurnstileToken: ({ signal }) => new Promise((_resolve, reject) => signal.addEventListener("abort", () => reject(new DOMException("aborted", "AbortError")), { once: true })),
129
+ fetchImpl: async () => { throw new Error("fetch must not run after Turnstile abort"); },
130
+ });
131
+ const aborted = abortClient.submit({ issue, signal: abortController.signal });
132
+ abortController.abort();
133
+ await assert.rejects(aborted, (error) => error?.name === "AbortError", "dialog-close cancellation must abort before admission");
134
+
135
+ console.log("issue-bot-client.test.mjs passed");
@@ -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");
@@ -96,8 +96,28 @@ assert.match(server, /const THINKING_LEVELS = \["off", "minimal", "low", "medium
96
96
  assert.match(html, /id="terminalTabsLayoutSelect"[\s\S]*<option value="left">Left sidebar<\/option>/, "side panel controls should expose a terminal-tabs layout selector");
97
97
  assert.match(html, /id="terminalTabsLayoutStatus"/, "terminal-tabs layout selector should expose status text");
98
98
  assert.match(html, /id="nativeCommandDialog"/, "native slash selector UI should have a dedicated dialog");
99
+ assert.match(html, /id="optionsWorkflowSetupButton"[^>]*data-command="\/workflow-setup"[^>]*hidden[\s\S]*Workflow Permission Setup/, "Common Pi options should expose catalog-gated Workflow Permission Setup");
99
100
  assert.match(html, /id="optionsSafetyGuardSetupButton"[\s\S]*data-command="\/safety-guard-setup"[\s\S]*Safety Guard Setup/, "Common Pi options should expose native Safety Guard Setup");
100
101
  assert.match(html, /id="optionsGitWorkflowSetupButton"[\s\S]*data-command="\/git-workflow-setup"[\s\S]*Guided Git Setup/, "Common Pi options should expose native Guided Git Setup");
102
+ assert.match(app, /const NATIVE_SELECTOR_COMMANDS = new Set\(\[[^\]]*"workflow-setup"[^\]]*\]\)/, "exact /workflow-setup should be a browser-native selector command");
103
+ assert.match(app, /function normalizedWorkflowPolicyList\(value\)[\s\S]*new Set[\s\S]*\.filter\(Boolean\)\)\]\.sort\(\)/, "workflow policy list fields should trim, deduplicate, and sort for the canonical preview");
104
+ assert.match(app, /function parseWorkflowPolicyVerificationCommands\(value\)[\s\S]*JSON\.parse\(line\)[\s\S]*non-empty JSON string argv array[\s\S]*commands\.push\(command\)/, "workflow verification should accept one ordered JSON argv array per nonblank line");
105
+ assert.match(app, /async function openNativeWorkflowSetupDialog\(\)[\s\S]*api\("\/api\/workflow-policy", \{ scoped: false \}\)[\s\S]*nativeSettingToggle\("Allow write"[\s\S]*nativeSettingToggle\("Allow shell"[\s\S]*nativeSettingToggle\("Allow network"[\s\S]*Exact normalized JSON preview/, "workflow setup should load the localhost policy API and render accessible permission controls plus an exact normalized preview");
106
+ assert.match(app, /Authorization ceiling[\s\S]*not blanket authority[\s\S]*Shell safety[\s\S]*not an OS sandbox[\s\S]*explicit empty-verification waiver/, "workflow setup should explain ceiling, shell sandbox, and empty-verification limitations");
107
+ assert.match(app, /nativeSettingsDirty = workflowPolicyDraftSignature\(controls\) !== initialDraftSignature/, "workflow setup edits should participate in native dialog discard protection");
108
+ assert.match(app, /addNativeCommandAction\("Reset to all deny"[\s\S]*applyDeniedWorkflowPolicyControls\(controls\)[\s\S]*controls\.write\.input\.focus\(\)/, "workflow setup should expose an explicit reset-to-all-deny action");
109
+ assert.match(app, /title: "Save reviewed workflow permission ceiling\?"[\s\S]*Exact normalized JSON:[\s\S]*if \(!reviewed\) return;[\s\S]*api\("\/api\/workflow-policy", \{[\s\S]*body: \{ policy: policyToSave, expectedRevision: data\.revision \?\? null \}[\s\S]*No agent turn was started/, "workflow setup should require explicit normalized review before revision-protected save and report transient no-turn success");
110
+ assert.match(app, /name === "workflow-setup" && !hasLoadedRpcCommand\(name\)[\s\S]*case "workflow-setup":[\s\S]*await openNativeWorkflowSetupDialog\(\)/, "workflow setup native routing should require the active Pi tab's loaded extension command catalog");
111
+ assert.match(app, /function normalizeWorkflowPolicySuggestions\(value\)[\s\S]*if \(!value \|\| typeof value !== "object" \|\| Array\.isArray\(value\)\) return empty;[\s\S]*if \(!Array\.isArray\(group\) \|\| group\.some[\s\S]*return \[\];[\s\S]*shellAllowlist: normalizeStringGroup\(value\.shellAllowlist\)[\s\S]*networkAllowlist: normalizeStringGroup\(value\.networkAllowlist\)[\s\S]*verificationCommands: normalizeVerificationGroup\(value\.verificationCommands\)/, "workflow suggestions should defensively normalize each server-provided catalog group and render no fallback for malformed groups");
112
+ assert.match(app, /const suggestions = normalizeWorkflowPolicySuggestions\(data\.suggestions\)[\s\S]*suggestionLabel: "Shell executable suggestions"[\s\S]*suggestionLabel: "Network host suggestions"[\s\S]*suggestionLabel: "Verification command suggestions"/, "all three workflow policy textareas should consume only GET-provided suggestions in labelled groups");
113
+ const appendWorkflowPolicySuggestionSource = appFunctionSource("appendWorkflowPolicySuggestion", "workflowPolicySuggestionGroup");
114
+ assert.match(appendWorkflowPolicySuggestionSource, /const separator = textarea\.value && !textarea\.value\.endsWith\("\\n"\)[\s\S]*textarea\.value = `\$\{textarea\.value\}\$\{separator\}\$\{line\}`[\s\S]*dispatchEvent\(new Event\("input", \{ bubbles: true \}\)\)[\s\S]*textarea\.focus\(\)/, "workflow suggestions should append an exact line without replacing manual text and dispatch current input tracking");
115
+ assert.doesNotMatch(appendWorkflowPolicySuggestionSource, /\.checked|permissions|api\(/, "adding a workflow suggestion must not toggle permissions or persist anything");
116
+ const workflowPolicySuggestionGroupSource = appFunctionSource("workflowPolicySuggestionGroup", "workflowPolicyTextarea");
117
+ assert.match(workflowPolicySuggestionGroupSource, /setAttribute\("role", "group"\)[\s\S]*setAttribute\("aria-labelledby", labelNode\.id\)[\s\S]*button\.type = "button"[\s\S]*button\.disabled = present\.has\(line\)[\s\S]*textarea\.addEventListener\("input", sync\)/, "workflow suggestion controls should be labelled, keyboard-native buttons that disable and resync with manual edits");
118
+ assert.match(app, /function workflowPolicyPresentSuggestionLines\(textarea, kind\)[\s\S]*normalizedWorkflowPolicyList\(textarea\.value\)[\s\S]*JSON\.parse\(line\)[\s\S]*present\.add\(JSON\.stringify\(command\)\)/, "workflow suggestion deduplication should compare normalized exact list and verification values");
119
+ assert.match(app, /const renderPreview = \(\) => \{\s*controls\.shellAllowlist\.syncSuggestions\(\);\s*controls\.networkAllowlist\.syncSuggestions\(\);\s*controls\.verificationCommands\.syncSuggestions\(\);[\s\S]*addNativeCommandAction\("Reset to all deny"[\s\S]*applyDeniedWorkflowPolicyControls\(controls\);\s*renderPreview\(\);/, "workflow preview and reset should resync suggestion availability after additions or removals");
120
+ assert.match(app, /body: \{ policy: policyToSave, expectedRevision: data\.revision \?\? null \}/, "workflow save should persist only canonical policy and revision, never suggestion metadata");
101
121
  assert.match(html, /id="nativeCommandSearch"[^>]*type="search"/, "native slash selector dialog should expose a filter box");
102
122
  assert.match(html, /id="remoteQrDialog"[\s\S]*id="remoteQrBody"[\s\S]*id="remoteQrCopyButton"/, "remote WebUI should expose a dedicated QR popup dialog");
103
123
  assert.match(html, /id="commandPaletteCloseButton"[^>]*aria-label="Close command palette"[^>]*>Close<\/button>/, "command palette should expose a visible accessible close button");
@@ -250,7 +270,10 @@ assert.match(html, /id="optionsConversationModeButton"[^>]*data-command="\/talk"
250
270
  assert.match(html, /id="conversationModeChip" class="composer-conversation-mode-chip"[\s\S]*hidden>Voice: off<\/button>/, "composer should expose a hidden-until-active conversation status chip");
251
271
  const workflowModeButtonHtml = html.match(/<button\s+id="workflowModeButton"[\s\S]*?<\/button>/)?.[0] || "";
252
272
  const workflowOverlayOpenButtonHtml = html.match(/<button\s+id="workflowOverlayOpenButton"[\s\S]*?<\/button>/)?.[0] || "";
253
- assert.match(html, /id="workflowModeControls" class="composer-publish-menu composer-workflow-mode-controls"[\s\S]*id="workflowOverlayOpenButton"[\s\S]*aria-controls="widgetArea"[\s\S]*id="workflowModeButton"/, "Workflow controls should group a restore affordance with the mode button like the app-runner helper control");
273
+ const optionsMenuHtml = html.match(/<div id="optionsMenu"[\s\S]*?<\/div>/)?.[0] || "";
274
+ assert.match(html, /id="commandSuggest"[\s\S]*?<div class="composer-input-row">\s*<div id="workflowModeControls" class="composer-workflow-mode-dock" role="group" aria-label="Workflow Mode controls"[\s\S]*id="workflowOverlayOpenButton"[\s\S]*aria-controls="widgetArea"[\s\S]*id="workflowModeButton"[\s\S]*?<\/div>\s*<div class="composer-context-tags">/, "Workflow Mode should remain directly accessible as an isolated icon-only overlay inside the prompt frame");
275
+ assert.doesNotMatch(html, /composer-workflow-mode-dock-label|>Workflow mode<\/span>/, "Workflow Mode dock should not render visible text beside the icon");
276
+ assert.doesNotMatch(optionsMenuHtml, /id="workflowModeButton"|Workflow Mode/, "Options menu should not duplicate or hide the directly accessible Workflow Mode control");
254
277
  assert.doesNotMatch(workflowOverlayOpenButtonHtml, /\stitle=/, "Workflow overlay restore should not combine a browser-native tooltip with its styled tooltip");
255
278
  assert.match(workflowModeButtonHtml, /class="composer-icon-button composer-workflow-mode-button"[\s\S]*aria-label="Enable Workflow Mode"[\s\S]*aria-pressed="false"[\s\S]*hidden[\s\S]*<svg class="composer-icon"[\s\S]*aria-hidden="true"/, "composer actions should expose a capability-gated, accessible Workflow Mode icon toggle");
256
279
  assert.doesNotMatch(workflowModeButtonHtml, /<span>Workflow<\/span>/, "Workflow Mode should use the shared icon treatment instead of a text label");
@@ -280,6 +303,17 @@ assert.match(app, /appRunnerCustomPathInput[\s\S]*Browse/, "custom app-runner pa
280
303
  assert.match(server, /APP_RUNNER_CONFIG_FILE = "\.pi-webui-runners\.json"/, "server should use a project-local custom app-runner config file");
281
304
  assert.match(server, /\/api\/app-runner-config/, "server should expose custom app-runner config endpoints");
282
305
  assert.match(server, /\/api\/app-runner-files/, "server should expose project-scoped file browsing for custom runner paths");
306
+ assert.match(app, /function renderAppRunnerSearchPathSection\(\)[\s\S]*Project discovery paths/, "app-runner popup should offer a project discovery paths section");
307
+ assert.match(app, /body\.append\(current, renderAppRunnerSearchPathSection\(\), renderAppRunnerCustomSection\(\)/, "project discovery paths should render above custom project runners");
308
+ assert.match(app, /function renderAppRunnerSearchPathSection\(\)[\s\S]*relative to the project root[\s\S]*one level deep only \(no subdirectories\)[\s\S]*\.sh, \.bash, \.zsh, \.fish, and \.py[\s\S]*Python shebang[\s\S]*uv and\/or python3\/python/, "discovery-path copy should state project scope, non-recursive scanning, and supported shell/Python runtimes");
309
+ assert.match(app, /async function saveAppRunnerSearchPaths\(searchPaths[\s\S]*api\("\/api\/app-runner-config", \{ method: "POST", body: \{ searchPaths \}[\s\S]*setAppRunnerData\(tabContext\.tabId, response\.data \|\| \{\}\)[\s\S]*renderAppRunnerControls\(\)/, "discovery paths should be saved through the app-runner config endpoint and refresh runner data immediately");
310
+ assert.match(app, /async function addAppRunnerSearchPath\(container\)[\s\S]*already configured[\s\S]*APP_RUNNER_SEARCH_PATH_LIMIT/, "adding a discovery path should reject duplicates and respect the configured path limit");
311
+ assert.match(app, /async function removeAppRunnerSearchPath\(searchPath\)[\s\S]*offerUndo\(\{/, "removing a discovery path should stay undoable like other app-runner config edits");
312
+ assert.match(app, /async function loadAppRunnerDirectoryBrowser\(relativePath = ""\)[\s\S]*\/api\/app-runner-files\?path=/, "discovery paths should be browseable through the project-scoped file browser endpoint");
313
+ assert.match(app, /function renderAppRunnerDirectoryBrowser\(\)[\s\S]*Use this directory[\s\S]*chooseAppRunnerSearchPath/, "the discovery-path browser should let users pick the browsed directory");
314
+ assert.match(app, /appRunnerSearchPathInput[\s\S]*setAttribute\("aria-label", "Project-relative directory to scan for shell and Python scripts"\)/, "the discovery-path input should expose an accessible label for every supported script category");
315
+ assert.match(app, /elements\.appRunnerInfoButton\.hidden = false;\n\s+elements\.appRunnerInfoButton\.disabled = false;/, "app-runner configuration should stay reachable when no runner is detected");
316
+ assert.match(app, /function appRunnerSourceLabel\(runner = \{\}, displayCommand = ""\)[\s\S]*from \$\{projectFile\}/, "detected runners should disambiguate their project-relative source path");
283
317
  assert.doesNotMatch(html, /<code>\/release-(?:npm|aur)<\/code>/, "Publish menu should not show slash command names as option labels");
284
318
  assert.doesNotMatch(html, /data-tooltip="[^"]*\/release-(?:npm|aur)/, "Publish tooltip should not show slash command names");
285
319
  assert.match(html, /id="steerButton"[\s\S]*?data-tooltip="Steer usage:/, "Steer should explain type-first usage in a tooltip");
@@ -444,6 +478,11 @@ assert.match(css, /\.release-aur-widget \{[\s\S]*?border-color/, "release-aur ou
444
478
  assert.match(css, /\.app-runner-widget \{[\s\S]*?border-color/, "app runner output should render as a specialized Web UI widget variant");
445
479
  assert.match(css, /\.composer-app-runner-info-button \{[\s\S]*?position:\s*absolute;[\s\S]*?right:\s*-0\.48rem;[\s\S]*?flex:\s*none;[\s\S]*?pointer-events:\s*none/, "app runner info help should float over Run without consuming toolbar width");
446
480
  assert.match(css, /\.composer-app-runner-menu\.has-runners:hover \.composer-app-runner-info-button,[\s\S]*?\.composer-app-runner-info-button:focus-visible \{[\s\S]*?opacity:\s*1;[\s\S]*?pointer-events:\s*auto;[\s\S]*?transform:\s*translateY\(0\) scale\(1\)/, "app runner info help should reveal without reflowing neighboring composer buttons");
481
+ assert.match(css, /\.composer-app-runner-menu\.no-runners \.composer-app-runner-info-button,/, "app runner configuration help should stay visible when no runner is detected");
482
+ assert.match(css, /\.workflow-policy-suggestions \{[\s\S]*display:\s*flex;[\s\S]*flex-wrap:\s*wrap;[\s\S]*\.workflow-policy-suggestion:focus-visible \{[\s\S]*outline:/, "workflow policy suggestion buttons should wrap and expose a visible keyboard focus state");
483
+ assert.match(css, /@media \(max-width: 720px\)[\s\S]*\.workflow-policy-suggestions \{[\s\S]*flex-direction:\s*column;[\s\S]*\.workflow-policy-suggestion \{[\s\S]*width:\s*100%;[\s\S]*min-height:\s*44px;/, "workflow policy suggestions should stack into full-width touch targets on narrow screens");
484
+ assert.match(css, /\.app-runner-directory-row \{[\s\S]*?grid-template-columns:\s*minmax\(0, 1fr\) auto/, "discovery-path browser rows should pair navigation with a selection action");
485
+ assert.match(css, /@media \(max-width: 720px\)[\s\S]*?\.app-runner-directory-row,[\s\S]*?grid-template-columns:\s*1fr;/, "discovery-path browser rows should stack on narrow mobile widths");
447
486
  assert.match(css, /\.widget-area:has\(\.app-runner-live-widget \.release-npm-output-details\[open\]\)/, "live app runner output should reserve the same fixed top widget slot as release output");
448
487
  assert.match(css, /\.widget-area \.widget:not\(\.todo-widget\):not\(\.release-npm-widget\)/, "mobile widget filtering should keep release workflow output visible");
449
488
  assert.match(css, /\.message\.warn \.message-role \{ color: var\(--ctp-yellow\); \}/, "warning-level command output should be visually distinct");
@@ -462,9 +501,9 @@ assert.match(css, /\.action-feedback-controls \{[\s\S]*?opacity:\s*0/, "action r
462
501
  assert.match(css, /\.action-feedback-controls:hover,[\s\S]*?\.action-feedback-controls:focus-within/, "action reactions should reveal on hover or keyboard focus");
463
502
  assert.match(css, /\.action-feedback-controls:not\(:hover\):not\(:focus-within\) \.action-feedback-button/, "hidden action reactions should not expose button hit targets until the hover area is reached");
464
503
  assert.match(css, /\.action-feedback-button\.feedback-question\.active/, "question-mark reaction should have selected styling");
465
- assert.match(css, /\.composer-row button\[data-tooltip\]::after/, "composer button tooltips should be shared across Git, Steer, and Follow-up buttons");
466
- assert.match(css, /\.composer-row \.composer-workflow-mode-button\[data-tooltip\]::after \{[\s\S]*?left:\s*0;[\s\S]*?right:\s*auto;[\s\S]*?max-width:\s*min\(18rem, calc\(100vw - 2rem\)\);/, "Workflow Mode tooltip should open rightward and stay narrow enough to remain inside the outer chat frame");
467
- assert.match(css, /\.composer-row \.composer-workflow-mode-button\[data-tooltip\]::before \{[\s\S]*?left:\s*50%;[\s\S]*?right:\s*auto;[\s\S]*?translate\(-50%, 0\.24rem\)/, "Workflow Mode tooltip arrow should stay centered on the icon while its panel opens rightward");
504
+ assert.match(css, /\.composer-row button\[data-tooltip\]::after/, "composer-row button tooltips should be shared across Git, Steer, and Follow-up buttons");
505
+ assert.doesNotMatch(css, /\.composer-row \.composer-workflow-mode-button\[data-tooltip\]/, "isolated Workflow Mode dock should not retain composer-row pseudo-tooltip overrides");
506
+ assert.match(css, /\.composer-input-row \.composer-workflow-mode-dock button\[data-tooltip\]::before,\s*\.composer-input-row \.composer-workflow-mode-dock button\[data-tooltip\]::after \{\s*display:\s*none;/, "Workflow Mode dock controls should suppress inherited pseudo-tooltips and keep only their floating styled tooltip");
468
507
  assert.match(css, /\.composer-row \.composer-git-button\[data-tooltip\]::after \{[\s\S]*?left:\s*0;[\s\S]*?right:\s*auto;/, "Git workflow tooltip should open rightward so it is not clipped off the left edge");
469
508
  assert.match(css, /\.composer-row button\[data-tooltip\]\.tooltip-open::after/, "composer button tooltips should be triggerable from JS for empty mobile taps");
470
509
  assert.match(css, /\.composer-row button\[data-tooltip\]:hover,[\s\S]*?\.composer-input-row button\[data-tooltip\]\.tooltip-open \{\n\s+z-index:\s*40;/, "active composer tooltip triggers should stack above context tags and adjacent controls");
@@ -800,14 +839,16 @@ assert.match(app, /async function saveSubagentLaunchSlotConfig[\s\S]*scope: suba
800
839
  assert.match(app, /const subagentLaunchSlotReloadTabs = new Set\(\)[\s\S]*subagentLaunchSlotReloadTabs\.add\(activeTabId\)[\s\S]*subagentLaunchSlotReloadTabs\.delete\(activeTabId\)/, "reload-required reminders should survive tab switches until that tab is actually reloaded");
801
840
  const subagentOverviewRefreshSource = appFunctionSource("refreshSubagents", "scheduleRefreshSubagents");
802
841
  assert.doesNotMatch(subagentOverviewRefreshSource, /subagentLaunchSlot/, "live subagent polling must not recreate or reset the launch-slot editor");
803
- assert.match(app, /function renderSubagentGateAttempt\(attempt\)[\s\S]*failureKind[\s\S]*function renderSubagentGate\(gate\)[\s\S]*qualifyingSuccesses/, "frontend should render failure-classified attempts and gate quorum");
842
+ assert.match(app, /function renderSubagentGateAttempt\(attempt\)[\s\S]*failureKind[\s\S]*function renderSubagentGate\(tab, gate\)[\s\S]*qualifyingSuccesses/, "frontend should render failure-classified attempts and gate quorum");
804
843
  assert.match(helper, /async function enrichAsyncSubagentAgent\(run, agent, statusByDir\)[\s\S]*status\.json[\s\S]*agent\.model = subagentModel\(step\.model\)[\s\S]*agent\.thinking = subagentThinking\(step\.thinking\)/, "WebUI helper should enrich async children from effective lifecycle model and reasoning metadata");
805
844
  assert.match(helper, /SUBAGENT_GATE_UPDATE_EVENT[\s\S]*function publicSubagentGates\(\)[\s\S]*failureKind[\s\S]*gates = publicSubagentGates\(\)/, "WebUI helper should publish bounded retry-gate lifecycle data");
806
845
  assert.match(extension, /registerSubagentGate\(pi\)[\s\S]*session_shutdown[\s\S]*subagentGate\.dispose\(\)/, "the WebUI package extension should own the retry-gate tool lifecycle without another extension package");
807
846
  assert.match(server, /function normalizeWebuiSubagentPayload\(value\)[\s\S]*model: normalizeWebuiSubagentText\(rawAgent\.model, 240\)[\s\S]*thinking: normalizeWebuiSubagentText\(rawAgent\.thinking, 40\)/, "server should bound model and reasoning metadata in the cross-tab overview");
808
847
  assert.match(server, /WEBUI_SUBAGENT_GATE_LIMIT[\s\S]*rawGate\.attempts[\s\S]*failureKind: normalizeWebuiSubagentText\(rawAttempt\.failureKind, 80\)[\s\S]*totalGates/, "server should bound retry gates and expose their cross-tab total");
809
848
  assert.match(server, /function normalizeWebuiSubagentOutput\(value, selection\)[\s\S]*model: normalizeWebuiSubagentText\(rawAgent\.model, 240\)[\s\S]*thinking: normalizeWebuiSubagentText\(rawAgent\.thinking, 40\)/, "server should preserve model and reasoning metadata in selected child output");
849
+ assert.match(server, /function normalizeWebuiSubagentSource\(value\) \{[\s\S]*value === "foreground" \|\| value === "workflow"[\s\S]*function normalizeWebuiSubagentPayload\(value\)[\s\S]*source: normalizeWebuiSubagentSource\(rawRun\.source\)[\s\S]*function normalizeWebuiSubagentOutput\(value, selection\)[\s\S]*source: normalizeWebuiSubagentSource\(selection\.run\?\.source \|\| value\.source\)/, "server should preserve workflow source in overview and selected-output normalization");
810
850
  assert.match(app, /function subagentExecutionFacts\(agent = \{\}\)[\s\S]*model \$\{model \|\| "unknown"\}[\s\S]*reasoning \$\{thinking \|\| "unknown"\}/, "subagent metadata should use one honest model/reasoning formatter with unknown fallbacks");
851
+ assert.match(app, /function subagentSourceLabel\(source = ""\) \{[\s\S]*source === "foreground" \|\| source === "workflow"[\s\S]*function subagentOverlayStateFacts\(data = subagentOverlayData\)[\s\S]*subagentSourceLabel\(data\?\.source \|\| subagentOverlaySelection\?\.run\?\.source\)[\s\S]*function renderSubagentTerminalView\(\)[\s\S]*subagentSourceLabel\(view\.data\?\.source \|\| view\.run\?\.source\)[\s\S]*function renderSubagentTerminalTab\(view\)[\s\S]*subagentSourceLabel\(view\.data\?\.source \|\| view\.run\?\.source\)[\s\S]*function renderSubagentAgent\(tab, run, agent\)[\s\S]*subagentSourceLabel\(run\?\.source\)/, "one source-label helper should keep workflow rows, overlays, and virtual tabs honest");
811
852
  assert.match(app, /function renderSubagentAgent\(tab, run, agent\)[\s\S]*\.\.\.subagentExecutionFacts\(agent\)/, "Subagents side-panel rows should show model and reasoning effort");
812
853
  assert.match(app, /function subagentOverlayStateFacts\(data = subagentOverlayData\)[\s\S]*\.\.\.subagentExecutionFacts\(agent\)/, "subagent overlays should show model and reasoning effort");
813
854
  assert.match(app, /function renderSubagentTerminalView\(\)[\s\S]*\.\.\.subagentExecutionFacts\(agent\)/, "dedicated subagent terminal views should show model and reasoning effort");
@@ -978,6 +1019,10 @@ assert.match(css, /\.footer-branch-option-row \{[\s\S]*?grid-template-columns:\s
978
1019
  assert.match(css, /\.footer-branch-advanced-action:disabled \{[\s\S]*?cursor:\s*not-allowed/, "advanced branch switch action should visibly disable occupied branches");
979
1020
  assert.match(css, /\.footer-worktree \.footer-meta-value,[\s\S]*?\.footer-tui-worktree \{[\s\S]*?color:\s*var\(--ctp-green\)/, "worktree footer chips should have distinct green styling");
980
1021
  assert.match(css, /\.workspace-dashboard-action\.worktree \{[\s\S]*?color:\s*var\(--ctp-green\)/, "workspace dashboard should style the branch worktree action distinctly");
1022
+ assert.match(app, /const summary = make\("div", "workspace-dashboard-summary-row"\);[\s\S]*summary\.append\(make\("span", "workspace-dashboard-kicker", "Workspace"\), meta\);[\s\S]*const identity = make\("div", "workspace-dashboard-identity"\);[\s\S]*identity\.append\(heading, cwd\);/, "workspace dashboard should group status and identity into two compact rows");
1023
+ assert.match(css, /\.workspace-dashboard \{[\s\S]*?gap:\s*0\.52rem;[\s\S]*?padding:\s*0\.62rem 0\.78rem 0\.56rem;/, "workspace dashboard shell should use compact desktop spacing");
1024
+ assert.match(css, /\.workspace-dashboard-metric \{[\s\S]*?min-height:\s*3\.75rem;[\s\S]*?padding:\s*0\.48rem 0\.52rem;/, "workspace dashboard metrics should remain readable without tall cards");
1025
+ assert.match(css, /@media \(max-width: 720px\) \{[\s\S]*?\.workspace-dashboard-metrics \{ grid-template-columns: repeat\(2, minmax\(0, 1fr\)\); \}[\s\S]*?@media \(max-width: 480px\) \{\s*\.workspace-dashboard-metrics \{ grid-template-columns: 1fr; \}/, "workspace dashboard metrics should stay compact on tablets and stack on narrow phones");
981
1026
  assert.match(app, /async function createFooterGitBranchWorktree\(branch = footerBranchCreateName\(\)[\s\S]*chooseGitWorktreeBase\(branchName\)[\s\S]*api\("\/api\/git-worktrees", \{ method: "POST", body: \{ branchName, baseRef, sessionMode: "fork-current", openTab: true \}/, "new footer branch worktrees should ask for and submit the selected base ref");
982
1027
  assert.match(app, /async function openFooterGitWorktree\(path,[\s\S]*api\("\/api\/git-worktrees\/open", \{ method: "POST", body: \{ path: worktreePath, sessionMode: "fork-current", openTab: true \}/, "existing worktree actions should call the worktree open endpoint");
983
1028
  assert.match(app, /elements\.newTabWorktreeButton\?\.addEventListener\("click", \(\) => openBranchWorktreePicker\(\)\)/, "new-tab menu branch worktree item should open the picker");
@@ -1048,8 +1093,10 @@ assert.match(app, /const WORKFLOW_MODE_RPC_WIDGET_KEY = "workflow-mode:rpc"[\s\S
1048
1093
  assert.match(app, /function workflowModeStateFromRpcPayload\(lines\)[\s\S]*payload\?\.type !== WORKFLOW_MODE_RPC_PAYLOAD_TYPE[\s\S]*normalizeWorkflowModeState/, "frontend should strictly validate structured Workflow Mode payloads");
1049
1094
  assert.match(app, /const workflowModeByTab = new Map\(\)/, "frontend should track Workflow Mode independently for each Pi tab");
1050
1095
  assert.match(app, /function renderWorkflowModeControls\(\)[\s\S]*workflow-mode-active[\s\S]*workflowModeButton[\s\S]*workflowModeChip/, "frontend should render toggle, active chip, and composer state from extension status");
1051
- assert.match(app, /workflowModeButton\.toggleAttribute\("aria-busy", pending\)[\s\S]*pending\s*\? "Updating JavaScript Workflow Mode for this Pi tab\."/, "Workflow Mode icon should preserve pending-state feedback through busy semantics and its accessible tooltip");
1052
- assert.match(app, /applyStyledTooltip\(elements\.workflowModeButton, tooltip, \{ ariaLabel: true, align: "start", floating: false \}\)/, "Workflow Mode should use only its composer pseudo-element tooltip instead of also binding the floating tooltip");
1096
+ assert.match(app, /if \(pending\) elements\.workflowModeButton\.setAttribute\("aria-busy", "true"\);[\s\S]*else elements\.workflowModeButton\.removeAttribute\("aria-busy"\);[\s\S]*pending\s*\? "Updating JavaScript Workflow Mode for this Pi tab\."/, "Workflow Mode icon should expose valid pending busy semantics and accessible tooltip feedback");
1097
+ assert.match(app, /workflowOverlayOpenButton\.setAttribute\("aria-expanded", openAvailable \? "false" : "true"\)/, "Workflow overlay restore should keep disclosure state synchronized while visible or hidden");
1098
+ assert.match(app, /applyStyledTooltip\(elements\.workflowOverlayOpenButton, "Open the minimized workflow overlay\.", \{ ariaLabel: true, align: "end" \}\)/, "isolated Workflow restore should use the viewport-clamped floating tooltip");
1099
+ assert.match(app, /applyStyledTooltip\(elements\.workflowModeButton, tooltip, \{ ariaLabel: true, align: "end" \}\)/, "isolated Workflow Mode should use the viewport-clamped floating tooltip");
1053
1100
  assert.match(app, /function applyStyledTooltip\([\s\S]*if \(options\.floating !== false\) bindStyledTooltipEvents\(node\)/, "styled tooltip setup should allow controls with native scoped tooltip CSS to opt out of the floating tooltip layer");
1054
1101
  assert.match(app, /async function setWorkflowModeEnabled\(enabled\)[\s\S]*`\/\$\{commandName\} mode \$\{enabled \? "on" : "off"\}`/, "Workflow Mode toggle should send canonical extension commands rather than rewrite prompts locally");
1055
1102
  assert.match(app, /if \(statusKey === WORKFLOW_MODE_STATUS_KEY\) handleWorkflowModeStatus/, "Workflow Mode should synchronize from replayable extension setStatus events");
@@ -1063,7 +1110,8 @@ assert.match(app, /confirmMessage && !window\.confirm\(confirmMessage\)/, "destr
1063
1110
  assert.match(app, /const workflowInspectorByTab = new Map\(\)[\s\S]*workflowInspectorSelectionByTab = new Map\(\)[\s\S]*workflowInspectorMinimizedByTab = new Set\(\)/, "Workflow inspector run, selection, and minimized state should be per tab");
1064
1111
  assert.match(app, /const workflowTerminalScrollByTab = new Map\(\);\s*const workflowSubprocessMinimizedByTab = new Set\(\);\s*const workflowOverlayMinimizedByTab = new Set\(\);/, "Workflow subprocess and complete-overlay minimize state should be isolated per browser tab");
1065
1112
  assert.match(app, /function setWorkflowOverlayMinimized\(minimized\)[\s\S]*workflowOverlayMinimizedByTab\.(?:add|delete)[\s\S]*renderWidgets\(\)[\s\S]*workflowOverlayOpenButton[\s\S]*workflow-overlay-close-button[\s\S]*focus\(\{ preventScroll: true \}\)/, "complete Workflow overlay minimize and restore should survive rerenders and move focus to the replacement control");
1066
- assert.match(app, /function renderWidgets\(\)[\s\S]*if \(!workflowOverlayIsMinimized\(\)\)[\s\S]*attachWorkflowOverlayCloseButton\(workflowInspectorWidget \|\| workflowSubprocessWidget\)[\s\S]*renderWorkflowOverlayControls\(\)/, "the complete Workflow overlay should be omitted while minimized and expose one close control while open");
1113
+ assert.match(app, /function workflowOverlayHasContent\(\)[\s\S]*getWidgetLines\("workflow"\)\.length[\s\S]*getWidgetLines\("workflow:subprocess"\)/, "the Workflow restore affordance should remain available when only the legacy status/details widget remains");
1114
+ assert.match(app, /function renderWidgets\(\)[\s\S]*if \(!workflowOverlayIsMinimized\(\)\)[\s\S]*attachWorkflowOverlayCloseButton\(workflowInspectorWidget \|\| workflowSubprocessWidget\)[\s\S]*for \(const \[key, value\] of widgets\)[\s\S]*widgetFeatureId === "workflows" && workflowOverlayIsMinimized\(\)/, "closing the complete Workflow overlay should omit specialized surfaces and the legacy workflow status/details widget");
1067
1115
  assert.match(app, /workflowOverlayOpenButton\?\.addEventListener\("click", \(\) => setWorkflowOverlayMinimized\(false\)\)/, "the Workflow-button restore affordance should reopen the complete overlay");
1068
1116
  assert.match(app, /function workflowInspectorSetMinimized\(minimized\)[\s\S]*workflowInspectorMinimizedByTab\.(?:add|delete)[\s\S]*renderWidgets\(\)[\s\S]*requestAnimationFrame[\s\S]*workflow-inspector-minimize-button[\s\S]*focus\(\{ preventScroll: true \}\)/, "Workflow inspector minimize state should survive rerenders and restore focus to the replacement control");
1069
1117
  assert.match(app, /function renderWorkflowInspectorWidget\(\)[\s\S]*workflow-inspector-body[\s\S]*workflow-inspector-minimize-button[\s\S]*minimized \? "Restore" : "Minimize"[\s\S]*minimizeButton\.type = "button"[\s\S]*aria-controls[\s\S]*aria-expanded[\s\S]*aria-label[\s\S]*if \(minimized\) return node/, "Workflow inspector should expose an accessible minimize and restore disclosure control");
@@ -1076,9 +1124,18 @@ assert.match(css, /\.workflow-inspector-layout \{[\s\S]*grid-template-columns:[\
1076
1124
  assert.match(css, /\.workflow-inspector-widget\.minimized,[\s\S]*\.workflow-subprocess-widget\.minimized \{[\s\S]*\.workflow-inspector-minimize-button,[\s\S]*\.workflow-subprocess-minimize-button/, "Workflow inspector and subprocess widgets should share visible minimized-state toggle styling");
1077
1125
  assert.match(css, /\.workflow-subprocess-widget\.minimized > \.release-npm-header \{[\s\S]*?padding-bottom:\s*0;[\s\S]*?border-bottom:\s*0;/, "minimized Workflow subprocess output should collapse its header divider and extra spacing");
1078
1126
  assert.match(css, /\.terminal-tab-workflow-indicator \{[\s\S]*color: var\(--ctp-mauve\)/, "inactive-tab Workflow badges should have a distinct accessible style");
1079
- assert.match(css, /\.composer-workflow-mode-button \{[\s\S]*?min-width:\s*2\.9rem;/, "Workflow Mode icon should use the shared composer icon-button width");
1127
+ const workflowModeDockCss = css.match(/\.composer-workflow-mode-dock \{[^}]*\}/)?.[0] || "";
1128
+ assert.match(workflowModeDockCss, /position:\s*absolute;[\s\S]*?top:\s*-0\.48rem;[\s\S]*?right:\s*3\.55rem;[\s\S]*?margin:\s*0;[\s\S]*?padding:\s*0;/, "Workflow Mode dock should overlay the prompt frame without adding composer height");
1129
+ assert.doesNotMatch(workflowModeDockCss, /border(?:-radius)?:|background:|box-shadow:/, "icon-only Workflow Mode control should not retain a decorative outer box");
1130
+ assert.match(css, /body:not\(\.mobile-keyboard-open\) \.composer-input-row:has\(\.composer-workflow-mode-dock:not\(\[hidden\]\)\) #promptInput \{[\s\S]*?padding-right:\s*3\.35rem;/, "visible icon-only Workflow dock should reserve prompt text space without adding a layout row or a hidden-keyboard gutter");
1131
+ assert.match(css, /body:not\(\.mobile-keyboard-open\) \.composer-input-row:has\(\.composer-workflow-mode-dock:not\(\[hidden\]\)\) \.composer-context-tags \{[\s\S]*?max-width:\s*calc\(100% - 7\.5rem\);/, "visible icon-only Workflow dock should reserve top-border space from context tags");
1132
+ assert.doesNotMatch(css, /\.composer-workflow-mode-dock-label/, "icon-only Workflow dock should not retain obsolete label styling");
1133
+ assert.match(css, /body:not\(\.mobile-keyboard-open\)[\s\S]*?\.composer-context-tags \{ max-width:\s*calc\(100% - 6\.5rem\); \}/, "compact dock should reserve mobile context-tag space only while the keyboard is closed");
1134
+ assert.match(css, /\.composer-workflow-mode-dock \.composer-workflow-overlay-open-button \{\s*top:\s*-0\.2rem;\s*right:\s*-0\.2rem;/, "mobile Workflow restore badge should not protrude above the compact composer");
1135
+ assert.match(css, /body\.mobile-keyboard-open \.composer-workflow-mode-dock \{ display:\s*none !important; \}/, "Workflow Mode dock should leave the compact mobile typing surface uncluttered");
1136
+ assert.match(css, /\.composer-workflow-mode-dock \.composer-workflow-mode-button \{[\s\S]*?width:\s*2\.25rem;[\s\S]*?min-height:\s*2\.25rem;/, "overlay Workflow icon should use a compact deliberate target inside its isolated dock");
1080
1137
  assert.match(css, /\.composer-workflow-mode-button\.active,[\s\S]*aria-pressed="true"/, "active Workflow Mode toggle should have persistent pressed styling");
1081
- assert.match(css, /\.composer-workflow-mode-controls\.has-open-control \{[^}]*min-width:\s*1\.95rem;[^}]*min-height:\s*1\.95rem;/, "Workflow restore should retain an anchored box even if the Workflow Mode button is unavailable");
1138
+ assert.match(css, /\.composer-workflow-mode-dock\.has-open-control \{[^}]*min-width:\s*1\.95rem;[^}]*min-height:\s*2\.35rem;/, "Workflow restore should retain an anchored dock even if the Workflow Mode button is unavailable");
1082
1139
  assert.match(css, /\.composer-workflow-overlay-open-button \{[\s\S]*position:\s*absolute;[\s\S]*border-radius:\s*999px;[\s\S]*\.workflow-overlay-close-button \{/, "Workflow restore should use a visible helper badge and the complete overlay should expose a distinct close action");
1083
1140
  assert.match(css, /\.composer\.workflow-mode-active[\s\S]*body\.workflow-mode-active \.composer::before/, "active Workflow Mode should visibly accent the composer");
1084
1141
 
@@ -1121,7 +1178,7 @@ assert.match(app, /async function startVoiceConversationLoop\(tabId = activeTabI
1121
1178
  assert.match(app, /function isLocalhostWebui\(\)[\s\S]*127\.0\.0\.1/, "remote-consent detection should treat localhost as implicitly consented");
1122
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");
1123
1180
  assert.match(app, /function speakableTextFromMarkdown\(text\)[\s\S]*Code block omitted/, "spoken text should strip code blocks and markdown syntax");
1124
- assert.match(app, /case "agent_end":[\s\S]*handleVoiceConversationTurnEnd\(tabContext\)/, "agent_end should hand the finished turn to the voice loop");
1181
+ assert.match(app, /case "agent_settled":[\s\S]*handleVoiceConversationTurnEnd\(tabContext\)/, "agent_settled should hand the fully finished turn to the voice loop");
1125
1182
  assert.match(app, /case "tool_execution_start":[\s\S]*setAssistantActivity\(\{ toolRunning: true \}\)/, "tool execution start should mark the voice loop tool phase");
1126
1183
  assert.match(app, /case "tool_execution_end":[\s\S]*setAssistantActivity\(\{ toolRunning: false \}\)/, "tool execution end should clear the voice loop tool phase");
1127
1184
  assert.match(html, /id="remoteMicStreamingConsentButton"[^>]*disabled>Allow remote microphone streaming</, "remote mic consent button should exist, start disabled, and use action-specific copy");
@@ -1361,14 +1418,15 @@ assert.match(app, /case "tool_execution_update":[\s\S]*?handleToolExecutionUpdat
1361
1418
  assert.match(app, /case "auto_retry_start":[\s\S]*?addTransientMessage\(\{ role: "warn", title: "auto retry"/, "auto-retry starts should be transcript-visible warnings");
1362
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");
1363
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");
1364
- assert.match(app, /function queueAgentDoneBrowserNotification[\s\S]*?setTimeout\([\s\S]*?if \(isAutoRetryingTab\(tabId\)\) return;[\s\S]*?AGENT_DONE_NOTIFICATION_RETRY_GRACE_MS/, "agent-done notifications should wait briefly so imminent auto-retry events can cancel them");
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");
1365
1422
  assert.match(app, /case "extension_error":[\s\S]*?addTransientMessage\(\{ role: "error", title: "extension error"/, "extension errors should be transcript-visible error cards");
1366
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");
1367
1424
  assert.match(app, /function markContextUsageUnknownAfterCompaction\(/, "compaction should have a dedicated context-usage invalidation helper");
1368
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");
1369
1426
  assert.match(app, /function footerStatsContextDisplay[\s\S]*?contextUsageUnknownAfterCompaction\(\)[\s\S]*?unknownFooterContextText/, "fallback footer context should show an unknown value after compaction invalidates usage");
1370
- assert.match(app, /case "agent_end":[\s\S]*?clearRunIndicatorActivity\(\)/, "agent completion should remove the active agent transcript indicator");
1371
- assert.match(app, /case "agent_end":[\s\S]*?notifyAgentDone\(event\.tabId \|\| activeTabId/, "agent completion should trigger optional done notifications");
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");
1372
1430
  assert.match(app, /function getPathTrigger\(\)/, "prompt composer should detect @ file\/path reference triggers");
1373
1431
  assert.match(app, /api\(`\/api\/path-suggestions\?query=\$\{encodeURIComponent\(trigger\.query\)\}`/, "@ reference suggestions should load from the server as the user types");
1374
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");
@@ -1417,6 +1475,8 @@ assert.match(app, /function setBusyPromptBehaviorMenuOpen\(open,[\s\S]*aria-expa
1417
1475
  assert.match(app, /busyPromptBehaviorTag\?\.addEventListener\("click"[\s\S]*setBusyPromptBehaviorMenuOpen\(nextOpen\)/, "clicking the busy prompt behavior tag should toggle its dropdown");
1418
1476
  assert.match(app, /busyPromptBehaviorMenu\?\.addEventListener\("click"[\s\S]*chooseBusyPromptBehaviorFromMenu/, "busy prompt behavior dropdown choices should update the setting");
1419
1477
  assert.match(app, /setBusyPromptBehavior\(controls\.busyBehavior\.select\.value\)/, "native settings should update the busy prompt behavior tag immediately");
1478
+ assert.match(app, /const initialRuntime = JSON\.stringify\(\{[\s\S]*?busyBehavior: busyPromptBehavior,[\s\S]*?\}\);/, "native settings should snapshot the defined busy prompt behavior before rendering Apply");
1479
+ assert.match(app, /applyButton = addNativeCommandAction\("Apply"/, "native settings should render the Apply action after initializing the runtime snapshot");
1420
1480
  assert.match(app, /sendPromptFromModeButton\("steer", elements\.steerButton\)/, "Steer should show tooltip instead of silently doing nothing when input is empty");
1421
1481
  assert.match(app, /sendPromptFromModeButton\("follow-up", elements\.followUpButton\)/, "Follow-up should show tooltip instead of silently doing nothing when input is empty");
1422
1482
  assert.match(app, /async function sendBtwQuestion\(question,[\s\S]*?`\/btw \$\{cleanQuestion\}`[\s\S]*?await sendPrompt\("prompt", message, \{ targetTabId, throwOnError: true \}\)/, "/btw helper should send text as an ephemeral slash command");
@@ -1429,6 +1489,9 @@ assert.match(app, /async function sendBtwPromptFromButton\(\)[\s\S]*?if \(!quest
1429
1489
  assert.match(app, /function renderBtwComposerForm\(\)[\s\S]*?form\.requestSubmit\(\)[\s\S]*?sendBtwQuestion\(question\)/, "/btw widget input should submit each message as a /btw trigger");
1430
1490
  assert.match(app, /function makeBtwTransferIcon\(\)[\s\S]*?class", "btw-transfer-icon"[\s\S]*?function transferBtwContextToMain\(button, \{ transferMode = "full" \} = \{\}\)[\s\S]*?`\/btw-transfer \$\{encoded\}`[\s\S]*?streamingBehavior: "steer"[\s\S]*?Summarize & Steer/, "/btw widget should expose full-context and summary transfer actions that send steering context during active runs");
1431
1491
  assert.match(app, /async function sendPrompt\(kind = "prompt", explicitMessage, \{ targetTabId = activeTabId, throwOnError = false, streamingBehavior \} = \{\}\)[\s\S]*?if \(targetWasBusy\) body\.streamingBehavior = streamingBehavior \|\| busyBehavior/, "prompt sending should support a per-call streaming behavior override");
1492
+ assert.match(app, /function appendOptimisticUserPrompt\([\s\S]*?role: "user"[\s\S]*?transient: true/, "new prompts should be appended to the transcript optimistically before routing finishes");
1493
+ assert.match(app, /if \(startsRun\) \{\n\s+markTabWorkingLocally\(targetTabId\);\n\s+if \(isCurrentTabContext\(tabContext\)\) \{\n\s+appendOptimisticUserPrompt\(originalMessage, attachments\.length\);\n\s+setRunIndicatorActivity\(attachments\.length \? "Preparing attachments for routing…" : "Routing prompt to the selected agent…"\);/, "new runs should show the prompt and routing progress immediately in the target tab");
1494
+ assert.match(app, /if \(startsRun && isCurrentTabContext\(tabContext\)\) setRunIndicatorActivity\("Routing complete; starting agent…"\);/, "prepared prompts should transition from routing to agent-start progress before dispatch");
1432
1495
  assert.match(app, /function runPublishWorkflow\(command\)[\s\S]*?sendPrompt\("prompt", `\/\$\{resolvedCommandName\}\$\{commandRest\}`\)/, "Publish workflows should send resolved slash commands directly without replacing the draft");
1433
1496
  assert.match(app, /async function runNativeCommandMenu\(command\)[\s\S]*?await handleNativeSlashSelectorCommand\(command\)/, "skills/tools command menu should open native selector dialogs directly");
1434
1497
  assert.match(app, /async function runNativeCommandMenu\(command\)[\s\S]*?sendPrompt\("prompt", command\)/, "generic native command menu should fall back to slash-command prompt execution");
@@ -1465,9 +1528,9 @@ assert.match(server, /url\.pathname === "\/api\/safety-guard\/config" && req\.me
1465
1528
  assert.match(app, /async function openNativeGitWorkflowSetupDialog\([\s\S]*\/api\/git-workflow\/preferences/, "Web UI should implement Guided Git Setup with the persisted preferences API");
1466
1529
  assert.match(app, /async function sendPrompt\(kind = "prompt", explicitMessage, \{ targetTabId = activeTabId, throwOnError = false, streamingBehavior \} = \{\}\)/, "prompt sending should accept direct messages that bypass the input field and optional target tab");
1467
1530
  assert.match(app, /const rawMessage = usesPromptInput \? elements\.promptInput\.value : explicitMessage/, "direct prompt sends should not read the input textarea");
1468
- assert.match(app, /if \(usesPromptInput\) \{[\s\S]*?if \(targetStillActive\) \{[\s\S]*?elements\.promptInput\.value = "";/, "direct prompt sends should preserve the input textarea draft");
1531
+ assert.match(app, /function clearPromptInputForRouting\(\{ usesPromptInput,[\s\S]*?if \(!usesPromptInput\) return;/, "direct prompt sends should preserve the input textarea draft");
1469
1532
  assert.match(app, /make\("button", "command-item"\)[\s\S]*?sendPrompt\("prompt", `\/\$\{command\.name\}`\)/, "side-panel command clicks should send the slash command directly");
1470
- assert.match(app, /const NATIVE_SELECTOR_COMMANDS = new Set\(\["model", "settings", "safety-guard-setup", "git-workflow-setup", "theme", "fork", "clone", "name", "resume", "tree", "login", "logout", "scoped-models", "tools", "skills"\]\)/, "frontend should route native slash commands, including safety and Guided Git setup, into selector UIs");
1533
+ assert.match(app, /const NATIVE_SELECTOR_COMMANDS = new Set\(\["model", "settings", "workflow-setup", "safety-guard-setup", "git-workflow-setup", "theme", "fork", "clone", "name", "resume", "tree", "login", "logout", "scoped-models", "tools", "skills"\]\)/, "frontend should route native slash commands, including workflow permission, safety, and Guided Git setup, into selector UIs");
1471
1534
  assert.match(app, /async function handleNativeSlashSelectorCommand\(message/, "frontend should intercept exact native slash commands before prompt forwarding");
1472
1535
  assert.match(app, /kind === "prompt" && attachments\.length === 0 && await handleNativeSlashSelectorCommand/, "prompt sending should open native selector dialogs before marking a run active");
1473
1536
  assert.match(app, /function openNativeModelSelector\(\)[\s\S]*?nativeCommandApi\("\/api\/models"\)/, "native /model selector should load models through the active tab API");
@@ -43,6 +43,7 @@ assert.equal(isLocalRequest(remoteReq), false);
43
43
  assert.throws(() => requireLocalhost(remoteReq, "blocked"), (error) => error.statusCode === 403);
44
44
  assert.throws(() => requireLocalhostRoute(remoteReq, "/api/update"), (error) => error.statusCode === 403);
45
45
  assert.doesNotThrow(() => requireLocalhostRoute(localReq, "/api/update"));
46
+ assert.ok(LOCALHOST_ONLY_POST_ROUTES.has("/api/workflow-policy"), "workflow policy mutation must stay in the canonical localhost route registry");
46
47
 
47
48
  for (const pathname of LOCALHOST_ONLY_POST_ROUTES.keys()) {
48
49
  assert.match(pathname, /^\/api\//, `${pathname} should be an API route`);
@@ -129,7 +130,7 @@ for (const target of ["state", "tabs", "commands", "themes", "workspace"]) {
129
130
  }
130
131
 
131
132
  const slashCommands = nativeSlashCommandEntries(parity);
132
- assert.equal(slashCommands.length, 26);
133
+ assert.equal(slashCommands.length, 27);
133
134
  assert.equal(slashCommands[0].name, "settings");
134
135
  assert.equal(slashCommands.at(-1).name, "quit");
135
136
 
@@ -55,6 +55,7 @@ const requiredNativeCommands = [
55
55
  "settings",
56
56
  "safety-guard-setup",
57
57
  "git-workflow-setup",
58
+ "workflow-setup",
58
59
  "model",
59
60
  "theme",
60
61
  "scoped-models",
@@ -87,6 +88,12 @@ for (const surface of slashSurfaces) {
87
88
  assert.ok(surface.command.description.trim(), `${surface.id} command description should not be empty`);
88
89
  }
89
90
 
91
+ const workflowSetupSurface = slashSurfaces.find((surface) => surface.id === "/workflow-setup");
92
+ assert.ok(workflowSetupSurface, "/workflow-setup should be represented in the native parity matrix");
93
+ assert.equal(workflowSetupSurface.webStatus, "implemented", "/workflow-setup browser-native support should be implemented");
94
+ assert.equal(workflowSetupSurface.sensitive, true, "/workflow-setup should be tracked as a sensitive policy mutation");
95
+ assert.deepEqual(workflowSetupSurface.guards, ["localhost", "confirmation"], "/workflow-setup should require both localhost and explicit confirmation guards");
96
+
90
97
  const selectorMatch = app.match(/const NATIVE_SELECTOR_COMMANDS = new Set\(\[(.*?)\]\)/s);
91
98
  assert.ok(selectorMatch, "frontend native selector command set should be discoverable");
92
99
  const frontendSelectorCommands = [...selectorMatch[1].matchAll(/"([^"]+)"/g)].map((match) => match[1]);
@@ -132,6 +139,10 @@ assert.match(server, /url\.pathname === "\/api\/session-rename" && req\.method =
132
139
  assert.match(server, /url\.pathname === "\/api\/session-delete" && req\.method === "POST"/, "server should expose localhost-only POST /api/session-delete");
133
140
  assert.match(server, /url\.pathname === "\/api\/auth-providers" && req\.method === "GET"/, "server should expose GET /api/auth-providers");
134
141
  assert.match(server, /url\.pathname === "\/api\/auth-logout" && req\.method === "POST"/, "server should expose localhost-only POST /api/auth-logout");
142
+ assert.match(server, /url\.pathname === "\/api\/workflow-policy" && req\.method === "GET"[\s\S]*requireLocalhost\(req, "Workflow policy setup is only allowed from localhost\."\)/, "workflow policy reads should be localhost-only");
143
+ assert.match(server, /url\.pathname === "\/api\/workflow-policy" && req\.method === "POST"[\s\S]*requireLocalhostRoute\(req, url\.pathname\)[\s\S]*requireWorkflowPolicyJsonRequest\(req\)[\s\S]*expectedRevision: body\.expectedRevision/, "workflow policy saves should be registry-guarded, same-origin JSON, and revision protected");
144
+ assert.match(app, /name === "workflow-setup" && !hasLoadedRpcCommand\(name\)[\s\S]*case "workflow-setup":[\s\S]*openNativeWorkflowSetupDialog\(\)/, "frontend should gate exact /workflow-setup native routing on the active tab's loaded extension catalog");
145
+ assert.match(app, /title: "Save reviewed workflow permission ceiling\?"[\s\S]*if \(!reviewed\) return;[\s\S]*body: \{ policy: policyToSave, expectedRevision: data\.revision \?\? null \}/, "frontend should explicitly confirm the normalized workflow policy before revision-protected save");
135
146
  assert.match(server, /url\.pathname === "\/api\/native-parity" && req\.method === "GET"/, "server should expose the native parity matrix for clients/tests");
136
147
  assert.match(server, /const NATIVE_DOWNLOAD_TOKEN_TTL_MS = 10 \* 60 \* 1000/, "native downloads should use short-lived tokens");
137
148
  assert.match(server, /const WEBUI_HELPER_COMMAND = "webui-helper"/, "server should declare the hidden Web UI RPC helper command");
@@ -161,9 +172,9 @@ assert.match(server, /nativeExportDownloadPayload\(\{[\s\S]*localRequest: isLoca
161
172
  assert.match(server, /openUrl: record\.contentType === MIME_TYPES\.get\("\.html"\)/, "HTML native downloads should expose a browser-open URL");
162
173
  assert.match(server, /url\.searchParams\.get\("disposition"\) === "inline"/, "native download endpoint should support inline HTML rendering");
163
174
  assert.match(server, /copyFile\(sessionFile, targetPath\)/, "explicit .jsonl /export should copy the active session file");
164
- assert.match(app, /function triggerNativeDownload\(download\)/, "frontend should know how to trigger native command downloads");
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");
165
176
  assert.match(app, /function applyNativeSlashCommandEffects\(response, message, tabContext/, "frontend should apply centralized native slash-command adapter effects");
166
- assert.match(app, /data\.download && handleNativeDownloadResponse\(data\.download, data\.command, data\.serverPath\)/, "frontend should route native downloads and their saved path through command-specific handling");
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");
167
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");
168
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");
169
180
  assert.match(app, /for \(const warning of response\.warnings/, "frontend should surface remote bash trust warnings");