Repository navigation
fix(mobile): revalidate input bindings before fill and clear #1410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
okwasniewski
merged 7 commits into
e2e-inc:main
from
bheemreddy-samsara:fix/mobile-input-freshness
Oct 28, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b10ea45
fix(mobile): revalidate input bindings before fill and clear
bheemreddy181 19735a9
fix(mobile): reject non-input fills before stale retries
bheemreddy181 8d56213
test(mobile): cover recovery from incomplete input preflights
bheemreddy181 c6f49aa
fix(mobile): relocate inputs once without geometry guards
bheemreddy181 2dbda1c
docs(mobile): clarify stale retries and coordinate limits
bheemreddy181 7d71094
refactor(mobile): separate transition waits from input refresh
bheemreddy181 11cffff
Merge remote-tracking branch 'origin/main' into pr-1410
okwasniewski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@e2e-dev/mobile': patch | ||
| --- | ||
|
|
||
| Re-read mobile fill and clear targets before typing, including cached replay. Missing inputs, changed security state, or incomplete captures retry after a fresh observation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
packages/e2e/tests/integration/agent-input-stale.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| /** A stale fill must re-enter secret authorization, on live actions and cached replay alike. */ | ||
|
|
||
| import { describe, expect, it } from 'vitest'; | ||
| import type { StepExecutor } from '../../src/agent/executor.ts'; | ||
| import { EngineError, type SemanticNode } from 'e2e/engine'; | ||
| import { createFakeEngine } from '../helpers/fake-engine.ts'; | ||
| import { nodeIdFor } from '../helpers/fake-loop-model.ts'; | ||
| import { createProject, resultByTitle, runExisting } from '../helpers/run-project.ts'; | ||
|
|
||
| const SUITE = `import { test, credentials, expect } from 'e2e'; | ||
| test('fills the account password', async ({ agent, screen }) => { | ||
| await agent.act('fill the password', { params: { password: credentials.user('member').password } }); | ||
| await expect(screen.getByRole('status')).toBeVisible(); | ||
| }); | ||
| `; | ||
|
|
||
| describe('secret fill stale retry', () => { | ||
| for (const replay of [false, true]) { | ||
| it.each([false, true])(`reauthorizes a changed sink with disabled=%s during ${replay ? 'replay' : 'live execution'}`, async (disabled) => { | ||
| const field: SemanticNode = { | ||
| ref: { id: 'password', revision: '' }, role: 'textbox', name: 'Password', | ||
| testId: 'password', inputPurpose: 'password', states: { secure: true }, | ||
| rect: { x: 40, y: 237, width: 322, height: 49 }, | ||
| }; | ||
| const tree = { ref: { id: 'root', revision: '' }, role: 'document', children: [field] }; | ||
| let stale = false; | ||
| let dispatched = 0; | ||
| const origins: string[] = []; | ||
| const pixels: boolean[] = []; | ||
| const fake = createFakeEngine({ | ||
| tree, | ||
| onStartAttempt: () => { tree.children = [field]; }, | ||
| locate: () => tree.children.filter((node) => node.role === 'status'), | ||
| perform: (_ref, action, operation) => { | ||
| if (action.kind !== 'fill') throw new Error('expected fill'); | ||
| origins.push(operation.origin); | ||
| if (stale) { | ||
| stale = false; | ||
| tree.children = [{ ...field, states: { secure: true, disabled }, rect: { x: 40, y: 126, width: 322, height: 49 } }]; | ||
| throw new EngineError('NODE_STALE', 'input moved before mutation', { retryable: true }); | ||
| } | ||
| dispatched += 1; | ||
| tree.children.push({ ref: { id: 'saved', revision: '' }, role: 'status', name: 'Saved' }); | ||
| }, | ||
| // No pixel payload is needed: this records any request after authorization. | ||
| pixels: () => { pixels.push(true); return undefined; }, | ||
| }); | ||
| const taint: boolean[] = []; | ||
| const executor: StepExecutor = { | ||
| name: 'stale-secret', | ||
| async runStep(context) { | ||
| const observation = await context.observe(); | ||
| try { | ||
| await context.actions.typeSecret({ id: nodeIdFor(observation.text, /textbox "Password"/) }, 'member.password'); | ||
| } finally { | ||
| taint.push(context.pixelsTainted); | ||
| expect((await context.observe({ pixels: true })).pixels).toBeUndefined(); | ||
| } | ||
| return { status: 'passed', summary: 'filled' }; | ||
| }, | ||
| }; | ||
| const project = createProject({ 'tests/input.e2e.ts': SUITE }); | ||
| const options = { | ||
| config: { | ||
| targets: [{ name: 'fake', platform: 'fake', engine: fake.engine }], | ||
| agents: { default: { executor } }, | ||
| credentials: { member: { username: 'example', password: 'private-fixture-value' } }, | ||
| cache: 'read-write' as const, | ||
| }, | ||
| }; | ||
| try { | ||
| if (replay) { | ||
| const recorded = await runExisting(project, options); | ||
| const recording = resultByTitle(recorded, 'fills the account password'); | ||
| expect(recording.status).toBe('passed'); | ||
| expect(recording.attempts[0]?.steps.find((entry) => entry.api === 'agent.act')?.cache).toMatchObject({ write: 'saved' }); | ||
| dispatched = 0; | ||
| origins.length = 0; | ||
| pixels.length = 0; | ||
| taint.length = 0; | ||
| } | ||
| stale = true; | ||
| const outcome = await runExisting(project, options); | ||
| const result = resultByTitle(outcome, 'fills the account password'); | ||
| const step = result.attempts[0]!.steps.find((entry) => entry.api === 'agent.act')!; | ||
| expect(result.status, JSON.stringify(result.attempts[0]?.error)).toBe(disabled ? 'failed' : 'passed'); | ||
| expect(dispatched).toBe(disabled ? 0 : 1); | ||
| expect(origins).toEqual(Array(disabled ? 1 : 2).fill(replay ? 'test' : 'agent')); | ||
| // A denied replay hands off to the executor, whose own denied action also counts. | ||
| expect(step.metrics?.actionSteps).toBe(replay && disabled ? 2 : 1); | ||
| expect(step.events.filter((event) => event.kind === 'observation' && event.name === 'relocate')).toHaveLength(1); | ||
| expect(step.events.filter((event) => event.kind === 'policy' && event.name === 'secret.fill' && event.status === 'passed')).toHaveLength(disabled ? 1 : 2); | ||
| if (disabled) expect(JSON.stringify(step)).toContain('POLICY_DENIED'); | ||
| if (!replay || disabled) expect(taint).toEqual([true]); | ||
| else expect(step.cache).toMatchObject({ mode: 'self-finalized', replayedActions: 1 }); | ||
| expect(pixels).toEqual([]); | ||
| expect(JSON.stringify(outcome)).not.toContain('private-fixture-value'); | ||
| } finally { | ||
| project.cleanup(); | ||
| } | ||
| }, 60_000); | ||
| } | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.