Offer Claude sign-in from failed sessions
This commit is contained in:
1 parent
0be15adbee
commit
f0661919bb
9 files changed
+140
-12
No files matched your search
@@ -192,6 +192,8 @@ sealed class SessionEvent {
|
||||
*/
|
||||
data class LimitReached(val resetsAt: Double?) : SessionEvent()
|
||||
|
||||
data class AuthenticationRequired(val message: String) : SessionEvent()
|
||||
|
||||
data class Error(val message: String) : SessionEvent()
|
||||
|
||||
/**
|
||||
@@ -303,6 +305,8 @@ fun parseSeqEvent(json: String): SeqEvent {
|
||||
SessionEvent.LimitReached(
|
||||
if (body.has("resetsAt")) body.getDouble("resetsAt") else null
|
||||
)
|
||||
"authenticationRequired" ->
|
||||
SessionEvent.AuthenticationRequired(body.getString("message"))
|
||||
"error" -> SessionEvent.Error(body.getString("message"))
|
||||
else -> SessionEvent.Unknown(type)
|
||||
}
|
||||
@@ -319,6 +323,19 @@ fun parseSeqEvent(json: String): SeqEvent {
|
||||
*/
|
||||
fun sessionWorking(state: String): Boolean = state == "running" || state == "compacting"
|
||||
|
||||
/** Whether the latest events still say this session needs an explicit provider login. */
|
||||
internal fun authenticationPromptAfter(open: Boolean, event: SessionEvent): Boolean =
|
||||
when (event) {
|
||||
is SessionEvent.AuthenticationRequired -> true
|
||||
// A later provider response proves an older authentication failure in a replayed page is
|
||||
// no longer current. Without this, one old failure reopened sign-in after every later
|
||||
// successful turn.
|
||||
is SessionEvent.AssistantText,
|
||||
is SessionEvent.AssistantTextFinal,
|
||||
is SessionEvent.ToolStart -> false
|
||||
else -> open
|
||||
}
|
||||
|
||||
/**
|
||||
* The context after [event], given what it was before.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user