Libra CodeHub

CedarCopilot/cedar-mail

Branch: staging

feat: canvas metrics bar, chat stream listener, and CRM deal-age fixes

merged#2496CedarCopilot

CedarCopilot wants to merge 0 commits into staging from feat/canvas-metrics-bar

Live on prod, no production signal yetTimeline and evidence
  1. Opened
    Aug 15, 2026, 1:45 PM
  2. Merged
    Aug 15, 2026, 7:50 PM
  3. Live on staging
    Aug 15, 2026, 7:50 PM
  4. Live on prod
    Aug 15, 2026, 7:50 PM
  5. Observed 2 days
    Aug 15, 2026, 7:50 PM
  6. Pipelines steady after this deploy
    Aug 15, 2026, 7:50 PM
  7. Pipelines steady after this deploy
    Aug 15, 2026, 7:50 PM
  8. Unobserved

    Live on prod, no production signal yet

    Aug 18, 2026, 2:58 PM

Behaviors Libra is checking

Conversation canvases can display configurable roll-up tiles for deal count, amounts, weighted/open/closed/new amounts, and average deal age above their rows.Inconclusivelow confidence

OTEL fallback found no prod spans matching ConversationCanvas / crm.aggregateConversations since deploy.

prod, checked Aug 18, 2026, 11:24 AM
Users can choose cumulative metrics from the Fields popover, retain them in canonical order, hide the bar by deselecting all metrics, and collapse or expand it without losing the selection.Inconclusivelow confidence

OTEL fallback found no prod spans matching ConversationCanvas Fields popover / canvas viewConfig since deploy.

prod, checked Aug 18, 2026, 12:24 PM
Canvas metric tiles use the exact same filters, relative-date resolution, pinned conversation set, and refresh cadence as the table they summarize.Inconclusivemedium confidence

Since 2026-08-16T02:50:39Z, no OTEL spans, tRPC routes, or span attributes identified crm.aggregateConversations (0 matching rows), and CloudWatch yielded no concrete aggregate-operation or metric/table-mismatch signal. In the same window, crm.listConversations had 9.

prod, checked Aug 18, 2026, 1:24 PM
Metric tiles distinguish unavailable values from zero and disclose when a value is calculated from fewer deals than the displayed total.Inconclusivehigh confidence

Since 2026-08-16T02:50:39Z, production telemetry returned 0 spans matching crm.aggregateConversations/aggregateConversations and 0 CloudWatch log lines matching aggregateConversations, aggregate conversations, or populatedCount. A broader aggregate telemetry search found only.

prod, checked Aug 18, 2026, 2:24 PM
The chat client records delivered SSE event IDs and sends Last-Event-ID when reconnecting so it replays only missed output and does not duplicate an in-progress generation.Inconclusivelow confidence

Only 2 prod OTEL spans matching POST /api/trpc/mastra.chatStream reached Libra since the deploy, below the 20-span floor for calling a change verified. Nothing is failing; there is not yet enough traffic to confirm it.

prod, checked Aug 18, 2026, 2:24 PM
A chat reply that is still generating resumes in the same thread after a page reload or dropped client connection instead of appearing blank until persistence completes.Inconclusivelow confidence

Only 1 prod OTEL span matching POST /api/trpc/mastra.chatStream reached Libra since the deploy, below the 20-span floor for calling a change verified. Nothing is failing; there is not yet enough traffic to confirm it.

prod, checked Aug 18, 2026, 2:57 PM

Failures attributed to this change

No prod customers are affected while this is only in staging. If promoted, customer impact is not proven from the retained evidence. 1 hit · no retained affected-user count · no retained trace sample.Introducedmedium confidence

single_user

staging, first seen Aug 16, 2026, 6:51 PM

Libra has verdicts on 0 of 7 tracked behaviors on prod; 7 are still being checked. Libra checks hourly for 3 days after each deploy.

Summary

Three independent threads that accumulated on this branch:

Canvas metrics bar (phases 4,5 of pipeline-tabs-and-canvas-aggregates)

  • viewConfig.summaries on the canvas schema + a useCanvasAggregates hook backed by a new crm tRPC field.
  • CanvasMetricsBar renders the configured cumulative tiles above the canvas.
  • Tile picker lives in the Fields popover (CumulativeFieldsSection), collapsed behind a toggle so it doesn't crowd the default popover.
  • Split use-canvas-list-variables.ts out of use-canvas-conversations.ts (that file was doing two unrelated jobs).

Chat SSE: listener instead of a poll

  • The Upstash REST client can't express a blocking read, so the chat relay polled every 200ms , one billable request per glance, which exhausted the 500k quota on 2026-08-14.
  • Adds an optional REDIS_TCP_URL (TCP endpoint for the same database). Set it and chat streams over XREAD BLOCK; leave it unset and the existing REST polling path runs completely unchanged.
  • createBlockingTcpClient() hands out one dedicated connection per in-flight reader, capped at 64 , past the cap callers fall back to polling rather than failing.
  • An error listener is attached on every TCP client: an EventEmitter without one rethrows, so a bad REDIS_TCP_URL would have taken the process down instead of degrading to REST.
  • Design notes in apps/server/docs/design/chat-stream-listener.md.

