Skip to content

fix(cluster): sign out of the cluster when signing out of an instance#1411

Open
dawsontoth wants to merge 2 commits into
stagefrom
claude/affectionate-hugle-bf6974
Open

fix(cluster): sign out of the cluster when signing out of an instance#1411
dawsontoth wants to merge 2 commits into
stagefrom
claude/affectionate-hugle-bf6974

Conversation

@dawsontoth

Copy link
Copy Markdown
Contributor

Fixes #1320

Problem

Signing out of an instance invalidates the session on that node, but Studio kept the cluster flagged as signed in (Studio:PotentiallyAuthenticated). The cluster FQDN load-balances across the same nodes, so the next cluster request could land on the logged-out node and fail with a "Must login" error — nondeterministically, depending on the FQDN and instance count.

Fix

Instance sign-out (both the row's "Direct Sign Out" button in InstanceLogInCell and the context/"…" menu in useInstanceMenuItems) now goes through a shared signOutOfInstance() helper that, after the server-side logout:

  • signs the instance out locally (as before), and
  • clears the cluster's local auth state via a new authStore.signOutLocally() — the potentially-authenticated flag, stored basic-auth credentials, the Fabric Connect flag, and its in-memory token.

Sibling instances hold their own sessions and are deliberately left signed in, per the issue.

This mirrors the existing inverse behavior: cluster sign-out already flags all of its instances as signed out (ClusterCard), and cluster sign-in flags them all as signed in (useClusterInstanceSignIn).

Testing

  • New signOutOfInstance.test.ts covers: instance + cluster signed out while a sibling instance stays signed in; cluster credentials/Fabric Connect flags cleared; local state preserved when the server-side logout fails.
  • Full suite passes (164 files, 1039 tests), plus tsc -b, oxlint, and dprint.
  • Verified the mechanism in the running dev app by driving the real authStore through the new helper: the persisted auth map drops the cluster and the signed-out instance, keeps the sibling.

🤖 Generated with Claude Code

Signing out of an instance invalidates the session on that node, but the
cluster stayed flagged as signed in — so the next cluster request could be
load-balanced onto the logged-out node and fail with 'Must login' (#1320).

Instance sign-out (row button and context menu) now also clears the
cluster's local auth state — potentially-authenticated flag, stored basic
auth, Fabric Connect flag and in-memory token — via a new
authStore.signOutLocally(). Sibling instances hold their own sessions and
stay signed in.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@dawsontoth dawsontoth requested a review from a team as a code owner July 2, 2026 20:46

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a helper function signOutOfInstance to sign out of a single instance and locally sign out of its cluster, preventing load-balancing routing issues to logged-out nodes. It also adds corresponding unit tests and updates the UI components to use this new helper. The reviewer recommends ensuring that local state and credentials are cleared unconditionally (using a try...finally block) even if the server-side logout API request fails, and updating the unit tests to reflect this behavior.

Comment thread src/features/cluster/signOutOfInstance.ts
Comment thread src/features/cluster/signOutOfInstance.test.ts Outdated
A failed logout request must not leave stale flags or credentials behind
in localStorage — swallow the server error and clear the instance's and
cluster's local auth state regardless, matching ClusterHome's onDisconnect.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@kriszyp kriszyp 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.

Approving — signing out of an instance now also clears the local cluster auth state (closing the lingering-cluster-session-after-logout gap), correctly scoped so it doesn't drop other still-connected instances, and well-tested. Thanks @dawsontoth!

— 🤖 KrAIs (Kris's review assistant)

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.

Ensure signing out of an instance signs out of the cluster

2 participants