You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(dev-tools): edit settings from an in-app panel in the dev server - #105
npm run dev now adds a dev tools panel to every Edge App page it serves, so apps need no markup. It runs only in the dev server and never reaches a build.
The panel edits the app's settings and screen metadata. Saving writes them to mock-data.yml (keeping comments and other keys) and the page reloads, which is how a device applies settings too. The form comes from screenly.yml:
select settings are a dropdown
boolean settings are a switch
secret settings are masked
settings marked advanced are in a collapsed group, ordered by display_order
screen name, location, coordinates and tags have their own group
It also shows:
when the app called signalReady(), in ms after page load
whether the app asked to be skipped with signalAbort(), and when
a network switch: Offline makes cross-origin fetch reject and sets navigator.onLine to false; Hang keeps requests pending until their AbortSignal fires. Use these to test cache fallbacks and timeouts.
The existing viewport, scale and orientation info stays, and D still toggles the panel. It no longer fires while you type in a field.
Dev server API
GET /__screenly/config returns the manifest settings, current values and metadata.
POST /__screenly/config merges settings and metadata into mock-data.yml. It accepts only settings declared in screenly.yml, as strings, plus screen_name, hostname, location, coordinates and tags. The request must be JSON from the dev server's own origin, otherwise it gets a 403.
Library changes
ScreenlyObject gets an optional signalAbort, and there's a signalAbort() helper next to signalReady(). It returns false on players before ScreenlyOS 26.9 and in browsers, so apps can show a message instead.
The dev server's screenly.js now provides signalAbort() and records both signals on window.__screenlyDevServer.
Fix
Blank values in mock-data.yml (county:) reached apps as null, and YAML booleans as booleans. Every setting is now a string, as on a device.
Notes
vite-plugins/dev-server.ts is split into screenly-config.ts, config-api.ts and screenly-js.ts to stay under the lint limits on file and function length.
The Vite dev server now adds <edge-app-devtools> to every page it serves
(serve mode only, so builds never include it). With the new dev-server
attribute the panel shows:
- a form built from the screenly.yml settings: select as a dropdown,
boolean as a switch, secret masked, advanced settings collapsed, plus
screen metadata. Saving writes mock-data.yml, keeping its comments,
and the existing file watcher reloads the page.
- whether the app called signalReady() and how many ms after load.
- a network simulator: offline makes cross-origin fetch reject, hang
keeps it pending until its AbortSignal fires.
The dev server exposes GET and POST /__screenly/config for the panel.
POST accepts only manifest settings and a few metadata fields, as JSON
from the dev server origin.
Blank values in mock-data.yml (county:) used to reach apps as null and
YAML booleans as booleans; every setting is now a string, as on a
device. The D shortcut no longer fires while typing in a field.
The dev server's screenly.js now has signalAbort(), the skip request
ScreenlyOS 26.9+ players support. It records when the app calls it and
dispatches screenly:abort. A new Player switch removes signalAbort()
to simulate older players and browsers, so fallback paths in apps can
be tested too.
The library gets an optional signalAbort on ScreenlyObject and a
signalAbort() helper that returns false where the player lacks it.
The panel moves from the green-on-black terminal look to a neutral dark
panel: stat tiles, status dots for the ready and skip signals,
segmented controls for network and player, switches for boolean
settings and a sticky save bar. It keeps visible focus rings and
respects prefers-reduced-motion.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Two unresolved critical issues remain: the API accepts write requests without an Origin header, and the dev-server injection builds incorrect /@fs/ URLs for absolute Unix paths.
Adds a dev-server-only in-app panel for editing Screenly settings and screen metadata, monitoring app signals, and simulating network conditions. It also introduces signalAbort() support and normalizes mock settings to device-compatible strings.
Changes:
Adds manifest-driven configuration APIs with YAML-preserving mock-data.yml updates.
Adds settings, metadata, signal monitoring, network simulation, and dev-tools panel integration.
Adds signalAbort() support, tests, styling, and documentation.
File
Description
vite-plugins/screenly-js.ts
Generates development screenly.js state, signal tracking, and network simulation.
vite-plugins/screenly-js.test.ts
Tests generated signal tracking and simulated network behavior.
vite-plugins/screenly-config.ts
Loads manifests and mock data, normalizes settings, and builds panel configuration.
vite-plugins/screenly-config.test.ts
Tests manifest parsing, string conversion, and mock-data overrides.
vite-plugins/dev-server.ts
Integrates the configuration API and injects dev tools into served pages.
vite-plugins/dev-server.test.ts
Tests configuration requests and dev-server plugin behavior.
vite-plugins/config-api.ts
Validates configuration updates and preserves YAML structure while writing changes.
vite-plugins/config-api.test.ts
Tests configuration validation and comment-preserving YAML writes.
src/utils/settings.ts
Adds the public signalAbort() helper.
src/utils/settings.test.ts
Tests supported and unsupported signalAbort() behavior.
src/types/index.ts
Adds optional signalAbort support to ScreenlyObject.
src/components/dev-tools/settings-form.ts
Provides settings and metadata form rendering and API helpers.
src/components/dev-tools/settings-form.test.ts
Tests field grouping, input rendering, and value serialization.
src/components/dev-tools/dev-tools.ts
Adds dev-server panel integration and keyboard and collapse behavior.
src/components/dev-tools/dev-tools.test.ts
Tests panel rendering, signal status, network controls, and keyboard behavior.
src/components/dev-tools/dev-tools.styles.ts
Adds styling for the expanded dev-tools interface.
src/components/dev-tools/dev-server-panel.ts
Implements signal display, network controls, configuration loading, and saving.
README.md
Documents signalAbort() and the development server panel.
docs/components.md
Documents dev-tools features and the configuration API.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Two unresolved issues remain: production bundles still statically include the dev-server panel, and origin validation omits the protocol check needed to enforce same-origin writes.
Keep the dev-server panel out of the production component bundle
src/components/dev-tools/dev-tools.ts:7
Although the Vite plugin is serve-only, this static import pulls DevServerPanel (and its config API client) into dev-tools.ts. src/components/register.ts imports this module unconditionally, so normal production consumers bundle the dev-server form/fetch code even when no dev-server attribute is present. That contradicts the PR's guarantee that the dev-server panel never reaches a build; isolate the dev-server implementation behind a dev-only entry or otherwise keep it out of the production component graph.
The reason will be displayed to describe this comment to others. Learn more.
Reviewed the full diff, ran the suite locally (259 tests pass, tsc --noEmit clean), and CI is green.
The design holds up. The screenly.js / config-api / screenly-config split reads well, all the panel DOM goes through textContent, the write endpoint has an allow-list and a 1 MB body cap, and editing mock-data.yml in place keeps its comments, which is a nice touch. I agree with your answers on both remaining Copilot threads. Vite's fsPathFromId does put the leading slash back on /@fs/home/.... Comparing on host (which includes the port) is enough: a cross-site page can't forge Origin, and a check on the scheme would break saves behind an HTTPS proxy.
One non-blocking suggestion: Save writes every setting, including ones you didn't touch.readSettingValues collects every [data-setting-key] input and the POST merges all of them into mock-data.yml. So after the first save, every manifest setting is fixed at its current value. If someone later changes a default_value in screenly.yml, the dev server keeps serving the old value from mock-data.yml, and nothing explains why. Booleans make it worse: a switch whose value was '' or True gets written back as 'false' / 'true'. If the panel sent only the fields that differ from config.values (the same goes for metadata), mock-data.yml would stay a list of real overrides. Fine as a follow-up.
Follow-ups from testing #105 (dev tools settings panel) end to end in a real Edge App (opensky-live-app, packed library installed from dist/). Everything else checked out: save and reload, origin guard, validation, Offline and Hang modes, signal pills, the D key, and no dev-tools code in production builds.
1. Simulated network modes make fetch throw on an invalid URL (bug)
In Offline or Hang mode, the fetch wrapper in vite-plugins/screenly-js.ts calls new URL(url, window.location.href) outside a promise, so an invalid URL throws synchronously:
fetch('http://[')// Offline/Hang: throws TypeError// native fetch: returns a rejected promise
App code written as fetch(x).catch(...) would crash only when these modes are on.
Fix: wrap the wrapper's body in try { ... } catch (error) { return Promise.reject(error) }.
2. Saving copies every setting into mock-data.yml (design)
The panel posts the whole form, so one save writes every setting, including ones the user never touched. In testing, a save that changed only airport and units also wrote flight_number, refresh_interval, override_coordinates, override_timezone and sentry_dsn (all empty).
Those values match the current defaults, so nothing changes right away. But they pin the defaults: if a default_value in screenly.yml changes later, the stale value in mock-data.yml silently overrides it.
Suggestion: send only the fields that differ from the values the panel loaded.
3. Offline mode only affects fetch (docs)
XHR, WebSocket, EventSource and image requests still go through in Offline and Hang modes. The PR description says "cross-origin fetch", but docs/components.md should say so too, since apps such as map apps load tiles as images.
Thanks for testing this end to end. I checked all three points against 80868ae, and I agree with each of them.
Confirmed, and I missed it when I approved. In vite-plugins/screenly-js.ts:31, new URL(url, window.location.href) runs synchronously in the wrapper. A malformed URL therefore throws instead of returning a rejected promise, but only when Offline or Hang is on. That's the worst kind of difference, because it only shows up while you're trying to simulate failure. Wrapping the body in try { … } catch (e) { return Promise.reject(e) } fixes it, and so does making the wrapper async. I'd like this fixed before merge, ideally with a test that calls fetch('http://[').catch(...) in both modes.
Agreed. Writing back only the keys the user changed keeps mock-data.yml from pinning today's defaults. The panel already has the loaded values, so it can diff against them. This one is fine as a follow-up if you'd rather keep the PR small.
Agreed.docs/components.md should say that the simulated modes only intercept cross-origin fetch, and that XHR, WebSocket, EventSource and <img>/tile loads still go through.
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
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.
What this does
npm run devnow adds a dev tools panel to every Edge App page it serves, so apps need no markup. It runs only in the dev server and never reaches a build.The panel edits the app's settings and screen metadata. Saving writes them to
mock-data.yml(keeping comments and other keys) and the page reloads, which is how a device applies settings too. The form comes fromscreenly.yml:selectsettings are a dropdownbooleansettings are a switchsecretsettings are maskedadvancedare in a collapsed group, ordered bydisplay_orderIt also shows:
signalReady(), in ms after page loadsignalAbort(), and whenfetchreject and setsnavigator.onLineto false; Hang keeps requests pending until theirAbortSignalfires. Use these to test cache fallbacks and timeouts.The existing viewport, scale and orientation info stays, and
Dstill toggles the panel. It no longer fires while you type in a field.Dev server API
GET /__screenly/configreturns the manifest settings, current values and metadata.POST /__screenly/configmerges settings and metadata intomock-data.yml. It accepts only settings declared inscreenly.yml, as strings, plusscreen_name,hostname,location,coordinatesandtags. The request must be JSON from the dev server's own origin, otherwise it gets a 403.Library changes
ScreenlyObjectgets an optionalsignalAbort, and there's asignalAbort()helper next tosignalReady(). It returnsfalseon players before ScreenlyOS 26.9 and in browsers, so apps can show a message instead.screenly.jsnow providessignalAbort()and records both signals onwindow.__screenlyDevServer.Fix
Blank values in
mock-data.yml(county:) reached apps asnull, and YAML booleans as booleans. Every setting is now a string, as on a device.Notes
vite-plugins/dev-server.tsis split intoscreenly-config.ts,config-api.tsandscreenly-js.tsto stay under the lint limits on file and function length.isDevelopmentMode()is untouched, so this merges cleanly with fix(dev-tools): use import.meta.env directly for dev mode check #74.docs/components.mdand the README's dev server section.