Skip to content

ui: 结构化报价卡把 Quote.timestamp(epoch 秒)当毫秒渲染,「Updated」恒显示 1970 年 #216

Closed

Description

@wxrbyte

问题与复现

Copilot 在 get_quote 成功后会在右侧面板渲染结构化报价卡(packages/ui/src/components/agent/AgentPanel.tsx:306 → QuoteCard)。卡片右下角的「Updated」把 Quote.timestamp 直接交给 new Date(ts):

// packages/ui/src/components/agent/structured/QuoteCard.tsx:17-18
const fmtTime = (ts: number | null | undefined): string =>
  ts == null || Number.isNaN(ts) ? '—' : new Date(ts).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });

而 Quote.timestamp 的契约是 epoch 秒:

  • packages/core/src/index.ts:19 — Quote.timestamp(见 packages/core/src/market-data.ts:10-14「Timestamps are epoch SECONDS unless noted otherwise, matching the existing core convention (Quote.timestamp…)」);
  • packages/ui/src/atoms/quoteAtoms.ts:32 — 注释「Newest quote timestamp (epoch seconds)」;
  • packages/shared/src/capabilities/manifests/market-quote.ts:51 — marketTime: quote.timestamp * 1000。

于是真实报价时间被当成毫秒解释,恒落到 1970 年。

反例(可直接写成断言):timestamp = 1_710_000_000(= 2024-03-09T16:00:00Z)

「Updated」渲染值
实际(GMT+8,修复前) 03:00 ← 1970-01-20
预期 00:00 ← 2024-03-10

同仓四处对称写法都乘 1000,只有这一处漏了:SecurityHeader.tsx:181、ResearchMarketWorkspace.tsx:178、ChartView.tsx:132、FinancialKLineChart.tsx:34。

预期与修复方向

new Date(ts * 1000),与上述四处保持一致;保留 ts == null || Number.isNaN(ts) → '—' 的防御分支。

复现证据

  • 环境:Windows 11 (10.0.26200) + Bun 1.4.2;上游 main ba5dcdfd(干净检出)
  • 聚焦测试:bun test packages/ui/src/components/agent/structured/QuoteCard.test.tsx
    • 修复前 1 pass / 1 fail —— Expected to contain: "16:00" / Received: "QuoteAAPL.US$182.31+1.02 (+0.56%)…UPDATED19:00"(测试进程 TZ=UTC)
    • 修复后 2 pass / 0 fail
  • 全量:bun test packages/ui --isolate = 323 pass / 0 fail(含本组新增 2 条用例)
  • bun run typecheck:core / i18n / shared / ui / electron 全部 exit 0
  • 组件级截图(真实组件 + 真实 payload、Electron 渲染):Before UPDATED 03:00 / After UPDATED 00:00,见关联 PR

范围

仅改 packages/ui/src/components/agent/structured/QuoteCard.tsx 的 fmtTime(1 行 + 注释)。
不改 Quote 契约、不改其他组件、无布局/样式变化。

Activity

  1. wxrbyte commented on Sep 26, 2026

    @wxrbyte
    ContributorAuthor

    /claim

  2. added
    claimed
    on Sep 26, 2026
  3. github-actions commented on Sep 26, 2026

    @github-actions

    @wxrbyte 已认领该 Issue,并已自动设为 Assignee。提交 PR 时请在描述中写 Closes #216。

  4. added a commit that references this issue on Oct 18, 2026
    210b5c5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

claimed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions