Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48e6f64c9a | ||
|
|
d55a92623c | ||
|
|
c70a090983 | ||
|
|
cc0270326e |
@@ -71,12 +71,21 @@ public partial class LoginWindow : Window
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
const string script = @"(async()=>{try{
|
const string script = @"(async()=>{try{
|
||||||
const b=await(await fetch('/api/bootstrap',{headers:{accept:'application/json'}})).json();
|
const h={headers:{accept:'application/json'}};
|
||||||
const id=b?.memberships?.[0]?.organization?.uuid||b?.organizations?.[0]?.uuid
|
const b=await(await fetch('/api/bootstrap',h)).json();
|
||||||
||b?.default_organization?.uuid||null;
|
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;
|
const e=b?.account?.email_address||b?.account?.email||b?.email||null;
|
||||||
if(!id)return{email:e,orgId:null,usage:null};
|
if(!id){
|
||||||
const u=await(await fetch('/api/organizations/'+id+'/usage',{headers:{accept:'application/json'}})).json();
|
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};
|
return{email:e,orgId:id,usage:u};
|
||||||
}catch(ex){return{error:String(ex)};}})()";
|
}catch(ex){return{error:String(ex)};}})()";
|
||||||
|
|
||||||
|
|||||||
@@ -333,11 +333,18 @@ public partial class PopupWindow : Window
|
|||||||
var login = new LoginWindow { Owner = this };
|
var login = new LoginWindow { Owner = this };
|
||||||
if (login.ShowDialog() == true)
|
if (login.ShowDialog() == true)
|
||||||
{
|
{
|
||||||
// Brief pause so the LoginWindow WebView2 fully releases its user data folder lock
|
// Show cached data from SaveAndClose immediately (no WebView2 needed)
|
||||||
// before RefreshAsync may create another WebView2 on the same folder.
|
await VM.LoadFromCacheAsync();
|
||||||
await Task.Delay(1500);
|
|
||||||
await VM.RefreshAsync();
|
|
||||||
InitSettings();
|
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();
|
Show();
|
||||||
Activate();
|
Activate();
|
||||||
|
|||||||
@@ -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 now shows email and data immediately after login (loads from cache set during login flow)
|
||||||
- Sign-in: fixed app showing signed out after login window closes — cookies and cached auth now correctly set IsSignedIn=true
|
- Background refresh runs 3 seconds after login — avoids WebView2 user data folder lock race
|
||||||
- Sign-in: added brief delay before refresh so WebView2 user data folder is fully released by LoginWindow before reuse
|
- Added /api/organizations and personal /api/usage fallbacks when bootstrap has no org ID
|
||||||
- Wider cookie domain filter (anthropic.com included alongside claude.ai)
|
- Broader JS paths for email and org ID
|
||||||
- Broader JS paths for email and org ID in bootstrap response
|
|
||||||
|
|||||||
@@ -191,12 +191,21 @@ public class UsageViewModel : INotifyPropertyChanged
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
const string script = @"(async()=>{try{
|
const string script = @"(async()=>{try{
|
||||||
const b=await(await fetch('/api/bootstrap',{headers:{accept:'application/json'}})).json();
|
const h={headers:{accept:'application/json'}};
|
||||||
const id=b?.memberships?.[0]?.organization?.uuid||b?.organizations?.[0]?.uuid
|
const b=await(await fetch('/api/bootstrap',h)).json();
|
||||||
||b?.default_organization?.uuid||null;
|
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;
|
const em=b?.account?.email_address||b?.account?.email||b?.email||null;
|
||||||
if(!id)return{email:em,orgId:null,usage:null};
|
if(!id){
|
||||||
const u=await(await fetch('/api/organizations/'+id+'/usage',{headers:{accept:'application/json'}})).json();
|
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};
|
return{email:em,orgId:id,usage:u};
|
||||||
}catch(ex){return null;}})()";
|
}catch(ex){return null;}})()";
|
||||||
|
|
||||||
@@ -237,6 +246,38 @@ public class UsageViewModel : INotifyPropertyChanged
|
|||||||
catch { return ([], null, null); }
|
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()
|
public async Task SignOutAsync()
|
||||||
{
|
{
|
||||||
AppSettings.Default.CookieStore = "";
|
AppSettings.Default.CookieStore = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user