Skip to content

[Improve] Streamline DCG command approval - #1062

Merged
edelauna merged 28 commits into
mainfrom
feat/dcg-command-integration
Aug 5, 2026
Merged

[Improve] Streamline DCG command approval#1062
edelauna merged 28 commits into
mainfrom
feat/dcg-command-integration

Conversation

@navedmerchant

@navedmerchantnavedmerchant commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

What changed

Reads the persisted DCG setting without eagerly building full provider state, restores full state loading until after approval, and adds coverage for an allowed command continuing through execution and for command rows awaiting a decision.

Why this change was made

The DCG integration should avoid unnecessary state work on ordinary commands while preserving explicit approval for guarded commands. Closes#1058 and completes #1049.

Impact

Command approval remains responsive when DCG is disabled, while guarded-command behavior and denied-state rendering are covered more completely.

Related PRs

Summary by CodeRabbit

  • New Features

    • Added destructive command protection with localized block messages, reasons, and rule details.
    • Commands approved by the protection system can bypass standard approval rules.
    • Added clear denied-command indicators in chat, with support for multiple languages.
  • Bug Fixes

    • Commands denied by protection now require explicit approval and fail safely when protection is unavailable.
    • Hidden command-pattern controls prevent changes when protection is active or a command is denied.
  • Tests

    • Expanded coverage for approval precedence, blocked commands, denied states, localization, and fail-closed behavior.

@navedmerchantnavedmerchant added the enhancement New feature or request label Jul 30, 2026
@navedmerchantnavedmerchant added the enhancement New feature or request label Jul 30, 2026
@navedmerchantnavedmerchant self-assigned this Jul 30, 2026
@coderabbitai

coderabbitaiBot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change integrates destructive-command-guard evaluation with command auto-approval, persists approval decisions on messages, adds localized denial details, and updates chat rendering for denied commands.

Changes

Destructive command approval and persistence

Layer / File(s)Summary
Persist auto-approval decisions
packages/types/src/message.ts, packages/types/src/__tests__/message.test.ts, src/core/task/Task.ts, AGENTS.md
Messages now store "approve" or "deny" decisions. Task ask messages persist these decisions across completion paths.
Apply DCG approval precedence
src/core/auto-approval/index.ts, src/core/auto-approval/__tests__/dcg.spec.ts
Protected commands require explicit approval. DCG-approved commands can bypass configured command lists when the required auto-approval settings are enabled.
Evaluate commands before execution
src/core/tools/ExecuteCommandTool.ts, src/core/tools/__tests__/executeCommandTool.spec.ts, src/i18n/locales/*/tools.json
Commands are installed and evaluated by DCG before approval. Blocked commands include localized reason and rule details. Installation and unavailable-guard failures stop evaluation, approval, and execution.
Render denied command state
webview-ui/src/components/chat/ChatRow.tsx, webview-ui/src/components/chat/CommandExecution.tsx, webview-ui/src/components/chat/__tests__/*, webview-ui/src/i18n/locales/*/chat.json
Denied commands display a localized status and denial icon. Pattern controls are hidden when DCG is enabled or the command is denied. Tests cover denied, approved, and undecided states.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
participant ExecuteCommandTool
participant DCG
participant AutoApproval
participant Task
participant ChatRow
ExecuteCommandTool->>DCG: Install and evaluate command
DCG-->>ExecuteCommandTool: Allow or denial details
ExecuteCommandTool->>AutoApproval: Request approval
AutoApproval-->>ExecuteCommandTool: Approve or deny
ExecuteCommandTool->>Task: Persist autoApprovalDecision
Task-->>ChatRow: Render command message state
Loading

Possibly related PRs

Suggested labels:awaiting-review

