From b42b286879ebca718b12b352d8be373ff0794bbf Mon Sep 17 00:00:00 2001 From: Jinwoo Hong <73622457+Jinwoo-H@users.noreply.github.com> Date: Tue, 9 Jun 2026 00:27:33 -0400 Subject: [PATCH] Fix mobile markdown actions above keyboard (#4945) Co-authored-by: Orca --- .../app/h/[hostId]/session/[worktreeId].tsx | 24 ++++++++++++++++--- .../markdown-floating-actions-layout.test.ts | 24 +++++++++++++++++++ .../markdown-floating-actions-layout.ts | 11 +++++++++ 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 mobile/src/session/markdown-floating-actions-layout.test.ts create mode 100644 mobile/src/session/markdown-floating-actions-layout.ts diff --git a/mobile/app/h/[hostId]/session/[worktreeId].tsx b/mobile/app/h/[hostId]/session/[worktreeId].tsx index 6f7100ba4..a9cc8eb70 100644 --- a/mobile/app/h/[hostId]/session/[worktreeId].tsx +++ b/mobile/app/h/[hostId]/session/[worktreeId].tsx @@ -123,6 +123,7 @@ import { type MobileNewTabAgentOption, type MobileNewTabAgentSettings } from '../../../../src/session/mobile-new-tab-agent-options' +import { resolveMarkdownFloatingActionsBottom } from '../../../../src/session/markdown-floating-actions-layout' import { createMobileSessionCreateWarningState, dismissMobileSessionCreateWarningState, @@ -411,7 +412,8 @@ function MarkdownReader({ onChange, onSave, onCopy, - onDiscard + onDiscard, + keyboardLift }: { documentId: string doc: MarkdownDocState | undefined @@ -420,6 +422,7 @@ function MarkdownReader({ onSave: () => void onCopy: () => void onDiscard: () => void + keyboardLift: number }) { if (!doc || doc.status === 'loading') { return ( @@ -461,7 +464,21 @@ function MarkdownReader({ onChange={onChange} /> {showFloatingActions ? ( - + {statusText ? ( ) : activeMarkdownTab ? ( - + void saveMarkdownTab(activeMarkdownTab)} onCopy={() => void copyMarkdownLocalContent(activeMarkdownTab.id)} onDiscard={() => discardMarkdownLocalContent(activeMarkdownTab)} + keyboardLift={keyboardLift} /> {toastMessage && ( diff --git a/mobile/src/session/markdown-floating-actions-layout.test.ts b/mobile/src/session/markdown-floating-actions-layout.test.ts new file mode 100644 index 000000000..021b8de95 --- /dev/null +++ b/mobile/src/session/markdown-floating-actions-layout.test.ts @@ -0,0 +1,24 @@ +import { describe, expect, it } from 'vitest' +import { resolveMarkdownFloatingActionsBottom } from './markdown-floating-actions-layout' + +describe('resolveMarkdownFloatingActionsBottom', () => { + it('keeps markdown actions at their resting bottom when the keyboard is closed', () => { + expect( + resolveMarkdownFloatingActionsBottom({ + keyboardLift: 0, + restingBottom: 16, + liftedClearance: 12 + }) + ).toBe(16) + }) + + it('raises markdown actions above the keyboard with clearance', () => { + expect( + resolveMarkdownFloatingActionsBottom({ + keyboardLift: 291, + restingBottom: 16, + liftedClearance: 12 + }) + ).toBe(303) + }) +}) diff --git a/mobile/src/session/markdown-floating-actions-layout.ts b/mobile/src/session/markdown-floating-actions-layout.ts new file mode 100644 index 000000000..06aa5b922 --- /dev/null +++ b/mobile/src/session/markdown-floating-actions-layout.ts @@ -0,0 +1,11 @@ +export function resolveMarkdownFloatingActionsBottom({ + keyboardLift, + restingBottom, + liftedClearance +}: { + keyboardLift: number + restingBottom: number + liftedClearance: number +}): number { + return keyboardLift > 0 ? keyboardLift + liftedClearance : restingBottom +}