Skip to content

web: improve system message display + add systemMessages verbosity level#11

Merged
justinchuby merged 2 commits into
mainfrom
feat/web-system-message-display
Jun 14, 2026
Merged

web: improve system message display + add systemMessages verbosity level#11
justinchuby merged 2 commits into
mainfrom
feat/web-system-message-display

Conversation

@justinchuby

Copy link
Copy Markdown
Member

问题

聊天里的 System Message 全部用一个居中的圆角 pill 渲染。内容短还行,但长内容(spawn 失败的报错 + stack trace、转发给 agent 的整段 steer 文本)塞进 pill 就变成又宽又丑的一坨。而且系统消息在所有详细程度下都无条件显示,没有 off/summary/detail 分级。

改动

1. 渲染改造(Chat.tsx

按内容分类后分流渲染(新增 SystemMessage 组件):

类型 判定 渲染
error ⚠️//🛑 开头或含 "failed" 左边框告警卡片;长内容折叠成一行摘要 + 可展开正文(stack trace 不再溢出)
notice 普通操作通知 短 → pill(保持原样);长 → 居中可折叠一行
debug 转发 steer(system DM)、[scout]/orchestrator 内部 同 notice,但置灰

2. 详细程度(shared/display.ts

  • DisplayConfig 新增 systemMessages (off/summary/detail),并接入四个预设:
    • minimal / summary → off,detail → summary,debug → detail
  • 新增 classifySystemMessage()shouldShowSystemMessage() helper。
  • 错误消息始终显示(无视该设置),确保失败永远不会被藏起来;notice 在 summary 及以上显示,debug 类仅在 detail 显示。
  • Chat 的过滤逻辑接入该设置;DisplaySettings 新增 "System messages" 选择器。

各类信息 × 模式 显示表

信息类型 配置项 minimal summary detail debug
用户 / Lead / Agent 正文 始终
Thinking thinking
普通工具 toolCalls summary detail detail
Flightdeck 工具 flightdeckTools summary detail
Agent↔Agent DM agentMessages summary detail detail
System:error 始终
System:notice systemMessages summary detail
System:debug systemMessages detail

测试

  • shared:分类 + 可见性单测(display.test.ts,+8 用例)
  • web:系统消息渲染/门控测试(Chat.test.tsx,+3 用例)
  • 全量:server 838 passing、web 132 passing,无新增 lint 错误。

说明:我把系统消息拆成「错误」和「信息/调试」两类——错误属于上一个需求里"出错要直接告诉用户"的范畴,所以始终可见;其余噪音才按 detail/debug 收敛。这样比"全部只在 debug 显示"更安全。

System messages in the chat were all rendered as a centered pill, which
looks bad for long content (spawn errors with stack traces, forwarded
steer text). They were also always visible at every verbosity level.

Rendering (Chat.tsx):
- Classify system messages as error / notice / debug.
- error  → alert card with left border; long content collapses into a
  one-line summary + expandable body (stack traces no longer overflow).
- notice → short stays a pill; long becomes a centered collapsible one-liner.
- debug  → same as notice but muted.

Verbosity (shared/display.ts):
- New `systemMessages` ToolVisibility on DisplayConfig + presets
  (minimal/summary: off, detail: summary, debug: detail).
- `classifySystemMessage` + `shouldShowSystemMessage` helpers.
- Errors ALWAYS show regardless of the setting, so failures are never
  hidden; notices show at summary+, debug-class only at detail.
- Chat filtering honors the setting; DisplaySettings gains a "System
  messages" selector.

Tests: classification + visibility unit tests (shared), system message
rendering/gating tests (web). Full server suite 838 passing, web 132
passing, no new lint errors.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI 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.

Pull request overview

This PR improves how system chat messages are displayed in the web UI (avoiding oversized “pill” rendering for long operational messages) and introduces a new DisplayConfig.systemMessages verbosity level (off/summary/detail) in the shared display configuration to gate non-error system chatter while keeping failures always visible.

Changes:

  • Web: Add a dedicated SystemMessage renderer that classifies system messages and uses collapsible layouts for long content; integrate config-based gating into chat rendering.
  • Shared: Extend DisplayConfig with systemMessages, add classifySystemMessage() / shouldShowSystemMessage(), and wire the field into presets + config validation/merge.
  • Tests: Add unit tests for classification/visibility (server) and rendering/gating behavior (web).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/web/src/pages/Chat.tsx Adds SystemMessage rendering + config gating for system messages in the main chat feed.
packages/web/src/components/DisplaySettings.tsx Adds a “System messages” visibility selector to the display settings dialog.
packages/web/src/tests/Chat.test.tsx Adds coverage for system message gating and long-error collapsible rendering.
packages/shared/src/display.ts Introduces systemMessages in DisplayConfig, presets, validation/merge, plus system message classification + visibility helpers.
packages/server/tests/display/display.test.ts Adds tests for the new shared system message helpers and preset defaults.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/web/src/pages/Chat.tsx
Comment thread packages/shared/src/display.ts
Comment thread packages/shared/src/display.ts
- Chat.tsx: fix emoji-stripping regex in the error summary header so it
  consumes the U+FE0F variation selector (and repeated emoji), preventing a
  stray combining character at the start of "⚠️"-prefixed summaries.
- display.ts: reword the systemMessages JSDoc to describe only the gating
  contract enforced by shouldShowSystemMessage; layout (pill vs collapsible)
  is documented as a renderer concern, not part of the shared contract.
- display.ts: classifySystemMessage now scans the WHOLE message for failure
  keywords (failed/failure/error/exception/stack trace/panic/crash) instead
  of only the first 80 chars, so a failure keyword appearing after a prefix
  line still classifies as 'error' and is always shown. A failure keyword now
  also wins over the DM/scout debug heuristics.

Tests: added cases for late failure keywords and failure-keyword DMs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@justinchuby justinchuby merged commit e688a04 into main Jun 14, 2026
1 of 3 checks passed
@justinchuby justinchuby deleted the feat/web-system-message-display branch June 14, 2026 17:28
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.

2 participants