Show session expiry warning in statusline

When the fetcher gets a 401/403, it writes an error state to the cache
file instead of silently failing. The statusline reads this and shows
"Token: session expired — refresh cookie" so the user knows to re-extract
the sessionKey cookie from claude.ai.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Axel Meyer
2026-02-14 15:49:39 +00:00
parent d152dde002
commit 7b75630e67
2 changed files with 28 additions and 9 deletions

View File

@@ -41,8 +41,12 @@ function readCache() {
if (!fs.existsSync(CACHE_FILE)) return null;
const stat = fs.statSync(CACHE_FILE);
const ageS = (Date.now() - stat.mtimeMs) / 1000;
const data = JSON.parse(fs.readFileSync(CACHE_FILE, 'utf8'));
// Error state written by fetcher — always show regardless of age
if (data._error) return data;
// Normal data — respect max age
if (ageS > CACHE_MAX_AGE_S) return null;
return JSON.parse(fs.readFileSync(CACHE_FILE, 'utf8'));
return data;
} catch {
return null;
}
@@ -60,6 +64,11 @@ function formatMinutes(isoStr) {
function getUsagePart(data) {
if (!data) return '';
// Error state from fetcher
if (data._error === 'auth_expired') return 'Token: session expired — refresh cookie';
if (data._error) return 'Token: fetch error';
const parts = [];
if (data.five_hour && data.five_hour.utilization > 0) {