Skip to content

feat(ai): mode toggle UI and add AI support for folder & collection - #8385

Merged
sid-bruno merged 2 commits into
usebruno:mainfrom
naman-bruno:design/toolbar
Jun 26, 2026
Merged

sid-bruno merged 2 commits into
usebruno:mainfrom
naman-bruno:design/toolbar

Conversation

@naman-bruno

@naman-bruno naman-bruno commented Jun 26, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Updated UI for mode toggle and added ai context for folder and collection level.

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
    • Enhanced AI chat context handling across requests, folders, and collections, including more accurate labeling for root and folder conversations.
    • Improved content-type routing so the AI experience matches the active app/request tab context.
  • UI Improvements
    • Replaced “app” icons with a consistent window-style icon across the sidebar, request tabs, and empty state.
    • Refined the view-mode toggle layout, tooltips, and active/hover styling for clearer switching.
  • Bug Fixes
    • Stabilized AI chat initialization and switching by safely handling missing context and updating chat persistence accordingly.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

AiChatSidebar now derives a shared context for requests, folders, and collections, and routes chat history plus apply-code actions through that context. The app also switches several App icons to IconAppWindow and updates the collection header mode toggle layout, tooltips, and active-state styling.

Changes

AI Chat Sidebar context flow

Layer / File(s) Summary
Context and content derivation
packages/bruno-app/src/components/AiChatSidebar/index.js
AiChatSidebar derives aiContext, computes contentType and allContent from request, folder, and collection state, binds chat history to aiContext.pathname, labels chats by root/folder/request method, and returns null without aiContext.
Apply code dispatch
packages/bruno-app/src/components/AiChatSidebar/index.js
handleApplyCode now requires aiContext and dispatches request, folder, or collection update actions according to targetType.
Method badge colors
packages/bruno-app/src/components/AiChatSidebar/StyledWrapper.js
The header method badge adds grpc, ws, gql, and app color selectors from the theme.

App view and icon refresh

Layer / File(s) Summary
CollectionHeader mode toggle
packages/bruno-app/src/components/RequestTabs/CollectionHeader/StyledWrapper.js, packages/bruno-app/src/components/RequestTabs/CollectionHeader/index.js
The mode toggle becomes an inline-flex control with updated active and hover styling, per-button ToolHint wrappers, an IconAppWindow App icon, and the AI Assistant block inside !isScratchCollection.
App icon swaps
packages/bruno-app/src/components/AppView/EmptyAppState.js, packages/bruno-app/src/components/RequestTabs/RequestTab/index.js, packages/bruno-app/src/components/Sidebar/Collections/Collection/...
The empty state, request tabs, collection item icon, and New App menu entries switch their App icon from IconApps to IconAppWindow.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant FocusedTab
  participant AiChatSidebar
  participant ChatHistory
  participant CollectionsSlice
  User->>FocusedTab: select request, folder, or collection
  FocusedTab->>AiChatSidebar: active item/selection
  AiChatSidebar->>AiChatSidebar: derive aiContext, contentType, and allContent
  AiChatSidebar->>ChatHistory: setChatBinding(aiContext.pathname)
  AiChatSidebar->>ChatHistory: refreshChatHistory()
  User->>AiChatSidebar: apply AI code
  AiChatSidebar->>CollectionsSlice: dispatch updateRequest*/updateFolder*/updateCollection*
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • usebruno/bruno#6463 — Updates request-method theme mappings that match the new grpc/ws/gql badge colors.
  • usebruno/bruno#6603 — Adjusts method-badge styling around the same theme-driven color path used here.

Suggested reviewers

  • sid-bruno
  • helloanoop
  • lohit-bruno

Poem

A window icon winked in the app,
while chat learned folders, roots, and tabs.
Tooltips lined up in a tidy row,
and colors for grpc/ws/gql now glow,
with App mode humming softly back.

🚥 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 accurately summarizes the main changes: AI mode toggle UI updates and added folder/collection AI support.
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.

@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: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/bruno-app/src/components/RequestTabs/CollectionHeader/index.js (2)

654-709: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Please cover the new toggle/AI visibility behavior with a component test.

This hunk changes both the per-button toggle structure and the !isScratchCollection gate for the AI Assistant, but there is no matching behavioral coverage in the provided changes. A focused test here would lock down the active mode state and confirm the AI shortcut stays hidden for scratch collections. As per coding guidelines, "Add tests for any new functionality or meaningful changes."

🤖 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/RequestTabs/CollectionHeader/index.js`
around lines 654 - 709, The new view-mode toggle and AI Assistant visibility
changes in CollectionHeader need component test coverage. Add a focused test
around CollectionHeader that exercises the mode buttons and verifies the active
class/state for Request, App, and File toggles, then add a case proving the AI
Assistant ActionIcon renders only when !isScratchCollection and stays hidden for
scratch collections. Use the existing identifiers like CollectionHeader,
view-mode-request/view-mode-app/view-mode-file, and ai-assistant to locate and
assert the behavior.

Source: Coding guidelines


657-696: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Add accessible names to the mode toggle buttons.

These are still icon-only <button> elements, and ToolHint does not provide an accessible name for them. Screen readers will hit three unnamed controls here unless you add aria-label/title on each button.

🤖 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/RequestTabs/CollectionHeader/index.js`
around lines 657 - 696, The icon-only mode toggle buttons in CollectionHeader
need accessible names because ToolHint is not a substitute for one. Update the
three button elements in the mode-toggle block to include clear aria-label
values (and title if desired) for Request, App, and File, so screen readers can
identify each control by its purpose.
🧹 Nitpick comments (1)
packages/bruno-app/src/components/RequestTabs/CollectionHeader/StyledWrapper.js (1)

