Skip to content

Commit a91a366

Browse files
committed
fix(selectors): quote the recovery selector only when needed and bar it from ref targets
The zero-area recovery quotes its selector with shellQuoteIfNeeded, as the moving-target gate does, so a bare selector stays bare. The ref arm of the failure type forbids shellQuotedSelector, so a ref target cannot be handed the selector form of the hint.
1 parent 2addea4 commit a91a366

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

‎packages/command-runtime/src/commands/interaction/runtime/resolution.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { shellQuote } from '@agent-device/kernel/device-shell';
1+
import { shellQuoteIfNeeded } from '@agent-device/kernel/device-shell';
22
import { AppError } from '@agent-device/kernel/errors';
33
import type { AgentDeviceRuntime, CommandContext } from '@agent-device/contracts/runtime-contract';
44
import {
@@ -163,7 +163,7 @@ async function resolveSelectorInteractionTarget(
163163
invalidMessage: `Selector ${resolved.selector} resolved to invalid bounds`,
164164
blockedTargetLabel: `Selector ${selectorExpression}`,
165165
blockedTargetDetails: { selector: selectorExpression },
166-
shellQuotedSelector: shellQuote(selectorExpression),
166+
shellQuotedSelector: shellQuoteIfNeeded(selectorExpression),
167167
}),
168168
});
169169
return {

‎packages/selectors/src/node-touch-point.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export function resolveNodeTouchPoint(
165165
node: SnapshotNode,
166166
nodes: SnapshotState['nodes'],
167167
failure: { invalidMessage: string; blockedTargetLabel: string } & (
168-
| { blockedTargetDetails: { ref: string } }
168+
| { blockedTargetDetails: { ref: string }; shellQuotedSelector?: never }
169169
/**
170170
* The recovery names a command that takes the selector, so the caller hands it over as one
171171
* shell word: this entry's eager closure stops short of the kernel's `shellQuote`.
@@ -185,11 +185,7 @@ export function resolveNodeTouchPoint(
185185
new AppError('COMMAND_FAILED', failure.invalidMessage, {
186186
reason: INTERACTION_ERROR_REASONS.targetBoundsInvalid,
187187
...bareTargetDetails(failure.blockedTargetDetails),
188-
...scrollContainerRecovery(
189-
node,
190-
nodes,
191-
'shellQuotedSelector' in failure ? failure.shellQuotedSelector : undefined,
192-
),
188+
...scrollContainerRecovery(node, nodes, failure.shellQuotedSelector),
193189
}),
194190
'no',
195191
);

0 commit comments

Comments
 (0)