Skip to content

Commit 9883bec

Browse files
mchwangclaude
andcommitted
Move focus off Merge PR and its blockers button when a reload hides them, and test each way (#194 review round 19)
Reads the focused control before hiding it, since hiding blurs it at once. Also drops the redundant first save of the waiting checks and widens DESIGN.md's step-bar log entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent dc6e6df commit 9883bec

4 files changed

Lines changed: 30 additions & 4 deletions

File tree

‎DESIGN.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,4 +262,4 @@ There are no shadows and no glows. Depth comes from the surface brightness steps
262262
| 2026-10-21 | Two progress marks for the merge step list: ○ "Waiting" in `neutral-status` and ● "Running" in `text` | Steps that have not started or are under way are not outcomes, so they take no outcome color. Approved by the user (PR #194) |
263263
| 2026-10-21 | The not-applicable mark also reads "Skipped" for a merge step that was not needed | Same meaning as N/A, worded for a step. Part of the step list the user approved (PR #194) |
264264
| 2026-10-21 | The warning mark also reads "Stopped" (a cancelled merge step) and "Unknown" (GitHub's merge outcome not known) | Both mean "look at this, it did not finish normally". Approved by the user (PR #194) |
265-
| 2026-10-21 | While a merge job runs, a step bar sits between the review strip and the panes | It shows the merge step list and Cancel merge without replacing the review strip's merge control. Approved by the user (PR #194) |
265+
| 2026-10-21 | While a merge job runs, and after it ends until the review reloads, a step bar sits between the review strip and the panes | It shows the merge step list and Cancel merge without replacing the review strip's merge control. Approved by the user (PR #194) |

‎runner/merge-job.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,9 @@ export class MergeJobCoordinator {
354354
return { kind: 'blocked', reason: `Required checks passed only after the ${Math.round(this.checkWaitMs / 60_000)}-minute limit.`, next: 'Retry merge.' };
355355
}
356356
if (verdict.kind !== 'wait') return verdict;
357-
// The first inspection's checks are saved, then only a change, so an unchanged inspection makes no new revision and
358-
// the page's poll backs off.
359-
if (JSON.stringify(verdict.checks) !== JSON.stringify(waiting) || !waited)
357+
// Saved only when they change (the job starts, and the merging step leaves it, with none), so an unchanged inspection
358+
// makes no new revision and the page's poll backs off.
359+
if (JSON.stringify(verdict.checks) !== JSON.stringify(waiting))
360360
this.settle(() => store.updateMergeJob(identity, job.id, { checks: verdict.checks }));
361361
waiting = verdict.checks; waited = true;
362362
const remaining = until - performance.now();

‎test/browser/review.spec.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,28 @@ for (const answer of ['ended','newer'] as const) test(`polls again within second
10171017
await expect(page.locator('#banner')).toHaveText('Preparing the merge: refresh, rebase, push and command checks.');
10181018
}
10191019
});
1020+
for (const control of ['merge','merge-details'] as const) for (const reload of ['unavailable','failed'] as const) test(`moves focus off ${control==='merge'?'Merge PR':'the blockers button'} to Refresh when a reload ${reload==='failed'?'fails':'makes merging unavailable'} (D16)`,async({page})=>{
1021+
const config={...app.service.config,demo:false};await app.close();removeDemoOutOfScope(config);
1022+
const gateway:MergeGateway={inspect:async()=>{const snapshot=(await app.service.load()).snapshot;return {base:snapshot.base,head:snapshot.head,pullRequestState:'OPEN',mergeable:'MERGEABLE',rulesKnown:true,atomicBaseGuard:true,mergeQueue:false,requiredChecks:[],alreadyFixed:'clear',pullRequest:7,draft:false};},merge:async()=>{throw new Error('The browser test answers every merge request itself.');}};
1023+
app=await startServer(config,0,undefined,gateway);
1024+
let view=await app.service.load();for(const segment of view.segments.filter(value=>value.row==='Unplanned'||value.row==='Ambiguous'))view=await app.service.act({action:'accept',key:segment.key,token:view.token});for(const item of view.items)view=await app.service.act({action:'approve',item:item.id,confirmNoChange:item.count===0,token:view.token});
1025+
let reloaded=false;
1026+
await page.route('**/api/review',async route=>{
1027+
if(reloaded&&reload==='failed'){await route.fulfill({status:500,contentType:'application/json',body:JSON.stringify({error:'Could not read this branch\'s history.'})});return;}
1028+
const response=await route.fetch(),body=await response.json();
1029+
body.merge=reloaded?{...body.merge,available:false}:runnerMerge(body.merge,{ready:true,action:'merge',job:null,blockers:[...body.merge.blockers,...jobResolvedBlockers]});
1030+
await route.fulfill({response,json:body});});
1031+
await page.goto(app.url);
1032+
await expect(page.locator(`#${control}`)).toBeVisible({timeout:10_000});
1033+
await page.locator(`#${control}`).focus();
1034+
reloaded=true;
1035+
const answered=page.waitForResponse(response=>response.url().endsWith('/api/review'));
1036+
// A synthetic click on the Review link reloads the review without moving focus.
1037+
await page.locator('#review-link').dispatchEvent('click');
1038+
await answered;
1039+
await expect(page.locator(`#${control}`)).toBeHidden();
1040+
await expect(page.locator('#reload')).toBeFocused();
1041+
});
10201042
for (const reload of ['unavailable','failed','ended'] as const) test(`moves focus off Cancel when a reload ${{failed:'fails',unavailable:'hides the merge control',ended:'shows the job ended'}[reload]} (D16)`,async({page})=>{
10211043
const config={...app.service.config,demo:false};await app.close();removeDemoOutOfScope(config);
10221044
const gateway:MergeGateway={inspect:async()=>{const snapshot=(await app.service.load()).snapshot;return {base:snapshot.base,head:snapshot.head,pullRequestState:'OPEN',mergeable:'MERGEABLE',rulesKnown:true,atomicBaseGuard:true,mergeQueue:false,requiredChecks:[],alreadyFixed:'clear',pullRequest:7,draft:false};},merge:async()=>{throw new Error('The browser test answers every merge request itself.');}};

‎web/public/app.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,12 @@ async function refresh() {
178178
}
179179
function renderMerge() {
180180
const merge = data?.merge;
181+
// Read before hiding: hiding the focused control blurs it at once. A reload that hides the focused merge control (or its
182+
// blockers button) moves focus to what is still shown (AGENTS.md).
183+
const focused = document.activeElement;
181184
$("merge").hidden = !merge?.available;
182185
$("merge-details").hidden = !merge?.available || (!merge.blockers.length && !merge.queue);
186+
if ((focused === $("merge") || focused === $("merge-details")) && focused.hidden) ($("merge").hidden ? $("reload") : $("merge")).focus();
183187
renderMergeSteps();
184188
if (!merge?.available) return;
185189
// Once the attempt this retained key started has ended, a retry is a new action and needs a new key.

0 commit comments

Comments
 (0)