Skip to content

feat(events): "In the news" panel — current events on the dataset info panel#244

Merged
Hackshaven merged 5 commits into
mainfrom
claude/events-in-the-news
Jul 2, 2026
Merged

feat(events): "In the news" panel — current events on the dataset info panel#244
Hackshaven merged 5 commits into
mainfrom
claude/events-in-the-news

Conversation

@Hackshaven

Copy link
Copy Markdown
Member

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, the
info 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 the
data layer but had no consumer — this wires it up end to end.

Backend

  • GET /api/v1/datasets/:id/events — public, returns the approved
    events with an approved link to that dataset. Same curator gate as
    GET /api/v1/events (approved event + approved link + recency), so
    it's safe to serve anonymously.
  • New store helper listApprovedEventsForDataset mirrors
    listPublicEvents constrained to one dataset. No KV (cheap per-dataset
    query; avoids stale-after-approval); short Cache-Control +
    graceful { events: [] } on any read error.

Frontend

  • fetchEventsForDataset added to eventsService — reuses
    sanitizePublicEvent (http(s) source-url guard), per-dataset 60 s
    cache, degrades to [].
  • renderInTheNews fills 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

  • Backend: listApprovedEventsForDataset gating (approved/link/other-
    dataset) + the route (200 shape + cache header, [], 503).
  • Frontend: fetchEventsForDataset (endpoint URL, per-id cache, degrade)
    • the info panel renders the section / removes it when empty.
  • Full: npm run type-check + 4698 unit tests green; merged latest
    main (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

claude added 3 commits July 1, 2026 21:25
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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/events and a new store helper listApprovedEventsForDataset to return approved, recent events linked to a dataset.
  • Frontend: add fetchEventsForDataset with 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.

Comment thread functions/api/v1/_lib/events-store.ts
Comment thread functions/api/v1/_lib/events-store.test.ts
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

🖼️ Visual report

54 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.

Scene Viewport Change
browse-filters-open desktop 10.68% (138364 px)
browse-search-active desktop 0.17% (2162 px)
orbit-chat-open desktop 0.17% (2147 px)
browse-timeline-view desktop 2.38% (30853 px)
publish-events desktop 0.41% (5344 px)
browse-search-active mobile 0.64% (2111 px)
Shots with problems
Scene Viewport Errors Failed req a11y
catalog-landing desktop 0 1 0
browse-filters-open desktop 0 2 0
browse-search-active desktop 0 1 0
orbit-chat-open desktop 0 1 0
help-panel desktop 0 1 0
browse-graph-view desktop 0 1 0
browse-timeline-view desktop 0 1 0
browse-map-view desktop 0 1 0
orbit-settings desktop 0 1 0
publish-tours desktop 1 1 0
publish-featured-hero desktop 1 1 0
publish-datasets-error desktop 1 1 0
+3 more

Full report → visual-report artifact

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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Comment thread functions/api/v1/datasets/[id]/events.ts Outdated
…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>
@Hackshaven
Hackshaven merged commit 840f18c into main Jul 2, 2026
17 of 19 checks passed
@Hackshaven
Hackshaven deleted the claude/events-in-the-news branch July 2, 2026 03:51
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.

3 participants