Conversation
|
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request. |
WalkthroughThis pull request adds text-to-speech (TTS) functionality and Web Share API integration to the ChatMessage component, with a new custom React hook ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts`:
- Around line 74-75: The inline computed isSupported causes SSR/client mismatch;
replace the top-level const isSupported with a React state (e.g., const
[isSupported, setIsSupported] = useState(false)) inside useTextToSpeech and set
its value within a useEffect that runs on mount by checking typeof window !==
"undefined" && "speechSynthesis" in window; update any code that reads
isSupported to use the state variable and ensure the effect runs only once
(empty deps) to avoid hydration warnings and flicker.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsxautogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (14)
autogpt_platform/frontend/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
autogpt_platform/frontend/**/*.{ts,tsx,js,jsx}: Use Node.js 21+ with pnpm package manager for frontend development
Always run 'pnpm format' for formatting and linting code in frontend development
autogpt_platform/frontend/**/*.{ts,tsx,js,jsx}: Runpnpm formatto auto-fix formatting issues before completing work
Runpnpm lintto check for lint errors and fix any that appear before completing work
Files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsxautogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts
autogpt_platform/frontend/**/*.{tsx,ts}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
autogpt_platform/frontend/**/*.{tsx,ts}: Use function declarations for components and handlers (not arrow functions) in React components
Only use arrow functions for small inline lambdas (map, filter, etc.) in React components
Use PascalCase for component names and camelCase with 'use' prefix for hook names in React
Use Tailwind CSS utilities only for styling in frontend components
Use design system components from 'src/components/' (atoms, molecules, organisms) in frontend development
Never use 'src/components/legacy/' in frontend code
Only use Phosphor Icons (@phosphor-icons/react) for icons in frontend components
Use generated API hooks from '@/app/api/generated/endpoints/' instead of deprecated 'BackendAPI' or 'src/lib/autogpt-server-api/'
Use React Query for server state (via generated hooks) in frontend development
Default to client components ('use client') in Next.js; only use server components for SEO or extreme TTFB needs
Use '' component for rendering errors in frontend UI; use toast notifications for mutation errors; use 'Sentry.captureException()' for manual exceptions
Separate render logic from data/behavior in React components; keep comments minimal (code should be self-documenting)
Files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsxautogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts
autogpt_platform/frontend/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
autogpt_platform/frontend/**/*.{ts,tsx}: No barrel files or 'index.ts' re-exports in frontend code
Regenerate API hooks with 'pnpm generate:api' after backend OpenAPI spec changes in frontend developmentRun
pnpm typesto check for type errors and fix any that appear before completing work
Files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsxautogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts
autogpt_platform/frontend/src/components/**/*.{tsx,ts}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Structure React components as: ComponentName/ComponentName.tsx + useComponentName.ts + helpers.ts (exception: small 3-4 line components can be inline; render-only components can be direct files)
Files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsxautogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts
autogpt_platform/frontend/**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
autogpt_platform/frontend/**/*.{js,jsx,ts,tsx}: Format frontend code usingpnpm format
Never use components fromsrc/components/__legacy__/*
Files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsxautogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts
autogpt_platform/frontend/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
autogpt_platform/frontend/src/**/*.{ts,tsx}: Structure components asComponentName/ComponentName.tsx+useComponentName.ts+helpers.tsand use design system components fromsrc/components/(atoms, molecules, organisms)
Use generated API hooks from@/app/api/__generated__/endpoints/with patternuse{Method}{Version}{OperationName}and regenerate withpnpm generate:api
Use function declarations (not arrow functions) for components and handlers
Separate render logic from business logic with component.tsx + useComponent.ts + helpers.ts structure
Colocate state when possible, avoid creating large components, use sub-components in local/componentsfolder
Avoid large hooks, abstract logic intohelpers.tsfiles when sensible
Use arrow functions only for callbacks, not for component declarations
Avoid comments at all times unless the code is very complex
Do not useuseCallbackoruseMemounless asked to optimize a given function
autogpt_platform/frontend/src/**/*.{ts,tsx}: Use function declarations (not arrow functions) for components and handlers
Use type-safe generated API hooks via Orval + React Query for data fetching
Use React Query for server state management and co-locate UI state in components/hooks
Separate render logic (.tsx) from business logic (use*.tshooks)
Use only shadcn/ui (Radix UI primitives) with Tailwind CSS for UI components
Use Phosphor Icons only for all icon implementations
Use ErrorCard component for render errors, toast for mutations, and Sentry for exceptions
Use design system components fromsrc/components/(atoms, molecules, organisms)
Never usesrc/components/__legacy__/*components
Use generated API hooks from@/app/api/__generated__/endpoints/with patternuse{Method}{Version}{OperationName}
Use Tailwind CSS only for styling with design tokens
Do not useuseCallbackoruseMemounless asked to optimize a specific function
Never type withanyunless a variable/attribute can actually be of any type
Files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsxautogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts
autogpt_platform/frontend/**/*.{js,jsx,ts,tsx,css}
📄 CodeRabbit inference engine (AGENTS.md)
Use Tailwind CSS only for styling, use design tokens, and use Phosphor Icons only
Files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsxautogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts
autogpt_platform/frontend/src/**/*.tsx
📄 CodeRabbit inference engine (AGENTS.md)
Component props should be
interface Props { ... }(not exported) unless the interface needs to be used outside the componentUse
type Props = { ... }(not exported) for component props unless used outside the component
Files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsx
autogpt_platform/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Never type with
any, if no types available useunknown
Files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsxautogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts
autogpt_platform/frontend/src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (autogpt_platform/frontend/CLAUDE.md)
Fully capitalize acronyms in symbols, e.g.
graphID,useBackendAPI
Files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsxautogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts
autogpt_platform/frontend/src/**/components/**/*.{ts,tsx}
📄 CodeRabbit inference engine (autogpt_platform/frontend/CLAUDE.md)
Put sub-components in a local
components/folder within the feature directory
Files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsxautogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts
autogpt_platform/frontend/src/**/[A-Z]*/**/*.{ts,tsx}
📄 CodeRabbit inference engine (autogpt_platform/frontend/CLAUDE.md)
Structure components as ComponentName/ComponentName.tsx + useComponentName.ts + helpers.ts
Files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsxautogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts
autogpt_platform/frontend/src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Do not type hook returns, let Typescript infer as much as possible
Files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts
autogpt_platform/frontend/src/**/use*.ts
📄 CodeRabbit inference engine (autogpt_platform/frontend/CLAUDE.md)
autogpt_platform/frontend/src/**/use*.ts: Extract component logic into custom hooks grouped by concern, with each hook in its own.tsfile
Do not type hook returns; let TypeScript infer types as much as possible
Files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts
🧠 Learnings (9)
📚 Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/frontend/**/*.{tsx,ts} : Use design system components from 'src/components/' (atoms, molecules, organisms) in frontend development
Applied to files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsx
📚 Learning: 2026-02-26T21:29:44.094Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/CLAUDE.md:0-0
Timestamp: 2026-02-26T21:29:44.094Z
Learning: Applies to autogpt_platform/frontend/src/**/*.{ts,tsx} : Use design system components from `src/components/` (atoms, molecules, organisms)
Applied to files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsx
📚 Learning: 2026-02-26T21:29:44.094Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/CLAUDE.md:0-0
Timestamp: 2026-02-26T21:29:44.094Z
Learning: Applies to autogpt_platform/frontend/src/**/*.{ts,tsx} : Use ErrorCard component for render errors, toast for mutations, and Sentry for exceptions
Applied to files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsx
📚 Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/frontend/**/*.{tsx,ts} : Use '<ErrorCard />' component for rendering errors in frontend UI; use toast notifications for mutation errors; use 'Sentry.captureException()' for manual exceptions
Applied to files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsx
📚 Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/frontend/**/*.{tsx,ts} : Use PascalCase for component names and camelCase with 'use' prefix for hook names in React
Applied to files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsxautogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts
📚 Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/frontend/**/*.{tsx,ts} : Only use Phosphor Icons (phosphor-icons/react) for icons in frontend components
Applied to files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsx
📚 Learning: 2026-01-28T18:29:34.362Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/src/tests/CLAUDE.md:0-0
Timestamp: 2026-01-28T18:29:34.362Z
Learning: Applies to autogpt_platform/frontend/src/tests/**/*.stories.tsx : Use Storybook for design system, atoms, molecules, visual states (hover, disabled, loading), and responsive layouts
Applied to files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsx
📚 Learning: 2026-02-26T21:29:44.094Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/CLAUDE.md:0-0
Timestamp: 2026-02-26T21:29:44.094Z
Learning: Applies to autogpt_platform/frontend/src/**/*.{ts,tsx} : Use generated API hooks from `@/app/api/__generated__/endpoints/` with pattern `use{Method}{Version}{OperationName}`
Applied to files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts
📚 Learning: 2026-02-26T21:29:44.094Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/CLAUDE.md:0-0
Timestamp: 2026-02-26T21:29:44.094Z
Learning: Applies to autogpt_platform/frontend/src/**/*.{ts,tsx} : Separate render logic (`.tsx`) from business logic (`use*.ts` hooks)
Applied to files:
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts
🧬 Code graph analysis (1)
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsx (2)
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts (1)
useTextToSpeech(7-85)autogpt_platform/frontend/src/components/atoms/Button/Button.tsx (1)
Button(12-152)
🔇 Additional comments (3)
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts (1)
7-85: Clean hook implementation overall.The structure properly separates TTS concerns with appropriate cleanup on unmount and text changes. The status state machine (idle/playing/paused) and utterance lifecycle management are well handled.
autogpt_platform/frontend/src/components/contextual/Chat/components/ChatMessage/ChatMessage.tsx (2)
140-163: Share functionality with appropriate fallback.The Web Share API integration with clipboard fallback is well-structured. Using toast for the fallback feedback (instead of the
copiedstate) provides clearer user feedback since "Share" has different semantics than "Copy."
429-475: Action buttons UI follows design system conventions.The new Copy, TTS, and Share buttons correctly use Phosphor Icons, the design system Button component, and appropriate aria-labels for accessibility. The conditional rendering based on
tts.isSupportedproperly handles browsers without SpeechSynthesis support.
...t_platform/frontend/src/components/contextual/Chat/components/ChatMessage/useTextToSpeech.ts
Outdated
Show resolved
Hide resolved
Add two new action buttons to CoPilot assistant message responses: - Text-to-speech: Uses the browser's Web Speech API (SpeechSynthesis) to read message content aloud. The icon toggles between a speaker icon (idle) and a stop icon (playing) for clear state indication. - Share: Uses the Web Share API on supported browsers/mobile, with a clipboard fallback that shows a toast notification on success. Also replaces the inline SVG copy icon with Phosphor's CopyIcon for consistency with the project's icon conventions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
dcf203f to
5dd026a
Compare
|
Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly. |
- Initialize isSupported as state set in useEffect instead of inline computation - Prevents React hydration warnings from server/client mismatch Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…oice selection and markdown stripping Add a speaker button on every completed assistant message that reads the text content aloud using the browser speechSynthesis API. Selects the highest-quality voice available (macOS neural, Chrome, Edge) and strips markdown syntax and emoji before speaking. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🔍 PR Overlap DetectionThis check compares your PR against all other open PRs targeting the same branch to detect potential merge conflicts early. 🔴 Merge Conflicts DetectedThe following PRs have been tested and will have merge conflicts if merged after this PR. Consider coordinating with the authors.
Summary: 4 conflict(s), 0 medium risk, 0 low risk (out of 4 PRs with file overlap) Auto-generated on push. Ignores: |
...rontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/TTSButton.tsx
Dismissed
Show dismissed
Hide dismissed
|
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request. |
…or/stop Add a copy-to-clipboard button next to the TTS action on assistant messages. Hide both action buttons when the message ended with an error or manual cancellation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly. |
...ontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/CopyButton.tsx
Show resolved
Hide resolved
…utton Show a toast notification when clipboard access fails instead of silently swallowing the error or showing a misleading "Copied!" state. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…utput-actions-text-to-speech-share
Summary
Linked Issue
SECRT-2052
Test plan
Note: This PR should be merged after SECRT-2051 PR