Skip to content

wavebase: symlink ~/.config/waveterm for snap users#3404

Open
sargonkadnezar wants to merge 1 commit into
wavetermdev:mainfrom
sargonkadnezar:fix/snap-config-symlink
Open

wavebase: symlink ~/.config/waveterm for snap users#3404
sargonkadnezar wants to merge 1 commit into
wavetermdev:mainfrom
sargonkadnezar:fix/snap-config-symlink

Conversation

@sargonkadnezar

Copy link
Copy Markdown

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.

@CLAassistant

CLAassistant commented Jun 29, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e0f4d702-38cf-4d2b-a3f9-7923da4040dd

📥 Commits

Reviewing files that changed from the base of the PR and between 5737194 and d346a87.

📒 Files selected for processing (1)
  • pkg/wavebase/wavebase.go
 __________________________________________________
< Veni, Vidi, Validavi. I came, I saw, I reviewed. >
 --------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).

Walkthrough

In EnsureWaveConfigDir(), new logic is added for snap packages: when ClientPackageType() returns "snap", the function checks whether ~/.config/waveterm exists, and if it does not, creates a symlink pointing from ~/.config/waveterm to the result of GetWaveConfigDir(). The existing CacheEnsureDir(...) call follows unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: creating a symlink for snap users' config path.
Description check ✅ Passed The description directly explains the snap config path mismatch and the symlink-based fix.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between c99022c and 775addf.

📒 Files selected for processing (1)
  • pkg/wavebase/wavebase.go

Comment thread pkg/wavebase/wavebase.go Outdated
Comment on lines +202 to +205
if ClientPackageType() == "snap" {
stdDir := filepath.Join(GetHomeDir(), ".config", "waveterm")
if _, err := os.Lstat(stdDir); os.IsNotExist(err) {
os.Symlink(GetWaveConfigDir(), stdDir)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

Suggested change
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.

@sargonkadnezar sargonkadnezar force-pushed the fix/snap-config-symlink branch from 775addf to 5737194 Compare June 29, 2026 23:56
$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.
@sargonkadnezar sargonkadnezar force-pushed the fix/snap-config-symlink branch from 5737194 to d346a87 Compare June 29, 2026 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants