Skip to content

Fix runaway Convex demo dashboard reads - #72

Open
bryanlin850 wants to merge 2 commits into
raroque:mainfrom
bryanlin850:codex/fix-convex-demo-read-amplification
Open

Fix runaway Convex demo dashboard reads#72
bryanlin850 wants to merge 2 commits into
raroque:mainfrom
bryanlin850:codex/fix-convex-demo-read-amplification

Conversation

@bryanlin850

Copy link
Copy Markdown

Summary

  • Replace the reactive demo-status scans across ten tables with two settings reads, persisting seeded counts when demo data changes.
  • Load dashboard metrics as an explicit refreshable snapshot instead of keeping a live subscription open.
  • Stop memory-record scans as soon as enough matching rows are found, with bounded scan work and normalized fractional limits.
  • Preserve safe UI behavior for legacy deployments that do not have a persisted demo summary yet.

Why

The debug dashboard's reactive demo-status query repeatedly scanned operational tables after writes. On an active development deployment, this caused excessive Convex function calls and database reads even when the dashboard only needed a small status summary.

Validation

  • npm run typecheck
  • npm test — 16 test files, 73 tests
  • npm run build:debug

Scope

Two commits and six files, all specific to the Convex demo/dashboard read-amplification fix. No fork-only application changes are included.

@greptile-apps

greptile-apps Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Replace reactive, scan-heavy dashboard queries with persisted demo summaries and explicitly refreshed snapshots.

  • Persist demo row counts whenever demo mode is reseeded or cleared.
  • Bound memory-record scans and normalize fractional or invalid limits.
  • Add dashboard snapshot refresh, loading, error, and last-updated states.
  • Preserve legacy demo-status behavior when persisted counts are unavailable.

Confidence Score: 5/5

The PR appears safe to merge with no concrete correctness or security failures identified.

The persisted demo summary is maintained by the sole demo seed and teardown mutation, existing memory-list callers retain equivalent behavior, and dashboard snapshot races and failures are handled with request guards and explicit retry controls.

Important Files Changed

Filename Overview
convex/demo.ts Replaces repeated operational-table status scans with an atomically maintained settings-backed demo summary and a legacy-safe fallback.
convex/memoryRecordLimits.ts Adds deterministic normalization and clamping for optional memory-list limits.
convex/memoryRecords.ts Stops ordered memory scans after collecting the requested matches or reaching the existing scan bound.
debug/src/components/DashboardPanel.tsx Replaces the live metrics subscription with a guarded, manually refreshable snapshot and explicit loading/error states.
debug/src/components/SettingsPanel.tsx Handles unavailable legacy demo counts without presenting them as zero.
test/memory-record-limits.test.ts Covers fractional, default, negative, infinite, and NaN limit normalization.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Demo mode mutation] --> B[Delete existing demo rows]
    B --> C{Enable demo mode?}
    C -->|Yes| D[Seed demo rows]
    C -->|No| E[Use zero counts]
    D --> F[Persist demo count summary]
    E --> F
    F --> G[Persist enabled setting]
    G --> H[Status reads two settings rows]
    I[Dashboard mounts or user refreshes] --> J[Run one-shot metrics query]
    J --> K[Render snapshot and timestamp]
Loading

Reviews (1): Last reviewed commit: "fix: normalize memory dashboard limits" | Re-trigger Greptile

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