Skip to content

Conversation

@premiumjibles
Copy link
Collaborator

@premiumjibles premiumjibles commented Jan 19, 2026

Description

First phase POC of getting the agentic chat into web. This currently limited in features just to act as a "tracer bullet" and get everything working end to end. Most of the tools don't work like swaps, limit orders, etc... and there's no chat history. But you can open up a window in dev and chat with the agent.

Issue (if applicable)

closes shapeshift/agentic-chat#177

Risk

Low risk, i've kept this code segregated so it's easy to pull out if we want to and doesn't break any existing code

High Risk PRs Require 2 approvals

What protocols, transaction types, wallets or contract interactions might be affected by this PR?

Testing

  • Make sure nothing shows up with no flag on
  • With the flag on, open up the chat bubble and send a few test messages to the agent.

Engineering

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)

Screenshots (if applicable)

image

Summary by CodeRabbit

  • New Features

    • Adds an agentic chat: floating action button opens a responsive chat UI (desktop panel, mobile full-screen) with message streaming, composer (Enter-to-send), loading indicator, and full Markdown rendering.
    • Adds English translations for chat UI text.
  • Chores

    • Adds feature flag and production/development server URL environment variables.
    • Adds runtime dependencies for AI/chat UI integration.

✏️ Tip: You can customize this high-level summary in your review settings.

@premiumjibles premiumjibles requested a review from a team as a code owner January 19, 2026 09:12
@premiumjibles premiumjibles marked this pull request as draft January 19, 2026 09:12
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

📝 Walkthrough

Walkthrough

Adds an Agentic Chat feature: new env flags and server URL, runtime deps, config validators, feature-flag wiring, translations, a useAgenticChat hook, multiple UI components (FAB, window, chat, composer, markdown, loading), App integration, and test mock updates.

Changes

