Sessione salvata: copia alla chiusura della finestra e alla fine della guida, «Serve «Ho finito»», scelta per la copia incompleta e stato in Collegamento (#36, S4b)

Risposte 1, 5, 6, 9 e 10 di Alberto a S4. I valori __spin_r, __spin_b e __spin_t si copiano dalla pagina come gli altri (su Instagram da SiteData, ipotesi H23, operazioni ancora non configurate; nel sito di prova dal modulo GiroProva). La sessione si copia anche quando si chiude la finestra del browser su Windows e quando il permesso di guida finisce, sempre prima che la pagina torni al motore e con le garanzie di «Ho finito». Con «richieste» «Collegato» vuole una sessione salvata leggibile, altrimenti lo stato è «Serve «Ho finito»» e il motore aspetta. Nuova impostazione sessione.copia-incompleta (sostituisci, predefinita, o tieni-completa) e riquadro della sessione salvata nella pagina Collegamento, con soli conteggi e nomi.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-18 11:41:35 +01:00
1 parent 9958745e53
commit 883ea4683c
41 files changed
+1349 -101

No files matched your search

+67 -7
View File
@@ -2,7 +2,9 @@
// the steps «Come collegarti», the note that the password goes only to Instagram (keys pass through the server without
// being recorded), the risk note, Annulla and «Ho finito». Windows: the browser is the separate window «Browser di
// Febe» and the large area says so, with «Portalo in primo piano». When connected: the account, «Usa il browser» and
// «Scollega» with its confirmation. While Alberto uses the browser the engine is still.
// «Scollega» with its confirmation. While Alberto uses the browser the engine is still. With the raccolta «richieste»
// (issue #36, S4b) the page also shows the saved session in counts and names (never values), the choice for an
// incomplete copy, and «Serve «Ho finito»» when the browser is connected but the copy is missing.
import { api } from '../core/api.js';
import { caps } from '../core/context.js';
@@ -10,10 +12,10 @@ import { h, icon, fill } from '../core/dom.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';
import { avatar, confirmDialog, label, radio, showError, toast } from '../core/ui.js';
import { remoteView } from './remote-view.js';
const STATE_KIND = { notConnected: 'ambra', connected: 'verde', verificationRequired: 'rosso', browserUnavailable: '' };
const STATE_KIND = { notConnected: 'ambra', connected: 'verde', copyMissing: 'ambra', verificationRequired: 'rosso', browserUnavailable: '' };
/** True while the engine waits for «Riprendi» (the stop strip of a verification or a disconnection). */
function waitsForResume(state) {
@@ -120,6 +122,7 @@ export async function mountConnection(page) {
fill(stateLabel, label(t(`impostazioni.collegamento.stati.${status.state}`), STATE_KIND[status.state] || ''));
if (status.state === 'connected') drawConnected();
else if (status.state === 'browserUnavailable') drawUnavailable();
else if (status.state === 'copyMissing') drawLogin({ copyMissing: true });
else drawLogin();
}
@@ -145,15 +148,17 @@ export async function mountConnection(page) {
});
// ------------------------------------------------------------------------------------------- login or verification
function drawLogin() {
function drawLogin({ copyMissing = false } = {}) {
const verification = status.state === 'verificationRequired';
// Connected but without the copy for the requests: the start page (the site's home), never the login page.
const login = !verification && !copyMissing;
waitingResume = false;
closeView();
lease.begin(!verification);
lease.begin(login);
if (windows) {
fill(left, windowPanel());
} else {
view = remoteView(page, { url: status.currentUrl, login: !verification });
view = remoteView(page, { url: status.currentUrl, login });
fill(left, view.element);
}
const steps = t(windows ? 'impostazioni.collegamento.passiWindows' : 'impostazioni.collegamento.passi');
@@ -161,6 +166,8 @@ export async function mountConnection(page) {
fill(right,
verification
? h('div.avviso.rosso', icon('octagon-alert', 's'), h('span', h('b', t('impostazioni.collegamento.verificaTitolo')), ' ', t('impostazioni.collegamento.verificaTesto')))
: copyMissing
? h('div.avviso.ambra', icon('triangle-alert', 's'), h('span', h('b', t('impostazioni.collegamento.copiaMancanteTitolo')), ' ', t('impostazioni.collegamento.copiaMancanteTesto')))
: h('div',
h('h2.sez', t('impostazioni.collegamento.come')),
h('ol.passi-collegamento', (Array.isArray(steps) ? steps : []).map((s, i) => h('li', h('span.numero', String(i + 1)), h('div', h('b', s.titolo), h('p', s.testo)))))),
@@ -168,6 +175,7 @@ export async function mountConnection(page) {
h('div.avviso.ambra', icon('triangle-alert', 's'), h('span', t('impostazioni.collegamento.rischio'))),
// Windows: one engine per account (spec §5) said before the login too; Docker keeps mockup 10 as it is.
windows ? h('div.avviso', icon('info', 's'), h('span', t('impostazioni.collegamento.unMotore'))) : null,
copyMissing ? savedSessionBox(status.savedSession, page) : null,
message,
h('div.molla'),
h('div.bottoni-collegamento',
@@ -235,7 +243,8 @@ export async function mountConnection(page) {
fill(right,
passwordNote(windows),
h('div.avviso.ambra', icon('triangle-alert', 's'), h('span', t('impostazioni.collegamento.rischio'))),
h('div.avviso', icon('info', 's'), h('span', t('impostazioni.collegamento.unMotore'))));
h('div.avviso', icon('info', 's'), h('span', t('impostazioni.collegamento.unMotore'))),
savedSessionBox(status.savedSession, page));
}
async function useBrowser() {
@@ -287,6 +296,57 @@ export async function mountConnection(page) {
await draw();
}
/**
* The saved session of the raccolta «richieste» (issue #36, S4b): when it was copied, the values and doc_id present
* and the names of the missing ones — counts and names only, the server never sends a value — and the choice for an
* incomplete copy. Nothing without a saved session in this start («pagine»).
*/
export function savedSessionBox(saved, page) {
if (!saved) return null;
const k = (key, vars) => t(`impostazioni.collegamento.salvata.${key}`, vars);
const lines = [];
if (saved.state === 'present') {
if (saved.copiedAt) {
const when = new Date(saved.copiedAt).toLocaleString('it-IT', { dateStyle: 'medium', timeStyle: 'short' });
lines.push(h('p', k('copiata', { quando: when })));
}
lines.push(h('p.muto', [
k('valori', { presenti: String(saved.valuesPresent), attesi: String(saved.valuesExpected) }),
k('docId', { presenti: String(saved.docIdsPresent), attesi: String(saved.docIdsExpected) }),
k('cookie', { n: String(saved.cookies) }),
].join(' ')));
const missing = [...(saved.missingValues || []), ...(saved.missingDocIds || [])];
if (missing.length) lines.push(h('p', k('mancano', { nomi: missing.join(', ') })));
lines.push(saved.neededMissing
? h('div.avviso.ambra', icon('triangle-alert', 's'), h('span', k('servono', { n: String(saved.neededMissing) })))
: h('p', k('completa')));
} else {
lines.push(h('p', k(saved.state === 'unreadable' ? 'illeggibile' : 'nessuna')));
}
const choose = async (value) => {
try {
await api('/api/connection/settings', { method: 'PUT', body: { incompleteCopy: value } });
toast(k('salvato'));
} catch (error) {
showError(error);
}
};
const replace = radio({ name: 'copia-incompleta', value: 'sostituisci', checked: true, onchange: choose, labelNode: h('span', h('b', k('sostituisci')), h('small', k('sostituisciAiuto'))) });
const keep = radio({ name: 'copia-incompleta', value: 'tieni-completa', onchange: choose, labelNode: h('span', h('b', k('tieni')), h('small', k('tieniAiuto'))) });
api('/api/connection/settings', { signal: page && page.signal }).then((settings) => {
keep.input.checked = settings.incompleteCopy === 'tieni-completa';
replace.input.checked = !keep.input.checked;
}).catch(() => {});
return h('div.pannello.sessione-salvata',
h('h2.sez', k('titolo')),
...lines,
h('p.aiuto.piccolo', k('nota')),
h('h3.sez', k('incompleta')),
h('div.scelte', { role: 'radiogroup', 'aria-label': k('incompleta') }, replace, keep));
}
/** «La password va solo a Instagram», with the true wording of each shell (spec §10.3). */
export function passwordNote(windows) {
return h('div.avviso.nota-password', icon('shield-check', 's'),