Skip to content

feat: add Reasoning AI element#864

Merged
rohanchkrabrty merged 4 commits into
mainfrom
feat-ai-reasoning
Jul 24, 2026
Merged

feat: add Reasoning AI element#864
rohanchkrabrty merged 4 commits into
mainfrom
feat-ai-reasoning

Conversation

@rohanchkrabrty

Copy link
Copy Markdown
Contributor

Summary

  • Adds the Reasoning AI-element component to packages/raystack — a collapsible thinking block built on Collapsible for displaying model reasoning/chain-of-thought in chat UIs.
  • Supports a streaming prop that shows a shimmering "Thinking…" label and auto-opens the panel while reasoning streams in, auto-collapsing when done unless the user has toggled it manually, plus a duration prop that renders a "Worked for N seconds" label afterward.
  • Ships CSS-module styling with --rs-* tokens and unit tests covering open/close, streaming auto-open/collapse, and controlled usage.
  • Adds a Reasoning docs page (demos and props tables) under the AI Elements section of the website and exports the component from the package root.
  • Stacked on feat: add Message AI element component #863 (feat-ai-message) — review that PR first; this branch adds one commit on top.

rohanchkrabrty and others added 3 commits July 23, 2026 11:27
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C7QST4WHS5DmTqgJkvQoyf
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C7QST4WHS5DmTqgJkvQoyf
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C7QST4WHS5DmTqgJkvQoyf
@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
apsara Ready Ready Preview, Comment Jul 24, 2026 4:51am

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new Reasoning component with collapsible content, streaming-aware open state, duration-based labels, custom triggers, and labeled steps. The component is styled with responsive motion behavior, exported from the Raystack package, and covered by tests. A documentation page, interactive demos, prop definitions, accessibility guidance, and navigation metadata are also added.

Sequence Diagram(s)

sequenceDiagram
  participant Consumer
  participant Reasoning
  participant Collapsible
  participant Content
  Consumer->>Reasoning: Pass streaming and duration
  Reasoning->>Collapsible: Update open state
  Consumer->>Collapsible: Toggle trigger
  Collapsible->>Content: Show or hide reasoning steps
Loading

Suggested reviewers: rohilsurana, shreyag02

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding the Reasoning AI element.
Description check ✅ Passed The description is directly related to the change set and accurately summarizes the new component, docs, tests, and export.
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.

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.

Comment thread packages/raystack/components/reasoning/reasoning.tsx
Comment thread packages/raystack/components/reasoning/reasoning.tsx
Base automatically changed from feat-ai-message to main July 23, 2026 19:11

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

🧹 Nitpick comments (1)
packages/raystack/components/reasoning/__tests__/reasoning.test.tsx (1)

6-10: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add controlled-state coverage.

This helper cannot render open or onOpenChange, so the controlled branch is untested. Add a controlled wrapper that verifies trigger interaction requests state changes through onOpenChange and only reflects the parent-provided open value.

🤖 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/raystack/components/reasoning/__tests__/reasoning.test.tsx` around
lines 6 - 10, Add controlled-state coverage around the ReasoningExample test
helper by introducing a wrapper that passes parent-managed open state and an
onOpenChange handler. Verify trigger interaction requests state changes through
onOpenChange, while rendering remains driven only by the parent-provided open
value.
🤖 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 `@apps/www/src/content/docs/ai-elements/reasoning/demo.ts`:
- Around line 32-35: Update the onClick handler to clear any existing timer
through timerRef.current before starting the new three-second simulation, then
assign the newly created timeout to timerRef.current so only the latest timer
can set streaming to false.

In `@packages/raystack/components/reasoning/reasoning.tsx`:
- Around line 185-188: Update the label and children rendering conditions in the
reasoning component to render all valid ReactNode values, including falsy values
such as 0. Replace the truthiness checks with explicit null/undefined checks
while preserving the existing markup and styles.

---

Nitpick comments:
In `@packages/raystack/components/reasoning/__tests__/reasoning.test.tsx`:
- Around line 6-10: Add controlled-state coverage around the ReasoningExample
test helper by introducing a wrapper that passes parent-managed open state and
an onOpenChange handler. Verify trigger interaction requests state changes
through onOpenChange, while rendering remains driven only by the parent-provided
open value.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d722b958-4121-4347-bdf9-cc27432b1e6c

📥 Commits

Reviewing files that changed from the base of the PR and between dde1260 and 419bb62.

📒 Files selected for processing (9)
  • apps/www/src/content/docs/ai-elements/meta.json
  • apps/www/src/content/docs/ai-elements/reasoning/demo.ts
  • apps/www/src/content/docs/ai-elements/reasoning/index.mdx
  • apps/www/src/content/docs/ai-elements/reasoning/props.ts
  • packages/raystack/components/reasoning/__tests__/reasoning.test.tsx
  • packages/raystack/components/reasoning/index.tsx
  • packages/raystack/components/reasoning/reasoning.module.css
  • packages/raystack/components/reasoning/reasoning.tsx
  • packages/raystack/index.tsx

Comment on lines +32 to +35
onClick={() => {
setStreaming(true);
timerRef.current = setTimeout(() => setStreaming(false), 3000);
}}

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Clear the previous simulation timer before restarting.

A second click leaves the first timeout active, so it can set streaming to false before the latest three-second simulation completes.

Proposed fix
         onClick={() => {
+          if (timerRef.current !== null) {
+            clearTimeout(timerRef.current);
+          }
           setStreaming(true);
           timerRef.current = setTimeout(() => setStreaming(false), 3000);
         }}
📝 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
onClick={() => {
setStreaming(true);
timerRef.current = setTimeout(() => setStreaming(false), 3000);
}}
onClick={() => {
if (timerRef.current !== null) {
clearTimeout(timerRef.current);
}
setStreaming(true);
timerRef.current = setTimeout(() => setStreaming(false), 3000);
}}
🤖 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 `@apps/www/src/content/docs/ai-elements/reasoning/demo.ts` around lines 32 -
35, Update the onClick handler to clear any existing timer through
timerRef.current before starting the new three-second simulation, then assign
the newly created timeout to timerRef.current so only the latest timer can set
streaming to false.

Comment on lines +185 to +188
{label && <div className={styles['reasoning-step-label']}>{label}</div>}
{children && (
<div className={styles['reasoning-step-body']}>{children}</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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Render valid falsy React nodes.

label and children accept ReactNode, but 0 is suppressed by these truthiness checks. Check for null/undefined instead.

Proposed fix
-      {label && <div className={styles['reasoning-step-label']}>{label}</div>}
-      {children && (
+      {label != null && (
+        <div className={styles['reasoning-step-label']}>{label}</div>
+      )}
+      {children != null && (
         <div className={styles['reasoning-step-body']}>{children}</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
{label && <div className={styles['reasoning-step-label']}>{label}</div>}
{children && (
<div className={styles['reasoning-step-body']}>{children}</div>
)}
{label != null && (
<div className={styles['reasoning-step-label']}>{label}</div>
)}
{children != null && (
<div className={styles['reasoning-step-body']}>{children}</div>
)}
🤖 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/raystack/components/reasoning/reasoning.tsx` around lines 185 - 188,
Update the label and children rendering conditions in the reasoning component to
render all valid ReactNode values, including falsy values such as 0. Replace the
truthiness checks with explicit null/undefined checks while preserving the
existing markup and styles.

@rohanchkrabrty
rohanchkrabrty merged commit 6d37652 into main Jul 24, 2026
5 checks passed
@rohanchkrabrty
rohanchkrabrty deleted the feat-ai-reasoning branch July 24, 2026 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants