Skip to content

[NoQA] Dev-only app-state tools over Appduct: get_state, sign_in, complete_onboarding - #103808

Merged
rlinoz merged 23 commits into
Expensify:mainfrom
callstack-internal:kacper-mikolajczak/appduct-login-poc
Nov 10, 2026
Merged

rlinoz merged 23 commits into
Expensify:mainfrom
callstack-internal:kacper-mikolajczak/appduct-login-poc

Conversation

@kacper-mikolajczak

@kacper-mikolajczak kacper-mikolajczak commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Adds three dev-only in-app tools, get_state, sign_in and complete_onboarding, that a test harness calls over Appduct to reach a signed-in, onboarded Home screen without replaying the sign-in and onboarding screens.

Flow: before and after

flowchart TD
    boot(["Dev build boots with an anonymous session"]):::shared
    boot --> uiEmail["Fill Phone or email, press Continue"]:::removed
    uiEmail --> uiJoin["Press Join"]:::removed
    uiJoin --> uiSkip["Skip the work email step"]:::removed
    uiSkip --> uiPurpose["Pick Something else"]:::removed
    uiPurpose --> uiName["Fill first and last name, press Continue"]:::removed
    uiName --> home
    boot --> signIn["sign_in(email)"]:::added
    signIn --> onboard["complete_onboarding(firstName, lastName)"]:::added
    onboard --> home(["Home, onboarding modal closed"]):::shared
    boot -.-> getState["get_state(): read-only, callable at any step"]:::added
    classDef shared fill:#e5e7eb,stroke:#4b5563,color:#111827
    classDef removed fill:#fee2e2,stroke:#b91c1c,color:#7f1d1d
    classDef added fill:#dcfce7,stroke:#15803d,color:#14532d
Loading

Legend: gray = shared, red = UI steps a caller no longer replays (the UI flows under .claude/skills/agent-device/flows/macros/ are unchanged), green = tool calls added here.

Contracts

Every tool returns the same result and never throws:

Field Type Meaning
ok boolean, required true only after the target state is read back inside the app, not when work is dispatched
already boolean, optional The state already held before the call
state object, optional The state read back
reason string, optional Present on every ok: false
Tool Input state on success already: true when ok: false reasons Tool timeout
get_state none booted, signedIn, anonymous, login, accountID, onboardingCompleted (null until loaded), isLoadingApp never none, always ok: true 5 s
sign_in email (required), timeoutMs (default 45000) signedIn, accountID, login signed in as that email missing email; session never loaded; signed in as another login; account already exists and needs the emailed magic code; beginSignIn errors; no session token in time 120 s
complete_onboarding firstName, lastName (required), timeoutMs (default 60000) onboardingCompleted: true, onboardingModalClosed flag already true and nothing queued missing names; preconditions not met in time; Concierge report never loaded; request stuck in the queue; request never left the queue (offline); server reverted the flag 180 s

How the tools act

  • They call the same actions the screens call: beginSignIn, signUpUser, completeOnboarding with CONST.ONBOARDING_CHOICES.LOOKING_AROUND (the "Something else" choice).
  • They read Onyx through connectWithoutView and write nothing directly.
  • complete_onboarding waits for CompleteGuidedSetup to leave the write queue, re-reads the stored flag, then closes the onboarding modal.
  • A queued CompleteGuidedSetup from an earlier call is awaited, never posted twice.

Platforms

Platform Package Release builds
Web @appduct/web ^0.16.0 Resolves to an inert entry outside the development condition
Android, iOS @appduct/react-native ^0.16.0 Registration returns early when __DEV__ is false; the native module is debug-only

Both packages ship ESM only, so Jest uses mocks under __mocks__/@appduct/.

Improvement landscape

A typed, dev-only tool layer turns setup into function calls that run the app's own actions, so UI driving is left for the screen under test.

Tool or use What a test does today Cost it removes Status
sign_in: composite session creation Fill email, Continue, Join through selector replays Per-platform selectors that drift; success is read back, not inferred from a screen Shipped
complete_onboarding: composite onboarding Skip work email, pick a purpose, type names, Continue, close the modal Five UI steps; waits on the request queue instead of a screen Shipped
get_state: state assertion Screenshot or snapshot to judge signed-in or onboarded Visual inference; tells an unloaded flag (null) from false Shipped
Typed reason on failure Read a selector-divergence error and a screenshot Triage: the reason names the unmet condition Shipped
create_workspace over createWorkspace Walk the workspace creation screens Multi-screen setup before every workspace check Possible
invite_members over addMembersToWorkspace Run the invite flow per member Seeding a multi-member workspace Possible
Expense seeding over requestMoney / trackExpense Enter amount, merchant and receipt on screen Per-test data entry and keypad input flake Possible
sign_out over signOut, then sign_in as a second new account Sign out through the menu and repeat sign-in Acting as another user (submitter, approver); returning accounts still need the emailed magic code Possible
reset_state over clearOnyxAndResetApp Reinstall the app or clear its data Reinstall time between checks Possible
navigate over Navigation.navigate Tap through screens to reach the one under test Navigation steps unrelated to the check Possible
wait_for_writes over waitForWrites and the persisted queue Fixed sleeps or polling the screen Timing flake; complete_onboarding already does this internally Possible
Read-only Onyx assertions by key Compare a value in a screenshot Visual checks for data that lives in Onyx Possible

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/699321

