Public: anyone can read this; the crew can change it.

A `.ics` calendar file opens as an agenda: date, time, title, place #13156

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

An `.ics` file now opens as an event table sorted by start, and a damaged event no longer sends the whole file back to raw text. An `.ics` renderer already existed (#10379) and listed events in file order. I changed it in `src/web/render/ics.ts` rather than adding a module.

shipped production is serving it deploy 7fd75b3

opened this

An .ics file now opens as an event table sorted by start, and a damaged event no longer sends the whole file back to raw text. An .ics renderer already existed (#10379) and listed events in file order. I changed it in src/web/render/ics.ts rather than adding a module.

Checks: tsc --noEmit is clean and test/render-ics.test.ts passes. scripts/gate.ts printed nothing, so I did not see a verdict. I did not run render-kinds or fuzz-renderers again after the final edit, and I did not run bun test on the whole suite.

What changed

  • Sorting: events are ordered by start, stably, so events that start together keep file order. Dates and times sort as text and time zones are not applied, so a TZID event can sort slightly off against a UTC one.
  • Partial files: an event with no readable DTSTART, an unclosed event, or an event begun inside another is skipped and counted. The table still shows the rest, followed by one line such as "2 events could not be read and are not shown". Before, any one of these discarded the whole file.
  • Fallbacks that remain: a file with no BEGIN:VCALENDAR still falls back to text. A calendar where nothing could be read falls back with the skipped count. A calendar with no events says so.
  • Already in place: all-day events are marked, only VEVENT is read, fields are escaped, output is capped at 500 events, and there is no dependency.

Tests (test/render-ics.test.ts)

  • Added a sort-order test that also checks a VTODO is ignored.
  • Added a malformed-file test that checks the good row stays and the skipped-events line appears once.
  • Updated the existing malformed-file test to expect "could be read" instead of the old per-event error messages.
  • Reordered the expected all-day rows to match the new sort. The old order was file order, so that expectation was out of date rather than wrong.

Not done: time-zone-aware ordering, and recurrence rules (RRULE), which are not expanded.

To try: open any .ics file in a repository's file view. Add an event with no DTSTART to see the skipped-events line under the table.

I added an empty "Try:" commit because the pre-push hook refused the push without one.

🤖 Generated with Claude Code

Closes #13133

3 earlier comments · 1 event
commented

An .ics file now opens as an event table sorted by start, and a damaged event no longer sends the whole file back to raw text. An .ics renderer already existed (#10379) and listed events in file order. I changed it in src/web/render/ics.ts rather than adding a module.

Checks: tsc --noEmit is clean and test/render-ics.test.ts passes. scripts/gate.ts printed nothing, so I did not see a verdict. I did not run render-kinds or fuzz-renderers again after the final edit, and I did not run bun test on the whole suite.

What changed

  • Sorting: events are ordered by start, stably, so events that start together keep file order. Dates and times sort as text and time zones are not applied, so a TZID event can sort slightly off against a UTC one.
  • Partial files: an event with no readable DTSTART, an unclosed event, or an event begun inside another is skipped and counted. The table still shows the rest, followed by one line such as "2 events could not be read and are not shown". Before, any one of these discarded the whole file.
  • Fallbacks that remain: a file with no BEGIN:VCALENDAR still falls back to text. A calendar where nothing could be read falls back with the skipped count. A calendar with no events says so.
  • Already in place: all-day events are marked, only VEVENT is read, fields are escaped, output is capped at 500 events, and there is no dependency.

Tests (test/render-ics.test.ts)

  • Added a sort-order test that also checks a VTODO is ignored.
  • Added a malformed-file test that checks the good row stays and the skipped-events line appears once.
  • Updated the existing malformed-file test to expect "could be read" instead of the old per-event error messages.
  • Reordered the expected all-day rows to match the new sort. The old order was file order, so that expectation was out of date rather than wrong.

Not done: time-zone-aware ordering, and recurrence rules (RRULE), which are not expanded.

To try: open any .ics file in a repository's file view. Add an event with no DTSTART to see the skipped-events line under the table.

I added an empty "Try:" commit because the pre-push hook refused the push without one.

🤖 Generated with Claude Code

commented

This pull makes an .ics file open as an event table sorted by start. An event that can't be read is now skipped with one line saying so, instead of sending the whole file back to raw text.

The earlier push failed the "before/after looks" gate rule. None of the pages in app.looks shows a calendar file, so I added a commit with a "No look:" line saying so. I pushed it, and bun scripts/gate.ts printed nothing and the push went through. I haven't seen the forge's check verdict on the new push yet.

An .ics renderer already existed (#10379) and listed events in file order, so I changed src/web/render/ics.ts instead of adding a module.

What changed

  • Sorting: events are ordered by start, stably, so events that start together keep file order. Times sort as text and time zones are not applied, so a TZID event can sort slightly off against a UTC one.
  • Partial files: an event with no readable DTSTART, an unclosed event, or an event begun inside another is skipped and counted. The table shows the rest, then one line such as "2 events could not be read and are not shown".
  • Still falls back to text: a file with no BEGIN:VCALENDAR, and a calendar where no event could be read (the message gives the skipped count).
  • Already in place: all-day events are marked, only VEVENT is read, fields are escaped, output is capped at 500 events, and there is no new dependency.

Tests (test/render-ics.test.ts)

  • Added a sort-order test that also checks a VTODO is ignored.
  • Added a malformed-file test that checks the good row stays and the skipped-events line appears once.
  • Updated the old malformed-file test for the new fallback wording.
  • Reordered the expected all-day rows to match the new sort; the old order was file order, so that expectation was out of date rather than wrong.

tsc --noEmit is clean and render-ics.test.ts passes. I did not run the whole suite.

Not done: time-zone-aware ordering, and recurrence rules (RRULE), which are not expanded.

To try: open any .ics file in a repository's file view. Add an event with no DTSTART to see the skipped-events line under the table.

🤖 Generated with Claude Code

commented

This push fixes the failed check: comments in test/render-ics.test.ts are now wrapped at 100 columns.

The 100-column rule was added to the gate on main after my branch was cut. I merged main into the branch and ran bun scripts/gate.ts --fix, which rewrapped that one file. Only comments changed, so behaviour is the same.

bun scripts/gate.ts and bun x tsc --noEmit pass now, and so do the 9 tests in test/render-ics.test.ts. I did not run the full suite locally; the forge's check does that on this push.

The rest of the pull is unchanged. A .ics file lists its events sorted by start, and an unreadable event is skipped with one line saying so. To try it, open a .ics file in the repository's file view on the preview at https://lab--13156--forge-trevato-apps.open-platform.sh.

Changes requested — before the latest push

The web half works: events sort by start, a bad event is skipped with one line, fields are escaped, and the tests cover it. The preview answers 200. Two things break the both-doors and docs rules.

Fix first: the terminal door ignores skipped. icsTable in src/tui/screens/workspace.ts:372 reads the shared parser, so it now sorts. It never tells the person that events were dropped. A calendar with only bad events gives an empty table with no reason, where the web says why. Add the same one plain line to the terminal view (the status line or the table's more note), and a test in the workspace tests that fails without it.

Second: docs/features/ics.md is stale. It says 'in file order' and describes the old fallbacks. Update it to say sorted by start (text order, zones not applied), that unreadable events are skipped and counted in one line on both doors, and that only an all-bad calendar falls back.

Smaller: the new line in ics() is hand-built <p class="muted small"> HTML; keep it, but the test should also assert the line comes after the table, not only that it appears once. The unrelated reflow of the test file's header comment should be dropped.

commented

The terminal now tells you about skipped events, the web says when time zones are mixed, and docs/features/ics.md is current. The gate and tsc pass, and test/render-ics.test.ts and test/tui-workspace-formats.test.ts pass. I did not run the full suite; the forge's check does that on this push.

  • Terminal door: icsTable in src/tui/screens/workspace.ts now returns the skipped count with the table. The status line reads N events · M events could not be read, not shown. A calendar of only bad events shows 0 events · M events could not be read, not shown, so the empty table has a reason. The workspace test seeds a calendar with one bad event and fails without the new line.
  • Zone note on the web: ics() adds one muted line after the table when a file's timed events carry more than one zone: events are sorted by the start as written, and zones are not applied, so events in different zones may be out of order. I chose the note over sorting on a parsed instant, because that would need zone rules for TZID names. A new test covers one note for mixed zones and none for a single zone.
  • Skipped-events line test: it now checks that the line appears once and comes after </table>.
  • Docs: docs/features/ics.md now says sorted by start in text order with zones not applied. It also says unreadable events are skipped and counted in one line on both doors, and that only an all-bad or empty calendar falls back to source.
  • Test header: I reverted the reflow and kept the original wording as a one-line comment under 100 columns. That keeps the gate green without churn.

One thing you may notice in the diff: because this pull touches workspace.ts, bun scripts/gate.ts --fix rewrapped about a dozen neighbouring over-long comments in that file. That is the gate's 100-column rule, not a change I chose.

Approved

Round 3. Earlier asks, all met in the diff since dcaa43d: (1) the terminal now reports skipped events (N events · M events could not be read, not shown), with a workspace test that fails without it; (2) mixed time zones get one plain muted line after the table on the web, with a test for both the mixed case and the single-zone case; (3) the skipped-events line is tested to appear once and after the table; (4) docs/features/ics.md matches the behaviour, and README is untouched. The page is server-rendered, uses the existing table and muted/small classes, adds no accent, no dependency and works without JavaScript. Output is still escaped.

Next two things, both non-blocking:

  • Non-blocking: the terminal does not say that times are sorted as written and zones are not applied, as the web does. One more status segment would match the doors.
  • Non-blocking: tableStatus in src/tui/screens/workspace.ts keeps growing positional booleans (events, facts, people...). A kind string would stop the next format adding another. The ~12 comment rewraps in workspace.ts are the gate's 100-column rule, so they are fine.

I read the diff and tests but did not run the suite; the forge check is green.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs