Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🔗 refactor: Restyle the Connected Accounts Settings Row (#17460)

Marco Berettaec9aea1f699d
diff --git a/client/src/components/Nav/Settings/ConnectedAccounts.tsx b/client/src/components/Nav/Settings/ConnectedAccounts.tsx
index 3dc0c953ee..9003639d1c 100644
--- a/client/src/components/Nav/Settings/ConnectedAccounts.tsx
+++ b/client/src/components/Nav/Settings/ConnectedAccounts.tsx
@@ -1,18 +1,14 @@
import { useCallback, useEffect, useId, useRef, useState } from 'react';
-import { ExternalLink, Gitlab } from 'lucide-react';
import { apiBaseUrl } from 'librechat-data-provider';
import { useQueryClient } from '@tanstack/react-query';
+import { ExternalLink, Gitlab, RotateCw } from 'lucide-react';
import {
- AlertDialog,
- AlertDialogCancel,
- AlertDialogContent,
- AlertDialogDescription,
- AlertDialogFooter,
- AlertDialogHeader,
- AlertDialogTitle,
- AlertDialogTrigger,
+ Alert,
Button,
Chip,
+ OGDialog,
+ OGDialogTemplate,
+ OGDialogTrigger,
GithubIcon,
Skeleton,
Spinner,
@@ -29,6 +25,7 @@ import {
pullRequestSignInSession,
} from '~/data-provider';
import { useLocalize } from '~/hooks';
+import { cn } from '~/utils';
const PROVIDERS: Record<
PullRequestProvider,
@@ -222,13 +219,17 @@ export default function ConnectedAccounts() {
});
};
- let statusContent = <Chip tone="neutral">{localize('com_ui_pr_account_checking')}</Chip>;
- let action = <Skeleton className="h-9 w-24" aria-hidden="true" />;
+ let statusContent = (
+ <Chip tone="neutral" leading={<Spinner className="shrink-0" size={12} aria-hidden="true" />}>
+ {localize('com_ui_pr_account_checking')}
+ </Chip>
+ );
+ let action = <Skeleton className="h-8 w-24 rounded-lg" aria-hidden="true" />;
const statusError = (
- <span className="text-text-destructive text-xs">
+ <Chip tone="error" leading={<StatusDot className="bg-status-error" />}>
{localize('com_ui_pr_account_status_error')}
- </span>
+ </Chip>
);
/** A grant known to be removable stays removable while a later status check fails. */
@@ -244,17 +245,25 @@ export default function ConnectedAccounts() {
aria-busy={status.isFetching}
onClick={retry}
>
- {status.isFetching ? <Spinner className="h-4 w-4" /> : localize('com_ui_retry')}
+ <RotateCw
+ className={cn('size-4', status.isFetching && 'animate-spin motion-reduce:animate-none')}
+ aria-hidden="true"
+ />
+ {localize('com_ui_retry')}
</Button>
);
} else if (status.data?.connected === true) {
statusContent = unused ? (
- <Chip tone="neutral">{localize('com_ui_pr_account_not_in_use')}</Chip>
+ <Chip tone="neutral" leading={<StatusDot className="bg-status-neutral" />}>
+ {localize('com_ui_pr_account_not_in_use')}
+ </Chip>
) : (
- <Chip tone="success">{localize('com_ui_pr_account_connected')}</Chip>
+ <Chip tone="success" leading={<StatusDot className="bg-status-success" />}>
+ {localize('com_ui_pr_account_connected')}
+ </Chip>
);
action = (
- <AlertDialogTrigger asChild>
+ <OGDialogTrigger asChild>
<Button
ref={bindAction}
type="button"
@@ -264,25 +273,25 @@ export default function ConnectedAccounts() {
>
{localize('com_ui_pr_account_disconnect')}
</Button>
- </AlertDialogTrigger>
+ </OGDialogTrigger>
);
} else if (status.data != null) {
- statusContent = <Chip tone="neutral">{localize('com_ui_pr_account_not_connected')}</Chip>;
+ /** No badge for the resting state; the status region still announces it. */
+ statusContent = <span className="sr-only">{localize('com_ui_pr_account_not_connected')}</span>;
action = (
<Button
ref={bindAction}
type="button"
- variant="outline"
+ variant="submit"
size="sm"
aria-label={localize('com_ui_pr_account_connect_aria', { 0: name })}
aria-busy={connectMutation.isLoading}
aria-disabled={connectMutation.isLoading}
onClick={connect}
>
- {connectMutation.isLoading ? (
- <Spinner className="h-4 w-4" />
- ) : (
- localize('com_ui_pr_account_connect')
+ {connectMutation.isLoading && <Spinner className="size-4" aria-hidden="true" />}
+ {localize(
+ connectMutation.isLoading ? 'com_ui_pr_account_connecting' : 'com_ui_pr_account_connect',
)}
</Button>
);
@@ -293,7 +302,7 @@ export default function ConnectedAccounts() {
}
return (
- <AlertDialog
+ <OGDialog
open={confirmOpen}
onOpenChange={(open) => {
/** A disconnect already sent cannot be taken back, so it is not dismissed mid-request. */
@@ -314,13 +323,17 @@ export default function ConnectedAccounts() {
role="group"
aria-labelledby={labelId}
aria-describedby={descriptionId}
- className="flex flex-col gap-2"
+ aria-busy={status.isLoading}
+ className="flex flex-col gap-3"
>
<div className="flex items-center gap-3">
- <span className="text-text-secondary shrink-0" aria-hidden="true">
- <Icon className="h-5 w-5" />
+ <span
+ className="border-border-light bg-surface-secondary text-text-primary flex size-10 shrink-0 items-center justify-center rounded-lg border"
+ aria-hidden="true"
+ >
+ <Icon className="size-5" />
</span>
- <div className="min-w-0 flex-1">
+ <div className="flex min-w-0 flex-1 flex-col gap-0.5">
{/** The status sits beside the name, not in the row, so the description keeps the
* column's width on a phone. */}
<div className="flex flex-wrap items-center gap-x-2 gap-y-1">
@@ -337,15 +350,15 @@ export default function ConnectedAccounts() {
</div>
<div className="shrink-0">{action}</div>
</div>
- {connectError != null && (
- <p role="alert" className="text-text-destructive text-xs">
- {localize(connectError)}
- </p>
- )}
+ {connectError != null && <Alert variant="error">{localize(connectError)}</Alert>}
</div>
- <AlertDialogContent
- className="w-11/12 max-w-md"
+ <OGDialogTemplate
+ title={localize('com_ui_pr_account_disconnect_title', { 0: name })}
+ description={localize('com_ui_pr_account_disconnect_description')}
+ className="max-w-md"
+ mainClassName={disconnectFailed ? undefined : 'hidden'}
+ cancelDisabled={disconnectMutation.isLoading}
onCloseAutoFocus={(event) => {
event.preventDefault();
const action = actionRef.current;
@@ -355,26 +368,12 @@ export default function ConnectedAccounts() {
fallbackRef.current?.focus();
}
}}
- >
- <AlertDialogHeader>
- <AlertDialogTitle>
- {localize('com_ui_pr_account_disconnect_title', { 0: name })}
- </AlertDialogTitle>
- <AlertDialogDescription>
- {localize('com_ui_pr_account_disconnect_description')}
- </AlertDialogDescription>
- </AlertDialogHeader>
- {disconnectFailed && (
- <p role="alert" className="text-text-destructive text-xs">
- {localize('com_ui_pr_account_disconnect_error')}
- </p>
- )}
- <AlertDialogFooter className="mt-2">
- <AlertDialogCancel asChild>
- <Button type="button" variant="outline" disabled={disconnectMutation.isLoading}>
- {localize('com_ui_cancel')}
- </Button>
- </AlertDialogCancel>
+ main={
+ disconnectFailed ? (
+ <Alert variant="error">{localize('com_ui_pr_account_disconnect_error')}</Alert>
+ ) : null
+ }
+ selection={
<Button
type="button"
variant="destructive"
@@ -382,15 +381,21 @@ export default function ConnectedAccounts() {
aria-busy={disconnectMutation.isLoading}
disabled={disconnectMutation.isLoading}
onClick={disconnect}
+ className="max-sm:order-first max-sm:w-full"
>
- {disconnectMutation.isLoading ? (
- <Spinner className="h-4 w-4" />
- ) : (
- localize('com_ui_pr_account_disconnect')
+ {disconnectMutation.isLoading && <Spinner className="size-4" aria-hidden="true" />}
+ {localize(
+ disconnectMutation.isLoading
+ ? 'com_ui_pr_account_disconnecting'
+ : 'com_ui_pr_account_disconnect',
)}
</Button>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
+ }
+ />
+ </OGDialog>
);
}
+
+function StatusDot({ className }: { className: string }) {
+ return <span className={cn('size-1.5 shrink-0 rounded-full', className)} aria-hidden="true" />;
+}
diff --git a/client/src/components/Nav/Settings/__tests__/ConnectedAccounts.spec.tsx b/client/src/components/Nav/Settings/__tests__/ConnectedAccounts.spec.tsx
index c2c3f86450..99d7d20c4d 100644
--- a/client/src/components/Nav/Settings/__tests__/ConnectedAccounts.spec.tsx
+++ b/client/src/components/Nav/Settings/__tests__/ConnectedAccounts.spec.tsx
@@ -405,7 +405,7 @@ describe('ConnectedAccounts', () => {
expect(screen.getByRole('status')).toHaveTextContent('com_ui_pr_account_connected');
await userEvent.click(trigger);
- const dialog = await screen.findByRole('alertdialog');
+ const dialog = await screen.findByRole('dialog');
expect(dialog).toHaveTextContent(
'com_ui_pr_account_disconnect_title:com_ui_pr_provider_github',
);
@@ -415,7 +415,7 @@ describe('ConnectedAccounts', () => {
await userEvent.click(screen.getByRole('button', { name: 'com_ui_pr_account_disconnect' }));
await waitFor(() => expect(mockDisconnect).toHaveBeenCalledTimes(1));
- await waitFor(() => expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument());
+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());
expect(invalidate).toHaveBeenCalledWith([QueryKeys.pullRequestConnection]);
expect(invalidate).toHaveBeenCalledWith([QueryKeys.conversationPullRequest]);
const connect = await screen.findByRole('button', { name: /com_ui_pr_account_connect_aria/ });
@@ -443,11 +443,11 @@ describe('ConnectedAccounts', () => {
await userEvent.click(
await screen.findByRole('button', { name: /com_ui_pr_account_disconnect_aria/ }),
);
- await screen.findByRole('alertdialog');
+ await screen.findByRole('dialog');
mockGetConnection.mockResolvedValue({ configured: false, connected: false });
await userEvent.click(screen.getByRole('button', { name: 'com_ui_pr_account_disconnect' }));
- await waitFor(() => expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument());
+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());
expect(screen.queryByRole('group')).toBeNull();
await waitFor(() => expect(screen.getByRole('tabpanel')).toHaveFocus());
});
@@ -482,13 +482,13 @@ describe('ConnectedAccounts', () => {
await screen.findByRole('button', { name: 'com_ui_pr_account_disconnect' }),
);
- const cancel = screen.getByRole('button', { name: 'com_ui_cancel' });
+ const cancel = screen.getByRole('button', { name: 'Cancel' });
await waitFor(() => expect(cancel).toBeDisabled());
await userEvent.keyboard('{Escape}');
- expect(screen.getByRole('alertdialog')).toBeInTheDocument();
+ expect(screen.getByRole('dialog')).toBeInTheDocument();
settle();
- await waitFor(() => expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument());
+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());
});
it('keeps the confirmation open with an error when disconnecting fails', async () => {
@@ -506,7 +506,7 @@ describe('ConnectedAccounts', () => {
expect(await screen.findByRole('alert')).toHaveTextContent(
'com_ui_pr_account_disconnect_error',
);
- expect(screen.getByRole('alertdialog')).toBeInTheDocument();
+ expect(screen.getByRole('dialog')).toBeInTheDocument();
});
it('closes the confirmation when a failed disconnect had ended the connection after all', async () => {
@@ -526,7 +526,7 @@ describe('ConnectedAccounts', () => {
);
await waitFor(() => expect(mockGetConnection.mock.calls.length).toBeGreaterThan(asked));
- await waitFor(() => expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument());
+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());
const connect = await screen.findByRole('button', { name: /com_ui_pr_account_connect_aria/ });
await waitFor(() => expect(connect).toHaveFocus());
/** Pull requests follow the server's token now. */
@@ -552,8 +552,8 @@ describe('ConnectedAccounts', () => {
expect(await screen.findByRole('alert')).toHaveTextContent(
'com_ui_pr_account_disconnect_error',
);
- await userEvent.click(screen.getByRole('button', { name: 'com_ui_cancel' }));
- await waitFor(() => expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument());
+ await userEvent.click(screen.getByRole('button', { name: 'Cancel' }));
+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());
act(() => answer(connection(false)));
const connect = await screen.findByRole('button', { name: /com_ui_pr_account_connect_aria/ });
@@ -577,7 +577,7 @@ describe('ConnectedAccounts', () => {
expect(await screen.findByRole('alert')).toHaveTextContent(
'com_ui_pr_account_disconnect_error',
);
- expect(screen.getByRole('alertdialog')).toBeInTheDocument();
+ expect(screen.getByRole('dialog')).toBeInTheDocument();
});
it('keeps the confirmation button named while the disconnect is in flight', async () => {
@@ -595,7 +595,7 @@ describe('ConnectedAccounts', () => {
await waitFor(() => expect(confirm).toHaveAttribute('aria-busy', 'true'));
expect(screen.getByRole('button', { name: 'com_ui_pr_account_disconnect' })).toBe(confirm);
settle();
- await waitFor(() => expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument());
+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());
});
it('names the provider the server reports over a stale startup config', async () => {
diff --git a/client/src/locales/en/translation.json b/client/src/locales/en/translation.json
index 84c3168972..466b7381de 100644
--- a/client/src/locales/en/translation.json
+++ b/client/src/locales/en/translation.json
@@ -4,12 +4,14 @@
"com_ui_pr_account_connect_aria": "Connect {{0}}",
"com_ui_pr_account_connect_error": "Couldn't start connecting. Try again.",
"com_ui_pr_account_connected": "Connected",
+ "com_ui_pr_account_connecting": "Connecting",
"com_ui_pr_account_description": "Look up pull requests with your own account",
"com_ui_pr_account_disconnect": "Disconnect",
"com_ui_pr_account_disconnect_aria": "Disconnect {{0}}",
"com_ui_pr_account_disconnect_description": "Pull requests will no longer be looked up with your account. You can connect it again at any time.",
"com_ui_pr_account_disconnect_error": "Couldn't disconnect. Try again.",
"com_ui_pr_account_disconnect_title": "Disconnect {{0}}?",
+ "com_ui_pr_account_disconnecting": "Disconnecting",
"com_ui_pr_account_not_connected": "Not connected",
"com_ui_pr_account_not_in_use": "Not in use",
"com_ui_pr_account_popup_blocked": "Your browser blocked the sign-in window. Allow pop-ups and try again.",
diff --git a/e2e/specs/mock/scenarios/connected-accounts.spec.ts b/e2e/specs/mock/scenarios/connected-accounts.spec.ts
new file mode 100644
index 0000000000..f2eb17c4ca
--- /dev/null
+++ b/e2e/specs/mock/scenarios/connected-accounts.spec.ts
@@ -0,0 +1,149 @@
+import { expect, test } from '@playwright/test';
+import type { Page, Route } from '@playwright/test';
+import { accountButton } from './ui-scale.helpers';
+
+/**
+ * The Connected Accounts row in Settings > Account. The mock config has no pull request OAuth
+ * app, so startup is told one is configured and the connection endpoints are answered here:
+ * each test drives the row through the states a real server reports.
+ */
+
+type Status = { configured: boolean; connected: boolean; provider: 'github' } | 'error';
+
+const connected: Status = { configured: true, connected: true, provider: 'github' };
+const disconnected: Status = { configured: true, connected: false, provider: 'github' };
+
+const json = (route: Route, body: unknown, status = 200) =>
+ route.fulfill({ status, contentType: 'application/json', body: JSON.stringify(body) });
+
+/** The PWA service worker serves API GETs itself, which would bypass every `page.route` below. */
+test.use({ serviceWorkers: 'block' });
+
+/** Answers the status endpoint with whatever `state.status` holds when the request arrives. */
+async function mockConnection(page: Page, initial: Status) {
+ const state = { status: initial };
+ await page.route('**/api/config', async (route) => {
+ const response = await route.fetch();
+ const config = await response.json();
+ await route.fulfill({ response, json: { ...config, pullRequestsConnect: 'github' } });
+ });
+ await page.route('**/api/pull-requests/oauth/status', (route) =>
+ state.status === 'error'
+ ? json(route, { error: 'unavailable' }, 500)
+ : json(route, state.status),
+ );
+ return state;
+}
+
+async function openConnectedAccounts(page: Page) {
+ await page.goto('/c/new', { timeout: 10000 });
+ await (await accountButton(page)).click();
+ await page.getByRole('menuitem', { name: 'Settings' }).click();
+ const settings = page.getByRole('dialog', { name: /Settings/ });
+ await settings.getByRole('tab', { name: 'Account' }).click();
+ const row = settings.getByRole('group', { name: 'GitHub' });
+ await expect(row).toBeVisible();
+ return row;
+}
+
+test.describe('connected accounts', () => {
+ test('an unconnected account offers Connect as the primary action and announces its state @scenario:connected-accounts-not-connected', async ({
+ page,
+ }) => {
+ await mockConnection(page, disconnected);
+ const row = await openConnectedAccounts(page);
+
+ await expect(row.getByRole('status')).toHaveText('Not connected');
+ const connect = row.getByRole('button', { name: 'Connect GitHub' });
+ await expect(connect).toBeVisible();
+ await expect(connect).toHaveText('Connect');
+ await connect.focus();
+ await expect(connect).toBeFocused();
+ });
+
+ test('confirming Disconnect ends the connection and moves focus to Connect @scenario:connected-accounts-disconnect-confirmed', async ({
+ page,
+ }) => {
+ const state = await mockConnection(page, connected);
+ let deletes = 0;
+ await page.route('**/api/pull-requests/oauth', (route) => {
+ if (route.request().method() !== 'DELETE') {
+ return route.fallback();
+ }
+ deletes += 1;
+ state.status = disconnected;
+ return json(route, { connected: false });
+ });
+ const row = await openConnectedAccounts(page);
+
+ await expect(row.getByRole('status')).toHaveText('Connected');
+ await row.getByRole('button', { name: 'Disconnect GitHub' }).click();
+ const confirm = page.getByRole('dialog', { name: 'Disconnect GitHub?' });
+ await expect(confirm).toBeVisible();
+ await confirm.getByRole('button', { name: 'Disconnect', exact: true }).click();
+
+ await expect(confirm).toBeHidden();
+ expect(deletes).toBe(1);
+ await expect(row.getByRole('button', { name: 'Connect GitHub' })).toBeFocused();
+ });
+
+ test('a failed disconnect keeps the confirmation open with an error, and Cancel returns focus @scenario:connected-accounts-disconnect-failed', async ({
+ page,
+ }) => {
+ await mockConnection(page, connected);
+ await page.route('**/api/pull-requests/oauth', (route) =>
+ route.request().method() === 'DELETE'
+ ? json(route, { error: 'failed' }, 500)
+ : route.fallback(),
+ );
+ const row = await openConnectedAccounts(page);
+
+ const trigger = row.getByRole('button', { name: 'Disconnect GitHub' });
+ await trigger.click();
+ const confirm = page.getByRole('dialog', { name: 'Disconnect GitHub?' });
+ await confirm.getByRole('button', { name: 'Disconnect', exact: true }).click();
+
+ await expect(confirm.getByRole('alert')).toHaveText("Couldn't disconnect. Try again.");
+ await expect(confirm).toBeVisible();
+ await confirm.getByRole('button', { name: 'Cancel' }).click();
+ await expect(confirm).toBeHidden();
+ await expect(trigger).toBeFocused();
+ await expect(row.getByRole('status')).toHaveText('Connected');
+ });
+
+ test('a failed status check shows an error and Retry recovers the real state @scenario:connected-accounts-status-retry', async ({
+ page,
+ }) => {
+ const state = await mockConnection(page, 'error');
+ const row = await openConnectedAccounts(page);
+
+ await expect(row.getByRole('status')).toHaveText("Couldn't check the connection", {
+ timeout: 20000,
+ });
+ state.status = connected;
+ const retry = row.getByRole('button', { name: 'Retry' });
+ await retry.click();
+
+ await expect(row.getByRole('status')).toHaveText('Connected');
+ await expect(row.getByRole('button', { name: 'Disconnect GitHub' })).toBeFocused();
+ });
+
+ test('a connect request the server rejects explains the failure in the row @scenario:connected-accounts-connect-failed', async ({
+ page,
+ }) => {
+ await mockConnection(page, disconnected);
+ await page.route('**/api/pull-requests/oauth/connect', (route) =>
+ json(route, { error: 'failed' }, 500),
+ );
+ const row = await openConnectedAccounts(page);
+
+ const popup = page.waitForEvent('popup');
+ await row.getByRole('button', { name: 'Connect GitHub' }).click();
+
+ await expect(row.getByRole('alert')).toHaveText("Couldn't start connecting. Try again.");
+ /** The blank window opened in the click is closed rather than left behind. */
+ const opened = await popup;
+ await expect.poll(() => opened.isClosed()).toBe(true);
+ await expect(row.getByRole('button', { name: 'Connect GitHub' })).toHaveText('Connect');
+ });
+});