Skip to content

feat(console): desk phases 8-9 — alerts, logs and the overview - #1097

Merged
Pigbibi merged 5 commits into
mainfrom
feat/desk-phase8-alerts-logs
Nov 9, 2026
Merged

Pigbibi merged 5 commits into
mainfrom
feat/desk-phase8-alerts-logs

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

AI assistance

WorkBuddy agent (DeepSeek V4.1) drafted both phases; the owner reviewed the scope and approved the CSS budget change. The owner will review this diff.

What changed

Meridian 控制台(#/desk)原来只有四个页面有内容:提醒、日志是 PageStub,总览只有 hero 和 needs-you 两段。本 PR 把这两块补齐,六个导航由此都有真实内容。

Phase 8 — 提醒与日志

契约 页面 内容
§3.17 alerts #/desk/alerts 严重程度筛选、未处理优先排序、已解决行、投递渠道面板
§3.18 alert_delivery 同页右栏 渠道状态(unknown ≠ failing)、最近投递、每日摘要
§3.19 logs #/desk/logs 今日时段 + 运行记录(取 ribbon.tape)+ 按级别筛选的日志尾巴

Phase 9 — 总览

契约和 fixture 里本来就有 totals / book / equity_curve,页面一个都没用。现在:

  • 头部:净资产、今日变动、覆盖度、数据新鲜度,以及一句话。三个计数共用同一个分母(正在运行的策略数),所以句子永远自洽。
  • 风险边界:回撤按上限画分段计量条;总敞口与杠杆 ETF 敞口;今日运行进度;配置偏离。
  • 净值走势:组合与基准共用一条刻度,下方是回撤带;没有基准就不画线,而不是画一条平线。
  • 六张策略卡:脱敏账户、今日变动、30 天曲线(在缺失日期处断开)、回撤计量条、保存=平台状态、最近运行。
  • 近期信号:取 ribbon.tape 前 5 条;读取失败会明说,不留空。

诚实态规则(本 PR 的边界)

  • 比率没有上限 → 计量条不填、显示未知,绝不当作 0 或安全。
  • 读不到的账户(runtime.unknown)不计入"正在运行",不会被算成正常。
  • 两个页面都只读;DESK_SOURCES 里 alerts / alertDelivery / logs 仍是 mock,后端路由不存在时不会发请求、不会写入。
  • 日志按文本渲染({line.message}),无 dangerouslySetInnerHTML。
  • 默认路由、部署、Secret 一律没动。

How verified

npm run build             # Size budget OK;CSS 21.7 KB gz(上限 22 KB,owner 已同意)
npm run test:operations   # 全绿,含 phase8 + overview 两个新校验
npm run check:style-guards # 仅 app.css 既有 1 条 warn-only
npm run sync:v2-assets    # 资产表已同步
node --experimental-strip-types --test tests/console_desk_delivery_validation.mjs  # 11/11

新增校验覆盖:六个 fixture 通过 guard;拒绝"已解决但无 resolved_at""未解决却带 resolved_at"、未知 severity、retention.days != 90、未知 level、redaction != applied;未处理优先排序;计数取自响应;日志总量取自 ribbon tape;总览的符号金额、计数同分母、计量条在缺失上限时不填、单点不成线、缺口断线;两页无写请求、无 HTML 注入。

Risk

  • R2:改前端源码 + 交换资产表;不触碰 Worker 路由、认证、Secret、默认入口。
  • check-budget.mjs 上限已由 20 KB 调至 22 KB gzip;本 PR 结束于 21.7 KB,余量约 300 字节。

The Meridian desk shipped with two of its six pages as stubs. This adds the
remaining pair against the contracts that already existed in schemas/desk
(API-CONTRACT.md 3.17-3.19), so all six dock destinations render real content.

- alerts: severity filters, open-first ordering, resolved rows, and the
  delivery channel panel; a resolved alert always carries its resolution time.
- logs: today's sessions and run tape from the ribbon, plus a level-filtered
  log tail rendered as text (never HTML).
- both read from fixtures; DESK_SOURCES keeps them mock until the backend
  routes exist, so nothing here can call a live endpoint.
- guards reject a resolved alert without resolved_at, an unknown level, a
  shortened retention window, and an unredacted tail.
- new console_desk_phase8_validation joins test:operations.
- css budget: 20 -> 22 KB gzip, since two real pages cost ~0.9 KB and the old
  ceiling had no slack left.
@Pigbibi Pigbibi added the agent-approved An agent cleared this high-risk change on the current head; not an owner confirmation label Nov 9, 2026
@Pigbibi

Pigbibi commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

governance head 1f28ea4 — 分支已合并最新 main(含 #1096),请按当前 head 出评审回执。

关注点:

  1. desk/alerts/model.ts / desk/logs/model.ts 为纯函数,页面不再持有排序与计数逻辑;
  2. 已解决提醒必须带 resolved_at,否则 guard 拒绝(schemas/desk/alerts.json §3.17);
  3. 日志按 {line.message} 文本渲染,无 dangerouslySetInnerHTML;
  4. DESK_SOURCES 三项仍为 mock,不产生任何网络写入;
  5. CSS 预算 20 → 22 KB gzip 已获 owner 同意。

@Pigbibi Pigbibi added agent-approved An agent cleared this high-risk change on the current head; not an owner confirmation and removed agent-approved An agent cleared this high-risk change on the current head; not an owner confirmation labels Nov 9, 2026
The overview rendered the hero and the needs-you list and stopped there, so the
page the desk opens on was the least informative screen in it. The contract and
the fixture already carried the rest: totals, the six book rows with their own
30-day paths, the equity curve with a benchmark and a drawdown series.

- headline figures: NAV, day change, coverage, freshness, and a sentence whose
  three counts share one denominator (running books), so it always adds up.
- risk envelope: a segmented meter for drawdown against its limit; gross and
  leveraged-ETF exposure as multiples; today's run progress; config drift.
- equity curve: portfolio and benchmark on one scale, the drawdown band below;
  no benchmark draws no line rather than a flat one.
- six book cards: masked account, day change, sparkline broken at gap dates,
  drawdown meter, saved-vs-platform state, last run.
- signals from the ribbon tape; a failed ribbon read says so instead of going blank.

A ratio without its limit fills no cells and reads unknown; an unreadable book
drops out of the running count instead of counting as fine.

- overview/model.ts holds the formatting, counting and plotting geometry, so the
  page holds no arithmetic.
- console_desk_overview_validation joins test:operations.
@Pigbibi Pigbibi changed the title feat(console): desk phase 8 — alerts and logs pages feat(console): desk phases 8-9 — alerts, logs and the overview Nov 9, 2026
@Pigbibi Pigbibi added agent-approved An agent cleared this high-risk change on the current head; not an owner confirmation and removed agent-approved An agent cleared this high-risk change on the current head; not an owner confirmation labels Nov 9, 2026
@Pigbibi

Pigbibi commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

新 head 00718cc(phase 9:补齐总览)。请按当前 head 出评审回执。

phase 9 关注点:

  1. desk/overview/model.ts 承载全部格式化、计数与绘图几何,页面不做算术;
  2. 三个计数共用同一分母(runtime known 且 running 的账户),句子不会出现 4+2≠5;
  3. 比率缺上限时计量条不填、显示未知,不当作 0 或安全;
  4. 单点数据不成线(返回 null 让页面说明),缺失日期处断开曲线;
  5. 只读,未改默认路由/部署/Secret。

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T11:11:17.534203Z dd63b3c Manual request
🔒 Security Review ✅ Completed 2026-11-09T11:13:13.378140Z dd63b3c Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 00718cc910

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 00718cc910

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

All four are honesty bugs rather than formatting nits.

- sparklines were drawn per segment with each segment scaled to the full width and
  its own min/max, so a series with a missing day produced two overlapping lines and
  no sense of when the gap happened. sparkPaths now places every point on the
  window's calendar and plots all runs on one shared x and y scale; a run of a
  single point draws nothing, and an unaligned series is drawn by index rather than
  split at a guessed date.
- the same function no longer falls back to the unsegmented series when every run
  is a single point, which had rejoined the line across the missing day.
- a running book whose config could not be read was counted as steady, so a page
  where no config was readable still claimed everything matched the saved plan.
  headlineCounts now counts those separately and the sentence says they are unknown.
- the logs page showed 'loading' forever when the ribbon failed, hiding sessions and
  runs with no error. It now says the runs could not be read and keeps the log tail.

console_desk_overview_validation covers the gap geometry exactly (both runs on one
timeline), the all-single-point case and the unreadable-config count.
@Pigbibi Pigbibi added agent-approved An agent cleared this high-risk change on the current head; not an owner confirmation and removed agent-approved An agent cleared this high-risk change on the current head; not an owner confirmation labels Nov 9, 2026
@Pigbibi

Pigbibi commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

新 head 30865f2 — 已按上一轮 4 个 P2 修复:

  1. sparkline 缺口:新增 sparkPaths,所有分段共用同一时间轴与同一纵轴;缺口两侧不再各自拉伸到满宽。测试锁定了精确坐标(10/11 日 → x 1、30.5;13/14 日 → x 89.5、119)。
  2. 全单点回退:不再回退成未分段的原始序列,改为返回空,页面显示「没有可用走势」。
  3. 配置未知算作稳定:headlineCounts 增加 configUnknown,运行中但配置读不到的账户单独计数,文案改为「{unknown} 条配置未知」,不再声称全部一致。
  4. 日志页 ribbon 失败:标题直接显示「运行记录读取失败」,并给出说明卡;不再无限停留「加载中」。

本地:tsc --noEmit 通过,npm run build 预算 OK(CSS 21.7 KB gz),npm run test:operations 全绿,console_desk_delivery_validation 11/11。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 30865f2c45

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 30865f2c45

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Second review round, three findings.

- the alert fixtures carried Chinese titles and details, so the English UI showed
  English filters over Chinese bodies. Fixture copy is now a key translated by
  deskText, which passes a live server string through untouched instead of
  mistaking it for a key.
- an unreadable runtime was reported as 'no strategy is running'. It now reports
  how many accounts could not be confirmed; only confirmed-stopped accounts reach
  the 'nothing is running' sentence.
- the logs headline counted the tape's entries and called them today's runs, which
  contradicted the overview's 11-of-12. The copy now says what the list is: runs
  confirmed complete in this list.
@Pigbibi Pigbibi added agent-approved An agent cleared this high-risk change on the current head; not an owner confirmation and removed agent-approved An agent cleared this high-risk change on the current head; not an owner confirmation labels Nov 9, 2026
@Pigbibi

Pigbibi commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

新 head(第三轮)已修完上一轮 3 条:

  1. P1 告警中文:fixture 的标题/说明改为文案键(alerts.mock.*),渲染走 deskText():键 → 翻译,真实服务端文本原样透传。测试断言 zh 命中中文、en 命中英文、任意服务端字符串不被当作键。
  2. 运行状态未知被说成"没有策略运行":headlineCounts 增加 runtimeUnknown,running === 0 且存在未知账户时改说"无法确认是否有策略在运行:{unknown} 个账户状态未知"。
  3. 日志页把 tape 条数当作今日总数:文案改为"本列表内已确认完成 {runs} 条,其中 {drift} 条偏离",不再与总览的 11/12 冲突。

上一轮讨论串已全部 resolve(改动对应位置)。本地:tsc --noEmit 通过、npm run build 预算 OK(21.7 KB gz)、npm run test:operations 全绿、delivery 11/11。

@Pigbibi
Pigbibi marked this pull request as ready for review November 9, 2026 10:20
@Pigbibi
Pigbibi merged commit dd63b3c into main Nov 9, 2026
21 of 24 checks passed
@Pigbibi
Pigbibi deleted the feat/desk-phase8-alerts-logs branch November 9, 2026 10:26
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: dd63b3c8b7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: dd63b3c8b7

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-approved An agent cleared this high-risk change on the current head; not an owner confirmation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant