Skip to content

refactor(web): derive week paging from the owning page set - #5439

Merged
tyler-dane merged 1 commit into
mainfrom
claude/kind-dirac-y4g2mg
Dec 5, 2026
Merged

tyler-dane merged 1 commit into
mainfrom
claude/kind-dirac-y4g2mg

Conversation

@tyler-dane

Copy link
Copy Markdown
Contributor

What and why

Scheduled tech-debt sweep, .agents/skills/tech-debt-sweep/SKILL.md. One
finding, in the admissible "drifted copy of a shared definition" class.

computeVisibleWindowOffset owns which offsets within the calendar week the
week view can land on: min(floor(anchorIndex / count) * count, 7 - count)
over the seven anchor days, which is {0, 3, 4} at three columns, {0, 2} at
five and {0, 1} at six. #5437's new pagedWindowStart restated that set as a
condition rather than reading it, as
offset % visibleDayCount !== 0 && offset !== lastPage meaning "not a page".
That admits every multiple of the column count, including the ones past
lastPage, which are not pages; the forward branch then clamps those with
Math.min(offset + visibleDayCount, lastPage) and returns an offset lower than
the one it started from, so paging forward moves the view backwards in time.

Reachable through shiftViewByDay, which sets the anchor to
start.add(days, "day") with no bound and is reached both from the Shift+J /
Shift+K day-shift shortcuts in useWeekShortcutOwner and from onCrossed, the
Shift+Arrow nudge that carries an event across the window edge. Six day-shifts
forward from Sunday on a six-column viewport puts the anchor at offset 6;
pressing J then moved the window from Sat..Thu back to Mon..Sat, five days
backwards within the same week. Enumerated over all seven widths and all seven
offsets, five pairs regress: count 2 at offset 6 (-1d), count 3 at offset 6
(-2d), count 4 at offset 4 (-1d), count 5 at offset 5 (-3d) and count 6 at
offset 6 (-5d). Before #5437 pageWindow was
start.add(direction * visibleDayCount, "day") and none of them could happen,
so this is new. #5437's four pagedWindowStart tests pin page offsets and one
hand-shifted offset that takes the correct branch; none of the five covered.

Closed by derivation rather than by correcting the condition, since the owning
function is importable here. A private weekPageOffsets enumerates
computeVisibleWindowOffset over the seven anchor days and dedupes, and
pagedWindowStart looks its offset up in that list and steps to the
neighbouring page, crossing weeks at the ends. No second copy of the page
arithmetic is left to drift: change the owning formula and paging follows it.

Behavior is identical on every page offset, checked against the previous
implementation for all seven widths. The only change is that the five non-page
offsets now take the hand-shifted branch and move forward by the column count,
which is what the function's own doc comment already said they should do, so
this is a defect against the stated contract rather than a product decision.
Two tests pin it: one asserts paging is monotonic across all 49
width-and-offset pairs, and one pins the step between pages against
computeVisibleWindowOffset's own image. The monotonic test fails on the
pre-change implementation with exactly the five pairs above.

Churn guard: no refactor commit has touched week-window.util.ts or
useWeek.ts in 30 days; their history is #5283, #5405 and #5437, a chore and
two fixes. The ledger's only prior entry on this file is the 2026-12-01
weekViewDateString entry (#5405), a different function, not re-opened.

Examined and deliberately left alone, recorded in judged-fine.md so the next
sweep does not redo it: #5437's change to computeVisibleWindowOffset itself
(centred-and-clamped to floor-paged) is the behavior change that PR exists to
make, with the e2e expectations moved with it and anchorDateForWindowOffset
deleted rather than orphaned; its deletion of the old round-trip test was
correct, the gap it left being the paging direction this PR closes; #5436 is the
previous sweep's own output; #5427 and #5438 are Dependabot bumps, with the
msw major smoke-checked over the whole Week view rather than taken on trust.

The ledger also records a pattern worth a person's attention: both of the last
two findings are the same shape, a rule owned in one place and restated as a
literal condition somewhere that has to agree with it, and both arrived inside a
same-day fix to a surface under active iteration rather than in old code.

Verify

bun run verify --strict

Summary
Selected packages: web
Checks run: test:web, type-check, lint, knip, test:a11y, test:e2e
Checks skipped: (none)

✓ All checks passed
VERDICT: PASS

No Baseline against origin/main: block: nothing failed, so there are no
PRE-EXISTING or FLAKY lists to paste.


Generated by Claude Code

`pagedWindowStart` restated which offsets `computeVisibleWindowOffset`
can produce, as `offset % visibleDayCount !== 0 && offset !== lastPage`.
That admits multiples of the column count past `lastPage`, which are not
pages, and the forward branch then clamps them with
`Math.min(offset + visibleDayCount, lastPage)` and lands earlier in the
week than it started. On five of the seven column widths, "next week"
moved the view backwards.

Derive the page set from `computeVisibleWindowOffset` instead and step
between neighbours, so there is no second copy of the page arithmetic to
drift. Behavior is unchanged on every page offset.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HmwVQGtuqunekRQpZAP4dB
@tyler-dane
tyler-dane enabled auto-merge December 5, 2026 11:20
@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Boot bundle: 608.7 KB gzip (+0.0 KB vs main)

@tyler-dane
tyler-dane added this pull request to the merge queue Dec 5, 2026
Merged via the queue into main with commit bd568d3 Dec 5, 2026
23 checks passed
@tyler-dane
tyler-dane deleted the claude/kind-dirac-y4g2mg branch December 5, 2026 11:35
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.

2 participants