Skip to content

fix(dashboard-v2): align projection bridge and registry - #20

Merged
github-actions[bot] merged 1 commit into
mainfrom
jonah/omn-6977-omnidash-v2
Apr 28, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
jonah/omn-6977-omnidash-v2

Conversation

@jonahgabriel

@jonahgabriel jonahgabriel commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add a /projection/:topic HTTP bridge for the v2 snapshot topics used by the dashboard widgets
  • regenerate the component registry so widget metadata points at snapshot topics instead of stale legacy /api/* routes
  • align websocket invalidation so the shared cost channel refreshes all cost widgets, not just the 2D trend view

Verification

  • npm ci
  • npm run generate:registry
  • npm run test:run -- server/routes.test.ts server/broadcast.test.ts
  • npm run check

Summary by CodeRabbit

  • New Features

    • Added dedicated projection endpoints for querying snapshot data (delegation summary, routing decisions, baselines, cost trends, quality summaries, readiness status, and recent events).
    • Integrated WebSocket live updates for real-time data synchronization across multiple dashboard panels.
  • Tests

    • Added comprehensive test coverage for projection endpoints, including response validation and error handling.
  • Chores

    • Updated component registry configuration to use new projection endpoints and live update channels.

@linear

linear Bot commented Apr 28, 2026

Copy link
Copy Markdown

OMN-6977

@coderabbitai

coderabbitai Bot commented Apr 28, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Lite

Run ID: d643dc23-4753-4287-bac4-d9b671fe0387

📥 Commits

Reviewing files that changed from the base of the PR and between accfa2a and 6b27ae1.

📒 Files selected for processing (5)
  • scripts/generate-registry.ts
  • server/routes.test.ts
  • server/routes.ts
  • src/hooks/useWebSocketInvalidation.ts
  • src/registry/component-registry.json

📝 Walkthrough

Walkthrough

The PR introduces centralized projection API endpoints and websocket invalidation topics, replacing hardcoded REST endpoints across multiple components. It adds a new /projection/:topic route that delegates to helper functions for database queries and response formatting, updates the WebSocket invalidation hook to map channels to multiple TanStack Query query keys, and modifies component registry manifests to reference the new projection-backed endpoints.

Changes

Cohort / File(s) Summary
Server Routes
server/routes.ts, server/routes.test.ts
New GET /projection/:topic endpoint introduced with helper functions encapsulating database queries and response shaping for cost trends, delegation summary, routing decisions, baselines summary, quality summary, readiness summary, and recent events. Test suite extended with coverage for projection endpoint responses, status codes, payload shapes, and error handling (404 for unknown topics).
Client State Management
src/hooks/useWebSocketInvalidation.ts
WebSocket invalidation hook refactored to map server channels to arrays of TanStack Query queryKey values. The cost-trends channel now invalidates multiple related keys (cost-trends, cost-trends-3d, cost-by-model, cost-by-model-2d), while other channels retain single-key mappings in the new structure.
Registry and Configuration
scripts/generate-registry.ts, src/registry/component-registry.json
Centralized constants added for projection API endpoints and websocket invalidation channels. Component manifests updated to consume snapshot projections via type: 'api' endpoints with corresponding optional type: 'websocket' live-update data sources. Websocket topic names standardized from generic names (delegation, llm-routing, baselines) to explicit projection topics (delegation-summary, routing-decisions, baselines-summary).

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant QueryClient as TanStack Query Client
    participant Server
    participant WebSocket as WebSocket Server
    participant Database

    Client->>QueryClient: useQuery({queryKey: ['cost-trends']})
    QueryClient->>Server: GET /projection/cost-trends
    Server->>Database: Query cost trend data
    Database-->>Server: Result
    Server-->>QueryClient: Projection response
    QueryClient-->>Client: Data displayed

    WebSocket->>WebSocket: Monitor 'cost-trends' channel
    Database->>Database: Cost trends updated
    WebSocket->>WebSocket: Publish 'cost-trends' message
    QueryClient->>QueryClient: Invalidate ['cost-trends', 'cost-trends-3d', 'cost-by-model', 'cost-by-model-2d']
    QueryClient->>Server: Refetch affected queries
    Server->>Database: Fetch updated data
    Database-->>Server: Result
    Server-->>QueryClient: Updated projections
    QueryClient-->>Client: UI refreshed with latest data
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Poem

🐰 Projections now centralized, so neat,
With websocket channels keeping queries fleet,
Routes delegate like carrots shared around,
Each component finds the endpoint it's bound,
Invalidation cascades—refresh the view!


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
github-actions Bot merged commit 3a81309 into main Apr 28, 2026
13 of 16 checks passed
@jonahgabriel

Copy link
Copy Markdown
Contributor Author

Follow-up landed on this branch in 867cd23.

This extends the initial bridge/registry repair by moving the delegation summary lane onto the event bus by default:

  • adds an in-memory task-delegated.v1 snapshot store for the v2 delegation widget shape
  • starts a kafkajs consumer from the server entrypoint to keep that summary current
  • makes /api/delegation/summary and /projection/onex.snapshot.projection.delegation.summary.v1 read the bus-backed summary first
  • keeps the old DB-backed summary behind explicit OMNIDASH_V2_ALLOW_DELEGATION_DB_FALLBACK=1 instead of a silent default

Additional verification:

  • npm run test:run -- server/routes.test.ts server/broadcast.test.ts server/delegation-snapshot-store.test.ts
  • npm run check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant