fix(sidebar): show newly created sessions immediately - #808
Open
Raymond8196 wants to merge 2 commits into
Open
Conversation
Pre-commit hook ran. Total eslint: 2, total circular: 0
Harry19081
marked this pull request as ready for review
August 15, 2026 06:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A newly launched session is inserted into the local session entity cache, but the sidebar renders only IDs owned by its paginated roster once that roster has loaded. The new row is therefore filtered out until a later refresh. If an older first-page request completes after the launch, it can also overwrite a local roster registration.
Solution
Register each newly inserted top-level native session in the sidebar roster at the same write boundary as the authoritative launch result. Preserve only registrations that occurred after an in-flight roster read began when that read commits, so a stale first page cannot hide the new row. Child and imported sessions remain outside the primary native roster.
Closes #809.
Potential risks
A session whose backend record is removed immediately after launch can remain locally visible until the next authoritative roster read; this is bounded by the existing refresh lifecycle and is preferable to hiding a successful launch. No schema, persistence format, public API, or background cadence changes are introduced.
Verification
NODE_OPTIONS='--localstorage-file=/private/tmp/org2-vitest-localstorage' pnpm exec vitest run src/store/session/sessionAtom/__tests__/mutations.test.ts src/store/session/sessionAtom/__tests__/sidebarRoster.test.ts src/store/session/sessionAtom/__tests__/sidebarLoaders.test.ts— 37 tests passed.pnpm typecheck— passed.pnpm lint:file -- src/store/session/sessionAtom/sidebarRoster.ts src/store/session/sessionAtom/loaders.ts src/store/session/sessionAtom/mutations.ts src/store/session/sessionAtom/__tests__/mutations.test.ts src/store/session/sessionAtom/__tests__/sidebarLoaders.test.ts— passed.git diff --check— passed.Performance audit
Manual verification
Not run: desktop UI smoke test and screenshot/recording. The regression is covered at the store-to-render matcher boundary, including the stale-first-page ordering case; this PR remains Draft pending visual confirmation.