Skip to content

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

Go

fix(agents): make issue tasks easier to open from agent details (#1152)

Black2c1478a69c05
diff --git a/packages/views/agents/components/tabs/tasks-tab.test.tsx b/packages/views/agents/components/tabs/tasks-tab.test.tsx
new file mode 100644
index 0000000000..39ca36a22e
--- /dev/null
+++ b/packages/views/agents/components/tabs/tasks-tab.test.tsx
@@ -0,0 +1,174 @@
+// @vitest-environment jsdom
+
+import { describe, it, expect, vi, beforeEach } from "vitest";
+import { render, screen, waitFor } from "@testing-library/react";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import type { Agent, AgentTask, Issue } from "@multica/core/types";
+
+const mockListAgentTasks = vi.hoisted(() => vi.fn());
+const mockListIssues = vi.hoisted(() => vi.fn());
+
+vi.mock("@multica/core/hooks", () => ({
+ useWorkspaceId: () => "ws-1",
+}));
+
+vi.mock("@multica/core/paths", async () => {
+ const actual = await vi.importActual<typeof import("@multica/core/paths")>(
+ "@multica/core/paths",
+ );
+ return {
+ ...actual,
+ useWorkspacePaths: () => actual.paths.workspace("test"),
+ };
+});
+
+vi.mock("@multica/core/api", () => ({
+ api: {
+ listAgentTasks: (...args: unknown[]) => mockListAgentTasks(...args),
+ listIssues: (...args: unknown[]) => mockListIssues(...args),
+ },
+}));
+
+vi.mock("../../../navigation", () => ({
+ AppLink: ({ children, href, ...props }: any) => (
+ <a href={href} {...props}>
+ {children}
+ </a>
+ ),
+}));
+
+import { TasksTab } from "./tasks-tab";
+
+const agent: Agent = {
+ id: "agent-1",
+ workspace_id: "ws-1",
+ runtime_id: "runtime-1",
+ name: "Agent",
+ description: "",
+ instructions: "",
+ avatar_url: null,
+ runtime_mode: "local",
+ runtime_config: {},
+ custom_env: {},
+ custom_args: [],
+ custom_env_redacted: false,
+ visibility: "workspace",
+ status: "idle",
+ max_concurrent_tasks: 1,
+ owner_id: null,
+ skills: [],
+ created_at: "2026-04-16T00:00:00Z",
+ updated_at: "2026-04-16T00:00:00Z",
+ archived_at: null,
+ archived_by: null,
+};
+
+function renderTasksTab(tasks: AgentTask[], issues: Issue[]) {
+ mockListAgentTasks.mockResolvedValue(tasks);
+ mockListIssues.mockImplementation(
+ ({ open_only, status }: { open_only?: boolean; status?: string }) =>
+ Promise.resolve({
+ issues: open_only ? issues : status === "done" ? [] : [],
+ total: open_only ? issues.length : 0,
+ }),
+ );
+
+ const queryClient = new QueryClient({
+ defaultOptions: {
+ queries: {
+ retry: false,
+ },
+ },
+ });
+
+ return render(
+ <QueryClientProvider client={queryClient}>
+ <TasksTab agent={agent} />
+ </QueryClientProvider>,
+ );
+}
+
+describe("TasksTab", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ });
+
+ it("uses workspace-scoped issue detail paths when issue data is loaded", async () => {
+ renderTasksTab(
+ [
+ {
+ id: "task-1",
+ agent_id: "agent-1",
+ runtime_id: "runtime-1",
+ issue_id: "issue-1",
+ status: "queued",
+ priority: 1,
+ dispatched_at: null,
+ started_at: null,
+ completed_at: null,
+ result: null,
+ error: null,
+ created_at: "2026-04-16T00:00:00Z",
+ },
+ ],
+ [
+ {
+ id: "issue-1",
+ workspace_id: "ws-1",
+ number: 1,
+ identifier: "MUL-1",
+ title: "Fix agent task routing",
+ description: "",
+ status: "todo",
+ priority: "medium",
+ assignee_type: null,
+ assignee_id: null,
+ creator_type: "member",
+ creator_id: "user-1",
+ parent_issue_id: null,
+ project_id: null,
+ position: 1,
+ due_date: null,
+ created_at: "2026-04-16T00:00:00Z",
+ updated_at: "2026-04-16T00:00:00Z",
+ },
+ ],
+ );
+
+ const title = await screen.findByText("Fix agent task routing");
+ const link = title.closest("a");
+
+ expect(link?.getAttribute("href")).toBe("/test/issues/issue-1");
+ });
+
+ it("keeps task rows clickable when the issue is missing from the list query", async () => {
+ renderTasksTab(
+ [
+ {
+ id: "task-2",
+ agent_id: "agent-1",
+ runtime_id: "runtime-1",
+ issue_id: "12345678-fallback",
+ status: "completed",
+ priority: 1,
+ dispatched_at: null,
+ started_at: null,
+ completed_at: "2026-04-16T01:00:00Z",
+ result: null,
+ error: null,
+ created_at: "2026-04-16T00:00:00Z",
+ },
+ ],
+ [],
+ );
+
+ await waitFor(() => {
+ expect(mockListAgentTasks).toHaveBeenCalledWith("agent-1");
+ });
+
+ const title = await screen.findByText("Issue 12345678...");
+ const link = title.closest("a");
+
+ expect(link?.getAttribute("href")).toBe("/test/issues/12345678-fallback");
+ });
+});
diff --git a/packages/views/agents/components/tabs/tasks-tab.tsx b/packages/views/agents/components/tabs/tasks-tab.tsx
index d405caf578..83704b650e 100644
--- a/packages/views/agents/components/tabs/tasks-tab.tsx
+++ b/packages/views/agents/components/tabs/tasks-tab.tsx
@@ -6,14 +6,17 @@ import type { Agent, AgentTask } from "@multica/core/types";
import { Skeleton } from "@multica/ui/components/ui/skeleton";
import { api } from "@multica/core/api";
import { useWorkspaceId } from "@multica/core/hooks";
+import { useWorkspacePaths } from "@multica/core/paths";
import { issueListOptions } from "@multica/core/issues/queries";
import { useQuery } from "@tanstack/react-query";
+import { AppLink } from "../../../navigation";
import { taskStatusConfig } from "../../config";
export function TasksTab({ agent }: { agent: Agent }) {
const [tasks, setTasks] = useState<AgentTask[]>([]);
const [loading, setLoading] = useState(true);
const wsId = useWorkspaceId();
+ const paths = useWorkspacePaths();
const { data: issues = [] } = useQuery(issueListOptions(wsId));
useEffect(() => {
@@ -82,18 +85,16 @@ export function TasksTab({ agent }: { agent: Agent }) {
const issue = issueMap.get(task.issue_id);
const isActive = task.status === "running" || task.status === "dispatched";
const isRunning = task.status === "running";
+ const rowClassName = `flex items-center gap-3 rounded-lg border px-4 py-3 transition-shadow hover:shadow-sm ${
+ isRunning
+ ? "border-success/40 bg-success/5"
+ : task.status === "dispatched"
+ ? "border-info/40 bg-info/5"
+ : ""
+ }`;
- return (
- <div
- key={task.id}
- className={`flex items-center gap-3 rounded-lg border px-4 py-3 ${
- isRunning
- ? "border-success/40 bg-success/5"
- : task.status === "dispatched"
- ? "border-info/40 bg-info/5"
- : ""
- }`}
- >
+ const content = (
+ <>
<Icon
className={`h-4 w-4 shrink-0 ${config.color} ${
isRunning ? "animate-spin" : ""
@@ -110,7 +111,7 @@ export function TasksTab({ agent }: { agent: Agent }) {
{issue?.title ?? `Issue ${task.issue_id.slice(0, 8)}...`}
</span>
</div>
- <div className="text-xs text-muted-foreground mt-0.5">
+ <div className="mt-0.5 text-xs text-muted-foreground">
{isRunning && task.started_at
? `Started ${new Date(task.started_at).toLocaleString()}`
: task.status === "dispatched" && task.dispatched_at
@@ -125,7 +126,17 @@ export function TasksTab({ agent }: { agent: Agent }) {
<span className={`shrink-0 text-xs font-medium ${config.color}`}>
{config.label}
</span>
- </div>
+ </>
+ );
+
+ return (
+ <AppLink
+ key={task.id}
+ href={paths.issueDetail(task.issue_id)}
+ className={`${rowClassName} text-foreground no-underline hover:no-underline`}
+ >
+ {content}
+ </AppLink>
);
})}
</div>