Repository navigation
Description
Context
The current dashboard is a metrics-first screen: Dashboard.tsx renders a StatsGrid fed by getTaskStats, getQueueStats, and getStatsOverview, plus TaskStatsChart, RepositoryBreakdown, TopModels, ActivitySparkline and an embedded TaskList. None of those sources can answer the four questions the new specification asks: what needs attention, what is running, what just happened, and are things generally going well.
The specification is explicit that the dashboard needs three distinct sources of truth:
- Task state for running, queued, and blocked work.
- Outcome events for recent history.
- Aggregated execution data for stats.
It is equally explicit that notification read/dismissal state must stay an inbox concern: "Dismissing a notification must not resolve a blocker. Attention state should come from the underlying work." This means the attention list cannot simply be a filtered /api/notifications read, even though today's notificationApi.ts would make that the easiest path.
This task builds the backend endpoints and the typed UI clients for those three sources. The UI components that consume them are built in the follow-up task, so this task must land a complete, tested API surface that the components can be written against without further backend work.
Requirements
- Add four new API endpoints under a new
packages/api/routes/dashboardRoutes.tsmodule:GET /api/dashboard/summary— the four summary-strip counts.GET /api/dashboard/attention— unresolved work requiring human intervention.GET /api/dashboard/active— running and queued work.GET /api/dashboard/outcomes— recent meaningful results.
- Extend the existing
GET /api/stats/*surface with a period-aware, comparison-capable endpoint for the historical stats section (completed, success rate, spend, daily chart) rather than inventing a fourth parallel stats system. - Every endpoint must accept a
repositoryfilter parameter that accepts eitherallor anowner/repostring, validated with the existingvalidateRepositoryFilterhelper inpackages/api/routes/validation.ts. - Counts must use identical definitions across
summary,attention,active, and the task pages. Derive them from one shared query helper so they cannot drift. - Success rate must exclude queued, running, and cancelled work from its denominator.
- Unavailable data must be represented as
null, never as0. Cost must be labelled as recorded spend. - Add typed frontend clients in
propr-ui/src/api/dashboardApi.tsfollowing the existingtaskStatsApi.tspattern (apiFetch+handleApiResponseagainstAPI_BASE_URL).
Implementation Specification
Backend
- Create
packages/api/routes/dashboardRoutes.tsexportingcreateDashboardRoutes(deps)returning{ getSummary, getAttention, getActive, getOutcomes }, matching the factory convention used bycreateTaskRoutes,createStatsRoutes, andcreateQueueRoutes. - Create
packages/api/routes/dashboardQueries.tsholding the shared SQL/Redis helpers so the four handlers cannot produce inconsistent counts. - Register the new router in
packages/api/routes/index.ts(barrel) and in the server's route wiring alongsidecreateStatsRoutes. - Attention derivation must read from task state and plan-issue state, not from
notification_user_states. The sources are:- Failed tasks whose failure has not been superseded by a later successful run for the same issue/PR.
- Plan issues in a status that awaits a human decision (see
PlanIssueStatusinpackages/core/src/config/planIssueManager.ts). - Tasks in an explicit
action_required/needs_attentionstate (the same statesnative-notifications.tsalready treats as attention states).
- Recovery-aware exclusion: if a task is currently being retried or auto-recovered, it belongs in
active, notattention. The spec is explicit: "Avoid asking the user to fix something the system is already fixing." - Ordering: blocking problems first, then pending decisions; oldest first within each category.
activemust return the current phase label from data the backend actually has. Do not synthesise percentage progress. Use the existing live-details projection (projectTaskLiveDetailsinliveDetailsRoutes.ts) for the latest meaningful progress line and leave itnullwhen unknown.activemust also return a queue summary withqueuedCountand areasonstring that isnullunless the backend genuinely knows why (e.g. all agents busy, agents paused). Do not return estimated start times.outcomesmust collapse redundant events. "Implementation completed" and "PR ready" for the same task are one outcome; a later review is a separate outcome. Exclude heartbeats, indexing updates, and individual CI jobs.- Stats: extend
packages/api/routes/statsRoutes.tswithgetDashboardStatsacceptingperiod(7ddefault,30d) and returning{ completed, successRate, recordedSpend, dailyCompleted[], previous: { completed, successRate, recordedSpend } }, with each scalar nullable.
Frontend client
propr-ui/src/api/dashboardApi.tsexports the request functions and the response interfaces. UseshareInFlightApiReadwhere the existing code does (seesystemStatusApi.ts) so concurrent mounts of the dashboard sections do not duplicate reads.
Acceptance Criteria
GET /api/dashboard/summary?repository=allreturns four integer counts.- The same repository filter value produces consistent counts between
/api/dashboard/summaryand/api/dashboard/active. - A failed task that is currently being retried appears in
activeand does not appear inattention. - Dismissing a notification through
/api/notifications/:id/dismissdoes not change/api/dashboard/attentionoutput for the same underlying task. - Success rate denominators exclude cancelled, queued, and running work; a repository with only running work returns
successRate: null, not0. - All four endpoints reject a malformed
repositoryvalue with HTTP 400. - New tests exist under
packages/api/test/covering count consistency, recovery exclusion, notification independence, and success-rate denominator rules.
Created by ProPR AI Planner
Activity
propr-dev commentedon Sep 23, 2026
Suggested Implementation:
Implementation Approach
This implementation introduces a dedicated dashboard API module rather than extending
taskRoutes.tsor reusing/api/notifications. Three reasons drove that choice.First, the specification names three distinct sources of truth and explicitly separates attention state from notification state. Reusing the notification endpoints would structurally couple the dashboard to inbox read/dismiss semantics, which the spec forbids. A separate module makes that boundary enforceable rather than a convention someone can accidentally break.
Second, consistency of counts is a stated requirement ("Counts should use consistent definitions across the dashboard and task pages"). Placing the count logic in a single
dashboardQueries.tshelper and having every handler call it is the cheapest way to guarantee this. An alternative was to compute counts inline in each handler, which was rejected because four hand-written queries will drift.Third, we extend rather than replace the stats endpoints.
statsRoutes.tsalready owns aggregation overtasks,task_history, andllm_executions. Creating a parallel stats system would duplicate that join logic and produce two numbers for the same question.Trade-off accepted:
dashboardQueries.tsperforms several queries per request instead of one large join. This is deliberate — the queries read from different stores (SQLite for task history, Redis/BullMQ for queue state), so a single join is impossible anyway, and separate queries keep each definition independently testable.File:
packages/api/routes/dashboardQueries.ts(new file)Why this file: This is the single source of truth for what "needs attention", "running", "queued", and "completed today" mean. Every dashboard handler and the summary strip read from here, so a definition can only change in one place. Keeping it separate from the route handlers also makes it directly unit-testable without spinning up Express.
File:
packages/api/routes/dashboardRoutes.ts(new file)Why this file: The four dashboard sections need four HTTP endpoints, and the existing route modules are already organised one-module-per-feature (
queueRoutes,statsRoutes,taskRoutes). Placing them here keeps the dashboard's contract discoverable and lets the shared query helpers above stay free of Express types.File:
packages/api/routes/statsRoutes.tsWhy this file: The historical stats section needs completed/success-rate/spend with a previous-period comparison.
statsRoutes.tsalready owns aggregation overtasksandllm_executions, so extending it keeps one implementation of "how many tasks completed in a window" instead of creating a second.File:
propr-ui/src/api/dashboardApi.ts(new file)Why this file: The dashboard components built in the next task need typed access to the new endpoints. Following the existing
taskStatsApi.tsshape (thinapiFetch+handleApiResponsewrappers) means the components can be written exactly like the currentDashboard.tsxones, with no new client conventions to learn.File:
packages/api/routes/index.tsWhy this file: This is the barrel that the server imports route factories from. Adding the export here is what makes the new module reachable from server wiring.
propr-dev commentedon Sep 23, 2026
🤖 AI processing has started for this issue using claude agent with claude-opus-5 model.
I'll analyze the problem and work on a solution. This may take a few minutes.
Processing Details:
claudeclaude-opus-52478/claude-opus-5-dashboard-data-layer-atte-20260923-1205-tng2478-epic-dashboard-data-2kiissue-2478-20260923-1205-claude-opus-5-tng🔍 Track Task Execution