Port upstream 0.60.4: keep Chrome DeepSeek balance through same-session transport failures (stacked on #646) - #709
Conversation
…on transport failures
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…branch # Conflicts: # apps/desktop-tauri/src-tauri/src/commands/mod.rs
Adversarial validation (lane-A) at 823e091 — restack onto the fresh #646 headRestack result: the branch was previously built on the old #646 commit Review verdict: the branch matches the audit-0.60.4 Gap-1 spec: DeepSeek gains a Chrome Checks at 823e091 (CARGO_TARGET_DIR=W:\cargo-target\lane-a, jobs=4, RUST_TEST_THREADS=4, run in the branch's own worktree
Fast-forward pushed |
…en session lane, last-good retention)
Summary
Ports the behavior of upstream CodexBar 0.60.4 "keep Chrome DeepSeek balances visible through temporary connection failures for the same browser session, preserving the original measurement time".
When no DeepSeek API key is configured, Auto mode now reads the Platform balance through a signed-in Chrome session (token read with the LevelDB reader from #646). If a later refresh fails with a transport failure (timeout or connection refused), the cached balance stays visible with its original
updated_at, but only when the failed request used the same Chrome profile and the same token that produced the cached balance. A rejected session, a different profile or token, a resolution deadline, or a balance with no session owner (for example an API-key balance) is never retained; the error is shown instead.Found by the 0.60.4-0.69.0 port gap audit.
Upstream reference
LastGoodOwner(rust/src/core/last_good_owner.rs), never serialized,Debugredacted.GET https://platform.deepseek.com/api/v0/users/get_user_summary(Bearer,x-client-platform: web), 401/403 or envelope code/biz_code 40002/40003 mean the session is rejected.Ported / Deferred
Ported:
ProviderError::OwnedTransportwraps only transport failures; the shell (commands/providers.rs) records the owner of each fresh snapshot inAppState.last_good_ownersand keeps the cached snapshot only when the failure's owner matches.chrome:<dir>ids), 30-minute validation cache holding digests only, selected-profile balance always fetched live.Deferred (not in this PR):
CODEXBAR_DEEPSEEK_PROFILE_ID(for examplechrome:Profile 1); without it the user is told to set it.DEEPSEEK_PLATFORM_TOKENand other manual-token env support.Local Stateprofile display names (labels use the directory name).Validation
All with toolchain 1.98.0, slot-3 target dir,
--test-threads=4.cargo fmt --all: clean.cargo clippy --workspace --all-targets -- -D warnings: pass.cargo test -p codexbar deepseek: 42 passed, 0 failed.cargo test -p codexbar(full): 2223 passed, 0 failed, 1 ignored.cargo test -p codexbar-desktop-tauri last_good: 9 passed.cargo test -p codexbar-desktop-tauri(full): 468 passed, 1 failed. The failure is the knownbootstrap_payload_exposes_every_provider_variant(fixed by Isolate bootstrap payload test from real settings #684), unrelated.Affected areas
rust/src/core/(owner type,ProviderErrorvariant,ProviderFetchResult.last_good_owner)rust/src/providers/deepseek/(Chrome session lane, platform balance, resolver)rust/src/cli/(exhaustiveProviderErrormatches)apps/desktop-tauri/src-tauri/src/(state.rs,commands/providers.rsretention path)No new dependencies (
sha2andfuturesalready inrust/Cargo.toml). No secrets logged; only profile ids go totracing::debug.Stacked on #646 (base
port/micro-0.66.0-browser-leveldb-reader).UI proof
Pending: coordinator will capture CUA proof on a fresh build.