Skip to content

Commit 01bfc6b

Browse files
Prithvi-Webclaude
andcommitted
fix(confirm): a sheet whose action is not a move to the Trash names that action on its OK button - Re-encode, Empty the Trash, Purge snapshots, Forget this copy, Run git gc, Move it, Approve (review F3.2 of QA third pass)
The shared confirm sheet's OK reads "Move to Trash", with the trash icon, until a dialog relabels it, and every close puts that back. Seven sheets never relabelled it, so each offered a recoverable "Move to Trash" for something else: "Re-encode and replace?" (a lossy HEVC re-encode), "Empty the Trash?" (beside "This empties the system Trash and cannot be undone"), "Purge local snapshots?", "Forget this copy?", "Run git gc?", "Move it somewhere safer?" (a move that deletes nothing) and the Autopilot approval ("Let this policy delete on its own?"). setConfirmButton takes the icon as well as the label (the trash icon stays the default), and each of those openers now sets its own: Re-encode (video), Empty the Trash (trash), Purge snapshots (clock), Forget this copy (trash), Run git gc (gitBranch), Move it (shield), Approve (check). Tests: confirmFooter runs each of the seven openers out of the built page, from the button as a close leaves it, and holds its OK to its own label and icon; and an inventory of all 15 places that open the sheet, with the label each shows, must account for every opening in the page, so a new opener is a decision about its button rather than an inherited "Move to Trash". Lifts that now meet setConfirmButton get a stub (cleanUpModalHonesty, autopilotApprove; the encode lifts are awaited so a missing dependency fails inside its own test), and the two open-file-guard tests end their slice at "function setConfirmButton(", the landmark they name, rather than at its old parameter list. Twelve hand mutants (each opener's label removed, the icon ignored, the default icon changed, an unlisted opening, a listed label changed, an opening dropped), all RED, each file restored by SHA-256. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 800bc1b commit 01bfc6b

12 files changed

Lines changed: 155 additions & 16 deletions

‎public/index.html‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8355,6 +8355,7 @@ <h3 id="portableTitle"><span data-icon="disc"></span>Portable session</h3>
83558355
? `Empty the system Trash?<br><span style="color:var(--text-3)">${escapeHtml(t.incompleteReason || 'TreeMap could not read the Trash, so it cannot say how much this frees.')} This cannot be undone.</span>`
83568356
: `Permanently delete <b>${formatCount(t.itemCount)} item${t.itemCount === 1 ? '' : 's'}</b> (${formatBytes(t.totalBytes)})?` +
83578357
`<br><span style="color:var(--text-3)">This empties the system Trash and cannot be undone.</span>`;
8358+
setConfirmButton('Empty the Trash');
83588359
onConfirmTrash = emptyTrashAction;
83598360
$('confirmModal').classList.add('open');
83608361
});
@@ -8405,6 +8406,7 @@ <h3 id="portableTitle"><span data-icon="disc"></span>Portable session</h3>
84058406
const n = state.snapshots && state.snapshots.snapshots ? state.snapshots.snapshots.length : 0;
84068407
$('confirmTitle').innerHTML = icon('clock', 18) + 'Purge local snapshots?';
84078408
$('confirmText').innerHTML = `Delete <b>${formatCount(n)} local snapshot${n === 1 ? '' : 's'}</b>?<br><span style="color:var(--text-3)">This frees the space they hold. Time Machine will create fresh ones on the next backup.</span>`;
8409+
setConfirmButton('Purge snapshots', 'clock');
84088410
onConfirmTrash = purgeSnapshotsAction;
84098411
$('confirmModal').classList.add('open');
84108412
});
@@ -24958,6 +24960,7 @@ <h3 id="portableTitle"><span data-icon="disc"></span>Portable session</h3>
2495824960
`<b>${escapeHtml(entry ? entry.name : 'This item')}</b> was already deleted from your disk — this only removes ` +
2495924961
`TreeMap’s spare copy${entry ? `, freeing ${formatBytes(entry.sizeBytes)}` : ''}.` +
2496024962
`<br><span style="color:var(--text-3)">It can’t be restored from here afterwards.</span>`;
24963+
setConfirmButton('Forget this copy');
2496124964
$('confirmModal').classList.add('open');
2496224965
}
2496324966

@@ -27965,6 +27968,7 @@ <h3 id="portableTitle"><span data-icon="disc"></span>Portable session</h3>
2796527968
: `<b>${escapeHtml(policy.name)}</b>'s next run will remove what it matches ${scope}, up to <b>${formatBytes(run.bytesMatched)}</b>, once. ` +
2796627969
`A later run that matches more than ${formatBytes(policy.requireConfirmationAbove || 0)} asks again.`) +
2796727970
`<br><span style="color:var(--text-3)">Everything it removes is copied to the Time Capsule first, and a run can be undone from here until the Time Capsule removes its copies.</span>`;
27971+
setConfirmButton('Approve', 'check');
2796827972
$('confirmModal').classList.add('open');
2796927973
}
2797027974

@@ -28611,8 +28615,14 @@ <h3 id="portableTitle"><span data-icon="disc"></span>Portable session</h3>
2861128615
return parts[parts.length - 1] || p;
2861228616
}
2861328617

28614-
function setConfirmButton(label) {
28615-
$('confirmOk').innerHTML = icon('trash', 15) + escapeHtml(label);
28618+
/**
28619+
* The shared dialog's OK, saying what pressing it does. "Move to Trash" is the
28620+
* label of a move to the Trash only: a sheet whose action is something else —
28621+
* a re-encode, emptying the Trash, a purge, a move, an approval — names that
28622+
* action here, with its own icon (review F3.2 of QA third pass).
28623+
*/
28624+
function setConfirmButton(label, iconName = 'trash') {
28625+
$('confirmOk').innerHTML = icon(iconName, 15) + escapeHtml(label);
2861628626
}
2861728627

2861828628
/**
@@ -28621,7 +28631,7 @@ <h3 id="portableTitle"><span data-icon="disc"></span>Portable session</h3>
2862128631
* "Done") hide Cancel and relabel OK "Close", and other dialogs relabel OK
2862228632
* too; closeModal runs this on every close of the dialog, so none of that
2862328633
* outlives the dialog that made it — a "Close" label must never sit on the
28624-
* next dialog's delete (Empty the Trash does not relabel its button).
28634+
* next dialog's OK, whatever that dialog does.
2862528635
*
2862628636
* It also abandons the open-file check still out for the dialog that closed.
2862728637
* Answering after a Cancel, that check relabelled OK "Delete anyway" and armed
@@ -31970,6 +31980,7 @@ <h4>${icon('cart', 16)}Staged — deleted only when you say so</h4>
3197031980
toast('Not moved: ' + e.message, 'error');
3197131981
}
3197231982
};
31983+
setConfirmButton('Move it', 'shield');
3197331984
$('confirmModal').classList.add('open');
3197431985
}
3197531986

@@ -34480,6 +34491,7 @@ <h2><span style="display:inline-flex;">${icon('diff', 13)}</span>${cmpWhenPair(r
3448034491
`<span style="color:var(--text-3)"><b>This is lossy</b> — the picture is compressed again and a little quality is lost permanently. ` +
3448134492
`Each new file is checked (it opens, and it runs the full length) <b>before</b> the original is moved to the Trash. ` +
3448234493
`If a check fails, that file is left exactly as it is. This can take a long time.</span>`;
34494+
setConfirmButton('Re-encode', 'video');
3448334495
onConfirmTrash = () => startEncode(chosen.map(c => c.path));
3448434496
$('confirmModal').classList.add('open');
3448534497
}
@@ -34670,6 +34682,7 @@ <h2><span style="display:inline-flex;">${icon('diff', 13)}</span>${cmpWhenPair(r
3467034682
const name = repo.split(/[\\/]/).pop() || repo;
3467134683
$('confirmTitle').innerHTML = icon('gitBranch', 18) + 'Run git gc?';
3467234684
$('confirmText').innerHTML = `Run <b>git gc --aggressive</b> on <b>${escapeHtml(name)}</b>?<br><span style="color:var(--text-3)">Safe — it compacts the repo without changing any commits. Large repos can take a while.</span>`;
34685+
setConfirmButton('Run git gc', 'gitBranch');
3467334686
onConfirmTrash = () => runGitGcAction(repo);
3467434687
$('confirmModal').classList.add('open');
3467534688
});

‎src/ui/app/035-system-info.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ $('emptyTrashBtn').addEventListener('click', () => {
143143
? `Empty the system Trash?<br><span style="color:var(--text-3)">${escapeHtml(t.incompleteReason || 'TreeMap could not read the Trash, so it cannot say how much this frees.')} This cannot be undone.</span>`
144144
: `Permanently delete <b>${formatCount(t.itemCount)} item${t.itemCount === 1 ? '' : 's'}</b> (${formatBytes(t.totalBytes)})?` +
145145
`<br><span style="color:var(--text-3)">This empties the system Trash and cannot be undone.</span>`;
146+
setConfirmButton('Empty the Trash');
146147
onConfirmTrash = emptyTrashAction;
147148
$('confirmModal').classList.add('open');
148149
});
@@ -193,6 +194,7 @@ $('snapPurgeBtn').addEventListener('click', () => {
193194
const n = state.snapshots && state.snapshots.snapshots ? state.snapshots.snapshots.length : 0;
194195
$('confirmTitle').innerHTML = icon('clock', 18) + 'Purge local snapshots?';
195196
$('confirmText').innerHTML = `Delete <b>${formatCount(n)} local snapshot${n === 1 ? '' : 's'}</b>?<br><span style="color:var(--text-3)">This frees the space they hold. Time Machine will create fresh ones on the next backup.</span>`;
197+
setConfirmButton('Purge snapshots', 'clock');
196198
onConfirmTrash = purgeSnapshotsAction;
197199
$('confirmModal').classList.add('open');
198200
});

‎src/ui/app/130-time-capsule-tab.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ function forgetCapsuleEntry(id) {
269269
`<b>${escapeHtml(entry ? entry.name : 'This item')}</b> was already deleted from your disk — this only removes ` +
270270
`TreeMap’s spare copy${entry ? `, freeing ${formatBytes(entry.sizeBytes)}` : ''}.` +
271271
`<br><span style="color:var(--text-3)">It can’t be restored from here afterwards.</span>`;
272+
setConfirmButton('Forget this copy');
272273
$('confirmModal').classList.add('open');
273274
}
274275

‎src/ui/app/150-autopilot-tab.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ function approveAutopilotRun(runId) {
282282
: `<b>${escapeHtml(policy.name)}</b>'s next run will remove what it matches ${scope}, up to <b>${formatBytes(run.bytesMatched)}</b>, once. ` +
283283
`A later run that matches more than ${formatBytes(policy.requireConfirmationAbove || 0)} asks again.`) +
284284
`<br><span style="color:var(--text-3)">Everything it removes is copied to the Time Capsule first, and a run can be undone from here until the Time Capsule removes its copies.</span>`;
285+
setConfirmButton('Approve', 'check');
285286
$('confirmModal').classList.add('open');
286287
}
287288

‎src/ui/app/155-open-file-guard.js‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,14 @@ function baseName(p) {
252252
return parts[parts.length - 1] || p;
253253
}
254254

255-
function setConfirmButton(label) {
256-
$('confirmOk').innerHTML = icon('trash', 15) + escapeHtml(label);
255+
/**
256+
* The shared dialog's OK, saying what pressing it does. "Move to Trash" is the
257+
* label of a move to the Trash only: a sheet whose action is something else —
258+
* a re-encode, emptying the Trash, a purge, a move, an approval — names that
259+
* action here, with its own icon (review F3.2 of QA third pass).
260+
*/
261+
function setConfirmButton(label, iconName = 'trash') {
262+
$('confirmOk').innerHTML = icon(iconName, 15) + escapeHtml(label);
257263
}
258264

259265
/**
@@ -262,7 +268,7 @@ function setConfirmButton(label) {
262268
* "Done") hide Cancel and relabel OK "Close", and other dialogs relabel OK
263269
* too; closeModal runs this on every close of the dialog, so none of that
264270
* outlives the dialog that made it — a "Close" label must never sit on the
265-
* next dialog's delete (Empty the Trash does not relabel its button).
271+
* next dialog's OK, whatever that dialog does.
266272
*
267273
* It also abandons the open-file check still out for the dialog that closed.
268274
* Answering after a Cancel, that check relabelled OK "Delete anyway" and armed

‎src/ui/app/190-grid-view.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,7 @@ function confirmRelocateSecret(finding) {
776776
toast('Not moved: ' + e.message, 'error');
777777
}
778778
};
779+
setConfirmButton('Move it', 'shield');
779780
$('confirmModal').classList.add('open');
780781
}
781782

‎src/ui/app/220-clean-up-modal.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ function confirmEncode(chosen) {
183183
`<span style="color:var(--text-3)"><b>This is lossy</b> — the picture is compressed again and a little quality is lost permanently. ` +
184184
`Each new file is checked (it opens, and it runs the full length) <b>before</b> the original is moved to the Trash. ` +
185185
`If a check fails, that file is left exactly as it is. This can take a long time.</span>`;
186+
setConfirmButton('Re-encode', 'video');
186187
onConfirmTrash = () => startEncode(chosen.map(c => c.path));
187188
$('confirmModal').classList.add('open');
188189
}
@@ -373,6 +374,7 @@ document.addEventListener('click', (e) => {
373374
const name = repo.split(/[\\/]/).pop() || repo;
374375
$('confirmTitle').innerHTML = icon('gitBranch', 18) + 'Run git gc?';
375376
$('confirmText').innerHTML = `Run <b>git gc --aggressive</b> on <b>${escapeHtml(name)}</b>?<br><span style="color:var(--text-3)">Safe — it compacts the repo without changing any commits. Large repos can take a while.</span>`;
377+
setConfirmButton('Run git gc', 'gitBranch');
376378
onConfirmTrash = () => runGitGcAction(repo);
377379
$('confirmModal').classList.add('open');
378380
});

‎tests/autopilotApprove.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,13 +747,13 @@ test('the approval names the run, and its confirm says the folder, the match and
747747
set innerHTML(v: string) { texts[id] = v; }, get innerHTML() { return texts[id] ?? ''; }, classList: { add: () => undefined },
748748
});
749749
const make = new Function(
750-
'$', 'state', 'api', 'toast', 'icon', 'escapeHtml', 'formatBytes', 'loadAutopilot', 'describeMatch',
750+
'$', 'state', 'api', 'toast', 'icon', 'escapeHtml', 'formatBytes', 'loadAutopilot', 'describeMatch', 'setConfirmButton',
751751
`let onConfirmTrash = null; ${pageSource('approveAutopilotRun')}; return { approve: approveAutopilotRun, confirm: () => onConfirmTrash };`,
752752
);
753753
const page = make(
754754
el, { autopilot: { policies: [POLICY_A, POLICY_B], runs: RUNS } },
755755
async (url: string, opts: { body: string }) => { posted.push({ url, body: JSON.parse(opts.body) }); return {}; },
756-
() => undefined, () => '', (s: string) => s, (n: number) => `${n} B`, () => undefined, () => 'files ending .log/.txt',
756+
() => undefined, () => '', (s: string) => s, (n: number) => `${n} B`, () => undefined, () => 'files ending .log/.txt', () => undefined,
757757
) as { approve: (runId: string) => void; confirm: () => (() => Promise<void>) | null };
758758
page.approve('a-new');
759759
assert.match(texts.confirmText, /\/home\/me\/logs/, texts.confirmText);

‎tests/cleanUpModalHonesty.test.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -647,9 +647,9 @@ test('the sheets that ask before a re-encode or a shader-cache clear say the spa
647647
// the selection summary already said so. The Games view's "Move 2 shader
648648
// caches to the Trash, freeing 1.2 GB" made the same claim.
649649
const encode = makeDom();
650-
runnable(bodyOf('function confirmEncode(chosen) {'), {
650+
await runnable(bodyOf('function confirmEncode(chosen) {'), {
651651
$: encode.$, icon: () => '', formatBytes: (n: number) => `${n / 1e9} GB`,
652-
startEncode: () => {}, onConfirmTrash: null,
652+
startEncode: () => {}, setConfirmButton: () => {}, onConfirmTrash: null,
653653
}, 'chosen')([{ path: '/v/a.mov', estimatedSaving: 4_200_000_000 }]);
654654
const asked = sheetText(encode.els);
655655
assert.doesNotMatch(asked, /\bfree(ing|s|d)?\b/i, `nothing is freed by a move to the Trash: "${asked}"`);
@@ -658,9 +658,9 @@ test('the sheets that ask before a re-encode or a shader-cache clear say the spa
658658
assert.match(asked, /^Re-encode 1 video file to HEVC: .* where the original goes\./, `one video is spoken of as one: "${asked}"`);
659659
// Two videos: the plural half of the same sentence (review F3.3 of QA third pass D08).
660660
const pair = makeDom();
661-
runnable(bodyOf('function confirmEncode(chosen) {'), {
661+
await runnable(bodyOf('function confirmEncode(chosen) {'), {
662662
$: pair.$, icon: () => '', formatBytes: (n: number) => `${n / 1e9} GB`,
663-
startEncode: () => {}, onConfirmTrash: null,
663+
startEncode: () => {}, setConfirmButton: () => {}, onConfirmTrash: null,
664664
}, 'chosen')([{ path: '/v/a.mov', estimatedSaving: 4_200_000_000 }, { path: '/v/b.mov', estimatedSaving: 1_000_000_000 }]);
665665
const askedTwo = sheetText(pair.els);
666666
assert.doesNotMatch(askedTwo, /\bfree(ing|s|d)?\b/i, `nothing is freed by a move to the Trash: "${askedTwo}"`);
@@ -731,8 +731,8 @@ test('the Shrink Video pane\'s selection line says the space comes once the Tras
731731

732732
// And the sheet the button opens says the same thing of the same saving.
733733
const sheet = makeDom();
734-
runnable(bodyOf('function confirmEncode(chosen) {'), {
735-
$: sheet.$, icon: () => '', formatBytes: (n: number) => `${n / 1e9} GB`, startEncode: () => {}, onConfirmTrash: null,
734+
await runnable(bodyOf('function confirmEncode(chosen) {'), {
735+
$: sheet.$, icon: () => '', formatBytes: (n: number) => `${n / 1e9} GB`, startEncode: () => {}, setConfirmButton: () => {}, onConfirmTrash: null,
736736
}, 'chosen')([video('a.mov', 4_200_000_000), video('b.mov', 1_000_000_000)]);
737737
const asked = sheetText(sheet.els);
738738
const when = /5\.2 GB smaller once you empty the Trash/;

0 commit comments

Comments
 (0)