Skip to content

fix (desktop): build issue with ringtones/sounds directory#321

Merged
AviPeltz merged 2 commits intomainfrom
obedient-crab-813e02
Dec 11, 2025
Merged

fix (desktop): build issue with ringtones/sounds directory#321
AviPeltz merged 2 commits intomainfrom
obedient-crab-813e02

Conversation

@AviPeltz
Copy link
Copy Markdown
Collaborator

@AviPeltz AviPeltz commented Dec 11, 2025

Description

Related Issues

Type of Change

  • [ x] Bug fix
  • New feature
  • Documentation
  • Refactor
  • Other (please describe):

Testing

Screenshots (if applicable)

Additional Notes

Summary by CodeRabbit

  • Bug Fixes

    • Improved sound handling so notification sounds and ringtones play reliably in packaged and preview builds, with better fallbacks for missing or removed selections (including explicit "none" silence).
  • New Features

    • Included application sound resources in the build output so external audio players can access bundled sound files.
  • Refactor

    • Centralized path resolution for sound resources to make behavior consistent across development, preview, and production.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link
Copy Markdown

vercel Bot commented Dec 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
website Ready Ready Preview Comment Dec 11, 2025 5:37am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 11, 2025

Walkthrough

Centralizes sound resource handling and build packaging for the desktop Electron app, adds a Vite plugin to copy sound assets, restructures router registration to branch on NODE_ENV, and updates ringtone/notification code to use the new centralized sound-paths utilities.

Changes