Tests

Unit test file Cases
tests/unit/appductSignInToolTest.ts Registers all three tools; waits for boot and signs up a new account; already for a matching session; refuses another login; reports the magic-code wall; surfaces beginSignIn errors; times out with the account snapshot
tests/unit/appductGetStateToolTest.ts Anonymous boot; signed-in identity; unfinished onboarding reported as false
tests/unit/appductCompleteOnboardingToolTest.ts Completes with the "looking around" choice after the queue drains; already without calling the action; waits for a queued request instead of posting twice; fails on a reverted flag, a stuck queue, unmet preconditions, and a missing Concierge report
Internal CI harness run (single runs, not a benchmark) Result
Web, tools from this branch sign_in returned ok: true with the requested login in 1.7 s; complete_onboarding returned ok: true, onboardingModalClosed: true in 2.9 s; ready state about 11 s after start
Web, UI flows from main (same hour) Signed in about 22 s after start
Android, UI flows from main (same hour) Failed: the sign-in replay diverged at the Phone or email fill step
Android, tools from this branch Not run yet: no development APK exists for this branch; needs an Android build of the current head
Not yet verified Note
Tools on a native development build The ad-hoc Android build of an earlier commit compiled; tool calls on a development APK are pending
Server-side dedupe of a repeated onboarding completion The tool avoids second calls instead of relying on it
  • Verify that no errors appear in the JS console

Offline tests

Network state Result
Offline during complete_onboarding ok: false, reason CompleteGuidedSetup never left the queue (offline? the server never saw it); covered by the stuck-queue unit test

QA Steps

None: the tools register only in development builds (title carries [NoQA]).

  • 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 verified any copy / text that was added to the app 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 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 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.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • 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

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

The pre-start replays sign-in.ad through agent-device; its snapshot ref goes
stale when the tree re-renders before the press, so recent web prestart runs
fail with 'Unknown ref' on step 1. The sign_in tool performs the same
BeginSignIn/SignUpUser actions BaseLoginForm performs and waits for the
session token, with no snapshot in the path.

Dev builds only: @appduct/web resolves to its inert entry outside the
development export condition. accountExists=true refuses rather than faking
success (emailed magic code is a CI physical blocker); the caller mints a
fresh alias instead.
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ This PR is possibly changing native code and/or updating libraries, it may cause problems with HybridApp. Please check if any patch updates are required in the HybridApp repo and run an AdHoc build to verify that HybridApp will not break. Ask Contributor Plus for help if you are not sure how to handle this. ⚠️

@codecov

codecov Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/setup/appductTools/appductState.ts 100.00% <100.00%> (ø)
src/setup/index.ts 100.00% <100.00%> (ø)
src/setup/appductTools/index.ts 85.71% <85.71%> (ø)
src/setup/appductTools/index.web.ts 83.33% <83.33%> (ø)
src/setup/appductTools/tools.ts 95.29% <95.29%> (ø)
... and 915 files with indirect coverage changes

- Onyx.connect -> connectWithoutView (rulesdir/no-onyx-connect; registration
  has no view, same form as setup/addUtilsToWindow.ts).
- Test payloads used strings that drift from the real types:
  AUTH_TOKEN_TYPES.ANONYMOUS is 'anonymousAccount', AUTO_AUTH_STATE has no
  'signedIn' member, OnyxCommon.Errors values are message strings. Tests now
  read the constants themselves so the anonymous-boot regression cannot
  regress to a string that merely looks right.
- cspell: appduct + prestart.

Found via PR Expensify#103808 CI: typecheck, ESLint, spellcheck all failed on these.
The native entry needs the RN SDK for tool registration and the /auto deep-link
install. 0.16.0 pins @appduct/web to the same version, so the PoC's ^0.14 range
is raised to match instead of carrying two SDK majors.
Tool logic moves to platform-neutral modules registered through a registerTool
parameter: index.web.ts passes @appduct/web's, index.ts passes
@appduct/react-native's (guarded on __DEV__, /auto imported lazily so the
deep-link install is not bundled in release). prestart_status becomes
get_state; sign_in and get_state return the shared {ok, already, state, reason}
envelope; complete_onboarding added per the looking-around path in research 03.

