Open the documentation page when an editor starts the service - #40
Merged
Conversation
mjaksn
force-pushed
the
open-docs-on-start
branch
from
September 3, 2026 00:53
6c57b9b to
c0d1ca8
Compare
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.
Every launch configuration that starts the service now opens
/docsin abrowser once the service is listening.
How
A new setting,
open_docs, off by default. All seven configurations that startthe service set
READERBOARD_OPEN_DOCS=1: four in.vscode/launch.jsonandthree in
.idea/runConfigurations/. The two that start the sign simulator alone,and the one that runs the tests, do not.
The waiting and the opening are the service's job rather than the editor's, and
that is the load-bearing part. It means the browser lands on the address actually
bound rather than one repeated in a launch file, which is what makes it right for
"readerboard against the real sign", whose port comes from a config file no launch
file knows anything about. Waiting for the port rather than sleeping a fixed time
is what makes it right on a slow start: the link to the sign is opened before the
socket is, and a browser opened too early shows a connection error for a page that
was going to work.
Nothing about it can take the service down. A browser that raises, a machine with
no browser, a port that never answers: each is a log line and nothing more. The
service drives a sign whether or not anybody is looking at a page.
The one change beyond the configurations
"readerboard against the loopback" in VSCode ran
module: uvicorn, which does notgo through the service's entry point at all, so the setting could never have
reached it. Confirmed by running it that way with the variable set: no browser, no
log line. It now runs
module: readerboard, which is what the PyCharmconfiguration of the same name has always done, so the two read settings the same
way.
That would have cost it
--reload, which is the point of that configuration, soreaderboard --reloadnow exists. Under it the open-docs wait stays in thesupervising process, so the tab opens once at the first bind rather than on every
restart.
Tests
tests/test_open_docs.pyis new and is mostly about failure, because that iswhere the risk is: a port that never answers, a browser that raises, a machine
with no browser at all. It uses real sockets rather than fakes, since what is
being tested is telling a port that answers from one that does not.
tests/test_launch_configurations.pycovered PyCharm parsing; it now also loads.vscode/launch.jsonand checks that every configuration in either editor whichstarts the service asks for the documentation page, and that the ones which start
no service do not. That second half matters: without it the easy way to pass the
first is to put the variable everywhere, which would open a browser when running
the test suite. A configuration that quietly lost the setting would still run
perfectly and simply stop opening a tab, which is not something anybody reports.
Both new config tests were mutation checked: removing the variable from one
configuration fails the suite and names it.
Checks
708 tests pass, 18 of them new.
ruff check .andmypyon the service and bothtools are clean, and
docs/openapi.jsonis unchanged, so nothing here reaches theAPI description.
Verified end to end with a stubbed browser on all three paths a configuration can
take:
python -m readerboard, the same with--reload, and throughscripts/run_with_simulator.py. The launcher run used a non-default port and thetab opened on that port rather than on 5001, which is the behaviour the whole
design is for.
Two judgement calls
open_docsis deliberately not inpackaging/config.example.toml. It is adevelopment setting and that file is what gets installed on a Pi. It stays
discoverable:
--print-configlists it, because that iterates the settings.No version bump.
[Unreleased]is back inCHANGELOG.mdwith the entry, which isthe shape the 0.3.0 cut left behind.