Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Summary

Fix a regression where changing the diff base in the Review tab doesn't update the UI. The handlers were capturing stale filters props in closures.

Background

When calling setFilters({ ...filters, diffBase: value }), the filters object is captured at render time. While React Compiler should handle this, using functional updates is the idiomatic and safer approach that guarantees correct behavior.

Implementation

  • Changed onFiltersChange type to accept functional updates: (filters: ReviewFilters | ((prev: ReviewFilters) => ReviewFilters)) => void
  • Converted all filter handlers to use functional form:
    // Before
    onFiltersChange({ ...filters, diffBase: value })
    
    // After  
    onFiltersChange((prev) => ({ ...prev, diffBase: value }))
  • Added data-testid props for testing

Validation

  • Added UI integration tests that verify base value updates correctly when changed via updatePersistedState
  • Tests pass locally: TEST_INTEGRATION=1 bun x jest tests/ui/reviewBaseSelector.integration.test.ts

Generated with mux • Model: anthropic:claude-opus-4-5 • Thinking: high • Cost: $13.69

@github-actions github-actions bot added the bug label Jan 24, 2026
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 83a2544919

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

- Change onFiltersChange handlers to use callback form: (prev) => ({ ...prev, field: value })
- This avoids potential stale closure issues when filters prop is captured
- Add data-testid props for testing base selector
- Add UI integration tests for base value sync
- Refactor BaseSelectorPopover from Radix Portal to conditional rendering
  (matches AgentModePicker pattern, enables happy-dom testing)
- Add onMouseDown preventDefault on suggestion buttons to prevent blur
- Update tests/ui with UI-driven interaction tests (2 tests, ~4s)
- Add --no-sandbox flag for E2E tests running as root

Fixes regression where clicking suggestions in diff base dropdown had no effect.
@ammario ammario merged commit be5e9cc into main Jan 24, 2026
23 checks passed
@ammario ammario deleted the review-base-exfb branch January 24, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants