From df320d5990eae782182567c7877f27b46bd3f58b Mon Sep 17 00:00:00 2001 From: Raunak Raj <71929976+bajrangCoder@users.noreply.github.com> Date: Sun, 11 Jan 2026 19:27:15 +0530 Subject: [PATCH 1/4] feat: add "Open in Terminal" option to folder context menu --- src/lang/en-us.json | 1 + src/lib/openFolder.js | 76 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/src/lang/en-us.json b/src/lang/en-us.json index ab7aa23dc..8c15b4ba7 100644 --- a/src/lang/en-us.json +++ b/src/lang/en-us.json @@ -59,6 +59,7 @@ "open file": "Open file", "open files and folders": "Open files and folders", "open folder": "Open folder", + "open in terminal": "Open in Terminal", "open recent": "Open recent", "ok": "ok", "overwrite": "Overwrite", diff --git a/src/lib/openFolder.js b/src/lib/openFolder.js index 6268ea053..24bfa7bfd 100644 --- a/src/lib/openFolder.js +++ b/src/lib/openFolder.js @@ -3,6 +3,7 @@ import sidebarApps from "sidebarApps"; import collapsableList from "components/collapsableList"; import FileTree from "components/fileTree"; import Sidebar from "components/sidebar"; +import { TerminalManager } from "components/terminal"; import tile from "components/tile"; import toast from "components/toast"; import alert from "dialogs/alert"; @@ -27,6 +28,39 @@ const isAcodeTerminalPublicSafUri = (value = "") => const isTerminalSafUri = (value = "") => isTermuxSafUri(value) || isAcodeTerminalPublicSafUri(value); +const getTerminalPaths = () => { + const packageName = window.BuildInfo?.packageName || "com.foxdebug.acode"; + const dataDir = `/data/user/0/${packageName}`; + const alpineRoot = `${dataDir}/files/alpine`; + const publicDir = `${dataDir}/files/public`; + return { alpineRoot, publicDir, dataDir }; +}; + +const isTerminalAccessiblePath = (url = "") => { + if (isAcodeTerminalPublicSafUri(url)) return true; + const { alpineRoot, publicDir } = getTerminalPaths(); + const cleanUrl = url.replace(/^file:\/\//, ""); + if (cleanUrl.startsWith(alpineRoot) || cleanUrl.startsWith(publicDir)) { + return true; + } + return false; +}; + +const convertToProotPath = (url = "") => { + const { alpineRoot, publicDir } = getTerminalPaths(); + if (isAcodeTerminalPublicSafUri(url)) { + return "/public"; + } + const cleanUrl = url.replace(/^file:\/\//, ""); + if (cleanUrl.startsWith(publicDir)) { + return cleanUrl.replace(publicDir, "/public"); + } + if (cleanUrl.startsWith(alpineRoot)) { + return cleanUrl.replace(alpineRoot, "") || "/"; + } + return cleanUrl; +}; + /** * @typedef {import('../components/collapsableList').Collapsible} Collapsible */ @@ -311,6 +345,15 @@ async function handleContextmenu(type, url, name, $target) { } options.push(NEW_FILE, NEW_FOLDER, OPEN_FOLDER, INSERT_FILE); + + if (isTerminalAccessiblePath(url)) { + const OPEN_IN_TERMINAL = [ + "open-in-terminal", + strings["open in terminal"] || "Open in Terminal", + "licons terminal", + ]; + options.push(OPEN_IN_TERMINAL); + } } else if (type === "root") { options = []; @@ -318,7 +361,18 @@ async function handleContextmenu(type, url, name, $target) { options.push(PASTE); } - options.push(NEW_FILE, NEW_FOLDER, INSERT_FILE, CLOSE_FOLDER); + options.push(NEW_FILE, NEW_FOLDER, INSERT_FILE); + + if (isTerminalAccessiblePath(url)) { + const OPEN_IN_TERMINAL = [ + "open-in-terminal", + strings["open in terminal"] || "Open in Terminal", + "licons terminal", + ]; + options.push(OPEN_IN_TERMINAL); + } + + options.push(CLOSE_FOLDER); } if (clipBoard.action) options.push(CANCEL); @@ -378,6 +432,9 @@ function execOperation(type, action, url, $target, name) { case "install-plugin": return installPlugin(); + + case "open-in-terminal": + return openInTerminal(); } async function installPlugin() { @@ -396,6 +453,23 @@ function execOperation(type, action, url, $target, name) { } } + async function openInTerminal() { + try { + const prootPath = convertToProotPath(url); + const terminal = await TerminalManager.createTerminal({ + name: `Terminal - ${name}`, + render: true, + }); + if (terminal?.component) { + terminal.component.write(`cd ${JSON.stringify(prootPath)}\n`); + Sidebar.hide(); + } + } catch (error) { + console.error("Failed to open terminal:", error); + toast(strings["error"] || "Error"); + } + } + async function deleteFile() { const msg = strings["delete entry"].replace("{name}", name); const confirmation = await confirm(strings.warning, msg); From c480a01274d8f9e5f80ca619332cad858b39feae Mon Sep 17 00:00:00 2001 From: Raunak Raj <71929976+bajrangCoder@users.noreply.github.com> Date: Sun, 11 Jan 2026 19:28:40 +0530 Subject: [PATCH 2/4] feat: Add localization string for "open in terminal" --- src/lang/ar-ye.json | 3 ++- src/lang/be-by.json | 3 ++- src/lang/bn-bd.json | 3 ++- src/lang/cs-cz.json | 3 ++- src/lang/de-de.json | 3 ++- src/lang/en-us.json | 4 ++-- src/lang/es-sv.json | 3 ++- src/lang/fr-fr.json | 3 ++- src/lang/he-il.json | 3 ++- src/lang/hi-in.json | 3 ++- src/lang/hu-hu.json | 3 ++- src/lang/id-id.json | 3 ++- src/lang/ir-fa.json | 3 ++- src/lang/it-it.json | 3 ++- src/lang/ja-jp.json | 3 ++- src/lang/ko-kr.json | 3 ++- src/lang/ml-in.json | 3 ++- src/lang/mm-unicode.json | 3 ++- src/lang/mm-zawgyi.json | 3 ++- src/lang/pl-pl.json | 3 ++- src/lang/pt-br.json | 3 ++- src/lang/pu-in.json | 3 ++- src/lang/ru-ru.json | 3 ++- src/lang/tl-ph.json | 3 ++- src/lang/tr-tr.json | 3 ++- src/lang/uk-ua.json | 3 ++- src/lang/uz-uz.json | 3 ++- src/lang/vi-vn.json | 3 ++- src/lang/zh-cn.json | 3 ++- src/lang/zh-hant.json | 3 ++- src/lang/zh-tw.json | 3 ++- 31 files changed, 62 insertions(+), 32 deletions(-) diff --git a/src/lang/ar-ye.json b/src/lang/ar-ye.json index 15fd059b9..5dcc22100 100644 --- a/src/lang/ar-ye.json +++ b/src/lang/ar-ye.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/be-by.json b/src/lang/be-by.json index 28e72d2d2..dc3fc1f27 100644 --- a/src/lang/be-by.json +++ b/src/lang/be-by.json @@ -494,5 +494,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/bn-bd.json b/src/lang/bn-bd.json index f4a3153b8..70efd9da4 100644 --- a/src/lang/bn-bd.json +++ b/src/lang/bn-bd.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/cs-cz.json b/src/lang/cs-cz.json index d10be055d..92022ebb7 100644 --- a/src/lang/cs-cz.json +++ b/src/lang/cs-cz.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/de-de.json b/src/lang/de-de.json index 63bb34ff7..3ae6dfcee 100644 --- a/src/lang/de-de.json +++ b/src/lang/de-de.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/en-us.json b/src/lang/en-us.json index 8c15b4ba7..e8d89320e 100644 --- a/src/lang/en-us.json +++ b/src/lang/en-us.json @@ -59,7 +59,6 @@ "open file": "Open file", "open files and folders": "Open files and folders", "open folder": "Open folder", - "open in terminal": "Open in Terminal", "open recent": "Open recent", "ok": "ok", "overwrite": "Overwrite", @@ -494,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/es-sv.json b/src/lang/es-sv.json index 4a6d0501b..8f9796cb1 100644 --- a/src/lang/es-sv.json +++ b/src/lang/es-sv.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/fr-fr.json b/src/lang/fr-fr.json index 3ada6f3cb..4300e03de 100644 --- a/src/lang/fr-fr.json +++ b/src/lang/fr-fr.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/he-il.json b/src/lang/he-il.json index 6b91116cb..3aa295b66 100644 --- a/src/lang/he-il.json +++ b/src/lang/he-il.json @@ -494,5 +494,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/hi-in.json b/src/lang/hi-in.json index 381ab2ea7..895613126 100644 --- a/src/lang/hi-in.json +++ b/src/lang/hi-in.json @@ -494,5 +494,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/hu-hu.json b/src/lang/hu-hu.json index 0b9ae85c3..e5991f54f 100644 --- a/src/lang/hu-hu.json +++ b/src/lang/hu-hu.json @@ -493,5 +493,6 @@ "recent": "Legutóbbi fájlok", "command palette": "Parancspaletta megnyitása", "change theme": "Téma módosítása", - "documentation": "Dokumentáció" + "documentation": "Dokumentáció", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/id-id.json b/src/lang/id-id.json index 9c12bf109..227352aaf 100644 --- a/src/lang/id-id.json +++ b/src/lang/id-id.json @@ -494,5 +494,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/ir-fa.json b/src/lang/ir-fa.json index ec018cbb6..4121138b5 100644 --- a/src/lang/ir-fa.json +++ b/src/lang/ir-fa.json @@ -494,5 +494,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/it-it.json b/src/lang/it-it.json index 59b19e238..78da24419 100644 --- a/src/lang/it-it.json +++ b/src/lang/it-it.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/ja-jp.json b/src/lang/ja-jp.json index 0d2aaf5f2..a24bcd4ef 100644 --- a/src/lang/ja-jp.json +++ b/src/lang/ja-jp.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/ko-kr.json b/src/lang/ko-kr.json index 383aa081a..445c4da62 100644 --- a/src/lang/ko-kr.json +++ b/src/lang/ko-kr.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/ml-in.json b/src/lang/ml-in.json index b528b78ee..f08d98432 100644 --- a/src/lang/ml-in.json +++ b/src/lang/ml-in.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/mm-unicode.json b/src/lang/mm-unicode.json index b69a6c4a8..78743343c 100644 --- a/src/lang/mm-unicode.json +++ b/src/lang/mm-unicode.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/mm-zawgyi.json b/src/lang/mm-zawgyi.json index d32917c69..2663570d3 100644 --- a/src/lang/mm-zawgyi.json +++ b/src/lang/mm-zawgyi.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/pl-pl.json b/src/lang/pl-pl.json index 03258cb54..8fb0d5296 100644 --- a/src/lang/pl-pl.json +++ b/src/lang/pl-pl.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/pt-br.json b/src/lang/pt-br.json index e168eee70..3b6a2a5a5 100644 --- a/src/lang/pt-br.json +++ b/src/lang/pt-br.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/pu-in.json b/src/lang/pu-in.json index 21212aff6..6f1372b7f 100644 --- a/src/lang/pu-in.json +++ b/src/lang/pu-in.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/ru-ru.json b/src/lang/ru-ru.json index b18c7f9bc..b0b22da28 100644 --- a/src/lang/ru-ru.json +++ b/src/lang/ru-ru.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/tl-ph.json b/src/lang/tl-ph.json index f7ac70075..000636bf4 100644 --- a/src/lang/tl-ph.json +++ b/src/lang/tl-ph.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/tr-tr.json b/src/lang/tr-tr.json index 31f6abb91..9a39f5231 100644 --- a/src/lang/tr-tr.json +++ b/src/lang/tr-tr.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/uk-ua.json b/src/lang/uk-ua.json index f88f880e8..c76c0c9fb 100644 --- a/src/lang/uk-ua.json +++ b/src/lang/uk-ua.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/uz-uz.json b/src/lang/uz-uz.json index 5523589b9..56054aa35 100644 --- a/src/lang/uz-uz.json +++ b/src/lang/uz-uz.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/vi-vn.json b/src/lang/vi-vn.json index b321447d4..213d9bad8 100644 --- a/src/lang/vi-vn.json +++ b/src/lang/vi-vn.json @@ -494,5 +494,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/zh-cn.json b/src/lang/zh-cn.json index f7942af7d..c4c1e539d 100644 --- a/src/lang/zh-cn.json +++ b/src/lang/zh-cn.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/zh-hant.json b/src/lang/zh-hant.json index 595ff6e0d..a36942c44 100644 --- a/src/lang/zh-hant.json +++ b/src/lang/zh-hant.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } diff --git a/src/lang/zh-tw.json b/src/lang/zh-tw.json index dea6c1133..3d8d6db43 100644 --- a/src/lang/zh-tw.json +++ b/src/lang/zh-tw.json @@ -493,5 +493,6 @@ "recent": "Recent Files", "command palette": "Open Command Palette", "change theme": "Change Theme", - "documentation": "Documentation" + "documentation": "Documentation", + "open in terminal": "Open in Terminal" } From 155b1d9f4b5774b8e4769c368b3e7688fd98bf77 Mon Sep 17 00:00:00 2001 From: Raunak Raj <71929976+bajrangCoder@users.noreply.github.com> Date: Sun, 11 Jan 2026 19:35:50 +0530 Subject: [PATCH 3/4] fix: race condition --- src/lib/openFolder.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib/openFolder.js b/src/lib/openFolder.js index 24bfa7bfd..70d0e1f5d 100644 --- a/src/lib/openFolder.js +++ b/src/lib/openFolder.js @@ -461,6 +461,15 @@ function execOperation(type, action, url, $target, name) { render: true, }); if (terminal?.component) { + const waitForConnection = () => + new Promise((resolve) => { + const check = () => + terminal.component.isConnected + ? resolve() + : setTimeout(check, 50); + check(); + }); + await waitForConnection(); terminal.component.write(`cd ${JSON.stringify(prootPath)}\n`); Sidebar.hide(); } From 6090eedcc860a581b1da8c86a8f38492518a6900 Mon Sep 17 00:00:00 2001 From: Raunak Raj <71929976+bajrangCoder@users.noreply.github.com> Date: Sun, 11 Jan 2026 19:45:11 +0530 Subject: [PATCH 4/4] fix --- src/lib/openFolder.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/lib/openFolder.js b/src/lib/openFolder.js index 70d0e1f5d..d18489209 100644 --- a/src/lib/openFolder.js +++ b/src/lib/openFolder.js @@ -58,6 +58,7 @@ const convertToProotPath = (url = "") => { if (cleanUrl.startsWith(alpineRoot)) { return cleanUrl.replace(alpineRoot, "") || "/"; } + console.warn(`Unrecognized path for terminal conversion: ${url}`); return cleanUrl; }; @@ -461,12 +462,18 @@ function execOperation(type, action, url, $target, name) { render: true, }); if (terminal?.component) { - const waitForConnection = () => - new Promise((resolve) => { - const check = () => - terminal.component.isConnected - ? resolve() - : setTimeout(check, 50); + const waitForConnection = (timeoutMs = 5000) => + new Promise((resolve, reject) => { + const startTime = Date.now(); + const check = () => { + if (terminal.component.isConnected) { + resolve(); + } else if (Date.now() - startTime > timeoutMs) { + reject(new Error("Terminal connection timeout")); + } else { + setTimeout(check, 50); + } + }; check(); }); await waitForConnection(); @@ -475,7 +482,8 @@ function execOperation(type, action, url, $target, name) { } } catch (error) { console.error("Failed to open terminal:", error); - toast(strings["error"] || "Error"); + const errorMsg = error.message || "Unknown error occurred"; + toast(`Failed to open terminal: ${errorMsg}`); } }