Skip to content

MGMT-21370: Focus text area when opening chat/starting new one#3099

Merged
openshift-merge-bot[bot] merged 1 commit intoopenshift-assisted:masterfrom
rawagner:chatbot_focus
Aug 7, 2025
Merged

MGMT-21370: Focus text area when opening chat/starting new one#3099
openshift-merge-bot[bot] merged 1 commit intoopenshift-assisted:masterfrom
rawagner:chatbot_focus

Conversation

@rawagner
Copy link
Copy Markdown
Member

@rawagner rawagner commented Aug 5, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Improved focus behavior to ensure the message input box is only focused when the confirmation modal is closed, providing a smoother chat experience.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Aug 5, 2025
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Aug 5, 2025

@rawagner: This pull request references MGMT-21370 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.20.0" version, but no target version was set.

Details

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested review from ElayAharoni and batzionb August 5, 2025 13:54
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Aug 5, 2025

Walkthrough

A React effect was added to the ChatBotWindow component to handle focusing the new message input box when the confirmation modal closes. The direct focus call within the startNewChat function was removed, but all other logic in that function remains unchanged.

Changes

Cohort / File(s) Change Summary
ChatBotWindow Focus Handling
libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx
Added a React effect to focus the message box when the confirmation modal closes; removed direct focus call from startNewChat.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ChatBotWindow (Component)
    participant Modal

    User->>ChatBotWindow (Component): Initiates new chat
    ChatBotWindow (Component)->>Modal: Closes confirmation modal
    Modal-->>ChatBotWindow (Component): isConfirmModalOpen changes to false
    ChatBotWindow (Component)->>ChatBotWindow (Component): useEffect triggers
    ChatBotWindow (Component)->>ChatBotWindow (Component): focusNewMessageBox()
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Possibly related PRs

  • MGMT-21260 focus input on new chat #3074: Both PRs modify the focus behavior of the message input box in the ChatBotWindow component during the start of a new chat, with the main PR moving the focus call into a React effect triggered by modal state changes, while the retrieved PR adds the focus call directly inside the startNewChat function and refactors related helpers.

Suggested labels

lgtm, approved, size/S

Suggested reviewers

  • batzionb
  • ElayAharoni

Poem

A modal closes, the chat begins anew,
With focus set just right, the code feels fresh as dew.
React hooks in action, smooth as a bunny’s hop,
Conversations start with ease—no need to stop!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 650ce70 and 2addca7.

📒 Files selected for processing (1)
  • libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: celdrake
PR: openshift-assisted/assisted-installer-ui#3051
File: libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx:196-222
Timestamp: 2025-07-18T12:35:50.945Z
Learning: In the assisted-installer-ui chatbot feedback implementation, the onFeedbackSubmit callback requires access to the messages array to retrieve both the bot response content and the associated user question for the API call, making it necessary to include messages in the useCallback dependency array rather than passing message content as props to avoid duplicating potentially long message data.
📚 Learning: in the assisted-installer-ui chatbot feedback implementation, the onfeedbacksubmit callback requires...
Learnt from: celdrake
PR: openshift-assisted/assisted-installer-ui#3051
File: libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx:196-222
Timestamp: 2025-07-18T12:35:50.945Z
Learning: In the assisted-installer-ui chatbot feedback implementation, the onFeedbackSubmit callback requires access to the messages array to retrieve both the bot response content and the associated user question for the API call, making it necessary to include messages in the useCallback dependency array rather than passing message content as props to avoid duplicating potentially long message data.

Applied to files:

  • libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx
🔇 Additional comments (1)
libs/chatbot/lib/components/ChatBot/ChatBotWindow.tsx (1)

79-81: LGTM! Clean implementation of auto-focus functionality.

The useEffect correctly focuses the message input when the confirmation modal closes and also handles the initial render case when no modal is open. This aligns perfectly with the PR objective to focus the text area when opening chat or starting a new one.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@openshift-ci openshift-ci bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 5, 2025
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Aug 5, 2025

@rawagner: This pull request references MGMT-21370 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.20.0" version, but no target version was set.

Details

In response to this:

Summary by CodeRabbit

  • Bug Fixes
  • Improved focus behavior to ensure the message input box is only focused when the confirmation modal is closed, providing a smoother chat experience.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 6, 2025
@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Aug 6, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ammont82, rawagner

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rawagner
Copy link
Copy Markdown
Member Author

rawagner commented Aug 6, 2025

/retest

1 similar comment
@rawagner
Copy link
Copy Markdown
Member Author

rawagner commented Aug 7, 2025

/retest

@openshift-merge-bot openshift-merge-bot bot merged commit babdf8b into openshift-assisted:master Aug 7, 2025
11 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants