Skip to content

fix(desktop): wait for the forked tab before loading its history#3934

Merged
esengine merged 2 commits into
main-v2from
fix/3742-fork-empty-history
Jun 11, 2026
Merged

fix(desktop): wait for the forked tab before loading its history#3934
esengine merged 2 commits into
main-v2from
fix/3742-fork-empty-history

Conversation

@esengine

Copy link
Copy Markdown
Owner

Root cause

Fork returns as soon as the new tab exists, but the tab's controller — including the resume of the forked session file — builds in a background goroutine (startTabControllerBuild). The frontend's fork path then did setActiveTabId + loadSessionDataForTab immediately, so HistoryForTab ran against a tab with no controller yet and returned [] — a reset to an empty transcript.

The ready-event fallback was supposed to heal this, but it reloads activeTabIdRef.current, and when the backend build wins the race against React committing the new active-tab id, the reload targets the source tab — leaving the forked conversation permanently blank, exactly as reported.

Fix

Gate the fork path on waitForTabReady(tab.id) before loading — the same deterministic gate resumeSession already uses for tabs it just created. The sessionLoadSeq guard dedupes any overlapping ready-triggered reload.

One-line behavioral change, no backend involvement.

Closes #3742

reasonix added 2 commits June 10, 2026 20:57
Compaction stores its summary as a user-role message so the model
treats it as context, but IsSyntheticUserMessage did not recognize the
three fold prefixes. A history reload that races a compaction pass
(switch tabs mid-/compact, switch back -> missedTurnDone reload) then
rendered the entire fold - tool calls, commands, console digests - as
a giant user bubble.

Closes #3653
Fork created the new tab, switched to it, and immediately read
HistoryForTab - but the tab controller builds in a background
goroutine, so the read raced the session resume and returned empty.
The ready-event fallback reloads activeTabIdRef, which can still point
at the source tab when the build wins the race, so the forked
conversation stayed blank. Reuse the waitForTabReady gate the resume
path already relies on.

Closes #3742
@esengine esengine requested a review from SivanCola as a code owner June 11, 2026 04:05
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) agent Core agent loop (internal/agent, internal/control) labels Jun 11, 2026
@esengine esengine merged commit 74d7b64 into main-v2 Jun 11, 2026
14 checks passed
@esengine esengine deleted the fix/3742-fork-empty-history branch June 11, 2026 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Core agent loop (internal/agent, internal/control) 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]: 分叉会话后,新生成的会话完全是新会话,没有之前的会话内容

1 participant