Skip to content

Commit 6090eed

Browse files
committed
fix
1 parent 155b1d9 commit 6090eed

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/lib/openFolder.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const convertToProotPath = (url = "") => {
5858
if (cleanUrl.startsWith(alpineRoot)) {
5959
return cleanUrl.replace(alpineRoot, "") || "/";
6060
}
61+
console.warn(`Unrecognized path for terminal conversion: ${url}`);
6162
return cleanUrl;
6263
};
6364

@@ -461,12 +462,18 @@ function execOperation(type, action, url, $target, name) {
461462
render: true,
462463
});
463464
if (terminal?.component) {
464-
const waitForConnection = () =>
465-
new Promise((resolve) => {
466-
const check = () =>
467-
terminal.component.isConnected
468-
? resolve()
469-
: setTimeout(check, 50);
465+
const waitForConnection = (timeoutMs = 5000) =>
466+
new Promise((resolve, reject) => {
467+
const startTime = Date.now();
468+
const check = () => {
469+
if (terminal.component.isConnected) {
470+
resolve();
471+
} else if (Date.now() - startTime > timeoutMs) {
472+
reject(new Error("Terminal connection timeout"));
473+
} else {
474+
setTimeout(check, 50);
475+
}
476+
};
470477
check();
471478
});
472479
await waitForConnection();
@@ -475,7 +482,8 @@ function execOperation(type, action, url, $target, name) {
475482
}
476483
} catch (error) {
477484
console.error("Failed to open terminal:", error);
478-
toast(strings["error"] || "Error");
485+
const errorMsg = error.message || "Unknown error occurred";
486+
toast(`Failed to open terminal: ${errorMsg}`);
479487
}
480488
}
481489

0 commit comments

Comments
 (0)