AIStudio2API icon indicating copy to clipboard operation
AIStudio2API copied to clipboard

Allow seamless in-place cookie replacement for auth_required and restricted accounts without deleting runtime-state.json

Open photobrand opened this issue 1 week ago • 0 comments

想要什么,用来做什么 / What you want and what for

What I want & Use Case

For accounts added via Paste cookies (which often carry __Secure-1PSIDRTS and expire after ~2 hours without Chrome OAuth/DBSC renewal material, hitting 401 auth_required — see #203), users regularly need to paste fresh cookies for an existing account email.

Right now, the UI and import checks push users toward Delete -> Re-add, which calls AccountStore.Delete (os.RemoveAll) and destroys auth/<email>/runtime-state.json — wiping cooldowns, benefit_tier, model_access, and Drive resources bindings for that account.

Current Friction Points (verified in v0.3.13 / c77dd89)

  1. auth_required accounts hide their "Already imported" status and have no cookie-update row action:
    • In internal/app/admin.go, accountIDs() explicitly skips AccountAuthRequired. In the Paste cookies dialog (DiscoverCookieAccounts), an expired account shows imported: false instead of indicating it will update the existing account in place.
    • On the account row (web/src/components/AccountsPanel.vue), account.state === 'auth_required' only shows Re-login (Camoufox browser login), with no Update cookies action for cookie-imported accounts. (Calling ImportAccountState without deleting actually works via upsertAccount -> updateImportedAccount and preserves runtime-state.json, but the UI obscures this.)
  2. restricted accounts block in-place cookie updates completely:
    • In internal/app/admin.go, checkAccountAccess rejects ImportAccountState with 403 account_restricted based on the old admin.accountIDs() state before even checking the newly submitted StorageState, and AccountsPanel.vue disables the checkbox (:disabled="candidate.restricted !== ''").
    • Once an account is restricted (e.g., 403 verification), a user who verified the account in a browser and exported fresh cookies cannot overwrite cookies in place — they must either delete the account (wiping runtime-state.json) or reset state to ready (which also clears all Cooldowns).

Proposed Improvement

  1. Preserve "Already imported" / updatable indicator for auth_required accounts in DiscoverCookieAccounts (e.g., distinguish imported: true + state or let the Paste cookies UI clearly show it will replace cookies in place).
  2. Allow ImportAccountState to replace cookies for an existing restricted account when the newly submitted StorageState passes chromeauth.CheckAccess (instead of short-circuiting on the stale restricted status in checkAccountAccess), clearing runtimeState.Restricted upon successful verification while keeping runtimeState.Cooldowns, Resources, and ModelAccess intact.
  3. Add an "Update cookies" row action (or pre-targeted Paste cookies shortcut) for existing accounts (especially auth_required / restricted) so users can refresh expired cookies without deleting the account.

版本 / Version

v0.3.13

photobrand avatar Nov 20 '26 23:11 photobrand