Address review: re-check a failed resolution before declining an agent target

A page's element can be momentarily absent (a route still rendering, an
HMR commit mid-swap), so a failed resolution is not that page's final
word. The overlay now re-checks at 300, 700, and 1500 ms, claims the moment
the element mounts (the server already drops the stale report on an
eligible claim), and reports only the last miss. A genuine no_match now
takes about two seconds instead of tens of milliseconds, well inside the
server's hold.

Also normalizes a path separator in the new hook unit test, which failed
on rust-windows because the audit's file path carries backslashes there.

AI-assisted: implemented and tested with Claude Code under maintainer
direction.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Abdul Wahab
2026-09-15 05:45:49 +05:00
committed by Abdul Wahab
co-authored by Claude Fable 5
parent 25263adc51
commit 46f1dd6b36
3 changed files with 35 additions and 6 deletions
+9 -4
View File
@@ -866,8 +866,13 @@ describe('live-browser source contracts', () => {
);
assert.match(
SOURCE,
/function declineAgentTargetUnresolvable\(msg\) \{[\s\S]{0,200}?resolveAgentTargetElement\(msg\)[\s\S]{0,200}?reason: 'no_match', result: probe\.error/,
'the decline carries the resolution verdict for the server to return when no page can serve',
/function declineAgentTargetUnresolvable\(msg\) \{[\s\S]{0,200}?resolveAgentTargetElement\(msg\)[\s\S]{0,120}?retryAgentTargetResolution\(msg, 0, probe\.error\)/,
'a failed resolution is re-checked before it becomes this page\'s word',
);
assert.match(
SOURCE,
/function retryAgentTargetResolution\(msg, attempt, lastError\) \{[\s\S]{0,200}?reason: 'no_match', result: lastError[\s\S]{0,600}?if \(!probe\.error\) \{ claimAndActOnAgentTarget\(msg\); return; \}/,
'the page claims the moment the element mounts, and reports only the last miss',
);
// The per-origin session cache must not let a tab on another page of
// the app resume this page's session (it would sit in GENERATING for a
@@ -885,8 +890,8 @@ describe('live-browser source contracts', () => {
);
assert.equal(
(SOURCE.match(/claimAndActOnAgentTarget\(msg\)/g) || []).length,
4,
'the first claim and the busy-to-idle re-claim must share the rescue path (definition, two call sites, the retry)',
5,
'the first claim, the busy-to-idle re-claim, and the resolution re-check must share the rescue path (definition, three call sites, the retry)',
);
});