Compare commits

..
Author SHA1 Message Date
SuperDooper 8b367ee539 chore: release notes for beta.28 2026-05-08 16:24:42 +02:00
SuperDooper 9134b8945d fix: don't wipe existing limits when refresh returns no data 2026-05-08 16:24:31 +02:00
SuperDooper 19b1751e78 debug: wire DebugBanner in InitSettings 2026-05-08 16:24:30 +02:00
SuperDooper a20956cde2 debug: show debug banner on main panel so it's always visible 2026-05-08 16:24:29 +02:00
SuperDooper 659171bf0a debug: capture raw bootstrap JSON in debug field, try account.uuid as org ID fallback 2026-05-08 16:24:28 +02:00
SuperDooper f5b3accc13 chore: release notes for beta.27 2026-05-08 16:15:17 +02:00
SuperDooper 22e9096f7c fix: post plain objects in WebView2 refresh script 2026-05-08 16:15:07 +02:00
SuperDooper 6aee17fad2 fix: use WebMessageAsJson 2026-05-08 16:15:05 +02:00
SuperDooper b594889239 fix: use WebMessageAsJson and post plain objects (not JSON strings) 2026-05-08 16:15:04 +02:00
SuperDooper 0300e4a72e chore: release notes for beta.26 2026-05-08 16:12:06 +02:00
SuperDooper 7febb0384f fix: update WebView2 refresh script to use postMessage 2026-05-08 16:11:55 +02:00
SuperDooper 55e1f754c5 fix: switch WebViewFetchWindow to WebMessageReceived for script results 2026-05-08 16:11:54 +02:00
SuperDooper 03676a980f fix: use WebMessageReceived instead of ExecuteScriptAsync return value for async script results 2026-05-08 16:11:53 +02:00
SuperDooper a74d0cece5 chore: release notes for beta.25 2026-05-08 16:06:16 +02:00
SuperDooper b5cd7b1bc9 debug: show DebugInfo in settings panel after login 2026-05-08 16:06:06 +02:00
SuperDooper 3249dbd4aa debug: add DebugText block in settings panel 2026-05-08 16:06:05 +02:00
SuperDooper 189c513677 debug: capture bootstrap keys and save to DebugInfo 2026-05-08 16:06:04 +02:00
SuperDooper 05e66b22d1 feat: add DebugInfo field to AppSettings 2026-05-08 16:06:03 +02:00
7 changed files with 107 additions and 40 deletions
+1
View File
@@ -14,6 +14,7 @@ public class AppSettings
public int RefreshInterval { get; set; } = 120; public int RefreshInterval { get; set; } = 120;
public bool ShowInTaskbar { get; set; } = true; public bool ShowInTaskbar { get; set; } = true;
public bool BetaChannel { get; set; } = false; public bool BetaChannel { get; set; } = false;
public string DebugInfo { get; set; } = "";
private static readonly string FilePath = Path.Combine( private static readonly string FilePath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
+46 -12
View File
@@ -47,7 +47,6 @@ public partial class LoginWindow : Window
: "Complete sign-in, then click Done."; : "Complete sign-in, then click Done.";
}); });
// Auto-close once we land on any claude.ai page that isn't the login flow
if (!uri.Contains("/login") && !uri.Contains("/signin") && signedIn) if (!uri.Contains("/login") && !uri.Contains("/signin") && signedIn)
await SaveAndClose(cookies); await SaveAndClose(cookies);
}; };
@@ -67,30 +66,49 @@ public partial class LoginWindow : Window
UsageViewModel.SaveCookies(cookies); UsageViewModel.SaveCookies(cookies);
// Fetch bootstrap + usage from within WebView2 (already authenticated, no header issues)
try try
{ {
// Use WebMessageReceived so the async script can post back without relying
// on Promise-awaiting support in the WebView2 runtime version.
var tcs = new TaskCompletionSource<string?>(TaskCreationOptions.RunContinuationsAsynchronously);
EventHandler<CoreWebView2WebMessageReceivedEventArgs>? msgHandler = null;
msgHandler = (_, args) =>
{
Browser.CoreWebView2.WebMessageReceived -= msgHandler;
tcs.TrySetResult(args.WebMessageAsJson);
};
Browser.CoreWebView2.WebMessageReceived += msgHandler;
const string script = @"(async()=>{try{ const string script = @"(async()=>{try{
const h={headers:{accept:'application/json'}}; const h={headers:{accept:'application/json'}};
const b=await(await fetch('/api/bootstrap',h)).json(); const b=await(await fetch('/api/bootstrap',h)).json();
const rawB=JSON.stringify(b).slice(0,600);
let id=b?.memberships?.[0]?.organization?.uuid||b?.organizations?.[0]?.uuid let id=b?.memberships?.[0]?.organization?.uuid||b?.organizations?.[0]?.uuid
||b?.default_organization?.uuid||null; ||b?.default_organization?.uuid||b?.account?.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;
let orgSrc='bootstrap';
if(!id){ if(!id){
try{const ol=await(await fetch('/api/organizations',h)).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(Array.isArray(ol)&&ol.length>0){id=ol[0]?.uuid||null;orgSrc='orgs-list';}}catch(e2){}
} }
if(!id){ if(!id){
try{const pu=await(await fetch('/api/usage',h)).json(); let pu=null;
if(pu&&!pu.error)return{email:e,orgId:null,usage:pu};}catch(e3){} try{pu=await(await fetch('/api/usage',h)).json();}catch(e3){}
return{email:e,orgId:null,usage:null}; window.chrome.webview.postMessage({email:e,orgId:null,usage:(pu&&!pu.error?pu:null),debug:'no-org|raw:'+rawB});
return;
} }
const u=await(await fetch('/api/organizations/'+id+'/usage',h)).json(); const u=await(await fetch('/api/organizations/'+id+'/usage',h)).json();
return{email:e,orgId:id,usage:u}; const rawU=JSON.stringify(u).slice(0,300);
}catch(ex){return{error:String(ex)};}})()"; window.chrome.webview.postMessage({email:e,orgId:id,usage:u,debug:'src:'+orgSrc+'|ukeys:'+Object.keys(u||{}).join(',')+'|raw:'+rawB});
}catch(ex){window.chrome.webview.postMessage({error:String(ex)});}})()";
var json = await Browser.CoreWebView2.ExecuteScriptAsync(script); await Browser.CoreWebView2.ExecuteScriptAsync(script);
if (json != "null" && !string.IsNullOrEmpty(json))
// Wait up to 15 s for the script to post its message
var completed = await Task.WhenAny(tcs.Task, Task.Delay(15000));
var json = completed == tcs.Task ? tcs.Task.Result : null;
if (!string.IsNullOrEmpty(json))
{ {
using var doc = JsonDocument.Parse(json); using var doc = JsonDocument.Parse(json);
var root = doc.RootElement; var root = doc.RootElement;
@@ -104,10 +122,26 @@ public partial class LoginWindow : Window
if (root.TryGetProperty("usage", out var us) && us.ValueKind == JsonValueKind.Object) if (root.TryGetProperty("usage", out var us) && us.ValueKind == JsonValueKind.Object)
AppSettings.Default.UsageJson = us.GetRawText(); AppSettings.Default.UsageJson = us.GetRawText();
if (root.TryGetProperty("debug", out var dbg) && dbg.ValueKind == JsonValueKind.String)
AppSettings.Default.DebugInfo = dbg.GetString() ?? "";
else if (root.TryGetProperty("error", out var err))
AppSettings.Default.DebugInfo = "JS error: " + err.GetRawText();
else
AppSettings.Default.DebugInfo = "timeout or empty message";
AppSettings.Default.Save();
}
else
{
AppSettings.Default.DebugInfo = json == null ? "script timeout (15s)" : "empty message";
AppSettings.Default.Save(); AppSettings.Default.Save();
} }
} }
catch { } catch (Exception ex)
{
AppSettings.Default.DebugInfo = "exception: " + ex.Message;
AppSettings.Default.Save();
}
await Dispatcher.InvokeAsync(() => DialogResult = true); await Dispatcher.InvokeAsync(() => DialogResult = true);
} }
+14 -1
View File
@@ -66,7 +66,16 @@
<!-- Cards scroll area --> <!-- Cards scroll area -->
<ScrollViewer VerticalScrollBarVisibility="Auto"> <ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel x:Name="CardsPanel" Margin="0,4,0,4"/> <StackPanel Margin="0,4,0,4">
<Border x:Name="DebugBanner" Visibility="Collapsed"
Background="{DynamicResource CardBrush}"
BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1"
CornerRadius="6" Margin="12,4,12,4" Padding="12,8">
<TextBlock x:Name="DebugBannerText" FontSize="10" FontFamily="Consolas"
Foreground="{DynamicResource SecondaryBrush}" TextWrapping="Wrap"/>
</Border>
<StackPanel x:Name="CardsPanel"/>
</StackPanel>
</ScrollViewer> </ScrollViewer>
</DockPanel> </DockPanel>
@@ -185,6 +194,10 @@
</Grid> </Grid>
</Border> </Border>
<TextBlock x:Name="DebugText" FontSize="10" Foreground="{DynamicResource SecondaryBrush}"
TextWrapping="Wrap" Margin="0,12,0,0" FontFamily="Consolas"
Visibility="Collapsed"/>
</StackPanel> </StackPanel>
</ScrollViewer> </ScrollViewer>
</DockPanel> </DockPanel>
+14
View File
@@ -283,6 +283,20 @@ public partial class PopupWindow : Window
SignOutButton.Visibility = VM.IsSignedIn ? Visibility.Visible : Visibility.Collapsed; SignOutButton.Visibility = VM.IsSignedIn ? Visibility.Visible : Visibility.Collapsed;
SignInButton.Content = VM.IsSignedIn ? "Re-authenticate" : "Sign In"; SignInButton.Content = VM.IsSignedIn ? "Re-authenticate" : "Sign In";
var dbg = AppSettings.Default.DebugInfo;
if (!string.IsNullOrEmpty(dbg))
{
DebugText.Text = dbg;
DebugText.Visibility = Visibility.Visible;
DebugBannerText.Text = dbg;
DebugBanner.Visibility = Visibility.Visible;
}
else
{
DebugText.Visibility = Visibility.Collapsed;
DebugBanner.Visibility = Visibility.Collapsed;
}
} }
// ── Event handlers ─────────────────────────────────────────────── // ── Event handlers ───────────────────────────────────────────────
+4 -5
View File
@@ -1,6 +1,5 @@
## What's new in beta.24 ## What's new in beta.28
- Sign-in now shows email and data immediately after login (loads from cache set during login flow) - Debug banner now appears on the main panel after sign-in showing raw bootstrap data — paste this here so we can fix org ID parsing
- Background refresh runs 3 seconds after login — avoids WebView2 user data folder lock race - Fix: limits no longer wiped when a refresh cycle returns no data (placeholders stay until real data arrives)
- Added /api/organizations and personal /api/usage fallbacks when bootstrap has no org ID - Try account.uuid as org ID fallback when no org found in bootstrap
- Broader JS paths for email and org ID
+7 -10
View File
@@ -131,12 +131,8 @@ public class UsageViewModel : INotifyPropertyChanged
await Application.Current.Dispatcher.InvokeAsync(() => await Application.Current.Dispatcher.InvokeAsync(() =>
{ {
Limits = limits; if (limits.Count > 0) { Limits = limits; Overage = overage; Prepaid = prepaid; }
Overage = overage;
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;
@@ -201,13 +197,14 @@ public class UsageViewModel : INotifyPropertyChanged
if(Array.isArray(ol)&&ol.length>0)id=ol[0]?.uuid||null;}catch(e2){} if(Array.isArray(ol)&&ol.length>0)id=ol[0]?.uuid||null;}catch(e2){}
} }
if(!id){ if(!id){
try{const pu=await(await fetch('/api/usage',h)).json(); let pu=null;
if(pu&&!pu.error)return{email:em,orgId:null,usage:pu};}catch(e3){} try{pu=await(await fetch('/api/usage',h)).json();}catch(e3){}
return{email:em,orgId:null,usage:null}; window.chrome.webview.postMessage({email:em,orgId:null,usage:(pu&&!pu.error?pu:null)});
return;
} }
const u=await(await fetch('/api/organizations/'+id+'/usage',h)).json(); const u=await(await fetch('/api/organizations/'+id+'/usage',h)).json();
return{email:em,orgId:id,usage:u}; window.chrome.webview.postMessage({email:em,orgId:id,usage:u});
}catch(ex){return null;}})()"; }catch(ex){window.chrome.webview.postMessage(null);}})();";
var resultJson = await Application.Current.Dispatcher.InvokeAsync(async () => var resultJson = await Application.Current.Dispatcher.InvokeAsync(async () =>
{ {
+21 -12
View File
@@ -34,25 +34,34 @@ internal sealed class WebViewFetchWindow : Window
await _wv.EnsureCoreWebView2Async(env); await _wv.EnsureCoreWebView2Async(env);
var tcs = new TaskCompletionSource<string?>(); var tcs = new TaskCompletionSource<string?>(TaskCreationOptions.RunContinuationsAsynchronously);
EventHandler<CoreWebView2NavigationCompletedEventArgs>? handler = null; // Use WebMessageReceived so the script can post back asynchronously without
handler = async (_, e) => // relying on Promise-awaiting support in the WebView2 runtime version.
EventHandler<CoreWebView2WebMessageReceivedEventArgs>? msgHandler = null;
msgHandler = (_, args) =>
{ {
_wv.CoreWebView2.NavigationCompleted -= handler; _wv.CoreWebView2.WebMessageReceived -= msgHandler;
tcs.TrySetResult(args.WebMessageAsJson);
};
_wv.CoreWebView2.WebMessageReceived += msgHandler;
EventHandler<CoreWebView2NavigationCompletedEventArgs>? navHandler = null;
navHandler = async (_, e) =>
{
_wv.CoreWebView2.NavigationCompleted -= navHandler;
if (!e.IsSuccess) { tcs.TrySetResult(null); return; } if (!e.IsSuccess) { tcs.TrySetResult(null); return; }
try try { await _wv.CoreWebView2.ExecuteScriptAsync(script); }
{
var result = await _wv.CoreWebView2.ExecuteScriptAsync(script);
tcs.TrySetResult(result);
}
catch { tcs.TrySetResult(null); } catch { tcs.TrySetResult(null); }
}; };
_wv.CoreWebView2.NavigationCompleted += navHandler;
_wv.CoreWebView2.NavigationCompleted += handler;
_wv.CoreWebView2.Navigate(navigateUrl); _wv.CoreWebView2.Navigate(navigateUrl);
_ = Task.Delay(timeoutMs).ContinueWith(_ => tcs.TrySetResult(null)); _ = Task.Delay(timeoutMs).ContinueWith(_ =>
{
_wv.CoreWebView2.WebMessageReceived -= msgHandler;
tcs.TrySetResult(null);
});
return await tcs.Task; return await tcs.Task;
} }