Skip to content

feat: implement true AI callbacks to summarize log/trace/pattern#2108

Draft
alex-fedotyev wants to merge 6 commits intomainfrom
cursor/ai-summarize-real-2405
Draft

feat: implement true AI callbacks to summarize log/trace/pattern#2108
alex-fedotyev wants to merge 6 commits intomainfrom
cursor/ai-summarize-real-2405

Conversation

@alex-fedotyev
Copy link
Copy Markdown
Contributor

Summary

Replaces the April Fools Easter egg "AI Summarize" feature with real LLM-powered summarization while preserving the Easter egg as a fallback when no AI provider is configured.

When AI is enabled (AI_API_KEY or ANTHROPIC_API_KEY set):

  • The Summarize button is always visible (not gated by Easter egg dates)
  • Clicking it calls POST /ai/summarize which uses the configured LLM to generate a concise, actionable 2-4 sentence summary
  • Supports both individual events and log patterns with tailored system prompts
  • Shows error messages gracefully on provider failures
  • Users can dismiss the button via "Don't show" link

When AI is not enabled (fallback):

  • The existing Easter egg behavior is preserved (themed summaries, info popover, time-gated visibility)
  • Users can still dismiss via the popover's "Don't show again" link

Changes

Backend (packages/api):

  • POST /ai/summarize endpoint accepting { type: 'event' | 'pattern', content: string }
  • Uses generateText with the configured AI model and type-specific system prompts
  • Proper error handling for APICallError

Frontend (packages/app):

  • useAISummarize hook wrapping the new endpoint
  • AISummarizeButton and AISummarizePatternButton check aiAssistantEnabled from /me to choose real AI vs fallback
  • formatEventContent / formatPatternContent extract structured text from row data / patterns for the LLM prompt
  • AISummaryPanel supports both modes: no theme label or April Fools popover in real AI mode

Screenshots or video

UI changes are minimal — the Summarize button behavior changes based on AI configuration. No visual layout changes.

How to test locally or on Vercel

  1. Without AI key (Easter egg fallback): Start the dev stack without AI_API_KEY / ANTHROPIC_API_KEY. Navigate to the search page, click a log row, and click "Summarize". Should show themed Easter egg summary.
  2. With AI key (real AI): Set AI_PROVIDER=anthropic and AI_API_KEY=<your-key> in .env, restart the API. Click "Summarize" on a log row — should call the LLM and return a real summary.
  3. Dismiss: Click "Don't show" next to the Summarize button — it should disappear for that component instance.

References

  • Linear Issue: HDX-3992
Open in Web Open in Cursor 

cursoragent and others added 2 commits April 11, 2026 02:30
- Add POST /ai/summarize endpoint that uses the configured LLM to generate
  concise, actionable summaries for individual events and patterns
- Add useAISummarize hook in the frontend to call the new endpoint
- Update AISummarizeButton and AISummarizePatternButton to use real AI
  when aiAssistantEnabled is true, falling back to the Easter egg themes
  when no AI provider is configured
- Update AISummaryPanel to support both real AI and Easter egg display
  modes (no info popover / dismiss for real AI, no italic theme label)

HDX-3992

Co-authored-by: Alex Fedotyev <alex-fedotyev@users.noreply.github.com>
- Export formatEventContent/formatPatternContent for testability
- Always show 'Don't show' link (both real AI and easter egg modes)
- Real AI: visible always (not gated by easter egg dates)
- Easter egg: still uses dismissEasterEgg() for localStorage persistence
- AISummaryPanel: show 'Don't show' link in collapsed state for easy
  dismissal, remove April Fools popover in real AI mode

Tests (42 new):
- formatEventContent: 9 tests covering all field extraction paths
- formatPatternContent: 3 tests for pattern/samples formatting
- AISummarizeButton: 10 tests (real AI, fake AI, dismiss, error, toggle)
- AISummarizePatternButton: 5 tests (visibility, AI/fallback, dismiss)
- AISummaryPanel: 8 tests (dismiss, error, theme label, real vs fake)
- POST /ai/summarize: 7 tests (validation, prompts, error handling)

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

changeset-bot bot commented Apr 11, 2026

⚠️ No Changeset found

Latest commit: d4a48a5

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 11, 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 15, 2026 3:23am

Request Review

The Pattern type requires an 'id' field. Added it to all test
fixtures to fix the CI TypeScript check.

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

github-actions bot commented Apr 11, 2026

E2E Test Results

All tests passed • 132 passed • 3 skipped • 1015s

Status Count
✅ Passed 132
❌ Failed 0
⚠️ Flaky 1
⏭️ Skipped 3

Tests ran across 4 shards in parallel.

View full report →

SampleLog requires __hdx_timestamp alongside __hdx_pattern_field.
Added the missing field and used proper Pattern typing throughout.

Co-authored-by: Alex Fedotyev <alex-fedotyev@users.noreply.github.com>
…own output

- Enrich trace summaries with full trace context (span groups with
  count/sum/p50 durations, error spans with details)
- Add tone/style picker (noir, attenborough, shakespeare) gated behind
  ?smart=true — persisted in localStorage, auto-regenerates on change
- Render AI output as markdown with highlighted key details
- Improve prompts: terse for healthy events, focused for errors
- Enrich pattern summaries with sample attributes
- Add env-local-preload.js so .env.development.local overrides work
- Fix react-markdown ESM mock for Jest
- Make trace span fetch lazy (only when user clicks Summarize)
- Filter __hdx_ internal keys from pattern sample attributes
- Add bounds clamp to percentile calculation
- Cap trace context output at 4KB to stay within content limits
- Fix stale test assertions for rewritten prompts
- Remove stale comment in AISummaryPanel
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.

2 participants