Skip to content

Commit 2401d28

Browse files
committed
refactor(daemon): drop the numeric-token heuristic instead of wrapping it
The previous commit replaced `formatGestureNoEffectWarning`'s "drop numeric-looking positionals" regex with a per-action builder table — but kept the regex as the table's fallback. That is two mechanisms where there was one, and the heuristic this finding exists to remove is still in the file. Only `scroll`, `swipe` and `gesture <subtype> …` reach the warning by default (`isPostGestureStabilizingAction`), and across all three exactly one positional is not part of the gesture's identity: `scroll`'s optional trailing amount. Echoing everything else verbatim is simpler than either version and strictly more truthful than the original, which ate all four coordinates of `swipe <x1> <y1> <x2> <y2>` and reported a contentless bare "swipe". scroll down 0.6 -> "scroll down" scroll up -> "scroll up" swipe 10 20 30 40 -> "swipe 10 20 30 40" (was: "swipe") swipe -> "swipe" gesture swipe left -> "gesture swipe left" gesture fling down 100 200 -> "gesture fling down 100 200" 35 lines of table, dispatch and regex become 4 lines with one named exception. `--postGestureStabilization` can still force an arbitrary action through; echoing its positionals is the honest answer for one warning string, and reconstructing each gesture subtype's layout would fork a grammar that lives in GestureSemanticInput, downstream of the raw positionals this function receives.
1 parent 7a827ae commit 2401d28

1 file changed

Lines changed: 17 additions & 31 deletions

File tree

src/daemon/post-gesture-stabilization.ts

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -242,40 +242,26 @@ export async function capturePostGestureStabilizedResult<T>(params: {
242242
}
243243

244244
/**
245-
* Which positionals actually name the gesture, keyed by the two actions that
246-
* reach this loop by default (`isPostGestureStabilizingAction`) and have a
247-
* single, fixed positional grammar declared elsewhere:
248-
* - `scroll <direction> [amount]` — `src/commands/interaction/interactions.ts`'s
249-
* `scroll` CLI reader (`readScrollDirection`/`optionalCliNumber`). Only the
250-
* direction names the gesture; the amount is a magnitude, not identity.
251-
* - `swipe <x1> <y1> <x2> <y2>` — `swipePayloadFromPositionals`
252-
* (`@agent-device/contracts/interaction`). Swipe carries no semantic label
253-
* at all: every positional IS the gesture, so dropping "numeric-looking"
254-
* ones here previously produced a bare, contentless "swipe".
245+
* Which positionals name the gesture in the warning. Echo them all, with one
246+
* exception: `scroll <direction> [amount]` carries a trailing magnitude that
247+
* is not part of the gesture's identity, so `scroll down 0.6` reads back as
248+
* "scroll down".
255249
*
256-
* `gesture <pan|fling|swipe|pinch|rotate|transform> ...`
257-
* (`src/commands/interaction/index.ts`'s usage grammar) has no single shape —
258-
* each subtype's positional layout differs (e.g. `fling <direction> <x> <y>
259-
* [distance]` vs `pinch <scale> [x] [y]`), and the discriminator lives in
260-
* `GestureSemanticInput`, built downstream of the raw positionals this
261-
* function receives. Duplicating all five shapes here would fork that
262-
* grammar rather than read it, so `gesture` (and any action forced through
263-
* `--postGestureStabilization`) keeps the narrower "drop numeric tokens"
264-
* fallback below.
250+
* Everything else echoes verbatim, which is both simpler and more truthful
251+
* than the "drop numeric-looking tokens" heuristic this replaces. That rule
252+
* ate every positional of `swipe <x1> <y1> <x2> <y2>` — the one action whose
253+
* coordinates ARE its identity — and reported a contentless bare "swipe".
254+
*
255+
* Only `scroll`, `swipe` and `gesture <subtype> …` reach here by default
256+
* (`isPostGestureStabilizingAction`); `--postGestureStabilization` can force
257+
* an arbitrary action through, and echoing its positionals is the honest
258+
* answer for one warning string. Reconstructing each `gesture` subtype's
259+
* layout would fork a grammar that lives in `GestureSemanticInput`, built
260+
* downstream of the raw positionals this function receives.
265261
*/
266-
const GESTURE_DESCRIPTION_BUILDERS: Record<string, (positionals: string[]) => string[]> = {
267-
scroll: (positionals) => (positionals[0] !== undefined ? [positionals[0]] : []),
268-
swipe: (positionals) => positionals,
269-
};
270-
271262
function describeGesturePositionals(action: string, positionals: string[]): string[] {
272-
const builder = GESTURE_DESCRIPTION_BUILDERS[action];
273-
if (builder) return builder(positionals);
274-
return positionals.filter((value) => !isNumericPositional(value));
275-
}
276-
277-
function isNumericPositional(value: string): boolean {
278-
return /^[\d.-]+$/.test(value);
263+
if (action !== 'scroll') return positionals;
264+
return positionals.slice(0, 1);
279265
}
280266

281267
/**

0 commit comments

Comments
 (0)