fix(desktop): register Windows OAuth callbacks with the app entry point #15995
main fromrefs/pull/15995/head·merged by juliusmarminge View on GitHubWindows OAuth callbacks in unpackaged production runs could launch bare Electron with the callback URL as its app path, producing “Unable to find Electron app.” After Clerk initializes, register the callback with the running Electron executable and the absolute dist-electron/main.cjs entry. Development remains excluded because this OS launch command cannot restore the development server environment.
Thanks @AskPlays for the diagnosis and original fix in #15995. This maintainer takeover preserves contributor history and merges current main, including its earlier single-instance locking behavior. The implementation stays focused on unpackaged, non-development Windows runs.
Verification on headless Linux:
DesktopClerk.test.ts: 20 → 23 tests. Replaced the two outdated PR cases with five parameterized registration-boundary cases covering the Windows path (including spaces), executable, scheme, bridge ordering, and development/packaged/macOS/Linux exclusions.- Before: main’s production code passes 22 tests and fails the Windows registration regression. After: all 23 pass.
- Desktop typecheck, targeted lint, formatting, and whitespace checks pass. Electron executable-path lookup is bypassed for tests; no Electron process launches.
The original author reported a successful Windows reproduction and fix. This takeover could not repeat actual Windows registry registration or OAuth callback delivery. Verification here covers the mocked Electron API boundary and startup code paths. Human approval and a Windows unpackaged production callback test remain required. Windows, macOS, iOS, Android, and Electron desktop were not exercised live; this change does not alter web/mobile authentication.
Implementation: GPT-6.1-Sol; tests: GPT-6-Astra; independent reviews: Claude Opus 5.5 and GPT-6-Sol. Orchestrated in T3 Code through the Codex harness.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
- apps/desktop/src/app/DesktopClerk.ts lines 148 to 148OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -138,3 +138,11 @@138138 return yield* Effect.interrupt;139139 }140140141+ // The bridge registers the callback scheme via bare142+ // setAsDefaultProtocolClient(scheme). For unpackaged Windows runs that143+ // records `"electron.exe" "%1"`, so a browser callback boots bare144+ // Electron with the URL as the app path ("Unable to find Electron145+ // app"). Re-register with the real entry point; the bridge already146+ // ran, so this wins. Packaged builds and the mac dev launcher own147+ // their registration.148+ if (!environment.isPackaged && environment.platform === "win32") {
🟠 High
app/DesktopClerk.ts:148The Windows protocol registration launches development callbacks without
VITE_DEV_SERVER_URL, so Electron derivesisDevelopmentas false and starts the productiont3codeinstance instead of delivering the callback to the existingt3code-devinstance. Limit this registration to non-development runs so the dev launcher remains responsible for its environment.Suggested change148- if (!environment.isPackaged && environment.platform === "win32") {148+ if (!environment.isPackaged && !environment.isDevelopment && environment.platform === "win32") {🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/desktop/src/app/DesktopClerk.ts around line 148: The Windows protocol registration launches development callbacks without `VITE_DEV_SERVER_URL`, so Electron derives `isDevelopment` as false and starts the production `t3code` instance instead of delivering the callback to the existing `t3code-dev` instance. Limit this registration to non-development runs so the dev launcher remains responsible for its environment.Sorry, I'm unable to act on this request because you do not have permissions within this repository.
Verified on the maintainer revision: registration is guarded by !environment.isDevelopment, so the development launcher retains responsibility for its environment. The focused DesktopClerk suite passes 23 tests, including a Windows development case that observes no registration override. The override is limited to unpackaged, non-development Windows. Actual Windows callback activation still needs a human runtime check.
Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — This change modifies Windows OAuth callback registration on a production desktop startup path and applies to unpackaged development runs as well as non-development runs. An unresolved high-severity finding indicates development callbacks may launch the production instance without the development environment, requiring runtime review.
Not approved because:
- 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity
Warning
Review limit reached#
Only developers with an assigned seat can use this organization's usage-based review budget, and seats here are assigned manually. Ask an admin to assign a seat, or change the review continuation mode in Billing.
Next included review available in 12 minutes.
View limit details
-
Limit details: You’ve used all 10 included reviews currently available.
Review configuration:
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
4c108162-3adf-46e3-9e2c-27e973eed402
📥 Commits
-
Reviewing files that changed from the base of the PR and between 60dea8755c90bf557e5d2a5ed9f95e0c4628b590 and beb7f5eab721074b0f7d3a3ee053159f2b0bc30d.
📒 Files selected for processing: 2
-
apps/desktop/src/app/DesktopClerk.test.tsapps/desktop/src/app/DesktopClerk.ts
-
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
- Review profile: CHILL
- Plan: Advanced
- Run ID:
b9bc29ed-6d16-48ed-b777-a90855cd6653
📥 Commits
-
Reviewing files that changed from the base of the PR and between cf3e714b0f58e29c8fa8660db50d2187e3263b65 and 60dea8755c90bf557e5d2a5ed9f95e0c4628b590.
📒 Files selected for processing (2)
-
apps/desktop/src/app/DesktopClerk.test.tsapps/desktop/src/app/DesktopClerk.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
📝 Walkthrough
-
Unpackaged Windows runs now register the
t3codeprotocol with the Electron executable and the distributionmain.cjsentry point. A test checks the registration behavior in development and non-development modes.Changes: Windows protocol registration
Layer / File(s) Summary Protocol registration and test
apps/desktop/src/app/DesktopClerk.ts,apps/desktop/src/app/DesktopClerk.test.tsFor unpackaged, non-development Windows runs, DesktopClerk.configureregisterst3codewithprocess.execPathand the distributionmain.cjsentry point. The test checks that development mode makes no registration call and that non-development mode uses those arguments.Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers:
juliusmarminge
Merge Risk: ⚪ Minimal · up to
60dea-
The Windows OAuth callback registration appears ready to merge after normal checks; no actionable issue remains in the supplied evidence.
Security Architecture Review
-
Security architecture risk: 🔵 Low · up to
60deaThe change is narrowly limited to unpackaged Windows sign-in callbacks. The executable and application entry point are selected by the running application, while existing URL and sign-in flow checks remain in place. Registration failure, persistence and cleanup behavior could not be fully verified.
Retained concerns No architecture-level concerns identified.
Security review details
-
Security Blast Radius
- inferred — The direct exposure change is restored browser-to-desktop callback reachability in the targeted Windows configuration. Existing provider handoffs can subsequently reach a target provider flow; the change does not itself supply new credentials, select a different executable from URL input, or remove the inspected flow controls. Exact OS registration scope remains unverified.
Trust Boundaries and Controls
- observed — The inspected Codex path constrains authorization URLs to OpenAI, requires a loopback redirect and PKCE/state shape, and checks callback origin, path and state. Server completion requires a matching active owner and flow ID, an unexpired waiting flow, and callback acceptance. The Codex completion callback rejects reuse. These controls predate this PR; external Clerk callback validation was not inspected.
Resilience and Maintainability Implications
- observed — The existing Codex callback helper binds only to loopback, rejects duplicate active state values, bounds the wait to five minutes, and closes its listener in finally. These containment measures remain unchanged by the registration fix.
Hardening Proposals
- proposed — Make registration failure distinguishable from successful callback setup, and document ownership and recovery expectations for the persistent Windows mapping. Validate overwrite failure, interruption, restart and cleanup against the actual SDK and OS behavior before treating the transition as rollback-safe.
-
Pre-merge checks:
5-
Check name Status Explanation Docstring Coverage No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Title check The title clearly and concisely describes the Windows OAuth callback registration fix. Description check The description explains the problem, implementation, scope, verification results, limitations, and tooling in sufficient detail. It does not use the template headings and does not provide explicit ma… Full details: Docstring Coverage
-
Explanation
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.
Full details: Description check
-
Explanation
The description explains the problem, implementation, scope, verification results, limitations, and tooling in sufficient detail. It does not use the template headings and does not provide explicit maintainer approval evidence, but the focused fix and linked prior PR provide adequate context.
-
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
@coderabbitai review
⚠️ Action not completed
Already reviewed the last commit. Use
@coderabbitai full reviewto rerun a review of the entire changeset.Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
@coderabbitai full review
✅ Action performed
Full review finished.
juliusmarminge assignedjuliusmarminge
Taking over this one as maintainer for desktop-app-03. I will preserve contributor history, merge main, keep development excluded from protocol registration, and run focused verification plus independent reviews. No merge is planned.
juliusmarminge merged this1e659c9
juliusmarminge closed this
Reverting this in #22222 together with the other desktop fixes the takeover campaign merged yesterday. Nothing was wrong with the review of this change; it was merged on CI and code audits only, and after #20907 from the same batch broke existing installs the maintainer decided that desktop changes do not ship without being run on a real desktop build. To bring it back: open a fresh PR from the original commit, run it on a real build that already has user state on each platform it touches, and put the before/after proof in the body.
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed