Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-10023 fix(issues): say what a published reply's run is still waiting on (#11533)

Multica Evefecda39bc4c3
diff --git a/packages/views/issues/components/inline-comment-run.test.tsx b/packages/views/issues/components/inline-comment-run.test.tsx
index 8f19d032f2..09cc1de533 100644
--- a/packages/views/issues/components/inline-comment-run.test.tsx
+++ b/packages/views/issues/components/inline-comment-run.test.tsx
@@ -9,7 +9,7 @@ import { issueKeys } from "@multica/core/issues/queries";
import type { AgentTask, TimelineEntry } from "@multica/core/types";
import type { TaskMessagePayload } from "@multica/core/types/events";
import { renderWithI18n } from "../../test/i18n";
-import { InlineCommentRun } from "./inline-comment-run";
+import { InlineCommentRun, PlacedInlineCommentRun, REPLY_PENDING_CALL_NOTICE_MS } from "./inline-comment-run";
const dispatchReasonCodeMock = vi.hoisted(() => vi.fn());
@@ -516,3 +516,56 @@ describe("InlineCommentRun", () => {
});
});
});
+
+describe("PlacedInlineCommentRun below a published reply", () => {
+ const startedAt = Date.parse("2026-09-07T00:10:00Z");
+ const pendingCommand: TaskMessagePayload[] = [
+ { task_id: id, issue_id: "issue", seq: 1, type: "tool_use", tool: "run_command", call_id: "a",
+ input: { command: "./scripts/build.sh" }, created_at: "2026-09-07T00:10:00Z" },
+ { task_id: id, issue_id: "issue", seq: 2, type: "tool_use", tool: "run_command", call_id: "b",
+ input: { command: "multica issue comment add" }, created_at: "2026-09-07T00:10:01Z" },
+ { task_id: id, issue_id: "issue", seq: 3, type: "tool_result", tool: "run_command", call_id: "b",
+ output: "posted", created_at: "2026-09-07T00:10:02Z" },
+ ];
+ function placed(current: AgentTask) {
+ const client = new QueryClient({ defaultOptions: { queries: { retry: false }, mutations: { retry: false } } });
+ return renderWithI18n(<QueryClientProvider client={client}>
+ <PlacedInlineCommentRun run={{ task: current, commentId: "comment", hasReply: true }} />
+ </QueryClientProvider>);
+ }
+ beforeEach(() => vi.useFakeTimers({ shouldAdvanceTime: true, now: startedAt + 5_000 }));
+ afterEach(() => vi.useRealTimers());
+
+ it("names the unfinished call once the reply has waited on it, and stops the run from there", async () => {
+ vi.mocked(api.listTaskMessages).mockResolvedValue(pendingCommand);
+ vi.mocked(api.cancelTask).mockResolvedValue(undefined as never);
+ placed(task());
+ await waitFor(() => expect(api.listTaskMessages).toHaveBeenCalled());
+ expect(screen.queryByRole("status")).not.toBeInTheDocument();
+
+ await act(async () => { vi.setSystemTime(startedAt + REPLY_PENDING_CALL_NOTICE_MS); await vi.advanceTimersByTimeAsync(1_000); });
+ expect(await screen.findByRole("status")).toHaveTextContent("Still running: waiting for ./scripts/build.sh to finish");
+ expect(screen.getByText("1m 01s")).toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole("button", { name: "Stop" }));
+ fireEvent.click(await screen.findByRole("button", { name: "Stop run" }));
+ await waitFor(() => expect(api.cancelTask).toHaveBeenCalledWith("issue", id));
+ });
+
+ it("stays settled when every call has returned or the run has ended", async () => {
+ vi.setSystemTime(startedAt + 10 * REPLY_PENDING_CALL_NOTICE_MS);
+ vi.mocked(api.listTaskMessages).mockResolvedValue([...pendingCommand,
+ { task_id: id, issue_id: "issue", seq: 4, type: "tool_result", tool: "run_command", call_id: "a", output: "ok", created_at: "2026-09-07T00:11:00Z" }]);
+ placed(task());
+ await waitFor(() => expect(api.listTaskMessages).toHaveBeenCalled());
+ await act(async () => { await vi.advanceTimersByTimeAsync(1_000); });
+ expect(screen.queryByRole("status")).not.toBeInTheDocument();
+ cleanup();
+
+ vi.mocked(api.listTaskMessages).mockResolvedValue(pendingCommand);
+ placed(task({ status: "completed", completed_at: "2026-09-07T00:20:00Z" }));
+ await act(async () => { await vi.advanceTimersByTimeAsync(1_000); });
+ expect(screen.queryByRole("status")).not.toBeInTheDocument();
+ expect(screen.queryByRole("button", { name: "Stop" })).not.toBeInTheDocument();
+ });
+});
diff --git a/packages/views/issues/components/inline-comment-run.tsx b/packages/views/issues/components/inline-comment-run.tsx
index 2e0089747c..ed1b8aca21 100644
--- a/packages/views/issues/components/inline-comment-run.tsx
+++ b/packages/views/issues/components/inline-comment-run.tsx
@@ -21,7 +21,7 @@ import { cn } from "@multica/ui/lib/utils";
import { TruncatedTooltip } from "@multica/ui/components/common/truncated-tooltip";
import { AgentTranscriptDialog, StepBody } from "../../common/task-transcript/agent-transcript-dialog";
import { buildTimeline } from "../../common/task-transcript/build-timeline";
-import { buildSteps, groupSteps, isCallStep, isGroupRow, type TraceRow } from "../../common/task-transcript/build-steps";
+import { buildSteps, groupSteps, isCallStep, isGroupRow, type TraceCallStep, type TraceRow, type TraceStep } from "../../common/task-transcript/build-steps";
import { traceEventSummary, traceToolArgSummary } from "../../common/task-transcript/trace-event-presenter";
import { redactSecrets } from "../../common/task-transcript/redact";
import { runOutputKey } from "../utils/timeline-row-content";
@@ -60,10 +60,77 @@ export type InlineCommentRunState = ReturnType<typeof useInlineCommentRunState>;
export function PlacedInlineCommentRun({ presentation = "inline", ...props }: Parameters<typeof InlineCommentRun>[0]) {
// A live reply compacts its run into the comment header.
- if ((presentation === "header") !== showCommentRunInHeader(props.run)) return null;
+ const inHeader = showCommentRunInHeader(props.run);
+ if (presentation === "inline" && inHeader && props.run.task.status === "running") {
+ return <ReplyRunPendingCall task={props.run.task} />;
+ }
+ if ((presentation === "header") !== inHeader) return null;
return <InlineCommentRun {...props} presentation={presentation} />;
}
+/**
+ * How long a published reply's run must sit on one unfinished tool call before
+ * the reply says so. Runs normally exit seconds after posting their reply, so
+ * this keeps the usual tail settled and only explains a wait that lasts.
+ */
+export const REPLY_PENDING_CALL_NOTICE_MS = 60_000;
+
+/**
+ * A reply can be published while its run is still waiting on a tool call, for
+ * example a command stuck behind a local permission prompt. The
+ * header shows only the log button, so without this line the answer looks
+ * finished while the run stays Running with no visible reason.
+ */
+function ReplyRunPendingCall({ task }: { task: AgentTask }) {
+ const { t } = useT("issues");
+ const [now, setNow] = useState(Date.now);
+ const { data } = useTaskMessages(task.id, true);
+ const items = useMemo(() => buildTimeline(data ?? []), [data]);
+ const formatText = useTraceIssueLabels(useWorkspaceId(), task.issue_id, items, true);
+ const pending = useMemo(() => lastPendingCall(buildSteps(items)), [items]);
+ const waiting = pending !== undefined;
+ // Only a pending call has a wait to count; a settled run stays idle.
+ useEffect(() => {
+ if (!waiting) return;
+ setNow(Date.now());
+ const timer = setInterval(() => setNow(Date.now()), 1000);
+ return () => clearInterval(timer);
+ }, [waiting]);
+ const startedAt = pending?.startedAt ? Date.parse(pending.startedAt) : Number.NaN;
+ if (!pending || !Number.isFinite(startedAt) || now - startedAt < REPLY_PENDING_CALL_NOTICE_MS) return null;
+ const step = redactSecrets(traceToolArgSummary(pending.call?.input, { formatText }) || pending.tool);
+ const text = t(($) => $.inline_run.reply_pending_call, { step });
+ return <div className="flex min-h-7 min-w-0 items-center gap-2 py-1 text-label text-muted-foreground" data-reply-pending-call={task.id}>
+ <Loader2 aria-hidden className="size-3.5 shrink-0 text-info motion-safe:animate-spin motion-safe:[animation-duration:900ms]" />
+ <span role="status" className="min-w-0 flex-1 truncate" title={text}>{text}</span>
+ <span className="shrink-0 whitespace-nowrap tabular-nums">{formatDuration(pending.startedAt!, now)}</span>
+ <RunStopControl task={task} />
+ </div>;
+}
+
+/** The call a live run is blocked on: the latest one still without a result. */
+function lastPendingCall(steps: TraceStep[]): TraceCallStep | undefined {
+ return steps.findLast((step): step is TraceCallStep => isCallStep(step) && !step.result);
+}
+
+/** Stop button and its confirmation, shared by the live run row and the reply's pending-call line. */
+function RunStopControl({ task }: { task: AgentTask }) {
+ const { t } = useT("issues");
+ const [confirmStop, setConfirmStop] = useState(false);
+ const cancel = useCancelIssueRun(task.issue_id);
+ const stopping = cancel.isPending || cancel.isSuccess;
+ return <>
+ <IconButton size="icon-sm" variant="ghost" className="text-muted-foreground"
+ label={stopping ? t(($) => $.inline_run.stopping) : t(($) => $.inline_run.stop)} disabled={stopping}
+ onClick={() => setConfirmStop(true)}>
+ {stopping ? <Loader2 className="size-3.5 animate-spin motion-reduce:animate-none" /> : <Square className="size-3.5" />}
+ </IconButton>
+ <TerminateTaskConfirmDialog open={confirmStop} onOpenChange={setConfirmStop}
+ showRunningNote={task.status !== "queued"}
+ onConfirm={() => cancel.mutate(task.id, { onError: () => toast.error(t(($) => $.execution_log.cancel_failed)) })} />
+ </>;
+}
+
export function InlineCommentRun({ run, className, viewState, showIdentity = false, presentation = "inline", replyTo, replacesFailureNotice = false }: {
run: CommentRun;
className?: string;
@@ -96,11 +163,9 @@ export function InlineCommentRun({ run, className, viewState, showIdentity = fal
const localViewState = useInlineCommentRunState();
const state = viewState ?? localViewState;
const { expanded, setExpanded, fullLogOpen, setFullLogOpen, openFullLog, logFromKeyboard } = state;
- const [confirmStop, setConfirmStop] = useState(false);
const [now, setNow] = useState(Date.now);
const [visibleCount, setVisibleCount] = useState(12);
const animationVisibility = useRunAnimationVisibility<HTMLDivElement>();
- const cancel = useCancelIssueRun(task.issue_id);
const retry = useRetryIssueRun(task.issue_id);
const regionId = useId();
// Keep one disclosure button mounted across queued, live, and historical states.
@@ -128,7 +193,7 @@ export function InlineCommentRun({ run, className, viewState, showIdentity = fal
? formatDuration(start, end) : "";
const output = !hasReply ? commentRunOutput(task) : null;
const latest = steps.findLast((step) => step.kind !== "text" || step.item.content?.trim());
- const pendingCall = steps.findLast((step) => isCallStep(step) && !step.result);
+ const pendingCall = lastPendingCall(steps);
const current = pendingCall ?? latest;
// Keep the last activity visible after a tool returns, until new progress arrives.
const activitySummary = current && isCallStep(current)
@@ -144,21 +209,13 @@ export function InlineCommentRun({ run, className, viewState, showIdentity = fal
const showProgress = active && !hasReply;
const activityLabel = t(($) => $.inline_run.view_activity);
const stepLabel = steps.length > 0 ? t(($) => $.inline_run.steps, { count: steps.length }) : "";
- const stopLabel = cancel.isPending || cancel.isSuccess ? t(($) => $.inline_run.stopping) : t(($) => $.inline_run.stop);
const transcript = fullLogOpen && <AgentTranscriptDialog open onOpenChange={setFullLogOpen}
task={task} items={items} agentName={name} isLive={active} finalFocus={logFromKeyboard}
contentState={isPending ? <p role="status" className="text-body text-muted-foreground">{t(($) => $.inline_run.loading)}</p>
: isError ? <div role="alert" className="text-body text-destructive">{t(($) => $.inline_run.load_failed)}
<button className="ml-2 underline" type="button" onClick={() => void refetch()}>{t(($) => $.inline_run.try_again)}</button>
</div> : undefined} />;
- const stopButton = active && <IconButton size="icon-sm" variant="ghost" className="text-muted-foreground"
- label={stopLabel} disabled={cancel.isPending || cancel.isSuccess}
- onClick={() => setConfirmStop(true)}>
- {cancel.isPending || cancel.isSuccess ? <Loader2 className="size-3.5 animate-spin motion-reduce:animate-none" /> : <Square className="size-3.5" />}
- </IconButton>;
- const stopDialog = <TerminateTaskConfirmDialog open={confirmStop} onOpenChange={setConfirmStop}
- showRunningNote={task.status !== "queued"}
- onConfirm={() => cancel.mutate(task.id, { onError: () => toast.error(t(($) => $.execution_log.cancel_failed)) })} />;
+ const stopButton = active && <RunStopControl task={task} />;
const fullLogButton = <Tooltip>
<TooltipTrigger render={<Button type="button" size="icon-sm" variant="ghost"
className="text-muted-foreground aria-expanded:bg-transparent aria-expanded:hover:bg-muted dark:aria-expanded:hover:bg-muted/50"
@@ -254,7 +311,6 @@ export function InlineCommentRun({ run, className, viewState, showIdentity = fal
</div>}
</div>
{transcript}
- {stopDialog}
</section>
);
}
diff --git a/packages/views/locales/en/issues.json b/packages/views/locales/en/issues.json
index 3a73aa6b31..4f9bbaeda2 100644
--- a/packages/views/locales/en/issues.json
+++ b/packages/views/locales/en/issues.json
@@ -26,6 +26,7 @@
"message": "Agent message",
"error": "Error",
"waiting_result": "Waiting for the tool result...",
+ "reply_pending_call": "Still running: waiting for {{step}} to finish",
"supplement_failure_turn_ended": "the run ended before delivery",
"supplement_failure_turn_not_started": "the agent was not ready",
"supplement_failure_provider_rejected": "the agent rejected the message",
diff --git a/packages/views/locales/es/issues.json b/packages/views/locales/es/issues.json
index cc1171dad5..8e89ab123f 100644
--- a/packages/views/locales/es/issues.json
+++ b/packages/views/locales/es/issues.json
@@ -26,6 +26,7 @@
"message": "Mensaje del agente",
"error": "Error",
"waiting_result": "Esperando el resultado de la herramienta...",
+ "reply_pending_call": "Sigue en curso: esperando a que termine {{step}}",
"supplement_failure_turn_ended": "la ejecución terminó antes de la entrega",
"supplement_failure_turn_not_started": "el agente no estaba listo",
"supplement_failure_provider_rejected": "el agente rechazó el mensaje",
diff --git a/packages/views/locales/fr/issues.json b/packages/views/locales/fr/issues.json
index b92e3274d8..f0363b8217 100644
--- a/packages/views/locales/fr/issues.json
+++ b/packages/views/locales/fr/issues.json
@@ -26,6 +26,7 @@
"message": "Message de l'agent",
"error": "Erreur",
"waiting_result": "En attente du résultat de l'outil...",
+ "reply_pending_call": "Toujours en cours : en attente de la fin de {{step}}",
"supplement_failure_turn_ended": "l'exécution s'est terminée avant la livraison",
"supplement_failure_turn_not_started": "l’agent n’était pas prêt",
"supplement_failure_provider_rejected": "l’agent a refusé le message",
diff --git a/packages/views/locales/ja/issues.json b/packages/views/locales/ja/issues.json
index e8e67881a4..1989185b94 100644
--- a/packages/views/locales/ja/issues.json
+++ b/packages/views/locales/ja/issues.json
@@ -25,6 +25,7 @@
"message": "エージェントのメッセージ",
"error": "エラー",
"waiting_result": "ツールの結果を待っています...",
+ "reply_pending_call": "実行中:{{step}} の終了を待っています",
"supplement_failure_turn_ended": "配信前に実行が終了しました",
"supplement_failure_turn_not_started": "エージェントの準備ができていませんでした",
"supplement_failure_provider_rejected": "エージェントがメッセージを拒否しました",
diff --git a/packages/views/locales/ko/issues.json b/packages/views/locales/ko/issues.json
index 9d3b66f775..c7cc272ac7 100644
--- a/packages/views/locales/ko/issues.json
+++ b/packages/views/locales/ko/issues.json
@@ -25,6 +25,7 @@
"message": "에이전트 메시지",
"error": "오류",
"waiting_result": "도구 결과를 기다리고 있습니다...",
+ "reply_pending_call": "아직 실행 중: {{step}} 완료를 기다리고 있습니다",
"supplement_failure_turn_ended": "전달 전에 실행이 종료됨",
"supplement_failure_turn_not_started": "에이전트가 준비되지 않음",
"supplement_failure_provider_rejected": "에이전트가 메시지를 거부함",
diff --git a/packages/views/locales/ru/issues.json b/packages/views/locales/ru/issues.json
index 8c4284338b..72dbddc8b2 100644
--- a/packages/views/locales/ru/issues.json
+++ b/packages/views/locales/ru/issues.json
@@ -26,6 +26,7 @@
"message": "Сообщение агента",
"error": "Ошибка",
"waiting_result": "Ожидание результата инструмента...",
+ "reply_pending_call": "Всё ещё выполняется: ожидание завершения {{step}}",
"supplement_failure_turn_ended": "запуск завершился до доставки",
"supplement_failure_turn_not_started": "агент не был готов",
"supplement_failure_provider_rejected": "агент отклонил сообщение",
diff --git a/packages/views/locales/zh-Hans/issues.json b/packages/views/locales/zh-Hans/issues.json
index d2928f5f40..78715ca5e1 100644
--- a/packages/views/locales/zh-Hans/issues.json
+++ b/packages/views/locales/zh-Hans/issues.json
@@ -25,6 +25,7 @@
"message": "智能体消息",
"error": "错误",
"waiting_result": "等待工具返回结果...",
+ "reply_pending_call": "仍在运行:等待 {{step}} 结束",
"supplement_failure_turn_ended": "送达前运行已结束",
"supplement_failure_turn_not_started": "智能体尚未就绪",
"supplement_failure_provider_rejected": "智能体拒绝了该消息",
diff --git a/packages/views/locales/zh-Hant/issues.json b/packages/views/locales/zh-Hant/issues.json
index 01b3e455aa..7a41b46805 100644
--- a/packages/views/locales/zh-Hant/issues.json
+++ b/packages/views/locales/zh-Hant/issues.json
@@ -25,6 +25,7 @@
"message": "AI 代理訊息",
"error": "錯誤",
"waiting_result": "等待工具返回結果...",
+ "reply_pending_call": "仍在執行:等待 {{step}} 結束",
"supplement_failure_turn_ended": "送達前執行已結束",
"supplement_failure_turn_not_started": "AI 代理尚未就緒",
"supplement_failure_provider_rejected": "AI 代理拒絕了該訊息",