@firstpick/pi-package-webui 0.9.7 → 0.9.9
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/DEVELOPMENT.md +882 -0
- package/README.md +8 -4
- package/TECHNICAL.md +415 -0
- package/bin/pi-webui.mjs +154 -26
- package/index.ts +2 -1
- package/lib/optional-feature-catalog.mjs +1 -1
- package/lib/windows-drive-roots.mjs +114 -0
- package/package.json +3 -1
- package/public/app.js +683 -115
- package/public/guided-git-command-state.mjs +175 -1
- package/public/index.html +17 -10
- package/public/service-worker.js +1 -1
- package/public/styles.css +146 -32
- package/public/transcript-renderer.mjs +62 -0
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/footer-model-advanced-layout.spec.mjs +512 -0
- package/tests/browser/guided-git-extension-command.spec.mjs +180 -0
- package/tests/browser/guided-git-fallback.spec.mjs +68 -3
- package/tests/browser/interaction-continuity.spec.mjs +33 -0
- package/tests/browser/windows-drive-parent.spec.mjs +198 -0
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/compaction-static.test.mjs +1 -1
- package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
- package/tests/control-visibility-static.test.mjs +3 -3
- package/tests/controls-layout-static.test.mjs +3 -3
- package/tests/events-tree-context-menu-static.test.mjs +3 -3
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/file-viewer-image-static.test.mjs +3 -3
- package/tests/fixtures/fake-pi.mjs +34 -3
- package/tests/git-footer-context-menu-static.test.mjs +103 -1
- package/tests/guided-git-activation-http.test.mjs +194 -0
- package/tests/guided-git-activation-static.test.mjs +80 -0
- package/tests/guided-git-activation.test.mjs +244 -0
- package/tests/guided-git-fallback-runtime.test.mjs +1 -0
- package/tests/guided-git-fallback-ui-static.test.mjs +2 -2
- package/tests/guided-git-message-reliability-static.test.mjs +2 -1
- package/tests/guided-git-optional-feature.test.mjs +31 -0
- package/tests/http-endpoints-harness.test.mjs +3 -0
- package/tests/interaction-state-stability-static.test.mjs +1 -1
- package/tests/intercom-conversation-viewer-static.test.mjs +3 -3
- package/tests/main-output-loading-static.test.mjs +11 -9
- package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +3 -3
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +85 -4
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/persistent-ui-layout-static.test.mjs +3 -3
- package/tests/prompt-input-vertical-scroll-static.test.mjs +6 -6
- package/tests/prompt-routing-input-clear-static.test.mjs +1 -1
- package/tests/questionnaire-dialog.test.mjs +3 -3
- package/tests/session-sampling-ui-static.test.mjs +3 -3
- package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
- package/tests/subagent-observability-static.test.mjs +2 -2
- package/tests/syntax-highlighting-static.test.mjs +3 -3
- package/tests/tab-close-continuity-static.test.mjs +2 -0
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/tests/thinking-block-grouping.test.mjs +79 -0
- package/tests/windows-drive-cwd-picker-static.test.mjs +81 -0
- package/tests/windows-drive-roots.test.mjs +130 -0
|
@@ -16,11 +16,11 @@ const resizeEnd = app.indexOf("\nfunction updateComposerModeButtons", resizeStar
|
|
|
16
16
|
assert.ok(resizeStart >= 0 && resizeEnd > resizeStart, "resizePromptInput should remain inspectable");
|
|
17
17
|
const resizePromptInput = app.slice(resizeStart, resizeEnd);
|
|
18
18
|
|
|
19
|
-
assert.match(css, /#promptInput \{[\s\S]*max-height:
|
|
20
|
-
assert.match(resizePromptInput, /input\.style\.height = "auto";[\s\S]*
|
|
21
|
-
assert.doesNotMatch(resizePromptInput, /overflowY
|
|
22
|
-
assert.match(html, /styles\.css\?v=
|
|
23
|
-
assert.match(html, /app\.js\?v=
|
|
24
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
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
|
+
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
|
+
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=143/, "the page should request the six-line prompt stylesheet revision");
|
|
23
|
+
assert.match(html, /app\.js\?v=175/, "the page should request the current app revision");
|
|
24
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v142"/, "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");
|
|
@@ -24,7 +24,7 @@ const requestIndex = sendSource.indexOf('await api("/api/prompt"');
|
|
|
24
24
|
assert.ok(clearIndex >= 0, "sendPrompt should clear the captured input-backed draft");
|
|
25
25
|
assert.ok(routingIndex >= 0 && clearIndex < routingIndex, "the submitted prompt should be cleared before routing progress starts");
|
|
26
26
|
assert.ok(requestIndex >= 0 && clearIndex < requestIndex, "the submitted prompt should be cleared before the prompt request starts");
|
|
27
|
-
assert.match(sendSource, /catch \(error\) \{\n\s+restorePromptInputAfterRoutingError\(inputMessage,/, "a routing failure should restore the sent input when no replacement draft exists");
|
|
27
|
+
assert.match(sendSource, /catch \(error\) \{\n\s+(?:if \(guidedGitPermitGranted\) guidedGitLaunchPermits\.clearTab\(targetTabId\);\n\s+)?restorePromptInputAfterRoutingError\(inputMessage,/, "a routing failure should revoke any activation permit and restore the sent input when no replacement draft exists");
|
|
28
28
|
|
|
29
29
|
const successStart = sendSource.indexOf("applyResponseTab(response);");
|
|
30
30
|
const catchStart = sendSource.indexOf("} catch (error)", successStart);
|
|
@@ -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=
|
|
508
|
-
assert.match(html, /app\.js\?v=
|
|
509
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
507
|
+
assert.match(html, /styles\.css\?v=143/, "questionnaire CSS needs the current stylesheet revision");
|
|
508
|
+
assert.match(html, /app\.js\?v=175/, "questionnaire behavior needs the current app revision");
|
|
509
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v142"/, "questionnaire public assets need a coherent PWA cache revision");
|
|
510
510
|
|
|
511
511
|
console.log("questionnaire-dialog.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-
|
|
60
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v142"/, "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=
|
|
63
|
-
assert.match(html, /app\.js\?v=
|
|
62
|
+
assert.match(html, /styles\.css\?v=143/, "the changed stylesheet should have a new revision");
|
|
63
|
+
assert.match(html, /app\.js\?v=175/, "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=
|
|
31
|
-
assert.match(html, /app\.js\?v=
|
|
32
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
30
|
+
assert.match(html, /styles\.css\?v=143/, "removing section resize styles should advance the stylesheet revision");
|
|
31
|
+
assert.match(html, /app\.js\?v=175/, "removing section resize behavior should advance the app revision");
|
|
32
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v142"/, "removing browser assets should advance the PWA cache identity");
|
|
33
33
|
|
|
34
34
|
console.log("side-panel-section-height-removal-static.test.mjs passed");
|
|
@@ -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=
|
|
32
|
-
assert.match(worker, /pi-webui-pwa-
|
|
31
|
+
assert.match(html, /styles\.css\?v=143[\s\S]*app\.js\?v=175/, "browser assets should use the current subagent-observability revisions");
|
|
32
|
+
assert.match(worker, /pi-webui-pwa-v142/, "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-
|
|
64
|
-
assert.match(html, /styles\.css\?v=
|
|
65
|
-
assert.match(html, /data-app-src="\/app\.js\?v=
|
|
63
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v142"/, "adding a startup module should advance the PWA cache identity");
|
|
64
|
+
assert.match(html, /styles\.css\?v=143/, "new token styles should advance the stylesheet revision");
|
|
65
|
+
assert.match(html, /data-app-src="\/app\.js\?v=175"/, "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")));
|
|
@@ -19,5 +19,7 @@ assert.match(app, /const closingTerminalTabIds = new Set\(\)/, "the frontend sho
|
|
|
19
19
|
assert.match(schedule, /closingTerminalTabIds\.has\(tabContext\.tabId\)/, "continuity refreshes should skip tabs that are intentionally closing");
|
|
20
20
|
assert.match(schedule, /if \(!isCurrentTabContext\(tabContext\) \|\| closingTerminalTabIds\.has\(tabContext\.tabId\)\) return;[\s\S]*continuity refresh failed/, "an in-flight refresh rejected by intentional shutdown should not produce a false error");
|
|
21
21
|
assert.match(closeTabs, /for \(const id of targetIds\) closingTerminalTabIds\.add\(id\);[\s\S]*finally \{\s*for \(const id of targetIds\) closingTerminalTabIds\.delete\(id\);/, "the close lifecycle should mark every target before the request and always clear the marker afterward");
|
|
22
|
+
assert.match(closeTabs, /addEvent\(`closed \$\{closedIds\.length \|\| targetTabs\.length\} terminal \$\{closedIds\.length === 1 \? "tab" : "tabs"\}`, "info"\)/, "successful terminal tab closure should be recorded as information rather than a warning");
|
|
23
|
+
assert.doesNotMatch(closeTabs, /addEvent\(`closed [^`]+`, "warn"\)/, "successful terminal tab closure should never be classified as a warning");
|
|
22
24
|
|
|
23
25
|
console.log("tab-close-continuity-static.test.mjs passed");
|
|
@@ -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-
|
|
37
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v142"/, "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");
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
import { groupConsecutiveThinkingItems, groupConsecutiveThinkingMessages } from "../public/transcript-renderer.mjs";
|
|
6
|
+
|
|
7
|
+
function thinking(content, timestamp) {
|
|
8
|
+
return { role: "thinking", title: "thinking", content, thinking: content, timestamp };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const first = thinking("inspect the renderer", "2026-08-23T13:00:00Z");
|
|
12
|
+
assert.equal(groupConsecutiveThinkingMessages([first])[0], first, "a single thinking message should retain its identity");
|
|
13
|
+
|
|
14
|
+
const grouped = groupConsecutiveThinkingMessages([
|
|
15
|
+
first,
|
|
16
|
+
thinking("confirm the display order", "2026-08-23T13:00:01Z"),
|
|
17
|
+
thinking("verify the final state", "2026-08-23T13:00:02Z"),
|
|
18
|
+
]);
|
|
19
|
+
assert.equal(grouped.length, 1, "adjacent thinking messages should render as one transcript message");
|
|
20
|
+
assert.equal(grouped[0].thinking, "inspect the renderer\n\nconfirm the display order\n\nverify the final state", "grouped thinking should remain chronological and readable");
|
|
21
|
+
assert.equal(grouped[0].content, grouped[0].thinking, "copy and rendering paths should receive the same grouped text");
|
|
22
|
+
assert.equal(grouped[0].timestamp, first.timestamp, "the grouped message should keep the first block's stable metadata");
|
|
23
|
+
assert.equal(grouped[0].thinkingSegmentCount, 3, "the aggregate should retain its source segment count");
|
|
24
|
+
|
|
25
|
+
const toolCall = { role: "toolCall", toolName: "read", content: {} };
|
|
26
|
+
const separated = groupConsecutiveThinkingMessages([
|
|
27
|
+
thinking("before the tool"),
|
|
28
|
+
toolCall,
|
|
29
|
+
thinking("after the tool"),
|
|
30
|
+
thinking("still after the tool"),
|
|
31
|
+
]);
|
|
32
|
+
assert.deepEqual(separated.map((message) => message.role), ["thinking", "toolCall", "thinking"], "non-thinking transcript messages should remain hard grouping boundaries");
|
|
33
|
+
assert.equal(separated[0].thinking, "before the tool");
|
|
34
|
+
assert.equal(separated[2].thinking, "after the tool\n\nstill after the tool");
|
|
35
|
+
|
|
36
|
+
const nonTextThinking = { role: "thinking", content: { provider: "opaque" } };
|
|
37
|
+
assert.deepEqual(
|
|
38
|
+
groupConsecutiveThinkingMessages([thinking("before"), nonTextThinking, thinking("after")]),
|
|
39
|
+
[thinking("before"), nonTextThinking, thinking("after")],
|
|
40
|
+
"non-text thinking payloads should not be stringified or merged",
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
function assistantItem(index, content) {
|
|
44
|
+
return {
|
|
45
|
+
message: { role: "assistant", timestamp: `2026-08-23T13:00:0${index}Z`, content: [{ type: "thinking", thinking: content }] },
|
|
46
|
+
messageIndex: index,
|
|
47
|
+
order: index,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const separateAssistantMessages = [
|
|
52
|
+
assistantItem(1, "first assistant message"),
|
|
53
|
+
assistantItem(2, "second assistant message"),
|
|
54
|
+
assistantItem(3, "third assistant message"),
|
|
55
|
+
];
|
|
56
|
+
const groupedItems = groupConsecutiveThinkingItems(separateAssistantMessages, (item) => {
|
|
57
|
+
const part = item.message.content[0];
|
|
58
|
+
return thinking(part.thinking, item.message.timestamp);
|
|
59
|
+
});
|
|
60
|
+
assert.equal(groupedItems.length, 1, "thinking-only assistant messages should collapse after transcript ordering");
|
|
61
|
+
assert.equal(groupedItems[0].message.thinking, "first assistant message\n\nsecond assistant message\n\nthird assistant message");
|
|
62
|
+
assert.equal(groupedItems[0].thinkingGroupSourceCount, 3, "the transcript aggregate should retain its source item count");
|
|
63
|
+
|
|
64
|
+
const finalOutputItem = { message: { role: "assistant", content: [{ type: "text", text: "answer" }] }, messageIndex: 4, order: 4 };
|
|
65
|
+
const itemBoundary = groupConsecutiveThinkingItems(
|
|
66
|
+
[assistantItem(1, "before"), finalOutputItem, assistantItem(2, "after")],
|
|
67
|
+
(item) => item.message.content[0]?.type === "thinking" ? thinking(item.message.content[0].thinking) : null,
|
|
68
|
+
);
|
|
69
|
+
assert.deepEqual(itemBoundary.map((item) => item.message.role), ["assistant", "assistant", "assistant"], "a rendered final-output item should keep separate thinking runs apart");
|
|
70
|
+
|
|
71
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
72
|
+
const app = await readFile(join(root, "public", "app.js"), "utf8");
|
|
73
|
+
assert.match(app, /import \{ createTranscriptRenderer, groupConsecutiveThinkingItems, groupConsecutiveThinkingMessages \} from "\.\/transcript-renderer\.mjs";/, "the browser should import both grouping helpers from the transcript renderer");
|
|
74
|
+
assert.match(app, /function assistantDisplayMessages\(message\)[\s\S]*?const displayMessages = assistantDisplayMessagesWithoutFailure[\s\S]*?return groupConsecutiveThinkingMessages\(failure \? \[\.\.\.displayMessages, failure\] : displayMessages\);/, "assistant display projection should group adjacent thinking inside one assistant message");
|
|
75
|
+
assert.match(app, /function transcriptItemThinkingMessage\(item\)[\s\S]*?assistantDisplayMessages\(message\)[\s\S]*?displayMessages\.length !== 1[\s\S]*?role !== "thinking"/, "only transcript items that render as one thinking card should be eligible for cross-message grouping");
|
|
76
|
+
assert.match(app, /function groupConsecutiveThinkingTranscriptItems\(items\)[\s\S]*?groupConsecutiveThinkingItems\(items, transcriptItemThinkingMessage\)[\s\S]*?transcriptKey: `thinking-group:\$\{sourceKey\}`/, "cross-message groups should receive one stable transcript identity");
|
|
77
|
+
assert.match(app, /const groupedThinking = compactOutputActive\(\) \? ordered : groupConsecutiveThinkingTranscriptItems\(ordered\);[\s\S]*?groupWorkflowStatusTranscriptItems\(groupedThinking, toolResults\)/, "normal transcripts should group thinking after complete chronological ordering");
|
|
78
|
+
|
|
79
|
+
console.log("thinking-block-grouping.test.mjs passed");
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, join, win32 } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
|
+
const [app, html, styles, readme, technical, development, serviceWorker, server, packageJsonText] = 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, "README.md"), "utf8"),
|
|
12
|
+
readFile(join(root, "TECHNICAL.md"), "utf8"),
|
|
13
|
+
readFile(join(root, "DEVELOPMENT.md"), "utf8"),
|
|
14
|
+
readFile(join(root, "public", "service-worker.js"), "utf8"),
|
|
15
|
+
readFile(join(root, "bin", "pi-webui.mjs"), "utf8"),
|
|
16
|
+
readFile(join(root, "package.json"), "utf8"),
|
|
17
|
+
]);
|
|
18
|
+
const packageJson = JSON.parse(packageJsonText);
|
|
19
|
+
|
|
20
|
+
function sourceBetween(source, start, end) {
|
|
21
|
+
const startIndex = source.indexOf(start);
|
|
22
|
+
const endIndex = source.indexOf(end, startIndex + start.length);
|
|
23
|
+
assert.ok(startIndex >= 0 && endIndex > startIndex, `expected source block from ${start} to ${end}`);
|
|
24
|
+
return source.slice(startIndex, endIndex);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
assert.equal(win32.resolve("C:\\repo", "D:/"), "D:\\", "Node should treat a slash-form drive root as an absolute Windows cwd");
|
|
28
|
+
assert.match(html, /id="pathPickerPathInput"[^>]*placeholder="Path, e\.g\. C:\/ or D:\/project"[^>]*aria-label="Directory path"/, "the cwd picker should expose an accessible direct-path field with Windows drive examples");
|
|
29
|
+
assert.match(html, /id="pathPickerPathButton"[^>]*>Go<\/button>/, "the direct-path field should have an explicit Go action");
|
|
30
|
+
assert.match(app, /pathPickerPathInput: \$\("#pathPickerPathInput"\)[\s\S]*pathPickerPathButton: \$\("#pathPickerPathButton"\)/, "the browser should bind both direct-path controls");
|
|
31
|
+
|
|
32
|
+
const openEnteredPath = sourceBetween(app, "async function openPathPickerEnteredPath()", "function pathPickerCreateName()");
|
|
33
|
+
assert.match(openEnteredPath, /const cwd = pathPickerEnteredPath\(\)[\s\S]*await loadPathPickerDirectory\(cwd\)/, "direct paths should use the existing validated directory loader without rewriting drive-qualified input");
|
|
34
|
+
const renderPicker = sourceBetween(app, "function renderPathPicker(data)", "async function loadPathPickerDirectory(cwd, { focusAfterLoad = false } = {})");
|
|
35
|
+
assert.match(renderPicker, /pathPickerState\.selectable = data\.selectable !== false/, "the browser should default ordinary directories to selectable while honoring the virtual view contract");
|
|
36
|
+
assert.match(renderPicker, /pathPickerState\.displayCwd = data\.displayCwd \|\| pathPickerState\.cwd/, "the virtual This PC label should be retained independently of its empty cwd");
|
|
37
|
+
assert.match(renderPicker, /pathPickerChooseButton\.disabled = !pathPickerState\.selectable \|\| !pathPickerState\.cwd/, "Use this directory should stay disabled for the virtual view");
|
|
38
|
+
const searchControls = sourceBetween(app, "function updatePathPickerSearchControls()", "function pathPickerDirectoryMatchesSearch");
|
|
39
|
+
assert.match(searchControls, /pathPickerState\.selectable === false \|\| !!pathPickerState\.cwd/, "search should remain available in the non-selectable This PC view");
|
|
40
|
+
const createControls = sourceBetween(app, "function updateCreateDirectoryControls()", "function pathPickerSearchQuery()");
|
|
41
|
+
assert.match(createControls, /pathPickerState\.selectable !== false/, "directory creation should be gated by virtual-view selectability");
|
|
42
|
+
const currentFastPickBlock = sourceBetween(app, "function currentFastPick()", "function updateAddFastPickButton()");
|
|
43
|
+
assert.match(currentFastPickBlock, /pathPickerState\.selectable === false/, "the virtual view should not be pinnable");
|
|
44
|
+
const directoryList = sourceBetween(app, "function renderPathPickerDirectoryList()", "function clearPathPickerSearch");
|
|
45
|
+
assert.match(directoryList, /loadPathPickerDirectory\(directory\.cwd, \{ focusAfterLoad: true \}\)/, "clicking a listed drive should use the existing directory loader and restore stable focus");
|
|
46
|
+
assert.match(renderPicker, /loadPathPickerDirectory\(data\.parent, \{ focusAfterLoad: true \}\)/, "Parent navigation should restore focus after replacing its button");
|
|
47
|
+
const fastPicks = sourceBetween(app, "function renderFastPicks()", "async function addCurrentFastPick()");
|
|
48
|
+
assert.match(fastPicks, /loadPathPickerDirectory\(pick\.cwd, \{ focusAfterLoad: true \}\)/, "fast-pick navigation should restore focus after rerendering");
|
|
49
|
+
|
|
50
|
+
const loadDirectory = sourceBetween(app, "async function loadPathPickerDirectory(cwd, { focusAfterLoad = false } = {})", "async function createPathPickerDirectory()");
|
|
51
|
+
assert.match(loadDirectory, /encodeURIComponent\(cwd\)/, "drive-qualified paths and the internal Parent destination should be URL-encoded before the directory request");
|
|
52
|
+
assert.doesNotMatch(loadDirectory.slice(loadDirectory.indexOf("} catch (error)")), /pathPickerPathInput\.value\s*=/, "failed drive lookups should keep the entered path editable");
|
|
53
|
+
assert.match(loadDirectory, /pathPickerCurrent\.textContent = pathPickerState\.displayCwd \|\| pathPickerState\.cwd \|\| "Unable to load directory"/, "a failed drive load from This PC should restore the virtual display label");
|
|
54
|
+
assert.match(loadDirectory, /if \(focusAfterLoad\) elements\.pathPickerSearchInput\.focus\(\{ preventScroll: true \}\)/, "navigation-originated loads should restore focus to the stable search control");
|
|
55
|
+
assert.match(html, /id="pathPickerError"[^>]*role="alert"[^>]*hidden/, "directory load failures should be exposed through one dedicated live alert");
|
|
56
|
+
assert.match(app, /pathPickerPathInput\.addEventListener\("keydown"[\s\S]*event\.key !== "Enter"[\s\S]*openPathPickerEnteredPath\(\)/, "Enter should open the entered path");
|
|
57
|
+
assert.match(app, /pathPickerPathButton\.addEventListener\("click"[\s\S]*openPathPickerEnteredPath\(\)/, "the Go button should open the entered path");
|
|
58
|
+
assert.match(server, /platform\(\) === "win32" && isWindowsDriveRoot\(cwd\)[\s\S]*WINDOWS_DRIVES_PICKER_PATH/, "Parent from a Windows drive root should target the virtual This PC destination");
|
|
59
|
+
assert.match(server, /platform\(\) === "win32" && viewPath === WINDOWS_DRIVES_PICKER_PATH[\s\S]*getWindowsDrivesPickerData\(activeCwd\)/, "the virtual Parent destination should be intercepted only on Windows");
|
|
60
|
+
|
|
61
|
+
const splitFlow = sourceBetween(app, "async function splitTerminalTab", "async function createTerminalTabFromChosenDirectory");
|
|
62
|
+
assert.match(splitFlow, /pickCwd\([\s\S]*body: \{ cwd: resolvedCwd \}/, "split terminals without a cwd should use the shared drive-aware picker");
|
|
63
|
+
const newTabFlow = sourceBetween(app, "async function createTerminalTabFromChosenDirectory", "async function createFirstTerminalTabFromChosenDirectory");
|
|
64
|
+
assert.match(newTabFlow, /pickCwd\([\s\S]*createTerminalTab\(cwd/, "new terminal tabs should use the shared drive-aware picker");
|
|
65
|
+
const firstTabFlow = sourceBetween(app, "async function createFirstTerminalTabFromChosenDirectory", "function tabHasActiveAgent");
|
|
66
|
+
assert.match(firstTabFlow, /pickCwd\([\s\S]*createTerminalTab\(cwd/, "the first terminal should use the shared drive-aware picker");
|
|
67
|
+
const cwdChangeFlow = sourceBetween(app, "async function changeActiveTabCwd()", "function footerControlKey(node)");
|
|
68
|
+
assert.match(cwdChangeFlow, /await pickCwd\([\s\S]*method: "PATCH", body: \{ cwd \}/, "cwd changes should use the shared picker and pass its selected drive-qualified path to the existing tab route");
|
|
69
|
+
|
|
70
|
+
assert.match(styles, /\.path-picker-path-row[\s\S]*grid-template-columns: minmax\(0, 1fr\) auto/, "the direct-path controls should use the picker row layout");
|
|
71
|
+
assert.match(styles, /\.path-picker-current-row,[\s\S]*\.path-picker-path-row,[\s\S]*grid-template-columns: 1fr/, "the direct-path controls should stack on narrow screens");
|
|
72
|
+
assert.match(readme, /Windows[\s\S]*`C:\/`[\s\S]*`D:\/project`[\s\S]*\*\*Parent\*\*[\s\S]*\*\*This PC\*\*/, "the README should explain both typed paths and Parent-based Windows drive switching");
|
|
73
|
+
assert.match(technical, /working-directory picker accepts a direct path[\s\S]*\*\*Parent\*\* opens a \*\*This PC\*\*[\s\S]*navigation-only/i, "the technical reference should document the virtual drive view and its control limits");
|
|
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
|
+
assert.ok(packageJson.files.includes("TECHNICAL.md"), "the published package should include its advanced user reference");
|
|
76
|
+
assert.ok(packageJson.files.includes("DEVELOPMENT.md"), "the published package should include its contributor guide");
|
|
77
|
+
assert.match(html, /styles\.css\?v=143/, "the existing picker layout should retain its stylesheet revision");
|
|
78
|
+
assert.match(html, /app\.js\?v=175/, "the changed picker behavior should advance the app revision");
|
|
79
|
+
assert.match(serviceWorker, /pi-webui-pwa-v142/, "the changed browser assets should advance the PWA cache identity");
|
|
80
|
+
|
|
81
|
+
console.log("windows-drive-cwd-picker-static.test.mjs passed");
|
|
@@ -0,0 +1,130 @@
|
|
|
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
|
+
import {
|
|
6
|
+
WINDOWS_DRIVES_PICKER_PATH,
|
|
7
|
+
WINDOWS_DRIVE_DISCOVERY_MAX_OUTPUT,
|
|
8
|
+
WINDOWS_DRIVE_DISCOVERY_TIMEOUT_MS,
|
|
9
|
+
createWindowsDriveRootDiscovery,
|
|
10
|
+
isWindowsDriveRoot,
|
|
11
|
+
mergeWindowsDriveRoots,
|
|
12
|
+
normalizeWindowsDriveRoot,
|
|
13
|
+
parseWindowsDriveRoots,
|
|
14
|
+
windowsDriveRootsFromKnownPaths,
|
|
15
|
+
windowsDrivesPickerData,
|
|
16
|
+
} from "../lib/windows-drive-roots.mjs";
|
|
17
|
+
|
|
18
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
19
|
+
|
|
20
|
+
assert.equal(normalizeWindowsDriveRoot("c:\\"), "C:\\");
|
|
21
|
+
assert.equal(normalizeWindowsDriveRoot("d:/"), "D:\\");
|
|
22
|
+
assert.equal(isWindowsDriveRoot("Z:\\"), true);
|
|
23
|
+
for (const invalid of ["C:", "C:project", "C:\\project", " C:\\", "C:\\\\", "\\\\server\\share\\", "/"] ) {
|
|
24
|
+
assert.equal(normalizeWindowsDriveRoot(invalid), null, `${JSON.stringify(invalid)} must not be accepted as a drive root`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
assert.deepEqual(
|
|
28
|
+
parseWindowsDriveRoots("D:\\\r\nc:/\r\ninvalid\r\nd:\\\r\n Z:\\\r\n"),
|
|
29
|
+
["C:\\", "D:\\"],
|
|
30
|
+
"PowerShell output should be parsed strictly, normalized, deduplicated, and sorted",
|
|
31
|
+
);
|
|
32
|
+
assert.deepEqual(
|
|
33
|
+
windowsDriveRootsFromKnownPaths(["d:\\project", "C:/Users/test", "e:", "e:relative", "/home/test", null]),
|
|
34
|
+
["C:\\", "D:\\", "E:\\"],
|
|
35
|
+
"known absolute paths and system drive designators should provide fallback roots",
|
|
36
|
+
);
|
|
37
|
+
assert.deepEqual(mergeWindowsDriveRoots(["z:/", "C:\\"], ["c:/", "D:\\"]), ["C:\\", "D:\\", "Z:\\"]);
|
|
38
|
+
|
|
39
|
+
const virtualData = windowsDrivesPickerData(["D:\\", "c:/", "bad"], [{ label: "Tab", cwd: "C:\\repo" }]);
|
|
40
|
+
assert.deepEqual(virtualData, {
|
|
41
|
+
cwd: "",
|
|
42
|
+
displayCwd: "This PC",
|
|
43
|
+
parent: null,
|
|
44
|
+
roots: [{ label: "Tab", cwd: "C:\\repo" }],
|
|
45
|
+
directories: [
|
|
46
|
+
{ name: "C:\\", cwd: "C:\\", displayCwd: "C:\\", hidden: false },
|
|
47
|
+
{ name: "D:\\", cwd: "D:\\", displayCwd: "D:\\", hidden: false },
|
|
48
|
+
],
|
|
49
|
+
truncated: false,
|
|
50
|
+
selectable: false,
|
|
51
|
+
});
|
|
52
|
+
assert.equal(WINDOWS_DRIVES_PICKER_PATH, "::pi-webui-windows-drives::");
|
|
53
|
+
|
|
54
|
+
let currentTime = 1_000;
|
|
55
|
+
const commandCalls = [];
|
|
56
|
+
const discover = createWindowsDriveRootDiscovery({
|
|
57
|
+
now: () => currentTime,
|
|
58
|
+
cacheTtlMs: 100,
|
|
59
|
+
runCommand: async (...args) => {
|
|
60
|
+
commandCalls.push(args);
|
|
61
|
+
return { exitCode: 0, timedOut: false, stdoutTruncated: false, stdout: "D:\\\r\nC:/\r\nmalformed\r\n" };
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
assert.deepEqual(await discover({ cwd: "C:\\repo", knownPaths: ["E:\\work"] }), ["C:\\", "D:\\", "E:\\"]);
|
|
66
|
+
assert.equal(commandCalls.length, 1);
|
|
67
|
+
assert.equal(commandCalls[0][0], "powershell.exe");
|
|
68
|
+
assert.deepEqual(commandCalls[0][1].slice(0, 4), ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command"]);
|
|
69
|
+
assert.match(commandCalls[0][1][4], /\[System\.IO\.DriveInfo\]::GetDrives\(\)/);
|
|
70
|
+
assert.match(commandCalls[0][1][4], /\.IsReady/);
|
|
71
|
+
assert.deepEqual(commandCalls[0][2], {
|
|
72
|
+
cwd: "C:\\repo",
|
|
73
|
+
timeoutMs: WINDOWS_DRIVE_DISCOVERY_TIMEOUT_MS,
|
|
74
|
+
maxOutputLength: WINDOWS_DRIVE_DISCOVERY_MAX_OUTPUT,
|
|
75
|
+
utf8Output: true,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
assert.deepEqual(
|
|
79
|
+
await discover({ cwd: "C:\\other", knownPaths: ["F:"] }),
|
|
80
|
+
["C:\\", "D:\\", "F:\\"],
|
|
81
|
+
"cached discovery should merge fresh known roots without rerunning PowerShell",
|
|
82
|
+
);
|
|
83
|
+
assert.equal(commandCalls.length, 1);
|
|
84
|
+
currentTime += 101;
|
|
85
|
+
await discover({ cwd: "C:\\other" });
|
|
86
|
+
assert.equal(commandCalls.length, 2, "expired discovery should rerun PowerShell");
|
|
87
|
+
|
|
88
|
+
let releaseConcurrent;
|
|
89
|
+
let concurrentCalls = 0;
|
|
90
|
+
const concurrent = createWindowsDriveRootDiscovery({
|
|
91
|
+
runCommand: async () => {
|
|
92
|
+
concurrentCalls += 1;
|
|
93
|
+
await new Promise((resolve) => { releaseConcurrent = resolve; });
|
|
94
|
+
return { exitCode: 0, timedOut: false, stdoutTruncated: false, stdout: "G:\\\n" };
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
const firstConcurrent = concurrent({ knownPaths: ["C:\\repo"] });
|
|
98
|
+
const secondConcurrent = concurrent({ knownPaths: ["D:\\repo"] });
|
|
99
|
+
releaseConcurrent();
|
|
100
|
+
assert.deepEqual(await firstConcurrent, ["C:\\", "G:\\"]);
|
|
101
|
+
assert.deepEqual(await secondConcurrent, ["D:\\", "G:\\"]);
|
|
102
|
+
assert.equal(concurrentCalls, 1, "concurrent picker requests should share one PowerShell process");
|
|
103
|
+
|
|
104
|
+
for (const failedResult of [
|
|
105
|
+
{ exitCode: 1, timedOut: false, stdout: "Z:\\\n" },
|
|
106
|
+
{ exitCode: undefined, timedOut: true, stdout: "Z:\\\n" },
|
|
107
|
+
{ exitCode: 0, timedOut: false, stdoutTruncated: true, stdout: "Z:\\\n" },
|
|
108
|
+
]) {
|
|
109
|
+
const failedDiscovery = createWindowsDriveRootDiscovery({ runCommand: async () => failedResult });
|
|
110
|
+
assert.deepEqual(await failedDiscovery({ knownPaths: ["C:\\repo", "D:"] }), ["C:\\", "D:\\"]);
|
|
111
|
+
}
|
|
112
|
+
const throwingDiscovery = createWindowsDriveRootDiscovery({ runCommand: async () => { throw new Error("unavailable"); } });
|
|
113
|
+
assert.deepEqual(await throwingDiscovery({ knownPaths: ["C:\\repo"] }), ["C:\\"]);
|
|
114
|
+
|
|
115
|
+
const serverSource = await readFile(join(root, "bin", "pi-webui.mjs"), "utf8");
|
|
116
|
+
assert.match(serverSource, /platform\(\) === "win32" && viewPath === WINDOWS_DRIVES_PICKER_PATH[\s\S]*return getWindowsDrivesPickerData\(activeCwd\)/, "the sentinel must be intercepted only on Windows before cwd resolution");
|
|
117
|
+
assert.match(serverSource, /platform\(\) === "win32" && isWindowsDriveRoot\(cwd\)[\s\S]*\? WINDOWS_DRIVES_PICKER_PATH/, "Windows drive roots should route Parent to the virtual picker");
|
|
118
|
+
assert.match(serverSource, /windowsDrivesPickerData\(driveRoots, pathPickerRoots\(activeCwd, activeCwd\)\)/, "the server should return the tested non-selectable virtual payload");
|
|
119
|
+
assert.match(
|
|
120
|
+
serverSource,
|
|
121
|
+
/function windowsDriveDiscoveryCwd\(\) \{[\s\S]*process\.env\.SystemRoot \|\| process\.env\.WINDIR \|\| path\.dirname\(process\.execPath\)[\s\S]*cwd: windowsDriveDiscoveryCwd\(\)/,
|
|
122
|
+
"drive discovery should launch from a stable Windows system or executable directory rather than the active drive",
|
|
123
|
+
);
|
|
124
|
+
assert.doesNotMatch(
|
|
125
|
+
serverSource,
|
|
126
|
+
/discoverWindowsDriveRoots\(\{\s*cwd: activeCwd/,
|
|
127
|
+
"a removable active cwd must not be used as the PowerShell process cwd",
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
console.log("windows-drive-roots.test.mjs passed");
|