feat: add tab:newtablayout setting for custom new tab layouts#3117
feat: add tab:newtablayout setting for custom new tab layouts#3117Wechat-ggGitHub wants to merge 1 commit intowavetermdev:mainfrom
Conversation
Allow users to define a custom block layout for new tabs via the
`tab:newtablayout` setting in settings.json. This enables use cases like
automatically opening a file browser alongside a terminal when creating
a new tab.
When not set, the default single-terminal layout is preserved.
Example configuration for files + terminal split:
{
"tab:newtablayout": [
{
"indexarr": [0],
"blockdef": {"meta": {"view": "preview", "file": "~"}},
"size": 20
},
{
"indexarr": [1],
"blockdef": {"meta": {"view": "term", "controller": "shell"}},
"focused": true
}
]
}
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
WalkthroughThis change introduces support for configurable default layouts when creating new tabs. A new Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/wcore/workspace.go (1)
199-214: Consider logging when configuration fallback occurs.The function silently falls back to the default layout when the user's configuration is invalid or cannot be parsed. While this matches the intended behavior (graceful degradation), users may not realize their custom layout configuration is being ignored due to a syntax or structural error.
Adding a debug/warning log when fallback occurs would help users troubleshoot configuration issues:
💡 Suggested enhancement for debugging
func getNewTabLayoutFromConfig() PortableLayout { settings := wconfig.GetWatcher().GetFullConfig() rawLayout := settings.Settings.TabNewTabLayout if rawLayout != nil { barr, err := json.Marshal(rawLayout) - if err == nil { - var layout PortableLayout - if json.Unmarshal(barr, &layout) == nil && len(layout) > 0 { - return layout - } + if err != nil { + log.Printf("warning: failed to marshal tab:newtablayout config: %v", err) + } else { + var layout PortableLayout + if err := json.Unmarshal(barr, &layout); err != nil { + log.Printf("warning: failed to parse tab:newtablayout config: %v", err) + } else if len(layout) > 0 { + return layout + } else { + log.Printf("warning: tab:newtablayout config is empty, using default") + } } } return GetNewTabLayout() }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/wcore/workspace.go` around lines 199 - 214, The getNewTabLayoutFromConfig function silently falls back to GetNewTabLayout() when settings.Settings.TabNewTabLayout is nil/invalid/empty; update getNewTabLayoutFromConfig to log a debug/warning whenever a fallback occurs, including the error (from json.Marshal/json.Unmarshal) and the offending rawLayout value so users can diagnose bad configs; reference the existing symbols getNewTabLayoutFromConfig, PortableLayout, GetNewTabLayout, and wconfig.GetWatcher().GetFullConfig and emit the log before returning the default layout.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pkg/wcore/workspace.go`:
- Around line 199-214: The getNewTabLayoutFromConfig function silently falls
back to GetNewTabLayout() when settings.Settings.TabNewTabLayout is
nil/invalid/empty; update getNewTabLayoutFromConfig to log a debug/warning
whenever a fallback occurs, including the error (from
json.Marshal/json.Unmarshal) and the offending rawLayout value so users can
diagnose bad configs; reference the existing symbols getNewTabLayoutFromConfig,
PortableLayout, GetNewTabLayout, and wconfig.GetWatcher().GetFullConfig and emit
the log before returning the default layout.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 0390ecef-71ea-4aa2-b09b-448131ae3118
📒 Files selected for processing (3)
pkg/wconfig/settingsconfig.gopkg/wcore/workspace.goschema/settings.json
Summary
tab:newtablayoutsetting that allows users to define a custom block layout for new tabs viasettings.jsonPortableLayoutstructure used internally by Wave (same asGetStarterLayout())Motivation
Currently, every new tab in Wave opens with a single terminal block. There is no way to configure a custom default layout. Users who want a consistent workflow (e.g., file browser + terminal side by side) must manually set up the layout each time. This is a frequently requested feature (e.g., #2057).
Example Usage
Add to
~/.config/waveterm/settings.json:{ "tab:newtablayout": [ { "indexarr": [0], "blockdef": { "meta": { "view": "preview", "file": "~" } }, "size": 20 }, { "indexarr": [1], "blockdef": { "meta": { "view": "term", "controller": "shell" } }, "focused": true } ] }This creates a split layout with a file browser on the left (20% width) and a terminal on the right (focused by default).
Available view types for blockdef meta
term— Terminal (with optionalcontroller: "shell")preview— File browser (withfilefor initial directory)web— Web view (withurlfor initial URL)sysinfo— System info panelHow indexarr works
[0]— First child of root (left/top)[1]— Second child of root (right/bottom)[1, 1]— Second child of second child (nested split)GetStarterLayout()inpkg/wcore/layout.gofor a 4-block exampleChanges
schema/settings.json— Added JSON Schema definition fortab:newtablayoutpkg/wconfig/settingsconfig.go— AddedTabNewTabLayoutfield toSettingsTypepkg/wcore/workspace.go— AddedgetNewTabLayoutFromConfig()and updatedCreateTab()to use itTest plan
tab:newtablayoutset, new tabs open with single terminal (unchanged behavior)tab:newtablayoutset as shown above, new tabs open with file browser + terminal split🤖 Generated with Claude Code