Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e45241ddc | ||
|
|
78e9004624 | ||
|
|
2dcea91a63 | ||
|
|
d240b543eb | ||
|
|
1a35ec064c | ||
|
|
204691772c | ||
|
|
15e3f1dd29 |
@@ -99,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,4 +1,4 @@
|
|||||||
## What's new in beta.29
|
## What's new in beta.32
|
||||||
|
|
||||||
- Fix: org ID is now correctly read from b.account.memberships[0].organization.uuid — bootstrap nests memberships inside account, not at the root
|
- 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)
|
||||||
- This was preventing usage limits from loading for all accounts
|
- Fix: placeholder cards shown while data loads instead of blank panel
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -269,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;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -324,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;
|
||||||
@@ -464,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