App icon indicating copy to clipboard operation
App copied to clipboard

[$175] Android - Rules - Create agent and Save buttons are hidden behind the keyboard

Open applause-bot[bot] opened this issue 6 days ago • 15 comments

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.5.54-0 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://github.com/Expensify/App/pull/106203 Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: Samsung Galaxy S21/Android 15 App Component: Other

Action Performed:

  1. Launch Expensify app
  2. Log in with valid credentials
  3. Go to Settings > Agents > New agent > Build custom agent.
  4. Tap the instructions box.
  5. Return to Settings > Agents > In the agent, tap Copilot into account.
  6. Go to Settings > Profile > AI prompt > Edit prompt.
  7. Tap the prompt.

Expected Result:

The form slides up smoothly when the keyboard opens, without jumping. The Create agent and Save buttons remain visible above the keyboard.

Actual Result:

The keyboard hides the Create agent and Save buttons.

Workaround:

Unknown

Platforms:

  • [x] Android: App
  • [ ] Android: mWeb Chrome
  • [ ] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [ ] Windows: Chrome
  • [ ] MacOS: Chrome Safari

Screenshots/Videos

https://github.com/user-attachments/assets/8c278be1-d8a6-4a34-ac41-f1e8184f6567

View all open jobs on GitHub

Applause Internal Information Exported by: Svetlana Lazutkina Bug ID: 7324321

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @jasperhuangg

applause-bot[bot] avatar Nov 25 '26 18:11 applause-bot[bot]

While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/84a7d0a147932ff2302a5e45633ea3afa82ee35aae0f4a19acbc55ef1755c77b

applause-bot[bot] avatar Nov 25 '26 18:11 applause-bot[bot]

Triggered auto assignment to Contributor-plus team member for initial proposal review - @eVoloshchak (External)

Job added to Upwork: https://www.upwork.com/jobs/~022125659344538711213

🤖 Web test steps verification results: ⚠️ partial

Web was signed in, but Agents was unavailable, blocking both editor flows. Browser testing cannot verify Android-native keyboard overlap.

Account Profile screen without an Agents entry
Step Status
Launch Expensify webHome displayed.
✅
Sign inExisting session was authenticated; login itself was not exercised.
✅
Open Build custom agentBlocked: no Agents entry appeared.
Account Profile screen without an Agents entry
❌
Focus instructions; check Create agentBlocked: editor inaccessible.
❌
Copilot into an agent accountBlocked: Agents unavailable.
❌
Open Profile AI prompt editorBlocked: agent account inaccessible.
❌
Focus prompt; check SaveBlocked: editor inaccessible. Android keyboard behavior remains unverified.
❌

Proposal

What is the root cause of that problem?

Likely cause — medium confidence, code evidence only: Android does not execute the explicit scroll request used by these instruction editors. Their buttons appear after the input within scrollable content, so revealing the focused input does not necessarily reveal Create agent or Save.

Supporting code and alternative explanations

Challenge to the hypothesis: This explains a button remaining below the visible viewport, but does not establish whether the reported device instead fails to resize correctly. Native measurements of keyboard top, viewport height, scroll offset, and button bounds are needed to distinguish those cases.

The no-op predates Scroll focused form inputs together with the keyboard on native; being found during that PR’s QA does not establish that PR introduced the bug.

What changes do you think we should make in order to solve the problem?

First confirm the native layout behavior. If the viewport resizes correctly, add Android keyboard-driven scrolling that reveals the action button—not merely the input’s top edge.

Cover both the create-agent form and Profile’s inline Save; changing form-footer placement alone would miss Profile. Verify short/long prompts and keyboard dismissal/reopening before treating this as a confirmed solution. No code changes were made.

What alternative solutions did you explore? (Optional)

A global keyboard-avoidance change is not currently justified. If native measurements show failed resizing rather than insufficient scrolling, the proposed direction must be revised.

Related issues: New rule keyboard jump and Describe Rule obscured after dismissing the keyboard concern nearby keyboard behavior, but are not confirmed duplicates.


Next Steps for Contributor+ team: Native verification is required before accepting an implementation. To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/108013) to create a draft PR. To refine: @MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.


view run · no recording available

MelvinBot avatar Nov 25 '26 18:11 MelvinBot

Proposal

Please re-state the problem that we are trying to solve in this issue.

On Android native, when focusing the instructions/prompt input on Settings > Agents > New agent > Build custom agent, or the AI prompt input on Settings > Profile while copiloted into an agent account, the keyboard hides the Create agent / Save button. The form should slide up smoothly with the keyboard (without jumping) and keep the submit button visible above it—matching Workspace > Rules > Add rule > Or just describe it below on Android. (Settings > Agents > [agent] > Write custom instructions, DynamicEditPromptPage, uses the identical helper and has the same issue.)

What is the root cause of that problem?

