Skip to content

fix(sessions): keep new sessions visible in sidebar - #725

Open
beruro wants to merge 2 commits into
developfrom
junyu/fix-new-session-sidebar-roster
Open

fix(sessions): keep new sessions visible in sidebar#725
beruro wants to merge 2 commits into
developfrom
junyu/fix-new-session-sidebar-roster

Conversation

@beruro

@beruro beruro commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Problem

A newly created backend session was written to sessionsAtom, so ChatPanel could resolve and open it by ID, but the Sidebar also filters through the paginated sessionPaginationAtom roster. Because creation paths did not register roster membership, the new session could exist in a tab while disappearing from the Sidebar after an authoritative page had loaded.

The same cache-only creation pattern existed across the standard launcher, SessionService.create, ADE Manager, collaboration fork/import, session-file import, and E2E seed paths.

Solution

Introduce registerCreatedSession as the single client-side creation boundary. One Jotai write transaction now stores the session entity and registers top-level native sessions in a separate localSessionIds overlay.

The overlay preserves these invariants:

  • server-returned sessionIds and keyset cursors remain authoritative and are never rewritten by local creation;
  • older in-flight page responses cannot hide a newly created session;
  • existing roster and recent-native refreshes acknowledge and promote confirmed IDs safely;
  • IDs behind the current cursor remain visible without pretending they belong to the loaded server window;
  • child sessions are cached but excluded from the top-level roster, and deletion removes both server and local roster membership.

A shared buildCreatedSessionRecord now maps session_launch responses consistently, and all known creation/import/fork entry points use the new registration boundary. Cache-only reconciliation of existing sessions continues to use upsertSession.

Potential risks

The local overlay retains a backend-confirmed creation until a native roster response encounters it, it is deleted, or the app process resets. For a row behind the current cursor this may last until pagination reaches it; growth is bounded to locally created, not-yet-acknowledged IDs. No new timer, subscription, polling loop, IPC call, persistence format, database migration, or wire-protocol change was introduced.

Rollback is a single-commit revert. No stored data migration or recovery step is required.

Audit

  • Architecture: entity-cache ownership, roster ownership, creation mapping, naming, default/cursor conditions, and all production sessionLaunch call sites were reviewed. Wire protocol and resolver layers were unchanged.
  • Performance: pass. Registration is one bounded Jotai transaction; acknowledgement reuses existing page/recent refreshes. No idle, hidden-window, or multi-instance background work was added.
  • React Effects: none added or modified.
  • UI evidence: screenshots are not useful because styling and layout are unchanged. A rendered integration regression verifies that registration produces an actual Sidebar row before roster refresh.

Verification

  • npx vitest run src/store/session/sessionAtom/__tests__/paginationAtoms.test.ts src/store/session/sessionAtom/__tests__/sidebarRoster.test.ts src/store/session/sessionAtom/__tests__/sidebarLoaders.test.ts src/store/session/sessionAtom/__tests__/mutations.test.ts src/scaffold/NavigationSidebar/connectors/useSessionMenuItems/__tests__/paginationHelpers.test.ts src/scaffold/NavigationSidebar/connectors/useSessionMenuItems/__tests__/createdSessionVisibility.test.ts src/engines/SessionCore/hooks/session/__tests__/launchPayload.test.ts src/engines/SessionCore/services/SessionService.create.test.ts src/scaffold/GlobalSpotlight/palettes/AgentControlPalette/utils.test.ts src/features/TeamCollaboration/forkSession.test.ts src/features/TeamCollaboration/engine/collabSessionFork.test.ts src/features/TeamCollaboration/engine/collabSyncEngineHelpers.test.ts — 12 files, 170 tests passed.
  • npx tsc --noEmit --pretty false — passed.
  • git diff --name-only origin/develop...HEAD -- '*.ts' '*.tsx' | xargs npx eslint — passed.
  • git diff --check origin/develop...HEAD — passed.
  • Commit hooks — lint-staged passed; TypeScript check passed; no Rust files staged.

beruro and others added 2 commits August 6, 2026 22:29
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