244-248: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid hardcoding the active shadow color here.

rgba(0, 0, 0, 0.15) bypasses the styled-components theme, so this state cannot adapt with theme changes the way the rest of the toggle does. Please source the shadow color from props.theme as well. As per coding guidelines, "Use styled component's theme prop to manage CSS colors and not CSS variables when in the context of a styled component or any React component using styled components."

🤖 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/RequestTabs/CollectionHeader/StyledWrapper.js`
around lines 244 - 248, The active state in StyledWrapper’s `.active` styles
uses a hardcoded shadow color, so it won’t adapt with theme changes. Update the
`box-shadow` in the active toggle styling to read the shadow color from
`props.theme` instead of embedding `rgba(0, 0, 0, 0.15)`, following the same
theme-driven pattern used by the surrounding `background`, `color`, and
`border-color` values.

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/AiChatSidebar/index.js`:
- Around line 273-276: The request-chat tab mapping in AiChatSidebar is ignoring
the selected script sub-tab, so script chats always resolve to pre-request.
Update the switch that maps requestPaneTab to use scriptPaneTab for the 'script'
case, matching the folder and collection branches, so post-response script chats
target the correct content/diff destination.
- Around line 483-500: The folder/collection write flow in AiChatSidebar is
incorrectly marking unsupported targetType values as accepted even when no
dispatch happens. Update the handling around the folder and collection switch
statements so the accepted status is only set when a supported targetType
actually triggers one of the updateFolder* or updateCollection* actions; for the
default case, leave the write unaccepted or return early before the accepted
flag is set.
- Around line 349-361: The requestContext memo in AiChatSidebar currently treats
every aiContext.kind === 'request' as an HTTP request, which also includes
activeItem.type === 'app' and produces an empty requestContext. Update the guard
in the useMemo that builds requestContext to only return data for actual request
items, using aiContext.item / activeItem.type checks alongside the existing
request kind logic, so App chats skip HTTP request context entirely.

---

Outside diff comments:
In `@packages/bruno-app/src/components/RequestTabs/CollectionHeader/index.js`:
- Around line 654-709: The new view-mode toggle and AI Assistant visibility
changes in CollectionHeader need component test coverage. Add a focused test
around CollectionHeader that exercises the mode buttons and verifies the active
class/state for Request, App, and File toggles, then add a case proving the AI
Assistant ActionIcon renders only when !isScratchCollection and stays hidden for
scratch collections. Use the existing identifiers like CollectionHeader,
view-mode-request/view-mode-app/view-mode-file, and ai-assistant to locate and
assert the behavior.
- Around line 657-696: The icon-only mode toggle buttons in CollectionHeader
need accessible names because ToolHint is not a substitute for one. Update the
three button elements in the mode-toggle block to include clear aria-label
values (and title if desired) for Request, App, and File, so screen readers can
identify each control by its purpose.

---

Nitpick comments:
In
`@packages/bruno-app/src/components/RequestTabs/CollectionHeader/StyledWrapper.js`:
- Around line 244-248: The active state in StyledWrapper’s `.active` styles uses
a hardcoded shadow color, so it won’t adapt with theme changes. Update the
`box-shadow` in the active toggle styling to read the shadow color from
`props.theme` instead of embedding `rgba(0, 0, 0, 0.15)`, following the same
theme-driven pattern used by the surrounding `background`, `color`, and
`border-color` values.
🪄 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: 3bb39a36-9b1a-4b51-b911-87d47a8dc8a7

📥 Commits

Reviewing files that changed from the base of the PR and between 7756564 and 4679df2.

📒 Files selected for processing (9)
  • packages/bruno-app/src/components/AiChatSidebar/StyledWrapper.js
  • packages/bruno-app/src/components/AiChatSidebar/index.js
  • packages/bruno-app/src/components/AppView/EmptyAppState.js
  • packages/bruno-app/src/components/RequestTabs/CollectionHeader/StyledWrapper.js
  • packages/bruno-app/src/components/RequestTabs/CollectionHeader/index.js
  • packages/bruno-app/src/components/RequestTabs/RequestTab/index.js
  • packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/CollectionItemIcon/index.js
  • packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js
  • packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js

utkarsh-bruno
utkarsh-bruno previously approved these changes Jun 26, 2026

@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. Just verify the coderabbit comment that does mention about using case 'script' for both post-response and pre-request, as I guess we'd be needing the sidebar for both.

Rest looks fine.

@sid-bruno
sid-bruno merged commit 30b4512 into usebruno:main Jun 26, 2026
15 of 19 checks passed
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.

3 participants