Skip to content

fix: replace stale activity cards with live alerts - #8

Merged
svg8bit merged 1 commit into
mainfrom
codex/fix-live-alerts
Aug 11, 2026
Merged

fix: replace stale activity cards with live alerts#8
svg8bit merged 1 commit into
mainfrom
codex/fix-live-alerts

Conversation

@svg8bit

@svg8bit svg8bit commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • stop turning rolling 7-day price changes into fake now activity cards
  • emit odds alerts only for newly observed >=2 percentage-point changes between fresh feed snapshots
  • monitor the top 60 map events for recent large trades instead of only weekly movers
  • bound Polymarket trade queries to the 15-minute alert TTL and refresh stale initial map feeds immediately

Verification

  • npm run check
  • npm run test:e2e — 21 passed
  • npm audit --audit-level=moderate — 0 vulnerabilities
  • production-like local activity request across 60 events — HTTP 200 in 0.30s and returned a timestamped live trade
  • staged high-signal secret scan — 0 findings

Summary by CodeRabbit

  • New Features

    • Activity updates now highlight newly observed odds changes and significant trades across live events.
    • Live activity includes a broader set of eligible events for more complete coverage.
  • Bug Fixes

    • Stale conflict-map data now refreshes immediately instead of waiting for the next interval.
    • Activity notices no longer appear for outdated, invalid, or unchanged data.
    • Feed refresh timing now more accurately reflects the latest available information.
  • Tests

    • Added coverage for live activity updates, stale-feed refreshes, and time-bounded activity results.

@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
oddsfront Ready Ready Preview Aug 11, 2026 8:42am

Request Review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e31acdc7-a8d5-4b25-96f9-99639273ac01

📥 Commits

Reviewing files that changed from the base of the PR and between f9db510 and 835ec70.

📒 Files selected for processing (6)
  • app/api/global-conflict-activity/route.ts
  • features/global-conflict-map/preview/activity-rail.tsx
  • features/global-conflict-map/preview/conflict-map-preview.tsx
  • lib/polymarket-activity-query.ts
  • tests/global-conflict-map-preview.spec.ts
  • tests/polymarket-activity-query.spec.ts

📝 Walkthrough

Walkthrough

The change centralizes Polymarket activity queries, updates activity filtering and cache expiry, detects odds changes between live snapshots, and refreshes stale conflict feeds immediately.

Changes

Conflict activity flow

Layer / File(s) Summary
Polymarket query contract and API route
lib/polymarket-activity-query.ts, app/api/global-conflict-activity/route.ts, tests/polymarket-activity-query.spec.ts
Adds shared Polymarket query constants and URL construction. The activity route uses bounded time windows, shared thresholds, a six-second timeout, versioned cache keys, and shared expiry metadata. Tests verify URL parameters and event ID normalization.
Live snapshot notices and refresh scheduling
features/global-conflict-map/preview/activity-rail.tsx, features/global-conflict-map/preview/conflict-map-preview.tsx, tests/global-conflict-map-preview.spec.ts
Compares successive live snapshots for odds changes and volume thresholds. Activity requests include valid event IDs. Feed refreshes use payload timestamps and immediately refresh stale feeds. Tests cover live updates, activity dismissal, and stale-feed recovery.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ConflictMapPreview
  participant ActivityRail
  participant GlobalConflictActivityRoute
  participant PolymarketTradesAPI
  ConflictMapPreview->>ActivityRail: provide refreshed live feed snapshot
  ActivityRail->>ActivityRail: compare current and previous snapshots
  ActivityRail->>GlobalConflictActivityRoute: request activity for valid event IDs
  GlobalConflictActivityRoute->>PolymarketTradesAPI: query bounded trade activity
  PolymarketTradesAPI-->>GlobalConflictActivityRoute: return matching trades
  GlobalConflictActivityRoute-->>ActivityRail: return activity items
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes replacing stale activity cards with live alerts, which matches the primary changes.
Description check ✅ Passed The description clearly covers the changes and verification, but it omits the template's required Safety section.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-live-alerts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@svg8bit
svg8bit merged commit 0e1c3fb into main Aug 11, 2026
6 checks passed
@svg8bit
svg8bit deleted the codex/fix-live-alerts branch August 11, 2026 08:46

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 835ec70750

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +125 to +127
const previousEvent = previousEvents.get(event.id);
if (!previousEvent) continue;
const change = event.yesOdds - previousEvent.yesOdds;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Verify the selected market before comparing odds

When a Gamma event contains multiple markets, normalizeConflictPreviewEvent can retain the same aggregate polymarket-${event.id} while selecting a different market because volume ordering changes or the previous market closes. Looking up the baseline only by that aggregate ID then subtracts odds belonging to different questions, producing a misleading live odds alert. Preserve a market-level identifier in the feed or otherwise confirm the selected market is unchanged before calculating the difference.

Useful? React with 👍 / 👎.

Comment on lines +259 to +260
const baseline = previousFeed.current;
previousFeed.current = feed;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the newest snapshot as the comparison baseline

When the browser or CDN's stale-while-revalidate cache returns an older live payload after a newer SSR or client payload, this assignment replaces the baseline even though snapshotMoverNotices rejects the out-of-order timestamp. The next fresh response is consequently compared with the older odds and can re-emit an already observed or cumulative change as happening now. Only advance the stored baseline when the incoming updatedAt is newer.

Useful? React with 👍 / 👎.

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