Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

align + comment to acp (#3153)

shagun-singh-inkeepf8e424587f53
diff --git a/.changeset/acp-composer-comment-chip.md b/.changeset/acp-composer-comment-chip.md
new file mode 100644
index 000000000..96b0e2731
--- /dev/null
+++ b/.changeset/acp-composer-comment-chip.md
@@ -0,0 +1,5 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+Queued review comments can now be sent into the agent thread you already have open. The agent panel's composer carries the same `+ Comments` chip as the Ask AI composer: click it to attach everything waiting in the queue, expand it to review or uncheck individual comments, and send.
diff --git a/packages/app/src/components/BottomComposer.tsx b/packages/app/src/components/BottomComposer.tsx
index d8d498a4a..2ddf41c0c 100644
--- a/packages/app/src/components/BottomComposer.tsx
+++ b/packages/app/src/components/BottomComposer.tsx
@@ -851,7 +851,14 @@ export function BottomComposer({
// instruction for the batch, and every queued comment rides along with its
// own doc + passage. One send, one agent turn.
if (hasQueuedComments) {
- void submitQueuedComments();
+ // `dispatchComments` reports every failure it knows about and returns an
+ // empty batch, so nothing here should reject. If something upstream ever
+ // does, the composer is already in the safe state — draft intact, batch
+ // still attached, comments still queued — so this only has to keep the
+ // rejection from disappearing.
+ submitQueuedComments().catch((err) => {
+ console.warn('[comments] queued-comment send rejected unexpectedly', err);
+ });
return;
}
void dispatchComposed(composeCurrentInput());
diff --git a/packages/app/src/components/ComposerContextChips.tsx b/packages/app/src/components/ComposerContextChips.tsx
index aced822ae..6634a9439 100644
--- a/packages/app/src/components/ComposerContextChips.tsx
+++ b/packages/app/src/components/ComposerContextChips.tsx
@@ -83,16 +83,17 @@ function FileChip({ path, onRemove }: { path: string; onRemove: () => void }) {
}
export function ComposerContextChips({
- files,
+ files = [],
onRemoveFile,
className,
children,
}: {
/** Ordered set of workspace-relative file paths to show as removable top-row
* chips (already deduped against inline mentions + sticky-dismissed by the
- * host). Empty → only `children` (if any) render. */
- files: readonly string[];
- onRemoveFile: (path: string) => void;
+ * host). Empty (the default) → only `children` (if any) render, which is how
+ * a composer with no file-context tracking of its own reuses the row. */
+ files?: readonly string[];
+ onRemoveFile?: (path: string) => void;
className?: string;
/** Extra context chips rendered as siblings in the SAME flex-wrap row (e.g.
* the captured-selection pill), so every reference shares one wrapping row and
@@ -111,7 +112,7 @@ export function ComposerContextChips({
data-testid="composer-context-chips"
>
{files.map((path) => (
- <FileChip key={path} path={path} onRemove={() => onRemoveFile(path)} />
+ <FileChip key={path} path={path} onRemove={() => onRemoveFile?.(path)} />
))}
{children}
</div>
diff --git a/packages/app/src/components/acp/ThreadView.comments.dom.test.tsx b/packages/app/src/components/acp/ThreadView.comments.dom.test.tsx
new file mode 100644
index 000000000..c799257e6
--- /dev/null
+++ b/packages/app/src/components/acp/ThreadView.comments.dom.test.tsx
@@ -0,0 +1,310 @@
+/**
+ * Queued review comments ride the agent panel's composer, not only the Ask AI
+ * one: the same `+ Comments` chip attaches the batch, and sending puts it into
+ * THIS thread as one turn rather than starting a detached conversation.
+ *
+ * The chip's own two-state rendering is `comment-chips`' behaviour; what this
+ * suite owns is the wiring — that the row appears in the ACP composer at all,
+ * that an attached batch makes an empty draft sendable, that the send reaches
+ * `client.prompt` with the composed instruction, and that a hand-off which
+ * never happened leaves the draft alone.
+ */
+
+import type { ThreadInfo } from '@inkeep/open-knowledge-core/acp/thread-protocol';
+import { cleanup, render as rtlRender, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
+import type { CommentThread } from '@/comments/types';
+import { TooltipProvider } from '@/components/ui/tooltip';
+import type { ThreadRenderModel } from '@/lib/acp/thread-event-model';
+
+const render = (ui: Parameters<typeof rtlRender>[0]) => rtlRender(ui, { wrapper: TooltipProvider });
+
+const prompt = vi.fn((_threadId: string, _content: string) => {});
+const createThread = vi.fn((_args: { prompt?: string }) => Promise.resolve({ threadId: 'new' }));
+/**
+ * Archived-thread resume, controlled per test.
+ *
+ * The ONLY send that can genuinely fail: a live thread's `prompt` is a
+ * fire-and-forget call the server queues, so every failure assertion below runs
+ * against an archived thread.
+ */
+let resumeSucceeds = false;
+const resumeThread = vi.fn((_threadId: string, _content: string) =>
+ resumeSucceeds ? Promise.resolve(undefined) : Promise.reject(new Error('agent session is gone')),
+);
+
+vi.doMock('@/lib/acp/thread-client', () => ({
+ getAgentThreadClient: () => ({
+ respondPermission: () => {},
+ respondRuntimeConsent: () => {},
+ cancel: () => {},
+ prompt,
+ editQueued: () => {},
+ removeQueued: () => {},
+ setMode: () => {},
+ setConfigOption: () => {},
+ closeThread: () => {},
+ createThread,
+ resumeThread,
+ }),
+ ThreadResumeError: class ThreadResumeError extends Error {},
+ useAgentThread: () => ({ info: undefined, events: [], lastSeq: 5 }),
+ useAgentThreadModel: () => model,
+}));
+
+vi.doMock('@/editor/DocumentContext', () => ({
+ useDocumentContext: () => ({ systemProvider: null }),
+}));
+
+vi.doMock('@/lib/use-workspace', () => ({ useWorkspace: () => null }));
+
+vi.doMock('@/components/acp/AgentMarkdown', () => ({
+ AgentMarkdown: ({ text }: { text: string }) => <div>{text}</div>,
+}));
+
+/**
+ * The comment store, doubled: a fixed queue with everything checked. The real
+ * one talks to the server on every read, and the dispatch path's server-side
+ * re-anchor is `dispatch-batch.test.ts`'s subject, not this suite's.
+ */
+const captured = {
+ dispatched: [] as string[],
+ selectAllCalls: 0,
+ /** Whether each send asked for the batch to be closed. */
+ resolved: [] as boolean[],
+};
+
+function thread(id: string, docName: string, body: string): CommentThread {
+ return {
+ id,
+ docName,
+ target: { kind: 'body' },
+ anchor: { quote: `quote for ${id}`, prefix: '', suffix: '', start: 0, end: 5 },
+ status: 'open',
+ body,
+ createdAt: 1,
+ queued: true,
+ };
+}
+
+const threads = [
+ thread('t1', 'notes.md', 'tighten this'),
+ thread('t2', 'plan.md', 'cite a source'),
+];
+
+vi.doMock('@/comments/store', () => ({
+ useQueue: () => threads.map((item) => item.id),
+ useQueueSelection: () => threads.map((item) => item.id),
+ getThreadById: (id: string) => threads.find((item) => item.id === id) ?? null,
+ removeFromQueue: () => {},
+ toggleQueueSelection: () => {},
+ selectAllQueued: () => {
+ captured.selectAllCalls += 1;
+ },
+ dispatchComments: async ({
+ compose,
+ resolve = true,
+ }: {
+ compose: (items: readonly { threadId: string; payload: unknown }[]) => Promise<boolean>;
+ resolve?: boolean;
+ }) => {
+ captured.resolved.push(resolve);
+ const items = threads.map((item) => ({
+ threadId: item.id,
+ payload: {
+ docName: item.docName,
+ instruction: item.body,
+ passage: { exact: item.anchor?.quote ?? '', prefix: '', suffix: '' },
+ anchorLost: false,
+ passageRepeats: false,
+ },
+ }));
+ // What ships is what `compose` reported, exactly as the real dispatch path
+ // decides it. Returning a preset list instead would let the send's own
+ // boolean go untested — and that boolean is the whole contract here: a
+ // hand-off that never happened must leave every comment queued.
+ const delivered = await compose(items);
+ if (!delivered) return [];
+ const ids = items.map((item) => item.threadId);
+ captured.dispatched.push(...ids);
+ return ids;
+ },
+}));
+
+const { ThreadView } = await import('./ThreadView');
+
+let model: ThreadRenderModel | null = null;
+
+function makeInfo(overrides?: Partial<ThreadInfo>): ThreadInfo {
+ return {
+ threadId: 'thread-1',
+ agent: { id: 'claude', name: 'Claude Agent', source: 'registry' },
+ title: 'Test thread',
+ status: 'ready',
+ createdAt: 1,
+ lastActivityAt: 2,
+ lastSeq: 5,
+ archived: false,
+ ...overrides,
+ };
+}
+
+beforeEach(() => {
+ model = {
+ items: [],
+ plan: [],
+ turnActive: false,
+ tokenUsage: null,
+ terminals: {},
+ permissionsByToolCall: {},
+ };
+ prompt.mockClear();
+ createThread.mockClear();
+ resumeThread.mockClear();
+ captured.dispatched = [];
+ captured.selectAllCalls = 0;
+ captured.resolved = [];
+ resumeSucceeds = false;
+});
+
+afterEach(cleanup);
+
+describe('ThreadView queued-comment chip', () => {
+ test('offers the queue as an add chip, then names what the message carries', async () => {
+ const user = userEvent.setup();
+ render(<ThreadView info={makeInfo()} />);
+
+ // Detached: the source, with no count — the chip's presence is the signal
+ // that a batch is waiting.
+ const chip = screen.getByTestId('composer-context-chip-comments');
+ expect(chip.textContent).toContain('Comments');
+ expect(chip.textContent).not.toContain('2');
+
+ await user.click(chip);
+
+ expect(captured.selectAllCalls).toBe(1);
+ expect(screen.getByTestId('composer-context-chip-comments').textContent).toContain(
+ '2 comments',
+ );
+ });
+
+ test('an attached batch is sendable with nothing typed, and lands as one prompt', async () => {
+ const user = userEvent.setup();
+ render(<ThreadView info={makeInfo()} />);
+
+ const send = screen.getByTestId('agent-thread-send') as HTMLButtonElement;
+ // Empty draft, nothing attached: there is nothing to send.
+ expect(send.disabled).toBe(true);
+
+ await user.click(screen.getByTestId('composer-context-chip-comments'));
+ expect(send.disabled).toBe(false);
+
+ await user.click(send);
+
+ expect(prompt).toHaveBeenCalledTimes(1);
+ const [threadId, content] = prompt.mock.calls[0] ?? [];
+ expect(threadId).toBe('thread-1');
+ // One turn carrying both comments, each naming its own document.
+ expect(content).toContain('notes.md');
+ expect(content).toContain('tighten this');
+ expect(content).toContain('plan.md');
+ expect(content).toContain('cite a source');
+ expect(captured.dispatched).toEqual(['t1', 't2']);
+ // The turn ran, so the comments close with it.
+ expect(captured.resolved).toEqual([true]);
+ });
+
+ test('the typed draft becomes the batch instruction and clears on a real send', async () => {
+ const user = userEvent.setup();
+ render(<ThreadView info={makeInfo()} />);
+
+ const field = screen.getByTestId('agent-thread-composer') as HTMLTextAreaElement;
+ await user.click(field);
+ await user.keyboard('apply these before the review');
+ await user.click(screen.getByTestId('composer-context-chip-comments'));
+ await user.click(screen.getByTestId('agent-thread-send'));
+
+ expect(prompt.mock.calls[0]?.[1]).toContain('apply these before the review');
+ expect(field.value).toBe('');
+ // The batch detaches with the draft, so the next message can't silently
+ // carry whatever has been queued since.
+ expect(screen.getByTestId('composer-context-chip-comments').textContent).toContain('Comments');
+ });
+
+ test('a mid-turn send queues the message but leaves the comments open', async () => {
+ // A turn is running, so the send lands in the server's message queue — and
+ // a cancel or a dead agent drops that queue before it is ever read.
+ model = { ...(model as ThreadRenderModel), turnActive: true };
+ const user = userEvent.setup();
+ render(<ThreadView info={makeInfo({ status: 'running' })} />);
+
+ await user.click(screen.getByTestId('composer-context-chip-comments'));
+ await user.click(screen.getByTestId('agent-thread-send'));
+
+ // The message really is sent...
+ expect(prompt).toHaveBeenCalledTimes(1);
+ // ...but nothing is marked done until the agent picks it up.
+ expect(captured.resolved).toEqual([false]);
+ });
+
+ test('a resumed archived thread ships the batch like any other send', async () => {
+ resumeSucceeds = true;
+ const user = userEvent.setup();
+ render(<ThreadView info={makeInfo({ archived: true })} />);
+
+ const field = screen.getByTestId('agent-thread-composer') as HTMLTextAreaElement;
+ await user.click(field);
+ await user.keyboard('handle these');
+ await user.click(screen.getByTestId('composer-context-chip-comments'));
+ await user.click(screen.getByTestId('agent-thread-send'));
+
+ // The message rides the resume op as the thread's first turn.
+ expect(resumeThread.mock.calls[0]?.[1]).toContain('tighten this');
+ await waitFor(() => expect(captured.dispatched).toEqual(['t1', 't2']));
+ await waitFor(() => expect(field.value).toBe(''));
+ });
+
+ test('a send that failed leaves the batch attached and the draft intact', async () => {
+ const user = userEvent.setup();
+ render(<ThreadView info={makeInfo({ archived: true })} />);
+
+ const field = screen.getByTestId('agent-thread-composer') as HTMLTextAreaElement;
+ await user.click(field);
+ await user.keyboard('handle these');
+ await user.click(screen.getByTestId('composer-context-chip-comments'));
+ await user.click(screen.getByTestId('agent-thread-send'));
+
+ await screen.findByTestId('agent-thread-resume-failed');
+ // Nothing resolved: the comments are all still queued, still on this
+ // message, and the words typed for them are where they were left.
+ expect(captured.dispatched).toEqual([]);
+ expect(field.value).toBe('handle these');
+ expect(screen.getByTestId('composer-context-chip-comments').textContent).toContain(
+ '2 comments',
+ );
+ });
+
+ test('a failed resume never hands the composed batch to the new-thread fallback', async () => {
+ const user = userEvent.setup();
+ render(<ThreadView info={makeInfo({ archived: true })} />);
+
+ const field = screen.getByTestId('agent-thread-composer') as HTMLTextAreaElement;
+ await user.click(field);
+ await user.keyboard('look at these');
+ await user.click(screen.getByTestId('composer-context-chip-comments'));
+ await user.click(screen.getByTestId('agent-thread-send'));
+
+ // The resume itself carried the batch — that send was real, it just failed.
+ expect(resumeThread.mock.calls[0]?.[1]).toContain('tighten this');
+
+ await user.click(await screen.findByTestId('agent-thread-resume-fallback-new'));
+
+ // The fresh thread starts from the reviewer's own words. Carrying the
+ // composed batch here would run it while the same comments sit queued,
+ // ready to ride a later send too.
+ const started = createThread.mock.calls[0]?.[0];
+ expect(started?.prompt).toBe('look at these');
+ expect(started?.prompt).not.toContain('tighten this');
+ });
+});
diff --git a/packages/app/src/components/acp/ThreadView.tsx b/packages/app/src/components/acp/ThreadView.tsx
index ca72f06cf..af2d9aa92 100644
--- a/packages/app/src/components/acp/ThreadView.tsx
+++ b/packages/app/src/components/acp/ThreadView.tsx
@@ -41,6 +41,18 @@ import {
useRef,
useState,
} from 'react';
+import { toast } from 'sonner';
+import {
+ composeCommentBatchInstruction,
+ QueuedCommentsChip,
+ QueuedCommentsList,
+ toCommentBatchItem,
+ useQueuedComments,
+ useSelectedCommentCount,
+} from '@/comments/comment-chips';
+import { dispatchComments, selectAllQueued } from '@/comments/store';
+import type { CommentThread } from '@/comments/types';
+import { ComposerContextChips } from '@/components/ComposerContextChips';
import { focusComposerInputOnCardPointer } from '@/components/focus-composer-on-card-pointer';
import { useOptionalPageList } from '@/components/PageListContext';
import { Badge } from '@/components/ui/badge';
@@ -289,37 +301,136 @@ export function ThreadView({ info }: { info: ThreadInfo }): ReactNode {
// would read as two copies.
const [failedPrompt, setFailedPrompt] = useState<string | null>(null);
+ // Queued review comments ride this composer the same way they ride the Ask AI
+ // one: the chip is the attach control, the typed draft becomes the batch's
+ // shared instruction, and the batch lands as ONE turn in THIS thread — which
+ // is the point of having it here rather than only in the omnicomposer, where
+ // every send starts a conversation detached from the one already going.
+ const queuedComments = useQueuedComments();
+ const selectedCommentCount = useSelectedCommentCount();
+ const [commentsAttached, setCommentsAttached] = useState(false);
+ const [commentsExpanded, setCommentsExpanded] = useState(false);
+ const hasQueuedComments = selectedCommentCount > 0 && commentsAttached;
+
+ /**
+ * The one send. A live thread prompts (the server queues it behind an active
+ * turn); an archived one type-to-resumes — the send respawns the agent and
+ * reconnects the stored session, with the message riding the resume op as its
+ * first turn (the server echoes it into the transcript immediately).
+ *
+ * Resolves to whether the message actually reached the agent, which the
+ * queued-comment send needs: a batch reported as delivered is resolved and
+ * dropped from the queue, so a resume that failed has to say so rather than
+ * close comments on a turn that never ran.
+ *
+ * `.catch().finally()` rather than try/catch: React Compiler bails on some
+ * TryStatement shapes, and the promise form is what the other composer uses.
+ */
+ const sendText = (
+ text: string,
+ /**
+ * What the "new thread" fallback should carry when an archived thread's
+ * resume fails. Defaults to the message itself.
+ *
+ * The queued-comment send passes null instead, because a failed hand-off
+ * leaves every comment QUEUED: stashing the composed batch would run it on
+ * the fresh thread and then let the same comments ride a later send too.
+ * Null falls the fallback back to the draft — the reviewer's own words —
+ * and re-attaching the still-queued batch there is the retry.
+ */
+ failureText: string | null = text,
+ ): Promise<boolean> => {
+ if (!archived) {
+ client.prompt(info.threadId, text);
+ // Sending re-engages the live edge even if the reader had scrolled up.
+ scrollApiRef.current?.scrollToEnd();
+ return Promise.resolve(true);
+ }
+ setResumePending(true);
+ setResumeError(null);
+ setFailedPrompt(null);
+ scrollApiRef.current?.scrollToEnd();
+ return client
+ .resumeThread(info.threadId, text)
+ .then(() => true)
+ .catch((err) => {
+ setResumeError(
+ err instanceof ThreadResumeError
+ ? err
+ : new ThreadResumeError('internal', err instanceof Error ? err.message : String(err)),
+ );
+ setFailedPrompt(failureText);
+ return false;
+ })
+ .finally(() => setResumePending(false));
+ };
+
const submit = (): void => {
const text = draft.trim();
// `canQueue` rides alongside `canPrompt`: a busy thread accepts a queued
// message rather than refusing the send.
- if (text === '' || !(canPrompt || canQueue)) return;
- if (archived) {
- // Type-to-resume: the send respawns the agent and reconnects the
- // stored session; the message rides the resume op as its first turn
- // (the server echoes it into the transcript immediately).
- setResumePending(true);
- setResumeError(null);
- setFailedPrompt(null);
- client
- .resumeThread(info.threadId, text)
- .catch((err) => {
- setResumeError(
- err instanceof ThreadResumeError
- ? err
- : new ThreadResumeError('internal', err instanceof Error ? err.message : String(err)),
- );
- setFailedPrompt(text);
- })
- .finally(() => setResumePending(false));
- setDraft('');
- // Sending re-engages the live edge even if the reader had scrolled up.
- scrollApiRef.current?.scrollToEnd();
+ if (!(canPrompt || canQueue)) return;
+ // An attached batch IS the content, so the empty-draft gate doesn't apply to
+ // it — the comments carry the ask even when nothing was typed for them.
+ if (hasQueuedComments) {
+ // `dispatchComments` reports every failure it knows about and returns an
+ // empty batch, so nothing here should reject. If something upstream ever
+ // does, the composer is already in the safe state — draft intact, batch
+ // still attached, comments still queued — so this only has to keep the
+ // rejection from disappearing.
+ submitQueuedComments(text).catch((err) => {
+ console.warn('[acp] queued-comment send rejected unexpectedly', err);
+ });
return;
}
- client.prompt(info.threadId, text);
+ if (text === '') return;
+ void sendText(text);
setDraft('');
- scrollApiRef.current?.scrollToEnd();
+ };
+
+ /**
+ * Dispatch the queued comments as one turn in this thread. The server
+ * re-finds each anchor first (so a passage that moved is still found, and one
+ * that is gone is flagged rather than silently retargeted), and the batch
+ * resolves only if the send actually happened — a failed resume leaves every
+ * comment queued, with the instruction still in the composer.
+ *
+ * Re-entrant sends are held off by `dispatchComments` itself, which guards the
+ * one queue across every surface that drains it.
+ */
+ const submitQueuedComments = async (instruction: string): Promise<void> => {
+ // A mid-turn send only reaches the server's MESSAGE queue, and both a
+ // cancel and a terminal status drop that queue before the agent ever reads
+ // it. Resolving there would close review work nobody has acted on — the one
+ // failure the comment queue exists to prevent — so the batch stays queued
+ // until a send that actually runs. The message itself is really sent, so
+ // the composer still clears; the toast is what explains the two facts
+ // sitting side by side.
+ const queuedBehindTurn = canQueue;
+ const shipped = await dispatchComments({
+ resolve: !queuedBehindTurn,
+ compose: (items) =>
+ sendText(
+ composeCommentBatchInstruction(
+ items.map((item) => toCommentBatchItem(item.payload)),
+ instruction,
+ ),
+ // Never stash the composed batch for the new-thread fallback — see
+ // `sendText`'s `failureText`.
+ null,
+ ),
+ });
+ if (shipped.length === 0) return;
+ if (queuedBehindTurn) {
+ toast.info(
+ t`Your comments are waiting behind the running turn — they stay queued until the agent picks the message up.`,
+ );
+ }
+ setDraft('');
+ // The batch detaches with the rest of the draft. Left on, the next message
+ // would silently carry whatever had been queued since.
+ setCommentsAttached(false);
+ setCommentsExpanded(false);
};
const startFreshThread = (): void => {
@@ -494,6 +605,22 @@ export function ThreadView({ info }: { info: ThreadInfo }): ReactNode {
archived={archived}
resumePending={resumePending}
usage={model?.tokenUsage ?? null}
+ queuedComments={queuedComments}
+ selectedCommentCount={selectedCommentCount}
+ hasQueuedComments={hasQueuedComments}
+ commentsExpanded={commentsExpanded}
+ onAttachComments={() => {
+ setCommentsAttached(true);
+ // Deselection is sticky, so re-attaching has to re-check the queue —
+ // otherwise this puts an empty batch on the message and the chip
+ // bounces straight back to detached.
+ selectAllQueued();
+ }}
+ onToggleCommentsExpanded={() => setCommentsExpanded((open) => !open)}
+ onDismissComments={() => {
+ setCommentsAttached(false);
+ setCommentsExpanded(false);
+ }}
/>
</div>
);
@@ -1995,6 +2122,13 @@ function ThreadComposer({
archived,
resumePending,
usage,
+ queuedComments,
+ selectedCommentCount,
+ hasQueuedComments,
+ commentsExpanded,
+ onAttachComments,
+ onToggleCommentsExpanded,
+ onDismissComments,
}: {
info: ThreadInfo;
draft: string;
@@ -2013,6 +2147,22 @@ function ThreadComposer({
resumePending: boolean;
/** Context-window fill the agent reported; null until it reports any. */
usage: { used?: number; size?: number } | null;
+ /** The review comments waiting to be sent, in queue order. */
+ queuedComments: readonly CommentThread[];
+ /** How many of them are checked — what an attached send would carry. */
+ selectedCommentCount: number;
+ /**
+ * The batch is riding this message AND still has something checked — the
+ * derived flag, never the raw attached state. `BottomComposer` carries the
+ * same distinction: unchecking the last item means nothing rides this
+ * message, which is the detached state however it was reached, and keying the
+ * chip on the raw flag leaves a countless chip above a list of unchecked rows.
+ */
+ hasQueuedComments: boolean;
+ commentsExpanded: boolean;
+ onAttachComments: () => void;
+ onToggleCommentsExpanded: () => void;
+ onDismissComments: () => void;
}): ReactNode {
const { t } = useLingui();
const ref = useRef<HTMLTextAreaElement>(null);
@@ -2038,9 +2188,12 @@ function ThreadComposer({
const queue = info.queue ?? [];
+ const queueSize = queuedComments.length;
+
// What the action slot keys off. Both the Stop/Send choice and Send's disabled
- // state read this, or the two disagree.
- const hasSendableContent = draft.trim() !== '';
+ // state read this, or the two disagree. An attached batch counts as content:
+ // the comments are the ask, so a send with nothing typed is a real send.
+ const hasSendableContent = draft.trim() !== '' || hasQueuedComments;
return (
<div className="p-2">
@@ -2058,6 +2211,32 @@ function ThreadComposer({
onMouseDown={(event) => focusComposerInputOnCardPointer(event, ref)}
className="cursor-text rounded-lg border border-input bg-transparent transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 dark:bg-input/30"
>
+ {/* Queued comments as a context chip above the field, the same control
+ the Ask AI composer carries — detached it is a `+ Comments` add
+ button, attached it grows the peek + ✕ the other context chips have.
+ Same row component, so the two composers read as one chip system. */}
+ {/* Gated here as well as inside the chip: `ComposerContextChips` decides
+ whether to render its row by counting children, and an element that
+ returns null still counts as one. An empty queue has to contribute NO
+ child, or the row appears as an empty strip above the field. */}
+ {queueSize > 0 ? (
+ <ComposerContextChips className="px-3 pt-2 pb-1">
+ <QueuedCommentsChip
+ // Attached, the count is what a SEND carries, so unchecking an
+ // item moves it. Detached the chip shows no number, so the raw
+ // queue is what decides it renders at all.
+ count={hasQueuedComments ? selectedCommentCount : queueSize}
+ attached={hasQueuedComments}
+ expanded={commentsExpanded}
+ onAttach={onAttachComments}
+ onToggleExpanded={onToggleCommentsExpanded}
+ onDismiss={onDismissComments}
+ />
+ {hasQueuedComments && commentsExpanded ? (
+ <QueuedCommentsList threads={queuedComments} />
+ ) : null}
+ </ComposerContextChips>
+ ) : null}
<Textarea
ref={ref}
value={draft}
diff --git a/packages/app/src/locales/en/messages.json b/packages/app/src/locales/en/messages.json
index de9385eca..a43f0d6d4 100644
--- a/packages/app/src/locales/en/messages.json
+++ b/packages/app/src/locales/en/messages.json
@@ -937,6 +937,9 @@
"EhDLBx": ["You modified <0>", ["filePath"], "</0> locally, but it was deleted upstream."],
"Ehkru0": ["Open, navigate, accept, or dismiss CodeMirror completion suggestions."],
"EiVgl5": ["You don't have permission to push to this repo."],
+ "Eiowpn": [
+ "Your comments are waiting behind the running turn — they stay queued until the agent picks the message up."
+ ],
"Eji13z": ["Toggle highlight formatting."],
"EkH9pt": ["Update"],
"EkUnmS": ["any"],
diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.po
index 39685abd2..66a4e57ef 100644
--- a/packages/app/src/locales/en/messages.po
+++ b/packages/app/src/locales/en/messages.po
@@ -12132,6 +12132,10 @@ msgstr "[email protected]"
msgid "Your change is still being saved — run the test again in a moment."
msgstr "Your change is still being saved — run the test again in a moment."
+#: src/components/acp/ThreadView.tsx
+msgid "Your comments are waiting behind the running turn — they stay queued until the agent picks the message up."
+msgstr "Your comments are waiting behind the running turn — they stay queued until the agent picks the message up."
+
#: src/components/ShareBranchSwitchDialog.tsx
msgid "Your copy of branch <0>{shareBranch}</0> has changes that aren't on GitHub. The {targetNoun} will appear once the branch syncs."
msgstr "Your copy of branch <0>{shareBranch}</0> has changes that aren't on GitHub. The {targetNoun} will appear once the branch syncs."
diff --git a/packages/app/src/locales/pseudo/messages.json b/packages/app/src/locales/pseudo/messages.json
index 97fa7bed1..f8970f7c7 100644
--- a/packages/app/src/locales/pseudo/messages.json
+++ b/packages/app/src/locales/pseudo/messages.json
@@ -937,6 +937,9 @@
"EhDLBx": ["Ŷōũ ḿōďĩƒĩēď <0>", ["filePath"], "</0> ĺōćàĺĺŷ, ƀũţ ĩţ ŵàś ďēĺēţēď ũƥśţŕēàḿ."],
"Ehkru0": ["Ōƥēń, ńàvĩĝàţē, àććēƥţ, ōŕ ďĩśḿĩśś ĆōďēḾĩŕŕōŕ ćōḿƥĺēţĩōń śũĝĝēśţĩōńś."],
"EiVgl5": ["Ŷōũ ďōń'ţ ĥàvē ƥēŕḿĩśśĩōń ţō ƥũśĥ ţō ţĥĩś ŕēƥō."],
+ "Eiowpn": [
+ "Ŷōũŕ ćōḿḿēńţś àŕē ŵàĩţĩńĝ ƀēĥĩńď ţĥē ŕũńńĩńĝ ţũŕń — ţĥēŷ śţàŷ ǫũēũēď ũńţĩĺ ţĥē àĝēńţ ƥĩćķś ţĥē ḿēśśàĝē ũƥ."
+ ],
"Eji13z": ["Ţōĝĝĺē ĥĩĝĥĺĩĝĥţ ƒōŕḿàţţĩńĝ."],
"EkH9pt": ["Ũƥďàţē"],
"EkUnmS": ["àńŷ"],
diff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.po
index 5e0782e02..3fb28a368 100644
--- a/packages/app/src/locales/pseudo/messages.po
+++ b/packages/app/src/locales/pseudo/messages.po
@@ -12128,6 +12128,10 @@ msgstr ""
msgid "Your change is still being saved — run the test again in a moment."
msgstr ""
+#: src/components/acp/ThreadView.tsx
+msgid "Your comments are waiting behind the running turn — they stay queued until the agent picks the message up."
+msgstr ""
+
#: src/components/ShareBranchSwitchDialog.tsx
msgid "Your copy of branch <0>{shareBranch}</0> has changes that aren't on GitHub. The {targetNoun} will appear once the branch syncs."
msgstr ""