use-mcp/examples/chat-ui
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Glen Maddern 40c75b1952 Claude Code
> When the assistant responds with a longer message including markdown markup, the UI renders it out but it ends up looking too spaced out. Can you investigate what library we're using to render the
  mark down and whether it's possible to tweak the visual spacing to keep things a little bit tighter. I'm thinking in particular headings and lists as well as the overall line height is a touch too
  big.

⏺ I'll investigate the markdown rendering library and spacing issues in your chat UI. Let me first explore the codebase to understand how markdown is being rendered.

⏺ Update Todos
  ⎿  ☐ Find and identify the markdown rendering library being used
     ☐ Analyze current CSS styling for markdown elements
     ☐ Adjust spacing for headings, lists, and line height

⏺ Search(pattern: "markdown|marked|remark|react-markdown", include: "*.json")
  ⎿  Found 1 file (ctrl+r to expand)

⏺ Search(pattern: "markdown|Markdown", include: "*.{js,jsx,ts,tsx}")
  ⎿  Found 2 files (ctrl+r to expand)

⏺ Search(pattern: "package.json")
  ⎿  Found 1 file (ctrl+r to expand)

⏺ Read(package.json)
  ⎿  Read 57 lines (ctrl+r to expand)

⏺ Read(src/components/messages/ChatMessage.tsx)
  ⎿  Read 54 lines (ctrl+r to expand)

⏺ Read(src/components/messages/AssistantMessage.tsx)
  ⎿  Read 32 lines (ctrl+r to expand)

⏺ Update Todos
  ⎿  ☒ Find and identify the markdown rendering library being used
     ☐ Analyze current CSS styling for markdown elements
     ☐ Adjust spacing for headings, lists, and line height

⏺ Now let me check the Tailwind typography configuration and look for any custom CSS:

⏺ Search(pattern: "**/*.css")
  ⎿  Found 3 files (ctrl+r to expand)

⏺ Search(pattern: "tailwind.config.*")
  ⎿  Found 1 file (ctrl+r to expand)

⏺ Search(pattern: "prose", include: "*.{js,jsx,ts,tsx,css}")
  ⎿  Found 2 files (ctrl+r to expand)

⏺ Read(tailwind.config.js)
  ⎿  Read 20 lines (ctrl+r to expand)

⏺ Read(src/index.css)
  ⎿  Read 32 lines (ctrl+r to expand)

⏺ Read(src/styles/github.css)
  ⎿  Read 120 lines (ctrl+r to expand)

⏺ Update Todos
  ⎿  ☒ Find and identify the markdown rendering library being used
     ☒ Analyze current CSS styling for markdown elements
     ☐ Adjust spacing for headings, lists, and line height

⏺ Perfect! I found the issue. You're using react-markdown with @tailwindcss/typography plugin (the prose classes). The spacing is controlled by Tailwind's typography plugin. Let me add custom CSS
  overrides to tighten the spacing:

⏺ Update(tailwind.config.js)
  ⎿  Updated tailwind.config.js with 45 additions
       11                  border: '0',
       12                  backgroundColor: 'transparent',
       13                },
       14 +              lineHeight: '1.5',
       15 +              h1: {
       16 +                marginTop: '1rem',
       17 +                marginBottom: '0.5rem',
       18 +              },
       19 +              h2: {
       20 +                marginTop: '1rem',
       21 +                marginBottom: '0.5rem',
       22 +              },
       23 +              h3: {
       24 +                marginTop: '0.75rem',
       25 +                marginBottom: '0.5rem',
       26 +              },
       27 +              h4: {
       28 +                marginTop: '0.75rem',
       29 +                marginBottom: '0.5rem',
       30 +              },
       31 +              h5: {
       32 +                marginTop: '0.75rem',
       33 +                marginBottom: '0.5rem',
       34 +              },
       35 +              h6: {
       36 +                marginTop: '0.75rem',
       37 +                marginBottom: '0.5rem',
       38 +              },
       39 +              p: {
       40 +                marginTop: '0.5rem',
       41 +                marginBottom: '0.5rem',
       42 +              },
       43 +              ul: {
       44 +                marginTop: '0.5rem',
       45 +                marginBottom: '0.5rem',
       46 +              },
       47 +              ol: {
       48 +                marginTop: '0.5rem',
       49 +                marginBottom: '0.5rem',
       50 +              },
       51 +              li: {
       52 +                marginTop: '0.25rem',
       53 +                marginBottom: '0.25rem',
       54 +              },
       55 +              blockquote: {
       56 +                marginTop: '0.5rem',
       57 +                marginBottom: '0.5rem',
       58 +              },
       59              },
       60            },
       61          },

