Docker: lasciare la pagina del browser copia la sessione (#36, S4b, risposta 1)
verifica / controlli (push) Successful in 24s
verifica / prove (push) Failing after 41m21s
verifica / installatore (push) Skipped
verifica / immagine (push) Skipped

In Docker lasciare la pagina «Browser» o la vista remota di Collegamento mentre
Alberto guida (un'altra pagina, la scheda chiusa, il collegamento perso) valeva
«Annulla» e la sessione non si copiava. Ora è come chiudere la finestra del
browser su Windows: `cancel` con `pageLeft` va a LeavePageAsync, la vista
remota chiusa dalla sua pagina lo dice alla connessione, e se per 5 secondi
non si apre un'altra vista né arriva un `begin` (una pagina ricaricata) il
controllo del permesso copia la sessione con CopyOnLetGoAsync, solo da una
pagina del sito che non sia di accesso o di verifica, poi rilascia il permesso
e il motore rimette il browser a riposo. Il pulsante «Annulla» continua a non
copiare; Windows non cambia.

Prove nuove per la copia lasciando la pagina, la ricarica che non è lasciare,
la pagina di accesso, la vista sostituita o chiusa da Febe; guida, protocollo
e una riga in decisioni.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-25 10:52:51 +01:00
1 parent 537517b855
commit 2fc4b40c41
15 files changed
+312 -44

No files matched your search

+20 -5
View File
@@ -26,6 +26,7 @@ internal sealed class BrowserRemoteViewHost : IRemoteViewHost
private readonly IClock _browserClock;
private readonly FebeLog _log;
private readonly Func<CancellationToken, Task>? _openStartPage;
private readonly Action? _viewClosed;
private readonly Lock _gate = new();
private readonly SemaphoreSlim _opening = new(1, 1);
private BrowserRemoteViewConnection? _current;
@@ -43,7 +44,12 @@ internal sealed class BrowserRemoteViewHost : IRemoteViewHost
/// What «Pagina iniziale» does (issue #52): the connection opens the start page once the engine's session ended and
/// with the page's turn; null: the button does nothing.
/// </param>
public BrowserRemoteViewHost(IFebeBrowser browser, BrowserUseTracker tracker, IClock clock, FebeLog log, IClock? browserClock = null, Func<CancellationToken, Task>? openStartPage = null)
/// <param name="viewClosed">
/// Told when a view ends from the page's side (the page left, the tab closed, the link lost), not when another view
/// takes its place or Febe stops: the connection then knows that Alberto may have left the browser (Docker, answer of
/// 25 November 2026, spec §6.0 «Quando si copia»); null: nobody is told.
/// </param>
public BrowserRemoteViewHost(IFebeBrowser browser, BrowserUseTracker tracker, IClock clock, FebeLog log, IClock? browserClock = null, Func<CancellationToken, Task>? openStartPage = null, Action? viewClosed = null)
{
_browser = browser ?? throw new ArgumentNullException(nameof(browser));
_tracker = tracker ?? throw new ArgumentNullException(nameof(tracker));
@@ -51,6 +57,7 @@ internal sealed class BrowserRemoteViewHost : IRemoteViewHost
_log = log ?? throw new ArgumentNullException(nameof(log));
_browserClock = browserClock ?? new SystemClock(clock.LocalZone);
_openStartPage = openStartPage;
_viewClosed = viewClosed;
}
/// <summary>
@@ -104,8 +111,8 @@ internal sealed class BrowserRemoteViewHost : IRemoteViewHost
catch (Exception ex)
{
// Whatever went wrong (the page gone away, an unexpected frame tree), nothing of the view stays behind:
// no lease, no screencast, no subscription.
await connection.DisposeAsync().ConfigureAwait(false);
// no lease, no screencast, no subscription. Ended by the server: the page did not leave the browser.
await connection.EndAsync(RemoteViewEnd.BrowserStopped).ConfigureAwait(false);
if (ex is CdpDisconnectedException or BrowserUnavailableException or CdpCommandException or TimeoutException)
{
throw new RemoteViewUnavailableException("Il browser di Febe non risponde: riprova fra qualche secondo.", ex);
@@ -158,7 +165,9 @@ internal sealed class BrowserRemoteViewHost : IRemoteViewHost
}
}
internal void Closed(BrowserRemoteViewConnection connection)
/// <param name="connection">The view that ended.</param>
/// <param name="byPage">True when the page ended it (left, tab closed, link lost), false when the server did.</param>
internal void Closed(BrowserRemoteViewConnection connection, bool byPage)
{
lock (_gate)
{
@@ -169,6 +178,10 @@ internal sealed class BrowserRemoteViewHost : IRemoteViewHost
}
_log.Info("vista", "Vista remota chiusa.");
if (byPage)
{
_viewClosed?.Invoke();
}
}
}
@@ -445,6 +458,8 @@ internal sealed class BrowserRemoteViewConnection : IRemoteViewConnection
return;
}
// No reason given by the server (another view, Febe stopping, the browser gone): the page closed it.
var byPage = Ended is null;
Ended ??= RemoteViewEnd.BrowserStopped;
await _ended.CancelAsync().ConfigureAwait(false);
_session.Screencast.FrameReceived -= OnFrame;
@@ -462,7 +477,7 @@ internal sealed class BrowserRemoteViewConnection : IRemoteViewConnection
// The browser is gone: the lease is released anyway.
}
_owner.Closed(this);
_owner.Closed(this, byPage);
}
private void MarkUsed()