feat: add mock update server#1180
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
214bf71 to
7f0c421
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| provider: "generic", | ||
| url: `http://localhost:${mockUpdateServerPort ?? 3000}`, | ||
| }, | ||
| ]; |
There was a problem hiding this comment.
Mock updates config ignored when GitHub config exists
Medium Severity
At build time, the else if means mockUpdates is silently ignored whenever resolveGitHubPublishConfig() returns a config (e.g. when GITHUB_REPOSITORY is set). At runtime in configureAutoUpdater, mock updates correctly override GitHub by running after the GitHub setFeedURL call. This inconsistency means a build with --mock-updates can produce an app-update.yml pointing to GitHub instead of localhost, contradicting the PR's stated intent that the flag controls "the manifest URL built into the built Electron app."
Additional Locations (1)
There was a problem hiding this comment.
The existence of a GitHub publish config and a mock update path are mutually exclusive. This is desired behavior. This conflict would only happen if someone were to pass --mock-updates and supply a GITHUB_REPOSITORY value, which is not a sane, normal, or expected use of the packaging script.
|
|
||
| function isWithinRoot(filePath: string): boolean { | ||
| try { | ||
| return !relative(realpathSync(root), realpathSync(filePath)).startsWith("."); |
There was a problem hiding this comment.
Path containment check incorrectly blocks dotfiles
Low Severity
The isWithinRoot check uses startsWith(".") on the relative() result, which rejects both .. parent-traversal paths and legitimate dotfiles at the root level (e.g., .gitkeep). A file like root/.something produces a relative path of ".something" which starts with "." and gets rejected. The check needs startsWith("..") instead to only block directory traversal while allowing dotfiles.
There was a problem hiding this comment.
The update server does not make use of dotfiles. This should be fine.
| provider: "generic", | ||
| url: `http://localhost:${process.env.T3CODE_DESKTOP_MOCK_UPDATE_SERVER_PORT ?? 3000}`, | ||
| }); | ||
| } |
There was a problem hiding this comment.
Truthy env check enables mock updates with "false"
Medium Severity
The runtime check process.env.T3CODE_DESKTOP_MOCK_UPDATES is a truthy check, so setting it to "false" or "0" still enables mock updates, redirecting the auto-updater to a localhost server that likely isn't running. This silently breaks update checks. The codebase already uses strict comparison for similar env vars (e.g., T3CODE_DISABLE_AUTO_UPDATE === "1"), and the build-time counterpart uses Config.boolean which correctly parses "false" as false.
There was a problem hiding this comment.
This is expected behavior. Mock updates are opt-in, so passing T3CODE_DESKTOP_MOCK_UPDATES=false is not a sane, normal, or expected use of the packaging script.


What Changed
cc @juliusmarminge
This adds a simple mock update server to our setup. There are several ways to use it, docs can be added if desired.
Here are the basics:
bun run start:mock-update-serverstarts the mock update server. By default, it serves onlocalhost:3000and out of./release-mockat the project root. Both are configurable.build-desktop-artifact.tshas two more options: (a) wether or not to build with mock updates, and (b) if so, which port to use. These options control two things: (c) wether or not to output to./release-mockover./release(the default) and (d) the manifest URL built into the built Electron app.When used normally, this functionality should work fine. However, users should be aware of the manifest URL's they cause to be built into the app and/or use runtime options to ensure they spin up the mock update server on the right port. Additionally, app artifacts must be signed for a full end-to-end update test to work.
This also includes a minor fix to our update state machine by adding an "in flight" status.
Why
This will help us when testing the update mechanisms.
Adding the "in flight" status also makes our state machine more correct.
UI Changes
N/A
Checklist
I included before/after screenshots for any UI changesI included a video for animation/interaction changesNote
Add mock update server for local desktop auto-update testing
release-mock/on a configurable localhost port.--mock-updatesand--mock-update-server-portflags to scripts/build-desktop-artifact.ts, directing build output torelease-mock/and configuring the generic update provider to point at the local server.T3CODE_DESKTOP_MOCK_UPDATESis set, the app'sautoUpdaterfeed URL is pointed at the local mock server instead of GitHub.updateInstallInFlight) in apps/desktop/src/main.ts so that errors duringquitAndInstallare surfaced as install failures rather than generic updater errors.shouldToastDesktopUpdateActionResultin apps/web/src/components/desktopUpdate.logic.ts to only show a toast when there is an actionable error, not on every accepted-but-incomplete result.Macroscope summarized 907c8d9.
Note
Medium Risk
Touches desktop auto-update install/error handling and build-time publish configuration; misconfiguration could break update flows or point builds at the wrong feed URL.
Overview
Adds a Bun-based local mock update server (
scripts/mock-update-server.ts) plus astart:mock-update-serverscript, and ignores the newrelease-mock/artifact directory.Extends the desktop artifact build pipeline (
build-desktop-artifact.ts) with--mock-updates/--mock-update-server-port(and env equivalents) to output torelease-mock/and embed a localgenericpublish/feed URL for update testing.Updates the Electron updater runtime to optionally use the mock feed (
T3CODE_DESKTOP_MOCK_UPDATES), improves install flow tracking viaupdateInstallInFlight(treatingquitAndInstall()as async and handling install-time updater errors), and tightens web UI toast logic to only notify when an actionable update error message exists.Written by Cursor Bugbot for commit 907c8d9. This will update automatically on new commits. Configure here.