Skip to content

fix(host): Web 目录不再列出临时侧边聊天 / keep temporary side chats out of the Web catalog - #1198

Merged
iruriQ merged 1 commit into
BytePioneer-AI:mainfrom
sduhantao-maker:fix/web-catalog-temporary-side-chats
Nov 26, 2026
Merged

iruriQ merged 1 commit into
BytePioneer-AI:mainfrom
sduhantao-maker:fix/web-catalog-temporary-side-chats

Conversation

@sduhantao-maker

Copy link
Copy Markdown
Contributor

摘要

Desktop 打开临时侧边聊天时,用 thread/fork 加 ephemeral: true 从主对话 Fork 出子 Thread(见 docs/architecture/external-thread-side-chats.md)。外部 Harness 的这类 Thread 由 Host 写入 mapping store 并一直保留。官方 Desktop 的侧栏不显示它们:Desktop 26.1120 的 shouldSurfaceRecentConversation 只显示满足三个条件的会话:不是 ephemeral,没有 attachedToThreadId,也不是 sideConversation。

Web 侧栏读取的 codexhost/thread/catalog/read 没有这项过滤,所以每个临时侧边聊天在 Web 中都是一条独立的顶层会话:

  • 它们没有标题,Web 用保存的预览作标题。预览来自继承的主对话历史,所以同一个主对话下会出现多条同名会话。
  • Native Session 已不存在的(例如被 Claude Code 的 transcript 清理删除)打不开,显示「历史加载失败:External Native Session is unavailable(host/rejected)」。Desktop 不列出它们,所以碰不到这个错误。

现在 readThreadCatalog() 的行为:

  • 合并各来源后去掉 ephemeral 行,threads 与 ownership 仍一一对应。来自 sharedThreads 的临时行也一并去掉。
  • 本地归档 ID 列表 archivedThreadIds 也不再包含临时 Thread。
  • Desktop 的 thread/list 不变。Desktop 自己会隐藏这些会话,而带 parentThreadId 的范围列表仍可能需要临时 Thread 下的 Subagent 记录。
  • 按 ID 直接读取的路径不变,包括 thread/read、置顶会话补读和直链。
  • docs/architecture/external-thread-side-chats.md 补充了 Web 目录的这条规则。thread/list 一行改为「不含挂靠的侧边聊天」,与实现一致。

关联 Issue

无 / N/A

测试

基于 main(0e5029124),macOS 27.2.1(arm64),Node 26.0.0:

  • npx vitest run --config tests/vitest.config.js packages/host-runtime/test/thread-catalog.test.ts packages/host-runtime/test/app-server-host.thread-catalog.test.ts:26 个通过。
    • thread-catalog.test.ts 的两条既有用例加入了三种临时 Fork(本地未归档、本地已归档、共享来源),以及一个应当保留的持久 Fork。
    • 去掉 thread-catalog.ts 的改动后,这两条用例失败:多出 3 条临时行和 1 个归档 ID。
  • 改动文件 prettier --check 通过,eslint 没有报错。
  • 本机 mapping store 里有 82 条已就绪、未归档的顶层临时 Fork 记录(Claude Code 56 条,Pi 26 条),修复前都会出现在 Web 目录中。
  • 未测试:真实 Web 页面(没有启动隔离的 Host 和 Web);Windows。

UI Demo

修复前侧栏有两条同名的临时侧边聊天「Compare the release notes」,修复后只剩来源会话和持久 Fork

这是示意图,不是 Web 实机截图:用修改前后的 readThreadCatalog() 和 Web 的 threadListTitle() 处理同一组合成记录,再把得到的标题画成简化的侧栏。修复前,一个本地 Claude Code 临时 Fork 和一个共享来源的 Pi 临时 Fork 都以继承来的预览「Compare the release notes」为标题出现;修复后只剩来源会话和持久 Fork。


Summary

Desktop opens a temporary side chat by forking a child Thread from the main conversation with thread/fork and ephemeral: true (see docs/architecture/external-thread-side-chats.md). For external Harnesses, the Host writes these Threads to the mapping store and keeps them. The official Desktop does not show them in its sidebar. In Desktop 26.1120, shouldSurfaceRecentConversation shows a conversation only if it meets three conditions: it is not ephemeral, has no attachedToThreadId, and is not a sideConversation.

The Web sidebar reads codexhost/thread/catalog/read, which had no such filter, so every temporary side chat shows up in the Web as a separate top-level Thread:

  • They have no title, so the Web uses the stored preview as the title. That preview comes from the inherited main-conversation history, so one main conversation can produce several rows with the same title.
  • If a Thread's Native Session no longer exists (for example, Claude Code's transcript cleanup removed it), it cannot be opened and shows "历史加载失败:External Native Session is unavailable(host/rejected)". Desktop does not list these Threads, so it never hits this error.

What readThreadCatalog() does now:

  • It drops ephemeral rows after merging the sources, so threads and ownership stay aligned. Temporary rows from sharedThreads are dropped too.
  • The local archived ID list, archivedThreadIds, no longer includes temporary Threads either.
  • Desktop's thread/list is unchanged. Desktop already hides these conversations, and scoped lists with parentThreadId may still need the Subagent records under a temporary Thread.
  • Paths that read a Thread directly by ID are unchanged, including thread/read, the pinned-thread fallback and direct links.
  • docs/architecture/external-thread-side-chats.md describes this catalog rule. The thread/list row now says "other lists do not include attached side chats", matching the implementation.

Related issues

N/A

Test plan

