-
Notifications
You must be signed in to change notification settings - Fork 683
New tabs inherit working directory from active tab #2681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
WalkthroughThe Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
a21f43c to
4a622b7
Compare
4a622b7 to
2f42152
Compare
When creating a new tab (Cmd+T), it now starts in the same directory as the currently active tab, instead of always defaulting to home. - Extract cmd:cwd from active tab's first block - Pass inherited cwd to new tab's terminal block via metadata - Only applies to user-created tabs (not initial launch) - Falls back to home directory if no cwd found - More intuitive workflow - stay in your project directory - Reduces need to cd after creating new tabs - Maintains context across tabs 🤖 Generated with [Claude Code](https://claude.com/claude-code)
2f42152 to
e17fa7b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
pkg/wcore/workspace.go (1)
228-228: Verify if storing cwd in both Tab.Meta and Block.Meta is intentional.The
inheritedMetais passed tocreateTabObj, which stores it intab.Meta(line 281). Then lines 243-249 merge the same metadata into the first block'sMeta. This results in the cwd being stored at two levels: the tab and the block.According to the PR description, the goal is to "pass cwd as metadata to the new tab's terminal block", which suggests the block's meta is the intended target. Please confirm whether storing it in both locations serves a specific purpose or if one is redundant.
Also note that
createTabObjcallsGetWorkspaceagain at line 271, which is now redundant since the workspace is already fetched at line 200.🔎 Optional refactor to eliminate redundant GetWorkspace call
Consider passing the workspace to
createTabObjinstead of re-fetching it:-func createTabObj(ctx context.Context, workspaceId string, name string, meta waveobj.MetaMapType) (*waveobj.Tab, error) { - ws, err := GetWorkspace(ctx, workspaceId) - if err != nil { - return nil, fmt.Errorf("workspace %s not found: %w", workspaceId, err) - } +func createTabObj(ctx context.Context, ws *waveobj.Workspace, name string, meta waveobj.MetaMapType) (*waveobj.Tab, error) {Then update the call site:
- tab, err := createTabObj(ctx, workspaceId, tabName, inheritedMeta) + tab, err := createTabObj(ctx, ws, tabName, inheritedMeta)
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pkg/wcore/workspace.go
🔇 Additional comments (3)
pkg/wcore/workspace.go (3)
200-207: LGTM: Good optimization by pre-fetching workspace.The early workspace fetch improves error handling and eliminates a redundant call for tab name derivation. This is cleaner than the previous implementation.
241-251: LGTM: Block metadata merging logic is correct.The implementation safely merges inherited metadata into the first block's Meta before applying the layout. The nil-check and iteration logic are appropriate.
Note: The potential redundancy with Tab.Meta was already flagged in the previous comment on line 228.
209-226: Relying on first block having CWD metadata without type validation.The inheritance logic assumes
activeTab.BlockIds[0]is a terminal block withMetaKey_CmdCwdset. However, there's no constraint preventing non-terminal blocks (preview, web, sysinfo) from being added as the first block. If a user creates a non-terminal block first, the inheritance silently fails without indication.The
DBGeterrors are silently ignored, but this is acceptable since the subsequent nil checks gracefully handle both "not found" and error cases, falling back to no inheritance.
Summary
Makes new tab creation more intuitive by inheriting the current working directory from the active tab.
Problem
When creating a new tab (Cmd+T), it always starts in the home directory, requiring users to cd back to their project directory. This breaks workflow continuity.
Solution
cmd:cwdfrom the active tab's first terminal blockBehavior
Implementation
Test Plan
🤖 Generated with Claude Code