Skip to content

Conversation

@hassoncs
Copy link
Contributor

@hassoncs hassoncs commented Jun 10, 2025

Related GitHub Issue

Kilo-Org/kilocode#619

Description

This fixes an issue where sometimes the menu options do not appear because the panel is not in focus: Kilo-Org/kilocode#619

Adds a new focusPanel command and utility function to allow focusing the active webview panel (tab or sidebar). This command is now triggered when a user clicks on any non-interactive content within the webview, improving user experience by automatically bringing the panel into focus.

Previously clicking the panel would sometimes focus it, sometimes not:
2025-06-10 13 14 50

Details

  • New Command: Introduced focusPanel command to programmatically focus the webview panel.
  • Utility Function: Created src/utils/focusPanel.ts to encapsulate the logic for revealing tab panels or focusing sidebar panels.
  • Webview Integration: Added a focusPanelRequest message type to WebviewMessage and implemented a handler in webviewMessageHandler to execute the new focusPanel command.
  • User Experience: Implemented a useAddNonInteractiveClickListener hook in webview-ui that sends a focusPanelRequest message to the extension when a click occurs on non-interactive elements, ensuring the webview gains focus.
  • Refactor: Modified the focusInput command to utilize the new focusPanel utility, reducing code duplication and centralizing panel focus logic.

Test Procedure

For both the sidebar and popped-out sidebar, I verified clicking now always focused the panel. Also verified the focusInput functionality is still working properly

Type of Change

  • 🐛 Bug Fix: Non-breaking change that fixes an issue.
  • New Feature: Non-breaking change that adds functionality.
  • 💥 Breaking Change: Fix or feature that would cause existing functionality to not work as expected.
  • ♻️ Refactor: Code change that neither fixes a bug nor adds a feature.
  • 💅 Style: Changes that do not affect the meaning of the code (white-space, formatting, etc.).
  • 📚 Documentation: Updates to documentation files.
  • ⚙️ Build/CI: Changes to the build process or CI configuration.
  • 🧹 Chore: Other changes that don't modify src or test files.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Code Quality:
    • My code adheres to the project's style guidelines.
    • There are no new linting errors or warnings (npm run lint).
    • All debug code (e.g., console.log) has been removed.
  • Testing:
    • New and/or updated tests have been added to cover my changes.
    • All tests pass locally (npm test).
    • The application builds successfully with my changes.
  • Branch Hygiene: My branch is up-to-date (rebased) with the main branch.
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Changeset: A changeset has been created using npm run changeset if this PR includes user-facing changes or dependency updates.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

2025-06-10 13 22 46


Important

Adds focusPanel command and utility to ensure webview panel focus on click, with supporting changes in message handling and UI hooks.

  • Behavior:
    • Adds focusPanel command to focus webview panel when clicked.
    • Implements focusPanelRequest message in webviewMessageHandler.ts to trigger focusPanel command.
    • Introduces useAddNonInteractiveClickListener hook in App.tsx to send focusPanelRequest on non-interactive clicks.
  • Utility:
    • Creates focusPanel.ts to centralize panel focusing logic.
    • Refactors focusInput command in registerCommands.ts to use focusPanel utility.
  • Types:
    • Adds focusPanelRequest to WebviewMessage type in WebviewMessage.ts.

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

@hassoncs hassoncs requested review from cte, jr and mrubens as code owners June 10, 2025 20:23
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Jun 10, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jun 10, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

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

Hey @hassoncs, Thank you for your contribution!

I tested it and it works pretty well.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 10, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Jun 10, 2025
Adds a new `focusPanel` command and utility function to allow focusing the active webview panel (tab or sidebar). This command is now triggered when a user clicks on non-interactive content within the webview, improving user experience by automatically bringing the panel into focus.

This fixes an issue where sometimes the menu options do not appear because the panel is not in focus:
https://github.com/orgs/Kilo-Org/projects/4/views/1?pane=issue&itemId=113936749&issue=Kilo-Org%7Ckilocode%7C619

**Details**
- **New Command:** Introduced `focusPanel` command to programmatically focus the webview panel.
- **Utility Function:** Created `src/utils/focusPanel.ts` to encapsulate the logic for revealing tab panels or focusing sidebar panels.
- **Webview Integration:** Added a `focusPanelRequest` message type to `WebviewMessage` and implemented a handler in `webviewMessageHandler` to execute the new `focusPanel` command.
- **User Experience:** Implemented a `useAddNonInteractiveClickListener` hook in `webview-ui` that sends a `focusPanelRequest` message to the extension when a click occurs on non-interactive elements, ensuring the webview gains focus.
- **Refactor:** Modified the `focusInput` command to utilize the new `focusPanel` utility, reducing code duplication and centralizing panel focus logic.
@hassoncs hassoncs force-pushed the fix-missing-icons-popout-view branch from 99bd5b1 to c4ab5bd Compare June 11, 2025 17:44
@hassoncs
Copy link
Contributor Author

@daniel-lxs, thank you for the quick review! I made one small change to add a useCallback here:

useAddNonInteractiveClickListener(
		useCallback(() => {
			vscode.postMessage({ type: "focusPanelRequest" })
		}, []),
	)

could you re-approve when you get a chance? I accidentally force-pushed, sorry about that!

Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

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

Thank you again!

@mrubens
Copy link
Collaborator

mrubens commented Jun 12, 2025

@daniel-lxs were you able to repro this issue? I don't believe I've seen it before, but maybe I just didn't notice...

@hassoncs
Copy link
Contributor Author

Note the the bug was only reproducible in the popped-out version of the Sidebar. The buttons are always visible in the main version.

@mrubens
Copy link
Collaborator

mrubens commented Jun 12, 2025

Note the the bug was only reproducible in the popped-out version of the Sidebar. The buttons are always visible in the main version.

Ahh got it. I don't usually run it popped out so makes sense that I haven't seen it.

@daniel-lxs
Copy link
Member

@mrubens
Yes, I was able to reproduce it, also it feels intuitive to have the tab gain focus when clicking anywhere on it since that's how the code ones behave.

@mrubens mrubens merged commit 1b1e5a2 into RooCodeInc:main Jun 12, 2025
9 checks passed
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jun 12, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jun 12, 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 lgtm This PR has been approved by a maintainer PR - Needs Review 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.

4 participants