Skip to content

fix: Resolve confusing auto-approve checkbox states #5602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Jul 11, 2025

Related GitHub Issue

Closes: #2579

Roo Code Task Context (Optional)

N/A

Description

This PR fixes the confusing auto-approve checkbox states by implementing the following changes:

Key Implementation Details:

  • Added derived state hasEnabledOptions to check if any auto-approve sub-options are enabled
  • Introduced effectiveAutoApprovalEnabled to ensure the master checkbox reflects the actual state
  • Master checkbox is now disabled when no sub-options are selected, preventing the confusing "checked with None" state
  • Display text now correctly shows "None" when no options are enabled, regardless of checkbox state
  • Added automatic master checkbox toggling: when the last sub-option is disabled, the master automatically unchecks
  • Added tooltip explaining why the checkbox is disabled: "Select at least one option to enable auto-approval"

Design Choices:

  • Used derived state pattern to ensure UI consistency without complex state management
  • Applied changes to both the chat UI (AutoApproveMenu) and settings page (AutoApproveSettings) for consistency
  • Updated the isAutoApproved function in ChatView to respect the new logic, preventing auto-approval when only the master is checked

Translation Updates:

  • Added new translation key autoApprove.selectOptionsFirst to all 17 supported languages
  • All translations were validated using the translation validation script

Areas for Review Focus:

  • The automatic toggling behavior when enabling/disabling sub-options
  • Consistency between chat UI and settings page behavior
  • The disabled state tooltip implementation

Test Procedure

Unit Tests Added:

  • Created comprehensive tests in AutoApproveMenu.spec.tsx covering:
    • Checkbox disabled state when no options selected
    • Display text showing "None" appropriately
    • Automatic master checkbox toggling behavior
    • User interaction scenarios
  • Added tests in ChatView.auto-approve-new.spec.tsx to verify auto-approval doesn't trigger when only master is enabled

Manual Testing Steps:

  1. Open Roo Code and navigate to the chat interface
  2. Click on the Auto-approve section to expand it
  3. Verify the master checkbox is disabled when no sub-options are selected
  4. Select one or more sub-options and verify:
    • Master checkbox becomes enabled and checked
    • Display text shows the selected options
  5. Uncheck all sub-options and verify:
    • Master checkbox automatically unchecks and becomes disabled
    • Display text shows "None"
  6. Test the same behavior in Settings > Auto-approve section
  7. Verify auto-approval only works when both master is checked AND at least one sub-option is enabled

Test Commands:

# Run the new unit tests
cd webview-ui && npx vitest src/components/chat/__tests__/AutoApproveMenu.spec.tsx
cd webview-ui && npx vitest src/components/chat/__tests__/ChatView.auto-approve-new.spec.tsx

All tests are passing ✅

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.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

[Screenshots to be added showing the before/after states of the auto-approve checkbox]

Documentation Updates

  • No documentation updates are required.
  • Yes, documentation updates are required. (Please describe what needs to be updated or link to a PR in the docs repository).

Additional Notes

This implementation follows the proposed solution from the issue, preventing the confusing states where:

  • Checkbox is checked while displaying "None"
  • Checkbox is unchecked while displaying selected options

The solution maintains backward compatibility with existing saved settings.

Get in Touch

[Your Discord username]


Important

This PR resolves confusing auto-approve checkbox states by adding derived states, ensuring UI consistency, and updating translations.

  • Behavior:
    • Added hasEnabledOptions and effectiveAutoApprovalEnabled states in AutoApproveMenu.tsx to manage checkbox states.
    • Master checkbox in AutoApproveMenu.tsx and AutoApproveSettings.tsx is disabled when no sub-options are selected.
    • Automatic toggling of master checkbox when sub-options change.
    • Tooltip added to explain disabled state.
  • UI Consistency:
    • Updated ChatView.tsx to respect new auto-approve logic.
    • Ensured consistent behavior between chat UI and settings page.
  • Testing:
    • Added tests in AutoApproveMenu.spec.tsx and ChatView.auto-approve-new.spec.tsx for new checkbox behavior and logic.
  • Translations:
    • Added autoApprove.selectOptionsFirst key to 17 languages for tooltip support.

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

