Skip to content

feat(ai): add security preferences management to AI settings - #8453

Merged
naman-bruno merged 4 commits into
usebruno:mainfrom
naman-bruno:feat/ai-security
Jul 2, 2026
Merged

naman-bruno merged 4 commits into
usebruno:mainfrom
naman-bruno:feat/ai-security

Conversation

@naman-bruno

@naman-bruno naman-bruno commented Jul 1, 2026 •

Copy link
Copy Markdown
Collaborator

Description

  • Introduced a new SecurityPane component for managing redaction preferences.
  • Updated AI preferences schema to include security settings for headers, body, variables, and responses.
  • Enhanced the AI component to support toggling redaction options and custom redacted headers/variables.
  • Implemented UI updates to allow users to configure security settings directly within the AI preferences.
  • Added validation for new security fields in the preferences schema.
  • Updated Redux store to handle security preferences and ensure persistence across sessions.

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

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

  • New Features
    • Added an AI Security tab with controls to redact headers, body fields, variables, and responses, plus custom “always redact” header/variable lists.
  • Bug Fixes
    • AI scripting, autocomplete prompts, and streamed chat now consistently apply the configured redaction rules to rendered request/variable/response content.
    • Preference saving now optimistically updates and rolls back on save failure.
  • Tests
    • Expanded automated coverage for security-driven redaction and variable tagging.
  • Style
    • Improved Security UI styling and refined toggle transition animations.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7ecef53b-7a97-4ad7-ad13-1dd16981cc4e

📥 Commits

Reviewing files that changed from the base of the PR and between 2c2b5cb and 40761bd.

📒 Files selected for processing (1)
  • packages/bruno-electron/src/ipc/ai/index.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bruno-electron/src/ipc/ai/index.js

Walkthrough

Adds 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.

Changes

AI Security Redaction Feature

Layer / File(s) Summary
Preferences state and persistence
packages/bruno-electron/src/store/preferences.js, packages/bruno-app/src/providers/ReduxStore/slices/app.js
Adds ai.security defaults and validation, extends Redux initial state, and changes preference saving to optimistically update state then revert on IPC failure.
Redaction policy and formatting
packages/bruno-electron/src/ipc/ai/context.js, packages/bruno-electron/src/ipc/ai/context.spec.js
Adds policy helpers and applies security-aware redaction to request contexts, response shapes, JSON bodies, variables, and search results, with tests for the new behavior.
Prompt and IPC security threading
packages/bruno-electron/src/ipc/ai/{autocomplete-prompts,chat,script-prompts,index}.js
Passes security through autocomplete, chat, and script-generation paths so prompt construction and tool formatting use the configured redaction policy.
Security preferences UI
packages/bruno-app/src/components/Preferences/AI/{SecurityPane,StyledWrapper,index}.js
Adds the Security tab, its redaction controls, chip editors, default coverage text, schema/form wiring, and styling.
ToggleSwitch interaction and transitions
packages/bruno-app/src/components/ToggleSwitch/{index,StyledWrapper}.js
Moves toggle handling to the checkbox and shortens the switch transition timings.

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

Possibly related PRs

  • usebruno/bruno#8048: Both changes extend the AI preferences state shape in packages/bruno-app/src/providers/ReduxStore/slices/app.js.
  • usebruno/bruno#8220: Shared script-prompt and request-context formatting paths are extended here with security-aware redaction.
  • usebruno/bruno#8404: Both modify the AI context variable formatting path used for search and prompt rendering.

Suggested labels: size/XXL

Suggested reviewers: helloanoop, bijin-bruno, lohit-bruno, sid-bruno, vijayh-bruno, utkarsh-bruno

Poem

A tiny shield now joins the chat,
With chips and toggles wearing hats.
Secrets fade, but flows still sing,
Through prompts and panes and every ring.
🔒✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding AI security preferences management to the settings UI.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@naman-bruno

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 6

🧹 Nitpick comments (1)
packages/bruno-app/src/components/Preferences/AI/index.js (1)

45-52: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4f31e9b and 097b753.

📒 Files selected for processing (14)
  • packages/bruno-app/src/components/Preferences/AI/SecurityPane.js
  • packages/bruno-app/src/components/Preferences/AI/StyledWrapper.js
  • packages/bruno-app/src/components/Preferences/AI/index.js
  • packages/bruno-app/src/components/ToggleSwitch/StyledWrapper.js
  • packages/bruno-app/src/components/ToggleSwitch/index.js
  • packages/bruno-app/src/providers/ReduxStore/slices/app.js
  • packages/bruno-electron/src/ipc/ai/autocomplete-prompts.js
  • packages/bruno-electron/src/ipc/ai/autocomplete.js
  • packages/bruno-electron/src/ipc/ai/chat.js
  • packages/bruno-electron/src/ipc/ai/context.js
  • packages/bruno-electron/src/ipc/ai/context.spec.js
  • packages/bruno-electron/src/ipc/ai/index.js
  • packages/bruno-electron/src/ipc/ai/script-prompts.js
  • packages/bruno-electron/src/store/preferences.js

@utkarsh-bruno utkarsh-bruno left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me.

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