@firstpick/pi-package-webui 0.7.9 → 0.8.1
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 +32 -9
- package/bin/pi-webui.mjs +750 -113
- package/lib/git-workflow-preferences.mjs +16 -0
- package/lib/git-worktrees.mjs +43 -4
- package/lib/npm-command.mjs +81 -0
- package/lib/queue-mutation.mjs +6 -0
- package/lib/workspace-files-live-watcher.mjs +138 -0
- package/package.json +11 -4
- package/public/app.js +3397 -380
- package/public/index.html +119 -20
- package/public/mobile-shell-state.mjs +166 -0
- package/public/service-worker.js +60 -13
- package/public/styles.css +1066 -362
- package/public/subagent-gate-visibility.mjs +16 -0
- package/public/subagent-launch-slot-state.mjs +16 -0
- package/public/transcript-renderer.mjs +433 -0
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/interaction-continuity.spec.mjs +739 -0
- package/tests/browser/mobile-foundation.spec.mjs +352 -0
- package/tests/browser/optimistic-prompt.spec.mjs +130 -0
- package/tests/chat-scroll-intent-static.test.mjs +6 -1
- package/tests/codex-fast-mode-static.test.mjs +59 -0
- package/tests/compact-sections-static.test.mjs +20 -2
- package/tests/compaction-mutation-contract.test.mjs +18 -4
- package/tests/compaction-static.test.mjs +1 -0
- package/tests/completion-signal-contract.test.mjs +13 -2
- package/tests/composer-skill-tag-layout.test.mjs +70 -0
- package/tests/fast-mode-client-static.test.mjs +14 -11
- package/tests/fixtures/fake-pi.mjs +222 -2
- package/tests/git-panel-gitignore-static.test.mjs +104 -0
- package/tests/git-workflow-preferences.test.mjs +8 -0
- package/tests/guided-git-publication-backend-static.test.mjs +40 -0
- package/tests/http-endpoints-harness.test.mjs +490 -3
- package/tests/interaction-state-stability-static.test.mjs +254 -0
- package/tests/mobile-continuity-tablet-static.test.mjs +55 -0
- package/tests/mobile-foundation-static.test.mjs +69 -0
- package/tests/mobile-phone-experience-static.test.mjs +65 -0
- package/tests/mobile-shell-state.test.mjs +69 -0
- package/tests/mobile-static.test.mjs +300 -43
- package/tests/mobile-transcript-cache-characterization.test.mjs +34 -0
- package/tests/npm-command.test.mjs +64 -1
- package/tests/open-issue-wizard-static.test.mjs +2 -1
- package/tests/queue-edit-reorder-static.test.mjs +9 -1
- package/tests/queue-mutation-contract.test.mjs +22 -0
- package/tests/service-worker-lifecycle.test.mjs +120 -0
- package/tests/side-panel-resize-static.test.mjs +8 -1
- package/tests/sse-backpressure-harness.test.mjs +98 -0
- package/tests/streaming-ui-coupling.test.mjs +7 -1
- package/tests/subagent-gate-visibility.test.mjs +18 -2
- package/tests/subagent-launch-slot-state.test.mjs +32 -0
- package/tests/subagent-launch-slots-static.test.mjs +8 -2
- package/tests/subagents-helper.test.mjs +90 -0
- package/tests/terminal-tab-workspace-static.test.mjs +1 -1
- package/tests/update-commands.test.mjs +4 -0
- package/tests/workspace-files-live-updates-static.test.mjs +76 -0
- package/tests/workspace-files-live-watcher.test.mjs +95 -0
- package/webui-rpc-helper.mjs +175 -3
|
@@ -21,6 +21,7 @@ assert.match(server, /function eventForTabClients\(tab, event\)[\s\S]*event\?\.t
|
|
|
21
21
|
assert.match(server, /function compactionQueueSnapshot\(tab\)[\s\S]*source: "webui-compaction"[\s\S]*revision: compactionQueueRevision\(tab\)[\s\S]*draining:/, "compaction queue snapshots should include source, monotonic revision, and draining state");
|
|
22
22
|
assert.match(server, /function mutateCompactionFollowUpQueue\(tab, request\)[\s\S]*if \(current\.draining\) return failed\("queue-draining"\)[\s\S]*request\.revision !== current\.revision[\s\S]*slots\.forEach\(\(slot, index\) => \{ queue\[slot\] = followUps\[index\]; \}\)/, "compaction mutations should reject draining/stale requests and only permute follow-up slots");
|
|
23
23
|
assert.match(server, /function mutateCompactionFollowUpQueue\(tab, request\)[\s\S]*queue\[slots\[operation\.index\]\]\.command\.message = operation\.text[\s\S]*advanceCompactionQueueRevision\(tab\)[\s\S]*broadcastTabEvent\(tab, compactionQueueEvent\(tab\)\)/, "compaction edits should preserve command metadata and emit one authoritative update after revision advancement");
|
|
24
|
+
assert.match(server, /operation\.type === "delete"[\s\S]*queue\.splice\(slots\[operation\.index\], 1\)/, "compaction deletion should remove the selected complete queued command record");
|
|
24
25
|
assert.match(server, /url\.pathname === "\/api\/queue\/mutate" && req\.method === "POST"[\s\S]*request\.source === "webui-compaction"[\s\S]*mutateCompactionFollowUpQueue[\s\S]*status = data\?\.mutated === true \? 200 : conflict \? 409 : 400/, "queue mutation HTTP handling should keep compaction mutations source-specific and map conflicts to 409");
|
|
25
26
|
|
|
26
27
|
assert.match(app, /function isRunActive\(\) \{\n\s+return !!currentState\?\.isStreaming \|\| !!currentState\?\.isCompacting/, "frontend should treat compaction as an active run for composer controls");
|
|
@@ -19,6 +19,9 @@ function functionSource(source, name) {
|
|
|
19
19
|
const context = vm.createContext({ console });
|
|
20
20
|
vm.runInContext(`
|
|
21
21
|
const TAB_ACTIVITY_IDLE_RECONCILE_GRACE_MS = 1200;
|
|
22
|
+
// The production server imports randomUUID from node:crypto; keep the
|
|
23
|
+
// extracted lifecycle contract deterministic while exercising run creation.
|
|
24
|
+
function randomUUID() { return "run_12345678"; }
|
|
22
25
|
function pendingExtensionUiRequests() { return []; }
|
|
23
26
|
function patchTabState(tab, patch) { tab.lastState = { ...(tab.lastState || {}), ...patch }; }
|
|
24
27
|
function rememberTabState(tab, state) { tab.lastState = state; }
|
|
@@ -27,6 +30,7 @@ vm.runInContext(`
|
|
|
27
30
|
${functionSource(server, "tabActivitySnapshot")}
|
|
28
31
|
${functionSource(server, "markTabWorking")}
|
|
29
32
|
${functionSource(server, "markTabDone")}
|
|
33
|
+
${functionSource(server, "markTabFailed")}
|
|
30
34
|
${functionSource(server, "markTabIdle")}
|
|
31
35
|
${functionSource(server, "stateHasVisibleWork")}
|
|
32
36
|
${functionSource(server, "activityRecentlyStarted")}
|
|
@@ -84,11 +88,18 @@ contract.event(compactionTab, { type: "compaction_end" });
|
|
|
84
88
|
assert.equal(compactionTab.activity.status, "idle");
|
|
85
89
|
assert.equal(compactionTab.activity.completionSerial, 0, "standalone compaction must not emit agent completion");
|
|
86
90
|
|
|
91
|
+
const failedTurnTab = contract.createTab();
|
|
92
|
+
contract.event(failedTurnTab, { type: "agent_start" });
|
|
93
|
+
contract.event(failedTurnTab, { type: "message_end", message: { role: "assistant", stopReason: "error" } });
|
|
94
|
+
contract.event(failedTurnTab, { type: "agent_settled" });
|
|
95
|
+
assert.equal(failedTurnTab.activity.status, "failed", "a terminal assistant error must remain distinct from successful completion");
|
|
96
|
+
assert.equal(failedTurnTab.activity.completionSerial, 1);
|
|
97
|
+
|
|
87
98
|
const failedProcessTab = contract.createTab();
|
|
88
99
|
contract.event(failedProcessTab, { type: "agent_start" });
|
|
89
100
|
contract.event(failedProcessTab, { type: "pi_process_error" });
|
|
90
|
-
assert.equal(failedProcessTab.activity.status, "
|
|
91
|
-
assert.equal(failedProcessTab.activity.completionSerial,
|
|
101
|
+
assert.equal(failedProcessTab.activity.status, "failed");
|
|
102
|
+
assert.equal(failedProcessTab.activity.completionSerial, 1, "a failed process must create one failed completion, not a successful one");
|
|
92
103
|
|
|
93
104
|
assert.match(app, /case "agent_settled":[\s\S]*?notifyAgentDone\(/, "the browser should notify only from settlement");
|
|
94
105
|
assert.doesNotMatch(functionSource(app, "handleInactiveTabEvent"), /event\.type === "agent_end"[\s\S]*?notifyAgentDone/, "background low-level run ends must not notify");
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import vm from "node:vm";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
8
|
+
const app = await readFile(join(root, "public", "app.js"), "utf8");
|
|
9
|
+
|
|
10
|
+
function functionSource(name, nextName) {
|
|
11
|
+
const start = app.indexOf(`function ${name}(`);
|
|
12
|
+
const end = app.indexOf(`\nfunction ${nextName}(`, start);
|
|
13
|
+
assert.ok(start >= 0 && end > start, `${name} should remain a standalone frontend helper`);
|
|
14
|
+
return app.slice(start, end);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function chip(width) {
|
|
18
|
+
return {
|
|
19
|
+
hidden: false,
|
|
20
|
+
textContent: "",
|
|
21
|
+
title: "",
|
|
22
|
+
measurements: 0,
|
|
23
|
+
getBoundingClientRect() {
|
|
24
|
+
this.measurements += 1;
|
|
25
|
+
return { width };
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const tags = [chip(50), chip(60), chip(70)];
|
|
31
|
+
const overflow = chip(22);
|
|
32
|
+
const container = {
|
|
33
|
+
hidden: false,
|
|
34
|
+
clientWidth: 150,
|
|
35
|
+
querySelectorAll: (selector) => selector === "button.composer-skill-tag" ? tags : [],
|
|
36
|
+
querySelector: (selector) => selector === ".composer-skill-tag.overflow" ? overflow : null,
|
|
37
|
+
};
|
|
38
|
+
const context = {
|
|
39
|
+
elements: { sessionSkillTags: container },
|
|
40
|
+
getComputedStyle: () => ({ columnGap: "5px", gap: "5px" }),
|
|
41
|
+
};
|
|
42
|
+
vm.runInNewContext(
|
|
43
|
+
`${functionSource("fitSessionSkillTags", "scheduleSessionSkillTagLayout")}\nthis.fitSessionSkillTags = fitSessionSkillTags;`,
|
|
44
|
+
context,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
context.fitSessionSkillTags();
|
|
48
|
+
assert.deepEqual(tags.map((tag) => tag.hidden), [false, false, true], "the strip should show the maximum chip count that fits the measured width");
|
|
49
|
+
assert.equal(overflow.hidden, false, "the overflow chip should remain visible while tags are hidden");
|
|
50
|
+
assert.equal(overflow.textContent, "+1", "the overflow chip should report the current hidden count");
|
|
51
|
+
assert.equal(overflow.measurements, 1, "fitting should measure one overflow width per digit count rather than forcing layout for every candidate");
|
|
52
|
+
|
|
53
|
+
container.clientWidth = 200;
|
|
54
|
+
context.fitSessionSkillTags();
|
|
55
|
+
assert.deepEqual(tags.map((tag) => tag.hidden), [false, false, false], "widening the input should reveal every tag without rerendering the session state");
|
|
56
|
+
assert.equal(overflow.hidden, true, "the overflow chip should disappear when every tag fits");
|
|
57
|
+
|
|
58
|
+
container.clientWidth = 80;
|
|
59
|
+
context.fitSessionSkillTags();
|
|
60
|
+
assert.deepEqual(tags.map((tag) => tag.hidden), [false, true, true], "narrowing the input should compact the tag strip again");
|
|
61
|
+
assert.equal(overflow.textContent, "+2", "responsive compaction should keep the overflow count current");
|
|
62
|
+
|
|
63
|
+
container.clientWidth = 0;
|
|
64
|
+
const zeroWidthState = tags.map((tag) => tag.hidden);
|
|
65
|
+
const zeroWidthOverflowText = overflow.textContent;
|
|
66
|
+
context.fitSessionSkillTags();
|
|
67
|
+
assert.deepEqual(tags.map((tag) => tag.hidden), zeroWidthState, "a temporarily unmeasurable strip should preserve its last stable visibility state");
|
|
68
|
+
assert.equal(overflow.textContent, zeroWidthOverflowText, "a zero-width pass should not expose a stale overflow count");
|
|
69
|
+
|
|
70
|
+
console.log("composer skill tag layout tests passed");
|
|
@@ -84,7 +84,8 @@ assert.doesNotMatch(compactUpdate, /event\.message|assistantMessageEvent\.partia
|
|
|
84
84
|
assert.match(compactUpdate, /reduceFastOutputLiveEvent\(compactLiveState, event\)/, "compact deltas should use the pure reducer");
|
|
85
85
|
assert.match(compactUpdate, /shouldConsumeFastOutputLiveEvent\(reduced\)/, "recognized compact empty end variants should be consumed instead of reaching normal handlers with stripped snapshots");
|
|
86
86
|
assert.match(helper, /function shouldConsumeFastOutputLiveEvent\(reduction = \{\}\)[\s\S]*?"text-end"[\s\S]*?"thinking-end"[\s\S]*?"toolcall-end"/, "the reducer policy should consume only recognized compact end variants when no DOM state changes");
|
|
87
|
-
assert.match(compactFlush,
|
|
87
|
+
assert.match(compactFlush, /transcriptRenderer\.updateTextSurface\(\{[\s\S]*?surface: compactTextNode,[\s\S]*?text: compactLiveState\.text/, "compact assistant text must update through the stable transcript text surface");
|
|
88
|
+
assert.doesNotMatch(compactFlush, /compactTextNode\.textContent\s*=/, "compact assistant streaming must not replace its selected text node");
|
|
88
89
|
assert.match(compactThinkingBubble, /title: "thinking \(live\)"[\s\S]*?compactThinkingAggregate: true[\s\S]*?compactThinkingKey: "live"[\s\S]*?compactThinkingDefaultExpanded: true[\s\S]*?make\("div", "markdown-body thinking-text compact-live-thinking"\)/, "compact live thinking should use one expanded-by-default aggregate disclosure with a stable key and established Markdown styles");
|
|
89
90
|
assert.match(resetCompactLiveOutput, /clearCompactThinkingDisclosureState\("live"\)/, "a new compact stream should clear any explicit live override and restore its expanded default");
|
|
90
91
|
assert.match(compactFlush, /compactThinkingNode\?\._rawThinkingText !== compactLiveState\.thinking[\s\S]*?renderThinkingMarkdown\(compactThinkingNode, compactLiveState\.thinking\)/, "compact live thinking should preserve Markdown formatting");
|
|
@@ -92,10 +93,10 @@ assert.doesNotMatch(compactFlush, /compactThinkingNode\.textContent|renderStream
|
|
|
92
93
|
assert.doesNotMatch(compactToolShell, /normalizeToolExecution|toolExecutionRenderSignature|renderToolExecution|handleToolExecutionUpdate|JSON\.stringify/, "compact tool shells must defer rich bodies and raw serialization");
|
|
93
94
|
assert.match(app, /case "tool_execution_update":\s+if \(!compactOutputActive\(\)\) handleToolExecutionUpdate\(event\);/, "compact mode should not build intermediate rich tool updates");
|
|
94
95
|
assert.match(app, /case "tool_execution_end":[\s\S]*?compactLiveScheduler\.flushNow\(\)[\s\S]*?renderCompactToolShell\(event, \{ complete: true \}\)[\s\S]*?finishCompactLiveOutput\(tabContext\)/, "compact tool completion should remain lightweight and request final reconciliation");
|
|
95
|
-
assert.match(resetStream, /resetCompactLiveOutput\(\)/, "reset and tab changes should cancel compact pending work");
|
|
96
|
+
assert.match(resetStream, /resetCompactLiveOutput\(\{ remove: !preserveCompact \}\)/, "reset and tab changes should cancel compact pending work while exact compact settlement may retain its adopted owner");
|
|
96
97
|
assert.match(app, /case "message_end": \{\s+if \(compactOutputActive\(\)\) finishCompactLiveOutput\(tabContext\);/, "message ends should synchronously flush compact output before reconciliation");
|
|
97
98
|
assert.match(app, /case "agent_end":\s+if \(compactOutputActive\(\)\) finishCompactLiveOutput\(tabContext\);/, "agent ends should synchronously flush compact output before reconciliation");
|
|
98
|
-
assert.match(compactTranscript, /message\.role !== "assistant"[\s\S]*?appendMarkdown\(body, output \|\| "_\[non-text output omitted in
|
|
99
|
+
assert.match(compactTranscript, /message\.role !== "assistant"[\s\S]*?appendMarkdown\(body, output \|\| "_\[non-text output omitted in compact mode\]_"\)[\s\S]*?classList\.add\("compact-transcript-text"\)/, "reconciled compact-mode assistant output should preserve Markdown and explain omitted non-text output");
|
|
99
100
|
assert.doesNotMatch(compactTranscript, /appendText|renderToolExecution|normalizeToolExecution|JSON\.stringify|appendToolOutput|appendToolDiff|appendToolImages/, "fast-mode final output must not fall back to plain text or render tool details");
|
|
100
101
|
assert.match(createMessageBubble, /compactOutputActive\(\) && !streaming[\s\S]*?renderCompactTranscriptBody\(body, message\)/, "final transcript rendering should select the compact Markdown path only for acknowledged fast mode");
|
|
101
102
|
assert.match(appendTranscriptMessage, /compactTranscript && transcriptMessage\.role !== "assistant"/, "fast-mode assistant reconciliation should defer all thinking to the aggregate transcript item and retain only final output");
|
|
@@ -115,7 +116,8 @@ assert.match(orderedTranscriptItems, /if \(!compactOutputActive\(\)\) \{[\s\S]*?
|
|
|
115
116
|
assert.match(transcriptRenderEpoch, /compactOutputActive\(\) \? "compact" : "normal"/, "mode changes should invalidate the keyed transcript renderer");
|
|
116
117
|
assert.match(clearCompactToolShells, /removeCompactLiveBubble\(shell\?\.bubble\)[\s\S]*?compactToolShells\.clear\(\)/, "fast mode should remove previous transient tool shells from the DOM and registry");
|
|
117
118
|
assert.match(compactToolShell, /if \(!shell\) \{\s+clearCompactToolShells\(\)/, "a newly-started tool should replace the previous transient tool shell");
|
|
118
|
-
assert.match(compactToolShell, /shell\.status
|
|
119
|
+
assert.match(compactToolShell, /transcriptRenderer\.updateTextSurface\(\{[\s\S]*?surface: shell\.status[\s\S]*?text: complete[\s\S]*?event\?\.isError \? "failed" : "done"[\s\S]*?: "running"/, "the current transient tool shell should expose only a non-duplicated status through its stable transcript text surface");
|
|
120
|
+
assert.doesNotMatch(compactToolShell, /shell\.status\.textContent\s*=/, "compact tool status updates must not replace selected text nodes");
|
|
119
121
|
assert.match(styles, /\.message\.compact-tool-shell\s*\{[\s\S]*?display: grid[\s\S]*?grid-template-columns:[\s\S]*?padding: 0\.46rem 0\.62rem[\s\S]*?box-shadow: none/, "fast-mode tool activity should render as a compact horizontal row");
|
|
120
122
|
assert.match(styles, /\.compact-tool-shell \.compact-tool-status\s*\{[\s\S]*?display: inline-flex[\s\S]*?border-radius: 999px[\s\S]*?font-size: 0\.7rem[\s\S]*?text-transform: uppercase/, "the minimal tool status should remain visually distinct as a small pill");
|
|
121
123
|
assert.match(styles, /\.compact-tool-shell\.tool-running \.compact-tool-status[\s\S]*?\.compact-tool-shell\.tool-success \.compact-tool-status[\s\S]*?\.compact-tool-shell\.tool-error \.compact-tool-status/, "running, success, and failure tool states should have distinct visual tones");
|
|
@@ -127,7 +129,7 @@ assert.match(refreshMessages, /preserveCompactStream = compactLiveStreamRenderAc
|
|
|
127
129
|
assert.match(app, /const SETTINGS_OUTPUT_MODE_OPTIONS = \[[\s\S]*?value: "normal"[\s\S]*?value: "compact-v1"/, "settings should offer normal and compact-v1 server defaults");
|
|
128
130
|
assert.match(nativeSettingsDialog, /api\("\/api\/webui-output-mode", \{ scoped: false \}\)/, "opening settings should load output-mode metadata from the separate server API");
|
|
129
131
|
assert.match(nativeSettingsDialog, /outputMode: nativeSettingSelect\("Output processing", outputModeMetadata\.persistedDefault, SETTINGS_OUTPUT_MODE_OPTIONS,[\s\S]*?\{ label: "server", tone: "startup" \}\)/, "Browser workflow should expose a server-badged output-processing selector");
|
|
130
|
-
assert.match(nativeSettingsDialog, /
|
|
132
|
+
assert.match(nativeSettingsDialog, /Compact mode preserves Markdown final output, keeps live thinking expanded, groups stored thinking in one collapsed disclosure per turn, shows only the current tool status transiently, and does not change model inference or token generation\. Changes use server barriers without restarting Pi\./, "settings copy should distinguish expanded live thinking from collapsed stored thinking without changing inference semantics");
|
|
131
133
|
assert.match(nativeSettingsDialog, /nativeSettingsSection\("Browser workflow"[\s\S]*?controls\.outputMode/, "the output-mode selector should be placed in Browser workflow");
|
|
132
134
|
assert.match(outputModeMetadataText, /Persisted default:[\s\S]*?Effective mode:[\s\S]*?Source:/, "settings should display persisted default plus effective mode and source");
|
|
133
135
|
assert.match(outputModeMetadataText, /metadata\.overridden[\s\S]*?overrides the persisted setting/, "settings should display CLI/environment override state when it wins");
|
|
@@ -137,12 +139,12 @@ assert.match(nativeSettingsDialog, /method: "PUT",[\s\S]*?body: \{ outputModeDef
|
|
|
137
139
|
assert.doesNotMatch(nativeSettingsPayload, /outputMode(?:Default|Metadata|ApiDiagnostic|Changed)?/, "server-scoped output mode must stay out of the native SettingsManager payload");
|
|
138
140
|
assert.match(nativeSettingsDialog, /const response = await nativeCommandApi\("\/api\/settings", \{ method: "POST", body: \{ settings: payload, reload \} \}\);[\s\S]*?nativeSettingsChangedMessage\(response, reload\)/, "existing native settings apply behavior should remain intact");
|
|
139
141
|
|
|
140
|
-
assert.match(html, /data-side-panel-section="controls"[\s\S]*?id="outputProcessingControlsTitle">Output processing<[\s\S]*?<span class="control-scope-badge">Server<\/span>[\s\S]*?id="fastOutputModeSelect"[\s\S]*?<option value="normal">Normal<\/option>[\s\S]*?<option value="compact-v1">
|
|
142
|
+
assert.match(html, /data-side-panel-section="controls"[\s\S]*?id="outputProcessingControlsTitle">Output processing<[\s\S]*?<span class="control-scope-badge">Server<\/span>[\s\S]*?id="fastOutputModeSelect"[\s\S]*?<option value="normal">Normal<\/option>[\s\S]*?<option value="compact-v1">Compact<\/option>[\s\S]*?id="setFastOutputModeButton"[\s\S]*?id="fastOutputModeStatus"/, "Controls should expose a server-scoped normal/compact selector with apply button and live status");
|
|
141
143
|
assert.match(app, /fastOutputModeSelect: \$\("#fastOutputModeSelect"\)[\s\S]*?setFastOutputModeButton: \$\("#setFastOutputModeButton"\)[\s\S]*?fastOutputModeStatus: \$\("#fastOutputModeStatus"\)/, "sidebar fast-mode elements should be wired");
|
|
142
144
|
assert.match(sidebarOutputModeRefresh, /api\("\/api\/webui-output-mode", \{ scoped: false \}\)[\s\S]*?normalizeWebuiOutputModeMetadata\(response\.data\)/, "sidebar selector should load current server output-mode metadata");
|
|
143
145
|
assert.match(sidebarOutputModeApply, /method: "PUT"[\s\S]*?body: \{ outputModeDefault \}[\s\S]*?scoped: false[\s\S]*?await refreshSidebarOutputMode\(\)/, "sidebar selector should persist the selected mode and refresh effective metadata");
|
|
144
|
-
assert.match(sidebarOutputModeApply, /outputModeDefault === "compact-v1"[\s\S]*?
|
|
145
|
-
assert.match(sidebarOutputModeApply, /sidebarOutputModeDiagnostic = ""[\s\S]*?sidebarOutputModeNotice = `Failed to update
|
|
146
|
+
assert.match(sidebarOutputModeApply, /outputModeDefault === "compact-v1"[\s\S]*?Compact output mode enabled[\s\S]*?Normal output processing restored/, "sidebar apply feedback should distinguish enabling compact mode from restoring normal mode");
|
|
147
|
+
assert.match(sidebarOutputModeApply, /sidebarOutputModeDiagnostic = ""[\s\S]*?sidebarOutputModeNotice = `Failed to update compact mode:[\s\S]*?You can retry\.`[\s\S]*?sidebarOutputModeLoaded = true/, "a transient apply failure should remain visible without permanently disabling retry");
|
|
146
148
|
assert.match(app, /function renderSidebarOutputModeControl[\s\S]*?sidebarOutputModeNotice[\s\S]*?webuiOutputModeMetadataText\(sidebarOutputModeMetadata\)[\s\S]*?updateSidebarOutputModeApplyState\(\)/, "sidebar status should expose retry notices or persisted/effective/source metadata and apply state");
|
|
147
149
|
assert.match(styles, /\.toggle-control-hint\.warning\s*\{[\s\S]*?color: var\(--ctp-yellow\)/, "sidebar output-mode failures should use the warning palette");
|
|
148
150
|
assert.match(app, /fastOutputModeSelect\?\.addEventListener\("change", \(\) => \{[\s\S]*?sidebarOutputModeNotice = ""[\s\S]*?renderSidebarOutputModeControl\(\{ syncSelection: false \}\)[\s\S]*?setFastOutputModeButton\?\.addEventListener\("click", \(\) => applySidebarOutputMode\(\)/, "sidebar selection should clear transient failures and keep Apply retryable");
|
|
@@ -150,9 +152,10 @@ assert.match(app, /refreshSidebarOutputMode\(\)\.catch[\s\S]*?initializeTabs\(\)
|
|
|
150
152
|
|
|
151
153
|
assert.match(helper, /FAST_OUTPUT_FLUSH_INTERVAL_MS = 100/, "the live scheduler should retain the exact 100 ms sustained-output bound");
|
|
152
154
|
assert.match(worker, /pi-webui-pwa-v\d+[\s\S]*?"\/fast-output-live\.mjs"/, "PWA cache identity and app shell should include the compact helper");
|
|
153
|
-
assert.match(html, /<label for="fastOutputModeSelect">
|
|
154
|
-
assert.match(html, /Markdown final output; live thinking expanded; stored thinking grouped and collapsed/, "the sidebar should distinguish
|
|
155
|
-
|
|
155
|
+
assert.match(html, /<label for="fastOutputModeSelect">Compact mode \(Experimental\)<\/label>/, "the sidebar should mark compact mode as experimental");
|
|
156
|
+
assert.match(html, /Lightweight browser rendering; Markdown final output; live thinking expanded; stored thinking grouped and collapsed/, "the sidebar should distinguish compact rendering from model inference");
|
|
157
|
+
// Intent preserved: the guarded PWA entry point must advance whenever app wiring changes.
|
|
158
|
+
assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=103"/, "the guarded PWA entry point should cache-bust browser wiring");
|
|
156
159
|
assert.match(JSON.parse(packageRaw).scripts.check, /node --check public\/fast-output-live\.mjs/, "package checks should parse the compact helper");
|
|
157
160
|
|
|
158
161
|
const events = createFastModeOutputEvents();
|
|
@@ -28,6 +28,8 @@ let activeBash = 0;
|
|
|
28
28
|
let peakBash = 0;
|
|
29
29
|
let thinkingLevel = "off";
|
|
30
30
|
let conversationEnabled = false;
|
|
31
|
+
let codexFastModeEnabled = false;
|
|
32
|
+
let rejectNextCodexFastModeMutation = false;
|
|
31
33
|
const fakeTools = [
|
|
32
34
|
{ name: "read", description: "Read files", sourceInfo: { source: "builtin", scope: "temporary", origin: "top-level" } },
|
|
33
35
|
{ name: "bash", description: "Run shell commands", sourceInfo: { source: "builtin", scope: "temporary", origin: "top-level" } },
|
|
@@ -44,6 +46,7 @@ const voiceScriptsEnabled = process.env.FAKE_PI_VOICE_SCRIPTS === "1";
|
|
|
44
46
|
// consumers retain their current timing and log shapes.
|
|
45
47
|
const continuityModeEnabled = process.env.FAKE_PI_CONTINUITY_MODE === "1";
|
|
46
48
|
const largePayloadsEnabled = process.env.FAKE_PI_LARGE_PAYLOADS === "1";
|
|
49
|
+
const sseFloodEnabled = process.env.FAKE_PI_SSE_FLOOD === "1";
|
|
47
50
|
const commandLogFile = process.env.FAKE_PI_LOG_FILE || "";
|
|
48
51
|
const largeRpcText = "large-rpc-payload:" + "λ".repeat(70_000);
|
|
49
52
|
const largeTokenSamples = Array.from({ length: 300 }, (_, index) => ({ index, input: index + 1, output: index + 2 }));
|
|
@@ -112,6 +115,11 @@ function mutateRuntimeQueue(payload = {}) {
|
|
|
112
115
|
const [message] = runtimeQueue.followUpMessages.splice(operation.from, 1);
|
|
113
116
|
runtimeQueue.followUp.splice(operation.to, 0, text);
|
|
114
117
|
runtimeQueue.followUpMessages.splice(operation.to, 0, message);
|
|
118
|
+
} else if (operation.type === "delete") {
|
|
119
|
+
if (!Number.isInteger(operation.index) || operation.index < 0 || operation.index >= runtimeQueue.followUp.length
|
|
120
|
+
|| runtimeQueue.followUp[operation.index] !== operation.expectedText) return failed("invalid-request");
|
|
121
|
+
runtimeQueue.followUp.splice(operation.index, 1);
|
|
122
|
+
runtimeQueue.followUpMessages.splice(operation.index, 1);
|
|
115
123
|
} else {
|
|
116
124
|
return failed("invalid-request");
|
|
117
125
|
}
|
|
@@ -274,11 +282,160 @@ function runContinuityDelayedStream() {
|
|
|
274
282
|
runScriptedSteps(steps);
|
|
275
283
|
}
|
|
276
284
|
|
|
285
|
+
function runContinuityDelayedStart() {
|
|
286
|
+
runScriptedSteps([{ afterMs: 3500, run: runContinuityDelayedStream }]);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function runContinuityConfirmedBeforeTool() {
|
|
290
|
+
scriptedStreaming = true;
|
|
291
|
+
runScriptedSteps([{ afterMs: 1500, run: () => runTranscriptContinuityScenario("tool") }]);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function runTranscriptContinuityScenario(scenario) {
|
|
295
|
+
scriptedStreaming = true;
|
|
296
|
+
const run = ++continuityRun;
|
|
297
|
+
const tagged = (payload) => ({ ...payload, continuityRun: run, continuityScenario: scenario });
|
|
298
|
+
const steps = [];
|
|
299
|
+
const start = () => steps.push(
|
|
300
|
+
{ afterMs: 40, run: () => emitScriptedEvent(tagged({ type: "agent_start" })) },
|
|
301
|
+
{ afterMs: 40, run: () => emitScriptedEvent(tagged({ type: "message_start", message: { role: "assistant" } })) },
|
|
302
|
+
);
|
|
303
|
+
const finish = (message, afterMs = 160) => {
|
|
304
|
+
if (message) {
|
|
305
|
+
steps.push({ afterMs, run: () => {
|
|
306
|
+
const settledMessage = typeof message === "function" ? message() : message;
|
|
307
|
+
appendDynamicMessage(settledMessage);
|
|
308
|
+
emitScriptedEvent(tagged({ type: "message_end", message: settledMessage }));
|
|
309
|
+
} });
|
|
310
|
+
}
|
|
311
|
+
steps.push(
|
|
312
|
+
{ afterMs: message ? 60 : afterMs, run: () => emitScriptedEvent(tagged({ type: "agent_end" })) },
|
|
313
|
+
{ afterMs: 20, run: () => {
|
|
314
|
+
scriptedStreaming = false;
|
|
315
|
+
emitScriptedEvent(tagged({ type: "agent_settled" }));
|
|
316
|
+
} },
|
|
317
|
+
);
|
|
318
|
+
};
|
|
319
|
+
const assistant = (text) => ({ role: "assistant", content: [{ type: "text", text }], timestamp: Date.now() });
|
|
320
|
+
|
|
321
|
+
if (scenario === "reverse") {
|
|
322
|
+
const text = "backward selection literal survives";
|
|
323
|
+
start();
|
|
324
|
+
steps.push(
|
|
325
|
+
{ afterMs: 120, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta: "backward selection literal" } })) },
|
|
326
|
+
{ afterMs: 650, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta: " survives" } })) },
|
|
327
|
+
);
|
|
328
|
+
finish(assistant(text), 400);
|
|
329
|
+
} else if (scenario === "duplicate") {
|
|
330
|
+
const text = "duplicate keyed selection literal";
|
|
331
|
+
start();
|
|
332
|
+
steps.push({ afterMs: 120, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta: text } })) });
|
|
333
|
+
finish(assistant(text), 400);
|
|
334
|
+
} else if (scenario === "pointer") {
|
|
335
|
+
const text = "pointer drag selection literal remains after update";
|
|
336
|
+
start();
|
|
337
|
+
steps.push(
|
|
338
|
+
{ afterMs: 120, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta: "pointer drag selection literal" } })) },
|
|
339
|
+
{ afterMs: 900, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta: " remains after update" } })) },
|
|
340
|
+
);
|
|
341
|
+
finish(assistant(text), 1_000);
|
|
342
|
+
} else if (scenario === "thinking") {
|
|
343
|
+
start();
|
|
344
|
+
steps.push(
|
|
345
|
+
{ afterMs: 120, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "thinking_delta", delta: "thinking selection literal" } })) },
|
|
346
|
+
{ afterMs: 650, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "thinking_delta", delta: " survives" } })) },
|
|
347
|
+
);
|
|
348
|
+
finish({ role: "assistant", content: [{ type: "thinking", thinking: "thinking selection literal survives" }, { type: "text", text: "thinking final answer" }], timestamp: Date.now() }, 450);
|
|
349
|
+
} else if (scenario === "tool") {
|
|
350
|
+
const toolCallId = `continuity-tool-${run}`;
|
|
351
|
+
steps.push(
|
|
352
|
+
{ afterMs: 40, run: () => emitScriptedEvent(tagged({ type: "agent_start" })) },
|
|
353
|
+
{ afterMs: 70, run: () => emitScriptedEvent(tagged({ type: "tool_execution_start", toolCallId, toolName: "read", args: { path: "continuity.txt" } })) },
|
|
354
|
+
{ afterMs: 100, run: () => emitScriptedEvent(tagged({ type: "tool_execution_update", toolCallId, toolName: "read", partialResult: { content: [{ type: "text", text: "tool selection literal\nunselected revision one" }] } })) },
|
|
355
|
+
{ afterMs: 700, run: () => emitScriptedEvent(tagged({ type: "tool_execution_update", toolCallId, toolName: "read", partialResult: { content: [{ type: "text", text: "tool selection literal\nunselected revision two" }] } })) },
|
|
356
|
+
{ afterMs: 600, run: () => emitScriptedEvent(tagged({ type: "tool_execution_end", toolCallId, toolName: "read", isError: false, result: { content: [{ type: "text", text: "tool selection literal\nunselected revision two" }] } })) },
|
|
357
|
+
);
|
|
358
|
+
finish(null, 120);
|
|
359
|
+
} else if (scenario === "authoritative") {
|
|
360
|
+
start();
|
|
361
|
+
steps.push({ afterMs: 120, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta: "authoritative selection literal" } })) });
|
|
362
|
+
finish(assistant("authoritative replacement text"), 700);
|
|
363
|
+
} else if (scenario === "cadence") {
|
|
364
|
+
const prefix = "high cadence selection literal\n\n";
|
|
365
|
+
let finalText = prefix;
|
|
366
|
+
start();
|
|
367
|
+
steps.push({ afterMs: 120, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta: prefix } })) });
|
|
368
|
+
steps.push({ afterMs: 800, run: () => {
|
|
369
|
+
for (let index = 0; index < 96; index += 1) {
|
|
370
|
+
const delta = `c${String(index).padStart(2, "0")} `;
|
|
371
|
+
finalText += delta;
|
|
372
|
+
emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta } }));
|
|
373
|
+
}
|
|
374
|
+
} });
|
|
375
|
+
finish(() => assistant(finalText), 500);
|
|
376
|
+
} else if (scenario === "dwell") {
|
|
377
|
+
const prefix = "thirty second selection literal anchor\n\n";
|
|
378
|
+
let finalText = prefix;
|
|
379
|
+
start();
|
|
380
|
+
steps.push({ afterMs: 120, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta: prefix } })) });
|
|
381
|
+
for (let index = 0; index < 300; index += 1) {
|
|
382
|
+
const delta = `d${String(index).padStart(3, "0")} `;
|
|
383
|
+
finalText += delta;
|
|
384
|
+
steps.push({ afterMs: 100, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta } })) });
|
|
385
|
+
}
|
|
386
|
+
finish(() => assistant(finalText), 200);
|
|
387
|
+
} else if (scenario === "mode") {
|
|
388
|
+
const text = "output mode transition literal";
|
|
389
|
+
start();
|
|
390
|
+
steps.push(
|
|
391
|
+
{ afterMs: 120, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta: text } })) },
|
|
392
|
+
{ afterMs: 3_000, run: () => emitScriptedEvent(tagged({ type: "webui_output_mode", protocolVersion: 1, activeMode: "compact-v1" })) },
|
|
393
|
+
);
|
|
394
|
+
finish(assistant(text), 1_200);
|
|
395
|
+
} else if (scenario === "mermaid") {
|
|
396
|
+
const text = "Mermaid source selection literal\n\n```mermaid\ngraph TD\n A-->B\n```\n\n";
|
|
397
|
+
start();
|
|
398
|
+
steps.push({ afterMs: 120, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta: text } })) });
|
|
399
|
+
finish(assistant(text), 1800);
|
|
400
|
+
} else {
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
runScriptedSteps(steps);
|
|
404
|
+
return true;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function handleTranscriptContinuityPrompt(command, base) {
|
|
408
|
+
if (!continuityModeEnabled) return false;
|
|
409
|
+
const match = String(command.message || "").trim().match(/^fixture transcript continuity (reverse|duplicate|pointer|thinking|tool|authoritative|cadence|dwell|mode|mermaid)$/);
|
|
410
|
+
if (!match) return false;
|
|
411
|
+
appendDynamicMessage({ role: "user", content: String(command.message), timestamp: Date.now() });
|
|
412
|
+
respond({ ...base, data: { output: `fake transcript continuity ${match[1]} accepted`, pid: process.pid } });
|
|
413
|
+
return runTranscriptContinuityScenario(match[1]);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
function handleMobileBlockerPrompt(command, base) {
|
|
417
|
+
if (String(command.message || "").trim() !== "fixture mobile blocker") return false;
|
|
418
|
+
respond({ ...base, data: { output: "mobile blocker fixture accepted" } });
|
|
419
|
+
emitEvent({ type: "agent_start" });
|
|
420
|
+
emitEvent({
|
|
421
|
+
type: "extension_ui_request",
|
|
422
|
+
id: "fixture_blocker_12345678",
|
|
423
|
+
method: "confirm",
|
|
424
|
+
title: "Fixture blocker",
|
|
425
|
+
message: "Confirm the background-tab blocker.",
|
|
426
|
+
});
|
|
427
|
+
return true;
|
|
428
|
+
}
|
|
429
|
+
|
|
277
430
|
function handleContinuityPrompt(command, base) {
|
|
278
|
-
if (!continuityModeEnabled
|
|
431
|
+
if (!continuityModeEnabled) return false;
|
|
432
|
+
const message = String(command.message || "").trim();
|
|
433
|
+
if (!["fixture continuity delayed stream", "fixture continuity delayed start", "fixture continuity confirmed before tool"].includes(message)) return false;
|
|
279
434
|
appendDynamicMessage({ role: "user", content: String(command.message), timestamp: Date.now() });
|
|
280
435
|
respond({ ...base, data: { output: "fake continuity stream accepted", pid: process.pid } });
|
|
281
|
-
|
|
436
|
+
if (message === "fixture continuity delayed start") runContinuityDelayedStart();
|
|
437
|
+
else if (message === "fixture continuity confirmed before tool") runContinuityConfirmedBeforeTool();
|
|
438
|
+
else runContinuityDelayedStream();
|
|
282
439
|
return true;
|
|
283
440
|
}
|
|
284
441
|
|
|
@@ -289,6 +446,16 @@ function handleLargePayloadPrompt(command, base) {
|
|
|
289
446
|
return true;
|
|
290
447
|
}
|
|
291
448
|
|
|
449
|
+
function handleSseFloodPrompt(command, base) {
|
|
450
|
+
if (!sseFloodEnabled || String(command.message || "").trim() !== "fixture sse flood") return false;
|
|
451
|
+
respond({ ...base, data: { output: "fake SSE flood accepted" } });
|
|
452
|
+
const payload = "s".repeat(8192);
|
|
453
|
+
for (let index = 0; index < 256; index += 1) {
|
|
454
|
+
emitEvent({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta: `${index}:${payload}` } });
|
|
455
|
+
}
|
|
456
|
+
return true;
|
|
457
|
+
}
|
|
458
|
+
|
|
292
459
|
function handleVoiceScriptPrompt(command, base) {
|
|
293
460
|
if (!voiceScriptsEnabled) return false;
|
|
294
461
|
const message = String(command.message || "");
|
|
@@ -326,6 +493,43 @@ function emitConversationStatus() {
|
|
|
326
493
|
});
|
|
327
494
|
}
|
|
328
495
|
|
|
496
|
+
function emitCodexFastModeStatus() {
|
|
497
|
+
emitEvent({
|
|
498
|
+
type: "extension_ui_request",
|
|
499
|
+
id: randomUUID(),
|
|
500
|
+
method: "setStatus",
|
|
501
|
+
statusKey: "codex-fast-mode",
|
|
502
|
+
statusText: codexFastModeEnabled ? "on" : "off",
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
function handleCodexFastModePrompt(command, base) {
|
|
507
|
+
const message = String(command.message || "").trim();
|
|
508
|
+
if (message === "fixture reject next codex fast mode mutation") {
|
|
509
|
+
rejectNextCodexFastModeMutation = true;
|
|
510
|
+
// Prompt routing marks the tab active before RPC dispatch; settle this control-only fixture
|
|
511
|
+
// synchronously so the following PUT exercises status confirmation rather than preflight busy.
|
|
512
|
+
emitEvent({ type: "agent_start" });
|
|
513
|
+
emitEvent({ type: "agent_settled" });
|
|
514
|
+
respond({ ...base, data: { output: "next Codex Fast mode mutation will be rejected" } });
|
|
515
|
+
return true;
|
|
516
|
+
}
|
|
517
|
+
const match = message.match(/^\/fast-mode(?:\s+(on|off|status))?$/i);
|
|
518
|
+
if (!match) return false;
|
|
519
|
+
const subcommand = String(match[1] || "").toLowerCase();
|
|
520
|
+
if (subcommand !== "status" && rejectNextCodexFastModeMutation) {
|
|
521
|
+
rejectNextCodexFastModeMutation = false;
|
|
522
|
+
respond({ ...base, data: { output: "Fast mode mutation rejected while busy" } });
|
|
523
|
+
return true;
|
|
524
|
+
}
|
|
525
|
+
if (!subcommand) codexFastModeEnabled = !codexFastModeEnabled;
|
|
526
|
+
else if (subcommand === "on") codexFastModeEnabled = true;
|
|
527
|
+
else if (subcommand === "off") codexFastModeEnabled = false;
|
|
528
|
+
emitCodexFastModeStatus();
|
|
529
|
+
respond({ ...base, data: { output: `Fast mode ${codexFastModeEnabled ? "on" : "off"}.` } });
|
|
530
|
+
return true;
|
|
531
|
+
}
|
|
532
|
+
|
|
329
533
|
function handleWebuiHelperPrompt(command, base) {
|
|
330
534
|
const message = String(command.message || "").trim();
|
|
331
535
|
const match = message.match(/^\/webui-helper\s+(\{[\s\S]*\})$/);
|
|
@@ -399,6 +603,17 @@ function handleWebuiHelperPrompt(command, base) {
|
|
|
399
603
|
currentToolArgs: "README.md",
|
|
400
604
|
model: agent.model || "anthropic/claude-opus-4-8:high",
|
|
401
605
|
thinking: agent.thinking || "high",
|
|
606
|
+
telemetry: {
|
|
607
|
+
promptInjectionTokens: 1234,
|
|
608
|
+
inputTokens: 300,
|
|
609
|
+
outputTokens: 100,
|
|
610
|
+
tokenSpeed: 20,
|
|
611
|
+
contextTokens: 240,
|
|
612
|
+
contextWindow: 200_000,
|
|
613
|
+
model: null,
|
|
614
|
+
effort: null,
|
|
615
|
+
rawSessionPayload: "must not leave fake helper telemetry",
|
|
616
|
+
},
|
|
402
617
|
recentTools: [{ tool: "grep", args: "Subagents", endMs: Date.now() - 200 }],
|
|
403
618
|
recentOutput: ["Inspecting current implementation", "Waiting for the next tool result"],
|
|
404
619
|
transcript: [
|
|
@@ -748,6 +963,7 @@ rl.on("line", (line) => {
|
|
|
748
963
|
{ name: "talk", source: "extension", description: "Toggle Natural Conversation Mode" },
|
|
749
964
|
{ name: "voice", source: "extension", description: "Natural Conversation Mode alias" },
|
|
750
965
|
{ name: "conversation", source: "extension", description: "Natural Conversation Mode alias" },
|
|
966
|
+
{ name: "fast-mode", source: "extension", description: "Toggle Codex subscription Fast mode" },
|
|
751
967
|
{ name: "workflow", source: "extension", description: "Run and inspect JavaScript workflows" },
|
|
752
968
|
],
|
|
753
969
|
},
|
|
@@ -777,9 +993,13 @@ rl.on("line", (line) => {
|
|
|
777
993
|
if (handleSubagentFixturePrompt(command, base)) return;
|
|
778
994
|
if (handleDocumentArtifactFixturePrompt(command, base)) return;
|
|
779
995
|
if (handleWorkflowFixturePrompt(command, base)) return;
|
|
996
|
+
if (handleCodexFastModePrompt(command, base)) return;
|
|
780
997
|
if (handleTalkPrompt(command, base)) return;
|
|
998
|
+
if (handleMobileBlockerPrompt(command, base)) return;
|
|
999
|
+
if (handleTranscriptContinuityPrompt(command, base)) return;
|
|
781
1000
|
if (handleContinuityPrompt(command, base)) return;
|
|
782
1001
|
if (handleLargePayloadPrompt(command, base)) return;
|
|
1002
|
+
if (handleSseFloodPrompt(command, base)) return;
|
|
783
1003
|
if (handleVoiceScriptPrompt(command, base)) return;
|
|
784
1004
|
respond({ ...base, data: { output: "fake prompt accepted" } });
|
|
785
1005
|
return;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
|
+
const app = await readFile(join(root, "public", "app.js"), "utf8");
|
|
8
|
+
|
|
9
|
+
function functionBody(name) {
|
|
10
|
+
const start = app.indexOf(`function ${name}(`);
|
|
11
|
+
assert.notEqual(start, -1, `${name} should be defined`);
|
|
12
|
+
const next = app.indexOf("\nfunction ", start + 1);
|
|
13
|
+
return app.slice(start, next === -1 ? app.length : next);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const menuItems = functionBody("gitPanelContextMenuItems");
|
|
17
|
+
const runAction = functionBody("runGitPanelAction");
|
|
18
|
+
|
|
19
|
+
// Repository menus must not gain the action.
|
|
20
|
+
const repositoryBranch = menuItems.slice(
|
|
21
|
+
menuItems.indexOf('if (kind === "repository")'),
|
|
22
|
+
menuItems.indexOf('const target = kind === "folder"'),
|
|
23
|
+
);
|
|
24
|
+
assert.ok(repositoryBranch.length > 0, "the repository menu branch should still exist");
|
|
25
|
+
assert.doesNotMatch(repositoryBranch, /gitignore/i, "repository context menus should not offer the .gitignore action");
|
|
26
|
+
|
|
27
|
+
// File/folder menus share one action entry that carries the selected kind.
|
|
28
|
+
assert.match(
|
|
29
|
+
menuItems,
|
|
30
|
+
/const ignoreAction = target === "folder" \? "ignore-folder" : "ignore-file";/,
|
|
31
|
+
"the menu should select the ignore action matching the selected row kind",
|
|
32
|
+
);
|
|
33
|
+
assert.match(
|
|
34
|
+
menuItems,
|
|
35
|
+
/const ignoreItem = \{ label: "Add to \.gitignore", disabled: gitPanelActionBusy\(card, ignoreAction, path\), run: \(\) => runGitPanelAction\(card, ignoreAction, path\) \};/,
|
|
36
|
+
"file and folder menus should share one busy-aware Add to .gitignore item",
|
|
37
|
+
);
|
|
38
|
+
assert.match(
|
|
39
|
+
menuItems,
|
|
40
|
+
/const target = kind === "folder" \? "folder" : "file";/,
|
|
41
|
+
"the action should resolve exactly the file or folder kind accepted by the endpoint",
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// Staged rows keep their early return but still include the action.
|
|
45
|
+
const stagedBranch = menuItems.slice(
|
|
46
|
+
menuItems.indexOf('if (category === "staged")'),
|
|
47
|
+
menuItems.indexOf("const stageLabel ="),
|
|
48
|
+
);
|
|
49
|
+
assert.match(stagedBranch, /Unstage \$\{target\}/, "the staged branch should keep its unstage item");
|
|
50
|
+
assert.match(stagedBranch, /\bignoreItem,/, "the staged early-return branch should also offer Add to .gitignore");
|
|
51
|
+
|
|
52
|
+
// Changed/conflicted/untracked menus include the action before destructive controls.
|
|
53
|
+
const ignoreIndex = menuItems.indexOf("run: () => runGitPanelAction(card, \"stage\", path) }, ignoreItem]");
|
|
54
|
+
assert.ok(ignoreIndex > 0, "non-staged menus should list Add to .gitignore next to the stage item");
|
|
55
|
+
assert.ok(
|
|
56
|
+
ignoreIndex < menuItems.indexOf('label: "Discard changes…"') &&
|
|
57
|
+
ignoreIndex < menuItems.indexOf('label: "Delete file…"'),
|
|
58
|
+
"Add to .gitignore should be ordered ahead of the destructive discard/delete controls",
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
// Action flow: route, body, and kind handling.
|
|
62
|
+
assert.match(
|
|
63
|
+
app,
|
|
64
|
+
/async function runGitPanelAction\(card, action, path = ""\) \{/,
|
|
65
|
+
"the shared action runner should keep its existing signature",
|
|
66
|
+
);
|
|
67
|
+
assert.match(
|
|
68
|
+
runAction,
|
|
69
|
+
/const gitignoreAction = \(kind\) => \(\{\s*url: "\/api\/git-changes\/add-to-gitignore",\s*body: \{ path, kind \},/,
|
|
70
|
+
"the ignore action should POST path and kind to the approved endpoint",
|
|
71
|
+
);
|
|
72
|
+
assert.match(runAction, /"ignore-file": gitignoreAction\("file"\),/, "file rows should send kind file");
|
|
73
|
+
assert.match(runAction, /"ignore-folder": gitignoreAction\("folder"\),/, "folder rows should send kind folder");
|
|
74
|
+
|
|
75
|
+
// Feedback distinguishes newly added entries from already-present ones.
|
|
76
|
+
const ignoreConfig = runAction.slice(runAction.indexOf("const gitignoreAction ="), runAction.indexOf("const config = {"));
|
|
77
|
+
assert.match(ignoreConfig, /data\?\.added/, "success feedback should read the response added flag");
|
|
78
|
+
assert.match(ignoreConfig, /data\?\.entry \|\| path/, "success feedback should prefer the normalized response entry");
|
|
79
|
+
assert.match(ignoreConfig, /Added \$\{data\?\.entry \|\| path\} to \.gitignore\./, "newly added entries should report an addition");
|
|
80
|
+
assert.match(ignoreConfig, /\$\{data\?\.entry \|\| path\} is already in \.gitignore\./, "already-present entries should not claim an addition");
|
|
81
|
+
assert.match(ignoreConfig, /Tracked files stay tracked until removed from the index\./, "success feedback should clarify that .gitignore does not untrack indexed files");
|
|
82
|
+
assert.doesNotMatch(ignoreConfig, /confirm/, "the ignore action should not introduce confirmation UI");
|
|
83
|
+
assert.match(
|
|
84
|
+
runAction,
|
|
85
|
+
/addEvent\(typeof config\.done === "function" \? config\.done\(response\.data\) : config\.past, "success"\);/,
|
|
86
|
+
"response-derived feedback should replace the static past-tense message only when configured",
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
// Regression: shared busy, error, and refresh behavior stays in the flow.
|
|
90
|
+
assert.match(runAction, /const busyKey = `\$\{card\.root\}\\u0000\$\{action\}\\u0000\$\{path\}`;/, "the ignore action should reuse the shared busy key scheme");
|
|
91
|
+
assert.match(runAction, /if \(gitPanelState\.busy\.has\(busyKey\)\) return;/, "concurrent duplicate actions should still be blocked");
|
|
92
|
+
assert.match(runAction, /gitPanelState\.busy\.add\(busyKey\);/, "the shared busy state should still be set before the request");
|
|
93
|
+
assert.match(runAction, /gitPanelState\.busy\.delete\(busyKey\);/, "the shared busy state should still be cleared afterwards");
|
|
94
|
+
assert.match(runAction, /if \(!response\.ok\) throw new Error/, "the shared error path should still reject failed responses");
|
|
95
|
+
assert.match(runAction, /await loadGitPanelRepository\(card, \{ force: true \}\);/, "successful actions should still force a Git repository refresh");
|
|
96
|
+
assert.match(runAction, /requestGitFooterWebuiPayload\(\{ tabId: card\.tabId \}, \{ force: true \}\);/, "successful actions should still refresh footer Git state");
|
|
97
|
+
|
|
98
|
+
// Regression: existing actions keep their static messages and endpoints.
|
|
99
|
+
assert.match(runAction, /stage: \{ url: "\/api\/git-changes\/stage-file", body: \{ path \}, past: `Staged \$\{path\}\.` \}/, "the stage action should be unchanged");
|
|
100
|
+
assert.match(runAction, /unstage: \{ url: "\/api\/git-changes\/unstage-file", body: \{ path \}, past: `Unstaged \$\{path\}\.` \}/, "the unstage action should be unchanged");
|
|
101
|
+
assert.match(runAction, /url: "\/api\/git-changes\/discard-file"/, "the discard action should be unchanged");
|
|
102
|
+
assert.match(runAction, /url: "\/api\/git-changes\/delete-untracked"/, "the delete action should be unchanged");
|
|
103
|
+
|
|
104
|
+
console.log("git-panel-gitignore-static.test.mjs passed");
|