Skip to content

fix(ai): render AI assist popup via portal to prevent clipping by response pane - #8463

Merged
naman-bruno merged 2 commits into
usebruno:mainfrom
gopu-bruno:fix/ai-assist-popup-clipped-by-console
Jul 2, 2026
Merged

naman-bruno merged 2 commits into
usebruno:mainfrom
gopu-bruno:fix/ai-assist-popup-clipped-by-console

Conversation

@gopu-bruno

@gopu-bruno gopu-bruno commented Jul 2, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fixes an issue where the AI Assist Popup was clipped or appeared below by the response tab when using the horizontal layout. The Popup now correctly appears above the terminal, ensuring the complete AI-generated output remains visible across all AI-enabled tabs.

JIRA

Screenshot of the fix

Screenshot 2026-07-02 at 12 51 38 PM

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

    • The AI Assist popup now opens as a floating dialog and renders correctly outside the main panel.
    • Keyboard behavior is improved, including automatic focus when opened and closing with Escape.
  • Bug Fixes

    • Fixed popup styling so it displays consistently when rendered in the page body.
    • Improved popup lifecycle behavior when switching between the prompt and preview states.
  • Tests

    • Added coverage to confirm the popup is rendered in the expected location.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The AIAssist popup is refactored from a manually rendered conditional div to a Tippy-driven portal component. Styling is moved to a new exported PopupWrapper, popup lifecycle uses refs and Tippy's show/hide/render APIs, and a new test verifies the popup portals into document.body.

Changes

AIAssist Popup Migration to Tippy

Layer / File(s) Summary
Popup styling extraction
packages/bruno-app/src/components/AIAssist/StyledWrapper.js
Removes .ai-assist-popup styles and exports PopupWrapper styled-component with a comment on Tippy rendering into document.body.
Popup state, refs, and lifecycle handling
packages/bruno-app/src/components/AIAssist/index.js
Imports PopupWrapper, adds streamIdRef/tippyRef, focus and Escape-key handling via useEffect, and changes close to hide the Tippy instance instead of mutating state directly.
Tippy render prop and popup content
packages/bruno-app/src/components/AIAssist/index.js
Replaces manual popup div and document event listeners with a Tippy component using a render prop for prompt/suggestions/error/preview UI, plus onCreate, onShow, onHide handlers.
Portal rendering test
packages/bruno-app/src/components/AIAssist/index.spec.js
Adds a test asserting the popup's data-tippy-root container is mounted under document.body.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • usebruno/bruno#8220: Introduced the original AIAssist/StyledWrapper popup UI and styling that this PR refactors into a Tippy-based portal.

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

Poem

A popup once trapped in a div so tight,
Now hops through a portal, out into the light. 🐇
Tippy holds the reins, Escape shuts the door,
Styled wrapper trimmed down, lean as before.
Tests confirm it lands on document.body's floor. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: rendering the AI assist popup via a portal to avoid clipping.
✨ 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: 1

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

72-90: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Focus logic is duplicated with onShow; consider consolidating.

The focus effect (Lines 73-77) re-focuses .popup-input on open, which onShow's rAF (Lines 177-181) already handles. The only path unique to this effect is the preview→prompt transition. Both effects are also pure side-effects that could live in a small custom hook (e.g. usePopupKeyboard/usePopupFocus) to keep the component lean.

As per coding guidelines: "MUST: Prefer custom hooks for business logic, data fetching, and side-effects in React".

🤖 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/AIAssist/index.js` around lines 72 - 90,
The focus behavior in AIAssist/index.js is duplicated between the opening effect
and the existing onShow handler, so consolidate it into a single focus path and
keep only the preview-to-prompt special case in the effect. Move the side-effect
logic into a small custom hook such as usePopupFocus or usePopupKeyboard, and
have the component use that hook instead of managing focus directly. Keep the
unique symbols useEffect, onShow, and
tippyRef.current?.popper?.querySelector('.popup-input') as the places to update.

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/AIAssist/index.js`:
- Around line 182-185: The AIAssist popup hide handler currently only closes the
panel and clears the error, so an in-flight generation can keep running and
stale prompt/preview state can reappear on reopen. Update the onHide logic in
AIAssist to also stop/cancel the active stream or request and reset all
transient generation state so hiding always returns the component to a clean
slate. Use the existing AIAssist state setters and any stream control helpers in
that component to ensure both the request and UI state are cleared together.

---

Nitpick comments:
In `@packages/bruno-app/src/components/AIAssist/index.js`:
- Around line 72-90: The focus behavior in AIAssist/index.js is duplicated
between the opening effect and the existing onShow handler, so consolidate it
into a single focus path and keep only the preview-to-prompt special case in the
effect. Move the side-effect logic into a small custom hook such as
usePopupFocus or usePopupKeyboard, and have the component use that hook instead
of managing focus directly. Keep the unique symbols useEffect, onShow, and
tippyRef.current?.popper?.querySelector('.popup-input') as the places to update.
🪄 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: e50bbefc-c7ac-4e40-8dee-0ce56816fbd7

📥 Commits

Reviewing files that changed from the base of the PR and between 6f96dfd and 2a670b7.

📒 Files selected for processing (3)
  • packages/bruno-app/src/components/AIAssist/StyledWrapper.js
  • packages/bruno-app/src/components/AIAssist/index.js
  • packages/bruno-app/src/components/AIAssist/index.spec.js

@gopu-bruno gopu-bruno changed the title fix(ai): render AI assist popup via portal to prevent clipping by devtools fix(ai): render AI assist popup via portal to prevent clipping by response pane Jul 2, 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.

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