Skip to content

fix(conversation): sync renamed titles with detail view#1927

Merged
piorpua merged 1 commit intoiOfficeAI:mainfrom
cdxiaodong:fix/1405-title-rename-sync
Mar 30, 2026
Merged

fix(conversation): sync renamed titles with detail view#1927
piorpua merged 1 commit intoiOfficeAI:mainfrom
cdxiaodong:fix/1405-title-rename-sync

Conversation

@cdxiaodong
Copy link
Copy Markdown
Member

Summary

  • refresh the active conversation SWR cache after a rename succeeds
  • apply the cache refresh in the title editor, grouped history rename flow, and legacy chat history rename flow
  • add regression tests for conversation cache refresh behavior

Testing

  • bun run format
  • bun run lint
  • bunx tsc --noEmit
  • bunx vitest run
  • bun run test

Closes #1405

@sentry
Copy link
Copy Markdown

sentry bot commented Mar 30, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...erer/pages/conversation/components/ChatHistory.tsx 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@piorpua piorpua added the bot:reviewing Review in progress (mutex) label Mar 30, 2026
@piorpua
Copy link
Copy Markdown
Contributor

piorpua commented Mar 30, 2026

Code Review:fix(conversation): sync renamed titles with detail view (#1927)

变更概述

此 PR 修复了会话重命名后 SWR 缓存未刷新导致详情视图标题不同步的问题。新增 conversationCache.ts 工具函数,并在三处重命名流程(useTitleRenameuseConversationActionsChatHistory)中统一调用。同步新增了针对缓存刷新逻辑的回归测试。


方案评估

结论:✅ 方案合理

将 SWR mutate 调用封装到 refreshConversationCache 工具函数中,方案轻量且内聚,与项目 SWR 使用惯例一致。三处调用点均在 IPC 成功响应后、UI 更新前触发,顺序正确。无过度抽象或设计盲点。


问题清单

🔵 LOW — ChatHistory.tsx 的 handleEditSave 未被测试覆盖

文件src/renderer/pages/conversation/components/ChatHistory.tsx,第 159 行

问题代码

await refreshConversationCache(editingId);

问题说明:Codecov 报告显示此行 patch 覆盖率为 0%。另外两处调用点(useTitleRenameuseConversationActions)均有对应测试,但 ChatHistoryhandleEditSave 分支缺失。

修复建议:在 tests/unit/ 中为 ChatHistory 组件添加 handleEditSave 成功路径的测试,验证 refreshConversationCache 被以 editingId 调用。


🔵 LOW — conversationCache.ts 的 .catch() 路径未覆盖

文件src/renderer/pages/conversation/utils/conversationCache.ts,第 12 行

问题代码

const conversation = await ipcBridge.conversation.get.invoke({ id: conversationId }).catch((): null => null);

问题说明conversationCache.test.ts 仅测试了 mockResolvedValue(null) 情形(IPC 返回 null),未测试 IPC 抛出异常(mockRejectedValue)时 .catch() 分支的行为。

修复建议

it('skips cache updates when IPC throws', async () => {
  getConversationMock.mockRejectedValue(new Error('IPC error'));
  await refreshConversationCache('some-id');
  expect(mutateMock).not.toHaveBeenCalled();
});

汇总

# 严重级别 文件 问题
1 🔵 LOW ChatHistory.tsx:159 handleEditSave 缺少测试覆盖
2 🔵 LOW conversationCache.ts:12 .catch() 异常路径未测试

结论

批准合并 — 无阻塞性问题,两个 LOW 级别问题均为测试补充建议,不影响功能正确性。


本报告由本地 pr-review skill 生成,包含完整项目上下文,无截断限制。

CONCLUSION: APPROVED
IS_CRITICAL_PATH: false
PR_NUMBER: 1927

@piorpua
Copy link
Copy Markdown
Contributor

piorpua commented Mar 30, 2026

✅ 已自动 review,无阻塞性问题,正在触发自动合并。

@piorpua piorpua merged commit 563b587 into iOfficeAI:main Mar 30, 2026
14 checks passed
@piorpua piorpua added bot:done Auto-merged by bot and removed bot:reviewing Review in progress (mutex) labels Mar 30, 2026
wuhao1477 added a commit to wuhao1477/AionUi that referenced this pull request Mar 30, 2026
* 'main' of github.com:wuhao1477/AionUi: (40 commits)
  fix(agents): prevent unhandled promise rejection in bootstrap initialization (iOfficeAI#1933)
  fix(gemini): restore context after stopping a reply (iOfficeAI#1932)
  fix(codex): reject start promise immediately on process exit during startup (iOfficeAI#1929)
  fix(conversation): sync renamed titles with detail view (iOfficeAI#1927)
  fix(paste): deduplicate filenames when pasting multiple images simultaneously
  fix(mobile): add SafeArea support and update app icon (iOfficeAI#1926)
  fix(database): guard against undefined params in databaseBridge providers (iOfficeAI#1924)
  fix(conversation): validate type field before creating conversation (iOfficeAI#1921)
  fix(docs): restore wechat_group_5.png reference to wx-5.png in readme
  fix(snapshot): add maxBuffer to git add/commit exec calls (iOfficeAI#1914)
  refactor(acp): consolidate AGENT_SKILLS_DIRS into ACP_BACKENDS_ALL (iOfficeAI#1913)
  fix(gemini): guard against EACCES in workspace realpath during init (ELECTRON-BM) (iOfficeAI#1912)
  fix(channels): send raw QR ticket instead of page URL in WeChat WebUI login SSE (iOfficeAI#1910)
  .md format
  chore(pr-automation): fix missed sleep 5 in comment to sleep 10
  chore(pr-automation): increase auto-merge retry delay to 10s
  chore(pr-automation): add 5s retry for transient GitHub mergeStateStatus UNKNOWN
  fix(docs): remove trailing whitespace in OfficeCLI readmes
  chore(pr-automation): verify auto-merge success before labeling bot:done
  fix(snapshot): guard against non-existent workspace in WorkspaceSnapshotService.init (iOfficeAI#1906)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:done Auto-merged by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

【Bug】话题重命名未实时同步到详情区 / [Bug] Topic rename does not sync to detail view in real time

2 participants