fix(space): record last-opened object for chats (JS-9821 follow-up)#2275
Merged
Conversation
…ct (JS-9821) Chats skip ObjectOpen (JS-9821), but setLastObject was only called inside the ObjectOpen handler — so opening a chat never updated the space's last-opened entry, and switching away and back reopened the previous page instead of the chat. Extract the popup/empty/dashboard guards and per-space keying into U.Space.setLastObject and call it from both ObjectOpen and the chat page's chat-layout branch. Adds unit coverage for the recording rules.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
Regression from #2274 (JS-9821, chat skips `ObjectOpen`).
The space's last-opened object is persisted in exactly one place — inside the `ObjectOpen` success handler (`command.ts`). JS-9821 made chat-layout objects open via a lightweight `ObjectSubscribeIds` subscription instead of `ObjectOpen`, so opening a chat never records it as the space's last-opened object.
Result: open a chat → switch to another space → switch back → the space reopens the previously opened page, not the chat.
Fix
Extract the recording logic (which was a dense inline condition) into a clearly-named, documented helper and call it from both open paths:
Tests
Adds 6 unit tests for the recording rules (per-space keying, `spaceId` fallback/override, dashboard/popup/empty skips). `bun run test src/ts/lib/util/space.test.ts` → 10/10 pass. `typecheck` + `lint` clean.
Manual verification
Open a chat → switch space → switch back → should reopen the chat (not the previous page).