Conversation
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughAdded diagnostic logging and explicit error handling for window loading, custom protocol requests, and renderer lifecycle events; made production filename extraction cross-platform. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
Participant AppMain as Main Process
Participant Protocol as Custom Protocol Handler
Participant FS as File System
Participant BrowserWin as BrowserWindow (Renderer)
AppMain->>Protocol: register protocol (non-dev)
Note right of Protocol: logs protocol scheme, paths
BrowserWin->>AppMain: request URL (via protocol)
Protocol->>FS: resolve pathname -> file path
Protocol-->>AppMain: return file path (served)
AppMain->>BrowserWin: loadURL(resolved URL)
BrowserWin-->>AppMain: did-finish-load / did-fail-load / render-process-gone / preload-error
Note left of AppMain: logs details and ensures window shown on failures
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
✏️ Tip: You can disable this entire section by setting 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
🤖 Fix all issues with AI agents
In `@apps/desktop/src/lib/window-loader.ts`:
- Line 1: Remove the Node.js path import and replace the use of path.basename in
window-loader.ts: instead of importing "node:path" and calling
path.basename(props.htmlFile), compute the file name from props.htmlFile using a
split on both slashes (e.g., split on /[/\\]/ and take the last element) and
fallback to "index.html" if empty; update any references to the old variable
(e.g., fileName) accordingly and delete the import line.
🧹 Nitpick comments (1)
apps/desktop/src/main/index.ts (1)
229-231: Consider removing or reducing verbosity of per-request logging.Logging every protocol request may generate excessive noise in production. These logs are helpful for debugging but could clutter logs during normal operation, especially if resources like images or fonts are loaded repeatedly.
Consider either:
- Removing these per-request logs before release (since they're for "release testing" per PR title)
- Gating them behind a debug flag or environment variable
💡 Optional: Gate verbose logging
+const DEBUG_PROTOCOL = process.env.DEBUG_PROTOCOL === "true"; + protocol.handle(PROTOCOL_SCHEME, (request) => { const parsedUrl = new URL(request.url); const pathname = parsedUrl.pathname; const filePath = path.normalize( path.join(__dirname, "../renderer", pathname), ); - console.log(`[protocol] Request: ${request.url}`); - console.log(`[protocol] Pathname: ${pathname}`); - console.log(`[protocol] Resolved file path: ${filePath}`); + if (DEBUG_PROTOCOL) { + console.log(`[protocol] Request: ${request.url}`); + console.log(`[protocol] Pathname: ${pathname}`); + console.log(`[protocol] Resolved file path: ${filePath}`); + } return net.fetch(`file://${filePath}`); });
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
apps/desktop/src/lib/window-loader.tsapps/desktop/src/main/index.tsapps/desktop/src/main/windows/main.ts
🧰 Additional context used
📓 Path-based instructions (6)
apps/desktop/**/*.{ts,tsx}
📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)
apps/desktop/**/*.{ts,tsx}: For Electron interprocess communication, ALWAYS use tRPC as defined insrc/lib/trpc
Use alias as defined intsconfig.jsonwhen possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary.
For tRPC subscriptions with trpc-electron, ALWAYS use the observable pattern from@trpc/server/observableinstead of async generators, as the library explicitly checksisObservable(result)and throws an error otherwise
Files:
apps/desktop/src/main/windows/main.tsapps/desktop/src/lib/window-loader.tsapps/desktop/src/main/index.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use object parameters for functions with 2+ parameters instead of positional arguments
Functions with 2+ parameters should accept a single params object with named properties for self-documentation and extensibility
Use prefixed console logging with context pattern: [domain/operation] message
Extract magic numbers and hardcoded values to named constants at module top
Use lookup objects/maps instead of repeated if (type === ...) conditionals
Avoid usinganytype - maintain type safety in TypeScript code
Never swallow errors silently - at minimum log them with context
Import from concrete files directly when possible - avoid barrel file abuse that creates circular dependencies
Avoid deep nesting (4+ levels) - use early returns, extract functions, and invert conditions
Use named properties in options objects instead of boolean parameters to avoid boolean blindness
Files:
apps/desktop/src/main/windows/main.tsapps/desktop/src/lib/window-loader.tsapps/desktop/src/main/index.ts
apps/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use Drizzle ORM for all database operations - never use raw SQL
Files:
apps/desktop/src/main/windows/main.tsapps/desktop/src/lib/window-loader.tsapps/desktop/src/main/index.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use Biome for formatting and linting - run at root level with
bun run lint:fixorbiome check --write
Files:
apps/desktop/src/main/windows/main.tsapps/desktop/src/lib/window-loader.tsapps/desktop/src/main/index.ts
apps/desktop/src/lib/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Never import Node.js modules in shared code like electron-router-dom.ts - it runs in both main and renderer processes
Files:
apps/desktop/src/lib/window-loader.ts
apps/desktop/src/main/index.ts
📄 CodeRabbit inference engine (AGENTS.md)
Load environment variables from monorepo root .env in desktop app with override: true before any imports in src/main/index.ts and electron.vite.config.ts
Files:
apps/desktop/src/main/index.ts
🧠 Learnings (4)
📚 Learning: 2026-01-02T06:50:28.671Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-02T06:50:28.671Z
Learning: Applies to apps/desktop/src/renderer/**/*.{ts,tsx} : Never import Node.js modules (fs, path, os, net) in renderer process or shared code - they are externalized for browser compatibility
Applied to files:
apps/desktop/src/main/windows/main.tsapps/desktop/src/lib/window-loader.tsapps/desktop/src/main/index.ts
📚 Learning: 2026-01-02T06:50:28.671Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-02T06:50:28.671Z
Learning: Applies to apps/desktop/src/lib/electron-router-dom.ts : Do not import Node.js modules like node:path or dotenv in electron-router-dom.ts and similar shared files - they run in both main and renderer processes
Applied to files:
apps/desktop/src/main/windows/main.tsapps/desktop/src/lib/window-loader.tsapps/desktop/src/main/index.ts
📚 Learning: 2026-01-02T06:50:28.671Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-02T06:50:28.671Z
Learning: Applies to apps/desktop/src/lib/*.ts : Never import Node.js modules in shared code like electron-router-dom.ts - it runs in both main and renderer processes
Applied to files:
apps/desktop/src/main/windows/main.tsapps/desktop/src/lib/window-loader.tsapps/desktop/src/main/index.ts
📚 Learning: 2025-12-21T04:39:28.543Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: apps/desktop/AGENTS.md:0-0
Timestamp: 2025-12-21T04:39:28.543Z
Learning: Applies to apps/desktop/**/*.{ts,tsx} : For Electron interprocess communication, ALWAYS use tRPC as defined in `src/lib/trpc`
Applied to files:
apps/desktop/src/lib/window-loader.ts
🧬 Code graph analysis (2)
apps/desktop/src/lib/window-loader.ts (1)
apps/desktop/src/shared/constants.ts (1)
PROTOCOL_SCHEME(30-31)
apps/desktop/src/main/index.ts (1)
apps/desktop/src/shared/constants.ts (1)
PROTOCOL_SCHEME(30-31)
⏰ 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 (7)
apps/desktop/src/main/windows/main.ts (4)
173-180: LGTM!The success log and window show logic are appropriate. The log follows the prefixed
[main-window]pattern per coding guidelines.
182-192: LGTM!Good error handling that logs all relevant details (error code, description, URL) and ensures the window is shown so the user isn't left with a blank screen. This aligns well with the PR's goal of diagnosing white screen issues.
194-196: LGTM!Logging renderer process crashes will help diagnose unexpected terminations. The
detailsobject from Electron includesreasonandexitCodewhich are useful for debugging.
198-202: LGTM!Preload script errors are a common source of white screen issues, so this logging is valuable for the stated PR objective.
apps/desktop/src/main/index.ts (1)
214-220: LGTM!These startup logs will help diagnose path resolution issues in packaged builds. The
[main]prefix follows coding guidelines.apps/desktop/src/lib/window-loader.ts (2)
25-31: LGTM!Good addition of error handling on
loadURL. The.catch()ensures load failures are logged rather than silently swallowed, which aligns with coding guidelines.
35-43: Good cross-platform fix withpath.basename.Using
path.basenameinstead of string splitting handles Windows backslash paths correctly. The error logging on load failure is valuable for diagnosing white screen issues.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Description
Related Issues
Type of Change
Testing
Screenshots (if applicable)
Additional Notes
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.