diff --git a/package.json b/package.json index a24c5336ac..7a783ee165 100644 --- a/package.json +++ b/package.json @@ -46,9 +46,7 @@ "cordova-plugin-iap": {}, "com.foxdebug.acode.rk.customtabs": {}, "cordova-plugin-crashhandler": {}, - "cordova-plugin-advanced-http": { - "ANDROIDBLACKLISTSECURESOCKETPROTOCOLS": "SSLv3,TLSv1" - }, + "cordova-plugin-advanced-http": {}, "cordova-plugin-acode-webview": {}, "cordova-plugin-system": {} }, diff --git a/src/components/terminal/terminal.js b/src/components/terminal/terminal.js index dca6f15b44..1a9f8b3a02 100644 --- a/src/components/terminal/terminal.js +++ b/src/components/terminal/terminal.js @@ -727,6 +727,7 @@ export default class TerminalComponent { () => {}, console.error, terminalValues.failsafeMode, + terminalValues.mergedHomeDirectories !== false, ); } diff --git a/src/components/terminal/terminalDefaults.js b/src/components/terminal/terminalDefaults.js index 2bde0aa88d..6b6d47da1c 100644 --- a/src/components/terminal/terminalDefaults.js +++ b/src/components/terminal/terminalDefaults.js @@ -18,6 +18,7 @@ export const DEFAULT_TERMINAL_SETTINGS = { confirmTabClose: true, failsafeMode: false, prootDebug: false, + mergedHomeDirectories: true, // Touch selection settings touchSelectionTapHoldDuration: 400, touchSelectionMoveThreshold: 8, diff --git a/src/components/terminal/terminalManager.js b/src/components/terminal/terminalManager.js index 63f05d44a0..1eaca24d58 100644 --- a/src/components/terminal/terminalManager.js +++ b/src/components/terminal/terminalManager.js @@ -461,6 +461,7 @@ class TerminalManager { `\x1b[31mError: ${cleanError}\x1b[0m\r\n`, ); }, + appSettings.value.terminalSettings?.mergedHomeDirectories !== false, ); // Only return success if Terminal.install() indicates success (exit code 0) @@ -1232,7 +1233,16 @@ class TerminalManager { let convertedPath; - if (prootPath.startsWith("/public")) { + const mergedHomeDirectories = + appSettings.value.terminalSettings?.mergedHomeDirectories !== false; + const homePathMatch = mergedHomeDirectories + ? prootPath.match(/^\/(home|root)(\/.*)?$/) + : null; + + if (homePathMatch) { + // /home and /root are bind-mounted to the public directory. + convertedPath = `file://${dataDir}/files/public${homePathMatch[2] || ""}`; + } else if (prootPath.startsWith("/public")) { // /public -> /data/user/0/com.foxdebug.acode/files/public convertedPath = `file://${dataDir}/files${prootPath}`; } else if ( diff --git a/src/lang/ar-ye.json b/src/lang/ar-ye.json index 67b21b3d7c..51d1958b7c 100644 --- a/src/lang/ar-ye.json +++ b/src/lang/ar-ye.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/az-az.json b/src/lang/az-az.json index 6285bb588a..8f0e7c0ec6 100644 --- a/src/lang/az-az.json +++ b/src/lang/az-az.json @@ -887,5 +887,10 @@ "plugin-review:error-max-length": "Rəy ən çox {max} simvoldan ibarət olmalıdır.", "plugin-review:error-downvote-comment": "Nəyin yaxşılaşdırıla biləcəyini tərtibatçıya bildir.", "plugin-review:error-empty": "Şərh əlavə et və ya «Bəyən» seçimini et.", - "plugin-review:unrated": "Qiymətləndirilməyib" + "plugin-review:unrated": "Qiymətləndirilməyib", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/be-by.json b/src/lang/be-by.json index 98601603c2..dd1995b69e 100644 --- a/src/lang/be-by.json +++ b/src/lang/be-by.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/bn-bd.json b/src/lang/bn-bd.json index c439ccecdc..0e4c4b18ec 100644 --- a/src/lang/bn-bd.json +++ b/src/lang/bn-bd.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/cs-cz.json b/src/lang/cs-cz.json index f33b46844d..41e22f05ad 100644 --- a/src/lang/cs-cz.json +++ b/src/lang/cs-cz.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/de-de.json b/src/lang/de-de.json index c19f4e6f56..24790c5ccc 100644 --- a/src/lang/de-de.json +++ b/src/lang/de-de.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/en-us.json b/src/lang/en-us.json index 2869c6c2c2..954643999c 100644 --- a/src/lang/en-us.json +++ b/src/lang/en-us.json @@ -478,6 +478,11 @@ "terminal:convert eol": "Convert EOL", "terminal:confirm tab close": "Confirm terminal tab close", "terminal:image support": "Image support", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change.", "terminal": "Terminal", "running processes": "Running processes", "terminal not installed prompt": "Terminal is not installed. Would you like to initialize it now?", diff --git a/src/lang/es-sv.json b/src/lang/es-sv.json index a65e2b8622..b044eab097 100644 --- a/src/lang/es-sv.json +++ b/src/lang/es-sv.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Elige si las líneas ajustadas comienzan desde el borde izquierdo, mantienen la indentación de la línea original o se indentan más. Cada nivel extra usa el tamaño del tabulador.", "icon pack": "Paquete de Íconos", "settings-info-icon-pack": "Elige el paquete de iconos usado para archivos y carpetas en el explorador y listas de archivos en la aplicación.", - "unavailable": "no disponible" + "unavailable": "no disponible", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/fr-fr.json b/src/lang/fr-fr.json index 5fc53c6f1d..bf848497e7 100644 --- a/src/lang/fr-fr.json +++ b/src/lang/fr-fr.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/he-il.json b/src/lang/he-il.json index 358b04abc6..b3e3d0693f 100644 --- a/src/lang/he-il.json +++ b/src/lang/he-il.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/hi-in.json b/src/lang/hi-in.json index 6aa97f71a1..2a656a4827 100644 --- a/src/lang/hi-in.json +++ b/src/lang/hi-in.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/hu-hu.json b/src/lang/hu-hu.json index f2865688a2..9ab0f892bf 100644 --- a/src/lang/hu-hu.json +++ b/src/lang/hu-hu.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Válassza ki, hogy a tördelt szövegek a képernyő bal szélétől kezdődjenek-e, az eredeti sor behúzását kövessék-e, vagy még jobban legyenek-e behúzva. Minden további behúzási szint a tabulátor méretét veszi alapul.", "icon pack": "Ikoncsomag", "settings-info-icon-pack": "Válassza ki a fájlokhoz és a mappákhoz használandó ikonokat a fájlkezelőben és az alkalmazás egészében megjelenő fájllistákban.", - "unavailable": "nem érhető el" + "unavailable": "nem érhető el", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/id-id.json b/src/lang/id-id.json index e21a315901..c70c422dda 100644 --- a/src/lang/id-id.json +++ b/src/lang/id-id.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Pilih apakah teks terbungkus dimulai dari tepi kiri, mengikuti indentasi baris asli, atau di-indentasi lebih jauh. Setiap level tambahan menggunakan ukuran tab Anda.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/ir-fa.json b/src/lang/ir-fa.json index 07f6c056bc..c8ea0509dc 100644 --- a/src/lang/ir-fa.json +++ b/src/lang/ir-fa.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/it-it.json b/src/lang/it-it.json index efe7c90e32..cbbceb0232 100644 --- a/src/lang/it-it.json +++ b/src/lang/it-it.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/ja-jp.json b/src/lang/ja-jp.json index 27fd7b6033..992aa02c59 100644 --- a/src/lang/ja-jp.json +++ b/src/lang/ja-jp.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/ko-kr.json b/src/lang/ko-kr.json index f331beb331..410f664c0c 100644 --- a/src/lang/ko-kr.json +++ b/src/lang/ko-kr.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/ln-ln.json b/src/lang/ln-ln.json index 63d4e9ce7e..06c8e927ab 100644 --- a/src/lang/ln-ln.json +++ b/src/lang/ln-ln.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/ml-in.json b/src/lang/ml-in.json index 04db791635..23660b10b2 100644 --- a/src/lang/ml-in.json +++ b/src/lang/ml-in.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/mm-unicode.json b/src/lang/mm-unicode.json index 6411d5b9b1..7100d0b73f 100644 --- a/src/lang/mm-unicode.json +++ b/src/lang/mm-unicode.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/mm-zawgyi.json b/src/lang/mm-zawgyi.json index dd8f456bf2..faafb59c4e 100644 --- a/src/lang/mm-zawgyi.json +++ b/src/lang/mm-zawgyi.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/pl-pl.json b/src/lang/pl-pl.json index d5b418a9e0..1235410910 100644 --- a/src/lang/pl-pl.json +++ b/src/lang/pl-pl.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/pt-br.json b/src/lang/pt-br.json index aa6de4b0e2..415704431f 100644 --- a/src/lang/pt-br.json +++ b/src/lang/pt-br.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/pu-in.json b/src/lang/pu-in.json index 05b389b8c7..bba76e0338 100644 --- a/src/lang/pu-in.json +++ b/src/lang/pu-in.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/ru-ru.json b/src/lang/ru-ru.json index 79e83dddba..a13aac0408 100644 --- a/src/lang/ru-ru.json +++ b/src/lang/ru-ru.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/tl-ph.json b/src/lang/tl-ph.json index b5a5424fca..f9494780eb 100644 --- a/src/lang/tl-ph.json +++ b/src/lang/tl-ph.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/tr-tr.json b/src/lang/tr-tr.json index 0d723b7ffd..4d8b152b15 100644 --- a/src/lang/tr-tr.json +++ b/src/lang/tr-tr.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/uk-ua.json b/src/lang/uk-ua.json index ab5da72106..13364cb2dc 100644 --- a/src/lang/uk-ua.json +++ b/src/lang/uk-ua.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/uz-uz.json b/src/lang/uz-uz.json index 986916b7e8..24bfc47896 100644 --- a/src/lang/uz-uz.json +++ b/src/lang/uz-uz.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/vi-vn.json b/src/lang/vi-vn.json index 64441eb461..d9d8210f42 100644 --- a/src/lang/vi-vn.json +++ b/src/lang/vi-vn.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/zh-cn.json b/src/lang/zh-cn.json index d6c1737b6d..9e47f868dd 100644 --- a/src/lang/zh-cn.json +++ b/src/lang/zh-cn.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "选择折行后的文本是从行首靠左对齐、保持原行的缩进,还是进一步向内缩进。每增加一级缩进将遵循您设定的制表符宽度。", "icon pack": "图标包", "settings-info-icon-pack": "选择资源管理器及整个应用文件列表中文件和文件夹所使用的图标。", - "unavailable": "不可用" + "unavailable": "不可用", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/zh-hant.json b/src/lang/zh-hant.json index 6ad71367e6..6a49410c47 100644 --- a/src/lang/zh-hant.json +++ b/src/lang/zh-hant.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "選擇換行後的文字是靠左對齊、保持原行的縮排,還是進一步向內縮排。每增加一級縮排將遵循您設定的製表符寬度。", "icon pack": "圖標包", "settings-info-icon-pack": "選擇檔案總管及整個應用程式檔案列表中檔案和文件夾所使用的圖標。", - "unavailable": "不可用" + "unavailable": "不可用", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/lang/zh-tw.json b/src/lang/zh-tw.json index c814718a27..19ae5a812e 100644 --- a/src/lang/zh-tw.json +++ b/src/lang/zh-tw.json @@ -887,5 +887,10 @@ "settings-info-editor-wrapping-indent": "Choose whether wrapped text starts at the left edge, matches the original line's indentation, or is indented further. Each extra level uses your tab size.", "icon pack": "Icon pack", "settings-info-icon-pack": "Choose the icons used for files and folders in the explorer and file lists across the app.", - "unavailable": "unavailable" + "unavailable": "unavailable", + "terminal:merged home directories": "Merged home directories", + "info-mergedHomeDirectories": "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + "terminal:restart home layout": "Restart terminal", + "info-terminal-restart-home-layout": "Open terminal sessions will be closed so the new home directory layout can take effect.", + "terminal:restart required": "Restart the terminal to apply this change." } diff --git a/src/pages/fileBrowser/fileBrowser.js b/src/pages/fileBrowser/fileBrowser.js index a093703f59..4d9e0acc2c 100644 --- a/src/pages/fileBrowser/fileBrowser.js +++ b/src/pages/fileBrowser/fileBrowser.js @@ -1390,8 +1390,15 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) { // Migrate any files left in the legacy alpine/home and // alpine/root directories into public/MIGRATE so they are - // not hidden after the home/root/public merge. - if (typeof Terminal !== "undefined" && Terminal.migrateLegacyHome) { + // not hidden after the home/root/public merge. Skip this in + // the separate layout, where those directories are live. + const mergedHomeDirectories = + appSettings.value.terminalSettings?.mergedHomeDirectories !== false; + if ( + mergedHomeDirectories && + typeof Terminal !== "undefined" && + Terminal.migrateLegacyHome + ) { Terminal.migrateLegacyHome(); } } catch (err) { diff --git a/src/plugins/terminal/scripts/init-alpine.sh b/src/plugins/terminal/scripts/init-alpine.sh index 130ae9588c..526bf99501 100644 --- a/src/plugins/terminal/scripts/init-alpine.sh +++ b/src/plugins/terminal/scripts/init-alpine.sh @@ -1,6 +1,11 @@ export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/share/bin:/usr/share/sbin:/usr/local/bin:/usr/local/sbin:/system/bin:/system/xbin:$PREFIX/local/bin export PS1="\[\e[38;5;46m\]\u\[\033[39m\]@localhost \[\033[39m\]\w \[\033[0m\]\\$ " -export HOME=/public +if [ "${MERGED_HOME_DIRS:-true}" = "true" ]; then + export HOME=/public +else + export HOME=/home +fi +export ACODE_HOME="$HOME" export TERM=xterm-256color INSTALLING=false @@ -193,7 +198,7 @@ fi # Environment setup export PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/share/bin:/usr/share/sbin:/usr/local/bin:/usr/local/sbin -export HOME=/public +export HOME="${ACODE_HOME:-/public}" export TERM=xterm-256color SHELL=/bin/bash export PIP_BREAK_SYSTEM_PACKAGES=1 @@ -340,6 +345,11 @@ fi EOF fi +# Keep older initrc files in sync with the home layout selected in settings. +if [ -f "$PREFIX/alpine/initrc" ] && grep -q '^export HOME=/public$' "$PREFIX/alpine/initrc" 2>/dev/null; then + sed -i 's|^export HOME=/public$|export HOME="${ACODE_HOME:-/public}"|' "$PREFIX/alpine/initrc" +fi + # Add PS1 only if not already present if ! grep -q 'PS1=' "$PREFIX/alpine/initrc"; then # Smart path shortening (fish-style: ~/p/s/components) diff --git a/src/plugins/terminal/scripts/init-sandbox.sh b/src/plugins/terminal/scripts/init-sandbox.sh index 1da53a95b4..63f5128f7f 100644 --- a/src/plugins/terminal/scripts/init-sandbox.sh +++ b/src/plugins/terminal/scripts/init-sandbox.sh @@ -4,6 +4,19 @@ mkdir -p "$PREFIX/tmp" mkdir -p "$PREFIX/alpine/tmp" mkdir -p "$PREFIX/public" +# The terminal settings page controls whether /home and /root are aliases of +# /public. Terminal.startAxs writes this marker before this script runs, so +# background Executor processes use the same layout as the interactive shell. +MERGED_HOME_DIRS=true +if [ -f "$PREFIX/terminal_home_mode" ] && [ "$(cat "$PREFIX/terminal_home_mode" 2>/dev/null)" = "separate" ]; then + MERGED_HOME_DIRS=false +fi +export MERGED_HOME_DIRS + +if [ "$MERGED_HOME_DIRS" != "true" ]; then + mkdir -p "$PREFIX/alpine/home" "$PREFIX/alpine/root" +fi + export PROOT_TMP_DIR=$PREFIX/tmp if [ "$FDROID" = "true" ]; then @@ -64,8 +77,10 @@ ARGS="$ARGS -b /sys" ARGS="$ARGS -b $PREFIX" ARGS="$ARGS -b $NATIVE_DIR" ARGS="$ARGS -b $PREFIX/public:/public" -ARGS="$ARGS -b $PREFIX/public:/home" -ARGS="$ARGS -b $PREFIX/public:/root" +if [ "$MERGED_HOME_DIRS" = "true" ]; then + ARGS="$ARGS -b $PREFIX/public:/home" + ARGS="$ARGS -b $PREFIX/public:/root" +fi ARGS="$ARGS -b $PREFIX/alpine/tmp:/dev/shm" diff --git a/src/plugins/terminal/www/Terminal.js b/src/plugins/terminal/www/Terminal.js index 21ffde3755..5e9e5bbf57 100644 --- a/src/plugins/terminal/www/Terminal.js +++ b/src/plugins/terminal/www/Terminal.js @@ -6,13 +6,18 @@ const Terminal = { * @param {boolean} [installing=false] - Whether AXS is being started during installation. * @param {Function} [logger=console.log] - Function to log standard output. * @param {Function} [err_logger=console.error] - Function to log errors. + * @param {boolean} [failsafe=false] - Whether to start the failsafe system shell. + * @param {boolean} [mergedHomeDirectories=true] - Whether /home and /root are aliases of /public. * @returns {Promise} - Returns true if installation completes with exit code 0, void if not installing */ - async startAxs(installing = false, logger = console.log, err_logger = console.error,failsafe = false) { + async startAxs(installing = false, logger = console.log, err_logger = console.error,failsafe = false, mergedHomeDirectories = true) { const filesDir = await new Promise((resolve, reject) => { system.getFilesDir(resolve, reject); }); + const mergedHome = mergedHomeDirectories !== false; + await this.setMergedHomeDirectories(mergedHome, filesDir); + const failsafeArg = failsafe ? "--failsafe" : ""; const [initAlpine, rmWrapper, initSandbox] = await Promise.all([ @@ -21,7 +26,7 @@ const Terminal = { readAsset("init-sandbox.sh"), ]); - await this.migrateLegacyHome(); + await this.migrateLegacyHome(mergedHome); const isFdroid = await Executor.execute("echo $FDROID"); @@ -118,9 +123,10 @@ const Terminal = { * Also sets up additional dependencies for F-Droid variant. * @param {Function} [logger=console.log] - Function to log standard output. * @param {Function} [err_logger=console.error] - Function to log errors. + * @param {boolean} [mergedHomeDirectories=true] - Whether /home and /root are aliases of /public. * @returns {Promise} - Returns true if installation completes with exit code 0 */ - async install(logger = console.log, err_logger = console.error) { + async install(logger = console.log, err_logger = console.error, mergedHomeDirectories = true) { if (!(await this.isSupported())) return false; const isFdroid = await Executor.execute("echo $FDROID"); @@ -369,7 +375,7 @@ const Terminal = { await ensureDir(`${filesDir}/.extracted`); logger("⚙️ Updating sandbox enviroment..."); - const installResult = await this.startAxs(true, logger, err_logger); + const installResult = await this.startAxs(true, logger, err_logger, false, mergedHomeDirectories); if (!installResult) { throw new Error(this.lastInstallError || "Sandbox configuration failed."); } @@ -569,6 +575,25 @@ const Terminal = { }); }, + /** + * Persists the home directory layout for the shell scripts. + * @param {boolean} [merged=true] - `true` to mount /public at /home and /root. + * @param {string} [filesDir] - App files directory, resolved when omitted. + * @returns {Promise} + */ + async setMergedHomeDirectories(merged = true, filesDir) { + if (!filesDir) { + filesDir = await new Promise((resolve, reject) => { + system.getFilesDir(resolve, reject); + }); + } + + await writeText( + `${filesDir}/terminal_home_mode`, + merged ? "merged" : "separate" + ); + }, + /** * Migrates the legacy terminal home directories into public/MIGRATE. * Older builds stored user files under alpine/home and alpine/root. @@ -576,23 +601,36 @@ const Terminal = { * directory, any files still left in the old locations are copied * into public/MIGRATE (keeping their source structure) so nothing is * hidden or lost. This is a no-op once the migration has run. + * + * When the separate layout is selected, no files are copied. The + * migration marker is still written so independent /home and /root + * contents are never later mistaken for legacy data. + * @param {boolean} [merged=true] - Whether the merged layout is active. * @returns {Promise} */ - async migrateLegacyHome() { + async migrateLegacyHome(merged = true) { if (this._legacyHomeMigrated) return; try { + if (!merged) { + await Executor.BackgroundExecutor.execute(` + MIGRATE="$PREFIX/public/MIGRATE" + mkdir -p "$MIGRATE" + touch "$MIGRATE/.migrated" + `); + this._legacyHomeMigrated = true; + return; + } + const cmd = ` MIGRATE="$PREFIX/public/MIGRATE" # Already migrated [ -e "$MIGRATE/.migrated" ] && exit 0 - COPIED=false - if [ -d "$PREFIX/alpine/home" ] && [ -n "$(find "$PREFIX/alpine/home" -mindepth 1 -maxdepth 1 2>/dev/null | head -n 1)" ]; then mkdir -p "$MIGRATE/home" if cp -a "$PREFIX/alpine/home/." "$MIGRATE/home/"; then - COPIED=true + : else exit 1 fi @@ -601,16 +639,16 @@ const Terminal = { if [ -d "$PREFIX/alpine/root" ] && [ -n "$(find "$PREFIX/alpine/root" -mindepth 1 -maxdepth 1 2>/dev/null | head -n 1)" ]; then mkdir -p "$MIGRATE/root" if cp -a "$PREFIX/alpine/root/." "$MIGRATE/root/"; then - COPIED=true + : else exit 1 fi fi - # Mark as migrated so this only runs once - if [ "$COPIED" = "true" ]; then - touch "$MIGRATE/.migrated" - fi + # Mark as migrated so this only runs once, even when there + # was nothing to copy. Later independent /home or /root + # contents must not be treated as legacy data. + touch "$MIGRATE/.migrated" `; await Executor.BackgroundExecutor.execute(cmd); this._legacyHomeMigrated = true; diff --git a/src/settings/terminalSettings.js b/src/settings/terminalSettings.js index e8e07112b6..19f0792bb1 100644 --- a/src/settings/terminalSettings.js +++ b/src/settings/terminalSettings.js @@ -4,6 +4,7 @@ import { DEFAULT_TERMINAL_SETTINGS, TerminalThemeManager, } from "components/terminal"; +import terminalManager from "components/terminal/terminalManager"; import toast from "components/toast"; import alert from "dialogs/alert"; import confirm from "dialogs/confirm"; @@ -228,6 +229,17 @@ export default function terminalSettings() { info: strings["info-confirmTabClose"], category: categories.session, }, + { + key: "mergedHomeDirectories", + text: + strings["terminal:merged home directories"] || + "Merged home directories", + checkbox: terminalValues.mergedHomeDirectories !== false, + info: + strings["info-mergedHomeDirectories"] || + "Mount /public as /home and /root inside the terminal. Disable to keep /public, /home and /root as separate directories; existing files stay where they are. Restarting the terminal is required for changes to take effect.", + category: categories.session, + }, { key: "failsafeMode", text: strings["terminal:failsafe"], @@ -336,6 +348,16 @@ export default function terminalSettings() { Executor.BackgroundExecutor.setProotDebug(value); break; + case "mergedHomeDirectories": + appSettings.update({ + terminalSettings: { + ...values.terminalSettings, + [key]: value, + }, + }); + await applyMergedHomeChange(value); + break; + default: appSettings.update({ terminalSettings: { @@ -418,6 +440,46 @@ export default function terminalSettings() { toast(error.toString()); } } + + /** + * Applies the merged/separate home layout and restarts AXS when needed. + * @param {boolean} enabled + */ + async function applyMergedHomeChange(enabled) { + try { + if (!(await Terminal.isAxsRunning())) { + await Terminal.setMergedHomeDirectories(enabled); + return; + } + + const terminalIds = Array.from(terminalManager.getAllTerminals().keys()); + + if (terminalIds.length) { + const shouldRestart = await confirm( + strings["terminal:restart home layout"] || "Restart terminal", + strings["info-terminal-restart-home-layout"] || + "Open terminal sessions will be closed so the new home directory layout can take effect.", + ); + if (!shouldRestart) { + toast( + strings["terminal:restart required"] || + "Restart the terminal to apply this change.", + ); + return; + } + } + + for (const terminalId of terminalIds) { + await terminalManager.closeTerminal(terminalId, true); + } + + await Terminal.stopAxs(); + await Terminal.setMergedHomeDirectories(enabled); + } catch (error) { + console.error("Failed to apply merged home directory setting:", error); + toast(error?.message || String(error)); + } + } } /** diff --git a/tests/unit/terminalHomeLayout.test.js b/tests/unit/terminalHomeLayout.test.js new file mode 100644 index 0000000000..4b86e52edb --- /dev/null +++ b/tests/unit/terminalHomeLayout.test.js @@ -0,0 +1,39 @@ +import { beforeEach, describe, expect, it, vi } from "vitest"; + +const { settings } = vi.hoisted(() => ({ + settings: { value: {} }, +})); + +vi.mock("lib/settings", () => ({ default: settings })); + +import { + DEFAULT_TERMINAL_SETTINGS, + getTerminalSettings, +} from "../../src/components/terminal/terminalDefaults.js"; + +describe("terminal home directory layout settings", () => { + beforeEach(() => { + settings.value = {}; + }); + + it("merges the home directories by default", () => { + expect(DEFAULT_TERMINAL_SETTINGS.mergedHomeDirectories).toBe(true); + expect(getTerminalSettings().mergedHomeDirectories).toBe(true); + }); + + it("honors an explicit opt-out", () => { + settings.value = { + terminalSettings: { mergedHomeDirectories: false }, + }; + + expect(getTerminalSettings().mergedHomeDirectories).toBe(false); + }); + + it("keeps the merge enabled when only other settings are stored", () => { + settings.value = { + terminalSettings: { fontSize: 18 }, + }; + + expect(getTerminalSettings().mergedHomeDirectories).toBe(true); + }); +}); diff --git a/tests/unit/terminalHomeLayoutScripts.test.js b/tests/unit/terminalHomeLayoutScripts.test.js new file mode 100644 index 0000000000..4731f550b2 --- /dev/null +++ b/tests/unit/terminalHomeLayoutScripts.test.js @@ -0,0 +1,54 @@ +import { execFileSync } from "node:child_process"; +import fs from "node:fs"; +import { fileURLToPath } from "node:url"; +import { describe, expect, it } from "vitest"; + +const rootDir = fileURLToPath(new URL("../..", import.meta.url)); +const scriptsDir = `${rootDir}/src/plugins/terminal/scripts`; +const sandboxScriptPath = `${scriptsDir}/init-sandbox.sh`; +const alpineScriptPath = `${scriptsDir}/init-alpine.sh`; +const terminalJsPath = `${rootDir}/src/plugins/terminal/www/Terminal.js`; + +const sandboxScript = fs.readFileSync(sandboxScriptPath, "utf8"); +const alpineScript = fs.readFileSync(alpineScriptPath, "utf8"); +const terminalJs = fs.readFileSync(terminalJsPath, "utf8"); + +describe("terminal home layout shell integration", () => { + it("keeps both scripts valid POSIX shell", () => { + for (const scriptPath of [sandboxScriptPath, alpineScriptPath]) { + expect(() => execFileSync("sh", ["-n", scriptPath])).not.toThrow(); + } + }); + + it("defaults to the merged layout when the marker is missing", () => { + expect(sandboxScript).toContain("MERGED_HOME_DIRS=true"); + expect(sandboxScript).toContain("terminal_home_mode"); + expect(sandboxScript).toContain('[ "$MERGED_HOME_DIRS" = "true" ]'); + }); + + it("only binds /home and /root while merged", () => { + const mergedGuard = sandboxScript.indexOf( + 'if [ "$MERGED_HOME_DIRS" = "true" ]; then', + ); + expect(mergedGuard).toBeGreaterThan(-1); + expect(sandboxScript.indexOf("public:/home")).toBeGreaterThan(mergedGuard); + expect(sandboxScript.indexOf("public:/root")).toBeGreaterThan(mergedGuard); + }); + + it("switches HOME with the selected layout", () => { + expect(alpineScript).toContain("export HOME=/public"); + expect(alpineScript).toContain("export HOME=/home"); + expect(alpineScript).toContain('export HOME="${ACODE_HOME:-/public}"'); + expect(alpineScript).toContain("sed -i"); + }); + + it("uses the same marker file from JavaScript and shell", () => { + expect(terminalJs).toContain("terminal_home_mode"); + expect(sandboxScript).toContain("terminal_home_mode"); + }); + + it("marks legacy migration complete in both layouts", () => { + expect(terminalJs).toContain('touch "$MIGRATE/.migrated"'); + expect(terminalJs).toContain("if (!merged)"); + }); +});