fix(sidebar): 编辑重发后进入分支会话,不再被过期的侧栏刷新抹掉 by AlphaCatMeow · Pull Request #1036 · Stack-Cairn/LiveAgent · GitHub
Skip to content

fix(sidebar): 编辑重发后进入分支会话,不再被过期的侧栏刷新抹掉 - #1036

Merged
xiaozhou26 merged 1 commit into
Stack-Cairn:v2-kbrianfrom
AlphaCatMeow:fix/edit-resend-branch-navigation
Oct 20, 2026
Merged

xiaozhou26 merged 1 commit into
Stack-Cairn:v2-kbrianfrom
AlphaCatMeow:fix/edit-resend-branch-navigation

Conversation

@AlphaCatMeow

Copy link
Copy Markdown
Contributor

编辑会话第一条用户消息重发时,分支会话已经创建,界面却停在"新对话"空白页。根因:编辑重发建分支后 sidebarStore.upsertLocal 写入分支会话,若此前已发出的侧栏首页刷新在写入之后才返回,reconcileSidebarConversations 会把不在结果里、非 pending、非保留的分支会话合并掉;ChatPage 发现当前会话从列表消失且未在发送,就自动新建对话。

Closes #1034

改动

  • 侧栏 store 为本地写入记序号(localUpsertSeq / localUpsertSeqById);首页请求开始时记下当时的序号。结果返回时,晚于该请求的本地写入一律保留(这次结果不可能知道它),早于请求的写入由这次结果决定去留并清除记录。
  • 写入之后才发出的刷新照常以服务端为准:包含即确认,不含即移除;removeLocal 同步清除记录,Map 大小不超过会话数。
  • GUI 与 WebUI 共用该 store。

截图

桌面 GUI(调试版真机):编辑首条消息并发送后,3.3 秒内进入新建的分支会话(侧栏选中项带分支图标),全程未出现新对话页。

桌面:编辑重发进入分支会话

验证

  • 基线:upstream/v2-kbrian 7e6291b
  • 静态:typecheck:ui / gui / webui 通过;biome(LF)通过;check-ui-boundaries 通过;git diff --check 通过
  • 新增测试:
    • test/chat/sidebar-store.test.mjs 2 条:写入之前发出的刷新晚到时不抹掉分支(修复前 UI 先看到 ["source"]);写入之后发出且不含它的刷新照常移除。
    • test/chat/sidebar-upsert-seq-probes.test.mjs 9 条探针:排队刷新、scope 切换、工作区历史/置顶列表、别处删除、重连、stop/start、频繁写入等路径(其中 3 条修复前失败)。
  • 全量(7 个批次全部运行):总计 3888,通过 3884,失败 3,跳过 1;3 个失败均为本机环境性失败(cargo 冒烟用例超过其 180 秒上限,直接 cargo test 为 1086 通过 / 23 失败,23 条均为 Windows 基线环境失败,本 PR 不改 src-tauri;两条按 CWD 读源码,在 crates/agent-gui 下重跑通过)
  • 对抗复审:独立子代理复审,未发现阻止合并的问题。
  • 真机:调试版编辑首条消息重发,逐 100ms 记录界面,全程未出现新对话页并进入分支会话;用户按验收步骤(首条与中间消息)验收通过。
  • 未覆盖:保留期间 totalCount 暂时比可见行少 1,下一次刷新纠正(仅显示)。

…eshes

Edit-resend creates a branch conversation and upserts it into the sidebar.
A first-page refresh issued before the branch existed could land afterwards
and reconcile it away; ChatPage then saw the current conversation vanish and
opened a new blank chat. Local upserts now carry a sequence number: a
first-page response keeps rows upserted after its request started and only
settles rows it could have known about. Later refreshes stay authoritative.

Closes Stack-Cairn#1034

@xiaozhou26 xiaozhou26 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed first-page request/upsert sequencing and authoritative post-upsert reconciliation. Passed stale/queued refresh, scope round trip, workspace history, deletion, failed request, reconnect, stop/start, and repeated-upsert regressions. No blocker found.

Integration review: all five PR heads merged locally without conflicts. Shared UI, GUI and WebUI typechecks passed; GUI frontend 3398 passed / 4 skipped, WebUI 808 passed; both Vite production builds, UI boundaries and diff whitespace checks passed. Browser verification used real shared components with fixture callbacks, not a native Tauri or live-provider end-to-end run. No new release requested.

@xiaozhou26
xiaozhou26 merged commit 2075465 into Stack-Cairn:v2-kbrian Oct 20, 2026
12 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.

2 participants