Skip to content

feat(reports): templates with section picker, four new modules, deltas and change-story summary - #419

Merged
gkhngyk merged 3 commits into
mainfrom
feature/report-templates
Jul 13, 2026
Merged

gkhngyk merged 3 commits into
mainfrom
feature/report-templates

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Report templates grow into a full pick-your-modules flow (US-1.1 → US-1.4):

Templates + section picker (US-1.1, US-1.3)

  • Four ready-made templates — Weekly Visibility Summary (7d), Monthly Executive Report (30d, everything), Competitor Benchmark, Citation & Sources — drive the generate dialog: template cards show name/description/default period and pre-select a module set.
  • Templates are now defaults, not fixed shapes: a section checkbox grid lets the user toggle any module before generating; createReport accepts explicit picks and only gathers what's selected.
  • The dialog gains a brand selector (defaults to the active brand).
  • Shopping is brand-pref-gated twice: the checkbox is hidden when the brand's shopping mode is off (mirroring the sidebar's requiresBrandPref), and the server refuses to gather it regardless of what a caller sends.

Four new modules, all windowed to the report period with previous-window deltas (US-1.4)

  • Topic Performance — per-topic avg visibility, points change vs the prior window, result counts (top 8)
  • AI Traffic — visits + % change, platform split, top pages
  • Shopping Visibility — shopping SoV + points change, products surfaced, card rate, top merchant
  • Site Audit Score — latest completed audit as of the period end, delta vs the prior audit

All are optional payload fields; the detail page and the PDF render purely by field presence, so legacy reports and slim section picks render cleanly.

Change-story executive summary (US-1.2)

  • The summary prompt now demands a narrative: open with the movement arc (e.g. "visibility climbed from 42 to 48"), name the driver (the platform/topic/prompt that moved), name the biggest risk (a competitor gaining, a topic sliding), close with the single next focus. Baseline wording when no prior-period data exists.

Also

  • prompts.topic_id and site_audits added to the generated Supabase types (the schema had them; the types file lagged).
  • Async generation stays out of scope for v1 (generation is a single ~10s action with a loading state); the job/progress pattern can be adopted later if needed.

Related issue

—

Type of change

  • feat — New feature

How to test

  1. /dashboard/reports (no sidebar entry — soft launch) → Generate Report.
  2. Pick each template and watch the section checkboxes re-seed; toggle modules on/off; pick a non-active brand from the selector.
  3. On a brand with shopping mode off, confirm the Shopping checkbox is absent; on a shopping brand, generate with it on.
  4. Generate → the detail page and the PDF must contain exactly the picked sections, each with deltas vs the previous period.
  5. Confirm the AI summary reads as a change story (arc + driver + risk), not a static description.
  6. cd server && npm test (112 passing) · cd web && yarn typecheck && yarn lint.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

gkhngyk added 3 commits July 10, 2026 19:40
…ctions, generate

US-1.1: four templates — Weekly Visibility Summary (7d), Monthly
Executive Report (full, 30d), Competitor Benchmark, Citation & Sources.

- template registry (lib/reports/templates.ts) drives everything: the
  generate dialog's template cards (name, description, section chips,
  default period = the static preview), which sections createReport
  gathers, and — since the detail page and PDF render purely by payload
  field presence — which sections appear in the output
- payload metric fields are now all optional; every renderer guards on
  its field, so legacy reports and slim templates both render cleanly
- summary endpoint accepts a template id and flavors the prose (weekly
  pulse / competitor standing / citation mix)
- library table + detail header show the template name; template ids are
  persisted in reports.template (existing column, no migration)
…hange-story summary

US-1.3 — templates are now defaults, not fixed shapes: the generate dialog
grows a section checkbox grid (pre-filled by the selected template) and
createReport accepts explicit section picks. Shopping is brand-pref-gated
twice: hidden in the dialog when the brand's shopping mode is off (like the
sidebar's requiresBrandPref) and refused server-side regardless of caller.

New modules, each windowed to the report period with a previous-window
delta (US-1.4): Topic Performance (per-topic avg visibility + points
change), AI Traffic (visits + % change, platform split, top pages),
Shopping Visibility (SoV + points change, products surfaced, card rate,
top merchant) and Site Audit Score (latest completed as of period end vs
the prior audit). Rendered in the detail page and the PDF; all optional
payload fields so legacy reports and slim picks render cleanly.

US-1.1 — the dialog gains a brand selector (defaults to the active brand).
US-1.2 — the AI summary prompt now demands a change story: open with the
movement arc (e.g. 42 → 48), name the driver, name the biggest risk, close
with the single next focus; baseline wording when no prior data exists.

Also: prompts.topic_id and site_audits added to the generated Supabase
types (schema had them; the types file lagged).
@gkhngyk
gkhngyk merged commit 7d64ed9 into main Jul 13, 2026
5 checks passed
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.

1 participant