The open-source app everyone uses to manage agents at work
TypeScript acpxagent-orchestrationagent-skillsagentic-aiai-agentsai-engineeringai-governanceai-toolsautonomous-agentsclaudeclaude-codeclaude-skillscodexhermesllmmcpmulti-agentopenclawproject-managementworkflow-automation
feat(ui): link routine-created tasks back to their source routine (#16471)
Devin Foley93d26eb84e4c
diff --git a/ui/src/components/IssueProperties.test.tsx b/ui/src/components/IssueProperties.test.tsxindex 7b573ef032..cb98118072 100644--- a/ui/src/components/IssueProperties.test.tsx+++ b/ui/src/components/IssueProperties.test.tsx@@ -18,6 +18,7 @@ import { getLastProjectId } from "../lib/recent-projects";import { IssueProperties } from "./IssueProperties";import { applyOptimisticIssueFieldUpdate } from "../lib/optimistic-issue-comments";import { queryKeys } from "../lib/queryKeys";+import { ApiError } from "../api/client";const mockAgentsApi = vi.hoisted(() => ({list: vi.fn(),@@ -48,6 +49,10 @@ const mockIssuesApi = vi.hoisted(() => ({unarchiveFromInbox: vi.fn(),}));+const mockRoutinesApi = vi.hoisted(() => ({+ get: vi.fn(),+}));+const mockAuthApi = vi.hoisted(() => ({getSession: vi.fn(),}));@@ -90,6 +95,10 @@ vi.mock("../api/issues", () => ({issuesApi: mockIssuesApi,}));+vi.mock("../api/routines", () => ({+ routinesApi: mockRoutinesApi,+}));+vi.mock("../api/auth", () => ({authApi: mockAuthApi,}));@@ -628,6 +637,7 @@ describe("IssueProperties", () => {document.body.appendChild(container);mockAgentsApi.list.mockResolvedValue([]);mockAgentsApi.adapterModels.mockResolvedValue([]);+ mockRoutinesApi.get.mockReset();mockProjectsApi.list.mockResolvedValue([]);mockExecutionWorkspacesApi.list.mockResolvedValue([]);mockExecutionWorkspacesApi.controlRuntimeCommands.mockReset();@@ -1141,6 +1151,77 @@ describe("IssueProperties", () => {act(() => root.unmount());});+ it("links a routine-created task back to its source routine under Relationships", async () => {+ mockRoutinesApi.get.mockResolvedValue({ id: "routine-1", title: "Nightly triage" });+ const root = renderProperties(container, {+ issue: createIssue({ originKind: "routine_execution", originId: "routine-1" }),+ childIssues: [],+ onUpdate: vi.fn(),+ inline: true,+ });++ await waitForAssertion(() => {+ const row = container+ .querySelector('[data-property-label="Routine"]')+ ?.closest('[data-property-row="true"]');+ const link = row?.querySelector("a");+ expect(link?.getAttribute("href")).toBe("/routines/routine-1");+ expect(link?.textContent).toContain("Nightly triage");+ });+ expect(mockRoutinesApi.get).toHaveBeenCalledWith("routine-1");++ act(() => root.unmount());+ });++ it("omits the Routine row while the source routine is still loading", async () => {+ mockRoutinesApi.get.mockReturnValue(new Promise(() => {}));+ const root = renderProperties(container, {+ issue: createIssue({ originKind: "routine_execution", originId: "routine-1" }),+ childIssues: [],+ onUpdate: vi.fn(),+ inline: true,+ });+ await flush();++ expect(mockRoutinesApi.get).toHaveBeenCalledWith("routine-1");+ expect(container.querySelector('[data-property-label="Routine"]')).toBeNull();++ act(() => root.unmount());+ });++ it("omits the Routine row when the source routine no longer exists", async () => {+ mockRoutinesApi.get.mockRejectedValue(new ApiError("Not found", 404, null));+ const root = renderProperties(container, {+ issue: createIssue({ originKind: "routine_execution", originId: "routine-gone" }),+ childIssues: [],+ onUpdate: vi.fn(),+ inline: true,+ });++ await waitForAssertion(() => {+ expect(mockRoutinesApi.get).toHaveBeenCalledWith("routine-gone");+ });+ await flush();+ expect(container.querySelector('[data-property-label="Routine"]')).toBeNull();++ act(() => root.unmount());+ });++ it("omits the Routine row for tasks not created by a routine", async () => {+ const root = renderProperties(container, {+ issue: createIssue(),+ childIssues: [],+ onUpdate: vi.fn(),+ inline: true,+ });+ await flush();++ expect(container.querySelector('[data-property-label="Routine"]')).toBeNull();+ expect(mockRoutinesApi.get).not.toHaveBeenCalled();++ act(() => root.unmount());+ });+it("groups the assignee picker and gates a live-run reassign behind an interrupt confirm", async () => {const minimalAgent = (id: string, name: string) =>({diff --git a/ui/src/components/issue-properties/IssueProperties.tsx b/ui/src/components/issue-properties/IssueProperties.tsxindex 736987aaa1..924c7c8eb0 100644--- a/ui/src/components/issue-properties/IssueProperties.tsx+++ b/ui/src/components/issue-properties/IssueProperties.tsx@@ -125,6 +125,7 @@ import {import { issueReviewPolicyBadge } from "../../lib/review-policy";import { IssueCasesPanel } from "../IssueCasesPanel";import { ExpandRelationListButton, RemovableIssueReferencePill } from "./relation-controls";+import { RoutineOriginRow } from "./routine-origin-row";import { Badge } from "@/components/ui/badge";import {TaskDetailReferencesPanel,@@ -2447,6 +2448,10 @@ export function IssueProperties({{parentContent}</PropertyPicker>+ {issue.originKind === "routine_execution" && issue.originId ? (+ <RoutineOriginRow routineId={issue.originId} />+ ) : null}+{streamlinedPropertiesEnabled ? (<PropertyPickerinline={inline}diff --git a/ui/src/components/issue-properties/routine-origin-row.tsx b/ui/src/components/issue-properties/routine-origin-row.tsxnew file mode 100644index 0000000000..3664060f60--- /dev/null+++ b/ui/src/components/issue-properties/routine-origin-row.tsx@@ -0,0 +1,34 @@+import { useQuery } from "@tanstack/react-query";+import { Repeat } from "lucide-react";+import { Link } from "@/lib/router";+import { badgeVariants } from "@/components/ui/badge";+import { routinesApi } from "../../api/routines";+import { queryKeys } from "../../lib/queryKeys";+import { cn } from "../../lib/utils";+import { PropertyRow } from "./primitives";++export function RoutineOriginRow({ routineId }: { routineId: string }) {+ const { data: routine } = useQuery({+ queryKey: queryKeys.routines.detail(routineId),+ queryFn: () => routinesApi.get(routineId),+ });++ const title = routine?.title?.trim();+ if (!title) return null;++ return (+ <PropertyRow label="Routine">+ <Link+ to={`/routines/${routineId}`}+ className={cn(+ badgeVariants({ variant: "outline" }),+ "min-w-0 max-w-full shrink font-normal no-underline hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-(length:--rad-3) focus-visible:ring-ring",+ )}+ title={title}+ >+ <Repeat className="h-3 w-3 shrink-0" aria-hidden />+ <span className="min-w-0 truncate">{title}</span>+ </Link>+ </PropertyRow>+ );+}