Skip to content

Fix landscape mode layout on Agents pages - #97782

Open
GCyganek wants to merge 11 commits into
Expensify:mainfrom
software-mansion-labs:@GCyganek/landscape-mode/fix-agent-pages
Open

Fix landscape mode layout on Agents pages#97782
GCyganek wants to merge 11 commits into
Expensify:mainfrom
software-mansion-labs:@GCyganek/landscape-mode/fix-agent-pages

Conversation

@GCyganek

@GCyganek GCyganek commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Changes from #97214 and #94565 that were reverted because of this #97196 (comment)

Fixes landscape layout on Agents/Agent Rules pages when the keyboard is open. Replaces the scrollable-form layout with a collapsing header, shrinks multiline prompt inputs to a fixed height while the keyboard is active, and renders Save/Delete in one row in landscape.

Also corrects the header collapse math for the top safe area inset. Fixes not restoring header height after device rotation to portrait mode. Also adding isKeyboardFullyOpen check and add naturalHeightRef.current !== height comparison in onLayout to make sure duplicated onLayout height updates do not cancel ongoing animationwhen rotating from portrait to landscape with opened keyboard

Fixed Issues

$ #93631, #97196
PROPOSAL: N/A

Tests

Test 1: Add agent page in landscape

  1. Rotate the device to landscape mode
  2. Go to Account > Agents > New agent > Build custom agent
  3. Tap the Write custom instructions multiline input to open the keyboard
  4. Verify that the prompt input shrinks to ~2 visible lines instead of stretching behind the keyboard, and that the input is visible
  5. Dismiss the keyboard and verify the header expands back to its full height and the prompt input grows back
  6. Rotate back to portrait and verify the layout is correct

Test 2: Edit agent page in landscape

  1. Rotate the device to landscape mode
  2. Go to Account > Agents and go to Write custom instructions screen of an already created agent
  3. Tap the Write custom instructions multiline input to open the keyboard
  4. Verify that the prompt input shrinks to ~2 visible lines instead of stretching behind the keyboard, and that the input is visible
  5. Dismiss the keyboard and verify the header expands back to its full height and the prompt input grows back
  6. Rotate back to portrait and verify the layout is correct

Test 3: Edit agent rule in landscape (Save + Delete in one row)

  1. In landscape mode, go to Workspaces > Workspace > Rules > Agent rules and open an existing rule
  2. Focus the rule prompt input to open the keyboard
  3. Verify the prompt input shrinks, and both the Delete and Save buttons are side by side in a single row
  4. Dismiss the keyboard and verify the input grows back and header is restored if was collapsed with open keyboard
  5. Rotate to portrait and verify Delete and Save are stacked vertically as before

Test 4: Add agent rule tabs + Profile page

  1. In landscape mode, go to Workspaces > Workspace > Rules > Agent rules > Add rule
  2. On the Suggestions tab, focus the search input to open the keyboard and verify the header + tab selector collapse and the Next button scrolls inside the list content instead of being pinned as a fixed footer behind the keyboard
  3. Switch to the Write tab, focus the prompt input, and verify the headline/description collapse, the prompt input shrinks, and the submit button stays visible
  4. Dismiss the keyboard and verify the layout is restored correctly

Test 5

  1. Navigate to Account settings.
  2. Tap Agents.
  3. Tap New Agent > Build custom agent.
  4. Tap Write custom instructions.
  5. Rotate the device to landscape mode.
  6. Enter multiline text in the custom instructions field so that header collapses.
  7. Rotate the device back to portrait mode.
  8. Verify the Back button remains visible after changing the device orientation, allowing the user to navigate back normally.
  9. Rotate the device to landscape mode with open keyboard
  10. Verify that header hides again in landscape mode to make space for input and Save button
  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

Same as tests.

  • 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

Android: Native
Screen.Recording.2026-08-06.at.13.31.36.mov
Screen.Recording.2026-08-06.at.13.32.51.mov

with isRulesRevampEnabled beta enabled:

Screen.Recording.2026-08-06.at.13.38.11.mov
Android: mWeb Chrome
iOS: Native
Screen.Recording.2026-08-06.at.13.34.39.mov
Screen.Recording.2026-08-06.at.13.35.25.mov

with isRulesRevampEnabled beta enabled:

Screen.Recording.2026-08-06.at.13.37.14.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-08-06.at.13.39.28.mov

with isRulesRevampEnabled beta enabled:

Screen.Recording.2026-08-06.at.13.39.05.mov

@melvin-bot

melvin-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers!

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
src/components/Form/FormProvider.tsx 71.91% <ø> (ø)
src/components/Form/FormWrapper.tsx 90.62% <ø> (ø)
src/components/FormAlertWithSubmitButton.tsx 97.14% <100.00%> (ø)
src/pages/settings/Agents/AddAgentPage.tsx 91.56% <100.00%> (+0.20%) ⬆️
...rc/pages/settings/Agents/Fields/EditPromptPage.tsx 72.09% <100.00%> (+0.66%) ⬆️
src/pages/settings/Agents/const.ts 100.00% <100.00%> (ø)
...ce/rules/AgentRules/AddAgentRuleSuggestionsTab.tsx 98.27% <100.00%> (+0.12%) ⬆️
...es/settings/Agents/scrollToMultilineInput/index.ts 0.00% <0.00%> (ø)
src/pages/settings/Profile/ProfilePage.tsx 95.04% <60.00%> (ø)
...orkspace/rules/AgentRules/AddAgentRuleWriteTab.tsx 0.00% <0.00%> (ø)
... and 5 more
... and 10 files with indirect coverage changes

