Skip to content

fix: timeline selections starting at offset 0#592

Open
sshane wants to merge 5 commits into
masterfrom
fix-drag-from-zero
Open

fix: timeline selections starting at offset 0#592
sshane wants to merge 5 commits into
masterfrom
fix-drag-from-zero

Conversation

@sshane
Copy link
Copy Markdown
Contributor

@sshane sshane commented Apr 30, 2026

Summary

Dragging a section on the timeline ruler from the very start (offset 0) was silently broken — the selection wouldn't render and any pre-existing loop would be cleared. Two falsy-zero bugs both rooted in treating `0` as "no value":

  • `TIMELINE_PUSH_SELECTION` reducer used `!action.start` to mean "no selection," which is also true when the user drags from second 0. That branch reset zoom to the full route and cleared the loop instead of creating the section.
  • `urlForState` dropped `start`/`end` from the URL when `start === 0` (`start && end && start > 0`), so even if the reducer had stored the right zoom, the URL forgot it on refresh.

Both replaced with explicit null checks. Updated the unit test that was asserting the buggy URL.

Test plan

  • Drag from second 0 on the route timeline → section renders, URL contains `/0/N`
  • Drag from second 5 → unchanged behavior
  • Refresh on `/dongleId/log_id/0/N` → loads the section
  • `pnpm lint` clean
  • `pnpm test` passes (30/30)

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 30, 2026

Welcome to connect! Make sure to:

  • read the contributing guidelines
  • mark your PR as a draft until it's ready to review
  • post the preview on Discord; feedback from users will speedup the PR review

deployed preview: https://592.connect-d5y.pages.dev

Dragging on the timeline ruler from the very start (offset 0) failed
to create a section. The same falsy-zero pattern affected click-route
URLs, where with the URL fix in place the click would otherwise
produce /log_id/0/N instead of the canonical /log_id.

- TIMELINE_PUSH_SELECTION reducer: replace !action.start with
  action.start == null so a drag at second 0 stops getting treated as
  "no selection" (which previously cleared zoom and the loop).
- urlForState: drop start/end only when not finite or when start ===
  end (was: dropped whenever start === 0).
- DriveListItem: dispatch null/null on click instead of (0, duration)
  so the URL stays /dongleId/log_id — refreshing on a still-uploading
  route picks up the latest duration instead of pinning the old end.
- updateTimeline: when start/end aren't finite, default the loop to
  (0, route.duration) by looking up the route in state.routes.
- Update the unit test that was asserting the buggy URL.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sshane sshane force-pushed the fix-drag-from-zero branch from be4d798 to a592d3d Compare April 30, 2026 12:40
@sshane sshane force-pushed the fix-drag-from-zero branch from 9f3e64d to fde5416 Compare May 4, 2026 23:00
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