Files
Febe/src/Febe.App/IFebePlatform.cs
T
Alby96andClaude Opus 5.5 654076d280 Browser vuoto: correzioni dopo la revisione (#52)
La revisione di c49df4c ha trovato alcuni punti deboli. Si correggono qui.

- Fuori vista la pagina torna al 100%. Lo zoom calcolato per uno schermo
  piccolo restava anche per le sessioni del motore, e le pagine vedevano un
  devicePixelRatio diverso (regola 4). Il rapporto si ricalcola solo quando
  la finestra viene sullo schermo.
- Pulsante nella barra delle applicazioni. WPF lo cambia nascondendo la
  finestra e mostrandola di nuovo (verificato con un aggancio a
  WM_WINDOWPOSCHANGED). Ora il pulsante cambia solo mentre la finestra è
  fuori vista. Sullo schermo la finestra chiede di ridisegnarsi
  (RedrawWindow), senza nulla che la pagina veda. Una prova con WebView2
  vero controlla che la finestra non si nasconda mai sullo schermo.
- Ridotta a icona troppo a lungo, la finestra si ripristina coperta (DWM) e
  senza prendere il fuoco, e si sposta fuori vista prima di scoprirsi. Prima
  ricompariva per un attimo dove stava. Spostare la posizione di ripristino
  non basta: Windows la riporta su uno schermo (provato).
- Dopo un riavvio del processo GPU i bordi della pagina cambiano davvero: un
  pixel in meno, poi quelli veri. Gli stessi bordi di nuovo potevano non
  servire a nulla.
- «Pagina iniziale», sulla barra di Windows e nella vista remota, passa da
  BrowserConnectionService.OpenStartPageAsync. Aspetta la fine della
  sessione del motore e il turno della pagina, come l'apertura dal riposo,
  e agisce solo mentre Alberto guida.
- Vista remota.
  - Dopo un riavvio dei fotogrammi la vista aspetta il primo fotogramma per
    mezzo secondo prima dell'immagine ferma: Chromium lo manda solo dopo la
    risposta allo start, e prima quasi ogni riavvio costava una cattura.
  - L'immagine ferma si scarta se nel frattempo arriva un fotogramma vero.
  - Il silenzio si conta dall'avvio.
  - Un riavvio del browser durante la chiusura non lascia eccezioni non
    osservate.
- Un POST vuoto senza Content-Length (a pezzi, HTTP/2) non dà più 400 su
  begin, cancel e browser/show (ApiHttp.OptionalBodyAsync).
- La pagina Browser toglie ?accesso=1 dall'indirizzo. Ricaricarla riapriva
  la pagina di accesso.
- RemoteViewFramesTests aspetta fino a 20 s invece di 5. Controlla che
  l'immagine arrivi, non quanto in fretta; il tempo va nell'uscita della
  prova.

Aggiornati PROTOCOLLO.md, la guida (Primo collegamento, Installazione
Windows) e docs/decisioni.md con le righe di #52.

Prove nuove:
- AFrameSoonAfterARestartNeedsNoStillPicture
- PaginaInizialeWaitsForThePageTurnAndActsOnlyWhileAlbertoIsAtTheBrowser
- ABodyWithoutALengthIsReadAndAnEmptyOneIsNoBody
- nella prova della finestra vera: nessun nascondere sullo schermo e pagina
  al 100% fuori vista

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 13:28:08 +01:00

132 lines
6.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Febe.Browser.Recipes;
using Febe.Core.Abstractions;
using Febe.Core.Alerts;
using Febe.Core.Library;
using Febe.Core.Storage;
using Febe.Web;
using Febe.Web.Connection;
using Febe.Web.Engine;
using Microsoft.Extensions.DependencyInjection;
namespace Febe.App;
/// <summary>
/// The parts of a shell that differ between Docker and Windows (spec §5 «I due involucri»): how the interface is
/// protected and where it listens, which checks stop the engine at start-up, which browser visits the site and how it
/// is supervised, and the native services (folder picker, notifications, remote view…). Everything else — database,
/// library, import, backups, collection pipeline, downloads, engine, connection, alerts, web host — is
/// <see cref="FebeApp"/>, the same for both.
/// </summary>
public interface IFebePlatform
{
/// <summary>Interface options: edition, access (password in Docker, per-start token on Windows), allowed hosts.</summary>
FebeWebOptions WebOptions { get; }
/// <summary>Where Kestrel listens (Docker: every address on 8480; Windows: 127.0.0.1 on a port chosen at start-up).</summary>
FebeListen Listen { get; }
/// <summary>
/// Problems that keep the engine and the browser from starting (spec §8.2, §11, §12). With any, only the interface
/// starts, on a temporary database, and shows the page that explains them.
/// </summary>
IReadOnlyList<ConfigurationProblem> CheckConfiguration(FebeAppOptions options, DataFolderCheck dataFolderCheck);
/// <summary>The browser of this shell. Called once, after the database is open and before the engine exists.</summary>
Task<IFebeBrowser> CreateBrowserAsync(FebePlatformContext context, CancellationToken ct);
/// <summary>
/// Services of this shell for a normal start, registered before the web layer (whose fallbacks use TryAdd):
/// native shell (its notifications are the Windows channel of the alerts), browser window, remote view, change of
/// the Data folder.
/// </summary>
void RegisterServices(IServiceCollection services, FebeApp app);
/// <summary>Services of this shell while a configuration problem keeps everything else still.</summary>
void RegisterProblemServices(IServiceCollection services, FebeApp app);
/// <summary>Called first when the composition stops (Docker: the open remote view is closed with its reason).</summary>
Task StoppingAsync();
}
/// <summary>What a platform gets to build its browser.</summary>
/// <param name="Options">The options of the composition.</param>
/// <param name="Data">The Data folder (profile in <see cref="DataFolderLayout.BrowserProfile"/>).</param>
/// <param name="Storage">The database (settings of the shell, e.g. the S2 hosting mode on Windows).</param>
/// <param name="Clock">The clock of the engine.</param>
/// <param name="Log">The log.</param>
/// <param name="Tracker">When Alberto last used the browser: the desktop window marks it when he uses and closes it.</param>
/// <param name="OpenStartPage">
/// What «Pagina iniziale» of the browser window does (issue #52): the connection opens the site's home when connected,
/// the login page otherwise, once the engine's session ended and with the page's turn
/// (<c>BrowserConnectionService.OpenStartPageAsync</c>). Null: the button does nothing.
/// </param>
public sealed record FebePlatformContext(FebeAppOptions Options, DataFolderLayout Data, IFebeStorage Storage, IClock Clock, FebeLog Log, BrowserUseTracker Tracker, Func<CancellationToken, Task>? OpenStartPage = null);
/// <summary>Options of the shared composition, filled by each shell from its own configuration.</summary>
public sealed record FebeAppOptions
{
/// <summary>Data folder: database, browser profile, thumbnails, backups, log (Docker /dati; Windows %LOCALAPPDATA%\Febe).</summary>
public required string DataFolder { get; init; }
/// <summary>Library folder (Docker /libreria, fixed; Windows Immagini\Febe, the default of the setting).</summary>
public required string LibraryFolder { get; init; }
/// <summary>
/// Windows: the library folder chosen in Impostazioni (stored in the database) wins over <see cref="LibraryFolder"/>,
/// which is only its default. Docker: false, the volume decides.
/// </summary>
public bool LibraryFolderFromSettings { get; init; }
/// <summary>Docker: the read-only root of the import sources (/importa). Null: any folder, chosen with the picker.</summary>
public string? ImportFolder { get; init; }
/// <summary>Time zone of the engine, of file names and (Docker) of the browser.</summary>
public string ZoneId { get; init; } = "Europe/Rome";
public TimeZoneInfo Zone { get; init; } = TimeZoneInfo.Local;
/// <summary>Language of the browser, for the log (Docker: LANG; Windows: the language of the system).</summary>
public string Language { get; init; } = "it_IT.UTF-8";
/// <summary>The site the browser works on: Instagram, or the local test site in development.</summary>
public CollectionSite Site { get; init; } = CollectionSite.Instagram;
/// <summary>The page «Accedi a Instagram» opens.</summary>
public string LoginUrl { get; init; } = "https://www.instagram.com/accounts/login/";
/// <summary>Development: the local test site (only for the warning in the log).</summary>
public Uri? TestSite { get; init; }
/// <summary>Development, test site only: opens the site once at start-up so its session cookie exists.</summary>
public bool TestSiteAutoLogin { get; init; }
/// <summary>Development: the first session comes after this delay instead of 2–10 minutes.</summary>
public TimeSpan? FirstSessionDelay { get; init; }
/// <summary>Warnings found while reading the configuration, for the log.</summary>
public IReadOnlyList<string> Warnings { get; init; } = [];
}
/// <summary>Things tests (and only tests) replace in the composition.</summary>
public sealed record FebeAppHooks
{
public IClock? Clock { get; init; }
public IRandomSource? Random { get; init; }
/// <summary>The Data folder check (tests inject a mount table with a network share).</summary>
public DataFolderCheck? DataFolderCheck { get; init; }
/// <summary>Console writer for the log; null: none (the desktop has no console).</summary>
public TextWriter? Console { get; init; }
/// <summary>How long the web host waits for open requests (events, remote view) when stopping.</summary>
public TimeSpan ShutdownTimeout { get; init; } = TimeSpan.FromSeconds(3);
/// <summary>Fake Telegram (tests never reach the real API).</summary>
public HttpMessageHandler? TelegramHandler { get; init; }
/// <summary>Fake free-space probe for the «Disco quasi pieno» alert.</summary>
public IFreeSpaceProbe? FreeSpace { get; init; }
}