Skip to content

feat: auto re-auth when all accounts are permanently unhealthy#70

Open
RaphaelManke wants to merge 1 commit intotickernelz:masterfrom
RaphaelManke:feat/auto-reauth-on-permanent-failure
Open

feat: auto re-auth when all accounts are permanently unhealthy#70
RaphaelManke wants to merge 1 commit intotickernelz:masterfrom
RaphaelManke:feat/auto-reauth-on-permanent-failure

Conversation

@RaphaelManke
Copy link

Problem

When all accounts become permanently unhealthy (e.g. after invalid_grant, account suspension, or token expiry), the plugin throws:

Error: All accounts are permanently unhealthy (quota exceeded or suspended)

This requires the user to manually restart OpenCode and re-authenticate.

Changes

  • When allAccountsPermanentlyUnhealthy() is detected, instead of throwing, call client.provider.oauth.authorize() to automatically trigger the browser-based OAuth re-auth flow
  • After re-auth completes, sync fresh tokens from Kiro CLI and reload accounts
  • Resume the request loop with the new valid tokens
  • Show toast notifications for re-auth progress and success

Result

Users no longer need to manually restart or re-authenticate — the plugin recovers automatically when tokens go permanently invalid.

Closes #43

When all accounts are marked permanently unhealthy (e.g. after invalid_grant,
account suspension, or token expiry), instead of throwing a hard error the
plugin now automatically triggers the OAuth re-auth flow via the OpenCode
client API, syncs fresh tokens from the Kiro CLI, and resumes the request.

This addresses the 'All accounts are unhealthy or rate-limited' error that
previously required a manual restart or re-authentication by the user.

Related to tickernelz#43 tickernelz#49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error: All accounts are unhealthy or rate-limited

1 participant