Skip to content

feat: use shared_with_user filter for the shared workspaces view#1026

Open
EhabY wants to merge 3 commits into
mainfrom
feat/shared-with-user-query
Open

feat: use shared_with_user filter for the shared workspaces view#1026
EhabY wants to merge 3 commits into
mainfrom
feat/shared-with-user-query

Conversation

@EhabY

@EhabY EhabY commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • The Shared Workspaces view now queries shared_with_user:<current user id> instead of fetching shared:true and filtering out own workspaces client-side. The server-side filter returns exactly the workspaces shared with the user, so excludeOwn/filterWorkspaces() are removed.
  • When the server rejects the workspaces query with HTTP 400 (deployments older than 2.27.0), the view is hidden via a new coder.sharedWorkspacesSupported context key instead of showing an empty tree. The flag resets on any session change (login/logout/deployment switch) and on coder.refreshWorkspaces, so the view re-probes without restarting VS Code.
  • Added initialSize weights to the sidebar views: My Workspaces 2, Shared 1, All 1 (50/25/25 when all are visible). Only affects fresh installs / reset layouts.

Compatibility

shared_with_user: shipped in the same server release as shared:true (both merged Sept 2025, first released in v2.27.0coder/coder#19807 and coder/coder#19875), so there is no deployment where the old query works and the new one doesn't. shared_with_user:me was intentionally avoided since "me" support only landed in coder/coder#26494 (v2.35+); the user UUID works on every supported version and is immune to renames.

On pre-2.27 deployments the previous behavior was a logged fetch error and a permanently empty Shared view; it is now hidden entirely.

Implementation plan / decision log
  1. workspacesProvider.ts
    • WorkspaceQuery enum values become plain identifiers (mine/all/shared); the actual search query moves into WORKSPACE_QUERY_CONFIG as getQuery(session), built at fetch time because the Shared query needs the signed-in user's ID.
    • UUID over username: parseUser on the server accepts both, but the UUID avoids rename/quoting issues.
    • New onQueryRejected option, invoked only for axios HTTP 400 responses. Network errors/5xx keep the existing behavior (warning log + empty tree) so transient failures never hide the view.
  2. extension.ts / contextManager.ts
    • New context key coder.sharedWorkspacesSupported, default true.
    • Shared provider sets it to false on onQueryRejected.
    • Reset to true on deploymentManager.session.onDidChange and in the coder.refreshWorkspaces command (covers in-place server upgrades: re-showing the view triggers its fetch, which hides it again if still unsupported). Hiding the view also stops its polling, since visibility drives the fetch loop.
  3. package.json
    • sharedWorkspaces view gated on coder.authenticated && coder.sharedWorkspacesSupported (same pattern as coder.isOwner on allWorkspaces).
    • initialSize is a stable views-contribution property honored when the extension owns the view container (it does).
  4. Tests: query expectations updated; the client-side ownership-filtering tests are replaced with onQueryRejected coverage (400 fires it once, non-400 does not).

Testing

  • pnpm typecheck, pnpm lint, pnpm format:check
  • pnpm test — 143 files, 2149 passed / 1 skipped

Generated by Coder Agents on behalf of @EhabY.

@EhabY EhabY self-assigned this Jul 7, 2026
@EhabY EhabY requested a review from code-asher July 7, 2026 15:54
Comment thread src/extension.ts Outdated
Comment thread package.json
Comment thread src/extension.ts Outdated
@EhabY EhabY force-pushed the feat/shared-with-user-query branch from 378bb06 to 8c5a8ae Compare July 8, 2026 11:51
@EhabY EhabY requested a review from code-asher July 8, 2026 12:46
@EhabY EhabY force-pushed the feat/shared-with-user-query branch from 4cd935f to 408bdda Compare July 9, 2026 09:47
EhabY and others added 3 commits July 9, 2026 16:43
Toggling view visibility based on coder.sharedWorkspacesSupported raced
the manual refresh command's context flip, causing the view to flicker
on and off across refreshes. The view is now always shown when
authenticated, with viewsWelcome explaining when shared workspaces
aren't supported or the list is empty.
@EhabY EhabY force-pushed the feat/shared-with-user-query branch from 408bdda to 6667b81 Compare July 9, 2026 13:43
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.

2 participants