Skip to content

Conversation

@Mnehmos
Copy link
Contributor

@Mnehmos Mnehmos commented May 6, 2025

I've successfully fixed the issue where pasting text in the chat would sometimes paste into the terminal instead (issue #3199). Here's what I did:

Identified the root cause: The focus was not being properly restored to the webview after terminal operations.

Made the following changes:

Fixed the problematic $esbuild-watch reference in tasks.json by changing it to $tsc-watch
Added a simplified launch configuration for easier debugging
Added explicit focus restoration to the webview after terminal operations complete
Created a changeset file to document the changes for the release process

Created a PR description file with detailed information about the fix

All changes have been committed and pushed to the fix-terminal-paste-focus branch.

This fix should ensure that the focus returns to the chat input after terminal commands are executed, preventing the issue where pasting text would go to the terminal instead of the chat.


Important

Fixes chat paste issue by restoring webview focus after terminal operations in ClineProvider.ts and TerminalProcess.ts.

  • Behavior:
    • Fixes issue where pasting text in chat would paste into terminal instead by adding explicit focus restoration to the webview after terminal operations in ClineProvider.ts and TerminalProcess.ts.
    • Ensures focus returns to chat input after terminal commands.
  • Misc:
    • Fixes $esbuild-watch reference in tasks.json to $tsc-watch.
    • Adds a simplified launch configuration for debugging.
    • Adds changeset files for documenting changes.

This description was created by Ellipsis for 1b031af. You can customize this summary. It will automatically update as commits are pushed.

Mnehmos added 6 commits May 5, 2025 18:58
This PR addresses issue #3190 by replacing npm-run-all with npm-run-all2.

Changes made:
- Updated all script commands in package.json to use npm-run-all2
- Changed the devDependency from "npm-run-all": "^4.1.5" to "npm-run-all2": "^5.0.0"
- Added a changeset file to document this change

Benefits:
- Reduced maintenance burden: npm-run-all2 is a fork with troublesome babel code removed
- Improved security: Includes dependabot updates for better dependency management
- Better automation: Release automation is enabled in npm-run-all2
- Same functionality: Provides the same CLI commands and API as the original package

This is a minimal change that should have no impact on existing functionality.
@changeset-bot
Copy link

changeset-bot bot commented May 6, 2025

🦋 Changeset detected

Latest commit: 1b031af

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

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

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels May 6, 2025
this.stopHotTimer()
this.emit("completed", this.removeEscapeSequences(this.fullOutput))

// Restore focus to the webview after terminal operation completes
Copy link
Contributor

Choose a reason for hiding this comment

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

The focus restoration block (using setTimeout to call cline.provider.focusWebview()) is duplicated here and in the continue() method (lines 280-292). Consider extracting it into a helper method to adhere to DRY principles.

This comment was generated because it violated a code review rule: mrule_fYE6mUdYYxZL58YF.

}

public async postMessageToWebview(message: ExtensionMessage) {
await this.view?.webview.postMessage(message)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider wrapping the await postMessageToWebview call in try/catch to log errors and handle potential failures.

This comment was generated because it violated a code review rule: mrule_OR1S8PRRHcvbdFib.


// Restore focus to the webview after terminal operation is aborted or completed
const cline = this.terminal.taskId
? vscode.extensions.getExtension("RooVetGit.roo-code")?.exports?.getClineProvider?.()?.getCurrentCline?.()
Copy link
Collaborator

Choose a reason for hiding this comment

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

This feels like a reach in terms of good separation of concerns. The terminal already fires callbacks that the Cline instance is listening for, and we should use that callback mechanism instead to communicate with Cline and ClineProvider. I can update this PR to demonstrate that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need this file as part of the PR?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need this file?

Copy link
Collaborator

@cte cte left a comment

Choose a reason for hiding this comment

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

Good catch; I think we should fix the issue using your general method, but I think the terminal process can communicate with Cline more cleanly per my comments inline.

Copy link
Contributor Author

@Mnehmos Mnehmos left a comment

Choose a reason for hiding this comment

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

Hi, sorry this is like my first time attempting this and i figured since its version controlled no harm no foul, if suck then so be it.

Um no those files were just created to help me automate some of the changelogs, they are not necessary.

@Mnehmos Mnehmos closed this by deleting the head repository May 6, 2025
@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap May 7, 2025
@hannesrudolph hannesrudolph moved this from New to Done in Roo Code Roadmap May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants