Repository navigation
feat(instance): run one copy per session - #18
Merged
Merged
Conversation
A second launch starts a second copy that competes for the COM port and the history file. The plan lets only one copy run: a second launch brings the open window to the front and exits, or says the first copy is not responding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A second SemiSpec copy would open the same COM port and the same history file, which takes one writer. SingleInstance claims a Local\ named mutex; createdNew decides primary or secondary, and the OS frees the name when the last handle closes, also after a crash. Two auto-reset named events carry the ask and the answer: the primary answers only after its UI scheduler ran the activation, and the secondary resets the answer before it asks, so a late answer cannot count. Release unregisters the wait and closes every handle, so a launch during a close claims the name anew. Program and App wire it in the next tasks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A second launch of SemiSpec still built the container and opened a window, a port and a store next to the running copy. Program.Main now claims the single-instance name right after the logger exists. A secondary allows the foreground hand-over, asks the running copy to activate its window, retries once, and exits before "SemiSpec starting". With no answer it logs one warning, shows the SingleInstanceNotResponding text in a MessageBoxW box and exits with 1. The three user32 calls live in NativeMethods as DllImport declarations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A running copy had a claim but nothing listened for a second launch, and the claim lived until the process exited, so a relaunch during the close would activate a window about to vanish. App.Run now takes the claim and starts Listen in AfterSetup, where the UI dispatcher exists; each ask restores a minimised main window through ShowWindow and activates it. The first accepted Closing releases the claim before the stop chain starts, so a launch from then on starts a new copy. Configure carries the claim, so headless tests cover the release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A claim the OS refuses had no test; an event holding the mutex name now shows it runs as primary with one Warning. The plan records the acceptance results: 1062 of 1062 tests pass, 17 in Area Instance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The docs still allowed a second running copy and said two copies share the history file. They now describe the claim, the second launch, the listener and the release at the close, the new text key and the Instance test area. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A secondary kept its mutex and events open while the not-responding box was up. The claim is handle existence, so killing the hung copy and starting again, as the message says, met a held name and failed again. A launch that got no answer also gave up after two asks, too soon for a cold start of the first copy. SecondLaunch.Run now closes its handles after every unanswered ask and claims the name again: a free name lets it continue as the primary, a held one gets another ask, for up to 10 s. The message shows only after that budget, with every handle closed. The tests no longer drive a TestScheduler from two threads, and the close test starts the listener as the app does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A copy started while the previous copy closes meets a history file that copy still holds for up to its 5 s close limit. The open failed with SQLITE_BUSY and the store stayed off for the whole run. StoreOpening retries an open that fails with SQLITE_BUSY or SQLITE_LOCKED every 0.5 s for 6 s from the start of the open, then fails as before. A held file is never set aside or deleted. The stop's drain token ends the retries early. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The docs described one retry, a message after about 4 s and a store open that fails on a held file. They now describe the re-claim rounds, the 10 s budget, the handles closed before the message, the busy-open retry and why the claim is released before the stop. The plan marks the smoke steps as not run and adds a cold-start step. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
A second launch started a second copy that competed for the COM port and the history file. Now only one copy runs per Windows session.
Verified: 1067 tests (1045 before), the instance tests 5 runs in a row, Release build 0 warnings, format and terse clean. Reviewed by a second model; the fixes for its findings are in the last three commits. Left for the operator PC: the 7 manual checks in the plan (window to the front, three launches, hung copy, close and relaunch, cold start after reboot).
🤖 Generated with Claude Code