Skip to content

armgit / avibe

Public Imported from GitHub
0

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.

feat(workbench): markdown in user chat bubbles + a queue-send button (#434)

Call Whitef6243239bfb3
diff --git a/ui/package-lock.json b/ui/package-lock.json
index d23b6300b..cd85522e1 100644
--- a/ui/package-lock.json
+++ b/ui/package-lock.json
@@ -31,6 +31,7 @@
"react-i18next": "^16.5.3",
"react-markdown": "^10.1.0",
"react-router-dom": "^7.12.0",
+ "remark-breaks": "^4.0.0",
"remark-gfm": "^4.0.1",
"shiki": "^4.2.0",
"tailwind-merge": "^3.4.0",
@@ -2546,7 +2547,6 @@
"integrity": "sha512-ne4A0IpG3+2ETuREInjPNhUGis1SFjv1d5asp8MzEAGtOZeTeHVDOYqOgqfhvseqg/iXty2hjBf1zAOb7RNiNw==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"undici-types": "~7.16.0"
}
@@ -4812,6 +4812,20 @@
"url": "https://opencollective.com/unified"
}
},
+ "node_modules/mdast-util-newline-to-break": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/mdast-util-newline-to-break/-/mdast-util-newline-to-break-2.0.0.tgz",
+ "integrity": "sha512-MbgeFca0hLYIEx/2zGsszCSEJJ1JSCdiY5xQxRcLDDGa8EPvlLPupJ4DSajbMPAnC0je8jfb9TiUATnxxrHUog==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "mdast-util-find-and-replace": "^3.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
"node_modules/mdast-util-phrasing": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz",
@@ -5957,6 +5971,21 @@
"integrity": "sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng==",
"license": "MIT"
},
+ "node_modules/remark-breaks": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/remark-breaks/-/remark-breaks-4.0.0.tgz",
+ "integrity": "sha512-IjEjJOkH4FuJvHZVIW0QCDWxcG96kCq7An/KVH2NfJe6rKZU2AsHeB3OEjPNRxi4QC34Xdx7I2KGYn6IpT7gxQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/mdast": "^4.0.0",
+ "mdast-util-newline-to-break": "^2.0.0",
+ "unified": "^11.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
"node_modules/remark-gfm": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-4.0.1.tgz",
diff --git a/ui/package.json b/ui/package.json
index 936e77424..1196f7fc9 100644
--- a/ui/package.json
+++ b/ui/package.json
@@ -34,6 +34,7 @@
"react-i18next": "^16.5.3",
"react-markdown": "^10.1.0",
"react-router-dom": "^7.12.0",
+ "remark-breaks": "^4.0.0",
"remark-gfm": "^4.0.1",
"shiki": "^4.2.0",
"tailwind-merge": "^3.4.0",
diff --git a/ui/src/components/ui/markdown.tsx b/ui/src/components/ui/markdown.tsx
index 4406fb29d..dc3a7b1bd 100644
--- a/ui/src/components/ui/markdown.tsx
+++ b/ui/src/components/ui/markdown.tsx
@@ -1,6 +1,7 @@
import * as React from 'react';
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
+import remarkBreaks from 'remark-breaks';
import { ChatImage, LinkedImageProvider } from '@/components/ui/chat-image';
import { FileCard } from '@/components/ui/file-card';
@@ -18,14 +19,21 @@ import { cn } from '@/lib/utils';
// that live inside a clickable row/button (e.g. inbox previews): links render as
// plain text so a nested <a> can't become invalid interactive content or steal
// the row's click.
-export const Markdown: React.FC<{ content: string; className?: string; interactive?: boolean }> = ({
- content,
- className,
- interactive = true,
-}) => (
+// ``softBreaks`` (default false) turns a single newline into a hard <br> via
+// remark-breaks — CommonMark otherwise collapses a soft break to a space. Enable
+// it for as-typed text (the user's own chat messages) so a multi-line prompt
+// echoes with its line breaks intact while still formatting explicit markdown;
+// leave it off for authored markdown (agent replies) where wrapped lines must
+// not sprout stray hard breaks.
+export const Markdown: React.FC<{
+ content: string;
+ className?: string;
+ interactive?: boolean;
+ softBreaks?: boolean;
+}> = ({ content, className, interactive = true, softBreaks = false }) => (
<div className={cn('vr-markdown', className)}>
<ReactMarkdown
- remarkPlugins={[remarkGfm]}
+ 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
diff --git a/ui/src/components/workbench/ChatPage.tsx b/ui/src/components/workbench/ChatPage.tsx
index a31695c3a..ece3c84d6 100644
--- a/ui/src/components/workbench/ChatPage.tsx
+++ b/ui/src/components/workbench/ChatPage.tsx
@@ -1250,13 +1250,17 @@ const MessageRow: React.FC<{
/>
) : null;
- // Agent / system replies are markdown; the user's own and harness-triggered
- // prompts are shown verbatim as typed/sent.
+ // Agent / system replies AND the user's own messages render as markdown (users
+ // routinely type lists / code / **emphasis** and expect it formatted). Only
+ // harness-triggered prompts (scheduled task / watch / webhook) stay verbatim —
+ // that row is a collapsed technical preview where the raw text is the point.
const bodyNode = message.text ? (
- isAgent || isSystem ? (
- <Markdown content={message.text} />
- ) : (
+ isHarness ? (
<div className="whitespace-pre-wrap break-words text-[13px] text-foreground">{message.text}</div>
+ ) : (
+ // Keep the user's own newlines visible (soft-break → <br>); agent/system
+ // replies are authored markdown and must not get stray hard breaks.
+ <Markdown content={message.text} softBreaks={isUser} />
)
) : messageAttachments.length === 0 ? (
<div className="text-[13px] text-muted">—</div>
@@ -1289,7 +1293,7 @@ const MessageRow: React.FC<{
return (
<div className="flex w-full justify-end">
<div className="flex max-w-[min(92%,860px)] flex-col items-end gap-1">
- <div className="w-fit min-w-0 max-w-full rounded-2xl rounded-tr-md border border-border-strong bg-foreground/[0.06] px-3.5 py-2.5 text-[13px] leading-relaxed">
+ <div className="w-fit min-w-0 max-w-full rounded-2xl rounded-tr-md border border-border-strong bg-foreground/[0.06] px-3.5 py-2.5 text-[13px] leading-relaxed [&_pre]:max-w-full [&_pre]:overflow-x-auto [&_table]:w-full">
{bodyNode}
{attachmentsNode}
</div>
diff --git a/ui/src/components/workbench/Composer.tsx b/ui/src/components/workbench/Composer.tsx
index 1c2a34e9f..3f4933ee0 100644
--- a/ui/src/components/workbench/Composer.tsx
+++ b/ui/src/components/workbench/Composer.tsx
@@ -1,6 +1,6 @@
import { useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { Loader2, Mic, Paperclip, Plus, Send, Square, Trash2, X } from 'lucide-react';
+import { Clock, Loader2, Mic, Paperclip, Plus, Send, Square, Trash2, X } from 'lucide-react';
import clsx from 'clsx';
import { apiFetch } from '../../lib/apiFetch';
@@ -457,19 +457,45 @@ export const Composer: React.FC<ComposerProps> = ({
<Trash2 className="size-4" />
</Button>
)}
- {/* 36px (size-9) icon button: pink-soft Stop while a turn runs, else a
+ {/* 36px (size-9) icon buttons: pink-soft Stop while a turn runs, else a
flat mint Send — design-system variants, not a glowy brand CTA. */}
{busy ? (
- <Button
- type="button"
- variant="destructive-soft"
- size="icon"
- onClick={onStop}
- aria-label={t('chat.compose.stop')}
- className="size-9 shrink-0"
- >
- <Square className="size-4" />
- </Button>
+ <>
+ {/* Sending while a turn runs is allowed — the backend enqueues it
+ (202) instead of refusing (Enter does this too). Surface a visible
+ affordance for it, but only when there's something to send: a cyan
+ "queue" button left of Stop. Paper-plane + a small clock badge
+ reads as "send, but later / into the queue". */}
+ {canSubmit && (
+ <Button
+ type="button"
+ variant="accent"
+ size="icon"
+ onClick={submit}
+ aria-label={t('chat.compose.queueSend')}
+ title={t('chat.compose.queueSend')}
+ className="size-9 shrink-0"
+ >
+ <span className="relative inline-flex">
+ <Send className="size-4" />
+ <Clock
+ className="absolute -bottom-1 -right-1 size-2.5 rounded-full bg-surface-2"
+ strokeWidth={2.5}
+ />
+ </span>
+ </Button>
+ )}
+ <Button
+ type="button"
+ variant="destructive-soft"
+ size="icon"
+ onClick={onStop}
+ aria-label={t('chat.compose.stop')}
+ className="size-9 shrink-0"
+ >
+ <Square className="size-4" />
+ </Button>
+ </>
) : (
<Button
type="button"
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index b8c3dc31b..c9ef25109 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -1702,6 +1702,7 @@
"placeholderBusy": "Type to queue while the agent works…",
"hint": "Enter to send",
"send": "Send",
+ "queueSend": "Send to queue",
"sending": "Sending…",
"stop": "Stop",
"attach": "Attach files",
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index 08a275358..c4ea59ab2 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -1701,6 +1701,7 @@
"placeholderBusy": "Agent 处理中,输入将排队…",
"hint": "Enter 发送",
"send": "发送",
+ "queueSend": "排队发送",
"sending": "发送中…",
"stop": "停止",
"attach": "添加附件",