fix(desktop): restore topic title from session fallback when switching projects in creation mode (#5438)#5478
Conversation
…g projects in creation mode (esengine#5438) In single-surface (creation/workbench) mode, switching between projects removes the previous tab via keepOnlyVisibleTab. When the user switches back, a new tab is created and the topic title is loaded from the persisted topic-titles file. However, if the topic-title file has no entry for this topic ID (e.g., due to path normalization differences on Windows), the title would incorrectly show the default '新的会话'. This fix adds a fallback: when the topic-title file has no entry and a valid session path is known, extract the title from the session and persist it back to the topic-titles file for consistency.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0dd1923ab1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ncelled The stream-reconnect loop calls sendChunk(ctx, out, error) with the caller's context after readStream returns context.Canceled. Since the context is already cancelled, sendChunk's second select races <-ctx.Done() against out<-chunk (both ready), dropping the error ~50% of the time — the caller sees a nil error instead of context.Canceled. Fix: use context.Background() for the final non-reconnectable error send, so the error chunk is always delivered to the reader. Fixes TestStreamCancelDoesNotReconnect flaky failure under -race.
Restore saved topic titles from session metadata or desktop session title sidecars when the topic title index is missing, while preserving manually defaulted topic titles. Also removes the unrelated OpenAI stream change from this PR diff. Co-authored-by: SivanCola <32437197+SivanCola@users.noreply.github.com>
There was a problem hiding this comment.
Approved. This now restores topic titles from the stored session metadata/title sidecar before auto-generating from the first user message, while preserving manual titles that happen to equal the default text. The final diff is scoped to desktop topic-title recovery and regression tests, with no provider/cache/prompt surface changes.
Verified:
- GitHub checks are passing, including desktop, race, CodeQL, and cache-impact.
- Merged into latest main-v2 locally and ran the focused topic-title recovery tests.
- Merged into latest main-v2 locally and ran the full desktop Go test suite.
修复内容
Fixes #5438
在创作模式(单表面布局)下切换项目时,
keepOnlyVisibleTab会移除先前可见 tab;切换回来重新打开 topic 时,如果desktop-topic-titles.json缺少该 topic 的标题条目,标题会退回默认的新的会话。变更说明
openTopicTabWithActivation的 topic 打开路径中改用受保护的 fallback:新的会话.jsonl.meta的BranchMeta.TopicTitle恢复验证
cd desktop && go test . -run 'TestOpenProjectTab(RecoversMissingTopicTitleFromSessionMeta|RecoversMissingTopicTitleFromSessionTitle|PreservesManualDefaultTopicTitle)$'cd desktop && go test ./...go test ./internal/provider/openai/...git diff --checkCache-impact: low - desktop topic title persistence/recovery only; no prompt, tool schema, provider request serialization, compaction, or reasoning upload changes.
Cache-guard: not required for provider-visible cache shape; covered by desktop regression tests above.