Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dec6a6eb75 | ||
|
|
7a8350b578 | ||
|
|
222ee55189 | ||
|
|
ec7260bd0d | ||
|
|
6d34567d85 |
@@ -37,6 +37,7 @@ public partial class App : Application
|
||||
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await ViewModel.LoadFromCacheAsync();
|
||||
await Task.Delay(1000);
|
||||
await ViewModel.RefreshAsync();
|
||||
await Updater.CheckForUpdatesAsync();
|
||||
|
||||
@@ -15,6 +15,9 @@ public class AppSettings
|
||||
public bool ShowInTaskbar { get; set; } = true;
|
||||
public bool BetaChannel { get; set; } = false;
|
||||
public string DebugInfo { get; set; } = "";
|
||||
public string PlanLabel { get; set; } = "";
|
||||
public string OverageJson { get; set; } = "";
|
||||
public string PrepaidJson { get; set; } = "";
|
||||
|
||||
private static readonly string FilePath = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
## What's new in beta.10
|
||||
## What's new in beta.36
|
||||
|
||||
### Bug fixes
|
||||
- Limits now update correctly on each refresh cycle
|
||||
- Session expiry is detected and prompts re-authentication instead of silently showing stale data
|
||||
- Plan name (e.g. Pro, Max) is now read from the API instead of being hardcoded
|
||||
- Settings no longer incorrectly shows "Not signed in" when limits are working
|
||||
- Session Diary now shows correctly after the first successful refresh
|
||||
- Extra Usage Credits section now restored from cache on startup
|
||||
- Plan name, overage, and prepaid credits are now cached and shown immediately on launch
|
||||
- App now loads cached state instantly on startup before the background refresh completes
|
||||
|
||||
+38
-15
@@ -117,17 +117,6 @@ public class UsageViewModel : INotifyPropertyChanged
|
||||
catch (Exception ex)
|
||||
{
|
||||
refreshError = ex.Message;
|
||||
bool authFailed = ex.Message.Contains("re-authenticate");
|
||||
if (authFailed)
|
||||
{
|
||||
await Application.Current.Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
IsSignedIn = false;
|
||||
ErrorMessage = ex.Message;
|
||||
IsLoading = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,7 +178,12 @@ public class UsageViewModel : INotifyPropertyChanged
|
||||
if (!bootstrapResp.IsSuccessStatusCode)
|
||||
throw new Exception($"Bootstrap failed ({(int)bootstrapResp.StatusCode}).");
|
||||
|
||||
var (email, orgId, planLabel) = ParseBootstrap(await bootstrapResp.Content.ReadAsStringAsync());
|
||||
var bootstrapJson = await bootstrapResp.Content.ReadAsStringAsync();
|
||||
// Save raw bootstrap for diagnostics — lets us see if 'capabilities' is returned
|
||||
AppSettings.Default.DebugInfo = bootstrapJson.Length > 2000
|
||||
? bootstrapJson.Substring(0, 2000) : bootstrapJson;
|
||||
AppSettings.Default.Save();
|
||||
var (email, orgId, planLabel) = ParseBootstrap(bootstrapJson);
|
||||
|
||||
if (string.IsNullOrEmpty(orgId))
|
||||
orgId = await FetchOrgIdFromListAsync(http);
|
||||
@@ -217,6 +211,9 @@ public class UsageViewModel : INotifyPropertyChanged
|
||||
|
||||
// Persist fresh usage so cache reflects live data
|
||||
AppSettings.Default.UsageJson = usageJson;
|
||||
if (!string.IsNullOrEmpty(planLabel)) AppSettings.Default.PlanLabel = planLabel;
|
||||
if (ot.Result != null) AppSettings.Default.OverageJson = JsonSerializer.Serialize(ot.Result);
|
||||
if (pt.Result != null) AppSettings.Default.PrepaidJson = JsonSerializer.Serialize(pt.Result);
|
||||
AppSettings.Default.Save();
|
||||
|
||||
return (BuildLimits(usage), ot.Result, pt.Result, usage?.ExtraUsage, email, orgId, planLabel, true);
|
||||
@@ -297,22 +294,48 @@ public class UsageViewModel : INotifyPropertyChanged
|
||||
if (!isAuth) return;
|
||||
|
||||
List<AgentLimit> limits = [];
|
||||
ExtraUsage? extraUsage = null;
|
||||
OverageSpendLimit? overage = null;
|
||||
PrepaidCredits? prepaid = null;
|
||||
|
||||
if (!string.IsNullOrEmpty(AppSettings.Default.UsageJson))
|
||||
{
|
||||
try
|
||||
{
|
||||
var cached = JsonSerializer.Deserialize<UsageResponse>(
|
||||
AppSettings.Default.UsageJson, JsonOpts);
|
||||
limits = BuildLimits(cached);
|
||||
limits = BuildLimits(cached);
|
||||
extraUsage = cached?.ExtraUsage;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
if (!string.IsNullOrEmpty(AppSettings.Default.OverageJson))
|
||||
{
|
||||
try { overage = JsonSerializer.Deserialize<OverageSpendLimit>(AppSettings.Default.OverageJson, JsonOpts); }
|
||||
catch { }
|
||||
}
|
||||
if (!string.IsNullOrEmpty(AppSettings.Default.PrepaidJson))
|
||||
{
|
||||
try { prepaid = JsonSerializer.Deserialize<PrepaidCredits>(AppSettings.Default.PrepaidJson, JsonOpts); }
|
||||
catch { }
|
||||
}
|
||||
|
||||
// Attach persisted burn history to cached limits
|
||||
foreach (var limit in limits)
|
||||
{
|
||||
var key = limit.Window.ToString();
|
||||
if (_burnHistory.TryGetValue(key, out var hist) && hist.Count > 0)
|
||||
limit.BurnHistory = [.. hist];
|
||||
}
|
||||
|
||||
await Application.Current.Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(email)) UserEmail = email;
|
||||
// Always show cards — real data if available, placeholders if not
|
||||
if (!string.IsNullOrEmpty(email)) UserEmail = email;
|
||||
if (!string.IsNullOrEmpty(AppSettings.Default.PlanLabel)) PlanLabel = AppSettings.Default.PlanLabel;
|
||||
Limits = limits.Count > 0 ? limits : LoadPlaceholderLimits();
|
||||
Overage = overage;
|
||||
Prepaid = prepaid;
|
||||
ExtraUsage = extraUsage;
|
||||
IsSignedIn = true;
|
||||
ErrorMessage = null;
|
||||
LastUpdated = limits.Count > 0 ? DateTime.Now : LastUpdated;
|
||||
|
||||
Reference in New Issue
Block a user