Skip to content

feat(wren-ui): show intent reasoning for general answer#1868

Merged
fredalai merged 2 commits intomainfrom
feat/intent-reasoning
Aug 6, 2025
Merged

feat(wren-ui): show intent reasoning for general answer#1868
fredalai merged 2 commits intomainfrom
feat/intent-reasoning

Conversation

@fredalai
Copy link
Copy Markdown
Contributor

@fredalai fredalai commented Aug 5, 2025

Description

This PR adds intent reasoning support to the prompt result component. The feature displays AI's intent analysis reasoning to users, providing transparency about how the system interprets and processes their questions. This enhancement helps users understand the AI's thought process and reasoning behind the generated responses.

Implementation

The implementation adds a new intent reasoning section to the GeneralAnswer component in the prompt result. A new BrainSVG icon component was created to visually represent the intent analysis process. The intent reasoning is displayed in a styled container above the main answer content, showing the AI's analysis of the user's question intent.

Actual Changes

  • Added intent reasoning display section in Result.tsx GeneralAnswer component

    • Added styled container with brain icon and "Analyzing Intent" label
    • Displays data.intentReasoning content with proper indentation
  • Created new BrainSVG.tsx component

    • Custom SVG brain icon with configurable styling
    • Supports fillCurrentColor and className props for flexibility
  • Updated svgs/index.ts to export the new BrainSVG component

    • Added export statement for the new icon component

Screenshots

截圖 2025-08-06 上午10 29 19

(Deprecation)
截圖 2025-08-05 下午4 34 58

截圖 2025-08-05 下午4 34 34

Test Verification

Manual testing should verify:

  • Intent reasoning displays correctly in the prompt result
  • BrainSVG icon renders properly with different styling options
  • Component integration works without breaking existing functionality

Summary by CodeRabbit

  • New Features

    • Added a "User Intent Recognized" section with a brain icon and explanatory text to the GeneralAnswer component.
    • Introduced a brain SVG icon for enhanced visual feedback during intent recognition.
  • Style

    • Updated layout and styling to accommodate the new intent recognition section and icon.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 5, 2025

Walkthrough

A new brain SVG icon component is introduced and exported for use within the application. The GeneralAnswer component on the home prompt page is updated to display a "User Intent Recognized" section with the brain icon and intent reasoning text, accompanied by style adjustments to accommodate the new UI element.

Changes

Cohort / File(s) Change Summary
GeneralAnswer UI Update
wren-ui/src/components/pages/home/prompt/Result.tsx
Adds a "User Intent Recognized" section with a brain SVG icon and intent reasoning text; adjusts scrollable content height and styles accordingly.
BrainSVG Component Introduction
wren-ui/src/utils/svgs/BrainSVG.tsx
Introduces a new BrainSVG React component rendering a customizable brain icon SVG with stroke styling.
SVG Exports Update
wren-ui/src/utils/svgs/index.ts
Adds export for the new BrainSVG component to the SVG utilities index.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A brainy SVG hops in with style,
Intent now recognized, it lingers a while.
With icons and code both shiny and neat,
The UI grows smarter—a visual treat!
🧠✨
— A rabbit who loves clever feats

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d109911 and 3098f52.

📒 Files selected for processing (1)
  • wren-ui/src/components/pages/home/prompt/Result.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • wren-ui/src/components/pages/home/prompt/Result.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript-typescript)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/intent-reasoning

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
wren-ui/src/utils/svgs/BrainSVG.tsx (1)

10-13: Width / height should be configurable for better re-use.

Hard-coding width="20" and height="20" forces consumers to override via CSS every time a different size is required. Consider accepting size, width, and height props with sensible defaults and forwarding them to the <svg> element.

wren-ui/src/components/pages/home/prompt/Result.tsx (1)

35-38: Prefer relative units over fixed PX for SVG sizing.

The .adm-brain-svg rule fixes the icon at 14px. Using em/rem would scale with user font-size settings and improve accessibility.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 48935b5 and eeb60a6.

📒 Files selected for processing (3)
  • wren-ui/src/components/pages/home/prompt/Result.tsx (3 hunks)
  • wren-ui/src/utils/svgs/BrainSVG.tsx (1 hunks)
  • wren-ui/src/utils/svgs/index.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
wren-ui/src/components/pages/home/prompt/Result.tsx (1)
wren-ui/src/utils/svgs/BrainSVG.tsx (1)
  • BrainSVG (1-30)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
wren-ui/src/utils/svgs/index.ts (1)

5-5: Re-export looks good.

No concerns – the central svgs barrel now properly re-exports the new BrainSVG component for tree-shakable imports elsewhere in the UI.

Comment on lines +216 to +223
<div className="bg-gray-2 gray-6 py-2 px-3">
<div className="d-flex align-center">
<BrainSVG className="mr-2 adm-brain-svg" />
<span className="text-medium ">Analyzing Intent</span>
</div>
<div style={{ paddingLeft: 22 }}>{data?.intentReasoning}</div>
</div>

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.

⚠️ Potential issue

Render intent section only when reasoning is available.

