@firstpick/pi-package-webui 0.9.4 → 0.9.6
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 +7 -2
- package/bin/pi-webui.mjs +90 -5
- package/lib/optional-feature-catalog.mjs +1 -1
- package/lib/session-actions.mjs +20 -2
- package/lib/ui-layout-settings.mjs +37 -6
- package/package.json +1 -1
- package/public/app.js +2311 -257
- package/public/index.html +82 -55
- package/public/service-worker.js +4 -1
- package/public/stream-derived-output.mjs +799 -0
- package/public/stream-markdown-tail.mjs +204 -0
- package/public/stream-output-controller.mjs +222 -51
- package/public/stream-render-scheduler.mjs +85 -0
- package/public/styles.css +276 -20
- package/public/transcript-renderer.mjs +73 -24
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/composer-action-grid-reorder.spec.mjs +114 -31
- package/tests/browser/control-deck-side-panels.spec.mjs +42 -0
- package/tests/browser/control-visibility.spec.mjs +396 -0
- package/tests/browser/mobile-foundation.spec.mjs +28 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +9 -9
- package/tests/browser/stream-output-isolation.spec.mjs +308 -3
- package/tests/browser/user-noticeable-fixes.spec.mjs +204 -0
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/composer-action-grid-reorder-static.test.mjs +8 -7
- package/tests/control-deck-side-panels-static.test.mjs +3 -1
- package/tests/control-visibility-static.test.mjs +294 -0
- package/tests/controls-layout-static.test.mjs +3 -3
- package/tests/cwd-footer-reliability-static.test.mjs +1 -1
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/file-viewer-image-static.test.mjs +3 -3
- package/tests/fixtures/fake-pi.mjs +57 -10
- package/tests/fixtures/streaming-workloads.mjs +167 -0
- package/tests/footer-provider-usage-visual-static.test.mjs +15 -0
- package/tests/foreground-transcript-catch-up-static.test.mjs +7 -1
- package/tests/git-workflow-preferences.test.mjs +2 -2
- package/tests/http-endpoints-harness.test.mjs +4 -4
- package/tests/interaction-state-stability-static.test.mjs +3 -1
- package/tests/intercom-conversation-viewer-static.test.mjs +4 -4
- package/tests/intercom-conversations-http.test.mjs +16 -0
- package/tests/main-output-loading-static.test.mjs +3 -3
- package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- 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 +77 -66
- package/tests/open-issue-wizard-static.test.mjs +2 -2
- package/tests/persistent-ui-layout-static.test.mjs +7 -7
- package/tests/prompt-input-vertical-scroll-static.test.mjs +26 -0
- package/tests/questionnaire-dialog.test.mjs +3 -3
- package/tests/runtime-error-visibility.test.mjs +3 -3
- package/tests/session-auth-harness.test.mjs +26 -1
- package/tests/session-sampling-ui-static.test.mjs +3 -3
- package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
- package/tests/stream-derived-output.test.mjs +121 -0
- package/tests/stream-markdown-tail.test.mjs +218 -0
- package/tests/stream-output-controller.test.mjs +119 -4
- package/tests/stream-output-isolation-static.test.mjs +34 -6
- package/tests/stream-output-workloads.test.mjs +276 -0
- package/tests/stream-render-scheduler.test.mjs +115 -0
- package/tests/streaming-ui-coupling.test.mjs +1 -1
- package/tests/subagent-observability-static.test.mjs +2 -2
- package/tests/syntax-highlighting-static.test.mjs +3 -3
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/tests/thinking-format-parser.test.mjs +15 -0
- package/tests/todo-filter-static.test.mjs +148 -0
- package/tests/transcript-markdown-tail.test.mjs +137 -0
- package/tests/ui-layout-settings.test.mjs +54 -7
- package/tests/webui-settings-locking.test.mjs +3 -3
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@ Pi Web UI keeps the normal Pi agent experience while giving you more room to man
|
|
|
25
25
|
| **Project utilities** | Launch detected app runners, manage working directories, search files and transcripts, and customize themes. |
|
|
26
26
|
| **Companion features** | Add stats, remote access, voice, `/btw`, richer Git status, themes, release tools, and other supported Pi packages. |
|
|
27
27
|
| **Desktop and mobile** | Use a full desktop workspace with resizable left and right side panels, or a compact phone layout with touch-friendly navigation and controls. |
|
|
28
|
+
| **Customizable controls** | Hide optional workspace, Control Deck, composer, workflow, attachment, and input-tag controls while keeping Send available. |
|
|
28
29
|
|
|
29
30
|
## Quick start
|
|
30
31
|
|
|
@@ -60,7 +61,7 @@ Check the server at any time with:
|
|
|
60
61
|
1. Start the Web UI with `/webui-start`.
|
|
61
62
|
2. Confirm the working directory in the footer or choose another project.
|
|
62
63
|
3. Select a model and thinking effort.
|
|
63
|
-
4. Enter a prompt, attach context if needed, and follow the live response.
|
|
64
|
+
4. Enter a prompt, attach context if needed, and follow the live response. The prompt grows to a bounded height, then scrolls vertically so every line stays reachable.
|
|
64
65
|
5. Open the Control Deck for sessions, Git, app runners, themes, updates, and optional features. Under **Controls → Interface**, choose **Top bar** or **Sidebar** for terminal tabs, then choose **Right**, **Left**, or **Both** for the Control Deck. In **Sidebar**, **Both** is unavailable; choosing **Right** or **Left** swaps the Control Deck and terminal/tabs rails across the chat.
|
|
65
66
|
6. On desktop, drag the workspace-facing edge of any visible Control Deck—or the terminal/tabs rail in **Sidebar**—to choose a comfortable width. In **Both**, resize the left and right Control Decks independently; widths return on your next visit.
|
|
66
67
|
|
|
@@ -68,6 +69,8 @@ When session history is still loading, the main window shows **Loading agent out
|
|
|
68
69
|
|
|
69
70
|
Tracked skills appear as compact tags above the composer. Select a named tag to open its skill file; when space is limited, select the **+X** tag to expand the remaining selectable tags upward.
|
|
70
71
|
|
|
72
|
+
To simplify the interface, right-click a supported button and choose **Hide** (an Undo notice appears), or right-click empty space in a marked toolbar, Control Deck header/footer, or composer area to choose every visible control and input-tag type. Use **Show all** or **Reset defaults** there, or the **Show all controls** / **Reset control visibility** actions in the command palette, to recover hidden items. This preference is global across Web UI workspaces and browsers; **Send** always remains available.
|
|
73
|
+
|
|
71
74
|
Open **Subagents** to follow agent runs launched by managed extensions or registered SDK, RPC, JSON, print, interactive, tmux, workflow, schedule, gate, and custom integrations. Runs linked to an open WebUI terminal stay in that terminal’s group; other registered runs appear under **External agents**. Each agent row shows its launch source and lifecycle, and only offers output or controls that its owner supports. A `pi-subagents` workflow appears as a collapsible **Workflow** header with its model-powered agents nested inside, rather than as another agent row. Starting or restarting the server reconnects active runs without reopening stale, lost, or already-finished rows from an earlier server run.
|
|
72
75
|
|
|
73
76
|
Independent Pi processes do not appear automatically. Start them through `pi-webui agent run`, attach a persisted session with `pi-webui agent attach`, or use a cooperating registration adapter. See [TECHNICAL.md](TECHNICAL.md#subagent-observability) for supported commands and limitations.
|
|
@@ -80,7 +83,9 @@ Useful shortcuts:
|
|
|
80
83
|
- `Ctrl/Cmd+L` opens the model selector.
|
|
81
84
|
- `Ctrl/Cmd+F` searches the active file, transcript, or subagent output and highlights every match.
|
|
82
85
|
- `Alt+Enter` queues the composer as a follow-up.
|
|
83
|
-
- Hold `Esc` to abort active work.
|
|
86
|
+
- Hold `Esc` (or the Abort button) for about a second to abort active work; a quick tap shows the hint instead.
|
|
87
|
+
- In the composer, `Enter` accepts a highlighted `/`, `@`, or `!` suggestion; once the token is complete, `Enter` sends. `Ctrl/Cmd+P`, `Ctrl/Cmd+T`, `Ctrl/Cmd+O`, and `Shift+Tab` (model cycle, thinking output, tool output, thinking level) act only while the composer has focus.
|
|
88
|
+
- Warnings and errors appear as short-lived notices at the bottom of the window and count up on the **Events** section header; the Events log keeps the full history.
|
|
84
89
|
- In the Control Deck, use `Alt+Up` / `Alt+Down` to reorder a section. In **Both**, use `Alt+Left` / `Alt+Right` to move it between sides.
|
|
85
90
|
|
|
86
91
|
## Feature gallery
|
package/bin/pi-webui.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import path from "node:path";
|
|
|
10
10
|
import { StringDecoder } from "node:string_decoder";
|
|
11
11
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
12
12
|
import { promisify } from "node:util";
|
|
13
|
-
import { brotliCompress, constants as zlibConstants, gzip } from "node:zlib";
|
|
13
|
+
import { brotliCompress, brotliCompressSync, constants as zlibConstants, gzip, gzipSync } from "node:zlib";
|
|
14
14
|
import { SessionManager, SettingsManager, DefaultPackageManager } from "@earendil-works/pi-coding-agent";
|
|
15
15
|
import {
|
|
16
16
|
ThemeContractError,
|
|
@@ -1143,14 +1143,37 @@ class PiRpcProcess {
|
|
|
1143
1143
|
}
|
|
1144
1144
|
}
|
|
1145
1145
|
|
|
1146
|
+
// JSON responses are compact and, when the client accepts it, compressed. Boot alone fetches
|
|
1147
|
+
// ~1.5 MB of JSON (models, commands, tools, subagent config); over remote access or a phone the
|
|
1148
|
+
// pretty-printed uncompressed payloads were seconds of transfer per reload.
|
|
1149
|
+
const JSON_COMPRESSION_MIN_BYTES = 2048;
|
|
1150
|
+
|
|
1146
1151
|
function sendJson(res, statusCode, payload, headers = {}) {
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1152
|
+
const raw = Buffer.from(JSON.stringify(payload));
|
|
1153
|
+
const responseHeaders = {
|
|
1149
1154
|
"content-type": "application/json; charset=utf-8",
|
|
1150
1155
|
"cache-control": "no-store",
|
|
1151
1156
|
"x-content-type-options": "nosniff",
|
|
1152
1157
|
...headers,
|
|
1153
|
-
}
|
|
1158
|
+
};
|
|
1159
|
+
let body = raw;
|
|
1160
|
+
const encoding = raw.length >= JSON_COMPRESSION_MIN_BYTES ? res.piAcceptedEncoding || "" : "";
|
|
1161
|
+
if (encoding === "br") {
|
|
1162
|
+
body = brotliCompressSync(raw, {
|
|
1163
|
+
params: {
|
|
1164
|
+
[zlibConstants.BROTLI_PARAM_QUALITY]: 4,
|
|
1165
|
+
[zlibConstants.BROTLI_PARAM_SIZE_HINT]: raw.length,
|
|
1166
|
+
},
|
|
1167
|
+
});
|
|
1168
|
+
responseHeaders["content-encoding"] = "br";
|
|
1169
|
+
responseHeaders.vary = "Accept-Encoding";
|
|
1170
|
+
} else if (encoding === "gzip") {
|
|
1171
|
+
body = gzipSync(raw, { level: 5 });
|
|
1172
|
+
responseHeaders["content-encoding"] = "gzip";
|
|
1173
|
+
responseHeaders.vary = "Accept-Encoding";
|
|
1174
|
+
}
|
|
1175
|
+
responseHeaders["content-length"] = body.length;
|
|
1176
|
+
res.writeHead(statusCode, responseHeaders);
|
|
1154
1177
|
res.end(body);
|
|
1155
1178
|
}
|
|
1156
1179
|
|
|
@@ -14173,6 +14196,32 @@ async function deleteFileSystemEntryData(tab, body = {}) {
|
|
|
14173
14196
|
};
|
|
14174
14197
|
}
|
|
14175
14198
|
|
|
14199
|
+
// Create an empty file or a directory inside the tab's working directory (Files panel
|
|
14200
|
+
// "New file…" / "New folder…"). Never overwrites; parents must already exist.
|
|
14201
|
+
async function createFileSystemEntryData(tab, body = {}) {
|
|
14202
|
+
const kind = body.type === "directory" ? "directory" : "file";
|
|
14203
|
+
const resolved = await resolveWorkspacePath(tab, body.path || body.filePath || "", { mustExist: false });
|
|
14204
|
+
if (resolved.targetPath === resolved.root) throw makeHttpError(400, "A name is required");
|
|
14205
|
+
if (resolved.info) throw makeHttpError(409, `Already exists: ${resolved.relative}`);
|
|
14206
|
+
const parentPath = path.dirname(resolved.targetPath);
|
|
14207
|
+
const parentInfo = await stat(parentPath).catch(() => null);
|
|
14208
|
+
if (!parentInfo?.isDirectory?.()) throw makeHttpError(404, `Parent folder not found: ${workspaceRelativePath(resolved.root, parentPath) || "."}`);
|
|
14209
|
+
const realParent = await realpath(parentPath).catch(() => parentPath);
|
|
14210
|
+
if (realParent !== resolved.realRoot && !pathInside(resolved.realRoot, realParent)) throw makeHttpError(403, "Parent folder escapes the active tab working directory");
|
|
14211
|
+
if (kind === "directory") await mkdir(resolved.targetPath);
|
|
14212
|
+
else await writeFile(resolved.targetPath, "", { encoding: "utf8", flag: "wx" });
|
|
14213
|
+
const nextStats = await stat(resolved.targetPath);
|
|
14214
|
+
return {
|
|
14215
|
+
path: resolved.relative,
|
|
14216
|
+
name: path.basename(resolved.targetPath),
|
|
14217
|
+
type: kind,
|
|
14218
|
+
parentPath: workspaceRelativePath(resolved.root, parentPath),
|
|
14219
|
+
created: true,
|
|
14220
|
+
size: nextStats.size,
|
|
14221
|
+
mtimeMs: nextStats.mtimeMs,
|
|
14222
|
+
};
|
|
14223
|
+
}
|
|
14224
|
+
|
|
14176
14225
|
async function moveFileSystemEntryData(tab, body = {}) {
|
|
14177
14226
|
if (body.confirmed !== true) throw makeHttpError(409, "Moving files or directories requires confirmed: true");
|
|
14178
14227
|
const source = await resolveWorkspacePath(tab, body.path || body.filePath || body.sourcePath || "");
|
|
@@ -14334,7 +14383,14 @@ async function getIntercomConversationsData(tab, conversationId = "") {
|
|
|
14334
14383
|
|
|
14335
14384
|
requireAllowedSessionPath(sessionFile);
|
|
14336
14385
|
const sessionInfo = await stat(sessionFile).catch(() => null);
|
|
14337
|
-
if (!sessionInfo?.isFile())
|
|
14386
|
+
if (!sessionInfo?.isFile()) {
|
|
14387
|
+
// Fresh/empty session: its file is only created on first persist, so there
|
|
14388
|
+
// cannot be any persisted conversations yet. Return an empty projection
|
|
14389
|
+
// instead of erroring out every intercom poll for the tab.
|
|
14390
|
+
const empty = projectIntercomConversations([], projectionOptions);
|
|
14391
|
+
if (conversationId) throw makeHttpError(404, "Intercom conversation not found");
|
|
14392
|
+
return empty;
|
|
14393
|
+
}
|
|
14338
14394
|
|
|
14339
14395
|
let manager;
|
|
14340
14396
|
try {
|
|
@@ -15695,6 +15751,7 @@ async function handlePromptRequest(tab, body, req) {
|
|
|
15695
15751
|
|
|
15696
15752
|
const server = createServer(async (req, res) => {
|
|
15697
15753
|
try {
|
|
15754
|
+
res.piAcceptedEncoding = acceptedStaticEncoding(req);
|
|
15698
15755
|
const url = new URL(req.url || "/", `http://${req.headers.host || "localhost"}`);
|
|
15699
15756
|
|
|
15700
15757
|
if (url.pathname === "/remote-auth" && req.method === "GET") {
|
|
@@ -15991,6 +16048,25 @@ const server = createServer(async (req, res) => {
|
|
|
15991
16048
|
return;
|
|
15992
16049
|
}
|
|
15993
16050
|
|
|
16051
|
+
// Reopen a recently closed tab (same cwd, title, and persisted session) — the server-side
|
|
16052
|
+
// record is used so clients cannot point Pi at arbitrary session files.
|
|
16053
|
+
if (url.pathname === "/api/tabs/reopen" && req.method === "POST") {
|
|
16054
|
+
const body = await readJsonBody(req);
|
|
16055
|
+
const wanted = String(body.id || "").trim();
|
|
16056
|
+
const index = closedRestorableTabs.findIndex((item) => item.id === wanted);
|
|
16057
|
+
if (!wanted || index === -1) throw makeHttpError(404, "That closed tab can no longer be reopened");
|
|
16058
|
+
const [descriptor] = closedRestorableTabs.splice(index, 1);
|
|
16059
|
+
const tab = await createTab({
|
|
16060
|
+
title: descriptor.titleSource === "explicit" || descriptor.titleSource === "auto" ? descriptor.title : undefined,
|
|
16061
|
+
titleSource: descriptor.titleSource,
|
|
16062
|
+
conversationStarted: descriptor.conversationStarted,
|
|
16063
|
+
cwd: descriptor.cwd,
|
|
16064
|
+
sessionFile: descriptor.sessionFile,
|
|
16065
|
+
});
|
|
16066
|
+
sendJson(res, 201, { ok: true, data: { tab: tabMeta(tab), tabs: listTabs() } });
|
|
16067
|
+
return;
|
|
16068
|
+
}
|
|
16069
|
+
|
|
15994
16070
|
if (url.pathname.startsWith("/api/tabs/") && req.method === "PATCH") {
|
|
15995
16071
|
const id = decodeURIComponent(url.pathname.slice("/api/tabs/".length));
|
|
15996
16072
|
const body = await readJsonBody(req);
|
|
@@ -16467,6 +16543,15 @@ const server = createServer(async (req, res) => {
|
|
|
16467
16543
|
return;
|
|
16468
16544
|
}
|
|
16469
16545
|
|
|
16546
|
+
if (url.pathname === "/api/files/create" && req.method === "POST") {
|
|
16547
|
+
requireLocalhostRoute(req, url.pathname);
|
|
16548
|
+
const body = await readJsonBody(req);
|
|
16549
|
+
const tab = getRequestedTab(req, url, body);
|
|
16550
|
+
ensureNaturalConversationRouteAllowed(tab, "file creation is blocked");
|
|
16551
|
+
sendJson(res, 201, { ok: true, data: await createFileSystemEntryData(tab, body) });
|
|
16552
|
+
return;
|
|
16553
|
+
}
|
|
16554
|
+
|
|
16470
16555
|
if (url.pathname === "/api/files/move" && req.method === "POST") {
|
|
16471
16556
|
requireLocalhostRoute(req, url.pathname);
|
|
16472
16557
|
const body = await readJsonBody(req);
|
|
@@ -15,7 +15,7 @@ const entries = [
|
|
|
15
15
|
["remoteWebui", "@firstpick/pi-package-remote-webui", "^0.1.8"],
|
|
16
16
|
["questionnaire", "@firstpick/pi-package-questionnaire", "^0.1.0"],
|
|
17
17
|
["naturalConversation", "@firstpick/pi-package-natural-conversation", "^0.1.4"],
|
|
18
|
-
["gitFooterStatus", "@firstpick/pi-extension-git-footer-status", "^0.
|
|
18
|
+
["gitFooterStatus", "@firstpick/pi-extension-git-footer-status", "^0.5.0"],
|
|
19
19
|
["statsCommand", "@firstpick/pi-extension-stats", "^0.2.9"],
|
|
20
20
|
["codexFastMode", "@firstpick/pi-extension-codex-fast-mode", "^0.1.0"],
|
|
21
21
|
["themeBundle", "@firstpick/pi-themes-bundle", "^0.1.5"],
|
package/lib/session-actions.mjs
CHANGED
|
@@ -11,14 +11,32 @@ export function normalizeSessionFilePath(value) {
|
|
|
11
11
|
return text ? path.resolve(text) : "";
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Resolve symlinks where possible so confinement checks compare canonical paths.
|
|
16
|
+
* For paths that do not exist yet (e.g. a brand-new session file), realpath the
|
|
17
|
+
* nearest existing ancestor and re-append the rest, so a symlinked session
|
|
18
|
+
* directory (such as ~/.pi pointing into a dotfiles repo) still canonicalizes
|
|
19
|
+
* instead of silently comparing against the unresolved path.
|
|
20
|
+
*/
|
|
15
21
|
function canonicalSessionPath(value) {
|
|
16
22
|
const resolved = normalizeSessionFilePath(value);
|
|
17
23
|
if (!resolved) return "";
|
|
18
24
|
try {
|
|
19
25
|
return realpathSync(resolved);
|
|
20
26
|
} catch {
|
|
21
|
-
|
|
27
|
+
const tail = [];
|
|
28
|
+
let current = resolved;
|
|
29
|
+
while (true) {
|
|
30
|
+
const parent = path.dirname(current);
|
|
31
|
+
if (parent === current) return resolved;
|
|
32
|
+
tail.unshift(path.basename(current));
|
|
33
|
+
current = parent;
|
|
34
|
+
try {
|
|
35
|
+
return path.join(realpathSync(current), ...tail);
|
|
36
|
+
} catch {
|
|
37
|
+
// keep walking up
|
|
38
|
+
}
|
|
39
|
+
}
|
|
22
40
|
}
|
|
23
41
|
}
|
|
24
42
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
|
|
3
|
-
export const UI_LAYOUT_VERSION =
|
|
3
|
+
export const UI_LAYOUT_VERSION = 3;
|
|
4
4
|
export const UI_LAYOUT_REQUEST_MAX_BYTES = 32 * 1024;
|
|
5
5
|
export const UI_LAYOUT_LIMITS = Object.freeze({
|
|
6
6
|
idLength: 256,
|
|
@@ -18,6 +18,7 @@ export const UI_LAYOUT_LIMITS = Object.freeze({
|
|
|
18
18
|
terminalTabsSidebarWidthMax: 4096,
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
+
const PREVIOUS_UI_LAYOUT_VERSION = 2;
|
|
21
22
|
const LEGACY_UI_LAYOUT_VERSION = 1;
|
|
22
23
|
const UNSAFE_OBJECT_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
23
24
|
const TERMINAL_TAB_LAYOUTS = new Set(["top", "left"]);
|
|
@@ -61,6 +62,10 @@ function boundedUniqueStringList(value, label) {
|
|
|
61
62
|
});
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
function boundedDeterministicStringList(value, label) {
|
|
66
|
+
return boundedUniqueStringList(value, label).sort();
|
|
67
|
+
}
|
|
68
|
+
|
|
64
69
|
function nullable(value, validate) {
|
|
65
70
|
return value === null ? null : validate(value);
|
|
66
71
|
}
|
|
@@ -247,6 +252,16 @@ function validateFileViewerWidth(value) {
|
|
|
247
252
|
return validateBoundedWidth(value, "layout.fileViewerWidth", UI_LAYOUT_LIMITS.fileViewerWidthMin, UI_LAYOUT_LIMITS.fileViewerWidthMax);
|
|
248
253
|
}
|
|
249
254
|
|
|
255
|
+
function validateControlVisibility(value) {
|
|
256
|
+
const source = objectValue(value);
|
|
257
|
+
if (!source) invalid("layout.controlVisibility must be an object or null");
|
|
258
|
+
assertOnlyKeys(source, new Set(["hiddenIds"]), "layout.controlVisibility");
|
|
259
|
+
if (!own(source, "hiddenIds")) invalid("layout.controlVisibility must include hiddenIds");
|
|
260
|
+
return {
|
|
261
|
+
hiddenIds: nullable(source.hiddenIds, (entry) => boundedDeterministicStringList(entry, "layout.controlVisibility.hiddenIds")),
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
250
265
|
export function defaultUiLayout() {
|
|
251
266
|
return {
|
|
252
267
|
version: UI_LAYOUT_VERSION,
|
|
@@ -259,6 +274,7 @@ export function defaultUiLayout() {
|
|
|
259
274
|
panelWidths: { left: null, right: null },
|
|
260
275
|
},
|
|
261
276
|
composerActions: { order: null, grid: null },
|
|
277
|
+
controlVisibility: { hiddenIds: null },
|
|
262
278
|
footerScopedModelOrder: null,
|
|
263
279
|
terminalTabs: { layout: null, customGroups: null, sidebarWidth: null },
|
|
264
280
|
fileViewerWidth: null,
|
|
@@ -273,7 +289,7 @@ function softField(validate, fallback = null) {
|
|
|
273
289
|
}
|
|
274
290
|
}
|
|
275
291
|
|
|
276
|
-
function normalizeSharedLayoutFields(source, sidePanel) {
|
|
292
|
+
function normalizeSharedLayoutFields(source, sidePanel, controlVisibility = defaultUiLayout().controlVisibility) {
|
|
277
293
|
const composerActions = objectValue(source.composerActions);
|
|
278
294
|
const terminalTabs = objectValue(source.terminalTabs);
|
|
279
295
|
return {
|
|
@@ -283,6 +299,7 @@ function normalizeSharedLayoutFields(source, sidePanel) {
|
|
|
283
299
|
order: softField(() => nullable(composerActions?.order ?? null, (entry) => boundedUniqueStringList(entry, "uiLayout.composerActions.order"))),
|
|
284
300
|
grid: softField(() => nullable(composerActions?.grid ?? null, validateGrid)),
|
|
285
301
|
},
|
|
302
|
+
controlVisibility,
|
|
286
303
|
footerScopedModelOrder: softField(() => nullable(source.footerScopedModelOrder ?? null, (entry) => boundedUniqueStringList(entry, "uiLayout.footerScopedModelOrder"))),
|
|
287
304
|
terminalTabs: {
|
|
288
305
|
layout: TERMINAL_TAB_LAYOUTS.has(terminalTabs?.layout) ? terminalTabs.layout : null,
|
|
@@ -303,7 +320,14 @@ function normalizeSideValues(source, validate, fallback) {
|
|
|
303
320
|
return Object.fromEntries(SIDES.map((side) => [side, softField(() => nullable(record?.[side] ?? null, (value) => validate(value, side)), fallback)]));
|
|
304
321
|
}
|
|
305
322
|
|
|
306
|
-
function
|
|
323
|
+
function normalizedControlVisibility(source) {
|
|
324
|
+
return softField(
|
|
325
|
+
() => source.controlVisibility == null ? defaultUiLayout().controlVisibility : validateControlVisibility(source.controlVisibility),
|
|
326
|
+
defaultUiLayout().controlVisibility,
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function normalizeCurrentVersion(source, { migrate = false } = {}) {
|
|
307
331
|
const sidePanel = objectValue(source.sidePanel);
|
|
308
332
|
return normalizeSharedLayoutFields(source, {
|
|
309
333
|
placement: CONTROL_DECK_PLACEMENTS.has(sidePanel?.placement) ? sidePanel.placement : null,
|
|
@@ -318,7 +342,11 @@ function normalizeVersionTwo(source) {
|
|
|
318
342
|
return value;
|
|
319
343
|
}, null),
|
|
320
344
|
panelWidths: normalizeSideValues(sidePanel?.panelWidths, (value, side) => validatePanelWidth(value, `uiLayout.sidePanel.panelWidths.${side}`), null),
|
|
321
|
-
});
|
|
345
|
+
}, migrate ? defaultUiLayout().controlVisibility : normalizedControlVisibility(source));
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function migrateVersionTwo(source) {
|
|
349
|
+
return normalizeCurrentVersion(source, { migrate: true });
|
|
322
350
|
}
|
|
323
351
|
|
|
324
352
|
function migrateVersionOne(source, legacySidePanelWidth) {
|
|
@@ -344,7 +372,8 @@ function migrateVersionOne(source, legacySidePanelWidth) {
|
|
|
344
372
|
export function normalizeUiLayout(value, { legacySidePanelWidth = null } = {}) {
|
|
345
373
|
const source = objectValue(value);
|
|
346
374
|
if (!source) return defaultUiLayout();
|
|
347
|
-
if (source.version === UI_LAYOUT_VERSION) return
|
|
375
|
+
if (source.version === UI_LAYOUT_VERSION) return normalizeCurrentVersion(source);
|
|
376
|
+
if (source.version === PREVIOUS_UI_LAYOUT_VERSION) return migrateVersionTwo(source);
|
|
348
377
|
if (source.version === LEGACY_UI_LAYOUT_VERSION) return migrateVersionOne(source, legacySidePanelWidth);
|
|
349
378
|
return defaultUiLayout();
|
|
350
379
|
}
|
|
@@ -352,7 +381,7 @@ export function normalizeUiLayout(value, { legacySidePanelWidth = null } = {}) {
|
|
|
352
381
|
export function validateUiLayoutPatch(value) {
|
|
353
382
|
const source = objectValue(value);
|
|
354
383
|
if (!source) invalid("layout must be an object");
|
|
355
|
-
const allowed = new Set(["version", "sidePanel", "composerActions", "footerScopedModelOrder", "terminalTabs", "fileViewerWidth"]);
|
|
384
|
+
const allowed = new Set(["version", "sidePanel", "composerActions", "controlVisibility", "footerScopedModelOrder", "terminalTabs", "fileViewerWidth"]);
|
|
356
385
|
assertOnlyKeys(source, allowed, "layout");
|
|
357
386
|
if (own(source, "version") && source.version !== UI_LAYOUT_VERSION) invalid(`layout.version must be ${UI_LAYOUT_VERSION}`);
|
|
358
387
|
const mutableFields = [...allowed].filter((field) => field !== "version" && own(source, field));
|
|
@@ -360,6 +389,7 @@ export function validateUiLayoutPatch(value) {
|
|
|
360
389
|
const patch = {};
|
|
361
390
|
if (own(source, "sidePanel")) patch.sidePanel = nullable(source.sidePanel, (entry) => validateSidePanel(entry, { partial: true }));
|
|
362
391
|
if (own(source, "composerActions")) patch.composerActions = nullable(source.composerActions, (entry) => validateComposerActions(entry, { partial: true }));
|
|
392
|
+
if (own(source, "controlVisibility")) patch.controlVisibility = nullable(source.controlVisibility, validateControlVisibility);
|
|
363
393
|
if (own(source, "footerScopedModelOrder")) patch.footerScopedModelOrder = nullable(source.footerScopedModelOrder, (entry) => boundedUniqueStringList(entry, "layout.footerScopedModelOrder"));
|
|
364
394
|
if (own(source, "terminalTabs")) patch.terminalTabs = nullable(source.terminalTabs, (entry) => validateTerminalTabs(entry, { partial: true }));
|
|
365
395
|
if (own(source, "fileViewerWidth")) patch.fileViewerWidth = nullable(source.fileViewerWidth, validateFileViewerWidth);
|
|
@@ -383,6 +413,7 @@ export function mergeUiLayout(current, patch) {
|
|
|
383
413
|
}
|
|
384
414
|
}
|
|
385
415
|
if (own(value, "composerActions")) merged.composerActions = value.composerActions === null ? defaultUiLayout().composerActions : value.composerActions;
|
|
416
|
+
if (own(value, "controlVisibility")) merged.controlVisibility = value.controlVisibility === null ? defaultUiLayout().controlVisibility : value.controlVisibility;
|
|
386
417
|
if (own(value, "footerScopedModelOrder")) merged.footerScopedModelOrder = value.footerScopedModelOrder;
|
|
387
418
|
if (own(value, "terminalTabs")) {
|
|
388
419
|
merged.terminalTabs = value.terminalTabs === null
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firstpick/pi-package-webui",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
4
4
|
"description": "Pi Web UI companion package with a local browser UI CLI plus /webui-start and /webui-status commands.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/Firstp1ck/pi-coding-agent-forge/tree/main/pi-package-webui#readme",
|