-
Notifications
You must be signed in to change notification settings - Fork 0
feat(quota): optimize quota refresh logic, add relative countdowns, parallelize card refreshes #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Removing serial refresh queue allows concurrent refreshes that race on the shared
refresh_runtimedirectoryThe old
drainRefreshQueueserialized all profile refreshes one-at-a-time via therefreshWorkerActive/refreshQueuepattern. The newperformProfileRefreshfires each refresh immediately and concurrently (viavoid performProfileRefresh(profile)). While the guard atsrc-tauri/shared/front/actions.ts:288-294prevents duplicate refreshes for the same profile, it allows concurrent refreshes for different profiles.This introduces a race condition in the backend's
refresh_via_app_serverfallback path: bothmac/runtime/refresh_runtime.rs:224-264andwin/runtime/refresh_runtime.rs:207-239callprepare_refresh_runtime_home, which copies the requesting profile'sauth.jsoninto a single shared directory (refresh_runtime/, defined atsrc-tauri/shared/runtime/paths.rs:15). If two profiles both fall back to the app-server path concurrently, they race on writing their respectiveauth.jsoninto the same directory, then each spawns acodex app-serverprocess against the mixed state, and finally copies the result back. This can cause one profile to receive the other's auth tokens — a data integrity and security issue.Why the fast HTTP path is unaffected
The primary
try_refresh_via_chatgpt_apipath uses direct HTTP calls against profile-specificauth.jsonfiles in the backup root and doesn't touch the shared runtime directory, so concurrent fast-path refreshes are safe. The race only surfaces when two or more profiles both fall through to therefresh_via_app_serverfallback (e.g., non-OAuth profiles, or transient HTTP failures).(Refers to lines 264-296)
Prompt for agents
Was this helpful? React with 👍 or 👎 to provide feedback.