fix(adminui): close a browse session that opens after its picker is gone (R04 L4)

Every picker and RawBrowseModal stored the OpenAsync token after the await; if
the host was disposed (or the modal closed) meanwhile, its teardown had already
run with no token, so the plant-side session lived until the reaper's idle TTL.
BrowseOpenGuard.CloseIfOrphaned closes it at once; each host sets _disposed
first thing in DisposeAsync (RawBrowseModal also treats !Visible as gone).

Refs #745
Claude-Session: https://claude.ai/code/session_01Ub9hGmYLQvn9XETzw7CMsT
This commit is contained in:
Joseph Doherty
2026-10-22 17:51:34 -04:00
parent 1313b94097
commit e16146fa0c
9 changed files with 248 additions and 0 deletions
@@ -300,6 +300,8 @@
private string? _groupPrefix;
private Guid _token = Guid.Empty;
// Set first thing in DisposeAsync; an open that lands afterwards closes its own session.
private volatile bool _disposed;
private bool _opening;
private string? _openError;
@@ -459,6 +461,8 @@
try
{
var result = await BrowserService.OpenAsync(_driverType, _mergedConfig, default);
// Host disposed or modal closed mid-open: close the session nobody will (R04 L4).
if (BrowseOpenGuard.CloseIfOrphaned(result, _disposed || !Visible, BrowserService)) { return; }
if (result.Ok)
{
_token = result.Token;
@@ -823,6 +827,7 @@
public ValueTask DisposeAsync()
{
_disposed = true;
if (_token != Guid.Empty)
{
// Fire-and-forget — don't block circuit teardown on a slow remote.