From 8e11d6c2a4f69a8fe453879d887bbbe087c42c7e Mon Sep 17 00:00:00 2001 From: Brendan Date: Sun, 13 Sep 2026 16:11:37 +0000 Subject: [PATCH] Show issue titles on every agent run --- src/tenant.ts | 19 +++++++++++++++++++ src/ui.ts | 2 +- test/ui.test.ts | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/tenant.ts b/src/tenant.ts index 78886385..ff0dac5f 100644 --- a/src/tenant.ts +++ b/src/tenant.ts @@ -296,6 +296,7 @@ export class Tenant extends DurableObject { const offset = (page - 1) * 10; const events = view === "events" ? this.rows("SELECT id, delivery_id, issue_id, issue_url, event_type, event_action, outcome, detail, provider, received_at FROM flow_events WHERE flow_id = ? ORDER BY received_at DESC, id DESC LIMIT 11 OFFSET ?", flowId, offset) : []; const runs = view === "runs" ? this.rows("SELECT id, issue_id, issue_title, issue_url, claim_key, agent_name, workspace_name, agent_kind, state, provider, prompt, result, created_at, updated_at, exec_request, exec_response, exec_status, exec_exit_code, recovery_reason, recovery_attempt, recovery_last_action, recovery_started_at FROM runs WHERE pipe_id = ? AND state != 'ignored' ORDER BY created_at DESC, id DESC LIMIT 11 OFFSET ?", flowId, offset) : []; + await this.backfillRunTitles(runs); const hasNext = (view === "events" ? events : runs).length > 10; if (events.length > 10) events.pop(); if (runs.length > 10) runs.pop(); @@ -310,6 +311,24 @@ export class Tenant extends DurableObject { return json({ flow, events, runs, pagination: { page, hasNext } }); } + private async backfillRunTitles(runs: Row[]): Promise { + const missing = runs.filter((run) => String(run.provider || "linear") === "linear" && !String(run.issue_title || "").trim()); + if (!missing.length) return; + const linear = await this.connection<{ accessToken: string }>("linear"); + if (!linear) return; + await Promise.all(missing.map(async (run) => { + try { + const data = await this.linear(linear.accessToken, LINEAR_ISSUE_PROJECT_QUERY, { id: String(run.issue_id) }); + const title = text(object(data?.issue).title).trim(); + if (!title) return; + run.issue_title = title; + this.ctx.storage.sql.exec("UPDATE runs SET issue_title = ? WHERE id = ?", title, run.id); + } catch { + // A stale or inaccessible issue should not prevent the runs page loading. + } + })); + } + private async runDetail(runId: string): Promise { const run = this.one("SELECT runs.*, pipes.name AS flow_name FROM runs JOIN pipes ON pipes.id = runs.pipe_id WHERE runs.id = ?", runId); if (!run) return new Response("Not found", { status: 404 }); diff --git a/src/ui.ts b/src/ui.ts index 987e6471..d5da042b 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -155,7 +155,7 @@ const root=document.querySelector('#flow-detail'),flowId=root.dataset.flowId,esc const issueLink=(id,url)=>{if(!id)return '—';const trusted=typeof url==='string'&&(url.startsWith('https://linear.app/')||/^https:\\/\\/github\\.com\\/[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+\\/pull\\/\\d+$/.test(url)),href=trusted?url:'https://linear.app/issue/'+encodeURIComponent(id);return ''+esc(id)+' ↗'}; const detail=(title,value)=>value?'

'+title+'

'+esc(value)+'
':''; const pager=p=>p.page===1&&!p.hasNext?'':''; -async function load(){const page=Math.max(1,parseInt(new URLSearchParams(location.search).get('page')||'1',10)||1),response=await fetch('/api/pipes/'+encodeURIComponent(flowId)+'?view=runs&page='+page);if(response.status===401)return location.href='/auth/linear';if(!response.ok){root.innerHTML='

Could not load this flow.

';return}const data=await response.json(),flow=data.flow,pagination=data.pagination||{page:1,hasNext:false},panels=(data.runs||[]).map(run=>'
'+esc(run.issue_title||run.issue_id)+''+issueLink(run.issue_id,run.issue_url)+''+esc(run.agent_kind||flow.agent_kind||'Herdr agent')+' · '+esc(run.agent_name)+''+badge(run.state)+''+time(run.updated_at)+'
'+detail('Prompt sent to agent',run.prompt)+detail('Exact command submitted to exe.dev',run.exec_request)+detail('Actual exe.dev response',run.exec_response)+detail('Full agent output',run.result)+'
').join('')||'

No agent runs yet.

';root.innerHTML='

'+esc(flow.name)+'

'+esc(flow.filter_type)+' trigger · '+esc(flow.max_concurrency)+' concurrent agents · '+esc(flow.agent_kind||'Herdr agent')+' · workspace '+esc(flow.workspace_name||'—')+'

Webhook activityEdit Flow

Agent runs

Open a run page or expand a row to inspect its output.

'+panels+pager(pagination)+'
'}load(); +async function load(){const page=Math.max(1,parseInt(new URLSearchParams(location.search).get('page')||'1',10)||1),response=await fetch('/api/pipes/'+encodeURIComponent(flowId)+'?view=runs&page='+page);if(response.status===401)return location.href='/auth/linear';if(!response.ok){root.innerHTML='

Could not load this flow.

';return}const data=await response.json(),flow=data.flow,pagination=data.pagination||{page:1,hasNext:false},panels=(data.runs||[]).map(run=>'
'+esc(run.issue_id)+(run.issue_title?': '+esc(run.issue_title):'')+''+esc(run.agent_kind||flow.agent_kind||'Herdr agent')+' · '+esc(run.agent_name)+''+badge(run.state)+''+time(run.updated_at)+'
'+detail('Prompt sent to agent',run.prompt)+detail('Exact command submitted to exe.dev',run.exec_request)+detail('Actual exe.dev response',run.exec_response)+detail('Full agent output',run.result)+'
').join('')||'

No agent runs yet.

';root.innerHTML='

'+esc(flow.name)+'

'+esc(flow.filter_type)+' trigger · '+esc(flow.max_concurrency)+' concurrent agents · '+esc(flow.agent_kind||'Herdr agent')+' · workspace '+esc(flow.workspace_name||'—')+'

Webhook activityEdit Flow

Agent runs

Open a run page or expand a row to inspect its output.

'+panels+pager(pagination)+'
'}load(); `); export const flowWebhooksPage = (viewer: { email: string }, flowId: string) => shell("Webhook activity — Factorize", viewer, ` diff --git a/test/ui.test.ts b/test/ui.test.ts index 3e2fa430..ab0589b4 100644 --- a/test/ui.test.ts +++ b/test/ui.test.ts @@ -68,6 +68,7 @@ describe("pages", () => { expect(html).toContain("Prompt sent to agent"); expect(html).toContain("Full agent output"); expect(html).toContain("issue_title"); + expect(html).toContain("esc(run.issue_id)+(run.issue_title?': '+esc(run.issue_title):'')"); expect(html).toContain('max-h-[32rem] overflow-auto'); expectInlineScriptsToParse(html); });