feat(events): "In the news" panel — current events on the dataset info panel#244
Merged
Conversation
GET /api/v1/datasets/:id/events returns the approved current events that
carry an approved link to that dataset — the reverse of GET /api/v1/events
and the data behind the info panel's "In the news" section. New store
helper listApprovedEventsForDataset mirrors listPublicEvents' gating
(approved event + approved link + recency) constrained to one dataset.
No KV (cheap per-dataset query; avoids stale-after-approval); short
Cache-Control + graceful { events: [] } on any read error. Store + route
tests; BACKEND_MODULES row.
Signed-off-by: Claude <noreply@anthropic.com>
When a dataset loads, the info panel now shows the approved current events that relate to it — each a cited card (headline + external source link + date), closing the news→data loop from the visitor side. Graceful absence: the placeholder is removed when a dataset has no events, so most datasets show no new UI (mirrors the hero's null behaviour). Client: fetchEventsForDataset added to eventsService (reuses sanitizePublicEvent; per-dataset 60s cache; degrades to []). Wiring: renderInTheNews fills a placeholder async in datasetLoader, mirroring the semantic-related progressive-enhancement pattern. i18n + info-panel CSS + tests (client cache/sanitize; panel renders section / removes when empty). Signed-off-by: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a new “In the news” surface to the dataset info panel by wiring up a public per-dataset events read end-to-end (backend route + store helper + frontend fetch/render), with short caching and graceful empty-state behavior.
Changes:
- Backend: introduce
GET /api/v1/datasets/:id/eventsand a new store helperlistApprovedEventsForDatasetto return approved, recent events linked to a dataset. - Frontend: add
fetchEventsForDatasetwith a per-dataset 60s in-memory cache and render/remove the “In the news” section asynchronously in the info panel. - Tests/docs: add backend route + store tests, frontend service/UI tests, and update backend module map + module index docs.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/styles/info-panel.css | Adds styling for the new “In the news” list/cards in the info panel. |
| src/services/eventsService.ts | Adds fetchEventsForDataset with per-dataset caching and reuse of sanitizePublicEvent. |
| src/services/eventsService.test.ts | Adds unit tests for per-dataset fetch behavior (URL, caching, degradation). |
| src/services/datasetLoader.ts | Renders an async “In the news” placeholder that fills or removes itself based on results. |
| src/services/datasetLoader.test.ts | Adds DOM tests asserting the section renders or is removed when empty. |
| locales/en.json | Adds the infoPanel.inTheNews string. |
| functions/api/v1/datasets/[id]/events.ts | Adds the public per-dataset events endpoint with short Cache-Control and graceful { events: [] } on read errors. |
| functions/api/v1/datasets/[id]/events.test.ts | Adds wire-level tests for 503-unbound, [] empty result, and happy-path response shape/cache header. |
| functions/api/v1/_lib/events-store.ts | Adds listApprovedEventsForDataset helper mirroring public-event gating but constrained to a dataset. |
| functions/api/v1/_lib/events-store.test.ts | Adds unit tests for the new store helper’s gating and ordering. |
| docs/BACKEND_MODULES.md | Registers the new backend route module for doc-coverage enforcement. |
| CLAUDE.md | Updates the module map description for eventsService to include per-dataset reads. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
🖼️ Visual report54 shot(s) · 2 viewport(s) (desktop, mobile) · 15 with problems · 22 problem(s) total Regression: 6 shot(s) changed, 0 new (baseline-less, soft pass), threshold 0.001.
Shots with problems
Full report → Advisory — this check never fails the build. Visual review only. |
listApprovedEventsForDataset gated only the LINK's approval, not the requested dataset's visibility — so probing a hidden/unpublished/retracted dataset id returned its linked events, and the `?? [datasetId]` fallback forced that hidden id into the public `datasetIds`. Add a `datasets` join gating the requested dataset's visibility, and skip any event with no visible approved link (mirrors listPublicEvents + the client sanitize contract). Test: a hidden requested dataset returns []. Signed-off-by: Claude <noreply@anthropic.com>
…review)
Copilot flagged that the catch in GET /api/v1/datasets/:id/events
swallowed the error and returned {events:[]} with no trace, so an
operator couldn't tell a genuine D1 failure apart from the expected
pre-migration case. Add a console.warn (with the dataset id) before the
graceful-absence return, mirroring events.ts / featured-event.ts.
Signed-off-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Completes the third of the plan's four current-events surfaces
(
docs/CURRENT_EVENTS_PLAN.md§6). When a visitor opens a dataset, theinfo panel now shows the approved current events that relate to it —
each a cited card (headline + external source link + date), closing the
loop from the data side (the hero + catalog overlays already go
news→data; this goes data→news).
The reverse-lookup plumbing (
listLinksForDataset) has existed since thedata layer but had no consumer — this wires it up end to end.
Backend
GET /api/v1/datasets/:id/events— public, returns the approvedevents with an
approvedlink to that dataset. Same curator gate asGET /api/v1/events(approved event + approved link + recency), soit's safe to serve anonymously.
listApprovedEventsForDatasetmirrorslistPublicEventsconstrained to one dataset. No KV (cheap per-datasetquery; avoids stale-after-approval); short
Cache-Control+graceful
{ events: [] }on any read error.Frontend
fetchEventsForDatasetadded toeventsService— reusessanitizePublicEvent(http(s) source-url guard), per-dataset 60 scache, degrades to
[].renderInTheNewsfills a placeholder in the info panel async,mirroring the semantic-related progressive-enhancement pattern.
Graceful absence (as chosen): the placeholder is removed when a
dataset has no events, so most datasets show no new UI.
Tests & verification
listApprovedEventsForDatasetgating (approved/link/other-dataset) + the route (200 shape + cache header,
[], 503).fetchEventsForDataset(endpoint URL, per-id cache, degrade)npm run type-check+ 4698 unit tests green; merged latestmain(with feat(events): add an off-list dataset to an existing event #243) cleanly.Follow-up to #241 / #243. The remaining surface (Orbit docent events) and
the semantic matcher signal (#33) are separate.
🤖 Generated with Claude Code
https://claude.ai/code/session_0127MmwB678BaV8Pfg1KG18E
Generated by Claude Code