Skip to content

Load no chat's log when a window drops its subscriptions - #545

Merged
quanticstudios merged 1 commit into
mainfrom
boot-flake
Nov 23, 2026
Merged

quanticstudios merged 1 commit into
mainfrom
boot-flake

Conversation

@quanticstudios

Copy link
Copy Markdown
Owner

TestChatBootLoadsNothing failed on windows-test (daemon-ah) about every other run since v0.3.5. TempDir cleanup could not delete some other chat's events.jsonl because it was still open. The cause was a real daemon bug, and it happened on every OS. Windows was just the only one that refused to delete an open file.

Cause

#537 made dropSubs (a window going) and chatUnsubscribe remove a subscriber with chat.do. do loads the chat first, so when the window closed, the daemon opened the log of every restored chat (199 of them in this test) to delete a map key. Those logs stayed open until shutdown. dropSubs runs in the client's reader goroutine, and Serve doesn't wait for that goroutine, so it raced the test's stop(). Any log it opened after its chat closed was never closed.

Changes

  • dropSubs and chatUnsubscribe use chat.run, which removes the subscriber without loading the log.
  • A chat's close cleanup sets loaded, so a do that lands between the cleanup and close(c.quit) can't reopen the log.
  • TestChatBootLoadsNothing now drops a window's subscriptions, unsubscribes one chat, stops the daemon, and checks after each step that no other chat's events.jsonl exists. Without the fix it fails on Linux, listing all 199 other chats.

Verification

  • go test ./internal/daemon -run 'TestChatBootLoadsNothing$' -count=50 passes. Before the fix it failed on every run.
  • go test -race on that test plus the subscribe, unsubscribe and archive tests, -count=20, passes.
  • gofmt, go vet ./... and go test ./... pass.

dropSubs and chatUnsubscribe removed a sink with chat.do, which loads the
chat first, so a window going opened every restored chat's events.jsonl.
On Windows the logs still open when the test's TempDir cleanup ran made
TestChatBootLoadsNothing fail about every other run. Both now use run.

A closed chat also marks itself loaded, so a do queued behind its close
cannot reopen the log.

TestChatBootLoadsNothing now drops a window's subscriptions and stops the
daemon, and checks no other chat's log opened, on every OS.
@quanticstudios
quanticstudios merged commit b336230 into main Nov 23, 2026
22 checks passed
@quanticstudios
quanticstudios deleted the boot-flake branch November 23, 2026 21:55
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