Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7601452f93 | ||
|
|
5a78a021cb | ||
|
|
7d465c13d8 | ||
|
|
ca67039e3e | ||
|
|
1e4cdc09b3 | ||
|
|
4e154bcaa7 | ||
|
|
ea784384c1 | ||
|
|
4e813995c9 |
@@ -47,8 +47,8 @@ public partial class LoginWindow : Window
|
|||||||
: "Complete sign-in, then click Done.";
|
: "Complete sign-in, then click Done.";
|
||||||
});
|
});
|
||||||
|
|
||||||
// Auto-close as soon as we detect sign-in on any claude.ai page
|
// Auto-close once we land on any claude.ai page that isn't the login flow
|
||||||
if (signedIn && !uri.Contains("/login") && !uri.Contains("/signin"))
|
if (!uri.Contains("/login") && !uri.Contains("/signin") && signedIn)
|
||||||
await SaveAndClose(cookies);
|
await SaveAndClose(cookies);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -72,8 +72,9 @@ public partial class LoginWindow : Window
|
|||||||
{
|
{
|
||||||
const string script = @"(async()=>{try{
|
const string script = @"(async()=>{try{
|
||||||
const b=await(await fetch('/api/bootstrap',{headers:{accept:'application/json'}})).json();
|
const b=await(await fetch('/api/bootstrap',{headers:{accept:'application/json'}})).json();
|
||||||
const id=b?.memberships?.[0]?.organization?.uuid||b?.organizations?.[0]?.uuid||null;
|
const id=b?.memberships?.[0]?.organization?.uuid||b?.organizations?.[0]?.uuid
|
||||||
const e=b?.account?.email_address||null;
|
||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};
|
if(!id)return{email:e,orgId:null,usage:null};
|
||||||
const u=await(await fetch('/api/organizations/'+id+'/usage',{headers:{accept:'application/json'}})).json();
|
const u=await(await fetch('/api/organizations/'+id+'/usage',{headers:{accept:'application/json'}})).json();
|
||||||
return{email:e,orgId:id,usage:u};
|
return{email:e,orgId:id,usage:u};
|
||||||
|
|||||||
@@ -173,9 +173,15 @@
|
|||||||
<TextBlock Text="Built by superdooper86 & claude"
|
<TextBlock Text="Built by superdooper86 & claude"
|
||||||
FontSize="11" Foreground="{DynamicResource SecondaryBrush}"/>
|
FontSize="11" Foreground="{DynamicResource SecondaryBrush}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Button Grid.Column="2" x:Name="CheckUpdateButton"
|
<StackPanel Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right">
|
||||||
Style="{StaticResource SmallButton}"
|
<Button x:Name="CheckUpdateButton"
|
||||||
Click="CheckUpdate_Click" VerticalAlignment="Center"/>
|
Style="{StaticResource SmallButton}"
|
||||||
|
Click="CheckUpdate_Click"/>
|
||||||
|
<TextBlock x:Name="UpdateAvailableText" FontSize="10"
|
||||||
|
Foreground="{DynamicResource BlueBrush}"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Visibility="Collapsed" Margin="0,4,0,0"/>
|
||||||
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public partial class PopupWindow : Window
|
|||||||
private static readonly UsageViewModel VM = App.ViewModel;
|
private static readonly UsageViewModel VM = App.ViewModel;
|
||||||
private static readonly UpdateManager Updater = App.Updater;
|
private static readonly UpdateManager Updater = App.Updater;
|
||||||
private readonly DispatcherTimer _clockTimer;
|
private readonly DispatcherTimer _clockTimer;
|
||||||
private bool _dialogOpen;
|
|
||||||
|
|
||||||
[DllImport("dwmapi.dll")]
|
[DllImport("dwmapi.dll")]
|
||||||
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int value, int size);
|
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int value, int size);
|
||||||
@@ -199,7 +199,10 @@ public partial class PopupWindow : Window
|
|||||||
private void OnUpdaterChanged(string? prop)
|
private void OnUpdaterChanged(string? prop)
|
||||||
{
|
{
|
||||||
if (prop is nameof(UpdateManager.UpdateAvailable) or nameof(UpdateManager.LatestVersion))
|
if (prop is nameof(UpdateManager.UpdateAvailable) or nameof(UpdateManager.LatestVersion))
|
||||||
|
{
|
||||||
UpdateBannerState();
|
UpdateBannerState();
|
||||||
|
UpdateAboutSection();
|
||||||
|
}
|
||||||
if (prop is nameof(UpdateManager.DownloadProgress))
|
if (prop is nameof(UpdateManager.DownloadProgress))
|
||||||
UpdateProgress.Value = Updater.DownloadProgress * 100;
|
UpdateProgress.Value = Updater.DownloadProgress * 100;
|
||||||
if (prop is nameof(UpdateManager.StatusMessage))
|
if (prop is nameof(UpdateManager.StatusMessage))
|
||||||
@@ -208,6 +211,21 @@ public partial class PopupWindow : Window
|
|||||||
InstallButton.Visibility = Visibility.Collapsed;
|
InstallButton.Visibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateAboutSection()
|
||||||
|
{
|
||||||
|
if (Updater.UpdateAvailable)
|
||||||
|
{
|
||||||
|
UpdateAvailableText.Text = $"v{Updater.LatestVersion} available";
|
||||||
|
UpdateAvailableText.Visibility = Visibility.Visible;
|
||||||
|
CheckUpdateButton.Content = "Install";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UpdateAvailableText.Visibility = Visibility.Collapsed;
|
||||||
|
CheckUpdateButton.Content = "Check";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateBannerState()
|
private void UpdateBannerState()
|
||||||
{
|
{
|
||||||
var visible = Updater.UpdateAvailable;
|
var visible = Updater.UpdateAvailable;
|
||||||
@@ -236,7 +254,7 @@ public partial class PopupWindow : Window
|
|||||||
{
|
{
|
||||||
VersionLabel.Text = $"v{Updater.CurrentVersion}";
|
VersionLabel.Text = $"v{Updater.CurrentVersion}";
|
||||||
BetaToggle.IsChecked = Updater.BetaChannel;
|
BetaToggle.IsChecked = Updater.BetaChannel;
|
||||||
CheckUpdateButton.Content = Updater.UpdateAvailable ? "Install" : "Check";
|
UpdateAboutSection();
|
||||||
|
|
||||||
var intervals = new[] { ("1 min", 60), ("2 min", 120), ("3 min", 180),
|
var intervals = new[] { ("1 min", 60), ("2 min", 120), ("3 min", 180),
|
||||||
("4 min", 240), ("5 min", 300), ("10 min", 600) };
|
("4 min", 240), ("5 min", 300), ("10 min", 600) };
|
||||||
@@ -312,14 +330,15 @@ public partial class PopupWindow : Window
|
|||||||
|
|
||||||
private async void SignIn_Click(object s, RoutedEventArgs e)
|
private async void SignIn_Click(object s, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
_dialogOpen = true;
|
|
||||||
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
|
||||||
|
// before RefreshAsync may create another WebView2 on the same folder.
|
||||||
|
await Task.Delay(1500);
|
||||||
await VM.RefreshAsync();
|
await VM.RefreshAsync();
|
||||||
InitSettings();
|
InitSettings();
|
||||||
}
|
}
|
||||||
_dialogOpen = false;
|
|
||||||
Show();
|
Show();
|
||||||
Activate();
|
Activate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
## What's new in beta.21
|
## What's new in beta.23
|
||||||
|
|
||||||
- Fixed: clicking Sign In now auto-closes as soon as you are detected as signed in (no need to click Done)
|
- About section now shows "vX.X.X available" label when an update is available (not just button label change)
|
||||||
- Fixed: login now fetches and caches your data directly via the browser session (no more authentication failures)
|
- Sign-in: fixed app showing signed out after login window closes — cookies and cached auth now correctly set IsSignedIn=true
|
||||||
- Fixed: periodic refresh falls back to browser-session API calls when HttpClient is rejected
|
- Sign-in: added brief delay before refresh so WebView2 user data folder is fully released by LoginWindow before reuse
|
||||||
- Fixed: cached usage from login is shown immediately while refreshing
|
- Wider cookie domain filter (anthropic.com included alongside claude.ai)
|
||||||
|
- Broader JS paths for email and org ID in bootstrap response
|
||||||
|
|||||||
+22
-28
@@ -78,7 +78,13 @@ public class UsageViewModel : INotifyPropertyChanged
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var cookies = await GetCookiesAsync();
|
var cookies = await GetCookiesAsync();
|
||||||
if (cookies.Count == 0)
|
|
||||||
|
// Check if we have any persistent proof that the user authenticated
|
||||||
|
bool hasCookies = cookies.Count > 0;
|
||||||
|
bool hasCachedAuth = !string.IsNullOrEmpty(AppSettings.Default.Email) ||
|
||||||
|
!string.IsNullOrEmpty(AppSettings.Default.OrgId);
|
||||||
|
|
||||||
|
if (!hasCookies && !hasCachedAuth)
|
||||||
{
|
{
|
||||||
await Application.Current.Dispatcher.InvokeAsync(() =>
|
await Application.Current.Dispatcher.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
@@ -89,20 +95,18 @@ public class UsageViewModel : INotifyPropertyChanged
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try HttpClient first (fast path)
|
// Try HttpClient first (fast path) — may be rejected by server CORS/header checks
|
||||||
var (limits, overage, prepaid, email, orgId, ok) = await TryHttpRefreshAsync(cookies);
|
var (limits, overage, prepaid, email, orgId, ok) = hasCookies
|
||||||
|
? await TryHttpRefreshAsync(cookies)
|
||||||
|
: ([], null, null, null, null, false);
|
||||||
|
|
||||||
// If HttpClient failed, fall back to WebView2 (uses existing browser session)
|
// Fall back to WebView2 (uses the shared browser session, not HttpClient)
|
||||||
if (!ok)
|
if (!ok)
|
||||||
(limits, email, orgId) = await TryWebView2RefreshAsync();
|
(limits, email, orgId) = await TryWebView2RefreshAsync();
|
||||||
|
|
||||||
// Still no org ID? Use cached values from last successful login
|
// Fill in any blanks from cached values saved at login time
|
||||||
if (string.IsNullOrEmpty(orgId) && !string.IsNullOrEmpty(AppSettings.Default.OrgId))
|
if (string.IsNullOrEmpty(email)) email = AppSettings.Default.Email;
|
||||||
orgId = AppSettings.Default.OrgId;
|
if (string.IsNullOrEmpty(orgId)) orgId = AppSettings.Default.OrgId;
|
||||||
if (string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(AppSettings.Default.Email))
|
|
||||||
email = AppSettings.Default.Email;
|
|
||||||
|
|
||||||
// If we have cached usage from login and still got nothing live, use that
|
|
||||||
if (limits.Count == 0 && !string.IsNullOrEmpty(AppSettings.Default.UsageJson))
|
if (limits.Count == 0 && !string.IsNullOrEmpty(AppSettings.Default.UsageJson))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -114,19 +118,6 @@ public class UsageViewModel : INotifyPropertyChanged
|
|||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAuth = !string.IsNullOrEmpty(email) || !string.IsNullOrEmpty(orgId) || limits.Count > 0;
|
|
||||||
if (!isAuth && cookies.Count > 0)
|
|
||||||
{
|
|
||||||
// Cookies exist but nothing worked — session likely expired
|
|
||||||
await Application.Current.Dispatcher.InvokeAsync(() =>
|
|
||||||
{
|
|
||||||
IsSignedIn = false;
|
|
||||||
ErrorMessage = "Session expired — click Sign In to re-authenticate.";
|
|
||||||
IsLoading = false;
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var limit in limits)
|
foreach (var limit in limits)
|
||||||
{
|
{
|
||||||
var key = limit.Window.ToString();
|
var key = limit.Window.ToString();
|
||||||
@@ -144,6 +135,8 @@ public class UsageViewModel : INotifyPropertyChanged
|
|||||||
Overage = overage;
|
Overage = overage;
|
||||||
Prepaid = prepaid;
|
Prepaid = prepaid;
|
||||||
if (!string.IsNullOrEmpty(email)) UserEmail = email;
|
if (!string.IsNullOrEmpty(email)) UserEmail = email;
|
||||||
|
// Trust that cookies / cached auth mean the user IS signed in,
|
||||||
|
// even if the live fetch failed this cycle.
|
||||||
IsSignedIn = true;
|
IsSignedIn = true;
|
||||||
ErrorMessage = null;
|
ErrorMessage = null;
|
||||||
LastUpdated = DateTime.Now;
|
LastUpdated = DateTime.Now;
|
||||||
@@ -199,8 +192,9 @@ public class UsageViewModel : INotifyPropertyChanged
|
|||||||
{
|
{
|
||||||
const string script = @"(async()=>{try{
|
const string script = @"(async()=>{try{
|
||||||
const b=await(await fetch('/api/bootstrap',{headers:{accept:'application/json'}})).json();
|
const b=await(await fetch('/api/bootstrap',{headers:{accept:'application/json'}})).json();
|
||||||
const id=b?.memberships?.[0]?.organization?.uuid||b?.organizations?.[0]?.uuid||null;
|
const id=b?.memberships?.[0]?.organization?.uuid||b?.organizations?.[0]?.uuid
|
||||||
const em=b?.account?.email_address||null;
|
||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};
|
if(!id)return{email:em,orgId:null,usage:null};
|
||||||
const u=await(await fetch('/api/organizations/'+id+'/usage',{headers:{accept:'application/json'}})).json();
|
const u=await(await fetch('/api/organizations/'+id+'/usage',{headers:{accept:'application/json'}})).json();
|
||||||
return{email:em,orgId:id,usage:u};
|
return{email:em,orgId:id,usage:u};
|
||||||
@@ -212,7 +206,7 @@ public class UsageViewModel : INotifyPropertyChanged
|
|||||||
host.Show();
|
host.Show();
|
||||||
try { return await host.FetchAsync("https://claude.ai", script); }
|
try { return await host.FetchAsync("https://claude.ai", script); }
|
||||||
finally { host.Close(); }
|
finally { host.Close(); }
|
||||||
}).Task;
|
}).Task.Unwrap();
|
||||||
|
|
||||||
if (resultJson == null || resultJson == "null") return ([], null, null);
|
if (resultJson == null || resultJson == "null") return ([], null, null);
|
||||||
|
|
||||||
@@ -276,7 +270,7 @@ public class UsageViewModel : INotifyPropertyChanged
|
|||||||
public static void SaveCookies(IEnumerable<CoreWebView2Cookie> cookies)
|
public static void SaveCookies(IEnumerable<CoreWebView2Cookie> cookies)
|
||||||
{
|
{
|
||||||
var entries = cookies
|
var entries = cookies
|
||||||
.Where(c => c.Domain.Contains("claude.ai"))
|
.Where(c => c.Domain.Contains("claude.ai") || c.Domain.Contains("anthropic.com"))
|
||||||
.Select(c => new CookieEntry { Name = c.Name, Value = c.Value, Domain = c.Domain, Path = c.Path })
|
.Select(c => new CookieEntry { Name = c.Name, Value = c.Value, Domain = c.Domain, Path = c.Path })
|
||||||
.ToList();
|
.ToList();
|
||||||
AppSettings.Default.CookieStore = JsonSerializer.Serialize(entries);
|
AppSettings.Default.CookieStore = JsonSerializer.Serialize(entries);
|
||||||
|
|||||||
Reference in New Issue
Block a user