fix: claude auth expiry warning — correct field name and smarter threshold
- Fix 'undefined' in auth banner: read access_token_hours_remaining (not hours_remaining) - Fix false-positive warning on fresh tokens: when refresh token present, only warn within 1 hour of expiry (not 24h) since the CLI should auto-rotate but sometimes misses - Emit claude_auth_expired SSE event on 401 so UI shows inline red banner immediately - app.js: handle claude_auth_expired SSE event with persistent top banner + dismiss button Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -975,6 +975,20 @@
|
||||
let data;
|
||||
try { data = JSON.parse(e.data); } catch { return; }
|
||||
if (data.type === 'keepalive') return;
|
||||
|
||||
if (data.type === 'claude_auth_expired') {
|
||||
let banner = document.getElementById('claude-auth-banner');
|
||||
if (!banner) {
|
||||
banner = document.createElement('div');
|
||||
banner.id = 'claude-auth-banner';
|
||||
banner.style.cssText = 'position:fixed;top:0;left:0;right:0;z-index:9999;background:#7c2d12;color:#fef2f2;padding:0.6rem 1rem;font-size:0.85rem;display:flex;align-items:center;justify-content:space-between;gap:1rem;';
|
||||
banner.innerHTML = '<span>⚠️ Claude authentication expired — run <code style="background:#991b1b;padding:0.1rem 0.3rem;border-radius:3px;">claude</code> in your terminal to re-authenticate, then reload.</span>'
|
||||
+ '<button onclick="this.parentElement.remove()" style="background:none;border:none;color:#fef2f2;font-size:1.1rem;cursor:pointer;padding:0 0.3rem;">✕</button>';
|
||||
document.body.prepend(banner);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.type !== 'nct_message' && data.type !== 'nct_response') return;
|
||||
|
||||
if (sessionId === data.session_id) {
|
||||
@@ -1188,7 +1202,7 @@
|
||||
warnings.push('✕ Claude CLI token has expired');
|
||||
anyExpired = true;
|
||||
} else {
|
||||
warnings.push(`⚠ Claude CLI token expires in ${d.claude.hours_remaining}h`);
|
||||
warnings.push(`⚠ Claude CLI token expires in ${d.claude.access_token_hours_remaining}h`);
|
||||
}
|
||||
fixes.push('<code>claude</code>');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user