Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/web/src/collab/useWorkspaceContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,9 @@ export function useWorkspaceContext(): WorkspaceContextState {
// (including plugin context defaults) remain compatible. This is display
// metadata only: authority still comes from the explicit ids above, and
// no daemon/backend "active workspace" state is consulted or written.
const workspaceName = selected.workspaceName.trim();
const workspaceName = typeof selected.workspaceName === 'string'
? selected.workspaceName.trim()
: '';
return workspaceName
? { context: { ...body.context, workspaceName } }
: body;
Expand Down
1 change: 1 addition & 0 deletions apps/web/tests/components/App.project-create-race.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ function workspaceContext(
) {
return {
workspaceId,
workspaceName: workspaceId,
workspaceType: 'team' as const,
workspaceMemberId,
role: 'member' as const,
Expand Down
35 changes: 35 additions & 0 deletions apps/web/tests/useWorkspaceContext.cache.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,39 @@ describe('useWorkspaceContext module cache', () => {
});
});
});

it('keeps a verified context when a legacy directory row omits workspaceName', async () => {
const legacyContext = workspaceContextFixture({
workspaceId: 'ws-legacy-no-name',
workspaceMemberId: 'member-legacy-no-name',
});
vi.stubGlobal(
'fetch',
vi.fn(async (input: RequestInfo | URL) =>
new Response(JSON.stringify(
String(input) === '/api/workspace/directory'
? {
items: [{
workspaceId: 'ws-legacy-no-name',
workspaceType: 'team',
workspaceMemberId: 'member-legacy-no-name',
role: 'member',
memberStatus: 'active',
lifecycleState: 'active',
}],
activeWorkspaceId: null,
}
: { context: legacyContext },
), {
status: 200,
headers: { 'content-type': 'application/json' },
}),
),
);

const result = renderHook(() => useWorkspaceContext());
await waitFor(() => expect(result.result.current.loading).toBe(false));
expect(result.result.current.context).toEqual(legacyContext);
expect(result.result.current.failure).toBeUndefined();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const SIGNED_IN = workspaceContextFixture({
workspaceId: 'ws-1',
workspaceMemberId: 'member-1',
teamName: 'Acme',
workspaceName: 'Acme',
});

/** A fetch whose every call resolves only when the test says so. */
Expand Down
Loading