- Add derived state to check if any auto-approve options are enabled
- Disable master checkbox when no sub-options selected
- Show 'None' when no options enabled regardless of checkbox state
- Add automatic master checkbox toggling
- Add tooltip explaining disabled state
- Create custom hook useAutoApprovalState for shared logic
- Add accessibility aria-labels
- Update translations for all 17 supported languages
- Add comprehensive unit tests

Closes #2579
@Copilot Copilot AI review requested due to automatic review settings July 11, 2025 16:31
@hannesrudolph hannesrudolph requested review from mrubens, cte and jr as code owners July 11, 2025 16:31
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. bug Something isn't working UI/UX UI/UX related or focused labels Jul 11, 2025
Copy link

delve-auditor bot commented Jul 11, 2025

No security or compliance issues detected. Reviewed everything up to 907cec5.

Security Overview
  • 🔎 Scanned files: 42 changed file(s)
Detected Code Changes

The diff is too large to display a summary of code changes.

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

Copy link

@Copilot 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 prevents confusing states in the auto-approve UI by disabling the master checkbox when no sub-options are selected and adding clear tooltips, as well as updating translations and underlying logic.

  • Added useAutoApprovalState hook to derive hasEnabledOptions and effectiveAutoApprovalEnabled
  • Updated both the Settings and Chat menus to disable and annotate the master checkbox appropriately, and ensure the display text matches selected sub-options
  • Added new translation keys (toggleAriaLabel, disabledAriaLabel, selectOptionsFirst) across all locales

Reviewed Changes

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

