feat: defer api key generation with mutation - #22318
Merged
jakehwll merged 3 commits intoMar 5, 2026
Merged
Conversation
Contributor
|
Can we update all uses of get api key to be mutations? Thinking about the dedicated VSCode buttons |
Contributor
Author
I'll scope this for another sprint 🙂 |
DanielleMaywood
approved these changes
Feb 27, 2026
Comment on lines
+808
to
+821
| const generateKeyMutation = useMutation({ | ||
| mutationFn: () => API.getApiKey(), | ||
| onSuccess: ({ key }) => { | ||
| // We use a `location.href` here instead of a `navigate` because | ||
| // these are protocol-specific links. | ||
| location.href = getVSCodeHref(variant, { | ||
| owner, | ||
| workspace, | ||
| token: key, | ||
| agent, | ||
| folder, | ||
| }); | ||
| }, | ||
| }); |
Contributor
There was a problem hiding this comment.
non-blocking: future work will require making multiple useMutation({ mutationFn: () => API.getApiKey() }). Thoughts on creating a helper for that now?
kylecarbs
added a commit
that referenced
this pull request
Mar 3, 2026
The handler used window.location.assign() and an async/await pattern that differed from the working VSCodeDesktopButton on the workspace page. Align with that component's proven pattern: generate the API key on click via useMutation and set location.href on success. Also simplify by accepting "cursor" in getVSCodeHref so we don't need the cursorApp lookup or regex replace hack. Changes: - Add "cursor" to getVSCodeHref app union type - Use useMutation for on-click API key generation matching #22318 - Use location.href = getVSCodeHref(editor, ...) for navigation - Remove workspace app lookup for cursor - Remove SESSION_TOKEN_PLACEHOLDER import (no longer needed)
jakehwll
deleted the
jakehwll/KIWI-24-defer-workspaceapps-api-key-generation
branch
March 5, 2026 04:50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #22065
This pull-request ensures that when we load the
<WorkspacePage />we're not instantly attempting to generate anapiKeyevery-time. These are now only generated once the user attempts to actually click on the VSCode link, this is now a mutation also (which is the correct action for this).