Skip to content

Extract stats derivation model (codex) - #2353

Merged
numnx merged 1 commit into
feature/CODUX-142-qs-code-quality-performance-audit-6from
task/feature-codux-142-qs-code-quality-performance-au-t06-codex-mr9j5pi5
Jul 6, 2026
Merged

Extract stats derivation model (codex)#2353
numnx merged 1 commit into
feature/CODUX-142-qs-code-quality-performance-audit-6from
task/feature-codux-142-qs-code-quality-performance-au-t06-codex-mr9j5pi5

Conversation

@numnx

@numnx numnx commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

🧩 Task: Extract stats derivation model

Automated task PR opened by Code UX for T06.

📋 Summary

Sprint: Sprint 142 · QS: Code Quality & Performance Audit · Task: T06

Audit and improve Code UX quality and performance by tightening existing hot-path contracts across live snapshots, execution projection, provider telemetry, dashboard render derivation, repository boundaries, MCP validation, guardrails, and documentation.

📝 Full Task Prompt
## Objective
Extract the pure derivation logic from `useStatsPageData` into a reusable view-model helper to improve testability and avoid hidden recomputation concerns in the hook.

## Scope
- Create `dashboard/src/v2/pages/stats/stats-page-view-model.ts`
- Edit `dashboard/src/v2/pages/stats/use-stats-page-data.ts`
- Edit `tests/dashboard/v2/use-stats-page-data.test.tsx`
- Create or edit `tests/dashboard/v2/stats-page-view-model.test.ts` if the suite pattern supports a focused helper test
- Update `docs/dashboard/design-system-stats.md` if the stats derivation ownership is documented there

## Implementation Requirements
1. Move token series, active-time series, wall-time series, planning usage lookup, provider/source/token segment creation, and completion confidence derivation into an exported pure helper.
2. Keep `useStatsPageData` responsible for state, fetching, and chart state only; call the pure helper inside `useMemo` with stable inputs.
3. Add focused tests for null stats, reported-only usage, mixed reported plus estimated usage, estimated-only usage, empty buckets, and custom range behavior remaining in the hook.
4. Preserve the `StatsPageData` return shape and all display strings currently consumed by Stats page components.

## Constraints
- Do not change `useProjectStats`, `useUsageChartState`, or backend stats APIs.
- Do not add external chart or state-management libraries.
- Keep date state initialization behavior unchanged.
- Do not modify unrelated Stats page layout or styling.

## Verification
- Run `pnpm exec vitest run tests/dashboard/v2/use-stats-page-data.test.tsx tests/dashboard/v2/stats-page-view-model.test.ts` if the new helper test file is created; otherwise run the existing hook test file.
- Run `pnpm run typecheck:dashboard`.
- Success means stats derivation has pure helper coverage and the hook’s public result remains backward compatible.

✅ QA Review

⏳ QA review runs after this PR is opened. Check the task card in the dashboard for the outcome once it lands.

🤖 Model & Provider

Provider Codex CLI
Model gpt-5.5

⏱️ Timing

Started 2026-07-06 18:05:06 UTC
Finished 2026-07-06 18:09:33 UTC
Duration 4m 27s

📊 Token Usage

Metric Value
Input tokens 85,817
Cached input tokens 478,976
Output tokens 6,920
Total tokens 571,713
Invocations 1
Tool calls 25
Active time 3m 13s

Included usage estimate (subscription/local login): $0.88

🌿 Branch Info

Base: feature/CODUX-142-qs-code-quality-performance-audit-6
Head: task/feature-codux-142-qs-code-quality-performance-au-t06-codex-mr9j5pi5


🤖 Generated by Code UX

@numnx
numnx merged commit cb8040e into feature/CODUX-142-qs-code-quality-performance-audit-6 Jul 6, 2026
6 checks passed
@numnx
numnx deleted the task/feature-codux-142-qs-code-quality-performance-au-t06-codex-mr9j5pi5 branch July 6, 2026 18:13
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