---
id: WF-PFM-CSH-004
title: Leave a workspace for Rhythm HQ
trigger: Staff navigate into HQ while a workspace remains selected.
product_area: platform
module: console-shell
revision: 1
status: draft
design_intent: confirmed
origin: >-
  react-console:docs/url-architecture.md#11. Decisions made during the build,
  item 24 (Andrew, 2026-10-15; final acceptance 2026-10-15)
implementation_evidence: observed
source_sha:
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
  services-platform: ad3f6a6582843008ed0f5a17b131878d15829af1
implements:
  - CAP-PFM-CSH-013
moves:
  - STATE-PFM-CSH-001
crosses:
  - SVC-PFM-CSH-console-shell
inference: []
idempotency: 'With no selected workspace, leaving returns without a context request.'
concurrency: >-
  A later entry ticket prevents the departure refresh from restoring an older
  context.
hops:
  - 'n': 1
    actor_or_service: console (provider)
    action: Detect staff navigation into an HQ route while a workspace is selected.
    anchor: >-
      react-console:lib/security-context/provider.tsx:SecurityContextProvider
      (inHqRoute effect)
    seam: sync
    on_failure: The route predicate has no failure branch.
    left_inconsistent: The selected workspace can still be held when HQ navigation is detected.
    observer: No dedicated observer.
    provenance: observed
    source: 'react-console:lib/security-context/provider.tsx:SecurityContextProvider'
  - 'n': 2
    actor_or_service: console (provider)
    action: >-
      Record the workspace departure, advance the ticket, reset notice and await
      SWR cache clearing.
    anchor: >-
      react-console:lib/security-context/provider.tsx:leaveTenant;
      lib/security-context/left-tenant.ts:noteLeftTenant
    seam: sync
    on_failure: >-
      Cache-clearing rejection has no local catch and prevents subsequent leave
      steps.
    left_inconsistent: >-
      The departure marker and cleared notice can exist before the selected
      workspace is removed.
    observer: No dedicated observer.
    provenance: observed
    source: 'react-console:lib/security-context/provider.tsx:leaveTenant'
  - 'n': 3
    actor_or_service: console (provider)
    action: >-
      If the ticket remains current, remove the selected workspace locally while
      preserving workspace memory.
    anchor: >-
      react-console:lib/security-context/provider.tsx:leaveTenant
      (withoutStaffDefaultTenant)
    seam: sync
    on_failure: >-
      Discard local continuation if a newer ticket has superseded this
      departure.
    left_inconsistent: The local snapshot has no selected workspace before refresh completes.
    observer: Person through HQ header and navigation.
    provenance: test
    source: >-
      react-console:e2e/mock/url-architecture.mock.spec.ts#a staff member's old
      tenant-less bookmark opens their remembered tenant after landing in Rhythm
      HQ
  - 'n': 4
    actor_or_service: Security (getMySecurityContext)
    action: >-
      Fetch a workspace-free Security context and apply it only if the ticket is
      still current.
    anchor: 'react-console:lib/security-context/provider.tsx:leaveTenant'
    seam: sync
    on_failure: Ignore refresh failure and retain the workspace-free snapshot.
    left_inconsistent: >-
      Reachable workspaces and permissions can remain stale after failed
      refresh.
    observer: No console error; Security retains its own logging.
    provenance: observed
    source: 'react-console:lib/security-context/provider.tsx:leaveTenant (catch)'
branches:
  - >-
    Denied staff entry leaves the selected workspace before creating its HQ
    notice.
waits:
  - >-
    The five-second departure marker suppresses immediate re-entry, with retry
    after six seconds.
evidence:
  - >-
    react-console at baf6dae:
    lib/security-context/{provider.tsx,left-tenant.ts};
    components/console/tenant-id-gate.tsx.
controls: [TC-AVL-001, TC-AVL-004, TC-AVL-005, TC-AZ-001, TC-AZ-002, TC-AZ-003, TC-AZ-004, TC-AZ-005, TC-AZ-006, TC-DAT-001, TC-DAT-002, TC-DAT-003, TC-IAM-001, TC-IAM-002, TC-IAM-003, TC-IAM-004, TC-IAM-005, TC-LOG-001, TC-LOG-004, TC-LOG-005, TC-MON-001, TC-MON-002, TC-MON-003, TC-PI-001, TC-PI-002, TC-PI-003, TC-PI-004, TC-PI-005, TC-TEN-001, TC-TEN-002, TC-TEN-003, TC-VEN-001, TC-VEN-002, TC-VEN-003]
---
# Leave a workspace for Rhythm HQ

## What It Does

Staff navigation to HQ removes the selected workspace locally and then refreshes the context. The remembered workspace remains available to later compatibility links.

## The Flow

```mermaid
sequenceDiagram
  participant C as Console provider
  participant S as Security
  Note over C: staff enters HQ
  C->>S: clear cache and remove selected workspace
  S-->>C: workspace-free context or ignored failure
  Note over C: apply only while ticket remains current
```

## When Something Fails

The leave sequence awaits cache clearing before removing the workspace. That await has no local recovery. Once the workspace is removed, a failed Security refresh is ignored and the held snapshot remains. The just-left marker prevents immediate re-entry for five seconds, with a six-second retry if the old address persists.
