feat(admin): refine dashboard UX, review modal, and history tabs - #44
Conversation
Move staff homepage to /admin?date= with calendar metrics, attention patient cards, and history-overview deep links so triage is not today-only. Co-authored-by: Cursor <cursoragent@cursor.com>
Polish the date-selectable workbench with week/mobile calendar, master-detail patient panel with in-app upload review, 歷史總覽 tab split, upload trend chart, and dashboard demo seed for UI review. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Summary
Solid admin dashboard v2: date-selectable daily workbench, patient triage pool with review modal, enriched calendar metrics (upload_count, uploaded_users, unhandled_patient_count), and history-overview tab split. Backend adds GET /v1/staff/uploads/today-attention with good test coverage (partitioning, local_date, staff scope). FE decomposition is clean and URL-driven date state (useAdminSelectedDate) is a nice touch.
Strengths
- Triage logic is well thought out — tier partitioning, representative upload selection, risk highlight ranking, and sort order are documented and covered by
test_staff_today_attention_api.py. - Access control preserved — staff assignment scoping on the new endpoint; calendar
unhandled_patient_countmirrors attention semantics. - Component extraction — admin homepage went from a monolith to focused
today-*/ calendar / review-modal pieces; history overview gainsUsageTrendsTab+ shared annotation helpers. - DX —
seed:dashboard-demoscript and local-dev doc note help verify without LINE.
Minor nits (non-blocking)
UploadThumbissues one image-access request per thumbnail — on a busy day with many cards this can fan out quickly. Consider reusinguseUploadImageUrlsat the pool level (like the review modal does) or a small request cache.recent-upload-thumbs.tsxappears unused — design spec says remove homepage thumbs; safe to delete the orphan file in a follow-up._count_unhandled_for_dayduplicateslist_today_attention_patientsrepresentative logic — works today and is tested, but a shared helper would reduce drift risk if triage rules change.admin/page.tsxduplicates fetch logic betweenrefreshAttentionand theuseEffect— minor DRY cleanup opportunity.
Verification
Static review in cloud env (pytest/eslint not installed locally here). CI was still pending at review time — backend tests + FE unit tests are the gate.
Verdict: Approve — ship after CI green. Monitor thumbnail API fan-out on prod-like data volumes.
Sent by Cursor Automation: PD Care PR Reviewer
|
|
||
| useEffect(() => { | ||
| let cancelled = false; | ||
| void fetchUploadImageAccess(uploadId) |
There was a problem hiding this comment.
Each UploadThumb fires its own fetchUploadImageAccess call. On a grid with dozens of patients (risk highlight + preview thumbs), this can create a burst of parallel requests on dashboard load. The review modal already batches via useUploadImageUrls — consider lifting batching to TodayPatientPool / row level, or adding a lightweight in-memory dedupe cache.
| error: string | null; | ||
| }; | ||
|
|
||
| export function RecentUploadThumbs({ items, loading, error }: RecentUploadThumbsProps) { |
There was a problem hiding this comment.
This component doesn't appear imported anywhere in apps/ (design doc also calls for removing homepage RecentUploadThumbs). Fine to land as-is, but worth deleting in a follow-up to avoid dead code.
| return suspected_patient_ids, elevated_patient_ids, rate_patient_ids | ||
|
|
||
|
|
||
| def _count_unhandled_for_day(day_rows: list[_RawUploadRow]) -> int: |
There was a problem hiding this comment.
_count_unhandled_for_day mirrors representative-selection + has_annotation semantics from list_today_attention_patients. The inline comment helps, but if triage rules evolve this is a drift hotspot — a shared helper (even a small internal function in staff_dashboard.py) would keep calendar badges and the workbench in sync.
| const [metricsByDate, setMetricsByDate] = useState<Record<string, DayCalendarMetrics>>({}); | ||
| const [calendarLoading, setCalendarLoading] = useState(true); | ||
|
|
||
| const refreshAttention = useCallback(() => { |
There was a problem hiding this comment.
refreshAttention and the useEffect below both fetch fetchTodayAttention with nearly identical success/error handling. Could DRY into one loader invoked from the effect and onReviewSaved to reduce future divergence.
Extract attention triage so today-attention and calendar unhandled counts stay aligned; batch upload image URLs in the patient pool; seed showcase days (today + Aug 6) with all 12 demo patients using UTC timestamps. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@cursoragent review again |
Re-review summaryPrior bot feedback is largely addressed in commit Prior feedback — resolved
What looks good
Blocker — out of scope regressionThis PR removes Onboarding bootstrap timing also changed: after bind, onboarding now always calls Nits (non-blocking)
Verification
Recommendation: Revert or isolate the identity/onboarding changes; the admin dashboard work itself looks ready to merge. Posted the full review as a PR comment on #44. I can revert |
Re-review (follow-up to prior bot comments)Prior feedback — status
What looks good
Blockers / scope concerns
Nits (non-blocking)
Verification run on this agent
Recommendation: Address or revert the identity/onboarding changes before merge; admin dashboard work itself looks ready. |
Revert identity bind retry, structured LINE verify errors, and guarded onboarding bootstrap redirect so admin dashboard work does not regress transient LINE verify handling. Co-authored-by: Cursor <cursoragent@cursor.com>
Identity routes from main require LineTokenVerifyError and line_verify_http; restore matching auth provider and bootstrap routes so backend imports and local stub login work again. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@cursoragent run CI on ur own machine because github actions is down now |
Local CI completeRan the full
One environment gotchaBackend tests initially failed (133 failures) because this cloud VM has The GitHub K8s manifest render failure ( Posted full results as a PR comment on #44. From a CI perspective this branch is green; the prior review note about reverting |
Local CI run (GitHub Actions unavailable)Ran the full
Environment notes
Verdict: CI-equivalent checks pass locally; safe to merge from a test/build perspective (identity/onboarding scope concern from prior review still applies). |



Summary
Test plan