mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-21 10:36:27 +03:00
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:
committed by
Abdul Wahab
co-authored by
Claude Fable 5
parent
25263adc51
commit
46f1dd6b36
@@ -7291,13 +7291,36 @@
|
||||
// another page has. The server prefers a busy report (a tab that could
|
||||
// serve later) over these, and returns the resolution verdict only when
|
||||
// no connected page can serve.
|
||||
//
|
||||
// An element can be momentarily absent (a route still rendering, an HMR
|
||||
// commit mid-swap), so a failed resolution is not this page's final word:
|
||||
// it is re-checked a few times over about two seconds, claiming the
|
||||
// moment the element mounts, and only the last miss is reported. The
|
||||
// server's timeout still bounds the whole exchange.
|
||||
const AGENT_TARGET_RESOLVE_RETRY_MS = [300, 700, 1500];
|
||||
|
||||
function declineAgentTargetUnresolvable(msg) {
|
||||
const probe = resolveAgentTargetElement(msg);
|
||||
if (!probe.error) return false;
|
||||
claimAgentTarget(msg.targetId, { eligible: false, state, reason: 'no_match', result: probe.error });
|
||||
retryAgentTargetResolution(msg, 0, probe.error);
|
||||
return true;
|
||||
}
|
||||
|
||||
function retryAgentTargetResolution(msg, attempt, lastError) {
|
||||
if (attempt >= AGENT_TARGET_RESOLVE_RETRY_MS.length) {
|
||||
claimAgentTarget(msg.targetId, { eligible: false, state, reason: 'no_match', result: lastError });
|
||||
return;
|
||||
}
|
||||
setTimeout(() => {
|
||||
if (agentTargetOverlayGone()) return;
|
||||
const busy = agentTargetBusyReason();
|
||||
if (busy) { declineAgentTargetBusy(msg, busy); return; }
|
||||
const probe = resolveAgentTargetElement(msg);
|
||||
if (!probe.error) { claimAndActOnAgentTarget(msg); return; }
|
||||
retryAgentTargetResolution(msg, attempt + 1, probe.error);
|
||||
}, AGENT_TARGET_RESOLVE_RETRY_MS[attempt]);
|
||||
}
|
||||
|
||||
function handleAgentTarget(msg) {
|
||||
if (!msg || typeof msg.targetId !== 'string') return;
|
||||
if (agentTargetsSeen.includes(msg.targetId)) return;
|
||||
|
||||
Reference in New Issue
Block a user