@firstpick/pi-package-webui 0.5.7 → 0.5.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/bin/pi-webui.mjs +97 -20
- package/package.json +1 -1
- package/public/app.js +7 -1
- package/public/styles.css +10 -4
- package/tests/http-endpoints-harness.test.mjs +59 -0
package/bin/pi-webui.mjs
CHANGED
|
@@ -192,6 +192,8 @@ const APP_RUNNER_INPUT_MAX_CHARS = 16_000;
|
|
|
192
192
|
const APP_RUNNER_CONTEXT_DEFAULT_LINES = 80;
|
|
193
193
|
const APP_RUNNER_CONTEXT_MAX_LINES = APP_RUNNER_OUTPUT_LINE_LIMIT;
|
|
194
194
|
const APP_RUNNER_STOP_GRACE_MS = 2_500;
|
|
195
|
+
const APP_RUNNER_PTY_DISABLED_VALUES = new Set(["0", "false", "no", "off"]);
|
|
196
|
+
const APP_RUNNER_PTY_SCRIPT_CACHE_TTL_MS = 5 * 60 * 1000;
|
|
195
197
|
const APP_RUNNER_PYTHON_ENTRIES = ["Main.py", "main.py", "src/main.py", "src/Main.py", "app.py", "src/app.py"];
|
|
196
198
|
const APP_RUNNER_JS_ENTRIES = ["main.js", "src/main.js", "index.js", "src/index.js", "server.js", "src/server.js", "app.js", "src/app.js"];
|
|
197
199
|
const APP_RUNNER_ZIG_ENTRIES = ["src/main.zig", "main.zig"];
|
|
@@ -1449,6 +1451,7 @@ async function readJsonFileIfExists(filePath) {
|
|
|
1449
1451
|
}
|
|
1450
1452
|
|
|
1451
1453
|
const appRunnerCommandAvailability = new Map();
|
|
1454
|
+
let appRunnerPtyScriptAvailability = { available: false, expiresAt: 0 };
|
|
1452
1455
|
|
|
1453
1456
|
async function fileStatsIfExists(filePath) {
|
|
1454
1457
|
try {
|
|
@@ -1504,6 +1507,25 @@ async function appRunnerCommandAvailable(command, cwd) {
|
|
|
1504
1507
|
return available;
|
|
1505
1508
|
}
|
|
1506
1509
|
|
|
1510
|
+
function appRunnerPtyDisabled() {
|
|
1511
|
+
return APP_RUNNER_PTY_DISABLED_VALUES.has(String(process.env.PI_WEBUI_APP_RUNNER_PTY || "").trim().toLowerCase());
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
async function appRunnerScriptPtyAvailable(cwd) {
|
|
1515
|
+
if (process.platform === "win32" || appRunnerPtyDisabled()) return false;
|
|
1516
|
+
const now = Date.now();
|
|
1517
|
+
if (appRunnerPtyScriptAvailability.expiresAt > now) return appRunnerPtyScriptAvailability.available;
|
|
1518
|
+
const result = await runCommand("script", ["--version"], {
|
|
1519
|
+
cwd,
|
|
1520
|
+
timeoutMs: APP_RUNNER_DETECTION_TIMEOUT_MS,
|
|
1521
|
+
maxOutputLength: 4_000,
|
|
1522
|
+
});
|
|
1523
|
+
const output = `${result.stdout || ""}\n${result.stderr || ""}`;
|
|
1524
|
+
const available = !result.error && !result.timedOut && /util-linux/i.test(output);
|
|
1525
|
+
appRunnerPtyScriptAvailability = { available, expiresAt: now + APP_RUNNER_PTY_SCRIPT_CACHE_TTL_MS };
|
|
1526
|
+
return available;
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1507
1529
|
function appRunnerPackageScripts(pkg) {
|
|
1508
1530
|
return pkg && typeof pkg.scripts === "object" && pkg.scripts ? pkg.scripts : {};
|
|
1509
1531
|
}
|
|
@@ -1538,6 +1560,41 @@ function shellQuote(value) {
|
|
|
1538
1560
|
return `'${String(value ?? "").replace(/'/g, `'\\''`)}'`;
|
|
1539
1561
|
}
|
|
1540
1562
|
|
|
1563
|
+
function appRunnerShellCommandLine(command, args = []) {
|
|
1564
|
+
return [command, ...args].map(shellQuote).join(" ");
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
async function spawnAppRunnerChild(run) {
|
|
1568
|
+
const baseOptions = {
|
|
1569
|
+
cwd: run.cwd,
|
|
1570
|
+
env: process.env,
|
|
1571
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
1572
|
+
windowsHide: true,
|
|
1573
|
+
detached: process.platform !== "win32",
|
|
1574
|
+
};
|
|
1575
|
+
if (await appRunnerScriptPtyAvailable(run.cwd)) {
|
|
1576
|
+
run.executionMode = "pty";
|
|
1577
|
+
return spawn("script", [
|
|
1578
|
+
"-q",
|
|
1579
|
+
"-e",
|
|
1580
|
+
"-f",
|
|
1581
|
+
"-c",
|
|
1582
|
+
`stty -echo 2>/dev/null || true; exec ${appRunnerShellCommandLine(run.command, run.args || [])}`,
|
|
1583
|
+
"/dev/null",
|
|
1584
|
+
], {
|
|
1585
|
+
...baseOptions,
|
|
1586
|
+
env: {
|
|
1587
|
+
...process.env,
|
|
1588
|
+
TERM: process.env.TERM || "xterm-256color",
|
|
1589
|
+
COLUMNS: process.env.COLUMNS || "120",
|
|
1590
|
+
LINES: process.env.LINES || "40",
|
|
1591
|
+
},
|
|
1592
|
+
});
|
|
1593
|
+
}
|
|
1594
|
+
run.executionMode = "pipe";
|
|
1595
|
+
return spawn(run.command, run.args || [], baseOptions);
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1541
1598
|
function appRunnerCandidate({ id, label, kind, command, args = [], projectFile = "", description = "", shortDisplayCommand = "", priority = 100, cwd = "", custom = false, configFile = "" }) {
|
|
1542
1599
|
return {
|
|
1543
1600
|
id,
|
|
@@ -2322,6 +2379,7 @@ function publicAppRunnerState(run) {
|
|
|
2322
2379
|
cwd: run.cwd,
|
|
2323
2380
|
pid: run.pid,
|
|
2324
2381
|
status: run.status,
|
|
2382
|
+
executionMode: run.executionMode || "pipe",
|
|
2325
2383
|
startedAt: run.startedAt,
|
|
2326
2384
|
endedAt: run.endedAt,
|
|
2327
2385
|
exitCode: run.exitCode,
|
|
@@ -2511,13 +2569,7 @@ async function startAppRunner(tab, runnerId) {
|
|
|
2511
2569
|
stdinWrites: 0,
|
|
2512
2570
|
};
|
|
2513
2571
|
appendAppRunnerLine(run, `$ ${run.displayCommand}`);
|
|
2514
|
-
const child =
|
|
2515
|
-
cwd: run.cwd,
|
|
2516
|
-
env: process.env,
|
|
2517
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
2518
|
-
windowsHide: true,
|
|
2519
|
-
detached: process.platform !== "win32",
|
|
2520
|
-
});
|
|
2572
|
+
const child = await spawnAppRunnerChild(run);
|
|
2521
2573
|
run.child = child;
|
|
2522
2574
|
run.pid = child.pid;
|
|
2523
2575
|
tab.appRunner = run;
|
|
@@ -3471,22 +3523,38 @@ async function readGitChanges(cwd) {
|
|
|
3471
3523
|
};
|
|
3472
3524
|
}
|
|
3473
3525
|
|
|
3474
|
-
function
|
|
3526
|
+
function gitWorkflowMessageCwd(root, cwd) {
|
|
3527
|
+
const messageCwd = path.resolve(String(cwd || root));
|
|
3528
|
+
if (!pathInside(root, messageCwd)) throw new Error(`Git workflow cwd must stay inside repository root: ${messageCwd}`);
|
|
3529
|
+
return messageCwd;
|
|
3530
|
+
}
|
|
3531
|
+
|
|
3532
|
+
function gitWorkflowMessageFileMeta(root, messageCwd, filePath) {
|
|
3533
|
+
return {
|
|
3534
|
+
path: filePath,
|
|
3535
|
+
relativePath: path.relative(messageCwd, filePath).split(path.sep).join("/"),
|
|
3536
|
+
repoRelativePath: path.relative(root, filePath).split(path.sep).join("/"),
|
|
3537
|
+
};
|
|
3538
|
+
}
|
|
3539
|
+
|
|
3540
|
+
function commitMessagePaths(baseDir) {
|
|
3475
3541
|
return {
|
|
3476
|
-
shortPath: path.join(
|
|
3477
|
-
longPath: path.join(
|
|
3478
|
-
branchPath: path.join(
|
|
3542
|
+
shortPath: path.join(baseDir, "dev", "COMMIT", "staged-commit-short.txt"),
|
|
3543
|
+
longPath: path.join(baseDir, "dev", "COMMIT", "staged-commit-long.txt"),
|
|
3544
|
+
branchPath: path.join(baseDir, "dev", "COMMIT", "staged-branch-name.txt"),
|
|
3479
3545
|
};
|
|
3480
3546
|
}
|
|
3481
3547
|
|
|
3482
3548
|
async function readGitWorkflowBranchName(cwd) {
|
|
3483
3549
|
const root = await getGitRoot(cwd);
|
|
3484
|
-
const
|
|
3550
|
+
const messageCwd = gitWorkflowMessageCwd(root, cwd);
|
|
3551
|
+
const { branchPath } = commitMessagePaths(messageCwd);
|
|
3485
3552
|
try {
|
|
3486
3553
|
const [branchText, branchStat] = await Promise.all([readFile(branchPath, "utf8"), stat(branchPath)]);
|
|
3487
3554
|
const branch = branchText.split(/\r?\n/).find((line) => line.trim())?.trim() || "";
|
|
3488
3555
|
if (!branch) throw new Error(`${branchPath} is empty`);
|
|
3489
|
-
|
|
3556
|
+
const branchFile = gitWorkflowMessageFileMeta(root, messageCwd, branchPath);
|
|
3557
|
+
return { root, cwd: messageCwd, branchPath, branchRelativePath: branchFile.relativePath, branchRepoRelativePath: branchFile.repoRelativePath, branch, mtimeMs: branchStat.mtimeMs };
|
|
3490
3558
|
} catch (error) {
|
|
3491
3559
|
throw new Error(`Missing generated branch name file ${branchPath}. Run /git-branch-name first. ${sanitizeError(error)}`);
|
|
3492
3560
|
}
|
|
@@ -3494,7 +3562,8 @@ async function readGitWorkflowBranchName(cwd) {
|
|
|
3494
3562
|
|
|
3495
3563
|
async function readGitWorkflowMessages(cwd) {
|
|
3496
3564
|
const root = await getGitRoot(cwd);
|
|
3497
|
-
const
|
|
3565
|
+
const messageCwd = gitWorkflowMessageCwd(root, cwd);
|
|
3566
|
+
const { shortPath, longPath } = commitMessagePaths(messageCwd);
|
|
3498
3567
|
try {
|
|
3499
3568
|
const [shortText, longText, shortStat, longStat] = await Promise.all([
|
|
3500
3569
|
readFile(shortPath, "utf8"),
|
|
@@ -3502,17 +3571,24 @@ async function readGitWorkflowMessages(cwd) {
|
|
|
3502
3571
|
stat(shortPath),
|
|
3503
3572
|
stat(longPath),
|
|
3504
3573
|
]);
|
|
3574
|
+
const shortFile = gitWorkflowMessageFileMeta(root, messageCwd, shortPath);
|
|
3575
|
+
const longFile = gitWorkflowMessageFileMeta(root, messageCwd, longPath);
|
|
3505
3576
|
return {
|
|
3506
3577
|
root,
|
|
3578
|
+
cwd: messageCwd,
|
|
3507
3579
|
shortPath,
|
|
3508
3580
|
longPath,
|
|
3581
|
+
shortRelativePath: shortFile.relativePath,
|
|
3582
|
+
longRelativePath: longFile.relativePath,
|
|
3583
|
+
shortRepoRelativePath: shortFile.repoRelativePath,
|
|
3584
|
+
longRepoRelativePath: longFile.repoRelativePath,
|
|
3509
3585
|
short: shortText.trimEnd(),
|
|
3510
3586
|
long: longText.trimEnd(),
|
|
3511
3587
|
shortMtimeMs: shortStat.mtimeMs,
|
|
3512
3588
|
longMtimeMs: longStat.mtimeMs,
|
|
3513
3589
|
};
|
|
3514
3590
|
} catch (error) {
|
|
3515
|
-
throw new Error(`Missing generated commit message files in ${path.join(
|
|
3591
|
+
throw new Error(`Missing generated commit message files in ${path.join(messageCwd, "dev", "COMMIT")}. Run /git-staged-msg first. ${sanitizeError(error)}`);
|
|
3516
3592
|
}
|
|
3517
3593
|
}
|
|
3518
3594
|
|
|
@@ -3938,8 +4014,8 @@ async function cleanupCreatedWorktreeAfterFailure(sourceCwd, worktreePath) {
|
|
|
3938
4014
|
}
|
|
3939
4015
|
}
|
|
3940
4016
|
|
|
3941
|
-
async function readGitWorkflowMessageFilesForTransfer(root) {
|
|
3942
|
-
const { shortPath, longPath } = commitMessagePaths(
|
|
4017
|
+
async function readGitWorkflowMessageFilesForTransfer(root, messageCwd = root) {
|
|
4018
|
+
const { shortPath, longPath } = commitMessagePaths(messageCwd);
|
|
3943
4019
|
const files = [];
|
|
3944
4020
|
for (const sourcePath of [shortPath, longPath]) {
|
|
3945
4021
|
try {
|
|
@@ -3952,7 +4028,8 @@ async function readGitWorkflowMessageFilesForTransfer(root) {
|
|
|
3952
4028
|
return files;
|
|
3953
4029
|
}
|
|
3954
4030
|
|
|
3955
|
-
async function snapshotGitWorkflowBranchState(root) {
|
|
4031
|
+
async function snapshotGitWorkflowBranchState(root, cwd = root) {
|
|
4032
|
+
const messageCwd = gitWorkflowMessageCwd(root, cwd);
|
|
3956
4033
|
const diffResult = await runGitWorkflowCommand(["diff", "--cached", "--binary", "--full-index"], {
|
|
3957
4034
|
cwd: root,
|
|
3958
4035
|
label: "git diff --cached --binary --full-index",
|
|
@@ -3963,7 +4040,7 @@ async function snapshotGitWorkflowBranchState(root) {
|
|
|
3963
4040
|
}
|
|
3964
4041
|
return {
|
|
3965
4042
|
stagedPatch: diffResult.stdout || "",
|
|
3966
|
-
messageFiles: await readGitWorkflowMessageFilesForTransfer(root),
|
|
4043
|
+
messageFiles: await readGitWorkflowMessageFilesForTransfer(root, messageCwd),
|
|
3967
4044
|
};
|
|
3968
4045
|
}
|
|
3969
4046
|
|
|
@@ -4019,7 +4096,7 @@ async function createGitWorkflowBranchWorktree(tab, body = {}) {
|
|
|
4019
4096
|
const root = await getGitRoot(tab.cwd);
|
|
4020
4097
|
const branch = cleanGitBranchName(body.branch || body.branchName);
|
|
4021
4098
|
await validateGitBranchName(root, branch);
|
|
4022
|
-
const snapshot = await snapshotGitWorkflowBranchState(root);
|
|
4099
|
+
const snapshot = await snapshotGitWorkflowBranchState(root, tab.cwd);
|
|
4023
4100
|
let createdResult = null;
|
|
4024
4101
|
try {
|
|
4025
4102
|
createdResult = await createGitWorktree(tab.cwd, { ...body, branchName: branch });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firstpick/pi-package-webui",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.8",
|
|
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/npm-packages/tree/main/pi-package-webui#readme",
|
package/public/app.js
CHANGED
|
@@ -11925,9 +11925,15 @@ function formatGitCommandResult(result) {
|
|
|
11925
11925
|
return lines.join("\n");
|
|
11926
11926
|
}
|
|
11927
11927
|
|
|
11928
|
+
function gitWorkflowMessagePreviewPath(message, key, fallback) {
|
|
11929
|
+
return normalizeDisplayPath(message?.[`${key}RelativePath`] || message?.[`${key}RepoRelativePath`] || fallback);
|
|
11930
|
+
}
|
|
11931
|
+
|
|
11928
11932
|
function formatCommitMessagePreview(message) {
|
|
11929
11933
|
if (!message) return "No commit message loaded yet.";
|
|
11930
|
-
|
|
11934
|
+
const shortPath = gitWorkflowMessagePreviewPath(message, "short", "dev/COMMIT/staged-commit-short.txt");
|
|
11935
|
+
const longPath = gitWorkflowMessagePreviewPath(message, "long", "dev/COMMIT/staged-commit-long.txt");
|
|
11936
|
+
return [`=== SHORT (${shortPath}) ===`, message.short || "(empty)", "", `=== LONG (${longPath}) ===`, message.long || "(empty)"].join("\n");
|
|
11931
11937
|
}
|
|
11932
11938
|
|
|
11933
11939
|
function formatInputCommitMessagePreview(message) {
|
package/public/styles.css
CHANGED
|
@@ -1950,8 +1950,7 @@ body.side-panel-collapsed .terminal-tabs-shell {
|
|
|
1950
1950
|
}
|
|
1951
1951
|
.widget-area:has(.release-npm-live-widget .release-npm-output-details[open]),
|
|
1952
1952
|
.widget-area:has(.release-aur-live-widget .release-npm-output-details[open]),
|
|
1953
|
-
.widget-area:has(.workflow-live-widget .release-npm-output-details[open])
|
|
1954
|
-
.widget-area:has(.app-runner-live-widget .release-npm-output-details[open]) {
|
|
1953
|
+
.widget-area:has(.workflow-live-widget .release-npm-output-details[open]) {
|
|
1955
1954
|
flex: 0 0 min(44rem, 68dvh);
|
|
1956
1955
|
min-height: 0;
|
|
1957
1956
|
overflow: auto;
|
|
@@ -1959,6 +1958,14 @@ body.side-panel-collapsed .terminal-tabs-shell {
|
|
|
1959
1958
|
scrollbar-gutter: stable;
|
|
1960
1959
|
overflow-anchor: none;
|
|
1961
1960
|
}
|
|
1961
|
+
.widget-area:has(.app-runner-live-widget .release-npm-output-details[open]) {
|
|
1962
|
+
flex: 0 0 auto;
|
|
1963
|
+
min-height: 0;
|
|
1964
|
+
overflow: visible;
|
|
1965
|
+
overscroll-behavior: contain;
|
|
1966
|
+
scrollbar-gutter: auto;
|
|
1967
|
+
overflow-anchor: none;
|
|
1968
|
+
}
|
|
1962
1969
|
.statusbar {
|
|
1963
1970
|
position: relative;
|
|
1964
1971
|
flex: 0 0 auto;
|
|
@@ -3842,8 +3849,7 @@ button.git-workflow-step:hover:not(:disabled) {
|
|
|
3842
3849
|
}
|
|
3843
3850
|
.release-npm-live-widget .release-npm-output-details[open] .release-npm-terminal,
|
|
3844
3851
|
.release-aur-live-widget .release-npm-output-details[open] .release-npm-terminal,
|
|
3845
|
-
.workflow-live-widget .release-npm-output-details[open] .release-npm-terminal
|
|
3846
|
-
.app-runner-live-widget .release-npm-output-details[open] .release-npm-terminal {
|
|
3852
|
+
.workflow-live-widget .release-npm-output-details[open] .release-npm-terminal {
|
|
3847
3853
|
height: clamp(15rem, 42dvh, 31rem);
|
|
3848
3854
|
min-height: 0;
|
|
3849
3855
|
}
|
|
@@ -508,6 +508,65 @@ try {
|
|
|
508
508
|
assert.match(interactiveOutput, /# stdin sent \(5 chars\) and closed/, "app runner output should show that stdin was sent without echoing the input text itself");
|
|
509
509
|
await request("127.0.0.1", "/api/app-runner/clear", { method: "POST", body: { tab: tabId } });
|
|
510
510
|
|
|
511
|
+
const scriptVersion = spawnSync("script", ["--version"], { encoding: "utf8" });
|
|
512
|
+
const utilLinuxScriptAvailable = process.platform !== "win32" && scriptVersion.status === 0 && /util-linux/i.test(`${scriptVersion.stdout}\n${scriptVersion.stderr}`);
|
|
513
|
+
const bashAvailable = spawnSync("bash", ["--version"], { encoding: "utf8" }).status === 0;
|
|
514
|
+
if (utilLinuxScriptAvailable && bashAvailable) {
|
|
515
|
+
await mkdir(path.join(cwd, "qa"), { recursive: true });
|
|
516
|
+
await writeFile(path.join(cwd, "qa", "read-p-runner.sh"), [
|
|
517
|
+
"#!/usr/bin/env bash",
|
|
518
|
+
"set -euo pipefail",
|
|
519
|
+
"read -r -p 'choice? ' answer",
|
|
520
|
+
"printf 'selected:%s\\n' \"$answer\"",
|
|
521
|
+
"",
|
|
522
|
+
].join("\n"));
|
|
523
|
+
const savedReadPromptRunner = await request("127.0.0.1", "/api/app-runner-config", {
|
|
524
|
+
method: "POST",
|
|
525
|
+
body: { tab: tabId, runner: { label: "Read prompt bash", command: "bash", path: "qa/read-p-runner.sh" } },
|
|
526
|
+
timeoutMs: 10_000,
|
|
527
|
+
});
|
|
528
|
+
assert.equal(savedReadPromptRunner.status, 200, `saving a bash read -p runner should succeed: ${savedReadPromptRunner.body?.error || ""}`);
|
|
529
|
+
const readPromptRunner = savedReadPromptRunner.body?.data?.runners?.find((runner) => runner.custom === true && runner.label === "Read prompt bash");
|
|
530
|
+
assert.ok(readPromptRunner?.id, "bash read -p runner should appear in detected app runners");
|
|
531
|
+
const readPromptStart = await request("127.0.0.1", "/api/app-runner", {
|
|
532
|
+
method: "POST",
|
|
533
|
+
body: { tab: tabId, runnerId: readPromptRunner.id },
|
|
534
|
+
timeoutMs: 10_000,
|
|
535
|
+
});
|
|
536
|
+
assert.equal(readPromptStart.status, 200, `bash read -p runner start should return ok: ${readPromptStart.body?.error || ""}`);
|
|
537
|
+
assert.equal(readPromptStart.body?.data?.activeRun?.executionMode, "pty", "bash read -p runner should use the PTY-backed execution path when util-linux script is available");
|
|
538
|
+
let readPromptState = readPromptStart;
|
|
539
|
+
for (let attempt = 0; attempt < 50; attempt++) {
|
|
540
|
+
readPromptState = await request("127.0.0.1", `/api/app-runners?tab=${encodeURIComponent(tabId)}`, { timeoutMs: 5_000 });
|
|
541
|
+
const output = [
|
|
542
|
+
...(readPromptState.body?.data?.activeRun?.lines || []),
|
|
543
|
+
readPromptState.body?.data?.activeRun?.pendingLine || "",
|
|
544
|
+
].join("\n");
|
|
545
|
+
if (/choice\?/.test(output)) break;
|
|
546
|
+
await delay(100);
|
|
547
|
+
}
|
|
548
|
+
assert.match([
|
|
549
|
+
...(readPromptState.body?.data?.activeRun?.lines || []),
|
|
550
|
+
readPromptState.body?.data?.activeRun?.pendingLine || "",
|
|
551
|
+
].join("\n"), /choice\?/, "bash read -p prompts should be captured before a trailing newline");
|
|
552
|
+
const readPromptInput = await request("127.0.0.1", "/api/app-runner/input", {
|
|
553
|
+
method: "POST",
|
|
554
|
+
body: { tab: tabId, text: "alpha", closeStdin: true },
|
|
555
|
+
timeoutMs: 10_000,
|
|
556
|
+
});
|
|
557
|
+
assert.equal(readPromptInput.status, 200, `bash read -p runner input should be accepted: ${readPromptInput.body?.error || ""}`);
|
|
558
|
+
for (let attempt = 0; attempt < 50; attempt++) {
|
|
559
|
+
if (readPromptState.body?.data?.activeRun?.status && readPromptState.body.data.activeRun.status !== "running") break;
|
|
560
|
+
await delay(100);
|
|
561
|
+
readPromptState = await request("127.0.0.1", `/api/app-runners?tab=${encodeURIComponent(tabId)}`, { timeoutMs: 5_000 });
|
|
562
|
+
}
|
|
563
|
+
assert.equal(readPromptState.body?.data?.activeRun?.status, "done", "bash read -p runner should finish after stdin");
|
|
564
|
+
const readPromptOutput = (readPromptState.body?.data?.activeRun?.lines || []).join("\n");
|
|
565
|
+
assert.match(readPromptOutput, /selected:alpha/, "bash read -p runner should receive stdin from the app-runner input endpoint");
|
|
566
|
+
assert.doesNotMatch(readPromptOutput, /^alpha$/m, "PTY-backed app runner should not echo raw stdin into captured output");
|
|
567
|
+
await request("127.0.0.1", "/api/app-runner/clear", { method: "POST", body: { tab: tabId } });
|
|
568
|
+
}
|
|
569
|
+
|
|
511
570
|
await writeFile(path.join(cwd, ".pi-webui-runners.json"), `${JSON.stringify({
|
|
512
571
|
version: 1,
|
|
513
572
|
runners: [{ id: "broken-custom", label: "Broken custom", command: "definitely-missing-pi-webui-runner", path: "custom-runner.mjs" }],
|