Skip to content

Commit b879189

Browse files
waleedlatif1claude
andcommitted
chore(mcp): drop redundant useCallback from startOauthForServer
The reference is only consumed by inline arrow handlers and is not observed by any memoized child or effect dep array, so useCallback adds overhead with no benefit. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 7f1c651 commit b879189

1 file changed

Lines changed: 28 additions & 32 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/settings/components/mcp

apps/sim/app/workspace/[workspaceId]/settings/components/mcp/mcp.tsx

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -225,41 +225,37 @@ export function MCP({ initialServerId }: MCPProps) {
225225
>({})
226226
const [expandedTools, setExpandedTools] = useState<Set<string>>(() => new Set())
227227

228-
const startOauthForServer = useCallback(
229-
async (serverId: string) => {
230-
setConnectingOauthServers((prev) => new Set(prev).add(serverId))
231-
const clear = () => {
232-
const existing = oauthPopupIntervalsRef.current.get(serverId)
233-
if (existing !== undefined) {
234-
window.clearInterval(existing)
235-
oauthPopupIntervalsRef.current.delete(serverId)
236-
}
237-
setConnectingOauthServers((prev) => {
238-
const next = new Set(prev)
239-
next.delete(serverId)
240-
return next
241-
})
228+
const startOauthForServer = async (serverId: string) => {
229+
setConnectingOauthServers((prev) => new Set(prev).add(serverId))
230+
const clear = () => {
231+
const existing = oauthPopupIntervalsRef.current.get(serverId)
232+
if (existing !== undefined) {
233+
window.clearInterval(existing)
234+
oauthPopupIntervalsRef.current.delete(serverId)
242235
}
243-
try {
244-
const result = await startOauthMutation.mutateAsync({ serverId, workspaceId })
245-
if (result.status === 'already_authorized') {
246-
clear()
247-
return
248-
}
249-
const { popup } = result
250-
const interval = window.setInterval(() => {
251-
if (popup.closed) clear()
252-
}, 500)
253-
oauthPopupIntervalsRef.current.set(serverId, interval)
254-
} catch (e) {
236+
setConnectingOauthServers((prev) => {
237+
const next = new Set(prev)
238+
next.delete(serverId)
239+
return next
240+
})
241+
}
242+
try {
243+
const result = await startOauthMutation.mutateAsync({ serverId, workspaceId })
244+
if (result.status === 'already_authorized') {
255245
clear()
256-
logger.error('Failed to start MCP OAuth', e)
257-
toast.error(toError(e).message || 'Failed to start authorization')
246+
return
258247
}
259-
},
260-
// eslint-disable-next-line react-hooks/exhaustive-deps -- mutateAsync is stable
261-
[workspaceId]
262-
)
248+
const { popup } = result
249+
const interval = window.setInterval(() => {
250+
if (popup.closed) clear()
251+
}, 500)
252+
oauthPopupIntervalsRef.current.set(serverId, interval)
253+
} catch (e) {
254+
clear()
255+
logger.error('Failed to start MCP OAuth', e)
256+
toast.error(toError(e).message || 'Failed to start authorization')
257+
}
258+
}
263259

264260
const handleRemoveServer = useCallback((serverId: string, serverName: string) => {
265261
setServerToDelete({ id: serverId, name: serverName })

0 commit comments

Comments
 (0)