Compare commits

...
4 changed files with 76 additions and 20 deletions
+14 -5
View File
@@ -71,12 +71,21 @@ public partial class LoginWindow : Window
try
{
const string script = @"(async()=>{try{
const b=await(await fetch('/api/bootstrap',{headers:{accept:'application/json'}})).json();
const id=b?.memberships?.[0]?.organization?.uuid||b?.organizations?.[0]?.uuid
||b?.default_organization?.uuid||null;
const h={headers:{accept:'application/json'}};
const b=await(await fetch('/api/bootstrap',h)).json();
let id=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;
if(!id)return{email:e,orgId:null,usage:null};
const u=await(await fetch('/api/organizations/'+id+'/usage',{headers:{accept:'application/json'}})).json();
if(!id){
try{const ol=await(await fetch('/api/organizations',h)).json();
if(Array.isArray(ol)&&ol.length>0)id=ol[0]?.uuid||null;}catch(e2){}
}
if(!id){
try{const pu=await(await fetch('/api/usage',h)).json();
if(pu&&!pu.error)return{email:e,orgId:null,usage:pu};}catch(e3){}
return{email:e,orgId:null,usage:null};
}
const u=await(await fetch('/api/organizations/'+id+'/usage',h)).json();
return{email:e,orgId:id,usage:u};
}catch(ex){return{error:String(ex)};}})()";
+11 -4
View File
@@ -333,11 +333,18 @@ public partial class PopupWindow : Window
var login = new LoginWindow { Owner = this };
if (login.ShowDialog() == true)
{
// Brief pause so the LoginWindow WebView2 fully releases its user data folder lock
// before RefreshAsync may create another WebView2 on the same folder.
await Task.Delay(1500);
await VM.RefreshAsync();
// Show cached data from SaveAndClose immediately (no WebView2 needed)
await VM.LoadFromCacheAsync();
InitSettings();
ShowMain();
// Full refresh in background after WebView2 folder is definitely released
_ = Task.Run(async () =>
{
await Task.Delay(3000);
await VM.RefreshAsync();
await Application.Current.Dispatcher.InvokeAsync(InitSettings);
});
}
Show();
Activate();
+5 -6
View File
@@ -1,7 +1,6 @@
## What's new in beta.23
## What's new in beta.24
- About section now shows "vX.X.X available" label when an update is available (not just button label change)
- Sign-in: fixed app showing signed out after login window closes — cookies and cached auth now correctly set IsSignedIn=true
- Sign-in: added brief delay before refresh so WebView2 user data folder is fully released by LoginWindow before reuse
- Wider cookie domain filter (anthropic.com included alongside claude.ai)
- Broader JS paths for email and org ID in bootstrap response
- Sign-in now shows email and data immediately after login (loads from cache set during login flow)
- Background refresh runs 3 seconds after login — avoids WebView2 user data folder lock race
- Added /api/organizations and personal /api/usage fallbacks when bootstrap has no org ID
- Broader JS paths for email and org ID
+46 -5
View File
@@ -191,12 +191,21 @@ public class UsageViewModel : INotifyPropertyChanged
try
{
const string script = @"(async()=>{try{
const b=await(await fetch('/api/bootstrap',{headers:{accept:'application/json'}})).json();
const id=b?.memberships?.[0]?.organization?.uuid||b?.organizations?.[0]?.uuid
||b?.default_organization?.uuid||null;
const h={headers:{accept:'application/json'}};
const b=await(await fetch('/api/bootstrap',h)).json();
let id=b?.memberships?.[0]?.organization?.uuid||b?.organizations?.[0]?.uuid
||b?.default_organization?.uuid||null;
const em=b?.account?.email_address||b?.account?.email||b?.email||null;
if(!id)return{email:em,orgId:null,usage:null};
const u=await(await fetch('/api/organizations/'+id+'/usage',{headers:{accept:'application/json'}})).json();
if(!id){
try{const ol=await(await fetch('/api/organizations',h)).json();
if(Array.isArray(ol)&&ol.length>0)id=ol[0]?.uuid||null;}catch(e2){}
}
if(!id){
try{const pu=await(await fetch('/api/usage',h)).json();
if(pu&&!pu.error)return{email:em,orgId:null,usage:pu};}catch(e3){}
return{email:em,orgId:null,usage:null};
}
const u=await(await fetch('/api/organizations/'+id+'/usage',h)).json();
return{email:em,orgId:id,usage:u};
}catch(ex){return null;}})()";
@@ -237,6 +246,38 @@ public class UsageViewModel : INotifyPropertyChanged
catch { return ([], null, null); }
}
public async Task LoadFromCacheAsync()
{
var email = AppSettings.Default.Email;
var orgId = AppSettings.Default.OrgId;
var cookie = AppSettings.Default.CookieStore;
bool isAuth = !string.IsNullOrEmpty(email) || !string.IsNullOrEmpty(orgId)
|| !string.IsNullOrEmpty(cookie);
if (!isAuth) return;
List<AgentLimit> limits = [];
if (!string.IsNullOrEmpty(AppSettings.Default.UsageJson))
{
try
{
var cached = JsonSerializer.Deserialize<UsageResponse>(
AppSettings.Default.UsageJson, JsonOpts);
limits = BuildLimits(cached);
}
catch { }
}
await Application.Current.Dispatcher.InvokeAsync(() =>
{
if (!string.IsNullOrEmpty(email)) UserEmail = email;
if (limits.Count > 0) Limits = limits;
IsSignedIn = true;
ErrorMessage = limits.Count == 0 ? "Signed in — refreshing data…" : null;
LastUpdated = limits.Count > 0 ? DateTime.Now : LastUpdated;
});
}
public async Task SignOutAsync()
{
AppSettings.Default.CookieStore = "";