feat: pipeline logs panel in editor and metrics pages#9
Conversation
Wire up the existing PipelineLogs component to both the pipeline metrics page (as a new Logs card) and the pipeline editor (as a collapsible bottom panel toggled from the toolbar). The toolbar shows a red dot indicator when recent errors exist, helping users spot pipeline issues during initial configuration.
Greptile SummaryThis PR wires the existing Key changes:
Minor findings:
Confidence Score: 4/5
Sequence DiagramsequenceDiagram
participant Editor as Pipeline Editor (page.tsx)
participant Toolbar as FlowToolbar
participant LogsPanel as PipelineLogs
participant TRPC as tRPC (pipeline.logs)
participant DB as PostgreSQL (PipelineLog)
Editor->>TRPC: background poll every 10s<br/>{ levels:["ERROR"], limit:1, since: errorCheckSince }<br/>(disabled when logsOpen=true)
TRPC->>DB: SELECT WHERE level=ERROR AND timestamp>=since LIMIT 2
DB-->>TRPC: items[]
TRPC-->>Editor: { items, nextCursor }
Editor->>Toolbar: hasRecentErrors = items.length > 0
Toolbar-->>Editor: red dot visible on ScrollText icon
Editor->>Toolbar: user clicks ScrollText
Toolbar-->>Editor: onToggleLogs() → logsOpen=true
Editor->>LogsPanel: render PipelineLogs (h-[300px])
LogsPanel->>TRPC: infiniteQuery every 5s<br/>{ pipelineId, levels: activeLevels }
TRPC->>DB: SELECT … ORDER BY timestamp DESC LIMIT 201
DB-->>TRPC: items[], nextCursor
TRPC-->>LogsPanel: pages[0].items
LogsPanel-->>LogsPanel: reverse → chronological display<br/>auto-scroll to bottom
LogsPanel->>TRPC: fetchNextPage (scroll to top)<br/>cursor = lastId
TRPC->>DB: SELECT … cursor:lastId skip:1
DB-->>TRPC: older items
TRPC-->>LogsPanel: prepend older logs, restore scroll position
|
| const recentErrorsQuery = useQuery( | ||
| trpc.pipeline.logs.queryOptions( | ||
| { pipelineId, levels: ["ERROR"], limit: 1 }, | ||
| { enabled: !!isDeployed && !logsOpen, refetchInterval: 10000 }, | ||
| ), | ||
| ); | ||
| const hasRecentErrors = (recentErrorsQuery.data?.items?.length ?? 0) > 0; |
There was a problem hiding this comment.
The error badge query fetches the single most recent ERROR log with no time-window filter. If a pipeline had an error 3 months ago and has been healthy since, hasRecentErrors remains permanently true — the red dot will always appear, even though the issue is long resolved.
The logs tRPC endpoint does not currently support time-window parameters. To fix this, consider:
- Adding a
since/afterparameter to the logs endpoint (e.g., last 24h) - Threading it through this query:
{ levels: ["ERROR"], limit: 1, since: new Date(Date.now() - 24*60*60*1000) } - Or at minimum, documenting in the UI that the badge reflects "any historical error" rather than recent ones
Without a recency bound, the signal degrades into noise for long-running pipelines.
Summary
PipelineLogscomponent to the pipeline metrics page as a new "Logs" card sectionPipelineLogsfor logs without an associated nodeHow it works
pipeline.logstRPC endpoint with 5s auto-refreshTest plan