Skip to content

feat: add PromptInput AI element#862

Merged
rohanchkrabrty merged 1 commit into
mainfrom
feat-ai-promptinput
Jul 23, 2026
Merged

feat: add PromptInput AI element#862
rohanchkrabrty merged 1 commit into
mainfrom
feat-ai-promptinput

Conversation

@rohanchkrabrty

Copy link
Copy Markdown
Contributor

Summary

  • Add the PromptInput compound component (Root, Textarea, Submit, Toolbar/parts) to packages/raystack/components/prompt-input/, with auto-growing textarea, Enter-to-submit handling, and a submit button that reflects status (idle/streaming/error)
  • Style with CSS Modules using --rs-* tokens and export the component from the raystack package root
  • Set up the new "AI Elements" docs section: sidebar meta.json entry and search grouping in apps/www
  • Add the PromptInput docs page with live demos and a full props reference
  • First PR of a 5-PR AI components stack: PromptInput -> Message -> Reasoning -> Chat -> ChatPanel

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 23, 2026 6:04am

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new composable PromptInput component with shared context, controlled and uncontrolled input, Enter-key submission, streaming stop behavior, disabled handling, styling, public exports, and interaction tests. Adds an AI Elements documentation section with metadata, demos, API references, accessibility guidance, and navigation updates. Updates documentation search grouping to exclude the new section from default results.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant PromptInputTextarea
  participant PromptInputRoot
  participant PromptInputSubmit
  User->>PromptInputTextarea: Press Enter
  PromptInputTextarea->>PromptInputRoot: Request form submission
  PromptInputRoot->>PromptInputRoot: Validate status and trimmed value
  PromptInputRoot->>User: Invoke onSubmit
  User->>PromptInputSubmit: Click during streaming
  PromptInputSubmit->>PromptInputRoot: Invoke onStop
Loading

Suggested reviewers: rsbh, paansinghcoder

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the addition of the PromptInput AI element and matches the main change.
Description check ✅ Passed The description is directly about the PromptInput component, docs section, and exports added in this PR.
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.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
apps/www/src/content/docs/ai-elements/meta.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

apps/www/src/content/docs/meta.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


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

🤖 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/prompt-input/props.ts`:
- Around line 17-21: Update the onSubmit documentation to distinguish reset
behavior: event.currentTarget.reset() clears uncontrolled input drafts, while
controlled value props remain unchanged until the parent updates them. Mention
that controlled consumers should clear their state, as demonstrated by calling
setValue(''), and preserve the existing submission details.
- Around line 47-95: Update PromptInputTextareaProps, PromptInputSubmitProps,
and PromptInputButtonProps to derive from their forwarded TextAreaProps, native
button props, and Button props respectively, while omitting only props
intentionally overridden or documented locally. Preserve the existing custom
descriptions/defaults and ensure supported handlers, disabled, className, and
ARIA attributes remain represented in the generated prop tables.

In `@packages/raystack/components/prompt-input/prompt-input-textarea.tsx`:
- Line 29: Make root PromptInput disabled state authoritative: update
resolvedDisabled in
packages/raystack/components/prompt-input/prompt-input-textarea.tsx (29-29) and
prompt-input-parts.tsx (49-49) to preserve context.disabled over child props,
and update the disabled resolution in
packages/raystack/components/prompt-input/prompt-input-submit.tsx (37-37) to
include context.disabled before any child override. Add a regression case in
packages/raystack/components/prompt-input/__tests__/prompt-input.test.tsx
(216-225) passing disabled={false} to each slot and verifying they remain
disabled.
🪄 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: 5775beff-8874-4ef4-b28f-84b493c0ff81

📥 Commits

Reviewing files that changed from the base of the PR and between 85637c4 and 0d5d920.

📒 Files selected for processing (16)
  • apps/www/src/components/docs/search.tsx
  • apps/www/src/content/docs/ai-elements/meta.json
  • apps/www/src/content/docs/ai-elements/prompt-input/demo.ts
  • apps/www/src/content/docs/ai-elements/prompt-input/index.mdx
  • apps/www/src/content/docs/ai-elements/prompt-input/props.ts
  • apps/www/src/content/docs/meta.json
  • packages/raystack/components/prompt-input/__tests__/prompt-input.test.tsx
  • packages/raystack/components/prompt-input/index.tsx
  • packages/raystack/components/prompt-input/prompt-input-context.tsx
  • packages/raystack/components/prompt-input/prompt-input-parts.tsx
  • packages/raystack/components/prompt-input/prompt-input-root.tsx
  • packages/raystack/components/prompt-input/prompt-input-submit.tsx
  • packages/raystack/components/prompt-input/prompt-input-textarea.tsx
  • packages/raystack/components/prompt-input/prompt-input.module.css
  • packages/raystack/components/prompt-input/prompt-input.tsx
  • packages/raystack/index.tsx

Comment on lines +17 to +21
* Called with the trimmed text when the prompt is submitted — Enter in the
* textarea or a click on `PromptInput.Submit`. Call
* `event.currentTarget.reset()` to clear the input after sending.
*/
onSubmit?: (value: string, event: React.FormEvent<HTMLFormElement>) => void;

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

Clarify reset behavior for controlled inputs.

event.currentTarget.reset() clears an uncontrolled draft, but a controlled value remains unchanged until the parent updates it. Document this distinction; the controlled example correctly calls setValue('').

🤖 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/prompt-input/props.ts` around lines 17
- 21, Update the onSubmit documentation to distinguish reset behavior:
event.currentTarget.reset() clears uncontrolled input drafts, while controlled
value props remain unchanged until the parent updates them. Mention that
controlled consumers should clear their state, as demonstrated by calling
setValue(''), and preserve the existing submission details.

Comment on lines +47 to +95
export interface PromptInputTextareaProps {
/** Placeholder shown while empty. @defaultValue "Write a message…" */
placeholder?: string;

/** Disables just the textarea. Inherits the root `disabled` by default. */
disabled?: boolean;

/** Custom CSS class names. */
className?: string;
}

export interface PromptInputSubmitProps {
/**
* Replaces the status-derived icon (send arrow, spinner or stop square).
*/
children?: React.ReactNode;

/**
* Accessible name. Defaults to "Send message", or "Stop response" while a
* response is in flight.
*/
'aria-label'?: string;

/** Custom CSS class names. */
className?: string;
}

export interface PromptInputButtonProps {
/**
* Visual style, forwarded to `Button`.
* @defaultValue "ghost"
*/
variant?: 'solid' | 'outline' | 'ghost' | 'text';

/**
* Color, forwarded to `Button`.
* @defaultValue "neutral"
*/
color?: 'accent' | 'danger' | 'neutral' | 'success';

/**
* Size, forwarded to `Button`.
* @defaultValue "small"
*/
size?: 'small' | 'normal';

/** Custom CSS class names. */
className?: string;
}

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Keep the prop reference aligned with forwarded component props.

These interfaces are narrower than the actual contracts: PromptInputTextareaProps forwards TextAreaProps (packages/raystack/components/prompt-input/prompt-input-textarea.tsx:10-14), PromptInputSubmitProps forwards native button props (packages/raystack/components/prompt-input/prompt-input-submit.tsx:10), and PromptInputButtonProps forwards Button props (packages/raystack/components/prompt-input/prompt-input-parts.tsx:31). The generated tables therefore omit supported props such as onKeyDown, onClick, disabled, and ARIA attributes. Derive these docs types from the component contracts or document the full forwarded surface.

🤖 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/prompt-input/props.ts` around lines 47
- 95, Update PromptInputTextareaProps, PromptInputSubmitProps, and
PromptInputButtonProps to derive from their forwarded TextAreaProps, native
button props, and Button props respectively, while omitting only props
intentionally overridden or documented locally. Preserve the existing custom
descriptions/defaults and ensure supported handlers, disabled, className, and
ARIA attributes remain represented in the generated prop tables.

const localRef = useRef<HTMLTextAreaElement | null>(null);
const mergedRef = useMergedRefs(localRef, context.textareaRef, ref);

const resolvedDisabled = disabled ?? context.disabled;

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 | 🟠 Major | ⚡ Quick win

Keep root-level disabled authoritative.

An explicit disabled={false} re-enables slots inside <PromptInput disabled>, so the textarea accepts edits and button handlers remain clickable even though submission is blocked. Root disabled should win over child props.

  • packages/raystack/components/prompt-input/prompt-input-textarea.tsx#L29-L29: resolve with context.disabled || disabled.
  • packages/raystack/components/prompt-input/prompt-input-submit.tsx#L37-L37: include context.disabled before any child override.
  • packages/raystack/components/prompt-input/prompt-input-parts.tsx#L49-L49: resolve with context.disabled || disabled.
  • packages/raystack/components/prompt-input/__tests__/prompt-input.test.tsx#L216-L225: add a regression case using disabled={false} on each slot.
📍 Affects 3 files
  • packages/raystack/components/prompt-input/prompt-input-textarea.tsx#L29-L29 (this comment)
  • packages/raystack/components/prompt-input/prompt-input-submit.tsx#L37-L37
  • packages/raystack/components/prompt-input/prompt-input-parts.tsx#L49-L49
🤖 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/prompt-input/prompt-input-textarea.tsx` at line
29, Make root PromptInput disabled state authoritative: update resolvedDisabled
in packages/raystack/components/prompt-input/prompt-input-textarea.tsx (29-29)
and prompt-input-parts.tsx (49-49) to preserve context.disabled over child
props, and update the disabled resolution in
packages/raystack/components/prompt-input/prompt-input-submit.tsx (37-37) to
include context.disabled before any child override. Add a regression case in
packages/raystack/components/prompt-input/__tests__/prompt-input.test.tsx
(216-225) passing disabled={false} to each slot and verifying they remain
disabled.

@rohanchkrabrty
rohanchkrabrty merged commit 03f022b into main Jul 23, 2026
5 checks passed
@rohanchkrabrty
rohanchkrabrty deleted the feat-ai-promptinput branch July 23, 2026 19:10
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