feat(store): share cookies across clients on same provider+key#2
Merged
Conversation
When two sentinel clients register against the same (provider_name,
api_key) fingerprint, the second registration now inherits any cookie
the first one provided instead of clobbering it with an empty value.
Use case: a programmatic client (CI worker) keeps the cookie fresh; a
desktop client (Stream Deck plugin) re-registers without one — e.g. its
browser auto-extract came up empty because the user logged out — and
now keeps using the cookie the CI worker injected, instead of going
"unauthenticated" until it gets a fresh one.
Implementation:
- ``UsageProvider.merge_credentials_from(other)`` no-op base method.
- Override in xiaomi / crofai / opencode_go to copy non-empty
session_cookie / auth_cookie / workspace_id from the previous
pool holder when the new instance left those fields empty.
- ``Store.register_instance`` calls it on every re-registration
before swapping the provider object in.
Also fixes the lint failure that blocked CI for the xiaomi commit
(tests/test_xiaomi.py: ``ruff format``).
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
xiaomi,crofai,opencode_go) gain amerge_credentials_from(other)hookStore.register_instancecalls it on every re-registration, so an empty-cookie client now inherits the cookie from a peer sharing the same(provider, api_key)fingerprint instead of clobbering itruff formatfailure ontests/test_xiaomi.pythat blocked CI on the previous merge tomainMotivation
A programmatic client (CI worker) keeps a session cookie fresh; a desktop client (Stream Deck plugin) re-registers without one — its browser auto-extract came up empty because the user logged out of that browser — and now keeps using the cookie the CI worker injected, instead of going "unauthenticated" until somebody hands it a fresh one.
The fingerprint already dedupes both clients into a single
ProviderEntry. The dedup branch inStore.register_instancealready does the "newer wins" swap; we just teach it to merge credentials first, so empty fields on the newcomer borrow from the existing holder.Test plan
ruff check .cleanruff format --check .cleanpytest— 240 tests pass locallytest_re_register_same_key_refreshes_provider_configstill passes — the "new provider wins after merge" contract is preserved