Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
chore(agents): expand and edit review notes before sending them to the agent (#6645)
Wolf Mermelstein8f9f62ab593a
diff --git a/apps/web/src/features/agent-changes/components/ReviewNotesChip.test.tsx b/apps/web/src/features/agent-changes/components/ReviewNotesChip.test.tsxnew file mode 100644index 0000000000..93d1f08340--- /dev/null+++ b/apps/web/src/features/agent-changes/components/ReviewNotesChip.test.tsx@@ -0,0 +1,99 @@+import { fireEvent, render, screen } from '@solidjs/testing-library';+import { createSignal } from 'solid-js';+import { describe, expect, it, vi } from 'vitest';+import type { ReviewNote } from '../core/review-notes';+import { ReviewNotesChip } from './ReviewNotesChip';++function note(overrides: Partial<ReviewNote> = {}): ReviewNote {+ return {+ id: 'n1',+ path: 'apps/web/src/a.ts',+ side: 'additions',+ lineNumber: 2,+ endLineNumber: 2,+ text: 'Use a constant',+ createdAt: '2026-09-15T00:00:00Z',+ ...overrides,+ };+}++describe('ReviewNotesChip', () => {+ it('hides note text until expanded, then lets the reviewer edit', () => {+ const [notes, setNotes] = createSignal([+ note(),+ note({+ id: 'n2',+ path: 'crates/x/src/lib.rs',+ lineNumber: 1,+ endLineNumber: 1,+ text: 'Name this',+ }),+ ]);+ const [expanded, setExpanded] = createSignal(false);+ const onUpdate = vi.fn((id: string, text: string) => {+ setNotes((current) =>+ current.map((item) => (item.id === id ? { ...item, text } : item))+ );+ });+ const onSend = vi.fn();+ render(() => (+ <ReviewNotesChip+ notes={notes()}+ expanded={expanded()}+ onToggleExpanded={() => setExpanded((open) => !open)}+ onUpdate={onUpdate}+ onRemove={() => {}}+ onSend={onSend}+ />+ ));++ expect(screen.getByText(/review notes/).textContent).toContain('2');+ expect(screen.queryByLabelText(/Review note on/)).toBeNull();++ fireEvent.click(+ screen.getByRole('button', { name: /2 review notes queued/ })+ );+ expect(+ screen+ .getByRole('button', { name: /2 review notes queued/ })+ .getAttribute('aria-expanded')+ ).toBe('true');++ const first = screen.getByLabelText(+ 'Review note on apps/web/src/a.ts, line 2 (new)'+ ) as HTMLTextAreaElement;+ expect(first.value).toBe('Use a constant');+ expect(+ screen.getByLabelText('Review note on crates/x/src/lib.rs, line 1 (new)')+ ).toBeTruthy();++ fireEvent.input(first, { target: { value: 'Use a named constant' } });+ expect(onUpdate).toHaveBeenCalledWith('n1', 'Use a named constant');++ fireEvent.click(screen.getByRole('button', { name: 'Send to agent' }));+ expect(onSend).toHaveBeenCalledTimes(1);+ });++ it('does not send when every note is empty', () => {+ const onSend = vi.fn();+ render(() => (+ <ReviewNotesChip+ notes={[note({ text: ' ' })]}+ expanded+ onToggleExpanded={() => {}}+ onUpdate={() => {}}+ onRemove={() => {}}+ onSend={onSend}+ />+ ));+ expect(+ (+ screen.getByRole('button', {+ name: 'Send to agent',+ }) as HTMLButtonElement+ ).disabled+ ).toBe(true);+ fireEvent.click(screen.getByRole('button', { name: 'Send to agent' }));+ expect(onSend).not.toHaveBeenCalled();+ });+});diff --git a/apps/web/src/features/agent-changes/components/ReviewNotesChip.tsx b/apps/web/src/features/agent-changes/components/ReviewNotesChip.tsxindex b0dab2da61..258f86c308 100644--- a/apps/web/src/features/agent-changes/components/ReviewNotesChip.tsx+++ b/apps/web/src/features/agent-changes/components/ReviewNotesChip.tsx@@ -1,31 +1,120 @@+import CaretRightIcon from '@phosphor/caret-right.svg';import NoteIcon from '@phosphor/note.svg';-import { Button } from '@ui';+import XIcon from '@phosphor/x.svg';+import { Button, cn } from '@ui';+import { Index, Show } from 'solid-js';+import {+ describeNoteLines,+ orderNotes,+ type ReviewNote,+ sendableNotes,+} from '../core/review-notes';++const LIST_ID = 'review-notes-dock-list';/** The composer-dock chip for notes that have not gone to the agent yet. */export function ReviewNotesChip(props: {- count: number;+ notes: readonly ReviewNote[];+ expanded: boolean;disabled?: boolean;+ onToggleExpanded: () => void;+ onUpdate: (id: string, text: string) => void;+ onRemove: (id: string) => void;onSend: () => void;+ onOpenNote?: (note: ReviewNote) => void;}) {+ const notes = () => orderNotes(props.notes);+ const count = () => notes().length;+ const canSend = () => !props.disabled && sendableNotes(notes()).length > 0;return (<div- class="flex items-center gap-2 rounded-[10px] bg-selected px-2.5 py-1.5 text-xs text-ink-muted shadow-[inset_0_0_0_1px_color-mix(in_oklch,var(--color-accent)_30%,transparent)]"- role="status"+ class="flex flex-col rounded-[10px] bg-selected text-xs text-ink-muted shadow-[inset_0_0_0_1px_color-mix(in_oklch,var(--color-accent)_30%,transparent)]"+ role="group"+ aria-label="Queued review notes">- <NoteIcon class="size-3.5 shrink-0" />- <span class="flex-1">- <b class="font-semibold tabular-nums">{props.count}</b>{' '}- {props.count === 1 ? 'review note' : 'review notes'} queued- </span>- <Button- variant="ghost"- size="xs"- class="h-6 px-2 text-[11.5px] text-ink"- disabled={props.disabled}- onClick={() => props.onSend()}- >- Send to agent- </Button>+ <div class="flex items-center gap-2 px-2.5 py-1.5">+ <button+ type="button"+ class="flex min-w-0 flex-1 items-center gap-2 text-left"+ aria-expanded={props.expanded}+ aria-controls={LIST_ID}+ title={+ props.expanded+ ? 'Hide queued notes'+ : 'Show queued notes so you can read and edit them'+ }+ onClick={() => props.onToggleExpanded()}+ >+ <CaretRightIcon+ class={cn(+ 'size-3 shrink-0 transition-transform duration-100 motion-reduce:transition-none',+ props.expanded && 'rotate-90'+ )}+ />+ <NoteIcon class="size-3.5 shrink-0" />+ <span class="min-w-0 flex-1">+ <b class="font-semibold tabular-nums">{count()}</b>{' '}+ {count() === 1 ? 'review note' : 'review notes'} queued+ </span>+ </button>+ <Button+ variant="ghost"+ size="xs"+ class="h-6 px-2 text-[11.5px] text-ink"+ disabled={!canSend()}+ onClick={() => props.onSend()}+ >+ Send to agent+ </Button>+ </div>+ <Show when={props.expanded}>+ <ul+ id={LIST_ID}+ class="flex max-h-60 flex-col gap-2 overflow-y-auto border-t border-edge-muted px-2.5 py-2"+ >+ <Index each={notes()}>+ {(note) => (+ <li class="flex flex-col gap-1">+ <div class="flex items-center gap-1.5">+ <Show+ when={props.onOpenNote}+ fallback={+ <span class="min-w-0 flex-1 truncate font-mono text-[11px] text-ink-placeholder">+ {note().path} · {describeNoteLines(note())}+ </span>+ }+ >+ <button+ type="button"+ class="min-w-0 flex-1 truncate text-left font-mono text-[11px] text-ink-placeholder hover:text-ink"+ title={`Show ${note().path} in the changes pane`}+ onClick={() => props.onOpenNote?.(note())}+ >+ {note().path} · {describeNoteLines(note())}+ </button>+ </Show>+ <Button+ variant="ghost"+ size="icon-xs"+ tooltip="Remove note"+ onClick={() => props.onRemove(note().id)}+ >+ <XIcon />+ </Button>+ </div>+ <textarea+ class="min-h-13 w-full resize-y rounded-md border border-edge bg-input px-2 py-1.5 font-sans text-xs text-ink outline-none placeholder:text-ink-placeholder focus:border-input-focus"+ aria-label={`Review note on ${note().path}, ${describeNoteLines(note())}`}+ value={note().text}+ onInput={(event) =>+ props.onUpdate(note().id, event.currentTarget.value)+ }+ />+ </li>+ )}+ </Index>+ </ul>+ </Show></div>);}diff --git a/apps/web/src/features/agent-changes/core/review-notes.test.ts b/apps/web/src/features/agent-changes/core/review-notes.test.tsindex 446fd2466f..4b4686520b 100644--- a/apps/web/src/features/agent-changes/core/review-notes.test.ts+++ b/apps/web/src/features/agent-changes/core/review-notes.test.ts@@ -1,9 +1,11 @@import { describe, expect, it } from 'vitest';import {+ describeNoteLines,formatNotesForAgent,notesForFile,queuedNotes,type ReviewNote,+ sendableNotes,} from './review-notes';function note(overrides: Partial<ReviewNote> = {}): ReviewNote {@@ -27,6 +29,30 @@ describe('queuedNotes', () => {});});+describe('sendableNotes', () => {+ it('drops sent and empty notes and orders by file then line', () => {+ expect(+ sendableNotes([+ note({ id: 'b', path: 'b.ts', text: 'Keep' }),+ note({ id: 'empty', text: ' ' }),+ note({ id: 'sent', sentAt: 't' }),+ note({ id: 'a', lineNumber: 3, endLineNumber: 3 }),+ ]).map((n) => n.id)+ ).toEqual(['a', 'b']);+ });+});++describe('describeNoteLines', () => {+ it('names a single line and a range on each side', () => {+ expect(describeNoteLines(note())).toBe('line 10 (new)');+ expect(+ describeNoteLines(+ note({ side: 'deletions', lineNumber: 3, endLineNumber: 6 })+ )+ ).toBe('lines 3–6 (old)');+ });+});+describe('notesForFile', () => {it('filters by path and sorts by line', () => {const list = [diff --git a/apps/web/src/features/agent-changes/core/review-notes.ts b/apps/web/src/features/agent-changes/core/review-notes.tsindex ccdbe972bf..91717fdfb4 100644--- a/apps/web/src/features/agent-changes/core/review-notes.ts+++ b/apps/web/src/features/agent-changes/core/review-notes.ts@@ -41,6 +41,20 @@ export function queuedNotes(notes: readonly ReviewNote[]): ReviewNote[] {return notes.filter((note) => note.sentAt === undefined);}+/** Queued notes that still have text, in the order the dump will use. */+export function sendableNotes(notes: readonly ReviewNote[]): ReviewNote[] {+ return orderNotes(queuedNotes(notes)).filter(+ (note) => note.text.trim() !== ''+ );+}++/** File then line, so the dock and the dump walk the diff the same way. */+export function orderNotes(notes: readonly ReviewNote[]): ReviewNote[] {+ return [...notes].sort(+ (a, b) => a.path.localeCompare(b.path) || a.lineNumber - b.lineNumber+ );+}+/** Notes on one file, in line order, queued first. */export function notesForFile(notes: readonly ReviewNote[],@@ -51,7 +65,9 @@ export function notesForFile(.sort((a, b) => a.lineNumber - b.lineNumber);}-function describeLines(note: ReviewNote): string {+export function describeNoteLines(+ note: Pick<ReviewNote, 'side' | 'lineNumber' | 'endLineNumber'>+): string {const version = note.side === 'additions' ? 'new' : 'old';if (note.endLineNumber > note.lineNumber) {return `lines ${note.lineNumber}–${note.endLineNumber} (${version})`;@@ -65,17 +81,15 @@ function describeLines(note: ReviewNote): string {* diff the way the reviewer did.*/export function formatNotesForAgent(notes: readonly ReviewNote[]): string {- const ordered = [...notes].sort(- (a, b) => a.path.localeCompare(b.path) || a.lineNumber - b.lineNumber- );+ const ordered = orderNotes(notes);if (ordered.length === 0) return '';if (ordered.length === 1) {const note = ordered[0]!;- return `Review note on \`${note.path}\`, ${describeLines(note)}:\n\n${note.text.trim()}`;+ return `Review note on \`${note.path}\`, ${describeNoteLines(note)}:\n\n${note.text.trim()}`;}const items = ordered.map((note, index) =>- `${index + 1}. \`${note.path}\`, ${describeLines(note)}: ${note.text.trim()}`+ `${index + 1}. \`${note.path}\`, ${describeNoteLines(note)}: ${note.text.trim()}`);return `Please address these ${ordered.length} review notes on the current changes:\n\n${items.join('\n')}`;}diff --git a/apps/web/src/features/agent-changes/debug/Gallery.tsx b/apps/web/src/features/agent-changes/debug/Gallery.tsxindex 37ffcfd95c..2f2d30fba3 100644--- a/apps/web/src/features/agent-changes/debug/Gallery.tsx+++ b/apps/web/src/features/agent-changes/debug/Gallery.tsx@@ -33,6 +33,26 @@ export default function AgentChangesGallery() {diffStyle: [urlState.diffStyle, urlState.setDiffStyle],dismissed: [dismissed, setDismissed],});+ if (controller.review.queued().length === 0) {+ controller.review.addNote(+ {+ path: 'apps/web/src/features/block-agent/state/unread.ts',+ side: 'additions',+ lineNumber: 8,+ endLineNumber: 8,+ },+ 'Keep archived sessions off the unread rail.'+ );+ controller.review.addNote(+ {+ path: 'crates/macro_agent_sessions/src/service.rs',+ side: 'additions',+ lineNumber: 88,+ endLineNumber: 92,+ },+ 'Mark the session read in the same transaction as the archive.'+ );+ }const [transcript, setTranscript] = createSignal<string[]>([]);// The mock host records prompts; surface them like a transcript would.const originalSend = context.host.agent.send;diff --git a/apps/web/src/features/agent-changes/primitives/create-agent-changes.ts b/apps/web/src/features/agent-changes/primitives/create-agent-changes.tsindex 2ea7e90bf8..49bae300f8 100644--- a/apps/web/src/features/agent-changes/primitives/create-agent-changes.ts+++ b/apps/web/src/features/agent-changes/primitives/create-agent-changes.ts@@ -6,7 +6,7 @@import type { Accessor } from 'solid-js';import type { AgentChangesContext } from '../context/agent-changes-context';import type { DiffStyle, PaneLayout } from '../core/layout';-import { formatNotesForAgent } from '../core/review-notes';+import { formatNotesForAgent, sendableNotes } from '../core/review-notes';import { type ChangesModel, createChangesModel } from './create-changes-model';import {createPaneLayout,@@ -88,7 +88,7 @@ export function createAgentChanges(options: {sendQueuedNotes: () => {const agent = host.agent;if (!agent) return;- const queued = review.queued();+ const queued = sendableNotes(review.notes());if (queued.length === 0) return;if (!agent.canSend()) {host.notify('The agent cannot take a prompt right now.', 'failure');diff --git a/apps/web/src/features/agent-changes/primitives/create-review-state.test.ts b/apps/web/src/features/agent-changes/primitives/create-review-state.test.tsindex 76452fd9ff..5fb2591343 100644--- a/apps/web/src/features/agent-changes/primitives/create-review-state.test.ts+++ b/apps/web/src/features/agent-changes/primitives/create-review-state.test.ts@@ -122,11 +122,17 @@ describe('createReviewState', () => {review.addNote({ ...anchor, path: 'b.ts' }, 'Keep');expect(review.queued().map((note) => note.id)).toEqual(['n1', 'n2']);+ review.updateNote('n1', 'Extract a helper, please');+ expect(review.notes()[0]?.text).toBe('Extract a helper, please');+review.removeNote('n2');const sent = review.markQueuedSent();expect(sent.map((note) => note.id)).toEqual(['n1']);expect(review.queued()).toEqual([]);expect(review.notes()[0]?.sentAt).toBe('T');+ expect(review.notes()[0]?.text).toBe('Extract a helper, please');+ review.updateNote('n1', 'ignored after send');+ expect(review.notes()[0]?.text).toBe('Extract a helper, please');expect(review.markQueuedSent()).toEqual([]);dispose();});diff --git a/apps/web/src/features/agent-changes/primitives/create-review-state.ts b/apps/web/src/features/agent-changes/primitives/create-review-state.tsindex 7330b941aa..f22c007a86 100644--- a/apps/web/src/features/agent-changes/primitives/create-review-state.ts+++ b/apps/web/src/features/agent-changes/primitives/create-review-state.ts@@ -37,6 +37,7 @@ export type ReviewController = {openNote: (anchor: NoteAnchor) => void;cancelNote: () => void;addNote: (anchor: NoteAnchor, text: string) => void;+ updateNote: (id: string, text: string) => void;removeNote: (id: string) => void;/** Stamp every queued note as sent, returning what was sent. */markQueuedSent: () => ReviewNote[];@@ -181,6 +182,13 @@ export function createReviewState(options: {],}));},+ updateNote: (id, text) =>+ setStored((previous) => ({+ ...previous,+ notes: previous.notes.map((note) =>+ note.id === id && note.sentAt === undefined ? { ...note, text } : note+ ),+ })),removeNote: (id) =>setStored((previous) => ({...previous,diff --git a/apps/web/src/features/agent-changes/views/SessionChangesControls.tsx b/apps/web/src/features/agent-changes/views/SessionChangesControls.tsxindex d98ef4ec83..14f9ba5c69 100644--- a/apps/web/src/features/agent-changes/views/SessionChangesControls.tsx+++ b/apps/web/src/features/agent-changes/views/SessionChangesControls.tsx@@ -4,7 +4,7 @@* Each renders nothing until a host has mounted the controller.*/-import { Show } from 'solid-js';+import { createSignal, Show } from 'solid-js';import { ChangesReadyCard } from '../components/ChangesReadyCard';import { ChangesToggleButton } from '../components/ChangesToggleButton';import { ReviewNotesChip } from '../components/ReviewNotesChip';@@ -58,14 +58,23 @@ export function ChangesHandoff() {export function ReviewNotesDock() {const controller = useOptionalAgentChanges();+ const [expanded, setExpanded] = createSignal(false);if (!controller) return null;- const { review, context } = controller;+ const { review, context, layout } = controller;return (<Show when={context.host.agent && review.queued().length > 0}><ReviewNotesChip- count={review.queued().length}+ notes={review.queued()}+ expanded={expanded()}disabled={!context.host.agent?.canSend()}+ onToggleExpanded={() => setExpanded((open) => !open)}+ onUpdate={review.updateNote}+ onRemove={review.removeNote}onSend={controller.sendQueuedNotes}+ onOpenNote={(note) => {+ layout.open();+ review.activate(note.path);+ }}/></Show>);diff --git a/apps/web/src/features/agent-changes/views/changes-pane.test.tsx b/apps/web/src/features/agent-changes/views/changes-pane.test.tsxindex d845bda43d..6b614e0e0e 100644--- a/apps/web/src/features/agent-changes/views/changes-pane.test.tsx+++ b/apps/web/src/features/agent-changes/views/changes-pane.test.tsx@@ -263,9 +263,39 @@ describe('session controls', () => {'Use a constant');expect(screen.getByText(/review note/).textContent).toContain('1');+ fireEvent.click(+ screen.getByRole('button', { name: /1 review note queued/ })+ );+ const editor = screen.getByLabelText(+ 'Review note on apps/web/src/a.ts, line 2 (new)'+ ) as HTMLTextAreaElement;+ expect(editor.value).toBe('Use a constant');+ fireEvent.input(editor, { target: { value: 'Use a named constant' } });fireEvent.click(screen.getByRole('button', { name: 'Send to agent' }));expect(context.sent[0]).toContain('`apps/web/src/a.ts`, line 2 (new)');- expect(context.sent[0]).toContain('Use a constant');+ expect(context.sent[0]).toContain('Use a named constant');expect(screen.queryByText(/review note/)).toBeNull();});++ it("opens the note's file from the expanded dock", () => {+ const context = readyContext();+ const { controller } = mount(context, () => <ReviewNotesDock />);+ controller().review.addNote(+ {+ path: 'apps/web/src/a.ts',+ side: 'additions',+ lineNumber: 2,+ endLineNumber: 2,+ },+ 'Use a constant'+ );+ fireEvent.click(+ screen.getByRole('button', { name: /1 review note queued/ })+ );+ fireEvent.click(+ screen.getByRole('button', { name: /apps\/web\/src\/a.ts/ })+ );+ expect(controller().layout.changesVisible()).toBe(true);+ expect(controller().review.active()).toBe('apps/web/src/a.ts');+ });});diff --git a/docs/AGENT_GUIDE/ai-chat.md b/docs/AGENT_GUIDE/ai-chat.mdindex db8e6c0cb2..2267052598 100644--- a/docs/AGENT_GUIDE/ai-chat.md+++ b/docs/AGENT_GUIDE/ai-chat.md@@ -434,10 +434,14 @@ caret, the path, `+adds −dels`, and **Copy path**. Diffs render with Pierre; hline and click the accent **+** in the gutter (drag for a range) to leave areview note for the agent (`aria-label="Review note"`; `Cmd/Ctrl+Enter` adds,`Escape` cancels). Notes hang under their line as "queued for the agent" and a-**N review notes queued · Send to agent** chip appears above the composer;-sending posts one prompt listing every note by file and line and marks them-"sent to agent". Notes never go to GitHub. Collapsed files and unsent notes-persist per session in localStorage; a new capture expands all files.+**N review notes queued · Send to agent** chip appears above the composer.+The chip's count row expands (`aria-expanded`) to show each queued note's+file, line, and text so the reviewer can read or edit them before sending;+**Send to agent** then posts one prompt listing every non-empty note by file+and line and marks them "sent to agent". Clicking a note's path opens that+file in the Changes pane. Notes never go to GitHub. Collapsed files and+unsent notes persist per session in localStorage; a new capture expands all+files.While the pane is closed and a capture has files, a **Changes ready toreview** card sits above the composer with **Review changes**, **Pull request