repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

docs(plan): fix caldav plan — timezone-safe window test, synthetic band fixture, single-Rectangle band, drop .pragma trap

561c1566b7561c01284f432804593744188fcb88

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Changed files (1)

+31 / −16 text lines

Diff layout

quickshell/nuguland/docs/superpowers/plans/2026-06-28-caldav-calendar.md

Modified

+31 / −16 text lines

116116- [ ] **Step 3: Write the implementation**
118Create `quickshell/nuguland/caldav.js`:
118Create `quickshell/nuguland/caldav.js`. **Do NOT add a `.pragma library` line** — it makes the file invalid node (`SyntaxError` on the leading dot). The `typeof module` guard at the bottom keeps the same file valid as a QML `.js` import. First line is the comment below:
120120```js
121.pragma library
123121// --- XML entity decode (named subset + numeric) ---
124122function decodeXmlEntities(s) {
125123 return String(s == null ? "" : s).replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, function (m, body) {
273271```
275Note: `.pragma library` must be the first line for QML; node ignores it as a comment-like directive? **No** — node will throw on `.pragma`. Resolve by putting `.pragma library` on its own first line and running node with a shim: the test `require` strips it. Simpler and chosen here: **omit `.pragma library`** (a plain QML `.js` without `.pragma library` is imported per-component, which is fine for stateless functions) so the same file is valid node. Delete the `.pragma library` line above.
273Note: the file has **no** `.pragma library` line (see Step 3). A plain QML `.js` without `.pragma library` is imported per-component — fine for these stateless functions — and stays valid node.
277275- [ ] **Step 4: Run test to verify it passes**
729727- [ ] **Step 1: Add a window self-test** (append to `selfTest()` try-block):
729**Assert the relationship, not a hardcoded stamp.** `windowUtc` builds *local* midnight then formats in UTC, so the literal `Z` value depends on the machine's timezone/DST (Berlin CEST → `20260607T220000Z`, not `...0608T000000Z`). Hardcoding a stamp makes the test fail on this machine. Assert instead: both stamps match the ICAL shape, `start` round-trips back to the local midnight we passed in, and `end` is exactly 42 days after `start`.
731731```qml
732732 const w = root.windowUtc("2026-06-08"); // Monday grid start
733 ok("window", /^20260608T000000Z$/.test(w.start) && /^20260720T000000Z$/.test(w.end)); // +42 days
733 const shape = /^\d{8}T\d{6}Z$/;
734 const back = new Date(Date.UTC(+w.start.slice(0,4), +w.start.slice(4,6)-1, +w.start.slice(6,8), +w.start.slice(9,11), +w.start.slice(11,13), +w.start.slice(13,15)));
735 const spanDays = (Date.UTC(+w.end.slice(0,4), +w.end.slice(4,6)-1, +w.end.slice(6,8), +w.end.slice(9,11)) - Date.UTC(+w.start.slice(0,4), +w.start.slice(4,6)-1, +w.start.slice(6,8), +w.start.slice(9,11))) / 86400000;
736 ok("window", shape.test(w.start) && shape.test(w.end)
737 && back.getFullYear() === 2026 && back.getMonth() === 5 && back.getDate() === 8 && back.getHours() === 0
738 && spanDays === 42); // local-midnight round-trip + 42-day span, timezone-independent
734739```
736741- [ ] **Step 2: Run to verify it fails**
10661071 z: 1
10671072 Repeater {
10681073 model: parent.parent.bandLayout.segments
1074 // single Rectangle: translucent calendar-color fill + matching border,
1075 // rounded only at the segment's true start/end (square through mid-week wraps)
10691076 Rectangle {
10701077 readonly property real pitchX: 28
10711078 readonly property real pitchY: 32
10731080 width: (modelData.colEnd - modelData.colStart + 1) * pitchX - 4
10741081 y: modelData.row * pitchY + 16 + modelData.lane * 6
10751082 height: 5
1076 radius: 2.5
1077 color: Qt.rgba(0,0,0,0) // set below
1078 Component.onCompleted: color = Qt.alpha ? modelData.color : modelData.color
1079 // translucent fill + border in the calendar color
1080 Rectangle {
1081 anchors.fill: parent; radius: parent.radius
1082 color: modelData.color; opacity: 0.30
1083 border.width: 1; border.color: modelData.color
1084 }
1083 color: Qt.alpha(modelData.color, 0.30)
1084 border.width: 1
1085 border.color: modelData.color
10851086 topLeftRadius: modelData.roundLeft ? 2.5 : 0
10861087 bottomLeftRadius: modelData.roundLeft ? 2.5 : 0
10871088 topRightRadius: modelData.roundRight ? 2.5 : 0
10961097- [ ] **Step 2: Reserve lane space** — increase cell height in Task 7's delegate so bands don't overlap the dots when `laneCount` is high. Bind the delegate `Item.height` to `30 + Math.max(0, (parent.parent.parent.bandLayout.laneCount) * 6)` (cap considered in `buildSegments` is open; lanes are typically 1–2).
1098- [ ] **Step 3: Restart, screenshot, verify** a real multi-day event renders as a spanning band, wrapping correctly at week boundaries.
1099- [ ] **Step 3: Restart, screenshot, verify** a multi-day event renders as a spanning band, wrapping correctly at week boundaries.
1101The live calendar has **no true multi-day events** (recurrences expand to single-day occurrences), so the band overlay has nothing to render live. Inject a deterministic synthetic event for the screenshot. Add this temporary `Component.onCompleted` to `CalDav.qml` (delete it before commit) — it spans a Fri→Mon so you exercise the week-wrap split:
1103```qml
1104 // TEMP (Task 8 visual verification only — DELETE before commit):
1105 Component.onCompleted: root.events = [{
1106 uid: "synthetic-band", summary: "Bandtest", color: "#5b8cff",
1107 allDay: true, start: "2026-06-26", end: "2026-06-30", // Fri → Tue, wraps Sun→Mon
1108 calendar: "test", isTask: false
1109 }]
1110```
1112(Match the field names to whatever `caldav.js` actually produces — confirm against the parser's event shape from Task 5 before pasting; adjust keys if they differ.)
11001114```bash
11011115rm -rf ~/.cache/quickshell/qmlcache && systemctl --user restart quickshell.service && sleep 3
1116qs ipc -c nuguland call nuguland openClock
11021117qs ipc -c nuguland call nuguland screenshotScreen /tmp/cal-bands.png
11031118```
1104Read `/tmp/cal-bands.png`. If no multi-day event exists in the live window, temporarily inject one via a self-test fixture or verify against the `buildSegments` node tests (already green) + a single-week manual case.
1119Read `/tmp/cal-bands.png`. Confirm: one band, rounded left edge on Fri 26, square right edge at the Sat 27 week-end, a fresh square-left segment on Mon 29, rounded right edge on Tue 30. Then **delete the TEMP block** and re-screenshot to confirm clean removal.
11061121- [ ] **Step 4: Fix geometry inline** until bands line up with cells.