@firstpick/pi-package-webui 0.8.0 → 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.
Files changed (51) hide show
  1. package/README.md +22 -5
  2. package/bin/pi-webui.mjs +434 -100
  3. package/lib/npm-command.mjs +81 -0
  4. package/lib/queue-mutation.mjs +6 -0
  5. package/lib/workspace-files-live-watcher.mjs +138 -0
  6. package/package.json +8 -3
  7. package/public/app.js +2816 -314
  8. package/public/index.html +112 -27
  9. package/public/mobile-shell-state.mjs +166 -0
  10. package/public/service-worker.js +60 -13
  11. package/public/styles.css +1049 -371
  12. package/public/subagent-gate-visibility.mjs +16 -0
  13. package/public/subagent-launch-slot-state.mjs +16 -0
  14. package/public/transcript-renderer.mjs +433 -0
  15. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  16. package/tests/browser/interaction-continuity.spec.mjs +739 -0
  17. package/tests/browser/mobile-foundation.spec.mjs +352 -0
  18. package/tests/browser/optimistic-prompt.spec.mjs +130 -0
  19. package/tests/chat-scroll-intent-static.test.mjs +6 -1
  20. package/tests/codex-fast-mode-static.test.mjs +8 -5
  21. package/tests/compact-sections-static.test.mjs +20 -2
  22. package/tests/compaction-mutation-contract.test.mjs +18 -4
  23. package/tests/compaction-static.test.mjs +1 -0
  24. package/tests/completion-signal-contract.test.mjs +13 -2
  25. package/tests/fast-mode-client-static.test.mjs +7 -4
  26. package/tests/fixtures/fake-pi.mjs +181 -2
  27. package/tests/git-panel-gitignore-static.test.mjs +104 -0
  28. package/tests/http-endpoints-harness.test.mjs +228 -2
  29. package/tests/interaction-state-stability-static.test.mjs +254 -0
  30. package/tests/mobile-continuity-tablet-static.test.mjs +55 -0
  31. package/tests/mobile-foundation-static.test.mjs +69 -0
  32. package/tests/mobile-phone-experience-static.test.mjs +65 -0
  33. package/tests/mobile-shell-state.test.mjs +69 -0
  34. package/tests/mobile-static.test.mjs +244 -38
  35. package/tests/mobile-transcript-cache-characterization.test.mjs +34 -0
  36. package/tests/npm-command.test.mjs +64 -1
  37. package/tests/open-issue-wizard-static.test.mjs +2 -1
  38. package/tests/queue-edit-reorder-static.test.mjs +9 -1
  39. package/tests/queue-mutation-contract.test.mjs +22 -0
  40. package/tests/service-worker-lifecycle.test.mjs +120 -0
  41. package/tests/sse-backpressure-harness.test.mjs +98 -0
  42. package/tests/streaming-ui-coupling.test.mjs +7 -1
  43. package/tests/subagent-gate-visibility.test.mjs +18 -2
  44. package/tests/subagent-launch-slot-state.test.mjs +32 -0
  45. package/tests/subagent-launch-slots-static.test.mjs +8 -2
  46. package/tests/subagents-helper.test.mjs +90 -0
  47. package/tests/terminal-tab-workspace-static.test.mjs +1 -1
  48. package/tests/update-commands.test.mjs +4 -0
  49. package/tests/workspace-files-live-updates-static.test.mjs +76 -0
  50. package/tests/workspace-files-live-watcher.test.mjs +95 -0
  51. package/webui-rpc-helper.mjs +175 -3
@@ -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");