Skip to content

feat(ui): Phase 5 - Complete toolbar UI with themes, positioning, and history#4

Merged
JacobCoffee merged 18 commits intomainfrom
phase-5-ui
Nov 27, 2025
Merged

feat(ui): Phase 5 - Complete toolbar UI with themes, positioning, and history#4
JacobCoffee merged 18 commits intomainfrom
phase-5-ui

Conversation

@JacobCoffee
Copy link
Owner

Summary

Complete Phase 5 UI/UX implementation for the debug toolbar:

  • Toolbar UI routes (/_debug_toolbar/) with history and detail views
  • Dark/light theme toggle with localStorage persistence across all pages
  • 4-position toolbar (left/right/top/bottom) with persistence
  • Resizable toolbar with drag handles and size persistence
  • Panel animations with smooth CSS transitions
  • SQLAlchemy auto-attach - queries now captured without explicit engine config
  • Routes panel - displays all registered app routes
  • Improved data rendering - nested objects/arrays display properly

New Files

  • src/debug_toolbar/litestar/routes/handlers.py - Toolbar UI routes, CSS, JS
  • tests/integration/test_toolbar_routes.py - 20 comprehensive route tests
  • biome.json / package.json - Frontend linting with Biome.js

Changes

  • Plugin now registers toolbar routes automatically
  • Middleware accepts shared toolbar instance
  • SQLAlchemy panel auto-attaches global event listeners
  • Examples updated with UI documentation and async fixes

Test plan

  • All 264 tests passing
  • Manual testing of theme toggle on all pages
  • Manual testing of positioning controls
  • Manual testing of resize functionality
  • Manual testing of panel expand/collapse animations
  • SQLAlchemy query capture verified
  • Routes panel displays app routes

Screenshots

Theme toggle, positioning, and resize all work across:

  • Inline toolbar on app pages
  • /_debug_toolbar/ history page
  • /_debug_toolbar/{request_id} detail page

🤖 Generated with Claude Code

JacobCoffee and others added 16 commits November 27, 2025 01:20
- Add routes/__init__.py module for route registration
- Create handlers.py with full route implementation:
  - GET /_debug_toolbar/ - Request history page
  - GET /_debug_toolbar/{id} - Request detail page
  - GET /_debug_toolbar/api/requests - JSON API for requests
  - GET /_debug_toolbar/api/requests/{id} - JSON API for single request
  - GET /_debug_toolbar/static/toolbar.css - CSS stylesheet
  - GET /_debug_toolbar/static/toolbar.js - JavaScript
- Implement CSS with:
  - Dark theme matching VS Code palette
  - Positioning support (right/left/top/bottom)
  - Panel collapsible sections
  - Request history table
- Implement JavaScript with:
  - DebugToolbar class for interactivity
  - Position controls with localStorage persistence
  - Panel data fetching via API
  - togglePanel for detail page panels

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Update DebugToolbarPlugin to create shared DebugToolbar instance
- Add _toolbar property for accessing toolbar from tests
- Register routes via create_debug_toolbar_router()
- Pass shared storage to routes for request history access

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Accept optional toolbar parameter to share storage with routes
- Update _render_toolbar() to use CSS classes
- Add links to request history and detail pages
- Fix line length lint issues in HTML template

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Add test_toolbar_routes.py with tests for:
  - Index route (history page)
  - Detail route (request view)
  - API endpoints (JSON responses)
  - Static assets (CSS/JS)
  - Route exclusion (no injection on toolbar pages)
  - Full workflow integration test
- Update test_litestar_middleware.py to use data-request-id assertion
- Copy existing test files to worktree

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Update litestar_basic/app.py:
  - Add docstring section for UI features
  - Update template to mention toolbar positioning
  - Add link to request history page
- Update litestar_advanced_alchemy/app.py:
  - Add docstring section for UI features
  - Add toolbar controls section to index template

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Add package.json with biome.js dependency and scripts:
  - bun run lint - Check JS/CSS/JSON files
  - bun run lint:fix - Auto-fix issues
  - bun run format - Format files
- Add biome.json configuration:
  - Space indentation (4 spaces)
  - Single quotes for JS
  - Recommended lint rules
  - CSS linting enabled
- Update .gitignore to exclude node_modules and bun.lock

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Add debug_toolbar.litestar.routes.rst for routes module
- Add debug_toolbar.litestar.routes.handlers.rst for handlers
- Update litestar.rst to include routes module

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

Co-Authored-By: Claude <noreply@anthropic.com>
The HTML form submits URL-encoded data, not JSON. Update endpoint to:
- Accept URL-encoded form data via Body parameter
- Return HTML response for browser redirect
- Show success message with link back to users list

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Add resize handle CSS for all toolbar positions (left/right/top/bottom)
- Implement JavaScript drag-to-resize functionality
- Store toolbar size in localStorage for persistence
- Reset to default size when switching between horizontal/vertical positions

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove manual session.commit() calls (handled by async_autocommit handler)
- Add explicit relationship loading with load=[Model.relation] parameter
- Prevents greenlet_spawn errors when accessing lazy-loaded relationships

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

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
The SQLAlchemy panel wasn't capturing queries because event listeners
were only attached when an engine was explicitly passed. Now, if no
engine is provided, global listeners are attached to the Engine class
itself, capturing queries from all SQLAlchemy engines.

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Middleware now collects route information from Litestar app
- Improved JavaScript formatValue to show nested objects/arrays properly
- Increased limits: maxDepth=3, maxItems=20, maxStringLen=500
- Added CSS styling for nested array/object display
- Routes panel now shows actual route data

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Add light theme CSS variables with proper contrast colors
- Add theme toggle button (sun/moon icon) in toolbar
- Theme preference persists in localStorage
- Add smooth CSS transitions for panel expand/collapse
- Panel details now animate open/closed with opacity and max-height
- History page panels also animate smoothly

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

Co-Authored-By: Claude <noreply@anthropic.com>
The panel-content div had style="display: none;" which overrode
the CSS transition classes. Panels now properly expand/collapse
using CSS classes only.

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Add inline script to apply saved theme on page load
- Theme now persists across all toolbar pages (not just inline toolbar)
- Add theme toggle button to history and detail page headers
- Add CSS for header-row layout and page theme button

🤖 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 27, 2025 07:49
@github-actions
Copy link
Contributor

github-actions bot commented Nov 27, 2025

PR Preview Action v1.6.3

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

Built to branch gh-pages at 2025-11-27 08:00 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Replace tuple syntax with union type syntax (X | Y) to fix UP038 ruff
lint violations in CI using ruff 0.9.0.

🤖 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 pull request implements Phase 5 UI/UX enhancements for the debug toolbar, introducing a comprehensive toolbar interface with theme support, positioning controls, request history tracking, and improved data visualization. The changes integrate new UI routes, enhance the middleware for better data collection, add SQLAlchemy auto-attach functionality, and include frontend linting setup.

Key Changes:

  • New toolbar UI routes (/_debug_toolbar/) serving history and detail pages with dark/light themes
  • Four-position toolbar support (left/right/top/bottom) with localStorage persistence
  • SQLAlchemy panel auto-attaches global event listeners when no explicit engine is provided
  • Enhanced middleware to collect route metadata and render improved toolbar HTML

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
src/debug_toolbar/litestar/routes/handlers.py New file implementing toolbar UI routes with HTML rendering, CSS, and JavaScript for the debug toolbar interface
src/debug_toolbar/litestar/routes/__init__.py Package initialization exposing create_debug_toolbar_router
src/debug_toolbar/litestar/plugin.py Updated to create shared toolbar instance and register UI routes automatically
src/debug_toolbar/litestar/middleware.py Enhanced to accept shared toolbar instance, collect route metadata, and render improved toolbar HTML with panel buttons
src/debug_toolbar/extras/advanced_alchemy/panel.py Added global listener auto-attach functionality for SQLAlchemy query tracking without explicit engine configuration
tests/integration/test_toolbar_routes.py New comprehensive test suite with 20 tests covering toolbar routes, API endpoints, static assets, and integration workflows
tests/integration/test_litestar_middleware.py Updated test assertion to check for data attribute instead of text content
tests/unit/__init__.py, tests/integration/__init__.py, tests/__init__.py Simplified docstrings
examples/litestar_basic/app.py Updated with UI feature documentation and links to request history
examples/litestar_advanced_alchemy/app.py Updated with UI documentation, fixed import order, removed manual commits (uses autocommit handler), changed POST response to HTML
examples/profiling_panel_example.py Fixed string literal formatting (f-string to regular string)
package.json Added Biome.js frontend linting configuration
biome.json Biome linter/formatter configuration for JavaScript/CSS
.gitignore Added Node.js/Bun ignore patterns
docs/api/_autosummary/debug_toolbar.litestar.rst Added routes module to documentation
docs/api/_autosummary/debug_toolbar.litestar.routes.rst New documentation file for routes module
docs/api/_autosummary/debug_toolbar.litestar.routes.handlers.rst New documentation file for handlers module functions

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

- Escape dictionary keys in _render_panel_content
- Escape method, path in _render_request_row with CSS class sanitization
- Escape panel_id, panel_title in panel rendering
- Escape query_string, content_type, client_host, client_port in detail view
- Sanitize CSS class names to only allow alphanumeric characters

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

Co-Authored-By: Claude <noreply@anthropic.com>
@JacobCoffee JacobCoffee enabled auto-merge (squash) November 27, 2025 08:05
@JacobCoffee JacobCoffee disabled auto-merge November 27, 2025 08:05
@JacobCoffee JacobCoffee enabled auto-merge (squash) November 27, 2025 08:05
@JacobCoffee JacobCoffee merged commit 2d5c8c0 into main Nov 27, 2025
18 checks passed
@JacobCoffee JacobCoffee deleted the phase-5-ui branch November 27, 2025 08:05
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