Skip to content

fix(ios): preserve chat live edge across keyboard transitions - #136660

Merged
Solvely-Colin merged 3 commits into
mainfrom
fix/ios-transcript-keyboard-visibility
Sep 3, 2026
Merged

Solvely-Colin merged 3 commits into
mainfrom
fix/ios-transcript-keyboard-visibility

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

When an iPhone chat is already following the live edge, opening the keyboard can move the latest transcript content behind the composer. The reader then appears stale or blank around typing and send transitions until another interaction changes the scroll geometry.

Refs #135214 and preserves the post-send live-edge regression boundary from #108692.

Why This Change Was Made

SwiftUI reports keyboard avoidance as a system .animating scroll phase. The chat reader intentionally releases its one-shot follow target for system animation, but the keyboard handlers previously only toggled isKeyboardVisible; nothing restored the live-edge anchor after the keyboard finished showing.

The reader now records whether it was following latest before the keyboard transition and restores the bottom anchor after keyboardDidShow. A real interactive scroll cancels the pending restore, and an active search result is rechecked before moving, so reading/search positions are not pulled to the bottom.

The UI test also queries the long sent prompt by its label predicate. XCUITest rejects direct string-subscript queries longer than 128 characters because that API performs an identifier lookup.

User Impact

The latest conversation content stays visibly rendered above the keyboard while the user types and after sending. People who intentionally scroll or search during the keyboard transition keep their chosen reading position.

Evidence

Exact repaired head: cd82ef193c2e78d00786432c532ffc9bf3afa7c0

Failing baseline, exact prior head 62a393cfc2b6273e561148fa4bf4f9bf84301401:

  • Focused iPhone UI test failed 3/3 at OpenClawSnapshotUITests.swift:785 because OPENCLAW_LONG_CHAT_LATEST was outside the visible area after the keyboard opened.
  • The failure reproduced on an iPhone 17 simulator running iOS 27.0 (24A5370g).

Passing repaired head:

  • OpenClawSnapshotUITests.testKeyboardOpenPreservesTranscriptAndFollowsLiveEdgeAfterSend: passed on the same iPhone 17 / iOS 27.0 simulator.
  • The test reached and passed the keyboard-open, while-typing, post-send geometry, rendered-pixel, and jump-affordance assertions.
  • Full apps/shared/OpenClawKit suite: 1,571 Swift Testing tests in 120 suites passed; 60 XCTest cases passed with two expected live speech/audio skips.
  • Repository changed-path gate passed with the pinned SwiftFormat 0.63.0 and SwiftLint 0.65.1, including Swift lint, macOS CI shards, protocol coverage, dependency/patch guards, conflict-marker checks, and native schema guard.
  • Independent autoreview of the complete staged PR diff: scoped-clean at P0-P2, no findings, confidence 0.94.

Hosted iOS and aggregate CI are currently skipped because this PR remains a draft; this description does not claim hosted exact-head CI.

