Skip to content

Keep a workspace switch on the account at once, and stop a new browser wiping it - #1756

Merged
sickerine merged 3 commits into
devfrom
fix/remember-on-switch
Dec 6, 2026
Merged

sickerine merged 3 commits into
devfrom
fix/remember-on-switch

Conversation

@sickerine

Copy link
Copy Markdown
Collaborator

Follows #1755. Found by the first-use walker Daniel.

What went wrong. Daniel switched to his organisation from the account menu and never reloaded. The next day his new browser opened in his own workspace. The account was told only on a full page load, and switching workspace doesn't do one. The switch, and making a new organisation, now tell the account as they happen (rail.tsx, switcher.tsx).

Found while replaying it. The account was being wiped. A new browser's first page shows the person's own workspace before it has asked the account. The cookie remembered that, and the proxy then told the account "own workspace". The proxy now tells the account only about organisations. Moving back to your own workspace is told by the switch itself.

Checks

  • tsc and Vitest lib/workspaces and convex/workspaces pass.
  • Replayed on a local build against shared dev, through Clerk's real sign-in page:
    • day one: sign in, switch to the board from the account menu without reloading, then open an own-workspace page;
    • day two, on a new browser: sign in. It lands on /o/rift-valley-water-board…, /publish opens there too, and the account still holds the board.

…rowser no longer wipes it

The first-use walker Daniel switched to his organization from the account menu, never reloaded, and the next day's new browser opened in his own workspace: the account was told only on a page load, which a switch doesn't make. The switch, and making a new organization, now tell it as they happen.

Replaying it then showed the account wiped: a new browser's first page shows the person's own workspace before it has asked, the cookie remembered that, and the proxy told the account "own workspace". The proxy now tells the account only of organizations; moving back to one's own workspace is told by the switch itself.

Checked on a local build against shared dev with Clerk's real sign-in page: day one signs in, switches from the menu and opens an own-workspace page; day two, on a new browser, signs in and lands in the organization, and /publish opens there too.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 6, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-06T00:59:37.654118Z 3719601 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Dec 6, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7cc764e5-0c70-43b9-9636-28521980917f
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3719601c87

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread components/workspaces/rail.tsx Outdated
onSwitch={(slug, to) => {
close();
if (to) setPicked(to);
void rememberWorkspace({ slug: slug ?? null }).catch(() => undefined);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Update the cookie's saved marker after remembering a switch

When the cookie already has saved: A, switching to B now updates the account to B but leaves saved at A. If the user then returns to A through a client-side path other than the account switcher—for example, moving an item into A through components/workspaces/move-dialog.tsx—LastWorkspace sets the cookie's last to A. Subsequent page loads see last === saved, so keepOnAccount skips the write indefinitely even though the account still remembers B; a new browser consequently opens in the wrong organization. Update or invalidate the cookie's saved marker when the new mutation succeeds so the proxy's deduplication remains accurate.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 5dbd12f: a switch now writes what it told the account into the cookie's saved, so moving back to A another way is told again. Test: lib/workspaces/look-cache.test.ts.

Codex review: with the cookie saying the account was told A, a switch to B told the account but left the note at A; moving back to A another way (an item moved there) then looked already told, and the account kept B. A switch now notes what it told, through one hook the switcher and new organizations share (lib/workspaces/remember.ts).
…orkspace

The sidebar now tells the account of a switch (lib/workspaces/remember.ts); its test's stand-in for the generated API lacked that function.
@sickerine
sickerine merged commit a0c01d2 into dev Dec 6, 2026
6 checks passed
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.

1 participant