wavebase: symlink ~/.config/waveterm for snap users#3404
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughIn Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/wavebase/wavebase.go`:
- Around line 202-205: The snap compatibility setup in EnsureWaveConfigDir is
ignoring failures from os.Symlink, so the function can return success even when
the ~/.config/waveterm link was not created. Update the ClientPackageType() ==
"snap" branch to capture and return any error from
os.Symlink(GetWaveConfigDir(), stdDir), and make sure the existing
os.Lstat/stdDir logic surfaces symlink creation failures instead of swallowing
them.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8a4b3ace-8f6c-4b5d-a2e9-4601a0e93602
📒 Files selected for processing (1)
pkg/wavebase/wavebase.go
| if ClientPackageType() == "snap" { | ||
| stdDir := filepath.Join(GetHomeDir(), ".config", "waveterm") | ||
| if _, err := os.Lstat(stdDir); os.IsNotExist(err) { | ||
| os.Symlink(GetWaveConfigDir(), stdDir) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Return symlink setup errors instead of swallowing them.
os.Symlink(GetWaveConfigDir(), stdDir) can fail here when ~/.config does not exist yet, or if the path changes between Lstat and Symlink. Because the error is ignored, EnsureWaveConfigDir() still reports success and the new snap compatibility path never gets created, so edits under ~/.config/waveterm remain invisible.
Suggested fix
if ClientPackageType() == "snap" {
stdDir := filepath.Join(GetHomeDir(), ".config", "waveterm")
if _, err := os.Lstat(stdDir); os.IsNotExist(err) {
- os.Symlink(GetWaveConfigDir(), stdDir)
+ if err := os.MkdirAll(filepath.Dir(stdDir), 0700); err != nil {
+ return err
+ }
+ if err := os.Symlink(GetWaveConfigDir(), stdDir); err != nil && !os.IsExist(err) {
+ return err
+ }
+ } else if err != nil {
+ return err
}
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if ClientPackageType() == "snap" { | |
| stdDir := filepath.Join(GetHomeDir(), ".config", "waveterm") | |
| if _, err := os.Lstat(stdDir); os.IsNotExist(err) { | |
| os.Symlink(GetWaveConfigDir(), stdDir) | |
| if ClientPackageType() == "snap" { | |
| stdDir := filepath.Join(GetHomeDir(), ".config", "waveterm") | |
| if _, err := os.Lstat(stdDir); os.IsNotExist(err) { | |
| if err := os.MkdirAll(filepath.Dir(stdDir), 0700); err != nil { | |
| return err | |
| } | |
| if err := os.Symlink(GetWaveConfigDir(), stdDir); err != nil && !os.IsExist(err) { | |
| return err | |
| } | |
| } else if err != nil { | |
| return err | |
| } | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@pkg/wavebase/wavebase.go` around lines 202 - 205, The snap compatibility
setup in EnsureWaveConfigDir is ignoring failures from os.Symlink, so the
function can return success even when the ~/.config/waveterm link was not
created. Update the ClientPackageType() == "snap" branch to capture and return
any error from os.Symlink(GetWaveConfigDir(), stdDir), and make sure the
existing os.Lstat/stdDir logic surfaces symlink creation failures instead of
swallowing them.
775addf to
5737194
Compare
$SNAP_USER_DATA/.config/waveterm is invisible from the standard XDG path under classic confinement. Create a symlink on startup so docs and guides that say 'edit ~/.config/waveterm/waveai.json' just work.
5737194 to
d346a87
Compare
When Wave runs as a classic snap, $WAVETERM_CONFIG_HOME points to
$SNAP_USER_DATA/.config/waveterm and not ~/.config/waveterm. Users
who follow the docs and edit ~/.config/waveterm/waveai.json directly
see no effect.
Fix: on startup, if ~/.config/waveterm doesn't exist, symlink it to
the snap config dir. Existing paths are left alone.