Skip to content

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

Go

fix(transcript): close dialog on desktop navigation (#2903)

Qiang Zhang1abd0e33a66d
diff --git a/packages/views/common/task-transcript/transcript-button.test.tsx b/packages/views/common/task-transcript/transcript-button.test.tsx
new file mode 100644
index 0000000000..1edd6ef700
--- /dev/null
+++ b/packages/views/common/task-transcript/transcript-button.test.tsx
@@ -0,0 +1,74 @@
+// @vitest-environment jsdom
+
+import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import type { AgentTask } from "@multica/core/types/agent";
+import { describe, expect, it, vi } from "vitest";
+import { TranscriptButton } from "./transcript-button";
+import type { TimelineItem } from "./build-timeline";
+
+vi.mock("@multica/core/api", () => ({
+ api: {
+ listTaskMessages: vi.fn(),
+ },
+}));
+
+vi.mock("./agent-transcript-dialog", () => ({
+ AgentTranscriptDialog: ({
+ open,
+ onOpenChange,
+ }: {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ }) =>
+ open ? (
+ <div role="dialog">
+ <button type="button" onClick={() => onOpenChange(false)}>
+ Close
+ </button>
+ </div>
+ ) : null,
+}));
+
+const task: AgentTask = {
+ id: "task-1",
+ agent_id: "agent-1",
+ runtime_id: "",
+ issue_id: "issue-1",
+ status: "completed",
+ priority: 0,
+ dispatched_at: "2026-05-15T10:00:05.000Z",
+ started_at: "2026-05-15T10:00:06.000Z",
+ completed_at: "2026-05-15T10:00:10.000Z",
+ result: null,
+ error: null,
+ created_at: "2026-05-15T10:00:00.000Z",
+};
+
+const items: TimelineItem[] = [
+ {
+ seq: 1,
+ type: "text",
+ content: "hello world",
+ },
+];
+
+describe("TranscriptButton", () => {
+ it("closes the transcript dialog when desktop navigation starts", async () => {
+ render(<TranscriptButton task={task} agentName="Codex" items={items} />);
+
+ fireEvent.click(screen.getByRole("button", { name: "View transcript" }));
+ expect(screen.getByRole("dialog")).toBeInTheDocument();
+
+ act(() => {
+ window.dispatchEvent(
+ new CustomEvent("multica:navigate", {
+ detail: { path: "/acme/inbox?issue=MUL-123" },
+ }),
+ );
+ });
+
+ await waitFor(() => {
+ expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
+ });
+ });
+});
diff --git a/packages/views/common/task-transcript/transcript-button.tsx b/packages/views/common/task-transcript/transcript-button.tsx
index 19afe03fa7..86cb05677f 100644
--- a/packages/views/common/task-transcript/transcript-button.tsx
+++ b/packages/views/common/task-transcript/transcript-button.tsx
@@ -1,6 +1,6 @@
"use client";
-import { useCallback, useState } from "react";
+import { useCallback, useEffect, useState } from "react";
import { Loader2, ScrollText } from "lucide-react";
import { cn } from "@multica/ui/lib/utils";
import {
@@ -81,6 +81,19 @@ export function TranscriptButton({
[providedItems, loadedItems, task.id],
);
+ useEffect(() => {
+ if (!open) return;
+
+ const handleGlobalNavigate = () => {
+ setOpen(false);
+ };
+
+ window.addEventListener("multica:navigate", handleGlobalNavigate);
+ return () => {
+ window.removeEventListener("multica:navigate", handleGlobalNavigate);
+ };
+ }, [open]);
+
return (
<>
<Tooltip>