Skip to content

Sleep: stop the stage strip clipping into a row of circles (#36)#38

Merged
ryanbr merged 1 commit into
mainfrom
sleep-stage-lanes
Jul 7, 2026
Merged

Sleep: stop the stage strip clipping into a row of circles (#36)#38
ryanbr merged 1 commit into
mainfrom
sleep-stage-lanes

Conversation

@ryanbr

@ryanbr ryanbr commented Jul 7, 2026

Copy link
Copy Markdown
Owner

What #36 reported

On Android the sleep-hero stage graphic renders as a single row of disconnected circles (WHOOP 5.0, on-device staging) instead of a continuous stage strip.

Root cause

HypnogramWithAxis floored each segment to a min width (minSegW = h, 34dp) and advanced x by that floored width. Two things then break on a fragmented night (a WHOOP 5.0 metadata-only sync produces many short approximate segments):

  1. Overflow / clipping — the floored widths sum past the canvas, so x runs off-screen and the tail clips. Only the first ~w/h segments (≈ the ~13 circles in the screenshot) stay visible; the rest of the night is drawn off-canvas.
  2. Circles — each segment was drawn as an h-wide round-capped line, so any sub-h segment renders as a full h-diameter circle rather than a block.

Together: a disconnected row of circles on one line.

The fix (minimal — keeps the single strip)

  • Floor every segment, then if the floored total overflows the canvas, scale them all to fit — the strip stays a continuous bar for the whole night instead of clipping the tail.
  • Draw rounded rects (not round-capped lines) advancing by the same width they're drawn, so x can never exceed the canvas and a narrow segment reads as a thin block, not a circle.
  • Proportions of normal-width segments are unchanged; the onset · midpoint · wake axis is untouched.

~20 lines in one function, no analytics change, no new composables.

Notes

  • This is a genuinely data-poor night ("No movement detail", metadata-only sync), so the stages stay approximate — the strip is now correct and legible, not more precise.
  • Chose the minimal single-strip fix over porting the iOS multi-lane (per-stage rows) layout; the multi-lane remains a possible later enhancement if we want "phases on separate lines."
  • Android-only; compiles clean (compileFullReleaseKotlin).

Fixes #36.

The Android sleep-hero stage strip (HypnogramWithAxis) floored each segment to a
min width (one strip-height, 34dp) and advanced x by that FLOORED width. On a
fragmented on-device night (e.g. a WHOOP 5.0 metadata-only sync with many short
approximate segments) the floored widths sum past the canvas, so the tail runs
off-screen and clips — only the first ~w/h segments stay visible. Drawn with a
h-wide round-capped line, each sub-h segment renders as a full circle, so the
night reads as a disconnected row of circles on a single line (issue #36).

Fix, keeping the single strip: floor every segment, then if the floored total
overflows the canvas, scale them ALL to fit so the strip is a continuous bar for
the whole night. Draw rounded RECTS advancing by the same width they're drawn, so
x can never exceed the canvas and narrow segments read as thin blocks, not
circles. Proportions of normal-width segments are unchanged.

Fixes #36.
@ryanbr ryanbr force-pushed the sleep-stage-lanes branch from 5e6444a to a5e652f Compare July 7, 2026 12:52
@ryanbr ryanbr changed the title Sleep: multi-lane stage timeline on Android (#36) Sleep: stop the stage strip clipping into a row of circles (#36) Jul 7, 2026
@ryanbr ryanbr merged commit b9ede2e into main Jul 7, 2026
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.

Sleep screen graphic not displayed correctly

1 participant