Cohort / File(s) Summary
Environment Configuration
\.env`, `.env.development`, `.env.production``
Adds VITE_FEATURE_AGENTIC_CHAT and VITE_AGENTIC_SERVER_BASE_URL per environment.
Dependencies
package.json
Adds runtime deps: @ai-sdk/react, ai, react-markdown, remark-gfm.
App Integration
src/App.tsx
Imports and renders AgenticChatFAB.
Config & Feature Flags
src/config.ts, src/state/slices/preferencesSlice/preferencesSlice.ts, src/test/mocks/store.ts
Adds env validators for new vars; wires AgenticChat into FeatureFlags initial state and test mock store.
Translations
src/assets/translations/en/main.json
Adds agenticChat localization keys (title, open/close, placeholder, emptyState, stop, send).
Chat UI Components
src/features/agenticChat/components/*
AgenticChatFAB.tsx, AgenticChatWindow.tsx, Chat.tsx, Composer.tsx, LoadingIndicator.tsx, Markdown.tsx
New components: FAB, responsive chat window (panel/modal), message list with auto-scroll, composer (send/stop), loading indicator, and Markdown renderer (Chakra-mapped).
Chat Hook & Exports
src/features/agenticChat/hooks/useAgenticChat.ts, src/features/agenticChat/index.ts
Adds useAgenticChat (transport + wallet context, endpoint from config) and re-exports AgenticChatFAB.
Tests / Mocks
src/test/mocks/store.ts
Adds AgenticChat: false to mock store featureFlags.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FAB as AgenticChatFAB
    participant Window as AgenticChatWindow
    participant Composer
    participant Hook as useAgenticChat
    participant Server as Agentic Server
    participant Chat

    User->>FAB: click
    FAB->>Window: open (isOpen = true)
    Window->>Chat: render messages
    Window->>Composer: render input

    User->>Composer: type + submit
    Composer->>Hook: handleSubmit(message)
    Hook->>Hook: attach wallet context (evm/sol/chainIds)
    Hook->>Server: POST /api/chat (stream)
    Server-->>Hook: stream response chunks
    Hook->>Chat: append messages
    Chat->>User: display (Markdown rendered)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

high risk

Suggested reviewers

  • NeOMakinG
  • gomesalexandre
  • 0xApotheosis

Poem

🐰 A tiny FAB pops up to say hello,
I tuck in wallet context and let the messages flow,
Markdown crumbs and loading dots gleam,
Flags keep us snug while the stream does its dream,
Hop, send, receive — the rabbit gives a glow.

🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR implements only a minimal POC integration in the web app, but the linked issue #177 requires creating a shared packages/agentic-chat package with extracted business logic and refactoring the standalone app. This PR only adds the feature to the web app. Complete the package creation, business logic extraction, and standalone app refactoring as specified in issue #177 before merging.
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 (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding agentic chat functionality as a proof of concept to the web app.
Out of Scope Changes check ✅ Passed All changes are scoped to integrating agentic chat into the web app with feature flags, dependencies, translations, and UI components.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 11696_agentic_chat

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 and usage tips.

@premiumjibles premiumjibles marked this pull request as ready for review January 19, 2026 09:16
Copy link
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: 2

🤖 Fix all issues with AI agents
In `@src/features/agenticChat/components/Composer.tsx`:
- Around line 21-76: The Composer only treats 'streaming' as loading; change the
isLoading definition to include both 'submitted' and 'streaming' (e.g., const
isLoading = status === 'streaming' || status === 'submitted'), then guard
submissions in handleKeyDown by returning early when isLoading and update the
IconButton props so it is disabled while isLoading (change isDisabled to
isLoading || !input.trim()) and ensure the onClick doesn't trigger handleSubmit
when isLoading (keep existing isLoading ? stop : () => handleSubmit() behavior).

In `@src/features/agenticChat/hooks/useAgenticChat.ts`:
- Around line 53-63: handleSubmit currently clears the input before awaiting
chat.sendMessage which can lose the user's message silently on failure; wrap the
await chat.sendMessage call in a try/catch, call setInput(trimmedInput) in the
catch to restore the text, and call the useErrorToast() error handler to surface
the failure (include the caught error message). Keep the preventDefault and
trimming logic, but only clear input after a successful send; reference the
handleSubmit function, chat.sendMessage call, setInput, input/trimmedInput
variables, and useErrorToast() when making the change.
🧹 Nitpick comments (3)
src/features/agenticChat/components/Markdown.tsx (1)

21-179: Consider wrapping in memo for chat performance.

Since this component receives the children prop and will be rendered for each message in the chat, wrapping it with memo can help avoid unnecessary re-renders when the parent re-renders but the markdown content hasn't changed.

♻️ Proposed optimization
-import { useMemo } from 'react'
+import { memo, useMemo } from 'react'
 import type { Components } from 'react-markdown'
 import ReactMarkdown from 'react-markdown'
 import remarkGfm from 'remark-gfm'

 type MarkdownProps = {
   children: string
 }

-export const Markdown = ({ children }: MarkdownProps) => {
+export const Markdown = memo(({ children }: MarkdownProps) => {
   // ... existing implementation
-}
+})
src/features/agenticChat/components/AgenticChatFAB.tsx (1)

1-43: Memoize open/close handlers passed as props.

Inline handlers are recreated every render and violate the project’s “useCallback for handlers/props” convention. Consider memoizing open/close callbacks. As per coding guidelines, event handlers passed as props should be memoized.

Suggested refactor
-import { useState } from 'react'
+import { useCallback, useState } from 'react'
@@
   const isEnabled = useFeatureFlag('AgenticChat')
   const [isOpen, setIsOpen] = useState(false)
   const translate = useTranslate()
+  const handleOpen = useCallback(() => setIsOpen(true), [])
+  const handleClose = useCallback(() => setIsOpen(false), [])
@@
         <IconButton
           icon={MESSAGE_SQUARE_ICON}
           aria-label={translate('agenticChat.openChat')}
-          onClick={() => setIsOpen(true)}
+          onClick={handleOpen}
@@
-      <AgenticChatWindow isOpen={isOpen} onClose={() => setIsOpen(false)} />
+      <AgenticChatWindow isOpen={isOpen} onClose={handleClose} />
src/features/agenticChat/components/AgenticChatWindow.tsx (1)

19-89: Confirm this UI is wrapped by an ErrorBoundary.

This feature introduces a new UI surface with async chat operations. Please verify it is rendered within an existing ErrorBoundary (or wrap it) so unexpected errors don’t take down the full app. As per coding guidelines, React components must be wrapped with error boundaries.

Copy link
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: 1

🤖 Fix all issues with AI agents
In `@package.json`:
- Around line 74-75: The package versions conflict: `@ai-sdk/react`@3.0.41 and
ai@6.0.39 expect `@ai-sdk/provider-utils`@4.0.8 and `@ai-sdk/provider`@3.0.4, but
`@ai-sdk/ui-utils`@1.2.11 pulls older provider-utils/provider versions; fix by
aligning or removing `@ai-sdk/ui-utils`: either (A) upgrade `@ai-sdk/ui-utils` to a
version that depends on `@ai-sdk/provider-utils`@4.x and `@ai-sdk/provider`@3.x, or
(B) remove/replace `@ai-sdk/ui-utils` if not needed and ensure `@ai-sdk/react` and
ai remain at compatible versions, then run your package manager to update
lockfile and verify with npm/yarn/pnpm install and dependency tree (npm ls) to
confirm `@ai-sdk/provider-utils` and `@ai-sdk/provider` resolve to the 4.x/3.x
versions required.
♻️ Duplicate comments (1)
src/features/agenticChat/components/Composer.tsx (1)

21-76: Block submissions while status is submitted or streaming.

There’s a short window in 'submitted' where Enter can queue another message before streaming starts.

✅ Proposed fix
-  const isLoading = status === 'streaming'
+  const isLoading = status === 'submitted' || status === 'streaming'

   const handleKeyDown = useCallback(
     (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
+      if (isLoading) return
       if (e.key === 'Enter' && !e.shiftKey) {
         e.preventDefault()
         if (input.trim()) {
           handleSubmit()
         }
       }
     },
-    [input, handleSubmit],
+    [input, handleSubmit, isLoading],
   )

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.

Phase 1: Basic Chat POC (Tracer Bullet)

2 participants