Skip to content

Commit de0c4a2

Browse files
author
埃博拉酱
committed
refactor: remove embedded AXS debug path
Remove the debug-only asset refresh flow from the terminal plugin and terminal session startup. Keep AXS acquisition on the normal download path so debug and release share the same runtime behavior. This also drops the PTY retry path that depended on replacing the local binary from bundled assets.
1 parent 8333395 commit de0c4a2

File tree

2 files changed

+9
-88
lines changed

2 files changed

+9
-88
lines changed

src/components/terminal/terminal.js

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,6 @@ export default class TerminalComponent {
637637
};
638638

639639
if (!axsRunning) {
640-
// In debug builds, refresh axs binary from assets before starting
641-
await Terminal.refreshAxsBinary();
642640
await Terminal.startAxs(false, () => {}, console.error);
643641
}
644642

@@ -719,35 +717,8 @@ export default class TerminalComponent {
719717
const data = await response.text();
720718
const ptyOpenError = parsePtyOpenError(data);
721719

722-
// Detect PTY errors from axs server (e.g. incompatible binary)
723720
if (ptyOpenError?.includes("Failed to open PTY")) {
724-
const refreshed = await Terminal.refreshAxsBinary();
725-
if (refreshed) {
726-
// Kill old axs, restart with fresh binary, and retry once
727-
try {
728-
await Terminal.stopAxs();
729-
} catch (_) {}
730-
await Terminal.startAxs(false, () => {}, console.error);
731-
const pollResult = await pollAxs(30);
732-
if (pollResult) {
733-
const retryResp = await fetch(
734-
`http://localhost:${this.options.port}/terminals`,
735-
{
736-
method: "POST",
737-
headers: { "Content-Type": "application/json" },
738-
body: JSON.stringify(requestBody),
739-
},
740-
);
741-
if (retryResp.ok) {
742-
const retryData = await retryResp.text();
743-
if (!parsePtyOpenError(retryData)) {
744-
this.pid = retryData.trim();
745-
return this.pid;
746-
}
747-
}
748-
}
749-
}
750-
throw new Error("Failed to open PTY even after refreshing AXS binary");
721+
throw new Error("Failed to open PTY");
751722
}
752723

753724
this.pid = data.trim();

src/plugins/terminal/www/Terminal.js

Lines changed: 8 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,6 @@
11
const Executor = require("./Executor");
22

3-
function formatAxsAssetError(error) {
4-
if (!error) return "unknown error";
5-
if (typeof error === "string") return error;
6-
if (error instanceof Error) {
7-
return error.stack || error.message || String(error);
8-
}
9-
try {
10-
return JSON.stringify(error);
11-
} catch (_) {
12-
return String(error);
13-
}
14-
}
15-
163
const Terminal = {
17-
/**
18-
* In debug builds, overwrite the axs binary from bundled assets to ensure
19-
* the running version always matches the build. Returns true if replaced.
20-
*/
21-
async refreshAxsBinary() {
22-
if (typeof BuildInfo === 'undefined' || !BuildInfo.debug) return false;
23-
const filesDir = await new Promise((resolve, reject) => {
24-
system.getFilesDir(resolve, reject);
25-
});
26-
try {
27-
await new Promise((resolve, reject) => {
28-
system.copyAsset("axs", `${filesDir}/axs`, resolve, reject);
29-
});
30-
return true;
31-
} catch (e) {
32-
console.warn("Failed to refresh bundled AXS from assets:", formatAxsAssetError(e));
33-
return false;
34-
}
35-
},
36-
374
/**
385
* Starts the AXS environment by writing init scripts and executing the sandbox.
396
* @param {boolean} [installing=false] - Whether AXS is being started during installation.
@@ -261,31 +228,14 @@ const Terminal = {
261228
}
262229

263230
if (!hasAxs) {
264-
let copiedFromAsset = false;
265-
// Only use bundled axs in debug builds; release builds always download latest
266-
if (typeof BuildInfo !== 'undefined' && BuildInfo.debug) {
267-
try {
268-
logger("📦 Copying bundled axs from assets...");
269-
await new Promise((resolve, reject) => {
270-
system.copyAsset("axs", `${filesDir}/axs`, resolve, reject);
271-
});
272-
copiedFromAsset = true;
273-
logger("✅ Bundled AXS copied from assets");
274-
} catch (assetError) {
275-
logger(`⚠️ Asset copy failed, will download instead: ${formatAxsAssetError(assetError)}`);
276-
}
277-
}
278-
279-
if (!copiedFromAsset) {
280-
logger("⬇️ Downloading axs...");
281-
await Executor.download(axsUrl, `${filesDir}/axs`, (p) => {
282-
const dl = formatBytes(p.downloaded);
283-
const total = p.total > 0 ? formatBytes(p.total) : "?";
284-
const speed = formatBytes(p.speed) + "/s";
285-
const eta = p.eta > 0 ? formatEta(p.eta) : "--";
286-
logger(`⬇️ ${dl} / ${total} ${speed} ETA ${eta}`);
287-
});
288-
}
231+
logger("⬇️ Downloading axs...");
232+
await Executor.download(axsUrl, `${filesDir}/axs`, (p) => {
233+
const dl = formatBytes(p.downloaded);
234+
const total = p.total > 0 ? formatBytes(p.total) : "?";
235+
const speed = formatBytes(p.speed) + "/s";
236+
const eta = p.eta > 0 ? formatEta(p.eta) : "--";
237+
logger(`⬇️ ${dl} / ${total} ${speed} ETA ${eta}`);
238+
});
289239
} else {
290240
logger("✅ AXS binary already downloaded");
291241
}

0 commit comments

Comments
 (0)