Skip to content

Implement real AI summarize callbacks with smart tone mode#2100

Closed
alex-fedotyev wants to merge 13 commits intomainfrom
cursor/ai-true-summarize-callbacks-e018
Closed

Implement real AI summarize callbacks with smart tone mode#2100
alex-fedotyev wants to merge 13 commits intomainfrom
cursor/ai-true-summarize-callbacks-e018

Conversation

@alex-fedotyev
Copy link
Copy Markdown
Contributor

@alex-fedotyev alex-fedotyev commented Apr 10, 2026

Summary

Replace the April Fools local summary generator with real AI summarize callbacks for event, pattern, and trace contexts, while enforcing token-aware context compaction and robust provider error handling.

  • Added backend summarize pipeline at POST /ai/summarize (reusing existing AI provider/model setup from chart assistant):
    • strict typed validation per summary kind (event | pattern | trace)
    • bounded payload compaction before prompting
    • concise, action-oriented prompt templates with trace-specific prioritization (errors + critical path)
    • provider/API error handling consistent with existing AI routes
  • Migrated summary UI from local phrase templates to backend callbacks:
    • event side panel summary
    • pattern side panel summary
    • trace tab summary (new button)
  • Implemented smart-mode style behavior exactly as requested:
    • default prompt/tone always when ?smart=true is absent
    • style selector only appears when ?smart=true
    • style choice persists in localStorage for subsequent summaries in smart mode
  • Removed obsolete April Fools generator files and wiring.
  • Addressed CI Knip findings by removing unused exports.

Screenshots or video

Before After

How to test locally or on Vercel

  1. Configure AI env vars (same as chart assistant), start app/api.
  2. Open an event side panel and click Summarize; confirm AI summary returns.
  3. Open a pattern side panel and click Summarize; confirm summary uses pattern sample/stat context.
  4. Open trace tab and click Summarize; confirm summary includes error and critical-path context.
  5. Without ?smart=true, verify no style selector and outgoing tone is default.
  6. With ?smart=true, select Detective Noir, summarize, refresh, and verify style persistence.

References

Linear Issue: HDX-3992

Open in Web Open in Cursor 

Co-authored-by: Alex Fedotyev <alex-fedotyev@users.noreply.github.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 10, 2026

⚠️ No Changeset found

Latest commit: a8f30c2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 10, 2026

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

Project Deployment Actions Updated (UTC)
hyperdx-oss Ready Ready Preview, Comment Apr 11, 2026 2:15am

Request Review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 10, 2026

E2E Test Results

All tests passed • 129 passed • 3 skipped • 1071s

Status Count
✅ Passed 129
❌ Failed 0
⚠️ Flaky 4
⏭️ Skipped 3

Tests ran across 4 shards in parallel.

View full report →

Co-authored-by: Alex Fedotyev <alex-fedotyev@users.noreply.github.com>
Co-authored-by: Alex Fedotyev <alex-fedotyev@users.noreply.github.com>
Co-authored-by: Alex Fedotyev <alex-fedotyev@users.noreply.github.com>
Co-authored-by: Alex Fedotyev <alex-fedotyev@users.noreply.github.com>
Co-authored-by: Alex Fedotyev <alex-fedotyev@users.noreply.github.com>
Co-authored-by: Alex Fedotyev <alex-fedotyev@users.noreply.github.com>
cursoragent and others added 2 commits April 11, 2026 00:42
Co-authored-by: Alex Fedotyev <alex-fedotyev@users.noreply.github.com>
Co-authored-by: Alex Fedotyev <alex-fedotyev@users.noreply.github.com>
Co-authored-by: Alex Fedotyev <alex-fedotyev@users.noreply.github.com>
Co-authored-by: Alex Fedotyev <alex-fedotyev@users.noreply.github.com>
@alex-fedotyev alex-fedotyev marked this pull request as ready for review April 11, 2026 01:13
@github-actions github-actions Bot added the review/tier-4 Critical — deep review + domain expert sign-off label Apr 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 11, 2026

🔴 Tier 4 — Critical

Touches auth, data models, config, tasks, OTel pipeline, ClickHouse, or CI/CD.

Why this tier:

  • Large diff: 2699 lines changed (threshold: 1000)

Additional context: touches API routes or data models

Review process: Deep review from a domain expert. Synchronous walkthrough may be required.
SLA: Schedule synchronous review within 2 business days.

Stats
  • Files changed: 21
  • Lines changed: 2699 (+ 349 in test files, excluded from tier calculation)
  • Branch: cursor/ai-true-summarize-callbacks-e018
  • Author: alex-fedotyev

To override this classification, remove the review/tier-4 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 11, 2026

PR Review

  • ⚠️ computeCriticalPath DFS has no cycle detection (requestBuilders.ts) → The memoization only prevents re-entering a key after it's been set, but memo.set happens after all children are visited. Cycles like A→B→A will cause infinite recursion and a browser tab crash. Add a visiting set and skip nodes already in the active call stack.

  • ⚠️ No rate limiting on /ai/summarize → A rate limiter utility already exists (packages/api/src/utils/rateLimiter.ts) but isn't applied here (or on /assistant). Authenticated users can spam this endpoint to amplify AI provider costs. Consider applying the existing rateLimiter to both AI routes.

  • ⚠️ AISummarizeTraceButton always fetches trace rows (AISummarizeTraceButton.tsx:62-80) → enabled: true causes useEventsAroundFocus to fire on every trace panel render, not just when the user clicks summarize. This duplicates queries already made by DBTraceWaterfallChartContainer. Change to enabled: isOpen || isGenerating or derive rows lazily.

  • ℹ️ Redundant alias (ai.ts:26) → const summaryBodySchema = AISummaryRequestSchema; is unused indirection — use AISummaryRequestSchema directly in validateRequest.

Co-authored-by: Alex Fedotyev <alex-fedotyev@users.noreply.github.com>
Co-authored-by: Alex Fedotyev <alex-fedotyev@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review/tier-4 Critical — deep review + domain expert sign-off

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants