Skip to content

Fix tiny UI race after add SSH key in instance create form#3177

Merged
david-crespo merged 2 commits intomainfrom
fix-ssh-key-race
Apr 10, 2026
Merged

Fix tiny UI race after add SSH key in instance create form#3177
david-crespo merged 2 commits intomainfrom
fix-ssh-key-race

Conversation

@david-crespo
Copy link
Copy Markdown
Collaborator

@david-crespo david-crespo commented Apr 10, 2026

It's barely worth fixing, but codex flagged it in #3173 and it's real. Watch the select all checkbox below when I submit the create SSH key form. In the very short interval of time after the key is created and but before list of keys refetches, the select all checkbox flashes checked (all are selected) before flipping back to intermediate when the list comes in. It's trivial and it's not worth keeping the e2e test I used to prove and fix it (removed in 966aac1), but it is worth fixing now that I know about.

2026-04-10-ssh-key-race.mp4

The checkbox showing the wrong thing is not actually the entire bug — if the user toggles select all during this interval, the behavior is slightly weird because the list of keys is out of sync, but it's nearly impossible for a human user to move fast enough to run into the issue, and the state after the request comes back will be up to date. The real fix would be to make onSuccess wait until after the invalidate is complete. But we don't have any other examples of async onSuccess, so I don't want to rush that fix in.

   const handleDismiss = onDismiss ? onDismiss : () => navigate(pb.sshKeys())
 
   const createSshKey = useApiMutation(api.currentUserSshKeyCreate, {
-    onSuccess(sshKey) {
-      queryClient.invalidateEndpoint('currentUserSshKeyList')
+    async onSuccess(sshKey) {
+      await queryClient.invalidateEndpoint('currentUserSshKeyList')
       onSuccess?.(sshKey)
       handleDismiss()
       // prettier-ignore

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
console Ready Ready Preview Apr 10, 2026 9:13pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant