@@ -9,6 +9,8 @@ import "@xterm/xterm/css/xterm.css";
99import quickTools from "components/quickTools" ;
1010import toast from "components/toast" ;
1111import confirm from "dialogs/confirm" ;
12+ import openFile from "lib/openFile" ;
13+ import openFolder from "lib/openFolder" ;
1214import appSettings from "lib/settings" ;
1315import helpers from "utils/helpers" ;
1416
@@ -577,6 +579,30 @@ class TerminalManager {
577579 toast ( message ) ;
578580 } ;
579581
582+ // Handle acode CLI open commands (OSC 7777)
583+ terminalComponent . onOscOpen = async ( type , path ) => {
584+ if ( ! path ) return ;
585+
586+ // Convert proot path
587+ const fileUri = this . convertProotPath ( path ) ;
588+ // Extract folder/file name from path
589+ const name = path . split ( "/" ) . filter ( Boolean ) . pop ( ) || "folder" ;
590+
591+ try {
592+ if ( type === "folder" ) {
593+ // Open folder in sidebar
594+ await openFolder ( fileUri , { name, saveState : true , listFiles : true } ) ;
595+ toast ( `Opened folder: ${ name } ` ) ;
596+ } else {
597+ // Open file in editor
598+ await openFile ( fileUri , { render : true } ) ;
599+ }
600+ } catch ( error ) {
601+ console . error ( "Failed to open from terminal:" , error ) ;
602+ toast ( `Failed to open: ${ path } ` ) ;
603+ }
604+ } ;
605+
580606 // Store references for cleanup
581607 terminalFile . _terminalId = terminalId ;
582608 terminalFile . terminalComponent = terminalComponent ;
@@ -791,6 +817,40 @@ class TerminalManager {
791817 } ) ;
792818 }
793819
820+ /**
821+ * Convert proot internal path to app-accessible path
822+ * @param {string } prootPath - Path from inside proot environment
823+ * @returns {string } App filesystem path
824+ */
825+ convertProotPath ( prootPath ) {
826+ if ( ! prootPath ) return prootPath ;
827+
828+ const packageName = window . BuildInfo ?. packageName || "com.foxdebug.acode" ;
829+ const dataDir = `/data/user/0/${ packageName } ` ;
830+ const alpineRoot = `${ dataDir } /files/alpine` ;
831+
832+ let convertedPath ;
833+
834+ if ( prootPath . startsWith ( "/public" ) ) {
835+ // /public -> /data/user/0/com.foxdebug.acode/files/public
836+ convertedPath = `file://${ dataDir } /files${ prootPath } ` ;
837+ } else if (
838+ prootPath . startsWith ( "/sdcard" ) ||
839+ prootPath . startsWith ( "/storage" ) ||
840+ prootPath . startsWith ( "/data" )
841+ ) {
842+ convertedPath = `file://${ prootPath } ` ;
843+ } else if ( prootPath . startsWith ( "/" ) ) {
844+ // Everything else is relative to alpine root
845+ convertedPath = `file://${ alpineRoot } ${ prootPath } ` ;
846+ } else {
847+ convertedPath = prootPath ;
848+ }
849+
850+ //console.log(`Path conversion: ${prootPath} -> ${convertedPath}`);
851+ return convertedPath ;
852+ }
853+
794854 shouldConfirmTerminalClose ( ) {
795855 const settings = appSettings ?. value ?. terminalSettings ;
796856 if ( settings && settings . confirmTabClose === false ) {
0 commit comments