Inject ScrollbackStore and ScrollbackIndex so tests can't pollute scrollback either#36
Merged
Conversation
buggerman
added a commit
that referenced
this pull request
Apr 26, 2026
* Add scrollback recovery script for the test-pollution incident * Inject ScrollbackStore and ScrollbackIndex so tests can't pollute scrollback either (#36)
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.
Summary
servers.jsonoverwrites; this finishes the job by stoppingIRCSessionTestsandAppStateNavigationTestsfrom creating fresh orphan scrollback dirs and trickling test-fixture rows into the production FTS5 index on everyswift testrun.IRCSessionandAppStateacceptScrollbackStoreandScrollbackIndexvia init with no defaults. Production passes.shared(path unchanged). Tests pass tempdir-rooted instances.ScrollbackIndex.shared.searchfromContentViewis left alone — it's the production search read path, never hit by tests.Changes
Sources/BryggaCore/IRC/IRCSession.swift— addsprivate let scrollbackStoreandprivate let scrollbackIndex. Constructor becomesinit(server:connection:scrollbackStore:scrollbackIndex:). Routesrecord(_:in:),recordServer(_:),loadScrollbackIfNeeded(for:), andfinalizeChathistoryBatchthrough the injected instances. Stores are captured into local vars beforeTaskblocks to avoid strong-self capture.Sources/BryggaCore/Models/AppState.swift— addsscrollbackStoreandscrollbackIndexproperties. Constructor becomesinit(store:scrollbackStore:scrollbackIndex:).restoreFromStore's rehydrate task,closePrivateMessage's clear, andremoveServer's clear all go through the injected instances.addServer(...)plumbs them through to everyIRCSessionit constructs.Sources/Brygga/BryggaApp.swift—AppState(store: .shared)→AppState(store: .shared, scrollbackStore: .shared, scrollbackIndex: .shared).Tests/AppStateNavigationTests.swift— replacesmakeStore()withmakeDeps()returning a(ServerStore, ScrollbackStore, ScrollbackIndex)triple, all rooted under a unique tempdir. Updates all threeAppState(...)construction sites.Tests/IRCSessionTests.swift—makeSession(...)now constructs both stores per-call (tempdir +:memory:SQLite) and passes them toIRCSession.Test plan
swift build— passesswift test— 132 tests passswiftformat --lint .— cleanswift testno longer touches the prod scrollback paths:Risk / rollback
IRCSession.init(server:connection:)is removed.AppState.init(store:)is removed. Any external consumer passing only(server, connection)or only(store:)would need to update. Internal call sites all updated in this PR..sharedinstances keep prod behavior identical — same JSONL paths, same SQLite path, no migrations.Stacking note
Per the squash-merge stacked-PR rule for this repo: merge this PR first (lands both this and the recovery script onto
mainas one squashed commit), then close #35 — its content has already landed.