Skip to content

Feat: Allow optional golds and personal_best in split files#61

Merged
alexozer merged 10 commits intoalexozer:mainfrom
Vxwilson:feat/init-split-file
Oct 17, 2025
Merged

Feat: Allow optional golds and personal_best in split files#61
alexozer merged 10 commits intoalexozer:mainfrom
Vxwilson:feat/init-split-file

Conversation

@Vxwilson
Copy link
Copy Markdown
Contributor

@Vxwilson Vxwilson commented Oct 12, 2025

Some changes in split_file and timer that should simplify new split file creation.

Closes #60 and #56.

Problem

Solution

Make golds and personal_best fields in the JSON optional, allowing users to create a minimal file with just a title, category, and split_names. The application will now handle missing fields on first load without crashing by initializing with blank values.

Details

  • split_file.rs:
    • Used #[serde(default)] to make golds and personal_best optional during deserialization.
    • Populate above fields with None values if missing.
  • timer.rs:
    • save_personal_best handles case where no previous PB exists.

Simple Test

Example split JSON with minimal config:

{
  "title": "Silksong",
  "category": "Any% (BlueSR Route)",
  "attempts": 0,
  "completed": 0,
  "split_names": [
    "Red",
    "Orange",
    "Yellow",
    "Green"
  ]
}

Steps:

  1. Run Flitter with above JSON. All segments and splits should appear as -.
  2. Start a run up until the Orange segment, then press Backspace to reset and save. The JSON should update to store the gold splits.
  3. Start another run and finish all segments. After pressing Backspace, the JSON should update accordingly.

@Vxwilson Vxwilson marked this pull request as draft October 12, 2025 15:51
@Vxwilson
Copy link
Copy Markdown
Contributor Author

Have yet to update the JSON example file + readme; converted to draft for now.

@alexozer
Copy link
Copy Markdown
Owner

alexozer commented Oct 12, 2025

Thanks again! Would you mind updating the README to indicate that the personal best and gold JSON fields are now optional, as well?

EDIT: nvm, just saw your previous comment

@Vxwilson
Copy link
Copy Markdown
Contributor Author

Thanks again! Would you mind updating the README to indicate that the personal best and gold JSON fields are now optional, as well?

Welcome, this is also me learning to contribute!

The README is updated now; feel free to reword it as you see fit.

@Vxwilson Vxwilson marked this pull request as ready for review October 12, 2025 16:17
@alexozer
Copy link
Copy Markdown
Owner

@Vxwilson What would you think of wrapping the personal_best field of SplitFile in Optional rather than checking if attempt > 0 when needed? I suspect this may better enforce correctness over remembering where/when to check attempts. So when personal_best is Some, the last split would always be valid.

@Vxwilson
Copy link
Copy Markdown
Contributor Author

@alexozer I agree with your judgement there, wrapping it with Optional is cleaner and makes the code more robust against future changes. I've pushed up the changes, lmk if that looks right; appreciate your feedback!

While we are at it, what's your opinion on extending this approach to other fields? I could see an argument for making attempts/completed default to 0, and category default to an empty string. But those are relatively effortless for users to configure, so it shouldn't be a big issue.

@alexozer
Copy link
Copy Markdown
Owner

alexozer commented Oct 13, 2025 via email

@Vxwilson
Copy link
Copy Markdown
Contributor Author

Vxwilson commented Oct 16, 2025

@alexozer Done. No validation needed for this part (IMO) as the counter should self-correct as the user perform new runs.

This feature branch should be ready to merge now, thanks for being patient :)

More minor formatting corrections
@alexozer alexozer merged commit ef03999 into alexozer:main Oct 17, 2025
1 check passed
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.

PB attempt in JSON not updated when new PB is achieved.

2 participants