@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
|
@@ -0,0 +1,254 @@
|
|
|
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
|
+
const renderer = await readFile(join(root, "public", "transcript-renderer.mjs"), "utf8");
|
|
9
|
+
|
|
10
|
+
function functionBody(name, source = app) {
|
|
11
|
+
const signature = new RegExp(`function\\s+${name}\\s*\\(`, "m");
|
|
12
|
+
const match = signature.exec(source);
|
|
13
|
+
assert.ok(match, `${name} should remain a standalone frontend helper`);
|
|
14
|
+
let parenDepth = 0;
|
|
15
|
+
let openBrace = -1;
|
|
16
|
+
for (let index = match.index + match[0].length - 1; index < source.length; index += 1) {
|
|
17
|
+
const char = source[index];
|
|
18
|
+
if (char === "(") parenDepth += 1;
|
|
19
|
+
else if (char === ")") parenDepth -= 1;
|
|
20
|
+
else if (char === "{" && parenDepth === 0) {
|
|
21
|
+
openBrace = index;
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
assert.notEqual(openBrace, -1, `${name} body should open`);
|
|
26
|
+
let depth = 0;
|
|
27
|
+
for (let index = openBrace; index < source.length; index += 1) {
|
|
28
|
+
const char = source[index];
|
|
29
|
+
if (char === "{") depth += 1;
|
|
30
|
+
else if (char === "}") {
|
|
31
|
+
depth -= 1;
|
|
32
|
+
if (depth === 0) return source.slice(openBrace + 1, index);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
assert.fail(`${name} body should close`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const captureControl = functionBody("captureScopedControlContinuity");
|
|
39
|
+
const restoreControl = functionBody("restoreScopedControlContinuity");
|
|
40
|
+
const setScroll = functionBody("setScopedScrollContinuity");
|
|
41
|
+
const rememberScroll = functionBody("rememberScopedScrollContinuity");
|
|
42
|
+
const bindScroll = functionBody("bindScopedScrollContinuity");
|
|
43
|
+
const restoreScroll = functionBody("restoreScopedScrollContinuity");
|
|
44
|
+
const deferPointer = functionBody("deferUiRenderDuringPointerActivation");
|
|
45
|
+
const deferSurface = functionBody("deferUiRenderDuringInteractiveSurface");
|
|
46
|
+
const flushDeferred = functionBody("flushDeferredUiRenders");
|
|
47
|
+
const captureTooltip = functionBody("captureTooltipContinuity");
|
|
48
|
+
const restoreTooltip = functionBody("restoreTooltipContinuity");
|
|
49
|
+
const renderTabs = functionBody("renderTabs");
|
|
50
|
+
const renderFooter = functionBody("renderFooter");
|
|
51
|
+
const renderFileTree = functionBody("renderFileTree");
|
|
52
|
+
const renderWidgets = functionBody("renderWidgets");
|
|
53
|
+
const renderSubagents = functionBody("renderSubagents");
|
|
54
|
+
const renderGitWorkflow = functionBody("renderGitWorkflow");
|
|
55
|
+
const renderGitPanel = functionBody("renderGitPanel");
|
|
56
|
+
const renderQueue = functionBody("renderQueue");
|
|
57
|
+
const captureChatText = functionBody("captureChatTextSelection");
|
|
58
|
+
const matchChatText = functionBody("chatTextSelectionMatch");
|
|
59
|
+
const restoreChatText = functionBody("restoreChatTextSelection");
|
|
60
|
+
const renderAllMessages = functionBody("renderAllMessages");
|
|
61
|
+
const renderStreamingMarkdown = functionBody("renderStreamingMarkdown");
|
|
62
|
+
const refreshMessages = functionBody("refreshMessages");
|
|
63
|
+
const captureMobileSurface = functionBody("captureMobileSurfaceRenderFocus");
|
|
64
|
+
const restoreMobileSurface = functionBody("restoreMobileSurfaceRenderFocus");
|
|
65
|
+
const captureAppRunnerInput = functionBody("captureAppRunnerInputFocus");
|
|
66
|
+
const restoreAppRunnerInput = functionBody("restoreAppRunnerInputFocus");
|
|
67
|
+
const captureGitInput = functionBody("captureGitWorkflowInputFocus");
|
|
68
|
+
const restoreGitInput = functionBody("restoreGitWorkflowInputFocus");
|
|
69
|
+
|
|
70
|
+
assert.match(captureControl, /root\?\.contains\(source\)/, "control capture must be scoped to the renderer root");
|
|
71
|
+
assert.match(captureControl, /const targetKey = targetKeyFor\?\.\(source\);[\s\S]*if \(!targetKey\) return null;/, "control capture requires a semantic target key");
|
|
72
|
+
assert.match(captureControl, /contextKey,[\s\S]*selectionStart:[\s\S]*selectionEnd:[\s\S]*selectionDirection:[\s\S]*scrollTop:[\s\S]*scrollLeft:/, "control snapshots must retain context, selection direction, and both control scroll axes");
|
|
73
|
+
assert.match(restoreControl, /snapshot\.contextKey !== contextKey \|\| document\.activeElement === snapshot\.source/, "restore must reject mismatched contexts and leave an already-focused surviving source alone");
|
|
74
|
+
assert.match(restoreControl, /isMeaningfulConnectedFocus\(document\.activeElement\)/, "restore must not steal focus from a meaningful connected target");
|
|
75
|
+
assert.match(restoreControl, /snapshot\.source\.isConnected && root\?\.contains\(snapshot\.source\)[\s\S]*targetForKey\?\.\(snapshot\.targetKey\)[\s\S]*root\?\.contains\(target\)[\s\S]*target\.disabled/, "restore must prefer a surviving reattached control or resolve a valid replacement inside its root");
|
|
76
|
+
assert.match(restoreControl, /target\.focus\(\{ preventScroll: true \}\)[\s\S]*setSelectionRange\(start, end, snapshot\.selectionDirection \|\| "none"\)/, "restore must restore focus and directional selection without scrolling the page");
|
|
77
|
+
assert.match(restoreControl, /target\.scrollTop = Math\.min[\s\S]*target\.scrollLeft = Math\.min/, "restore must bound control scroll rather than applying stale offsets blindly");
|
|
78
|
+
|
|
79
|
+
assert.match(captureTooltip, /footerTooltipTarget \|\| footerTooltipPendingTarget[\s\S]*root\?\.contains\(target\)[\s\S]*tooltipTargetKey\(target\)[\s\S]*target\.matches\?\.\(":hover"\)[\s\S]*remainingDelay:/, "tooltip capture must use a root-local semantic target and retain any in-progress hover delay");
|
|
80
|
+
assert.match(restoreTooltip, /querySelectorAll\?\.\("\[data-tooltip-target-key\]"\)[\s\S]*tooltipTargetKey\(node\) === snapshot\.key/, "tooltip restore must find the semantic replacement rather than reusing detached DOM");
|
|
81
|
+
assert.match(restoreTooltip, /!target \|\| !target\.hasAttribute\("data-tooltip"\)[\s\S]*hideFooterTooltip\(snapshot\.target\)/, "removed or inapplicable tooltip targets must close the old tooltip");
|
|
82
|
+
assert.match(restoreTooltip, /snapshot\.pending\) scheduleFooterTooltip\(target, snapshot\.remainingDelay\)[\s\S]*showFooterTooltip\(target\)/, "surviving visible tooltips must rebind synchronously while pending tooltips retain only their remaining delay");
|
|
83
|
+
|
|
84
|
+
assert.match(setScroll, /scopedScrollContinuityByKey\.delete\(key\)[\s\S]*size > SCOPED_SCROLL_CONTINUITY_LIMIT[\s\S]*keys\(\)\.next\(\)\.value/, "scroll continuity must use bounded recency storage");
|
|
85
|
+
assert.match(rememberScroll, /!node\?\.isConnected \|\| !key[\s\S]*const previous = scopedScrollContinuityByKey\.get\(key\);[\s\S]*preserveMode && previous \? previous\.mode : maxScrollTop - node\.scrollTop <= 24 \? "follow-end" : "position"/, "scroll capture must ignore detached stale emitters and latch reader mode across programmatic renders");
|
|
86
|
+
assert.match(bindScroll, /dataset\.continuityScrollKey = key[\s\S]*_scopedScrollContinuityUserIntentUntil[\s\S]*rememberScopedScrollContinuity\(node, undefined, \{ allowPendingRestore: userInitiated, preserveMode: !userInitiated \}\)/, "scroll listeners must resolve the current semantic key and only change mode after user intent");
|
|
87
|
+
assert.match(restoreScroll, /requestAnimationFrame[\s\S]*state\.mode === "follow-end" \? maxScrollTop : Math\.min/, "scroll restore must apply its mode after layout and bound a retained position");
|
|
88
|
+
assert.match(app, /bindScopedScrollContinuity\(terminal, scrollKey\)[\s\S]*restoreScopedScrollContinuity\(terminal, scrollKey\)/, "app-runner output must participate in explicit scroll continuity");
|
|
89
|
+
assert.match(app, /bindScopedScrollContinuity\(transcript, scrollKey\)[\s\S]*restoreScopedScrollContinuity\(transcript, scrollKey\)/, "subagent transcript output must participate in explicit scroll continuity");
|
|
90
|
+
|
|
91
|
+
assert.match(deferPointer, /shouldDeferUiRenderForPointerActivation\(\)[\s\S]*deferredUiRenderCallbacks\.set\(key, callback\)/, "pointer-active updates must defer through a latest-wins keyed callback map");
|
|
92
|
+
assert.match(deferSurface, /isInteractiveDropdownOpen\(\)[\s\S]*deferredUiRenderCallbacks\.set\(key, callback\)[\s\S]*scheduleDeferredUiFlushAfterDropdownClose\(\)/, "open interactive surfaces must defer their invalidation until they close");
|
|
93
|
+
assert.match(flushDeferred, /\[\.\.\.deferredUiRenderCallbacks\.values\(\)\][\s\S]*deferredUiRenderCallbacks\.clear\(\)[\s\S]*for \(const callback of callbacks\)/, "deferred renders must coalesce and flush each retained callback once");
|
|
94
|
+
|
|
95
|
+
for (const [name, source, root] of [
|
|
96
|
+
["terminal tabs", renderTabs, "elements.tabBar"],
|
|
97
|
+
["footer", renderFooter, "elements.statusBar"],
|
|
98
|
+
["file tree", renderFileTree, "root"],
|
|
99
|
+
["widgets", renderWidgets, "elements.widgetArea"],
|
|
100
|
+
["subagent panel", renderSubagents, "box"],
|
|
101
|
+
]) {
|
|
102
|
+
assert.match(source, /deferUiRenderDuringPointerActivation/, `${name} must participate in primary-pointer deferral`);
|
|
103
|
+
assert.match(source, /captureScopedControlContinuity|captureScopedScrollContinuity/, `${name} must capture only its own continuity state`);
|
|
104
|
+
if (name === "terminal tabs" || name === "footer" || name === "file tree" || name === "subagent panel") {
|
|
105
|
+
assert.match(source, new RegExp(`restoreScopedControlContinuity\\(${root.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`), `${name} must restore through its own root`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
assert.match(renderTabs, /captureTooltipContinuity\(elements\.tabBar\)[\s\S]*restoreTooltipContinuity\(elements\.tabBar, tooltipSnapshot\)/, "terminal-tab rerenders must retain semantic tooltip continuity");
|
|
109
|
+
assert.match(renderFooter, /captureTooltipContinuity\(elements\.statusBar\)[\s\S]*restoreTooltipContinuity\(elements\.statusBar, tooltipSnapshot\)/, "footer rerenders must retain semantic tooltip continuity");
|
|
110
|
+
assert.match(renderGitWorkflow, /captureGitWorkflowInputFocus\(\)[\s\S]*deferUiRenderDuringPointerActivation\("git-workflow", renderGitWorkflow\)[\s\S]*restoreGitWorkflowInputFocus\(inputFocus\)/, "guided Git renders must defer pointer teardown and restore only their captured input");
|
|
111
|
+
|
|
112
|
+
assert.match(captureAppRunnerInput, /activeTabContext\(\)[\s\S]*selectionDirection:[\s\S]*scrollTop:[\s\S]*scrollLeft:/, "app-runner input capture must include its tab context and complete text-control state");
|
|
113
|
+
assert.match(restoreAppRunnerInput, /isCurrentTabContext\(state\.context\) \|\| state\.source\?\.isConnected/, "app-runner input restore must reject stale tab contexts and connected sources");
|
|
114
|
+
assert.match(restoreAppRunnerInput, /isMeaningfulConnectedFocus\(document\.activeElement\)[\s\S]*elements\.widgetArea\.querySelectorAll\("\.app-runner-stdin-input"\)[\s\S]*candidate\.dataset\.runId === state\.runId/, "app-runner input restore must stay inside the widget root and match runner identity");
|
|
115
|
+
assert.match(captureGitInput, /activeTabContext\(\)[\s\S]*selectionDirection:[\s\S]*scrollTop:[\s\S]*scrollLeft:/, "Guided Git input capture must include its context and complete text-control state");
|
|
116
|
+
assert.match(restoreGitInput, /state\.tabId !== activeTabId \|\| state\.runId !== gitWorkflow\?\.runId \|\| !isCurrentTabContext\(state\.context\) \|\| state\.source\?\.isConnected/, "Guided Git input restore must require the exact tab, run, and current context");
|
|
117
|
+
|
|
118
|
+
assert.match(renderGitPanel, /captureScopedControlContinuity\(elements\.gitPanelGroups[\s\S]*data-git-panel-continuity-key[\s\S]*scrollTop = scrollTop/, "Git-panel rebuilds must preserve semantic focus and panel scroll");
|
|
119
|
+
assert.match(renderQueue, /captureScopedControlContinuity\(elements\.queueBox[\s\S]*data-queue-continuity-key[\s\S]*restoreContinuity\(\)/, "queue rebuilds must preserve semantic action focus and panel scroll");
|
|
120
|
+
assert.match(app, /dataset\.mobileContinuityKey = "context:paste-text"[\s\S]*dataset\.mobileDraftAuthority = "dom"/, "mobile paste text must have a stable DOM-authoritative continuity identity");
|
|
121
|
+
assert.match(captureMobileSurface, /mobileDraftAuthority === "dom"[\s\S]*selectionDirection:[\s\S]*scrollTop:[\s\S]*scrollLeft:/, "mobile DOM drafts must capture selection and scroll state");
|
|
122
|
+
assert.match(restoreMobileSurface, /target\.dataset\.mobileDraftAuthority === "dom"[\s\S]*target\.value = snapshot\.value[\s\S]*setSelectionRange[\s\S]*target\.focus\(\{ preventScroll: true \}\)/, "mobile DOM drafts must restore value, selection, scroll, and focus");
|
|
123
|
+
|
|
124
|
+
assert.match(captureChatText, /selection\.isCollapsed[\s\S]*anchorSurface !== focusSurface[\s\S]*chatTextSelectionContextKey\(\)[\s\S]*itemKey:[\s\S]*streaming:[\s\S]*anchorOffset,[\s\S]*focusOffset,[\s\S]*text,/, "main-output selection capture must require one semantic text surface and retain context, identity, direction, and exact text");
|
|
125
|
+
assert.match(matchChatText, /range\.toString\(\) === snapshot\.text/, "main-output selection restoration must reject offsets whose rendered text changed");
|
|
126
|
+
assert.match(restoreChatText, /snapshot\.contextKey !== chatTextSelectionContextKey\(\)[\s\S]*chatTextSelectionCandidates\(snapshot\)[\s\S]*candidates\.includes\(currentAnchorSurface\)[\s\S]*currentText && currentAnchorSurface && currentFocusSurface[\s\S]*setBaseAndExtent/, "main-output selection restoration must reject stale contexts and meaningful newer selections while preserving anchor direction");
|
|
127
|
+
assert.match(renderStreamingMarkdown, /captureChatTextSelection\(block\)[\s\S]*restoreChatTextSelection\(selectionSnapshot\)/, "streaming Markdown tail replacement must preserve a still-valid browser Range");
|
|
128
|
+
assert.match(renderAllMessages, /captureChatTextSelection\(\)[\s\S]*restoreChatTextSelection\(selectionSnapshot\)/, "authoritative transcript rerenders must preserve a still-valid main-output Range");
|
|
129
|
+
assert.match(refreshMessages, /const selectionSnapshot = captureChatTextSelection\(\);[\s\S]*adoptedOutput = adoptLiveAssistantBubble\(latestMessages\)[\s\S]*resetStreamBubble\(\{ preserveCompact: adoptedOutput === "compact" \}\)[\s\S]*restoreStreamRenderAfterChatRebuild\(\)[\s\S]*restoreChatTextSelection\(selectionSnapshot\)/, "stream settlement must adopt matching normal or compact output before reset and retain exact fallback selection");
|
|
130
|
+
|
|
131
|
+
// --- Transcript mutation coordinator contracts (keyed DOM ownership) ---
|
|
132
|
+
|
|
133
|
+
const renderThinkingMarkdown = functionBody("renderThinkingMarkdown");
|
|
134
|
+
const flushCompactLiveOutput = functionBody("flushCompactLiveOutput");
|
|
135
|
+
const updateLiveToolCard = functionBody("updateLiveToolCard");
|
|
136
|
+
const renderLiveToolRun = functionBody("renderLiveToolRun");
|
|
137
|
+
const renderMermaidDiagram = functionBody("renderMermaidDiagram");
|
|
138
|
+
const renderStreamingToolCallCard = functionBody("renderStreamingToolCallCard");
|
|
139
|
+
const adoptLiveAssistantBubble = functionBody("adoptLiveAssistantBubble");
|
|
140
|
+
const authoritativeAssistantTextForAdoption = functionBody("authoritativeAssistantTextForAdoption");
|
|
141
|
+
const resetChatOutput = functionBody("resetChatOutput");
|
|
142
|
+
const ownTranscriptBubble = functionBody("ownTranscriptBubble");
|
|
143
|
+
const transcriptSurfaceKind = functionBody("transcriptSurfaceKind");
|
|
144
|
+
const ensureStreamBubble = functionBody("ensureStreamBubble");
|
|
145
|
+
const ensureStreamingThinkingBubble = functionBody("ensureStreamingThinkingBubble");
|
|
146
|
+
const ensureCompactTextBubble = functionBody("ensureCompactTextBubble");
|
|
147
|
+
const ensureCompactThinkingBubble = functionBody("ensureCompactThinkingBubble");
|
|
148
|
+
const renderCompactToolShell = functionBody("renderCompactToolShell");
|
|
149
|
+
const removeLiveTranscriptBubble = functionBody("removeLiveTranscriptBubble");
|
|
150
|
+
const removeStreamingThinkingBubble = functionBody("removeStreamingThinkingBubble");
|
|
151
|
+
const removeStreamBubble = functionBody("removeStreamBubble");
|
|
152
|
+
const removeCompactLiveBubble = functionBody("removeCompactLiveBubble");
|
|
153
|
+
const finalizeAdoptedAssistantBubble = functionBody("finalizeAdoptedAssistantBubble");
|
|
154
|
+
const prunePendingTranscriptAdoptions = functionBody("prunePendingTranscriptAdoptions");
|
|
155
|
+
|
|
156
|
+
const commitTranscriptMutation = functionBody("commitTranscriptMutation", renderer);
|
|
157
|
+
const applyMutation = functionBody("applyMutation", renderer);
|
|
158
|
+
const reconcileMarkdownSurface = functionBody("reconcileMarkdownSurface", renderer);
|
|
159
|
+
const updateTextSurface = functionBody("updateTextSurface", renderer);
|
|
160
|
+
const ownMessage = functionBody("ownMessage", renderer);
|
|
161
|
+
const ownSurface = functionBody("ownSurface", renderer);
|
|
162
|
+
const ownBlocks = functionBody("ownBlocks", renderer);
|
|
163
|
+
const restoreCoordinatedSelection = functionBody("restoreSelection", renderer);
|
|
164
|
+
const rangeForSnapshot = functionBody("rangeForSnapshot", renderer);
|
|
165
|
+
const coordinatedTextPoint = functionBody("textPoint", renderer);
|
|
166
|
+
const logMutation = functionBody("logMutation", renderer);
|
|
167
|
+
|
|
168
|
+
// Coordinator import and initialization.
|
|
169
|
+
assert.match(app, /import \{ createTranscriptRenderer \} from "\.\/transcript-renderer\.mjs";/, "app must import the transcript mutation coordinator module");
|
|
170
|
+
assert.match(app, /const transcriptRenderer = createTranscriptRenderer\(\{[\s\S]*?chat: elements\.chat[\s\S]*?contextKey: \(\) => chatTextSelectionContextKey\(\)[\s\S]*?\}\);/, "the coordinator must be initialized once against #chat with the transcript context key");
|
|
171
|
+
assert.doesNotMatch(renderer, /^\s*import\s/m, "the transcript renderer must stay dependency-free");
|
|
172
|
+
assert.match(renderer, /export function createTranscriptRenderer\(/, "the coordinator must be the module's exported factory");
|
|
173
|
+
assert.match(renderer, /if \(!chat\) throw new Error/, "the coordinator must require the transcript root");
|
|
174
|
+
|
|
175
|
+
// Semantic message/surface/block ownership.
|
|
176
|
+
assert.match(ownMessage, /dataset\.transcriptMessageKey[\s\S]*dataset\.transcriptRole/, "messages must receive durable semantic keys and roles");
|
|
177
|
+
assert.match(ownSurface, /dataset\.transcriptSurface = kind[\s\S]*dataset\.transcriptSurfaceKey/, "surfaces must receive durable semantic kind and identity keys");
|
|
178
|
+
assert.match(ownBlocks, /dataset\.transcriptBlockKey[\s\S]*dataset\.transcriptBlock = tail \? "mutable-tail" : "committed"/, "streamed Markdown blocks must carry stable committed-block versus mutable-tail identity");
|
|
179
|
+
assert.match(transcriptSurfaceKind, /role === "thinking"[\s\S]*"assistant-thinking"[\s\S]*role === "toolExecution"[\s\S]*"tool-execution"[\s\S]*role === "toolResult"[\s\S]*"tool-result"[\s\S]*role === "compactionSummary"[\s\S]*"compaction-summary"[\s\S]*return "assistant-final"/, "surface kinds must cover assistant, thinking, tool execution/result, and compaction surfaces");
|
|
180
|
+
assert.match(ownTranscriptBubble, /transcriptRenderer\.ownMessage\(bubble, \{ key: itemKey \|\| bubble\.dataset\.itemKey \|\| fallbackKey, role \}\)[\s\S]*surfaces\.forEach\(\(surface, index\) => transcriptRenderer\.ownSurface/, "every transcript bubble and its selectable surfaces must receive semantic ownership");
|
|
181
|
+
assert.match(ensureStreamBubble, /transcriptRenderer\.ownSurface\(streamText, \{ messageKey: "live:assistant", kind: "assistant-final", segment: "0" \}\)/, "the live assistant surface must be semantically owned");
|
|
182
|
+
assert.match(ensureStreamingThinkingBubble, /transcriptRenderer\.ownSurface\(streamThinking, \{ messageKey: "live:thinking", kind: "assistant-thinking", segment: "0" \}\)/, "the live thinking surface must be semantically owned");
|
|
183
|
+
assert.match(ensureCompactTextBubble, /transcriptRenderer\.ownSurface\(compactTextNode, \{ messageKey: "live:compact-output", kind: "compact-output", segment: "0" \}\)/, "the compact live-output surface must be semantically owned");
|
|
184
|
+
assert.match(ensureCompactThinkingBubble, /transcriptRenderer\.ownSurface\(compactThinkingNode, \{ messageKey: "live:compact-thinking", kind: "assistant-thinking", segment: "0" \}\)/, "the compact thinking surface must be semantically owned");
|
|
185
|
+
assert.match(renderCompactToolShell, /transcriptRenderer\.ownMessage\(bubble, \{ key: `live:compact-tool:\$\{id\}`, role: "toolExecution" \}\)[\s\S]*transcriptRenderer\.ownSurface\(body, \{ messageKey: `live:compact-tool:\$\{id\}`, kind: "tool-execution"/, "compact tool shells must receive semantic message and surface ownership");
|
|
186
|
+
|
|
187
|
+
// Normal/compact/thinking/tool/Mermaid routing through the coordinator.
|
|
188
|
+
assert.match(renderStreamingMarkdown, /transcriptRenderer\.reconcileMarkdownSurface\(\{[\s\S]*?kind: "assistant-final"[\s\S]*?stableBoundary: streamingMarkdownStableBoundary[\s\S]*?renderInto: renderMarkdownInto/, "normal streaming output must route through the coordinator committed-block reconciler");
|
|
189
|
+
assert.match(renderThinkingMarkdown, /transcriptRenderer\.reconcileMarkdownSurface\(\{[\s\S]*?kind: "assistant-thinking"[\s\S]*?stableBoundary: streamingMarkdownStableBoundary[\s\S]*?renderInto: renderMarkdownInto/, "streaming thinking must share the same committed-block reconciler");
|
|
190
|
+
assert.match(flushCompactLiveOutput, /transcriptRenderer\.updateTextSurface\(\{[\s\S]*?surface: compactTextNode[\s\S]*?kind: "compact-output"/, "compact live output must update a stable text surface through the coordinator");
|
|
191
|
+
assert.match(flushCompactLiveOutput, /renderThinkingMarkdown\(compactThinkingNode, compactLiveState\.thinking\)/, "compact thinking must share the thinking reconciler path");
|
|
192
|
+
assert.match(updateLiveToolCard, /transcriptRenderer\.ownMessage\(bubble, \{ key: messageKey, role: "toolExecution" \}\)[\s\S]*transcriptRenderer\.ownSurface\(body, \{ messageKey, kind: "tool-execution"[\s\S]*transcriptRenderer\.commitTranscriptMutation\(\{[\s\S]*?kind: "reconcile"[\s\S]*?transcriptRenderer\.replaceChildren\(body\)[\s\S]*?transcriptRenderer\.ownSurface\(body, \{ messageKey, kind: "tool-execution"/, "live tool body must have semantic ownership before selection capture and remain inside one coordinator-owned transaction");
|
|
193
|
+
assert.match(renderLiveToolRun, /key: `tool-replace:\$\{id\}`[\s\S]*kind: "reconcile"[\s\S]*mutate: \(\) => existing\.replaceWith\(created\.bubble\)/, "live tool card replacement must be a coordinator transaction");
|
|
194
|
+
assert.match(renderMermaidDiagram, /transcriptRenderer\.commitTranscriptMutation\(\{[\s\S]*?kind: "destructive"[\s\S]*?transcriptRenderer\.replaceHtml\(diagram, svg\)/, "async Mermaid completion must register its destructive mutation with the coordinator");
|
|
195
|
+
assert.match(renderStreamingToolCallCard, /transcriptRenderer\.updateTextSurface\(\{[\s\S]*?surface: streamToolCallText[\s\S]*?kind: "tool-execution"/, "streaming tool-call text must update through the coordinator text surface");
|
|
196
|
+
assert.match(removeLiveTranscriptBubble, /transcriptRenderer\.commitTranscriptMutation\(\{[\s\S]*kind: "authoritative"[\s\S]*invalidateSelection: true[\s\S]*mutate: \(\) => bubble\.remove\(\)/, "presentation removals must be explicit coordinator-owned invalidations rather than raw transcript mutation");
|
|
197
|
+
assert.match(removeCompactLiveBubble, /removeLiveTranscriptBubble\(bubble, messageKey\)/, "compact removals must share the authoritative live-output removal gateway");
|
|
198
|
+
assert.match(removeStreamingThinkingBubble, /removeLiveTranscriptBubble\(streamThinkingBubble, "thinking"\)/, "thinking visibility changes must use the authoritative removal gateway");
|
|
199
|
+
assert.match(removeStreamBubble, /removeLiveTranscriptBubble\(streamBubble, "assistant"\)/, "normal-to-compact transitions must use the authoritative removal gateway");
|
|
200
|
+
for (const [name, source] of [["compact", removeCompactLiveBubble], ["thinking", removeStreamingThinkingBubble], ["assistant", removeStreamBubble]]) {
|
|
201
|
+
assert.doesNotMatch(source, /\.remove\(\)/, `${name} presentation removal must not bypass the coordinator helper`);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Stable compact text-node updates.
|
|
205
|
+
assert.match(updateTextSurface, /_transcriptTextNode[\s\S]*node\.appendData\(value\.slice\(node\.data\.length\)\)[\s\S]*else node\.data = value/, "text surfaces must reuse one stable Text node and append in place instead of replacing it");
|
|
206
|
+
|
|
207
|
+
// Stable committed blocks and a bounded mutable tail.
|
|
208
|
+
assert.match(reconcileMarkdownSurface, /if \(boundary > state\.stableText\.length\)/, "committed blocks must never be re-rendered for append-only input");
|
|
209
|
+
assert.match(reconcileMarkdownSurface, /for \(const node of state\.tailNodes\) node\.remove\(\)/, "only the mutable tail may be detached during streaming");
|
|
210
|
+
assert.match(reconcileMarkdownSurface, /const diverged = !!state && !value\.startsWith\(state\.stableText\);[\s\S]*invalidateSelection: diverged/, "authoritative divergence must explicitly invalidate selection rather than silently rebuilding");
|
|
211
|
+
|
|
212
|
+
// Live settlement adoption.
|
|
213
|
+
assert.match(authoritativeAssistantTextForAdoption, /if \(finalParts\.length !== 1\) return null;/, "multi-part settlement must not be fuzzy-adopted onto a single live surface");
|
|
214
|
+
assert.match(adoptLiveAssistantBubble, /compactCandidate[\s\S]*normalCandidate[\s\S]*authoritativeText !== candidate\.text[\s\S]*transcriptRenderer\.ownMessage\(candidate\.bubble, \{ key, role: "assistant" \}\)[\s\S]*transcriptRenderer\.ownSurface\(candidate\.surface[\s\S]*pendingTranscriptAdoptions\.set\(key, candidate\.bubble\)/, "live settlement adoption requires exact authoritative agreement and re-keys the same normal or compact bubble");
|
|
215
|
+
assert.match(renderAllMessages, /const commit = transcriptRenderer\.commitTranscriptMutation\(\{[\s\S]*?kind: forceRebuild \? "authoritative" : "reconcile"[\s\S]*?invalidateSelection: forceRebuild[\s\S]*?pendingTranscriptAdoptions\.get\(entry\.key\)/, "authoritative reconciliation must be one coordinator transaction that adopts matching live bubbles");
|
|
216
|
+
assert.match(renderAllMessages, /if \(commit\.deferred\) return;/, "a deferred transcript commit must not run post-mutation restore work");
|
|
217
|
+
assert.match(refreshMessages, /adoptedOutput = adoptLiveAssistantBubble\(latestMessages\);[\s\S]*resetStreamBubble\(\{ preserveCompact: adoptedOutput === "compact" \}\)/, "settlement must try exact live-bubble adoption and preserve a matching compact owner through reset");
|
|
218
|
+
assert.match(finalizeAdoptedAssistantBubble, /compact-live-text[\s\S]*classList\.add\("markdown-body", "compact-transcript-text"\)[\s\S]*transcriptRenderer\.reconcileMarkdownSurface\(\{[\s\S]*stableBoundary: \(value\) => value\.length/, "an adopted compact surface must retain its DOM owner while final Markdown reconciles in place");
|
|
219
|
+
assert.match(prunePendingTranscriptAdoptions, /for \(const \[key, bubble\] of pendingTranscriptAdoptions\)[\s\S]*!bubble\?\.isConnected[\s\S]*pendingTranscriptAdoptions\.delete\(key\)/, "disconnected unconsumed adoptions must not retain detached transcript trees");
|
|
220
|
+
|
|
221
|
+
// Bounded mutation logging.
|
|
222
|
+
assert.match(renderer, /MUTATION_LOG_LIMIT = \d+/, "the coordinator must bound its mutation log");
|
|
223
|
+
assert.match(logMutation, /mutationLog\.push\([\s\S]*mutationLog\.length > MUTATION_LOG_LIMIT[\s\S]*mutationLog\.splice/, "the mutation log must drop oldest entries once the bound is exceeded");
|
|
224
|
+
|
|
225
|
+
// Pointer-selection sessions and destructive-mutation coalescing.
|
|
226
|
+
assert.match(renderer, /document\.addEventListener\("pointerdown"[\s\S]*chat\.addEventListener\("pointerdown"[\s\S]*window\.addEventListener\("pointerup"[\s\S]*window\.addEventListener\("pointercancel"[\s\S]*window\.addEventListener\("blur"[\s\S]*document\.addEventListener\("selectionchange"[\s\S]*chat\.addEventListener\("copy"/, "the coordinator must track transcript pointer selection while ending gestures released outside #chat or the window");
|
|
227
|
+
assert.match(commitTranscriptMutation, /DESTRUCTIVE_KINDS\.has\(kind\)[\s\S]*!invalidateSelection[\s\S]*pointerSession[\s\S]*selectedSurfaceIntersects\(surfaces\)[\s\S]*deferredMutations\.set\(key, entry\)/, "destructive commits intersecting an active pointer drag must coalesce latest-wins until the gesture ends");
|
|
228
|
+
|
|
229
|
+
// Exact single-surface fallback and explicit invalidation.
|
|
230
|
+
assert.match(applyMutation, /if \(context !== contextKey\(\)\) return \{ applied: false, stale: true \}/, "stale-context mutations must be rejected");
|
|
231
|
+
assert.match(applyMutation, /selectionSnapshot\(\) \|\| selectionSession\?\.snapshot \|\| null/, "coordinator mutations must retain the last exact semantic bookmark when an adjacent render step already detached the native range");
|
|
232
|
+
assert.match(rangeForSnapshot, /range\.toString\(\) === snapshot\.text/, "fallback restoration must require exact text evidence");
|
|
233
|
+
assert.match(rangeForSnapshot, /surfaceText\.indexOf\(snapshot\.text\)[\s\S]*surfaceText\.indexOf\(snapshot\.text, exactStart \+ 1\) !== -1[\s\S]*anchorOffset = backward \? exactEnd : exactStart/, "structurally shifted selections may remap only to one exact occurrence in the same semantic surface while preserving direction");
|
|
234
|
+
assert.match(coordinatedTextPoint, /target < next \|\| \(target === next && !forwardAffinity\)/, "selection starts at text-node boundaries must bind to the next node while ends retain backward affinity, avoiding implicit block newlines");
|
|
235
|
+
assert.match(restoreCoordinatedSelection, /snapshot\.context !== contextKey\(\)[\s\S]*!forceRemap && currentText === snapshot\.text[\s\S]*currentText && currentAnchor && currentFocus[\s\S]*snapshot\.anchorOffset > snapshot\.focusOffset[\s\S]*setBaseAndExtent[\s\S]*selection\.addRange\(match\.range\)/, "fallback restoration must reject stale contexts, preserve backward direction, and use the exact validated Range for forward selection");
|
|
236
|
+
assert.match(applyMutation, /intersectsSelection = selectedSurfaceIntersects\(surfaces\)[\s\S]*forceRemap = DESTRUCTIVE_KINDS\.has\(kind\) && intersectsSelection[\s\S]*restoreSelection\(snapshot, \{ forceRemap \}\)/, "destructive mutations intersecting a captured selection must remap a fresh semantic Range instead of trusting transient browser boundaries");
|
|
237
|
+
assert.match(applyMutation, /restoredSelection && forceRemap && typeof requestAnimationFrame[\s\S]*requestAnimationFrame\(\(\) => \{[\s\S]*selectionIntentRevision !== restoreIntentRevision[\s\S]*restoreSelection\(snapshot, \{ forceRemap: true \}\)/, "destructive selection restoration must survive the browser's deferred Range adjustment without clobbering a newer pointer or keyboard selection");
|
|
238
|
+
assert.match(renderer, /function invalidateSelection\(\{ surfaces = \[\] \} = \{\}\) \{[\s\S]*clearSelectionFor\(surfaces\)/, "explicit invalidation must be a first-class coordinator operation");
|
|
239
|
+
|
|
240
|
+
// Prevention of unapproved direct destructive transcript mutations.
|
|
241
|
+
assert.doesNotMatch(app, /elements\.chat\.(?:replaceChildren|replaceWith)\(|elements\.chat\.innerHTML\s*=/, "no direct destructive #chat mutation may bypass the coordinator");
|
|
242
|
+
assert.match(resetChatOutput, /transcriptRenderer\.replaceChildren\(elements\.chat/, "full chat resets must go through the coordinator");
|
|
243
|
+
for (const [name, source] of [
|
|
244
|
+
["streaming markdown", renderStreamingMarkdown],
|
|
245
|
+
["streaming thinking", renderThinkingMarkdown],
|
|
246
|
+
["compact live output", flushCompactLiveOutput],
|
|
247
|
+
["authoritative reconciliation", renderAllMessages],
|
|
248
|
+
["live tool card", updateLiveToolCard],
|
|
249
|
+
["mermaid renderer", renderMermaidDiagram],
|
|
250
|
+
]) {
|
|
251
|
+
assert.doesNotMatch(source, /(?<!transcriptRenderer)\.(?:replaceChildren|replaceWith|replaceHtml)\(|\.innerHTML\s*=/, `${name} must not perform unapproved direct destructive transcript mutations`);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
console.log("interaction-state-stability-static.test.mjs passed");
|
|
@@ -0,0 +1,55 @@
|
|
|
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, html, css, serviceWorker, readme] = await Promise.all([
|
|
8
|
+
readFile(join(root, "public", "app.js"), "utf8"),
|
|
9
|
+
readFile(join(root, "public", "index.html"), "utf8"),
|
|
10
|
+
readFile(join(root, "public", "styles.css"), "utf8"),
|
|
11
|
+
readFile(join(root, "public", "service-worker.js"), "utf8"),
|
|
12
|
+
readFile(join(root, "README.md"), "utf8"),
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
assert.match(app, /MOBILE_CONTINUITY_STORAGE_KEY = "pi-webui-mobile-continuity-v1"/, "continuity state must be browser-scoped and versioned");
|
|
16
|
+
assert.match(app, /requiresReselect: true/, "restored attachment records must be metadata-only");
|
|
17
|
+
assert.match(app, /Reselect required/, "metadata-only attachment restoration must be labelled truthfully");
|
|
18
|
+
assert.match(app, /function retryMobileFailedSend\([\s\S]*?body: pending\.body[\s\S]*?original request identity/, "failed sends must require a manual retry with the original request body and identity");
|
|
19
|
+
assert.match(app, /error\?\.backendOffline === true[\s\S]*?mobileFailedSend =/, "manual failed-send recovery must be created only for ambiguous transport failures, not confirmed HTTP rejection");
|
|
20
|
+
assert.match(app, /MOBILE_FAILED_SEND_RECOVERY_TTL_MS = 10 \* 60 \* 1000[\s\S]*?recoveryAgeMs <= MOBILE_FAILED_SEND_RECOVERY_TTL_MS/, "persisted request identity must not outlive the server deduplication window");
|
|
21
|
+
assert.match(app, /!Array\.isArray\(mobileFailedSend\.body\?\.images\) \|\| mobileFailedSend\.body\.images\.length === 0[\s\S]*?!Array\.isArray\(failed\.body\.images\) \|\| failed\.body\.images\.length === 0/, "failed-send persistence and restore must agree on empty image arrays");
|
|
22
|
+
assert.match(app, /function scheduleMobileContinuityPersist\([\s\S]*?MOBILE_CONTINUITY_PERSIST_DEBOUNCE_MS/, "composer draft persistence must be debounced off the keystroke hot path");
|
|
23
|
+
assert.match(app, /This implementation intentionally never retries an\n \/\/ ambiguous mutation automatically/, "ambiguous prompt mutations must never replay automatically");
|
|
24
|
+
assert.match(html, /id="mobileFailedSendRecovery"[\s\S]*Not sent\.[\s\S]*id="mobileFailedSendRetryButton"[\s\S]*id="mobileFailedSendDiscardButton"/, "failed sends need visible Retry and Discard actions");
|
|
25
|
+
assert.match(app, /mobileButton\("Add Context"[\s\S]*mobileSetSurfacePage\("context"\)/, "the action sheet must expose unified context capture");
|
|
26
|
+
for (const source of ["Camera", "Photos", "Files", "Paste text"]) assert.match(app, new RegExp(source), `${source} must be represented in Add Context`);
|
|
27
|
+
assert.match(app, /Camera and photo access are requested by your browser only after you select them/, "capture permissions need contextual copy before the browser prompt");
|
|
28
|
+
assert.match(app, /active Web UI clients only/, "notification settings must state the active-client delivery limit");
|
|
29
|
+
assert.match(app, /mobileNotificationTarget\(\{ route: "activity", tabId, blockerId \}\)/, "blocker notifications must carry a versioned opaque target");
|
|
30
|
+
assert.match(app, /applyPendingMobileNavigationTarget\([\s\S]*?foreground reconcile/, "notification navigation must be deferred until reconciliation");
|
|
31
|
+
assert.match(app, /if \(targetTab\.id !== activeTabId\) await switchTab\(targetTab\.id\);[\s\S]*?if \(target\.blockerId && !mobileTargetBlockerExists/, "background-tab notification targets must switch before exact blocker validation");
|
|
32
|
+
assert.match(app, /That notification target is no longer available/, "stale targets need a visible fallback explanation");
|
|
33
|
+
assert.match(serviceWorker, /client\.postMessage\(\{ type: MOBILE_NAVIGATION_MESSAGE_TYPE, target \}\)/, "existing clients must focus and receive the exact target");
|
|
34
|
+
assert.match(serviceWorker, /openWindow\?\.\(targetUrl\)/, "no-client notification clicks must open only the bounded target URL");
|
|
35
|
+
assert.doesNotMatch(serviceWorker, /data\?\.url/, "service-worker fallback must not accept an arbitrary notification URL");
|
|
36
|
+
assert.match(app, /visibilitychange[\s\S]*?pageshow[\s\S]*?network online/, "visibility, page-show, and online returns must reconcile");
|
|
37
|
+
assert.match(app, /Continued while away · reconciled/, "return status must distinguish reconciled background continuation");
|
|
38
|
+
assert.match(app, /function renderMobileDiagnosticsPage\(/, "local diagnostics need a dedicated Copy/Clear surface");
|
|
39
|
+
assert.match(app, /function scrubMobileDiagnosticDetail\([\s\S]*?redacted potentially sensitive detail/, "diagnostic details must redact path-like and credential-like values");
|
|
40
|
+
assert.match(app, /excludes prompts, transcript text, paths, filenames, and credentials/, "diagnostics must document their privacy boundary");
|
|
41
|
+
assert.match(app, /function renderMobileInstallPage\(/, "install education must be contextual and dismissible");
|
|
42
|
+
|
|
43
|
+
assert.match(app, /TABLET_SHELL_STORAGE_KEY/, "tablet mode must use an independent browser flag");
|
|
44
|
+
assert.match(app, /initialUrlParams\.get\("tabletShell"\)/, "tablet mode must support an independent URL override");
|
|
45
|
+
assert.match(css, /@media \(min-width: 721px\) and \(max-width: 1050px\)/, "tablet layout must own only medium widths");
|
|
46
|
+
assert.match(css, /html\[data-tablet-shell="v2"\] \.mobile-shell-nav[\s\S]*?width: 7rem/, "tablet destinations must use a rail rather than the phone bottom bar");
|
|
47
|
+
assert.match(css, /html\[data-tablet-shell="v2"\] \.mobile-shell-surface[\s\S]*?width: min\(30rem, 72vw\)/, "tablet inspector must be a bounded right-side sheet");
|
|
48
|
+
assert.match(css, /html\[data-tablet-shell="v2"\] \.file-viewer-pane[\s\S]*?position: fixed[\s\S]*?inset: 0/, "tablet files must default to full-screen replacement");
|
|
49
|
+
assert.match(css, /and \(pointer: coarse\)[\s\S]*?min-height: 44px/, "coarse tablet pointers must retain the 44px target floor");
|
|
50
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v61"/, "continuity/tablet assets need a coherent cache identity");
|
|
51
|
+
assert.match(html, /styles\.css\?v=92/, "tablet CSS must have a coherent HTML revision");
|
|
52
|
+
assert.match(html, /app\.js\?v=103/, "continuity app logic must have a coherent HTML revision");
|
|
53
|
+
assert.match(readme, /tabletShell=v2/, "tablet preview and rollback must be documented");
|
|
54
|
+
|
|
55
|
+
console.log("mobile-continuity-tablet-static.test.mjs passed");
|
|
@@ -0,0 +1,69 @@
|
|
|
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, css, html, server, serviceWorker, packageRaw] = await Promise.all([
|
|
8
|
+
readFile(join(root, "public", "app.js"), "utf8"),
|
|
9
|
+
readFile(join(root, "public", "styles.css"), "utf8"),
|
|
10
|
+
readFile(join(root, "public", "index.html"), "utf8"),
|
|
11
|
+
readFile(join(root, "bin", "pi-webui.mjs"), "utf8"),
|
|
12
|
+
readFile(join(root, "public", "service-worker.js"), "utf8"),
|
|
13
|
+
readFile(join(root, "package.json"), "utf8"),
|
|
14
|
+
]);
|
|
15
|
+
const pkg = JSON.parse(packageRaw);
|
|
16
|
+
|
|
17
|
+
const assertionIntent = [
|
|
18
|
+
{
|
|
19
|
+
assertion: "legacy mobile composer controls used a 40px minimum",
|
|
20
|
+
status: "superseded",
|
|
21
|
+
reason: "Phase 0 establishes the approved 44px phone/coarse-pointer hit-area floor, including Compact density.",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
assertion: "legacy mobile tab popover remains available when the v2 flag is off",
|
|
25
|
+
status: "preserved",
|
|
26
|
+
reason: "Phase 1 only suppresses its mutation handlers while v2 is active and leaves the legacy selectors intact.",
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
assert.equal(assertionIntent.every((entry) => ["preserved", "superseded", "obsolete"].includes(entry.status)), true);
|
|
30
|
+
|
|
31
|
+
assert.equal(pkg.scripts["test:browser"], "playwright test", "the package must expose an explicit browser suite");
|
|
32
|
+
assert.equal(pkg.devDependencies?.["@playwright/test"], "1.62.1", "Playwright must be exact/pinned");
|
|
33
|
+
assert.equal(pkg.devDependencies?.["@axe-core/playwright"], "4.12.1", "axe must be exact/pinned");
|
|
34
|
+
assert.match(app, /from "\.\/mobile-shell-state\.mjs"/, "app boot must import the pure mobile shell module");
|
|
35
|
+
assert.match(pkg.scripts.check, /node --check public\/mobile-shell-state\.mjs/, "package checks must syntax-check every public module in the startup graph");
|
|
36
|
+
assert.match(pkg.scripts.check, /node --check public\/transcript-renderer\.mjs/, "package checks must syntax-check the transcript startup module");
|
|
37
|
+
assert.match(server, /"mobile-shell-state\.mjs"/, "the server allowlist must serve the new public module");
|
|
38
|
+
assert.match(server, /"transcript-renderer\.mjs"/, "the server allowlist must serve the transcript startup module");
|
|
39
|
+
assert.match(serviceWorker, /"\/mobile-shell-state\.mjs"/, "the PWA shell must cache the new startup module");
|
|
40
|
+
assert.match(serviceWorker, /"\/transcript-renderer\.mjs"/, "the PWA shell must cache the transcript startup module");
|
|
41
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v61"/, "the cache identity must change with the startup graph");
|
|
42
|
+
assert.match(html, /styles\.css\?v=92/, "the stylesheet revision must change with mobile/tablet CSS fixes");
|
|
43
|
+
assert.match(html, /app\.js\?v=103/, "the app revision must change with continuity/tablet wiring");
|
|
44
|
+
assert.match(serviceWorker, /const APP_SHELL_NETWORK_TIMEOUT_MS = 8_000;[\s\S]*?event\.waitUntil\([\s\S]*?cache\.put\(request, response\.clone\(\)\)[\s\S]*?return networkResponse;/, "runtime cache writes must extend the event lifetime without blocking bounded network responses");
|
|
45
|
+
assert.match(serviceWorker, /MOBILE_NAVIGATION_MESSAGE_TYPE = "pi-webui:navigate:v1"/, "the service worker must use a versioned active-client navigation message");
|
|
46
|
+
assert.match(serviceWorker, /client\.postMessage\(\{ type: MOBILE_NAVIGATION_MESSAGE_TYPE, target \}\)/, "existing clients must receive only a validated target message");
|
|
47
|
+
assert.match(app, /function installMobileShellNavigationBridge\([\s\S]*?pi-webui:navigate:v1/, "the app must accept the service-worker navigation contract");
|
|
48
|
+
assert.match(app, /function updateVisualViewportVars\([\s\S]*?keyboardOpen && !isMobileShellV2Active\(\)/, "v2 must retain viewport measurement but suppress legacy keyboard mutation");
|
|
49
|
+
assert.match(app, /function syncMobileChatToBottomForInput\(\) \{\n if \(!isMobileView\(\) \|\| isMobileShellV2Active\(\)\) return;/, "v2 must suppress legacy forced chat scrolling");
|
|
50
|
+
assert.match(app, /function bindMobileViewChanges\([\s\S]*?applyMobileShellViewport\(\);[\s\S]*?if \(isMobileShellV2Active\(\)\) return;/, "v2 must bypass legacy breakpoint mutations");
|
|
51
|
+
assert.match(app, /function setMobileTabsExpanded\(expanded\) \{\n if \(isMobileShellV2Active\(\)\) return;/, "v2 must own surface visibility rather than the legacy tabs expander");
|
|
52
|
+
assert.match(app, /function setMobileFooterExpanded\(expanded\) \{\n if \(isMobileShellV2Active\(\)\) return;/, "v2 must suppress legacy footer expansion");
|
|
53
|
+
assert.match(app, /function createBrowserPromptRequestId\(/, "browser prompt submission must mint an opaque request identity");
|
|
54
|
+
assert.match(app, /if \(kind === "prompt"\) bodyBase\.requestId = createBrowserPromptRequestId\(\)/, "the browser identity must travel with primary prompt submission and remain stable in the captured manual-retry body");
|
|
55
|
+
assert.match(server, /BROWSER_PROMPT_REQUEST_LIMIT = 256/, "server request deduplication must remain bounded");
|
|
56
|
+
assert.match(server, /deduplicateBrowserPromptRequest\(tab, body/, "server prompt dispatch must deduplicate tab-bound request IDs");
|
|
57
|
+
assert.match(server, /requestId was already used for a different prompt/, "request-ID reuse with a different mutation must be rejected");
|
|
58
|
+
assert.match(server, /runId: null/, "tab activity must expose an opaque parent-run field");
|
|
59
|
+
assert.match(server, /activity\.runId = randomUUID\(\)/, "parent-run IDs must be server-issued opaque values");
|
|
60
|
+
assert.match(server, /function markTabFailed\([\s\S]*?activity\.status = "failed"[\s\S]*?activity\.completionSerial/, "failed parent turns must be represented distinctly from successful completion");
|
|
61
|
+
assert.match(server, /if \(!accepted && client\?\.res\) evictSlowSseClient\(client\)/, "a slow SSE client must be evicted at backpressure instead of queued indefinitely");
|
|
62
|
+
assert.match(server, /client\.tab\?\.sseClients\?\.delete\(client\)/, "eviction must remove only the slow client");
|
|
63
|
+
assert.match(css, /\.terminal-tabs-toggle-button \{[\s\S]*?min-height: 44px/, "phone tab targets must meet the 44px floor");
|
|
64
|
+
assert.match(css, /\.composer-attach-button \{[\s\S]*?width: 44px;[\s\S]*?min-height: 44px/, "phone attachment target must meet the 44px floor");
|
|
65
|
+
assert.match(css, /\.composer-row button \{\n width: 100%;\n min-height: 44px/, "phone composer controls must meet the 44px floor");
|
|
66
|
+
assert.match(css, /html\[data-density="compact"\] button,[\s\S]*?@media \(max-width: 720px\)[\s\S]*?min-height: 44px/, "Compact density cannot shrink phone/coarse targets below 44px");
|
|
67
|
+
assert.match(css, /html\[data-mobile-shell="v2"\] \{ --mobile-shell-v2-active: 1; \}/, "new v2 CSS must be root-scoped");
|
|
68
|
+
|
|
69
|
+
console.log("mobile-foundation-static.test.mjs passed");
|
|
@@ -0,0 +1,65 @@
|
|
|
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, html, css, serviceWorker] = await Promise.all([
|
|
8
|
+
readFile(join(root, "public", "app.js"), "utf8"),
|
|
9
|
+
readFile(join(root, "public", "index.html"), "utf8"),
|
|
10
|
+
readFile(join(root, "public", "styles.css"), "utf8"),
|
|
11
|
+
readFile(join(root, "public", "service-worker.js"), "utf8"),
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
assert.match(html, /id="mobileShellV2"/, "the flagged phone shell must have one root");
|
|
15
|
+
for (const route of ["chat", "sessions", "activity", "project"]) {
|
|
16
|
+
assert.match(html, new RegExp(`data-mobile-route-button="${route}"`), `${route} must be a labelled bottom destination`);
|
|
17
|
+
}
|
|
18
|
+
assert.match(html, /id="mobileSessionsSearchInput"/, "Sessions must expose search");
|
|
19
|
+
assert.match(html, /id="mobileNewCurrentDirectoryButton"[\s\S]*id="mobileNewDirectoryButton"[\s\S]*id="mobileNewWorktreeButton"[\s\S]*id="mobileResumeSessionButton"/, "Sessions must retain the existing new/resume paths");
|
|
20
|
+
assert.match(html, /id="mobileProjectTopics"[\s\S]*data-mobile-project-topic="files"[\s\S]*data-mobile-project-topic="git"[\s\S]*data-mobile-project-topic="queue"[\s\S]*data-mobile-project-topic="workflows"/, "Project must provide all parity topics");
|
|
21
|
+
assert.match(html, /id="mobileLifecycleAnnouncer"[^>]*role="status"[^>]*aria-live="polite"[^>]*aria-atomic="true"/, "one atomic lifecycle announcer is required");
|
|
22
|
+
assert.match(html, /id="mobileShellIndicators"[^>]*role="group"/, "indicator refreshes must not create a second live region");
|
|
23
|
+
assert.match(html, /id="chat" class="chat" aria-live="polite"/, "desktop and legacy mobile must retain the canonical transcript live region");
|
|
24
|
+
assert.match(app, /if \(active\) elements\.chat\.removeAttribute\("aria-live"\);[\s\S]*?else elements\.chat\.setAttribute\("aria-live", "polite"\)/, "v2 must swap the transcript live region for its lifecycle announcer only while active");
|
|
25
|
+
assert.match(html, /id="mobileSurfaceBackButton"[^>]*hidden/, "surfaces need a visible Back control when child pages replace content");
|
|
26
|
+
assert.match(html, /id="mobileSurfaceCloseButton"/, "surfaces need a visible Close control");
|
|
27
|
+
|
|
28
|
+
for (const helper of ["mobileRenderSessions", "mobileRenderActivity", "mobileRenderProject", "mobileRenderMore", "mobileRenderActionSheet", "mobileRenderLifecycle", "installMobilePhoneExperience"]) {
|
|
29
|
+
assert.match(app, new RegExp(`function ${helper}\\(`), `${helper} must implement a functional phone path`);
|
|
30
|
+
}
|
|
31
|
+
assert.match(app, /switchTab\(tabId\)/, "session selection must call canonical switchTab");
|
|
32
|
+
assert.match(app, /mobileCanonicalMountContent\(host, \["sidePanelSectionFiles"\]/, "Files must reuse its canonical node");
|
|
33
|
+
assert.match(app, /mobileCanonicalMountContent\(host, \["sidePanelSectionGit"\]/, "Git must reuse its canonical node");
|
|
34
|
+
assert.match(app, /mobileCanonicalMountContent\(host, \["sidePanelSectionQueue"\]/, "Queue must reuse its canonical node");
|
|
35
|
+
assert.match(app, /mobileCanonicalMountContent\(host, topic\[1\]/, "More must reuse canonical settings/action nodes");
|
|
36
|
+
assert.match(app, /await appConfirm\(\{ title: "Abort active run\?"/, "Abort must have visible tap-confirm parity");
|
|
37
|
+
assert.match(app, /elements\.optionsConversationModeButton\?\.click\(\)/, "voice entry must retain the existing action");
|
|
38
|
+
assert.match(app, /window\.history\.pushState/, "route and sheet transitions must be history-owned");
|
|
39
|
+
assert.match(app, /document\.addEventListener\("keydown", \(event\) => \{[\s\S]*?event\.key !== "Escape"[\s\S]*?document\.querySelector\("dialog\[open\]"\)/, "Escape must share mobile Back handling without dismissing a surface under a native dialog");
|
|
40
|
+
assert.match(app, /projectTopics\?\.addEventListener\("keydown"[\s\S]*?"ArrowLeft"[\s\S]*?"Home"[\s\S]*?activateProjectTopic/, "Project tabs require arrow/Home/End keyboard activation");
|
|
41
|
+
assert.match(app, /function syncMobileShellInteractivity\([\s\S]*?layout\.inert = layoutObscured[\s\S]*?destination\.setAttribute\("role", "main"\)/, "full-screen destinations must inert the obscured layout and own the main landmark");
|
|
42
|
+
assert.match(app, /function restoreMobileSurfaceFocus\([\s\S]*?mobileSurfaceFocusReturn/, "closing a transient surface must restore its invoking control");
|
|
43
|
+
assert.match(app, /captureMobileSurfaceRenderFocus\([\s\S]*?restoreMobileSurfaceRenderFocus\(surface, surfaceFocusSnapshot\)/, "poll-driven surface rerenders must preserve focus");
|
|
44
|
+
assert.match(app, /event\.preventDefault\(\);\n event\.stopPropagation\(\);\n mobileBack\(\);/, "v2 Escape consumption must not reach legacy handlers");
|
|
45
|
+
assert.match(html, /id="mobileSessionsTitle" tabindex="-1"[\s\S]*id="mobileActivityTitle" tabindex="-1"[\s\S]*id="mobileProjectTitle" tabindex="-1"[\s\S]*id="mobileSurfaceTitle" tabindex="-1"/, "route and surface headings must be programmatically focusable");
|
|
46
|
+
assert.match(app, /mobilePresentation = value === "detailed" \? "detailed" : "essential"/, "Essential/Detailed is browser presentation state");
|
|
47
|
+
assert.match(app, /This does not enable compact-v1 or change transcript content/, "presentation must not mutate compact-v1 or transcript semantics");
|
|
48
|
+
assert.match(app, /mobileDismissedActivityKeys/, "completed activity can be dismissed without deleting session history");
|
|
49
|
+
assert.match(app, /const priorityTabs = visible\.filter[\s\S]*?renderGroup\("Priority", priorityTabs\)/, "Sessions must render needs-input and running work in a top Priority group");
|
|
50
|
+
assert.match(app, /const badgeLabels = \{[\s\S]*?button\.setAttribute\("aria-label", badgeLabel \? `\$\{base\}, \$\{badgeLabel\}` : base\)/, "destination names must describe the actual badge semantics");
|
|
51
|
+
assert.match(app, /tabPendingBlockerCount\(tab\)/, "Activity must consume canonical blocker state");
|
|
52
|
+
assert.match(app, /workflowRunningCountForTab\(tab\.id\)/, "Activity must consume canonical workflow state");
|
|
53
|
+
assert.match(app, /tabAppRunnerRunningRun\(tab\)/, "Activity must consume canonical app-runner state");
|
|
54
|
+
assert.match(app, /installMobilePhoneExperience\(\);/, "the phone shell must be installed at boot");
|
|
55
|
+
|
|
56
|
+
assert.match(css, /html\[data-mobile-shell="v2"\] \.mobile-shell-v2/, "mobile CSS must be root scoped");
|
|
57
|
+
assert.match(css, /min-height: 44px/, "phone targets must preserve the 44px floor");
|
|
58
|
+
assert.match(css, /env\(safe-area-inset-bottom\)/, "bottom controls must honor safe areas");
|
|
59
|
+
assert.match(css, /data-mobile-presentation="essential"/, "Essential presentation must use progressive disclosures");
|
|
60
|
+
assert.match(css, /html\[data-mobile-shell="v2"\] body\.mobile-keyboard-open \.widget-area,[\s\S]*?\.composer-actions-button \{ display: block !important; \}/, "v2 keyboard mode must keep run widgets and the actions entry available");
|
|
61
|
+
assert.match(css, /@media \(prefers-reduced-motion: reduce\)/, "reduced-motion behavior is required");
|
|
62
|
+
assert.match(css, /@media \(forced-colors: active\)/, "forced-color affordances are required");
|
|
63
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v61"/, "browser asset changes need a coherent cache tuple");
|
|
64
|
+
|
|
65
|
+
console.log("mobile-phone-experience-static.test.mjs passed");
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import {
|
|
3
|
+
MOBILE_SHELL_V2_DEFAULT,
|
|
4
|
+
TABLET_SHELL_V2_DEFAULT,
|
|
5
|
+
classifyMobileViewport,
|
|
6
|
+
createMobileShellState,
|
|
7
|
+
isMobileShellV2Enabled,
|
|
8
|
+
mobileNavigationTargetFromSearch,
|
|
9
|
+
mobileNavigationTargetSearch,
|
|
10
|
+
normalizeMobileNavigationTarget,
|
|
11
|
+
reduceMobileShellState,
|
|
12
|
+
resolveMobileShellFeatureMode,
|
|
13
|
+
resolveTabletShellFeatureMode,
|
|
14
|
+
} from "../public/mobile-shell-state.mjs";
|
|
15
|
+
|
|
16
|
+
assert.equal(MOBILE_SHELL_V2_DEFAULT, false, "the package default must remain rollback-safe");
|
|
17
|
+
assert.equal(TABLET_SHELL_V2_DEFAULT, false, "the independent tablet package default must remain rollback-safe");
|
|
18
|
+
assert.deepEqual(classifyMobileViewport({ width: 719, height: 844, coarsePointer: false, hover: true }), { viewportMode: "phone", posture: "regular" });
|
|
19
|
+
assert.deepEqual(classifyMobileViewport({ width: 720, height: 844, coarsePointer: false, hover: true }), { viewportMode: "phone", posture: "regular" });
|
|
20
|
+
assert.deepEqual(classifyMobileViewport({ width: 721, height: 844, coarsePointer: false, hover: true }), { viewportMode: "tablet", posture: "regular" });
|
|
21
|
+
assert.deepEqual(classifyMobileViewport({ width: 844, height: 390, coarsePointer: true, hover: false }), { viewportMode: "phone", posture: "compactLandscapePhone" });
|
|
22
|
+
assert.deepEqual(classifyMobileViewport({ width: 1049, height: 700, coarsePointer: false, hover: true }), { viewportMode: "tablet", posture: "regular" });
|
|
23
|
+
assert.deepEqual(classifyMobileViewport({ width: 1050, height: 700, coarsePointer: false, hover: true }), { viewportMode: "tablet", posture: "regular" });
|
|
24
|
+
assert.deepEqual(classifyMobileViewport({ width: 1051, height: 700, coarsePointer: false, hover: true }), { viewportMode: "desktop", posture: "regular" });
|
|
25
|
+
|
|
26
|
+
assert.equal(resolveMobileShellFeatureMode({ urlValue: "legacy", storedValue: "preview", defaultEnabled: true }), "legacy", "URL legacy must be the emergency rollback");
|
|
27
|
+
assert.equal(resolveMobileShellFeatureMode({ urlValue: "v2", storedValue: "legacy" }), "v2", "URL v2 must override browser storage");
|
|
28
|
+
assert.equal(resolveMobileShellFeatureMode({ storedValue: "preview" }), "preview");
|
|
29
|
+
assert.equal(resolveMobileShellFeatureMode({ storedValue: "unknown" }), "legacy", "unknown values must fail closed");
|
|
30
|
+
assert.equal(isMobileShellV2Enabled("v2", "phone"), true);
|
|
31
|
+
assert.equal(isMobileShellV2Enabled("legacy", "tablet", "v2"), true, "tablet activation is independently flagged");
|
|
32
|
+
assert.equal(isMobileShellV2Enabled("v2", "tablet", "legacy"), false, "phone v2 must not implicitly activate tablet");
|
|
33
|
+
assert.equal(resolveTabletShellFeatureMode({ urlValue: "legacy", storedValue: "preview" }), "legacy", "tablet URL rollback must override storage");
|
|
34
|
+
assert.equal(isMobileShellV2Enabled("preview", "desktop", "v2"), false, "desktop must preserve its legacy architecture");
|
|
35
|
+
|
|
36
|
+
let state = createMobileShellState({ viewport: { width: 390, height: 844, coarsePointer: true, hover: false }, featureMode: "v2" });
|
|
37
|
+
state = reduceMobileShellState(state, { type: "surface", surface: "more", page: "settings" });
|
|
38
|
+
assert.equal(state.surface, "more");
|
|
39
|
+
assert.equal(state.surfacePage, "settings");
|
|
40
|
+
state = reduceMobileShellState(state, { type: "back" });
|
|
41
|
+
assert.equal(state.surfacePage, "root", "Back leaves a sheet child before dismissing its parent");
|
|
42
|
+
state = reduceMobileShellState(state, { type: "back" });
|
|
43
|
+
assert.equal(state.surface, "none");
|
|
44
|
+
state = reduceMobileShellState(state, { type: "route", route: "activity" });
|
|
45
|
+
state = reduceMobileShellState(state, { type: "route", route: "project" });
|
|
46
|
+
state = reduceMobileShellState(state, { type: "back" });
|
|
47
|
+
assert.equal(state.route, "activity", "route history restores the preceding route after surfaces are closed");
|
|
48
|
+
state = reduceMobileShellState(state, { type: "viewport", viewport: { width: 1280, height: 800, coarsePointer: false, hover: true } });
|
|
49
|
+
assert.equal(state.surface, "none");
|
|
50
|
+
assert.equal(isMobileShellV2Enabled(state.featureMode, state.viewportMode), false, "desktop resize deactivates the v2 architecture without changing the selected flag");
|
|
51
|
+
|
|
52
|
+
let tabletState = createMobileShellState({ viewport: { width: 820, height: 1180, coarsePointer: true, hover: false }, featureMode: "legacy", tabletFeatureMode: "v2" });
|
|
53
|
+
assert.equal(isMobileShellV2Enabled(tabletState.featureMode, tabletState.viewportMode, tabletState.tabletFeatureMode), true);
|
|
54
|
+
tabletState = reduceMobileShellState(tabletState, { type: "surface", surface: "more", page: "settings" });
|
|
55
|
+
tabletState = reduceMobileShellState(tabletState, { type: "viewport", viewport: { width: 1024, height: 768, coarsePointer: true, hover: false } });
|
|
56
|
+
assert.equal(tabletState.surface, "more", "tablet rotation preserves compatible right-sheet state");
|
|
57
|
+
tabletState = reduceMobileShellState(tabletState, { type: "tablet-feature", featureMode: "legacy" });
|
|
58
|
+
assert.equal(tabletState.surface, "none", "tablet rollback closes only adaptive shell surfaces");
|
|
59
|
+
|
|
60
|
+
const validTarget = normalizeMobileNavigationTarget({ v: 1, route: "activity", tabId: "tab_12345678", runId: "run_12345678" });
|
|
61
|
+
assert.deepEqual(validTarget, { v: 1, route: "activity", tabId: "tab_12345678", runId: "run_12345678" });
|
|
62
|
+
assert.equal(normalizeMobileNavigationTarget({ v: 2, route: "activity", tabId: "tab_12345678" }), null, "unknown target versions must fail closed");
|
|
63
|
+
assert.equal(normalizeMobileNavigationTarget({ v: 1, route: "activity", tabId: "private title" }), null, "navigation targets accept opaque IDs only");
|
|
64
|
+
const targetSearch = mobileNavigationTargetSearch(validTarget);
|
|
65
|
+
assert.equal(targetSearch, "mobileRoute=activity&tab=tab_12345678&run=run_12345678");
|
|
66
|
+
assert.deepEqual(mobileNavigationTargetFromSearch(`?${targetSearch}`), validTarget);
|
|
67
|
+
assert.equal(mobileNavigationTargetFromSearch("?mobileRoute=activity&tab=unsafe%20title"), null);
|
|
68
|
+
|
|
69
|
+
console.log("mobile-shell-state.test.mjs passed");
|