Confirming and completing MelvinBot's code-level finding: all three Agent prompt editors route their focus scroll through scrollToMultilineInput, whose default (Android + web) implementation is an empty no-op.

  1. src/pages/settings/Agents/scrollToMultilineInput/index.ts#L3-L5 is resolved on Android and web:

    // This function is only needed on iOS where there is no auto scroll to the multiline text input on focus.
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    function scrollToMultilineInput(scrollWithKeyboard: ScrollWithKeyboard, shouldScrollToMultilineInput: boolean, inputTopOffset: number) {}
    

    Only index.ios.ts#L3-L8 actually calls scrollWithKeyboard(inputTopOffset).

  2. All three Agent prompt editors instantiate useKeyboardDrivenScroll(scrollViewRef) (introduced in #106203 specifically to drive smooth keyboard-synced scrolling on both iOS and Android—including SETTLE_DELAY_MS = 400 to outlast Android's own 250 ms focus scroll, useKeyboardDrivenScroll/index.native.ts#L13-L17), yet only invoke it through scrollToMultilineInput:

  3. Because the submit buttons render inside the ScrollView content below the prompt (FormWrapper.tsx#L251 and AgentAIPromptSection.tsx#L226-L237), Android's default scrollsChildToFocus={true} only reveals the focused TextInput, leaving the Create agent / Save button behind the keyboard.

  4. Comparing with the working Rules screen (DescribeRuleForm.tsx), which uses the exact same ScreenWrapper + KAV + FormProvider + useKeyboardDrivenScroll stack, there are exactly two differences:

    • DescribeRuleForm runs scrollWithKeyboard on both iOS and Android (#L293-L299), clamping at the end of content so the submit button stays visible.
    • DescribeRuleForm sets shouldScrollChildToFocus={false} (#L320-L321) per the documented contract in Form/types.ts#L231-L232 ("Set it to false when the form scrolls to the input itself") so Android does not trigger a competing focus scroll that causes a visible jump.

What changes do you think we should make in order to solve the problem?

  1. Enable scrollToMultilineInput on all native platforms (iOS + Android) while keeping web as a no-op:

    • Rename src/pages/settings/Agents/scrollToMultilineInput/index.ios.ts → src/pages/settings/Agents/scrollToMultilineInput/index.native.ts (implementation unchanged; update comment to explain both iOS and Android).
    • Keep src/pages/settings/Agents/scrollToMultilineInput/index.ts as the web no-op and update its comment.
  2. Disable Android's competing focus scroll on the Agent prompt scroll views (matching DescribeRuleForm so the form slides up smoothly once without jumping):

  3. Tests:

    • Add unit test tests/unit/pages/settings/Agents/scrollToMultilineInputTest.ts verifying index.native.ts invokes scrollWithKeyboard(offset) only when shouldScrollToMultilineInput is true, while web index.ts remains a no-op.
    • Extend tests/unit/pages/settings/AddAgentPageTest.tsx, EditPromptPageTest.tsx, and tests/ui/ProfilePageTest.tsx to assert shouldScrollChildToFocus={false} / scrollsChildToFocus={!isAgentAccount}.
    • Manually verify on Android (and iOS regression check):
      • Build custom agent → tap Instructions → smooth single slide, Create agent visible above keyboard (normal + >10-line prompt + landscape rotation + agentName focus).
      • Copilot into agent → Settings > Profile → tap AI prompt → smooth slide, Save visible above keyboard.
      • Edit custom instructions (DynamicEditPromptPage) → tap prompt → Save visible.
      • Dismiss/reopen keyboard, user drag mid-animation, and Rules > Add rule regression check.

What alternative solutions did you explore? (Optional)

  • Sticky submit footer (shouldSubmitButtonStickToBottom): Would only cover the two FormProvider pages (not AgentAIPromptSection's inline Button on ProfilePage) and diverges from the Rules design pattern established in #106203.
  • Removing scrollToMultilineInput and calling scrollWithKeyboard directly in all 3 screens: Equivalent on native, but larger diff and loses the clean web no-op platform split.
  • Skipping step 2 (shouldScrollChildToFocus={false}): useKeyboardDrivenScroll's 400 ms SETTLE_DELAY_MS would eventually re-apply the offset, but Android's native 250 ms focus scroll would still cause a visible two-step jump—failing the "without jumping" expected result.

Contributor details

Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01aee0111e1a0ae483

admin0330 avatar Nov 25 '26 19:11 admin0330

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 25 '26 19:11 melvin-bot[bot]

Hello is it i can do it this task ?

RamoDevAI avatar Nov 25 '26 22:11 RamoDevAI

📣 @RamoDevAI! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

melvin-bot[bot] avatar Nov 25 '26 22:11 melvin-bot[bot]

Proposal

Please re-state the problem that we are trying to solve in this issue?

On Android, when building a custom agent or editing an agent's prompt (Settings > Agents > New agent > Build custom agent, or Settings > Profile > AI prompt), tapping the prompt text input opens the keyboard, but the "Create agent" and "Save" buttons remain hidden behind the keyboard instead of sliding smoothly into view above it.

What is the root cause of that problem?

In src/pages/settings/Agents/DynamicAddAgentPage.tsx (lines 57, 237, 319) and src/pages/settings/Agents/Fields/DynamicEditPromptPage.tsx (lines 27, 62, 138), the component calls:

scrollToMultilineInput(scrollWithKeyboard, shouldUseScrollableLayout, promptTopOffsetRef.current);

Looking at src/pages/settings/Agents/scrollToMultilineInput/:

  • index.ios.ts implements the scroll trigger for iOS:
function scrollToMultilineInput(scrollWithKeyboard: ScrollWithKeyboard, shouldScrollToMultilineInput: boolean, inputTopOffset: number) {
    if (!shouldScrollToMultilineInput) {
        return;
    }
    scrollWithKeyboard(inputTopOffset);
}
export default scrollToMultilineInput;
  • index.ts is an empty stub:
function scrollToMultilineInput(scrollWithKeyboard: ScrollWithKeyboard, shouldScrollToMultilineInput: boolean, inputTopOffset: number) {}
export default scrollToMultilineInput;

Because the implementation file is named index.ios.ts and there is no index.android.ts or index.native.ts, React Native's Metro bundler resolves index.ts on Android! Therefore, on Android, scrollToMultilineInput is an empty no-op. When the multiline input receives focus on Android, scrollWithKeyboard is never invoked, leaving the submit buttons completely hidden beneath the soft keyboard.

Furthermore, on Android native, ScrollView / FormProvider has shouldScrollChildToFocus behavior enabled by default, which competes with useKeyboardDrivenScroll and causes visible double-jump stuttering if not disabled.

What changes do you think we should make in order to solve the problem?

1. Rename index.ios.ts to index.native.ts

Rename src/pages/settings/Agents/scrollToMultilineInput/index.ios.ts → src/pages/settings/Agents/scrollToMultilineInput/index.native.ts: This ensures both iOS and Android utilize the native scrollWithKeyboard implementation while Web continues using the no-op in index.ts.

2. Prevent Competing Focus Scroll on Android

  • In src/pages/settings/Agents/DynamicAddAgentPage.tsx: Pass shouldScrollChildToFocus={false} to <FormProvider>.
  • In src/pages/settings/Agents/Fields/DynamicEditPromptPage.tsx: Pass shouldScrollChildToFocus={false} to <FormProvider>.
  • In src/pages/settings/Profile/ProfilePage.tsx: Pass scrollsChildToFocus={!isAgentAccount} on <ScrollView>.

This allows useKeyboardDrivenScroll to smoothly animate the form scroll offset so that "Create agent" and "Save" are cleanly positioned above the keyboard without any jerky dual-scroll jumps.

What alternative solutions did you explore? (Optional)?

We considered using a sticky footer (shouldSubmitButtonStickToBottom). However, ProfilePage.tsx renders AgentAIPromptSection inline within the general profile scroll view where sticky footers break the profile layout hierarchy. Utilizing useKeyboardDrivenScroll via index.native.ts provides a unified, proven architecture across all native platforms that matches the pattern established in #106203.

What are the regression risks and how will you mitigate them?

  • Web platform: Web continues to use index.ts stub where native keyboard scrolling does not apply.
  • iOS platform: Renaming index.ios.ts to index.native.ts keeps iOS behavior 100% identical as index.native.ts targets both iOS and Android equally.
  • Other FormProvider forms: shouldScrollChildToFocus={false} is scoped specifically to the agent pages utilizing keyboard-driven scroll, leaving other forms unaffected.

Automated Tests?

Add unit tests verifying:

  1. scrollToMultilineInput invokes scrollWithKeyboard when called on native platforms (index.native.ts).
  2. scrollToMultilineInput no-ops cleanly on web (index.ts).

Manual Test Steps?

  1. Open the app on Android.
  2. Navigate to Settings > Agents > New agent > Build custom agent.
  3. Tap on the instructions/prompt multiline text input to open the soft keyboard.
  4. Verify that the page smoothly scrolls up and the "Create agent" button remains visible above the keyboard.
  5. Navigate to Settings > Profile > AI prompt (or copiloted agent profile).
  6. Tap on the prompt input.
  7. Verify that the "Save" button remains visible above the keyboard without double-scroll jitter.

Contributor Details?

  • GitHub Username: @kevinjosh10
  • Email: [email protected]
  • Upwork Profile: https://www.upwork.com/freelancers/~0131dae36abcf59374

kevinjosh10 avatar Nov 26 '26 07:11 kevinjosh10

Contributor details

Your Expensify account email: [email protected]

Upwork Profile Link: https://www.upwork.com/freelancers/omarhdev1?viewMode=1

RamoDevAI avatar Nov 27 '26 19:11 RamoDevAI

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 27 '26 19:11 melvin-bot[bot]

Hi, I've completed my contributor registration and reviewed the contributing guidelines. I'm interested in working on this issue.

Could you please confirm whether you are still accepting new proposals for this task? I'd be happy to investigate the issue and submit my own technical proposal.

Thank you!

RamoDevAI avatar Nov 27 '26 20:11 RamoDevAI

@eVoloshchak Eep! 4 days overdue now. Issues have feelings too...

I think we should proceed with @admin0330's proposal

🎀👀🎀 C+ reviewed!

eVoloshchak avatar Nov 30 '26 22:11 eVoloshchak

Triggered auto assignment to @jasperhuangg, see https://stackoverflow.com/c/expensify/questions/7972 for more details.