Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
feat(chat): markdown polish — scrollable wide tables + code-block copy button (#680)
Call White987602978409
diff --git a/ui/src/components/ui/markdown.tsx b/ui/src/components/ui/markdown.tsxindex 9179f2875..41ed72709 100644--- a/ui/src/components/ui/markdown.tsx+++ b/ui/src/components/ui/markdown.tsx@@ -2,6 +2,8 @@ import * as React from 'react';import ReactMarkdown, { type Components, defaultUrlTransform } from 'react-markdown';import remarkGfm from 'remark-gfm';import remarkBreaks from 'remark-breaks';+import { useTranslation } from 'react-i18next';+import { Check, Copy } from 'lucide-react';import { Badge } from '@/components/ui/badge';import { ChatImage, LinkedImageProvider } from '@/components/ui/chat-image';@@ -14,7 +16,7 @@ import {parseMentionHref,type MentionReference,} from '@/lib/mentions';-import { cn } from '@/lib/utils';+import { cn, copyTextToClipboard } from '@/lib/utils';// Shared markdown renderer. react-markdown + remark-gfm (tables, strikethrough,// task lists, autolinks); the element styling lives in index.css under@@ -74,6 +76,38 @@ function mentionUrlTransform(url: string): string {return defaultUrlTransform(url);}+// A fenced code block with a hover/tap copy button. The button lives on a+// relatively-positioned wrapper (not the <pre>, which scrolls horizontally) so+// it stays pinned top-right while the code scrolls. The code text is read from+// the rendered <pre> (textContent) rather than re-derived from the markdown AST.+const CodeBlock: React.FC<{ children?: React.ReactNode }> = ({ children }) => {+ const { t } = useTranslation();+ const preRef = React.useRef<HTMLPreElement>(null);+ const [copied, setCopied] = React.useState(false);+ const onCopy = React.useCallback(async () => {+ const text = preRef.current?.textContent ?? '';+ if (!text) return;+ if (!(await copyTextToClipboard(text))) return;+ setCopied(true);+ window.setTimeout(() => setCopied(false), 1500);+ }, []);+ const label = copied ? t('common.copied') : t('common.copy');+ return (+ <div className="vr-code-block">+ <pre ref={preRef}>{children}</pre>+ <button+ type="button"+ className={cn('vr-code-copy', copied && 'is-copied')}+ onClick={onCopy}+ aria-label={label}+ title={label}+ >+ {copied ? <Check size={14} /> : <Copy size={14} />}+ </button>+ </div>+ );+};+export const Markdown: React.FC<{content: string;className?: string;@@ -169,8 +203,21 @@ export const Markdown: React.FC<{</a>);},+ // Wrap tables in a horizontal-scroll viewport so a wide table scrolls within+ // the bubble instead of squeezing its columns to fit (see index.css). A plain+ // <div> is valid in both interactive and preview (clickable-row) surfaces.+ table: ({ children }) => (+ <div className="vr-table-scroll">+ <table>{children}</table>+ </div>+ ),...(interactive- ? {}+ ? {+ // Fenced code blocks get a hover/tap copy button. Only on the+ // interactive surface — a <button> nested in a clickable preview row+ // would be invalid interactive content.+ pre: ({ children }) => <CodeBlock>{children}</CodeBlock>,+ }: {// GFM task lists render a checkbox <input>; even disabled, an// <input> nested in the sidebar row <button> is invalid interactivediff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex 453cf882d..b2dcb9ffa 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -54,6 +54,7 @@"submit": "Submit","submitting": "Submitting…","copy": "Copy",+ "copied": "Copied","copyFailed": "Copy failed, please copy it manually","remove": "Remove","removing": "Removing…",diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex c31561e14..293847fb2 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -54,6 +54,7 @@"submit": "提交","submitting": "提交中…","copy": "复制",+ "copied": "已复制","copyFailed": "复制失败,请手动复制","remove": "移除","removing": "移除中…",diff --git a/ui/src/index.css b/ui/src/index.cssindex 34fb08e2a..a58b04952 100644--- a/ui/src/index.css+++ b/ui/src/index.css@@ -524,6 +524,35 @@ pre,font-size: 12px;line-height: 1.5;}+/* Copy button for fenced code blocks. The wrapper is the positioning context so+ the button stays pinned top-right while the <pre> scrolls horizontally. */+.vr-markdown .vr-code-block { position: relative; }+.vr-code-copy {+ position: absolute;+ top: 8px;+ right: 8px;+ display: inline-flex;+ align-items: center;+ justify-content: center;+ width: 28px;+ height: 28px;+ padding: 0;+ border-radius: 6px;+ border: 1px solid var(--border);+ background: var(--surface-2);+ color: var(--muted);+ cursor: pointer;+ opacity: 0;+ transition: opacity 0.12s ease, color 0.12s ease, background 0.12s ease;+}+.vr-code-block:hover .vr-code-copy,+.vr-code-copy:focus-visible { opacity: 1; }+.vr-code-copy:hover { color: var(--foreground); background: var(--surface-3); }+.vr-code-copy.is-copied { opacity: 1; color: var(--mint); border-color: rgba(91, 255, 160, 0.4); }+/* Touch devices have no hover — keep the button gently visible so it's tappable. */+@media (hover: none) {+ .vr-code-copy { opacity: 0.6; }+}.vr-markdown blockquote {margin: 0 0 0.6em;padding: 0.2em 0 0.2em 0.9em;@@ -531,14 +560,26 @@ pre,color: var(--muted);}.vr-markdown hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }+/* Tables are wrapped in a .vr-table-scroll div (see markdown.tsx) that is the+ horizontal scroll viewport. The table sizes to its own content width — columns+ sized to content, each capped (below) — and is NOT limited to the bubble width,+ so when it's wider than the bubble it scrolls inside the wrapper instead of+ squeezing/wrapping columns to fit (which collapsed a header to one char/line). */+.vr-markdown .vr-table-scroll { overflow-x: auto; margin: 0 0 0.6em; }.vr-markdown table {border-collapse: collapse;- margin: 0 0 0.6em;- display: block;- overflow-x: auto;+ width: max-content;}.vr-markdown th,-.vr-markdown td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }+.vr-markdown td {+ border: 1px solid var(--border);+ padding: 6px 10px;+ text-align: left;+ /* Per-column ceiling: short cells keep their natural width; a long cell wraps+ within this column instead of stretching into one endless line. Capped to the+ viewport so a single column can't exceed the screen on mobile. */+ max-width: min(22rem, 82vw);+}.vr-markdown th { background: var(--surface-2); font-weight: 600; }.vr-markdown img { max-width: 100%; border-radius: 8px; }.vr-markdown strong { font-weight: 700; }