@firstpick/pi-package-webui 0.7.7 → 0.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/bin/pi-webui-rpc-supervisor.mjs +115 -21
- package/bin/pi-webui.mjs +67 -32
- package/lib/rpc-supervisor-client.mjs +18 -2
- package/lib/rpc-supervisor-protocol.mjs +11 -2
- package/package.json +4 -4
- package/public/app.js +750 -89
- package/public/index.html +56 -2
- package/public/issue-bot-client.mjs +344 -0
- package/public/issue-wizard-state.mjs +443 -0
- package/public/service-worker.js +3 -1
- package/public/styles.css +212 -0
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/completion-signal-contract.test.mjs +156 -0
- package/tests/cwd-footer-reliability-static.test.mjs +107 -0
- package/tests/durable-rpc-supervisor-harness.test.mjs +25 -2
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/fixtures/compacting-pi.mjs +0 -0
- package/tests/fixtures/fake-pi.mjs +11 -6
- package/tests/footer-context-contrast-static.test.mjs +10 -0
- package/tests/git-panel-render-stability-static.test.mjs +11 -1
- package/tests/issue-bot-client.test.mjs +135 -0
- package/tests/issue-wizard-state.test.mjs +126 -0
- package/tests/mobile-static.test.mjs +5 -4
- package/tests/native-parity.test.mjs +2 -2
- package/tests/open-issue-wizard-static.test.mjs +75 -0
- package/tests/prompt-routing-tab-status.test.mjs +5 -0
- package/tests/rpc-supervisor-host.test.mjs +135 -2
- package/tests/rpc-supervisor-protocol.test.mjs +26 -0
- package/tests/streaming-ui-coupling.test.mjs +3 -2
- package/tests/terminal-tab-workspace-static.test.mjs +99 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import vm from "node:vm";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
8
|
+
const app = await readFile(join(root, "public", "app.js"), "utf8");
|
|
9
|
+
const styles = await readFile(join(root, "public", "styles.css"), "utf8");
|
|
10
|
+
|
|
11
|
+
function appFunctionSource(name, nextName) {
|
|
12
|
+
const start = app.indexOf(`function ${name}(`);
|
|
13
|
+
const end = app.indexOf(`\nfunction ${nextName}(`, start);
|
|
14
|
+
assert.ok(start >= 0 && end > start, `${name} should remain a standalone frontend helper`);
|
|
15
|
+
return app.slice(start, end);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function appFunctionToMarker(name, marker) {
|
|
19
|
+
const start = app.indexOf(`function ${name}(`);
|
|
20
|
+
const end = app.indexOf(marker, start);
|
|
21
|
+
assert.ok(start >= 0 && end > start, `${name} should remain extractable for behavioral tests`);
|
|
22
|
+
return app.slice(start, end);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const sources = [
|
|
26
|
+
appFunctionSource("tabGroupTitle", "terminalDisplayGroupTitle"),
|
|
27
|
+
appFunctionSource("normalizeGitWorkspaceInfo", "gitWorkspaceBadgeLabel"),
|
|
28
|
+
appFunctionSource("terminalTabWorkspaceName", "terminalTabMeta"),
|
|
29
|
+
appFunctionSource("terminalTabMeta", "terminalTabGitTooltip"),
|
|
30
|
+
appFunctionSource("terminalTabGitTooltip", "terminalTabActiveTooltip"),
|
|
31
|
+
appFunctionSource("terminalTabActiveTooltip", "terminalTabTooltip"),
|
|
32
|
+
appFunctionSource("terminalTabTooltip", "terminalTabGroupStatusTooltip"),
|
|
33
|
+
appFunctionSource("terminalTabGroupStatusTooltip", "terminalTabGroupWorkspaceTooltip"),
|
|
34
|
+
appFunctionSource("terminalTabGroupWorkspaceTooltip", "terminalTabGroupActiveTooltip"),
|
|
35
|
+
appFunctionSource("terminalTabGroupActiveTooltip", "terminalTabGroupTooltip"),
|
|
36
|
+
appFunctionSource("terminalTabGroupTooltip", "appendTerminalTabContent"),
|
|
37
|
+
appFunctionToMarker("cleanTooltipText", "\n\nconst TOOLTIP_HOVER_DELAY_MS"),
|
|
38
|
+
].join("\n");
|
|
39
|
+
const terminalTabMetaSource = appFunctionSource("terminalTabMeta", "terminalTabGitTooltip");
|
|
40
|
+
const renderTerminalTabGroupSource = appFunctionSource("renderTerminalTabGroup", "updateTerminalTabGroupOpenState");
|
|
41
|
+
|
|
42
|
+
const context = {
|
|
43
|
+
normalizeDisplayPath: (value) => String(value || "").replace(/\\/g, "/"),
|
|
44
|
+
cleanStatusText: (value) => String(value || "").trim(),
|
|
45
|
+
stripAnsi: (value) => String(value || ""),
|
|
46
|
+
tabIndicator: (tab) => ({ state: tab.running ? (tab.state || "idle") : "idle", label: tab.running ? (tab.label || "Idle") : "Stopped" }),
|
|
47
|
+
tabAppRunnerRunningRun: (tab) => tab.appRunner || null,
|
|
48
|
+
terminalAppRunnerLabel: (run) => `app runner: ${run.label}`,
|
|
49
|
+
tabConversationMode: (tab) => tab.conversationMode || { enabled: false },
|
|
50
|
+
tabConversationModeActive: (tab) => tab.conversationMode?.enabled === true,
|
|
51
|
+
tabWorkflowModeActive: (tab) => tab.workflowMode === true,
|
|
52
|
+
workflowRunningCountForTab: (id) => id === "tab-1" ? 2 : 0,
|
|
53
|
+
terminalDisplayGroupTitle: () => "Workspace group",
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const results = vm.runInNewContext(`
|
|
57
|
+
${sources}
|
|
58
|
+
const runningTab = {
|
|
59
|
+
id: "tab-1",
|
|
60
|
+
title: "Tooltip work",
|
|
61
|
+
running: true,
|
|
62
|
+
state: "working",
|
|
63
|
+
label: "Working",
|
|
64
|
+
cwd: "/home/user/projects/pi-package-webui",
|
|
65
|
+
gitWorkspace: { worktreePath: "/home/user/projects/pi-package-webui", branch: "feat/readable-tooltip", isMainWorktree: true },
|
|
66
|
+
appRunner: { label: "npm test" },
|
|
67
|
+
conversationMode: { enabled: true, uiState: "listening" },
|
|
68
|
+
workflowMode: true,
|
|
69
|
+
};
|
|
70
|
+
const stoppedTab = { id: "tab-2", title: "Closed tab", running: false, cwd: "/tmp/other/pi-package-webui", pid: 4242, command: "secret-command", sessionFile: "/private/session.jsonl" };
|
|
71
|
+
({
|
|
72
|
+
metadata: terminalTabMeta(runningTab, { meta: "working" }),
|
|
73
|
+
running: cleanTooltipText(terminalTabTooltip(runningTab)),
|
|
74
|
+
stopped: cleanTooltipText(terminalTabTooltip(stoppedTab)),
|
|
75
|
+
group: terminalTabGroupTooltip({ custom: true, tabs: [runningTab, stoppedTab] }, "Tooltip group"),
|
|
76
|
+
});
|
|
77
|
+
`, context);
|
|
78
|
+
|
|
79
|
+
assert.equal(results.metadata, "working · pi-package-webui · app runner · voice · workflow mode · 2 workflows", "compact tab metadata should keep workspace and live-mode context");
|
|
80
|
+
assert.equal(results.running.split("\n").length, 5, "a fully populated workspace tooltip should remain bounded to five lines");
|
|
81
|
+
assert.match(results.running, /^Tooltip work · Working\nWorking folder: \/home\/user\/projects\/pi-package-webui/m, "rendered tooltip should lead with identity/status and the full readable workspace path");
|
|
82
|
+
assert.match(results.running, /Git: feat\/readable-tooltip · main worktree/, "rendered tooltip should show optional branch/worktree context");
|
|
83
|
+
assert.match(results.running, /Active: app runner: npm test · voice: listening · workflow: 2 runs/, "rendered tooltip should summarize active workspace modes");
|
|
84
|
+
assert.equal((results.stopped.match(/Stopped/g) || []).length, 1, "stopped status should appear exactly once");
|
|
85
|
+
assert.match(results.stopped, /Working folder: \/tmp\/other\/pi-package-webui/, "same-basename workspaces should remain distinguishable by full path");
|
|
86
|
+
assert.doesNotMatch(`${results.running}\n${results.stopped}`, /4242|secret-command|session\.jsonl|\bpid\b/i, "tooltips should exclude diagnostic and private session details");
|
|
87
|
+
assert.match(results.group, /^Tooltip group · 2 tabs\nWorkspaces: projects\/pi-package-webui, other\/pi-package-webui\nStatus: 1 working · 1 stopped/m, "group hover summary should distinguish same-basename workspaces and aggregate status");
|
|
88
|
+
assert.match(results.group, /Click to switch · Drop tabs here to add$/, "group hover summary should preserve the drop-target affordance");
|
|
89
|
+
assert.doesNotMatch(terminalTabMetaSource, /\bpid\b/i, "compact tab metadata should not expose the process PID");
|
|
90
|
+
assert.equal(app.match(/applyStyledTooltip\(button, terminalTabTooltip\(tab\)/g)?.length, 2, "single and grouped-item tabs should share one tooltip formatter");
|
|
91
|
+
assert.match(renderTerminalTabGroupSource, /terminal-tab-group-summary[\s\S]*terminalTabGroupTooltip\(group, groupTitle\)[\s\S]*button\.setAttribute\("aria-describedby", summary\.id\)[\s\S]*menu\.append\(summary\)/, "group hover disclosure should expose its non-overlapping summary as an accessible description");
|
|
92
|
+
assert.match(app, /footerTooltipNode\.setAttribute\("role", "tooltip"\)/, "the shared visual tooltip should expose tooltip semantics");
|
|
93
|
+
assert.match(app, /document\.addEventListener\("keydown", \(event\) => \{[\s\S]*event\.key === "Escape" && footerTooltipTarget[\s\S]*hideFooterTooltip\(footerTooltipTarget\)[\s\S]*\}, true\)/, "Escape should dismiss both hover- and focus-triggered tooltips from the document capture phase");
|
|
94
|
+
assert.match(app, /data-tooltip-variant"\) === "workspace" && !node\.matches\(":focus-visible"\)/, "touch focus should not flash the large workspace tooltip while keyboard focus remains supported");
|
|
95
|
+
assert.match(app, /styled-tooltip-description[\s\S]*aria-describedby/, "detailed tab tooltip text should be available as an accessible description");
|
|
96
|
+
assert.match(styles, /footer-floating-tooltip\[data-variant="workspace"\][\s\S]*line-height: 1\.52/, "workspace tooltips should use the readable visual variant");
|
|
97
|
+
assert.match(styles, /terminal-tab-group-summary[\s\S]*white-space: pre-wrap/, "group summaries should preserve the readable multiline hierarchy");
|
|
98
|
+
|
|
99
|
+
console.log("terminal tab workspace static tests passed");
|