@firstpick/pi-package-webui 0.9.1 → 0.9.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 +31 -9
- package/bin/pi-webui-launcher.mjs +23 -12
- package/bin/pi-webui.mjs +729 -93
- package/index.ts +266 -1
- package/lib/agent-run-adapters.mjs +500 -0
- package/lib/agent-run-protocol.mjs +262 -0
- package/lib/agent-run-registry.mjs +339 -0
- package/lib/git-workflow-preferences.mjs +18 -28
- package/lib/intercom-conversations.mjs +491 -0
- package/lib/intercom-transcript-filter.mjs +99 -0
- package/lib/resource-selection.mjs +140 -0
- package/lib/trust-boundaries.mjs +2 -0
- package/lib/ui-layout-settings.mjs +172 -28
- package/lib/update/package-layout.mjs +50 -0
- package/lib/update/plan.mjs +11 -0
- package/package.json +2 -2
- package/public/app.js +2276 -419
- package/public/index.html +142 -72
- package/public/service-worker.js +2 -1
- package/public/stream-output-controller.mjs +15 -0
- package/public/styles.css +764 -92
- package/public/syntax-highlight.mjs +622 -0
- package/tests/agent-run-adapters.test.mjs +217 -0
- package/tests/agent-run-launcher.test.mjs +41 -0
- package/tests/agent-run-protocol.test.mjs +82 -0
- package/tests/agent-run-registry.test.mjs +102 -0
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/control-deck-side-panels.spec.mjs +354 -0
- package/tests/browser/controls-layout.spec.mjs +122 -0
- package/tests/browser/file-tree-git-ignored.spec.mjs +113 -0
- package/tests/browser/interaction-continuity.spec.mjs +161 -0
- package/tests/browser/intercom-conversation-viewer.spec.mjs +355 -0
- package/tests/browser/mobile-foundation.spec.mjs +26 -0
- package/tests/browser/model-search-focus.spec.mjs +96 -0
- package/tests/browser/optimistic-prompt.spec.mjs +22 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +285 -66
- package/tests/browser/resource-profiles.spec.mjs +200 -0
- package/tests/browser/subagent-observability.spec.mjs +116 -0
- package/tests/codex-fast-mode-static.test.mjs +7 -6
- package/tests/common-options-submenus-interaction-static.test.mjs +2 -0
- package/tests/common-options-submenus-markup-static.test.mjs +1 -0
- package/tests/component-update-api-static.test.mjs +2 -1
- package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
- package/tests/composer-skill-tag-layout.test.mjs +32 -2
- package/tests/control-deck-component-updates-static.test.mjs +6 -0
- package/tests/control-deck-side-panels-static.test.mjs +68 -0
- package/tests/controls-layout-static.test.mjs +22 -0
- package/tests/fast-mode-client-static.test.mjs +2 -2
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/feature-system-prompt-optional-feature-static.test.mjs +5 -5
- package/tests/file-tree-git-ignored-static.test.mjs +152 -0
- package/tests/file-tree-search-layout-static.test.mjs +2 -1
- package/tests/file-viewer-image-static.test.mjs +69 -0
- package/tests/fixtures/fake-pi.mjs +147 -12
- package/tests/foreground-transcript-catch-up-static.test.mjs +1 -1
- package/tests/git-panel-file-preview-static.test.mjs +5 -5
- package/tests/git-panel-live-updates-static.test.mjs +3 -3
- package/tests/git-workflow-preferences.test.mjs +55 -6
- package/tests/http-endpoints-harness.test.mjs +295 -14
- package/tests/intercom-conversation-viewer-static.test.mjs +105 -0
- package/tests/intercom-conversations-http.test.mjs +252 -0
- package/tests/intercom-conversations.test.mjs +374 -0
- package/tests/intercom-main-transcript-suppression-static.test.mjs +52 -0
- package/tests/intercom-tag-layout-static.test.mjs +46 -0
- package/tests/intercom-transcript-filter.test.mjs +98 -0
- package/tests/main-output-loading-static.test.mjs +59 -0
- package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
- package/tests/mobile-compact-layout.test.mjs +2 -3
- package/tests/mobile-continuity-tablet-static.test.mjs +6 -6
- package/tests/mobile-foundation-static.test.mjs +3 -3
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +76 -42
- package/tests/native-parity.test.mjs +8 -7
- package/tests/open-issue-wizard-static.test.mjs +2 -2
- package/tests/optional-feature-migration-frontend.test.mjs +5 -5
- package/tests/optional-feature-resource-setup-static.test.mjs +29 -0
- package/tests/persistent-ui-layout-static.test.mjs +13 -13
- package/tests/questionnaire-dialog.test.mjs +3 -3
- package/tests/remote-auth-settings-harness.test.mjs +1 -1
- package/tests/resource-defaults-helper.test.mjs +60 -6
- package/tests/resource-selection.test.mjs +114 -0
- package/tests/resource-tui-extension.test.mjs +23 -0
- package/tests/session-sampling-ui-static.test.mjs +3 -3
- package/tests/side-panel-context-menu-static.test.mjs +1 -1
- package/tests/side-panel-resize-static.test.mjs +26 -16
- package/tests/side-panel-section-height-removal-static.test.mjs +4 -4
- package/tests/side-panel-section-reorder-static.test.mjs +16 -70
- package/tests/stream-output-controller.test.mjs +8 -0
- package/tests/stream-output-isolation-static.test.mjs +2 -2
- package/tests/streaming-ui-coupling.test.mjs +5 -0
- package/tests/subagent-gate-visibility.test.mjs +2 -1
- package/tests/subagent-launch-slots.test.mjs +1 -1
- package/tests/subagent-observability-static.test.mjs +32 -0
- package/tests/subagent-reliability-integration.test.mjs +183 -0
- package/tests/subagent-workflow-section-static.test.mjs +67 -0
- package/tests/subagents-helper.test.mjs +548 -5
- package/tests/syntax-highlight.test.mjs +235 -0
- package/tests/syntax-highlighting-static.test.mjs +84 -0
- package/tests/terminal-tabs-resize-static.test.mjs +35 -0
- package/tests/theme-customizer-static.test.mjs +5 -5
- package/tests/thinking-format-parser.test.mjs +64 -0
- package/tests/ui-layout-settings.test.mjs +104 -32
- package/tests/update-api-harness.test.mjs +24 -10
- package/tests/update-package-layout.test.mjs +38 -0
- package/tests/update-plan.test.mjs +11 -1
- package/tests/webui-settings-locking.test.mjs +33 -3
- package/webui-rpc-helper.mjs +700 -89
|
@@ -14,7 +14,7 @@ const [html, app, serviceWorker] = await Promise.all([
|
|
|
14
14
|
|
|
15
15
|
assert.match(
|
|
16
16
|
app,
|
|
17
|
-
/const UI_LAYOUT_SCHEMA_VERSION =
|
|
17
|
+
/const UI_LAYOUT_SCHEMA_VERSION = 2;[\s\S]*const UI_LAYOUT_ENDPOINT = "\/api\/interface-preferences";/,
|
|
18
18
|
"the browser controller should target the accepted version-1 layout schema on the existing interface-preferences endpoint",
|
|
19
19
|
);
|
|
20
20
|
assert.match(
|
|
@@ -24,7 +24,7 @@ assert.match(
|
|
|
24
24
|
);
|
|
25
25
|
assert.match(
|
|
26
26
|
app,
|
|
27
|
-
/const UI_LAYOUT_SIDE_PANEL_FIELDS = \["
|
|
27
|
+
/const UI_LAYOUT_SIDE_PANEL_FIELDS = \["placement", "sectionLayout", "collapsedSectionIds", "hiddenSectionIds", "collapsedPanels", "panelWidths"\];/,
|
|
28
28
|
"Control Deck durable layout should contain only order, visibility, and collapse state",
|
|
29
29
|
);
|
|
30
30
|
for (const [constant, value] of [
|
|
@@ -68,12 +68,12 @@ assert.match(
|
|
|
68
68
|
);
|
|
69
69
|
assert.match(
|
|
70
70
|
app,
|
|
71
|
-
/function applyDurableUiLayoutSnapshot[\s\S]*!isDirty && !
|
|
71
|
+
/function applyDurableUiLayoutSnapshot[\s\S]*const activelyManipulated[\s\S]*!isDirty && !activelyManipulated && !generationChanged[\s\S]*applicable\[subfield\] = remote[\s\S]*applyDurableUiLayoutField\(field, applicable\)/,
|
|
72
72
|
"non-dirty sibling subfields should still adopt authoritative server values",
|
|
73
73
|
);
|
|
74
74
|
assert.match(
|
|
75
75
|
app,
|
|
76
|
-
/function applyDurableUiLayoutSnapshot[\s\S]
|
|
76
|
+
/function applyDurableUiLayoutSnapshot[\s\S]*const remotePresent = durableUiLayoutSubfieldValuePresent\(field, subfield, remote\)[\s\S]*!isDirty && !remotePresent && durableUiLayoutValuePresent\(local\)[\s\S]*markDurableUiLayoutDirty\(field, subfield\)/,
|
|
77
77
|
"missing server subfields should migrate only their valid local values",
|
|
78
78
|
);
|
|
79
79
|
assert.match(
|
|
@@ -96,7 +96,7 @@ assert.match(
|
|
|
96
96
|
);
|
|
97
97
|
assert.match(
|
|
98
98
|
app,
|
|
99
|
-
/const UI_LAYOUT_PENDING_STORAGE_PREFIX = "pi-webui-ui-layout-pending-v3:";[\s\S]*function durableUiLayoutPendingMutationRecords\(\)[\s\S]*
|
|
99
|
+
/const UI_LAYOUT_PENDING_STORAGE_PREFIX = "pi-webui-ui-layout-pending-v4:";[\s\S]*const UI_LAYOUT_LEGACY_PENDING_STORAGE_PREFIX = "pi-webui-ui-layout-pending-v3:";[\s\S]*function durableUiLayoutPendingMutationRecords\(\)[\s\S]*UI_LAYOUT_LEGACY_PENDING_STORAGE_PREFIX[\s\S]*!\[3, 4\]\.includes\(value\.version\)[\s\S]*function restoreDurableUiLayoutPendingJournal\(\)[\s\S]*candidate\.value[\s\S]*subfieldMutationIds[\s\S]*scheduleDurableUiLayoutSave\(\)/,
|
|
100
100
|
"per-writer pending layout values should survive reload without one tab replacing another tab's journal",
|
|
101
101
|
);
|
|
102
102
|
assert.match(
|
|
@@ -121,7 +121,7 @@ assert.match(
|
|
|
121
121
|
);
|
|
122
122
|
assert.match(
|
|
123
123
|
app,
|
|
124
|
-
/async function flushDurableUiLayoutSave[\s\S]*body: \{
|
|
124
|
+
/async function flushDurableUiLayoutSave[\s\S]*body: \{[\s\S]*layout: patch,[\s\S]*expectedLayoutRevision: durableLayoutRevision[\s\S]*\}/,
|
|
125
125
|
"layout writes should submit the latest known opaque revision",
|
|
126
126
|
);
|
|
127
127
|
assert.match(
|
|
@@ -169,7 +169,7 @@ assert.match(
|
|
|
169
169
|
// --- Every approved arrangement surface is durable -------------------------
|
|
170
170
|
|
|
171
171
|
for (const [persistFunction, field, subfield] of [
|
|
172
|
-
["persistSidePanelSectionOrder", "sidePanel", "
|
|
172
|
+
["persistSidePanelSectionOrder", "sidePanel", "sectionLayout"],
|
|
173
173
|
["persistSidePanelSectionState", "sidePanel", "collapsedSectionIds"],
|
|
174
174
|
["persistSidePanelSectionVisibility", "sidePanel", "hiddenSectionIds"],
|
|
175
175
|
["persistComposerActionOrder", "composerActions", null],
|
|
@@ -184,18 +184,18 @@ for (const [persistFunction, field, subfield] of [
|
|
|
184
184
|
: `markDurableUiLayoutDirty\\("${field}"\\)`;
|
|
185
185
|
assert.match(
|
|
186
186
|
app,
|
|
187
|
-
new RegExp(`function ${persistFunction}\\([^)]*\\) \\{[\\s\\S]*?${marker};\\s*\\n\\}`),
|
|
187
|
+
new RegExp(`(?:function ${persistFunction}\\([^)]*\\)|function persistControlDeckSectionLayout\\([^)]*\\)) \\{[\\s\\S]*?${marker};\\s*\\n\\}`),
|
|
188
188
|
`${persistFunction} should mark only its owned durable layout value after writing the local cache`,
|
|
189
189
|
);
|
|
190
190
|
}
|
|
191
191
|
assert.match(
|
|
192
192
|
app,
|
|
193
|
-
/localStorage\.setItem\(SIDE_PANEL_STORAGE_KEY, collapsed \? "1" : "0"\);[\s\S]{0,
|
|
193
|
+
/localStorage\.setItem\(SIDE_PANEL_STORAGE_KEY, collapsed \? "1" : "0"\);[\s\S]{0,300}markDurableUiLayoutDirty\("sidePanel", "collapsedPanels"\)/,
|
|
194
194
|
"Control Deck collapse state should be durable without dirtying sibling settings",
|
|
195
195
|
);
|
|
196
196
|
assert.match(
|
|
197
197
|
app,
|
|
198
|
-
/function restoreSidePanelState\(\)[\s\S]*
|
|
198
|
+
/function restoreSidePanelState\(\)[\s\S]*persist: false[\s\S]*side:/,
|
|
199
199
|
"passive Control Deck restoration must not echo stale cache back to the server",
|
|
200
200
|
);
|
|
201
201
|
assert.doesNotMatch(
|
|
@@ -271,8 +271,8 @@ assert.match(
|
|
|
271
271
|
|
|
272
272
|
// --- Coherent browser asset revisions --------------------------------------
|
|
273
273
|
|
|
274
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
275
|
-
assert.match(html, /styles\.css\?v=
|
|
276
|
-
assert.match(html, /data-app-src="\/app\.js\?v=
|
|
274
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "changed browser assets should advance the PWA cache identity");
|
|
275
|
+
assert.match(html, /styles\.css\?v=123/, "the page should request the updated layout stylesheet revision");
|
|
276
|
+
assert.match(html, /data-app-src="\/app\.js\?v=146"/, "the boot loader should request the updated app module revision");
|
|
277
277
|
|
|
278
278
|
console.log("persistent-ui-layout-static.test.mjs passed");
|
|
@@ -504,8 +504,8 @@ assert.match(css, /@media \(max-width: 720px\), \(max-device-width: 720px\), \(p
|
|
|
504
504
|
assert.match(css, /\.questionnaire-options button\s*\{\s*min-height:\s*3\.35rem/, "mobile questionnaire targets must exceed the 44px floor");
|
|
505
505
|
assert.match(css, /@media \(prefers-reduced-motion: reduce\)\s*\{[\s\S]*?\*, \*::before, \*::after[\s\S]*?transition-duration:\s*1ms !important/, "global reduced-motion rules must cover questionnaire transitions");
|
|
506
506
|
|
|
507
|
-
assert.match(html, /styles\.css\?v=
|
|
508
|
-
assert.match(html, /app\.js\?v=
|
|
509
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
507
|
+
assert.match(html, /styles\.css\?v=123/, "questionnaire CSS needs the current stylesheet revision");
|
|
508
|
+
assert.match(html, /app\.js\?v=146/, "questionnaire behavior needs the current app revision");
|
|
509
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "questionnaire public assets need a coherent PWA cache revision");
|
|
510
510
|
|
|
511
511
|
console.log("questionnaire-dialog.test.mjs passed");
|
|
@@ -179,7 +179,7 @@ try {
|
|
|
179
179
|
const disableAuth = await request("/api/remote-auth/settings", { method: "POST", body: { enabled: false } });
|
|
180
180
|
assert.equal(disableAuth.status, 200);
|
|
181
181
|
const savedAfterDisable = JSON.parse(await readFile(settingsFile, "utf8"));
|
|
182
|
-
assert.equal(savedAfterDisable.version,
|
|
182
|
+
assert.equal(savedAfterDisable.version, 8, "Web UI settings should retain the current private settings envelope version");
|
|
183
183
|
assert.equal(savedAfterDisable.remoteAuthEnabled, false, "disabling Remote PIN auth should persist the off preference");
|
|
184
184
|
assert.equal(savedAfterDisable.gitWorkflow?.generation?.modelId, "fake-model", "Remote PIN updates should preserve guided Git preferences");
|
|
185
185
|
|
|
@@ -27,13 +27,18 @@ const previousSettingsFile = process.env.PI_WEBUI_SETTINGS_FILE;
|
|
|
27
27
|
process.env.PI_WEBUI_SETTINGS_FILE = settingsFile;
|
|
28
28
|
|
|
29
29
|
try {
|
|
30
|
-
|
|
31
|
-
version:
|
|
30
|
+
const settingsPayload = {
|
|
31
|
+
version: 8,
|
|
32
32
|
resourceDefaults: {
|
|
33
33
|
tools: { enabledTools: ["read", "write"] },
|
|
34
34
|
skills: { enabledSkills: ["skill-a", "skill-c"] },
|
|
35
|
+
modelProfiles: [
|
|
36
|
+
{ provider: "provider", modelId: "model-a", tools: { enabledTools: ["bash"] }, skills: { enabledSkills: ["skill-b"] } },
|
|
37
|
+
{ provider: "provider", modelId: "model-b", tools: { enabledTools: ["write"] }, skills: { enabledSkills: [] } },
|
|
38
|
+
],
|
|
35
39
|
},
|
|
36
|
-
}
|
|
40
|
+
};
|
|
41
|
+
await writeFile(settingsFile, "{ invalid settings\n", "utf8");
|
|
37
42
|
|
|
38
43
|
const extensionHandlers = new Map();
|
|
39
44
|
const registeredCommands = new Map();
|
|
@@ -43,6 +48,7 @@ try {
|
|
|
43
48
|
let activeTools = ["read", "bash", "write"];
|
|
44
49
|
let branchEntries = [];
|
|
45
50
|
let availableSkills = [];
|
|
51
|
+
let runtimeReady = false;
|
|
46
52
|
|
|
47
53
|
const pi = {
|
|
48
54
|
events: bus,
|
|
@@ -55,15 +61,22 @@ try {
|
|
|
55
61
|
getAllTools() {
|
|
56
62
|
return ["read", "bash", "write"].map((name) => ({ name, description: `${name} tool`, sourceInfo: { source: "builtin" } }));
|
|
57
63
|
},
|
|
58
|
-
getActiveTools() {
|
|
64
|
+
getActiveTools() {
|
|
65
|
+
assert.equal(runtimeReady, true, "extension action methods must not run while the extension factory is loading");
|
|
66
|
+
return [...activeTools];
|
|
67
|
+
},
|
|
59
68
|
setActiveTools(names) { activeTools = [...names]; },
|
|
60
|
-
appendEntry(customType, data) {
|
|
69
|
+
appendEntry(customType, data) {
|
|
70
|
+
appendedEntries.push({ customType, data });
|
|
71
|
+
branchEntries.push({ type: "custom", customType, data });
|
|
72
|
+
},
|
|
61
73
|
};
|
|
62
74
|
|
|
63
75
|
const ctx = {
|
|
64
76
|
mode: "rpc",
|
|
65
77
|
hasUI: true,
|
|
66
78
|
cwd: root,
|
|
79
|
+
model: { provider: "provider", id: "unconfigured" },
|
|
67
80
|
sessionManager: {
|
|
68
81
|
getBranch() { return branchEntries; },
|
|
69
82
|
},
|
|
@@ -79,6 +92,7 @@ try {
|
|
|
79
92
|
};
|
|
80
93
|
|
|
81
94
|
webuiRpcHelper(pi);
|
|
95
|
+
runtimeReady = true;
|
|
82
96
|
const helperCommand = registeredCommands.get("webui-helper");
|
|
83
97
|
assert.ok(helperCommand?.handler, "resource defaults test requires the hidden helper command");
|
|
84
98
|
|
|
@@ -93,6 +107,11 @@ try {
|
|
|
93
107
|
}
|
|
94
108
|
|
|
95
109
|
for (const handler of extensionHandlers.get("session_start") || []) await handler({ reason: "startup" }, ctx);
|
|
110
|
+
assert.deepEqual(activeTools, ["read", "bash", "write"], "an initial settings-read failure must leave Pi's runtime tools unchanged");
|
|
111
|
+
assert.ok(notifications.some((entry) => /tools and skills remain unchanged/i.test(entry.message)), "initial settings failure should emit a bounded warning");
|
|
112
|
+
|
|
113
|
+
await writeFile(settingsFile, `${JSON.stringify(settingsPayload, null, 2)}\n`, "utf8");
|
|
114
|
+
for (const handler of extensionHandlers.get("session_start") || []) await handler({ reason: "settings-restored" }, ctx);
|
|
96
115
|
availableSkills = ["skill-a", "skill-b", "skill-c"];
|
|
97
116
|
assert.deepEqual(activeTools, ["read", "write"], "a new session should inherit the global tool allowlist");
|
|
98
117
|
assert.deepEqual(
|
|
@@ -113,9 +132,44 @@ try {
|
|
|
113
132
|
"session skill choices should override the global default",
|
|
114
133
|
);
|
|
115
134
|
|
|
135
|
+
branchEntries = [];
|
|
136
|
+
ctx.model = { provider: "provider", id: "model-a" };
|
|
137
|
+
for (const handler of extensionHandlers.get("model_select") || []) await handler({ model: ctx.model, source: "set" }, ctx);
|
|
138
|
+
assert.deepEqual(activeTools, ["bash"], "model selection should immediately apply the exact tool profile");
|
|
139
|
+
assert.deepEqual((await runHelper("skills-state")).enabledSkills, ["skill-b"], "model selection should immediately apply the exact skill profile");
|
|
140
|
+
|
|
141
|
+
await writeFile(settingsFile, "{ invalid settings\n", "utf8");
|
|
142
|
+
ctx.model = { provider: "provider", id: "model-b" };
|
|
143
|
+
for (const handler of extensionHandlers.get("model_select") || []) await handler({ model: ctx.model, source: "set" }, ctx);
|
|
144
|
+
assert.deepEqual(activeTools, ["bash"], "a later settings-read failure must retain the last safely applied tools");
|
|
145
|
+
assert.deepEqual((await runHelper("skills-state")).enabledSkills, ["skill-b"], "a later settings-read failure must retain the last safely applied skills");
|
|
146
|
+
await writeFile(settingsFile, `${JSON.stringify(settingsPayload, null, 2)}\n`, "utf8");
|
|
147
|
+
ctx.model = { provider: "provider", id: "model-a" };
|
|
148
|
+
|
|
116
149
|
await runHelper("tools-set", { enabledTools: ["read"] });
|
|
150
|
+
ctx.model = { provider: "provider", id: "model-b" };
|
|
151
|
+
for (const handler of extensionHandlers.get("model_select") || []) await handler({ model: ctx.model, source: "set" }, ctx);
|
|
152
|
+
assert.deepEqual(activeTools, ["read"], "a session-pinned tool selection should survive model changes");
|
|
153
|
+
assert.deepEqual((await runHelper("skills-state")).enabledSkills, [], "an unpinned skill selection should follow the new model independently");
|
|
154
|
+
const blockedSkill = await (extensionHandlers.get("input") || [])[0]({ text: "/skill:skill-a" }, ctx);
|
|
155
|
+
assert.deepEqual(blockedSkill, { action: "handled" }, "an explicit invocation of a model-disabled skill should be blocked");
|
|
156
|
+
|
|
157
|
+
await runHelper("tools-set", { mode: "inherit" });
|
|
158
|
+
assert.deepEqual(activeTools, ["write"], "unpinning tools should immediately restore the active model profile");
|
|
117
159
|
await runHelper("skills-set", { enabledSkills: ["skill-a", "skill-c"] });
|
|
118
|
-
|
|
160
|
+
const filteredPrompt = await (extensionHandlers.get("before_agent_start") || [])[0]({
|
|
161
|
+
systemPrompt: "The following skills provide guidance.\n<available_skills>\nold\n</available_skills>\n",
|
|
162
|
+
systemPromptOptions: {
|
|
163
|
+
skills: [
|
|
164
|
+
{ name: "skill-a", description: "normal", filePath: "/tmp/a/SKILL.md" },
|
|
165
|
+
{ name: "skill-c", description: "user only", filePath: "/tmp/c/SKILL.md", disableModelInvocation: true },
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
}, ctx);
|
|
169
|
+
assert.doesNotMatch(filteredPrompt.systemPrompt, /skill-c/, "disableModelInvocation skills must not be exposed to automatic model invocation");
|
|
170
|
+
assert.deepEqual(appendedEntries.map((entry) => entry.customType), ["webui-tools-config", "webui-tools-config", "webui-skills-config"], "session updates and inherit resets should remain branch-persisted");
|
|
171
|
+
assert.deepEqual(appendedEntries[0].data, { version: 2, mode: "explicit", enabledTools: ["read"] });
|
|
172
|
+
assert.deepEqual(appendedEntries[1].data, { version: 2, mode: "inherit" });
|
|
119
173
|
|
|
120
174
|
for (const handler of extensionHandlers.get("session_shutdown") || []) await handler({ reason: "quit" }, ctx);
|
|
121
175
|
console.log("resource-defaults-helper.test.mjs passed");
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import {
|
|
6
|
+
branchResourceDirective,
|
|
7
|
+
normalizeResourceDefaults,
|
|
8
|
+
preserveUnavailableResourceNames,
|
|
9
|
+
resolveResourceSelection,
|
|
10
|
+
setExactModelProfile,
|
|
11
|
+
} from "../lib/resource-selection.mjs";
|
|
12
|
+
import { normalizeWebuiSettings, readWebuiSettings, writeWebuiSettings } from "../lib/git-workflow-preferences.mjs";
|
|
13
|
+
|
|
14
|
+
const normalized = normalizeWebuiSettings({
|
|
15
|
+
version: 8,
|
|
16
|
+
retained: { ok: true },
|
|
17
|
+
resourceDefaults: {
|
|
18
|
+
tools: { enabledTools: ["read", "read", ""] },
|
|
19
|
+
skills: { enabledSkills: null },
|
|
20
|
+
modelProfiles: [
|
|
21
|
+
{ provider: "p", modelId: "m/one", tools: { enabledTools: ["bash"] }, skills: { enabledSkills: null } },
|
|
22
|
+
{ provider: "p", modelId: "m/one", tools: { enabledTools: [] }, skills: { enabledSkills: ["skill-a"] } },
|
|
23
|
+
{ provider: "", modelId: "bad", tools: { enabledTools: ["write"] } },
|
|
24
|
+
{ provider: "p", modelId: "empty", tools: { enabledTools: null }, skills: { enabledSkills: null } },
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
assert.equal(normalized.version, 8);
|
|
29
|
+
assert.deepEqual(normalized.retained, { ok: true });
|
|
30
|
+
assert.deepEqual(normalized.resourceDefaults.tools.enabledTools, ["read"]);
|
|
31
|
+
assert.equal(normalized.resourceDefaults.modelProfiles.length, 1);
|
|
32
|
+
assert.deepEqual(resolveResourceSelection(normalized.resourceDefaults, "tools", "p", "m/one", ["runtime"]), { names: [], source: "model" });
|
|
33
|
+
assert.deepEqual(resolveResourceSelection(normalized.resourceDefaults, "skills", "p", "m/one", null), { names: ["skill-a"], source: "model" });
|
|
34
|
+
assert.deepEqual(resolveResourceSelection(normalized.resourceDefaults, "skills", "p", "other", null), { names: null, source: "runtime" });
|
|
35
|
+
|
|
36
|
+
const legacyWithProfiles = normalizeWebuiSettings({
|
|
37
|
+
version: 7,
|
|
38
|
+
resourceDefaults: {
|
|
39
|
+
tools: { enabledTools: ["global"] },
|
|
40
|
+
modelProfiles: [{ provider: "p", modelId: "legacy", tools: { enabledTools: ["bash"] } }],
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
assert.deepEqual(legacyWithProfiles.resourceDefaults.modelProfiles, [], "version-7 settings must ignore model profiles");
|
|
44
|
+
assert.deepEqual(resolveResourceSelection(legacyWithProfiles.resourceDefaults, "tools", "p", "legacy", ["runtime"]), { names: ["global"], source: "global" });
|
|
45
|
+
|
|
46
|
+
const future = normalizeWebuiSettings({
|
|
47
|
+
version: 9,
|
|
48
|
+
resourceDefaults: {
|
|
49
|
+
futurePolicy: { keep: true },
|
|
50
|
+
tools: { enabledTools: ["read"], futureToolField: "keep" },
|
|
51
|
+
skills: { enabledSkills: null, futureSkillField: 3 },
|
|
52
|
+
modelProfiles: [{
|
|
53
|
+
provider: "p",
|
|
54
|
+
modelId: "future",
|
|
55
|
+
futureProfileField: ["keep"],
|
|
56
|
+
tools: { enabledTools: ["bash"], futureSelectionField: true },
|
|
57
|
+
skills: { enabledSkills: null },
|
|
58
|
+
}],
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
assert.deepEqual(future.resourceDefaults.futurePolicy, { keep: true });
|
|
62
|
+
assert.equal(future.resourceDefaults.tools.futureToolField, "keep");
|
|
63
|
+
assert.equal(future.resourceDefaults.skills.futureSkillField, 3);
|
|
64
|
+
assert.deepEqual(future.resourceDefaults.modelProfiles[0].futureProfileField, ["keep"]);
|
|
65
|
+
assert.equal(future.resourceDefaults.modelProfiles[0].tools.futureSelectionField, true);
|
|
66
|
+
|
|
67
|
+
const defaults = normalizeResourceDefaults({
|
|
68
|
+
tools: { enabledTools: ["global"] },
|
|
69
|
+
skills: { enabledSkills: ["global-skill"] },
|
|
70
|
+
modelProfiles: [],
|
|
71
|
+
});
|
|
72
|
+
let profiles = setExactModelProfile(defaults, "provider", "model/id", "tools", ["read"]);
|
|
73
|
+
profiles = setExactModelProfile({ ...defaults, modelProfiles: profiles }, "provider", "model/id", "skills", []);
|
|
74
|
+
assert.deepEqual(profiles[0], {
|
|
75
|
+
provider: "provider",
|
|
76
|
+
modelId: "model/id",
|
|
77
|
+
tools: { enabledTools: ["read"] },
|
|
78
|
+
skills: { enabledSkills: [] },
|
|
79
|
+
});
|
|
80
|
+
profiles = setExactModelProfile({ ...defaults, modelProfiles: profiles }, "provider", "model/id", "tools", null);
|
|
81
|
+
assert.equal(profiles.length, 1, "independent skill selection should retain the profile");
|
|
82
|
+
profiles = setExactModelProfile({ ...defaults, modelProfiles: profiles }, "provider", "model/id", "skills", null);
|
|
83
|
+
assert.deepEqual(profiles, [], "both inherited resources should remove the profile");
|
|
84
|
+
|
|
85
|
+
assert.deepEqual(branchResourceDirective({ enabledTools: ["read"] }, "tools"), { pinned: true, names: ["read"], legacyDisabledNames: null });
|
|
86
|
+
assert.deepEqual(branchResourceDirective({ disabledSkills: ["a"] }, "skills"), { pinned: true, names: null, legacyDisabledNames: ["a"] });
|
|
87
|
+
assert.deepEqual(branchResourceDirective({ version: 2, mode: "inherit" }, "tools"), { pinned: false, names: null, legacyDisabledNames: null });
|
|
88
|
+
assert.deepEqual(preserveUnavailableResourceNames(["read", "missing"], ["read", "bash"], ["bash"]), ["bash", "missing"]);
|
|
89
|
+
|
|
90
|
+
const root = await mkdtemp(path.join(tmpdir(), "pi-resource-settings-"));
|
|
91
|
+
try {
|
|
92
|
+
const file = path.join(root, "settings.json");
|
|
93
|
+
await writeFile(file, `${JSON.stringify({ version: 7, retained: { ok: true }, resourceDefaults: { tools: { enabledTools: ["read"] } } })}\n`);
|
|
94
|
+
const read = await readWebuiSettings(file);
|
|
95
|
+
assert.equal(read.version, 8, "legacy settings should normalize to v8 in memory");
|
|
96
|
+
assert.equal(JSON.parse(await readFile(file, "utf8")).version, 7, "reading should not eagerly rewrite legacy settings");
|
|
97
|
+
await writeWebuiSettings({ resourceDefaults: { skills: { enabledSkills: [] } } }, file);
|
|
98
|
+
const persisted = JSON.parse(await readFile(file, "utf8"));
|
|
99
|
+
assert.equal(persisted.version, 8, "the next normal write should persist v8");
|
|
100
|
+
assert.deepEqual(persisted.retained, { ok: true }, "migration writes should preserve unrelated fields");
|
|
101
|
+
assert.deepEqual(persisted.resourceDefaults.tools.enabledTools, ["read"]);
|
|
102
|
+
|
|
103
|
+
await writeFile(file, `${JSON.stringify({ version: 9, resourceDefaults: future.resourceDefaults })}\n`);
|
|
104
|
+
await writeWebuiSettings({ remoteAuthEnabled: true }, file);
|
|
105
|
+
const futurePersisted = JSON.parse(await readFile(file, "utf8"));
|
|
106
|
+
assert.deepEqual(futurePersisted.resourceDefaults.futurePolicy, { keep: true }, "future resource-default fields must survive writes");
|
|
107
|
+
assert.equal(futurePersisted.resourceDefaults.tools.futureToolField, "keep");
|
|
108
|
+
assert.equal(futurePersisted.resourceDefaults.modelProfiles[0].futureProfileField[0], "keep");
|
|
109
|
+
assert.equal(futurePersisted.resourceDefaults.modelProfiles[0].tools.futureSelectionField, true);
|
|
110
|
+
} finally {
|
|
111
|
+
await rm(root, { recursive: true, force: true });
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
console.log("resource-selection.test.mjs passed");
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
|
|
4
|
+
const source = await readFile(new URL("../index.ts", import.meta.url), "utf8");
|
|
5
|
+
assert.match(source, /pi\.registerCommand\("tools"/);
|
|
6
|
+
assert.match(source, /pi\.registerCommand\("skills"/);
|
|
7
|
+
assert.doesNotMatch(
|
|
8
|
+
source,
|
|
9
|
+
/const runtimeToolBaseline\s*=\s*normalizeResourceNameList\(pi\.getActiveTools\(\)\)/,
|
|
10
|
+
"extension action methods must not run while the extension factory is loading",
|
|
11
|
+
);
|
|
12
|
+
assert.match(source, /const runtimeTools = \(\): string\[\] => runtimeToolBaseline \?\?=/, "the tool baseline should be captured lazily after runtime binding");
|
|
13
|
+
assert.match(source, /ctx\.mode !== "tui"/);
|
|
14
|
+
assert.match(source, /pi\.on\("model_select"/);
|
|
15
|
+
assert.match(source, /await recompute\(ctx, event\.model\)/, "model selection should immediately recompute exact-model resources");
|
|
16
|
+
assert.match(source, /"Session only", "Global default", "Model default"/);
|
|
17
|
+
assert.match(source, /"Use inherited defaults"/);
|
|
18
|
+
assert.match(source, /ctx\.ui\.select\(/, "resource lists should use Pi's native selector");
|
|
19
|
+
assert.match(source, /preserveUnavailableResourceNames\(/);
|
|
20
|
+
assert.match(source, /setExactModelProfile\(/);
|
|
21
|
+
assert.match(source, /skill\.disableModelInvocation !== true/);
|
|
22
|
+
|
|
23
|
+
console.log("resource-tui-extension.test.mjs passed");
|
|
@@ -57,10 +57,10 @@ assert.match(css, /\.sampling-parameter-control\.unsupported:hover:not\(\.sampli
|
|
|
57
57
|
assert.match(css, /\.sampling-parameter-control\.unsupported:focus-visible:not\(\.sampling-tooltip-dismissed\) > \.sampling-parameter-unsupported-tooltip/, "keyboard focus should reveal dismissible unsupported reasons");
|
|
58
58
|
assert.match(css, /\.sampling-parameter-unsupported-tooltip\.sampling-tooltip-below/, "bounded placement should support flipping below top-edge rows");
|
|
59
59
|
assert.match(css, /pointer-events: auto;/, "a visible unsupported tooltip should remain pointer-hoverable");
|
|
60
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
60
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "native-control assets should advance the cache identity");
|
|
61
61
|
assert.match(serviceWorker, /"\/sampling-parameter-controls\.mjs"/, "the pure sampling module should be part of the offline app shell");
|
|
62
|
-
assert.match(html, /styles\.css\?v=
|
|
63
|
-
assert.match(html, /app\.js\?v=
|
|
62
|
+
assert.match(html, /styles\.css\?v=123/, "the changed stylesheet should have a new revision");
|
|
63
|
+
assert.match(html, /app\.js\?v=146/, "the changed app module should have a new revision");
|
|
64
64
|
|
|
65
65
|
// --- Browser state behavior -------------------------------------------------
|
|
66
66
|
|
|
@@ -52,7 +52,7 @@ assert.match(
|
|
|
52
52
|
);
|
|
53
53
|
assert.match(
|
|
54
54
|
app,
|
|
55
|
-
/function bindSidePanelContextMenu\(\)[\s\S]*addEventListener\("contextmenu", showSidePanelContextMenu\)[\s\S]*event\.key !== "ContextMenu"[\s\S]*event\.shiftKey && event\.key === "F10"/,
|
|
55
|
+
/function bindSidePanelContextMenu\(\)[\s\S]*\[elements\.sidePanelLeft, elements\.sidePanel\][\s\S]*addEventListener\("contextmenu", showSidePanelContextMenu\)[\s\S]*event\.key !== "ContextMenu"[\s\S]*event\.shiftKey && event\.key === "F10"/,
|
|
56
56
|
"the menu should support pointer and standard keyboard context-menu activation",
|
|
57
57
|
);
|
|
58
58
|
assert.match(
|
|
@@ -11,15 +11,20 @@ const app = fs.readFileSync(path.join(root, "public/app.js"), "utf8");
|
|
|
11
11
|
const server = fs.readFileSync(path.join(root, "bin/pi-webui.mjs"), "utf8");
|
|
12
12
|
|
|
13
13
|
test("Control Deck exposes an accessible resize separator", () => {
|
|
14
|
-
assert.match(html, /id="sidePanelResizeHandle"[^>]*role="separator"[^>]*aria-orientation="vertical"[^>]*aria-label="Resize Control Deck width"[^>]*tabindex="0"/);
|
|
14
|
+
assert.match(html, /id="sidePanelResizeHandle"[^>]*role="separator"[^>]*aria-orientation="vertical"[^>]*aria-label="Resize right Control Deck width"[^>]*tabindex="0"/);
|
|
15
|
+
assert.match(html, /id="sidePanelLeftResizeHandle"[^>]*role="separator"[^>]*aria-orientation="vertical"[^>]*aria-label="Resize left Control Deck width"[^>]*tabindex="0"/);
|
|
15
16
|
assert.match(css, /--side-panel-width:\s*384px/);
|
|
16
|
-
assert.match(css, /\.side-panel-resize-handle[\s\S]*cursor:\s*col-resize[\s\S]*touch-action:\s*none
|
|
17
|
+
assert.match(css, /\.file-viewer-resize-handle,[\s\S]*\.side-panel-resize-handle,[\s\S]*\.terminal-tabs-resize-handle \{[\s\S]*width:\s*1\.35rem;[\s\S]*height:\s*5\.2rem;[\s\S]*cursor:\s*col-resize;[\s\S]*touch-action:\s*none;/, "the Control Deck handle must keep its 1.35rem hit target and pointer geometry");
|
|
18
|
+
assert.match(css, /\.side-panel-resize-handle::after \{[\s\S]*left:\s*50%;[\s\S]*width:\s*0\.8rem;[\s\S]*transform:\s*translateX\(-50%\);/, "the painted Control Deck pill should be 0.8rem wide and centered within the hit target");
|
|
19
|
+
assert.match(css, /\.side-panel-resize-handle:hover::after,[\s\S]*\.side-panel-resize-handle:focus-visible::after,[\s\S]*body\.side-panel-resizing \.side-panel-resize-handle::after \{[\s\S]*border-color:/, "hover, focus, and active resizing must style the narrow painted pill rather than the hit target");
|
|
20
|
+
assert.match(css, /\.side-panel-resize-handle-right \{[\s\S]*left:\s*-1\.175rem/);
|
|
21
|
+
assert.match(css, /\.side-panel-resize-handle-left \{[\s\S]*right:\s*-1\.175rem;[\s\S]*left:\s*auto/, "the left Control Deck handle must sit in the workspace-facing inter-column gap");
|
|
17
22
|
});
|
|
18
23
|
|
|
19
24
|
test("desktop layouts and Control Deck content follow the selected width", () => {
|
|
20
|
-
assert.match(css, /\.layout \{[\s\S]*grid-template-columns:\s*minmax\(0, 1fr\) minmax\(20rem, var\(--side-panel-width\)\)/);
|
|
21
|
-
assert.match(css, /body\.
|
|
22
|
-
assert.match(css, /body\.
|
|
25
|
+
assert.match(css, /\.layout \{[\s\S]*grid-template-columns:\s*minmax\(20rem, var\(--side-panel-left-width, 384px\)\) minmax\(0, 1fr\) minmax\(20rem, var\(--side-panel-right-width, var\(--side-panel-width\)\)\)/);
|
|
26
|
+
assert.match(css, /body\.control-deck-left \.layout[\s\S]*grid-template-columns:/);
|
|
27
|
+
assert.match(css, /body\.control-deck-both \.layout[\s\S]*grid-template-columns:/);
|
|
23
28
|
assert.match(css, /\.side-panel \{[\s\S]*width:\s*100%;[\s\S]*min-width:\s*0/);
|
|
24
29
|
});
|
|
25
30
|
|
|
@@ -27,25 +32,30 @@ test("Control Deck width is clamped, user-persisted, pointer-resizable, and keyb
|
|
|
27
32
|
assert.match(app, /const SIDE_PANEL_WIDTH_STORAGE_KEY = "pi-webui-side-panel-width"/);
|
|
28
33
|
assert.match(app, /const SIDE_PANEL_WIDTH_MAX_PX = 4096/);
|
|
29
34
|
assert.match(app, /width >= SIDE_PANEL_WIDTH_MIN_PX && width <= SIDE_PANEL_WIDTH_MAX_PX/);
|
|
30
|
-
assert.match(app, /function persistSidePanelWidth\(width\)[\s\S]
|
|
35
|
+
assert.match(app, /function persistSidePanelWidth\(width, side = "right"\)[\s\S]*panelWidths[\s\S]*markDurableUiLayoutDirty\("sidePanel", "panelWidths"\)/);
|
|
31
36
|
assert.match(app, /async function restoreSidePanelWidthPreference\(\)[\s\S]*\/api\/interface-preferences[\s\S]*response\.data\?\.preferences\?\.sidePanelWidth[\s\S]*cacheSidePanelWidth/);
|
|
32
37
|
assert.match(server, /url\.pathname === "\/api\/interface-preferences" && req\.method === "GET"/);
|
|
33
38
|
assert.match(server, /url\.pathname === "\/api\/interface-preferences" && req\.method === "PUT"/);
|
|
34
|
-
assert.match(app, /function sidePanelMaxWidth\(\)[\s\S]*fileViewerVisible[\s\S]*splitOpen[\s\S]*
|
|
35
|
-
assert.match(app, /function applySidePanelWidth\(width, \{ persist = false \} = \{\}\)[\s\S]*--side-panel-width[\s\S]*persistSidePanelWidth/);
|
|
36
|
-
assert.match(app, /function
|
|
37
|
-
assert.match(app, /function
|
|
39
|
+
assert.match(app, /function sidePanelMaxWidth\(side = "right"\)[\s\S]*fileViewerVisible[\s\S]*splitOpen[\s\S]*centralMinimum[\s\S]*otherPanelWidth[\s\S]*available/);
|
|
40
|
+
assert.match(app, /function applySidePanelWidth\(width, \{ persist = false, side = "right" \} = \{\}\)[\s\S]*--side-panel-left-width[\s\S]*--side-panel-right-width[\s\S]*if \(side === "right"\)[\s\S]*--side-panel-width[\s\S]*persistSidePanelWidth/);
|
|
41
|
+
assert.match(app, /function controlDeckSideResizeAvailable\(side = "right"\)[\s\S]*presentation === "left"[\s\S]*presentation === "both"[\s\S]*presentation === "right"/);
|
|
42
|
+
assert.match(app, /function beginSidePanelResize\(event, forcedSide = null\)[\s\S]*controlDeckSideResizeAvailable\(side\)[\s\S]*setPointerCapture[\s\S]*pointermove[\s\S]*pointercancel/);
|
|
43
|
+
assert.match(app, /function updateSidePanelResize\(event\)[\s\S]*state\.side === "left" \? event\.clientX - state\.startX : state\.startX - event\.clientX/);
|
|
44
|
+
assert.match(app, /function persistSidePanelWidth\(width, side = "right"\)[\s\S]*if \(side === "right"\) cacheSidePanelWidth\(rounded\)/, "left width must not overwrite the legacy right-width mirror");
|
|
45
|
+
assert.match(app, /sidePanel:\s*Boolean\(sidePanelSectionPointerDrag\?\.active \|\| sidePanelResizeState\)/, "active side-panel resize must fence durable reconciliation");
|
|
38
46
|
assert.match(app, /function handleSidePanelResizeKeydown\(event\)[\s\S]*ArrowLeft[\s\S]*ArrowRight[\s\S]*Home[\s\S]*End/);
|
|
39
47
|
assert.match(app, /elements\.sidePanelResizeHandle\?\.addEventListener\("pointerdown", beginSidePanelResize\);\nelements\.sidePanelResizeHandle\?\.addEventListener\("keydown", handleSidePanelResizeKeydown\);/);
|
|
48
|
+
assert.match(app, /elements\.sidePanelResizeHandleLeft\?\.addEventListener\("pointerdown", \(event\) => beginSidePanelResize\(event, "left"\)\);\nelements\.sidePanelResizeHandleLeft\?\.addEventListener\("keydown", handleSidePanelResizeKeydown\);/);
|
|
49
|
+
assert.match(app, /function reconcileControlDeckHosts\(\)[\s\S]*updateSidePanelResizeHandle\(currentSidePanelWidth\("left"\), "left"\)[\s\S]*updateSidePanelResizeHandle\(currentSidePanelWidth\("right"\), "right"\)/);
|
|
40
50
|
});
|
|
41
51
|
|
|
42
52
|
test("Control Deck resizing disables itself in overlay layouts and responds to viewport changes", () => {
|
|
43
|
-
assert.match(app, /
|
|
53
|
+
assert.match(app, /function controlDeckSideResizeAvailable\(side = "right"\)[\s\S]*presentation === "overlay"[\s\S]*presentation === "embedded"[\s\S]*collapsedPanels/);
|
|
44
54
|
assert.match(css, /@media \(max-width: 1050px\)[\s\S]*\.file-viewer-resize-handle,[\s\S]*\.side-panel-resize-handle \{\s*display:\s*none/);
|
|
45
|
-
assert.match(app, /window\.addEventListener\("resize",
|
|
46
|
-
assert.match(app, /function syncSidePanelWidthForViewport\(\)[\s\S]*applySidePanelWidth\(
|
|
47
|
-
assert.match(app, /function updateFileViewerUi\(\)[\s\S]*
|
|
48
|
-
assert.match(app, /function
|
|
49
|
-
assert.match(app, /function updateTerminalSplitUi\(\)[\s\S]*
|
|
55
|
+
assert.match(app, /window\.addEventListener\("resize", scheduleControlDeckPresentationReconciliation/);
|
|
56
|
+
assert.match(app, /function syncSidePanelWidthForViewport\(\)[\s\S]*applySidePanelWidth\(controlDeckLayout\.panelWidths\?\.left[\s\S]*applySidePanelWidth\(controlDeckLayout\.panelWidths\?\.right/, "viewport reconciliation should preserve both durable widths instead of freezing an in-progress CSS transition");
|
|
57
|
+
assert.match(app, /function updateFileViewerUi\(\)[\s\S]*scheduleControlDeckPresentationReconciliation\(\)/);
|
|
58
|
+
assert.match(app, /function resetFileViewerUi\(\)[\s\S]*scheduleControlDeckPresentationReconciliation\(\)/);
|
|
59
|
+
assert.match(app, /function updateTerminalSplitUi\(\)[\s\S]*scheduleControlDeckPresentationReconciliation\(\)/);
|
|
50
60
|
assert.match(app, /restoreSidePanelWidthPreference\(\);\nrestoreFileViewerWidthPreference\(\);/);
|
|
51
61
|
});
|
|
@@ -24,11 +24,11 @@ for (const removedToken of [
|
|
|
24
24
|
assert.doesNotMatch(css, new RegExp(removedToken), `${removedToken} should be absent from side-panel styles`);
|
|
25
25
|
}
|
|
26
26
|
assert.doesNotMatch(layout, /sectionHeightMin|sectionHeightMax|validateSectionHeights|sectionHeights/, "the durable layout schema should not expose section heights");
|
|
27
|
-
assert.match(app, /const UI_LAYOUT_SIDE_PANEL_FIELDS = \["
|
|
27
|
+
assert.match(app, /const UI_LAYOUT_SIDE_PANEL_FIELDS = \["placement", "sectionLayout", "collapsedSectionIds", "hiddenSectionIds", "collapsedPanels", "panelWidths"\];/, "the browser durable layout field list should omit section heights");
|
|
28
28
|
assert.match(app, /function clearRemovedSidePanelSectionHeightState\(\)[\s\S]*localStorage\.removeItem\(REMOVED_SIDE_PANEL_SECTION_HEIGHT_STORAGE_KEY\)[\s\S]*record\.field === "sidePanel" && record\.subfield === "sectionHeights"/, "startup should remove the retired cache and pending mutations");
|
|
29
29
|
assert.match(app, /clearRemovedSidePanelSectionHeightState\(\);\s*restoreDurableUiLayoutPendingJournal\(\);/, "retired height state should be cleared before pending layout restoration");
|
|
30
|
-
assert.match(html, /styles\.css\?v=
|
|
31
|
-
assert.match(html, /app\.js\?v=
|
|
32
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
30
|
+
assert.match(html, /styles\.css\?v=123/, "removing section resize styles should advance the stylesheet revision");
|
|
31
|
+
assert.match(html, /app\.js\?v=146/, "removing section resize behavior should advance the app revision");
|
|
32
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "removing browser assets should advance the PWA cache identity");
|
|
33
33
|
|
|
34
34
|
console.log("side-panel-section-height-removal-static.test.mjs passed");
|
|
@@ -4,78 +4,24 @@ import { dirname, join } from "node:path";
|
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
|
|
6
6
|
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
|
-
const [html, app, css
|
|
7
|
+
const [html, app, css] = await Promise.all([
|
|
8
8
|
readFile(join(root, "public", "index.html"), "utf8"),
|
|
9
9
|
readFile(join(root, "public", "app.js"), "utf8"),
|
|
10
10
|
readFile(join(root, "public", "styles.css"), "utf8"),
|
|
11
|
-
readFile(join(root, "public", "service-worker.js"), "utf8"),
|
|
12
11
|
]);
|
|
13
|
-
|
|
14
|
-
assert.match(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
);
|
|
19
|
-
assert.match(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
);
|
|
24
|
-
assert.match(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
);
|
|
29
|
-
assert.match(
|
|
30
|
-
app,
|
|
31
|
-
/function isSidePanelSectionReorderingEnabled\(\) \{\n\s+return !isMobileView\(\) \|\| sidePanelSectionEditMode;[\s\S]*function moveSidePanelSectionRelative\(fromId, targetRecord, insertBefore\) \{\n\s+if \(!isSidePanelSectionReorderingEnabled\(\)\) return false;[\s\S]*parent\.insertBefore\(sourceRecord\.section, targetRecord\.section\)[\s\S]*targetRecord\.section\.nextSibling[\s\S]*persistSidePanelSectionOrder\(\)/,
|
|
32
|
-
"desktop reordering should stay enabled while mobile reordering fails closed outside Edit mode",
|
|
33
|
-
);
|
|
34
|
-
assert.match(
|
|
35
|
-
app,
|
|
36
|
-
/function moveSidePanelSectionByOffset\(sectionId, offset\) \{\n\s+if \(!isSidePanelSectionReorderingEnabled\(\)\) return false;/,
|
|
37
|
-
"keyboard reordering should follow the desktop-always/mobile-Edit gate",
|
|
38
|
-
);
|
|
39
|
-
assert.match(
|
|
40
|
-
app,
|
|
41
|
-
/function beginSidePanelSectionPointerDrag\(event, sectionId\) \{\n\s+if \(!isSidePanelSectionReorderingEnabled\(\) \|\| event\.button !== 0/,
|
|
42
|
-
"pointer and touch dragging should follow the responsive reorder gate",
|
|
43
|
-
);
|
|
44
|
-
assert.match(
|
|
45
|
-
app,
|
|
46
|
-
/function updateSidePanelSectionPointerDrag\(event\)[\s\S]*Math\.hypot[\s\S]*SIDE_PANEL_SECTION_POINTER_DRAG_THRESHOLD_PX[\s\S]*sidePanelSectionToggleFromPoint[\s\S]*getBoundingClientRect\(\)[\s\S]*moveSidePanelSectionRelative/,
|
|
47
|
-
"edit-mode pointer dragging should activate only after the threshold and use header midpoint placement",
|
|
48
|
-
);
|
|
49
|
-
assert.match(
|
|
50
|
-
app,
|
|
51
|
-
/function endSidePanelSectionPointerDrag\(event\)[\s\S]*sidePanelSectionSuppressClickUntil = Date\.now\(\) \+ 250[\s\S]*focus\(\{ preventScroll: true \}\)/,
|
|
52
|
-
"a completed drag should suppress the accidental toggle click and restore focus",
|
|
53
|
-
);
|
|
54
|
-
assert.match(
|
|
55
|
-
app,
|
|
56
|
-
/function bindSidePanelSectionToggles\(\)[\s\S]*Date\.now\(\) < sidePanelSectionSuppressClickUntil[\s\S]*!isSidePanelSectionReorderingEnabled\(\) \|\| !event\.altKey[\s\S]*event\.key !== "ArrowUp"[\s\S]*moveSidePanelSectionByOffset[\s\S]*beginSidePanelSectionPointerDrag/,
|
|
57
|
-
"section headers should retain click toggling while the responsive gate controls Alt+Arrow and pointer reordering",
|
|
58
|
-
);
|
|
59
|
-
assert.match(
|
|
60
|
-
app,
|
|
61
|
-
/restoreSidePanelSectionOrder\(\);\s*restoreSidePanelSectionVisibility\(\);\s*restoreSidePanelSectionState\(\);/,
|
|
62
|
-
"saved order should restore before visibility and accordion state",
|
|
63
|
-
);
|
|
64
|
-
assert.match(
|
|
65
|
-
app,
|
|
66
|
-
/event\.key === SIDE_PANEL_SECTION_ORDER_STORAGE_KEY\) restoreSidePanelSectionOrder\(\)/,
|
|
67
|
-
"other tabs should apply stored side-panel order changes",
|
|
68
|
-
);
|
|
69
|
-
assert.match(
|
|
70
|
-
css,
|
|
71
|
-
/\.side-panel-edit-button \{\n\s+display: none;[\s\S]*?\.side-panel\.section-edit-mode \.side-panel-section-toggle\[data-side-panel-section-toggle\] \{\n\s+cursor: grab;\n\s+touch-action: none;\n\s+user-select: none;\n\}[\s\S]*?@media \(max-width: 720px\), \(max-device-width: 720px\), \(pointer: coarse\) and \(hover: none\) \{[\s\S]*?\.side-panel-edit-button \{ display: inline-flex;[\s\S]*?\.side-panel\.section-edit-mode \.side-panel-section-toggle\[data-side-panel-section-toggle\] \{\n\s+border-color:[\s\S]*?box-shadow:[\s\S]*?\.side-panel\.section-edit-mode \.side-panel-section-label::before \{/,
|
|
72
|
-
"desktop should keep drag capture without edit highlighting while mobile restores Edit and its visual affordance",
|
|
73
|
-
);
|
|
74
|
-
assert.match(html, /id="sidePanelEditButton"[^>]*aria-controls="sidePanel"[^>]*aria-pressed="false"[^>]*aria-label="Edit Control Deck section order"[\s\S]*side-panel-edit-button-label">Edit</, "mobile Control Deck should retain an accessible Edit toggle");
|
|
75
|
-
assert.match(app, /function setSidePanelSectionEditMode\(enabled\)[\s\S]*const next = isMobileView\(\) && !!enabled;[\s\S]*classList\.toggle\("section-edit-mode", reorderingEnabled\)[\s\S]*aria-pressed[\s\S]*"Done" : "Edit"[\s\S]*aria-keyshortcuts/, "mobile Edit state and always-enabled desktop reorder affordances should stay synchronized");
|
|
76
|
-
assert.match(app, /function setSidePanelCollapsed\(collapsed,[\s\S]*if \(collapsed\) setSidePanelSectionEditMode\(false\);/, "closing the Control Deck should leave transient edit mode");
|
|
77
|
-
assert.match(html, /styles\.css\?v=107/, "changed side-panel styles should advance the stylesheet revision");
|
|
78
|
-
assert.match(html, /app\.js\?v=121/, "changed side-panel behavior should advance the app revision");
|
|
79
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v84"/, "changed browser assets should advance the PWA cache identity");
|
|
80
|
-
|
|
12
|
+
assert.match(app, /const SIDE_PANEL_SECTION_ORDER_STORAGE_KEY = "pi-webui-side-panel-section-order-v1"/);
|
|
13
|
+
assert.match(app, /const SIDE_PANEL_SECTION_POINTER_DRAG_THRESHOLD_PX = 6/);
|
|
14
|
+
assert.match(app, /function controlDeckSectionRecords\(\)[\s\S]*document\.querySelectorAll\("\[data-side-panel-section\]"\)/);
|
|
15
|
+
assert.match(app, /function persistControlDeckSectionLayout\(\)[\s\S]*sectionLayout[\s\S]*markDurableUiLayoutDirty\("sidePanel", "sectionLayout"\)/);
|
|
16
|
+
assert.match(app, /function moveSidePanelSectionRelative\(fromId, targetRecord, insertBefore, targetSide = null\)[\s\S]*parent\.insertBefore\(sourceRecord\.section, targetRecord\.section\)/);
|
|
17
|
+
assert.match(app, /function moveSidePanelSectionToSide\(sectionId, side\)[\s\S]*effectiveControlDeckPresentation\(\) !== "both"/);
|
|
18
|
+
assert.match(app, /function updateSidePanelSectionPointerDrag\(event\)[\s\S]*Math\.hypot[\s\S]*SIDE_PANEL_SECTION_POINTER_DRAG_THRESHOLD_PX[\s\S]*data-control-deck-drop-target/);
|
|
19
|
+
assert.match(app, /\["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"\]/);
|
|
20
|
+
assert.match(app, /function setOnlySidePanelSectionExpanded[\s\S]*controlDeckSectionSide\(record\.id\) !== targetSide/);
|
|
21
|
+
assert.match(app, /function setSidePanelSectionEditMode\(enabled\)[\s\S]*const next = isMobileView\(\) && !!enabled/);
|
|
22
|
+
assert.match(html, /id="sidePanelEditButton"[^>]*aria-controls="sidePanel"[^>]*aria-pressed="false"/);
|
|
23
|
+
assert.match(html, /data-control-deck-drop-target="left"/);
|
|
24
|
+
assert.match(html, /data-control-deck-drop-target="right"/);
|
|
25
|
+
assert.match(css, /\.side-panel\.section-edit-mode \.side-panel-section-toggle\[data-side-panel-section-toggle\]/);
|
|
26
|
+
assert.match(css, /\.side-panel-section\.drag-over-before/);
|
|
81
27
|
console.log("side-panel-section-reorder-static.test.mjs passed");
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
TRANSCRIPT_STREAM_MESSAGE_UPDATE_TYPES,
|
|
6
6
|
classifyTranscriptStreamEvent,
|
|
7
7
|
createStreamOutputController,
|
|
8
|
+
reconcileTranscriptThinkingSnapshot,
|
|
8
9
|
} from "../public/stream-output-controller.mjs";
|
|
9
10
|
|
|
10
11
|
function messageUpdate(type, delta = "", extra = {}) {
|
|
@@ -53,6 +54,13 @@ assert.deepEqual(classifyTranscriptStreamEvent(messageUpdate("future_delta")), {
|
|
|
53
54
|
assert.equal(classifyTranscriptStreamEvent({ type: "agent_start" }), null);
|
|
54
55
|
assert.equal(DEFAULT_STREAM_PENDING_ENTRY_LIMIT, 128);
|
|
55
56
|
assert.equal(DEFAULT_STREAM_PENDING_BYTE_LIMIT, 256 * 1024);
|
|
57
|
+
assert.equal(
|
|
58
|
+
reconcileTranscriptThinkingSnapshot("first\n\nsecond\n\nthird\n\nfourth", "first\n\nsecond\n\nthird"),
|
|
59
|
+
"first\n\nsecond\n\nthird\n\nfourth",
|
|
60
|
+
"a regressive final thinking snapshot must not remove an already-rendered tail",
|
|
61
|
+
);
|
|
62
|
+
assert.equal(reconcileTranscriptThinkingSnapshot("short", "shorter complete"), "shorter complete", "a longer compatible final snapshot should win");
|
|
63
|
+
assert.equal(reconcileTranscriptThinkingSnapshot("draft reasoning", "provider correction"), "provider correction", "divergent provider corrections must remain authoritative");
|
|
56
64
|
|
|
57
65
|
// Adjacent compatible deltas coalesce, while kind changes retain exact order.
|
|
58
66
|
{
|