-
Notifications
You must be signed in to change notification settings - Fork 0
feat: pipeline logs panel in editor and metrics pages #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| "use client"; | ||
|
|
||
| import { useCallback, useEffect, useRef, useState } from "react"; | ||
| import { useCallback, useEffect, useMemo, useRef, useState } from "react"; | ||
| import { useParams, useRouter } from "next/navigation"; | ||
| import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"; | ||
| import type { NodeMetricsData } from "@/stores/flow-store"; | ||
|
|
@@ -34,6 +34,7 @@ import { DeployDialog } from "@/components/flow/deploy-dialog"; | |
| import { SaveTemplateDialog } from "@/components/flow/save-template-dialog"; | ||
| import { ConfirmDialog } from "@/components/confirm-dialog"; | ||
| import { PipelineMetricsChart } from "@/components/pipeline/metrics-chart"; | ||
| import { PipelineLogs } from "@/components/pipeline/pipeline-logs"; | ||
|
|
||
| function aggregateProcessStatus( | ||
| statuses: Array<{ status: string }> | ||
|
|
@@ -114,6 +115,7 @@ function PipelineBuilderInner({ pipelineId }: { pipelineId: string }) { | |
| const [deleteOpen, setDeleteOpen] = useState(false); | ||
| const [undeployOpen, setUndeployOpen] = useState(false); | ||
| const [metricsOpen, setMetricsOpen] = useState(false); | ||
| const [logsOpen, setLogsOpen] = useState(false); | ||
|
|
||
| const loadGraph = useFlowStore((s) => s.loadGraph); | ||
| const isDirty = useFlowStore((s) => s.isDirty); | ||
|
|
@@ -157,6 +159,20 @@ function PipelineBuilderInner({ pipelineId }: { pipelineId: string }) { | |
| ), | ||
| ); | ||
|
|
||
| // Lightweight check for recent errors (for toolbar badge) — 24h window | ||
| const errorCheckSince = useMemo( | ||
| () => new Date(Date.now() - 24 * 60 * 60 * 1000), | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| [], | ||
| ); | ||
| const recentErrorsQuery = useQuery( | ||
| trpc.pipeline.logs.queryOptions( | ||
| { pipelineId, levels: ["ERROR"], limit: 1, since: errorCheckSince }, | ||
| { enabled: !!isDeployed && !logsOpen, refetchInterval: 10000 }, | ||
| ), | ||
| ); | ||
TerrifiedBug marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const hasRecentErrors = (recentErrorsQuery.data?.items?.length ?? 0) > 0; | ||
|
Comment on lines
+168
to
+174
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error badge query fetches the single most recent The logs tRPC endpoint does not currently support time-window parameters. To fix this, consider:
Without a recency bound, the signal degrades into noise for long-running pipelines. |
||
|
|
||
| // Merge component metrics into flow node data | ||
| useEffect(() => { | ||
| const components = componentMetricsQuery.data?.components; | ||
|
|
@@ -367,6 +383,9 @@ function PipelineBuilderInner({ pipelineId }: { pipelineId: string }) { | |
| isDirty={isDirty} | ||
| metricsOpen={metricsOpen} | ||
| onToggleMetrics={() => setMetricsOpen((v) => !v)} | ||
| logsOpen={logsOpen} | ||
| onToggleLogs={() => setLogsOpen((v) => !v)} | ||
| hasRecentErrors={hasRecentErrors} | ||
| processStatus={ | ||
| pipelineQuery.data?.nodeStatuses | ||
| ? aggregateProcessStatus(pipelineQuery.data.nodeStatuses) | ||
|
|
@@ -417,6 +436,11 @@ function PipelineBuilderInner({ pipelineId }: { pipelineId: string }) { | |
| <PipelineMetricsChart pipelineId={pipelineId} /> | ||
| </div> | ||
| )} | ||
| {logsOpen && ( | ||
| <div className="h-[300px] shrink-0 border-t"> | ||
| <PipelineLogs pipelineId={pipelineId} /> | ||
| </div> | ||
| )} | ||
| <DeployDialog pipelineId={pipelineId} open={deployOpen} onOpenChange={setDeployOpen} /> | ||
| <SaveTemplateDialog open={templateOpen} onOpenChange={setTemplateOpen} /> | ||
| <ConfirmDialog | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.