Skip to content

Commit 9182de7

Browse files
committed
feat(inbox): show research task logs inline in report detail pane
- Add signal_report field to Task type (FK from backend's sig/add-signal-report-task branch) - Add signalReportId to TaskCreationInput and pass signal_report through API - Add ReportTaskLogs component that finds the backend research task (origin_product: "signal_report") for a report and embeds TaskLogsPanel - Show live-streaming task progress in the report detail pane during research - Only matches backend research tasks, not user-created "Run cloud" tasks Depends on PostHog/posthog sig/add-signal-report-task branch.
1 parent ac0cf99 commit 9182de7

5 files changed

Lines changed: 73 additions & 1 deletion

File tree

apps/code/src/renderer/api/posthogClient.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,14 @@ export class PostHogAPIClient {
424424
async createTask(
425425
options: Pick<Task, "description"> &
426426
Partial<
427-
Pick<Task, "title" | "repository" | "json_schema" | "origin_product">
427+
Pick<
428+
Task,
429+
| "title"
430+
| "repository"
431+
| "json_schema"
432+
| "origin_product"
433+
| "signal_report"
434+
>
428435
> & {
429436
github_integration?: number | null;
430437
},

apps/code/src/renderer/features/inbox/components/InboxSignalsTab.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import { useRendererWindowFocusStore } from "@stores/rendererWindowFocusStore";
5858
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
5959
import { toast } from "sonner";
6060
import { ReportCard } from "./ReportCard";
61+
import { ReportTaskLogs } from "./ReportTaskLogs";
6162
import { SignalCard } from "./SignalCard";
6263
import { SignalReportPriorityBadge } from "./SignalReportPriorityBadge";
6364
import { SignalReportSummaryMarkdown } from "./SignalReportSummaryMarkdown";
@@ -594,6 +595,8 @@ export function InboxSignalsTab() {
594595
</Text>
595596
) : null}
596597
</Flex>
598+
{/* Task logs take over when a linked task exists */}
599+
<ReportTaskLogs reportId={selectedReport.id} />
597600
<ScrollArea
598601
type="auto"
599602
scrollbars="vertical"
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { TaskLogsPanel } from "@features/task-detail/components/TaskLogsPanel";
2+
import { useAuthenticatedQuery } from "@hooks/useAuthenticatedQuery";
3+
import { Flex, Spinner, Text } from "@radix-ui/themes";
4+
import type { Task } from "@shared/types";
5+
6+
/**
7+
* Fetch the task linked to a signal report (via the `signal_report` FK).
8+
* Returns the first task found, or undefined if none.
9+
*/
10+
/**
11+
* Fetch the backend research task linked to a signal report.
12+
* Only matches tasks with `origin_product: "signal_report"` — not user-created
13+
* "Run cloud" tasks that act on the report's findings.
14+
*/
15+
function useReportTask(reportId: string) {
16+
return useAuthenticatedQuery<Task | null>(
17+
["inbox", "report-task", reportId],
18+
async (client) => {
19+
const tasks = (await client.getTasks()) as unknown as Task[];
20+
return (
21+
tasks.find(
22+
(t) =>
23+
t.signal_report === reportId &&
24+
t.origin_product === "signal_report",
25+
) ?? null
26+
);
27+
},
28+
{
29+
enabled: !!reportId,
30+
staleTime: 10_000,
31+
},
32+
);
33+
}
34+
35+
interface ReportTaskLogsProps {
36+
reportId: string;
37+
}
38+
39+
export function ReportTaskLogs({ reportId }: ReportTaskLogsProps) {
40+
const { data: task, isLoading } = useReportTask(reportId);
41+
42+
if (isLoading) {
43+
return (
44+
<Flex align="center" gap="2" px="3" py="4">
45+
<Spinner size="1" />
46+
<Text size="1" color="gray" className="text-[12px]">
47+
Loading task...
48+
</Text>
49+
</Flex>
50+
);
51+
}
52+
53+
if (!task) {
54+
return null;
55+
}
56+
57+
return <TaskLogsPanel taskId={task.id} task={task} />;
58+
}

apps/code/src/renderer/sagas/task/task-creation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export interface TaskCreationInput {
7272
reasoningLevel?: string;
7373
environmentId?: string;
7474
sandboxEnvironmentId?: string;
75+
signalReportId?: string;
7576
}
7677

7778
export interface TaskCreationOutput {
@@ -388,6 +389,8 @@ export class TaskCreationSaga extends Saga<
388389
input.workspaceMode === "cloud"
389390
? input.githubIntegrationId
390391
: undefined,
392+
origin_product: input.signalReportId ? "signal_report" : undefined,
393+
signal_report: input.signalReportId ?? undefined,
391394
});
392395
return result as unknown as Task;
393396
},

apps/code/src/shared/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export interface Task {
3838
repository?: string | null; // Format: "organization/repository" (e.g., "posthog/posthog-js")
3939
github_integration?: number | null;
4040
json_schema?: Record<string, unknown> | null;
41+
signal_report?: string | null;
4142
latest_run?: TaskRun;
4243
}
4344

0 commit comments

Comments
 (0)