Skip to content
Open
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
59 changes: 53 additions & 6 deletions src/renderer/features/settings/components/IntegrationsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,35 @@ const IntegrationsCard: React.FC = () => {
} = useIntegrationsContext();

const showIntegrationSetup = useShowModal('integrationSetupModal');
const showConfirmDisconnect = useShowModal('confirmActionModal');

const isCliManaged = authenticated && tokenSource === 'cli';

useEffect(() => {
void checkStatus();
}, [checkStatus]);

const confirmDisconnect = ({
name,
credential,
onDisconnect,
}: {
name: string;
credential?: string;
onDisconnect: () => void | Promise<void>;
}) => {
showConfirmDisconnect({
title: `Disconnect ${name}`,
description: credential
? `This will delete the saved ${name} ${credential} and disconnect ${name}.`
: `This will disconnect ${name}.`,
confirmLabel: 'Disconnect',
onSuccess: () => {
void onDisconnect();
},
Comment on lines +89 to +91
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Async disconnect errors are silently swallowed here. void onDisconnect() discards the returned Promise, so if disconnectMutation.mutateAsync() (inside each disconnect function) rejects — e.g. a network failure — the modal has already closed and the user receives no feedback. The integration card will remain in the connected state, but no error is surfaced. Consider awaiting the promise or propagating the error to a toast.

Suggested change
onSuccess: () => {
void onDisconnect();
},
onSuccess: async () => {
try {
await onDisconnect();
} catch {
// TODO: surface disconnect errors (e.g. via toast)
}
},
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/renderer/features/settings/components/IntegrationsCard.tsx
Line: 89-91

Comment:
Async disconnect errors are silently swallowed here. `void onDisconnect()` discards the returned `Promise`, so if `disconnectMutation.mutateAsync()` (inside each disconnect function) rejects — e.g. a network failure — the modal has already closed and the user receives no feedback. The integration card will remain in the connected state, but no error is surfaced. Consider awaiting the promise or propagating the error to a toast.

```suggestion
      onSuccess: async () => {
        try {
          await onDisconnect();
        } catch {
          // TODO: surface disconnect errors (e.g. via toast)
        }
      },
```

How can I resolve this? If you propose a fix, please make it concise.

});
};

const integrations = [
{
id: 'github',
Expand All @@ -80,7 +102,7 @@ const IntegrationsCard: React.FC = () => {
loading: isLoading || githubLoading,
onConnect: handleGithubConnect,
onCancel: cancelGithubConnect,
onDisconnect: logout,
onDisconnect: () => confirmDisconnect({ name: 'GitHub', onDisconnect: logout }),
disabledTooltip: isCliManaged
? 'Run `gh auth logout` in your terminal to disconnect'
: undefined,
Expand All @@ -96,7 +118,12 @@ const IntegrationsCard: React.FC = () => {
connected: !!isLinearConnected,
loading: isLinearLoading,
onConnect: () => showIntegrationSetup({ integration: 'linear' }),
onDisconnect: disconnectLinear,
onDisconnect: () =>
confirmDisconnect({
name: 'Linear',
credential: 'API key',
onDisconnect: disconnectLinear,
}),
},
{
id: 'jira',
Expand All @@ -109,7 +136,12 @@ const IntegrationsCard: React.FC = () => {
connected: !!isJiraConnected,
loading: isJiraLoading,
onConnect: () => showIntegrationSetup({ integration: 'jira' }),
onDisconnect: disconnectJira,
onDisconnect: () =>
confirmDisconnect({
name: 'Jira',
credential: 'credentials',
onDisconnect: disconnectJira,
}),
},
{
id: 'gitlab',
Expand All @@ -122,7 +154,12 @@ const IntegrationsCard: React.FC = () => {
connected: !!isGitlabConnected,
loading: isGitlabLoading,
onConnect: () => showIntegrationSetup({ integration: 'gitlab' }),
onDisconnect: disconnectGitlab,
onDisconnect: () =>
confirmDisconnect({
name: 'GitLab',
credential: 'credentials',
onDisconnect: disconnectGitlab,
}),
},
{
id: 'plain',
Expand All @@ -132,7 +169,12 @@ const IntegrationsCard: React.FC = () => {
connected: !!isPlainConnected,
loading: isPlainLoading,
onConnect: () => showIntegrationSetup({ integration: 'plain' }),
onDisconnect: disconnectPlain,
onDisconnect: () =>
confirmDisconnect({
name: 'Plain',
credential: 'API key',
onDisconnect: disconnectPlain,
}),
},
{
id: 'forgejo',
Expand All @@ -145,7 +187,12 @@ const IntegrationsCard: React.FC = () => {
connected: !!isForgejoConnected,
loading: isForgejoLoading,
onConnect: () => showIntegrationSetup({ integration: 'forgejo' }),
onDisconnect: disconnectForgejo,
onDisconnect: () =>
confirmDisconnect({
name: 'Forgejo',
credential: 'credentials',
onDisconnect: disconnectForgejo,
}),
},
];

Expand Down
Loading