Source:

  • Live-edge keyboard lifecycle owner:
    .onReceive(NotificationCenter.default.publisher(for: UIResponder.keyboardWillShowNotification)) { _ in
    self.restoresLiveEdgeAfterKeyboardShows =
    self.followTarget == .latest && !self.isUserScrolling && self.searchMessageID == nil
    self.isKeyboardVisible = true
    }
    .onReceive(NotificationCenter.default.publisher(for: UIResponder.keyboardDidShowNotification)) { _ in
    guard self.restoresLiveEdgeAfterKeyboardShows else { return }
    self.restoresLiveEdgeAfterKeyboardShows = false
    guard self.searchMessageID == nil else { return }
    self.isUserScrolling = false
    self.followTarget = .latest
    self.hasNewerContentBelow = false
    self.moveScrollPosition(to: self.scrollerBottomID)
    }
    .onReceive(NotificationCenter.default.publisher(for: UIResponder.keyboardWillHideNotification)) { _ in
    self.restoresLiveEdgeAfterKeyboardShows = false
    self.isKeyboardVisible = false
    }
  • End-to-end regression:
    func testKeyboardOpenPreservesTranscriptAndFollowsLiveEdgeAfterSend() throws {
    try XCTSkipIf(UIDevice.current.userInterfaceIdiom != .phone, "Phone keyboard proof only")
    self.launchApp(
    for: ScreenshotTarget(
    initialTab: "chat",
    initialDestination: "chat",
    name: "keyboard-follow"),
    additionalArguments: ["--openclaw-long-chat-fixture"])
    let app = try XCTUnwrap(self.app)
    let latestSeededReply = app.staticTexts["OPENCLAW_LONG_CHAT_LATEST"]
    XCTAssertTrue(latestSeededReply.waitForExistence(timeout: 8))
    let input = self.chatMessageInput(in: app)
    XCTAssertTrue(input.waitForExistence(timeout: 8))
    input.tap()
    let keyboard = app.keyboards.firstMatch
    XCTAssertTrue(keyboard.waitForExistence(timeout: 3))
    func visibleAreaAboveKeyboard() -> CGRect {
    CGRect(
    x: app.frame.minX,
    y: app.frame.minY,
    width: app.frame.width,
    height: keyboard.frame.minY - app.frame.minY)
    }
    XCTAssertTrue(latestSeededReply.exists)
    XCTAssertTrue(latestSeededReply.frame.intersects(visibleAreaAboveKeyboard()))
    XCTAssertLessThanOrEqual(latestSeededReply.frame.maxY, keyboard.frame.minY + 1)
    self.assertElementHasRenderedContent(latestSeededReply, named: "seeded reply after keyboard opens")
    let promptPrefix =
    "Give me a long, detailed status update covering the release plan, review feedback, " +
    "open follow-ups, "
    let promptSuffix = "and the next steps for the team."
    let prompt = promptPrefix + promptSuffix
    input.typeText(promptPrefix)
    XCTAssertTrue(latestSeededReply.exists)
    XCTAssertTrue(latestSeededReply.frame.intersects(visibleAreaAboveKeyboard()))
    self.assertElementHasRenderedContent(latestSeededReply, named: "seeded reply while typing")
    input.typeText(promptSuffix)
    XCTAssertEqual(input.value as? String, prompt)
    XCTAssertTrue(latestSeededReply.exists)
    XCTAssertTrue(latestSeededReply.frame.intersects(visibleAreaAboveKeyboard()))
    XCTAssertLessThanOrEqual(latestSeededReply.frame.maxY, keyboard.frame.minY + 1)
    self.attachScreenshot(named: "keyboard-transcript-visible-while-typing")
    let send = app.buttons["chat-send-message"]
    XCTAssertTrue(send.waitForExistence(timeout: 5))
    send.tap()
    // Regression proof for #108692 and #135214: the transcript remains rendered while typing,
    // then the sent turn follows the live edge without a manual redraw or scroll.
    XCTAssertTrue(keyboard.exists)
    let sentPrompt = app.staticTexts.matching(
    NSPredicate(format: "label == %@", prompt))
    .firstMatch
    XCTAssertTrue(sentPrompt.waitForExistence(timeout: 8))
    let reply = app.staticTexts.matching(
    NSPredicate(format: "label CONTAINS %@", "keep the mobile workflow connected to the gateway"))
    .firstMatch
    XCTAssertTrue(reply.waitForExistence(timeout: 8))
    Thread.sleep(forTimeInterval: 1.0)
    let visibleArea = visibleAreaAboveKeyboard()
    XCTAssertTrue(sentPrompt.frame.intersects(visibleArea))
    XCTAssertTrue(reply.frame.intersects(visibleArea))
    XCTAssertLessThanOrEqual(reply.frame.maxY, keyboard.frame.minY + 1)
    self.assertElementHasRenderedContent(sentPrompt, named: "sent prompt after send")
    self.assertElementHasRenderedContent(reply, named: "reply after send")
    XCTAssertFalse(app.buttons["Jump to latest reply"].exists)
    self.attachScreenshot(named: "keyboard-transcript-visible-after-send")

Scope

  • Production: +16/-0 in the shared chat reader. The added state and notification handling are the lifecycle owner required to distinguish keyboard animation from intentional reader movement.
  • Tests: +132/-12 in the iPhone snapshot UI suite.
  • No protocol, configuration, storage, dependency, or release changes.

Worked on by

  • roboclaw-bot
  • Colin

Visual proof

Real, unedited XCUIElement screenshots captured from the passing exact-head test on an iPhone 17 simulator running iOS 27.0 (24A5370g). The full test simultaneously asserted that the keyboard was present and each captured transcript element intersected the visible area above it.

Latest seeded transcript content remains rendered while typing:

Latest seeded transcript content remains rendered while typing

Reply remains rendered after send:

Reply remains rendered after send

@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added app: ios App: ios size: S maintainer Maintainer-authored PR labels Sep 2, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 2, 2026, 10:12 PM ET / September 3, 2026, 02:12 UTC.

ClawSweeper review

What this changes

The PR records whether an iOS chat was following its latest message before the keyboard opens, restores that position after the keyboard appears, and adds a simulator UI regression test for typing and sending.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open. This is an active Member-authored, maintainer-labeled repair; current main still lacks the keyboard live-edge restoration, and the focused owner-local change has no supported blocking correctness finding.

Priority: P2
Reviewed head: 0c6a0610b56272a576773593a861e7c39559c1d7

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-local repair with direct simulator regression evidence and no actionable correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository context identifies a Member author, so the external-contributor proof gate does not apply; the PR nevertheless supplies before/after iPhone simulator UI-test evidence and screenshots for the changed behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository context identifies a Member author, so the external-contributor proof gate does not apply; the PR nevertheless supplies before/after iPhone simulator UI-test evidence and screenshots for the changed behavior.
Evidence reviewed 6 items Introduced lifecycle repair: The PR snapshots the existing live-edge state on keyboard show, cancels that snapshot for an interactive scroll, and restores the bottom anchor after the keyboard is shown.
Owner and caller path: The transcript’s geometry and scroll-phase handlers own follow state, while timeline changes consume that state and call the same one-shot bottom-positioning helper.
Focused regression coverage: The new phone-only UI test verifies the seeded transcript is above the keyboard while typing and that both sent prompt and reply remain visible after sending, with rendered-content checks.
Findings None None.
Security None None.

How this fits together

The shared Apple chat view renders the transcript above a composer and tracks whether it should follow the newest content. Keyboard notifications alter the available viewport, so the view must preserve a live-edge decision across that system transition.

flowchart LR
A[Chat at latest message] --> B[Keyboard starts showing]
B --> C[Save live-edge state]
C --> D[Keyboard shown]
D --> E[Restore bottom anchor]
F[User scroll] --> G[Cancel pending restore]
E --> H[Transcript visible above keyboard]
Loading

Before merge

  • Resolve merge risk (P1) - The repair adds 16 production lines to an order-sensitive scroll lifecycle; retain the focused iPhone UI regression because the lightweight scroll-state tests do not exercise keyboard viewport transitions.
Agent review details

Security

None.

PR surface

Other +136. Total +136 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 148 12 +136
Total 2 148 12 +136

Review metrics

Metric Value Why it matters
Production vs. test delta production +16/-0; tests +132/-12 The new owner-local state is justified by the need to retain live-edge state across a system transition; the larger test change supplies direct UI regression coverage.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the pre-transition snapshot at the chat-view lifecycle owner; it cannot be absorbed into the persistent follow target without losing the distinction between a system keyboard animation and intentional reader movement.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the pre-transition snapshot at the chat-view lifecycle owner; it cannot be absorbed into the persistent follow target without losing the distinction between a system keyboard animation and intentional reader movement.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible with high confidence: the supplied exact-head simulator scenario reports a failure on the immediately preceding test head and a pass after the owner repair, while current main still lacks that repair.

Is this the best way to solve the issue?

Yes. Capturing the pre-keyboard live-edge fact and restoring it in the view that owns scroll state is preferable to keeping follow enabled through all system animations, which would also override intentional reader movement.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5db0387dff05.

Labels

Label justifications:

  • P2: This fixes a scoped but disruptive iOS chat-transcript usability regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository context identifies a Member author, so the external-contributor proof gate does not apply; the PR nevertheless supplies before/after iPhone simulator UI-test evidence and screenshots for the changed behavior.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jason (Json): Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Colin Johnson: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-02T22:15:21.996Z sha 62a393c :: blocked before merge. :: none
  • reviewed 2026-09-03T00:09:03.557Z sha cd82ef1 :: blocked before merge. :: none
  • reviewed 2026-09-03T01:26:12.749Z sha cd82ef1 :: blocked before merge. :: none

@Solvely-Colin Solvely-Colin changed the title test(ios): cover keyboard transcript rendering fix(ios): preserve chat live edge across keyboard transitions Sep 3, 2026
@Solvely-Colin

Copy link
Copy Markdown
Contributor

Exact-head repair and proof are now on cd82ef193c2e78d00786432c532ffc9bf3afa7c0.

Root cause: keyboard avoidance enters a system animated scroll phase that releases the chat reader's one-shot live-edge target. The prior keyboard handlers never restored that target after the viewport finished shrinking. The fix restores only a pre-existing live-edge position and cancels restoration for an interactive scroll or active search.

Proof:

  • Prior head 62a393cfc2b6273e561148fa4bf4f9bf84301401: focused iPhone UI test failed 3/3 at the keyboard-open visibility assertion.
  • Repaired head cd82ef193c2e78d00786432c532ffc9bf3afa7c0: the same test passed on an iPhone 17 simulator with iOS 27.0, including rendered-pixel assertions while typing and after send.
  • Full shared-kit suite passed: 1,571 Swift Testing tests plus 60 XCTest cases; two live speech/audio tests skipped as expected.
  • Repository changed-path gate passed with the pinned Swift tools.
  • Independent P0-P2 autoreview: scoped-clean, 0 findings.

The PR remains draft, so hosted iOS and aggregate CI are still skipped; this is local exact-head simulator proof, not hosted-CI proof.

@Solvely-Colin

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 3, 2026
@Solvely-Colin
Solvely-Colin marked this pull request as ready for review September 3, 2026 00:36
Copilot AI lite review requested due to automatic review settings September 3, 2026 00:36

Copilot AI 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.

🟡 Changes recommended

The keyboard restore flag is currently gated in a way that can be invalidated by SwiftUI’s .animating scroll phase (which sets isUserScrolling and clears followTarget), potentially skipping the intended restore.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Fixes an iOS SwiftUI chat-reader regression where opening the keyboard can cause the transcript to appear stale/blank or slip behind the composer, by restoring the live-edge anchor after the keyboard finishes showing (while respecting intentional user scroll and active search).

Changes:

  • Track whether the chat was following the live edge when the keyboard transition began, and restore the bottom anchor on keyboardDidShow.
  • Cancel the pending restore when the user performs an interactive scroll during the keyboard transition.
  • Extend the iPhone UI snapshot test to cover “keyboard opens → typing → send” while asserting the transcript remains visible and follows the live edge.
File summaries
File Description
apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift Adds keyboard lifecycle handling to restore the live-edge follow target after keyboard presentation.
apps/ios/UITests/OpenClawSnapshotUITests.swift Strengthens UI regression coverage for keyboard-visible chat rendering and post-send live-edge following.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 502 to 505
.onReceive(NotificationCenter.default.publisher(for: UIResponder.keyboardWillShowNotification)) { _ in
self.restoresLiveEdgeAfterKeyboardShows =
self.followTarget == .latest && !self.isUserScrolling && self.searchMessageID == nil
self.isKeyboardVisible = true
@Solvely-Colin
Solvely-Colin merged commit 9939a92 into main Sep 3, 2026
66 checks passed
@Solvely-Colin
Solvely-Colin deleted the fix/ios-transcript-keyboard-visibility branch September 3, 2026 15:48
vincentkoc added a commit that referenced this pull request Sep 3, 2026
* refs/remotes/origin/main:
  fix(plugins): reject unverifiable pinned npm installs (#136725)
  improve(ui): lift sidebar section headers on hover and mark online owners (#136985)
  test(cron): reuse isolated run suite hooks (#137341)
  test(channels): reuse shared indexed call guards (#137350)
  fix(ui): sidebar header controls read misaligned after the + button lost its border (#137317)
  fix(qa-channel): preserve conversation kind for implicit actions (#137343)
  fix: target the source checkout in Control UI repair commands (#137354)
  chore: reduce CI job count and database test overhead (#137352)
  fix(ios): preserve chat live edge across keyboard transitions (#136660)
  refactor(control-ui): consolidate mention inbox requests (#137375)
  fix(openai): preserve ChatGPT HTTP status for retry pacing (#137146)
  fix(mcp): hide policy-denied plugin tools from ACP sessions [AI] (#136546)
  test(queue): reuse shared deferred fixtures (#137338)
  fix(gateway): repair the Gateway E2E shard (browser suite project, skill resource argv, Codex diagnostic) (#137358)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 4, 2026
…aw#136660)

* test(ios): cover keyboard transcript rendering

* fix(ios): preserve live edge across keyboard show

---------

Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: Colin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: ios App: ios maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants