Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e45241ddc | ||
|
|
78e9004624 | ||
|
|
2dcea91a63 | ||
|
|
d240b543eb | ||
|
|
1a35ec064c | ||
|
|
204691772c | ||
|
|
15e3f1dd29 | ||
|
|
bcd208684b | ||
|
|
2bdbe4943d | ||
|
|
1c365a55a8 |
@@ -83,8 +83,9 @@ public partial class LoginWindow : Window
|
|||||||
const h={headers:{accept:'application/json'}};
|
const h={headers:{accept:'application/json'}};
|
||||||
const b=await(await fetch('/api/bootstrap',h)).json();
|
const b=await(await fetch('/api/bootstrap',h)).json();
|
||||||
const rawB=JSON.stringify(b).slice(0,600);
|
const rawB=JSON.stringify(b).slice(0,600);
|
||||||
let id=b?.memberships?.[0]?.organization?.uuid||b?.organizations?.[0]?.uuid
|
let id=b?.account?.memberships?.[0]?.organization?.uuid
|
||||||
||b?.default_organization?.uuid||b?.account?.uuid||null;
|
||b?.memberships?.[0]?.organization?.uuid||b?.organizations?.[0]?.uuid
|
||||||
|
||b?.default_organization?.uuid||null;
|
||||||
const e=b?.account?.email_address||b?.account?.email||b?.email||null;
|
const e=b?.account?.email_address||b?.account?.email||b?.email||null;
|
||||||
let orgSrc='bootstrap';
|
let orgSrc='bootstrap';
|
||||||
if(!id){
|
if(!id){
|
||||||
@@ -98,8 +99,8 @@ public partial class LoginWindow : Window
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const u=await(await fetch('/api/organizations/'+id+'/usage',h)).json();
|
const u=await(await fetch('/api/organizations/'+id+'/usage',h)).json();
|
||||||
const rawU=JSON.stringify(u).slice(0,300);
|
const rawU=JSON.stringify(u).slice(0,400);
|
||||||
window.chrome.webview.postMessage({email:e,orgId:id,usage:u,debug:'src:'+orgSrc+'|ukeys:'+Object.keys(u||{}).join(',')+'|raw:'+rawB});
|
window.chrome.webview.postMessage({email:e,orgId:id,usage:u,debug:'src:'+orgSrc+'|ukeys:'+Object.keys(u||{}).join(',')+'|rawU:'+rawU+'|rawB:'+rawB});
|
||||||
}catch(ex){window.chrome.webview.postMessage({error:String(ex)});}})()";
|
}catch(ex){window.chrome.webview.postMessage({error:String(ex)});}})()";
|
||||||
|
|
||||||
await Browser.CoreWebView2.ExecuteScriptAsync(script);
|
await Browser.CoreWebView2.ExecuteScriptAsync(script);
|
||||||
|
|||||||
+2
-2
@@ -21,8 +21,8 @@ public class AgentLimit
|
|||||||
|
|
||||||
public class UsageResponse
|
public class UsageResponse
|
||||||
{
|
{
|
||||||
[JsonPropertyName("claude_ai_default_5h")] public WindowData? FiveHour { get; set; }
|
[JsonPropertyName("five_hour")] public WindowData? FiveHour { get; set; }
|
||||||
[JsonPropertyName("claude_ai_default")] public WindowData? SevenDay { get; set; }
|
[JsonPropertyName("seven_day")] public WindowData? SevenDay { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WindowData
|
public class WindowData
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
## What's new in beta.28
|
## What's new in beta.32
|
||||||
|
|
||||||
- Debug banner now appears on the main panel after sign-in showing raw bootstrap data — paste this here so we can fix org ID parsing
|
- Fix: usage response fields were completely wrong — five_hour/seven_day not claude_ai_default_5h/claude_ai_default (this is why limits never loaded)
|
||||||
- Fix: limits no longer wiped when a refresh cycle returns no data (placeholders stay until real data arrives)
|
- Fix: placeholder cards shown while data loads instead of blank panel
|
||||||
- Try account.uuid as org ID fallback when no org found in bootstrap
|
|
||||||
|
|||||||
+34
-13
@@ -95,15 +95,13 @@ public class UsageViewModel : INotifyPropertyChanged
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try HttpClient first (fast path) — may be rejected by server CORS/header checks
|
// HttpClient refresh — WebView2 is NOT used here to avoid spawning a heavy
|
||||||
|
// browser process every refresh cycle (causes memory accumulation).
|
||||||
|
// SaveAndClose at login time is responsible for fetching live data via WebView2.
|
||||||
var (limits, overage, prepaid, email, orgId, ok) = hasCookies
|
var (limits, overage, prepaid, email, orgId, ok) = hasCookies
|
||||||
? await TryHttpRefreshAsync(cookies)
|
? await TryHttpRefreshAsync(cookies)
|
||||||
: ([], null, null, null, null, false);
|
: ([], null, null, null, null, false);
|
||||||
|
|
||||||
// Fall back to WebView2 (uses the shared browser session, not HttpClient)
|
|
||||||
if (!ok)
|
|
||||||
(limits, email, orgId) = await TryWebView2RefreshAsync();
|
|
||||||
|
|
||||||
// Fill in any blanks from cached values saved at login time
|
// Fill in any blanks from cached values saved at login time
|
||||||
if (string.IsNullOrEmpty(email)) email = AppSettings.Default.Email;
|
if (string.IsNullOrEmpty(email)) email = AppSettings.Default.Email;
|
||||||
if (string.IsNullOrEmpty(orgId)) orgId = AppSettings.Default.OrgId;
|
if (string.IsNullOrEmpty(orgId)) orgId = AppSettings.Default.OrgId;
|
||||||
@@ -189,7 +187,8 @@ public class UsageViewModel : INotifyPropertyChanged
|
|||||||
const string script = @"(async()=>{try{
|
const string script = @"(async()=>{try{
|
||||||
const h={headers:{accept:'application/json'}};
|
const h={headers:{accept:'application/json'}};
|
||||||
const b=await(await fetch('/api/bootstrap',h)).json();
|
const b=await(await fetch('/api/bootstrap',h)).json();
|
||||||
let id=b?.memberships?.[0]?.organization?.uuid||b?.organizations?.[0]?.uuid
|
let id=b?.account?.memberships?.[0]?.organization?.uuid
|
||||||
|
||b?.memberships?.[0]?.organization?.uuid||b?.organizations?.[0]?.uuid
|
||||||
||b?.default_organization?.uuid||null;
|
||b?.default_organization?.uuid||null;
|
||||||
const em=b?.account?.email_address||b?.account?.email||b?.email||null;
|
const em=b?.account?.email_address||b?.account?.email||b?.email||null;
|
||||||
if(!id){
|
if(!id){
|
||||||
@@ -268,9 +267,10 @@ public class UsageViewModel : INotifyPropertyChanged
|
|||||||
await Application.Current.Dispatcher.InvokeAsync(() =>
|
await Application.Current.Dispatcher.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(email)) UserEmail = email;
|
if (!string.IsNullOrEmpty(email)) UserEmail = email;
|
||||||
if (limits.Count > 0) Limits = limits;
|
// Always show cards — real data if available, placeholders if not
|
||||||
|
Limits = limits.Count > 0 ? limits : LoadPlaceholderLimits();
|
||||||
IsSignedIn = true;
|
IsSignedIn = true;
|
||||||
ErrorMessage = limits.Count == 0 ? "Signed in — refreshing data…" : null;
|
ErrorMessage = null;
|
||||||
LastUpdated = limits.Count > 0 ? DateTime.Now : LastUpdated;
|
LastUpdated = limits.Count > 0 ? DateTime.Now : LastUpdated;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -323,6 +323,14 @@ public class UsageViewModel : INotifyPropertyChanged
|
|||||||
http.DefaultRequestHeaders.Add("User-Agent",
|
http.DefaultRequestHeaders.Add("User-Agent",
|
||||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " +
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " +
|
||||||
"(KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36");
|
"(KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36");
|
||||||
|
http.DefaultRequestHeaders.Add("Origin", "https://claude.ai");
|
||||||
|
http.DefaultRequestHeaders.Add("Referer", "https://claude.ai/");
|
||||||
|
http.DefaultRequestHeaders.Add("sec-fetch-dest", "empty");
|
||||||
|
http.DefaultRequestHeaders.Add("sec-fetch-mode", "cors");
|
||||||
|
http.DefaultRequestHeaders.Add("sec-fetch-site", "same-origin");
|
||||||
|
http.DefaultRequestHeaders.Add("sec-ch-ua", "\"Chromium\";v=\"124\", \"Google Chrome\";v=\"124\"");
|
||||||
|
http.DefaultRequestHeaders.Add("sec-ch-ua-mobile", "?0");
|
||||||
|
http.DefaultRequestHeaders.Add("sec-ch-ua-platform", "\"Windows\"");
|
||||||
var cookieHeader = string.Join("; ", cookies.Select(c => $"{c.Name}={c.Value}"));
|
var cookieHeader = string.Join("; ", cookies.Select(c => $"{c.Name}={c.Value}"));
|
||||||
http.DefaultRequestHeaders.Add("Cookie", cookieHeader);
|
http.DefaultRequestHeaders.Add("Cookie", cookieHeader);
|
||||||
return http;
|
return http;
|
||||||
@@ -355,8 +363,9 @@ public class UsageViewModel : INotifyPropertyChanged
|
|||||||
acct.TryGetProperty("email_address", out var em))
|
acct.TryGetProperty("email_address", out var em))
|
||||||
email = em.GetString();
|
email = em.GetString();
|
||||||
|
|
||||||
// Path 1: memberships[0].organization.uuid
|
// Path 1: account.memberships[0].organization.uuid (Claude.ai personal/pro accounts)
|
||||||
if (root.TryGetProperty("memberships", out var mems) && mems.GetArrayLength() > 0)
|
if (root.TryGetProperty("account", out var acctNode) &&
|
||||||
|
acctNode.TryGetProperty("memberships", out var mems) && mems.GetArrayLength() > 0)
|
||||||
{
|
{
|
||||||
var first = mems[0];
|
var first = mems[0];
|
||||||
if (first.TryGetProperty("organization", out var org) &&
|
if (first.TryGetProperty("organization", out var org) &&
|
||||||
@@ -364,7 +373,17 @@ public class UsageViewModel : INotifyPropertyChanged
|
|||||||
orgId = uuid.GetString();
|
orgId = uuid.GetString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Path 2: organizations[0].uuid (flat list on root)
|
// Path 2: memberships[0].organization.uuid (root-level, older API shape)
|
||||||
|
if (string.IsNullOrEmpty(orgId) &&
|
||||||
|
root.TryGetProperty("memberships", out var rootMems) && rootMems.GetArrayLength() > 0)
|
||||||
|
{
|
||||||
|
var first = rootMems[0];
|
||||||
|
if (first.TryGetProperty("organization", out var org) &&
|
||||||
|
org.TryGetProperty("uuid", out var uuid))
|
||||||
|
orgId = uuid.GetString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Path 3: organizations[0].uuid (flat list on root)
|
||||||
if (string.IsNullOrEmpty(orgId) &&
|
if (string.IsNullOrEmpty(orgId) &&
|
||||||
root.TryGetProperty("organizations", out var orgs) && orgs.GetArrayLength() > 0)
|
root.TryGetProperty("organizations", out var orgs) && orgs.GetArrayLength() > 0)
|
||||||
{
|
{
|
||||||
@@ -452,16 +471,18 @@ public class UsageViewModel : INotifyPropertyChanged
|
|||||||
return $"{diff.Hours}h {diff.Minutes}m";
|
return $"{diff.Hours}h {diff.Minutes}m";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadPlaceholders()
|
private static List<AgentLimit> LoadPlaceholderLimits()
|
||||||
{
|
{
|
||||||
var now = DateTime.Now;
|
var now = DateTime.Now;
|
||||||
Limits =
|
return
|
||||||
[
|
[
|
||||||
new() { Window = WindowKind.FiveHour, UsedPercent = 0, TimeRemaining = "—", ResetDate = now.AddHours(1) },
|
new() { Window = WindowKind.FiveHour, UsedPercent = 0, TimeRemaining = "—", ResetDate = now.AddHours(1) },
|
||||||
new() { Window = WindowKind.SevenDay, UsedPercent = 0, TimeRemaining = "—", ResetDate = now.AddDays(7) },
|
new() { Window = WindowKind.SevenDay, UsedPercent = 0, TimeRemaining = "—", ResetDate = now.AddDays(7) },
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LoadPlaceholders() => Limits = LoadPlaceholderLimits();
|
||||||
|
|
||||||
private void LoadBurnHistory()
|
private void LoadBurnHistory()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
Reference in New Issue
Block a user