Skip to content

Commit 8fefd4a

Browse files
committed
feat: allow launchApp to open explorer at a specific path
1 parent cdd1a8c commit 8fefd4a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/gui/src/UI/UIWindow.js

+4
Original file line numberDiff line numberDiff line change
@@ -2879,6 +2879,10 @@ window.navbar_path_droppable = (el_window)=>{
28792879
*
28802880
*/
28812881
window.navbar_path = (abs_path)=>{
2882+
// remove trailing slash
2883+
if(abs_path.endsWith('/') && abs_path !== '/')
2884+
abs_path = abs_path.slice(0, -1);
2885+
28822886
const dirs = (abs_path === '/' ? [''] : abs_path.split('/'));
28832887
const dirpaths = (abs_path === '/' ? ['/'] : [])
28842888
const path_seperator_html = `<img class="path-seperator" draggable="false" src="${html_encode(window.icons['triangle-right.svg'])}">`;

src/gui/src/helpers/launch_app.js

+14
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,20 @@ const launch_app = async (options)=>{
129129
else
130130
title = path.dirname(options.path);
131131

132+
// if options.args.path is provided, use it as the path
133+
if(options.args?.path){
134+
// if args.path is provided, enforce the directory
135+
let fsentry = await puter.fs.stat(options.args.path);
136+
if(!fsentry.is_dir){
137+
let parent = path.dirname(options.args.path);
138+
if(parent === options.args.path)
139+
parent = window.home_path;
140+
options.path = parent;
141+
}else{
142+
options.path = options.args.path;
143+
}
144+
}
145+
132146
// open window
133147
el_win = UIWindow({
134148
element_uuid: uuid,

0 commit comments

Comments
 (0)