Tell the mirror that Phase 2 is running instead of leaving it on a greyed button
The mirror's own job ends in seconds while Phase 2 runs for minutes on the owner, so the screen sat unchanged on the phase-1 panel — which reads as a hang, and the reasonable response to a hang is to start clicking.
This commit is contained in:
@@ -525,6 +525,8 @@ function vvRenderOnboardPanel(d) {
|
||||
termCmd: `bash ${dir}/Partnership/partnership_onboard.sh --phase1-only`,
|
||||
phase: vvDetectedIdentity.phase ?? 0,
|
||||
hasPartner: true,
|
||||
waiting: _vvPhase2Waiting,
|
||||
waitingSince: _vvPhase2Since,
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -599,23 +601,45 @@ function vvRenderDone(d) {
|
||||
// bootstrap in Step 9 pushed a real run to 4m05s and it grows with library size, so the poll was
|
||||
// expiring before the flag landed and the wizard sat unchanged on a partnership that had already
|
||||
// succeeded — the exact symptom this function exists to remove.
|
||||
let _vvPartnerPoll = null;
|
||||
let _vvPartnerPoll = null;
|
||||
let _vvPhase2Waiting = false; // Phase 2 is running on the owner right now
|
||||
let _vvPhase2Since = 0; // epoch ms, for the elapsed counter
|
||||
let _vvPhase2Tick = null; // redraws the counter between checklist polls
|
||||
let _vvLastChecklist = null; // last payload, so the ticker can redraw without refetching
|
||||
function vvOnJobDone(id, status) {
|
||||
if (!String(id).includes('partnership_onboard')) { vvLoadChecklist(); return; }
|
||||
if (_vvPartnerPoll) clearInterval(_vvPartnerPoll);
|
||||
if (_vvPhase2Tick) clearInterval(_vvPhase2Tick);
|
||||
|
||||
// The mirror's job ending is the START of the wait, not the end of the work — Phase 2 begins on
|
||||
// the owner at this moment. Hold the in-progress panel until the checklist actually turns.
|
||||
_vvPhase2Waiting = true;
|
||||
_vvPhase2Since = Date.now();
|
||||
|
||||
const stop = () => {
|
||||
_vvPhase2Waiting = false;
|
||||
if (_vvPartnerPoll) { clearInterval(_vvPartnerPoll); _vvPartnerPoll = null; }
|
||||
if (_vvPhase2Tick) { clearInterval(_vvPhase2Tick); _vvPhase2Tick = null; }
|
||||
vvLoadChecklist();
|
||||
};
|
||||
|
||||
const deadline = Date.now() + 20 * 60 * 1000;
|
||||
const check = () => {
|
||||
fetch('/plugins/varaverk/api/checklist.php?_=' + Date.now())
|
||||
.then(r => r.json())
|
||||
.then(d => {
|
||||
const done = (d.items || []).some(i => i.id === 'partnership' && i.ok);
|
||||
if (done || Date.now() > deadline) {
|
||||
clearInterval(_vvPartnerPoll); _vvPartnerPoll = null;
|
||||
vvLoadChecklist();
|
||||
}
|
||||
if (done || Date.now() > deadline) stop();
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
// Redraw between checklist polls so the elapsed counter moves. Without it the panel is static
|
||||
// for six seconds at a time, which reads as frozen — the thing this panel exists to prevent.
|
||||
_vvPhase2Tick = setInterval(() => {
|
||||
if (_vvPhase2Waiting) vvRenderOnboardPanel(_vvLastChecklist || {items: []});
|
||||
}, 1000);
|
||||
|
||||
vvLoadChecklist();
|
||||
check();
|
||||
_vvPartnerPoll = setInterval(check, 6000);
|
||||
@@ -625,6 +649,7 @@ function vvLoadChecklist() {
|
||||
fetch('/plugins/varaverk/api/checklist.php?_=' + Date.now())
|
||||
.then(r => r.json()).then(d => {
|
||||
const el = document.getElementById('vv-checklist');
|
||||
_vvLastChecklist = d;
|
||||
if (!d.ok || !d.items) { el.innerHTML = '<span style="color:#555">Unable to load checklist</span>'; return; }
|
||||
vvLabelExit();
|
||||
vvRenderOnboardPanel(d);
|
||||
|
||||
Reference in New Issue
Block a user