CRM deal age + discovery since

  • Deal age is measured from the CRM create date rather than the Cedar row's, so backsynced deals stop reading as brand new.
  • Exposes the discovery since override with a headless verb on the crm-admin CLI.

Test plan

  • pnpm run autofix:local , oxlint, deps:check, paraglide compile, and the Jest mail suite all green. The server vitest run reported 5807 passed / 6 failed, every failure a 30s beforeEach hook timeout in the PGlite outbound harness (worker starvation under full-suite parallelism on a loaded local machine).
  • Re-ran that area scoped to confirm: pnpm --filter @zero/server exec vitest run src/services/outbound/73 files / 302 tests passed, 0 failed. No outbound code is touched by this branch.
  • New coverage: chat-stream-listen.test.ts, chat-stream-writer.test.ts, chat-stream-store.test.ts updates, canvas-view-config-persistence.test.ts, deal-link-metrics.test.ts.
  • Merged fresh origin/staging before pushing (clean merge).

🤖 Generated with Claude Code

Greptile Summary

The PR adds configurable canvas aggregate tiles, an optional TCP-backed Redis listener for chat streams, and CRM deal-discovery and age corrections. It also makes the stage-tab recovery script transactional.

  • Adds shared canvas-list filter derivation, a server aggregate procedure, metrics UI, and persisted summary configuration.
  • Introduces dedicated blocking Redis readers with REST compatibility for chat streaming.
  • Adds CRM discovery CLI support and uses provider creation dates for deal-age metrics.
  • Seeds metrics on Reform stage tabs within an atomic rebuild.

Confidence Score: 3/5

The PR is not safe to merge until capped chat listeners fall back to polling and pinned canvases pass their pinned IDs into aggregate queries.

Under blocking-client saturation, chat SSE responses can close without content, while pinned conversation canvases can render aggregate totals for a broader deal set than the visible rows.

Files Needing Attention: apps/server/src/mastra/routeHandlers/chat/handleChat.ts; apps/mail/modules/crm/hooks/use-canvas-aggregates.ts

Important Files Changed

FilenameOverview
apps/server/src/mastra/routeHandlers/chat/handleChat.tsSelects the TCP stream listener but omits the required REST fallback when capped client acquisition returns null.
apps/server/src/services/chat/chat-stream-listen.tsImplements bounded blocking stream reads and
Show production surfaces and changed-file mapping

Production surfaces

Libra has not measured any production surfaces for this change yet.

Changed files → surfaces

  • apps/mail/docs/pipeline-tabs-and-canvas-aggregates.mdno production surface mapped
  • apps/mail/modules/canvas/types/canvas-types.tsno production surface mapped
  • apps/mail/modules/cedar-os/src/cedar-os-components/chatComponents/EmbeddedCedarChat.tsxno production surface mapped
  • apps/mail/modules/cedar-os/src/store/agentConnection/agentConnectionSlice.tsno production surface mapped
  • apps/mail/modules/cedar-os/src/store/agentConnection/agentUtils.tsno production surface mapped
  • apps/mail/modules/cedar-os/src/store/agentConnection/providers/mastra.tsno production surface mapped
  • apps/mail/modules/crm/components/conversation-canvas/CanvasMetricsBar.tsxno production surface mapped
  • apps/mail/modules/crm/components/conversation-canvas/ConversationCanvas.tsxno production surface mapped
  • apps/mail/modules/crm/components/conversation-canvas/CumulativeFieldsSection.tsxno production surface mapped
  • apps/mail/modules/crm/components/conversation-canvas/FilterSortConfigurationRow.tsxno production surface mapped
  • apps/mail/modules/crm/hooks/use-canvas-aggregates.tsno production surface mapped
  • apps/mail/modules/crm/hooks/use-canvas-conversations.tsno production surface mapped
  • apps/mail/modules/crm/hooks/use-canvas-list-variables.tsno production surface mapped
  • apps/mail/modules/store/index.tsno production surface mapped
  • apps/mail/tests/modules/canvas/canvas-view-config-persistence.test.tsno production surface mapped
  • apps/server/docs/design/chat-stream-listener.mdno production surface mapped
  • apps/server/package.jsonno production surface mapped
  • apps/server/src/crm-admin/cli.tsno production surface mapped
  • apps/server/src/db/canvas-schema.tsno production surface mapped
  • apps/server/src/db/migrations/scripts/account-setup/reform-brock-stage-tabs.tsno production surface mapped
  • apps/server/src/env.tsno production surface mapped
  • apps/server/src/lib/services.tsno production surface mapped
  • apps/server/src/mastra/routeHandlers/chat/handleChat.tsno production surface mapped
  • apps/server/src/services/chat/chat-stream-listen.test.tsno production surface mapped
  • apps/server/src/services/chat/chat-stream-listen.tsno production surface mapped
  • apps/server/src/services/chat/chat-stream-store.test.tsno production surface mapped
  • apps/server/src/services/chat/chat-stream-store.tsno production surface mapped
  • apps/server/src/services/chat/chat-stream-writer.test.tsno production surface mapped
  • apps/server/src/services/chat/chat-stream-writer.tsno production surface mapped
  • apps/server/src/services/crm/conversation-aggregates.tsno production surface mapped
  • apps/server/src/trpc/routes/crm.tsno production surface mapped
  • aws/lib/runtime-contract.tsno production surface mapped
  • pnpm-lock.yamlno production surface mapped