mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-14 05:42:54 -07:00
2.5 KiB
2.5 KiB
Review Findings - PR #20361
Summary
The PR implements "auto-add to policy by default" with workspace-first persistence and rule narrowing for edit tools. The core logic is sound, but there are several violations of the "Strict Development Rules".
Actionable Findings
1. Type Safety (STRICT TYPING Rule)
packages/core/src/scheduler/policy.test.ts: Still usesanyfordetailsin 'should narrow edit tools with argsPattern' test (Line 512).packages/cli/src/ui/components/messages/ToolConfirmationMessage.tsx: TheinitialIndexcalculation logic usesconfirmationDetailswhich is complex. Ensure noanyis leaked here.
2. React Best Practices (packages/cli)
- Dependency Management: In
ToolConfirmationMessage.tsx, theuseMemoblock forquestion,bodyContent, etc. (Lines 418-444) includes many new dependencies. EnsureinitialIndexis calculated correctly and doesn't trigger unnecessary re-renders. - Reducers: The
initialIndexis derived state. WhileuseMemois acceptable here, verify if this state should be part of a larger reducer if the confirmation UI becomes more complex.
3. Core Logic Placement
- Inconsistency: Narrowing for edit tools is implemented in both
scheduler/policy.tsand individual tools (write-file.ts,edit.ts).- Recommendation: Centralize the narrowing logic in the tools via
getPolicyUpdateOptionsand ensurescheduler/policy.tspurely respects what the tool provides, rather than duplicating thebuildFilePathArgsPatterncall.
- Recommendation: Centralize the narrowing logic in the tools via
4. Testing Guidelines
- Snapshot Clarity: The new snapshot for
ToolConfirmationMessageincludes a large block of text. Ensure the snapshot specifically highlights the change in the selected radio button (the●indicator). - Mocking: In
persistence.test.ts, ensurevi.restoreAllMocks()orvi.clearAllMocks()is consistently used to avoid pollution between the new workspace persistence tests and existing ones.
5. Settings & Documentation
- RequiresRestart: The
autoAddToPolicyByDefaultsetting hasrequiresRestart: false. Verify if theToolConfirmationMessagecorrectly picks up setting changes without a restart (it should, as it uses thesettingshook). - Documentation: Ensure this new setting is added to
docs/get-started/configuration.mdas per the general principles.
Directive
Fix all findings above, prioritizing strict typing and removal of duplicate narrowing logic.