Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Feb 11, 2026

Related GitHub Issue

Closes: #11411

Description

This PR attempts to address Issue #11411. Feedback and guidance are welcome.

Problem: In CommandPatternSelector, when a user edits a command pattern suggestion and then presses Enter or clicks away (blur), the edited value resets to the original pattern. This means when they subsequently click the allow/deny button, the original pattern is sent instead of their edit.

Root cause: The setEditState helper used value ?? pattern as the stored value. When blur/Enter called setEditState(item.pattern, false) without an explicit value, it fell back to the original pattern key, discarding the edit.

Fix: Changed the default in the functional state updater from value ?? pattern to value ?? prev[pattern]?.value ?? pattern. This means:

  • When value is omitted (blur/Enter), the current edited value from state is preserved
  • When value is explicitly passed as the original pattern (Escape), it correctly reverts
  • When value is explicitly set (onChange), it updates normally

This ensures the edited command prefix is actually consumed when the user clicks accept/deny, which is the specific concern raised in the issue comments.

Test Procedure

  • Ran npx vitest run src/components/chat/__tests__/CommandPatternSelector.spec.tsx -- all 14 tests pass (9 existing + 5 new)
  • Ran npx vitest run src/components/chat/__tests__/CommandExecution.spec.tsx -- all 29 tests pass
  • All lint and type checks pass via pre-push hooks

New tests added:

  1. should preserve edited value after blur - verifies edit persists when clicking away
  2. should preserve edited value after pressing Enter - verifies edit persists on Enter
  3. should use edited pattern value when allow button is clicked after blur - verifies the edited value (not original) is sent to onAllowPatternChange after the user blurs then clicks allow
  4. should use edited pattern value when deny button is clicked after Enter - same for deny after Enter

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.
  • Documentation Impact: No documentation updates are required.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

Additional Notes

The fix is a single-line change in setEditState inside CommandPatternSelector.tsx. The key insight is using a functional state updater that reads the current value from state (prev[pattern]?.value) rather than falling back to the original pattern key when no explicit value is provided.

@roomote
Copy link
Contributor Author

roomote bot commented Feb 11, 2026

Rooviewer Clock   See task

Review complete. No issues found. The one-line fix in setEditState correctly preserves the edited value on blur/Enter by reading from the previous state before falling back to the original pattern. The 4 new tests cover value persistence (blur and Enter) and end-to-end callback verification (allow after blur, deny after Enter). All 14 tests pass.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Auto approve command suggestions are editable fields even though they have no edit functionality

1 participant