Skip to content

issue/fix: (#51) consolidate storage #56

Merged
vyrx-dev merged 5 commits into
masterfrom
fix/55-refactor-consolidate-storage
Jun 7, 2026
Merged

issue/fix: (#51) consolidate storage #56
vyrx-dev merged 5 commits into
masterfrom
fix/55-refactor-consolidate-storage

Conversation

@aaravmaloo

Copy link
Copy Markdown
Collaborator

Summary

Fixes #55.
Consolidated Toofan user data from 4 mixed-format files to 3 consistent JSON-based files:

  • config.txt + pb.txt -> config.json
  • results.txt -> results.jsonl
  • races.txt -> races.jsonl (same JSONL payload, extension/path corrected)

This removes custom string parsing, unifies persistence format, and keeps append-only logs efficient.

New data layout

~/.config/toofan/
├── config.json
├── results.jsonl
└── races.jsonl

@aaravmaloo aaravmaloo self-assigned this May 12, 2026
@aaravmaloo aaravmaloo added the in-review tag indicating the PR is in review label May 12, 2026
@aaravmaloo aaravmaloo linked an issue May 12, 2026 that may be closed by this pull request
@vyrx-dev vyrx-dev requested a review from Copilot June 7, 2026 04:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements the storage refactor from mixed plain-text formats to a consistent JSON/JSONL-based layout under ~/.config/toofan/, including migration logic for existing users.

Changes:

  • Replaces pipe-delimited results.txt with JSONL results.jsonl and updates profile parsing accordingly.
  • Consolidates config.txt + pb.txt into a single config.json with new ConfigRecord/ResultRecord structures.
  • Adds first-run migration in internal/game/storage.go and updates internal documentation (AGENTS.md) to reflect the new formats.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
internal/tui/profile.go Reads results.jsonl and parses each line as JSON into a shared ResultRecord.
internal/game/storage.go Introduces JSON/JSONL persistence, config+PB consolidation, and migration/backup updates.
AGENTS.md Updates documentation to describe the new JSON/JSONL storage layout and migration behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/game/storage.go Outdated
Comment on lines +372 to +374
if err := os.Rename(oldRaces, newRaces); err != nil {
return
}
Comment thread internal/tui/profile.go
Comment on lines 46 to 55
configDir, err := os.UserConfigDir()
if err != nil {
return pd
}
dataDir := filepath.Join(configDir, "toofan")

f, err := os.Open(filepath.Join(dataDir, "results.txt"))
f, err := os.Open(filepath.Join(dataDir, "results.jsonl"))
if err != nil {
return pd
}
Comment thread internal/game/storage.go
vyrx-dev and others added 2 commits June 7, 2026 11:33
- migration now removes config.txt, pb.txt, results.txt, races.txt
  after successful conversion (also handles leftover case where
  new json files already exist from a prior run)
- backups use human-readable section format with .bak extension
- existing .txt and .jsonl backups are converted to .bak on startup
- restore handles both old and new backup formats via SplitBundle
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@vyrx-dev vyrx-dev merged commit a9945de into master Jun 7, 2026
1 check passed
@aaravmaloo aaravmaloo deleted the fix/55-refactor-consolidate-storage branch June 7, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in-review tag indicating the PR is in review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: consolidate storage to JSON format

3 participants