feat: shared workspaces support#957
Conversation
Adds a third tree view, Shared Workspaces, that lists workspaces the current user has access to but does not own. Visible to any authenticated user (unlike All Workspaces, which is admin-only). Generated with Coder Agents on behalf of @aslilac.
| // Shared returns workspaces the user has access to via sharing but does not | ||
| // own. The server-side `shared:true` filter also includes workspaces the | ||
| // user owns and has shared out, so the provider filters those out | ||
| // client-side using the current user's id. |
There was a problem hiding this comment.
Agents tend to over explain with what and not why. I'd trim this a bit more (same for all of the new comments here)
| private readonly getCurrentUserId: () => string | undefined = () => | ||
| undefined, |
There was a problem hiding this comment.
I'd rather decouple this, like maybe pass filterWorkspaces?: (ws: Workspace[]) => Workspace[] and remove any knowledge of the current user from here
| #deployment: Deployment | null = null; | ||
| #currentUserId: string | undefined; |
There was a problem hiding this comment.
Maybe call it #authedUser: User | null so it's more explicit, we can keep the derived getCurrentUserId
| client, | ||
| output, | ||
| isAuthenticated, | ||
| undefined, |
There was a problem hiding this comment.
Do we want to poll for refreshes or keep it like All and only on manual refreshes?
| let workspaces = resp.workspaces; | ||
| if (this.getWorkspacesQuery === WorkspaceQuery.Shared) { | ||
| const currentUserId = this.getCurrentUserId(); | ||
| if (currentUserId) { | ||
| workspaces = workspaces.filter( | ||
| (workspace) => workspace.owner_id !== currentUserId, | ||
| ); | ||
| } | ||
| } |
There was a problem hiding this comment.
If we make this a filter then we can just make it a const and should be cleaner (separation of concerns)
Adds a third tree view, Shared Workspaces, that lists workspaces the current user has access to but does not own. The view is visible to any authenticated user, sits between My Workspaces and All Workspaces, and reuses the existing context-menu actions and refresh/search affordances.
Implementation notes
WorkspaceQuery.Shared = "shared:true"value; the provider filters out workspaces owned by the current user client-side, becauseshared:trueserver-side also matches workspaces the current user shared out.DeploymentManagerexposesgetCurrentUserId()so the new provider can scope the filter to the active session; this is cleared on logout/suspend.coder.refreshWorkspacesnow also refreshes the new view.