Repository navigation
feat(ai): mode toggle UI and add AI support for folder & collection - #8385
Conversation
|
Caution Review failedPull request was closed or merged during review WalkthroughAiChatSidebar 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 ChangesAI Chat Sidebar context flow
App view and icon refresh
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*
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
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 |
There was a problem hiding this comment.
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 winPlease cover the new toggle/AI visibility behavior with a component test.
This hunk changes both the per-button toggle structure and the
!isScratchCollectiongate 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 winAdd accessible names to the mode toggle buttons.
These are still icon-only
<button>elements, andToolHintdoes not provide an accessible name for them. Screen readers will hit three unnamed controls here unless you addaria-label/titleon 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 winAvoid 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 fromprops.themeas 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
📒 Files selected for processing (9)
packages/bruno-app/src/components/AiChatSidebar/StyledWrapper.jspackages/bruno-app/src/components/AiChatSidebar/index.jspackages/bruno-app/src/components/AppView/EmptyAppState.jspackages/bruno-app/src/components/RequestTabs/CollectionHeader/StyledWrapper.jspackages/bruno-app/src/components/RequestTabs/CollectionHeader/index.jspackages/bruno-app/src/components/RequestTabs/RequestTab/index.jspackages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/CollectionItemIcon/index.jspackages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.jspackages/bruno-app/src/components/Sidebar/Collections/Collection/index.js
utkarsh-bruno
left a comment
There was a problem hiding this comment.
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.
Description
Updated UI for mode toggle and added ai context for folder and collection level.
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