Skip to content

feat(message): show past chat references and files in user message bubble#3338

Open
SuMuxi66 wants to merge 3 commits into
esengine:main-v2from
SuMuxi66:feature/user-message-reference-bubble
Open

feat(message): show past chat references and files in user message bubble#3338
SuMuxi66 wants to merge 3 commits into
esengine:main-v2from
SuMuxi66:feature/user-message-reference-bubble

Conversation

@SuMuxi66

@SuMuxi66 SuMuxi66 commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

概述

本 PR 是 #3336 合并后的 follow-up。

#3336 已经完成 past:chats 的选择、预览和上下文注入流程。本 PR 只补充发送后的展示能力:当用户消息引用了历史会话时,在用户消息气泡中展示对应的引用卡片。

改动内容

  • 将已选中的 past:chats references 随用户消息一起传入 transcript
  • 用户消息支持携带并渲染 references
  • 在用户消息气泡中展示历史会话引用卡片
  • 引用卡片展示会话标题、消息数量、文件名等信息
  • 调整用户消息气泡和引用卡片样式

范围说明

本 PR 只处理“发送后如何展示引用”的问题。

不修改:

  • past:chats 菜单选择逻辑
  • 历史会话预览逻辑
  • 上下文注入逻辑
  • @ 文件引用逻辑

验证

@github-actions github-actions Bot added the v2 Go rewrite (1.x) — main-v2 branch, active development label Jun 6, 2026

@SivanCola SivanCola left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, this is directionally useful, but I cannot approve it yet.

Required changes:

  • The send path waits for PreviewSession/buildSessionContext before calling onSend or clearing the composer. While that await is pending, the input and send button remain enabled, so pressing Enter or clicking send again can submit duplicate turns with the same referenced sessions. It also breaks the PR's stated "display immediately after send" behavior for referenced sends. Please snapshot/lock/clear the composer before the async session reads, or add an explicit sending guard that makes duplicate submission impossible.

  • The new past:chats UI is not wired into the existing keyboard menu state. menuMode only opens the @ menu when atMatches.length > 0, count still excludes the special/session rows, and pickActive() always calls pickEntry(atMatches[active]). This means the past-chat option can disappear when there are no file matches, and Enter/Tab cannot select a highlighted past-chat session. Please make past-chat rows first-class menu items for open/active/count/pick handling.

  • New visible UI strings are hard-coded in Chinese in Composer.tsx and Message.tsx. The desktop frontend has an existing en/zh dictionary contract, so English locale users will see mixed Chinese. Please add the required i18n keys in both locale files and use t(...)/useT() for visible text.

  • git diff --check origin/main-v2...origin/pr/3338 currently fails because docs/SESSION_REFERENCE_ARCHITECTURE.md contains trailing whitespace. Please clean that up before merge.

Integration notes:

  • This PR is still draft and stacked on #3336; it should be rebased after the core past-chats PR is finalized.
  • It also overlaps #3356 on user-message bubble styling, so one of the two PRs should become the integration source for that layout.

Verified locally:

  • wails generate module passed after creating the expected temporary frontend/dist placeholder in a throwaway worktree.
  • npm run build passed in desktop/frontend.
  • go test . -run 'TestPreviewSession|TestListSessions|TestHistory|TestSession' passed in desktop.
  • git merge-tree --write-tree origin/main-v2 origin/pr/3338 produced an auto-merge tree with no textual conflicts.

@SuMuxi66 SuMuxi66 changed the title feat(message): show referenced past chats in user message feat(message): show referenced past chats in user message and files Jun 7, 2026
@SuMuxi66 SuMuxi66 changed the title feat(message): show referenced past chats in user message and files feat(message): show referenced past chats and files in user message Jun 7, 2026
@SuMuxi66 SuMuxi66 changed the title feat(message): show referenced past chats and files in user message feat(message): show past chat references in user message bubble Jun 8, 2026
@SuMuxi66 SuMuxi66 changed the title feat(message): show past chat references in user message bubble feat(message): show past chat references and files in user message bubble Jun 8, 2026
@github-actions github-actions Bot added the desktop Wails desktop app (desktop/**) label Jun 8, 2026
@SuMuxi66 SuMuxi66 force-pushed the feature/user-message-reference-bubble branch from eeb7324 to 850e36d Compare June 8, 2026 02:10
@SuMuxi66 SuMuxi66 marked this pull request as ready for review June 8, 2026 02:15
@SuMuxi66 SuMuxi66 requested a review from esengine as a code owner June 8, 2026 02:15
@SuMuxi66 SuMuxi66 force-pushed the feature/user-message-reference-bubble branch from 850e36d to a9d4bd3 Compare June 8, 2026 06:55

@SivanCola SivanCola left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the follow-up changes. I re-reviewed the current head and the earlier blockers around duplicate sends, menu state, i18n, and diff --check look addressed now.

I still found a couple of issues that should be fixed before merge:

  • The referenced-session cards are not persisted. send() only passes references into the frontend reducer, while the backend history/display sidecar still stores only strings, and historyMessagesToItems() rebuilds user messages without references. So the cards appear right after sending, but disappear after reload/resume/history replay. Please persist the structured session refs alongside the display content and restore them when mapping history back to Items.

  • Message.tsx wraps a block <div className="msg__reference-item"> inside Tooltip, which defaults to a <span> trigger. That creates invalid DOM / React nesting warnings and can affect layout. Please use the Tooltip block mode here or change the child to an inline-compatible element.

  • A selected past-chat reference alone cannot be sent: the submit guard and send-button disabled condition still only count text, attachments, and workspace refs. If a session ref is meant to be usable as context by itself, include sessionRefs.length in those checks; if not, the UI should make the “question required” state explicit instead of showing an attached chip with a disabled send button.

Verified: git diff --check origin/main-v2...origin/pr/3338 passes on the current PR head.

@SuMuxi66 SuMuxi66 force-pushed the feature/user-message-reference-bubble branch 2 times, most recently from ae0057a to 177bd8b Compare June 8, 2026 14:17
@SuMuxi66

SuMuxi66 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

感谢 review,我已经按反馈修复了这三个 blocker。

本次更新:

  • "past:chats" references 现在会通过 ".references.json" sidecar 持久化,模式和现有 ".display.json" sidecar 保持一致。
  • "HistoryForTab()" 和 history-to-transcript 映射现在会恢复 references,所以刷新、继续会话、历史回放后,用户消息里的引用卡片不会丢失。
  • references 卡片块现在位于 ".msg__body" 下,不再嵌套进 Markdown paragraph / "

    " 内,避免非法 DOM 结构。

  • submit guard 和 send button disabled 逻辑都已加入 "sessionRefs.length === 0" 判断,因此只选择 past chat reference、正文为空时也可以发送。

验证结果:

  • reload 测试通过:浏览器刷新后,引用卡片仍然显示。
  • DOM 检查通过:reference card 的父节点是 ".msg__body"。
  • console 检查通过:没有前端错误。
  • "git diff --check" 通过。
  • Go 端 "go build"、"go vet" 和相关 history / preview 测试通过。
  • full frontend "tsc" 目前仍被既有的 "VirtualMenu.tsx" / "@tanstack/react-virtual" 依赖问题阻塞;本 PR 没有在改动文件中引入新的 TypeScript 错误。

@SuMuxi66 SuMuxi66 force-pushed the feature/user-message-reference-bubble branch from 177bd8b to d9e2c66 Compare June 10, 2026 04:32
@SuMuxi66 SuMuxi66 force-pushed the feature/user-message-reference-bubble branch from d9e2c66 to ad3615c Compare June 10, 2026 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants