Skip to content

fix(space): record last-opened object for chats (JS-9821 follow-up)#2275

Merged
requilence merged 1 commit into
developfrom
js-9821-chat-skip-objectopen
Jun 28, 2026
Merged

fix(space): record last-opened object for chats (JS-9821 follow-up)#2275
requilence merged 1 commit into
developfrom
js-9821-chat-skip-objectopen

Conversation

@requilence

Copy link
Copy Markdown
Contributor

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:

  • `U.Space.setLastObject(object, spaceId?)` — each guard is now its own early-return (empty object / popup / dashboard layout), and the per-space keying that prevents cross-space pollution (JS-9815) lives in one place.
  • `command.ts` `ObjectOpen` now calls the helper (behavior unchanged; removed the now-dead `Storage` import).
  • `page/main/chat.tsx` calls the helper in the chat-layout branch (Space-layout still records via its `ObjectOpen`).

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).

…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.
@requilence requilence merged commit e5c96b3 into develop Jun 28, 2026
3 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant