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
fix(ui): stop chat image bubbles flickering on scroll (iOS Safari) (#442)
Call Whiteafba937a8d0e
diff --git a/ui/src/components/ui/markdown.tsx b/ui/src/components/ui/markdown.tsxindex dc3a7b1bd..a66b8691f 100644--- a/ui/src/components/ui/markdown.tsx+++ b/ui/src/components/ui/markdown.tsx@@ -1,5 +1,5 @@import * as React from 'react';-import ReactMarkdown from 'react-markdown';+import ReactMarkdown, { type Components } from 'react-markdown';import remarkGfm from 'remark-gfm';import remarkBreaks from 'remark-breaks';@@ -30,67 +30,86 @@ export const Markdown: React.FC<{className?: string;interactive?: boolean;softBreaks?: boolean;-}> = ({ content, className, interactive = true, softBreaks = false }) => (- <div className={cn('vr-markdown', className)}>- <ReactMarkdown- remarkPlugins={softBreaks ? [remarkGfm, remarkBreaks] : [remarkGfm]}- components={{- // Markdown here is untrusted (agent replies, user-authored prompts) and- // can embed images. The default <img> renderer would auto-fetch any URL- // the moment the view opens (````), leaking the- // viewer's IP / network metadata to an attacker-chosen host. So we only- // render a real inline <img> for our OWN same-origin media proxy; every- // other URL stays a click-through link (or plain text when- // non-interactive) so nothing is fetched without an explicit action.- img: ({ src, alt }) => {- if (!src) return null;- const url = String(src);- if (interactive && isProxyMediaUrl(url)) {- // Pixel dimensions ride on the proxy URL (``?w=&h=``) so the image's- // box is reserved before it loads — no scroll shift on the transcript.- const { width, height } = readMediaDims(url);- return <ChatImage src={url} alt={alt || ''} width={width} height={height} />;- }- const label = `🖼 ${alt || url}`;- return interactive ? (- <a href={url} target="_blank" rel="noopener noreferrer nofollow">- {label}- </a>- ) : (- <span>{label}</span>- );- },- // Links to our media proxy are agent-produced files → render the- // download card (filename + type + download / preview). Other links keep- // the normal anchor (interactive) or collapse to plain text inside a- // clickable row (non-interactive).- a: ({ href, children }) => {- const url = href ? String(href) : '';- if (interactive && url && isProxyMediaUrl(url)) {- return <FileCard href={url}>{children}</FileCard>;- }- if (!interactive) return <span>{children}</span>;- // Wrap children so a nested ChatImage (``[](href)``) renders- // bare — without its own download anchor inside this one.- return (- <a href={url} target="_blank" rel="noopener noreferrer nofollow">- <LinkedImageProvider>{children}</LinkedImageProvider>- </a>- );- },- ...(interactive- ? {}- : {- // GFM task lists render a checkbox <input>; even disabled, an- // <input> nested in the sidebar row <button> is invalid interactive- // content, so show the state as a plain glyph instead.- input: ({ checked }: { checked?: boolean }) => (- <span aria-hidden="true">{checked ? '☑ ' : '☐ '}</span>- ),- }),- }}- >- {content}- </ReactMarkdown>- </div>-);+}> = ({ content, className, interactive = true, softBreaks = false }) => {+ // Stable ``remarkPlugins`` + ``components`` identities across re-renders.+ // ReactMarkdown keys its rendered tree on the component functions it is handed;+ // the old inline object minted fresh functions every render, so ReactMarkdown+ // treated each custom <img>/<a> as a NEW component type and REMOUNTED the whole+ // subtree. A remounted <img> is re-fetched / re-decoded — which is exactly what+ // makes a chat bubble's image FLICKER on every scroll-triggered re-render in iOS+ // Safari (the box is already reserved, so it isn't a layout shift; the bitmap+ // itself blinks). Memoizing lets ReactMarkdown reconcile the existing nodes in+ // place. (MessageRow is also React.memo'd so a scroll re-render of the transcript+ // never reaches here to begin with — this is defence in depth + correctness for+ // the editor-preview caller that lacks that wrapper.)+ const remarkPlugins = React.useMemo(+ () => (softBreaks ? [remarkGfm, remarkBreaks] : [remarkGfm]),+ [softBreaks],+ );+ const components = React.useMemo<Components>(+ () => ({+ // Markdown here is untrusted (agent replies, user-authored prompts) and+ // can embed images. The default <img> renderer would auto-fetch any URL+ // the moment the view opens (````), leaking the+ // viewer's IP / network metadata to an attacker-chosen host. So we only+ // render a real inline <img> for our OWN same-origin media proxy; every+ // other URL stays a click-through link (or plain text when+ // non-interactive) so nothing is fetched without an explicit action.+ img: ({ src, alt }) => {+ if (!src) return null;+ const url = String(src);+ if (interactive && isProxyMediaUrl(url)) {+ // Pixel dimensions ride on the proxy URL (``?w=&h=``) so the image's+ // box is reserved before it loads — no scroll shift on the transcript.+ const { width, height } = readMediaDims(url);+ return <ChatImage src={url} alt={alt || ''} width={width} height={height} />;+ }+ const label = `🖼 ${alt || url}`;+ return interactive ? (+ <a href={url} target="_blank" rel="noopener noreferrer nofollow">+ {label}+ </a>+ ) : (+ <span>{label}</span>+ );+ },+ // Links to our media proxy are agent-produced files → render the+ // download card (filename + type + download / preview). Other links keep+ // the normal anchor (interactive) or collapse to plain text inside a+ // clickable row (non-interactive).+ a: ({ href, children }) => {+ const url = href ? String(href) : '';+ if (interactive && url && isProxyMediaUrl(url)) {+ return <FileCard href={url}>{children}</FileCard>;+ }+ if (!interactive) return <span>{children}</span>;+ // Wrap children so a nested ChatImage (``[](href)``) renders+ // bare — without its own download anchor inside this one.+ return (+ <a href={url} target="_blank" rel="noopener noreferrer nofollow">+ <LinkedImageProvider>{children}</LinkedImageProvider>+ </a>+ );+ },+ ...(interactive+ ? {}+ : {+ // GFM task lists render a checkbox <input>; even disabled, an+ // <input> nested in the sidebar row <button> is invalid interactive+ // content, so show the state as a plain glyph instead.+ input: ({ checked }: { checked?: boolean }) => (+ <span aria-hidden="true">{checked ? '☑ ' : '☐ '}</span>+ ),+ }),+ }),+ [interactive],+ );++ return (+ <div className={cn('vr-markdown', className)}>+ <ReactMarkdown remarkPlugins={remarkPlugins} components={components}>+ {content}+ </ReactMarkdown>+ </div>+ );+};diff --git a/ui/src/components/workbench/ChatPage.tsx b/ui/src/components/workbench/ChatPage.tsxindex 52bcb4b66..28f4d4167 100644--- a/ui/src/components/workbench/ChatPage.tsx+++ b/ui/src/components/workbench/ChatPage.tsx@@ -1,4 +1,4 @@-import { useCallback, useEffect, useMemo, useRef, useState } from 'react';+import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';import { useLocation, useNavigate, useParams } from 'react-router-dom';import { ArrowLeft, Bell, Bot, ChevronDown, Clock, Info, Loader2, MessageSquare, Pencil, X } from 'lucide-react';@@ -1235,12 +1235,22 @@ const harnessLabel = (kind: string | null | undefined, t: (k: string) => string)}};-const MessageRow: React.FC<{+type MessageRowProps = {message: WorkbenchMessage;session: WorkbenchSession;messageFontSize: number;onQuickReply?: (messageId: string, choice: string) => boolean | void | Promise<boolean | void>;-}> = ({ message, session, messageFontSize, onQuickReply }) => {+};++// Memoized so a transcript re-render that doesn't touch THIS row — the scroll+// handler's showJump toggle, the working/thinking state, a sibling message+// arriving — skips it entirely. Without this, every such re-render re-runs+// <Markdown>, which (via react-markdown) remounts the row's <img>s; a remounted+// image is re-decoded, which is what flickers the bubble on iOS Safari while+// scrolling. The props are referentially stable per row (the message/session+// objects only change when that row's data does, and onQuickReply is a+// useCallback), so the default shallow compare is correct here.+const MessageRow = memo(function MessageRow({ message, session, messageFontSize, onQuickReply }: MessageRowProps) {const { t } = useTranslation();// Harness rows are collapsed by default; this tracks the per-row expand state.const [expanded, setExpanded] = useState(false);@@ -1419,7 +1429,7 @@ const MessageRow: React.FC<{</div></div>);-};+});const ChatMissing: React.FC<{ onBack: () => void }> = ({ onBack }) => {const { t } = useTranslation();