@firstpick/pi-package-webui 0.7.2 → 0.7.3
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 +5 -5
- package/bin/pi-webui.mjs +266 -67
- package/lib/git-live-watcher.mjs +135 -0
- package/lib/git-message-artifacts.mjs +103 -0
- package/lib/process-tree.mjs +3 -1
- package/package.json +4 -3
- package/public/app.js +482 -73
- package/public/index.html +3 -2
- package/public/styles.css +92 -5
- package/tests/app-runner-windows-conpty-harness.test.mjs +140 -0
- package/tests/danger-button-contrast-static.test.mjs +32 -0
- package/tests/fixtures/fake-pi.mjs +1 -0
- package/tests/footer-middle-truncation.test.mjs +118 -0
- package/tests/git-live-watcher.test.mjs +93 -0
- package/tests/git-message-artifacts.test.mjs +59 -0
- package/tests/git-panel-live-updates-static.test.mjs +54 -0
- package/tests/git-panel-render-stability-static.test.mjs +1 -1
- package/tests/guided-git-message-reliability-static.test.mjs +38 -0
- package/tests/http-endpoints-harness.test.mjs +52 -5
- package/tests/image-payload-hardening-harness.test.mjs +115 -0
- package/tests/mobile-static.test.mjs +24 -9
- package/tests/pi-footer-calibration-static.test.mjs +55 -0
- package/tests/runtime-error-visibility.test.mjs +63 -0
- package/tests/side-panel-context-menu-static.test.mjs +74 -0
package/public/index.html
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<link rel="manifest" href="/manifest.webmanifest" />
|
|
13
13
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
14
14
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
|
15
|
-
<link rel="stylesheet" href="/styles.css?v=
|
|
15
|
+
<link rel="stylesheet" href="/styles.css?v=81" />
|
|
16
16
|
</head>
|
|
17
17
|
<body>
|
|
18
18
|
<button id="sidePanelExpandButton" class="side-panel-expand-button" type="button" aria-controls="sidePanel" aria-expanded="false" aria-label="Expand side panel" title="Expand side panel">
|
|
@@ -399,7 +399,7 @@
|
|
|
399
399
|
</div>
|
|
400
400
|
</div>
|
|
401
401
|
<div class="file-viewer-content">
|
|
402
|
-
<textarea id="fileViewerEditor" class="file-viewer-editor" spellcheck="false" aria-label="File contents"></textarea>
|
|
402
|
+
<textarea id="fileViewerEditor" class="file-viewer-editor" wrap="soft" spellcheck="false" aria-label="File contents"></textarea>
|
|
403
403
|
<div id="fileViewerPreview" class="file-viewer-preview markdown-body" tabindex="0" hidden></div>
|
|
404
404
|
</div>
|
|
405
405
|
<p id="fileViewerStatus" class="file-viewer-status muted" role="status" aria-live="polite"></p>
|
|
@@ -775,6 +775,7 @@
|
|
|
775
775
|
<button type="button" role="menuitem" class="danger" data-file-menu-action="delete">Delete…</button>
|
|
776
776
|
</div>
|
|
777
777
|
<div id="gitPanelContextMenu" class="file-context-menu git-side-panel-context-menu" role="menu" aria-label="Git actions" hidden></div>
|
|
778
|
+
<div id="sidePanelContextMenu" class="file-context-menu side-panel-context-menu" role="menu" aria-label="Choose visible side panel sections" hidden></div>
|
|
778
779
|
|
|
779
780
|
<aside id="undoToast" class="undo-toast" aria-live="polite" aria-atomic="true" hidden>
|
|
780
781
|
<span id="undoToastMessage" class="undo-toast-message"></span>
|
package/public/styles.css
CHANGED
|
@@ -916,10 +916,13 @@ body.file-viewer-resizing * {
|
|
|
916
916
|
.file-viewer-editor {
|
|
917
917
|
resize: none;
|
|
918
918
|
padding: 0.72rem;
|
|
919
|
+
overflow-x: hidden;
|
|
920
|
+
overflow-y: auto;
|
|
921
|
+
overflow-wrap: anywhere;
|
|
919
922
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
|
|
920
923
|
font-size: 0.82rem;
|
|
921
924
|
line-height: 1.45;
|
|
922
|
-
white-space: pre;
|
|
925
|
+
white-space: pre-wrap;
|
|
923
926
|
}
|
|
924
927
|
.file-viewer-preview {
|
|
925
928
|
padding: 0.85rem;
|
|
@@ -956,6 +959,44 @@ body.file-viewer-resizing * {
|
|
|
956
959
|
text-align: left;
|
|
957
960
|
box-shadow: none;
|
|
958
961
|
}
|
|
962
|
+
.side-panel-context-menu {
|
|
963
|
+
max-height: calc(100vh - 1rem);
|
|
964
|
+
max-height: calc(100dvh - 1rem);
|
|
965
|
+
overflow-y: auto;
|
|
966
|
+
}
|
|
967
|
+
.side-panel-context-menu-label {
|
|
968
|
+
padding: 0.38rem 0.58rem 0.24rem;
|
|
969
|
+
color: var(--ctp-subtext);
|
|
970
|
+
font-size: var(--text-xs);
|
|
971
|
+
font-weight: 850;
|
|
972
|
+
letter-spacing: 0.06em;
|
|
973
|
+
text-transform: uppercase;
|
|
974
|
+
}
|
|
975
|
+
.side-panel-context-menu-item {
|
|
976
|
+
display: grid;
|
|
977
|
+
grid-template-columns: 1.1rem minmax(0, 1fr);
|
|
978
|
+
align-items: center;
|
|
979
|
+
gap: 0.48rem;
|
|
980
|
+
}
|
|
981
|
+
.side-panel-context-menu-item::before {
|
|
982
|
+
content: "";
|
|
983
|
+
display: grid;
|
|
984
|
+
place-items: center;
|
|
985
|
+
width: 1rem;
|
|
986
|
+
height: 1rem;
|
|
987
|
+
border: 1px solid rgba(180, 190, 254, 0.48);
|
|
988
|
+
border-radius: 0.28rem;
|
|
989
|
+
color: var(--ctp-crust);
|
|
990
|
+
background: rgba(var(--ctp-crust-rgb), 0.52);
|
|
991
|
+
font-size: var(--text-xs);
|
|
992
|
+
font-weight: 950;
|
|
993
|
+
line-height: 1;
|
|
994
|
+
}
|
|
995
|
+
.side-panel-context-menu-item[aria-checked="true"]::before {
|
|
996
|
+
content: "✓";
|
|
997
|
+
border-color: rgba(148, 226, 213, 0.82);
|
|
998
|
+
background: var(--ctp-teal);
|
|
999
|
+
}
|
|
959
1000
|
body.embedded-split .layout,
|
|
960
1001
|
body.embedded-split.side-panel-collapsed .layout {
|
|
961
1002
|
grid-template-columns: minmax(0, 1fr);
|
|
@@ -1522,7 +1563,10 @@ body.embedded-split .side-panel-backdrop {
|
|
|
1522
1563
|
text-overflow: ellipsis;
|
|
1523
1564
|
white-space: nowrap;
|
|
1524
1565
|
}
|
|
1525
|
-
.git-side-panel-context-menu button.danger {
|
|
1566
|
+
.git-side-panel-context-menu button.danger {
|
|
1567
|
+
color: var(--ctp-red);
|
|
1568
|
+
background: rgba(var(--ctp-crust-rgb), 0.54);
|
|
1569
|
+
}
|
|
1526
1570
|
.git-side-panel-commit {
|
|
1527
1571
|
display: grid;
|
|
1528
1572
|
grid-template-columns: auto minmax(0, 1fr);
|
|
@@ -2054,6 +2098,7 @@ body.embedded-split .side-panel-backdrop {
|
|
|
2054
2098
|
overflow: hidden;
|
|
2055
2099
|
text-overflow: ellipsis;
|
|
2056
2100
|
white-space: nowrap;
|
|
2101
|
+
line-height: 1.3;
|
|
2057
2102
|
}
|
|
2058
2103
|
.model-search-result-main {
|
|
2059
2104
|
font-weight: 900;
|
|
@@ -3758,6 +3803,15 @@ body.embedded-split .side-panel-backdrop {
|
|
|
3758
3803
|
scrollbar-gutter: auto;
|
|
3759
3804
|
overflow-anchor: none;
|
|
3760
3805
|
}
|
|
3806
|
+
.widget-area:has(.workflow-widget) {
|
|
3807
|
+
flex: 0 1 auto;
|
|
3808
|
+
max-height: min(34rem, 52dvh);
|
|
3809
|
+
min-height: 0;
|
|
3810
|
+
overflow: auto;
|
|
3811
|
+
overscroll-behavior: contain;
|
|
3812
|
+
scrollbar-gutter: stable;
|
|
3813
|
+
overflow-anchor: none;
|
|
3814
|
+
}
|
|
3761
3815
|
.statusbar {
|
|
3762
3816
|
position: relative;
|
|
3763
3817
|
flex: 0 0 auto;
|
|
@@ -4009,6 +4063,25 @@ button.footer-tui-item {
|
|
|
4009
4063
|
text-overflow: ellipsis;
|
|
4010
4064
|
white-space: nowrap;
|
|
4011
4065
|
}
|
|
4066
|
+
.middle-truncate-value {
|
|
4067
|
+
display: flex;
|
|
4068
|
+
align-items: baseline;
|
|
4069
|
+
min-width: 0;
|
|
4070
|
+
overflow: hidden;
|
|
4071
|
+
text-overflow: clip;
|
|
4072
|
+
white-space: nowrap;
|
|
4073
|
+
}
|
|
4074
|
+
.middle-truncate-start {
|
|
4075
|
+
flex: 1 1 auto;
|
|
4076
|
+
min-width: 6ch;
|
|
4077
|
+
overflow: hidden;
|
|
4078
|
+
text-overflow: ellipsis;
|
|
4079
|
+
white-space: nowrap;
|
|
4080
|
+
}
|
|
4081
|
+
.middle-truncate-end {
|
|
4082
|
+
flex: 0 0 auto;
|
|
4083
|
+
white-space: nowrap;
|
|
4084
|
+
}
|
|
4012
4085
|
.footer-meta {
|
|
4013
4086
|
display: grid;
|
|
4014
4087
|
grid-template-columns: auto minmax(0, 1fr);
|
|
@@ -5372,7 +5445,11 @@ button.git-workflow-step:hover:not(:disabled) {
|
|
|
5372
5445
|
.aur-review-action:hover,
|
|
5373
5446
|
.aur-review-report:hover { border-color: rgba(250, 179, 135, 0.8); color: var(--ctp-peach); }
|
|
5374
5447
|
.aur-review-action.primary { border-color: rgba(166, 227, 161, 0.58); color: var(--ctp-green); }
|
|
5375
|
-
.aur-review-action.danger {
|
|
5448
|
+
.aur-review-action.danger {
|
|
5449
|
+
color: var(--ctp-red);
|
|
5450
|
+
border-color: rgba(243, 139, 168, 0.58);
|
|
5451
|
+
background: rgba(var(--ctp-crust-rgb), 0.54);
|
|
5452
|
+
}
|
|
5376
5453
|
.aur-review-summary { flex-wrap: wrap; align-items: baseline; color: var(--ctp-subtext0); font-size: var(--text-xs); }
|
|
5377
5454
|
.aur-review-status { color: var(--ctp-peach); font-weight: 720; }
|
|
5378
5455
|
.aur-review-root,
|
|
@@ -5410,6 +5487,13 @@ button.git-workflow-step:hover:not(:disabled) {
|
|
|
5410
5487
|
linear-gradient(145deg, rgba(var(--ctp-crust-rgb), 0.98), rgba(var(--ctp-mantle-rgb), 0.92));
|
|
5411
5488
|
}
|
|
5412
5489
|
.workflow-widget .release-npm-kicker { color: var(--ctp-blue); }
|
|
5490
|
+
.workflow-inspector-widget.minimized { gap: 0; }
|
|
5491
|
+
.workflow-inspector-minimize-button {
|
|
5492
|
+
border-color: rgba(137, 180, 250, 0.42);
|
|
5493
|
+
color: var(--ctp-blue);
|
|
5494
|
+
}
|
|
5495
|
+
.workflow-inspector-minimize-button:hover,
|
|
5496
|
+
.workflow-inspector-minimize-button:focus-visible { border-color: rgba(137, 180, 250, 0.82); }
|
|
5413
5497
|
.workflow-widget .release-npm-pill.workflow-status.completed { color: var(--ctp-green); }
|
|
5414
5498
|
.workflow-widget .release-npm-pill.workflow-status.failed { color: var(--ctp-red); }
|
|
5415
5499
|
.workflow-widget .release-npm-pill.workflow-status.cancelled { color: var(--ctp-yellow); }
|
|
@@ -5516,6 +5600,7 @@ button.git-workflow-step:hover:not(:disabled) {
|
|
|
5516
5600
|
.workflow-inspector-run-list { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 13rem; }
|
|
5517
5601
|
.workflow-inspector-actions { justify-content: stretch; }
|
|
5518
5602
|
.workflow-inspector-actions button { flex: 1 1 7rem; min-height: 44px; }
|
|
5603
|
+
.workflow-inspector-minimize-button { min-height: 44px; }
|
|
5519
5604
|
}
|
|
5520
5605
|
.btw-widget {
|
|
5521
5606
|
border-color: rgba(148, 226, 213, 0.62);
|
|
@@ -12107,8 +12192,9 @@ button.workspace-dashboard-chip {
|
|
|
12107
12192
|
color: var(--ctp-green);
|
|
12108
12193
|
}
|
|
12109
12194
|
.git-operation-button.danger {
|
|
12110
|
-
border-color: rgba(243, 139, 168, 0.4);
|
|
12111
12195
|
color: var(--ctp-red);
|
|
12196
|
+
border-color: rgba(243, 139, 168, 0.4);
|
|
12197
|
+
background: rgba(var(--ctp-crust-rgb), 0.5);
|
|
12112
12198
|
}
|
|
12113
12199
|
.git-conflict-list {
|
|
12114
12200
|
display: grid;
|
|
@@ -12187,8 +12273,9 @@ button.workspace-dashboard-chip {
|
|
|
12187
12273
|
background: rgba(var(--ctp-mantle-rgb), 0.75);
|
|
12188
12274
|
}
|
|
12189
12275
|
.git-file-action.danger {
|
|
12190
|
-
border-color: rgba(243, 139, 168, 0.38);
|
|
12191
12276
|
color: var(--ctp-red);
|
|
12277
|
+
border-color: rgba(243, 139, 168, 0.38);
|
|
12278
|
+
background: rgba(var(--ctp-crust-rgb), 0.55);
|
|
12192
12279
|
}
|
|
12193
12280
|
|
|
12194
12281
|
/* Git tools (stash, undo, worktrees, submodules, tags, signing) */
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
3
|
+
import { chmod, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
7
|
+
import { dirname, join } from "node:path";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
|
|
10
|
+
if (process.platform !== "win32") {
|
|
11
|
+
console.log("app-runner-windows-conpty-harness.test.mjs skipped (Windows only)");
|
|
12
|
+
process.exit(0);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
assert.equal(spawnSync("bash", ["--version"], { stdio: "ignore" }).status, 0, "Windows ConPTY test requires bash on PATH");
|
|
16
|
+
await import("node-pty");
|
|
17
|
+
|
|
18
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
19
|
+
const serverScript = join(root, "bin", "pi-webui.mjs");
|
|
20
|
+
const fakePi = join(root, "tests", "fixtures", "fake-pi.mjs");
|
|
21
|
+
const port = 30000 + Math.floor(Math.random() * 20000);
|
|
22
|
+
|
|
23
|
+
async function request(pathname, { method = "GET", body, timeoutMs = 5_000 } = {}) {
|
|
24
|
+
const response = await fetch(`http://127.0.0.1:${port}${pathname}`, {
|
|
25
|
+
method,
|
|
26
|
+
headers: body === undefined ? undefined : { "content-type": "application/json" },
|
|
27
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
28
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
29
|
+
});
|
|
30
|
+
const payload = await response.json().catch(() => undefined);
|
|
31
|
+
return { status: response.status, body: payload };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function waitFor(description, probe, { attempts = 100, intervalMs = 100 } = {}) {
|
|
35
|
+
let last;
|
|
36
|
+
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
|
37
|
+
last = await probe();
|
|
38
|
+
if (last) return last;
|
|
39
|
+
await delay(intervalMs);
|
|
40
|
+
}
|
|
41
|
+
assert.fail(`${description} did not happen in time${last ? `; last=${JSON.stringify(last)}` : ""}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function rmWithRetry(target) {
|
|
45
|
+
for (let attempt = 0; attempt < 8; attempt += 1) {
|
|
46
|
+
try {
|
|
47
|
+
await rm(target, { recursive: true, force: true });
|
|
48
|
+
return;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
if (attempt === 7 || !["EBUSY", "EPERM", "ENOTEMPTY"].includes(error?.code)) throw error;
|
|
51
|
+
await delay(150 * (attempt + 1));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const cwd = await mkdtemp(path.join(tmpdir(), "pi-webui-conpty-"));
|
|
57
|
+
const settingsFile = path.join(cwd, "webui-settings.json");
|
|
58
|
+
await chmod(fakePi, 0o755);
|
|
59
|
+
await writeFile(path.join(cwd, "interactive-fixture"), [
|
|
60
|
+
"#!/usr/bin/env bash",
|
|
61
|
+
"set -euo pipefail",
|
|
62
|
+
"if [[ -t 0 && -t 1 ]]; then printf 'tty=yes\\n'; else printf 'tty=no\\n'; fi",
|
|
63
|
+
"read -r -p 'choice? ' answer",
|
|
64
|
+
"printf 'selected:%s\\n' \"$answer\"",
|
|
65
|
+
"",
|
|
66
|
+
].join("\n"));
|
|
67
|
+
|
|
68
|
+
const server = spawn(process.execPath, [serverScript, "--cwd", cwd, "--host", "127.0.0.1", "--port", String(port), "--pi", fakePi], {
|
|
69
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
70
|
+
env: { ...process.env, PI_WEBUI_SETTINGS_FILE: settingsFile },
|
|
71
|
+
windowsHide: true,
|
|
72
|
+
});
|
|
73
|
+
let serverOutput = "";
|
|
74
|
+
server.stdout.on("data", (chunk) => { serverOutput += String(chunk); });
|
|
75
|
+
server.stderr.on("data", (chunk) => { serverOutput += String(chunk); });
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
await waitFor("server health", async () => {
|
|
79
|
+
if (server.exitCode !== null) return false;
|
|
80
|
+
try {
|
|
81
|
+
const health = await request("/api/health", { timeoutMs: 1_000 });
|
|
82
|
+
return health.status === 200 && health.body?.ok === true;
|
|
83
|
+
} catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const tabsResponse = await request("/api/tabs");
|
|
89
|
+
const tabId = tabsResponse.body?.data?.tabs?.[0]?.id || tabsResponse.body?.tabs?.[0]?.id;
|
|
90
|
+
assert.ok(tabId, `startup tab should exist, output:\n${serverOutput}`);
|
|
91
|
+
|
|
92
|
+
const saved = await request("/api/app-runner-config", {
|
|
93
|
+
method: "POST",
|
|
94
|
+
body: { tab: tabId, runner: { label: "Windows ConPTY bash", command: "bash", path: "interactive-fixture" } },
|
|
95
|
+
timeoutMs: 10_000,
|
|
96
|
+
});
|
|
97
|
+
assert.equal(saved.status, 200, `saving ConPTY runner should succeed: ${saved.body?.error || serverOutput}`);
|
|
98
|
+
const runner = saved.body?.data?.runners?.find((item) => item.custom === true && item.label === "Windows ConPTY bash");
|
|
99
|
+
assert.ok(runner?.id, "Windows ConPTY custom runner should be available");
|
|
100
|
+
|
|
101
|
+
let state = await request("/api/app-runner", {
|
|
102
|
+
method: "POST",
|
|
103
|
+
body: { tab: tabId, runnerId: runner.id },
|
|
104
|
+
timeoutMs: 10_000,
|
|
105
|
+
});
|
|
106
|
+
assert.equal(state.status, 200, `ConPTY runner should start: ${state.body?.error || serverOutput}`);
|
|
107
|
+
assert.equal(state.body?.data?.activeRun?.executionMode, "conpty", "Windows runner should use ConPTY");
|
|
108
|
+
|
|
109
|
+
await waitFor("TTY prompt", async () => {
|
|
110
|
+
state = await request(`/api/app-runners?tab=${encodeURIComponent(tabId)}`);
|
|
111
|
+
const output = [...(state.body?.data?.activeRun?.lines || []), state.body?.data?.activeRun?.pendingLine || ""].join("\n");
|
|
112
|
+
return /tty=yes/.test(output) && /choice\?/.test(output);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const input = await request("/api/app-runner/input", {
|
|
116
|
+
method: "POST",
|
|
117
|
+
body: { tab: tabId, text: "alpha", closeStdin: true },
|
|
118
|
+
timeoutMs: 10_000,
|
|
119
|
+
});
|
|
120
|
+
assert.equal(input.status, 200, `ConPTY input should be accepted: ${input.body?.error || serverOutput}`);
|
|
121
|
+
|
|
122
|
+
await waitFor("interactive runner completion", async () => {
|
|
123
|
+
state = await request(`/api/app-runners?tab=${encodeURIComponent(tabId)}`);
|
|
124
|
+
return state.body?.data?.activeRun?.status === "done";
|
|
125
|
+
});
|
|
126
|
+
const output = [...(state.body?.data?.activeRun?.lines || []), state.body?.data?.activeRun?.pendingLine || ""].join("\n");
|
|
127
|
+
assert.match(output, /selected:alpha/, "Windows ConPTY runner should receive WebUI input");
|
|
128
|
+
|
|
129
|
+
await request("/api/shutdown", { method: "POST" }).catch(() => undefined);
|
|
130
|
+
for (let attempt = 0; attempt < 50 && server.exitCode === null; attempt += 1) await delay(100);
|
|
131
|
+
assert.notEqual(server.exitCode, null, "server should exit after shutdown");
|
|
132
|
+
console.log("app-runner-windows-conpty-harness.test.mjs passed");
|
|
133
|
+
} finally {
|
|
134
|
+
if (server.exitCode === null) {
|
|
135
|
+
await request("/api/shutdown", { method: "POST", timeoutMs: 1_000 }).catch(() => undefined);
|
|
136
|
+
for (let attempt = 0; attempt < 20 && server.exitCode === null; attempt += 1) await delay(100);
|
|
137
|
+
if (server.exitCode === null) server.kill("SIGKILL");
|
|
138
|
+
}
|
|
139
|
+
await rmWithRetry(cwd);
|
|
140
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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 css = await readFile(join(root, "public", "styles.css"), "utf8");
|
|
8
|
+
|
|
9
|
+
function ruleBody(selector) {
|
|
10
|
+
const escaped = selector.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
11
|
+
const match = css.match(new RegExp(`${escaped}\\s*\\{([^}]+)\\}`));
|
|
12
|
+
assert.ok(match, `${selector} should have a CSS rule`);
|
|
13
|
+
return match[1];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const filledDanger = ruleBody("button.danger");
|
|
17
|
+
assert.match(filledDanger, /color:\s*var\(--button-primary-text\)/, "filled danger buttons should retain dark high-contrast text");
|
|
18
|
+
assert.match(filledDanger, /background:\s*linear-gradient\([^;]*var\(--ctp-red\)[^;]*var\(--ctp-peach\)/, "filled danger buttons should retain their danger gradient");
|
|
19
|
+
|
|
20
|
+
for (const selector of [
|
|
21
|
+
".git-side-panel-context-menu button.danger",
|
|
22
|
+
".aur-review-action.danger",
|
|
23
|
+
".git-operation-button.danger",
|
|
24
|
+
".git-file-action.danger",
|
|
25
|
+
]) {
|
|
26
|
+
const body = ruleBody(selector);
|
|
27
|
+
assert.match(body, /color:\s*var\(--ctp-red\)/, `${selector} should retain its red outline-button text`);
|
|
28
|
+
assert.match(body, /background:\s*rgba\(var\(--ctp-crust-rgb\),\s*0\.[0-9]+\)/, `${selector} should place red text on a neutral surface`);
|
|
29
|
+
assert.doesNotMatch(body, /background:[^;]*(?:--ctp-red|--ctp-peach)/, `${selector} must not place red text on a red danger background`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
console.log("danger button contrast static tests passed");
|
|
@@ -439,6 +439,7 @@ rl.on("line", (line) => {
|
|
|
439
439
|
direction: "command",
|
|
440
440
|
type,
|
|
441
441
|
...(command.message !== undefined ? { message: String(command.message) } : {}),
|
|
442
|
+
...(Array.isArray(command.images) ? { images: command.images } : {}),
|
|
442
443
|
...(command.provider !== undefined ? { provider: String(command.provider) } : {}),
|
|
443
444
|
...(command.modelId !== undefined ? { modelId: String(command.modelId) } : {}),
|
|
444
445
|
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import vm from "node:vm";
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
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, css] = await Promise.all([
|
|
9
|
+
readFile(join(root, "public", "app.js"), "utf8"),
|
|
10
|
+
readFile(join(root, "public", "styles.css"), "utf8"),
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
function findFunctionSource(source, name) {
|
|
14
|
+
const signature = new RegExp(`function\\s+${name}\\s*\\(`, "m");
|
|
15
|
+
const match = signature.exec(source);
|
|
16
|
+
assert.ok(match, `${name} should be defined`);
|
|
17
|
+
let parenDepth = 0;
|
|
18
|
+
let openBrace = -1;
|
|
19
|
+
for (let index = match.index + match[0].length - 1; index < source.length; index += 1) {
|
|
20
|
+
const char = source[index];
|
|
21
|
+
if (char === "(") parenDepth += 1;
|
|
22
|
+
else if (char === ")") parenDepth -= 1;
|
|
23
|
+
else if (char === "{" && parenDepth === 0) {
|
|
24
|
+
openBrace = index;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
assert.notEqual(openBrace, -1, `${name} body should open`);
|
|
29
|
+
let depth = 0;
|
|
30
|
+
for (let index = openBrace; index < source.length; index += 1) {
|
|
31
|
+
const char = source[index];
|
|
32
|
+
if (char === "{") depth += 1;
|
|
33
|
+
else if (char === "}") {
|
|
34
|
+
depth -= 1;
|
|
35
|
+
if (depth === 0) return source.slice(match.index, index + 1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
assert.fail(`${name} body should close`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const context = {
|
|
42
|
+
FOOTER_MIDDLE_TRUNCATION_END_CHARS: 16,
|
|
43
|
+
FOOTER_MIDDLE_TRUNCATION_MIN_START_CHARS: 6,
|
|
44
|
+
};
|
|
45
|
+
vm.runInNewContext(
|
|
46
|
+
`${findFunctionSource(app, "splitMiddleTruncationText")}\nthis.splitMiddleTruncationText = splitMiddleTruncationText;`,
|
|
47
|
+
context,
|
|
48
|
+
);
|
|
49
|
+
const { splitMiddleTruncationText } = context;
|
|
50
|
+
|
|
51
|
+
assert.deepEqual(
|
|
52
|
+
{ ...splitMiddleTruncationText("/tmp/project") },
|
|
53
|
+
{ start: "/tmp/project", end: "" },
|
|
54
|
+
"short paths should remain a single uninterrupted value",
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const boundary = "x".repeat(22);
|
|
58
|
+
assert.deepEqual(
|
|
59
|
+
{ ...splitMiddleTruncationText(boundary) },
|
|
60
|
+
{ start: boundary, end: "" },
|
|
61
|
+
"the split threshold should leave enough room for the visible prefix",
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const longPath = "/mnt/SSD_NVME_4TB/GitHub/laboratory-planning-app";
|
|
65
|
+
const split = { ...splitMiddleTruncationText(longPath) };
|
|
66
|
+
assert.equal(split.start + split.end, longPath, "split spans should preserve the complete path text and accessible name");
|
|
67
|
+
assert.equal(split.end, "/laboratory-planning-app", "the suffix should preserve the complete final POSIX path component");
|
|
68
|
+
assert.ok(split.start.startsWith("/mnt/"), "the flexible prefix should contain the path beginning");
|
|
69
|
+
|
|
70
|
+
const windowsPath = String.raw`C:\Users\Dev\Repos\project-tail-component`;
|
|
71
|
+
const windowsSplit = { ...splitMiddleTruncationText(windowsPath) };
|
|
72
|
+
assert.equal(windowsSplit.end, String.raw`\project-tail-component`, "the suffix should preserve the complete final Windows path component");
|
|
73
|
+
assert.equal(windowsSplit.start + windowsSplit.end, windowsPath, "Windows split spans should preserve the complete path");
|
|
74
|
+
|
|
75
|
+
const trailingSeparatorsPath = "/mnt/data/project-tail-component///";
|
|
76
|
+
const trailingSeparatorsSplit = { ...splitMiddleTruncationText(trailingSeparatorsPath) };
|
|
77
|
+
assert.equal(trailingSeparatorsSplit.end, "/project-tail-component///", "trailing separators should remain attached to the final component");
|
|
78
|
+
assert.equal(trailingSeparatorsSplit.start + trailingSeparatorsSplit.end, trailingSeparatorsPath, "trailing-separator paths should reconstruct exactly");
|
|
79
|
+
assert.deepEqual(
|
|
80
|
+
{ ...splitMiddleTruncationText(longPath, 0) },
|
|
81
|
+
{ start: longPath, end: "" },
|
|
82
|
+
"a disabled suffix should fall back to the untouched value",
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const unicodeBoundaryPath = `/long/prefix/${"x".repeat(20)}😀${"y".repeat(15)}`;
|
|
86
|
+
const unicodeSplit = { ...splitMiddleTruncationText(unicodeBoundaryPath) };
|
|
87
|
+
assert.equal(unicodeSplit.start + unicodeSplit.end, unicodeBoundaryPath, "Unicode paths should reconstruct exactly");
|
|
88
|
+
assert.ok(unicodeSplit.end.includes("😀"), "the suffix split should preserve an astral character at the boundary");
|
|
89
|
+
assert.doesNotMatch(unicodeSplit.start, /[\uD800-\uDBFF]$/, "the prefix should not end with an unpaired high surrogate");
|
|
90
|
+
assert.doesNotMatch(unicodeSplit.end, /^[\uDC00-\uDFFF]/, "the suffix should not begin with an unpaired low surrogate");
|
|
91
|
+
|
|
92
|
+
assert.match(
|
|
93
|
+
app,
|
|
94
|
+
/function setMiddleTruncatedText[\s\S]*?if \(!parts\.end\)[\s\S]*?classList\.remove\("middle-truncate-value"\)[\s\S]*?classList\.add\("middle-truncate-value"\)/,
|
|
95
|
+
"short unsplit CWD values should retain the normal end-ellipsis fallback",
|
|
96
|
+
);
|
|
97
|
+
assert.match(
|
|
98
|
+
app,
|
|
99
|
+
/function renderTuiFooterLine[\s\S]*?footer-tui-cwd[\s\S]*?middleTruncate: true/,
|
|
100
|
+
"the fallback TUI footer should middle-truncate its CWD",
|
|
101
|
+
);
|
|
102
|
+
assert.match(
|
|
103
|
+
app,
|
|
104
|
+
/function renderGitFooterPayloadMeta[\s\S]*?options\.middleTruncate = chip\.key === "cwd";[\s\S]*?footerMeta\(chip\.label, chip\.value/,
|
|
105
|
+
"the enhanced git footer should middle-truncate only its CWD chip",
|
|
106
|
+
);
|
|
107
|
+
assert.match(
|
|
108
|
+
app,
|
|
109
|
+
/function updateGitFooterChipNodeValue[\s\S]*?chip\.key === "cwd"[\s\S]*?setMiddleTruncatedText\(valueNode, nextValue\)/,
|
|
110
|
+
"dynamic CWD updates should retain structured middle truncation",
|
|
111
|
+
);
|
|
112
|
+
assert.match(
|
|
113
|
+
css,
|
|
114
|
+
/\.middle-truncate-start \{[\s\S]*?min-width:\s*6ch;[\s\S]*?text-overflow:\s*ellipsis[\s\S]*?\.middle-truncate-end \{[\s\S]*?flex:\s*0 0 auto/,
|
|
115
|
+
"responsive styling should shrink the prefix while keeping the suffix fixed",
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
console.log("footer-middle-truncation.test.mjs passed");
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { EventEmitter } from "node:events";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
5
|
+
import { createGitLiveWatcher } from "../lib/git-live-watcher.mjs";
|
|
6
|
+
|
|
7
|
+
const created = [];
|
|
8
|
+
const changes = [];
|
|
9
|
+
const errors = [];
|
|
10
|
+
|
|
11
|
+
function fakeWatch(root, options, listener) {
|
|
12
|
+
const watcher = new EventEmitter();
|
|
13
|
+
watcher.root = root;
|
|
14
|
+
watcher.options = options;
|
|
15
|
+
watcher.listener = listener;
|
|
16
|
+
watcher.closed = false;
|
|
17
|
+
watcher.close = () => {
|
|
18
|
+
watcher.closed = true;
|
|
19
|
+
};
|
|
20
|
+
created.push(watcher);
|
|
21
|
+
return watcher;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const manager = createGitLiveWatcher({
|
|
25
|
+
watch: fakeWatch,
|
|
26
|
+
debounceMs: 20,
|
|
27
|
+
onChange: (event) => changes.push(event),
|
|
28
|
+
onError: (event) => errors.push(event),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const firstRoot = path.resolve("/tmp/pi-webui-live-one");
|
|
32
|
+
const secondRoot = path.resolve("/tmp/pi-webui-live-two");
|
|
33
|
+
|
|
34
|
+
assert.equal(manager.subscribe("tab-a", firstRoot), true);
|
|
35
|
+
assert.equal(manager.subscribe("tab-b", firstRoot), true);
|
|
36
|
+
assert.equal(created.length, 1, "tabs in one repository should share one recursive watcher");
|
|
37
|
+
assert.deepEqual(created[0].options, { recursive: true, persistent: false });
|
|
38
|
+
assert.equal(manager.watchedRootCount(), 1);
|
|
39
|
+
|
|
40
|
+
created[0].listener("change", "file.txt");
|
|
41
|
+
created[0].listener("rename", "created.txt");
|
|
42
|
+
created[0].listener("change", "file.txt");
|
|
43
|
+
await delay(50);
|
|
44
|
+
assert.equal(changes.length, 1, "one filesystem burst should emit one debounced invalidation");
|
|
45
|
+
assert.equal(changes[0].root, firstRoot);
|
|
46
|
+
assert.match(changes[0].changedAt, /^\d{4}-\d{2}-\d{2}T/);
|
|
47
|
+
|
|
48
|
+
const maxWaitChanges = [];
|
|
49
|
+
const maxWaitManager = createGitLiveWatcher({
|
|
50
|
+
watch: fakeWatch,
|
|
51
|
+
debounceMs: 80,
|
|
52
|
+
maxWaitMs: 40,
|
|
53
|
+
onChange: (event) => maxWaitChanges.push(event),
|
|
54
|
+
});
|
|
55
|
+
assert.equal(maxWaitManager.subscribe("tab-max-wait", firstRoot), true);
|
|
56
|
+
const maxWaitWatcher = created.at(-1);
|
|
57
|
+
maxWaitWatcher.listener("change", "continuous.txt");
|
|
58
|
+
await delay(25);
|
|
59
|
+
maxWaitWatcher.listener("change", "continuous.txt");
|
|
60
|
+
await delay(30);
|
|
61
|
+
assert.equal(maxWaitChanges.length, 1, "sustained writes should emit by the bounded maximum wait");
|
|
62
|
+
maxWaitManager.closeAll();
|
|
63
|
+
|
|
64
|
+
assert.equal(manager.unsubscribe("tab-a"), true);
|
|
65
|
+
assert.equal(created[0].closed, false, "the shared watcher should remain while another tab subscribes");
|
|
66
|
+
assert.equal(manager.subscribe("tab-b", secondRoot), true, "moving a tab should subscribe its new repository");
|
|
67
|
+
assert.equal(created[0].closed, true, "moving the last subscriber should close the old watcher");
|
|
68
|
+
assert.equal(created.length, 3);
|
|
69
|
+
assert.equal(manager.subscribedRootForTab("tab-b"), secondRoot);
|
|
70
|
+
|
|
71
|
+
created.at(-1).emit("error", new Error("fixture watcher failed"));
|
|
72
|
+
assert.equal(errors.length, 1, "runtime watcher failures should be reported once");
|
|
73
|
+
assert.equal(errors[0].root, secondRoot);
|
|
74
|
+
assert.equal(manager.watchedRootCount(), 0, "a failed watcher should be removed");
|
|
75
|
+
assert.equal(manager.subscribedRootForTab("tab-b"), "", "failed roots should release tab subscriptions for later retry");
|
|
76
|
+
|
|
77
|
+
const throwingManager = createGitLiveWatcher({
|
|
78
|
+
watch: () => {
|
|
79
|
+
throw new Error("watch unsupported");
|
|
80
|
+
},
|
|
81
|
+
onError: (event) => errors.push(event),
|
|
82
|
+
});
|
|
83
|
+
assert.equal(throwingManager.subscribe("tab-c", firstRoot), false, "synchronous watcher startup errors should be non-fatal");
|
|
84
|
+
assert.match(errors.at(-1)?.error?.message || "", /watch unsupported/);
|
|
85
|
+
|
|
86
|
+
assert.equal(manager.subscribe("tab-d", firstRoot), true);
|
|
87
|
+
assert.equal(manager.subscribe("tab-e", secondRoot), true);
|
|
88
|
+
const latestWatchers = created.slice(-2);
|
|
89
|
+
manager.closeAll();
|
|
90
|
+
assert.equal(manager.watchedRootCount(), 0);
|
|
91
|
+
assert.equal(latestWatchers.every((watcher) => watcher.closed), true, "closeAll should release every watcher");
|
|
92
|
+
|
|
93
|
+
console.log("git-live-watcher.test.mjs passed");
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import {
|
|
6
|
+
gitMessageArtifactPairReadiness,
|
|
7
|
+
readStableGitMessageArtifactPair,
|
|
8
|
+
sameGitMessageArtifactPair,
|
|
9
|
+
sameGitMessageArtifactVersion,
|
|
10
|
+
} from "../lib/git-message-artifacts.mjs";
|
|
11
|
+
|
|
12
|
+
const root = await mkdtemp(path.join(tmpdir(), "pi-webui-git-messages-"));
|
|
13
|
+
const commitDir = path.join(root, "dev", "COMMIT");
|
|
14
|
+
const paths = {
|
|
15
|
+
shortPath: path.join(commitDir, "staged-commit-short.txt"),
|
|
16
|
+
longPath: path.join(commitDir, "staged-commit-long.txt"),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
await mkdir(commitDir, { recursive: true });
|
|
21
|
+
|
|
22
|
+
const missingBaseline = await readStableGitMessageArtifactPair(paths);
|
|
23
|
+
assert.equal(missingBaseline.short.exists, false);
|
|
24
|
+
assert.equal(missingBaseline.long.exists, false);
|
|
25
|
+
assert.equal(gitMessageArtifactPairReadiness(missingBaseline, missingBaseline).ready, false, "missing files must not be ready");
|
|
26
|
+
|
|
27
|
+
await writeFile(paths.shortPath, "feat: correlated message\n", "utf8");
|
|
28
|
+
await writeFile(paths.longPath, "feat: correlated message\n\n- feat: load both files\n", "utf8");
|
|
29
|
+
const firstPair = await readStableGitMessageArtifactPair(paths);
|
|
30
|
+
assert.equal(gitMessageArtifactPairReadiness(missingBaseline, firstPair).ready, true, "two new non-empty files should be ready");
|
|
31
|
+
assert.equal(sameGitMessageArtifactPair(firstPair, await readStableGitMessageArtifactPair(paths)), true, "unchanged stable pairs should compare equal");
|
|
32
|
+
|
|
33
|
+
await writeFile(paths.shortPath, "fix: only short changed\n", "utf8");
|
|
34
|
+
const partialPair = await readStableGitMessageArtifactPair(paths);
|
|
35
|
+
const partialReadiness = gitMessageArtifactPairReadiness(firstPair, partialPair);
|
|
36
|
+
assert.equal(partialReadiness.ready, false, "one stale member must keep the pair pending");
|
|
37
|
+
assert.deepEqual(partialReadiness.unchanged, ["long"]);
|
|
38
|
+
|
|
39
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
40
|
+
await writeFile(paths.shortPath, firstPair.short.text, "utf8");
|
|
41
|
+
await writeFile(paths.longPath, firstPair.long.text, "utf8");
|
|
42
|
+
const identicalRewrite = await readStableGitMessageArtifactPair(paths);
|
|
43
|
+
assert.equal(identicalRewrite.short.sha256, firstPair.short.sha256, "test setup keeps identical short content");
|
|
44
|
+
assert.equal(identicalRewrite.long.sha256, firstPair.long.sha256, "test setup keeps identical long content");
|
|
45
|
+
assert.equal(sameGitMessageArtifactVersion(firstPair.short, identicalRewrite.short), false, "metadata must identify an identical-content rewrite");
|
|
46
|
+
assert.equal(sameGitMessageArtifactVersion(firstPair.long, identicalRewrite.long), false, "both identical-content rewrites must be fresh");
|
|
47
|
+
assert.equal(gitMessageArtifactPairReadiness(firstPair, identicalRewrite).ready, true, "identical generated text is valid when both files were rewritten");
|
|
48
|
+
|
|
49
|
+
await writeFile(paths.shortPath, "", "utf8");
|
|
50
|
+
await writeFile(paths.longPath, "fix: long is present\n", "utf8");
|
|
51
|
+
const emptyPair = await readStableGitMessageArtifactPair(paths);
|
|
52
|
+
const emptyReadiness = gitMessageArtifactPairReadiness(identicalRewrite, emptyPair);
|
|
53
|
+
assert.equal(emptyReadiness.ready, false, "empty generated files must remain pending");
|
|
54
|
+
assert.deepEqual(emptyReadiness.empty, ["short"]);
|
|
55
|
+
|
|
56
|
+
console.log("git message artifact tests passed");
|
|
57
|
+
} finally {
|
|
58
|
+
await rm(root, { recursive: true, force: true });
|
|
59
|
+
}
|