Skip to content

[No QA] Settle agent-device drive actions and preserve sign-in replay diagnostics - #98094

Merged
rlinoz merged 3 commits into
Expensify:mainfrom
kacper-mikolajczak:claude-agent-device-settle-drive-lib
Aug 11, 2026
Merged

[No QA] Settle agent-device drive actions and preserve sign-in replay diagnostics#98094
rlinoz merged 3 commits into
Expensify:mainfrom
kacper-mikolajczak:claude-agent-device-settle-drive-lib

Conversation

@kacper-mikolajczak

@kacper-mikolajczak kacper-mikolajczak commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Three related fixes to .claude/skills/agent-device/flows/lib/sign-in-drive.sh. No production App code is touched — this is agent tooling under .claude/.

1. Settle drive actions instead of sleeping blindly. press_label, the onboarding name fill, and the sign-in fallback fill/press now pass --settle, so agent-device waits for the UI to go quiet (500ms quiet window, 10s deadline) and returns the settled diff. Previously the drive loop pressed, slept a fixed 1s, then snapshotted — which samples the accessibility tree mid-transition. The observed symptom is the onboarding ladder logging onboarding clear — nothing actionable several times in a row while the next screen is still rendering, then giving up on a screen it could have handled.

2. Keep drive-command output off stdout. This library documents that it never emits protocol lines, because callers may parse its stdout as a machine protocol. agent-device was already breaking that from inside press_label and the name fill — it echoes Tapped (x, y) and Filled N chars to stdout — and --settle makes it much worse by returning a full settled diff there. Every internal drive command now routes stdout to artifacts/melvin-drive-<session>.log.

3. Keep replay's diagnosis. agent-device replay previously had neither stream redirected, so its failure output was discarded into the caller's stdout. On failure it names the diverging step, the exact selector it could not match, and a repair hint. That now lands in artifacts/melvin-signin-replay-<session>.log, and the last lines are surfaced through human(). Same treatment for the fill/press fallback path. Previously a failed sign-in reported only a generic "direct fill failed" with no way to tell a selector drift from a timeout.

The same three fixes land in parallel in the Melvin staging mirror of this library (Expensify/melvin#333), which this file's header already describes; they should stay in sync until that mirror is retired.

Artifact paths use the existing ${GITHUB_WORKSPACE:-/tmp}/artifacts convention already in this file, so the standalone (non-CI) mode writes under /tmp and still works.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/667790
PROPOSAL:

Tests

  1. bash -n .claude/skills/agent-device/flows/lib/sign-in-drive.sh — parses clean.
  2. shellcheck -S warning .claude/skills/agent-device/flows/lib/sign-in-drive.sh — no findings.
  3. Run the library with no args — prints usage to stderr and exits 2 without touching any device, confirming stdout stays empty.
  4. Start the web dev server, agent-device open "https://dev.new.expensify.com:8082/" --platform web --session drive-test, then run .claude/skills/agent-device/flows/lib/sign-in-drive.sh --platform web --session drive-test --email <fresh test alias> — verify it signs in and exits 0, and that ${GITHUB_WORKSPACE:-/tmp}/artifacts/melvin-drive-drive-test.log now contains the Tapped / Filled / settled-diff output that previously went to stdout.
  5. Point the run at a deliberately stale macro so agent-device replay fails — verify melvin-signin-replay-drive-test.log contains a real REPLAY_DIVERGENCE naming the failed step and selector, and that the same detail is echoed through human() rather than the old generic message.
  • Verify that no errors appear in the JS console

Offline tests

N/A — agent tooling, not reachable from the app UI and not network-state dependent.

QA Steps

N/A — [No QA], no user-facing surface.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

N/A — no UI surface. This changes shell tooling under .claude/.

press_label, the onboarding name fill, and the sign-in fallback now pass
--settle, so agent-device waits for the UI to go quiet before returning instead
of the drive loop sleeping blindly and snapshotting a half-rendered transition.

--settle returns the settled diff on stdout, and this library must not write
there — callers may parse stdout as a machine protocol. agent-device already
leaked action results that way ("Tapped (x, y)", "Filled N chars"), so every
internal drive command now routes stdout to an artifacts drive log.

Replay keeps its stderr in a dedicated log: on failure it names the diverging
step, the selector it could not match, and a repair hint, which the previous
generic fallback message discarded.
@kacper-mikolajczak

Copy link
Copy Markdown
Contributor Author

It's a counterpart PR for https://github.com/Expensify/melvin/pull/333 that needs to be merged after original improvement.

CC @Julesssss @rlinoz

@kacper-mikolajczak
kacper-mikolajczak marked this pull request as ready for review August 9, 2026 13:56
@kacper-mikolajczak
kacper-mikolajczak requested a review from a team as a code owner August 9, 2026 13:56
@melvin-bot
melvin-bot Bot requested a review from linhvovan29546 August 9, 2026 13:56
@melvin-bot

melvin-bot Bot commented Aug 9, 2026

Copy link
Copy Markdown

@linhvovan29546 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot removed the request for review from a team August 9, 2026 13:56
wait_for_login_field waited on SEL_LOGIN_FIELD, which carries no editable
predicate, so it returned as soon as the input had rendered. sign-in.ad then
fills that field requiring editable=true, so the replay could start against an
element that existed but was not yet interactive and fail at step 1:

  Replay failed at step 1 (fill "id=\"username\" || role=\"textfield\" label=\"Phone or email\" editable=true || ..."): Selector did not match

The selector is not stale - id="username" is still on the login form at
src/pages/signin/LoginForm/BaseLoginForm.tsx:256, and the direct-fill fallback
matched the same element moments later using a selector without the predicate.
The wait and the fill were testing different conditions.

The wait now mirrors the macro's selector. SEL_LOGIN_FIELD keeps its existing
form for the fallback fill, which does not require the element to report
editable.
@rlinoz
rlinoz requested review from Julesssss and rlinoz and removed request for linhvovan29546 August 10, 2026 12:33
Julesssss
Julesssss previously approved these changes Aug 10, 2026

@Julesssss Julesssss left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verbose comments could be simplified, but NAB

@kacper-mikolajczak

Copy link
Copy Markdown
Contributor Author

@Julesssss Done ✅ Ready for merge.

@rlinoz

rlinoz commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari

@rlinoz
rlinoz merged commit cb2e17a into Expensify:main Aug 11, 2026
14 of 16 checks passed
@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/rlinoz in version: 9.4.53-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants