@firstpick/pi-package-webui 0.7.9 → 0.8.1
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 +32 -9
- package/bin/pi-webui.mjs +750 -113
- package/lib/git-workflow-preferences.mjs +16 -0
- package/lib/git-worktrees.mjs +43 -4
- package/lib/npm-command.mjs +81 -0
- package/lib/queue-mutation.mjs +6 -0
- package/lib/workspace-files-live-watcher.mjs +138 -0
- package/package.json +11 -4
- package/public/app.js +3397 -380
- package/public/index.html +119 -20
- package/public/mobile-shell-state.mjs +166 -0
- package/public/service-worker.js +60 -13
- package/public/styles.css +1066 -362
- package/public/subagent-gate-visibility.mjs +16 -0
- package/public/subagent-launch-slot-state.mjs +16 -0
- package/public/transcript-renderer.mjs +433 -0
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/interaction-continuity.spec.mjs +739 -0
- package/tests/browser/mobile-foundation.spec.mjs +352 -0
- package/tests/browser/optimistic-prompt.spec.mjs +130 -0
- package/tests/chat-scroll-intent-static.test.mjs +6 -1
- package/tests/codex-fast-mode-static.test.mjs +59 -0
- package/tests/compact-sections-static.test.mjs +20 -2
- package/tests/compaction-mutation-contract.test.mjs +18 -4
- package/tests/compaction-static.test.mjs +1 -0
- package/tests/completion-signal-contract.test.mjs +13 -2
- package/tests/composer-skill-tag-layout.test.mjs +70 -0
- package/tests/fast-mode-client-static.test.mjs +14 -11
- package/tests/fixtures/fake-pi.mjs +222 -2
- package/tests/git-panel-gitignore-static.test.mjs +104 -0
- package/tests/git-workflow-preferences.test.mjs +8 -0
- package/tests/guided-git-publication-backend-static.test.mjs +40 -0
- package/tests/http-endpoints-harness.test.mjs +490 -3
- package/tests/interaction-state-stability-static.test.mjs +254 -0
- package/tests/mobile-continuity-tablet-static.test.mjs +55 -0
- package/tests/mobile-foundation-static.test.mjs +69 -0
- package/tests/mobile-phone-experience-static.test.mjs +65 -0
- package/tests/mobile-shell-state.test.mjs +69 -0
- package/tests/mobile-static.test.mjs +300 -43
- package/tests/mobile-transcript-cache-characterization.test.mjs +34 -0
- package/tests/npm-command.test.mjs +64 -1
- package/tests/open-issue-wizard-static.test.mjs +2 -1
- package/tests/queue-edit-reorder-static.test.mjs +9 -1
- package/tests/queue-mutation-contract.test.mjs +22 -0
- package/tests/service-worker-lifecycle.test.mjs +120 -0
- package/tests/side-panel-resize-static.test.mjs +8 -1
- package/tests/sse-backpressure-harness.test.mjs +98 -0
- package/tests/streaming-ui-coupling.test.mjs +7 -1
- package/tests/subagent-gate-visibility.test.mjs +18 -2
- package/tests/subagent-launch-slot-state.test.mjs +32 -0
- package/tests/subagent-launch-slots-static.test.mjs +8 -2
- package/tests/subagents-helper.test.mjs +90 -0
- package/tests/terminal-tab-workspace-static.test.mjs +1 -1
- package/tests/update-commands.test.mjs +4 -0
- package/tests/workspace-files-live-updates-static.test.mjs +76 -0
- package/tests/workspace-files-live-watcher.test.mjs +95 -0
- package/webui-rpc-helper.mjs +175 -3
|
@@ -26,6 +26,8 @@ export function supportedGitWorkflowThinkingLevels(model) {
|
|
|
26
26
|
|
|
27
27
|
const WEBUI_SETTINGS_VERSION = 4;
|
|
28
28
|
const WEBUI_SETTINGS_FILE_ENV = "PI_WEBUI_SETTINGS_FILE";
|
|
29
|
+
export const WEBUI_SIDE_PANEL_WIDTH_MIN_PX = 320;
|
|
30
|
+
export const WEBUI_SIDE_PANEL_WIDTH_MAX_PX = 4096;
|
|
29
31
|
const webuiSettingsUpdateQueues = new Map();
|
|
30
32
|
|
|
31
33
|
function cleanBoundedString(value, maxLength = 512) {
|
|
@@ -138,6 +140,16 @@ export function normalizeResourceDefaults(value) {
|
|
|
138
140
|
};
|
|
139
141
|
}
|
|
140
142
|
|
|
143
|
+
export function normalizeInterfacePreferences(value) {
|
|
144
|
+
const rawSidePanelWidth = value?.sidePanelWidth;
|
|
145
|
+
const sidePanelWidth = rawSidePanelWidth === null || rawSidePanelWidth === undefined ? Number.NaN : Number(rawSidePanelWidth);
|
|
146
|
+
return {
|
|
147
|
+
sidePanelWidth: Number.isFinite(sidePanelWidth)
|
|
148
|
+
? Math.max(WEBUI_SIDE_PANEL_WIDTH_MIN_PX, Math.min(WEBUI_SIDE_PANEL_WIDTH_MAX_PX, Math.round(sidePanelWidth)))
|
|
149
|
+
: null,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
141
153
|
function settingsObject(value) {
|
|
142
154
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
143
155
|
}
|
|
@@ -156,6 +168,7 @@ export function normalizeWebuiSettings(value) {
|
|
|
156
168
|
outputModeDefault: normalizeOutputMode(source.outputModeDefault, OUTPUT_MODE_NORMAL),
|
|
157
169
|
gitWorkflow: normalizeGitWorkflowPreferences(source.gitWorkflow),
|
|
158
170
|
resourceDefaults: normalizeResourceDefaults(source.resourceDefaults),
|
|
171
|
+
interfacePreferences: normalizeInterfacePreferences(source.interfacePreferences),
|
|
159
172
|
subagentLaunchSlots: normalizeSubagentLaunchSlots(source.subagentLaunchSlots),
|
|
160
173
|
};
|
|
161
174
|
}
|
|
@@ -198,6 +211,9 @@ function mergeWebuiSettings(rawCurrent, patch) {
|
|
|
198
211
|
skills: { ...current.resourceDefaults.skills, ...(patchValue.resourceDefaults.skills || {}) },
|
|
199
212
|
}
|
|
200
213
|
: current.resourceDefaults,
|
|
214
|
+
interfacePreferences: patchValue.interfacePreferences
|
|
215
|
+
? { ...current.interfacePreferences, ...patchValue.interfacePreferences }
|
|
216
|
+
: current.interfacePreferences,
|
|
201
217
|
};
|
|
202
218
|
if (persistLaunchSlots) {
|
|
203
219
|
source.subagentLaunchSlots = hasLaunchSlotPatch
|
package/lib/git-worktrees.mjs
CHANGED
|
@@ -342,6 +342,33 @@ async function branchExists(repoRoot, branch) {
|
|
|
342
342
|
throw makeGitWorktreeError(WORKTREE_ERROR_CODES.GIT_COMMAND_FAILED, gitFailureMessage(["show-ref", "--verify", "--quiet", `refs/heads/${branch}`], result), { branch });
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
+
function configuredRemoteForRef(remoteRef, remoteNames = []) {
|
|
346
|
+
return remoteNames
|
|
347
|
+
.filter((remoteName) => remoteRef.startsWith(`${remoteName}/`))
|
|
348
|
+
.sort((left, right) => right.length - left.length || left.localeCompare(right))[0] || "";
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
async function verifyTrackingRemoteRef(repo, branch, value) {
|
|
352
|
+
if (typeof value !== "string" || !value || value !== value.trim() || value.includes("\0")) {
|
|
353
|
+
throw makeGitWorktreeError(WORKTREE_ERROR_CODES.GIT_COMMAND_FAILED, "remoteRef must be a non-empty exact remote-tracking ref", { branch });
|
|
354
|
+
}
|
|
355
|
+
const remoteNames = (await runGit(["remote"], { cwd: repo.repoRoot, timeoutMs: 5000, maxOutputLength: 20_000 }))
|
|
356
|
+
.split(/\r?\n/)
|
|
357
|
+
.map((line) => line.trim())
|
|
358
|
+
.filter(Boolean);
|
|
359
|
+
const remoteName = configuredRemoteForRef(value, remoteNames);
|
|
360
|
+
if (!remoteName || value.slice(remoteName.length + 1) !== branch) {
|
|
361
|
+
throw makeGitWorktreeError(WORKTREE_ERROR_CODES.GIT_COMMAND_FAILED, `Remote git branch ${value} does not match local branch ${branch}`, { branch, remoteRef: value });
|
|
362
|
+
}
|
|
363
|
+
const fullRef = `refs/remotes/${value}`;
|
|
364
|
+
const output = await runGit(["for-each-ref", "--format=%(refname)%09%(symref)", fullRef], { cwd: repo.repoRoot, timeoutMs: 5000, maxOutputLength: 20_000 });
|
|
365
|
+
const exactRef = output.split(/\r?\n/).map((line) => line.split("\t", 2)).find(([ref]) => ref === fullRef);
|
|
366
|
+
if (!exactRef || exactRef[1]) {
|
|
367
|
+
throw makeGitWorktreeError(WORKTREE_ERROR_CODES.GIT_COMMAND_FAILED, `Unknown remote git branch: ${value}`, { branch, remoteRef: value });
|
|
368
|
+
}
|
|
369
|
+
return value;
|
|
370
|
+
}
|
|
371
|
+
|
|
345
372
|
export function slugifyWorktreeBranch(branch) {
|
|
346
373
|
const slug = String(branch || "")
|
|
347
374
|
.toLowerCase()
|
|
@@ -416,6 +443,7 @@ function occupiedBranch(worktrees, branch) {
|
|
|
416
443
|
|
|
417
444
|
export async function createGitWorktree(cwd, request = {}) {
|
|
418
445
|
const branch = cleanBranchName(request.branchName || request.branch);
|
|
446
|
+
const trackingRemoteRequested = Object.hasOwn(request, "remoteRef");
|
|
419
447
|
let data = await readWorktreeData(cwd);
|
|
420
448
|
await validateBranchName(data, branch);
|
|
421
449
|
|
|
@@ -423,6 +451,9 @@ export async function createGitWorktree(cwd, request = {}) {
|
|
|
423
451
|
data = await readWorktreeData(cwd);
|
|
424
452
|
const existing = occupiedBranch(data.worktrees, branch);
|
|
425
453
|
if (existing) {
|
|
454
|
+
if (trackingRemoteRequested) {
|
|
455
|
+
throw makeGitWorktreeError(WORKTREE_ERROR_CODES.BRANCH_CHECKED_OUT_ELSEWHERE, `Branch ${branch} is already checked out at ${existing.path}. Refresh the picker and open that worktree instead.`, { branch, remoteRef: request.remoteRef, worktreePath: existing.path });
|
|
456
|
+
}
|
|
426
457
|
return {
|
|
427
458
|
ok: true,
|
|
428
459
|
created: false,
|
|
@@ -434,12 +465,20 @@ export async function createGitWorktree(cwd, request = {}) {
|
|
|
434
465
|
};
|
|
435
466
|
}
|
|
436
467
|
|
|
437
|
-
const targetPath = await resolveCreateTarget(data, branch, data.worktrees, request.path);
|
|
438
468
|
const exists = await branchExists(data.repoRoot, branch);
|
|
469
|
+
if (trackingRemoteRequested && exists) {
|
|
470
|
+
throw makeGitWorktreeError(WORKTREE_ERROR_CODES.GIT_COMMAND_FAILED, `Local git branch already exists: ${branch}`, { branch, remoteRef: request.remoteRef });
|
|
471
|
+
}
|
|
472
|
+
const targetPath = await resolveCreateTarget(data, branch, data.worktrees, request.path);
|
|
473
|
+
// Re-read the exact remote ref under the mutation lock immediately before
|
|
474
|
+
// `worktree add`; symbolic, stale, and colliding selections fail closed.
|
|
475
|
+
const trackingRemoteRef = trackingRemoteRequested ? await verifyTrackingRemoteRef(data, branch, request.remoteRef) : "";
|
|
439
476
|
const baseRef = String(request.baseRef || "").trim();
|
|
440
|
-
const args =
|
|
441
|
-
? ["worktree", "add", targetPath,
|
|
442
|
-
:
|
|
477
|
+
const args = trackingRemoteRef
|
|
478
|
+
? ["worktree", "add", "--track", "-b", branch, targetPath, trackingRemoteRef]
|
|
479
|
+
: exists
|
|
480
|
+
? ["worktree", "add", targetPath, branch]
|
|
481
|
+
: ["worktree", "add", "-b", branch, targetPath, ...(baseRef ? [baseRef] : [])];
|
|
443
482
|
const worktreeAddCwd = data.currentWorktreePath || data.repoRoot;
|
|
444
483
|
|
|
445
484
|
try {
|
package/lib/npm-command.mjs
CHANGED
|
@@ -41,6 +41,83 @@ function existingPath(candidates, exists) {
|
|
|
41
41
|
return "";
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
function windowsCommandExtensions(command, env, pathApi) {
|
|
45
|
+
if (pathApi.extname(command)) return [""];
|
|
46
|
+
const configured = String(env.PATHEXT || env.PathExt || ".COM;.EXE;.BAT;.CMD")
|
|
47
|
+
.split(";")
|
|
48
|
+
.map((extension) => extension.trim())
|
|
49
|
+
.filter(Boolean);
|
|
50
|
+
return ["", ...configured];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Resolve the directory that supplies a command, using the same PATH order as the process. */
|
|
54
|
+
export function resolveCommandDirectory(command, runtime = {}) {
|
|
55
|
+
const env = runtime.env ?? process.env;
|
|
56
|
+
const platform = runtime.platform ?? process.platform;
|
|
57
|
+
const exists = runtime.existsSync ?? existsSync;
|
|
58
|
+
const pathApi = pathApiForPlatform(platform);
|
|
59
|
+
const value = String(command || "").trim().replace(/^"|"$/g, "");
|
|
60
|
+
if (!value) return "";
|
|
61
|
+
|
|
62
|
+
const directBase = pathApi.isAbsolute(value)
|
|
63
|
+
? value
|
|
64
|
+
: value.includes("/") || value.includes("\\")
|
|
65
|
+
? pathApi.resolve(runtime.cwd ?? process.cwd(), value)
|
|
66
|
+
: "";
|
|
67
|
+
const extensions = platform === "win32" ? windowsCommandExtensions(value, env, pathApi) : [""];
|
|
68
|
+
const pathCandidates = directBase
|
|
69
|
+
? extensions.map((extension) => `${directBase}${extension}`)
|
|
70
|
+
: pathEntries(env, pathApi).flatMap((entry) => extensions.map((extension) => pathApi.join(entry, `${value}${extension}`)));
|
|
71
|
+
const resolved = existingPath(pathCandidates, exists);
|
|
72
|
+
return resolved ? pathApi.dirname(resolved) : "";
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Put the selected Pi/Node installation first without discarding other PATH entries. */
|
|
76
|
+
export function prependPathDirectory(directory, runtime = {}) {
|
|
77
|
+
const env = runtime.env ?? process.env;
|
|
78
|
+
const platform = runtime.platform ?? process.platform;
|
|
79
|
+
const pathApi = pathApiForPlatform(platform);
|
|
80
|
+
const value = String(directory || "").trim();
|
|
81
|
+
if (!value) return envPathValue(env);
|
|
82
|
+
const comparable = (entry) => platform === "win32" ? pathApi.normalize(entry).toLowerCase() : pathApi.normalize(entry);
|
|
83
|
+
const selected = comparable(value);
|
|
84
|
+
const remaining = pathEntries(env, pathApi).filter((entry) => comparable(entry) !== selected);
|
|
85
|
+
return [value, ...remaining].join(pathApi.delimiter);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Preserve the process's PATH key casing so Windows does not receive Path and PATH entries. */
|
|
89
|
+
export function prependedPathEnvironment(directory, runtime = {}) {
|
|
90
|
+
const env = runtime.env ?? process.env;
|
|
91
|
+
const pathKey = Object.keys(env).find((key) => key.toLowerCase() === "path") || "PATH";
|
|
92
|
+
return { [pathKey]: prependPathDirectory(directory, runtime) };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Normalize Windows npm-generated Pi shims to Node plus the installation's CLI script. */
|
|
96
|
+
export function resolvePiCommandInvocation(command, args = [], runtime = {}) {
|
|
97
|
+
const env = runtime.env ?? process.env;
|
|
98
|
+
const execPath = runtime.execPath ?? process.execPath;
|
|
99
|
+
const platform = runtime.platform ?? process.platform;
|
|
100
|
+
const exists = runtime.existsSync ?? existsSync;
|
|
101
|
+
const pathApi = pathApiForPlatform(platform);
|
|
102
|
+
const requestedArgs = Array.isArray(args) ? args.map(String) : [];
|
|
103
|
+
const value = String(command || "").trim();
|
|
104
|
+
|
|
105
|
+
if (isJavaScriptPath(value)) {
|
|
106
|
+
return { command: execPath, args: [value, ...requestedArgs], source: "node-script" };
|
|
107
|
+
}
|
|
108
|
+
if (platform !== "win32" || !/^pi(?:\.(?:cmd|ps1))?$/i.test(pathApi.basename(value))) {
|
|
109
|
+
return { command: value, args: requestedArgs, source: "command" };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const installDirectory = resolveCommandDirectory(value, { ...runtime, env, execPath, platform, existsSync: exists });
|
|
113
|
+
const cliPath = pathApi.join(installDirectory, "node_modules", "@earendil-works", "pi-coding-agent", "dist", "cli.js");
|
|
114
|
+
if (installDirectory && existingPath([cliPath], exists)) {
|
|
115
|
+
const bundledNode = existingPath([pathApi.join(installDirectory, "node.exe"), execPath], exists) || execPath;
|
|
116
|
+
return { command: bundledNode, args: [cliPath, ...requestedArgs], source: "windows-node-cli", installDirectory };
|
|
117
|
+
}
|
|
118
|
+
return { command: value, args: requestedArgs, source: "command", installDirectory };
|
|
119
|
+
}
|
|
120
|
+
|
|
44
121
|
/**
|
|
45
122
|
* Resolve npm without relying on Windows CreateProcess to discover npm.cmd.
|
|
46
123
|
* The returned display command intentionally remains npm-oriented while the
|
|
@@ -79,7 +156,11 @@ export function resolveNpmCommandInvocation(args = [], runtime = {}) {
|
|
|
79
156
|
}
|
|
80
157
|
|
|
81
158
|
const npmExecPath = String(env.npm_execpath || "").trim();
|
|
159
|
+
const preferredDirectories = Array.isArray(runtime.preferredDirectories)
|
|
160
|
+
? runtime.preferredDirectories.map(String).filter(Boolean)
|
|
161
|
+
: [];
|
|
82
162
|
const candidates = [
|
|
163
|
+
...preferredDirectories.map((directory) => npmCliPathForDirectory(directory, pathApi)),
|
|
83
164
|
isJavaScriptPath(npmExecPath) ? npmExecPath : "",
|
|
84
165
|
npmCliPathForDirectory(pathApi.dirname(execPath), pathApi),
|
|
85
166
|
...pathEntries(env, pathApi).map((entry) => npmCliPathForDirectory(entry, pathApi)),
|
package/lib/queue-mutation.mjs
CHANGED
|
@@ -98,6 +98,12 @@ export function mutatePiRuntimeFollowUpQueue(session, payload = {}) {
|
|
|
98
98
|
// `to` is the final zero-based index after the item has been removed.
|
|
99
99
|
nextTracked.splice(operation.to, 0, tracked);
|
|
100
100
|
nextMessages.splice(operation.to, 0, message);
|
|
101
|
+
} else if (operation.type === "delete") {
|
|
102
|
+
if (!validIndex(operation.index, followUp.length) || followUp[operation.index] !== operation.expectedText) {
|
|
103
|
+
return mutationFailure("invalid-request", steering, followUp);
|
|
104
|
+
}
|
|
105
|
+
nextTracked.splice(operation.index, 1);
|
|
106
|
+
nextMessages.splice(operation.index, 1);
|
|
101
107
|
} else {
|
|
102
108
|
return mutationFailure("invalid-request", steering, followUp);
|
|
103
109
|
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { watch as watchDirectory } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
export const WORKSPACE_FILES_LIVE_WATCH_DEBOUNCE_MS = 250;
|
|
5
|
+
export const WORKSPACE_FILES_LIVE_WATCH_MAX_WAIT_MS = 2_000;
|
|
6
|
+
|
|
7
|
+
function cleanTabId(value) {
|
|
8
|
+
return String(value || "").trim();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function canonicalRoot(value) {
|
|
12
|
+
const root = String(value || "").trim();
|
|
13
|
+
return root ? path.resolve(root) : "";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function createWorkspaceFilesLiveWatcher({
|
|
17
|
+
watch = watchDirectory,
|
|
18
|
+
debounceMs = WORKSPACE_FILES_LIVE_WATCH_DEBOUNCE_MS,
|
|
19
|
+
maxWaitMs = WORKSPACE_FILES_LIVE_WATCH_MAX_WAIT_MS,
|
|
20
|
+
onChange = () => {},
|
|
21
|
+
onError = () => {},
|
|
22
|
+
} = {}) {
|
|
23
|
+
const roots = new Map();
|
|
24
|
+
const tabRoots = new Map();
|
|
25
|
+
const delayMs = Math.max(0, Number(debounceMs) || 0);
|
|
26
|
+
const maximumWaitMs = Math.max(0, Number(maxWaitMs) || WORKSPACE_FILES_LIVE_WATCH_MAX_WAIT_MS);
|
|
27
|
+
|
|
28
|
+
function reportError(root, error) {
|
|
29
|
+
try {
|
|
30
|
+
onError({ root, error });
|
|
31
|
+
} catch {
|
|
32
|
+
// Watcher diagnostics must never crash the Web UI server.
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function closeRoot(root, { clearTabs = true } = {}) {
|
|
37
|
+
const record = roots.get(root);
|
|
38
|
+
if (!record) return false;
|
|
39
|
+
roots.delete(root);
|
|
40
|
+
if (record.timer) clearTimeout(record.timer);
|
|
41
|
+
try {
|
|
42
|
+
record.watcher?.close();
|
|
43
|
+
} catch {
|
|
44
|
+
// The watcher may already be closed after an error.
|
|
45
|
+
}
|
|
46
|
+
if (clearTabs) {
|
|
47
|
+
for (const tabId of record.tabs) {
|
|
48
|
+
if (tabRoots.get(tabId) === root) tabRoots.delete(tabId);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function failRoot(root, error) {
|
|
55
|
+
if (!roots.has(root)) return;
|
|
56
|
+
closeRoot(root);
|
|
57
|
+
reportError(root, error);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function scheduleChange(root) {
|
|
61
|
+
const record = roots.get(root);
|
|
62
|
+
if (!record) return;
|
|
63
|
+
record.tabIds = new Set(record.tabs);
|
|
64
|
+
if (record.timer) clearTimeout(record.timer);
|
|
65
|
+
const now = Date.now();
|
|
66
|
+
if (!record.burstStartedAt) record.burstStartedAt = now;
|
|
67
|
+
const remainingMs = Math.max(0, maximumWaitMs - (now - record.burstStartedAt));
|
|
68
|
+
record.timer = setTimeout(() => {
|
|
69
|
+
const current = roots.get(root);
|
|
70
|
+
if (!current || current !== record) return;
|
|
71
|
+
current.timer = null;
|
|
72
|
+
current.burstStartedAt = 0;
|
|
73
|
+
const tabIds = [...current.tabIds];
|
|
74
|
+
current.tabIds.clear();
|
|
75
|
+
try {
|
|
76
|
+
onChange({ root, tabIds, changedAt: new Date().toISOString() });
|
|
77
|
+
} catch (error) {
|
|
78
|
+
reportError(root, error);
|
|
79
|
+
}
|
|
80
|
+
}, Math.min(delayMs, remainingMs));
|
|
81
|
+
record.timer.unref?.();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function ensureRoot(root) {
|
|
85
|
+
const existing = roots.get(root);
|
|
86
|
+
if (existing) return existing;
|
|
87
|
+
const record = { root, tabs: new Set(), tabIds: new Set(), watcher: null, timer: null, burstStartedAt: 0 };
|
|
88
|
+
roots.set(root, record);
|
|
89
|
+
try {
|
|
90
|
+
record.watcher = watch(root, { recursive: true, persistent: false }, () => scheduleChange(root));
|
|
91
|
+
record.watcher.on?.("error", (error) => failRoot(root, error));
|
|
92
|
+
return record;
|
|
93
|
+
} catch (error) {
|
|
94
|
+
roots.delete(root);
|
|
95
|
+
reportError(root, error);
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function unsubscribe(tabIdValue) {
|
|
101
|
+
const tabId = cleanTabId(tabIdValue);
|
|
102
|
+
const root = tabRoots.get(tabId);
|
|
103
|
+
if (!root) return false;
|
|
104
|
+
tabRoots.delete(tabId);
|
|
105
|
+
const record = roots.get(root);
|
|
106
|
+
if (!record) return true;
|
|
107
|
+
record.tabs.delete(tabId);
|
|
108
|
+
if (!record.tabs.size) closeRoot(root, { clearTabs: false });
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function subscribe(tabIdValue, rootValue) {
|
|
113
|
+
const tabId = cleanTabId(tabIdValue);
|
|
114
|
+
const root = canonicalRoot(rootValue);
|
|
115
|
+
if (!tabId || !root) return false;
|
|
116
|
+
const previousRoot = tabRoots.get(tabId);
|
|
117
|
+
if (previousRoot === root && roots.has(root)) return true;
|
|
118
|
+
if (previousRoot) unsubscribe(tabId);
|
|
119
|
+
const record = ensureRoot(root);
|
|
120
|
+
if (!record) return false;
|
|
121
|
+
record.tabs.add(tabId);
|
|
122
|
+
tabRoots.set(tabId, root);
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function closeAll() {
|
|
127
|
+
for (const root of [...roots.keys()]) closeRoot(root);
|
|
128
|
+
tabRoots.clear();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
subscribe,
|
|
133
|
+
unsubscribe,
|
|
134
|
+
closeAll,
|
|
135
|
+
watchedRootCount: () => roots.size,
|
|
136
|
+
subscribedRootForTab: (tabId) => tabRoots.get(cleanTabId(tabId)) || "",
|
|
137
|
+
};
|
|
138
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firstpick/pi-package-webui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
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",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"node_modules/@firstpick/pi-extension-bang-command-autocomplete/index.ts",
|
|
27
27
|
"node_modules/@firstpick/pi-extension-fish-user-bash/index.ts",
|
|
28
28
|
"node_modules/@firstpick/pi-extension-btw/index.ts",
|
|
29
|
+
"node_modules/@firstpick/pi-extension-codex-fast-mode/index.ts",
|
|
29
30
|
"node_modules/@firstpick/pi-extension-git-footer-status/index.ts",
|
|
30
31
|
"node_modules/@firstpick/pi-extension-release-aur/index.ts",
|
|
31
32
|
"node_modules/@firstpick/pi-extension-release-npm/index.ts",
|
|
@@ -51,11 +52,12 @@
|
|
|
51
52
|
"pi-webui": "./bin/pi-webui.mjs"
|
|
52
53
|
},
|
|
53
54
|
"scripts": {
|
|
54
|
-
"check": "node --check public/app.js && node --check public/issue-wizard-state.mjs && node --check public/issue-bot-client.mjs && node --check public/workflow-status-stack.mjs && node --check public/fast-output-live.mjs && node --check public/subagent-launch-slot-state.mjs && node --check public/subagent-gate-visibility.mjs && node --check public/voice-conversation.mjs && node --check public/aur-review-payload.mjs && node --check public/guided-git-command-state.mjs && node --check public/guided-git-review-state.mjs && node --check bin/pi-webui.mjs && node --check bin/pi-webui-rpc-supervisor.mjs && node --check lib/rpc-supervisor-protocol.mjs && node --check lib/rpc-supervisor-state.mjs && node --check lib/rpc-supervisor-client.mjs && node --check webui-rpc-helper.mjs && node --check lib/subagent-launch-slots.mjs && node --check lib/git-live-watcher.mjs && node --check lib/git-message-artifacts.mjs && node --check lib/trust-boundaries.mjs && node --check lib/native-command-adapter.mjs && node --check lib/session-actions.mjs && node --check lib/auth-actions.mjs && node --check lib/temp-artifacts.mjs && node tests/run-all.mjs",
|
|
55
|
-
"test": "node tests/run-all.mjs"
|
|
55
|
+
"check": "node --check public/app.js && node --check public/transcript-renderer.mjs && node --check public/mobile-shell-state.mjs && node --check public/issue-wizard-state.mjs && node --check public/issue-bot-client.mjs && node --check public/workflow-status-stack.mjs && node --check public/fast-output-live.mjs && node --check public/subagent-launch-slot-state.mjs && node --check public/subagent-gate-visibility.mjs && node --check public/voice-conversation.mjs && node --check public/aur-review-payload.mjs && node --check public/guided-git-command-state.mjs && node --check public/guided-git-review-state.mjs && node --check bin/pi-webui.mjs && node --check bin/pi-webui-rpc-supervisor.mjs && node --check lib/rpc-supervisor-protocol.mjs && node --check lib/rpc-supervisor-state.mjs && node --check lib/rpc-supervisor-client.mjs && node --check webui-rpc-helper.mjs && node --check lib/subagent-launch-slots.mjs && node --check lib/git-live-watcher.mjs && node --check lib/workspace-files-live-watcher.mjs && node --check lib/git-message-artifacts.mjs && node --check lib/trust-boundaries.mjs && node --check lib/native-command-adapter.mjs && node --check lib/session-actions.mjs && node --check lib/auth-actions.mjs && node --check lib/temp-artifacts.mjs && node tests/run-all.mjs",
|
|
56
|
+
"test": "node tests/run-all.mjs",
|
|
57
|
+
"test:browser": "playwright test"
|
|
56
58
|
},
|
|
57
59
|
"dependencies": {
|
|
58
|
-
"@earendil-works/pi-coding-agent": "^0.
|
|
60
|
+
"@earendil-works/pi-coding-agent": "^0.83.0",
|
|
59
61
|
"@firstpick/pi-utils": "^0.2.5",
|
|
60
62
|
"mermaid": "^11.15.0",
|
|
61
63
|
"typebox": "^1.3.6"
|
|
@@ -63,6 +65,7 @@
|
|
|
63
65
|
"optionalDependencies": {
|
|
64
66
|
"@firstpick/pi-extension-bang-command-autocomplete": "^0.2.2",
|
|
65
67
|
"@firstpick/pi-extension-btw": "^0.1.4",
|
|
68
|
+
"@firstpick/pi-extension-codex-fast-mode": "^0.1.0",
|
|
66
69
|
"@firstpick/pi-extension-fish-user-bash": "^0.2.2",
|
|
67
70
|
"@firstpick/pi-extension-git-footer-status": "^0.4.3",
|
|
68
71
|
"@firstpick/pi-extension-release-aur": "^0.1.8",
|
|
@@ -99,5 +102,9 @@
|
|
|
99
102
|
"undici": "8.5.0",
|
|
100
103
|
"ws": "8.21.0"
|
|
101
104
|
}
|
|
105
|
+
},
|
|
106
|
+
"devDependencies": {
|
|
107
|
+
"@axe-core/playwright": "4.12.1",
|
|
108
|
+
"@playwright/test": "1.62.1"
|
|
102
109
|
}
|
|
103
110
|
}
|