feat(web): the Display tab is an ES-module page, with a page-visibility service (stage 4) - #771
Merged
Merged
Conversation
…ty service (stage 4) - core/visibility.js: each page gets ctx.visibility (whileVisible, every, isVisible). Work registered there runs only while the page's tab is active and the browser tab visible, and ends when the page is swapped out. It reads the active tab from window.LEDVisibility, so it agrees with the classic partials. The registry gained a mountContext option for per-mount services. - pages/display.js replaces display.html's two inline scripts. The 5 s sync status poll runs through ctx.visibility.every; the status and scroll-speed hint requests go through ctx.api with ctx.signal, as does the Vegas order widget's plugin-list request. The Advanced toggle is a delegated data-action; window.updateSyncUI is a deprecated alias. - New DOM suites test_visibility_service.js and test_display_page.js; test_display_partial_ids.js imports the module. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 58 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (15)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 150 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
…troy Codacy's object-injection rule flagged v[id] and ctx.state[name]. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Step 8 of the web UI's ES-module migration (
docs/WEB_FRONTEND_ARCHITECTURE.md): the Display tab, and the page-visibility service it needs first. Follows #767 (Schedule, General).The visibility service:
core/visibility.jsEach mounted page gets
ctx.visibility. The registry has a newmountContextoption, andboot.jsuses it to bind one handle to each mount:whileVisible(start, stop)start()when the page comes on screen (at once if it mounts on screen),stop()when it leaves. Returns an end functionevery(ms, fn)fn()at once, then everymswhile on screen. The interval is cleared while hidden and restarted, with an immediatefn(), when the page is backisVisible()Everything a page registers ends when its
ctx.signalaborts, afterdestroy(), so a swapped-out partial leaves no interval behind. The service reads the active tab fromwindow.LEDVisibility(app-shell.js) at call time, so the page modules agree with the classic partials that still use it (Overview, Logs, Tools). Each registration gets its own key, so registrations never replace each other or a classic one. WithoutLEDVisibility, the browser tab's visibility alone decides. Moving the tracker itself out ofapp-shell.jsis still the separate shell-service row.The Display tab:
pages/display.jsdisplay.htmlloses its two inline scripts (292 lines), itsonclickand itsonchange. Its root isdata-page="display".ctx.visibility.every(5000, ...). The status request and the scroll-speed hint go throughctx.apiwithctx.signal. So does the Vegas order widget's plugin-list request.data-action="toggle-section"that calls the sharedtoggleSection. The settings form keeps itshx-oncall toshowSaveResultand itsonsubmitcall tofixInvalidNumberInputs, as Rotation's does.window.updateSyncUIis a deprecated alias inboot.js.escapeHtmlandescapeAttrwere never called, so they are dropped, along with their entry intest_html_escaping.js.Behaviour differences
updateSyncUI()and the visibility start each polled. A Display tab that mounts while not on screen now waits until it is on screen before asking.window.syncStatusInterval(the old timer id) is gone. Nothing read it.LEDVisibilityreplaced it by key when the script re-ran. It now also ends when the partial goes without being replaced.Tests
dom/test_visibility_service.js: realLEDVisibilityfromapp-shell.js, the real registry, no server. It covers starting and stopping with the active tab and with browser-tab visibility, that no interval runs while hidden or after a swap-out, one interval after five swaps, registrations staying independent, a destroyed page registering nothing, a throwingstart()being contained, and the fallback whenLEDVisibilityis absent.dom/test_display_page.js: the real partial, the realplugin-order-listwidget, realLEDVisibilityand real API shapes. After five swaps there is one page and one sync interval, and each control acts once. The poll runs only while the tab is on screen and never after a swap-out. Sync states and hostile names render as text. Failure and login answers, the debounced hint, the late widget andupdateSyncUIare covered too.unit/test_display_partial_ids.jsnow imports the module on a fake root that answers only for ids the partial renders.unit/test_page_registry.jscoversmountContext.test_es_modules.pyregisters the page and its alias.every()no longer clears its intervalsetInterval#brightness-displaymountContextdocument.hiddenREQUIRE_DOM=1 node test/js/run_all.js: all 35 suites pass.python scripts/build_css.py --check: up to date.test/web_interface, web smoke and settings UI, partial save, display hardware, JS unit suites): the FAILED lists are identical on this branch and an origin/main baseline. Both have 11 failures, the existing Windows ones such astest_starlark_pixlet_routes.updateSyncUIwarned once and forwarded.🤖 Generated with Claude Code