Background
The TaskStats bug fix (PR #234, fixes #233) exposed a broader architectural pattern: components that use useAgentState() hook without considering project phase may show incorrect data during non-development phases.
This is the "late-joining user" scenario - when a user opens the Dashboard after certain actions have occurred, they may see stale or incorrect data because the component is looking at the wrong data source.
Root Cause
The application has two parallel data systems:
| Data Source |
Phase |
Update Mechanism |
| REST API (issues endpoint) |
Planning |
HTTP polling/SWR |
| WebSocket (agent state) |
Development/Review |
Real-time push |
Components that rely solely on one data source without phase awareness are vulnerable to showing incorrect data.
At-Risk Components (Audit Needed)
High Priority
| Component |
Risk |
Current Behavior |
AgentPanel |
HIGH |
May show "no agents" during planning when agents are planned but not yet active |
ProgressIndicator |
HIGH |
May calculate 0% progress during planning phase |
TaskTreeView |
MEDIUM |
May show empty tree if only reading agent state |
Medium Priority
| Component |
Risk |
Current Behavior |
MetricsCharts / CostDashboard |
LOW |
Should show "Metrics available during development" during planning |
QualityGates |
LOW |
Should show configured gates during planning (pending execution) |
Pattern to Apply
Each affected component should follow the pattern established in PR #234:
interface ComponentProps {
phase?: string; // Current project phase
issuesData?: IssuesResponse; // REST API data for planning phase
}
function Component({ phase, issuesData }: ComponentProps) {
const agentState = useAgentState(); // Always call (hooks rules)
const data = useMemo(() => {
if (phase === 'planning') {
return calculateFromIssuesData(issuesData);
}
return agentState; // development/review phases
}, [phase, issuesData, agentState]);
}
Testing Strategy
Each component should have "late-joining user" tests that verify:
Acceptance Criteria
Related
References
- Beads issue:
codeframe-7pya
- Code review:
docs/code-review/2026-01-08-taskstats-phase-awareness-review.md
Background
The TaskStats bug fix (PR #234, fixes #233) exposed a broader architectural pattern: components that use
useAgentState()hook without considering project phase may show incorrect data during non-development phases.This is the "late-joining user" scenario - when a user opens the Dashboard after certain actions have occurred, they may see stale or incorrect data because the component is looking at the wrong data source.
Root Cause
The application has two parallel data systems:
Components that rely solely on one data source without phase awareness are vulnerable to showing incorrect data.
At-Risk Components (Audit Needed)
High Priority
AgentPanelProgressIndicatorTaskTreeViewMedium Priority
MetricsCharts/CostDashboardQualityGatesPattern to Apply
Each affected component should follow the pattern established in PR #234:
Testing Strategy
Each component should have "late-joining user" tests that verify:
Acceptance Criteria
useAgentState()for phase-awarenessRelated
References
codeframe-7pyadocs/code-review/2026-01-08-taskstats-phase-awareness-review.md