⏺ Update Todos
  ⎿  ☒ Find and identify the markdown rendering library being used
     ☒ Analyze current CSS styling for markdown elements
     ☒ Adjust spacing for headings, lists, and line height

⏺ Fixed! You're using react-markdown with Tailwind's @tailwindcss/typography plugin. I've updated tailwind.config.js:14-58 to tighten the spacing by:

  - Reducing line height from default 1.75 to 1.5
  - Cutting heading margins (top: 1rem, bottom: 0.5rem for h1/h2, smaller for h3-h6)
  - Reducing paragraph and list margins to 0.5rem
  - Shrinking list item margins to 0.25rem

  The changes will take effect after restarting your dev server.

Total cost:            $0.1342
Total duration (API):  1m 7.4s
Total duration (wall): 5m 14.3s
Total code changes:    45 lines added, 0 lines removed
Token usage by model:
    claude-3-5-haiku:  638 input, 24 output, 0 cache read, 0 cache write
       claude-sonnet:  227 input, 2.5k output, 166.5k cache read, 12.1k cache write
2025-06-27 12:05:30 +10:00
..
api Copying chat example across 2025-06-19 11:51:02 +10:00
e2e fixing prettier 2025-06-25 15:09:09 +10:00
public Copying chat example across 2025-06-19 11:51:02 +10:00
src Round corners more on blue connected server transport type badge 2025-06-26 09:50:50 +10:00
.gitignore Copying chat example across 2025-06-19 11:51:02 +10:00
.prettierrc Copying chat example across 2025-06-19 11:51:02 +10:00
AGENT.md Update AGENT.md with chat UI development guidelines 2025-06-24 08:21:55 +10:00
eslint.config.js fixing prettier 2025-06-25 15:09:09 +10:00
index.html Almost ready 2025-06-25 22:14:36 +10:00
package.json Implement OAuth callback support for MCP servers 2025-06-23 20:19:10 +10:00
playwright.config.ts Copying chat example across 2025-06-19 11:51:02 +10:00
pnpm-lock.yaml Implement OAuth callback support for MCP servers 2025-06-23 20:19:10 +10:00
README.md Copying chat example across 2025-06-19 11:51:02 +10:00
tailwind.config.js Claude Code 2025-06-27 12:05:30 +10:00
tsconfig.app.json wip, changing the logic in useStreamResponse 2025-06-25 17:06:50 +10:00
tsconfig.json fixing prettier 2025-06-25 15:09:09 +10:00
tsconfig.node.json Copying chat example across 2025-06-19 11:51:02 +10:00
tsconfig.worker.json Copying chat example across 2025-06-19 11:51:02 +10:00
vite.config.ts fixing prettier 2025-06-25 15:09:09 +10:00
wrangler.jsonc fixing prettier 2025-06-25 15:09:09 +10:00

AI chat template

An unofficial template for ⚛️ React ⨉ ⚡️ Vite ⨉ ⛅️ Cloudflare Workers AI.

Full-stack AI chat application using Workers for the APIs (using the Cloudflare vite-plugin) and Vite for the React application (hosted using Workers Static Assets). Provides chat functionality with Workers AI, stores conversations in the browser's IndexedDB, and uses ai-sdk, tailwindcss and workers-ai-provider.

Get started

Create the project using create-cloudflare:

npm create cloudflare@latest -- --template thomasgauvin/ai-chat-template

Run the project and deploy it:

cd <project-name>
npm install
npm run dev
npm run deploy

What's next?

  • Change the name of the package (in package.json)
  • Change the name of the worker (in wrangler.jsonc)