Skip to content

Pin the detached window's close-reentry latch too - #492

Merged
erikdarlingdata merged 1 commit into
devfrom
test-detached-close-reentry
Sep 3, 2026
Merged

Pin the detached window's close-reentry latch too#492
erikdarlingdata merged 1 commit into
devfrom
test-detached-close-reentry

Conversation

@erikdarlingdata

Copy link
Copy Markdown
Owner

#488 closed a reentrancy gap in two places — MainWindow.OnClosing and DetachedWindowHelper each latch while their unsaved-work question is still up, because _closeConfirmed / closeConfirmed only latch after a yes and so do nothing about a second close arriving mid-walk.

Only the MainWindow half was pinned. I deleted the detached closeGuardPending check outright and the suite stayed green:

--- latch deleted
   WindowCloseReentryTests  Total: 1, Failed: 0

Two separate guards with separate state, one test. That is how a latch gets tidied away by someone who reasonably believes the tests are watching it.

This adds the twin, same shape as the existing one but against the detached window: close once and the question comes up, close again and no second prompt stacks, dismiss it and the window stays with the latch cleared, close once more and a fresh question starts. That last step matters as much as the others — a latch that never clears makes the X dead for the rest of the window's life.

Proved red first. With the latch removed:

   WindowCloseReentryTests.ASecondCloseOfADetachedWindowDoesNotStackASecondPrompt [FAIL]
   Total: 2, Failed: 1

Restored: 445 passed, 0 failed, 2 skipped.

Tests only — no production change.

🤖 Generated with Claude Code

https://claude.ai/code/session_016a1AnKAHwcALrwdYVVrpgR

#488 gave DetachedWindowHelper the same walk-in-progress latch MainWindow.OnClosing
got, for the same gap, but only the MainWindow half was pinned. Deleting the detached
closeGuardPending check outright left the suite green — which is how a latch gets
tidied away by someone who reasonably believes the tests are watching it.

Same shape as the existing test, against the detached window: close once and the
question comes up, close again and no second prompt stacks, dismiss it and the window
stays with the latch cleared, close once more and a fresh question starts. Proved red
against the latch's absence before it went green.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016a1AnKAHwcALrwdYVVrpgR
@claude

claude Bot commented Sep 3, 2026

Copy link
Copy Markdown

Reviewed. Test-only change, no production code touched — verified the latch it's pinning (closeGuardPending in DetachedWindowHelper.cs) is already in place and matches the guard/reissue flow the new test exercises. The new test mirrors the existing MainWindow reentrancy test's shape correctly: dirty session → detach → close → second close is swallowed (single owned window) → dismiss clears the latch → next close starts a fresh prompt. Cleanup in both finally blocks (close leftover prompt, mark session clean, close window) is ordered correctly so it won't leak state into other tests. No correctness, untrusted-input, security, or repo-convention issues found.

@erikdarlingdata
erikdarlingdata merged commit 05cc205 into dev Sep 3, 2026
3 checks passed
@erikdarlingdata
erikdarlingdata deleted the test-detached-close-reentry branch September 3, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant