Skip to content

feat(events): add Events Panel for Litestar lifecycle tracking#9

Merged
JacobCoffee merged 6 commits intomainfrom
events-panel
Nov 29, 2025
Merged

feat(events): add Events Panel for Litestar lifecycle tracking#9
JacobCoffee merged 6 commits intomainfrom
events-panel

Conversation

@JacobCoffee
Copy link
Owner

Summary

  • Implements Phase 9.1 from PLAN.md - the Events Panel for tracking Litestar application lifecycle events and handlers
  • Adds EventsPanel class that displays lifecycle hooks, request hooks, and exception handlers
  • Integrates with middleware to automatically collect event metadata from Litestar apps
  • Includes 22 comprehensive unit tests (all passing)

Features

  • Track application lifecycle hooks (on_startup, on_shutdown)
  • Track request lifecycle hooks (before_request, after_request, after_response)
  • Display registered exception handlers with their exception types
  • Record hook execution with timing information
  • Capture call stack for failed hook executions
  • Helper functions for handler introspection

Changes

  • src/debug_toolbar/litestar/panels/events.py - New Events Panel implementation
  • src/debug_toolbar/litestar/middleware.py - Added events metadata collection
  • src/debug_toolbar/litestar/config.py - Registered Events Panel as default
  • tests/unit/test_events_panel.py - Comprehensive test suite

Test plan

  • All 22 new unit tests pass
  • Full test suite passes (254 tests)
  • Lint checks pass
  • Code formatted correctly
  • Manual testing with a Litestar app that has lifecycle hooks registered

🤖 Generated with Claude Code

Implements Phase 9.1 from PLAN.md - the Events Panel for tracking
Litestar application lifecycle events and handlers.

Features:
- Track application lifecycle hooks (on_startup, on_shutdown)
- Track request lifecycle hooks (before_request, after_request, after_response)
- Display registered exception handlers with their exception types
- Record hook execution with timing information
- Capture call stack for failed hook executions
- Helper functions for handler introspection

The panel automatically collects metadata from the Litestar app instance
during request processing and displays:
- Total number of registered hooks
- Number of hooks executed during the request
- Total execution time for hooks
- Exception handler registry

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings November 29, 2025 18:51
@github-actions
Copy link
Contributor

github-actions bot commented Nov 29, 2025

PR Preview Action v1.6.3

🚀 View preview at
https://JacobCoffee.github.io/debug-toolbar/pr-preview/pr-9/

Built to branch gh-pages at 2025-11-29 19:31 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

…ooks

- Fix Makefile to use --extra flags for optional dependencies
- Add Events Panel to advanced-alchemy example's extra_panels
- Add on_shutdown, before_request, after_request hooks for demo
- Makes the Events Panel more interesting to test

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements Phase 9.1 from the project roadmap, adding comprehensive event and lifecycle tracking capabilities to the Litestar debug toolbar. The implementation introduces a new EventsPanel that displays application lifecycle hooks, request hooks, and exception handlers with execution timing information.

Key Changes

  • New Events Panel: Displays lifecycle hooks (on_startup, on_shutdown), request hooks (before_request, after_request, after_response), and exception handlers with metadata about each handler
  • Middleware Integration: Automatically collects event metadata from Litestar applications during request processing with graceful error handling
  • Comprehensive Testing: Adds 22 unit tests covering all major functionality with good coverage of edge cases

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/debug_toolbar/litestar/panels/events.py Core implementation of the Events Panel with helper functions for handler introspection and stack frame capture
tests/unit/test_events_panel.py Comprehensive test suite covering all functions and edge cases including None handlers, lambdas, and wrapped functions
src/debug_toolbar/litestar/middleware.py Integration of events metadata collection into the middleware request processing pipeline
src/debug_toolbar/litestar/config.py Registration of the Events Panel in the default panel configuration
src/debug_toolbar/litestar/panels/__init__.py Export of EventsPanel in the panels module
src/debug_toolbar/litestar/__init__.py Export of EventsPanel in the main Litestar integration module

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

JacobCoffee and others added 2 commits November 29, 2025 12:58
- Add toolbar-events-panel.png screenshot
- Add Events Panel to "More Screenshots" section
- Add Events panel to Built-in Panels table

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add Events Panel section to panels.md
- Add Events Panel screenshot to index.md gallery

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings November 29, 2025 19:01
- Update status to Phase 9.1 COMPLETE
- Mark all Events Panel tasks as done
- Update priority matrix
- Update competitive advantages (Django signals equivalent)
- Update test count to 305

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Add `qualname` field to handler info dict for None handlers
- Add docstrings with Args/Returns to helper functions
- Remove empty TYPE_CHECKING block from test file
- Move fixture to top of test file per codebase convention
- Add qualname assertions in handler info tests
- Add tests for EventsPanel auto-addition in config
- Remove duplicate EventsPanel from example app (auto-added)
- Add type annotations to fix type checker errors

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@JacobCoffee JacobCoffee enabled auto-merge (squash) November 29, 2025 19:33
@JacobCoffee JacobCoffee merged commit 4cb8136 into main Nov 29, 2025
18 checks passed
@JacobCoffee JacobCoffee deleted the events-panel branch November 29, 2025 19:33
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