Fix for frontend stall (#12069)

This commit is contained in:
Tim O'Farrell 2025-12-16 20:35:46 -07:00 committed by GitHub
parent 281ac91540
commit dc14624480
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,3 +1,5 @@
const START = "[Python Interpreter: ";
/**
* Parses the raw output from the terminal into the command and symbol
* @param raw The raw output to be displayed in the terminal
@ -13,9 +15,14 @@
* console.log(parsed.symbol); // openhands@659478cb008c:/workspace $
*/
export const parseTerminalOutput = (raw: string) => {
const envRegex = /(.*)\[Python Interpreter: (.*)\]/s;
const match = raw.match(envRegex);
if (!match) return raw;
return match[1]?.trim() || "";
const start = raw.indexOf(START);
if (start < 0) {
return raw;
}
const offset = start + START.length;
const end = raw.indexOf("]", offset);
if (end <= offset) {
return raw;
}
return raw.substring(0, start).trim();
};