If data.intentReasoning is empty or undefined, the UI still shows the “Analyzing Intent” header followed by a blank / undefined string, which feels broken.

-        <div className="bg-gray-2 gray-6 py-2 px-3">
+        {!!data?.intentReasoning?.trim() && (
+          <div className="bg-gray-2 gray-6 py-2 px-3">
             <div className="d-flex align-center">
               <BrainSVG className="mr-2 adm-brain-svg" />
               <span className="text-medium ">Analyzing Intent</span>
             </div>
             <div style={{ paddingLeft: 22 }}>{data.intentReasoning}</div>
-        </div>
+          </div>
+        )}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div className="bg-gray-2 gray-6 py-2 px-3">
<div className="d-flex align-center">
<BrainSVG className="mr-2 adm-brain-svg" />
<span className="text-medium ">Analyzing Intent</span>
</div>
<div style={{ paddingLeft: 22 }}>{data?.intentReasoning}</div>
</div>
{!!data?.intentReasoning?.trim() && (
<div className="bg-gray-2 gray-6 py-2 px-3">
<div className="d-flex align-center">
<BrainSVG className="mr-2 adm-brain-svg" />
<span className="text-medium ">Analyzing Intent</span>
</div>
<div style={{ paddingLeft: 22 }}>{data.intentReasoning}</div>
</div>
)}
🤖 Prompt for AI Agents
In wren-ui/src/components/pages/home/prompt/Result.tsx around lines 216 to 223,
the intent section renders the "Analyzing Intent" header and an empty or
undefined reasoning string even when data.intentReasoning is missing. To fix
this, wrap the entire intent section JSX in a conditional check that only
renders it if data.intentReasoning is truthy, preventing the header and empty
content from displaying when no reasoning is available.

className="py-2 px-3"
style={{ maxHeight: 'calc(100vh - 420px)', overflowY: 'auto' }}
style={{ maxHeight: 'calc(100vh - 480px)', overflowY: 'auto' }}
>
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.

🛠️ Refactor suggestion

Magic 480px offset may break on future layout changes.

The scroll container’s maxHeight is manually adjusted from 420px to 480px to account for the new header. Consider calculating this via flexbox, CSS grid, or a CSS variable so the value stays correct if more elements are added or heights change.

🤖 Prompt for AI Agents
In wren-ui/src/components/pages/home/prompt/Result.tsx at line 228, the scroll
container's maxHeight is hardcoded as 480px, which is a magic number that may
break with future layout changes. Replace this fixed pixel value by using a CSS
variable, flexbox, or CSS grid to dynamically calculate the height based on the
header or surrounding elements, ensuring the layout adapts automatically if
element sizes change.

Comment on lines +18 to +26
stroke={fillCurrentColor ? 'currentColor' : undefined}
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M9.86341 9.78626C9.43808 10.1961 8.71083 10.2668 8.08927 9.91734C7.46766 9.56784 7.15026 8.90976 7.27946 8.33334"
stroke={fillCurrentColor ? 'currentColor' : undefined}
strokeWidth="1.5"
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.

⚠️ Potential issue

fillCurrentColor makes the icon disappear when set to false.

When fillCurrentColor is false, the stroke attribute is omitted, which defaults to none; both paths therefore render invisible. Either remove the prop or replace it with an explicit strokeColor fallback.

-      stroke={fillCurrentColor ? 'currentColor' : undefined}
+      stroke={fillCurrentColor ? 'currentColor' : 'inherit'}

(or introduce a strokeColor prop that defaults to currentColor).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
stroke={fillCurrentColor ? 'currentColor' : undefined}
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M9.86341 9.78626C9.43808 10.1961 8.71083 10.2668 8.08927 9.91734C7.46766 9.56784 7.15026 8.90976 7.27946 8.33334"
stroke={fillCurrentColor ? 'currentColor' : undefined}
strokeWidth="1.5"
stroke={fillCurrentColor ? 'currentColor' : 'inherit'}
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M9.86341 9.78626C9.43808 10.1961 8.71083 10.2668 8.08927 9.91734C7.46766 9.56784 7.15026 8.90976 7.27946 8.33334"
stroke={fillCurrentColor ? 'currentColor' : undefined}
strokeWidth="1.5"
🤖 Prompt for AI Agents
In wren-ui/src/utils/svgs/BrainSVG.tsx around lines 18 to 26, the stroke
attribute is conditionally set to 'currentColor' or undefined based on
fillCurrentColor, causing the icon to disappear when fillCurrentColor is false
because stroke defaults to none. Fix this by either removing the
fillCurrentColor prop or replacing it with a strokeColor prop that defaults to
'currentColor', and use strokeColor explicitly for the stroke attribute to
ensure the paths always render visibly.

@fredalai fredalai force-pushed the feat/intent-reasoning branch from eeb60a6 to d109911 Compare August 5, 2025 10:20
Copy link
Copy Markdown
Contributor

@andreashimin andreashimin left a comment

Choose a reason for hiding this comment

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

lgtm

@fredalai fredalai merged commit e076609 into main Aug 6, 2025
10 checks passed
@fredalai fredalai deleted the feat/intent-reasoning branch August 6, 2025 03:09
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