Skip to content

fix(auth): hydrate workspace list names#95

Merged
luanvdw merged 2 commits into
mainfrom
fix/auth-workspace-list-names
Jun 22, 2026
Merged

fix(auth): hydrate workspace list names#95
luanvdw merged 2 commits into
mainfrom
fix/auth-workspace-list-names

Conversation

@luanvdw

@luanvdw luanvdw commented Jun 22, 2026

Copy link
Copy Markdown
Member

Overview

Fixes local OAuth workspace sessions that could render the credential workspace id as both the display name and id in auth workspace list and selection flows. The command now upgrades cached placeholder metadata when the Management API can resolve the workspace.

Changes

  • Adds best-effort hydration for local OAuth workspace metadata in packages/cli/src/controllers/auth.ts before list, use, and logout paths consume cached sessions.
  • Updates FileTokenStorage in packages/cli/src/adapters/token-storage.ts so unresolved placeholder metadata falls back to Unknown workspace instead of treating the credential id as a display name.
  • Preserves service-token precedence: PRISMA_SERVICE_TOKEN remains the active source while cached local OAuth sessions are still shown as non-switchable.
  • Expands auth regression coverage for hydrated list output, unresolved fallback behavior, interactive picker labels, and compact table formatting consistency.

Why

The presenter was faithfully rendering bad cached metadata, so masking only the table output would leave auth workspace use picker labels and name-based flows wrong. Hydrating at the storage/controller boundary repairs existing local state opportunistically while keeping the command usable when API lookup fails.

auth_workspace_list

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The PR adds OAuth workspace metadata hydration to the CLI's auth subsystem. In token-storage.ts, a new UNKNOWN_WORKSPACE_NAME constant and workspaceDisplayName helper replace direct use of the raw credential workspace ID as a display fallback, and a new listWorkspaceTokens() method reads stored credential tokens from disk. In auth.ts, a set of internal helpers (hydrateLocalAuthWorkspaces, resolveOAuthWorkspaceMetadata, createSingleWorkspaceTokenStorage, etc.) resolve workspace id/name by calling GET /v1/workspaces/{id} via the management API, persist resolved metadata back to storage, and are wired as a pre-step into listRealAuthWorkspaces, useRealAuthWorkspace, and logoutRealAuthWorkspace. Tests cover successful hydration, 404 fallback behavior, and the interactive workspace picker.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding hydration of workspace list names to fix the display issue with local OAuth workspace sessions.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description clearly relates to the changeset, explaining a fix for local OAuth workspace sessions that render incorrect metadata, with details on what was changed and why.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/auth-workspace-list-names
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/auth-workspace-list-names

Comment @coderabbitai help to get the list of available commands and usage tips.

@luanvdw
luanvdw marked this pull request as ready for review June 22, 2026 07:34
@luanvdw
luanvdw requested a review from AmanVarshney01 June 22, 2026 08:04
@luanvdw
luanvdw merged commit 3919db7 into main Jun 22, 2026
10 checks passed
@luanvdw
luanvdw deleted the fix/auth-workspace-list-names branch June 22, 2026 08:08
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