Skip to content

fix(chat): wrap long slash command chips in the transcript (#1019) - #1031

Merged
vastsa merged 3 commits into
vastsa:mainfrom
yuxino:fix/transcript-command-chip-wrap
Sep 24, 2026
Merged

vastsa merged 3 commits into
vastsa:mainfrom
yuxino:fix/transcript-command-chip-wrap

Conversation

@yuxino

@yuxino yuxino commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem / 问题

在输入框选择一个 Skill(如 /nature-polishing),粘贴多段较长文字后发送,聊天记录中的用户消息被渲染为单行命令 chip,超出气泡宽度时以省略号截断;同样的正文不带 Skill 时可以正常换行(与 issue #1019 的现象一致)。

修复前:Skill 消息与普通消息的对比(同一段正文)——

before

原因:.chat-command-chip 沿用了短 slash 命令时代的 white-space: nowrap + text-overflow: ellipsis。D393 / ADR 0219 之后,Skill 调用的 typed form(命令名 + 用户整段正文)也存入 command 字段并渲染为同一个 chip,单行截断对这种内容不再成立。普通消息容器 .message-user-text 本身是 pre-wrap + overflow-wrap: break-word 的换行模型,chip 把它覆盖了。

Proposed change / 期望改动

让 chip 跟随 .message-user-text 的换行模型:white-space: pre-wrap、overflow-wrap: anywhere,移除 overflow: hidden / text-overflow: ellipsis;加 vertical-align: top,多行 chip 与单行一样贴齐气泡。短命令(/compact 等)仍是紧凑单行 chip。规范只要求记录中以等宽命令 chip 呈现 typed form(component-spec §11.8),未要求单行,无规范改动。

修复后:正文按气泡宽度换行、段落与超长 token 均正常折行——

after

Verification / 验证

  • 本地 harness(真实 ChatTranscript 组件 + 构建产物样式,Electron 内量几何):修复前长 chip 单行 23.4px、内容水平被裁约 2998px;修复后约 13 行,段落换行保留,无水平裁剪,不超出气泡;/compact 短 chip 仍为单行。即上文两张截图。
  • pnpm --filter @pi-desktop/desktop typecheck 通过;node scripts/e2e-transcript-render.mjs、node scripts/e2e-composer-autocomplete.mjs 通过。
  • 基线 35d690374 的 2 处样式违规和 13 项 desktop 测试失败已在后续提交修复(见下方)。

CI 跟进修复

首次 CI 被主分支已有的样式违规阻塞。后续提交保留原有换行改动,并修复阻塞项:

  • 菜单行高和浅色描边使用现有设计变量;移除覆盖统一滚动条规则的局部样式。
  • 恢复共享 SegmentedControl 在 Import / Remote Hosts 页面的稳定 tab-panel 关联,覆盖切换选项和切换语言后的行为。
  • 更新重构后失效的源码断言(共享控件、语音独立设置页、紧凑菜单尺寸),收窄交通灯检查,避免把无关的纵向间距误判为横向预留。
  • Electron 主题检查等待初始 Tab 焦点事件后再采样,消除键盘输入与首次阴影检查之间的竞争;修复后连续三次通过。

本地验证:pnpm build:js、desktop typecheck、pnpm lint、架构检查通过;完整 JS 测试 5,460 项通过、1 项按既有条件跳过。e2e-transcript-render、e2e-composer-autocomplete、e2e-theme-surfaces 通过。当前基线 35d690374;远端 CI 结果以本 PR checks 为准。

Fixes #1019

The transcript chip for typed slash invocations kept the single-line
truncation written for short commands like /compact: white-space nowrap
with a text-overflow ellipsis. Skill invocations (D393/ADR 0219) store
the user's whole typed body in the same command field, so sending a
long skill invocation collapsed the message to one ellipsized line
that could not be read.

Drop the truncation rules and let the chip follow the wrapping model of
.message-user-text (white-space pre-wrap, overflow-wrap anywhere), so
the typed body wraps at the bubble edge with the user's paragraph
breaks preserved and long unbroken tokens cannot overflow. Vertical
alignment moves to the top so multi-line chips sit flush with the
bubble like single-line ones. Short commands remain compact
single-line chips.
Restore stable tab-panel associations after the shared control migration
and keep composer menus on the existing theme and scrollbar contracts.
These regressions blocked CI independently of transcript command wrapping.

Update stale source assertions for the current settings and compact menu
layout, and cover localized tab associations and selection semantics with
a rendered shared-control regression test.
Electron delivers synthetic Tab input asynchronously. Wait for the first
search field to receive focus before the probe blurs it, so the initial
unfocused paint sample cannot race with the keyboard focus seed.
@vastsa
vastsa force-pushed the fix/transcript-command-chip-wrap branch from 7443f68 to 7e20006 Compare September 24, 2026 18:31
@yuxino

yuxino commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

@vastsa 佬,中秋快乐,晚安

@vastsa
vastsa merged commit d9f6e02 into vastsa:main Sep 24, 2026
3 of 4 checks passed
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.

[Feature] 使用 Skill 发送长消息后,用户消息被单行截断,无法自动换行

2 participants