@firstpick/pi-package-webui 0.7.6 → 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 +60 -4
- package/bin/pi-webui-rpc-supervisor.mjs +612 -0
- package/bin/pi-webui.mjs +1051 -95
- package/lib/WEBUI_TUI_NATIVE_PARITY.json +13 -0
- package/lib/rpc-supervisor-client.mjs +317 -0
- package/lib/rpc-supervisor-protocol.mjs +245 -0
- package/lib/rpc-supervisor-state.mjs +165 -0
- package/lib/trust-boundaries.mjs +1 -0
- package/package.json +4 -4
- package/public/app.js +1986 -170
- package/public/index.html +388 -25
- package/public/issue-bot-client.mjs +344 -0
- package/public/issue-wizard-state.mjs +443 -0
- package/public/service-worker.js +8 -1
- package/public/styles.css +578 -52
- package/public/subagent-gate-visibility.mjs +36 -0
- package/public/workflow-status-stack.mjs +69 -0
- package/tests/app-runner-process-tree-harness.test.mjs +37 -3
- package/tests/boot-failure-diagnostics.test.mjs +180 -0
- 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 +275 -0
- package/tests/fast-mode-client-static.test.mjs +2 -2
- package/tests/fixtures/fake-pi.mjs +90 -6
- package/tests/footer-context-contrast-static.test.mjs +10 -0
- package/tests/git-panel-file-preview-static.test.mjs +221 -0
- package/tests/git-panel-render-stability-static.test.mjs +11 -1
- package/tests/http-endpoints-harness.test.mjs +458 -33
- package/tests/issue-bot-client.test.mjs +135 -0
- package/tests/issue-wizard-state.test.mjs +126 -0
- package/tests/mobile-static.test.mjs +79 -16
- package/tests/native-parity-harness.test.mjs +2 -1
- package/tests/native-parity.test.mjs +13 -2
- package/tests/numpad-decimal-input-static.test.mjs +128 -0
- package/tests/open-issue-wizard-static.test.mjs +75 -0
- package/tests/prompt-routing-input-clear-static.test.mjs +34 -0
- package/tests/prompt-routing-tab-status.test.mjs +108 -0
- package/tests/rpc-supervisor-host.test.mjs +408 -0
- package/tests/rpc-supervisor-protocol.test.mjs +93 -0
- package/tests/rpc-supervisor-state.test.mjs +62 -0
- package/tests/run-all.mjs +4 -1
- package/tests/streaming-ui-coupling.test.mjs +18 -2
- package/tests/subagent-gate-visibility.test.mjs +66 -0
- package/tests/subagent-launch-slots-static.test.mjs +1 -1
- package/tests/subagents-helper.test.mjs +136 -0
- package/tests/terminal-tab-workspace-static.test.mjs +99 -0
- package/tests/workflow-status-stack.test.mjs +87 -0
- package/webui-rpc-helper.mjs +160 -2
|
@@ -0,0 +1,221 @@
|
|
|
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 vm from "node:vm";
|
|
6
|
+
|
|
7
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
8
|
+
const [app, css, html] = await Promise.all([
|
|
9
|
+
readFile(join(root, "public", "app.js"), "utf8"),
|
|
10
|
+
readFile(join(root, "public", "styles.css"), "utf8"),
|
|
11
|
+
readFile(join(root, "public", "index.html"), "utf8"),
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
function sourceBetween(startMarker, endMarker, label) {
|
|
15
|
+
const start = app.indexOf(startMarker);
|
|
16
|
+
const end = app.indexOf(endMarker, start);
|
|
17
|
+
assert.ok(start >= 0 && end > start, `${label} should remain a standalone frontend helper`);
|
|
18
|
+
return app.slice(start, end);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const normalizePathSource = sourceBetween("function normalizeFileTreePath(", "\nfunction fileApiPath(", "normalizeFileTreePath");
|
|
22
|
+
const targetSource = sourceBetween("function gitFileViewerTarget(", "\nasync function openGitFileInViewer(", "gitFileViewerTarget");
|
|
23
|
+
const openSource = sourceBetween("async function openGitFileInViewer(", "\nasync function openGitFileFromChanges(", "openGitFileInViewer");
|
|
24
|
+
const renderSource = sourceBetween("function renderGitPanelFile(", "\nfunction renderGitPanelTreeSection(", "renderGitPanelFile");
|
|
25
|
+
const categorySource = sourceBetween("const GIT_FILE_DIFF_CATEGORY_BY_PANEL = Object.freeze({", "\nasync function loadGitFileChangesSnapshot(", "gitFileDiffCategory");
|
|
26
|
+
const modeSource = sourceBetween("function resolveFileViewerMode(", "\nfunction setFileViewerMode(", "resolveFileViewerMode");
|
|
27
|
+
const setModeSource = sourceBetween("function setFileViewerMode(", "\nfunction setFileViewerDirty(", "setFileViewerMode");
|
|
28
|
+
const viewerUiSource = sourceBetween("function updateFileViewerUi(", "\nfunction fileViewerChangesNotice(", "updateFileViewerUi");
|
|
29
|
+
const changesRenderSource = sourceBetween("function fileViewerChangesNotice(", "\nfunction clearFileViewerSelection(", "file viewer changes rendering");
|
|
30
|
+
const combinedSyntaxSource = sourceBetween("function gitFileDiffUsesCombinedSyntax(", "\nfunction renderFileViewerUntrackedChanges(", "gitFileDiffUsesCombinedSyntax");
|
|
31
|
+
const snapshotSource = sourceBetween("async function loadGitFileChangesSnapshot(", "\nfunction gitFileChangesPlaceholder(", "loadGitFileChangesSnapshot");
|
|
32
|
+
const applySnapshotSource = sourceBetween("function gitFileChangesPlaceholder(", "\nasync function openFileInViewer(", "gitFileChangesPlaceholder");
|
|
33
|
+
const openFileSource = sourceBetween("async function openFileInViewer(", "\nasync function openAurReviewReportInViewer(", "openFileInViewer");
|
|
34
|
+
const closeSource = sourceBetween("function closeFileViewer(", "\n// Side-panel Git categories are UI labels", "closeFileViewer");
|
|
35
|
+
const moveSource = sourceBetween("function updateActiveFileViewerAfterMove(", "\nfunction closeActiveFileViewerIfDeleted(", "updateActiveFileViewerAfterMove");
|
|
36
|
+
|
|
37
|
+
const targets = JSON.parse(vm.runInNewContext(`${normalizePathSource}\n${targetSource}\nJSON.stringify([
|
|
38
|
+
gitFileViewerTarget("sub/active.js", "/repo", [{ tabId: "repo-tab", cwd: "/repo" }]),
|
|
39
|
+
gitFileViewerTarget("other/fallback.js", "/repo", [{ tabId: "repo-tab", cwd: "/repo" }]),
|
|
40
|
+
gitFileViewerTarget("src/windows.js", "C:\\\\Repo", [{ tabId: "windows-tab", cwd: "c:\\\\repo" }]),
|
|
41
|
+
gitFileViewerTarget("root.js", "/", [{ tabId: "root-tab", cwd: "/" }]),
|
|
42
|
+
gitFileViewerTarget("outside.js", "/repo", [{ tabId: "nested-tab", cwd: "/repo/sub" }]),
|
|
43
|
+
])`, {
|
|
44
|
+
activeTab: () => ({ id: "active-tab", cwd: "/repo/sub" }),
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
assert.deepEqual(targets[0], { tabId: "active-tab", path: "active.js" }, "Git files inside the active cwd should stay on the active tab");
|
|
48
|
+
assert.deepEqual(targets[1], { tabId: "repo-tab", path: "other/fallback.js" }, "Git files outside the active cwd should use a repository tab that contains them");
|
|
49
|
+
assert.deepEqual(targets[2], { tabId: "windows-tab", path: "src/windows.js" }, "Git preview path translation should normalize Windows separators and compare drive paths case-insensitively");
|
|
50
|
+
assert.deepEqual(targets[3], { tabId: "root-tab", path: "root.js" }, "filesystem-root workspaces should retain a usable relative viewer path");
|
|
51
|
+
assert.equal(targets[4], null, "Git files outside every available tab cwd should fail closed");
|
|
52
|
+
|
|
53
|
+
assert.match(openSource, /gitFileViewerTarget\(repoRelPath, root, candidates\)/, "Git file opening should use the shared repo-to-workspace path resolver");
|
|
54
|
+
assert.match(openSource, /target\.tabId !== activeTabId[\s\S]*await switchTab\(target\.tabId\)[\s\S]*openFileInViewer\(target\.path/, "Git file opening should activate the owning tab before using the standard WebUI viewer");
|
|
55
|
+
assert.match(openSource, /its terminal tab is no longer available/, "a stale Git-card tab should produce visible failure feedback");
|
|
56
|
+
assert.match(renderSource, /row\.setAttribute\("role", "button"\)/, "Git file rows should expose button semantics");
|
|
57
|
+
assert.match(renderSource, /row\.addEventListener\("click", open\)/, "clicking a Git file row should open its preview");
|
|
58
|
+
assert.match(renderSource, /event\.repeat \|\| \(event\.key !== "Enter" && event\.key !== " "\)/, "Git file rows should support keyboard activation without key-repeat request bursts");
|
|
59
|
+
assert.match(renderSource, /openGitFileInViewer\(entry\.path, \{ root: card\.root, candidates: card\.candidates, category \}\)/, "Git file rows should pass repository and category context to the shared preview flow");
|
|
60
|
+
assert.match(css, /\.git-side-panel-file \{[^}]*cursor: pointer;[^}]*\}/, "Git file rows should visually indicate their primary open action");
|
|
61
|
+
|
|
62
|
+
// --- Changes mode DOM wiring ---
|
|
63
|
+
|
|
64
|
+
assert.match(
|
|
65
|
+
html,
|
|
66
|
+
/<div class="file-viewer-mode-toggle" role="group" aria-label="File view mode">\s*<button id="fileViewerChangesModeButton" type="button" aria-pressed="false" hidden>Changes<\/button>\s*<button id="fileViewerSourceModeButton"/,
|
|
67
|
+
"the file viewer mode toggle should expose a Changes control that is hidden until a Git-originated open supplies one",
|
|
68
|
+
);
|
|
69
|
+
assert.match(
|
|
70
|
+
html,
|
|
71
|
+
/<div class="file-viewer-content">[\s\S]*<div id="fileViewerChanges" class="file-viewer-changes"[^>]*hidden><\/div>\s*<\/div>/,
|
|
72
|
+
"the file viewer content area should own a dedicated, initially hidden Git changes surface",
|
|
73
|
+
);
|
|
74
|
+
assert.match(html, /id="fileViewerChanges"[^>]*aria-label="Git changes for this file"/, "the changes surface should be labelled for assistive technology");
|
|
75
|
+
assert.match(html, /id="fileViewerHelp"[^>]*>Files opened from Git start in Changes mode\./, "the viewer help should explain the Git-specific default mode");
|
|
76
|
+
assert.match(app, /fileViewerChangesModeButton: \$\("#fileViewerChangesModeButton"\)/, "the Changes mode button should be registered in the element map");
|
|
77
|
+
assert.match(app, /fileViewerChanges: \$\("#fileViewerChanges"\)/, "the changes surface should be registered in the element map");
|
|
78
|
+
assert.match(
|
|
79
|
+
app,
|
|
80
|
+
/elements\.fileViewerChangesModeButton\?\.addEventListener\("click", \(\) => setFileViewerMode\("changes"\)\);\nelements\.fileViewerSourceModeButton\?\.addEventListener\("click", \(\) => setFileViewerMode\("source"\)\);\nelements\.fileViewerPreviewModeButton\?\.addEventListener\("click", \(\) => setFileViewerMode\("preview"\)\);/,
|
|
81
|
+
"Changes mode should be selectable alongside the untouched Source and Preview controls",
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
// --- Mode resolution: default selection, availability, and isolation ---
|
|
85
|
+
|
|
86
|
+
const modes = JSON.parse(vm.runInNewContext(`${modeSource}\nJSON.stringify([
|
|
87
|
+
resolveFileViewerMode({ mode: "changes", gitChanges: { category: "unstaged" }, language: "text" }),
|
|
88
|
+
resolveFileViewerMode({ mode: "changes", gitChanges: null, language: "text" }),
|
|
89
|
+
resolveFileViewerMode({ mode: "source", gitChanges: { category: "unstaged" }, language: "text" }),
|
|
90
|
+
resolveFileViewerMode({ mode: "preview", gitChanges: { category: "unstaged" }, language: "markdown" }),
|
|
91
|
+
resolveFileViewerMode({ mode: "preview", language: "markdown" }),
|
|
92
|
+
resolveFileViewerMode({ mode: "preview", language: "text" }),
|
|
93
|
+
resolveFileViewerMode({ mode: "source", language: "markdown" }),
|
|
94
|
+
resolveFileViewerMode({ mode: "source", sourceAvailable: false, gitChanges: { category: "staged" }, language: "text" }),
|
|
95
|
+
resolveFileViewerMode({ mode: "source", sourceAvailable: false, language: "text" }),
|
|
96
|
+
resolveFileViewerMode(null),
|
|
97
|
+
])`, {}));
|
|
98
|
+
|
|
99
|
+
assert.equal(modes[0], "changes", "a Git-originated viewer should stay in Changes mode when requested");
|
|
100
|
+
assert.equal(modes[1], "source", "Changes mode should fall back to Source when the viewer has no Git snapshot");
|
|
101
|
+
assert.equal(modes[2], "source", "a Git-originated viewer should still allow the live Source view");
|
|
102
|
+
assert.equal(modes[3], "preview", "Markdown Preview should remain reachable for Git-originated Markdown files");
|
|
103
|
+
assert.equal(modes[4], "preview", "normal Markdown opens should keep their Preview default");
|
|
104
|
+
assert.equal(modes[5], "source", "Preview should degrade to Source for non-Markdown files");
|
|
105
|
+
assert.equal(modes[6], "source", "Source stays Source for Markdown when explicitly selected");
|
|
106
|
+
assert.equal(modes[7], "changes", "a deleted tracked file without live source should resolve to Changes");
|
|
107
|
+
assert.equal(modes[8], "source", "a missing source without any Git snapshot should not invent a Changes view");
|
|
108
|
+
assert.equal(modes[9], "source", "mode resolution should fail closed without a viewer");
|
|
109
|
+
|
|
110
|
+
assert.match(setModeSource, /activeFileViewer\.mode = resolveFileViewerMode\(\{ \.\.\.activeFileViewer, mode \}\);/, "mode switching should route every request through the shared resolver");
|
|
111
|
+
assert.match(setModeSource, /if \(activeFileViewer\.mode === "changes" && previousMode !== "changes"\) clearFileViewerSelection\(\);/, "entering Changes mode should clear a stale Source or Preview selection bar");
|
|
112
|
+
assert.match(viewerUiSource, /const hasChanges = !!viewer\.gitChanges;/, "the viewer UI should derive Changes availability from the open-time snapshot");
|
|
113
|
+
assert.match(viewerUiSource, /elements\.fileViewerChangesModeButton\.hidden = !hasChanges;\s*elements\.fileViewerChangesModeButton\.disabled = !hasChanges;/, "the Changes control should stay hidden and disabled for non-Git opens");
|
|
114
|
+
assert.match(viewerUiSource, /elements\.fileViewerSourceModeButton\.disabled = !sourceAvailable;/, "Source should be disabled when the live file content is unavailable");
|
|
115
|
+
assert.match(viewerUiSource, /elements\.fileViewerPreviewModeButton\.hidden = !isMarkdown;\s*elements\.fileViewerPreviewModeButton\.disabled = !isMarkdown \|\| !sourceAvailable;/, "Markdown Preview should stay hidden for non-Markdown and disabled when live source is unavailable");
|
|
116
|
+
assert.match(viewerUiSource, /elements\.fileViewerEditor\.hidden = mode !== "source";/, "Source editing should remain bound to Source mode");
|
|
117
|
+
assert.match(
|
|
118
|
+
viewerUiSource,
|
|
119
|
+
/elements\.fileViewerChanges\.hidden = mode !== "changes";\s*if \(mode === "changes"\) renderFileViewerChanges\(viewer\.gitChanges\);\s*else elements\.fileViewerChanges\.replaceChildren\(\);/,
|
|
120
|
+
"the changes surface should render only in Changes mode and clear itself otherwise",
|
|
121
|
+
);
|
|
122
|
+
assert.match(viewerUiSource, /elements\.fileViewerSaveButton\.disabled = viewer\.readOnly === true \|\| !viewer\.dirty;/, "save semantics should stay tied to read-only and dirty state");
|
|
123
|
+
assert.match(viewerUiSource, /\["source unavailable"\]/, "a viewer without live content should say so in its metadata line");
|
|
124
|
+
|
|
125
|
+
// --- Category mapping ---
|
|
126
|
+
|
|
127
|
+
const categories = JSON.parse(vm.runInNewContext(`${categorySource}\nJSON.stringify([
|
|
128
|
+
gitFileDiffCategory("staged"),
|
|
129
|
+
gitFileDiffCategory("changes"),
|
|
130
|
+
gitFileDiffCategory("conflicted"),
|
|
131
|
+
gitFileDiffCategory("untracked"),
|
|
132
|
+
gitFileDiffCategory("history"),
|
|
133
|
+
gitFileDiffCategory(""),
|
|
134
|
+
gitFileDiffCategory(),
|
|
135
|
+
])`, {}));
|
|
136
|
+
|
|
137
|
+
assert.deepEqual(
|
|
138
|
+
categories,
|
|
139
|
+
["staged", "unstaged", "conflicted", "untracked", "", "", ""],
|
|
140
|
+
"side-panel categories should map onto the allowlisted API categories and fail closed for anything else",
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
// --- Backend request contract ---
|
|
144
|
+
|
|
145
|
+
assert.match(snapshotSource, /new URLSearchParams\(\{ path: repoRelPath, category \}\)/, "the changes request should send the repo-relative path and the mapped category");
|
|
146
|
+
assert.match(snapshotSource, /api\(`\/api\/git-file-diff\?\$\{params\.toString\(\)\}`, \{ tabId \}\)/, "the changes request should call the read-only Git file diff endpoint on the owning tab");
|
|
147
|
+
assert.match(snapshotSource, /if \(!response\.ok\) throw new Error\(response\.error \|\| "Failed to load Git changes for this file"\)/, "an ok:false response should surface a readable error");
|
|
148
|
+
assert.match(snapshotSource, /truncated: data\.truncated === true/, "truncation should be carried into the viewer snapshot");
|
|
149
|
+
assert.match(snapshotSource, /contentError: data\.error \? String\(data\.error\) : ""/, "an untracked read error should stay distinct from a request failure");
|
|
150
|
+
assert.match(snapshotSource, /return \{ \.\.\.snapshot, error: error\.message \|\| String\(error\) \};/, "a failed changes request should resolve to an error snapshot instead of rejecting the open");
|
|
151
|
+
assert.match(app, /let fileViewerGitChangesRequestSerial = 0;/, "Git changes opens should have a request identity counter");
|
|
152
|
+
assert.match(applySnapshotSource, /loading: true, requestSerial/, "the viewer should show an identified loading snapshot until the bounded diff arrives");
|
|
153
|
+
assert.match(
|
|
154
|
+
applySnapshotSource,
|
|
155
|
+
/if \(!isCurrentTabContext\(tabContext\)\) return;\s*if \(!activeFileViewer\?\.gitChanges\?\.loading \|\| activeFileViewer\.path !== viewerPath \|\| activeFileViewer\.gitChanges\.requestSerial !== requestSerial\) return;/,
|
|
156
|
+
"a late diff response should be discarded when the tab, viewer, or same-path request identity changed",
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
// --- Open flow: Git default, normal-open isolation, deleted files ---
|
|
160
|
+
|
|
161
|
+
assert.match(openSource, /category = "" \} = \{\}/, "Git opens should accept an optional side-panel category");
|
|
162
|
+
assert.match(openSource, /openFileInViewer\(target\.path, \{ gitCategory: category, gitPath: normalizeFileTreePath\(repoRelPath\) \}\)/, "Git opens should hand the category and repo path to the standard viewer");
|
|
163
|
+
assert.match(openFileSource, /async function openFileInViewer\(path = "", \{ gitCategory = "", gitPath = "" \} = \{\}\)/, "the standard viewer should accept optional Git context without changing its default signature");
|
|
164
|
+
assert.match(app, /let fileViewerOpenRequestSerial = 0;/, "file viewer opens should have a shared request identity counter");
|
|
165
|
+
assert.match(openFileSource, /const openRequestSerial = \+\+fileViewerOpenRequestSerial;/, "every viewer open should capture a unique request identity");
|
|
166
|
+
assert.match(openFileSource, /const category = gitFileDiffCategory\(gitCategory\);/, "the viewer should map the side-panel category through the shared allowlist");
|
|
167
|
+
assert.match(openFileSource, /const changesRequestSerial = category \? \+\+fileViewerGitChangesRequestSerial : 0;/, "each Git-originated open should receive a unique changes request identity");
|
|
168
|
+
assert.match(openFileSource, /const changesRequest = category \? loadGitFileChangesSnapshot\(changesPath, category, tabContext\.tabId\) : null;/, "only category-carrying opens should request a diff");
|
|
169
|
+
assert.match(openFileSource, /const gitChanges = changesRequest \? gitFileChangesPlaceholder\(category, changesPath, changesRequestSerial\) : null;/, "normal File-section opens should carry no Git snapshot at all");
|
|
170
|
+
assert.match(openFileSource, /applyGitFileChangesSnapshot\(changesRequest, tabContext, activeFileViewer\.path, changesRequestSerial\)/, "same-path Git requests should apply only through their captured request identity");
|
|
171
|
+
assert.match(openFileSource, /mode: gitChanges \? "changes" : data\.language === "markdown" \? "preview" : "source",/, "Git opens should default to Changes while normal opens keep the Markdown/Source default");
|
|
172
|
+
assert.match(openFileSource, /if \(!isCurrentTabContext\(tabContext\) \|\| openRequestSerial !== fileViewerOpenRequestSerial\) return;/, "the source-success path should reject stale same-tab viewer opens");
|
|
173
|
+
assert.match(openFileSource, /const gitChanges = changesRequest \? await changesRequest : null;\s*if \(!isCurrentTabContext\(tabContext\) \|\| openRequestSerial !== fileViewerOpenRequestSerial\) return;/, "the deleted-file fallback should reject stale same-tab viewer opens after awaiting the diff");
|
|
174
|
+
assert.match(openFileSource, /readOnly: false,\s*sourceAvailable: true,/, "a live Git-originated file should stay editable");
|
|
175
|
+
assert.match(
|
|
176
|
+
openFileSource,
|
|
177
|
+
/const gitChanges = changesRequest \? await changesRequest : null;\s*if \(!isCurrentTabContext\(tabContext\) \|\| openRequestSerial !== fileViewerOpenRequestSerial\) return;\s*if \(gitChanges && !gitChanges\.error\) \{/,
|
|
178
|
+
"a current failed source load should fall back to the diff only when that diff actually loaded",
|
|
179
|
+
);
|
|
180
|
+
assert.match(openFileSource, /mode: "changes",\s*dirty: false,\s*readOnly: true,\s*sourceAvailable: false,/, "a deleted tracked file should open read-only in Changes mode");
|
|
181
|
+
assert.match(openFileSource, /setFileViewerStatus\("File content unavailable; showing Git changes \(read-only\)\.", "warn"\)/, "the deleted-file fallback should explain itself in the viewer status");
|
|
182
|
+
assert.match(openFileSource, /setFileViewerStatus\(message, "error"\);\s*addEvent\(`file open failed: \$\{message\}`, "error"\);/, "a total failure should still report the original open error");
|
|
183
|
+
assert.match(closeSource, /fileViewerOpenRequestSerial \+= 1;\s*activeFileViewer = null;/, "closing the viewer should invalidate pending source and deleted-file opens");
|
|
184
|
+
assert.match(closeSource, /elements\.fileViewerChanges\.hidden = true;\s*elements\.fileViewerChanges\.replaceChildren\(\);/, "closing the viewer should clear the changes surface");
|
|
185
|
+
assert.match(moveSource, /gitChanges: null,/, "renaming the open file should drop its stale open-time diff snapshot");
|
|
186
|
+
|
|
187
|
+
// --- Changes rendering contracts ---
|
|
188
|
+
|
|
189
|
+
const combined = JSON.parse(vm.runInNewContext(`${combinedSyntaxSource}\nJSON.stringify([
|
|
190
|
+
gitFileDiffUsesCombinedSyntax("@@@ -1,4 -1,4 +1,6 @@@\\n context"),
|
|
191
|
+
gitFileDiffUsesCombinedSyntax("diff --git a/x b/x\\n@@ -1,2 +1,3 @@\\n context"),
|
|
192
|
+
gitFileDiffUsesCombinedSyntax(""),
|
|
193
|
+
])`, {}));
|
|
194
|
+
|
|
195
|
+
assert.deepEqual(combined, [true, false, false], "combined conflict hunks should be detected while ordinary unified hunks stay on the split renderer");
|
|
196
|
+
|
|
197
|
+
assert.match(changesRenderSource, /make\("section", `git-diff-section file-viewer-changes-section \$\{snapshot\.category \|\| ""\}`\.trim\(\)\)/, "the changes surface should reuse the shared Git diff section shell");
|
|
198
|
+
assert.match(changesRenderSource, /if \(snapshot\.loading\) wrapper\.append\(fileViewerChangesNotice\("Loading Git changes…"\)\);/, "a pending diff should render an explicit loading state");
|
|
199
|
+
assert.match(changesRenderSource, /else if \(snapshot\.error\) wrapper\.append\(fileViewerChangesNotice\(snapshot\.error, "error"\)\);/, "a failed diff should render an in-viewer error state");
|
|
200
|
+
assert.match(
|
|
201
|
+
changesRenderSource,
|
|
202
|
+
/wrapper\.append\(snapshot\.category === "untracked" \? renderFileViewerUntrackedChanges\(snapshot\) : renderFileViewerTrackedChanges\(snapshot\)\);/,
|
|
203
|
+
"untracked files should use whole-file rendering while tracked categories use the diff renderer",
|
|
204
|
+
);
|
|
205
|
+
assert.match(changesRenderSource, /if \(snapshot\.truncated\) wrapper\.append\(renderFileViewerChangesTruncation\(snapshot\)\);/, "a truncated snapshot should be flagged in the viewer");
|
|
206
|
+
assert.match(changesRenderSource, /make\("div", "git-diff-truncated-notice"\)[\s\S]*formatBytes\(snapshot\.capBytes \|\| 0\)[\s\S]*make\("code", "git-tools-command", snapshot\.command \|\| "git diff"\)/, "the truncation notice should name the cap and the exact command");
|
|
207
|
+
assert.match(changesRenderSource, /if \(!diff\.trim\(\)\) return fileViewerChangesNotice\(`No \$\{String\(snapshot\.label \|\| "Git"\)\.toLowerCase\(\)\} changes for this file\.`\)/, "an empty diff should render an explicit empty state");
|
|
208
|
+
assert.match(changesRenderSource, /if \(gitFileDiffUsesCombinedSyntax\(diff\)\) return make\("pre", "git-diff-raw", diff\);/, "combined conflict syntax should fall back to readable raw diff text");
|
|
209
|
+
assert.match(changesRenderSource, /const files = parseGitUnifiedDiff\(diff\);[\s\S]*for \(const file of files\) fragment\.append\(renderGitDiffFile\(file\)\);/, "parsed diffs should render through the existing split Git grid");
|
|
210
|
+
assert.match(changesRenderSource, /if \(!files\.length\) return make\("pre", "git-diff-raw", diff\);/, "an unparsable diff should still show its raw text");
|
|
211
|
+
assert.match(changesRenderSource, /if \(entry\.error \|\| entry\.binary\) return renderGitUntrackedRawFile\(entry\);/, "binary or unreadable untracked files should show the shared notice instead of fake diff lines");
|
|
212
|
+
assert.match(changesRenderSource, /return renderGitDiffFile\(gitUntrackedEntryToDiffFile\(entry\)\);/, "verified untracked text should render as all-added lines");
|
|
213
|
+
assert.match(changesRenderSource, /if \(entry\.contentMissing\) return fileViewerChangesNotice\("Untracked file content is unavailable\.", "error"\);/, "an untracked response without content should not pretend the file is empty");
|
|
214
|
+
assert.doesNotMatch(changesRenderSource, /runGitFileAction|gitChangesFileActionsFor|gitFileActionButtons/, "the read-only changes surface must not expose staging or discard actions");
|
|
215
|
+
|
|
216
|
+
assert.match(css, /\.file-viewer-editor,\n\.file-viewer-preview,\n\.file-viewer-changes \{/, "the changes surface should share the file viewer content frame");
|
|
217
|
+
assert.match(css, /\.file-viewer-changes \{\n\s*padding: 0\.72rem;\n\}/, "the changes surface should have its own padding inside the shared frame");
|
|
218
|
+
assert.match(css, /\.file-viewer-changes \.git-diff-grid \{[\s\S]*grid-template-columns:[\s\S]*min-width: 30rem;[\s\S]*\}/, "the split diff grid should be narrowed for the file viewer pane");
|
|
219
|
+
assert.match(css, /\.file-viewer-changes-notice \{[\s\S]*font-size: var\(--text-xs\);[\s\S]*\}\n\.file-viewer-changes-notice\.error \{ color: var\(--ctp-red\); \}/, "changes notices should be readable and mark errors distinctly");
|
|
220
|
+
|
|
221
|
+
console.log("git panel file preview static tests passed");
|
|
@@ -15,6 +15,8 @@ function functionBody(name) {
|
|
|
15
15
|
|
|
16
16
|
const renderGitPanel = functionBody("renderGitPanel");
|
|
17
17
|
const renderGitPanelFolder = functionBody("renderGitPanelFolder");
|
|
18
|
+
const renderGitPanelRepositoryCard = functionBody("renderGitPanelRepositoryCard");
|
|
19
|
+
const updateGitPanelRepositoryMeta = functionBody("updateGitPanelRepositoryMeta");
|
|
18
20
|
const renderContextMeter = functionBody("renderContextMeter");
|
|
19
21
|
const renderWorkspaceDashboard = functionBody("renderWorkspaceDashboard");
|
|
20
22
|
|
|
@@ -29,8 +31,16 @@ assert.doesNotMatch(renderGitPanel, /\bsectionExpanded\b/, "Git panel signature
|
|
|
29
31
|
const gitGuard = renderGitPanel.indexOf("signature === gitPanelRenderSignature");
|
|
30
32
|
const gitRebuild = renderGitPanel.indexOf("elements.gitPanelGroups.replaceChildren");
|
|
31
33
|
assert.ok(gitGuard > 0 && gitGuard < gitRebuild, "Git panel signature guard should precede its DOM rebuild");
|
|
32
|
-
assert.
|
|
34
|
+
assert.doesNotMatch(renderGitPanel, /snapshot\?\.loadedAt|data\?\.generatedAt/, "Git panel signature should ignore refresh timestamps");
|
|
35
|
+
assert.match(renderGitPanel, /!data && !!snapshot\?\.loading/, "initial repository loads should still update their loading state");
|
|
36
|
+
assert.match(renderGitPanel, /gitPanelDataRenderSignature\(data\)/, "Git panel signature should still track rendered repository data");
|
|
33
37
|
assert.match(renderGitPanel, /gitPanelState\.activeViews\.get/, "Git panel signature should include active repository views");
|
|
38
|
+
assert.match(renderGitPanelRepositoryCard, /section\.dataset\.gitRoot = card\.root;/, "repository cards should expose a stable root for targeted metadata updates");
|
|
39
|
+
assert.match(updateGitPanelRepositoryMeta, /\.git-side-panel-repository-updated/, "refresh state should target only the update-time label");
|
|
40
|
+
assert.match(updateGitPanelRepositoryMeta, /snapshot\.loading \? "Refreshing…" : `Updated /, "the targeted label should reflect refresh progress and completion time");
|
|
41
|
+
|
|
42
|
+
const gitMetaUpdate = renderGitPanel.indexOf("updateGitPanelRepositoryMeta(cards)");
|
|
43
|
+
assert.ok(gitMetaUpdate > gitGuard && gitMetaUpdate < gitRebuild, "unchanged Git content should update metadata before returning without a DOM rebuild");
|
|
34
44
|
|
|
35
45
|
const contextGuard = renderContextMeter.indexOf("signature === contextMeterSignature");
|
|
36
46
|
const contextRebuild = renderContextMeter.lastIndexOf("root.replaceChildren");
|