Contributing to Glasshouse¶
Contributions are welcome. This guide outlines how to propose changes, write compatible code, and review pull requests.
Core principles¶
- You own the glass: The project exists to give owners direct control over their TV without vendor lock-in, cloud dependencies, or tracking. No telemetry or analytics are collected.
- Keep the TV lightweight: The TV's onboard CPU and RAM are shared with video decoding and system processes. Code running on the TV must remain fast, lean, and free of unnecessary background work.
- Zero runtime dependencies: The on-TV server runs with no npm packages installed on the device.
Working conventions¶
Never push to main¶
Always work on a branch and submit a pull request:
- Create a branch from
main. - Make changes, keeping commits focused and logically distinct.
- Push the branch to your fork or the repository.
- Open a pull request against
main.
If a pull request needs follow-up adjustments, push additional commits to the existing branch rather than opening a new pull request for the same work.
Commit messages and PR descriptions¶
Focus on clarity and readability. Clearly state what changed and why, keeping pull request descriptions concise and focused on the context reviewers need.
If you are using AI coding assistants or automated agents, ensure they adhere to the repository conventions in CLAUDE.md (symlinked as AGENTS.md).
Rules for a pull request¶
The rules and the guidelines below exist to keep the code good and to make pull requests quick to review, so they get merged sooner. A pull request that arrives tested, translated and documented, built the way the rest of the code is, needs fewer rounds of changes.
Keep a pull request in draft while any of these that applies to it is unmet, and mark it ready for review once they are. Not every rule applies to every change: a docs-only change needs no TV testing or translation.
- Tried on a real TV, with a Testing section in the description and a screenshot of anything that shows on a screen.
- All checks pass:
scripts/check-all.sh. - Translated. Every new or changed string has its translation in each
language file in
server/assets/i18n/that covers the page it is on: Arabic, Spanish, French, Hungarian, Italian, Polish, European and Brazilian Portuguese, Russian and Vietnamese for the dashboards, and German too for Glasshouse Home.python3 scripts/check-strings.py --missinglists what is left. - Docs updated: the pages that describe what it changes, as in Docs.
Guidelines¶
What reviews look for. Unlike the rules, these leave room for judgement: a pull request that departs from one says why in its description. This is a starting set, added to as reviews turn up more.
The dashboards' design¶
- Reuse what is there. Buttons, dropdowns, rows, headings and notes use
the existing classes (
pill,pill-sel,prot-row,pv-sec), not new styles for the same thing. A new kind of element is the exception, and is made to match the ones around it. - Keep the design language. Spacing, type sizes and lines between rows follow the sections around a change. Check it in the dark and light themes and at phone width.
- Colour means something. Green is for the action that turns something on
or connects it, and red (
pill bad) only for removing something. Other buttons stay neutral. - Every press gets an answer. A button responds when pressed, and every state says what is happening: loading, empty, in progress, failed. A button is never greyed out without a visible reason.
- Say what the owner needs, not how it works. Text on screen leaves out services, timings and other mechanics.
Code¶
- One concern per file. A server module in
server/lib/and a dashboard script inserver/assets/ui/each handle one thing. A feature of its own, or one that serves more than one tab, gets its own file rather than growing another. - Small functions. A function does one job and reads without scrolling. One that handles several cases in nested branches or callbacks is split, one function per case, with the shared steps in helpers.
- A new setting goes in the settings backup, or says why not. A control
added to
server/lib/controls.jsis either a part inserver/lib/backup-parts.jsor listed in itsNOT_CARRIEDwith the reason, and the backup table indocs/dashboard/server.mdfollows.test/test-backup-parts.jsfails on one in neither.
Tests¶
Testing and CI says what each suite and check covers.
- Wait for the thing, not a time. Wait for the reply, element or state a
check is about (
waitForResponse,waitForFunction, or polling a condition), not a fixedwaitForTimeout, which a slow CI runner can outlast. A fixed wait is only for showing that something doesn't happen. In a unit test,waitForfromtest/wait-for.jspolls for it. - Check before acting on something that may be absent. An action on a
missing element waits out Playwright's 30 s before it fails, so
.catch()after one costs that whole wait. Usecount()first. - Don't wait on the server's real timers. If a test needs a 10 s grace
period or a retry interval to pass, the module takes it from
initand the test passes a few milliseconds. Time that has to look as if it passed comes from a faked clock (now). A suite with no real network, file or process I/O can run all its timers ontest/fake-clock.jsinstead, which takes no real time and fires every timer in its order however slow the runner. - Listen on port 0, or take a port from
test/ports.js. Suites run side by side, so a port the system handed out and was closed again can be another suite's by the time a server starts on it. A server the test starts itself listens on 0 and reads its port back; one that is told its port beforehand, such as the whole server in its own process, gets it fromfreePortintest/ports.js. - Never run a TV's commands for real. A module that runs
systemctl,mountorluna-sendtakes the function that runs them frominit, and its tests pass one that records the command. - Keep the run short. A new unit test takes well under a second. A new browser check goes in the group it shares state with, or the shortest, and the pull request says how long it takes.
Docs¶
- The page for a tab in
docs/dashboard/says what each part does for the owner, in a sentence or two, without how it works. - Findings about LG's software go in
docs/development/TV-RESEARCH.md, and anything the server changes on the TV indocs/TV-CHANGES.md.
Code reviews¶
We prefer code review comments to follow the Conventional Comments standard (e.g. praise:, suggestion:, issue:, nitpick:, question:). This keeps feedback constructive, actionable, and makes it clear whether a comment is blocking or an optional suggestion. Refer to conventionalcomments.org for the complete specification and examples.
Environment and compatibility¶
Strict ES5 for on-TV code¶
The server runs on the TV under Node.js 0.12 on webOS 3 and 4, and 0.10 on webOS 2. All files executing on the TV must remain strict ES5:
server/tvweb.jsserver/lib/*.jsserver/assets/dashboard.htmlserver/assets/setup.htmlserver/assets/setup-phone.htmlserver/assets/home.htmlserver/assets/home-app/index.html
Avoid all ES6+ constructs in these files: no const or let, arrow functions, template literals, classes, default parameters, destructuring, promises, async/await, for...of, or ES6 built-in methods (Object.assign, Array.prototype.find, etc.).
Run python3 scripts/check-es5.py to verify compliance.
Modern JavaScript in browser dashboards¶
Modern JavaScript (ES6+) is permitted exclusively in client-side code running in modern desktop/mobile browsers:
server/assets/ui.htmlserver/assets/ui/*.js
Adding new server assets¶
The deploy script (server/deploy.sh) maintains an explicit list of files copied to the TV via SSH (FILES). Any new module or asset in server/ required by the TV must be added to this list. scripts/check-drift.py verifies that all files on disk match the deploy manifest.
Localized strings¶
All user-visible text on the dashboards is keyed for localization:
- In HTML:
data-t="section.key" - In JavaScript:
t('section.key', 'Default English string', { vars })
Strings are cataloged in server/assets/i18n/. Refer to Translating the dashboards for full formatting rules. Run python3 scripts/check-strings.py to ensure all strings are keyed and translated without drift.
Running tests and verification¶
Before opening a pull request, run the test suite and validation scripts locally:
scripts/check-all.sh runs all of these side by side. One at a time:
# Run all unit and integration tests
node test/run-all.js
# Type checking
npx tsc
# Syntax and architecture checks
python3 scripts/check-es5.py
python3 scripts/check-drift.py
python3 scripts/check-strings.py
python3 scripts/check-ui-ids.py
python3 scripts/check-screensavers.py
python3 scripts/check-module-calls.py
python3 scripts/check-entity-stability.py
python3 scripts/check-entities.py --stats test/fixtures/stats-b8-webos4.json
# The release's updater can still install the change on TVs already out there
node scripts/check-upgrade.js
All automated checks must pass cleanly.
Previewing UI changes locally¶
To visually preview and interact with the web dashboard, TV app, or Glasshouse Home on your computer without a physical TV:
npm run emulate
This starts the server against a virtual webOS environment with procfs, sysfs, Luna bus calls, apps, remote keys, and recent apps mocked. You can also specify a model or port:
node scripts/emulate-tv.js [--model c2|b8|c3|cx|c1] [--webos 6.5.3] [--home on|off] [--port 8080] [--open]
Direct URLs:
* Web Dashboard: http://localhost:8080/
* TV App Dashboard: http://localhost:8080/assets/dashboard.html
* Glasshouse Home: http://localhost:8080/assets/home.html
Previewing documentation locally¶
The documentation site is built with MkDocs and the Material for MkDocs theme. To preview documentation changes locally with live reloading:
python3 -m venv .venv
.venv/bin/pip install 'mkdocs>=1.6,<2' 'mkdocs-material>=9.7,<10' 'markdown-callouts>=0.4,<0.5'
NO_MKDOCS_2_WARNING=1 .venv/bin/mkdocs serve
Then open http://127.0.0.1:8000/glasshouse/ in a browser. The page reloads automatically whenever a file under docs/ or mkdocs.yml is saved. (With Nix, nix develop provides these packages directly so mkdocs serve works without a virtual environment.)
To run the same strict build and link check that CI runs on pull requests:
NO_MKDOCS_2_WARNING=1 .venv/bin/mkdocs build
Testing on a real TV¶
The automated checks run the server's code, not the TV. LG's services, the picture and sound pipeline and the start-up sequence behave differently between models and webOS versions, and only a real TV shows how a change behaves there. Before asking for a review:
- Deploy the change to a rooted TV with
server/deploy.sh <tv-ip>, and use what it changes the way someone would: on the web dashboard, in the TV app, or from Home Assistant. - Check that what's around it still works. The TV still shows its inputs, sound still plays, and the dashboard keeps updating.
- Restart the server or the TV if the change affects start-up, the boot hook (
server/50-tvweb.sh), or anything that runs only once. - Mind older TVs. On webOS 2 to 4 the server runs on Node 0.10 or 0.12, and a call newer firmware accepts may not exist there. If you can only test on one generation, say which.
- Older TVs get fewer features, not a lower ceiling. webOS 2 and 3 lack many of LG's services, so features that need them are left out there rather than held back everywhere: gate a feature on the TV's version or on the service answering. The oldest TVs set only one limit, that the server and the TV app stay ES5 for Node 0.10 and 0.12. Support for both goes together, once keeping it costs real development, such as wanting ES6 in the server.
Testing details in the pull request¶
Add a short Testing section to the pull request description:
- the TV's model and webOS version, for example "OLED42C24LA, webOS 9.2";
- what you did and what you saw;
- what you didn't test, such as other webOS versions or something that needs hardware you don't have;
- where the change shows on a screen, a screenshot of it: the dashboard, the TV app, Glasshouse Home or the TV's own screen.
scripts/tv.sh <tv-ip> capture out.jpgtakes one from the TV.
For example:
## Testing
- OLED42C24LA, webOS 9.2: hid and unhid three tiles from the Apps tab. Each took
about 4 seconds, and HDMI 2 kept its picture and sound throughout.
- Not tested on webOS 4 or on webOS 10 and later.
If you can't test on the right TV¶
If you don't have a TV to test on, or the change affects TVs you don't have, say so in the pull request and ask for testers. A maintainer will label it testers wanted, where people with other TVs look for things to try.
Help by testing on your TV¶
Some changes can only be checked on TVs the maintainers don't have, such as newer or less common models. If you have a rooted LG TV, you can help without writing any code: pull requests and issues labelled testers wanted say what to run and what to send back.