Segnalazione #5. La prova del pulsante Indietro con modifiche non salvate passava per caso: ora aspetta lo stato finale
della Libreria. Indagando è emerso un difetto vero nella Libreria al primo avvio, corretto con una prova.
Causa (accertata, con Chrome 155 su Windows)
La prova. Dopo «Lascia le modifiche» aspettava main .vuoto-pagina, main .mosaico. Il server di prova però non ha
account ed è «non collegato», quindi la Libreria vuota finisce sul benvenuto (.benvenuto). .mosaico esiste solo
per circa 12 ms, prima che arrivi /api/library/days. Traccia del DOM con un MutationObserver: a 0 ms il percorso è /libreria, a 9 ms c'è il mosaico, a 21 ms il benvenuto. Su 16 esecuzioni con il primo controllo ritardato da 0 a
300 ms, la condizione vecchia scade sempre da 5 ms in su; quella nuova è 16 su 16.
Il prodotto. Lo stato vuoto si sceglieva una volta sola, alla risposta della libreria. Se lo stato del motore
arrivava dopo, il primo avvio restava su «La libreria è ancora vuota» invece del benvenuto con «Collegati a
Instagram». Riprodotto trattenendo /api/engine per 800 ms.
«Lascia le modifiche» funziona anche con una pagina lenta (le API trattenute per 2 s): nessun difetto lì.
Che cosa cambia
TheBackButtonAsksBeforeLosingUnsavedChanges aspetta main .benvenuto e controlla che dialogo, pagina Limiti e barra
di salvataggio non ci siano più. Le altre attese di InterfaceTests sono state controllate: nessuna dipende da uno
stato di passaggio.
library.js: lo stato vuoto senza filtri segue il motore finché è sullo schermo. Finché non si sa se Febe è collegato
non mostra nessuno stato vuoto, quindi niente salto da un testo all'altro, e si ridisegna solo se il tipo cambia. Il
benvenuto è identico a docs/schermate/primo-avvio.png.
Prova nuova TheEmptyLibraryFollowsTheConnectionAlsoWhenTheEngineAnswersLate: fallisce sul library.js di main e
passa qui.
Righe in docs/decisioni.md e in CHANGELOG.md (0.1.1).
Come è stato provato
dotnet build Febe.slnx -warnaserror → 0 avvisi, 0 errori
dotnet test tests/Febe.Tests (Windows) → 781: 705 superate, 0 fallite, 76 saltate (Chromium)
InterfaceTests con Chrome 155 su Windows, 3 volte di seguito → 19 su 19 ogni volta
prova nuova contro il library.js di main → fallisce, come deve
La revisione avversaria, rifatta in un clone separato con 18 ripetizioni del percorso, ha trovato due rilievi minori,
corretti. Uno ha aggiunto lo stato «in attesa» al posto del testo provvisorio.
La verifica di questa PR deve mostrare 781 prove su 781 con 0 saltate e tutte le 19 InterfaceTests superate.
Rischi e ritorno indietro
Cambia solo come la Libreria sceglie lo stato vuoto. Ritorno indietro: git revert -m 1 <commit di unione>.
Controlli prima di unire
1–13. Nessun cambiamento a motore, browser, dati o dipendenze; la schermata del benvenuto è confrontata con docs/schermate/primo-avvio.png
## Sintesi
Segnalazione #5. La prova del pulsante Indietro con modifiche non salvate passava per caso: ora aspetta lo stato finale
della Libreria. Indagando è emerso un difetto vero nella Libreria al primo avvio, corretto con una prova.
## Causa (accertata, con Chrome 155 su Windows)
- **La prova.** Dopo «Lascia le modifiche» aspettava `main .vuoto-pagina, main .mosaico`. Il server di prova però non ha
account ed è «non collegato», quindi la Libreria vuota finisce sul **benvenuto** (`.benvenuto`). `.mosaico` esiste solo
per circa 12 ms, prima che arrivi `/api/library/days`. Traccia del DOM con un MutationObserver: a 0 ms il percorso è
`/libreria`, a 9 ms c'è il mosaico, a 21 ms il benvenuto. Su 16 esecuzioni con il primo controllo ritardato da 0 a
300 ms, la condizione vecchia scade sempre da 5 ms in su; quella nuova è 16 su 16.
- **Il prodotto.** Lo stato vuoto si sceglieva una volta sola, alla risposta della libreria. Se lo stato del motore
arrivava dopo, il primo avvio restava su «La libreria è ancora vuota» invece del benvenuto con «Collegati a
Instagram». Riprodotto trattenendo `/api/engine` per 800 ms.
- «Lascia le modifiche» funziona anche con una pagina lenta (le API trattenute per 2 s): nessun difetto lì.
## Che cosa cambia
- `TheBackButtonAsksBeforeLosingUnsavedChanges` aspetta `main .benvenuto` e controlla che dialogo, pagina Limiti e barra
di salvataggio non ci siano più. Le altre attese di `InterfaceTests` sono state controllate: nessuna dipende da uno
stato di passaggio.
- `library.js`: lo stato vuoto senza filtri segue il motore finché è sullo schermo. Finché non si sa se Febe è collegato
non mostra nessuno stato vuoto, quindi niente salto da un testo all'altro, e si ridisegna solo se il tipo cambia. Il
benvenuto è identico a `docs/schermate/primo-avvio.png`.
- Prova nuova `TheEmptyLibraryFollowsTheConnectionAlsoWhenTheEngineAnswersLate`: fallisce sul `library.js` di `main` e
passa qui.
- Righe in `docs/decisioni.md` e in `CHANGELOG.md` (0.1.1).
## Come è stato provato
```text
dotnet build Febe.slnx -warnaserror → 0 avvisi, 0 errori
dotnet test tests/Febe.Tests (Windows) → 781: 705 superate, 0 fallite, 76 saltate (Chromium)
InterfaceTests con Chrome 155 su Windows, 3 volte di seguito → 19 su 19 ogni volta
prova nuova contro il library.js di main → fallisce, come deve
```
La revisione avversaria, rifatta in un clone separato con 18 ripetizioni del percorso, ha trovato due rilievi minori,
corretti. Uno ha aggiunto lo stato «in attesa» al posto del testo provvisorio.
La verifica di questa PR deve mostrare 781 prove su 781 con 0 saltate e tutte le 19 `InterfaceTests` superate.
## Rischi e ritorno indietro
- Cambia solo come la Libreria sceglie lo stato vuoto. Ritorno indietro: `git revert -m 1 <commit di unione>`.
## Controlli prima di unire
- [x] 1–13. Nessun cambiamento a motore, browser, dati o dipendenze; la schermata del benvenuto è confrontata con
`docs/schermate/primo-avvio.png`
- [x] 14. Ciò che non è stato provato è scritto sopra
- [ ] La verifica è verde sull'ultimo commit
Chiude #5.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
TheBackButtonAsksBeforeLosingUnsavedChanges, dopo «Lascia le modifiche», aspettava
«main .vuoto-pagina, main .mosaico». Una libreria vuota con Febe non collegato (il server
di prova: motore spento, nessun account proprio) finisce però sul benvenuto del primo
avvio (.benvenuto, §10.3); .mosaico c'è solo nei millisecondi fra la costruzione del
mosaico e la risposta di /api/library/days. La prova passava quando il primo controllo
cadeva in quella finestra (circa 10 ms, misurati con Chrome) e falliva per 30 secondi
quando arrivava un poco dopo, come nella esecuzione 19 della CI. Con il primo controllo
ritardato di 5 ms o più falliva sempre; con la nuova condizione 16 su 16.
Ora aspetta il benvenuto e controlla che il dialogo e la pagina Limiti non ci siano più.
Il prodotto non c'entra: «Lascia le modifiche» torna alla Libreria anche con la pagina lenta.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
La Libreria vuota sceglieva una volta sola, alla risposta di /api/library/days, fra il
benvenuto del primo avvio (§10.3: Febe non collegato, i due pulsanti) e «La libreria è
ancora vuota», guardando lo stato del motore in quel momento. Se /api/engine (o il primo
evento del flusso) arrivava dopo, lo stato era ancora sconosciuto: il primo avvio mostrava
la libreria vuota e ci restava, anche dopo che il motore aveva detto «non collegato».
Provato con Chrome trattenendo la risposta del motore.
È un difetto a sé, trovato mentre si cercava la causa dell'issue #5, e non è fra le cause
di quel fallimento: nella prova del pulsante Indietro lo stato del motore è già noto
quando la Libreria si ridisegna, e quella prova passa anche senza questa correzione.
Ora lo stato vuoto senza filtri segue il motore finché è sullo schermo: diventa il
benvenuto quando si sa che Febe non è collegato e torna «La libreria è ancora vuota»
quando si collega. Si ridisegna solo quando cambia tipo, così il fuoco su un pulsante del
benvenuto non si perde a ogni evento. Il benvenuto è lo stesso di prima: confrontato con
docs/schermate/primo-avvio.png.
Nuova prova TheEmptyLibraryFollowsTheConnectionAlsoWhenTheEngineAnswersLate: trattiene
/api/engine fino a un segnale e toglie EventSource; sul codice di prima fallisce.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Con la libreria vuota e lo stato del motore ancora sconosciuto, lo stato vuoto sceglieva
«La libreria è ancora vuota». Al primo avvio, con /api/engine più lento di
/api/library/days, quel testo era falso e poi lasciava il posto al benvenuto con un salto
della pagina (rilievo R2 della revisione).
Ora, senza filtri e senza lo stato del motore, la Libreria resta bianca come il mosaico
mentre carica: un riquadro vuoto con aria-busy, che il primo stato del motore sostituisce
con il benvenuto o con «La libreria è ancora vuota». La barra laterale dice già
«Caricamento…» in quell'attesa, e il motore arriva comunque: il flusso lo manda appena si
apre e, senza flusso, l'interfaccia lo richiede a intervalli. Benvenuto e libreria vuota
non cambiano.
La prova TheEmptyLibraryFollowsTheConnectionAlsoWhenTheEngineAnswersLate, con il motore
trattenuto, ora aspetta quel riquadro e controlla che il conteggio dica 0 e che non ci
siano né stato vuoto né mosaico; sul codice di prima fallisce («timeout: libreria vuota in
attesa del motore»).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Le righe per CHANGELOG.md di questo ramo: il benvenuto del primo avvio che poteva non comparire, e le due prove che la
CI con Chromium vero ha trovato instabili (#3 e #5).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Un revisore indipendente ha letto tutto il ramo e ha rifatto compilazione e prove; l'autore ha poi verificato ogni rilievo prima di correggerlo o respingerlo.
Giudizio del revisore
The branch is good. There are no blocking or important findings, only two minor notes. Both commits, fbb9e60 (test) and 8c36c86 (product), can go to a PR.
I checked the author's claims myself in a separate clone, B:\Altro\Sviluppo.febe-lavoro\revisione-indietro\clone, at 8c36c86. In that clone only, UiBrowser was patched so it runs on Windows, with FEBE_CHROMIUM set to Chrome 155.
The stated cause is the real one. I wrote a throwaway test that runs the back-button flow 18 times. When the dialog is open, before «Lascia le modifiche», engineState().connection.state is already "notConnected" every time, so the final state of the Libreria is always .benvenuto. .mosaico exists only for the moment between the Mosaic constructor and the reply to /api/library/days.
Old condition, first check at once: 8 of 8 passed on this PC.
Old condition, first check 100 or 300 ms later: TIMEOUT both times, with the final state "/libreria benvenuto". That is the «timeout: Libreria» of CI run 19.
New condition, first check at 0, 100, 300 or 1000 ms: 8 of 8 passed.
The leave-guard has no product bug: dialog() closes and resolves synchronously, and onHistory then calls render().
The test was not weakened. The new wait can only come true once the Libreria has really replaced Limiti. While the dialog is open, location.pathname is already '/libreria' but main still shows Limiti, with no .benvenuto. So a «Lascia le modifiche» that did not navigate would still fail the test. The «Annulla» part is unchanged. The added assertion checks that the dialog is gone, .cerchio-giorno is gone and .salva is hidden; .salva exists only in shell.js, so querySelector finds the new page's bar.
The product fix in library.js is correct.
drawEmpty is idempotent for the same kind of empty state.
Through empty.node.isConnected, onEngine has no effect once a new Mosaic or Mosaic.refresh() has replaced the content of host.
Filters are always applied synchronously together with apply(), so filtersActive() never disagrees with what is on screen.
The listener is removed by PageFrame.destroy.
The demo's screenshot step benvenuto.js is not affected, because empty stays null there.
The new test TheEmptyLibraryFollowsTheConnectionAlsoWhenTheEngineAnswersLate is deterministic: the engine answer is held behind a gate and EventSource is removed. I put main's library.js back in the clone and rebuilt: the new test fails with «timeout: primo avvio dopo la risposta del motore», while TheBackButtonAsksBeforeLosingUnsavedChanges passes. So the test fix does not depend on the product fix, and the new test does prove the product fix.
The welcome markup and CSS are unchanged; only when it is shown changes. The author's comparison with primo-avvio.png is enough.
I found no other waits of the same kind. UiBrowser is used only in InterfaceTests. The other waits either target a final state (.gruppo-giorno/.tess with data, .pannello.collegato, .arresto, .stato .chi with a fixed monitor) or are followed by a real sync point (window.__done, WaitForAsync on the server side). Line 368 already accepts both empty states.
My own checks:
Check
Result
dotnet build Febe.slnx -c Release -warnaserror
0 warnings, 0 errors
dotnet test tests/Febe.Tests -c Release, no FEBE_CHROMIUM, TEMP/TMP in the review folder
705 passed, 76 skipped, 0 failed, 781 total
InterfaceTests, Windows Chrome with the temporary patch
19 of 19, twice
git diff --check
clean
The diff touches only decisioni.md (two rows at the end, dated 2026-10-20), library.js and InterfaceTests.cs. CHANGELOG.md and stato.md are untouched, and the worktree is clean.
Not checked: Linux or Chromium in the CI container. On CI, the green re-runs the author lists are still needed.
Side note, not this branch's work and not part of issue #5: accounts.js:35 has the same "decided only once" pattern. suspended() reads engineState() when the table is drawn. If /api/engine arrives after /api/accounts, «Prossimo» shows «verso le…» instead of «Sospeso» until the next engine event at least 55 s after loading. If wanted, open a separate issue.
On the proposed CHANGELOG line for the test: «non falliva più a caso» has the wrong tense; it should be «non fallisce più a caso». It is also worth deciding whether a test-only fix belongs in the user-facing CHANGELOG at all.
Rilievi ed esito
Rilievo
Gravità
Esito
R1 (src/Febe.Web/wwwroot/js/pages/library.js:331): The message of commit 8c36c86 says the product defect is «anche il motivo per cui lo stato vuoto della Libreria cambiava con i tempi delle risposte (issue #5)». The report's cause says something similar («più un difetto di tempi nel prodotto…»). In the test that failed in run 19, the product defect plays no part: the engine state is already known when the Libreria is drawn again. Linking the commit to issue #5 makes the history suggest that the product fix is part of the cure for the flake.
Minore
Corretto: Rilievo vero. La prova del pulsante Indietro passa anche con il library.js di main (riverificato in questa sessione), quindi il difetto del prodotto non è fra le cause del fallimento dell'issue #5. Ho riscritto solo il messaggio di 8c36c86 con git commit --amend: era il commit in cima, mai spinto, senza upstream. Il nuovo commit è 3719adc e l'albero è identico (git diff 8c36c86 3719adc è vuoto). Il messaggio ora dice: «È un difetto a sé, trovato mentre si cercava la causa dell'issue #5, e non è fra le cause di quel fallimento: nella prova del pulsante Indietro lo stato del motore è già noto quando la Libreria si ridisegna, e quella prova passa anche senza questa correzione.» Ho corretto anche la riga proposta per il CHANGELOG («non fallisce più»), che ora va sotto «Sviluppo e qualità». Lo stesso va detto nel testo della PR, che non ho scritto io.
R2 (src/Febe.Web/wwwroot/js/pages/library.js:331): While engineState() is still null, drawEmpty chooses the kind 'vuota'. On a first start where the engine answers after /api/library/days, the user first sees «La libreria è ancora vuota», which is not true for a first start, and then the welcome replaces it with a layout jump. Before this branch the wrong state stayed for good; now it lasts only as long as the engine's delay, but it still appears.
Minore
Corretto: Rilievo vero. Con engineState() ancora null, notConnected() restituisce false e drawEmpty sceglieva 'vuota'. Al primo avvio quel testo è falso e poi il benvenuto lo sostituisce con un salto della pagina. Ho aggiunto il tipo 'attesa' (commit 0a6dd19): senza filtri e senza lo stato del motore, la pagina mostra un div vuoto con aria-busy, che page.onEngine sostituisce con il benvenuto o con «La libreria è ancora vuota». È coerente con l'interfaccia di oggi: il mosaico mentre carica è un'area vuota, e la barra laterale dice già «Caricamento…» finché il motore non risponde. Il motore arriva comunque, perché /api/eventi lo manda appena il flusso si apre (EngineApi.cs) e, senza flusso, engine.js lo richiede a intervalli. Il passo 2 della prova nuova ora aspetta main [aria-busy=true] e controlla che il conteggio cominci con «0 », che engineState() sia null e che non ci siano .vuoto-pagina, .benvenuto né .mosaico. Sul library.js di 3719adc la prova fallisce («timeout: libreria vuota in attesa del motore»), con la correzione passa. In decisioni.md la riga del 20/10 sullo stato vuoto è corretta (non dice più che «La libreria è ancora vuota» diventa il benvenuto) e c'è una riga nuova, datata 2026-10-20, per la scelta dello stato d'attesa.
## Revisione avversaria
Un revisore indipendente ha letto tutto il ramo e ha rifatto compilazione e prove; l'autore ha poi verificato ogni rilievo prima di correggerlo o respingerlo.
**Giudizio del revisore**
The branch is good. There are no blocking or important findings, only two minor notes. Both commits, fbb9e60 (test) and 8c36c86 (product), can go to a PR.
I checked the author's claims myself in a separate clone, B:\Altro\Sviluppo\.febe-lavoro\revisione-indietro\clone, at 8c36c86. In that clone only, UiBrowser was patched so it runs on Windows, with FEBE_CHROMIUM set to Chrome 155.
1) The stated cause is the real one. I wrote a throwaway test that runs the back-button flow 18 times. When the dialog is open, before «Lascia le modifiche», `engineState().connection.state` is already "notConnected" every time, so the final state of the Libreria is always `.benvenuto`. `.mosaico` exists only for the moment between the Mosaic constructor and the reply to /api/library/days.
- Old condition, first check at once: 8 of 8 passed on this PC.
- Old condition, first check 100 or 300 ms later: TIMEOUT both times, with the final state "/libreria benvenuto". That is the «timeout: Libreria» of CI run 19.
- New condition, first check at 0, 100, 300 or 1000 ms: 8 of 8 passed.
- The leave-guard has no product bug: dialog() closes and resolves synchronously, and onHistory then calls render().
2) The test was not weakened. The new wait can only come true once the Libreria has really replaced Limiti. While the dialog is open, `location.pathname` is already '/libreria' but main still shows Limiti, with no `.benvenuto`. So a «Lascia le modifiche» that did not navigate would still fail the test. The «Annulla» part is unchanged. The added assertion checks that the dialog is gone, `.cerchio-giorno` is gone and `.salva` is hidden; `.salva` exists only in shell.js, so querySelector finds the new page's bar.
3) The product fix in library.js is correct.
- drawEmpty is idempotent for the same kind of empty state.
- Through `empty.node.isConnected`, onEngine has no effect once a new Mosaic or Mosaic.refresh() has replaced the content of host.
- Filters are always applied synchronously together with apply(), so filtersActive() never disagrees with what is on screen.
- The listener is removed by PageFrame.destroy.
- The demo's screenshot step benvenuto.js is not affected, because `empty` stays null there.
- The new test TheEmptyLibraryFollowsTheConnectionAlsoWhenTheEngineAnswersLate is deterministic: the engine answer is held behind a gate and EventSource is removed. I put main's library.js back in the clone and rebuilt: the new test fails with «timeout: primo avvio dopo la risposta del motore», while TheBackButtonAsksBeforeLosingUnsavedChanges passes. So the test fix does not depend on the product fix, and the new test does prove the product fix.
- The welcome markup and CSS are unchanged; only when it is shown changes. The author's comparison with primo-avvio.png is enough.
4) I found no other waits of the same kind. UiBrowser is used only in InterfaceTests. The other waits either target a final state (.gruppo-giorno/.tess with data, .pannello.collegato, .arresto, .stato .chi with a fixed monitor) or are followed by a real sync point (window.__done, WaitForAsync on the server side). Line 368 already accepts both empty states.
My own checks:
| Check | Result |
|---|---|
| `dotnet build Febe.slnx -c Release -warnaserror` | 0 warnings, 0 errors |
| `dotnet test tests/Febe.Tests -c Release`, no FEBE_CHROMIUM, TEMP/TMP in the review folder | 705 passed, 76 skipped, 0 failed, 781 total |
| InterfaceTests, Windows Chrome with the temporary patch | 19 of 19, twice |
| `git diff --check` | clean |
The diff touches only decisioni.md (two rows at the end, dated 2026-10-20), library.js and InterfaceTests.cs. CHANGELOG.md and stato.md are untouched, and the worktree is clean.
Not checked: Linux or Chromium in the CI container. On CI, the green re-runs the author lists are still needed.
Side note, not this branch's work and not part of issue #5: accounts.js:35 has the same "decided only once" pattern. `suspended()` reads engineState() when the table is drawn. If /api/engine arrives after /api/accounts, «Prossimo» shows «verso le…» instead of «Sospeso» until the next engine event at least 55 s after loading. If wanted, open a separate issue.
On the proposed CHANGELOG line for the test: «non falliva più a caso» has the wrong tense; it should be «non fallisce più a caso». It is also worth deciding whether a test-only fix belongs in the user-facing CHANGELOG at all.
**Rilievi ed esito**
| Rilievo | Gravità | Esito |
|---|---|---|
| **R1** (src/Febe.Web/wwwroot/js/pages/library.js:331): The message of commit 8c36c86 says the product defect is «anche il motivo per cui lo stato vuoto della Libreria cambiava con i tempi delle risposte (issue #5)». The report's cause says something similar («più un difetto di tempi nel prodotto…»). In the test that failed in run 19, the product defect plays no part: the engine state is already known when the Libreria is drawn again. Linking the commit to issue #5 makes the history suggest that the product fix is part of the cure for the flake. | Minore | Corretto: Rilievo vero. La prova del pulsante Indietro passa anche con il library.js di main (riverificato in questa sessione), quindi il difetto del prodotto non è fra le cause del fallimento dell'issue #5. Ho riscritto solo il messaggio di 8c36c86 con git commit --amend: era il commit in cima, mai spinto, senza upstream. Il nuovo commit è 3719adc e l'albero è identico (git diff 8c36c86 3719adc è vuoto). Il messaggio ora dice: «È un difetto a sé, trovato mentre si cercava la causa dell'issue #5, e non è fra le cause di quel fallimento: nella prova del pulsante Indietro lo stato del motore è già noto quando la Libreria si ridisegna, e quella prova passa anche senza questa correzione.» Ho corretto anche la riga proposta per il CHANGELOG («non fallisce più»), che ora va sotto «Sviluppo e qualità». Lo stesso va detto nel testo della PR, che non ho scritto io. |
| **R2** (src/Febe.Web/wwwroot/js/pages/library.js:331): While engineState() is still null, drawEmpty chooses the kind 'vuota'. On a first start where the engine answers after /api/library/days, the user first sees «La libreria è ancora vuota», which is not true for a first start, and then the welcome replaces it with a layout jump. Before this branch the wrong state stayed for good; now it lasts only as long as the engine's delay, but it still appears. | Minore | Corretto: Rilievo vero. Con engineState() ancora null, notConnected() restituisce false e drawEmpty sceglieva 'vuota'. Al primo avvio quel testo è falso e poi il benvenuto lo sostituisce con un salto della pagina. Ho aggiunto il tipo 'attesa' (commit 0a6dd19): senza filtri e senza lo stato del motore, la pagina mostra un div vuoto con aria-busy, che page.onEngine sostituisce con il benvenuto o con «La libreria è ancora vuota». È coerente con l'interfaccia di oggi: il mosaico mentre carica è un'area vuota, e la barra laterale dice già «Caricamento…» finché il motore non risponde. Il motore arriva comunque, perché /api/eventi lo manda appena il flusso si apre (EngineApi.cs) e, senza flusso, engine.js lo richiede a intervalli. Il passo 2 della prova nuova ora aspetta `main [aria-busy=true]` e controlla che il conteggio cominci con «0 », che engineState() sia null e che non ci siano .vuoto-pagina, .benvenuto né .mosaico. Sul library.js di 3719adc la prova fallisce («timeout: libreria vuota in attesa del motore»), con la correzione passa. In decisioni.md la riga del 20/10 sullo stato vuoto è corretta (non dice più che «La libreria è ancora vuota» diventa il benvenuto) e c'è una riga nuova, datata 2026-10-20, per la scelta dello stato d'attesa. |
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Alby96
merged commit eb7db4d2bf into main2026-10-20 21:51:03 +02:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Sintesi
Segnalazione #5. La prova del pulsante Indietro con modifiche non salvate passava per caso: ora aspetta lo stato finale
della Libreria. Indagando è emerso un difetto vero nella Libreria al primo avvio, corretto con una prova.
Causa (accertata, con Chrome 155 su Windows)
main .vuoto-pagina, main .mosaico. Il server di prova però non haaccount ed è «non collegato», quindi la Libreria vuota finisce sul benvenuto (
.benvenuto)..mosaicoesiste soloper circa 12 ms, prima che arrivi
/api/library/days. Traccia del DOM con un MutationObserver: a 0 ms il percorso è/libreria, a 9 ms c'è il mosaico, a 21 ms il benvenuto. Su 16 esecuzioni con il primo controllo ritardato da 0 a300 ms, la condizione vecchia scade sempre da 5 ms in su; quella nuova è 16 su 16.
arrivava dopo, il primo avvio restava su «La libreria è ancora vuota» invece del benvenuto con «Collegati a
Instagram». Riprodotto trattenendo
/api/engineper 800 ms.Che cosa cambia
TheBackButtonAsksBeforeLosingUnsavedChangesaspettamain .benvenutoe controlla che dialogo, pagina Limiti e barradi salvataggio non ci siano più. Le altre attese di
InterfaceTestssono state controllate: nessuna dipende da unostato di passaggio.
library.js: lo stato vuoto senza filtri segue il motore finché è sullo schermo. Finché non si sa se Febe è collegatonon mostra nessuno stato vuoto, quindi niente salto da un testo all'altro, e si ridisegna solo se il tipo cambia. Il
benvenuto è identico a
docs/schermate/primo-avvio.png.TheEmptyLibraryFollowsTheConnectionAlsoWhenTheEngineAnswersLate: fallisce sullibrary.jsdimainepassa qui.
docs/decisioni.mde inCHANGELOG.md(0.1.1).Come è stato provato
La revisione avversaria, rifatta in un clone separato con 18 ripetizioni del percorso, ha trovato due rilievi minori,
corretti. Uno ha aggiunto lo stato «in attesa» al posto del testo provvisorio.
La verifica di questa PR deve mostrare 781 prove su 781 con 0 saltate e tutte le 19
InterfaceTestssuperate.Rischi e ritorno indietro
git revert -m 1 <commit di unione>.Controlli prima di unire
docs/schermate/primo-avvio.pngChiude #5.
🤖 Generated with Claude Code
Revisione avversaria
Un revisore indipendente ha letto tutto il ramo e ha rifatto compilazione e prove; l'autore ha poi verificato ogni rilievo prima di correggerlo o respingerlo.
Giudizio del revisore
The branch is good. There are no blocking or important findings, only two minor notes. Both commits,
fbb9e60(test) and 8c36c86 (product), can go to a PR.I checked the author's claims myself in a separate clone, B:\Altro\Sviluppo.febe-lavoro\revisione-indietro\clone, at 8c36c86. In that clone only, UiBrowser was patched so it runs on Windows, with FEBE_CHROMIUM set to Chrome 155.
The stated cause is the real one. I wrote a throwaway test that runs the back-button flow 18 times. When the dialog is open, before «Lascia le modifiche»,
engineState().connection.stateis already "notConnected" every time, so the final state of the Libreria is always.benvenuto..mosaicoexists only for the moment between the Mosaic constructor and the reply to /api/library/days.The test was not weakened. The new wait can only come true once the Libreria has really replaced Limiti. While the dialog is open,
location.pathnameis already '/libreria' but main still shows Limiti, with no.benvenuto. So a «Lascia le modifiche» that did not navigate would still fail the test. The «Annulla» part is unchanged. The added assertion checks that the dialog is gone,.cerchio-giornois gone and.salvais hidden;.salvaexists only in shell.js, so querySelector finds the new page's bar.The product fix in library.js is correct.
empty.node.isConnected, onEngine has no effect once a new Mosaic or Mosaic.refresh() has replaced the content of host.emptystays null there.I found no other waits of the same kind. UiBrowser is used only in InterfaceTests. The other waits either target a final state (.gruppo-giorno/.tess with data, .pannello.collegato, .arresto, .stato .chi with a fixed monitor) or are followed by a real sync point (window.__done, WaitForAsync on the server side). Line 368 already accepts both empty states.
My own checks:
dotnet build Febe.slnx -c Release -warnaserrordotnet test tests/Febe.Tests -c Release, no FEBE_CHROMIUM, TEMP/TMP in the review foldergit diff --checkThe diff touches only decisioni.md (two rows at the end, dated 2026-10-20), library.js and InterfaceTests.cs. CHANGELOG.md and stato.md are untouched, and the worktree is clean.
Not checked: Linux or Chromium in the CI container. On CI, the green re-runs the author lists are still needed.
Side note, not this branch's work and not part of issue #5: accounts.js:35 has the same "decided only once" pattern.
suspended()reads engineState() when the table is drawn. If /api/engine arrives after /api/accounts, «Prossimo» shows «verso le…» instead of «Sospeso» until the next engine event at least 55 s after loading. If wanted, open a separate issue.On the proposed CHANGELOG line for the test: «non falliva più a caso» has the wrong tense; it should be «non fallisce più a caso». It is also worth deciding whether a test-only fix belongs in the user-facing CHANGELOG at all.
Rilievi ed esito
3719adce l'albero è identico (git diff 8c36c863719adcè vuoto). Il messaggio ora dice: «È un difetto a sé, trovato mentre si cercava la causa dell'issue #5, e non è fra le cause di quel fallimento: nella prova del pulsante Indietro lo stato del motore è già noto quando la Libreria si ridisegna, e quella prova passa anche senza questa correzione.» Ho corretto anche la riga proposta per il CHANGELOG («non fallisce più»), che ora va sotto «Sviluppo e qualità». Lo stesso va detto nel testo della PR, che non ho scritto io.0a6dd19): senza filtri e senza lo stato del motore, la pagina mostra un div vuoto con aria-busy, che page.onEngine sostituisce con il benvenuto o con «La libreria è ancora vuota». È coerente con l'interfaccia di oggi: il mosaico mentre carica è un'area vuota, e la barra laterale dice già «Caricamento…» finché il motore non risponde. Il motore arriva comunque, perché /api/eventi lo manda appena il flusso si apre (EngineApi.cs) e, senza flusso, engine.js lo richiede a intervalli. Il passo 2 della prova nuova ora aspettamain [aria-busy=true]e controlla che il conteggio cominci con «0 », che engineState() sia null e che non ci siano .vuoto-pagina, .benvenuto né .mosaico. Sul library.js di3719adcla prova fallisce («timeout: libreria vuota in attesa del motore»), con la correzione passa. In decisioni.md la riga del 20/10 sullo stato vuoto è corretta (non dice più che «La libreria è ancora vuota» diventa il benvenuto) e c'è una riga nuova, datata 2026-10-20, per la scelta dello stato d'attesa.🤖 Generated with Claude Code