New tabs inherit working directory from active tab
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
- Extract
cmd:cwdfrom the active tab's first terminal block - Pass inherited cwd as metadata to the new tab's terminal block
- Terminal starts in the same directory as the previous tab
Behavior
- With active tab in /projects/myapp: New tab starts in /projects/myapp
- No active tab or no cwd: Falls back to home directory (~)
- Initial launch: Not affected (uses default behavior)
Implementation
- Modified CreateTab in pkg/wcore/workspace.go
- Reads active tab's block metadata for cmd:cwd
- Merges inherited cwd into new tab's terminal block
- Backward compatible (doesn't break existing tab creation)
Test Plan
- [x] cd to project directory
- [x] Press Cmd+T to create new tab
- [x] Verify pwd shows same directory
- [x] Test with no active tab (home directory)
- [x] Test initial app launch (unchanged)
🤖 Generated with Claude Code
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
Walkthrough
The CreateTab function in pkg/wcore/workspace.go has been refactored to optimize workspace handling and implement metadata inheritance. The function now pre-fetches the workspace once at the start and reuses it for tab name derivation, eliminating a redundant call. Additionally, when creating a new tab alongside an active tab that isn't part of an initial launch, the function extracts the CmdCwd meta value from the first block of the active tab and propagates this metadata to the first block of the new tab by merging it into the layout before application.
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~22 minutes
Pre-merge checks and finishing touches
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title 'New tabs inherit working directory from active tab' directly and clearly summarizes the main change in the pull request. |
| Description check | ✅ Passed | The description is comprehensive and directly related to the changeset, covering the problem, solution, behavior, implementation details, and test plan. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
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 @coderabbitai help to get the list of available commands and usage tips.