Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(agents): render queued prompt previews as markdown (#7415)

Wolf Mermelsteinc8a648136df3
diff --git a/apps/web/src/features/block-agent/ui/QueuedPrompts.test.tsx b/apps/web/src/features/block-agent/ui/QueuedPrompts.test.tsx
index 900d40a391..9707ce5d67 100644
--- a/apps/web/src/features/block-agent/ui/QueuedPrompts.test.tsx
+++ b/apps/web/src/features/block-agent/ui/QueuedPrompts.test.tsx
@@ -15,7 +15,12 @@ vi.mock(
buildConfig: () => {
const builder = {
namespace: () => builder,
+ withAppLinkResolver: () => builder,
+ withMentions: () => builder,
+ withEmojis: () => builder,
+ withLinks: () => builder,
withHistory: () => builder,
+ withCode: () => builder,
onChange: (callback: (markdown: string) => void) => {
editor.change = callback;
return builder;
@@ -43,6 +48,32 @@ vi.mock('@core/component/LexicalMarkdown/builder/MarkdownShell', () => ({
</div>
),
}));
+// The real static surface has its own markdown rendering suite; here the
+// preview only needs to show which markdown it was handed.
+vi.mock(
+ '@core/component/LexicalMarkdown/component/core/StaticMarkdown',
+ () => ({
+ StaticMarkdown: (props: {
+ markdown: string;
+ singleLine?: boolean;
+ inert?: boolean;
+ }) => (
+ <span
+ data-testid="static-markdown"
+ data-single-line={props.singleLine}
+ data-inert={props.inert}
+ >
+ {props.markdown}
+ </span>
+ ),
+ })
+);
+vi.mock('@core/component/LexicalMarkdown/theme', () => ({
+ singleLineMarkdownTheme: {},
+}));
+vi.mock('@components/app/split-layout/split-router/mention-links', () => ({
+ useMacroMentionLinkResolver: () => undefined,
+}));
vi.mock('@ui', () => ({
Surface: (props: { children?: JSX.Element }) => props.children,
Button: (props: {
@@ -68,6 +99,51 @@ afterEach(() => {
vi.useRealTimers();
});
+describe('queued prompt preview', () => {
+ it('renders prompt markdown through the single-line static surface', () => {
+ const link =
+ '<m-link>{"url":"https://example.com","text":"example"}</m-link>';
+ render(() => (
+ <QueuedPrompts
+ items={[
+ { actionId: 'linked', kind: 'prompt', prompt: `Read ${link}` },
+ { actionId: 'files', kind: 'prompt', prompt: '' },
+ { actionId: 'compact', kind: 'compact' },
+ ]}
+ onEdit={vi.fn()}
+ onRemove={vi.fn()}
+ />
+ ));
+ const previews = screen.getAllByTestId('static-markdown');
+ expect(previews).toHaveLength(1);
+ expect(previews[0]?.textContent).toBe(`Read ${link}`);
+ expect(previews[0]?.getAttribute('data-single-line')).toBe('true');
+ expect(previews[0]?.getAttribute('data-inert')).toBe('true');
+ expect(screen.getByRole('button', { name: 'Attached files' })).toBeTruthy();
+ expect(
+ screen.getByRole('button', { name: 'Compact the conversation' })
+ ).toBeTruthy();
+ });
+
+ it('keeps the preview on the edited text while the editor is open', () => {
+ render(() => (
+ <QueuedPrompts
+ items={[
+ { actionId: 'first', kind: 'prompt', prompt: 'Queued request' },
+ ]}
+ onEdit={vi.fn()}
+ onRemove={vi.fn()}
+ />
+ ));
+ fireEvent.click(screen.getByRole('button', { name: 'Queued request' }));
+ editor.markdown = 'Updated request';
+ editor.change?.(editor.markdown);
+ expect(screen.getByTestId('static-markdown').textContent).toBe(
+ 'Updated request'
+ );
+ });
+});
+
describe('queued prompt access', () => {
it('collapses every message and opens only the selected editor', () => {
render(() => (
diff --git a/apps/web/src/features/block-agent/ui/QueuedPrompts.tsx b/apps/web/src/features/block-agent/ui/QueuedPrompts.tsx
index ad7b617cef..8bf9124d8e 100644
--- a/apps/web/src/features/block-agent/ui/QueuedPrompts.tsx
+++ b/apps/web/src/features/block-agent/ui/QueuedPrompts.tsx
@@ -6,7 +6,9 @@
* the bottom, immediately above the composer, so Up from the input lands on
* "the one about to be sent" and further Up presses walk toward the newest.
*
- * Rows start as one-line previews. Opening a prompt reveals its scrollable
+ * Rows start as one-line previews rendered through the static Lexical
+ * surface, so mentions and links read as they do in the transcript rather
+ * than as serialized markup. Opening a prompt reveals its scrollable
* Lexical editor; only one row is expanded at a time.
* Edits debounce and autosave through `onEdit`, with a flush on blur; there
* are no save/cancel affordances. Non-prompt entries (compact) are
@@ -16,8 +18,11 @@
* steer the server refused stays queued and says it was not sent.
*/
+import { useMacroMentionLinkResolver } from '@components/app/split-layout/split-router/mention-links';
import { buildConfig } from '@core/component/LexicalMarkdown/builder/MarkdownConfigBuilder';
import { MarkdownShell } from '@core/component/LexicalMarkdown/builder/MarkdownShell';
+import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
+import { singleLineMarkdownTheme } from '@core/component/LexicalMarkdown/theme';
import CaretUpIcon from '@icon/system/regular/caret-up.svg?component-solid';
import XIcon from '@icon/system/regular/x.svg?component-solid';
import { stripAgentContext } from '@macro-inc/lexical-core/utils/parsers';
@@ -172,10 +177,13 @@ function QueuedRow(props: QueuedRowProps) {
const [draft, setDraft] = createSignal<string>();
let toggle: HTMLButtonElement | undefined;
let focusBody: (() => void) | undefined;
- const preview = () =>
+ const previewMarkdown = () =>
props.item.kind === 'prompt'
- ? (draft() ?? stripAgentContext(props.item.prompt ?? '')).trim() ||
- 'Attached files'
+ ? (draft() ?? stripAgentContext(props.item.prompt ?? '')).trim()
+ : '';
+ const previewLabel = () =>
+ props.item.kind === 'prompt'
+ ? 'Attached files'
: 'Compact the conversation';
const open = () => {
props.onExpandedChange(true);
@@ -221,7 +229,23 @@ function QueuedRow(props: QueuedRowProps) {
class="size-3 shrink-0 text-ink-muted transition-transform"
classList={{ 'rotate-180': props.expanded }}
/>
- <span class="truncate">{preview()}</span>
+ <Show
+ when={previewMarkdown()}
+ fallback={<span class="truncate">{previewLabel()}</span>}
+ >
+ {(markdown) => (
+ // Inert so chips and links never take the click that opens
+ // the row.
+ <div class="min-w-0 flex-1 truncate">
+ <StaticMarkdown
+ markdown={markdown()}
+ theme={singleLineMarkdownTheme}
+ singleLine
+ inert
+ />
+ </div>
+ )}
+ </Show>
</button>
<Show
when={props.item.sendFailed}
@@ -336,9 +360,15 @@ function PromptBody(
saveTimer = setTimeout(flush, AUTOSAVE_DEBOUNCE_MS);
};
+ // The composer's features, so a queued prompt edits the way it was written.
const editor = buildConfig('chat')
+ .withAppLinkResolver(useMacroMentionLinkResolver())
.namespace('agent-queued-prompt')
+ .withMentions({ showOpenTabs: true, block: 'agent' })
+ .withEmojis()
+ .withLinks({ floatingMenu: true, autoLinkMatchMode: 'common-tlds' })
.withHistory({ timeGap: 400 })
+ .withCode()
.onChange(scheduleSave)
.onEscape(() => {
flush();
diff --git a/docs/agent-guide/ai-chat.md b/docs/agent-guide/ai-chat.md
index 082cbb3164..76eab56123 100644
--- a/docs/agent-guide/ai-chat.md
+++ b/docs/agent-guide/ai-chat.md
@@ -1852,6 +1852,10 @@ must stay hidden; subsequent live messages must still appear.
it scrolls on its own and starts scrolled to the bottom, so the next-to-send row stays
visible. Scroll up inside the list to reach newer entries; no extra count row hides
messages. Each prompt starts as a single-line preview, including long messages.
+ The preview is rendered markdown: links and `@` mention chips appear as they do
+ in the transcript, never as their `<m-link>` / `<m-document-mention>` markup, and
+ clicking one opens the row rather than the link. The expanded editor has the
+ composer's `@` mentions, links, emoji, and code.
Click a preview (or press Enter/Space on it) to open its editor; opening another
row collapses the previous one. The expanded editor scrolls within the smaller of
32% of the viewport and 16rem. Click the preview again or press Escape to collapse