Show a summary per file
File Description
src/i18n/locales/*/settings.json and chat.json Added translation keys for checkbox aria-labels and select-first message in all supported locales
src/hooks/useAutoApprovalState.ts Introduced hook computing derived auto-approval state
src/components/settings/AutoApproveSettings.tsx Disabled master checkbox when no sub-options, added tooltip in settings UI
src/components/chat/AutoApproveMenu.tsx Mirror settings changes in chat menu: derived state, disable logic, tooltip, summary text
src/components/chat/ChatView.tsx Updated isAutoApproved logic to require at least one sub-option
Comments suppressed due to low confidence (2)

webview-ui/src/i18n/locales/hi/chat.json:224

  • The word 'कॉन्फ़िgeration' mixes English and Hindi scripts; consider correcting it to 'कॉन्फ़िगरेशन'.
		"description": "स्वत:-स्वीकृति Roo Code को अनुमति मांगे बिना क्रियाएँ करने की अनुमति देती है। केवल उन क्रियाओं के लिए सक्षम करें जिन पर आप पूरी तरह से विश्वास करते हैं। अधिक विस्तृत कॉन्फ़िgerेशन <settingsLink>सेटिंग्स</settingsLink> में उपलब्ध है।",

webview-ui/src/components/chat/tests/AutoApproveMenu.spec.tsx:50

  • Add tests to verify the tooltip content and the disabled aria-label on the master checkbox when no sub-options are selected (e.g., ensure the 'selectOptionsFirst' message is shown and the aria-label is correct).
describe("AutoApproveMenu", () => {

@@ -122,7 +122,9 @@
"resetToDefault": "Réinitialiser par défaut"
},
"autoApprove": {
"description": "Permettre à Roo d'effectuer automatiquement des opérations sans requérir d'approbation. Activez ces paramètres uniquement si vous faites entièrement confiance à l'IA et que vous comprenez les risques de sécurité associés.",
"description": "Permettre à Roo d'effectuer automatically des opérations sans requérir d'approbation. Activez ces paramètres uniquement si vous faites entièrement confiance à l'IA et que vous comprenez les risques de sécurité associés.",
Copy link
Preview

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

Replace the English word 'automatically' with the French 'automatiquement' in this description.

Suggested change
"description": "Permettre à Roo d'effectuer automatically des opérations sans requérir d'approbation. Activez ces paramètres uniquement si vous faites entièrement confiance à l'IA et que vous comprenez les risques de sécurité associés.",
"description": "Permettre à Roo d'effectuer automatiquement des opérations sans requérir d'approbation. Activez ces paramètres uniquement si vous faites entièrement confiance à l'IA et que vous comprenez les risques de sécurité associés.",

Copilot uses AI. Check for mistakes.


interface AutoApproveMenuProps {
style?: React.CSSProperties
}

const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
const [isExpanded, setIsExpanded] = useState(false)
const [isMenuExpanded, setIsMenuExpanded] = useState(false)
Copy link
Preview

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

[nitpick] The component uses both isExpanded and isMenuExpanded to track the same state. Consider consolidating to a single state variable to reduce redundancy and simplify the disable logic for the master checkbox.

Suggested change
const [isMenuExpanded, setIsMenuExpanded] = useState(false)

Copilot uses AI. Check for mistakes.

@@ -89,6 +121,25 @@ export const AutoApproveSettings = ({
<div {...props}>
<SectionHeader description={t("settings:autoApprove.description")}>
<div className="flex items-center gap-2">
<StandardTooltip content={!hasEnabledOptions ? t("chat:autoApprove.selectOptionsFirst") : ""}>
Copy link
Preview

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

[nitpick] Here you reference the chat namespace for the 'selectOptionsFirst' translation in the settings UI. For consistency and clarity, consider introducing a settings-specific key (e.g., settings:autoApprove.selectOptionsFirst) or moving this shared message into a common namespace.

Suggested change
<StandardTooltip content={!hasEnabledOptions ? t("chat:autoApprove.selectOptionsFirst") : ""}>
<StandardTooltip content={!hasEnabledOptions ? t("settings:autoApprove.selectOptionsFirst") : ""}>

Copilot uses AI. Check for mistakes.

CODE_BLOCK_BG_COLOR: "rgb(30, 30, 30)",
}))

vi.mock("@src/components/common/CodeAccordian", () => ({
Copy link

Choose a reason for hiding this comment

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

Typo: The module name 'CodeAccordian' appears to be misspelled. It should likely be 'CodeAccordion' to match the standard spelling.

@@ -221,7 +221,10 @@
"autoApprove": {
"title": "स्वत:-स्वीकृति:",
"none": "कोई नहीं",
"description": "स्वत:-स्वीकृति Roo Code को अनुमति मांगे बिना क्रियाएँ करने की अनुमति देती है। केवल उन क्रियाओं के लिए सक्षम करें जिन पर आप पूरी तरह से विश्वास करते हैं। अधिक विस्तृत कॉन्फ़िगरेशन <settingsLink>सेटिंग्स</settingsLink> में उपलब्ध है।"
"description": "स्वत:-स्वीकृति Roo Code को अनुमति मांगे बिना क्रियाएँ करने की अनुमति देती है। केवल उन क्रियाओं के लिए सक्षम करें जिन पर आप पूरी तरह से विश्वास करते हैं। अधिक विस्तृत कॉन्फ़िgerेशन <settingsLink>सेटिंग्स</settingsLink> में उपलब्ध है।",
Copy link

Choose a reason for hiding this comment

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

Typo: In the description string, "कॉन्फ़िgerेशन" contains a mix of scripts. It should likely be "कॉन्फ़िगरेशन".

Suggested change
"description": "स्वत:-स्वीकृति Roo Code को अनुमति मांगे बिना क्रियाएँ करने की अनुमति देती है। केवल उन क्रियाओं के लिए सक्षम करें जिन पर आप पूरी तरह से विश्वास करते हैं। अधिक विस्तृत कॉन्फ़िgerेशन <settingsLink>सेटिंग्स</settingsLink> में उपलब्ध है।",
"description": "स्वत:-स्वीकृति Roo Code को अनुमति मांगे बिना क्रियाएँ करने की अनुमति देती है। केवल उन क्रियाओं के लिए सक्षम करें जिन पर आप पूरी तरह से विश्वास करते हैं। अधिक विस्तृत कॉन्फ़िगरेशन <settingsLink>सेटिंग्स</settingsLink> में उपलब्ध है।",

@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jul 11, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Draft / In Progress] in Roo Code Roadmap Jul 11, 2025
@daniel-lxs daniel-lxs marked this pull request as draft July 11, 2025 22:57
@daniel-lxs daniel-lxs moved this from PR [Draft / In Progress] to PR [Needs Prelim Review] in Roo Code Roadmap Jul 11, 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 PR - Needs Preliminary Review size:XXL This PR changes 1000+ lines, ignoring generated files. UI/UX UI/UX related or focused
Projects
Status: PR [Needs Prelim Review]
Development

Successfully merging this pull request may close these issues.

Redesign Auto-approve; don't allow confusing checkbox status with labels
1 participant