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

@Harry19081 Harry19081 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Requesting changes before merge.

  1. Fix roster ownership for non-native creations.
  • Collaboration imports are created with category: "external_history" and an imported-session-... ID. sidebarCategoryForSession cannot assign that shape to a roster category, so registerCreatedSessionWithNativeRoster returns unchanged state. Please give collaboration replays an explicit authoritative roster projection and test it after an authoritative roster page has loaded.
  • JSON imports and collaboration forks are client-created rows, not native-roster rows. They therefore may never be acknowledged by a native page. The current volatile localSessionIds overlay can lose visibility after restart or a flat-list replacement, and it has no growth bound for never-acknowledged rows. Please either persist these rows through the native owning boundary or introduce a durable, bounded local-roster registry with explicit deletion/eviction semantics.
  1. Add regression coverage for the actual lifecycle boundaries:
  • collaboration import visibility after an authoritative roster load;
  • JSON import and collaboration fork visibility across restart/rehydration and loadSessions replacement;
  • stale in-flight page protection;
  • overlay/registry bounds and cleanup on deletion.

The current rendered test covers only a warm, same-process native sdeagent-* creation and does not exercise these paths.

  1. Split commit 339f491d6 (fix(ui): tolerate missing ResizeObserver) into a separate PR. It is unrelated to the session-roster invariant and violates this repository single-responsibility PR contract.

CI is green, but these owning-boundary and lifecycle gaps should be resolved before merge.

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