feat: implement true AI callbacks to summarize log/trace/pattern#2108
Draft
alex-fedotyev wants to merge 6 commits intomainfrom
Draft
feat: implement true AI callbacks to summarize log/trace/pattern#2108alex-fedotyev wants to merge 6 commits intomainfrom
alex-fedotyev wants to merge 6 commits intomainfrom
Conversation
- 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>
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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>
Contributor
E2E Test Results✅ All tests passed • 132 passed • 3 skipped • 1015s
Tests ran across 4 shards in parallel. |
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_KEYorANTHROPIC_API_KEYset):POST /ai/summarizewhich uses the configured LLM to generate a concise, actionable 2-4 sentence summaryWhen AI is not enabled (fallback):
Changes
Backend (
packages/api):POST /ai/summarizeendpoint accepting{ type: 'event' | 'pattern', content: string }generateTextwith the configured AI model and type-specific system promptsAPICallErrorFrontend (
packages/app):useAISummarizehook wrapping the new endpointAISummarizeButtonandAISummarizePatternButtoncheckaiAssistantEnabledfrom/meto choose real AI vs fallbackformatEventContent/formatPatternContentextract structured text from row data / patterns for the LLM promptAISummaryPanelsupports both modes: no theme label or April Fools popover in real AI modeScreenshots 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
AI_API_KEY/ANTHROPIC_API_KEY. Navigate to the search page, click a log row, and click "Summarize". Should show themed Easter egg summary.AI_PROVIDER=anthropicandAI_API_KEY=<your-key>in.env, restart the API. Click "Summarize" on a log row — should call the LLM and return a real summary.References