Skip to content

fix(desktop): deduplicate blank tab creation (#3219)#3741

Merged
esengine merged 8 commits into
esengine:main-v2from
HBLADEH:feat/3219-duplicate-blank-tabs
Jun 10, 2026
Merged

fix(desktop): deduplicate blank tab creation (#3219)#3741
esengine merged 8 commits into
esengine:main-v2from
HBLADEH:feat/3219-duplicate-blank-tabs

Conversation

@HBLADEH

@HBLADEH HBLADEH commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary / 摘要

在进行"新建会话"操作时,新增了检测逻辑:如果当前已经有了空白会话标签页,则直接跳转到该标签页,避免重复创建。

Adds a detection path for the "New Session" flow: when a blank tab already exists, it is reused rather than creating a duplicate. This prevents repeated "new session" clicks from piling up empty conversations.

同时,在点击顶部标签页栏的"新建会话"时,如果侧边栏已经存在未打开的空白会话,则直接打开该会话,而不是创建一个全新的话题。

Additionally, when clicking "New session" from the top tab bar, if the sidebar already contains an unopened blank topic, EnsureBlankTab opens it instead of creating a fresh one — covering both the in-memory reuse path (open blank tab) and the on-disk reuse path (indexed blank topic).

What was changed / 改动清单

  • EnsureBlankTab(Go 后端):三阶段管线——复用已打开的空白标签页 → 复用磁盘上已索引的空白话题 → 最后才创建全新话题
    reuse open blank tab → reuse indexed blank topic on disk → create new topic as last resort
  • NewSession:当当前标签页没有实质性对话内容时跳过快照
    Skip snapshot when the current tab has no real conversation content
  • 前端绑定(bridge.tsuseController.tsApp.tsxProjectTree.tsx):将侧边栏"新建话题"操作接入 EnsureBlankTab,使其进入去重管线
    Wire sidebar "new topic" action through EnsureBlankTab so it enters the dedup path

Tests / 测试

cd desktop && go test . -run 'TestEnsureBlankTab|TestNewSession' -count=1 -v
git diff --check

Fixes #3219

感谢您们制作了该项目⛄️

Add EnsureBlankTab with a three-stage pipeline that reuses existing
blank tabs, falls back to indexed blank topics on disk, and only
creates a new topic as a last resort. Also short-circuit NewSession
when the current tab is already blank.

- EnsureBlankTab: reuse open blank tab → reuse indexed blank topic → create new
- blankTabMatchesTargetLocked: helper to identify reusable blank tabs
- indexedBlankTopicIDLocked: helper to find blank topics on disk not in any tab
- NewSession: skip snapshot when the tab has no real conversation content
- messagesHaveConversationContent: utility to check for non-system messages
- Comprehensive tests covering all three stages for global and project scopes
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) labels Jun 9, 2026
@HBLADEH HBLADEH changed the title fix(desktop): deduplicate blank tab creation fix(desktop): deduplicate blank tab creation (#3219) Jun 9, 2026
@HBLADEH

HBLADEH commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

别地方的合并导致该pr冲突,先进行处理

@HBLADEH

HBLADEH commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

注意到新版本 UI 会去除了顶部栏,不过侧边栏仍然存在无限创建的问题,已经对其进行调整。

HBLADEH and others added 2 commits June 10, 2026 16:08
The code is self-explanatory here; drop the section-banner and line-end
restating comments to match the repo comment policy.

@esengine esengine left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks @HBLADEH — clean three-layer dedup (open blank tab → indexed blank topic → create) covering both the tab-bar and sidebar entry points, with solid Go test coverage. Merging.

@esengine esengine merged commit ec9ff89 into esengine:main-v2 Jun 10, 2026
13 checks passed
@HBLADEH

HBLADEH commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @HBLADEH — clean three-layer dedup (open blank tab → indexed blank topic → create) covering both the tab-bar and sidebar entry points, with solid Go test coverage. Merging.

Thank you for creating such a wonderful project. ☃️☃️

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.

[Bug]: 不应该允许无限创建空白新对话

2 participants