M001: Baseline Quality — TS fixes, refactoring, UI consistency, tests, performance audit#106
M001: Baseline Quality — TS fixes, refactoring, UI consistency, tests, performance audit#106TerrifiedBug merged 73 commits intomainfrom
Conversation
- src/lib/pipeline-status.ts - src/lib/format.ts - src/lib/status.ts
- src/app/(dashboard)/pipelines/page.tsx - src/app/(dashboard)/pipelines/[id]/page.tsx - src/app/(dashboard)/page.tsx - src/components/dashboard/custom-view.tsx - src/components/fleet/event-log.tsx - src/components/fleet/status-timeline.tsx - src/components/fleet/node-metrics-charts.tsx - src/components/fleet/node-logs.tsx
Split 5 over-limit files across 4 tasks: - T01: alerts page (1910 lines) → 4 section components - T02: pipeline router (1318 lines) → pipeline-graph service - T03: dashboard router (1074 lines) → dashboard-data service - T04: settings components (865/813 lines) → dialog extractions Covers R003 (file size), R007 (router→service), maintains R001/R008.
- src/server/services/pipeline-graph.ts - src/server/routers/pipeline.ts
- src/server/services/dashboard-data.ts - src/server/routers/dashboard.ts
- src/app/(dashboard)/settings/_components/team-member-dialogs.tsx - src/app/(dashboard)/settings/_components/user-management-dialogs.tsx - src/app/(dashboard)/settings/_components/team-settings.tsx - src/app/(dashboard)/settings/_components/users-settings.tsx
- src/server/services/__tests__/alert-evaluator.test.ts - src/__mocks__/lib/prisma.ts
- src/server/services/__tests__/pipeline-graph.test.ts - src/server/services/__tests__/deploy-agent.test.ts
- next.config.ts - package.json - src/app/(dashboard)/alerts/_components/alert-rules-section.tsx - src/server/routers/dashboard.ts
- .gsd/milestones/M001/slices/S05/S05-REPORT.md
These are local agent artifacts that belong in global gitignore, not in the repository. Files remain on disk.
Internal planning artifacts — should not be committed.
Greptile SummaryThis PR establishes a clean maintainability baseline across 61 source files: extracting duplicated utilities into shared modules, splitting over-target files into focused components and services, wiring consistent The large majority of the work is a faithful lift-and-shift of existing logic into new service modules (
Everything else — middleware correctness, encryption round-trips, audit patterns, team-scoping, and the performance scope fix on Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
subgraph Routers["tRPC Routers (trimmed)"]
PR[pipeline.ts\n847 lines]
DR[dashboard.ts\n652 lines]
end
subgraph Services["New Service Modules"]
PG[pipeline-graph.ts\n• saveGraphComponents\n• promotePipeline\n• discardPipelineChanges\n• detectConfigChanges\n• listPipelinesForEnvironment]
DD[dashboard-data.ts\n• computeChartMetrics\n• assembleNodeCards\n• assemblePipelineCards]
end
subgraph Libs["New Shared Libs"]
PS[lib/pipeline-status.ts\n• aggregateProcessStatus\n• derivePipelineStatus]
FMT[lib/format.ts\n• formatTime\n• formatTimeWithSeconds\n• formatTimestamp ✏️]
ST[lib/status.ts\n• STATUS_COLORS\n• statusColor]
end
subgraph UI["New Shared UI"]
ES[components/empty-state.tsx]
QE[components/query-error.tsx]
end
subgraph Tests["New Test Suite (105 tests)"]
T1[pipeline-graph.test.ts]
T2[dashboard-data.test.ts]
T3[alert-evaluator.test.ts]
T4[deploy-agent.test.ts]
T5[crypto.test.ts]
T6[totp.test.ts]
T7[pipeline-status.test.ts]
end
PR -->|delegates to| PG
DR -->|delegates to| DD
PG -->|uses| FMT
DD -->|uses| FMT
PG -.->|tested by| T1
DD -.->|tested by| T2
PS -.->|tested by| T7
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/server/services/pipeline-graph.ts
Line: 525-526
Comment:
**`detectConfigChanges` returns `true` for a null version — behavioral change from original**
The original `pipeline.list` logic in the router treated a missing `latestVersion` as _no changes_ (`hasUndeployedChanges` was left `false`). The extracted `detectConfigChanges` now returns `true` when `latestVersion` is `null`:
```typescript
if (!latestVersion) return true;
```
This means a deployed pipeline that somehow has no version records will now surface as "has undeployed changes" rather than "no changes". While this edge case shouldn't occur in normal operation (deploying always creates a version), it is a silent behavioral regression from the original code introduced during the refactoring.
If the intent is to keep parity with the pre-refactor behavior, the caller in `listPipelinesForEnvironment` should guard the call:
```typescript
hasUndeployedChanges = latestVersion
? detectConfigChanges({ ..., latestVersion: { ... } })
: false;
```
Alternatively, add a comment to `detectConfigChanges` noting that the `null` → `true` behavior is intentional (the more conservative "no snapshot means state is unknown").
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "chore: remove .planning/ from git tracki..." | Re-trigger Greptile |
| updatedAt: true, | ||
| globalConfig: true, |
There was a problem hiding this comment.
detectConfigChanges returns true for a null version — behavioral change from original
The original pipeline.list logic in the router treated a missing latestVersion as no changes (hasUndeployedChanges was left false). The extracted detectConfigChanges now returns true when latestVersion is null:
if (!latestVersion) return true;This means a deployed pipeline that somehow has no version records will now surface as "has undeployed changes" rather than "no changes". While this edge case shouldn't occur in normal operation (deploying always creates a version), it is a silent behavioral regression from the original code introduced during the refactoring.
If the intent is to keep parity with the pre-refactor behavior, the caller in listPipelinesForEnvironment should guard the call:
hasUndeployedChanges = latestVersion
? detectConfigChanges({ ..., latestVersion: { ... } })
: false;Alternatively, add a comment to detectConfigChanges noting that the null → true behavior is intentional (the more conservative "no snapshot means state is unknown").
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/server/services/pipeline-graph.ts
Line: 525-526
Comment:
**`detectConfigChanges` returns `true` for a null version — behavioral change from original**
The original `pipeline.list` logic in the router treated a missing `latestVersion` as _no changes_ (`hasUndeployedChanges` was left `false`). The extracted `detectConfigChanges` now returns `true` when `latestVersion` is `null`:
```typescript
if (!latestVersion) return true;
```
This means a deployed pipeline that somehow has no version records will now surface as "has undeployed changes" rather than "no changes". While this edge case shouldn't occur in normal operation (deploying always creates a version), it is a silent behavioral regression from the original code introduced during the refactoring.
If the intent is to keep parity with the pre-refactor behavior, the caller in `listPipelinesForEnvironment` should guard the call:
```typescript
hasUndeployedChanges = latestVersion
? detectConfigChanges({ ..., latestVersion: { ... } })
: false;
```
Alternatively, add a comment to `detectConfigChanges` noting that the `null` → `true` behavior is intentional (the more conservative "no snapshot means state is unknown").
How can I resolve this? If you propose a fix, please make it concise.
Summary
Establishes a clean, maintainable codebase baseline before building new features.
What Changed
S01: TypeScript Fixes & Shared Utilities
src/lib/pipeline-status.ts,src/lib/format.ts,src/lib/status.ts)S02: Router & Component Refactoring
pipeline-graph.ts(5 exports),dashboard-data.ts(3 exports)S03: UI Consistency Sweep
EmptyStateandQueryErrorcomponentsborder-dashedempty state patterns remainS04: Foundational Test Suite
S05: Performance Audit & Optimization
@next/bundle-analyzerimport typefor enums)allComponentNodesquery to user pipeline IDs (eliminates full-table scan)Cleanup
.gsd/and.bg-shell/agent artifacts from git tracking (belong in global gitignore)Verification
tsc --noEmiteslint src/pnpm test(105 tests)Stats
.gsd/cleanup)