Skip to content

Revert "fix(desktop): queue early macOS deep links to prevent auth redirect loss"#1440

Closed
Kitenite wants to merge 1 commit into
mainfrom
revert-1436-kitenite/entrypoint
Closed

Revert "fix(desktop): queue early macOS deep links to prevent auth redirect loss"#1440
Kitenite wants to merge 1 commit into
mainfrom
revert-1436-kitenite/entrypoint

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Feb 12, 2026

Reverts #1436

Summary by CodeRabbit

Release Notes

  • New Features

    • Added project icon serving and display functionality
    • Enhanced deep link handling for authentication flows and navigation
  • Bug Fixes

    • Improved deep link processing on application startup
    • Refined application quit confirmation behavior and termination handling
  • Chores

    • Optimized initialization order for improved startup performance

@Kitenite
Copy link
Copy Markdown
Collaborator Author

Doesn't fix initial issue

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

The PR modifies the Electron main process to enhance deep-linking with protocol registration and auth/non-auth handling, add SQLite-based quit-confirmation preferences, introduce termination signal handling for development, register an icon protocol, and reorganize startup initialization order to ensure proper sequencing of dependencies.

Changes

Cohort / File(s) Summary
Main Process Enhancement
apps/desktop/src/main/index.ts
Adds SQLite DB initialization; implements processDeepLink with auth/non-auth branching; registers superset-icon protocol for icon serving; adds getConfirmOnQuitSetting, setSkipQuitConfirmation, and quitWithoutConfirmation functions; replaces pendingDeepLinkUrl with direct open-url event handling; adds SIGTERM/SIGINT handlers and parent-process monitor for graceful shutdown in development; reorganizes initialization sequence for proper dependency ordering.

Sequence Diagram(s)

sequenceDiagram
    participant App as Electron App
    participant Event as open-url Event
    participant Auth as Auth Handler
    participant Renderer as Renderer Process
    participant Window as Main Window

    Event->>App: Receive deep-link URL
    App->>App: processDeepLink(url)
    alt Auth Deep Link
        App->>Auth: Handle auth callback
        Auth->>App: Return result
        App->>Window: focusMainWindow()
        Window->>Renderer: Focus & activate
    else Non-Auth Deep Link
        App->>Renderer: Send deep-link-navigate IPC
        Renderer->>Renderer: Navigate to URL
        App->>Window: focusMainWindow()
    end
Loading
sequenceDiagram
    participant User as User
    participant App as Electron App
    participant DB as SQLite DB
    participant Dialog as Dialog
    participant Cleanup as Cleanup Handler

    User->>App: Initiate quit
    App->>DB: getConfirmOnQuitSetting()
    alt Confirmation Enabled
        App->>Dialog: Show quit confirmation
        Dialog->>User: User response
        alt User Cancels
            Dialog-->>App: Cancel signal
            App->>App: Prevent quit
        else User Confirms
            Dialog-->>App: Proceed signal
            App->>Cleanup: Cleanup & exit
        end
    else Confirmation Disabled
        App->>Cleanup: Cleanup & exit
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • PR #50: Implements and modifies app deep-linking flow with protocol registration and open-url handling, directly intersecting with the deep-link processing enhancements in this PR.
  • PR #524: Extends the quit-confirmation feature with DB setting retrieval and behavioral exports (setSkipQuitConfirmation, quitWithoutConfirmation) that are core additions in this PR.
  • PR #809: Directly depends on and uses the new quitWithoutConfirmation export introduced by this PR to implement a restart flow.

Poem

🐰 The main process hops anew,
Deep links flow and protocols brew,
Quit confirmations dance with DB grace,
Signals caught, termination's embrace—
Startup order runs true! 🎯

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is extremely minimal and lacks all required template sections (Type of Change, Testing, Related Issues details). Add required sections: expand on the revert rationale, specify the Type of Change (appears to be a Refactor), describe testing performed, and provide context on why the original fix needed reverting.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly indicates this is a revert commit, which is a major change that would be immediately understood by reviewers scanning history.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 revert-1436-kitenite/entrypoint

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.

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: 1

🤖 Fix all issues with AI agents
In `@apps/desktop/src/main/index.ts`:
- Around line 95-99: The macOS open-url handler (app.on("open-url", ...) calling
processDeepLink) can fire before initialization (initAppState) and before
windows exist, causing cold-start deep links to be lost; modify the handler to
detect when the app is not ready or initAppState hasn't run and stash the
incoming URL (e.g., in a module-level pendingDeepLink variable or queue) and
then process it after startup (reuse existing processDeepLink call in the
post-init path that runs findDeepLinkInArgv), ensuring handleAuthCallback can
access initialized state and BrowserWindow.getAllWindows() will find windows; if
this is intentionally deferred, add a TODO comment here referencing the known
gap and link to the follow-up issue.
🧹 Nitpick comments (1)
apps/desktop/src/main/index.ts (1)

57-70: Variable path shadows the node:path import; deep-link navigation uses direct IPC instead of tRPC.

Two issues in this segment:

  1. Line 60: const path shadows the top-level import path from "node:path" (line 1). No functional bug today, but it will bite if node:path is ever needed inside this function.

  2. Line 69: webContents.send("deep-link-navigate", path) is raw Electron IPC. As per coding guidelines, Electron IPC should always go through tRPC (src/lib/trpc).

Suggested fix for the shadowing
-	const path = `/${url.split("://")[1]}`;
+	const deepLinkPath = `/${url.split("://")[1]}`;

 	focusMainWindow();

 	// Navigate in renderer via loading the route directly
 	const windows = BrowserWindow.getAllWindows();
 	if (windows.length > 0) {
 		const mainWindow = windows[0];
 		// Send navigation request to renderer
-		mainWindow.webContents.send("deep-link-navigate", path);
+		mainWindow.webContents.send("deep-link-navigate", deepLinkPath);
 	}

Comment on lines +95 to 99
// Handle deep links when app is already running (macOS)
app.on("open-url", async (event, url) => {
event.preventDefault();
if (appReady) {
await processDeepLink(url);
} else {
pendingDeepLinkUrl = url;
}
await processDeepLink(url);
});
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.

⚠️ Potential issue | 🟠 Major

macOS cold-start deep links will be silently lost.

On macOS, open-url fires before app.whenReady(). At that point:

  • Auth deep links: handleAuthCallback may not have the required state (e.g., initAppState at line 266 hasn't run yet).
  • Non-auth deep links: BrowserWindow.getAllWindows() returns [], so the navigation at line 66–70 is silently skipped.

Windows/Linux cold-start deep links are handled correctly via findDeepLinkInArgv at lines 285–289 (post-init), but macOS has no equivalent deferred path after this revert.

If the revert is intentional and temporary, consider adding a // TODO here documenting the known gap and linking to the follow-up issue.

🤖 Prompt for AI Agents
In `@apps/desktop/src/main/index.ts` around lines 95 - 99, The macOS open-url
handler (app.on("open-url", ...) calling processDeepLink) can fire before
initialization (initAppState) and before windows exist, causing cold-start deep
links to be lost; modify the handler to detect when the app is not ready or
initAppState hasn't run and stash the incoming URL (e.g., in a module-level
pendingDeepLink variable or queue) and then process it after startup (reuse
existing processDeepLink call in the post-init path that runs
findDeepLinkInArgv), ensuring handleAuthCallback can access initialized state
and BrowserWindow.getAllWindows() will find windows; if this is intentionally
deferred, add a TODO comment here referencing the known gap and link to the
follow-up issue.

@Kitenite Kitenite closed this Feb 17, 2026
@Kitenite Kitenite deleted the revert-1436-kitenite/entrypoint branch February 19, 2026 21:44
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