Cohort / File(s) Summary
Build & Resource Configuration
apps/desktop/electron-builder.ts, apps/desktop/electron.vite.config.ts
Unpacked ASAR includes sound resources; added copyResourcesPlugin() (Vite) to copy resources/soundsdist/resources/sounds during writeBundle; integrated plugin into build plugins.
Sound Path Resolution
apps/desktop/src/main/lib/sound-paths.ts
New module providing getSoundPath(filename) and getSoundsDirectory() with environment-aware resolution: production → app.asar.unpacked/resources/sounds, development → src/resources/sounds, preview → dist/resources/sounds with fallbacks and existence checks.
Ringtone Router Integration
apps/desktop/src/lib/trpc/routers/ringtone/index.ts
Replaced in-file filesystem path helpers with imports of getSoundPath and getSoundsDirectory; updated preview, listing, and play ringtone logic to use centralized helpers.
Notification Sound Handler
apps/desktop/src/main/lib/notification-sound.ts
Replaced local path construction with getSoundPath; added getSelectedRingtoneFilename() to resolve filename (handles none and stale IDs) and adjusted playNotificationSound to use centralized path lookup.
Router Refactoring
apps/desktop/src/lib/electron-router-dom.ts
Introduced electronRouter instance; exported Router and settings from it; added `type WindowId = "main"

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Areas requiring extra attention:

  • apps/desktop/src/lib/electron-router-dom.ts: verify NODE_ENV detection, hash URL + query construction, and that dev behavior still delegates correctly to the router.
  • apps/desktop/src/main/lib/sound-paths.ts: confirm path resolutions, existsSync guards, and fallback warnings across platforms and preview/packaged layouts.
  • apps/desktop/electron.vite.config.ts: ensure copyResourcesPlugin() runs in the intended lifecycle (writeBundle), cleans and copies correctly, and handles missing source dir gracefully.
  • apps/desktop/electron-builder.ts: confirm asarUnpack changes cover all required runtime/unpacked resource paths (native modules and sound files).

Poem

🐰
I hopped through code with ears held high,
Collected sounds and let them fly,
Plugins copy, routes decide,
Ringtones now have one clear guide,
A little rabbit cheers—oh my! 🎵

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is a template with empty sections and lacks concrete details about the changes, rationale, testing, or related issues. Fill in the Description section explaining the build issue and the solution. Add Related Issues links if applicable. Provide specific testing steps to verify the fix works across build environments.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: addressing a build issue with ringtones/sounds directory handling through improved path resolution and resource bundling.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch obedient-crab-813e02

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f5f96dd and c24b5ee.

📒 Files selected for processing (1)
  • apps/desktop/electron-builder.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
apps/desktop/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

For Electron interprocess communication, ALWAYS use tRPC as defined in src/lib/trpc

Files:

  • apps/desktop/electron-builder.ts
apps/desktop/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

apps/desktop/**/*.{ts,tsx}: Please use alias as defined in tsconfig.json when possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary

Files:

  • apps/desktop/electron-builder.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Maintain type safety and avoid using any unless absolutely necessary in TypeScript code

Files:

  • apps/desktop/electron-builder.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T23:32:32.232Z
Learning: Applies to apps/desktop/src/lib/**/*.{ts,tsx} : Never import Node.js modules like node:fs, node:path, node:os in src/lib/electron-router-dom.ts or similar shared code
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T23:32:32.232Z
Learning: Applies to apps/desktop/src/main/lib/*{workspace,worktree}-*.ts : Use git worktree-based workspace management in the desktop app through workspace-manager.ts and worktree-manager.ts
📚 Learning: 2025-12-08T23:32:32.232Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T23:32:32.232Z
Learning: Applies to apps/desktop/src/lib/**/*.{ts,tsx} : Never import Node.js modules like node:fs, node:path, node:os in src/lib/electron-router-dom.ts or similar shared code

Applied to files:

  • apps/desktop/electron-builder.ts
📚 Learning: 2025-11-24T21:33:13.267Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: apps/desktop/AGENTS.md:0-0
Timestamp: 2025-11-24T21:33:13.267Z
Learning: Applies to apps/desktop/**/*.{ts,tsx} : Please use alias as defined in `tsconfig.json` when possible

Applied to files:

  • apps/desktop/electron-builder.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build
🔇 Additional comments (1)
apps/desktop/electron-builder.ts (1)

33-39: Update comment to document Windows audio playback support.

The path pattern **/resources/sounds/**/* is correct and properly aligns with the build output (sounds are copied to the resources directory and unpacked from ASAR so external audio players can access them). However, the comment only mentions macOS (afplay) and Linux (paplay) but omits Windows, which uses powershell with Media.SoundPlayer for playback. Update the comment to include Windows for consistency:

// Sound files must be unpacked so external audio players can access them
// macOS: afplay, Windows: powershell Media.SoundPlayer, Linux: paplay/aplay
"**/resources/sounds/**/*",

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 and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 11, 2025

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a 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 (3)
apps/desktop/electron.vite.config.ts (1)

34-51: Consider adding error handling for file operations.

The cpSync, rmSync, and mkdirSync operations can throw errors (e.g., permission issues, disk full). Consider wrapping in try-catch to prevent build failures from propagating cryptically.

 function copyResourcesPlugin(): Plugin {
 	return {
 		name: "copy-resources",
 		writeBundle() {
 			const srcDir = resolve(resources, "sounds");
 			const destDir = resolve(devPath, "resources/sounds");

 			if (existsSync(srcDir)) {
+				try {
 				// Clean destination to avoid stale files
 				if (existsSync(destDir)) {
 					rmSync(destDir, { recursive: true });
 				}
 				mkdirSync(destDir, { recursive: true });
 				cpSync(srcDir, destDir, { recursive: true });
+				} catch (error) {
+					console.error("[copy-resources] Failed to copy sounds:", error);
+				}
 			}
 		},
 	};
 }
apps/desktop/src/main/lib/notification-sound.ts (1)

45-49: Consider escaping the sound path for PowerShell command injection safety.

The path is interpolated directly into a PowerShell command. While the filename is derived from controlled sources (getRingtoneFilename), a sound file with a single quote in its name could break the command or enable injection.

 	} else if (process.platform === "win32") {
 		execFile("powershell", [
 			"-c",
-			`(New-Object Media.SoundPlayer '${soundPath}').PlaySync()`,
+			`(New-Object Media.SoundPlayer '${soundPath.replace(/'/g, "''")}').PlaySync()`,
 		]);
apps/desktop/src/lib/electron-router-dom.ts (1)

36-44: Remove unnecessary fallback since id is required.