On main (0e50291), macOS 27.2.1 (arm64), Node 26.0.0:

  • npx vitest run --config tests/vitest.config.js packages/host-runtime/test/thread-catalog.test.ts packages/host-runtime/test/app-server-host.thread-catalog.test.ts: 26 passed.
    • Two existing cases in thread-catalog.test.ts now include three temporary forks (local live, local archived and shared) and one persistent fork that must stay.
    • Without the change to thread-catalog.ts, both cases fail: 3 extra temporary rows and 1 extra archived ID.
  • prettier --check passes and eslint reports no errors on the changed files.
  • The local mapping store has 82 ready, unarchived top-level temporary fork records (56 Claude Code, 26 Pi). Before the fix, all of them appear in the Web catalog.
  • Not tested: a real Web page (no isolated Host or Web was started); Windows.

UI Demo

Before: the sidebar has two temporary side chats titled Compare the release notes; after: only the source Thread and the persistent fork remain

This is a schematic, not a screenshot of a running Web page. The old and new readThreadCatalog() and the Web's threadListTitle() processed the same synthetic records, and the resulting titles were drawn as a simplified sidebar. Before the fix, a local Claude Code temporary fork and a shared Pi temporary fork both appear, titled with the inherited preview "Compare the release notes". After the fix, only the source Thread and the persistent fork remain.

Filter ephemeral rows after merging catalog sources and omit their IDs from the local archive summary. Scoped Thread lists still have the full record set for ancestry checks.
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • 功能改进
    • 临时侧边聊天不再出现在会话目录和归档 ID 列表中;Native Session 可用时,仍可通过 ID 直接读取。
    • 会话列表默认仅排除挂靠的侧边聊天。

线程目录和外部归档线程 ID 现在会排除临时侧边聊天。测试和架构文档补充了本地、共享线程及直接读取行为的说明。

Changes: 临时侧边聊天目录过滤

Layer / File(s) Summary
目录过滤与行为说明
packages/host-runtime/src/thread-catalog.ts, packages/host-runtime/test/thread-catalog.test.ts, docs/architecture/external-thread-side-chats.md
归档线程 ID 生成和目录行合并会过滤临时记录。测试覆盖本地与共享线程。文档说明列表不包含挂靠的侧边聊天(带 includeAttachedThreads 的搜索除外),目录和归档 ID 列表不包含临时侧边聊天;Native Session 可用时,仍可通过 thread/read 按 ID 读取。

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

Suggested reviewers: bytepioneer-ai, zxd-666

Merge Risk: Minimal · up to 79ca3

This change hides temporary side chats from the thread catalog and archived-ID summary, and leaves direct reads unchanged. No concrete merge-blocking risk was identified. A real Web page and Windows were not tested.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题指出本次修改的主要行为:Web 目录不再列出临时侧边聊天。这与 readThreadCatalog 过滤 ephemeral 记录、并从 archivedThreadIds 中排除临时线程的改动一致。标题中中英文并列,略显冗长,但范围和主题都明确。
Description check Passed 描述详细说明了问题背景(临时侧边聊天在 Web 侧栏中作为顶层会话出现)、修复内容(readThreadCatalog 过滤 ephemeral 行并排除归档 ID)、文档更新、测试计划和界面示意图,均与变更集相关。
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 0e50291 and 79ca381.

Files selected for processing: 3

  • docs/architecture/external-thread-side-chats.md
  • packages/host-runtime/src/thread-catalog.ts
  • packages/host-runtime/test/thread-catalog.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Recent review details

Context from checks skipped due to timeout: 8

  • GitHub Check: CodeRabbit
  • GitHub Check: Web Host tests
  • GitHub Check: Check ubuntu-22.04
  • GitHub Check: Check windows-latest
  • GitHub Check: Check Linux ARM64
  • GitHub Check: Check macos-26
  • GitHub Check: Vitest
  • GitHub Check: Static checks
Additional context used

Code guidelines: 2

CLAUDE.md — auto-discovered
AGENTS.md — auto-discovered
Path-based instructions: 2

Source excerpt: Host Runtime loads installed plugins through public contracts, not direct imports of concrete Adapter packages.

CodeRabbit inference engine (CLAUDE.md)

Files:

  • packages/host-runtime/src/thread-catalog.ts
  • packages/host-runtime/test/thread-catalog.test.ts
Source excerpt: Use package public exports for cross-package dependencies.

CodeRabbit inference engine (AGENTS.md)

Files:

  • packages/host-runtime/src/thread-catalog.ts
  • packages/host-runtime/test/thread-catalog.test.ts
Additional comments: 1

packages/host-runtime/src/thread-catalog.ts: 1

285-285: Data Integrity & Integration

共享 Thread 行的 ephemeral 字段缺失是否会导致临时记录留在目录中,仓库内证据无法确定。SharedThreadBridge.list 原样返回 thread/list 的行,并且不会改写字段。该过滤器只在字段为 true 时排除行。因此,结论取决于官方 thread/list 的返回结构。仓库内没有该结构的 schema、生产端或夹具能证明它会省略字段。

该评论提出的检查项是开放问题,不是可以直接修改的代码缺陷。当前证据不能建立“生产端省略 ephemeral 会导致目录过滤失效”这一前提。

@iruriQ
iruriQ merged commit ce90a3f into BytePioneer-AI:main Nov 26, 2026
8 checks passed
@iruriQ

iruriQ commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

感谢修复!改动精准收敛,过滤临时侧边聊天与 Desktop 语义一致且文档单测齐备,现已合并。

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