@firstpick/pi-package-webui 0.10.0 → 0.10.2

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 (49) hide show
  1. package/DEVELOPMENT.md +20 -21
  2. package/README.md +7 -5
  3. package/TECHNICAL.md +6 -2
  4. package/bin/pi-webui.mjs +26 -60
  5. package/index.ts +1 -256
  6. package/package.json +1 -1
  7. package/public/app.js +145 -33
  8. package/public/index.html +10 -7
  9. package/public/service-worker.js +1 -1
  10. package/public/styles.css +51 -7
  11. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  12. package/tests/browser/interaction-continuity.spec.mjs +9 -3
  13. package/tests/codex-fast-mode-static.test.mjs +2 -2
  14. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  15. package/tests/control-visibility-static.test.mjs +3 -3
  16. package/tests/controls-layout-static.test.mjs +3 -3
  17. package/tests/events-tree-context-menu-static.test.mjs +3 -3
  18. package/tests/fast-mode-client-static.test.mjs +1 -1
  19. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  20. package/tests/file-viewer-image-static.test.mjs +3 -3
  21. package/tests/guided-git-activation-static.test.mjs +11 -4
  22. package/tests/guided-git-fallback-runtime.test.mjs +46 -21
  23. package/tests/guided-git-fallback-ui-static.test.mjs +3 -3
  24. package/tests/guided-git-publication-backend-static.test.mjs +10 -5
  25. package/tests/http-endpoints-harness.test.mjs +5 -9
  26. package/tests/intercom-conversation-viewer-static.test.mjs +3 -3
  27. package/tests/main-output-loading-static.test.mjs +18 -12
  28. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  29. package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
  30. package/tests/mobile-foundation-static.test.mjs +3 -3
  31. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  32. package/tests/mobile-static.test.mjs +11 -7
  33. package/tests/open-issue-wizard-static.test.mjs +1 -1
  34. package/tests/optional-feature-prompt-impact-static.test.mjs +67 -0
  35. package/tests/persistent-ui-layout-static.test.mjs +3 -3
  36. package/tests/prompt-input-vertical-scroll-static.test.mjs +3 -3
  37. package/tests/questionnaire-dialog.test.mjs +3 -3
  38. package/tests/resource-tui-extension.test.mjs +4 -18
  39. package/tests/session-sampling-ui-static.test.mjs +3 -3
  40. package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
  41. package/tests/streaming-ui-coupling.test.mjs +2 -0
  42. package/tests/subagent-observability-static.test.mjs +2 -2
  43. package/tests/syntax-highlighting-static.test.mjs +3 -3
  44. package/tests/theme-customizer-static.test.mjs +1 -1
  45. package/tests/windows-drive-cwd-picker-static.test.mjs +3 -3
  46. package/lib/tui-model-profile-selector.mjs +0 -183
  47. package/lib/tui-resource-selector.mjs +0 -173
  48. package/tests/tui-model-profile-selector.test.mjs +0 -102
  49. package/tests/tui-resource-selector.test.mjs +0 -74
