Skip to content

fix(dashboard): normalize task modal timestamps to local time#282

Open
luoyanglang wants to merge 1 commit intocft0808:mainfrom
luoyanglang:wolf/fix-task-modal-timezone-consistency
Open

fix(dashboard): normalize task modal timestamps to local time#282
luoyanglang wants to merge 1 commit intocft0808:mainfrom
luoyanglang:wolf/fix-task-modal-timezone-consistency

Conversation

@luoyanglang
Copy link
Copy Markdown
Contributor

Summary

Issue: #277 - 任务详情弹窗内多个时间字段存在时区口径不一致问题
Type: Bug Fix
Severity: Medium

This PR normalizes timestamp parsing inside the task detail modal so all relevant time fields are rendered in the browser's local timezone. It removes the current UTC/local mix across scheduler info, flow log entries, and live activity timestamps.


Root Cause

The task detail modal was using multiple incompatible display paths for the same class of timestamp values:

  • edict/frontend/src/components/TaskModal.tsx:46
    • fmtActivityTime() returned ts.substring(11, 19) for string timestamps, which displayed raw UTC clock text instead of local time.
  • edict/frontend/src/components/TaskModal.tsx:300
    • scheduler timestamps (lastProgressAt / lastDispatchAt) were rendered via string slicing as well.
  • edict/frontend/src/components/TaskModal.tsx:363
    • flow log timestamps were also truncated directly from the ISO string.
  • dashboard/server.py already emits UTC ISO timestamps via now_iso(), so the data source was mostly consistent; the inconsistency came from the frontend display logic.
// Before
flow.at            -> substring(...)
scheduler.at       -> replace('T', ' ').substring(...)
activity.at        -> substring(...)
// After
flow.at            -> shared local-time formatter
scheduler.at       -> shared local datetime formatter
activity.at        -> shared local-time formatter

Fix Description

Changed files:

  • edict/frontend/src/time.ts:1 - add a shared timestamp parser/formatter that normalizes UTC-ish strings and numeric timestamps into browser-local display values
  • edict/frontend/src/components/TaskModal.tsx:4 - import the shared formatter utilities
  • edict/frontend/src/components/TaskModal.tsx:46 - route activity timestamps through the shared local formatter
  • edict/frontend/src/components/TaskModal.tsx:300 - render scheduler timestamps with unified local datetime formatting
  • edict/frontend/src/components/TaskModal.tsx:363 - render flow log timestamps with the same local parsing logic
  • edict/frontend/src/components/TaskModal.tsx:456 - align the “最后活跃” summary line with the same formatter

Why this approach:

  • It keeps the fix scoped to the actual bug surface: the task detail modal.
  • It avoids changing backend timestamp storage or API semantics.
  • It preserves each section's existing display granularity (YYYY-MM-DD HH:mm:ss, HH:mm, HH:mm:ss) while unifying timezone handling.

Test Results

Test Description Status
npm.cmd install Install missing local frontend dependencies so TypeScript/Vite build can run in this workspace PASS
npm.cmd run build Type-check and production-build the frontend after the timestamp formatting change PASS

Manual verification target:

  1. Open a task detail modal.
  2. Compare 最近进展 / 最近派发, flow log timestamps, 最近更新, and activity item timestamps.
  3. Confirm they all now render in the same local timezone basis.

Disprove Analysis

Is this already fixed elsewhere?

Impact scope

  • The change is limited to the React task detail modal.
  • Backend APIs and timestamp generation remain unchanged.
  • Display precision stays consistent with the existing UI intent.

Edge cases

  • Numeric timestamps are normalized as seconds-or-milliseconds before formatting.
  • ISO-like strings without explicit timezone suffix are treated as UTC for consistent rendering with current dashboard data.
  • Invalid/empty timestamps still degrade to empty display strings instead of throwing.

Known limitation

  • This PR only fixes the React task modal path served from dashboard/dist.
  • It does not attempt to refactor every other historical timestamp formatter in the repo.

Checklist

  • 代码遵循现有项目风格
  • 相关 issue 编号已在 PR 描述中引用(#277
  • 已提供构建验证与手动验证口径
  • 未引入硬编码路径、密钥或调试输出

Found during issue triage and reproduced through code-path inspection of the current dashboard modal. Happy to adjust if you prefer a different timestamp normalization policy.

@luoyanglang luoyanglang requested a review from cft0808 as a code owner April 12, 2026 07:11
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