Skip to content

fix: scope empty session reuse to current window to prevent session mixing#7602

Merged
jh-block merged 1 commit intoblock:mainfrom
fresh3nough:fix/session-mixing-on-upgrade-7601
Mar 4, 2026
Merged

fix: scope empty session reuse to current window to prevent session mixing#7602
jh-block merged 1 commit intoblock:mainfrom
fresh3nough:fix/session-mixing-on-upgrade-7601

Conversation

@fresh3nough
Copy link
Copy Markdown
Contributor

Problem

Fixes #7601

When multiple goose desktop windows are open during an upgrade or restart, all windows reload and call handleNewChat. The previous implementation used a global sessions.find(s => shouldShowNewChatTitle(s)) which picked the first empty session from the shared session list. Every window would grab the same empty session, causing:

  • Session data mixing/overwriting between windows
  • Loss of conversation history
  • Confusing UX where multiple windows show the same session

Root Cause

In AppSidebar.tsx, handleNewChat (line 432) searched the entire recentSessions list for any empty session to reuse. Since all windows load the same session list from the API, they all race for the same first empty session.

Fix

Changed handleNewChat to only reuse the current window's own active session (identified by activeSessionId from the URL search params) if that session is empty. If the window has no active session or the active session already has messages, a new session is always created.

This prevents cross-window collisions because each window has its own distinct activeSessionId.

Changes

  • ui/desktop/src/components/GooseSidebar/AppSidebar.tsx: Replaced global empty-session lookup with window-scoped active session check
  • ui/desktop/src/__tests__/sessions.test.ts: Added 9 tests covering shouldShowNewChatTitle and the scoped reuse logic, including a test that demonstrates the old bug

Testing

All 307 existing tests pass plus 9 new tests. ESLint clean.

@fresh3nough fresh3nough force-pushed the fix/session-mixing-on-upgrade-7601 branch from 23a5283 to 72cddf4 Compare March 2, 2026 15:03
…ixing (block#7601)

When multiple windows are open during an upgrade/restart, handleNewChat
previously grabbed the first empty session from the global session list.
All windows would race for the same empty session, causing session mixing
and data loss.

Now handleNewChat only reuses the current window's own active session if
it is empty. If the active session has messages or no session is active,
a new session is always created. This prevents cross-window collisions.

Signed-off-by: fresh3nough <[email protected]>
@jh-block
Copy link
Copy Markdown
Collaborator

jh-block commented Mar 4, 2026

thanks!

@jh-block jh-block added this pull request to the merge queue Mar 4, 2026
Merged via the queue into block:main with commit c65cfa6 Mar 4, 2026
20 checks passed
lifeizhou-ap added a commit that referenced this pull request Mar 4, 2026
* main:
  docs: add GOOSE_INPUT_LIMIT environment variable documentation (#7299)
  Merge platform/builtin extensions (#7630)
  Clean up stale references to removed components (#7644)
  fix: scope empty session reuse to current window to prevent session mixing (#7602)
  fix: prevent abort in local inference  (#7633)
  Revert git patch for llama-cpp-2 (#7642)
  docs: update recipe usage step to reflect auto-submit behavior (#7639)
  docs: add guide for customizing the sidebar (#7638)
  docs: update Claude Code approve behavior and model list in cli-providers guide (#7448)
  fix: restore provider and extensions for LRU-evicted sessions (#7616)
  Restore goosed logging (#7622)
@fresh3nough
Copy link
Copy Markdown
Contributor Author

np

craigwalkeruk pushed a commit to craigwalkeruk/custom-goose that referenced this pull request Mar 5, 2026
tlongwell-block added a commit that referenced this pull request Mar 5, 2026
* origin/main: (107 commits)
  Merge platform/builtin extensions (#7630)
  Clean up stale references to removed components (#7644)
  fix: scope empty session reuse to current window to prevent session mixing (#7602)
  fix: prevent abort in local inference  (#7633)
  Revert git patch for llama-cpp-2 (#7642)
  docs: update recipe usage step to reflect auto-submit behavior (#7639)
  docs: add guide for customizing the sidebar (#7638)
  docs: update Claude Code approve behavior and model list in cli-providers guide (#7448)
  fix: restore provider and extensions for LRU-evicted sessions (#7616)
  Restore goosed logging (#7622)
  feat: return structured {stdout, stderr} from shell tool with output schema (#7604)
  Improve custom provider creation experience (#7541)
  fix(scheduler): schedules added via CLI showing up in UI (#7594)
  chore: openai reasoning model cleanup (#7529)
  chore(deps): bump hono from 4.12.1 to 4.12.3 in /evals/open-model-gym/mcp-harness (#7585)
  chore(deps): bump minimatch from 10.1.1 to 10.2.3 in /evals/open-model-gym/suite (#7498)
  chore(deps): bump swiper from 11.2.10 to 12.1.2 in /documentation (#7368)
  Better network failure error & antrhopic retry (#7595)
  feat: make the text bar persistent and add a queue for messages (#7560)
  fix: outdated clippy command in goosehints (#7590)
  ...

# Conflicts:
#	Cargo.lock
#	Cargo.toml
#	crates/goose-server/src/commands/agent.rs
#	crates/goose-server/src/main.rs
#	crates/goose-server/src/routes/reply.rs
Abhijay007 pushed a commit to Abhijay007/goose that referenced this pull request Mar 6, 2026
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.

Desktop: Sessions can get mixed up/overwritten during upgrade with multiple windows open

2 participants