@@ -1882,19 +1882,23 @@ assert.match(app, /async function acceptCurrentGitStaging\([\s\S]*summary\?\.sta
1882
1882
  assert.match(app, /function gitWorkflowRequest\([\s\S]*response\.hint \? `\\n\\nHint:/, "guided git failures should show actionable backend hints");
1883
1883
  assert.match(app, /function gitWorkflowRequest\([\s\S]*if \(response\.code\) failure\.code = response\.code;[\s\S]*if \(response\.hint\) failure\.hint = response\.hint;[\s\S]*if \(response\.data\) failure\.data = response\.data;[\s\S]*throw failure;/, "guided git request failures should preserve the structured backend code, hint, and process result");
1884
1884
  assert.match(app, /async function pushGitWorkflow\([\s\S]*if \(error\?\.code === "NO_REMOTE"\) \{[\s\S]*await publishGitWorkflowRepository\(tabId, error\)/, "guided git push should offer GitHub publication only for structured NO_REMOTE failures");
1885
- assert.match(app, /async function publishGitWorkflowRepository\(tabId, failure\)[\s\S]*Publish this repository to GitHub with the authenticated GitHub CLI \(gh\) account instead\?[\s\S]*if \(!publishRequested\) return false;[\s\S]*repoName = promptGitPublishRepoName\(tabId\);[\s\S]*if \(!repoName\) return false;[\s\S]*visibility = promptGitPublishVisibility\(repoName\);[\s\S]*if \(!visibility\) return false;/, "guided git publication should ask to publish, then require a repository name and explicit visibility before continuing");
1886
- assert.match(app, /async function publishGitWorkflowRepository\([\s\S]*const confirmed = await appConfirmText\(\[[\s\S]*Repository name: \$\{repoName\}[\s\S]*Visibility: \$\{visibility\}[\s\S]*Branch to push: \$\{branch\}[\s\S]*Resulting remote: origin[\s\S]*if \(!confirmed\) return false;[\s\S]*gitWorkflowRequest\("\/api\/git-workflow\/publish", \{ body: \{ repoName, visibility, confirmed: true \}/, "guided git publication should require a final summary confirmation before the confirmed publish request");
1885
+ assert.match(app, /async function publishGitWorkflowRepository\(tabId, failure\)[\s\S]*const repoName = cleanGitHubRepoNameInput\(failure\?\.data\?\.repoName \|\| defaultGitInitRepoName\(targetTab\)\);[\s\S]*Publish this repository to GitHub as \$\{repoName\} with the authenticated GitHub CLI \(gh\) account\?[\s\S]*if \(!publishRequested\) return false;[\s\S]*visibility = await promptGitPublishVisibility\(repoName\);[\s\S]*if \(!visibility\) return false;/, "guided git publication should derive the repository name and ask only for explicit visibility");
1886
+ assert.match(app, /async function publishGitWorkflowRepository\([\s\S]*const confirmed = await appConfirmText\(\[[\s\S]*Repository name: \$\{repoName\}[\s\S]*Visibility: \$\{visibility\}[\s\S]*Branch to push: \$\{branch\}[\s\S]*Resulting remote: origin[\s\S]*if \(!confirmed\) return false;[\s\S]*gitWorkflowRequest\("\/api\/git-workflow\/publish", \{ body: \{ visibility, confirmed: true \}/, "guided git publication should confirm the derived name and omit a client-controlled name from the publish request");
1887
1887
  assert.match(app, /async function publishGitWorkflowRepository\([\s\S]*Published \$\{result\.repoName \|\| repoName\} as \$\{result\.visibility \|\| visibility\}\.[\s\S]*Remote: \$\{result\.remote \|\| "origin"\}[\s\S]*Branch: \$\{result\.branch \|\| branch\}[\s\S]*scheduleRefreshFooter\(\)/, "successful publication should report branch/remote metadata and refresh the footer");
1888
- assert.match(app, /function promptGitPublishRepoName\(tabId = activeTabId\) \{\n\s+const targetTab = tabs\.find\(\(tab\) => tab\.id === tabId\) \|\| activeTab\(\);\n\s+const value = window\.prompt\("GitHub repository name to create", defaultGitInitRepoName\(targetTab\)\);[\s\S]*return cleanGitHubRepoNameInput\(value\);/, "publication should prefill the repository name from the publishing tab's workspace directory and validate it with the existing client rules");
1889
- assert.match(app, /async function publishGitWorkflowRepository\(tabId, failure\)[\s\S]*const branch = failure\?\.data\?\.branch \|\| gitFooterCurrentBranch\(\) \|\| "the current branch";[\s\S]*repoName = promptGitPublishRepoName\(tabId\);/, "publication confirmation should prefer the server-reported branch and resolve the repository-name default from the publishing tab");
1890
- assert.match(app, /function promptGitPublishVisibility\(repoName\) \{\n\s+const value = window\.prompt\(`Visibility for GitHub repository \$\{repoName\} — type public or private \(no default\)`, ""\);/, "visibility must be typed with no preselected default");
1888
+ assert.doesNotMatch(app, /function promptGitPublishRepoName\(/, "publication should not ask the user to name a repository");
1889
+ assert.match(server, /case "\/api\/git-workflow\/publish": \{[\s\S]*const root = await getGitRoot\(cwd\);[\s\S]*const repoName = cleanGitHubRepoName\(path\.basename\(root\)\);[\s\S]*\["repo", "create", repoName, `--\$\{visibility\}`, "--source", "\.", "--remote", "origin", "--push"\][\s\S]*\{ cwd: root, timeoutMs:/, "server publication should derive the Git root directory name and let gh use system configuration while adding origin and pushing");
1890
+ assert.match(html, /<select id="textPromptSelect" class="dialog-input" aria-labelledby="textPromptTitle" hidden><\/select>/, "the application prompt should provide a native dropdown control");
1891
+ assert.match(app, /function appPromptSelect\([\s\S]*placeholderOption\.disabled = true;[\s\S]*placeholderOption\.selected = true;[\s\S]*select\.value = "";/, "selection prompts should require an explicit choice with no preselected value");
1892
+ assert.match(app, /async function promptGitPublishVisibility\(repoName\) \{[\s\S]*await appPromptSelect\(\{[\s\S]*\{ value: "public", label: "Public" \}[\s\S]*\{ value: "private", label: "Private" \}[\s\S]*placeholder: "Choose visibility…"/, "repository visibility should use a public/private dropdown with no default");
1893
+ assert.doesNotMatch(app, /async function promptGitPublishVisibility\(repoName\) \{[\s\S]{0,500}window\.prompt/, "repository visibility should not use the browser text prompt");
1891
1894
  assert.match(app, /function cleanGitPublishVisibilityInput\(value\)[\s\S]*if \(visibility !== "public" && visibility !== "private"\)[\s\S]*nothing was published/, "publication visibility must be exactly public or private");
1892
1895
  assert.doesNotMatch(app, /visibility = "(?:public|private)"/, "publication visibility should never be defaulted in the frontend");
1893
1896
  assert.match(server, /async function gitAddAllPayload\([\s\S]*platform\(\) === "win32"[\s\S]*findWindowsReservedGitPath\([\s\S]*windowsReservedGitPathFailure\(/, "guided git add should preflight Windows-reserved untracked paths before staging");
1894
1897
  assert.match(app, /Pre-commit verification reminder[\s\S]*Continue with this commit/, "configured verification reminders should run before committing");
1895
- assert.match(server, /async function startGitWorkflowGeneration\([\s\S]*set_model[\s\S]*setThinkingLevelForTab[\s\S]*type: "prompt"/, "server should apply the configured generation profile before prompting Pi");
1898
+ assert.match(server, /function gitWorkflowGenerationProfileArgument\(profile\)[\s\S]*--firstpick-webui-generation-profile=/, "server should encode the configured generation profile for the native extension command");
1899
+ assert.match(server, /async function dispatchGitWorkflowGenerationAttempt\([\s\S]*record\.message = gitWorkflowGenerationPrompt\(record\.kind, record\.preferences, record\.nativeCommandName, profile\)[\s\S]*type: "prompt"/, "server should dispatch the configured generation profile without changing the tab profile");
1896
1900
  assert.match(server, /function consumeGitWorkflowGenerationEvent\(tab, event[\s\S]*event\?\.type !== "agent_settled"[\s\S]*settleGitWorkflowGeneration\(tab, record, settlement\)/, "server should settle the owned Guided Git attempt only after agent settlement");
1897
- assert.match(server, /async function finishGitWorkflowGeneration\(tab, record[\s\S]*restoreGitWorkflowGenerationProfile\(tab, record\)/, "server should restore the active tab model and effort after Guided Git generation finishes");
1901
+ assert.match(server, /async function finishGitWorkflowGeneration\(tab, record[\s\S]*if \(tab\.gitWorkflowGeneration === record\) tab\.gitWorkflowGeneration = null;/, "server should finish Guided Git generation without restoring or changing the active tab model and effort");
1898
1902
  assert.match(server, /case "\/api\/git-workflow\/branch-name": \{[\s\S]*generationId[\s\S]*readGitWorkflowBranchName\(cwd, \{ generationId/, "server should expose exactly correlated generated branch-name loading for the guided PR workflow");
1899
1903
  assert.match(server, /case "\/api\/git-workflow\/branch":[\s\S]*createGitWorkflowBranchWorktree\(tab, body\)/, "server should route guided PR branch creation through worktree tabs");
1900
1904
  assert.match(server, /async function createGitWorkflowBranchWorktree\(tab, body = \{\}\)[\s\S]*expectedStagedContentHashFromBody\(body\)[\s\S]*snapshotGitWorkflowBranchState\(root, tab\.cwd, expectedStagedContentHash\)[\s\S]*applyGitWorkflowBranchStateToWorktree\(snapshot, worktreePath\)[\s\S]*openWorktreeResultForTab\(tab, createdResult/, "guided PR worktree creation should verify and copy exact staged state before opening the worktree tab");
@@ -68,7 +68,7 @@ assert.match(server, /STATIC_PUBLIC_FILE_EXTENSIONS[\s\S]*"\.mjs"/, "the server
68
68
  assert.match(serviceWorker, /"\/issue-wizard-state\.mjs"/, "the PWA shell must keep caching the pure wizard module");
69
69
  assert.match(serviceWorker, /"\/issue-bot-client\.mjs"/, "the PWA shell must cache the browser client module");
70
70
  // Intent preserved: changing the public startup graph advances the PWA cache identity.
71
- assert.match(serviceWorker, /pi-webui-pwa-v145/, "the PWA cache name must change with browser wiring updates");
71
+ assert.match(serviceWorker, /pi-webui-pwa-v153/, "the PWA cache name must change with browser wiring updates");
72
72
  assert.match(packageJson, /node --check public\/issue-wizard-state\.mjs/, "the package check must keep syntax-checking the pure wizard module");
73
73
  assert.match(packageJson, /node --check public\/issue-bot-client\.mjs/, "the package check must syntax-check the browser client module");
74
74
 
@@ -0,0 +1,67 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFile } from "node:fs/promises";
3
+
4
+ const [app, css, html, serviceWorker, readme, technical, development] = await Promise.all([
5
+ readFile(new URL("../public/app.js", import.meta.url), "utf8"),
6
+ readFile(new URL("../public/styles.css", import.meta.url), "utf8"),
7
+ readFile(new URL("../public/index.html", import.meta.url), "utf8"),
8
+ readFile(new URL("../public/service-worker.js", import.meta.url), "utf8"),
9
+ readFile(new URL("../README.md", import.meta.url), "utf8"),
10
+ readFile(new URL("../TECHNICAL.md", import.meta.url), "utf8"),
11
+ readFile(new URL("../DEVELOPMENT.md", import.meta.url), "utf8"),
12
+ ]);
13
+
14
+ const expectedImpact = new Map([
15
+ ["bangCommandAutocomplete", "none"],
16
+ ["fishUserBash", "none"],
17
+ ["btwCommand", "none"],
18
+ ["gitWorkflow", "none"],
19
+ ["releaseNpm", "none"],
20
+ ["releaseAur", "initial"],
21
+ ["aurReview", "none"],
22
+ ["workflows", "initial"],
23
+ ["featureSystemPrompt", "conditional"],
24
+ ["safetyGuard", "none"],
25
+ ["tuiSkillsCommand", "none"],
26
+ ["todoProgressWidget", "initial"],
27
+ ["tuiToolsCommand", "none"],
28
+ ["remoteWebui", "none"],
29
+ ["questionnaire", "initial"],
30
+ ["naturalConversation", "conditional"],
31
+ ["gitFooterStatus", "none"],
32
+ ["statsCommand", "none"],
33
+ ["codexFastMode", "none"],
34
+ ["themeBundle", "none"],
35
+ ]);
36
+
37
+ function optionalFeatureBlock(featureId) {
38
+ const match = app.match(new RegExp(`\\{\\n\\s+id: "${featureId}",[\\s\\S]*?\\n\\s+\\},`));
39
+ assert.ok(match, `optional feature ${featureId} should remain declared`);
40
+ return match[0];
41
+ }
42
+
43
+ for (const [featureId, impact] of expectedImpact) {
44
+ assert.match(optionalFeatureBlock(featureId), new RegExp(`promptImpact: "${impact}"`), `${featureId} should declare ${impact} prompt impact`);
45
+ }
46
+
47
+ const catalog = app.slice(app.indexOf("const OPTIONAL_FEATURES = ["), app.indexOf("const OPTIONAL_FEATURE_PROMPT_IMPACTS"));
48
+ const declaredImpacts = [...catalog.matchAll(/promptImpact: "(initial|conditional|none)"/g)];
49
+ assert.equal(declaredImpacts.length, expectedImpact.size, "every optional feature should declare exactly one recognized prompt-impact class");
50
+
51
+ assert.match(app, /initial: Object\.freeze\(\{ symbol: "\+", label: "Adds to the initial system prompt" \}\)/, "+ should describe initial system-prompt text");
52
+ assert.match(app, /conditional: Object\.freeze\(\{ symbol: "\+\.\.\.", label: "Can add system-prompt text while the session is running" \}\)/, "+... should describe conditional session-time prompt text");
53
+ assert.match(app, /none: Object\.freeze\(\{ symbol: "-", label: "No additional system-prompt text measured" \}\)/, "- should describe no measured system-prompt text");
54
+ assert.doesNotMatch(app, /renderOptionalFeaturePromptImpactLegend|optional-feature-prompt-impact-legend/, "the panel should not repeat a prompt-impact legend above the feature list");
55
+ assert.match(app, /function renderOptionalFeatureRow\(feature\)[\s\S]*?System prompt impact: \$\{impact\.label\}[\s\S]*?renderOptionalFeaturePromptImpactBadge\(feature\)/, "each feature row should expose the impact in its tooltip and visible heading");
56
+ assert.match(css, /\.optional-feature-prompt-impact \{[\s\S]*?width: 2\.8rem;[\s\S]*?min-width: 2\.8rem;[\s\S]*?\.optional-feature-prompt-impact\.initial[\s\S]*?\.optional-feature-prompt-impact\.conditional[\s\S]*?\.optional-feature-prompt-impact\.none/, "all three row indicator classes should use the same fixed width");
57
+ assert.doesNotMatch(css, /optional-feature-prompt-impact-legend/, "removed legend styles should not remain in the browser bundle");
58
+ assert.match(app, /const statusTags = make\("div", "optional-feature-status-tags"\);[\s\S]*?statusTags\.append\(renderOptionalFeaturePromptImpactBadge\(feature\), make\("span", `optional-feature-pill/, "the impact and feature-status badges should share one dedicated row");
59
+ assert.match(css, /\.optional-feature-title \{[\s\S]*?flex-direction: column;[\s\S]*?\.optional-feature-status-tags \{[\s\S]*?display: inline-flex;[\s\S]*?gap: 0\.34rem;[\s\S]*?\.optional-feature-pill \{[\s\S]*?flex: 0 0 auto;/, "title width should not stretch the feature-status badge or the gap between badges");
60
+ assert.match(readme, /\+.*initial system prompt[\s\S]*?\+\.\.\..*session is running[\s\S]*?-.*no measured system-prompt text/i, "README should explain the symbols in user language");
61
+ assert.match(technical, /prompt-impact indicators[\s\S]*?tool schemas and ordinary user or tool messages are not counted/i, "technical reference should state the measurement boundary");
62
+ assert.match(development, /reports\/pi-default-system-prompt-evaluation\.md[\s\S]*?promptImpact/, "contributor guide should identify the evidence source and catalog field");
63
+ assert.match(html, /styles\.css\?v=152/, "indicator styles should advance the stylesheet revision");
64
+ assert.match(html, /app\.js\?v=182/, "indicator rendering should advance the app revision");
65
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "browser asset changes should advance the PWA cache identity");
66
+
67
+ console.log("optional-feature-prompt-impact-static.test.mjs passed");
@@ -271,8 +271,8 @@ assert.match(
271
271
 
272
272
  // --- Coherent browser asset revisions --------------------------------------
273
273
 
274
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v145"/, "changed browser assets should advance the PWA cache identity");
275
- assert.match(html, /styles\.css\?v=145/, "the page should request the updated layout stylesheet revision");
276
- assert.match(html, /data-app-src="\/app\.js\?v=177"/, "the boot loader should request the updated app module revision");
274
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "changed browser assets should advance the PWA cache identity");
275
+ assert.match(html, /styles\.css\?v=152/, "the page should request the updated layout stylesheet revision");
276
+ assert.match(html, /data-app-src="\/app\.js\?v=182"/, "the boot loader should request the updated app module revision");
277
277
 
278
278
  console.log("persistent-ui-layout-static.test.mjs passed");
@@ -19,8 +19,8 @@ const resizePromptInput = app.slice(resizeStart, resizeEnd);
19
19
  assert.match(css, /#promptInput \{[\s\S]*--prompt-input-block-chrome: calc\(1\.8rem \+ 2px\);[\s\S]*max-height: calc\(6lh \+ var\(--prompt-input-block-chrome\)\);[\s\S]*overflow-y: auto;[\s\S]*overscroll-behavior-y: contain;/, "the prompt should show six complete lines before native vertical scrolling begins");
20
20
  assert.match(resizePromptInput, /input\.style\.height = "auto";[\s\S]*borderTopWidth[\s\S]*borderBottomWidth[\s\S]*naturalHeight = input\.scrollHeight \+ borderBlock[\s\S]*isCapped \? "auto" : "hidden"/, "auto-resizing should include the textarea borders and enable vertical scrolling only after the six-line cap");
21
21
  assert.doesNotMatch(resizePromptInput, /input\.style\.overflowY = "auto";/, "auto-resizing must not force a scrollbar below the six-line cap");
22
- assert.match(html, /styles\.css\?v=145/, "the page should request the six-line prompt stylesheet revision");
23
- assert.match(html, /app\.js\?v=177/, "the page should request the current app revision");
24
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v145"/, "the PWA cache identity should advance with the prompt scroll assets");
22
+ assert.match(html, /styles\.css\?v=152/, "the page should request the six-line prompt stylesheet revision");
23
+ assert.match(html, /app\.js\?v=182/, "the page should request the current app revision");
24
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "the PWA cache identity should advance with the prompt scroll assets");
25
25
 
26
26
  console.log("prompt-input-vertical-scroll-static.test.mjs passed");
@@ -504,8 +504,8 @@ assert.match(css, /@media \(max-width: 720px\), \(max-device-width: 720px\), \(p
504
504
  assert.match(css, /\.questionnaire-options button\s*\{\s*min-height:\s*3\.35rem/, "mobile questionnaire targets must exceed the 44px floor");
505
505
  assert.match(css, /@media \(prefers-reduced-motion: reduce\)\s*\{[\s\S]*?\*, \*::before, \*::after[\s\S]*?transition-duration:\s*1ms !important/, "global reduced-motion rules must cover questionnaire transitions");
506
506
 
507
- assert.match(html, /styles\.css\?v=145/, "questionnaire CSS needs the current stylesheet revision");
508
- assert.match(html, /app\.js\?v=177/, "questionnaire behavior needs the current app revision");
509
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v145"/, "questionnaire public assets need a coherent PWA cache revision");
507
+ assert.match(html, /styles\.css\?v=152/, "questionnaire CSS needs the current stylesheet revision");
508
+ assert.match(html, /app\.js\?v=182/, "questionnaire behavior needs the current app revision");
509
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "questionnaire public assets need a coherent PWA cache revision");
510
510
 
511
511
  console.log("questionnaire-dialog.test.mjs passed");
@@ -2,23 +2,9 @@ import assert from "node:assert/strict";
2
2
  import { readFile } from "node:fs/promises";
3
3
 
4
4
  const source = await readFile(new URL("../index.ts", import.meta.url), "utf8");
5
- assert.match(source, /pi\.registerCommand\("tools"/);
6
- assert.match(source, /pi\.registerCommand\("skills"/);
7
- assert.doesNotMatch(
8
- source,
9
- /const runtimeToolBaseline\s*=\s*normalizeResourceNameList\(pi\.getActiveTools\(\)\)/,
10
- "extension action methods must not run while the extension factory is loading",
11
- );
12
- assert.match(source, /const runtimeTools = \(\): string\[\] => runtimeToolBaseline \?\?=/, "the tool baseline should be captured lazily after runtime binding");
13
- assert.match(source, /ctx\.mode !== "tui"/);
14
- assert.match(source, /pi\.on\("model_select"/);
15
- assert.match(source, /await recompute\(ctx, event\.model\)/, "model selection should immediately recompute exact-model resources");
16
- assert.match(source, /"Session only", "Global default", "Model default"/);
17
- assert.match(source, /"Use inherited defaults"/);
18
- assert.match(source, /selectTuiModelProfile\(ctx, \{/, "exact-model profiles should use the shared searchable model picker");
19
- assert.match(source, /selectTuiResources\(ctx, \{/, "resource lists should use the shared keyboard-driven selector");
20
- assert.match(source, /preserveUnavailableResourceNames\(/);
21
- assert.match(source, /setExactModelProfile\(/);
22
- assert.match(source, /skill\.disableModelInvocation !== true/);
5
+
6
+ assert.doesNotMatch(source, /pi\.registerCommand\("tools"/, "the tools extension must own /tools");
7
+ assert.doesNotMatch(source, /pi\.registerCommand\("skills"/, "the skills extension must own /skills");
8
+ assert.doesNotMatch(source, /registerTuiResourceController/, "WebUI must not manage TUI tool or skill state");
23
9
 
24
10
  console.log("resource-tui-extension.test.mjs passed");
@@ -57,10 +57,10 @@ assert.match(css, /\.sampling-parameter-control\.unsupported:hover:not\(\.sampli
57
57
  assert.match(css, /\.sampling-parameter-control\.unsupported:focus-visible:not\(\.sampling-tooltip-dismissed\) > \.sampling-parameter-unsupported-tooltip/, "keyboard focus should reveal dismissible unsupported reasons");
58
58
  assert.match(css, /\.sampling-parameter-unsupported-tooltip\.sampling-tooltip-below/, "bounded placement should support flipping below top-edge rows");
59
59
  assert.match(css, /pointer-events: auto;/, "a visible unsupported tooltip should remain pointer-hoverable");
60
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v145"/, "native-control assets should advance the cache identity");
60
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "native-control assets should advance the cache identity");
61
61
  assert.match(serviceWorker, /"\/sampling-parameter-controls\.mjs"/, "the pure sampling module should be part of the offline app shell");
62
- assert.match(html, /styles\.css\?v=145/, "the changed stylesheet should have a new revision");
63
- assert.match(html, /app\.js\?v=177/, "the changed app module should have a new revision");
62
+ assert.match(html, /styles\.css\?v=152/, "the changed stylesheet should have a new revision");
63
+ assert.match(html, /app\.js\?v=182/, "the changed app module should have a new revision");
64
64
 
65
65
  // --- Browser state behavior -------------------------------------------------
66
66
 
@@ -27,8 +27,8 @@ assert.doesNotMatch(layout, /sectionHeightMin|sectionHeightMax|validateSectionHe
27
27
  assert.match(app, /const UI_LAYOUT_SIDE_PANEL_FIELDS = \["placement", "sectionLayout", "collapsedSectionIds", "hiddenSectionIds", "collapsedPanels", "panelWidths"\];/, "the browser durable layout field list should omit section heights");
28
28
  assert.match(app, /function clearRemovedSidePanelSectionHeightState\(\)[\s\S]*localStorage\.removeItem\(REMOVED_SIDE_PANEL_SECTION_HEIGHT_STORAGE_KEY\)[\s\S]*record\.field === "sidePanel" && record\.subfield === "sectionHeights"/, "startup should remove the retired cache and pending mutations");
29
29
  assert.match(app, /clearRemovedSidePanelSectionHeightState\(\);\s*restoreDurableUiLayoutPendingJournal\(\);/, "retired height state should be cleared before pending layout restoration");
30
- assert.match(html, /styles\.css\?v=145/, "removing section resize styles should advance the stylesheet revision");
31
- assert.match(html, /app\.js\?v=177/, "removing section resize behavior should advance the app revision");
32
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v145"/, "removing browser assets should advance the PWA cache identity");
30
+ assert.match(html, /styles\.css\?v=152/, "removing section resize styles should advance the stylesheet revision");
31
+ assert.match(html, /app\.js\?v=182/, "removing section resize behavior should advance the app revision");
32
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "removing browser assets should advance the PWA cache identity");
33
33
 
34
34
  console.log("side-panel-section-height-removal-static.test.mjs passed");
@@ -259,6 +259,8 @@ assert.match(findCaseBody(handleEvent, "tool_execution_end"), /claimToolBoundary
259
259
  assert.match(findFunctionBody(app, "scheduleSemanticReconcile"), /mergeSemanticReconcileRequest\(semanticReconcilePending, dirty, tabContext\)[\s\S]*?semanticReconcileFrame !== null\) return;/, "WS2a: semantic reconciliation must coalesce partitioned requests to one pending flush");
260
260
  assert.match(findFunctionBody(app, "mergeSemanticReconcileRequest"), /semanticReconcileContextKey\(tabContext\)[\s\S]*?pendingByContext\.set\(key, request\)/, "WS2a: semantic dirty flags must remain partitioned by tab generation");
261
261
  assert.match(flushSemanticReconcile, /if \(dirty\.workflow\) reconcileGitWorkflowContinuation\(tabContext\.tabId\);[\s\S]*?if \(!isCurrentTabContext\(tabContext\)\) continue;/, "WS2a: originating workflow settlement must run before stale active-DOM work no-ops");
262
+ const reconcileGitWorkflowContinuation = findFunctionBody(app, "reconcileGitWorkflowContinuation");
263
+ assert.match(reconcileGitWorkflowContinuation, /workflow\.step === "readmeGenerating"[\s\S]*?prepareGitInitFiles\(\{ afterReadmePrompt: true,[\s\S]*?workflow\.step === "gitignoreGenerating"[\s\S]*?prepareGitInitFiles\(\{ afterGitignorePrompt: true,/, "WS2a: settlement must continue README and .gitignore initialization after Pi finishes");
262
264
  for (const [caseLabel, flag] of [["agent_start", "state: true"], ["agent_end", "messages: true"], ["message_end", "messages: true"], ["agent_settled", "messages: true"]]) {
263
265
  assert.match(findCaseBody(handleEvent, caseLabel), new RegExp(`scheduleSemanticReconcile\\(\\{[\\s\\S]*?${flag}`), `WS2a: ${caseLabel} must reconcile chrome through the coalesced semantic scheduler`);
264
266
  }
@@ -28,7 +28,7 @@ assert.match(app, /const SUBAGENT_ASYNC_WIDGET_KEY = "subagent-async"[\s\S]*case
28
28
  assert.match(app, /for \(const \[key, value\] of widgets\)[\s\S]*if \(key === SUBAGENT_ASYNC_WIDGET_KEY\) continue;/, "stale cached async-status widgets should remain hidden defensively");
29
29
  assert.match(css, /\.subagent-source-badge[\s\S]*text-overflow: ellipsis[\s\S]*@media \(max-width: 720px\)/, "source badges should remain compact and responsive");
30
30
  assert.match(html, /Managed and registered Pi agent runs[\s\S]*External agents/, "help should explain managed, registered, and external groups");
31
- assert.match(html, /styles\.css\?v=145[\s\S]*app\.js\?v=177/, "browser assets should use the current subagent-observability revisions");
32
- assert.match(worker, /pi-webui-pwa-v145/, "PWA cache identity should advance with subagent widget suppression");
31
+ assert.match(html, /styles\.css\?v=152[\s\S]*app\.js\?v=182/, "browser assets should use the current subagent-observability revisions");
32
+ assert.match(worker, /pi-webui-pwa-v153/, "PWA cache identity should advance with subagent widget suppression");
33
33
 
34
34
  console.log("subagent-observability-static.test.mjs passed");
@@ -60,9 +60,9 @@ assert.match(css, /\.markdown-code \.syntax-comment \{[^}]*font-style: italic;/,
60
60
 
61
61
  // --- Offline/PWA startup closure and coherent revisions ---
62
62
  assert.match(serviceWorker, /"\/syntax-highlight\.mjs",/, "the eagerly imported tokenizer must be part of the offline app shell");
63
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v145"/, "adding a startup module should advance the PWA cache identity");
64
- assert.match(html, /styles\.css\?v=145/, "new token styles should advance the stylesheet revision");
65
- assert.match(html, /data-app-src="\/app\.js\?v=177"/, "new renderer wiring should advance the app module revision");
63
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "adding a startup module should advance the PWA cache identity");
64
+ assert.match(html, /styles\.css\?v=152/, "new token styles should advance the stylesheet revision");
65
+ assert.match(html, /data-app-src="\/app\.js\?v=182"/, "new renderer wiring should advance the app module revision");
66
66
  assert.match(pkg, /node --check public\/syntax-highlight\.mjs/, "the package check should syntax-check the startup-critical tokenizer");
67
67
 
68
68
  const appShell = serviceWorker.slice(serviceWorker.indexOf("const APP_SHELL"), serviceWorker.indexOf("];", serviceWorker.indexOf("const APP_SHELL")));
@@ -34,7 +34,7 @@ assert.match(html, /role="alert" hidden>[\s\S]*Replace this exact target\?/, "ov
34
34
 
35
35
  assert.match(app, /from "\.\/theme-contract\.mjs"/, "frontend should consume the shared browser-safe theme contract");
36
36
  assert.match(serviceWorker, /"\/theme-contract\.mjs"/, "the PWA app shell should cache the startup-critical theme contract");
37
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v145"/, "adding the theme contract to the startup graph should advance the PWA cache identity");
37
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "adding the theme contract to the startup graph should advance the PWA cache identity");
38
38
  assert.match(pkg, /node --check public\/theme-contract\.mjs/, "the package check should syntax-check the startup-critical theme contract");
39
39
  assert.match(app, /function themeDraftFromCatalog\(theme, name = theme\?\.name\)[\s\S]*colors: cloneThemeDraft\(theme\?\.colors \|\| \{\}\)/, "catalog metadata should be projected into a schema-only editable draft");
40
40
  assert.match(app, /for \(const \{ name, label \} of group\.tokens\)/, "visual controls should render from the exact shared token inventory");
@@ -74,8 +74,8 @@ assert.match(technical, /working-directory picker accepts a direct path[\s\S]*\*
74
74
  assert.match(development, /virtual \*\*This PC\*\* response with an empty cwd and `selectable: false`/i, "the contributor guide should record the server/browser virtual-view contract");
75
75
  assert.ok(packageJson.files.includes("TECHNICAL.md"), "the published package should include its advanced user reference");
76
76
  assert.ok(packageJson.files.includes("DEVELOPMENT.md"), "the published package should include its contributor guide");
77
- assert.match(html, /styles\.css\?v=145/, "the existing picker layout should retain its stylesheet revision");
78
- assert.match(html, /app\.js\?v=177/, "the changed picker behavior should advance the app revision");
79
- assert.match(serviceWorker, /pi-webui-pwa-v145/, "the changed browser assets should advance the PWA cache identity");
77
+ assert.match(html, /styles\.css\?v=152/, "the existing picker layout should retain its stylesheet revision");
78
+ assert.match(html, /app\.js\?v=182/, "the changed picker behavior should advance the app revision");
79
+ assert.match(serviceWorker, /pi-webui-pwa-v153/, "the changed browser assets should advance the PWA cache identity");
80
80
 
81
81
  console.log("windows-drive-cwd-picker-static.test.mjs passed");
@@ -1,183 +0,0 @@
1
- import { DynamicBorder } from "@earendil-works/pi-coding-agent";
2
- import { Container, fuzzyFilter, getKeybindings, Input, Key, matchesKey, Spacer, Text } from "@earendil-works/pi-tui";
3
-
4
- function modelKey(model) {
5
- return `${model.provider}\0${model.id}`;
6
- }
7
-
8
- function modelSearchText(model) {
9
- return `${model.provider} ${model.id} ${model.name || ""}`;
10
- }
11
-
12
- export class TuiModelProfileSelectorComponent extends Container {
13
- constructor(config, theme, callbacks) {
14
- super();
15
- const seen = new Set();
16
- this.models = config.models.filter((model) => {
17
- if (!model?.provider || !model?.id) return false;
18
- const key = modelKey(model);
19
- if (seen.has(key)) return false;
20
- seen.add(key);
21
- return true;
22
- });
23
- this.activeModelKey = config.activeModelKey || "";
24
- this.configuredModelKeys = new Set(config.configuredModelKeys || []);
25
- this.theme = theme;
26
- this.callbacks = callbacks;
27
- this.filteredModels = [...this.models];
28
- const activeModel = this.models.find((model) => modelKey(model) === this.activeModelKey);
29
- const configuredModel = this.models.find((model) => this.configuredModelKeys.has(modelKey(model)));
30
- const initialKey = activeModel ? this.activeModelKey : configuredModel ? modelKey(configuredModel) : "";
31
- this.selectedIndex = Math.max(0, this.filteredModels.findIndex((model) => modelKey(model) === initialKey));
32
- this.lastQuery = "";
33
- this.maxVisible = 10;
34
- this._focused = false;
35
-
36
- this.addChild(new DynamicBorder((text) => theme.fg("accent", text)));
37
- this.addChild(new Spacer(1));
38
- this.addChild(new Text(theme.fg("accent", theme.bold(config.title)), 0, 0));
39
- this.addChild(new Text(theme.fg("muted", config.subtitle), 0, 0));
40
- this.addChild(new Spacer(1));
41
-
42
- this.searchInput = new Input();
43
- this.addChild(this.searchInput);
44
- this.addChild(new Spacer(1));
45
-
46
- this.listContainer = new Container();
47
- this.addChild(this.listContainer);
48
- this.addChild(new Spacer(1));
49
-
50
- this.footerText = new Text(this.footer(), 0, 0);
51
- this.addChild(this.footerText);
52
- this.addChild(new DynamicBorder((text) => theme.fg("accent", text)));
53
- this.refresh();
54
- }
55
-
56
- get focused() {
57
- return this._focused;
58
- }
59
-
60
- set focused(value) {
61
- this._focused = value;
62
- this.searchInput.focused = value;
63
- }
64
-
65
- footer() {
66
- const position = this.filteredModels.length ? `${this.selectedIndex + 1}/${this.filteredModels.length}` : "0/0";
67
- return this.theme.fg("dim", ` ↑/↓ navigate · Enter select · Ctrl+C clear/cancel · Esc cancel · ${position}`);
68
- }
69
-
70
- refresh() {
71
- const selectedKey = this.filteredModels[this.selectedIndex] ? modelKey(this.filteredModels[this.selectedIndex]) : "";
72
- const query = this.searchInput.getValue();
73
- const queryChanged = query !== this.lastQuery;
74
- this.lastQuery = query;
75
- this.filteredModels = query ? fuzzyFilter(this.models, query, modelSearchText) : [...this.models];
76
- const retainedIndex = selectedKey
77
- ? this.filteredModels.findIndex((model) => modelKey(model) === selectedKey)
78
- : -1;
79
- this.selectedIndex = retainedIndex >= 0
80
- ? retainedIndex
81
- : queryChanged
82
- ? 0
83
- : Math.min(this.selectedIndex, Math.max(0, this.filteredModels.length - 1));
84
- this.updateList();
85
- this.footerText.setText(this.footer());
86
- this.callbacks.onRender?.();
87
- }
88
-
89
- updateList() {
90
- this.listContainer.clear();
91
- if (this.filteredModels.length === 0) {
92
- this.listContainer.addChild(new Text(this.theme.fg("muted", " No matching models"), 0, 0));
93
- return;
94
- }
95
-
96
- const startIndex = Math.max(
97
- 0,
98
- Math.min(this.selectedIndex - Math.floor(this.maxVisible / 2), this.filteredModels.length - this.maxVisible),
99
- );
100
- const endIndex = Math.min(startIndex + this.maxVisible, this.filteredModels.length);
101
- for (let index = startIndex; index < endIndex; index++) {
102
- const model = this.filteredModels[index];
103
- const key = modelKey(model);
104
- const selected = index === this.selectedIndex;
105
- const prefix = selected ? this.theme.fg("accent", "→ ") : " ";
106
- const id = selected ? this.theme.fg("accent", model.id) : model.id;
107
- const provider = this.theme.fg("muted", ` [${model.provider}]`);
108
- const active = key === this.activeModelKey ? this.theme.fg("success", " [active]") : "";
109
- const configured = this.configuredModelKeys.has(key) ? this.theme.fg("warning", " [profile]") : "";
110
- this.listContainer.addChild(new Text(`${prefix}${id}${provider}${active}${configured}`, 0, 0));
111
- }
112
-
113
- if (startIndex > 0 || endIndex < this.filteredModels.length) {
114
- this.listContainer.addChild(
115
- new Text(this.theme.fg("muted", ` (${this.selectedIndex + 1}/${this.filteredModels.length})`), 0, 0),
116
- );
117
- }
118
-
119
- const selectedModel = this.filteredModels[this.selectedIndex];
120
- if (selectedModel) {
121
- const profileState = this.configuredModelKeys.has(modelKey(selectedModel)) ? "configured" : "inherited";
122
- this.listContainer.addChild(new Spacer(1));
123
- this.listContainer.addChild(
124
- new Text(this.theme.fg("muted", ` Model Name: ${selectedModel.name || selectedModel.id} · Profile: ${profileState}`), 0, 0),
125
- );
126
- }
127
- }
128
-
129
- handleInput(data) {
130
- const keybindings = getKeybindings();
131
- if (keybindings.matches(data, "tui.select.up")) {
132
- if (this.filteredModels.length > 0) {
133
- this.selectedIndex = this.selectedIndex === 0 ? this.filteredModels.length - 1 : this.selectedIndex - 1;
134
- this.updateList();
135
- this.footerText.setText(this.footer());
136
- this.callbacks.onRender?.();
137
- }
138
- return;
139
- }
140
- if (keybindings.matches(data, "tui.select.down")) {
141
- if (this.filteredModels.length > 0) {
142
- this.selectedIndex = this.selectedIndex === this.filteredModels.length - 1 ? 0 : this.selectedIndex + 1;
143
- this.updateList();
144
- this.footerText.setText(this.footer());
145
- this.callbacks.onRender?.();
146
- }
147
- return;
148
- }
149
- if (keybindings.matches(data, "tui.select.confirm")) {
150
- const model = this.filteredModels[this.selectedIndex];
151
- if (model) this.callbacks.onSelect(model);
152
- return;
153
- }
154
- if (matchesKey(data, Key.ctrl("c"))) {
155
- if (this.searchInput.getValue()) {
156
- this.searchInput.setValue("");
157
- this.refresh();
158
- } else {
159
- this.callbacks.onCancel();
160
- }
161
- return;
162
- }
163
- if (matchesKey(data, Key.escape)) {
164
- this.callbacks.onCancel();
165
- return;
166
- }
167
-
168
- this.searchInput.handleInput(data);
169
- this.refresh();
170
- }
171
-
172
- getSearchInput() {
173
- return this.searchInput;
174
- }
175
- }
176
-
177
- export async function selectTuiModelProfile(ctx, config) {
178
- return await ctx.ui.custom((tui, theme, _keybindings, done) => new TuiModelProfileSelectorComponent(config, theme, {
179
- onSelect: done,
180
- onCancel: () => done(undefined),
181
- onRender: () => tui.requestRender(),
182
- }));
183
- }