Skip to content

Fix Electron dev and packaged renderer startup#3557

Merged
juliusmarminge merged 8 commits into
mainfrom
codex/fix-electron-protocol-startup
Jun 25, 2026
Merged

Fix Electron dev and packaged renderer startup#3557
juliusmarminge merged 8 commits into
mainfrom
codex/fix-electron-protocol-startup

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 25, 2026

Copy link
Copy Markdown
Member

Summary

  • preserve the dedicated t3code-dev://app origin for development and t3code://app for packaged builds
  • allow both desktop renderer origins through the local development backend CORS policy
  • sanitize custom-protocol navigation headers before proxying renderer assets to Vite/server
  • retry transient idempotent renderer fetch failures during startup
  • do not rewrite, impersonate, or automatically select Clerk credentials

Verification

  • switched the existing T3CODE_CLERK_PUBLISHABLE_KEY and T3CODE_CLERK_CLI_OAUTH_CLIENT_ID entries in the ignored local .env for each mode
  • vp run dev:desktop with development credentials; Computer Use verified the signed-in project UI at t3code-dev://app/
  • vp run dist:desktop:artifact with production credentials; fresh arm64 Alpha package reached backend ready and main window created
  • focused suite: 115 passing tests
  • vp check
  • vp run typecheck

Note

Medium Risk
Touches auth-adjacent CORS and the Electron protocol proxy path used for all renderer traffic; changes are scoped to dev origins and idempotent GET/HEAD retries with tests.

Overview
Improves Electron desktop dev and packaged startup by fixing how the custom protocol proxies traffic and how the local API accepts browser calls from the renderer.

ElectronProtocol strips hop-by-hop and browser-only headers (origin, referer, sec-fetch-*, etc.) before forwarding to Vite/the app server, and retries GET/HEAD fetches up to three times (0/50/150ms) on transient connection failures like ECONNREFUSED.

In development, the server CORS layer now allows credentialed preflights from t3code://app and t3code-dev://app alongside the Vite dev origin. Vite HMR sets an explicit clientPort so the HMR WebSocket connects reliably inside Electron.

Marketing bumps Astro from 6 to 7.0.3. Tests cover header sanitization, retry behavior, and desktop-origin CORS preflights.

Reviewed by Cursor Bugbot for commit 41d30ee. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix Electron renderer startup by retrying transient fetch failures and correcting CORS and HMR config

  • Adds fetchWithTransientRetry in ElectronProtocol.ts to retry GET/HEAD requests up to 3 times with short delays (0, 50, 150 ms) on transient failures like ECONNREFUSED during renderer startup.
  • Strips browser-specific headers (origin, referer, sec-fetch-*, etc.) before forwarding proxied requests to the target.
  • Adds t3code://app and t3code-dev://app to allowed CORS origins in apps/server/src/http.ts so credentialed requests from the packaged and dev Electron renderer work correctly.
  • Sets clientPort explicitly in the Vite HMR config so WebSocket connections work inside the Electron BrowserWindow.
  • Behavioral Change: non-GET/HEAD requests no longer forward origin, referer, or sec-fetch-* headers to the target.

Macroscope summarized 41d30ee.

Toolchain follow-up

  • configure Vite HMR with the explicit desktop dev client port, removing the recoverable initial WebSocket failure
  • upgrade Vite+ and Vite+ core from 0.1.24 to exact 0.2.1
  • remove the retired vite-plus-test wrapper and obsolete Vitest resolution rules; retain one transitive Vitest 4.1.9 / Vite+ core graph
  • upgrade the marketing app from Astro 6 to Astro 7.0.3
  • full verification: vp test (536 files / 4099 tests passed), vp check, vp run typecheck, Astro production build, dev UI + clean DevTools console, packaged renderer IPC bootstrap

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2b6e73fc-1fea-4b72-ab19-f263e3211ac0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-electron-protocol-startup

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Jun 25, 2026
@juliusmarminge juliusmarminge changed the title [codex] fix Electron protocol startup race [codex] fix Electron custom-origin startup Jun 25, 2026
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Jun 25, 2026
@juliusmarminge juliusmarminge changed the title [codex] fix Electron custom-origin startup Fix Electron dev and packaged renderer startup Jun 25, 2026
@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Jun 25, 2026
@juliusmarminge
juliusmarminge marked this pull request as ready for review June 25, 2026 20:01
Comment thread apps/server/src/http.ts
@macroscopeapp

macroscopeapp Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

Bug fix for Electron renderer startup with well-tested, limited-scope changes: header stripping for proxied requests, retry logic for transient GET/HEAD failures, and dev-mode CORS configuration. All changes include corresponding tests.

You can customize Macroscope's approvability policy. Learn more.

@github-actions github-actions Bot added size:XXL 1,000+ changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Jun 25, 2026
@juliusmarminge
juliusmarminge enabled auto-merge (squash) June 25, 2026 20:58
@juliusmarminge
juliusmarminge merged commit 31dfe35 into main Jun 25, 2026
16 checks passed
@juliusmarminge
juliusmarminge deleted the codex/fix-electron-protocol-startup branch June 25, 2026 20:58
aaditagrawal pushed a commit to aaditagrawal/t3code that referenced this pull request Jun 26, 2026
Co-authored-by: Julius Marminge <julius@mac.lan>
aaditagrawal added a commit to aaditagrawal/t3code that referenced this pull request Jun 26, 2026
<!--
⚠️ READ BEFORE OPENING ⚠️

We are not actively accepting contributions right now.

You can still open a PR, but please do so knowing there is a high chance
we may close it without merging it, or never review it.

- Small, focused PRs are strongly preferred. Bug fixes are most likely to be merged.
- New features will most likely just annoy us.
- 1,000+ line PRs with a bunch of new features will probably get you banned from the repo.
-->

## What Changed

<!-- Describe the change clearly and keep scope tight. -->

## Why

<!-- Explain the problem being solved and why this approach is the right one. -->

## UI Changes

<!-- If this PR changes UI, include clear before/after screenshots.
     If the change involves motion or interaction, include a short video.
     Delete this section if not applicable. -->

## 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
chanyeinthaw pushed a commit to sats-lab/pulse that referenced this pull request Jun 28, 2026
Co-authored-by: Julius Marminge <julius@mac.lan>
simonbetton pushed a commit to simonbetton/reviewer that referenced this pull request Jun 29, 2026
Co-authored-by: Julius Marminge <julius@mac.lan>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ 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.

1 participant