Repository navigation
fix(auth): retry a failed revoke and sign out a running TUI - #12
Merged
Merged
Conversation
An offline `kite auth logout` removed the only copy of the token, so it could never be revoked: a second logout printed "nothing to revoke" while the session was still live on Kite, and a TUI that was already open kept using it. Logout now drops a token only once Kite confirms the session ended, either by revoking it or by rejecting it as already invalid. A token it cannot revoke is kept in revoke_pending, and the next logout retries it and reports the result. The TUI's own logout goes through the same path; before, it removed the local token without revoking it at all. A running TUI watches the saved token. When a logout clears it the TUI returns to the sign-in screen, and when a new login replaces it the TUI restarts on the new session. Closes #10
mr-karan
force-pushed
the
fix/auth-logout-retry
branch
from
November 16, 2026 08:46
161a48f to
81d7a0b
Compare
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.
Why
kite auth logoutshould end the session on Kite, or say plainly that it has not. Closes #10: after an offline logout the CLI discarded the only copy of the token, so it could never be revoked. A second logout printed "nothing to revoke" while the session was still live, and an open TUI kept trading on it.This takes options A and C from the issue.
What changed
TokenExceptionsaying it is already invalid. Any other failure keeps the token in a newrevoke_pendingconfig field. The next logout retries it and reportsRevoked 1 session on Kite from an earlier logout, or warns that it is still active. Tokens expire at 6 AM IST, after which Kite answersTokenException, so the list cannot grow without bound.kite auth logout"). If a login in another terminal replaced it, the TUI restarts on the new session. Sessions started fromKITE_ACCESS_TOKENare not watched.app::logout::end_sessionaskite auth logout, and its confirm modal says it revokes.Reviewer notes
auth logout --jsongainsearlier_revokedandrevoke_pending.revokedkeeps its meaning for the current session.revoke_pendingholds live tokens, so it gets the same protection asaccess_token. It is written with the existing private file mode and redacted fromDebug, which a test checks.Verification
TokenExceptionis dropped.cargo clippy -D warningsand the fullcargo testpass locally.Not checked by hand: a real offline logout against a running TUI on a live account.