Interfaccia: correzioni della revisione (web-1, web-2, web-3, web-4, web-5, web-6, web-7, web-9, web-10, web-11, web-12, web-13, web-14, web-15)

Il browser preso dalle pagine Browser e Collegamento si restituisce uscendo senza «Ho finito» (anche chiudendo o ricaricando la scheda); dopo «Ho finito» la vista remota si chiude e non si riprende il browser. Vista remota: AltGr/Option come testo, pulsante rilasciato anche fuori dalla vista. Mosaico e scheda account senza risposte vecchie né viste sovrascritte; nuovi elementi dopo la libreria vuota; intestazione sempre aggiornata. Indietro del browser con la richiesta delle modifiche non salvate; nulla resta registrato da una pagina lasciata mentre caricava; maniglie della fascia trascinabili. «Da una data» come giorno locale; niente «@null» nel riquadro di stato; orari futuri dei fermi «verso le». Prove nel browser vero (InterfaceTests).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
Claude committed 2026-10-14 01:38:13 +00:00
1 parent 78c92eb2a4
commit 0ceffffe50
27 files changed
+1365 -59

No files matched your search

+114 -4
View File
@@ -7,7 +7,7 @@
import { api } from '../core/api.js';
import { caps } from '../core/context.js';
import { h, icon, fill } from '../core/dom.js';
import { refreshEngine } from '../core/engine.js';
import { engineState, refreshEngine } from '../core/engine.js';
import { navigate } from '../core/shell.js';
import { t } from '../core/text.js';
import { avatar, confirmDialog, label, showError, toast } from '../core/ui.js';
@@ -15,8 +15,19 @@ import { remoteView } from './remote-view.js';
const STATE_KIND = { notConnected: 'ambra', connected: 'verde', verificationRequired: 'rosso', browserUnavailable: '' };
/** True while the engine waits for «Riprendi» (the stop strip of a verification or a disconnection). */
function waitsForResume(state) {
const banner = state && state.snapshot && state.snapshot.banner;
return Boolean(banner && banner.needsResume);
}
// The last «give the browser back» sent by a page that was left: the next «begin» waits for it, so that the server
// never sees the new page's begin before the old page's release.
let releasing = Promise.resolve();
/** Starts using the browser (the engine is still); with openLogin the real login page is loaded. */
export async function beginDriving(openLogin) {
await releasing;
try {
await api('/api/connection/begin', { method: 'POST', body: { openLogin } });
return true;
@@ -26,6 +37,39 @@ export async function beginDriving(openLogin) {
}
}
/**
* The browser as a page uses it (spec §4.1, §10.3: the engine is still only while Alberto uses the browser). begin()
* takes it; «Ho finito», «Annulla» and «Scollega» give it back on the server, and the page calls settled(). Leaving the
* page in any other way — another page, a reload, closing the tab — counts as «Annulla»: the browser goes back to the
* empty page and the engine may work again.
*/
export function drivingLease(page) {
let held = false;
const release = (keepalive) => {
if (!held) return;
held = false;
releasing = api('/api/connection/cancel', { method: 'POST', keepalive }).then(() => {}, () => {});
};
const onHide = () => release(true);
window.addEventListener('pagehide', onHide);
page.onLeave(() => {
window.removeEventListener('pagehide', onHide);
release(false);
});
return {
/** Takes the browser (nothing when the page was already left). */
begin(openLogin) {
if (page.signal.aborted) return Promise.resolve(false);
held = true;
return beginDriving(openLogin);
},
/** The server already gave the browser back («Ho finito», «Annulla», «Scollega»). */
settled() {
held = false;
},
};
}
/** The area that replaces the remote view on Windows: the browser is its own window. */
export function windowPanel() {
return h('div.vista.vista-finestra',
@@ -57,6 +101,18 @@ export async function mountConnection(page) {
const right = h('div.collega-destra');
fill(page.body, h('div.pagina-collegamento', left, right));
const windows = caps().browserWindow;
const lease = drivingLease(page);
// The remote view drawn now (Docker): open, it keeps the engine still, so it closes as soon as it is not shown.
let view = null;
// «Ho finito» went well but the engine still waits for «Riprendi» (verification or disconnection); stopSeen: the
// engine was seen stopped since then, so the end of the stop is «Riprendi».
let waitingResume = false;
let stopSeen = false;
function closeView() {
if (view) view.close();
view = null;
}
let status = await api('/api/connection', { signal: page.signal });
async function draw() {
@@ -66,11 +122,39 @@ export async function mountConnection(page) {
else drawLogin();
}
// After «Riprendi» (in the red strip of this page) the page shows the connection as it is now. It never takes the
// browser again by itself: still waiting for the verification, the panel stays.
page.onEngine((state) => {
if (!waitingResume) return;
if (waitsForResume(state)) {
stopSeen = true;
return;
}
if (!stopSeen) return;
waitingResume = false;
api('/api/connection', { signal: page.signal }).then((answer) => {
status = answer;
if (status.state !== 'verificationRequired') {
draw();
return;
}
waitingResume = true;
stopSeen = false;
}).catch(showError);
});
// ------------------------------------------------------------------------------------------- login or verification
function drawLogin() {
const verification = status.state === 'verificationRequired';
beginDriving(!verification);
fill(left, windows ? windowPanel() : remoteView(page, { url: status.currentUrl, login: !verification }).element);
waitingResume = false;
closeView();
lease.begin(!verification);
if (windows) {
fill(left, windowPanel());
} else {
view = remoteView(page, { url: status.currentUrl, login: !verification });
fill(left, view.element);
}
const steps = t(windows ? 'impostazioni.collegamento.passiWindows' : 'impostazioni.collegamento.passi');
const message = h('div', { 'aria-live': 'polite' });
fill(right,
@@ -93,6 +177,7 @@ export async function mountConnection(page) {
async function cancel() {
try {
await api('/api/connection/cancel', { method: 'POST' });
lease.settled();
} catch (error) {
showError(error);
}
@@ -102,17 +187,39 @@ export async function mountConnection(page) {
async function finish(message) {
const result = await finishDriving();
if (!result) return;
// «Ho finito» gives the browser back on the server whatever the answer.
lease.settled();
if (result.connected) {
toast(result.message);
closeView();
status = await api('/api/connection', { signal: page.signal });
draw();
// Still stopped for the verification: «Riprendi» is next, the browser is not taken again.
if (status.state === 'verificationRequired') drawFinished(result.message);
else draw();
} else {
fill(message, h('div.avviso.rosso', icon('octagon-alert', 's'), h('span', result.message)));
}
}
/** After «Ho finito» during a verification: what is left is «Riprendi»; the browser can be opened again. */
function drawFinished(text) {
waitingResume = true;
stopSeen = waitsForResume(engineState());
closeView();
fill(left, h('div.vista.vista-finestra', h('div.vista-segnaposto',
icon('circle-check', 'l'),
h('h2', t('impostazioni.collegamento.finitoTitolo')),
h('p', text),
h('button.btn.riapri-browser', { type: 'button', onclick: () => drawLogin() }, icon('app-window', 's'), t('impostazioni.collegamento.riapri')))));
fill(right,
passwordNote(windows),
h('div.avviso.ambra', icon('triangle-alert', 's'), h('span', t('impostazioni.collegamento.rischio'))));
}
// ------------------------------------------------------------------------------------------- connected
function drawConnected() {
waitingResume = false;
closeView();
fill(left, h('div.pannello.collegato',
h('div.chi-collegato', avatar(status.username || '', 'g'),
h('div', h('h2', t('impostazioni.collegamento.collegatoCome', { nome: status.username || '' })), status.displayName ? h('span.muto', status.displayName) : null)),
@@ -152,6 +259,7 @@ export async function mountConnection(page) {
if (choice !== 'yes') return;
try {
await api('/api/connection/disconnect', { method: 'POST' });
lease.settled();
toast(t('impostazioni.collegamento.scollegato'));
refreshEngine();
status = await api('/api/connection', { signal: page.signal });
@@ -163,6 +271,8 @@ export async function mountConnection(page) {
// ------------------------------------------------------------------------------------------- unavailable
function drawUnavailable() {
waitingResume = false;
closeView();
fill(left, h('div.vista.vista-finestra', h('div.vista-segnaposto',
icon('octagon-alert', 'l'),
h('h2', t('impostazioni.collegamento.nonDisponibileTitolo')),