feat(lens): show the live run on investigations and open it from run now

This commit is contained in:
Ishaan Jaff 2026-10-03 16:36:40 -07:00
parent 97225a7143
commit d77bdf8fa4
No known key found for this signature in database
2 changed files with 15 additions and 19 deletions

View file

@ -153,7 +153,9 @@ export function InvestigationsView({
setEditing(null);
refresh();
};
const editFromTable = (id: string) => {
const openFromTable = (id: string) => {
const running = lenses.find((l) => l.id === id)?.jobs.some((j) => j.status === "queued" || j.status === "running");
if (running) return selectLens(id);
setPeek(true);
selectLens(id);
setEditing("edit");
@ -260,7 +262,7 @@ export function InvestigationsView({
lenses={lenses}
connected={connected}
readOnly={readOnly}
onEdit={editFromTable}
onEdit={openFromTable}
onRunNow={(id) => setRunNowId(id)}
/>
)}
@ -310,8 +312,9 @@ export function InvestigationsView({
busy={busy}
onClose={() => setRunNowId(null)}
onRun={async (request) => {
await update((api) => api.startRun(runNowId, request));
const started = await update((api) => api.startRun(runNowId, request));
setRunNowId(null);
if (started) selectLens(runNowId);
}}
/>
)}

View file

@ -5,8 +5,8 @@ import { Button } from "@/components/ui/button";
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";
import { RunsTab } from "./RunsTab";
import { InvestigationProgress } from "../InvestigationProgress";
import { StepFeed } from "../StepFeed";
import { LiveRun } from "../live/LiveRun";
import { previewJob } from "../../__fixtures__/reviews";
import { RunNowDialog } from "./RunNowDialog";
import { useState } from "react";
import { InvestigationSummary } from "./InvestigationSummary";
@ -72,6 +72,8 @@ export function InvestigationDetail({
historyOffset,
setHistoryOffset,
} = results;
// TODO: drop the previewJob fallback together with __fixtures__/reviews.ts once real reviews flow everywhere
const shown = active ?? lens.jobs.find((j) => j.reviews.length > 0) ?? previewJob(lens);
return (
<div>
<section className="min-w-0 space-y-5">
@ -96,20 +98,11 @@ export function InvestigationDetail({
)}
</div>
<InvestigationSummary lens={lens} connected={connected} />
{active && (
<InvestigationProgress
key={active.id}
job={active}
onCancel={
readOnly
? undefined
: () => {
void update((api) => api.cancelRun(lens.id));
}
}
/>
)}
{active && <StepFeed job={active} />}
<LiveRun
key={shown.id}
job={shown}
onCancel={readOnly || !active ? undefined : () => void update((api) => api.cancelRun(lens.id))}
/>
{runNow && (
<RunNowDialog
lens={lens}