Off by default and per session: it spends quota the moment quota exists,
with nobody watching, which is not a thing a default may decide. Switched
on from the session settings dialog, with the message it sends editable
("continue" unless something else is typed).
Running out of quota becomes a state rather than an error. The Claude
driver recognises its dialect's sentence -- `Claude AI usage limit
reached|1788546972` -- and reports `LimitReached` with the reset time it
gave; nothing above a driver matches on a string. The transcript draws it
as a divider, like a clear or a compaction.
The schedule is a plan to *ask*, never a plan to send. Both reset times
available are untrustworthy in the direction that matters -- the dialect's
is written when the turn fails, the endpoint's moves when the window does
-- so the wait ends in a question to the usage meter, and only `ok` with
no window at 100% sends anything. A window still spent reschedules to its
own reset time, which is what makes a limit that lifts late wait longer
and one that lifts early resume sooner. A meter that cannot be asked is a
longer wait too, never a send. A day after the limit was hit the wait
gives up and says so in the transcript, so a machine that can never be
asked is not retried for ever.
The schedule is persisted on the session: a five-hour window outlasts a
backend restart, and a wait forgotten across one never comes back.
Driven end to end with echo, never a real account: `/limit [minutes]`
reports the same event a real driver does and `/usage` sets what the meter
answers, deliberately separate so the two can disagree. The wait moved
from the dialect's two minutes to the meter's seven when the meter changed
its mind, and the message went out on the first check after the meter came
back under the limit.
Also makes the settings dialog scrollable, which these two controls made
necessary: at a 1.5x system font it clipped the last of them with nothing
on screen to say so.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
33 lines
1.2 KiB
Kotlin
33 lines
1.2 KiB
Kotlin
package com.example.aiapp
|
|
|
|
import java.time.ZoneId
|
|
import kotlin.test.Test
|
|
import kotlin.test.assertEquals
|
|
import kotlin.test.assertTrue
|
|
|
|
/**
|
|
* What the transcript says where a session ran out of quota.
|
|
*
|
|
* The pair worth a test is the one that reads the same when it goes wrong: a reset time that
|
|
* arrived and one that never did. The second must not turn into a plausible-looking time, because a
|
|
* reader has no way of telling an invented one from a reported one.
|
|
*/
|
|
class LimitRowTest {
|
|
private val utc = ZoneId.of("UTC")
|
|
|
|
@Test
|
|
fun `a reported reset time is shown as a time`() {
|
|
// 2026-09-05T12:00:00Z. Asserted as a prefix and the clock reading rather than as the
|
|
// whole string: the platform's own short-time format is what this asks for, and it
|
|
// differs by JDK and locale down to which space character separates the meridiem.
|
|
val summary = limitSummary(1_788_609_600.0, utc)
|
|
assertTrue(summary.startsWith("Usage limit reached • resets "), summary)
|
|
assertTrue(summary.contains("12:00"), summary)
|
|
}
|
|
|
|
@Test
|
|
fun `a limit with no reset time says only what is known`() {
|
|
assertEquals("Usage limit reached", limitSummary(null, utc))
|
|
}
|
|
}
|