fix(terra): surface Claude usage errors and retry sooner
The CLD panel went blank with no reason when Claude Code's saved OAuth token had expired and the widget's own renewal was refused. - Collapsed panel shows EXPIRED/ERR instead of dashes; failures are logged to `qs log`. - Retry every minute after a failure instead of every 5. - claude-usage identifies as claude-cli, the suspected cause of the refresh 429s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,8 +16,16 @@ QtObject {
|
||||
property string error: ""
|
||||
property bool ready: false
|
||||
|
||||
// The endpoint is rate-limited and the numbers move slowly.
|
||||
property int interval: 300000
|
||||
// The endpoint is rate-limited and the numbers move slowly; a failure
|
||||
// retries sooner so the panel recovers once Claude Code renews the token.
|
||||
property int interval: root.error !== "" ? 60000 : 300000
|
||||
|
||||
// Collapsed-rail label for the current error.
|
||||
readonly property string shortError: {
|
||||
if (root.error === "")
|
||||
return "";
|
||||
return /refresh|401|not logged in|no refresh token/.test(root.error) ? "EXPIRED" : "ERR";
|
||||
}
|
||||
|
||||
readonly property var proc: Process {
|
||||
id: proc
|
||||
@@ -39,17 +47,22 @@ QtObject {
|
||||
}
|
||||
}
|
||||
|
||||
function fail(message: string): void {
|
||||
console.warn(`claude-usage: ${message}`);
|
||||
root.error = message;
|
||||
}
|
||||
|
||||
function ingest(text: string): void {
|
||||
let msg;
|
||||
try {
|
||||
msg = JSON.parse(text);
|
||||
} catch (e) {
|
||||
root.error = "no output";
|
||||
root.fail("no output");
|
||||
return;
|
||||
}
|
||||
if (msg.error) {
|
||||
// Keep the last good numbers; a failed poll is not zero usage.
|
||||
root.error = msg.error;
|
||||
root.fail(msg.error);
|
||||
return;
|
||||
}
|
||||
root.error = "";
|
||||
|
||||
Reference in New Issue
Block a user