Repository navigation
Guard against overlapping and abandoned switches (#8) - #12
Merged
Merged
Conversation
A second Connect during the credential check could start another switch that overwrote the first one's job file. start() now claims the switch before its first await and refuses a second one, and the panel disables Connect while a card is checking credentials. A switch that timed out left switch-status.json as running, which blocked every later switch until Studio reloaded. A running status older than the timeout now counts as stale and is discarded, and a timeout removes its own status file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sorenbcoding
added a commit
that referenced
this pull request
Nov 19, 2026
Guard against overlapping and abandoned switches (#8)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #8. Found in an external code review.
What changes
Switcher.start()claims the switch (current) before its firstawaitand refuses a secondstart()with "A tenant switch is already running". Every exit before the runner starts releases the claim (abort()).src/switchState.tsisActiveStatus()rule says arunningstatus older than the 5-minute timeout is stale.preflight(),start()andresumePending()sharerunningStatus(), which discards a stale file with a log line. A timeout also removes its own job's status file.Unreleased.Cross-process locking (two Studio windows, or Studio plus the desktop app) is tracked separately in #11.
Testing
npm run typecheck,npm run buildand the brand check pass.npm test: 48 passed. The newtest/switchState.test.tscovers recent, stale, finished, missing and unreadable statuses.Switcheritself has no unit tests (it needs the vscode API). The guard logic is checked by reading it through. A manual check in Studio comes with the 0.4.2 test packages.🤖 Generated with Claude Code