@GCyganek

GCyganek commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@m-natarajan would you be able to check if this is still happening for you here? I tested Android on different simulators and on my Android 16 physical device, but I'm not able to reproduce this bug so I just want to confirm this needs a separate fix

Screen.Recording.2026-08-04.at.13.15.58.mov

@m-natarajan

Copy link
Copy Markdown

@GCyganek
Xiaomi Redmi Note 10 / Android 12
App 9.4.49-1
Passed

Screenrecorder-2026-08-04-16-40-08-799.mp4

@GCyganek

GCyganek commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@m-natarajan thank you, from what I see you tested version without the changes from this PR, but the bug I linked in my previous comment is what caused the revert, so I wanted to make sure it is not reproducible on this PR. Are you able to do that in any way? I'd be really grateful as I can't reproduce it on my end, but you were able to first time these changes were merged to main. I can ask someone for an ad-hoc build if it's needed

@m-natarajan

Copy link
Copy Markdown

@GCyganek Share the Ad-hoc build when its ready and ping, Will retest the same.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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

@GCyganek

GCyganek commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@m-natarajan build is ready

@m-natarajan

Copy link
Copy Markdown

@GCyganek Passed in the Ad-hoc build

Screenrecorder-2026-08-05-17-23-28-822.mp4

@GCyganek

GCyganek commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@GCyganek Passed in the Ad-hoc build

Thank you!

@GCyganek

GCyganek commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@codex please review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b04699907

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/pages/settings/Agents/AddAgentPage.tsx
@GCyganek
GCyganek marked this pull request as ready for review August 6, 2026 12:09
@GCyganek
GCyganek requested review from a team as code owners August 6, 2026 12:09
@melvin-bot
melvin-bot Bot requested review from mkhutornyi and trjExpensify and removed request for a team August 6, 2026 12:09
@melvin-bot

melvin-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

@mkhutornyi 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]

@GCyganek

GCyganek commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@truph01 could you review again as you reviewed the reverted PRs? I only added a few small changes to the reverted PRs, although the QA that reported the bug that triggered the revert confirmed it's not reproducible anymore even though I haven't changed anything before the test

Comment thread src/pages/workspace/rules/AgentRules/EditAgentRulePage.tsx Outdated
Comment thread src/components/FormAlertWithSubmitButton.tsx Outdated
@truph01

truph01 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

@GCyganek Sure. I will review this one.

@truph01

truph01 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

@trjExpensify Could you help assign me to this PR?

@NicolasBonet
NicolasBonet requested a review from truph01 August 12, 2026 17:39
@NicolasBonet

Copy link
Copy Markdown
Contributor

Added you as a reviewer @truph01

@truph01

truph01 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Bug 1: There is no padding bottom below the submit button in test 2:

Screen.Recording.2026-08-19.at.11.24.17.mov

@truph01

truph01 commented Aug 19, 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
Screen.Recording.2026-08-19.at.11.56.43.mov
iOS: HybridApp

Test 1:

Screen.Recording.2026-08-19.at.11.13.34.mov
Screen.Recording.2026-08-19.at.11.14.49.mov

Test 2:

Screen.Recording.2026-08-19.at.11.29.20.mov
Screen.Recording.2026-08-19.at.11.29.32.mov

Test 3:

Screen.Recording.2026-08-19.at.11.34.51.mov
Screen.Recording.2026-08-19.at.11.35.10.mov

Test 4:

Screen.Recording.2026-08-19.at.11.42.03.mov
Screen.Recording.2026-08-19.at.11.43.32.mov

Test 5:

Screen.Recording.2026-08-19.at.11.48.56.mov
iOS: mWeb Safari

Test 1:

Screen.Recording.2026-08-19.at.11.17.00.mov

Test 2:

Screen.Recording.2026-08-19.at.11.30.19.mov

Test 3:

Screen.Recording.2026-08-19.at.11.36.17.mov

Test 4:

Screen.Recording.2026-08-19.at.11.44.43.mov
MacOS: Chrome / Safari
Screen.Recording.2026-08-19.at.11.57.52.mov

@GCyganek

GCyganek commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

Bug 1: There is no padding bottom below the submit button in test 2:

Not sure I can do anything else here with this amount of vertical space, maybe collapsing header fully, but IMO this is good enough:

Screenshot 2026-08-19 at 09 07 03

Header already collapses to prioritize showing as much of the submit button as possible, so I think it's fine

Screenshot 2026-08-19 at 09 08 50

But we can ask the design team if you want

@truph01

truph01 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

@Expensify/design Do you think this behavior is fine?

@shawnborton

Copy link
Copy Markdown
Contributor

Have we considered making it where the green button is not fixed and you would need to scroll or dismiss the keyboard to get to it?

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.

5 participants