Suggested reviewers:hannesrudolph

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check nameStatusExplanationResolution
Description check⚠️ WarningThe description explains the change, rationale, impact, and issue links, but omits the required Test Procedure and Pre-Submission Checklist sections.Add the template sections, document reproducible tests and environment details, and complete the checklist including documentation impact.
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check nameStatusExplanation
Title check✅ PassedThe title clearly summarizes the main change: streamlining destructive command guard approval.
Linked Issues check✅ PassedThe implementation covers DCG precedence, explicit approval, disabled behavior, denied persistence and rendering, localized details, hidden controls, and regression tests for [#1058].
Out of Scope Changes check✅ PassedAll code and localization changes support DCG approval precedence, execution, denied-state UX, or regression coverage; no unrelated code changes are evident.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/dcg-command-integration

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.

packages/types/src/__tests__/message.test.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

packages/types/src/message.ts

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

src/core/auto-approval/__tests__/dcg.spec.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

  • 8 others

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

Comment @coderabbitai help to get the list of available commands.

@codecov

codecovBot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.17647% with 3 lines in your changes missing coverage. Please review.

Files with missing linesPatch %Lines
src/core/tools/ExecuteCommandTool.ts90.47%1 Missing and 1 partial ⚠️
src/core/task/Task.ts50.00%1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actionsgithub-actionsBot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Jul 30, 2026
@navedmerchant
navedmerchantforce-pushed the feat/dcg-command-integration branch from 3e1b109 to 5f6e0a8CompareJuly 30, 2026 04:50
@github-actionsgithub-actionsBot added awaiting-review PR changes are ready and waiting for maintainer re-review and removed awaiting-review PR changes are ready and waiting for maintainer re-review labels Jul 30, 2026

@edelaunaedelauna left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

some minor questions

Comment threadsrc/core/auto-approval/__tests__/dcg.spec.ts
Comment threadsrc/core/auto-approval/index.ts
@github-actionsgithub-actionsBot added awaiting-author PR is waiting for the author to address requested changes and removed awaiting-review PR changes are ready and waiting for maintainer re-review labels Jul 31, 2026
@navedmerchant
navedmerchantforce-pushed the feat/dcg-command-integration branch from 5f6e0a8 to dd00d03CompareAugust 1, 2026 17:23
@github-actionsgithub-actionsBot removed the awaiting-author PR is waiting for the author to address requested changes label Aug 1, 2026
@zoomotezoomoteBot changed the title [Feat] Integrate DCG with command auto-approval and denial UX[Improve] Streamline DCG command approvalAug 2, 2026
@zoomote

zoomoteBot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Addressed the implementation and coverage feedback in 900282f. DCG reads the persisted flag cheaply before approval, preserves deferred full-state loading, and covers allow and pending chat-row paths.

edelauna
edelauna previously approved these changes Aug 2, 2026

@edelaunaedelauna left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for addressing the feedback, approving - but still unclear on how you want to handle the design for a DCG blocked command: #1062 (comment)

@github-actionsgithub-actionsBot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Aug 2, 2026
Base automatically changed from feat/dcg-setting to mainAugust 5, 2026 02:33
@edelauna
edelauna dismissed their stale reviewAugust 5, 2026 02:33

The base branch was changed.

@github-actionsgithub-actionsBot added awaiting-author PR is waiting for the author to address requested changes and removed awaiting-review PR changes are ready and waiting for maintainer re-review labels Aug 5, 2026
@github-actionsgithub-actionsBot removed the awaiting-author PR is waiting for the author to address requested changes label Aug 5, 2026

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
src/core/tools/__tests__/executeCommandTool.spec.ts (1)

243-247: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use typed test doubles instead of repeated double assertions.

Define typed Task and callback test doubles once in the fixture. Remove the repeated as unknown as casts. If a cast is unavoidable, document why near the fixture.

  • src/core/tools/__tests__/executeCommandTool.spec.ts#L243-L247: pass typed Task and callback doubles.
  • src/core/tools/__tests__/executeCommandTool.spec.ts#L266-L270: reuse the typed doubles.
  • src/core/tools/__tests__/executeCommandTool.spec.ts#L284-L288: reuse the typed doubles.
  • src/core/tools/__tests__/executeCommandTool.spec.ts#L304-L308: reuse the typed doubles.
  • src/core/tools/__tests__/executeCommandTool.spec.ts#L329-L333: reuse the typed doubles.

As per coding guidelines: “Avoid as any; use typed APIs, bracket notation for private members, or precise test doubles and type guards. Use double assertions only as a last resort and explain them with a nearby comment.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/core/tools/__tests__/executeCommandTool.spec.ts` around lines 243 - 247,
Replace the repeated double assertions in the executeCommandTool.handle test
calls with typed Task and callback test doubles defined once in the fixture.
Reuse those doubles at src/core/tools/__tests__/executeCommandTool.spec.ts lines
243-247, 266-270, 284-288, 304-308, and 329-333; if any cast remains necessary,
document its reason beside the fixture.

Source: Coding guidelines

webview-ui/src/components/chat/__tests__/CommandExecution.spec.tsx (1)

114-140: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Type the extension-state fixtures instead of using as any.

mockExtensionState, ExtensionStateWrapper, and the local state passed to ExtensionStateContext.Provider are all cast to any, which removes compile-time checks for required context fields like destructiveCommandGuardEnabled, setAllowedCommands, and setDeniedCommands. Use the typed context value type or a typed wrapper in CommandExecution.spec.tsx.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@webview-ui/src/components/chat/__tests__/CommandExecution.spec.tsx` around
lines 114 - 140, Replace the any casts in the CommandExecution tests with the
actual ExtensionStateContext value type, including the local state and
ExtensionStateWrapper fixtures. Ensure mockExtensionState and the provider value
satisfy required fields such as destructiveCommandGuardEnabled,
setAllowedCommands, and setDeniedCommands without weakening type checking.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/core/tools/__tests__/executeCommandTool.spec.ts`:
- Around line 243-247: Replace the repeated double assertions in the
executeCommandTool.handle test calls with typed Task and callback test doubles
defined once in the fixture. Reuse those doubles at
src/core/tools/__tests__/executeCommandTool.spec.ts lines 243-247, 266-270,
284-288, 304-308, and 329-333; if any cast remains necessary, document its
reason beside the fixture.
In `@webview-ui/src/components/chat/__tests__/CommandExecution.spec.tsx`:
- Around line 114-140: Replace the any casts in the CommandExecution tests with
the actual ExtensionStateContext value type, including the local state and
ExtensionStateWrapper fixtures. Ensure mockExtensionState and the provider value
satisfy required fields such as destructiveCommandGuardEnabled,
setAllowedCommands, and setDeniedCommands without weakening type checking.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 84b524a3-87e4-4028-9574-e9338ea3e230

📥 Commits

Reviewing files that changed from the base of the PR and between 0ae9217 and 10476b3.

📒 Files selected for processing (48)
  • AGENTS.md
  • packages/types/src/__tests__/message.test.ts
  • packages/types/src/message.ts
  • src/core/auto-approval/__tests__/dcg.spec.ts
  • src/core/auto-approval/index.ts
  • src/core/task/Task.ts
  • src/core/tools/ExecuteCommandTool.ts
  • src/core/tools/__tests__/executeCommandTool.spec.ts
  • src/i18n/locales/ca/tools.json
  • src/i18n/locales/de/tools.json
  • src/i18n/locales/en/tools.json
  • src/i18n/locales/es/tools.json
  • src/i18n/locales/fr/tools.json
  • src/i18n/locales/hi/tools.json
  • src/i18n/locales/id/tools.json
  • src/i18n/locales/it/tools.json
  • src/i18n/locales/ja/tools.json
  • src/i18n/locales/ko/tools.json
  • src/i18n/locales/nl/tools.json
  • src/i18n/locales/pl/tools.json
  • src/i18n/locales/pt-BR/tools.json
  • src/i18n/locales/ru/tools.json
  • src/i18n/locales/tr/tools.json
  • src/i18n/locales/vi/tools.json
  • src/i18n/locales/zh-CN/tools.json
  • src/i18n/locales/zh-TW/tools.json
  • webview-ui/src/components/chat/ChatRow.tsx
  • webview-ui/src/components/chat/CommandExecution.tsx
  • webview-ui/src/components/chat/__tests__/ChatRow.command-denied.spec.tsx
  • webview-ui/src/components/chat/__tests__/CommandExecution.spec.tsx
  • webview-ui/src/i18n/locales/ca/chat.json
  • webview-ui/src/i18n/locales/de/chat.json
  • webview-ui/src/i18n/locales/en/chat.json
  • webview-ui/src/i18n/locales/es/chat.json
  • webview-ui/src/i18n/locales/fr/chat.json
  • webview-ui/src/i18n/locales/hi/chat.json
  • webview-ui/src/i18n/locales/id/chat.json
  • webview-ui/src/i18n/locales/it/chat.json
  • webview-ui/src/i18n/locales/ja/chat.json
  • webview-ui/src/i18n/locales/ko/chat.json
  • webview-ui/src/i18n/locales/nl/chat.json
  • webview-ui/src/i18n/locales/pl/chat.json
  • webview-ui/src/i18n/locales/pt-BR/chat.json
  • webview-ui/src/i18n/locales/ru/chat.json
  • webview-ui/src/i18n/locales/tr/chat.json
  • webview-ui/src/i18n/locales/vi/chat.json
  • webview-ui/src/i18n/locales/zh-CN/chat.json
  • webview-ui/src/i18n/locales/zh-TW/chat.json

@edelauna
edelauna added this pull request to the merge queueAug 5, 2026
Merged via the queue into main with commit f589ce7Aug 5, 2026
17 checks passed
@edelauna
edelauna deleted the feat/dcg-command-integration branch August 5, 2026 03:03
@coderabbitaicoderabbitaiBot mentioned this pull request Aug 6, 2026
myk1yt pushed a commit to myk1yt/Zoo-Code that referenced this pull request Aug 6, 2026
* refactor: extract managed binary installation infrastructure
Refs Zoo-Code-Org#1055
* fix: address managed binary review feedback
* feat: add destructive command guard binary service
Refs Zoo-Code-Org#1056
* test: strengthen DCG binary service coverage
* feat: add persisted destructive command guard setting
Refs Zoo-Code-Org#1057
* fix: clarify DCG enablement errors
* test: cover DCG global setting schema
* feat: integrate destructive command guard with auto-approval
ClosesZoo-Code-Org#1058
Completes Zoo-Code-Org#1049
* test: document DCG auto-approval precedence
* test: raise DCG setting patch coverage
* fix: address DCG service review feedback
* fix: address managed binary review feedback
* test: cover managed binary cleanup boundaries
* fix: address DCG binary service feedback
* fix: address DCG integration feedback
* fix: finalize managed binary download handling
* test: mirror download stream close events
* test: mirror download stream close events
---------
Co-authored-by: Naved Merchant <14171946+navedmerchant@users.noreply.github.com>
Co-authored-by: edelauna <54631123+edelauna@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancementNew feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate DCG with command auto-approval and denied-command UX

2 participants

@navedmerchant@edelauna