Repository navigation
Description
Spin off from #10156.
related https://discord.com/channels/917386801235247114/1506590920085082173/1507215808529436682
The motivation is my word and the overall iteration loop is mostly working. Having URL persisted mode looks like a quick win to boost the ergonomics. Haven't verified the technicality though. The following is AI-assisted write up:
Motivation
Trace View's HTML report can support a concrete visual UI iteration workflow:
- A developer or agent edits a UI and runs a browser scenario once.
- Vitest generates
.vitest/index.htmlwith the captured DOM snapshots. - A human reloads the local report and continues reviewing the design. (Side note, as shown in discord link above, vscode can now renders
index.htmlfrom filesystem, so no dedicated server is needed.)
Watch mode already supports this workflow by refreshing Trace View when tests rerun, but supporting a similar iteration mechanism through one-shot HTML reports is equally important. One reason is that when an agent drives the changes, a workflow based on one-shot commands is simpler and more robust than managing a long-running watch process and browser session.
The current report adds friction to that one-shot loop because reloading loses the selected test and trace entry. In addition, the full Vitest UI uses excessive space when the reviewer only needs a trace or DOM snapshot of a specific moment for design review.
This proposes URL-backed trace selection and focused-view state to preserve continuity across regenerated reports while making exact local and CI views directly shareable.
Proposed Features
1. Persist Trace Selection in the URL
Note
Encode the selected test, attempt, and trace target, either a step or mark, in the report URL. Selecting a trace entry should update the URL, and reloading the report should restore that selection.
For example:
index.html#/?test=<test-id>&attempt=0:0&step=12
A mark name could identify a stable target across regenerated traces, while a step index could preserve an exact selection within a specific trace.
2. Focused Trace and Snapshot Views
Provide links from the main Trace View to:
- A focused trace view centered on the step list and DOM snapshot.
- A snapshot-only view containing only the selected DOM snapshot.
For example, the same trace selection could open in either mode:
index.html#/?test=<test-id>&attempt=0:0&step=12&mode=trace
index.html#/?test=<test-id>&attempt=0:0&step=12&mode=snapshot
Reloading or sharing either URL should restore the same focused view.
Follow-ups
- Agent integration: Expose machine-readable trace targets so agents can return direct links. This can be designed separately in connection with AI-friendly tooling #10634.
- Automatic reload: Detect when a local HTML report is regenerated and reload it while preserving the selected focused view.
- VS Code integration: If the proposed
vscode.window.openBrowserTabAPI stabilizes, the Vitest extension could open a generated.vitest/index.html#...trace or snapshot URL directly, with an HTTP-served URL as a fallback when direct file loading is unavailable.
These follow-ups can reuse the report's normal URL navigation, but none is part of this proposal.
Related issue: #10156.
Activity