@firstpick/pi-package-webui 0.8.6 → 0.8.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 +18 -606
- package/bin/pi-webui-launcher.mjs +22 -0
- package/bin/pi-webui-update-supervisor.mjs +86 -0
- package/bin/pi-webui.mjs +562 -524
- package/index.ts +8 -5
- package/lib/component-update-state.mjs +21 -0
- package/lib/git-workflow-preferences.mjs +17 -2
- package/lib/optional-feature-catalog.mjs +1 -0
- package/lib/sampling-parameter-capabilities.mjs +160 -0
- package/lib/session-summary-preferences.mjs +16 -1
- package/lib/subagent-launch-slots.mjs +14 -2
- package/lib/trust-boundaries.mjs +3 -0
- package/lib/update/executor.mjs +99 -0
- package/lib/update/journal.mjs +175 -0
- package/lib/update/owners.mjs +70 -0
- package/lib/update/plan.mjs +134 -0
- package/lib/update/resolver.mjs +168 -0
- package/lib/update/supervisor.mjs +238 -0
- package/lib/update/verify.mjs +52 -0
- package/lib/update-commands.mjs +25 -13
- package/lib/webui-workspaces.mjs +17 -1
- package/package.json +4 -4
- package/public/app.js +1543 -109
- package/public/index.html +146 -48
- package/public/middle-button-drag-scroll.mjs +154 -0
- package/public/sampling-parameter-controls.mjs +361 -0
- package/public/service-worker.js +3 -1
- package/public/styles.css +512 -1
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/control-deck-component-updates.spec.mjs +20 -22
- package/tests/browser/middle-button-drag-scroll.spec.mjs +145 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +68 -23
- package/tests/browser/sampling-tooltip.spec.mjs +228 -0
- package/tests/browser/update-reconnect.spec.mjs +92 -0
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/common-options-submenus-interaction-static.test.mjs +172 -0
- package/tests/common-options-submenus-markup-static.test.mjs +152 -0
- package/tests/component-update-api-static.test.mjs +22 -61
- package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
- package/tests/control-deck-component-updates-static.test.mjs +13 -237
- package/tests/durable-rpc-supervisor-harness.test.mjs +3 -1
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/feature-system-prompt-optional-feature-static.test.mjs +49 -0
- package/tests/fixtures/fake-pi.mjs +68 -1
- package/tests/fixtures/update/tree-timeout-descendant.mjs +6 -0
- package/tests/fixtures/update/tree-timeout-parent.mjs +11 -0
- package/tests/git-footer-context-menu-static.test.mjs +58 -0
- package/tests/http-endpoints-harness.test.mjs +68 -18
- package/tests/middle-button-drag-scroll-static.test.mjs +24 -0
- package/tests/middle-button-drag-scroll.test.mjs +170 -0
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +4 -4
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +217 -24
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/optional-feature-migration-frontend.test.mjs +13 -5
- package/tests/persistent-ui-layout-static.test.mjs +13 -2
- package/tests/prompt-routing-tab-status.test.mjs +8 -0
- package/tests/questionnaire-dialog.test.mjs +3 -3
- package/tests/remote-auth-settings-harness.test.mjs +34 -0
- package/tests/rpc-supervisor-host.test.mjs +11 -2
- package/tests/safety-guard-auto-review-harness.test.mjs +117 -0
- package/tests/safety-guard-auto-review-static.test.mjs +34 -0
- package/tests/sampling-native-controls-user-flow.test.mjs +752 -0
- package/tests/sampling-parameter-capabilities.test.mjs +167 -0
- package/tests/sampling-parameter-controls.test.mjs +241 -0
- package/tests/session-sampling-helper.test.mjs +228 -0
- package/tests/session-sampling-http.test.mjs +168 -0
- package/tests/session-sampling-ui-static.test.mjs +370 -0
- package/tests/session-summary-core.test.mjs +24 -11
- package/tests/side-panel-section-height-removal-static.test.mjs +34 -0
- package/tests/side-panel-section-reorder-static.test.mjs +3 -3
- package/tests/staged-content-hash-contract.test.mjs +52 -11
- package/tests/subagent-launch-slots.test.mjs +18 -1
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/tests/ui-layout-settings.test.mjs +18 -1
- package/tests/update-api-harness.test.mjs +111 -0
- package/tests/update-commands.test.mjs +15 -45
- package/tests/update-executor-process-tree-harness.test.mjs +22 -0
- package/tests/update-journal-harness.test.mjs +59 -0
- package/tests/update-lock-multiprocess-harness.test.mjs +46 -0
- package/tests/update-owners.test.mjs +27 -0
- package/tests/update-plan.test.mjs +58 -0
- package/tests/update-resolver.test.mjs +56 -0
- package/tests/update-supervisor-harness.test.mjs +57 -0
- package/tests/update-tab-restore-harness.test.mjs +24 -0
- package/tests/update-verify.test.mjs +31 -0
- package/tests/workspace-files-live-updates-static.test.mjs +13 -4
- package/webui-rpc-helper.mjs +119 -0
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
const PARAMETER_DEFINITIONS = [
|
|
2
|
+
{
|
|
3
|
+
key: "temperature",
|
|
4
|
+
label: "Temperature",
|
|
5
|
+
kind: "number",
|
|
6
|
+
group: "core",
|
|
7
|
+
scopeLabel: "OpenAI-compatible core",
|
|
8
|
+
description: "Controls randomness. A value of 0 is deterministic on common compatible servers.",
|
|
9
|
+
min: 0,
|
|
10
|
+
max: 2,
|
|
11
|
+
step: 0.01,
|
|
12
|
+
slider: { min: 0, max: 2, step: 0.01 },
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
key: "top_p",
|
|
16
|
+
label: "Top P",
|
|
17
|
+
kind: "number",
|
|
18
|
+
group: "core",
|
|
19
|
+
scopeLabel: "OpenAI-compatible core",
|
|
20
|
+
description: "Limits sampling to tokens inside the selected cumulative probability mass.",
|
|
21
|
+
min: 0,
|
|
22
|
+
minExclusive: true,
|
|
23
|
+
max: 1,
|
|
24
|
+
step: 0.01,
|
|
25
|
+
slider: { min: 0.01, max: 1, step: 0.01 },
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
key: "frequency_penalty",
|
|
29
|
+
label: "Frequency penalty",
|
|
30
|
+
kind: "number",
|
|
31
|
+
group: "core",
|
|
32
|
+
scopeLabel: "OpenAI-compatible core",
|
|
33
|
+
description: "Adjusts repeated-token likelihood according to prior frequency.",
|
|
34
|
+
min: -2,
|
|
35
|
+
max: 2,
|
|
36
|
+
step: 0.1,
|
|
37
|
+
slider: { min: -2, max: 2, step: 0.1 },
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
key: "presence_penalty",
|
|
41
|
+
label: "Presence penalty",
|
|
42
|
+
kind: "number",
|
|
43
|
+
group: "core",
|
|
44
|
+
scopeLabel: "OpenAI-compatible core",
|
|
45
|
+
description: "Adjusts repeated-token likelihood according to whether a token appeared.",
|
|
46
|
+
min: -2,
|
|
47
|
+
max: 2,
|
|
48
|
+
step: 0.1,
|
|
49
|
+
slider: { min: -2, max: 2, step: 0.1 },
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
key: "seed",
|
|
53
|
+
label: "Seed",
|
|
54
|
+
kind: "integer",
|
|
55
|
+
group: "core",
|
|
56
|
+
scopeLabel: "Provider-dependent core",
|
|
57
|
+
description: "Requests repeatable sampling when supported. Common local servers use -1 for a random seed.",
|
|
58
|
+
min: -1,
|
|
59
|
+
step: 1,
|
|
60
|
+
slider: { min: 0, max: 100000, step: 1 },
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
key: "top_k",
|
|
64
|
+
label: "Top K",
|
|
65
|
+
kind: "integer",
|
|
66
|
+
group: "server-extension",
|
|
67
|
+
scopeLabel: "llama.cpp / vLLM extension",
|
|
68
|
+
description: "Limits sampling to the most likely tokens. Common compatible servers use 0 to disable it.",
|
|
69
|
+
min: -1,
|
|
70
|
+
step: 1,
|
|
71
|
+
slider: { min: 0, max: 200, step: 1 },
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
key: "min_p",
|
|
75
|
+
label: "Min P",
|
|
76
|
+
kind: "number",
|
|
77
|
+
group: "server-extension",
|
|
78
|
+
scopeLabel: "llama.cpp / vLLM extension",
|
|
79
|
+
description: "Filters tokens relative to the most likely token. Common compatible servers use 0 to disable it.",
|
|
80
|
+
min: 0,
|
|
81
|
+
max: 1,
|
|
82
|
+
step: 0.01,
|
|
83
|
+
slider: { min: 0, max: 1, step: 0.01 },
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
function freezeDefinition(definition) {
|
|
88
|
+
return Object.freeze({
|
|
89
|
+
...definition,
|
|
90
|
+
slider: Object.freeze({ ...definition.slider }),
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export const SAMPLING_PARAMETER_CATALOG = Object.freeze(PARAMETER_DEFINITIONS.map(freezeDefinition));
|
|
95
|
+
export const SAMPLING_PARAMETER_KEYS = Object.freeze(SAMPLING_PARAMETER_CATALOG.map(({ key }) => key));
|
|
96
|
+
|
|
97
|
+
const CATALOG_BY_KEY = new Map(SAMPLING_PARAMETER_CATALOG.map((definition) => [definition.key, definition]));
|
|
98
|
+
const NUMERIC_TEXT_PATTERN = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;
|
|
99
|
+
|
|
100
|
+
export class SamplingParameterValidationError extends Error {
|
|
101
|
+
constructor(message, errors = {}) {
|
|
102
|
+
super(message);
|
|
103
|
+
this.name = "SamplingParameterValidationError";
|
|
104
|
+
this.code = "SAMPLING_PARAMETERS_INVALID";
|
|
105
|
+
this.errors = errors;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function isPlainObject(value) {
|
|
110
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
111
|
+
const prototype = Object.getPrototypeOf(value);
|
|
112
|
+
return prototype === Object.prototype || prototype === null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function assertJsonValue(value, seen = new Set()) {
|
|
116
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return;
|
|
117
|
+
if (typeof value === "number") {
|
|
118
|
+
if (!Number.isFinite(value)) throw new TypeError("Sampling parameter values must contain only finite JSON numbers.");
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (typeof value !== "object") throw new TypeError("Sampling parameters must contain only JSON-compatible values.");
|
|
122
|
+
if (seen.has(value)) throw new TypeError("Sampling parameters must not contain circular values.");
|
|
123
|
+
seen.add(value);
|
|
124
|
+
if (Array.isArray(value)) {
|
|
125
|
+
for (const item of value) assertJsonValue(item, seen);
|
|
126
|
+
} else {
|
|
127
|
+
if (!isPlainObject(value)) throw new TypeError("Sampling parameter objects must use a plain object prototype.");
|
|
128
|
+
for (const item of Object.values(value)) assertJsonValue(item, seen);
|
|
129
|
+
}
|
|
130
|
+
seen.delete(value);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function cloneJsonObject(value, label = "Sampling parameters") {
|
|
134
|
+
if (!isPlainObject(value)) throw new TypeError(`${label} must be a plain object.`);
|
|
135
|
+
assertJsonValue(value);
|
|
136
|
+
return JSON.parse(JSON.stringify(value));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function errorResult(message) {
|
|
140
|
+
return { valid: false, error: message };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function numericValue(rawValue) {
|
|
144
|
+
if (typeof rawValue === "number") return Number.isFinite(rawValue) ? rawValue : null;
|
|
145
|
+
if (typeof rawValue !== "string") return null;
|
|
146
|
+
const text = rawValue.trim();
|
|
147
|
+
if (!text || !NUMERIC_TEXT_PATTERN.test(text)) return null;
|
|
148
|
+
const value = Number(text);
|
|
149
|
+
return Number.isFinite(value) ? value : null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function rangeMessage(definition) {
|
|
153
|
+
const { label, min, minExclusive, max } = definition;
|
|
154
|
+
if (min !== undefined && max !== undefined) {
|
|
155
|
+
return minExclusive
|
|
156
|
+
? `${label} must be greater than ${min} and at most ${max}.`
|
|
157
|
+
: `${label} must be from ${min} to ${max}.`;
|
|
158
|
+
}
|
|
159
|
+
if (min !== undefined) return minExclusive ? `${label} must be greater than ${min}.` : `${label} must be at least ${min}.`;
|
|
160
|
+
if (max !== undefined) return `${label} must be at most ${max}.`;
|
|
161
|
+
return `${label} is outside its accepted range.`;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function samplingParameterDefinition(key) {
|
|
165
|
+
return CATALOG_BY_KEY.get(String(key || "")) || null;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Normalize one backend capability entry. Support is explicit: a missing or
|
|
170
|
+
* malformed per-key map never inherits the legacy whole-API support flag.
|
|
171
|
+
*/
|
|
172
|
+
export function samplingParameterCapability(parameters, key) {
|
|
173
|
+
const definition = samplingParameterDefinition(key);
|
|
174
|
+
if (!definition) throw new RangeError(`Unknown sampling parameter: ${String(key)}.`);
|
|
175
|
+
const entry = isPlainObject(parameters) && isPlainObject(parameters[key]) ? parameters[key] : null;
|
|
176
|
+
const supported = entry?.supported === true;
|
|
177
|
+
const suppliedReason = typeof entry?.reason === "string" ? entry.reason.trim() : "";
|
|
178
|
+
return {
|
|
179
|
+
supported,
|
|
180
|
+
reason: suppliedReason || (supported
|
|
181
|
+
? `${definition.label} is supported by the active model.`
|
|
182
|
+
: `${definition.label} is disabled because support was not reported for the active model.`),
|
|
183
|
+
source: typeof entry?.source === "string" && entry.source ? entry.source : supported ? "api" : "unsupported",
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Parse and validate a value from either API state or a native number input. */
|
|
188
|
+
export function validateSamplingParameterValue(key, rawValue, { requireNumber = false } = {}) {
|
|
189
|
+
const definition = samplingParameterDefinition(key);
|
|
190
|
+
if (!definition) return errorResult(`Unknown sampling parameter: ${String(key)}.`);
|
|
191
|
+
if (requireNumber && typeof rawValue !== "number") return errorResult(`${definition.label} must be a number.`);
|
|
192
|
+
const value = numericValue(rawValue);
|
|
193
|
+
if (value === null) return errorResult(`${definition.label} must be a finite number.`);
|
|
194
|
+
if (definition.kind === "integer" && !Number.isInteger(value)) {
|
|
195
|
+
return errorResult(`${definition.label} must be an integer.`);
|
|
196
|
+
}
|
|
197
|
+
if (definition.min !== undefined) {
|
|
198
|
+
if (definition.minExclusive ? value <= definition.min : value < definition.min) return errorResult(rangeMessage(definition));
|
|
199
|
+
}
|
|
200
|
+
if (definition.max !== undefined && value > definition.max) return errorResult(rangeMessage(definition));
|
|
201
|
+
return { valid: true, value };
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** Validate catalog-known values from a direct JSON write without rejecting unknown keys. */
|
|
205
|
+
export function validateSamplingParameterObject(parameters) {
|
|
206
|
+
if (!isPlainObject(parameters)) {
|
|
207
|
+
return { valid: false, errors: { parameters: "Sampling parameters must be a plain object." } };
|
|
208
|
+
}
|
|
209
|
+
const errors = {};
|
|
210
|
+
for (const definition of SAMPLING_PARAMETER_CATALOG) {
|
|
211
|
+
if (!Object.hasOwn(parameters, definition.key)) continue;
|
|
212
|
+
const result = validateSamplingParameterValue(definition.key, parameters[definition.key], { requireNumber: true });
|
|
213
|
+
if (!result.valid) errors[definition.key] = result.error;
|
|
214
|
+
}
|
|
215
|
+
return { valid: Object.keys(errors).length === 0, errors };
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Return the slider's visual position without changing the exact number-input value.
|
|
220
|
+
* Values outside the common slider range are represented at the nearest slider edge.
|
|
221
|
+
*/
|
|
222
|
+
export function samplingParameterSliderValue(key, rawValue) {
|
|
223
|
+
const definition = samplingParameterDefinition(key);
|
|
224
|
+
if (!definition) throw new RangeError(`Unknown sampling parameter: ${String(key)}.`);
|
|
225
|
+
const result = validateSamplingParameterValue(key, rawValue);
|
|
226
|
+
if (!result.valid) return definition.slider.min;
|
|
227
|
+
return Math.min(definition.slider.max, Math.max(definition.slider.min, result.value));
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** Split a plain JSON object into catalog-known values and preserved hidden values. */
|
|
231
|
+
export function splitSamplingParameters(parameters = {}) {
|
|
232
|
+
const source = cloneJsonObject(parameters);
|
|
233
|
+
const known = {};
|
|
234
|
+
const unknown = {};
|
|
235
|
+
for (const [key, value] of Object.entries(source)) {
|
|
236
|
+
if (CATALOG_BY_KEY.has(key)) known[key] = value;
|
|
237
|
+
else Object.defineProperty(unknown, key, { value, enumerable: true, writable: true, configurable: true });
|
|
238
|
+
}
|
|
239
|
+
return { known, unknown };
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function validSuggestedValue(key, ...candidates) {
|
|
243
|
+
for (const candidate of candidates) {
|
|
244
|
+
const result = validateSamplingParameterValue(key, candidate);
|
|
245
|
+
if (result.valid) return result.value;
|
|
246
|
+
}
|
|
247
|
+
return "";
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Create a UI draft from the session object. Disabled controls may show a valid model
|
|
252
|
+
* default as a suggestion, but disabled values are never serialized.
|
|
253
|
+
*/
|
|
254
|
+
export function createSamplingControlDraft(parameters = {}, { defaults = {} } = {}) {
|
|
255
|
+
const session = splitSamplingParameters(parameters);
|
|
256
|
+
const modelDefaults = splitSamplingParameters(defaults);
|
|
257
|
+
const controls = {};
|
|
258
|
+
for (const definition of SAMPLING_PARAMETER_CATALOG) {
|
|
259
|
+
const enabled = Object.hasOwn(session.known, definition.key);
|
|
260
|
+
controls[definition.key] = {
|
|
261
|
+
enabled,
|
|
262
|
+
value: enabled
|
|
263
|
+
? session.known[definition.key]
|
|
264
|
+
: validSuggestedValue(definition.key, modelDefaults.known[definition.key]),
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
return {
|
|
268
|
+
controls,
|
|
269
|
+
preservedUnknown: session.unknown,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export function validateSamplingControlDraft(draft) {
|
|
274
|
+
const errors = {};
|
|
275
|
+
const values = {};
|
|
276
|
+
if (!isPlainObject(draft)) return { valid: false, errors: { draft: "Sampling control draft must be an object." }, values };
|
|
277
|
+
if (!isPlainObject(draft.controls)) errors.controls = "Sampling control draft controls must be an object.";
|
|
278
|
+
try {
|
|
279
|
+
cloneJsonObject(draft.preservedUnknown ?? {}, "Preserved sampling parameters");
|
|
280
|
+
} catch (error) {
|
|
281
|
+
errors.preservedUnknown = error.message || String(error);
|
|
282
|
+
}
|
|
283
|
+
const controls = isPlainObject(draft.controls) ? draft.controls : {};
|
|
284
|
+
for (const definition of SAMPLING_PARAMETER_CATALOG) {
|
|
285
|
+
const control = controls[definition.key];
|
|
286
|
+
if (control === undefined) continue;
|
|
287
|
+
if (!isPlainObject(control)) {
|
|
288
|
+
errors[definition.key] = `${definition.label} control state must be an object.`;
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
if (typeof control.enabled !== "boolean") {
|
|
292
|
+
errors[definition.key] = `${definition.label} enabled state must be a boolean.`;
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
if (!control.enabled) continue;
|
|
296
|
+
const result = validateSamplingParameterValue(definition.key, control.value);
|
|
297
|
+
if (!result.valid) errors[definition.key] = result.error;
|
|
298
|
+
else values[definition.key] = result.value;
|
|
299
|
+
}
|
|
300
|
+
return { valid: Object.keys(errors).length === 0, errors, values };
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** Build the direct JSON API object while preserving unknown values and deleting disabled known keys. */
|
|
304
|
+
export function buildSamplingParametersFromDraft(draft) {
|
|
305
|
+
const validation = validateSamplingControlDraft(draft);
|
|
306
|
+
if (!validation.valid) {
|
|
307
|
+
throw new SamplingParameterValidationError(
|
|
308
|
+
`Invalid sampling parameters: ${Object.values(validation.errors).join(" ")}`,
|
|
309
|
+
validation.errors,
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
const output = cloneJsonObject(draft.preservedUnknown ?? {}, "Preserved sampling parameters");
|
|
313
|
+
for (const key of SAMPLING_PARAMETER_KEYS) delete output[key];
|
|
314
|
+
for (const [key, value] of Object.entries(validation.values)) output[key] = value;
|
|
315
|
+
return output;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function stableJson(value) {
|
|
319
|
+
if (Array.isArray(value)) return `[${value.map(stableJson).join(",")}]`;
|
|
320
|
+
if (isPlainObject(value)) {
|
|
321
|
+
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stableJson(value[key])}`).join(",")}}`;
|
|
322
|
+
}
|
|
323
|
+
return JSON.stringify(value);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function comparableDraft(draft) {
|
|
327
|
+
const controls = {};
|
|
328
|
+
const draftControls = isPlainObject(draft?.controls) ? draft.controls : {};
|
|
329
|
+
for (const definition of SAMPLING_PARAMETER_CATALOG) {
|
|
330
|
+
const control = isPlainObject(draftControls[definition.key]) ? draftControls[definition.key] : { enabled: false, value: "" };
|
|
331
|
+
const enabled = control.enabled === true;
|
|
332
|
+
const validation = enabled ? validateSamplingParameterValue(definition.key, control.value) : null;
|
|
333
|
+
controls[definition.key] = {
|
|
334
|
+
enabled,
|
|
335
|
+
value: !enabled ? null : validation?.valid ? validation.value : String(control.value ?? ""),
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
let preservedUnknown;
|
|
339
|
+
try {
|
|
340
|
+
preservedUnknown = cloneJsonObject(draft?.preservedUnknown ?? {}, "Preserved sampling parameters");
|
|
341
|
+
} catch {
|
|
342
|
+
preservedUnknown = { invalid: true };
|
|
343
|
+
}
|
|
344
|
+
return { controls, preservedUnknown };
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/** Compare serialized meaning; equivalent numeric text such as 1 and "1.0" is equal. */
|
|
348
|
+
export function samplingControlDraftEquals(left, right) {
|
|
349
|
+
return stableJson(comparableDraft(left)) === stableJson(comparableDraft(right));
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export function summarizePreservedSamplingParameters(parameters = {}) {
|
|
353
|
+
const preserved = cloneJsonObject(parameters, "Preserved sampling parameters");
|
|
354
|
+
const count = Object.keys(preserved).length;
|
|
355
|
+
return {
|
|
356
|
+
count,
|
|
357
|
+
text: count === 0
|
|
358
|
+
? "No additional parameters are preserved outside this editor."
|
|
359
|
+
: `${count} additional ${count === 1 ? "parameter is" : "parameters are"} preserved outside this editor.`,
|
|
360
|
+
};
|
|
361
|
+
}
|
package/public/service-worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const CACHE_NAME = "pi-webui-pwa-
|
|
1
|
+
const CACHE_NAME = "pi-webui-pwa-v81";
|
|
2
2
|
const APP_SHELL = [
|
|
3
3
|
"/",
|
|
4
4
|
"/index.html",
|
|
@@ -12,7 +12,9 @@ const APP_SHELL = [
|
|
|
12
12
|
"/guided-git-review-state.mjs",
|
|
13
13
|
"/fast-output-live.mjs",
|
|
14
14
|
"/stream-output-controller.mjs",
|
|
15
|
+
"/middle-button-drag-scroll.mjs",
|
|
15
16
|
"/theme-contract.mjs",
|
|
17
|
+
"/sampling-parameter-controls.mjs",
|
|
16
18
|
"/transcript-renderer.mjs",
|
|
17
19
|
"/subagent-launch-slot-state.mjs",
|
|
18
20
|
"/subagent-gate-visibility.mjs",
|