feat: implement live temperature threshold chart logic with auto-visibility policies and snapshot testing

This commit is contained in:
2569718930@qq.com
2026-05-26 23:12:48 +08:00
parent 645e304b3e
commit b6194b4756
6 changed files with 1829 additions and 1475 deletions
@@ -0,0 +1,26 @@
# Live Temperature Chart Split Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Split `LiveTemperatureThresholdChart.tsx` so chart data generation and SSE patch merge logic live in focused pure modules, while the visible chart behavior stays unchanged.
**Architecture:** Keep the React component as the orchestration/rendering layer. Move types, constants, time helpers, series builders, fallback rules, and patch merge into adjacent modules under `frontend/components/dashboard/scan-terminal/`. Preserve existing test exports through the component file during the first split to avoid changing test callers.
**Tech Stack:** Next.js/React, TypeScript, Recharts, existing business-state test runner.
---
## Files
- Create: `frontend/components/dashboard/scan-terminal/temperature-chart-logic.ts`
- Modify: `frontend/components/dashboard/scan-terminal/LiveTemperatureThresholdChart.tsx`
- Modify: `frontend/components/dashboard/scan-terminal/__tests__/ssePatchArchitecture.test.ts`
- Verify: `frontend/components/dashboard/scan-terminal/__tests__/temperatureDefaultVisibilityPolicy.test.ts`
## Tasks
- [ ] Add a failing architecture test that rejects keeping all chart data builders inside `LiveTemperatureThresholdChart.tsx`.
- [ ] Extract pure chart logic into `temperature-chart-logic.ts`.
- [ ] Import extracted functions/types back into `LiveTemperatureThresholdChart.tsx`.
- [ ] Keep the current test-only exports stable from `LiveTemperatureThresholdChart.tsx`.
- [ ] Run `npm run test:business`, `npm run typecheck`, and `npm run build`.