fix: pipeline editor UX improvements#112
Conversation
…ity lint Date.now() is impure and cannot be called inside useMemo per react-hooks/purity. Moved to useEffect + useState instead.
Greptile SummaryThis PR delivers five UX improvements to the pipeline editor and fleet pages: scoping the error badge to the current process session via Confidence Score: 4/5Safe to merge after the one-line formatUptime fix; no security or data-loss risk introduced. All logic changes are correct and the implementation is clean. Only one minor correctness bug exists (formatUptime returning "—" for 0 seconds instead of "0s"), which is a trivial one-line fix. The session-scoped error badge, merged AI dialog, and global refetchOnWindowFocus change all behave as intended. src/app/(dashboard)/pipelines/page.tsx — formatUptime bug on line 128 Important Files Changed
Sequence DiagramsequenceDiagram
participant PE as Pipeline Editor
participant PQ as pipelineQuery (tRPC)
participant DB as DB (nodeStatuses)
participant EQ as recentErrorsQuery
PE->>PQ: pipeline.get({ id })
PQ->>DB: SELECT status, uptimeSeconds FROM nodeStatuses
DB-->>PQ: [{ status: "RUNNING", uptimeSeconds: 300 }]
PQ-->>PE: pipelineQuery.data.nodeStatuses
Note over PE: useMemo → sessionStart = now - minUptime*1000
alt sessionStart != null AND isDeployed
PE->>EQ: pipeline.logs({ since: sessionStart, levels: ["ERROR"] })
EQ-->>PE: hasRecentErrors = items.length > 0
Note over PE: Red dot shown only for current session
else sessionStart is null (no running nodes)
Note over PE: recentErrorsQuery disabled, no badge
end
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/app/(dashboard)/pipelines/page.tsx
Line: 128
Comment:
**`formatUptime` returns "—" for `0` seconds**
`!seconds` is truthy for both `null` and `0`. If a heartbeat arrives with `uptimeSeconds: 0` (pipeline just started), the Uptime column will display "—" instead of "0s". The condition should check strictly for `null`/`undefined`:
```suggestion
if (seconds == null) return "\u2014";
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix: use useEffect instead of useMemo fo..." | Re-trigger Greptile |
| } | ||
|
|
||
| function formatUptime(seconds: number | null): string { | ||
| if (!seconds) return "\u2014"; |
There was a problem hiding this comment.
formatUptime returns "—" for 0 seconds
!seconds is truthy for both null and 0. If a heartbeat arrives with uptimeSeconds: 0 (pipeline just started), the Uptime column will display "—" instead of "0s". The condition should check strictly for null/undefined:
| if (!seconds) return "\u2014"; | |
| if (seconds == null) return "\u2014"; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/app/(dashboard)/pipelines/page.tsx
Line: 128
Comment:
**`formatUptime` returns "—" for `0` seconds**
`!seconds` is truthy for both `null` and `0`. If a heartbeat arrives with `uptimeSeconds: 0` (pipeline just started), the Uptime column will display "—" instead of "0s". The condition should check strictly for `null`/`undefined`:
```suggestion
if (seconds == null) return "\u2014";
```
How can I resolve this? If you propose a fix, please make it concise.- Replace useEffect+setState with useMemo using pipelineQuery.dataUpdatedAt as stable timestamp (satisfies both purity and set-state-in-effect rules) - Fix formatUptime to use == null instead of !seconds so uptimeSeconds: 0 displays "0s" instead of "—"
Summary
uptimeSeconds), not a hardcoded 24h windowrefetchOnWindowFocusglobally to prevent modals (VRL editor, config forms) from closing when switching browser tabsTest plan