complete_onboarding guarantees the stored flag, not the dispatch: it waits for
the sequential queue to drain, fails when CompleteGuidedSetup never left the
queue or the flag reverted, never posts a second request while one is queued,
and runs the UI's post-onboarding navigation so the modal closes.

Jest: @Appduct ships ESM only, so the transform allowlist gains @Appduct.
Handlers read input defensively instead of asserting the shape, so a malformed
call returns ok:false with a reason. Test files follow the house ordering
(imports, then jest.mock factories), drop await Onyx.init (init is sync), and
reuse real isAnonymousUser through a typed requireActual.
@kacper-mikolajczak kacper-mikolajczak changed the title [NoQA] Add appduct sign_in tool for the CI web pre-start (PoC) [NoQA] Dev-only app-state tools over Appduct: get_state, sign_in, complete_onboarding Oct 25, 2026
navigateAfterOnboardingWithMicrotaskQueue gained an isAnonymousUser
parameter before onboardingPolicyID. Pass it from the tool, and mock
@libs/API without requireActual in the complete-onboarding test, which now
hits an import cycle through the real module.
…rminology checks

npm test runs Jest with --experimental-vm-modules, where requiring the
type:module @Appduct packages fails for every suite that imports the app
setup. Add root mocks for @appduct/react-native, its /auto entry and
@appduct/web, and drop the transform allowlist entry that could not help.

Also stop exporting the tool types nothing imports (knip) and rename a test
title that tripped the validateCode terminology check.
@github-actions

Copy link
Copy Markdown
Contributor

🚧 rlinoz has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

This comment has been minimized.

One TOOL_RESULT_SCHEMA replaces three copies of the output schema, currentAccountID() and
sessionLogin() replace the repeated session/credentials lookups, and complete_onboarding's
already-completed path shares the exit with the main path.
@kacper-mikolajczak

Copy link
Copy Markdown
Contributor Author

@kacper-mikolajczak
kacper-mikolajczak marked this pull request as ready for review November 3, 2026 12:56
@kacper-mikolajczak
kacper-mikolajczak requested review from a team as code owners November 3, 2026 12:56
@mountiny
mountiny removed their request for review November 6, 2026 01:05
tgolen
tgolen previously approved these changes Nov 6, 2026

@tgolen tgolen 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.

Looks, good. Thanks for moving those!

luacmartins
luacmartins previously approved these changes Nov 6, 2026
Comment thread package.json Resolved
Comment thread src/setup/appductTools/tools.ts Resolved
Comment thread src/setup/appductTools/tools.ts Resolved
@chuckdries
chuckdries removed their request for review November 9, 2026 18:21
@appduct/react-native links only into a configuration named Debug, while
standalone iOS builds use DebugDevelopment, so the tools never registered.
The unchecked wait fell through to signUpUser while the sign-in attempt could
still be pending, then reported a misleading missing-session reason.
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

This PR adds a new Onyx.connectWithoutView call, so I've requested a review from the Onyx performance reviewers (@tgolen, @mountiny, @luacmartins, @chuckdries) — a review from any one of them is enough. Please add a link in your PR description to the Slack discussion where the @frontend-performance team approved using connectWithoutView here.

@kacper-mikolajczak

Copy link
Copy Markdown
Contributor Author

Thank you for the review @rlinoz ❤️ Addressed ✅

@chuckdries
chuckdries removed their request for review November 9, 2026 21:23

@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.

Cautiously approving the new approach. Lets make sure to keep an eye on the success rate of tests and follow up with any regressions.

@mountiny
mountiny removed their request for review November 10, 2026 04:13

@rlinoz rlinoz 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.

Thank you!

@rlinoz

rlinoz commented Nov 10, 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 3cc7ba1 into Expensify:main Nov 10, 2026
64 of 97 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 rlinoz has triggered a test Expensify/App build. You can view the workflow run here.

@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.

@github-actions

Copy link
Copy Markdown
Contributor

@kacper-mikolajczak

Copy link
Copy Markdown
Contributor Author

Thanks @rlinoz @Julesssss! I will share a health check after collecting meaningful run sample to make validate we are doing ok.

@kacper-mikolajczak

Copy link
Copy Markdown
Contributor Author

Heads-up: I am aware pre-start is failing and working on fixing this right now 🔜

@OSBotify

Copy link
Copy Markdown
Contributor

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

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed — this PR adds development-only test automation tools, without changing customer-facing features, workflows, or existing article accuracy.


view run

@MelvinBot

Copy link
Copy Markdown
Contributor

No FullStory changes needed — this PR adds development-only test automation tools, with no new user-facing elements, screens, user-property values, or sensitive-content displays.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.5.36-0 🚀

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

Bundle Size Analysis (Sentry):

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants