Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
feat(SKY-11075): recent-activity history view on workflow build canvas (#7025)
Aaron Perezc49ab35dabe9
diff --git a/docs/design/2026-06-15-workflow-build-recent-activity-design.md b/docs/design/2026-06-15-workflow-build-recent-activity-design.mdnew file mode 100644index 000000000..e94bbfc5d--- /dev/null+++ b/docs/design/2026-06-15-workflow-build-recent-activity-design.md@@ -0,0 +1,306 @@+# Workflow Build — Recent Activity History (SKY-11075)++Replace the bottom-of-canvas **dot/carousel indicator** on `/workflows/:id/build` with a+real recent-activity history view that's easy to scan and lets you jump directly to a+specific recent activity.++Status: **Final — recent activity is a compact run selector locked to the right+run-detail panel; the A/B/C style and placement preview toggles were removed. See+the Round 7 section below.**++---++## 1. Frame++- **Page:** Workflow editor, *build* mode — `/workflows/:id/build` (and the run-loaded+ variant `/workflows/:wpid/:workflowRunId/:blockLabel/build`). The history surface only+ renders in **debug/browser mode** (`showBrowser`), bottom-center over the canvas+code+ pane. Redesign of an existing affordance.+- **Job to be done:** While iterating on a workflow you fire blocks/the workflow many times+ in one debug session. Today those runs collapse into a row of identical ~16px dots whose+ only metadata is a hover tooltip. You can't tell at a glance *what* ran, *whether it+ passed*, *how long it took*, or *which mode* (agent vs cached code) — you must hover each+ dot one by one. The job: make each recent run legible at a glance and jump straight to it.+- **Deciding constraint — what counts as "recent activity":** **Debug-session runs**+ (confirmed with requester). Each entry = one block/workflow run triggered in the current+ debug session, sourced from `GET /debug-session/{id}/runs` (`useDebugSessionRunsQuery`).+ No new backend. Deliberately distinct from (a) the global **Runs** page and (b) the+ right-side **run-detail timeline** (`DebuggerRun`/`DebuggerRunTimeline`) which shows the+ *inside* of one selected run. This surface is the *list of runs*; selecting one drives the+ existing detail rail — no overlapping history surfaces.+- **Open sub-question (requester):** is a dock/strip the best surface, or do we want a+ "proper timeline"? → resolved via the concepts below; requester to pick direction.+- **Platform:** web.+- **North star references:** Databricks pipeline run-selector + event log; Vercel Activity feed.++### Data available per entry (`DebugSessionRun`) — today all hidden behind one dot+`block_label`, `status` (running/completed/failed/terminated/timed_out/canceled/queued/+skipped), `created_at` / `queued_at` / `started_at` / `finished_at` (→ duration + "x ago"),+`failure_reason`, `run_with` (agent | code), `code_gen`, `ai_fallback`, `workflow_run_id`,+`workflow_permanent_id`, `script_run_id`. Selecting → `navigate(/workflows/{wpid}/{workflow_run_id}/{block_label}/build)`.++---++## 2. DS inventory (read from code — Figma DS is thin by design)++| Need | Reuse (exists in repo) |+|---|---|+| Status glyph | `StatusDot` pattern (WorkflowRunTimelineBlockItem): `CheckCircledIcon text-success`, `CrossCircledIcon text-destructive`, `ReloadIcon animate-spin text-sky-400`, neutral `rounded-full bg-slate-600` |+| Block-type glyph | `WorkflowBlockIcon` (per `WorkflowBlockType`) |+| Type / mode pills | inline pill convention `rounded bg-slate-700/70 px-1.5 py-0.5 text-[10px] font-medium` |+| Relative time / duration | `formatMs(Date.now()-created).ago`, `formatDuration(toDuration(ms))`, `tabular-nums` |+| Tooltip | `Tip` (`@/components/Tip`) |+| Scroll container | `ScrollArea` (`@/components/ui/scroll-area`) |+| Dropdown / flyout | `Popover` (`@/components/ui/popover`) |+| Expand / collapse | `Collapsible` (`@/components/ui/collapsible`) |+| Buttons / badges | `Button`, `Badge` |+| Surface tokens | `bg-neutral-50 dark:bg-background`, `border-neutral-200 dark:border-neutral-800`, focus `focus-visible:ring-1 focus-visible:ring-white/40` |++Conventions: build-mode rails skew dark (`slate-*`); pills `text-[10px]`, `tabular-nums` for+numbers; every interactive row is a `<button>` with a visible focus ring.++## 3. Gap ledger (DS lacks → candidate Step-5 tickets)+- No dedicated **Status badge** component — status color/icon mapping is re-derived inline in+ several places (`StatusDot`, run cards). Candidate: extract a shared `RunStatusBadge`.+- No **horizontal "activity strip"/run-history rail** primitive.+- (Append as concepts/implementation pressure the library.)++---++## 4. Inspiration (Mobbin — web)++1. **Databricks — pipeline "Update details"** — editor canvas with a **Run: {timestamp}+ [status]** selector top-left, a detail panel (Update ID, *Status, Duration, Start time,+ Run time, Completion date*), and a timestamped **Event log** below. Closest analog: a+ build canvas whose run history is a compact selector + per-run metadata.+ [link](https://mobbin.com/screens/2a53f9eb-b8e1-4958-afb7-f441acbdf414). a11y: the+ selector must be a real listbox/menu button, not a click-only div.+2. **Vercel — Activity** — scannable vertical feed: each row = entity icon + plain-language+ description + **relative time** ("42m"), grouped by date, left filter rail. Gold standard+ for "legible at a glance."+ [link](https://mobbin.com/screens/2f3056eb-a31a-4b3e-ae4b-1bcc1352117f). a11y: relative+ time needs a `title`/`<time datetime>` with the absolute timestamp.+3. **WorkOS — Events** — master-detail: list (event + date/time) on the left, metadata on the+ right. [link](https://mobbin.com/screens/a5b50327-60e0-4075-9cfd-7f383d18265c).+4. **Okta — System Log** / **Stripe — Events** / **Cloudflare — Observability** — dense log+ tables (timestamp · type · message), some with a count-over-time bar.+ [Okta](https://mobbin.com/screens/70f42b3f-1823-4cb2-872d-346ad3eab8dc) ·+ [Stripe](https://mobbin.com/screens/5423e185-8374-4b6c-a4a0-2d3ae9adc1d0) ·+ [Cloudflare](https://mobbin.com/screens/db64bfde-eac6-4786-8c29-62b98eb1a149). a11y:+ color-coded status must pair with an icon/text, not color alone.++---++## 5. Concepts++All three keep the data scope (debug-session runs), keep the existing bottom-center anchor+over the canvas+code pane, and preserve the existing select→navigate behavior. They differ in+*how the history is surfaced*.++### Concept A — "Activity Strip" (in-place horizontal chips)+- **Thesis:** smallest change. Swap the row of bare dots for a row of legible **chips** in the+ same pill, scrolling horizontally. Each chip: status glyph + block icon + block label ++ "x ago"; duration/mode in tooltip. Click → navigate.+- **Lineage:** Databricks run-selector (canvas-anchored) + Vercel chip legibility.+- **DS:** `StatusDot`, `WorkflowBlockIcon`, pills, `ScrollArea`, `formatMs`. Same wrapper/position.+- **Tradeoffs:** + tiny diff, preserves muscle memory, fast. − horizontal scroll is less+ scannable than vertical; limited metadata per chip; long lists hide off-screen.++### Concept B — "Activity History panel" (collapsed timeline bar → expanding vertical list) — RECOMMENDED+- **Thesis:** the dock's **collapsed** state is a slim **status-segment bar** — one thin+ segment per run, colored by status, newest on the right, labeled "N runs · last ✓ 2m ago".+ That's the at-a-glance, time-ordered "timeline." Click/hover **expands upward** into a+ **vertical, scannable list**: one rich row per run = status glyph · block icon · block name ·+ type pill · mode pill (Agent/Code) · duration · "x ago", with a one-line failure reason on+ failures. Newest first. Row click → navigate (existing behavior); current run highlighted.+- **Lineage:** Vercel Activity feed (legible rows) + Okta count-over-time bar (collapsed+ status density) + WorkOS master-detail (list feeds the existing right-side detail rail).+- **DS:** `Popover`/`Collapsible` + `ScrollArea`, the `WorkflowRunTimelineBlockItem` row+ vocabulary, `StatusDot`, pills. New: a small **status-segment bar** (gap-ledger item).+- **Tradeoffs:** + most legible (vertical rows, full metadata — directly satisfies the AC),+ + collapsed footprint stays tiny so the canvas isn't crowded, + serves *both* the+ "scannable history" and "proper timeline" instincts, + scales to long lists.+ − one extra primitive (segment bar); − popover sizing over the canvas needs care.++### Concept C — "Run Selector + Segmented Timeline" (header selector + bottom bar)+- **Thesis:** Databricks-style. A **run selector** near the header ("Run: Login ✓ · 2m ago ▾")+ opens the activity list, *and* a persistent thin **segmented timeline bar** sits at the+ bottom (each run a proportional, status-colored segment; hover→tooltip, click→navigate).+- **Lineage:** Databricks run-selector + Okta status-density bar.+- **DS:** `Popover`, segment bar (new), `StatusDot` colors.+- **Tradeoffs:** + strongest "timeline" metaphor, scales well. − most net-new UI and two+ surfaces (header + bottom) risk fragmenting the history; − largest build/QA; − header is+ already busy in build mode.++## 6. Recommendation & Decision++**Recommend Concept B.** It's the most faithful to the acceptance criteria — each entry+legible at a glance with real metadata, and one click to jump to a run — while keeping the+collapsed footprint as small as today's dot pill. Its collapsed status-segment bar answers the+requester's "proper timeline?" instinct without splitting the history across two surfaces+(Concept C's main risk), and it reuses the established run-row vocabulary so it looks native.++Decision (2026-06-15): requester chose to **build all three (A, B, C) behind a live variant+toggle** so they can compare directly in the PR preview, then collapse to one winner later.+Implementation ships a `RecentActivity` orchestrator that renders the variant selected by a+persisted (localStorage + `?activityVariant=` URL seed) toggle; default = B.++## 7. Implementation (shipped)++New module `skyvern-frontend/src/routes/workflows/debugger/recentActivity/`:+- `useRecentActivity.ts` — data hook (debug-session runs, sorted asc; block-type map;+ `navigateToRun` preserving the old select→navigate target, now also resolving nested loop+ blocks for the "block still exists" guard).+- `runActivity.ts` / `RunGlyphs.tsx` — shared status/duration/time helpers + status/block glyphs.+- `RecentActivitySegmentBar.tsx`, `RecentActivityList.tsx` — shared primitives.+- `RecentActivityStrip.tsx` (A), `RecentActivityPanel.tsx` (B), `RecentActivityTimeline.tsx`+ (C), `RecentActivityVariantToggle.tsx`, `RecentActivity.tsx` (orchestrator).+- `src/store/RecentActivityVariantStore.ts` — variant store.+- `Workspace.tsx` now renders `<RecentActivity />`; `DebuggerBlockRuns.tsx` deleted.++Verification: `tsc --noEmit` ✓, `eslint --max-warnings 0` ✓, `vite build` ✓. Live visual+verification of the populated state needs a debug session with ≥1 run (backend + browser+session) — delegated to the PR preview by design (the whole point of the A/B/C toggle).++### Gap ledger outcome (→ Step 5 DS ticket)+- Shipped one-off **`RecentActivitySegmentBar`** (status-segment/timeline-bar primitive) — DS has none.+- Re-derived **run-status → icon/color** inline (`RunGlyphs` + `STATUS_PILL_TONE`/`SEGMENT_FILL`)+ because there's no shared `RunStatusBadge`.+- Filed **SKY-11082** (team Skyvern AI) to extract both primitives into the DS once the winning+ variant is chosen. Pure helpers covered by `runActivity.test.ts`.++---++# Round 2 — Placement exploration (2026-06-16)++The A/B/C work settled the *surface design*; this round explores *where on the build page*+the surface lives. Orthogonal axis: any style (A/B/C) can sit at any placement.++## Frame (placement)++The surface only renders in **debug/browser mode** (`showBrowser`), inside the vertical+`Splitter`. Candidate regions and their occupants:+- **Left pane** = code (left half) + infinite canvas (right half). Bottom-left corner holds the+ FlowRenderer controls (FitView/Lock/GlobalCollapse); top is overlaid by `WorkflowHeader`+ (`absolute left-6 top-8 h-20`) and header-anchored sub-panels (`top-[8.5rem]`).+- **Right pane** (`skyvern-split-right`) = live browser + footer (copilot/power/reload); far+ right edge holds the run-detail **timeline rail** (`w-[5rem]`, expandable, `z-[15]`).++**Deciding constraint:** a placement must not block the live browser, the canvas controls, or+the run-detail timeline, and should not fight the header/sub-panels. So placements are+pointer-events-transparent floating bands (only the dock itself captures clicks).++## Inspiration (Mobbin — web, node-canvas editors)+- **WRITER — Blueprints**: execution log as a full-width **bottom** panel (node rows + status ++ Trace + duration). [link](https://mobbin.com/screens/2368f17d-4fcc-4590-912d-08cb39245dab)+- **n8n — Executions**: run history as a **left side panel** (status + duration, auto-refresh),+ entered via a top **Editor | Executions** tab.+ [link](https://mobbin.com/screens/d3af4413-04f9-4534-8aa4-01916d2b4910)+- **StackAI — Version history / Run Details**: **right side panel** co-located with the run+ (status, timestamps, duration, tokens).+ [link](https://mobbin.com/screens/cffa32bb-fa1e-43fa-913b-27001b35f395) ·+ [link](https://mobbin.com/screens/bb0174f4-60aa-4e30-ac5f-73679b160f38)+- **Databricks** (round 1): top **run-selector** + bottom **event log** in one editor.++## Placement concepts++- **P1 — Bottom dock (baseline, current):** floating bottom-center over the canvas/code pane.+ Lineage: WRITER bottom log + StackAI bottom toolbar. + canvas stays clear, controls reachable.+ − easy to miss; far from where the eye starts.+- **P2 — Top rail (under header):** pinned top-center over the canvas/code pane, just below the+ header. Lineage: n8n Editor|Executions top tab + Databricks top run-selector. + high+ discoverability, reads top-down, near run controls. − competes with header sub-panels when one+ is open; popover opens downward over the canvas.+- **P3 — Browser-pane header (co-located with run viewing):** pinned to the top of the right+ (live-browser) pane, so picking a recent run sits beside viewing that run + its detail+ timeline. Lineage: StackAI right-side run history/details. + strongest pick→view coherence+ (directly answers the ticket's "reconcile with run viewing"). − eats a strip of browser space;+ must clear the far-right timeline rail.++**Recommendation:** **P3 (browser-pane header)** for coherence — it puts "which run" right next+to "this run's browser + timeline," which is the actual debugging loop — with **P1** as the+low-risk default if we want the canvas untouched. P2 is the most discoverable but the most+crowded.++**Decision (2026-06-16):** per the established pattern, build all three behind a **placement+toggle** (orthogonal to the A/B/C style toggle; persisted via localStorage + `?activityPlacement=`+URL seed; default `bottom`) so they can be compared live in the PR preview.++### Gap-ledger addition+- No shared **floating-dock anchor** convention for build-canvas overlays (each overlay+ re-implements `absolute … pointer-events-none [&>*]:pointer-events-auto`). Minor; noted on+ [[SKY-11082]] rather than a new ticket.++## Round 2 decision — style converges to one "Activity Timeline" (2026-06-16)++Requester: "I like C the most, and B for its compression and all the events in one place."+→ **Merge B + C into a single default surface** and drop A (and the A/B/C style toggle):++**Activity Timeline** — compact two-row dock:+- Row 1: a **run selector** ("Run: ✓ Login · 2m ago ▾") + a compression summary ("N runs ·+ last ✓ 2m ago"). The selector opens **B's consolidated, scannable event list**+ (`RecentActivityList`) — all events in one place.+- Row 2: a **persistent segmented timeline bar** (C) — proportional, status-colored; hover→tip,+ click a segment → jump to that run.++This keeps C's timeline metaphor + direct segment navigation, with B's compression (compact+collapsed form) and single consolidated list. Built behind the **placement toggle** (bottom /+top / right) so location can still be compared in the PR preview.++## Round 3 decision — placement locked to browser-pane header (2026-06-16)++Requester locked the **browser-pane header (right)** placement. Removed the placement toggle ++store and the bottom/top anchors; `RecentActivity` now mounts unconditionally at the top of the+live-browser pane (`popoverSide="bottom"`). Rendered visual proof (mock runs) below — produced+via a throwaway standalone preview page, not committed.++++## Round 4 — re-added the 3-way placement toggle (2026-06-16)++Reverted the round-3 lock: requester wants to compare bottom / top / right **by eye** in the+preview rather than commit blind. Restored `RecentActivityPlacementStore` ++`RecentActivityPlacementToggle` and the three Workspace anchors (default `bottom`,+`?activityPlacement=` URL seed). Decide, then re-lock.++++## Round 5 — drop floating, integrate the run selector (2026-06-16)++Real screenshots showed every floating placement collides with canvas/browser content and+duplicates the existing right-side run-detail panel (`DebuggerRunTimeline`: Actions/Steps/Credits++ block/action timeline) — the overlap the ticket warned about. So: **remove the floating dock,+segmented bar, and placement toggle**, and make recent-activity a compact **run selector** that+opens the consolidated list. Two integration points behind a small mode toggle (default `panel`,+`?activityMode=panel|toolbar`):+- **panel:** selector at the top of the right run-detail panel (`DebuggerRun`) — co-located with+ viewing; picking a run drives the panel below.+- **toolbar:** selector as a dropdown in the editor header toolbar (`EditorActionToolbar`).+Removed: `RecentActivity`, `RecentActivityTimeline`, `RecentActivitySegmentBar`,+`RecentActivityPlacementToggle`, `RecentActivityPlacementStore`. Added: `RecentActivityRunSelector`,+`RecentActivityIntegrationStore`, `RecentActivityIntegrationToggle`.++## Round 6 — timeline strip below the browser (2026-06-16)++Panel/toolbar selectors still read as bolted-on. Requester idea: dock the timeline as a+horizontal strip **below the live browser session window** — the browser is what you're+watching, so a run history beneath it is contextual (WRITER bottom log / Databricks event-log+lineage). Added as a third integration option (`browser`) on the mode toggle:+`RecentActivityStrip` — a scannable horizontal row of run chips (oldest→newest, auto-scrolled to+newest, click→jump) + an "N runs ▾" button opening the consolidated list. Mounted between the+browser stream and its footer in both VNC and CDP panels. Compare via the Panel/Toolbar/Browser+toggle (`?activityMode=panel|toolbar|browser`).++## Round 7 — placement locked to the run-detail panel; preview toggle removed (final, 2026-06-29)++Compared the three integrations live in the PR preview and **locked `panel`**: the run+selector mounts at the top of the right run-detail panel (`DebuggerRun`), co-located with+viewing a run, which reconciles the history surface with run viewing (the ticket's open+question) without a second overlapping surface. Removed the exploration scaffolding —+`RecentActivityIntegrationStore` (+test), `RecentActivityIntegrationToggle`, and+`RecentActivityStrip` — plus the toolbar/browser wirings in `WorkflowHeader`/`Workspace`.+`RecentActivityRunSelector` mounts unconditionally (it self-hides until the debug session has+≥1 run) and its now-single-use `variant`/`popoverSide` props were dropped. Run rows in the+consolidated list are disabled while a workflow run is in progress (navigation is a no-op+then), covered by `RecentActivityList.test.tsx`. Dead exports `SEGMENT_FILL` and+`getRunTooltip` (orphaned when the segment bar / strip were cut) were removed.diff --git a/docs/design/activity-timeline-placements.png b/docs/design/activity-timeline-placements.pngnew file mode 100644index 000000000..a5f1b6086Binary files /dev/null and b/docs/design/activity-timeline-placements.png differdiff --git a/docs/design/activity-timeline-preview.png b/docs/design/activity-timeline-preview.pngnew file mode 100644index 000000000..2b4b64f42Binary files /dev/null and b/docs/design/activity-timeline-preview.png differdiff --git a/skyvern-frontend/src/routes/workflows/debugger/DebuggerBlockRuns.tsx b/skyvern-frontend/src/routes/workflows/debugger/DebuggerBlockRuns.tsxdeleted file mode 100644index c2bfb72a1..000000000--- a/skyvern-frontend/src/routes/workflows/debugger/DebuggerBlockRuns.tsx+++ /dev/null@@ -1,131 +0,0 @@-/**- * THe debugger has an underlying debug_session_id. Block runs that occur within- * same debug session are grouped together. We will show them with this component.- */--import { useEffect, useRef } from "react";-import { useNavigate, useParams } from "react-router-dom";-import { useQueryClient } from "@tanstack/react-query";--import { Tip } from "@/components/Tip";-import { statusIsFinalized } from "@/routes/tasks/types";-import { useWorkflowRunQuery } from "@/routes/workflows/hooks/useWorkflowRunQuery";-import { cn, formatMs, toDate } from "@/util/utils";--import { useBrowserSessionRateLimit } from "../hooks/useBrowserSessionRateLimit";-import { useDebugSessionQuery } from "../hooks/useDebugSessionQuery";-import { useWorkflowQuery } from "../hooks/useWorkflowQuery";-import {- useDebugSessionRunsQuery,- type DebugSessionRun,-} from "../hooks/useDebugSessionRunsQuery";-import { toast } from "@/components/ui/use-toast";--function DebuggerBlockRuns() {- const { workflowPermanentId } = useParams();- const navigate = useNavigate();- const queryClient = useQueryClient();- const scrollContainerRef = useRef<HTMLDivElement>(null);- const { data: workflowRun } = useWorkflowRunQuery();- const { data: workflow } = useWorkflowQuery({- workflowPermanentId,- });- const { isRateLimited } = useBrowserSessionRateLimit(workflowPermanentId);- const { data: debugSession } = useDebugSessionQuery({- workflowPermanentId,- isRateLimited,- });- const { data: debugSessionRuns } = useDebugSessionRunsQuery({- debugSessionId: debugSession?.debug_session_id,- });-- const numRuns = debugSessionRuns?.runs.length ?? 0;- const isFinalized = workflowRun ? statusIsFinalized(workflowRun) : null;- const isRunning = isFinalized !== null && !isFinalized;-- const handleClick = (run: DebugSessionRun) => {- if (isRunning) {- return;- }-- const blockLabel = run.block_label;- const workflowDefinition = workflow?.workflow_definition;- const blocks = workflowDefinition?.blocks ?? [];- const block = blocks.find((b) => b.label === blockLabel);-- if (!block) {- toast({- variant: "destructive",- title: "Block not found",- description: `The block with label '${blockLabel}' is no longer found in the workflow.`,- });-- return;- }-- navigate(- `/agents/${run.workflow_permanent_id}/${run.workflow_run_id}/${blockLabel}/build`,- );- };-- useEffect(() => {- queryClient.invalidateQueries({- queryKey: ["debug-session-runs"],- });- // We only want to run this when the workflowRun changes, not on every render- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [workflowRun]);-- useEffect(() => {- if (scrollContainerRef.current) {- scrollContainerRef.current.scrollLeft =- scrollContainerRef.current.scrollWidth;- }- }, [debugSessionRuns]);-- if (numRuns <= 1) {- return null;- }-- return (- <div className="relative flex items-center justify-center gap-2 opacity-80 hover:opacity-100">- <div- ref={scrollContainerRef}- className="flex max-w-[7rem] gap-2 overflow-x-auto rounded-full bg-[#050505] p-2 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"- >- {[...(debugSessionRuns?.runs ?? [])].reverse().map((run) => {- const dt = toDate(run.created_at ?? "", null);- const ago = dt ? formatMs(Date.now() - dt.getTime()).ago : null;- return (- <Tip- key={run.workflow_run_id}- content={- ago- ? `${run.block_label} [${run.status}] (${ago})`- : `${run.block_label} [${run.status}]`- }- >- <div- className={cn(- "h-[1rem] w-[1rem] flex-shrink-0 rounded-full border border-white/50 hover:border-white/80",- {- "cursor-pointer": !isRunning,- },- {- "animate-spin border-dashed [animation-duration:_2s]":- run.status === "running" && isRunning,- "border-[red] opacity-50 hover:border-[red] hover:opacity-100":- run.status === "failed",- },- )}- onClick={() => handleClick(run)}- />- </Tip>- );- })}- </div>- </div>- );-}--export { DebuggerBlockRuns };diff --git a/skyvern-frontend/src/routes/workflows/debugger/DebuggerRun.tsx b/skyvern-frontend/src/routes/workflows/debugger/DebuggerRun.tsxindex 15a598c73..6509f3bfb 100644--- a/skyvern-frontend/src/routes/workflows/debugger/DebuggerRun.tsx+++ b/skyvern-frontend/src/routes/workflows/debugger/DebuggerRun.tsx@@ -1,5 +1,6 @@import { useWorkflowRunQuery } from "@/routes/workflows/hooks/useWorkflowRunQuery";import { DebuggerRunTimeline } from "./DebuggerRunTimeline";+import { RecentActivityRunSelector } from "./recentActivity/RecentActivityRunSelector";function DebuggerRun() {const { data: workflowRun } = useWorkflowRunQuery();@@ -13,6 +14,9 @@ function DebuggerRun() {return (<div className="flex h-full w-full flex-col items-center justify-start overflow-hidden overflow-y-auto">+ <div className="w-[calc(100%-2rem)] self-start pb-2">+ <RecentActivityRunSelector />+ </div>{workflowFailureReason}<div className="h-full w-full"><DebuggerRunTimelinediff --git a/skyvern-frontend/src/routes/workflows/debugger/recentActivity/RecentActivityList.test.tsx b/skyvern-frontend/src/routes/workflows/debugger/recentActivity/RecentActivityList.test.tsxnew file mode 100644index 000000000..dc306a4ff--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/debugger/recentActivity/RecentActivityList.test.tsx@@ -0,0 +1,92 @@+// @vitest-environment jsdom++import { fireEvent, render } from "@testing-library/react";+import { describe, expect, test, vi } from "vitest";++import type { DebugSessionRun } from "../../hooks/useDebugSessionRunsQuery";+import { getRunActivityKey } from "./runActivity";+import { RecentActivityList } from "./RecentActivityList";++function makeRun(partial: Partial<DebugSessionRun> = {}): DebugSessionRun {+ return {+ ai_fallback: null,+ block_label: "Login",+ browser_session_id: "bs_1",+ code_gen: null,+ debug_session_id: "ds_1",+ failure_reason: null,+ output_parameter_id: "op_1",+ run_with: "agent",+ script_run_id: null,+ status: "completed",+ workflow_id: "w_1",+ workflow_permanent_id: "wpid_1",+ workflow_run_id: "wr_1",+ created_at: "2026-06-15T10:00:00Z",+ queued_at: null,+ started_at: null,+ finished_at: null,+ ...partial,+ };+}++function renderList(isWorkflowRunning: boolean) {+ const onSelect = vi.fn();+ const { container } = render(+ <RecentActivityList+ runs={[makeRun()]}+ currentActivityKey={null}+ isWorkflowRunning={isWorkflowRunning}+ blockTypeByLabel={new Map()}+ now={Date.parse("2026-06-15T10:05:00Z")}+ onSelect={onSelect}+ />,+ );+ const row = container.querySelector("button") as HTMLButtonElement;+ return { onSelect, row };+}++describe("RecentActivityList", () => {+ test("navigates when no workflow run is in progress", () => {+ const { onSelect, row } = renderList(false);+ expect(row.getAttribute("aria-disabled")).toBeNull();+ fireEvent.click(row);+ expect(onSelect).toHaveBeenCalledTimes(1);+ });++ test("disables run selection while a workflow run is in progress", () => {+ const { onSelect, row } = renderList(true);+ expect(row.getAttribute("aria-disabled")).toBe("true");+ fireEvent.click(row);+ expect(onSelect).not.toHaveBeenCalled();+ });++ test("tracks the current row by workflow run and block label", () => {+ const loginRun = makeRun({ workflow_run_id: "wr_1", block_label: "Login" });+ const extractRun = makeRun({+ workflow_run_id: "wr_1",+ block_label: "Extract",+ });+ const { container } = render(+ <RecentActivityList+ runs={[loginRun, extractRun]}+ currentActivityKey={getRunActivityKey(extractRun)}+ isWorkflowRunning={false}+ blockTypeByLabel={new Map()}+ now={Date.parse("2026-06-15T10:05:00Z")}+ onSelect={vi.fn()}+ />,+ );++ const rows = Array.from(container.querySelectorAll("button"));+ expect(rows).toHaveLength(2);+ const [newestRow, oldestRow] = rows;+ if (!newestRow || !oldestRow) {+ throw new Error("Expected recent activity rows to render");+ }+ expect(newestRow.textContent).toContain("Extract");+ expect(newestRow.getAttribute("aria-current")).toBe("true");+ expect(oldestRow.textContent).toContain("Login");+ expect(oldestRow.getAttribute("aria-current")).toBeNull();+ });+});diff --git a/skyvern-frontend/src/routes/workflows/debugger/recentActivity/RecentActivityList.tsx b/skyvern-frontend/src/routes/workflows/debugger/recentActivity/RecentActivityList.tsxnew file mode 100644index 000000000..fce4e0339--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/debugger/recentActivity/RecentActivityList.tsx@@ -0,0 +1,156 @@+import { cn } from "@/util/utils";++import type { DebugSessionRun } from "../../hooks/useDebugSessionRunsQuery";+import type { WorkflowBlockType } from "../../types/workflowTypes";+import type { RecentActivityViewProps } from "./viewProps";+import {+ getBlockTypeTitle,+ getRunAbsoluteTime,+ getRunActivityKey,+ getRunAgoLabel,+ getRunDurationLabel,+ getRunModeLabel,+ getRunStatusKind,+ getRunStatusLabel,+ normalizeReason,+ STATUS_PILL_TONE,+} from "./runActivity";+import { RunBlockGlyph, RunStatusGlyph } from "./RunGlyphs";++function RecentActivityRow({+ run,+ isCurrent,+ isWorkflowRunning,+ blockType,+ now,+ onSelect,+}: {+ run: DebugSessionRun;+ isCurrent: boolean;+ isWorkflowRunning: boolean;+ blockType: WorkflowBlockType | undefined;+ now: number;+ onSelect: (run: DebugSessionRun) => void;+}) {+ const kind = getRunStatusKind(run.status, isWorkflowRunning);+ const duration = getRunDurationLabel(run);+ const ago = getRunAgoLabel(run, now);+ const absoluteTime = getRunAbsoluteTime(run);+ const failureReason =+ kind === "failure" ? normalizeReason(run.failure_reason) : null;++ return (+ <li>+ <button+ type="button"+ onClick={isWorkflowRunning ? undefined : () => onSelect(run)}+ aria-current={isCurrent ? "true" : undefined}+ aria-disabled={isWorkflowRunning || undefined}+ title={+ isWorkflowRunning+ ? "Can't switch runs while this run is in progress"+ : undefined+ }+ className={cn(+ "flex w-full flex-col gap-1 rounded-md px-2 py-1.5 text-left outline-none transition-colors",+ isWorkflowRunning+ ? "cursor-not-allowed opacity-50"+ : "hover:bg-white/5 focus-visible:ring-1 focus-visible:ring-white/40",+ isCurrent && "bg-white/10",+ )}+ >+ <div className="flex items-center gap-2">+ <RunStatusGlyph+ status={run.status}+ isWorkflowRunning={isWorkflowRunning}+ className="size-3.5"+ />+ <RunBlockGlyph+ blockType={blockType}+ className="size-3.5 text-slate-300"+ />+ <span className="min-w-0 flex-1 truncate text-xs font-medium text-slate-100">+ {run.block_label}+ </span>+ {ago && (+ <span+ title={absoluteTime ?? undefined}+ className="shrink-0 text-[10px] tabular-nums text-slate-500"+ >+ {ago}+ </span>+ )}+ </div>+ <div className="flex items-center gap-1.5 pl-[1.625rem]">+ <span className="rounded bg-slate-700/70 px-1.5 py-0.5 text-[10px] font-medium text-slate-300">+ {getBlockTypeTitle(blockType)}+ </span>+ <span className="rounded border border-white/10 px-1.5 py-0.5 text-[10px] font-medium text-slate-400">+ {getRunModeLabel(run)}+ </span>+ <span+ className={cn(+ "rounded px-1.5 py-0.5 text-[10px] font-medium",+ STATUS_PILL_TONE[kind],+ )}+ >+ {getRunStatusLabel(run.status)}+ </span>+ {duration && (+ <span className="ml-auto shrink-0 text-[10px] tabular-nums text-slate-500">+ {duration}+ </span>+ )}+ </div>+ {failureReason && (+ <div className="line-clamp-2 pl-[1.625rem] text-[10px] leading-snug text-destructive/80">+ {failureReason}+ </div>+ )}+ </button>+ </li>+ );+}++function RecentActivityList({+ runs,+ currentActivityKey,+ isWorkflowRunning,+ blockTypeByLabel,+ now,+ onSelect,+}: RecentActivityViewProps) {+ // Newest first in the list, the natural reading order for "recent activity".+ const ordered = [...runs].reverse();++ return (+ <div className="flex w-[26rem] max-w-[80vw] flex-col overflow-hidden rounded-lg border border-white/10 bg-[#0b0b0b] text-slate-200 shadow-xl">+ <div className="flex items-center justify-between border-b border-white/10 px-3 py-2">+ <span className="text-xs font-medium text-slate-300">+ Recent activity+ </span>+ <span className="text-[10px] tabular-nums text-slate-500">+ {runs.length} {runs.length === 1 ? "run" : "runs"}+ </span>+ </div>+ <ul className="flex max-h-[20rem] flex-col gap-0.5 overflow-y-auto p-1">+ {ordered.map((run) => {+ const activityKey = getRunActivityKey(run);+ return (+ <RecentActivityRow+ key={activityKey}+ run={run}+ isCurrent={currentActivityKey === activityKey}+ isWorkflowRunning={isWorkflowRunning}+ blockType={blockTypeByLabel.get(run.block_label)}+ now={now}+ onSelect={onSelect}+ />+ );+ })}+ </ul>+ </div>+ );+}++export { RecentActivityList };diff --git a/skyvern-frontend/src/routes/workflows/debugger/recentActivity/RecentActivityRunSelector.tsx b/skyvern-frontend/src/routes/workflows/debugger/recentActivity/RecentActivityRunSelector.tsxnew file mode 100644index 000000000..bba212b95--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/debugger/recentActivity/RecentActivityRunSelector.tsx@@ -0,0 +1,114 @@+import { useEffect, useState } from "react";+import {+ ChevronDownIcon,+ CounterClockwiseClockIcon,+} from "@radix-ui/react-icons";++import {+ Popover,+ PopoverContent,+ PopoverTrigger,+} from "@/components/ui/popover";+import { cn } from "@/util/utils";++import { useRecentActivity } from "./useRecentActivity";+import { RecentActivityList } from "./RecentActivityList";+import { RunStatusGlyph } from "./RunGlyphs";+import { getRunActivityKey, getRunAgoLabel } from "./runActivity";+import type { RecentActivityViewProps } from "./viewProps";++type PopoverPlacement = {+ contentSide?: "top" | "right" | "bottom" | "left";+ contentAlign?: "start" | "center" | "end";+};++function RecentActivityRunSelector({+ contentSide = "bottom",+ contentAlign = "start",+}: PopoverPlacement = {}) {+ const {+ runs,+ currentActivityKey,+ isWorkflowRunning,+ blockTypeByLabel,+ navigateToRun,+ } = useRecentActivity();+ const [open, setOpen] = useState(false);+ const [now, setNow] = useState(() => Date.now());++ useEffect(() => {+ if (!open) {+ setNow(Date.now());+ return;+ }+ const intervalId = window.setInterval(() => setNow(Date.now()), 30_000);+ return () => window.clearInterval(intervalId);+ }, [open]);++ if (runs.length === 0) {+ return null;+ }++ const viewProps: RecentActivityViewProps = {+ runs,+ currentActivityKey,+ isWorkflowRunning,+ blockTypeByLabel,+ now,+ onSelect: navigateToRun,+ };+ const current = currentActivityKey+ ? runs.find((run) => getRunActivityKey(run) === currentActivityKey)+ : null;+ const selected = current ?? runs[runs.length - 1];+ const ago = selected ? getRunAgoLabel(selected, viewProps.now) : null;++ return (+ <Popover open={open} onOpenChange={setOpen}>+ <PopoverTrigger asChild>+ <button+ type="button"+ aria-label="Recent activity — select a run"+ className={cn(+ "flex w-full items-center gap-2 rounded-lg border border-white/10 bg-white/5 px-3 py-2 text-xs text-slate-200 outline-none transition-colors hover:bg-white/10 focus-visible:ring-1 focus-visible:ring-white/40",+ )}+ >+ <CounterClockwiseClockIcon className="size-4 shrink-0 text-slate-400" />+ {selected ? (+ <>+ <RunStatusGlyph+ status={selected.status}+ isWorkflowRunning={isWorkflowRunning}+ className="size-3.5"+ />+ <span className="max-w-[9rem] truncate font-medium">+ {selected.block_label}+ </span>+ {ago && (+ <span className="shrink-0 text-[10px] tabular-nums text-slate-500">+ {ago}+ </span>+ )}+ </>+ ) : (+ <span className="text-slate-400">Recent activity</span>+ )}+ <span className="shrink-0 text-[10px] tabular-nums text-slate-500">+ · {runs.length} {runs.length === 1 ? "run" : "runs"}+ </span>+ <ChevronDownIcon className="size-3.5 shrink-0 text-slate-500" />+ </button>+ </PopoverTrigger>+ <PopoverContent+ side={contentSide}+ align={contentAlign}+ sideOffset={8}+ className="w-auto border-none bg-transparent p-0 shadow-none"+ >+ <RecentActivityList {...viewProps} />+ </PopoverContent>+ </Popover>+ );+}++export { RecentActivityRunSelector };diff --git a/skyvern-frontend/src/routes/workflows/debugger/recentActivity/RunGlyphs.tsx b/skyvern-frontend/src/routes/workflows/debugger/recentActivity/RunGlyphs.tsxnew file mode 100644index 000000000..2aaaa3803--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/debugger/recentActivity/RunGlyphs.tsx@@ -0,0 +1,70 @@+import {+ CheckCircledIcon,+ CrossCircledIcon,+ DotFilledIcon,+ ReloadIcon,+} from "@radix-ui/react-icons";++import { cn } from "@/util/utils";++import { WorkflowBlockIcon } from "../../editor/nodes/WorkflowBlockIcon";+import type { WorkflowBlockType } from "../../types/workflowTypes";+import { getRunStatusKind } from "./runActivity";++export function RunStatusGlyph({+ status,+ isWorkflowRunning,+ className,+}: {+ status: string;+ isWorkflowRunning: boolean;+ className?: string;+}) {+ const kind = getRunStatusKind(status, isWorkflowRunning);+ if (kind === "success") {+ return (+ <CheckCircledIcon className={cn("shrink-0 text-success", className)} />+ );+ }+ if (kind === "failure") {+ return (+ <CrossCircledIcon+ className={cn("shrink-0 text-destructive", className)}+ />+ );+ }+ if (kind === "running") {+ return (+ <ReloadIcon+ className={cn("shrink-0 animate-spin text-sky-400", className)}+ />+ );+ }+ return (+ <span+ className={cn("flex shrink-0 items-center justify-center", className)}+ >+ <span className="size-2 rounded-full border border-slate-500" />+ </span>+ );+}++export function RunBlockGlyph({+ blockType,+ className,+}: {+ blockType: WorkflowBlockType | undefined;+ className?: string;+}) {+ if (!blockType) {+ return (+ <DotFilledIcon className={cn("shrink-0 text-slate-500", className)} />+ );+ }+ return (+ <WorkflowBlockIcon+ workflowBlockType={blockType}+ className={cn("shrink-0", className)}+ />+ );+}diff --git a/skyvern-frontend/src/routes/workflows/debugger/recentActivity/runActivity.test.ts b/skyvern-frontend/src/routes/workflows/debugger/recentActivity/runActivity.test.tsnew file mode 100644index 000000000..d7274c9c7--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/debugger/recentActivity/runActivity.test.ts@@ -0,0 +1,127 @@+import { describe, expect, it } from "vitest";++import type { WorkflowBlock } from "../../types/workflowTypes";+import type { DebugSessionRun } from "../../hooks/useDebugSessionRunsQuery";+import {+ buildBlockTypeByLabel,+ getRunActivityKey,+ getRunDurationLabel,+ getRunModeLabel,+ getRunStatusKind,+ getRunStatusLabel,+} from "./runActivity";++function makeRun(partial: Partial<DebugSessionRun>): DebugSessionRun {+ return {+ ai_fallback: null,+ block_label: "block_1",+ browser_session_id: "bs_1",+ code_gen: null,+ debug_session_id: "ds_1",+ failure_reason: null,+ output_parameter_id: "op_1",+ run_with: null,+ script_run_id: null,+ status: "completed",+ workflow_id: "w_1",+ workflow_permanent_id: "wpid_1",+ workflow_run_id: "wr_1",+ created_at: "2026-06-15T10:00:00Z",+ queued_at: null,+ started_at: null,+ finished_at: null,+ ...partial,+ };+}++describe("getRunStatusKind", () => {+ it("maps terminal statuses", () => {+ expect(getRunStatusKind("completed", false)).toBe("success");+ expect(getRunStatusKind("failed", false)).toBe("failure");+ expect(getRunStatusKind("terminated", false)).toBe("failure");+ expect(getRunStatusKind("timed_out", false)).toBe("failure");+ expect(getRunStatusKind("canceled", false)).toBe("failure");+ expect(getRunStatusKind("queued", false)).toBe("pending");+ expect(getRunStatusKind("created", false)).toBe("pending");+ expect(getRunStatusKind("skipped", false)).toBe("neutral");+ });++ it("only spins a running status while the workflow is live", () => {+ expect(getRunStatusKind("running", true)).toBe("running");+ expect(getRunStatusKind("running", false)).toBe("neutral");+ });+});++describe("getRunDurationLabel", () => {+ it("formats started→finished elapsed time", () => {+ const run = makeRun({+ started_at: "2026-06-15T10:00:00Z",+ finished_at: "2026-06-15T10:00:05Z",+ });+ expect(getRunDurationLabel(run)).toBe("5s");+ });++ it("falls back to created_at when started_at is absent", () => {+ const run = makeRun({+ created_at: "2026-06-15T10:00:00Z",+ started_at: null,+ finished_at: "2026-06-15T10:01:30Z",+ });+ expect(getRunDurationLabel(run)).toBe("1m 30s");+ });++ it("returns null without a finish time or with a negative span", () => {+ expect(getRunDurationLabel(makeRun({ finished_at: null }))).toBeNull();+ expect(+ getRunDurationLabel(+ makeRun({+ started_at: "2026-06-15T10:00:05Z",+ finished_at: "2026-06-15T10:00:00Z",+ }),+ ),+ ).toBeNull();+ });+});++describe("getRunModeLabel", () => {+ it("distinguishes explicit run modes from missing or unknown values", () => {+ expect(getRunModeLabel(makeRun({ run_with: "code" }))).toBe("Code");+ expect(getRunModeLabel(makeRun({ run_with: "agent" }))).toBe("Agent");+ expect(getRunModeLabel(makeRun({ run_with: null }))).toBe("Unknown");+ expect(getRunModeLabel(makeRun({ run_with: "legacy" }))).toBe("Unknown");+ });+});++describe("getRunStatusLabel", () => {+ it("humanizes snake_case statuses", () => {+ expect(getRunStatusLabel("timed_out")).toBe("Timed Out");+ expect(getRunStatusLabel("completed")).toBe("Completed");+ });+});++describe("getRunActivityKey", () => {+ it("disambiguates block runs that share a workflow run", () => {+ expect(+ getRunActivityKey(+ makeRun({ workflow_run_id: "wr_1", block_label: "block_2" }),+ ),+ ).toBe("wr_1:block_2");+ });+});++describe("buildBlockTypeByLabel", () => {+ it("maps top-level and nested loop block labels", () => {+ const blocks = [+ { label: "nav", block_type: "navigation" },+ {+ label: "loop",+ block_type: "for_loop",+ loop_blocks: [{ label: "inner", block_type: "task" }],+ },+ ] as unknown as Array<WorkflowBlock>;+ const map = buildBlockTypeByLabel(blocks);+ expect(map.get("nav")).toBe("navigation");+ expect(map.get("loop")).toBe("for_loop");+ expect(map.get("inner")).toBe("task");+ });+});diff --git a/skyvern-frontend/src/routes/workflows/debugger/recentActivity/runActivity.ts b/skyvern-frontend/src/routes/workflows/debugger/recentActivity/runActivity.tsnew file mode 100644index 000000000..f2afaf7b1--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/debugger/recentActivity/runActivity.ts@@ -0,0 +1,120 @@+import { formatMs, toDate } from "@/util/utils";+import { formatDuration, toDuration } from "@/routes/workflows/utils";++import { workflowBlockTitle } from "../../editor/nodes/types";+import type {+ WorkflowBlock,+ WorkflowBlockType,+} from "../../types/workflowTypes";+import type { DebugSessionRun } from "../../hooks/useDebugSessionRunsQuery";++export type RunStatusKind =+ | "success"+ | "failure"+ | "running"+ | "pending"+ | "neutral";++const FAILURE_STATUSES = new Set([+ "failed",+ "terminated",+ "timed_out",+ "canceled",+]);++export function getRunStatusKind(+ status: string,+ isWorkflowRunning: boolean,+): RunStatusKind {+ if (status === "completed") return "success";+ if (FAILURE_STATUSES.has(status)) return "failure";+ // A run can be left in "running" after the workflow itself finalized (e.g. a+ // cancelled session); only spin while the workflow is genuinely live.+ if (status === "running") return isWorkflowRunning ? "running" : "neutral";+ if (status === "queued" || status === "created") return "pending";+ return "neutral";+}++export const STATUS_PILL_TONE: Record<RunStatusKind, string> = {+ success: "bg-emerald-500/15 text-emerald-300",+ failure: "bg-red-500/15 text-red-300",+ running: "bg-sky-500/15 text-sky-300",+ pending: "bg-amber-500/15 text-amber-300",+ neutral: "bg-slate-500/15 text-slate-300",+};++export function getRunDurationLabel(run: DebugSessionRun): string | null {+ const begin = run.started_at+ ? toDate(run.started_at, null)+ : run.created_at+ ? toDate(run.created_at, null)+ : null;+ const end = run.finished_at ? toDate(run.finished_at, null) : null;+ if (!begin || !end) return null;+ const seconds = Math.round((end.getTime() - begin.getTime()) / 1000);+ if (seconds < 0) return null;+ return formatDuration(toDuration(seconds));+}++export function getRunAgoLabel(+ run: DebugSessionRun,+ now: number,+): string | null {+ const dt = run.created_at ? toDate(run.created_at, null) : null;+ if (!dt) return null;+ return formatMs(now - dt.getTime()).ago;+}++export function getRunAbsoluteTime(run: DebugSessionRun): string | null {+ const dt = run.created_at ? toDate(run.created_at, null) : null;+ return dt ? dt.toLocaleString() : null;+}++export function getRunModeLabel(run: DebugSessionRun): string {+ if (run.run_with === "code") return "Code";+ if (run.run_with === "agent") return "Agent";+ return "Unknown";+}++export function getRunStatusLabel(status: string): string {+ return status+ .replace(/_/g, " ")+ .replace(/\b\w/g, (character) => character.toUpperCase());+}++export function getRunActivityKey(+ run: Pick<DebugSessionRun, "workflow_run_id" | "block_label">,+): string {+ return `${run.workflow_run_id}:${run.block_label}`;+}++export function normalizeReason(+ value: string | null | undefined,+): string | null {+ const normalized = value?.replace(/\s+/g, " ").trim();+ return normalized ? normalized : null;+}++export function getBlockTypeTitle(+ blockType: WorkflowBlockType | undefined,+): string {+ return blockType ? workflowBlockTitle[blockType] : "Block";+}++// `DebugSessionRun` only carries a `block_label`; the block's type (and thus its+// icon/title) lives in the workflow definition. Walk top-level blocks plus loop+// children so nested blocks resolve too; extend this if non-loop containers gain+// child block arrays.+export function buildBlockTypeByLabel(+ blocks: Array<WorkflowBlock> | undefined,+ accumulator: Map<string, WorkflowBlockType> = new Map(),+): Map<string, WorkflowBlockType> {+ if (!blocks) return accumulator;+ for (const block of blocks) {+ accumulator.set(block.label, block.block_type);+ if (block.block_type === "for_loop" || block.block_type === "while_loop") {+ buildBlockTypeByLabel(block.loop_blocks, accumulator);+ }+ }+ return accumulator;+}diff --git a/skyvern-frontend/src/routes/workflows/debugger/recentActivity/useRecentActivity.ts b/skyvern-frontend/src/routes/workflows/debugger/recentActivity/useRecentActivity.tsnew file mode 100644index 000000000..951de6b14--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/debugger/recentActivity/useRecentActivity.ts@@ -0,0 +1,108 @@+import { useCallback, useEffect, useMemo } from "react";+import { useNavigate, useParams } from "react-router-dom";+import { useQueryClient } from "@tanstack/react-query";++import { toast } from "@/components/ui/use-toast";+import { statusIsFinalized } from "@/routes/tasks/types";+import { useWorkflowRunQuery } from "@/routes/workflows/hooks/useWorkflowRunQuery";+import { toDate } from "@/util/utils";++import { useBrowserSessionRateLimit } from "../../hooks/useBrowserSessionRateLimit";+import { useDebugSessionQuery } from "../../hooks/useDebugSessionQuery";+import { useWorkflowQuery } from "../../hooks/useWorkflowQuery";+import {+ useDebugSessionRunsQuery,+ type DebugSessionRun,+} from "../../hooks/useDebugSessionRunsQuery";+import type { WorkflowBlockType } from "../../types/workflowTypes";+import { buildBlockTypeByLabel, getRunActivityKey } from "./runActivity";++export type RecentActivity = {+ /** Debug-session runs sorted ascending by `created_at` (oldest → newest). */+ runs: Array<DebugSessionRun>;+ currentActivityKey: string | null;+ isWorkflowRunning: boolean;+ blockTypeByLabel: Map<string, WorkflowBlockType>;+ navigateToRun: (run: DebugSessionRun) => void;+};++function sortRunsAscending(+ runs: Array<DebugSessionRun>,+): Array<DebugSessionRun> {+ return [...runs].sort((left, right) => {+ const leftTime = toDate(left.created_at ?? "", null)?.getTime() ?? 0;+ const rightTime = toDate(right.created_at ?? "", null)?.getTime() ?? 0;+ return leftTime - rightTime;+ });+}++export function useRecentActivity(): RecentActivity {+ const { blockLabel, workflowPermanentId } = useParams();+ const navigate = useNavigate();+ const queryClient = useQueryClient();+ const { data: workflowRun } = useWorkflowRunQuery();+ const { data: workflow } = useWorkflowQuery({ workflowPermanentId });+ const { isRateLimited } = useBrowserSessionRateLimit(workflowPermanentId);+ const { data: debugSession } = useDebugSessionQuery({+ workflowPermanentId,+ isRateLimited,+ });+ const { data: debugSessionRuns } = useDebugSessionRunsQuery({+ debugSessionId: debugSession?.debug_session_id,+ });++ const isFinalized = workflowRun ? statusIsFinalized(workflowRun) : null;+ const isWorkflowRunning = isFinalized !== null && !isFinalized;++ const runs = useMemo(+ () => sortRunsAscending(debugSessionRuns?.runs ?? []),+ [debugSessionRuns],+ );++ const blockTypeByLabel = useMemo(+ () => buildBlockTypeByLabel(workflow?.workflow_definition?.blocks),+ [workflow],+ );++ useEffect(() => {+ queryClient.invalidateQueries({+ queryKey: ["debug-session-runs"],+ });+ // Refresh runs only when the active workflow run changes.+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [workflowRun]);++ const navigateToRun = useCallback(+ (run: DebugSessionRun) => {+ if (isWorkflowRunning) {+ return;+ }+ if (!blockTypeByLabel.has(run.block_label)) {+ toast({+ variant: "destructive",+ title: "Block not found",+ description: `The block with label '${run.block_label}' is no longer found in the workflow.`,+ });+ return;+ }+ navigate(+ `/agents/${run.workflow_permanent_id}/${run.workflow_run_id}/${run.block_label}/build`,+ );+ },+ [isWorkflowRunning, blockTypeByLabel, navigate],+ );++ return {+ runs,+ currentActivityKey:+ workflowRun?.workflow_run_id && blockLabel+ ? getRunActivityKey({+ workflow_run_id: workflowRun.workflow_run_id,+ block_label: blockLabel,+ })+ : null,+ isWorkflowRunning,+ blockTypeByLabel,+ navigateToRun,+ };+}diff --git a/skyvern-frontend/src/routes/workflows/debugger/recentActivity/viewProps.ts b/skyvern-frontend/src/routes/workflows/debugger/recentActivity/viewProps.tsnew file mode 100644index 000000000..029c25199--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/debugger/recentActivity/viewProps.ts@@ -0,0 +1,12 @@+import type { WorkflowBlockType } from "../../types/workflowTypes";+import type { DebugSessionRun } from "../../hooks/useDebugSessionRunsQuery";++export type RecentActivityViewProps = {+ /** Debug-session runs, ascending by `created_at`; list views may reverse a clone. */+ runs: Array<DebugSessionRun>;+ currentActivityKey: string | null;+ isWorkflowRunning: boolean;+ blockTypeByLabel: Map<string, WorkflowBlockType>;+ now: number;+ onSelect: (run: DebugSessionRun) => void;+};diff --git a/skyvern-frontend/src/routes/workflows/editor/Workspace.tsx b/skyvern-frontend/src/routes/workflows/editor/Workspace.tsxindex 5286841c2..dc820539f 100644--- a/skyvern-frontend/src/routes/workflows/editor/Workspace.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/Workspace.tsx@@ -90,6 +90,7 @@ import { statusIsFinalized } from "@/routes/tasks/types.ts";import { CodeEditor } from "@/routes/workflows/components/CodeEditor";import { DebuggerRun } from "@/routes/workflows/debugger/DebuggerRun";import { DebuggerRunMinimal } from "@/routes/workflows/debugger/DebuggerRunMinimal";+import { RecentActivityRunSelector } from "@/routes/workflows/debugger/recentActivity/RecentActivityRunSelector";import { useWorkflowRunQuery } from "@/routes/workflows/hooks/useWorkflowRunQuery";import {BranchContext,@@ -99,7 +100,6 @@ import { useWorkflowHasChangesStore } from "@/store/WorkflowHasChangesStore";import { useWorkflowParametersStore } from "@/store/WorkflowParametersStore";import { useWorkflowTitleStore } from "@/store/WorkflowTitleStore";import { getCode, getOrderedBlockLabels } from "@/routes/workflows/utils";-import { DebuggerBlockRuns } from "@/routes/workflows/debugger/DebuggerBlockRuns";import { copyText } from "@/util/copyText";import { isMacPlatform } from "@/util/platform";import { parseHeaderJson } from "@/util/secretHeaders";@@ -1991,7 +1991,7 @@ function Workspace({</div>{/* infinite canvas */}<div- className={cn("h-full w-[50%]", {+ className={cn("relative h-full w-[50%]", {"w-[100%]":leftSideLayoutMode === "side-by-side" && !showAllCode,})}@@ -2013,18 +2013,16 @@ function Workspace({historyApplyTrigger={historyApplyTrigger}onLayoutPhaseChange={setFlowLayoutPhase}/>+ {!blockLabel && (+ <div className="pointer-events-none absolute bottom-3 left-1/2 z-20 w-[20rem] max-w-[calc(100%-2rem)] -translate-x-1/2 [&>*]:pointer-events-auto">+ <RecentActivityRunSelector+ contentSide="top"+ contentAlign="center"+ />+ </div>+ )}</div></div>- {/* block runs history for current debug session id*/}- {/*- pointer-events-none on the wrapper so clicks pass through to- the FlowRenderer's bottom-left Controls (FitView, Lock,- GlobalCollapse) that sit in the same corner; the actual- debugger chip re-enables pointer events on itself.- */}- <div className="pointer-events-none absolute bottom-[0.5rem] left-[0.75rem] flex w-full items-start justify-center [&>*]:pointer-events-auto">- <DebuggerBlockRuns />- </div></div><div className="skyvern-split-right relative flex h-full items-end justify-center bg-neutral-50 p-4 pl-6 dark:bg-background">