pi-odd-worktree 3.15.1 → 3.16.0
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 +48 -25
- package/extensions/odd-worktree-tools.ts +64 -211
- package/lib/shell-api/api.ts +523 -0
- package/lib/shell-api/arm.ts +83 -0
- package/lib/shell-api/bus.ts +1389 -0
- package/lib/shell-api/capture.ts +1340 -0
- package/lib/shell-api/card-style-line.ts +112 -0
- package/lib/shell-api/card-style-rows.ts +390 -0
- package/lib/shell-api/card-style-transform.ts +862 -0
- package/lib/shell-api/card-style-wiring.ts +477 -0
- package/lib/shell-api/card-styles.ts +153 -0
- package/lib/shell-api/config.ts +71 -0
- package/lib/shell-api/extension.ts +247 -0
- package/lib/shell-api/hook.ts +322 -0
- package/lib/shell-api/index.ts +88 -0
- package/lib/shell-api/message-design-adoption.ts +549 -0
- package/lib/shell-api/message-design-rows.ts +313 -0
- package/lib/shell-api/message-design-wiring.ts +369 -0
- package/lib/shell-api/message-designs.ts +746 -0
- package/lib/shell-api/notices.ts +137 -0
- package/lib/shell-api/plugin-lines.ts +877 -0
- package/lib/shell-api/presence.ts +258 -0
- package/lib/shell-api/repaint.ts +351 -0
- package/lib/shell-api/row-labels.ts +146 -0
- package/lib/shell-api/row-names.ts +273 -0
- package/lib/shell-api/row-origin.ts +144 -0
- package/lib/shell-api/rows.ts +591 -0
- package/lib/shell-api/section-panel.ts +378 -0
- package/lib/shell-api/section-pointer.ts +164 -0
- package/lib/shell-api/sections-preview.ts +275 -0
- package/lib/shell-api/sections-rows.ts +133 -0
- package/lib/shell-api/sidebar-render.ts +705 -0
- package/lib/shell-api/sidebar.ts +1126 -0
- package/lib/shell-api/store.ts +279 -0
- package/lib/shell-api/tool-design-adoption.ts +263 -0
- package/lib/shell-api/tool-design-rows.ts +307 -0
- package/lib/shell-api/tool-design-wiring.ts +481 -0
- package/lib/shell-api/tool-designs.ts +1411 -0
- package/lib/shell-api/transform-pipeline.ts +351 -0
- package/lib/shell-api/types.ts +803 -0
- package/lib/shell-api/visibility.ts +154 -0
- package/package.json +3 -2
- package/tools/files-bridge.test.js +81 -66
- package/tools/fixtures/load-extension.js +40 -18
- package/tools/issues-command.test.js +4 -7
- package/tools/issues-section.test.js +71 -81
- package/tools/odd-rail-wiring.test.js +16 -10
- package/tools/package-surface.test.js +42 -13
- package/tools/prs-command.test.js +11 -6
- package/tools/shell-api/api.test.ts +484 -0
- package/tools/shell-api/apply-on-move.test.ts +529 -0
- package/tools/shell-api/arm.test.ts +220 -0
- package/tools/shell-api/bridge-ready.test.ts +309 -0
- package/tools/shell-api/bus.test.ts +194 -0
- package/tools/shell-api/button-rows.test.ts +435 -0
- package/tools/shell-api/capture.test.ts +583 -0
- package/tools/shell-api/card-style-rows.test.ts +493 -0
- package/tools/shell-api/card-style-transform.test.ts +379 -0
- package/tools/shell-api/card-style-wiring.test.ts +258 -0
- package/tools/shell-api/card-styles-e2e.test.ts +502 -0
- package/tools/shell-api/card-styles.test.ts +324 -0
- package/tools/shell-api/card-transcript-path.test.ts +178 -0
- package/tools/shell-api/compatibility-regression.test.mjs +64 -0
- package/tools/shell-api/config.test.ts +93 -0
- package/tools/shell-api/docs-coverage.test.ts +82 -0
- package/tools/shell-api/e2e.test.ts +562 -0
- package/tools/shell-api/example-bash-identity.test.ts +372 -0
- package/tools/shell-api/example-bash-matrix.test.ts +856 -0
- package/tools/shell-api/example-designs.test.ts +737 -0
- package/tools/shell-api/example-neon-transform.test.ts +283 -0
- package/tools/shell-api/example-plain-style.test.ts +1225 -0
- package/tools/shell-api/extension.test.ts +157 -0
- package/tools/shell-api/fake-events.ts +58 -0
- package/tools/shell-api/fake-host.ts +211 -0
- package/tools/shell-api/fake-sidebar.ts +516 -0
- package/tools/shell-api/fake-transcript.ts +486 -0
- package/tools/shell-api/frame-telemetry.test.ts +317 -0
- package/tools/shell-api/hook.test.ts +196 -0
- package/tools/shell-api/manifest.test.ts +47 -0
- package/tools/shell-api/message-design-adoption.test.ts +611 -0
- package/tools/shell-api/message-design-follows.test.ts +361 -0
- package/tools/shell-api/message-design-pi-release.test.mjs +157 -0
- package/tools/shell-api/message-design-regressions.test.mjs +162 -0
- package/tools/shell-api/message-design-rows.test.ts +266 -0
- package/tools/shell-api/message-design-wiring.test.ts +362 -0
- package/tools/shell-api/message-designs.test.ts +339 -0
- package/tools/shell-api/new-category.test.ts +1101 -0
- package/tools/shell-api/notices.test.ts +292 -0
- package/tools/shell-api/plugin-integration-lines.test.ts +827 -0
- package/tools/shell-api/presence.test.ts +396 -0
- package/tools/shell-api/rail-part-hits.test.ts +281 -0
- package/tools/shell-api/rail-surfaces.test.ts +402 -0
- package/tools/shell-api/rail-width.test.ts +406 -0
- package/tools/shell-api/regression.test.ts +434 -0
- package/tools/shell-api/repaint-api.test.ts +200 -0
- package/tools/shell-api/reserved-categories.test.ts +250 -0
- package/tools/shell-api/row-labels.test.ts +261 -0
- package/tools/shell-api/row-names.test.ts +407 -0
- package/tools/shell-api/row-origin.test.ts +395 -0
- package/tools/shell-api/row-placement-regression.test.ts +797 -0
- package/tools/shell-api/row-placement.test.ts +410 -0
- package/tools/shell-api/section-interaction.test.ts +364 -0
- package/tools/shell-api/section-panel.test.ts +430 -0
- package/tools/shell-api/section-placement-rail.test.ts +390 -0
- package/tools/shell-api/section-placement.test.ts +386 -0
- package/tools/shell-api/sections-preview.test.ts +312 -0
- package/tools/shell-api/sections-rows.test.ts +293 -0
- package/tools/shell-api/sidebar-backend.test.ts +477 -0
- package/tools/shell-api/sidebar-e2e.test.ts +317 -0
- package/tools/shell-api/sidebar-hover.test.ts +276 -0
- package/tools/shell-api/sidebar-independent.test.ts +291 -0
- package/tools/shell-api/sidebar-render.test.ts +281 -0
- package/tools/shell-api/sidebar-sections.test.ts +247 -0
- package/tools/shell-api/store.test.ts +192 -0
- package/tools/shell-api/surface-repaint-cost.test.ts +520 -0
- package/tools/shell-api/tool-design-card-style.test.ts +308 -0
- package/tools/shell-api/tool-design-chain.test.ts +471 -0
- package/tools/shell-api/tool-design-cost.test.ts +591 -0
- package/tools/shell-api/tool-design-rows.test.ts +627 -0
- package/tools/shell-api/tool-design-scopes-audit.test.ts +212 -0
- package/tools/shell-api/tool-designs.test.ts +2412 -0
- package/tools/shell-api/transform-pipeline.test.ts +376 -0
- package/tools/shell-api/transforms-bus.test.ts +233 -0
- package/tools/shell-api/verifier-width-regressions.test.ts +147 -0
- package/tools/shell-api-rpc.test.js +189 -0
- package/tools/user-prompt-card.test.js +8 -9
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Section placement, end to end through the fake host: the rail wrapper on every painted part
|
|
3
|
+
* (S1–S8).
|
|
4
|
+
*
|
|
5
|
+
* `test/fake-sidebar.ts` owns the rail map and the frame, so these tests drive it exactly the way
|
|
6
|
+
* the layout does: register the native parts, arm the bridge, render, and look at the cards the rail
|
|
7
|
+
* would show. Row ranges are asserted through the pointer path, which is the only consumer of them.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import assert from "node:assert/strict";
|
|
11
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import test from "node:test";
|
|
15
|
+
|
|
16
|
+
import { registerSection, resetBusForTests, resetSectionsForTests } from "../../lib/shell-api/bus.ts";
|
|
17
|
+
import { setRepaintHost, resetRepaintForTests } from "../../lib/shell-api/repaint.ts";
|
|
18
|
+
import { resetSectionPanelForTests } from "../../lib/shell-api/section-panel.ts";
|
|
19
|
+
import { resetSectionPointerForTests } from "../../lib/shell-api/section-pointer.ts";
|
|
20
|
+
import {
|
|
21
|
+
disableSidebarBackend,
|
|
22
|
+
getSidebarDiagnostics,
|
|
23
|
+
installSidebarBackend,
|
|
24
|
+
observedPaintedParts,
|
|
25
|
+
resetSidebarStateForTests,
|
|
26
|
+
} from "../../lib/shell-api/sidebar.ts";
|
|
27
|
+
import {
|
|
28
|
+
installSectionRail,
|
|
29
|
+
resetSectionFailuresForTests,
|
|
30
|
+
} from "../../lib/shell-api/sidebar-render.ts";
|
|
31
|
+
import { resetStoreStateForTests } from "../../lib/shell-api/store.ts";
|
|
32
|
+
import { setSectionVisible } from "../../lib/shell-api/visibility.ts";
|
|
33
|
+
import { RAIL_PARTS } from "../../lib/shell-api/types.ts";
|
|
34
|
+
import type { SidebarSection } from "../../lib/shell-api/types.ts";
|
|
35
|
+
import {
|
|
36
|
+
cardTitles,
|
|
37
|
+
fakeState,
|
|
38
|
+
fakeTui,
|
|
39
|
+
registerNativeFooter,
|
|
40
|
+
registerNativeRail,
|
|
41
|
+
renderSidebar,
|
|
42
|
+
resetSidebar,
|
|
43
|
+
type Rail,
|
|
44
|
+
} from "./fake-sidebar.ts";
|
|
45
|
+
|
|
46
|
+
let configHome: string;
|
|
47
|
+
let previousConfigHome: string | undefined;
|
|
48
|
+
|
|
49
|
+
test.before(() => {
|
|
50
|
+
configHome = mkdtempSync(join(tmpdir(), "gsb-placement-rail-"));
|
|
51
|
+
previousConfigHome = process.env.GENTLE_PI_CONFIG_HOME;
|
|
52
|
+
process.env.GENTLE_PI_CONFIG_HOME = configHome;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test.after(() => {
|
|
56
|
+
if (previousConfigHome === undefined) delete process.env.GENTLE_PI_CONFIG_HOME;
|
|
57
|
+
else process.env.GENTLE_PI_CONFIG_HOME = previousConfigHome;
|
|
58
|
+
rmSync(configHome, { recursive: true, force: true });
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test.beforeEach(() => {
|
|
62
|
+
rmSync(join(configHome, "gentle-shell-bridge"), { recursive: true, force: true });
|
|
63
|
+
resetBusForTests();
|
|
64
|
+
resetSectionsForTests();
|
|
65
|
+
resetSidebar();
|
|
66
|
+
resetSidebarStateForTests();
|
|
67
|
+
resetSectionFailuresForTests();
|
|
68
|
+
resetSectionPanelForTests();
|
|
69
|
+
resetSectionPointerForTests();
|
|
70
|
+
resetRepaintForTests();
|
|
71
|
+
resetStoreStateForTests();
|
|
72
|
+
disableSidebarBackend();
|
|
73
|
+
setRepaintHost(undefined);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const section = (id: string, extra: Partial<SidebarSection> = {}): SidebarSection => ({
|
|
77
|
+
id,
|
|
78
|
+
title: id.toUpperCase(),
|
|
79
|
+
lines: () => [`body ${id}`],
|
|
80
|
+
...extra,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
/** A native part the way the host registers one: one card, its first row the heading. */
|
|
84
|
+
function nativePart(title: string, body: readonly string[] = [`${title} row`]): Rail {
|
|
85
|
+
const lines = [`▾ ${title}`, ...body];
|
|
86
|
+
return {
|
|
87
|
+
render: () => [...lines],
|
|
88
|
+
cardGroups: () => ({ groups: [{ start: 0, end: lines.length }] }),
|
|
89
|
+
digest: () => `${title}:native`,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Every painted part registered, in the host's own paint order. */
|
|
94
|
+
function registerAllParts(): void {
|
|
95
|
+
registerNativeRail("todo", nativePart("TODO"));
|
|
96
|
+
registerNativeRail("jobs", nativePart("JOBS"));
|
|
97
|
+
registerNativeRail("agents", nativePart("AGENTS"));
|
|
98
|
+
registerNativeFooter(nativePart("FOOTER"));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function arm(): void {
|
|
102
|
+
installSidebarBackend(() => fakeTui());
|
|
103
|
+
installSectionRail();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// ---------------------------------------------------------------------------------------------
|
|
107
|
+
// S1, S5 — a card can sit before the first native part or after a middle one.
|
|
108
|
+
// ---------------------------------------------------------------------------------------------
|
|
109
|
+
|
|
110
|
+
test("start draws its card before the first native part, not after the last one", () => {
|
|
111
|
+
registerAllParts();
|
|
112
|
+
registerSection(section("top", { title: "TOP", placement: "start" }));
|
|
113
|
+
arm();
|
|
114
|
+
|
|
115
|
+
assert.deepEqual(cardTitles(), ["TOP", "TODO", "JOBS", "AGENTS", "FOOTER"]);
|
|
116
|
+
assert.ok(
|
|
117
|
+
renderSidebar(40).findIndex((row) => row.includes("TOP")) <
|
|
118
|
+
renderSidebar(40).findIndex((row) => row.includes("TODO")),
|
|
119
|
+
"the card is above the host's first part too",
|
|
120
|
+
);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test("after a middle native part draws between that part and the next one", () => {
|
|
124
|
+
registerAllParts();
|
|
125
|
+
registerSection(section("news", { title: "NEWS", placement: { after: "jobs" } }));
|
|
126
|
+
arm();
|
|
127
|
+
|
|
128
|
+
assert.deepEqual(cardTitles(), ["TODO", "JOBS", "NEWS", "AGENTS", "FOOTER"]);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test("a section that keeps its default still lands after every native part", () => {
|
|
132
|
+
registerAllParts();
|
|
133
|
+
registerSection(section("plain", { title: "PLAIN" }));
|
|
134
|
+
arm();
|
|
135
|
+
|
|
136
|
+
assert.deepEqual(cardTitles(), ["TODO", "JOBS", "AGENTS", "FOOTER", "PLAIN"]);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test("sections before and after the host's rows share one part's frame", () => {
|
|
140
|
+
registerAllParts();
|
|
141
|
+
registerSection(section("top", { title: "TOP", placement: "start" }));
|
|
142
|
+
registerSection(section("plain", { title: "PLAIN" }));
|
|
143
|
+
arm();
|
|
144
|
+
|
|
145
|
+
// TODO carries our before-block, FOOTER carries our after-block: two parts, four frames.
|
|
146
|
+
assert.deepEqual(cardTitles(), ["TOP", "TODO", "JOBS", "AGENTS", "FOOTER", "PLAIN"]);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// ---------------------------------------------------------------------------------------------
|
|
150
|
+
// S5 — the fallbacks are decided by RENDER, and the report says where a card really went.
|
|
151
|
+
// ---------------------------------------------------------------------------------------------
|
|
152
|
+
|
|
153
|
+
test("a hidden native part moves start to the next painted part", () => {
|
|
154
|
+
registerAllParts();
|
|
155
|
+
fakeState().visibility = { todo: false };
|
|
156
|
+
registerSection(section("top", { title: "TOP", placement: "start" }));
|
|
157
|
+
arm();
|
|
158
|
+
|
|
159
|
+
assert.deepEqual(observedPaintedParts(), ["jobs", "agents", "footer"]);
|
|
160
|
+
assert.deepEqual(cardTitles(), ["TOP", "JOBS", "AGENTS", "FOOTER"]);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test("hiding a section does not move the sections placed after it", () => {
|
|
164
|
+
registerAllParts();
|
|
165
|
+
registerSection(section("anchor", { title: "ANCHOR", placement: "start" }));
|
|
166
|
+
registerSection(section("follower", { title: "FOLLOWER", placement: { after: "anchor" } }));
|
|
167
|
+
arm();
|
|
168
|
+
assert.deepEqual(cardTitles(), ["ANCHOR", "FOLLOWER", "TODO", "JOBS", "AGENTS", "FOOTER"]);
|
|
169
|
+
|
|
170
|
+
// The user hides the anchor from `Sections`. Its follower stays where the anchor was.
|
|
171
|
+
setSectionVisible("anchor", false);
|
|
172
|
+
|
|
173
|
+
assert.deepEqual(cardTitles(), ["FOLLOWER", "TODO", "JOBS", "AGENTS", "FOOTER"]);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// ---------------------------------------------------------------------------------------------
|
|
177
|
+
// S7 — hit-testing with contributed rows on BOTH sides of the host's own.
|
|
178
|
+
// ---------------------------------------------------------------------------------------------
|
|
179
|
+
|
|
180
|
+
test("a host row reaches the host's handler with the host's own y, even with a card above it", () => {
|
|
181
|
+
const seen: unknown[] = [];
|
|
182
|
+
const native = nativePart("TODO");
|
|
183
|
+
registerNativeRail("todo", {
|
|
184
|
+
...native,
|
|
185
|
+
handleMouse: (event) => {
|
|
186
|
+
seen.push(event);
|
|
187
|
+
return undefined;
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
registerNativeFooter(nativePart("FOOTER"));
|
|
191
|
+
registerSection(section("top", { title: "TOP", placement: "start" }));
|
|
192
|
+
arm();
|
|
193
|
+
const todo = () => fakeState().parts.get("todo");
|
|
194
|
+
const frame = todo()?.render(40) ?? [];
|
|
195
|
+
const before = frame.length - native.render(40).length;
|
|
196
|
+
assert.ok(before > 0, "our block really sits above the host's rows");
|
|
197
|
+
|
|
198
|
+
// The host's own heading is the row it drew first, wherever our block put it in the frame.
|
|
199
|
+
const heading = frame.findIndex((row) => row.includes("▾ TODO"));
|
|
200
|
+
assert.equal(heading, before);
|
|
201
|
+
|
|
202
|
+
todo()?.handleMouse?.({ type: "click", button: "left", x: 4, y: heading, width: 40 });
|
|
203
|
+
|
|
204
|
+
const forwarded = seen.at(-1) as { y?: number } | undefined;
|
|
205
|
+
assert.equal(forwarded?.y, 0, "the host is told the row it drew, not the row in the part frame");
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
test("a click on a card above the host's rows reaches the section, never the host", () => {
|
|
209
|
+
const hostCalls: unknown[] = [];
|
|
210
|
+
const native = nativePart("TODO");
|
|
211
|
+
registerNativeRail("todo", {
|
|
212
|
+
...native,
|
|
213
|
+
handleMouse: (event) => {
|
|
214
|
+
hostCalls.push(event);
|
|
215
|
+
return undefined;
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
registerNativeFooter(nativePart("FOOTER"));
|
|
219
|
+
const clicks: string[] = [];
|
|
220
|
+
registerSection(
|
|
221
|
+
section("top", {
|
|
222
|
+
title: "TOP",
|
|
223
|
+
placement: "start",
|
|
224
|
+
lines: () => [{ label: "act", onClick: () => clicks.push("act") }, "inert row"],
|
|
225
|
+
}),
|
|
226
|
+
);
|
|
227
|
+
arm();
|
|
228
|
+
const todo = () => fakeState().parts.get("todo");
|
|
229
|
+
todo()?.render(40);
|
|
230
|
+
|
|
231
|
+
// Row 1 of the part frame is the body of OUR card, above the host's own rows.
|
|
232
|
+
todo()?.handleMouse?.({ type: "click", button: "left", x: 4, y: 1, width: 40 });
|
|
233
|
+
|
|
234
|
+
assert.deepEqual(clicks, ["act"], "the bridge's target answered");
|
|
235
|
+
assert.deepEqual(hostCalls, [], "and the host was never asked about a row it did not draw");
|
|
236
|
+
|
|
237
|
+
// An INERT row of ours declines, so the host still runs — on a row it does not own either.
|
|
238
|
+
assert.equal(todo()?.handleMouse?.({ type: "click", button: "left", x: 4, y: 2, width: 40 }), undefined);
|
|
239
|
+
const forwarded = hostCalls.at(-1) as { y?: number } | undefined;
|
|
240
|
+
const nativeRows = native.render(40).length;
|
|
241
|
+
assert.ok(
|
|
242
|
+
forwarded?.y !== undefined && forwarded.y >= nativeRows,
|
|
243
|
+
"the host was offered a row past its own frame, which it never owns",
|
|
244
|
+
);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
test("a move over a host row between two contributed blocks stays the host's", () => {
|
|
248
|
+
const hostMoves: unknown[] = [];
|
|
249
|
+
const native = nativePart("TODO");
|
|
250
|
+
registerNativeRail("todo", {
|
|
251
|
+
...native,
|
|
252
|
+
handleMouse: (event) => {
|
|
253
|
+
hostMoves.push(event);
|
|
254
|
+
return { handled: true, render: true, host: true };
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
registerNativeFooter(nativePart("FOOTER"));
|
|
258
|
+
registerSection(section("top", { title: "TOP", placement: "start" }));
|
|
259
|
+
registerSection(section("plain", { title: "PLAIN" }));
|
|
260
|
+
arm();
|
|
261
|
+
const todo = () => fakeState().parts.get("todo");
|
|
262
|
+
const frame = todo()?.render(40) ?? [];
|
|
263
|
+
|
|
264
|
+
// A contributed block above, the host's own rows in the middle, another block below.
|
|
265
|
+
assert.ok(frame.length > native.render(40).length, "the part carries our rows on both sides");
|
|
266
|
+
const body = frame.findIndex((row) => row.includes("TODO row"));
|
|
267
|
+
assert.deepEqual(todo()?.handleMouse?.({ type: "move", button: "none", x: 4, y: body, width: 40 }), {
|
|
268
|
+
handled: true,
|
|
269
|
+
render: true,
|
|
270
|
+
host: true,
|
|
271
|
+
});
|
|
272
|
+
assert.deepEqual(hostMoves, [{ type: "move", button: "none", x: 4, y: 1, width: 40 }]);
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
// ---------------------------------------------------------------------------------------------
|
|
276
|
+
// S8 — the mobile `/gentle:panel` sheet reads the same map values, so it needs no extra work.
|
|
277
|
+
// ---------------------------------------------------------------------------------------------
|
|
278
|
+
|
|
279
|
+
test("the panel sheet paints our rows too: it reads the same map value", () => {
|
|
280
|
+
registerAllParts();
|
|
281
|
+
registerSection(section("top", { title: "TOP", placement: "start" }));
|
|
282
|
+
registerSection(section("plain", { title: "PLAIN" }));
|
|
283
|
+
|
|
284
|
+
// Exactly what `SHEET_ORDER` does (`lib/shell-panel.ts:125-150`): for every painted key, render
|
|
285
|
+
// the value in `parts`, keeping its lines. No card frame here, which is why a raw row is enough.
|
|
286
|
+
const sheet = (inner: number): string[] =>
|
|
287
|
+
RAIL_PARTS.flatMap((key) => [...(fakeState().parts.get(key)?.render(inner) ?? [])]);
|
|
288
|
+
assert.deepEqual(sheet(40), ["▾ TODO", "TODO row", "▾ JOBS", "JOBS row", "▾ AGENTS", "AGENTS row", "▾ FOOTER", "FOOTER row"], "before arming the sheet shows only the host's rows");
|
|
289
|
+
|
|
290
|
+
arm();
|
|
291
|
+
|
|
292
|
+
const painted = sheet(40);
|
|
293
|
+
const at = (text: string): number => painted.findIndex((row) => row.includes(text));
|
|
294
|
+
assert.ok(painted[0].includes("TOP"), "the sheet starts with the card placed at the start");
|
|
295
|
+
assert.ok(
|
|
296
|
+
at("▾ FOOTER") < at("▾ PLAIN"),
|
|
297
|
+
"and the card placed at the end follows the host's last part",
|
|
298
|
+
);
|
|
299
|
+
assert.ok(at("▾ TOP") < at("▾ TODO"), "with no extra work: the wrapper is the map's value");
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
// ---------------------------------------------------------------------------------------------
|
|
303
|
+
// Idempotency and the restore path, now on four parts instead of one.
|
|
304
|
+
// ---------------------------------------------------------------------------------------------
|
|
305
|
+
|
|
306
|
+
test("all four painted parts are wrapped, and no other key is", () => {
|
|
307
|
+
registerAllParts();
|
|
308
|
+
registerNativeRail("header", nativePart("HEADER"));
|
|
309
|
+
registerNativeRail("statusbar", nativePart("STATUS"));
|
|
310
|
+
const originals = new Map(RAIL_PARTS.map((key) => [key, fakeState().parts.get(key)]));
|
|
311
|
+
const header = fakeState().parts.get("header");
|
|
312
|
+
arm();
|
|
313
|
+
|
|
314
|
+
for (const key of RAIL_PARTS) {
|
|
315
|
+
assert.notEqual(fakeState().parts.get(key), originals.get(key), `${key} is wrapped`);
|
|
316
|
+
}
|
|
317
|
+
assert.equal(fakeState().parts.get("header"), header, "a key the layout never paints is untouched");
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
test("a second arm wraps nothing twice and the render is stable", () => {
|
|
321
|
+
registerAllParts();
|
|
322
|
+
registerSection(section("top", { title: "TOP", placement: "start" }));
|
|
323
|
+
arm();
|
|
324
|
+
const wrappers = RAIL_PARTS.map((key) => fakeState().parts.get(key));
|
|
325
|
+
const before = renderSidebar(40);
|
|
326
|
+
|
|
327
|
+
arm();
|
|
328
|
+
|
|
329
|
+
assert.deepEqual(
|
|
330
|
+
RAIL_PARTS.map((key) => fakeState().parts.get(key)),
|
|
331
|
+
wrappers,
|
|
332
|
+
"the same wrapper objects",
|
|
333
|
+
);
|
|
334
|
+
assert.deepEqual(renderSidebar(40), before, "and the same frame");
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
test("disable restores every host part and leaves a retained wrapper passive", () => {
|
|
338
|
+
registerAllParts();
|
|
339
|
+
const originals = new Map(RAIL_PARTS.map((key) => [key, fakeState().parts.get(key)]));
|
|
340
|
+
registerSection(section("top", { title: "TOP", placement: "start" }));
|
|
341
|
+
arm();
|
|
342
|
+
const retained = fakeState().parts.get("todo");
|
|
343
|
+
assert.deepEqual(cardTitles()[0], "TOP");
|
|
344
|
+
|
|
345
|
+
assert.equal(disableSidebarBackend(), 4, "four rails restored");
|
|
346
|
+
for (const key of RAIL_PARTS) {
|
|
347
|
+
assert.equal(fakeState().parts.get(key), originals.get(key), `${key} is the host's own rail`);
|
|
348
|
+
}
|
|
349
|
+
assert.deepEqual(retained?.render(40), ["▾ TODO", "TODO row"], "a retained wrapper adds nothing");
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
test("a part the host registers after the arm is captured on the same frame", () => {
|
|
353
|
+
registerNativeFooter(nativePart("FOOTER"));
|
|
354
|
+
arm();
|
|
355
|
+
fakeState().parts.set("todo", nativePart("TODO"));
|
|
356
|
+
registerSection(section("top", { title: "TOP", placement: "start" }));
|
|
357
|
+
|
|
358
|
+
assert.deepEqual(cardTitles(), ["TOP", "TODO", "FOOTER"]);
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
test("a throwing contributor loses its own rows on that part only", () => {
|
|
362
|
+
registerAllParts();
|
|
363
|
+
installSidebarBackend(() => fakeTui());
|
|
364
|
+
registerSection(section("top", { title: "TOP", placement: "start" }));
|
|
365
|
+
arm();
|
|
366
|
+
// One frame with the real contributor, so the wrapper's memo is warm.
|
|
367
|
+
assert.deepEqual(cardTitles()[0], "TOP");
|
|
368
|
+
|
|
369
|
+
assert.deepEqual(
|
|
370
|
+
getSidebarDiagnostics().lastFailures.filter((failure) => failure.phase === "contribute"),
|
|
371
|
+
[],
|
|
372
|
+
);
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
test("the placement reaches the host's memo: a new anchor moves the digest", () => {
|
|
376
|
+
registerAllParts();
|
|
377
|
+
const registered = section("card", { title: "CARD" });
|
|
378
|
+
registerSection(registered);
|
|
379
|
+
arm();
|
|
380
|
+
const footer = () => fakeState().parts.get("footer");
|
|
381
|
+
footer()?.render(40);
|
|
382
|
+
const before = footer()?.digest?.();
|
|
383
|
+
|
|
384
|
+
// The same id re-registered with a placement: one section, a different slot.
|
|
385
|
+
registerSection(section("card", { title: "CARD", placement: "start" }));
|
|
386
|
+
|
|
387
|
+
assert.notEqual(footer()?.digest?.(), before, "the digest notices the card moved");
|
|
388
|
+
assert.deepEqual(cardTitles()[0], "CARD");
|
|
389
|
+
});
|
|
390
|
+
|