fix(screenshot): resolve dev screenshot path instead of hardcoding .png - #1
Open
bruceharrison1984 wants to merge 1 commit into
Open
fix(screenshot): resolve dev screenshot path instead of hardcoding .png#1bruceharrison1984 wants to merge 1 commit into
bruceharrison1984 wants to merge 1 commit into
Conversation
takeScreenshot() fetched /pkgs/dev.png unconditionally, but the dev-mode
screenshot format is device-dependent: HD (720p) Roku TVs write the capture
as a JPEG at /pkgs/dev.jpg, while newer/4K models write a PNG at
/pkgs/dev.png. On HD TVs the hardcoded .png GET 404s ("Digest GET failed:
404") even though the capture succeeded and a dev channel is running.
Read the actual path the device advertises in the /plugin_inspect response
HTML (e.g. src="pkgs/dev.jpg?time=...") and fetch that, falling back to
trying both extensions if the response names none or the reported path is
missing. Verified against a Roku 24R2EX (720p, firmware 15.2.4), which serves
only /pkgs/dev.jpg.
Adds unit tests for the JPEG device, the .png->.jpg fallback, the
no-advertised-path default, and the all-404 failure case.
Author
|
I stumbled on to this while using the MCP server, so fixing it here and re-rolling the MCP should fix it. The fix itself is straight-forward. Claude was used for generating the PR as well, but seems like a given since I found it while consuming the MCP version. |
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.
Problem
EcpClient.takeScreenshot()retrieves the capture from a hardcoded/pkgs/dev.png:But the dev-mode screenshot format is device-dependent. HD (720p) Roku TVs write the capture as a JPEG at
/pkgs/dev.jpg, while newer/4K models write a PNG at/pkgs/dev.png. On an HD TV the.pngpath does not exist, so the GET 404s andtakeScreenshot()throwsDigest GET failed: 404— even though the capture succeeded and a dev channel is running. This makesroku_screenshot(via@danecodes/roku-mcp) unusable on that whole class of devices.Reproduced on a Roku 24R2EX (720p, firmware 15.2.4)
The
/plugin_inspectPOST response already advertises the real filename.Fix
Read the actual path the device reports in the
/plugin_inspectresponse HTML (src="pkgs/dev.jpg?time=...") and fetch that. If the response advertises no path, fall back to trying both.jpgand.png. This keeps working on PNG devices and fixes JPEG devices, with no configuration.Tests
Adds
takeScreenshotunit tests (fetch-level mocks) covering:.jpg(asserts.pngis never requested).pngthat 404s, falling back to.jpgEcpScreenshotErrornpm run buildandnpm testpass (93 tests).