diff --git a/client/src/components/Chat/Input/CodeWorkspaceMenu.tsx b/client/src/components/Chat/Input/CodeWorkspaceMenu.tsx index 6221c959d7..5d35adefb1 100644 --- a/client/src/components/Chat/Input/CodeWorkspaceMenu.tsx +++ b/client/src/components/Chat/Input/CodeWorkspaceMenu.tsx @@ -380,10 +380,23 @@ function GitContext({ ); } -function WorkspaceRequirements({ id, requirements }: { id: string; requirements: string[] }) { +function WorkspaceRequirements({ + id, + requirements, + visible = false, +}: { + id: string; + requirements: string[]; + visible?: boolean; +}) { if (requirements.length === 0) return null; return ( -
+
{requirements.map((requirement) => (

{requirement}

))} @@ -653,6 +666,8 @@ export default function CodeWorkspaceMenu({ ) { requirements.unshift(localize('com_ui_code_workspace_graph_requirement')); } + const details = [...requirements, ...checkoutSummaries]; + const description = details.join(' '); if (workspace.locked && transition == null) { /** A sealed decision with no transition on offer only reports where this chat runs: without a @@ -675,9 +690,9 @@ export default function CodeWorkspaceMenu({ )} -
+
)} -
+
)} + { } }); + test.each([false, true])( + 'keeps changing workspace requirements out of the composer layout (locked: %s)', + (locked) => { + const requiredBy = [ + { id: 'lia', name: 'Lia' }, + { id: 'reviewer', name: 'PR Reviewer' }, + ]; + const graph = workspace({ locked }); + const setter = jest.fn(); + const { rerenderMenu } = renderMenu( + , + ); + for (const state of ['loading', 'choose', 'unavailable', 'missing'] as const) { + const pending = workspace({ + locked, + state, + canSubmit: false, + environments: [{ environment, state, workspaces: [], requiredBy }], + }); + rerenderMenu( + , + ); + const button = screen.getByTestId( + locked ? 'code-workspace-locked-status' : 'code-workspace', + ); + const requirements = document.getElementById(button.getAttribute('aria-describedby')!); + expect(requirements).toHaveClass('sr-only'); + expect(requirements).toHaveAttribute('role', 'status'); + expect(requirements).toHaveAttribute('aria-live', 'polite'); + expect(requirements).toHaveTextContent('Lia'); + expect(requirements).toHaveTextContent('PR Reviewer'); + expect(button.parentElement).not.toHaveClass('flex-col'); + } + rerenderMenu( + , + ); + expect(screen.queryByText(/Every coding agent/)).not.toBeInTheDocument(); + expect(setter).not.toHaveBeenCalled(); + }, + ); + + test('shows pending workspace requirements in the menu without a second live region', async () => { + const graph = workspace({ state: 'loading', canSubmit: false }); + graph.environments[0] = { + environment, + state: 'loading', + workspaces: [], + requiredBy: [ + { id: 'lia', name: 'Lia' }, + { id: 'reviewer', name: 'PR Reviewer' }, + ], + }; + renderMenu( + , + ); + await userEvent.click(screen.getByTestId('code-workspace')); + const detail = within(screen.getByRole('menu')).getByText( + 'Every coding agent in this chat needs a workspace, including subagents.', + ); + expect(detail).toBeVisible(); + expect(detail.parentElement).not.toHaveClass('sr-only'); + expect(detail.parentElement).not.toHaveAttribute('aria-live'); + expect(screen.getAllByRole('status')).toHaveLength(1); + }); + + test('keeps multi-machine checkout summaries in the menu instead of extra composer rows', async () => { + const graph = workspace(); + graph.environments[0].selected!.checkout = 'source'; + graph.environments.push({ + environment: { ...environment, id: 'reviewer-vm', name: 'Reviewer VM' }, + state: 'ready', + workspaces: [{ id: 'review', name: 'Review' }], + selected: { environmentId: 'reviewer-vm', workspaceId: 'review', checkout: 'isolated' }, + }); + renderMenu( + , + ); + const summary = 'Reviewer VM · Review · com_ui_code_checkout_isolated'; + expect(screen.getByText(summary).parentElement).toHaveClass('sr-only'); + await userEvent.click(screen.getByTestId('code-workspace')); + const detail = within(screen.getByRole('menu')).getByText(summary); + expect(detail).toBeVisible(); + expect(detail.parentElement).not.toHaveClass('sr-only'); + }); + test('explains the missing reviewer workspace while the selected primary workspace is ready', async () => { const reviewerMachine = { ...environment, id: 'reviewer-vm', name: 'Danny Skynet Trusted VM' }; const graph = workspace({ state: 'choose', canSubmit: false });