Skip to content

fix(desktop): resolve Windows userData without yielding before the Clerk bridge - #13204

Merged
juliusmarminge merged 4 commits into
pingdotgg:t3code/codex-turn-mappingfrom
SunkenInTime:devin/1790135103-win-clerk-sync-userdata
Sep 24, 2026
Merged

juliusmarminge merged 4 commits into
pingdotgg:t3code/codex-turn-mappingfrom
SunkenInTime:devin/1790135103-win-clerk-sync-userdata

Conversation

@SunkenInTime

@SunkenInTime SunkenInTime commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #13195

What Changed

DesktopClerk.make now runs DesktopUserData.resolveUserDataPath against a synchronous node:fs-backed FileSystem (existsSync, readFileSync, mkdirSync, writeFileSync, errno mapped to PlatformError.systemError so the wx / AlreadyExists write path still works). The resolver, its tests, and the setPath("userData") before createClerkBridge order are unchanged.

Regression test in DesktopClerk.test.ts: builds the layer under Effect.runSync with an ambient FileSystem whose exists is deferred, for packaged Windows and for development. Any yield before createClerkBridge throws AsyncFiberError. Both cases fail on the current branch and pass with this change.

Why

Every packaged Windows launch of the V2 branch exits with code 1 before a window appears:

ERROR (#4): DesktopClerkBridgeInitializationError: Failed to initialize the desktop Clerk bridge for state directory "C:\Users\<user>\.t3\userdata" (development: false).
  [cause]: Error: protocol.registerSchemesAsPrivileged should be called before app is ready
      at createClerkBridge (...\app.asar\apps\desktop\dist-electron\main.cjs:119042:22)
      at createDesktopClerkBridge (...\main.cjs:128507:9)

Since #12480, resolveUserDataPath inspects the profile directories on win32 (and the legacy profile in development on every platform) through the Effect Node FileSystem. exists there is async, so the startup fiber yields, Electron emits ready during that yield, and @clerk/electron's registerSchemesAsPrivileged throws. Non-Windows packaged builds return before any I/O, which is why macOS is unaffected. Creating the bridge before resolving userData is not an option because the bridge takes the single-instance lock in the userData directory, so the I/O has to stop yielding instead. This is the approach @juliusmarminge described in the issue.

Verification

Windows Server 2022 x64, Node 24.13.1, pnpm 11.10.0, Electron 44.4.2, branch t3code/codex-turn-mapping at 060756de5.

Before: pnpm dist:desktop:win:x64, install release\T3-Code-0.0.42-x64.exe /S, run T3 Code (Alpha).exe --enable-logging=stderr. Process exits with code 1 in about one second with the error above.

After: same build and install steps. The process stays up, the onboarding window opens, and GET http://127.0.0.1:3773/.well-known/t3/environment returns 200 with serverVersion 0.0.42.

Before After
Packaged app exits with DesktopClerkBridgeInitializationError Packaged app opens the onboarding window

Checks: apps/desktop typecheck exit 0, vp lint and vp fmt --check clean on the two changed files, DesktopClerk.test.ts 7/7. DesktopUserData.test.ts > identifies a failed source read and preserves its cause fails on this Windows machine both before and after this change (path separator in the expected error), so it is not related.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Sep 23, 2026
Comment thread apps/desktop/src/app/DesktopClerk.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This focused fix changes production desktop startup by introducing synchronous filesystem access before Clerk bridge registration. It also adds file- and line-level static-analysis suppressions, so the change warrants human review.

You can add or adjust custom eligibility rules. Learn more.

@juliusmarminge
juliusmarminge force-pushed the t3code/codex-turn-mapping branch from 060756d to d6dcd10 Compare September 23, 2026 04:10
@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1790135103-win-clerk-sync-userdata branch from cb94fc5 to 42b5fb8 Compare September 23, 2026 04:21
@juliusmarminge
juliusmarminge force-pushed the t3code/codex-turn-mapping branch 2 times, most recently from d2675dc to 9cbaf77 Compare September 23, 2026 07:35
@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1790135103-win-clerk-sync-userdata branch from 42b5fb8 to 2ff43ca Compare September 23, 2026 18:29
Comment thread apps/desktop/src/app/DesktopClerk.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Effect Service Conventions found one blocking issue in apps/desktop/src/app/DesktopClerk.ts: service construction hides the filesystem dependency behind a module-global concrete implementation instead of acquiring it from the Effect environment. See the inline review comment for the expected application-layer composition fix.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/desktop/src/app/DesktopPreReadyFileSystem.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Effect Service Conventions found one blocking issue in apps/desktop/src/app/DesktopPreReadyFileSystem.ts: the implementation module exposes only an inline layer rather than canonical make and layer values. See the inline review comment for the suggested fix.

Posted via Macroscope — Effect Service Conventions

1 similar comment
@macroscopeapp

This comment has been minimized.

@juliusmarminge
juliusmarminge force-pushed the t3code/codex-turn-mapping branch 2 times, most recently from 6ca6a24 to 3e4ca4c Compare September 23, 2026 23:24
SunkenInTime and others added 4 commits September 23, 2026 18:12
…erk bridge

resolveUserDataPath ran through the Effect Node FileSystem, so its async exists() check yielded the startup fiber; Electron then emitted ready and createClerkBridge's protocol.registerSchemesAsPrivileged threw, crashing packaged Windows (and dev) at startup with DesktopClerkBridgeInitializationError. Run the resolver against a synchronous node:fs-backed FileSystem so setPath('userData') and bridge creation complete before the first yield.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…rting missing

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
DesktopClerk.make overrode FileSystem with a module-global sync adapter,
hiding the dependency. Move the adapter to DesktopPreReadyFileSystem.layer
and provide it to the Clerk layer in main.ts. The regression test now
builds the Clerk layer under runSync with that real layer.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@juliusmarminge
juliusmarminge force-pushed the devin/1790135103-win-clerk-sync-userdata branch from 964d66c to 8d1f200 Compare September 24, 2026 01:13
@macroscopeapp

This comment has been minimized.

@juliusmarminge
juliusmarminge merged commit 1bd44f2 into pingdotgg:t3code/codex-turn-mapping Sep 24, 2026
31 of 32 checks passed
juliusmarminge added a commit that referenced this pull request Sep 24, 2026
…erk bridge (#13204)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
juliusmarminge added a commit that referenced this pull request Sep 24, 2026
…erk bridge (#13204)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
juliusmarminge added a commit that referenced this pull request Sep 24, 2026
…erk bridge (#13204)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
juliusmarminge added a commit that referenced this pull request Sep 25, 2026
…erk bridge (#13204)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
astarktc added a commit to astarktc/t3code that referenced this pull request Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants