Show batch progress in footer: '📡 50/630 relays · 2/25 batches · relay.example.com'

This commit is contained in:
Laan Tungir
2026-06-30 10:36:42 -04:00
parent fa019fe9a1
commit 011e4c303c
4 changed files with 38 additions and 6 deletions

View File

@@ -393,6 +393,8 @@ function handleWorkerMessage(event) {
latestRelay: message.latestRelay,
latestError: message.latestError,
relayUrls: message.relayUrls || [],
batchCurrent: message.batchCurrent,
batchTotal: message.batchTotal,
}
}));
} else if (message.type === 'startupStatus') {

View File

@@ -1,5 +1,5 @@
{
"VERSION": "v0.7.78",
"VERSION_NUMBER": "0.7.78",
"BUILD_DATE": "2026-06-30T14:33:14.964Z"
"VERSION": "v0.7.79",
"VERSION_NUMBER": "0.7.79",
"BUILD_DATE": "2026-06-30T14:36:42.724Z"
}

View File

@@ -6322,7 +6322,21 @@ async function handlePublish(requestId, event, port) {
for (let i = 0; i < broadcastOnlyUrls.length; i += BATCH_SIZE) {
batches.push(broadcastOnlyUrls.slice(i, i + BATCH_SIZE));
}
console.log(`[Worker] Phase 2: Broadcasting to ${broadcastOnlyUrls.length} relays in ${batches.length} batches of ${BATCH_SIZE}`);
const totalBatches = batches.length;
console.log(`[Worker] Phase 2: Broadcasting to ${broadcastOnlyUrls.length} relays in ${totalBatches} batches of ${BATCH_SIZE}`);
// Emit a progress event showing batch info before starting batches.
broadcast({
type: 'broadcastProgress',
sessionId: publishSessionId,
phase: 'progress',
total: totalTarget,
successful: publishedSoFar.size,
failed: failedSoFar.size + timedOutSoFar.size,
latestRelay: null,
batchCurrent: 0,
batchTotal: totalBatches,
});
for (let bi = 0; bi < batches.length; bi++) {
const batch = batches[bi];
@@ -6341,7 +6355,19 @@ async function handlePublish(requestId, event, port) {
} catch (batchErr) {
// Expected — some relays in this batch may fail.
}
console.log(`[Worker] Batch ${bi + 1}/${batches.length} complete — ` +
// Emit a progress event with batch info after each batch.
broadcast({
type: 'broadcastProgress',
sessionId: publishSessionId,
phase: 'progress',
total: totalTarget,
successful: publishedSoFar.size,
failed: failedSoFar.size + timedOutSoFar.size,
latestRelay: null,
batchCurrent: bi + 1,
batchTotal: totalBatches,
});
console.log(`[Worker] Batch ${bi + 1}/${totalBatches} complete — ` +
`${publishedSoFar.size}/${totalTarget} total succeeded, ` +
`${failedSoFar.size + timedOutSoFar.size} failed/timeout so far`);
}

View File

@@ -831,7 +831,11 @@ import { initPostCards } from './js/post-interactions2.mjs';
const shortRelay = d.latestRelay
? d.latestRelay.replace(/^wss?:\/\//, '').replace(/\/.*$/, '').slice(0, 30)
: '';
spanBroadcastStatus.textContent = `📡 ${d.successful}/${d.total} relays · ${shortRelay}`;
const batchInfo = (d.batchTotal && d.batchTotal > 0)
? ` · ${d.batchCurrent}/${d.batchTotal} batches`
: '';
const relayInfo = shortRelay ? ` · ${shortRelay}` : '';
spanBroadcastStatus.textContent = `📡 ${d.successful}/${d.total} relays${batchInfo}${relayInfo}`;
} else if (d.phase === 'done') {
// Keep the result displayed until the next publish overwrites it.
spanBroadcastStatus.textContent = `${d.successful}/${d.total} relays` + (d.failed > 0 ? ` (${d.failed} failed)` : '');