Repository navigation
Remember each port's choices between visits in the serial tool - #19
Open
SantaClaas wants to merge 1 commit into
Open
SantaClaas wants to merge 1 commit into
SantaClaas wants to merge 1 commit into
Conversation
The page is static and gets reloaded often — to pick up a new build, or because an adapter was unplugged and came back as a fresh panel — and every choice it offers is one the user made last time and would make again. Getting back to a device read meant six interactions: the preset, the open, the tab, the device, its address, the read. Each port's settings, tab, device and last-used address per device now live in localStorage under a key made from the adapter's USB ids, so a reload lands back where the bench session was. Only choices are kept, never readings: a restored register value beside a live one would make the page lie about what it knows, and the read stays the click at which the user takes responsibility for putting frames on the bus. Reopening the port on load is opt-in per port, with a checkbox beside Open port. Opening a port asserts the adapter's control lines, and on an adapter that drives its RS-485 transceiver from RTS that is the one thing a tool meant to be passive must not do unasked — so it is a decision, made once and then remembered. The preset select now shows which preset the settings actually are, rather than always the first: restored 9600 8N1 under a label reading "RadiCal fans — 19200 8E1" would be worse than no label. Settings that are nobody's preset say "Custom". preferences.ts takes its storage as an argument, so what it makes of a record written by an older build is tested without a browser. The parsing is forgiving by design — every field is checked and falls back on its own rather than discarding the record. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012EsZhBCaL9NHU6ySsMm7Kw
This branch has not been deployed
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.
The page is static and gets reloaded often — to pick up a new build, or because an adapter was unplugged and came back as a fresh panel — and every choice it offers is one that was made last time and would be made again. Getting back to a device read meant six interactions: the preset, the open, the tab, the device, its address, the read.
What it remembers
Per port, in
localStorage, under a key made from the adapter's USB ids:0x03keeps it independently of the relay's0x01)That takes getting back to a device read from six interactions to one — Read all registers — or two with auto-open left off.
Two ports of the same model are indistinguishable through the Web Serial API, so a second identical CH340 gets
1a86:7523#1rather than the first one's settings.Two judgement calls
Readings are not remembered, only choices. A restored register value sitting beside a live one would make the page claim to know something about the device that it does not, and the read is the click at which the user takes responsibility for putting frames on a bus the controller may be driving.
Reopening the port on load is opt-in per port, with a checkbox beside Open port, off until asked for. Opening a port asserts the adapter's control lines, and on an adapter that drives its RS-485 transceiver from RTS that is the one thing a tool meant to be passive must not do unasked. Once asked, it is remembered, and a refresh then costs no clicks at all to get back to a live port.
Also fixed
The preset select never reflected the settings and always showed the first entry. With settings now restored, that would have put 9600 8N1 under a label reading "RadiCal fans — 19200 8E1". It shows the matching preset, or "Custom" when the settings are nobody's preset.
Verification
pnpm buildandpnpm testpass — 165 tests, 25 of them new, covering key assignment, the round trip, and what the parser makes of a record written by an older build.preferences.tstakes its storage as an argument for exactly that reason, so the parsing is checked without a browser, the same way everything undersrc/modbusis.The built page was also driven in Chromium against a stubbed
navigator.serial: a relay session was set up, the page reloaded, and the port came back open at 9600 8N1 on the device tab with the relay at address 4 — and unchecking auto-open keeps the settings while leaving the port closed. That script lives outside the repository.Documentation
A "What it remembers" section in
serial/README.md, and a sixth entry in the serial tool's list of things to know inCLAUDE.md— including that anything added toRememberedhas to be parsed as if written by an older build.🤖 Generated with Claude Code
https://claude.ai/code/session_012EsZhBCaL9NHU6ySsMm7Kw
Generated by Claude Code