Skip to content

Add scrollback recovery script for the test-pollution incident#35

Merged
buggerman merged 2 commits intomainfrom
scrollback-recovery-script
Apr 26, 2026
Merged

Add scrollback recovery script for the test-pollution incident#35
buggerman merged 2 commits intomainfrom
scrollback-recovery-script

Conversation

@buggerman
Copy link
Copy Markdown
Owner

Summary

  • Companion to Make ServerStore instance-based so tests can't poison production servers.json #34. The ServerStore-injection PR stopped further damage to servers.json, but it doesn't help users whose real chat history is now stranded under orphan UUID directories in ~/Library/Application Support/Brygga/scrollback/.
  • New Scripts/recover-scrollback.sh walks the disk, lists orphan scrollback dirs sorted by recency, and prints exact mv commands the user can copy after re-adding their server. Read-only by design — never moves or deletes anything itself.
  • Filters out empty dirs and collapses pure test-fixture noise (_test, alice, __server__ only) into a single summary line so the user's real chat history stays visible.

Changes

  • Scripts/recover-scrollback.sh — new file, executable. ~170 lines of bash + one-liner Python embed for JSON parsing (avoids jq dependency since python3 ships with macOS).
    • Section 1 prints active server UUIDs from servers.json.
    • Section 2 prints networks discovered in ~/Library/Logs/Brygga/ (the user's real network names, intact because DiskLogger keys by network not UUID).
    • Section 3 lists orphan scrollback dirs with MOST RECENT / FILES / FIRST 10 CHANNELS, sorted newest-first. Empty dirs and pure-test-fixture orphans are excluded; test pollution is summarized as a count.
    • Section 4 walks the user through the 5-step recovery procedure with concrete commands.

Test plan

  • swift build / swift test — N/A, docs/script only (no source code).
  • swiftformat --lint . — N/A, no Swift changed.
  • Manual:
    • ./Scripts/recover-scrollback.sh runs against my real scrollback directory and surfaces 4 real orphan dirs (Libera sessions) above 143 hidden test-fixture orphans.
    • Output identifies channel filenames correctly even with the space in Application Support (initial bug — find | xargs was word-splitting; fixed with -print0).
    • No write/delete operations performed; verified by inspection.
    • On a machine with no orphans, prints the "None found" branch.

Risk / rollback

  • Script is read-only by design — it never invokes mv, rm, or any other mutation. Only prints commands.
  • Bundled in Scripts/ alongside build-app.sh. Not built into the app, not run by CI, not invoked at app launch.
  • Revert: this single commit. Removing the script has no impact on the running app.

Follow-up (separate PR)

Same injection treatment for ScrollbackStore.shared and ScrollbackIndex.shared so IRCSessionTests stops creating fresh orphan dirs on every swift test run. Today, every test pass adds ~30 new orphans (visible at the top of the recovery script's hidden-summary count). Lower priority than the ServerStore fix because the impact is "more dirs accumulate" not "user data overwritten", but worth fixing for hygiene.

@buggerman buggerman merged commit 52f55e1 into main Apr 26, 2026
1 check passed
@buggerman buggerman deleted the scrollback-recovery-script branch April 26, 2026 21:28
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