Repository navigation
feat(ai): add security preferences management to AI settings - #8453
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds AI security preferences for redaction toggles and custom lists, threads them through redaction formatting and prompt/chat IPC paths, and adds a new Security tab UI. Also adjusts toggle handling/transitions and preference save rollback behavior. ChangesAI Security Redaction Feature
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (1)
packages/bruno-app/src/components/Preferences/AI/index.js (1)
45-52: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a focused test for the new Security tab flow.
This PR adds new form state, normalization, and save mapping for security preferences, but this cohort has no matching test. One behavioral test that toggles a redaction flag, adds/removes a custom chip, and asserts the saved preferences payload would cover the highest-risk path. As per coding guidelines, "Add tests for any new functionality or meaningful changes".
Also applies to: 100-107, 129-140, 308-318, 480-498
🤖 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 `@packages/bruno-app/src/components/Preferences/AI/index.js` around lines 45 - 52, The new Security preferences flow in Preferences/AI/index.js lacks coverage for the updated form state and save mapping. Add a focused behavioral test around the Security tab path that uses the relevant helpers/components (such as the preferences form and save handler) to toggle a redaction flag, add and remove a custom chip, and verify the persisted preferences payload reflects the normalized security fields.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.
Inline comments:
In `@packages/bruno-app/src/components/Preferences/AI/SecurityPane.js`:
- Around line 22-34: The ChipListEditor in SecurityPane should enforce the same
persisted limits as the preference store. Update handleAdd (and any edit/update
path in ChipListEditor) to reject values over 200 characters and stop adding
when the current list already has 200 items, matching the validation used by
preferences in AI/index.js and store/preferences.js. Keep the guard local to the
editor so users can’t create chips that look valid in UI but fail to persist.
- Around line 77-82: Add a stable Playwright hook to the chip removal control in
SecurityPane by updating the remove button in the chip list to include a unique
data-testid alongside the existing aria-label and onClick handleRemove(name).
Use a consistent identifier tied to the chip name so tests can target the
specific delete action without relying on CSS classes or text.
In `@packages/bruno-app/src/providers/ReduxStore/slices/app.js`:
- Around line 302-312: Guard the rollback in savePreferences so an older failed
ipcRenderer.invoke('renderer:save-preferences') call cannot overwrite a newer
successful update in Redux. Track each request in savePreferences with a unique
request id or compare the current app.preferences against the optimistic
preferences payload before dispatching updatePreferences(previous) in the catch
handler. Only restore the previous snapshot when the store still reflects this
request’s own optimistic state, and leave newer preferences untouched.
In `@packages/bruno-electron/src/ipc/ai/autocomplete-prompts.js`:
- Around line 91-94: The body handling in autocomplete prompts is bypassing
`redactBody` for raw modes, so text/XML content can still be sent verbatim.
Update the bodyText selection logic in the autocomplete prompt builder to honor
the redaction policy for the `body.mode === 'text'` and `body.mode === 'xml'`
branches, using the same redaction path/pattern already used for JSON and
ensuring `redactBody` is respected before sending content to the model.
In `@packages/bruno-electron/src/ipc/ai/context.js`:
- Around line 174-185: The redaction logic in redactJsonBodyValues only masks
sensitive keys when their direct value is primitive, so nested objects under
keys like password can still leak data. Update redactJsonBodyValues to treat any
policy.isSensitiveKey(key) as fully redacted regardless of value type, while
keeping the existing recursion for non-sensitive keys and preserving the
maxDepth truncation behavior.
- Around line 264-271: The form body rendering in context.js is using maskHeader
for formUrlEncoded and multipartForm values, which ties body redaction to header
redaction. Update the logic in the body formatting switch so URL-encoded and
multipart fields respect redactBody instead of redactHeaders, using the existing
redaction helper path consistently with other body types while still preserving
file placeholders in multipartForm.
---
Nitpick comments:
In `@packages/bruno-app/src/components/Preferences/AI/index.js`:
- Around line 45-52: The new Security preferences flow in
Preferences/AI/index.js lacks coverage for the updated form state and save
mapping. Add a focused behavioral test around the Security tab path that uses
the relevant helpers/components (such as the preferences form and save handler)
to toggle a redaction flag, add and remove a custom chip, and verify the
persisted preferences payload reflects the normalized security fields.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2d9fe299-c36f-4b16-a683-013dda393b57
📒 Files selected for processing (14)
packages/bruno-app/src/components/Preferences/AI/SecurityPane.jspackages/bruno-app/src/components/Preferences/AI/StyledWrapper.jspackages/bruno-app/src/components/Preferences/AI/index.jspackages/bruno-app/src/components/ToggleSwitch/StyledWrapper.jspackages/bruno-app/src/components/ToggleSwitch/index.jspackages/bruno-app/src/providers/ReduxStore/slices/app.jspackages/bruno-electron/src/ipc/ai/autocomplete-prompts.jspackages/bruno-electron/src/ipc/ai/autocomplete.jspackages/bruno-electron/src/ipc/ai/chat.jspackages/bruno-electron/src/ipc/ai/context.jspackages/bruno-electron/src/ipc/ai/context.spec.jspackages/bruno-electron/src/ipc/ai/index.jspackages/bruno-electron/src/ipc/ai/script-prompts.jspackages/bruno-electron/src/store/preferences.js
utkarsh-bruno
left a comment
There was a problem hiding this comment.
Looks good to me.
Description
Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.
Summary by CodeRabbit