diff --git a/package-lock.json b/package-lock.json index 05925b3641..07531c9f04 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "waveterm", - "version": "0.14.5", + "version": "0.14.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "waveterm", - "version": "0.14.5", + "version": "0.14.6", "hasInstallScript": true, "license": "Apache-2.0", "workspaces": [ diff --git a/package.json b/package.json index f80607177e..20fc7b5007 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "productName": "Wave", "description": "Open-Source AI-Native Terminal Built for Seamless Workflows", "license": "Apache-2.0", - "version": "0.14.5", + "version": "0.14.6", "homepage": "https://waveterm.dev", "build": { "appId": "dev.commandline.waveterm" diff --git a/pkg/wcore/layout.go b/pkg/wcore/layout.go index 173b8218e4..a8a30bb1cc 100644 --- a/pkg/wcore/layout.go +++ b/pkg/wcore/layout.go @@ -174,5 +174,13 @@ func BootstrapStarterLayout(ctx context.Context) error { return fmt.Errorf("error applying starter layout: %w", err) } + // Apply the workspace's default connection/cwd to the freshly created blocks. + // Re-fetch the tab since ApplyPortableLayout updates BlockIds in the database only. + starterTab, err := wstore.DBGet[*waveobj.Tab](ctx, tabId) + if err != nil { + return fmt.Errorf("error reloading starter tab: %w", err) + } + applyWorkspaceDefaultsToBlocks(ctx, workspace.OID, starterTab) + return nil } diff --git a/pkg/wcore/workspace.go b/pkg/wcore/workspace.go index 4db3592a5d..659d2b180b 100644 --- a/pkg/wcore/workspace.go +++ b/pkg/wcore/workspace.go @@ -272,6 +272,13 @@ func CreateTab(ctx context.Context, workspaceId string, tabName string, activate if err != nil { return tab.OID, fmt.Errorf("error applying new tab layout: %w", err) } + // ApplyPortableLayout creates the blocks and updates the tab's BlockIds in the + // database, but the in-memory `tab` variable is not refreshed. Re-fetch the tab so + // that applyWorkspaceDefaultsToBlocks iterates over the actual created blocks. + tab, err = wstore.DBGet[*waveobj.Tab](ctx, tab.OID) + if err != nil { + return tab.OID, fmt.Errorf("error reloading tab: %w", err) + } applyWorkspaceDefaultsToBlocks(ctx, workspaceId, tab) tabBg := getTabBackground() if tabBg != "" { @@ -340,13 +347,17 @@ func applyWorkspaceDefaultsToBlocks(ctx context.Context, workspaceId string, tab updated = true } } - if ws.DefaultCwd != "" && isTerm { + // Only apply the workspace default cwd when the block's effective connection + // matches the workspace default connection. A block already on a different + // connection must keep its own cwd (or the remote home directory). + blockConn, _ := meta[waveobj.MetaKey_Connection].(string) + if ws.DefaultCwd != "" && isTerm && blockConn == ws.DefaultConnName { if _, exists := meta[waveobj.MetaKey_CmdCwd]; !exists { meta[waveobj.MetaKey_CmdCwd] = ws.DefaultCwd updated = true } } - if ws.DefaultCwd != "" && isFileBrowser { + if ws.DefaultCwd != "" && isFileBrowser && blockConn == ws.DefaultConnName { meta[waveobj.MetaKey_File] = "" meta[waveobj.MetaKey_FileCwd] = ws.DefaultCwd updated = true