Repository navigation
Conversation
The screenshot track found a marker's image through its schema, and the screenshot under the mouse, inside the component. Move both into profile-logic, and group the screenshot marker indexes by name in their own selector, so that profiler-cli can use the same logic.
Inline source maps were decoded by a private helper in embed-js-sources. Move it next to the other data URL helpers and return the media type and bytes, so that binary data URLs like screenshots can use it too.
"screenshot list" lists the screenshot frames of the current view with their m-N handles, grouped by window. "screenshot save" writes frames as image files into a directory, named "<time>-<m-N>.<ext>", so that they can be looked at: given marker handles, the frames on screen during a --range, the frame of each window on screen --at a time, or every frame of the view with --all. --range and --at take the "zoom push" syntax and apply inside the current zoom. --search keeps the windows whose marker name matches.
…info "profile info" lists the screenshot windows with frames in the current view, so that they can be found without knowing about "screenshot list". "marker info" on a screenshot frame says how to save it as an image.
There was a problem hiding this comment.
🟡 Changes recommended
Screenshot handling still rejects valid percent-encoded images, includes unsavable and out-of-view frames, and produces incorrect chronological filename ordering for submillisecond timestamps.
4 open issues
What changed in this PR
Adds screenshot discovery and image export to profiler-cli, reusing shared screenshot logic and the range syntax introduced in #6522.
Changes:
- Lists frames by window and saves images selected by handle, range, time, or
--all. - Adds screenshot summaries, command routing, output formatting, and documentation.
- Shares screenshot helpers with the timeline UI and adds unit and integration coverage.
| File | Description |
|---|---|
| src/utils/base64.ts | Adds synchronous data URL decoding. |
| src/test/unit/profile-query/screenshots.test.ts | Tests screenshot queries and exports. |
| src/test/unit/base64.test.ts | Tests data URL decoding. |
| src/selectors/per-thread/markers.ts | Groups screenshot indexes by name. |
| src/profile-query/types.ts | Defines screenshot query types. |
| src/profile-query/screenshots.ts | Implements frame selection and export. |
| src/profile-query/index.ts | Exposes screenshot queries. |
| src/profile-query/formatters/profile-info.ts | Adds screenshot summaries. |
| src/profile-query/formatters/marker-info.ts | Identifies screenshot markers. |
| src/profile-logic/marker-schema.ts | Extracts shared image metadata logic. |
| src/profile-logic/marker-data.ts | Adds shared time-based frame lookup. |
| src/profile-logic/embed-js-sources.ts | Reuses data URL decoding. |
| src/components/timeline/TrackScreenshots.tsx | Uses shared screenshot helpers. |
| profiler-cli/src/test/unit/network-formatting.test.ts | Updates profile-info fixtures. |
| profiler-cli/src/test/unit/marker-formatting.test.ts | Updates marker-info fixtures. |
| profiler-cli/src/test/integration/screenshot.test.ts | Tests end-to-end screenshot commands. |
| profiler-cli/src/protocol.ts | Adds screenshot commands and results. |
| profiler-cli/src/permalink-view.ts | Handles screenshot permalink routing. |
| profiler-cli/src/output.ts | Routes screenshot output formatting. |
| profiler-cli/src/index.ts | Registers commands and examples. |
| profiler-cli/src/formatters.ts | Formats screenshot results and hints. |
| profiler-cli/src/daemon.ts | Dispatches screenshot requests. |
| profiler-cli/src/commands/screenshot.ts | Defines command options and actions. |
| profiler-cli/schemas.txt | Documents screenshot JSON results. |
| profiler-cli/README.md | Lists screenshot commands. |
| profiler-cli/guide.txt | Adds screenshot workflow examples. |
Review effort: Balanced
| tracks.push({ | ||
| threadIndexes, | ||
| window: makeScreenshotWindow(state, threadMap, threadIndexes, markerName), | ||
| markerIndexes: indexesByName.get(markerName) ?? [], |
Comment on lines
+99
to
+108
| const indexesByName = | ||
| getThreadSelectors(threadIndex).getRangeFilteredScreenshotIndexesByName( | ||
| state | ||
| ); | ||
| const threadIndexes = new Set([threadIndex]); | ||
| tracks.push({ | ||
| threadIndexes, | ||
| window: makeScreenshotWindow(state, threadMap, threadIndexes, markerName), | ||
| markerIndexes: indexesByName.get(markerName) ?? [], | ||
| }); |
Comment on lines
+344
to
+345
| const formatFileTime = (relativeMs: number) => | ||
| `${(relativeMs / 1000).toFixed(3).padStart(secondsWidth + 4, '0')}s`; |
Comment on lines
+43
to
+49
| return { | ||
| // RFC 2397 makes a missing media type mean text/plain. | ||
| mediaType: header.split(';')[0] || 'text/plain', | ||
| bytes: header.endsWith(';base64') | ||
| ? new Uint8Array(base64StringToBytes(data)) | ||
| : new TextEncoder().encode(decodeURIComponent(data)), | ||
| }; |
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.

Stacked on #6522. (again trying stacked PRs, let's see if they are gonna work)
This PR adds two commands:
screenshot listlists the screenshot frames of the current view with their marker handles, grouped by window.screenshot save -o <dir>writes frames as image files named<time>-<m-N>.<ext>, so they sort by time. Frames are picked by marker handle,--range(the frames on screen during a range, e.g.--range m-500for a jank marker),--at(the frame of each window on screen at a time) or--all.