Skip to content

Add session-scoped request history browser - #23

Open
Alistar84 wants to merge 3 commits into
phalcon:masterfrom
Alistar84:feature/request-history
Open

Add session-scoped request history browser#23
Alistar84 wants to merge 3 commits into
phalcon:masterfrom
Alistar84:feature/request-history

Conversation

@Alistar84

Copy link
Copy Markdown

Hello!

In raising this pull request, I confirm the following:

  • I have read and understood the Contributing Guidelines
  • I have checked that another pull request for this purpose does not exist
  • I wrote tests for this PR
  • I have updated the relevant CHANGELOG
  • I have created a separate PR for the documentation (the documentation is included in this PR)

Small description of change:

This PR adds an optional, session-scoped request history system to the debug bar.

It resolves #21, which describes the current limitation where the bar can only inspect the request that rendered the current page. This makes completed AJAX requests, redirects, and earlier requests difficult to inspect once they have finished.

Closes #21.

When enabled, the new history system records the collected debug-bar payload together with request metadata such as:

  • HTTP method
  • URI
  • response status
  • AJAX flag
  • request timestamp

A new History item in the bottom bar opens the list of stored requests. Selecting a request replaces the currently displayed collector data without navigating away from or reloading the host page. The history browser also provides refresh and clear controls.

Storage and retention

History storage is disabled by default and must be enabled explicitly through configuration.

Stored requests are:

  • isolated by a SHA-256 hash of the active PHP session ID
  • written atomically to a configurable filesystem directory
  • limited by a configurable maximum request count
  • automatically removed after a configurable TTL
  • not recorded or exposed when no PHP session is active

The storage path defaults to the system temporary directory and can be configured outside the application document root.

Internal endpoint

When history is enabled, the provider automatically registers an internal controller for:

  • GET /_debugbar/open - list stored request metadata
  • GET /_debugbar/open?id=<request-id> - load a stored debug-bar payload
  • DELETE /_debugbar/open - clear the current session's history

The endpoint reuses the debug bar access gate, returns private non-cacheable responses, validates request IDs, and excludes its own requests from the history.

Backward compatibility

The feature is opt-in. Existing applications retain the current behavior when history.enabled is not enabled.

Tests

The PR includes tests covering:

  • session isolation
  • filesystem persistence
  • maximum request pruning
  • TTL expiration
  • request lookup and validation
  • clearing stored requests
  • the internal controller
  • provider route registration
  • the history collector

Thanks

@niden

niden commented Sep 2, 2026

Copy link
Copy Markdown
Member

@Alistar84 At some point please rebase from master. I put a fix in for the warning emitted in the CI that makes this CI red. Thanks

@Alistar84
Alistar84 force-pushed the feature/request-history branch from d26cba8 to 603fa1c Compare September 2, 2026 15:07
@Alistar84

Copy link
Copy Markdown
Author

Rebased onto the latest master. Thanks for the fix!

@Alistar84
Alistar84 marked this pull request as ready for review September 3, 2026 06:38
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.

Support for browsing previous requests (request history / multi-request navigation)

2 participants