feat(terminals): set PI WEB shell environment

This commit is contained in:
ongspxm
2026-07-14 21:21:50 +08:00
committed by Metta Ong
parent 4d9167e837
commit 73ac24c882
4 changed files with 28 additions and 2 deletions
@@ -0,0 +1,5 @@
---
"@jmfederico/pi-web": patch
---
Set `IS_PIWEB=1` in PI WEB terminal shells.
+3
View File
@@ -140,5 +140,8 @@
"./extensions" "./extensions"
], ],
"image": "https://raw.githubusercontent.com/jmfederico/pi-web/main/docs/assets/pi-web-banner.png" "image": "https://raw.githubusercontent.com/jmfederico/pi-web/main/docs/assets/pi-web-banner.png"
},
"allowScripts": {
"[email protected]": true
} }
} }
@@ -22,6 +22,24 @@ describe.skipIf(process.platform === "win32")("TerminalService command runs", ()
} }
}); });
it("sets IS_PIWEB for terminal commands", async () => {
const service = new TerminalService();
try {
const run = service.runCommand({
origin: "core",
projectId: "p1",
workspaceId: "w1",
cwd: process.cwd(),
title: "Environment check",
command: "printf '%s' \"$IS_PIWEB\"",
});
expect(await terminalExit(service, run.terminalId)).toContain("1");
} finally {
service.dispose();
}
});
it("tracks dedicated terminal command runs through completion", async () => { it("tracks dedicated terminal command runs through completion", async () => {
const service = new TerminalService(); const service = new TerminalService();
try { try {
+2 -2
View File
@@ -163,7 +163,7 @@ export class TerminalService {
cwd: record.cwd, cwd: record.cwd,
cols: 100, cols: 100,
rows: 30, rows: 30,
env: { ...process.env, TERM: "xterm-256color" }, env: { ...process.env, TERM: "xterm-256color", IS_PIWEB: "1" },
}); });
this.attachPtyEvents(record); this.attachPtyEvents(record);
const info = toInfo(record); const info = toInfo(record);
@@ -196,7 +196,7 @@ export class TerminalService {
cwd: options.cwd, cwd: options.cwd,
cols: options.cols ?? 100, cols: options.cols ?? 100,
rows: options.rows ?? 30, rows: options.rows ?? 30,
env: { ...process.env, TERM: "xterm-256color" }, env: { ...process.env, TERM: "xterm-256color", IS_PIWEB: "1" },
}); });
const requestedName = options.name?.trim(); const requestedName = options.name?.trim();
const record: TerminalRecord = { const record: TerminalRecord = {