plan 0016 (2/3): the two-screen sync + rename wizard - #382
Closed
TheAngryRaven wants to merge 5 commits into
Closed
Conversation
addTrack/addCourse deliberately only ever ADD: they backfill a short name only when there isn't one, and never remove a course. That is right for "add this one thing" and wrong for a sync, which has already worked out what the track must look like for both sides to agree — anything less than a wholesale write leaves them disagreeing, and the next connect re-offers the same track. Courses are marked user-defined on the way in because saveUserTracks drops any that aren't, which would silently discard a course walked on the device. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESkRRtF4vRrANPL6huSgmD
deviceSyncRunner walks the operation list with injected executors, so the risky part is testable without a radio or a browser. It keeps going after a failure, but a failed track ABANDONS ITS OWN remaining operations — once the new file didn't write, deleting the old one destroys the only copy, which for a course walked in the field is unrecoverable. Other tracks still run: one track failing is no reason to leave the other nine untouched, and the plan orders each track's work contiguously so that split is clean. deviceSyncFetch owns reading both folders. The Device → Tracks tab now uses it instead of its own copy of the loop, so there is exactly one place that applies deviceTrackFileFrom's identity rule — a second copy that keyed files by filename would quietly reintroduce the bug where an imported track never matches the file it came from. Behaviour is unchanged: same order, same per-file error swallowing, same sprint-capability skip. buildDeviceSyncSnapshot also collects the short names of tracks the plan is NOT touching, so a rename can't be pointed at an already-synced track's file. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESkRRtF4vRrANPL6huSgmD
Two screens, the selection, and the validation that decides whether "Save & import" can fire — all as pure functions, because the test environment is node with no testing-library and logic left in a component is logic nobody checks. Three rules worth naming: - Unchecking a row stops it being validated. Otherwise one track you don't want to name blocks the entire sync with no way past it. - A course name follows its track's name until the user types in it, and going Back to rename the track re-points every course that is still following. A name they typed themselves is never overwritten. - canSave re-checks the TRACK screen, not just the course screen. Going forward and then back and clearing a track name must not leave Save live. Duplicate short names are caught across the whole selection and against tracks outside the plan, per kind — two tracks sharing a short name are one file on the device, so the second write silently overwrites the first, while the same short name in the circuit and sprint folders is two legitimate files. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESkRRtF4vRrANPL6huSgmD
Screen 1 names the tracks: a checkbox per row, an upload/download bubble, a sprint bubble, and — only on rows the logger named itself — a full-name box with a narrower short-name box beside it that fills in as you type. Screen 2 does the same for course names with a circuit/sprint bubble. Back/Next, then Back and "Save & import". Rows the sync refuses to attempt are listed underneath with the reason, rather than silently missing. The component holds one useState and the markup; every decision comes from the pure modules. Problem and skip-reason strings are spelled out in switch statements because the i18n keys are literal-union typed — a computed key won't typecheck, which is the point. 37 new keys across all seven locales, matching each language's existing terminology for track and course. The walked-on date renders in UTC: the name encodes the GPS clock, so a local-time render would show the wrong minute. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESkRRtF4vRrANPL6huSgmD
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESkRRtF4vRrANPL6huSgmD
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
lapwing | 7af0c31 | Commit Preview URL Branch Preview URL |
Aug 05 2026, 06:27 AM |
Coverage SummaryLines: 58.23% (7458/12806) · Statements: 57.37% · Functions: 55.06% · Branches: 55.13% Per-file coverage
|
This was referenced Aug 5, 2026
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
Second of three (plan 0016). Targets #381, not
BETA, so the diff shows only this PR's work — retarget once #381 lands.The wizard itself:
Gating is as you specified: track names always required (circuit and sprint — a venue is permanent), course names required for circuit only (a sprint venue re-lays its course every event, so the walked date is genuinely the useful label).
New modules
deviceSyncWizard.tsdeviceSyncRunner.tsdeviceSyncFetch.tsbuildDeviceSyncSnapshotDeviceSyncWizard.tsxuseStateand the markuptrackStorage.saveSyncedTrackis new becauseaddTrack/addCourseonly ever add — they backfill a short name only when absent and never remove a course. A partial write leaves the two sides disagreeing, which is the loop this is trying to end.Failure handling
runSyncOperationskeeps going after a failure, but a failed track abandons its own remaining operations — once the new file didn't write, deleting the old one destroys the only copy, which for a course walked in the field is unrecoverable. Other tracks still run; one track failing is no reason to leave the other nine untouched.Related Issues
Stacked on #381 (plan 0016 1/3).
Type of Change
Checklist
bun run lintpassesbun run typecheckpassesbun run test:runpasses (2705 tests, 189 files — +42 here)bun run buildsucceedsCHANGELOG.mdNotes for Reviewers
The wizard has no launcher yet — that's 3/3. You asked for it to be connect-only, so PR 3 wires it to the connection event alongside the firmware prompt. The
DeviceSyncPromptyes/no lives here so 3/3 is purely "when does this fire".Two things worth a look:
DeviceTracksTablost ~35 lines — its device-read loop now calls the sharedfetchDeviceTrackFiles. Behaviour is identical (same order, same per-file error swallowing, same sprint-capability skip); the reason to share it is that a second copy keying files by filename would quietly reintroduce the bug 1/3 fixes. The tab's UI is otherwise untouched, as you asked.initialCourseDraft.The i18n is hand-written across 6 languages (no API key for
i18n:seed), matching each file's existing terms for track/course. Japanese is the one I'd second-guess: existing keys use コース for both track and course, so I used トラック for track in the new strings to keep the two boxes distinguishable side by side.Generated by Claude Code