Repository navigation
feat(action-center): KPIs, Signals and Actions — the goal, observation and prioritization layers - #808
Merged
Conversation
Adds the first Action Center screen: a KPIs table showing the brand's goal-aligned metrics — value, change vs the previous window, 7-day sparkline, derived status, goal and progress — computed at read time from the same actions and RPCs the analytics surfaces already use, so a KPI row and the dashboard it summarizes can never show different numbers. - kpi_definitions table (00077, applied): one row per activated KPI per brand, storing only the user's choices (target, timeframe, active). Member select, admin/manager write, brand_domains RLS shape. - Code-side KPI registry: category, unit, direction, source per key — static product knowledge stays out of the DB so it cannot drift. - getKpiSnapshots computes value/change/trend/progress per active KPI; status is derived on every read from documented thresholds, never stored, so a badge cannot go stale against the value next to it. - Route-backed tabs (KPIs | Actions | Signals | History); the other three render an honest coming-soon state. - Empty state applies the default KPI set in one click; the framework drawer that generalizes it is the follow-up issue. - Regenerates supabase.ts, which also catches up ga_page_ai_visibility from 00075.
Adds the way KPI definitions are written: a right-side drawer opened from Add KPI, Edit KPIs, the empty state and the row menu. - Template presets over the registry (AI Search Visibility default; Content Performance and Brand Monitoring render disabled until their KPIs are measurable; Custom builds from scratch). Presets decide what is checked, never what was typed — an edited target survives switching. - One time period per framework; per-KPI target inputs with unit suffix and validation (positive, percent capped at 100), Save gated on it. - saveKpiFramework upserts the listed KPIs active and deactivates the rest instead of deleting, so a re-enabled KPI keeps its old target. - Reopening after Cancel refetches, so an abandoned edit leaves nothing. - Replaces the interim one-click apply-defaults action: the empty state now opens the drawer prefilled with the same defaults. No workspace step, unlike the mockup: frameworks are brand-scoped and the brand is already selected in the app shell.
Selecting a template worked but could produce no visible change: with all five KPIs already active, choosing AI Search Visibility checks the same set the drawer opened with, and the old highlight was a near-invisible border tint. The selected card now carries a solid border ring and a check icon, per the mockup.
…engine KPIs The template was defined as the whole registry, making it identical to a custom all-on set — clicking it changed nothing visible when everything was already checked. Per the spec it is the four answer-engine KPIs (visibility, citations, mentions, share of voice); referral traffic measures what arrives at the site, not presence in answers, and now sits behind Show all KPIs where it belongs.
…tion Picking a template unchecked the KPIs outside it but then hid those rows behind Show all KPIs — so the visible rows were all still checked and the click read as doing nothing. With five KPIs total the hide mechanism buys nothing; every registry KPI is now always listed and a template visibly toggles checkmarks instead of making rows vanish.
Edit KPI on a row opened the same generic drawer as Add KPI, with no trace of which KPI was being edited. The row's key now travels with the open: once the prefill lands, that KPI's target input is scrolled into view, focused and selected. Add KPI / Edit KPIs still open unfocused.
Completes the mockup's toolbar right side: a Filters dropdown (status multi-select with an active count) and the shared DateRangeFilter (7d/30d/90d/custom, defaulting to 30d). The selected range is the measurement window: value, change and vs Goal answer for those days across every row, overriding each KPI's own timeframe — one control over one table must not mean five different windows. The sparkline stays the literal last 7 days; its column says Trend (7D). A half-entered custom range keeps the current data instead of refetching per keystroke, and Clear filters resets category and status together.
Switching the date range to 7d measured the value over a week but kept the Goal column at the full monthly target, so vs Goal under-reported on every row. Flow targets (counts, sessions) now pro-rate to the viewed window — monthly 100 over a week is 23, over a quarter 300. Percent targets are levels, not flows, and never scale: a 50% visibility goal is 50% over any window. Status derives from the scaled progress, so the badges agree with what the columns show.
…nges Switching Time Period left every target input as typed, silently turning a monthly goal of 100 citations into a weekly goal of 100 — 4x harder. Count and session targets now convert to the new cadence through the same flow/level rule the table's window scaling uses (weekly 23 → monthly ~99); percent targets are levels and stay put. A half-typed non-numeric value is left alone.
The shared DateRangeFilter carries a label line and smaller buttons, so it sat visibly shorter than its neighbors and said Date Range twice over. Replaced with a label-free h-9 segmented control (7d / 30d / 90d) matching the Filters and Edit KPIs buttons; the custom range is dropped — the presets cover the window question this table answers.
Everything ran one step larger than Citations/Insights. Now matching the house scale: table heads text-xs like every other table; toolbar controls (Filters, date segments, Edit KPIs, category pills) h-8 with text-xs like the insights filter bar; numeric cells text-xs/tabular-nums like the citations table. The KPI value keeps a half-step of emphasis (text-sm semibold) as the row's strongest element; the Add KPI card shrinks to match.
…lbar The mockup's dashed Add KPI card was designed for an 18-KPI grid; above a five-row table it read as a large empty block. It is now a small primary button next to Edit KPIs, and the dead space above the table is gone.
The Action Center's observation layer: every row is a real detection, not a mock. The producers are detectors already running nightly — the Daily Pulse highlight/warning engine (its thresholds are the noise control) and the page-opportunity engine — now also written into a signals table with what the pulse email never had: a lifecycle (new / acknowledged / resolved / dismissed), cross-night dedup, and a stable identity a future Action can reference (many signals -> one action, via a nullable action_id placed from day one). - signals table (00078, applied) + signals_summary RPC (one round trip for cards and breakdowns, immune to the 1000-row cap). Members read and triage, the service role writes. - Recording runs after every stamped tracking run, independent of pulse email settings — signals are a product surface, not a notification preference. Guards: no-fresh-results and platform outages skip auto-resolve, so silence is never mistaken for recovery. - Re-detection refreshes; a resolved signal that fires again reopens; a dismissed one stays dismissed. - Titles are i18n templates composed from kind + payload (nothing display-shaped is stored), which is also why search filters client-side over what the user actually reads. - Page: five summary cards, category pills with counts, impact/status/ source filters + search, the mockup's table (type + state, impact dots, dual detected time), row -> detail drawer with related KPIs and triage actions. - One-time backfill ran across all active brands; the nightly hook keeps it current from the next deploy.
Fills the two categories the first pass left empty, both from data already in production — no mocks: - uncited_mentions (mention): prompts whose window answers mention the brand at least once and cite it never, from the same per-prompt aggregates the Prompts page reads. One consolidated signal with the prompt count; below 3 prompts it is normal noise, not a signal. - audit_low_score (technical): audited pages whose LATEST completed audit scores under 50/100, capped at 90 days so stale audits age out. Also one consolidated signal — the first cut emitted one row per URL and produced 38 on the test brand, exactly the flood the brief's quality rule forbids; the worst ten pages ride in the payload for the drawer and the full list stays on the Site Audit page. Both are persistent conditions: they auto-resolve when a later run no longer detects them. Backfill re-ran across all brands.
…tates its scope Cards: the first cut conflated total with new (both counted detections in the window, so the two cards could never differ) and only Total carried a sparkline. signals_summary now reports the honest split — total is conditions ACTIVE in the window (lifetime overlaps), new is first detected inside it, important is total's high-impact subset, resolved is resolutions inside it — each with its previous-window twin and per-day series. All four numeric cards show sparkline + delta vs the previous range spelled out as dates (mockup style), and Avg. Signal Impact gains its higher/same/lower-than-previous line. The table window follows the same active-in-window semantics so it always shows what Total counts. Copy: competitor signal descriptions now name their scope — the 7-day visibility score across the brand's tracked prompts — instead of bare percentages that read as per-prompt numbers.
main gained 00077_citations_rpcs_custom_plan from another branch after this one forked, colliding with our 00077. File numbering only — the hosted database tracks these by timestamped name and already has all of them applied.
The prioritization/execution layer: open signals consolidate into a
handful of actions — many signals to one action, deterministically, so
the count follows what the detectors actually found (quality over
quantity). Five rules: recover visibility+citations, capture AI traffic,
convert uncited mentions, fix low audit scores, close competitor gaps.
- actions/action_tasks/action_events tables (00081, applied) with the
outcome lifecycle the brief requires (new/in_progress/completed/
on_hold/no_improvement/dismissed), an AC-{n} identity, and a baseline
snapshot of the linked signals' values — the before half of future
validation. signals.action_id becomes a real FK.
- Generator chains after nightly signal recording; dismissed actions
stay dismissed, completed ones reopen if the condition still fires 14
days later. Task templates per rule; every lifecycle change writes an
action_event, so the drawer's History tab reads a trail that was
written as it happened.
- Page: five summary cards, category pills, impact/status/assignee
filters + search + sort (priority = impact, then evidence, then
recency), table with task-progress bars, row drawer with Overview
(why/goal/KPIs/primary signals), Tasks (status changes), Signals,
History, and working assignment + due date. Assign to Agent is absent
until agent execution exists — no dead primary CTA.
- Signal row mapping extracted to lib/signals/map.ts for reuse.
Base UI's Select.Value renders the bare value unless the root receives items — every Action Center select showed in_progress instead of In Progress once picked. All seven selects (filters, sort, statuses, assignee, KPI time period) now pass their value-label pairs.
The pattern behind 5f34014, made self-enforcing: Base UI's Select.Value
shows the raw value in the trigger unless the root receives {value,
label} items, and the mistake keeps slipping into first implementations
because the dropdown list looks right — only the picked state is wrong.
The wrapper now documents the rule where the component is defined and,
in development, warns once per page load when a Select renders without
items. Roughly thirty pre-existing selects outside the Action Center
still lack items; they keep working as before and can be cleaned up
separately.
Primary Signals cards and the Signals tab rows in the action drawer were static. They now navigate to the Signals page with that signal's drawer open (via ?signal=<id>, consumed once and cleaned from the URL) — the evidence is one click from the action it created, and triage happens where triage lives instead of stacking drawers.
Following an action's evidence to the Signals page and pressing back landed on a bare Actions list — the open drawer lived only in component state. The drawer's identity now rides the URL (?action=<id>, via replaceState so open/close never grows the history stack) and the page reopens it once the list loads, which also makes a refresh keep the drawer and the URL shareable.
Two gaps in the evidence chain: - The Signals page consumed ?signal=<id> and cleaned it, so the open drawer had no identity — back from a prompt page or a refresh lost it. Same treatment as the Actions page now: the param stays while the drawer is open, and the restore effect reopens it once the list lands. - Prompt-scoped signals (visibility gained, citations lost) named the prompt but offered no way to reach it. The producer now surfaces the prompt id from the dedup key into the payload, and the drawer's Affected section links straight to the prompt page. Existing rows pick the id up on their next detection refresh.
Five touches, all informational rather than decorative, per the mockups: - Signal rows get the same 8x8 kind-icon tile the KPI and Action tables already carry, so all three tables scan the same way. - Status badges (KPI, signal, action) lead with a small dot in the badge's own color — the mockups' badge anatomy. - The Source column and drawer render per-source icons beside the names instead of a plain joined string. - The Signals tab shows an untriaged count only when there is one — something new is waiting — via a head count query. - Both drawers repeat the row's kind icon in their header, so the drawer reads as the same object that was clicked. Tabs stay text-only and category pills stay unadorned, deliberately.
The conflict resolutions during the rebase onto main regenerated schema.sql at intermediate commits; this is the final regeneration with all 80 migration files, restoring 00081_actions' section.
This was referenced Sep 14, 2026
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.
Summary
Adds the Action Center module: three live pages (KPIs, Signals, Actions) built as one architecture —
KPIs → Signals → Actions → Tasks → Validation— with no mock data anywhere. Every number on every page is computed from data the product already tracks.KPIs — the goal-setting layer.
kpi_definitionsstores only user decisions (target, timeframe, active); value, change, 7-day sparkline, progress and status are computed at read time from the same actions and RPCs the analytics pages use, so a KPI row and the dashboard it summarizes can never disagree. A configure drawer applies templates and per-KPI targets; flow targets rescale between weekly/monthly/quarterly cadences while percent targets stay put, and the same flow/level rule holds goals against the toolbar's 7d/30d/90d window.Signals — the observation layer. Eleven detector kinds write to a
signalstable with a lifecycle (new / acknowledged / resolved / dismissed) and cross-night dedup: one row per ongoing condition, re-detections refresh it, resolved conditions that fire again reopen, dismissed stays dismissed. The producers are detectors already running in production (the Daily Pulse highlight/warning engine — its thresholds are the noise control — plus page opportunities, uncited mentions, and Site Audit scores). Recording runs after every stamped tracking run, independent of pulse email settings. Guards keep silence from being mistaken for recovery (no-fresh-results and platform outages skip auto-resolve).Actions — the prioritization layer. A deterministic generator consolidates open signals into at most five actions per brand (many signals → one action), each carrying linked evidence, template tasks, KPI references, and a
baselinesnapshot for the future validation loop. Users execute: status (six outcome-oriented states includingno_improvement), assignee, due date, per-task progress — every mutation logged to anaction_eventstrail the drawer's History tab renders. Action count follows what detectors actually found: four important things yield four actions, never a manufactured ten.The three surfaces share one visual system (icon tiles, dotted status badges, impact dots, h-8/text-xs toolbars) and full traceability: an action's evidence links to the signal, the signal links to its prompt, and both drawers ride the URL so back/refresh restore them.
Also included: the shared
Selectnow warns in dev when rendered withoutitems(the raw-value-in-trigger trap), and migrations were renumbered over main's 00077.Database (already applied to hosted)
00078_kpi_definitions,00079_signals,00080_signals_summary_cards,00081_actions— all additive; RLS follows existing patterns (member read/triage, admin-manager writes where policy-shaped, service-role detection writes). Applied weeks ago and verified against production data; merging deploys no schema change.Server
Signal recording + action generation chain onto the existing nightly tracking trigger (fire-and-forget, never blocks the run). A one-time backfill script exists (
backfill-signals.js); it has already been run across active brands.Related issue
None — built from the Action Center product briefs (KPI, Signals, Actions mockups + implementation briefs).
Type of change
feat— New featureHow to test
yarn build,yarn lint,yarn vitest run(208 tests) all pass fromweb/.Checklist
feature/,fix/,chore/,docs/)yarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)