Line 38 uses props.id || "main" as a fallback, but id is a required property of type WindowId in the function signature. This fallback is dead code.

 	} else {
 		// Preview or Production: load from file with hash routing
-		const windowId = props.id || "main";
+		const windowId = props.id;
 		let url = `/${windowId}`;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 20faa46 and f5f96dd.

📒 Files selected for processing (6)
  • apps/desktop/electron-builder.ts (1 hunks)
  • apps/desktop/electron.vite.config.ts (2 hunks)
  • apps/desktop/src/lib/electron-router-dom.ts (1 hunks)
  • apps/desktop/src/lib/trpc/routers/ringtone/index.ts (4 hunks)
  • apps/desktop/src/main/lib/notification-sound.ts (2 hunks)
  • apps/desktop/src/main/lib/sound-paths.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
apps/desktop/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

For Electron interprocess communication, ALWAYS use tRPC as defined in src/lib/trpc

Files:

  • apps/desktop/src/main/lib/sound-paths.ts
  • apps/desktop/electron-builder.ts
  • apps/desktop/src/main/lib/notification-sound.ts
  • apps/desktop/electron.vite.config.ts
  • apps/desktop/src/lib/electron-router-dom.ts
  • apps/desktop/src/lib/trpc/routers/ringtone/index.ts
apps/desktop/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

apps/desktop/**/*.{ts,tsx}: Please use alias as defined in tsconfig.json when possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary

Files:

  • apps/desktop/src/main/lib/sound-paths.ts
  • apps/desktop/electron-builder.ts
  • apps/desktop/src/main/lib/notification-sound.ts
  • apps/desktop/electron.vite.config.ts
  • apps/desktop/src/lib/electron-router-dom.ts
  • apps/desktop/src/lib/trpc/routers/ringtone/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Maintain type safety and avoid using any unless absolutely necessary in TypeScript code

Files:

  • apps/desktop/src/main/lib/sound-paths.ts
  • apps/desktop/electron-builder.ts
  • apps/desktop/src/main/lib/notification-sound.ts
  • apps/desktop/electron.vite.config.ts
  • apps/desktop/src/lib/electron-router-dom.ts
  • apps/desktop/src/lib/trpc/routers/ringtone/index.ts
apps/desktop/src/lib/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Never import Node.js modules like node:fs, node:path, node:os in src/lib/electron-router-dom.ts or similar shared code

Files:

  • apps/desktop/src/lib/electron-router-dom.ts
  • apps/desktop/src/lib/trpc/routers/ringtone/index.ts
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T23:32:32.232Z
Learning: Applies to apps/desktop/src/lib/**/*.{ts,tsx} : Never import Node.js modules like node:fs, node:path, node:os in src/lib/electron-router-dom.ts or similar shared code
📚 Learning: 2025-12-08T23:32:32.232Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T23:32:32.232Z
Learning: Applies to apps/desktop/src/main/lib/*{workspace,worktree}-*.ts : Use git worktree-based workspace management in the desktop app through workspace-manager.ts and worktree-manager.ts

Applied to files:

  • apps/desktop/src/main/lib/sound-paths.ts
  • apps/desktop/electron.vite.config.ts
📚 Learning: 2025-11-24T21:33:13.267Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: apps/desktop/AGENTS.md:0-0
Timestamp: 2025-11-24T21:33:13.267Z
Learning: Applies to apps/desktop/**/*.{ts,tsx} : Please use alias as defined in `tsconfig.json` when possible

Applied to files:

  • apps/desktop/src/main/lib/sound-paths.ts
📚 Learning: 2025-12-08T23:32:32.232Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T23:32:32.232Z
Learning: Applies to apps/desktop/src/lib/**/*.{ts,tsx} : Never import Node.js modules like node:fs, node:path, node:os in src/lib/electron-router-dom.ts or similar shared code

Applied to files:

  • apps/desktop/src/main/lib/sound-paths.ts
  • apps/desktop/electron-builder.ts
  • apps/desktop/electron.vite.config.ts
  • apps/desktop/src/lib/electron-router-dom.ts
  • apps/desktop/src/lib/trpc/routers/ringtone/index.ts
📚 Learning: 2025-11-24T21:33:13.267Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: apps/desktop/AGENTS.md:0-0
Timestamp: 2025-11-24T21:33:13.267Z
Learning: Applies to apps/desktop/**/*.{ts,tsx,js,jsx} : For Electron interprocess communication, ALWAYS use tRPC as defined in `src/lib/trpc`

Applied to files:

  • apps/desktop/src/main/lib/sound-paths.ts
  • apps/desktop/src/lib/electron-router-dom.ts
  • apps/desktop/src/lib/trpc/routers/ringtone/index.ts
📚 Learning: 2025-12-08T23:32:32.232Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T23:32:32.232Z
Learning: Applies to apps/desktop/src/renderer/**/*.{ts,tsx} : Never import Node.js modules in renderer process or shared code - only in src/main/

Applied to files:

  • apps/desktop/src/main/lib/sound-paths.ts
📚 Learning: 2025-12-08T23:32:32.232Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T23:32:32.232Z
Learning: Applies to apps/desktop/src/main/lib/terminal-*.ts : Use node-pty for terminal session management in the desktop app

Applied to files:

  • apps/desktop/src/main/lib/sound-paths.ts
🧬 Code graph analysis (2)
apps/desktop/src/lib/electron-router-dom.ts (1)
apps/desktop/src/shared/constants.ts (1)
  • PORTS (12-17)
apps/desktop/src/lib/trpc/routers/ringtone/index.ts (1)
apps/desktop/src/main/lib/sound-paths.ts (2)
  • getSoundPath (15-18)
  • getSoundsDirectory (26-58)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build
🔇 Additional comments (8)
apps/desktop/src/lib/trpc/routers/ringtone/index.ts (2)

107-109: LGTM!

The refactor to use centralized getSoundPath helper is clean and maintains the same behavior while consolidating path resolution logic.


5-8: No actionable changes needed. The tsconfig.json does not define an alias for the main/lib path (only *src/* and ~/*./* are configured). The relative import ../../../../main/lib/sound-paths is the correct approach given the current alias configuration.

Likely an incorrect or invalid review comment.

apps/desktop/src/main/lib/notification-sound.ts (1)

8-8: LGTM!

The import and integration with the centralized getSoundPath utility is clean and appropriate for main process code.

apps/desktop/src/main/lib/sound-paths.ts (2)

1-18: LGTM!

Clean implementation of centralized sound path utilities. The getSoundPath function properly delegates to getSoundsDirectory for environment-aware path resolution.


26-57: Well-designed environment detection with graceful fallbacks.

The three-tier path resolution (production → development → preview) with existence checks and warning logs provides good debugging information when paths are misconfigured. The production path correctly aligns with the asarUnpack configuration in electron-builder.ts.

apps/desktop/src/lib/electron-router-dom.ts (2)

5-10: LGTM!

The router configuration is appropriate. The custom registerRoute implementation correctly bypasses the dev server port in preview/production modes by loading files directly, which mitigates any port configuration concerns.


1-3: This file does not import Node.js modules, but Router is used in the renderer process.

The file correctly avoids importing Node.js modules like fs, path, or os. However, electron-router-dom.ts is imported at runtime in apps/desktop/src/renderer/routes.tsx (line 1: import { Router }), and the module evaluates process.env.NODE_ENV at load time. The Router object should be exported without relying on environment variables that may not be available or reliable in the renderer process context. Move any NODE_ENV checks to the main process where the router is actually registered (apps/desktop/src/lib/electron-app/factories/windows/create.ts).

Likely an incorrect or invalid review comment.

apps/desktop/electron-builder.ts (1)

35-39: No action needed. The asarUnpack path correctly aligns with the files configuration. The pkg.resources field resolves to "src/resources", which is copied to the "resources" directory in the output. The sounds directory exists at apps/desktop/src/resources/sounds and will be included in the bundled resources, making the "resources/sounds/**/*" asarUnpack pattern correct.

@AviPeltz AviPeltz merged commit 8bdb730 into main Dec 11, 2025
8 checks passed
@Kitenite Kitenite deleted the obedient-crab-813e02 branch December 12, 2025 02:06
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.

1 participant