Skip to content

Conversation

@hassoncs
Copy link
Contributor

@hassoncs hassoncs commented Jul 25, 2025

Previously, we had a bug where if either of the buttons in the agent chat was clicked, the ChatTextArea would get cleared. Now, the text box will only get cleared if the message is sent as part of the response.

Moved input clearing logic to only execute when a message is successfully sent, preventing the input field from clearing prematurely when clicking "yes" or "no" buttons in the chat interface. This improves user experience by retaining the input content if an action fails or requires further interaction

Fixes #1520

2025-07-25 12 53 57

Opened the same PR on the Roo side: RooCodeInc/Roo-Code#6222

Summary by CodeRabbit

  • Bug Fixes
    • The chat input box is now only cleared after a message is successfully sent, rather than on every button click. This prevents accidental loss of unsent text or images in the chat interface.

@hassoncs hassoncs requested a review from Copilot July 25, 2025 19:55
@changeset-bot
Copy link

changeset-bot bot commented Jul 25, 2025

🦋 Changeset detected

Latest commit: b9e7ecf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
kilo-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

The chat box is no longer cleared when clicking buttons

Previously, we had a bug where if either of the buttons in the agent chat was clicked, the ChatTextArea would get cleared. Now, the text box will only get cleared if the message is sent as part of the response.

Moved input clearing logic to only execute when a message is successfully sent,
preventing the input field from clearing prematurely when clicking "yes" or "no"
buttons in the chat interface. This improves user experience by retaining the
input content if an action fails or requires further interaction

Fixes #1520
@coderabbitai
Copy link

coderabbitai bot commented Jul 25, 2025

Walkthrough

The patch updates the agent chat interface so that the chat input area is only cleared when a message is actually sent, rather than on any button click. The logic for clearing the input and selected images is now directly tied to successful message dispatch, preserving user input during retries or other button interactions.

Changes

File(s) Change Summary
.changeset/calm-pears-fry.md Adds a changeset describing the refined chat input clearing behavior and its rationale.
webview-ui/src/components/chat/ChatView.tsx Refactors input and image clearing logic to occur only after sending a message; updates button handlers accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant Agent as Agent UI
    participant User as User
    participant ChatTextArea as Chat Input
    participant Backend as Message Handler

    User->>ChatTextArea: Type message
    User->>Agent: Clicks button (e.g., Retry or Send)
    alt Message is sent (text or images exist)
        Agent->>Backend: Send message
        Backend-->>Agent: Response
        Agent->>ChatTextArea: Clear input and images
    else Button click without sending message
        Agent-->>ChatTextArea: Preserve input and images
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A bunny hopped by the chat box one day,
Saw messages vanish, much to dismay.
Now the input stays put,
Until you say "Send!"—what a cute little rut!
So type all your thoughts, don’t fear the retry,
Your words will remain, as moments hop by.
🐇💬

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

webview-ui/src/components/chat/ChatView.tsx

Oops! Something went wrong! :(

ESLint: 9.28.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

Note

⚡️ Unit Test Generation is now available in beta!

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

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-dont-clear-chat-when-clicking-buttons

🪧 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.
    • @coderabbitai modularize this function.
  • 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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.

@hassoncs hassoncs force-pushed the fix-dont-clear-chat-when-clicking-buttons branch from a755932 to b9e7ecf Compare July 25, 2025 19:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a user experience issue where the chat input field was being cleared prematurely when clicking "yes" or "no" buttons in the agent chat interface. The fix ensures that input clearing only occurs when a message is actually sent, preserving user input if an action fails or requires further interaction.

Key changes:

  • Moved input clearing logic inside the conditional blocks that handle successful message sending
  • Removed parameters from button click handlers as they no longer need to pass input values directly

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
webview-ui/src/components/chat/ChatView.tsx Relocated input clearing logic to execute only after successful message sending, and simplified button click handler signatures
.changeset/calm-pears-fry.md Added changeset documentation describing the bug fix

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
webview-ui/src/components/chat/ChatView.tsx (1)

1912-1912: Correctly addresses past review feedback with improved design.

The previous review comment suggested passing inputValue and selectedImages as parameters, but the current implementation uses a better approach by accessing these values directly from the closure. This decouples the button clicks from parameter passing and ensures the handlers always work with current state values, which aligns perfectly with the new input clearing logic.

🧹 Nitpick comments (1)
webview-ui/src/components/chat/ChatView.tsx (1)

661-663: Add required kilocode_change comments per coding guidelines.

The changed lines need kilocode_change comments as specified in the coding guidelines:

Lines 661-663 and 724-726 (multi-line changes):

+ // kilocode_change start
  // Clear input state after sending
  setInputValue("")
  setSelectedImages([])
+ // kilocode_change end

Lines 1912 and 1934 (single line changes):

- onClick={() => handlePrimaryButtonClick()}>
+ onClick={() => handlePrimaryButtonClick()}> // kilocode_change

Also applies to: 724-726, 1912-1912, 1934-1934

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b7585ea and b9e7ecf.

📒 Files selected for processing (2)
  • .changeset/calm-pears-fry.md (1 hunks)
  • webview-ui/src/components/chat/ChatView.tsx (4 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/!(*kilocode*)/**/*.{ts,tsx,js,jsx,html,css,scss}

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

**/!(*kilocode*)/**/*.{ts,tsx,js,jsx,html,css,scss}: For single line changes, add the comment '// kilocode_change' at the end of the line.
For multiple consecutive lines changed, wrap them with '// kilocode_change start' and '// kilocode_change end' comments.

Files:

  • webview-ui/src/components/chat/ChatView.tsx
**/!(*kilocode*)/**/*.{html,jsx,tsx}

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

In HTML/JSX/TSX files, use '{/* kilocode_change start /}' and '{/ kilocode_change end */}' to wrap multi-line changes.

Files:

  • webview-ui/src/components/chat/ChatView.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: storybook-playwright-snapshot
  • GitHub Check: test-extension (windows-latest)
  • GitHub Check: test-webview (windows-latest)
🔇 Additional comments (3)
webview-ui/src/components/chat/ChatView.tsx (2)

661-663: LGTM! Input clearing logic properly relocated.

The input clearing now occurs only after successfully sending a message, which prevents premature clearing when buttons are clicked but ensures the input is cleared when a message is actually dispatched. This correctly implements the fix described in the PR objectives.


724-726: LGTM! Consistent implementation for secondary button.

The secondary button handler now follows the same pattern as the primary button, clearing the input state only after successfully sending a message. This ensures consistent behavior across both button types.

.changeset/calm-pears-fry.md (1)

1-8: LGTM! Changeset accurately documents the fix.

The changeset clearly describes the behavior change: preventing premature input clearing on button clicks while ensuring clearing occurs only when messages are actually sent. This documentation aligns perfectly with the implemented changes and PR objectives.

@hassoncs hassoncs merged commit 08ccbea into main Jul 25, 2025
11 checks passed
@hassoncs hassoncs deleted the fix-dont-clear-chat-when-clicking-buttons branch July 25, 2025 20:13
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.

When you press retry after a failed api call the content of the chat box is cleared

3 participants