diff --git a/public/index.html b/public/index.html index 98279fc..e686c04 100644 --- a/public/index.html +++ b/public/index.html @@ -9491,17 +9491,27 @@

Delegate to Agent

if (!card) return; const review = _planReviews[messageId], sel = _planSelections[messageId]; card.querySelectorAll('.prc-task input[type=checkbox]').forEach(cb => { cb.checked = sel.has(cb.dataset.taskId); }); + const n = sel.size; + const count = card.querySelector('.prc-count'); + if (count) count.textContent = t('plan.selected.count').replace('{n}', n).replace('{total}', review ? review.tasks.length : n); const btn = card.querySelector('.prc-approve-btn'); - if (btn) { const n = sel.size; btn.disabled = n === 0; btn.textContent = n ? t('plan.approve.btn').replace('{n}', n) : t('plan.approve.none'); } + if (btn) { btn.disabled = n === 0; btn.textContent = n ? t('plan.approve.btn').replace('{n}', n) : t('plan.approve.none'); } } function planReviewCardHtml(review, messageId, imported) { + // The one place a selection is defaulted: every task without a lint error of its own, starts + // picked. Self-healing on purpose — a card restored from the DB never went through _prRender, + // so nothing else guarantees _planSelections[messageId] exists yet; computing (and STORING) the + // default here, once, is what makes a checkbox drawn as checked and the "N selected" count + // agree, and what makes clicking that checkbox work on the very first render. + if (!_planSelections[messageId]) _planSelections[messageId] = new Set(review.tasks.filter(t => !t.errors.length).map(t => t.id)); + const sel = _planSelections[messageId]; const errBlock = review.errors.length ? `
⚠️ ${escH(t('plan.errors.title'))}
` : ''; const warnBlock = (!imported && review.warnings.length) ? `
${escH(t('plan.warnings.title'))}
` : ''; const depsTitle = (ids) => ids.length ? `${t('plan.deps')} ${ids.join(', ')}` : ''; const rows = review.tasks.map(tk => { - const checked = imported ? true : (_planSelections[messageId] ? _planSelections[messageId].has(tk.id) : true); + const checked = imported ? true : sel.has(tk.id); const issues = [...tk.errors.map(m => `⚠ ${escH(m)}`), ...tk.warnings.map(m => `${escH(m)}`)]; return `