Skip to content

Fix layout edge cases and load less work - #10

Merged
vpetersson-bot merged 1 commit into
masterfrom
layout-performance
Nov 18, 2026
Merged

vpetersson-bot merged 1 commit into
masterfrom
layout-performance

Conversation

@vpetersson-bot

Copy link
Copy Markdown
Collaborator

Fixes the layout-maths and performance findings from the code review. Each BlotterKit fix comes with a regression test.

Layout

  • HourFit clipped late events. It shrank the hour height so a late event would fit, then moved the start earlier to fill the space below midnight, which pushed that event off the bottom. Reproduced: a 15-minute event at 23:30–23:54 in a 528pt grid overflowed by 2–17pt. The start now moves only as far as every event still fits, and the rest stays empty below midnight. When no hour height can fit the events, the whole day is shown. Degenerate inputs (a 24...24 working range, infinite height) now give finite results. Tests cover 23:30, 23:36, 23:45 and 23:54, and the degenerate cases.
  • Negative event widths. horizontalExtent returned negative widths when the gaps were wider than the column, at width 0 during transitions or with many overlapping events. It now clamps. DayColumn passes maximumColumns (one per 12pt), so heavy overlap shares columns instead of producing 0–1pt slivers. A test sweeps small widths and column counts.
  • All-day row vs day titles. PaneLayout split the full height between all-day and timed events, but the week view also reserves 32pt for day titles. In a short calendar the all-day row took everything, and its "+N more" line was clipped. The split now subtracts the title height. Tested.
  • Week slide direction. Going forward then back made both weeks slide from the same side, because the outgoing week keeps the transition from its last render. CalendarState.navigate(to:) now commits the direction first. When the direction flips, the week changes on the next run loop pass.

Performance

  • Debounced reloads. EKEventStoreChanged now debounces for 0.3s before the full reload. iCloud and CalDAV syncs post bursts of these notifications.
  • Loaded range. Events used to be loaded for everything between today and the shown week, so paging 10 weeks back fetched 10 weeks on every step. Now only the visible week and today are loaded, as separate ranges, and events in both are de-duplicated.
  • Arranging the week. Schedule.arrange runs once per update instead of inside the GeometryReader.

🤖 Generated with Claude Code

Layout:
- HourFit no longer clips a short event late in the evening: after
  shrinking the hours to fit it, it only shows earlier hours as far as
  every event still fits, and shows the whole day when nothing else
  works. Degenerate inputs (an empty or infinite range) stay finite.
- Event extents are never negative, and a day shows at most one column
  per 12 points, so heavy overlap does not produce invalid frames.
- The all-day and timed split leaves room for the day titles, so in a
  short calendar the all-day row no longer pushes content off the
  bottom.
- Reversing direction between weeks slides both weeks the same way:
  the direction is committed before the week changes.

Performance:
- Bursts of calendar change notifications reload once, after 0.3 s.
- Events are loaded for the visible week and today only, not every
  week in between.
- The week is arranged once per update instead of inside the geometry
  reader.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vpetersson-bot
vpetersson-bot merged commit d295121 into master Nov 18, 2026
2 checks passed
@vpetersson-bot
vpetersson-bot deleted the layout-performance branch November 18, 2026 19:40
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