Skip to content

fix: keep the composer's focus when the chat view leaves its zero state - #52

Merged
divyanshub024 merged 1 commit into
mainfrom
fix/composer-focus-zero-state
Oct 8, 2026
Merged

divyanshub024 merged 1 commit into
mainfrom
fix/composer-focus-zero-state

Conversation

@divyanshub024

@divyanshub024 divyanshub024 commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

On wide layouts, FlowChatView puts the composer in the centred cluster while the conversation is empty, and docks it at the bottom edge once there are messages. Nothing carried the composer between the two places, so the first send rebuilt it from scratch and the field lost focus: text typed straight after the first message went nowhere. Sends from the docked composer were unaffected.

The view now holds a GlobalKey and wraps the composer in a KeyedSubtree in both places, so the element moves instead of remounting, keeping its focus and the rest of its state. A host's own key on its composer still works, since the KeyedSubtree wraps it rather than replacing it.

This is also groundwork for #46: the composer's send animations need it to survive its first send.

Verified

  • Playground, Full Chat, web at 1440×900: type, press Enter in the centred composer, keep typing. The text now lands in the docked field; on main it went nowhere. No framework errors in the console.
  • dart run melos run analyze is clean in every workspace member.

Note

Low Risk
Narrow layout/identity fix in FlowChatView with no auth, data, or API surface changes.

Overview
Fixes composer focus loss on the first send in wide layouts: when FlowChatView switches from the centred empty-state cluster to the bottom-docked composer, Flutter used to mount a new element and the text field dropped focus.

FlowChatView now keeps a GlobalKey and wraps the host composer in KeyedSubtree in both _emptyCentre and _composerZone, so the same subtree moves instead of remounting—preserving focus, draft, and internal state. Host keys on the composer still apply because the subtree wraps the child rather than replacing it. The CHANGELOG documents the behaviour for 0.4.0.

Reviewed by Cursor Bugbot for commit a9c5626. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes
    • The chat composer now keeps its current state and focus when moving from the wide empty view to the docked layout. Text already entered remains available, and the composer stays focused during the transition, providing a smoother move between these views without interrupting the conversation.

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3592e147-674c-49eb-b4e8-eb2b1204b780
📥 Commits

Reviewing files that changed from the base of the PR and between 2fc1ad1 and a9c5626.

📒 Files selected for processing (2)
  • packages/flow_ui/CHANGELOG.md
  • packages/flow_ui/lib/src/widgets/flow_chat_view.dart

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

FlowChatView now uses the same keyed composer subtree in its wide empty-state and docked layouts. The changelog states that this preserves composer state and focus when leaving the wide zero state.

Changes

Composer state across layouts

Layer / File(s) Summary
Key the composer across layouts
packages/flow_ui/lib/src/widgets/flow_chat_view.dart, packages/flow_ui/CHANGELOG.md
A state-owned GlobalKey now wraps the composer in both layouts. The 0.4.0 changelog notes that leaving the wide zero state preserves composer state and focus.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to a9c56

The supplied review context identifies no actionable merge-blocking risk in the composer layout change.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: preserving composer focus when FlowChatView leaves its zero state.
Description check ✅ Passed The description clearly explains the problem, implementation, scope, and verification results. It does not include the template's screenshots table or checklist, and it uses a Verified heading instead…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@divyanshub024
divyanshub024 merged commit 193fec0 into main Oct 8, 2026
9 checks passed
@divyanshub024
divyanshub024 deleted the fix/composer-focus-zero-state branch October 8, 2026 14:41
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.

1 participant