@firstpick/pi-package-webui 0.9.5 → 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 +5 -3
- package/bin/pi-webui.mjs +90 -5
- package/lib/optional-feature-catalog.mjs +1 -1
- package/lib/session-actions.mjs +20 -2
- package/package.json +1 -1
- package/public/app.js +1823 -262
- package/public/index.html +51 -31
- 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 +193 -51
- package/public/stream-render-scheduler.mjs +85 -0
- package/public/styles.css +249 -18
- 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/mobile-foundation.spec.mjs +28 -0
- 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-visibility-static.test.mjs +3 -3
- 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 +36 -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/interaction-state-stability-static.test.mjs +3 -1
- package/tests/intercom-conversation-viewer-static.test.mjs +3 -3
- 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 +74 -63
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/persistent-ui-layout-static.test.mjs +4 -4
- 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 +27 -6
- package/tests/stream-output-workloads.test.mjs +40 -3
- 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/README.md
CHANGED
|
@@ -61,7 +61,7 @@ Check the server at any time with:
|
|
|
61
61
|
1. Start the Web UI with `/webui-start`.
|
|
62
62
|
2. Confirm the working directory in the footer or choose another project.
|
|
63
63
|
3. Select a model and thinking effort.
|
|
64
|
-
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.
|
|
65
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.
|
|
66
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.
|
|
67
67
|
|
|
@@ -69,7 +69,7 @@ When session history is still loading, the main window shows **Loading agent out
|
|
|
69
69
|
|
|
70
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.
|
|
71
71
|
|
|
72
|
-
To simplify the interface, right-click a supported button and choose **Hide
|
|
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
73
|
|
|
74
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.
|
|
75
75
|
|
|
@@ -83,7 +83,9 @@ Useful shortcuts:
|
|
|
83
83
|
- `Ctrl/Cmd+L` opens the model selector.
|
|
84
84
|
- `Ctrl/Cmd+F` searches the active file, transcript, or subagent output and highlights every match.
|
|
85
85
|
- `Alt+Enter` queues the composer as a follow-up.
|
|
86
|
-
- 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.
|
|
87
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.
|
|
88
90
|
|
|
89
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
|
|
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",
|