diff --git a/frontend/app/view/directorypreview.tsx b/frontend/app/view/directorypreview.tsx index 44c301a7d..a0cd58eed 100644 --- a/frontend/app/view/directorypreview.tsx +++ b/frontend/app/view/directorypreview.tsx @@ -388,20 +388,10 @@ function TableBody({ }, [focusIndex, parentHeight]); const handleFileContextMenu = useCallback( - (e, path) => { + (e: any, path: string, mimetype: string) => { e.preventDefault(); e.stopPropagation(); const menu = [ - { - label: "Open in New Block", - click: async () => { - const blockDef = { - view: "preview", - meta: { file: path }, - }; - await createBlock(blockDef); - }, - }, { label: "Delete File", click: async () => { @@ -415,7 +405,32 @@ function TableBody({ getApi().downloadFile(path); }, }, + { + label: "Open Preview in New Block", + click: async () => { + const blockDef = { + view: "preview", + meta: { file: path }, + }; + await createBlock(blockDef); + }, + }, ]; + if (mimetype == "directory") { + menu.push({ + label: "Open Terminal in New Block", + click: async () => { + const termBlockDef: BlockDef = { + controller: "shell", + view: "term", + meta: { + cwd: path, + }, + }; + await createBlock(termBlockDef); + }, + }); + } ContextMenuModel.showContextMenu(menu, e); }, [setRefreshVersion] @@ -433,7 +448,7 @@ function TableBody({ setSearch(""); }} onClick={() => setFocusIndex(idx)} - onContextMenu={(e) => handleFileContextMenu(e, row.getValue("path"))} + onContextMenu={(e) => handleFileContextMenu(e, row.getValue("path"), row.getValue("mimetype"))} > {row.getVisibleCells().map((cell) => (
{ + const termBlockDef: BlockDef = { + controller: "shell", + view: "term", + meta: { + cwd: globalStore.get(this.fileName), + }, + }; + await createBlock(termBlockDef); + }, + }); + } return menuItems; } @@ -563,4 +579,4 @@ function PreviewView({ blockId, model }: { blockId: string; model: PreviewModel ); } -export { makePreviewModel, PreviewView }; +export { PreviewView, makePreviewModel }; diff --git a/frontend/app/view/waveai.tsx b/frontend/app/view/waveai.tsx index fb590e73a..b6797ef9a 100644 --- a/frontend/app/view/waveai.tsx +++ b/frontend/app/view/waveai.tsx @@ -132,7 +132,6 @@ export class WaveAiModel implements ViewModel { name: (metadata?.name as string) || "user", }, ]; - console.log("opts.apitoken:", opts.apitoken); const beMsg: OpenAiStreamRequest = { clientid: clientId, opts: opts, diff --git a/pkg/blockcontroller/blockcontroller.go b/pkg/blockcontroller/blockcontroller.go index 7c1ba7158..40c71390f 100644 --- a/pkg/blockcontroller/blockcontroller.go +++ b/pkg/blockcontroller/blockcontroller.go @@ -241,6 +241,10 @@ func (bc *BlockController) DoRunShellCommand(rc *RunShellOpts, blockMeta map[str if bc.ControllerType == BlockController_Shell { cmdOpts.Interactive = true cmdOpts.Login = true + cmdOpts.Cwd, _ = blockMeta["cwd"].(string) + if cmdOpts.Cwd != "" { + cmdOpts.Cwd = wavebase.ExpandHomeDir(cmdOpts.Cwd) + } } else if bc.ControllerType == BlockController_Cmd { if _, ok := blockMeta["cmd"].(string); ok { cmdStr = blockMeta["cmd"].(string)