03f8e1496fc7c8c05fa4e11caeec3daa608da48d
82
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
03f8e1496f |
Every row says what it does, not what it is
The descriptions were written for someone who already knew the answer. A user reading "Airtime budget: duty cycle = 100 / (factor + 1) %" or "Per-hop path-hash size; larger resists collisions, adds overhead" has to ask, which is the opposite of what a description is for. So both registries now answer the reader's actual question -- what does this do to me -- in as few words as it takes. "Wider is faster, narrower reaches further" instead of naming the unit twice. "Caps how much of the air we use; 0 = no cap" instead of the formula. "How loud this radio transmits." Labels went with them where the name was ours to choose: Sweep floor and Sweep ceiling are Lowest power and Highest power, Opening frame is Map fit, Silence alarm is Alert after, Basemap source is Map tiles. The radio's own names stay -- someone matching Spreading factor against their phone app should find the words they came for. History kept is just History. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
fe4780e070 |
The page keeps what MeshTerm alone decides
Background adverts came off it. The cadence is the *companion's*, remembered per public key and set on Device config, so a preference could only ever be the value a radio starts on before you give it one -- a default behind a default, and a row that says "newly seen device" while meaning "your own radio, the first time". adverts.json answers for it again; the store is back to the constants it had. Transmit cooldown now defaults to 5s rather than 1s. It paces every burst we are allowed to make, and on a shared mesh the polite number is the larger one. The last-column choices answer their own row: it asks whether to use the column a terminal hides, so the values are auto, yes, no instead of naming the mechanism a second time. YAML 1.1 reads a bare yes/no as a boolean, so a hand-edited file that writes the obvious thing is understood rather than silently dropped -- we still quote ours on the way out. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
cef7a764af |
How MeshTerm behaves gets a page of its own
Three kinds of "setting" were tangled into two files and one of them had no screen at all. The radio's settings live on the radio and are edited on Device config. Machine setup -- where the database is, which companion to talk to -- stays in config.toml, a text editor's job. Everything in between was app behaviour: six keys sitting in config.toml with nothing to open them, and a dozen more that were only module constants a reader could never reach. Those are preferences now, and they have a page. core/preferences.py is a PrefSpec registry in the shape of the device-config one -- group, type, bounds, help, and a default -- and the page is built from the same parts as the device editor, deliberately: one grouped lane-aligned list, current -> new staged in warn, Apply/Back appearing only once something is staged, the shared discard confirm on the way out. Two editors that stage values should not be two screens to learn. What it adds is a Defaults section holding one row that stages every changed preference back to its built-in value; it is drawn only while a reset would do something, and it stages rather than writes, so it is as reviewable and as Esc-discardable as any other change and the file is still only ever written by the one action at the bottom. Its rows scroll sideways where the device editor's don't: the explanation is the widest thing on the row and the only part that runs past the edge, so <-> slide it under a pinned setting and value. The file is preferences.yaml and holds only the values you disagree with the code about -- grouped and commented, each entry above its help and its default. That is what lets a later change to a default reach an install that never asked to be exempt; delete a line and the code takes over again. A hand edit gone wrong costs that line, never the session. Every preference is wired to something that reads it. ctx.preferences is the explicit path; preferences.current() is for the render layer, which has no context to reach through, the same reason get_platform() exists. The About pages come along into a This app section, the third scope after this node and other nodes, with Preferences leading it -- the one row there that changes MeshTerm rather than describing it. A section of one would have broken the menu's own no-bucket-of-one rule, and the app's scope is the honest home for both halves anyway. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
6924ff7f45 |
The presets are MeshCore's, not ours
Every one of the region presets named a modulation no mesh runs any more, and two of them named a frequency nobody was ever on. MeshTerm's list was three regions on 250 kHz / SF11 — the shape MeshCore shipped with — plus two trade-off rows built on the EU frequency. Through 2025 most regions left that modulation for a narrow 62.5 kHz one, so the EU row is what MeshCore now calls "EU/UK (Deprecated)", the US row had the right frequency with the wrong modem (910.525 is SF7/BW62.5/CR5), and "AU / NZ 915" at 915.525 was not a preset at all: Australia is 915.800 wide, 916.575 narrow, 923.125 in SA/WA and QLD, and New Zealand is 917.375. Four parameters have to match for two nodes to hear each other, so a stale table is a radio staged onto an empty channel. The list is now MeshCore's own suggested settings, mirrored verbatim — names, order and values — from what its apps, the web flasher and config.meshcore.dev all read at api.meshcore.nz/api/v1/config. Twenty-three regions, including the two MeshCore still lists under its own "(Deprecated)" names, because nodes that never re-tuned are on them and picking one is how you go and listen. The names are spelled as MeshCore spells them so the row can be read against the phone app. Four regions also name a path-hash size, which the preset now stages alongside the radio fields as the firmware's mode (size - 1), exactly as MeshCore's own config GUI converts it. The rows moved to the two-lane menu shape — name, then the parameters in MeshCore's print order — which fits 53 columns where the old one-line title ran to 85, and the list opens on the preset the radio is already tuned to, staged values included, so picking a neighbour is a comparison rather than a guess. The trade-off pair is gone with them. They were ours rather than MeshCore's, they pinned a deprecated EU frequency onto whoever picked them, and the wide / mid / narrow choice they were reaching for is one the region list now makes properly per region. The simulator boots on the firmware's build defaults too (869.618, BW 62.5, SF8, CR5 per MeshCore's platformio.ini), rather than on the settings the EU mesh left behind. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
0b719a4736 |
The client nobody closed, closed
A Bluetooth session that lost its companion could not get it back, and the reason was one call that four separate layers each declined to make (JP, 2026-09-04). When the peripheral is what goes away, bleak fires `BLEConnection`'s dropped-link callback, which restores the connection's fields to what the caller originally passed — setting `client` back to None and letting go of the live object. `BLEConnection.disconnect` then guards on `self.client and self.client.is_connected` and has nothing to close; `ConnectionManager .disconnect` guards on a flag its own drop handler already cleared; `_force_close_transport` reaches past both, but only as far as that same `BLEConnection`, whose disconnect is the no-op above. Every guard is locally right and the sum of them is that `BleakClient.disconnect()` is never called on a link that dropped by itself. On Windows the WinRT `BluetoothLEDevice` and its GATT session then stay open for the life of the process, and every later connect to that address is served a broken service table: the link comes up and the UART subscribe fails with "Characteristic 6E400003-… was not found!". The device advertises at -61 dBm, answers a hand-written APP_START over raw GATT with a valid SELF_INFO, and is unreachable to this app until it restarts — while a fresh process connects to it in 0.6s. That asymmetry is the whole tell, and it is what turned every reconnect attempt into a fast, inexplicable failure. So the client is ours now: taken at connect while the library still has one to give, and closed unconditionally at teardown — never guarded on `is_connected`, because the case that matters is exactly the one where it is already False. Bounded and silent, since a teardown may not raise or hang, and a no-op on the transports that have no client to hold. Measured on the real companion: the session drops, is heard again 7.2s after the device comes back, and is rebuilt 0.97s later — 8.3s from drop to live, where it previously never recovered at all. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
c090db829c |
A returning companion is heard, not guessed at
Bluetooth notices a drop cleanly — the client's connection flag flips the
moment the peripheral goes — but the way back was two guesses stacked on each
other, and neither held (JP, 2026-09-04).
The reconnect flow gave serial a real question to ask ("has the port
re-enumerated?") and gave Bluetooth nothing: it simply attempted the connect
every couple of seconds. Each of those blind attempts drove bleak's own
internal address lookup into a device that wasn't advertising, which is a slow
failure, so the attempts sprawled across and past the window in which the
companion actually came back. And when one finally did land, it landed holding
the `BLEDevice` the startup scan produced — a handle that names a peripheral
the OS no longer has, because a device that power-cycles comes back as a new
one. The session opened over BLE and then, having dropped, could not find its
way back to a radio sitting a foot away with its light on.
BLE now gets the same shape serial has, asked of the only registry Bluetooth
keeps: `find_ble_device` watches for that one address's advertisement and
returns the instant it is heard. The answer arrives with a live handle, so the
listening and the fixing are one step — the reconnect opens the peripheral
that is on the air now, and `reconnect(ble_device=...)` prefers it over
anything the picker scanned. A miss costs a scan window rather than a failed
connect, and nothing is attempted against a device that isn't there.
The ordering is load-bearing, so the teardown splits out as `release_link` and
runs before the first scan: a companion we are still holding a link to does
not advertise, and the old flow's first act was a connect attempt that dropped
the dead client on its way past. Waiting first would have waited out a device
that was powered on and silent purely because we hadn't let go of it. The
resume intent is captured there and held across retries exactly as before.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
c8c7eab128 |
A direct message's frames are its own, by the MAC over its ciphertext
The paths on a DM listed a message's own retransmissions, the other end's traffic, and both of those for every other message sent in the same minute and a half. On one real bob_caribou message that was 30 rows over 8 paths, of which 23 were the same two one-hop routes repeated. Those one-hops were the tell (JP): they were our *own* sends, overheard coming back off the two repeaters in earshot, correctly showing one hop because one hop is all they had travelled — but shown under the message as if they were its route. The channel view has always matched by decrypted content, and asked for here. A direct frame cannot be read, but it does not need to be: its body is [dest 1B][src 1B][MAC 2B][ciphertext], and that MAC is a tag over this message's plaintext. Copies of one message share it; the next message's differ. frame_addressing already knew where those two bytes were and threw them away, and the observations table already had a cipher_mac column its channel sibling used — so a direct message now groups exactly as a channel one does, with no schema change and nothing decrypted. Three filters, in order. The frame ran between the conversation's two ends; it travelled the direction this message did; it carries its group's MAC. The middle one is doing more work than it looks: both ends' hashes sit on every frame either way, so matching on the pair alone was what put our sends under a received message. The window is clamped by the conversation's own messages rather than a flat ±90 s — nine messages fell inside one such window. The clamp reads only messages going the *same* way, which the first cut of it got wrong: an inbound stamp is the sender's clock, so ordering it against our own sends compares two clocks, and a received message came back with an empty window. The directions are also bounded differently, because we know different things about them. A send is stamped by our clock as it leaves, so no frame of it predates it and all the room goes forward to the next send, where the retries are. A received message keeps a centred window, halfway to the received messages either side. Rows are paths now, not frames: identical routes fold into one line carrying its copy count, its first sighting, and the best SNR that path managed. Twelve identical lines said "twelve arrivals" where the truth was "two paths, six times each". Measured on the conversation that prompted this, whose history predates the MAC and so exercises only the direction and window fixes: outbound "Allo! Ça marche JF" 30 rows / 8 paths -> 2 rows (x3 each) inbound "J'ai pas de ack..." 30 rows / 8 paths -> 2 rows, 6 and 7 hops which is exactly what the packet log says by hand. Old history keeps the address-and-time fallback and is billed as such; frames recorded from now on match exactly, and say so in the same words the channel view uses. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
424c33ac93 |
The purge is an edit, and archiving is not a deletion
JP's pass over the sweep, and one cut corner it found: the gallery specimen hand-stamped its percentiles, so three contacts rendered as the 2nd, 7th and 11th of a field of three. The number cannot be written down and still be true — it is a rank against the others in the same list — so the specimen now scores through rank_contacts like everything else and reads 10/30/50. The computation was never wrong; the picture of it was. The ladder answers in the number the reader is choosing: how many contacts you *keep*, the one that has to fit the device, with what goes as the muted remainder. It also stops rounding with round(), whose banker's habit sent 4.5 and 3.75 to the same 4 and made "keep 90%" and "keep 75%" identical rungs on a five-contact table; ceil is both distinct and the safe direction on a keep. The preview is editable. Delete lifts one contact out of the sweep and the list refreshes through replace_items, so sparing the one node you recognised no longer means backing out to a shallower rung that also spares forty you didn't care about. Rows h-scroll with the percentile lane pinned out of the shift — it is your place in a list ordered by it. Neither the scroll atom nor the keep atom is written into the base hint; the select list splices each in where its key would act, which is also what keeps all three inside 72 cells. It is a hub now, held by session.stay: re-running run_screen on a screen that had already resolved spun forever the first time a row was spared. Opening a candidate's page from in there offered to delete it, which was two answers to one question. open_node_detail takes manage=False: the rule is that management verbs belong to the list a contact lives in, never to a page opened out of a list about to act on it wholesale. The confirm is amber and button-only. Two caution tiers exist for two costs, and a red typed gate here spent the app's loudest warning on its most reversible bulk action. Red is left to the deletion, which now says what it is — the key forgotten by both sides, no restore, only being heard again — and points at the archive as the reversible way to free the same slot. The page carries all three verbs: archive a live contact, restore an archived one, delete either for good. Archived contacts get their own screen rather than a section nailed to the foot of the Contacts list, reached by a row under the purge carrying the tally. That needed the shared contact list to stop believing every list has the same columns: the middle lanes are now a declared tuple of ContactLane (NAME and KEY stay fixtures), read by the header, the row builder, the sort metric and the width arithmetic alike, replacing a show_traced flag that had already made three of those four say "and if it's the trace picker…". The archived list declares NAME · ARCHIVED · KEY and sorts on exactly those. ARCHIVED draws as HEARD does — a relative age under recency heat — because it is the same question about a different event. One simplification falls out: TRACED sorted on a raw timestamp and opened descending to mean newest-first, alone among the age columns. Every age lane now sorts by age with never at +inf, so traced opens ascending like heard, and reads the same either way. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
99cd616ae5 |
The purge keeps the contacts worth a slot, and archives the rest
A device's contact table is finite, and a busy mesh fills it with whatever adverts arrived — mostly nodes heard once, in passing, four hops out — until there is no room left to discover anyone new. The age ladder could only ask how long ago; it had nothing to say about which of two equally quiet contacts was the one you would miss. So contacts are now rated. Six weighted terms, each normalised and summed: direct correspondence heaviest at 30, then how lately heard (25), how often (15), channel posting (12), hops (10) and distance (8). Additive rather than multiplicative, because a product lets one zero annihilate a contact that is strong everywhere else — a node advertising no position would have scored nothing however much you talk to it. The rule the whole thing rests on is that an unknown scores *neutral*. Half a real mesh advertises no location, plenty of nodes are never overheard as a relayed frame so carry no hop count, and a channel poster whose name two contacts share can be attributed to neither — the wire gives a channel frame no sender key at all. A term that cannot be computed takes the population median of the contacts that could, so the decision falls to the axes that are known. Scoring those as zero would have swept by how much metadata a node happens to broadcast. It is also why the two least reliable terms carry the two smallest weights, and why distance calibrates against this mesh's own median spread rather than a constant: 50 km is far downtown and unremarkable in a valley. A newcomer gets 25 points decaying to nothing over a fortnight, because every other term rewards accumulated evidence and a node first heard this morning is otherwise arithmetically identical to one quiet for a year. Four things are never candidates at all: a watched node, anyone you have sent a message to, a repeater whose admin login is stored, and a contact MeshTerm has never heard — that last one predates this history, and sweeping it would be purging by how long the app has been running. They still rank, since a percentile that dropped them would not be a rank against your contacts; they just consume no kept slot, so starring a node never deepens the next sweep. Only the percentile is ever displayed. A raw 47.3 means nothing without the distribution it came from and would need a legend the moment the weights were retuned. The victims are archived, not deleted: off the device, which is the scarce resource, and kept here with a stamp. Everything else was already independent of the contact row — reception history, map position, transcripts — and the store keeps the full key, so a restore is one write, which the chat screen already performs on demand when a send is rejected for an unknown recipient. merge_contacts learns to withhold them, or the union would put them straight back and the sweep would look like it did nothing. The old age ladder survives as the second section of the one picker, because "everything I haven't heard in a year" is a plain predictable operation a ranking cannot express. Both routes converge on the same preview — weakest first, with each row's percentile and the two or three facts that put it there — so an age rung reaching into contacts that rank perfectly well says so before the typed confirm rather than after. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
0fa8290add |
Contacts: a contact the device never held is still ours to remove
The list a screen removes from is the union of the device's contact table and the contacts MeshTerm remembers for it, so an entry can exist only on our side — or the firmware can drop one since we last read. Removing such a contact hit ERR_CODE_NOT_FOUND and reported "couldn't remove", leaving a row the reader had no way to get rid of. The device layer now raises ContactNotOnDeviceError for that code, the same class (and the same table lookup) the send path already raises. The single removal reports it as a warning naming what happened, forgets our half and ends the visit; the purge sweep counts it as purged rather than failed. The simulator refuses the same way, so the path is walkable under --mock. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
c6e6ee8a60 |
Chat: a contact the device forgot is offered back, not a wire error
Sending to a contact the firmware no longer holds came back as
`send failed: failed to send message to 'bob_caribou': {'error_code': 2,
'code_string': 'ERR_CODE_NOT_FOUND'}` — a wire constant in a status line, and
no hint of what to do about it.
It is reachable for a contact MeshTerm itself listed. The list a screen sees is
the union of the device's live table and the contacts MeshTerm remembers for
that device (core/contact_store), which exists so a RAM-only radio bridge still
shows the nodes you know. The store claims those stay messageable without
writing anything back — true for the bridge, false for a firmware companion,
which addresses a direct message by looking the recipient up in its *own* table
by a key prefix and refuses when nothing matches. So a contact the firmware has
dropped still lists, still opens a chat, and only the send finds out it is gone.
Now the rejection is its own class carrying the contact, and the chat offers the
one write that fixes it: "bob_caribou isn't in this device's contacts, so the
radio can't address it. Add it back and send?" — Cancel or Add & send, then the
same send runs again. Declining reports the refusal in words. The write is
offered rather than silent because it changes what the device stores, and a full
contact table refuses it, which is worth seeing. Retry (^R) takes the same path.
Adding a contact is new to the Device contract (the inverse of remove_contact,
ADD_UPDATE_CONTACT on the wire): the record carries the key, name, type and last
advertised position we already hold, with no learned route, so the first message
floods exactly as it would for a freshly-heard node. The name is clipped to the
32 *bytes* the firmware field holds, not 32 characters.
Every other rejection now reads as a sentence too — reject_reason maps the six
error codes to plain words, so a send, an admin command, or any _ok()'d command
says "the device's table is full" rather than printing its payload dict. The
simulator refuses a recipient it doesn't hold, exactly as hardware does, so the
whole offer is walkable under --mock.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
e0a681b293 |
Busy screens: stop the spinner starving the work it reports on
On the PicoCalc a repaint costs about 154ms, and these two loops waited 60ms (the overlay) and 120ms (the splash) between them — rates hardcoded past spinner_interval(), which every other animated wait in the app already sleeps on. The animation asked for repaints faster than the console could finish them, so it took the event loop from the device read it was covering for: the wait got slower for being animated, and the spinner stuttered anyway. Both defer to the platform now (0.5s there, 0.12s on the desktop). Two calls were also blocking the loop outright, which stops the animation dead however it is paced. Enumerating serial ports is a SetupAPI/sysfs walk — behind the "Scanning for companion devices…" splash, and again on every poll of the reconnect dialog — so both go to a thread. The UI itself cannot: prompt_toolkit owns the loop for render and keys. Moving the blocking work off it is the same fix from the other side. Two tests: neither busy screen may carry a spin rate of its own, and the spinner advances *during* an awaited read rather than only side of it. Also drops the "· experimental" tag from the network-device row. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
4e3208b1c2 |
Admin login: the repeater is not charged for the queue ahead of it
Remote administration still failed. My last two commits classified the failure correctly and fixed the credential policy, but the login itself kept coming back as no reply from repeaters that were up, traced, and holding the right password. The wait I added was counted from the wrong moment. `budget` is the *node's* answer window, but the clock started before `send_login_sync`, and almost none of what that call spends is the node's: it first waits its turn on meshcore's mesh-request lock — which every telemetry poll, status read and courier retry holds for a whole round trip — and only then blocks until a MSG_SENT the library correlates by event type alone arrives. Whatever that came to was subtracted from the repeater's window, so the fix read as "wait longer" and behaved as "wait the same ten seconds, minus the queue". A send that outlasted the budget left the node no window at all, and the log bears the shape out: both attempts to YUL-UpperSalaberry ended at 9985 ms and 10015 ms — the budget exactly, spent from before the request was on the air. So the answer is timed from the send, the way `run_trace` times its reply. And the route sizing is a floor rather than a verdict: a login is an admin exchange out and back, not a trace's single small packet, so a contact we hold a one-hop route for was being given a narrower window (7.2 s) than the routeless contact beside it that floods (10 s). Knowing where a node is must not make us give up on it sooner. The rest is making the next failure readable, because this one was not. A no-reply has three causes that the old line could not tell apart, so it now reports where the time went — the send's own duration, the budget, and how long the node had — and quotes the frames it heard but could not act on: a LOGIN_SUCCESS/LOGIN_FAILED naming some other node (a key prefix that did not match, not a quiet node), and a companion ERROR, which is the one failure that never reaches the mesh and which `send_login_sync` erases into the same bare `None`. Uncorrelated, so it is evidence in the log and never a verdict. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
7633f5153d |
Admin login: hear the answer, even when the library has stopped listening
A repeater that is up, with the right password, was answering "no reply". My last commit did not cause that — it renamed it. The failure was already there, mislabelled as a wrong password (and clearing the credential on its way past, which is how it got reported in the first place). `send_login_sync` does not start listening until its own send returns, and that send blocks until a MSG_SENT arrives — which the library correlates by nothing but its event type. So a scheduled advert, a telemetry poll or the courier can consume ours and leave the send sitting on its 15-second default, and every answer that lands during the stall is dispatched to no listener and dropped. The login the repeater accepted is recorded as silence. The mirror case is as bad: catching another command's MSG_SENT takes its `suggested_timeout` with it, and a neighbour's second or two is nowhere near a multi-hop repeater's round trip. `run_trace` already documents this exact trap and already solves it, so the login now does what a trace does: subscribe to LOGIN_SUCCESS *and* LOGIN_FAILED before transmitting, and keep listening across the whole exchange. `send_login_sync` still transmits — it is the supported path, and its own listener is harmless, the dispatcher delivers to every matching subscription — but ours is armed first and outlives it. When it gives up early we keep waiting for the rest of a budget sized to the route: a login walks out along the contact's hops and back, which is the shape `trace_timeout` already describes, so the wire carries twice the stored one-way route. A contact we hold no route for floods, and takes the flood budget. The classification falls out of that — the two real frames now reach us, so ACCEPTED and REFUSED are read off the frame instead of inferred from a `None`. The outcome is logged at debug (budget, verdict, elapsed) so the next "no reply" is diagnosable from the JSONL rather than by argument. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
667c0321e4 |
Admin login: silence from a node is not a wrong password
Administering a repeater that happened to be down made MeshTerm forget its admin
password. The node had said nothing at all, and we took the silence as a denial.
`admin_login` returned a bool, and all five callers read `False` as *wrong password* and
dropped the credential. Underneath, they could not have done better: meshcore's
`send_login_sync` waits for LOGIN_SUCCESS and only LOGIN_SUCCESS, so a refusal — which
the firmware does send, as a LOGIN_FAILED frame the library parses and dispatches like
any other event — times out exactly like an unreachable node and comes back as the same
`None`. Our own `etype in (ERROR, LOGIN_FAILED)` branch could never fire.
So the device now watches for that frame itself, subscribed before the request goes out
because the refusal can land the moment the request does, and answers with a three-way
`LoginResult`: ACCEPTED, REFUSED (the node said no), NO_REPLY (nothing came back — which
includes a companion-side error, where the request never even left the radio). It is
truthy only when logged in, so `if not await device.admin_login(...)` still reads "we are
not in"; a caller that acts on the failure has to name which failure.
What that means for the stored password now lives in one place, `AdminStore.record`:
remember on accepted, forget on refused, leave it exactly as it is on silence. It was
five copies of the policy, and every copy was wrong the same way. Each surface still
phrases its own message — the sweep says "sweep again", the CLI says "re-run" — and a
no-reply now says so plainly ("No reply from X — it may be out of reach, asleep, or busy.
The saved password was kept") instead of accusing the operator of a typo. The trace
screen's forget-on-DeviceAuthenticationError goes with it: the credential is settled
where the outcome is known, and an exception there is only a message to show.
A source-level test walks the package's AST and holds the line: anything that calls
`admin_login` records the outcome through the store, and nothing reaches for `forget()`
to decide this on its own.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
9ff25b3709 |
Device config: a coupled setting must not re-send a stale sibling
Restoring a backup onto a freshly flashed companion put the identity and the channels back, reported all eighteen operations applied, and left the node advertising from latitude 0.0 on the factory frequency. Latitude and longitude reach the firmware through one command, and so do the four radio parameters, so changing one means re-sending its siblings unchanged. Those siblings are read from the caller's snapshot — taken once, before the first write. Applying adv_lat preserved the stale longitude; applying adv_lon then preserved the stale *latitude*, undoing the first write. Same shape for radio_freq followed by radio_sf. Nothing errored: each op did exactly what it was told, with a picture of the device that was two writes out of date. So each coupled applier now records what it set. Any later sibling in the same batch preserves the new value rather than the one that was true before the batch began — whether the batch comes from config restore or from the editor's staged changes, which had the same hole. And the Device PIN row, found while writing the restore instructions: it read 'device_pin' out of a snapshot that only ever held SELF_INFO, while real firmware reports the code as 'ble_pin' in the device-query frame. It could therefore only ever render "?" on hardware — writable, with no way to see what you wrote, so a typo sat in NVS until the next pairing. The snapshot now folds in that frame (SELF_INFO still wins where they overlap, as probe_device already had it), the row reads the firmware's own name while keeping the key its backups and CLI use, and the simulator reports it the same way so --mock shows the same screen. Verified on the reflashed device: the row reads 701307, and model and firmware version arrive with it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
337792d4d1 |
BLE: closing the client is not closing the link
Owning the meshcore client was necessary but not sufficient, and the device said so: the same probe still went off the air. ConnectionManager.disconnect closes its transport only if _is_connected, a flag it sets *after* connection.connect() returns. The GATT auth error is thrown from start_notify, long after bleak brought the link up and well before the manager records anything — so the manager is certain there is nothing to close while BLEConnection is still holding a live, connected BleakClient. Calling mc.disconnect() and stopping there looks exactly like a teardown and leaks the link anyway. So _discard_meshcore now runs both halves: the graceful call, which stops the dispatcher and cancels any reconnect task, then the transport closed directly, which is what actually drops the link. BLEConnection.disconnect re-checks client.is_connected, so the second close is a no-op whenever the first one sufficed. That forced path already existed inside disconnect() for the dispatcher's queue.join() deadlock; it is factored out as _force_close_transport and shared, so the two teardowns cannot drift. The tests grow a fake that models the manager's guard rather than counting disconnect() calls, so they assert the link went down instead of asserting a method was invoked — the distinction the first attempt failed on. A test named for that mistake pins it; reverting to graceful-only fails seven of the ten. Verified on hardware, instrumented: the auth path now shows is_connected True -> False inside the discard, the client ends at None, and the peripheral keeps advertising. Full lifecycle clean in one session with no power-cycle — PIN-less probe, PIN retry, bonded session with real traffic, mid-session bond query, Unpair & quit, and a relaunch after it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
d3735c8f7b |
BLE: a connect that fails must put the link back down
MeshCore.create_ble builds its client, calls connect() on it, and hands it back only on success. A connect that *raises* therefore left that client — and the bleak link it had already opened — orphaned inside the library with no reference we could close. Our _mc was never assigned, so disconnect() was a no-op and the probe's _safe_disconnect closed nothing. That is not a corner: a PIN-protected companion answers the unbonded notify-subscribe with a GATT authentication error, and the picker's first attempt is always PIN-less. So selecting an unbonded companion leaked the link, Windows held it for the life of the process, and the peripheral — still believing it had a peer — stopped advertising. The PIN dialog then asked for a code it could no longer deliver: the retry paired at the OS level (the bond really is created) but could not form a GATT session, and the user was told their correct PIN belonged to something that "isn't a MeshCore companion". Since Unpair & quit is what leaves you unbonded, the whole thing read as unpairing having changed the PIN. Assemble the two objects here instead. _connect_owned_ble keeps the handle, so both failure shapes close it: a raise (closed, then re-raised) and a None handshake (closed, then reported as "not a companion"). The teardown is shielded — the other way in is a probe whose wait_for expired and cancelled the handshake, where a plain await would be cancelled the moment it suspended and abandon the very close it was called to perform. The picker's accepted PIN now also rides on the context, so a mid-session reconnect doesn't re-run the whole "needs a PIN" dance against a companion we already authenticated to. Session-lifetime only; nothing reaches disk. Tests stop naming a real companion: the addresses and pairing code are stand-ins now, and the fakes model the class we construct rather than the create_ble we no longer call. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
6217a7dc58 |
Packets: the frames a neighbour sends were being thrown away
Two silent drops in the RX-log mapper, and between them a device sitting beside this one could trace all day and never appear in the feed. A frame that crossed no relays was discarded as having "no topology content". It has the most there is: nothing stood between us, so we heard the transmitter itself. Only an advert survived, and only because it carries an origin key — every trace, message, request and ack from an adjacent node went into the bin. Now a frame is kept unless the library could not even give it a payload class, and the empty path says what it means: zero hops crossed. The other is a trace reading its own header wrong. Every class keeps relay hashes in the path field; a trace keeps one signed SNR byte per hop it has traversed. Read as hashes those bytes resolved to whichever nodes shared their leading digits and entered the topology graph as links that were never observed. The population says so plainly: across 1604 stored traces, all 2221 path entries land inside the LoRa SNR band when read as signed bytes, spanning -10.5 to +15.0 dB, where hashes would put five in six outside it. So a trace now yields no hops, and its readings — which are worth having — ride alongside as trace_snrs. The 1604 rows already stored keep their bad paths; a one-shot cleanup follows separately. |
||
|
|
936ab10770 |
Traces: listen for the reply before the send goes out
A trace subscribed to its tag only after send_trace returned. That send waits on the companion's MSG_SENT, which the meshcore library correlates by event type alone — so any other command in flight (a scheduled advert, a telemetry poll, the courier) can consume ours and leave the send blocked on its own 15-second default. Every reply that landed inside that window was dispatched to no listener and dropped, and the walk recorded as "no reply" though the mesh had answered it. Because the traffic that steals the acknowledgement is periodic, the condition outlives the trace that hit it: traces keep failing for as long as it lasts. Subscribe first, stamp the reply's own arrival so a stalled send inflates no round trip, and log every trace and every reply heard so a silent walk can be told apart from a deaf one. The other half is pacing. run_traces sleeps between its own samples and never after the last one, so at one trace per candidate — the path probe's default — it paced nothing at all, and the sweep walked every candidate back to back. Same hole across the TX optimizer's level boundaries, and on the trace screen, where aborting a walk and hitting Enter again transmitted immediately. Repeaters penalize a node that bursts, and a penalized node's every later trace comes home empty. Pace between probe candidates and TX levels, and measure the screen's cooldown from its last transmission rather than only from the previous sample. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
e53e35523e |
Map: draw the ground off the keystroke, and stop reprojecting the world
A pan cost 0.9-2.4 s. It was never the tiles - those already load in a thread - it was render_map, which rasterizes the vector ground on the paint path: 900-2342 ms for a view holding ~16k features. Two changes, in that order. The projection was doing the same trigonometry once per vertex. Every feature_to_dot call recomputed Viewport.origin_world - a sin/log pair - and a 2** for values constant across the whole frame, 107k times a frame. The mapping is affine in tile-local coordinates, so tile_transform folds it into three numbers and _draw_tile spells the arithmetic out inline: two multiplies and two adds per vertex, no call at all. That alone is 2.4x (z12 2342 -> 991 ms). The rest is genuinely per-feature Python and will not shrink to keystroke size, so the raster moved off the paint path. A paint now returns the best picture available immediately and a background task draws the real one: unchanged view serves the finished frame; a view that only gained a tile keeps the old raster, which is still correctly aligned; a view that *moved* draws the nodes alone on the new viewport, which is a few ms, so panning tracks the keys and the streets catch up. The title says "drawing..." while it does. Exactly one raster runs at a time and it is always the newest requested - a held arrow hands us a new viewport every repaint, and starting a second of thread-bound work per keypress would queue frames that are already stale on arrival and slow the keystrokes this exists to protect. On the device: pan 1205 -> 89 ms, 1156 -> 130 ms, 2449 -> 91 ms; zoom 1161 -> 142 ms; a settled view 37 ms. Also flips MESHTERM_FASTRENDER on by default (=0 still opts out), and asks whether a loop is running *before* building a coroutine, so a static render no longer leaves an un-awaited one behind. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
71e979eadb |
Tile decode: decide the layer once, on the way past
The narrowing walked each layer twice -- once for _layer_head to read its name, once to decode it -- which is free when there is a lot to skip and a straight loss when there isn't. Measured against a cache spanning zooms 2-14: low-zoom tiles carry no buildings, housenumbers or POIs at all (a z10 tile is 98% drawn layers, a z2 tile 100%), so the whitelist saved them nothing while the extra walk cost 16-18%. The name is field 1 and in practice the first thing written, so the walk already knows by then whether the rest is worth keeping; from there an unwanted layer is stepped over rather than copied out. Field order isn't guaranteed though, so the flag is only an optimisation -- the decision is the check after the loop, which is right however the fields arrived and also covers a layer declaring no name at all. _layer_head goes away. On the regular platform this turns a 0.97x into a 1.03x on low-zoom tiles and 1.00x on the largest, while urban z14 tiles keep their 3.19x; the whole 293-tile cache goes 1.4x -> 1.6x. On the Lyra the median tile is 3.24x and the largest 4.85x, both up. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
504ee37b9a |
Tile cache: write the decoding down, not just the bytes
The layer narrowing cut what a tile costs to parse; this stops us paying it twice. Decoding is a pure function of the bytes and the layer set, but the cache only held the bytes, so every session re-parsed the same tiles from scratch -- and parsing is the single most expensive thing this app does. A decoded/ sidecar now sits beside the raw tiles holding the parsed layers, via marshal: stdlib, C-speed, and it understands the plain tuples and scalars a decoded tile reduces to. Deliberately not pickle -- this reads a file off disk, and marshal cannot be talked into importing a module or calling a constructor. The sidecar is derived data throughout, and the design leans on that. It is never what makes a tile "known", so losing it costs only the decode it was saving. Every way it can fail to be what this build expects -- bumped wire version, a Python whose marshal differs, a truncated file -- reads as a cache miss rather than an error. It carries a stamp of the layer set it was decoded under, so widening DRAWN_LAYERS re-decodes instead of serving a narrower blob. And because it runs ~2.4x the size of the bytes it came from, it is the half of the cache that gets a budget: 64 MB, LRU by mtime, swept once per 8 MB written rather than per tile, since the walk is slow on the SD card the PicoCalc runs from. Measured on the device over the 50 real cached tiles: a first session costs 126 s and a later one 13 s, 9x, with all 50 tiles restoring identically. Disk goes 7.8 MB -> 7.8 + 19.0 MB. Serialising adds ~13% to the first decode. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
4e7bcacc37 |
Tile decode: don't pay for the layers the map never draws
Profiling on the Lyra found vector-tile decode dominating everything else in the app by about two orders of magnitude: a median cached tile took 1236 ms of pure CPU, the largest 3.4 s, against 16 ms of SD read for a whole viewport. Decoded tiles are memoised for the session, so this is a first-pan cost -- but it runs on a GIL-bound worker thread, so it starves the render loop for those seconds rather than running beside it. Roughly 40% of that work was thrown away. A planet tile ships building, housenumber, poi and mountain_peak; _draw_tile looks up ten layer names and none of them is those. So decode_tile now takes the set of layers the caller actually wants, reads each layer's identity with a cheap header walk, and decodes the features only for the ones asked for. Unwanted layers are still returned, named and empty -- which matters, because the tile source decides whether a cache entry is real by whether the bytes parsed into layers, and a tile whose every layer we skip must not read as blank and get its perfectly good cache entry pruned and re-downloaded every session. That test moves off "has features" and onto "parsed into layers", which is sound because the other two ways a tile isn't real -- empty and corrupt -- decode to nothing and raise respectively. Only the decode narrows; whole tiles are still cached, so drawing more later costs a re-decode and never a re-download. Measured on the device across the 46 real cached tiles: 183 s -> 51 s, 3.6x, with the drawn layers byte-identical on every one. The median tile is 1259 -> 353 ms, the largest 3545 -> 759 ms. _Reader.skip stopped slicing out the bytes it steps over while it was here, which is most of what makes the header walk cheap. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
935b4fb3b6 |
PicoCalc: nodes colour by key, like everywhere else
A platform's ceiling may change a rule's resolution, never the rule. P3 had picocalc colour node names by *type* instead of by key, so a name's colour there meant something different than it does on the desktop — the node's kind, not its identity. Both platforms now run one rule: the key's first byte picks the hue. The console just spends fewer of them. node_style gains the binding the heat scale already had. Regular keeps the full 256-hue wheel; picocalc snaps the same hue to its sixth of it — the six chromatic bright slots, ~43 first bytes each. It returns the slot's own hex rather than a color(N), so every downsample on the way out (Rich's, and the fold's quantizer) lands on that exact slot instead of guessing a neighbour, and the callers that read an RGB back out of a style string keep working. The type marks needed the opposite treatment: their hues are fixed, not derived, and a naive nearest-RGB match drained the repeater's violet to grey — a repeater read as an unknown node. They move to the theme's type.* entries so each platform picks its slot deliberately, and a braille raster resolves the same entry through theme.mark_rgb, so the canvas marker and its Rich-drawn twin can't drift. With names off the type registry, nothing reads it: Platform.name_colour and core/nodetypes.py go, along with the three reception-layer feeders. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
f69d1785b7 |
Performance sweep: cache the render funnel, the queries, the graphs
Every repaint re-rasterized every row and re-ran every layout; every screen open re-scanned the whole history. Now work is done once per change instead of once per frame: Render pipeline — a content-keyed ANSI cache in render_to_ansi (every Text/str row app-wide), memoized corner glow, and panel-wrap memos for the base frame and stacked dialogs, all dropped on a platform switch or emoji recalibration. Idle-frame compose falls 5-100x per screen (contacts 5.6->0.1 ms, record card 8.5->0.07 ms, trace 7.6->0.6 ms). Repository — an observed_at index turns every since-window query into a range walk (recent_observations 7.5->1 ms); heard_nodes and first_seen aggregate in one streaming pass by ISO-string comparison instead of hydrating dataclasses and sorting; node_names groups in SQL (NOT INDEXED past a slow planner choice). Per packet — livefeed no longer repaints on events that drew nothing, the channel list's stats TTL rises above the tick so the repository is not queried per frame, watch-store alerts batch through the throttled flush instead of a full-state disk write per new node, and the header's 360-bucket histogram/flags tuples are memoized per minute and packet. Per open — the resolvers, topology canonical()/display_name(), and Yen's route search memoize over their frozen inputs; timemachine, chat, and livefeed drop duplicate queries; the config editor, device actions, info, advert, and tx-optimize reuse the devstate session cache instead of re-asking the radio. Per frame, per screen — dashboard folds five window scans into one digest; walk caches everything derived from its frozen graph (the onward-count quadratic included); packet viewer, record dialog, trophy rows, trace stats/log, and the node-detail route fan memoize on their frozen inputs, invalidated by revision counters where the input can move. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
84caae53f8 |
P3 rework: the PicoCalc visual language, done properly
The first P3 (a84abf3) ran on the wrong model and its palette never reached the TUI: MESH_THEME_16 was written in 256-colour cube indices instead of the 16 VT slots, and the platform theme pick was wired into the scripted-CLI console while the real rasterizer stayed hardcoded to truecolor. Replace it end to end: - theme._VT_SLOTS: the canonical slot->RGB design (conventional hue families kept; slots 5/6 become the track/faint slates), MESH_THEME_16 rewritten against color(0..15) with the VT's bold-as-brightness and dim-bank-background rules pinned by tests. /etc/vtrgb + a boot oneshot install it (console-font script), OSC fallback when kbd is absent. - platforms.on_platform: set_platform now re-runs registered bindings, so theme, rasterizer and widgets swap implementations once per switch and hot paths read module globals - no per-call get_platform(). - The render-boundary fold (theme.fold_text): one str.translate pass (NFKD accent folds - the Terminus base has no accented Latin - plus symbol stand-ins and the width-padded emoji map), an embedded-SGR quantizer for canvas truecolor, and a ?-at-own-width catch-all that makes the no-wide-glyph short-circuit true by construction. Applied at the only two places every visible byte passes: render_to_ansi and MapCanvas.to_ansi_lines. - ui/fontset.py freezes the installed font's inventory (dumped live); the gallery now asserts rendered picocalc ANSI carries no truecolor/ 256-colour SGR and no character outside it - the parity gate the first attempt faked by asserting a dataclass field. - Font build: nine new 6x12 marks (ellipsis, warn, backspace, shift, gear, refresh, clock, crosshair, padlock) drawn into donor slots, with donor misses now fatal and a keeper canary (donating pi once erased Cyrillic pe - shared slot). Table re-dumped on-device: identical to fontset.py, 519 = 519. - Type-based name colouring: registry moved to core/nodetypes (services no longer import ui), fed from monitor observations, heard_nodes and merge_contacts. Heat gradient quantizes to heat.* steps on picocalc. - ui/marks.py: the P2-deferred constant relocation - widgets no longer drags map_render/mapcanvas/pathgraph for tuples and aliases. - meshterm specimen: the visual language on one card through the real funnels - the on-device acceptance screen (JP's request). - tools/chat: delivered/no-ack state uses the standard check/query marks, not the banned emoji pair. Verified on the Lyra: font+palette installed, specimen framebuffer captures in .claude/plans/. 1259 tests green, 13 xfailed (P6 list). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
63cd4e5f96 |
Performance: SQLite WAL, lighter startup, per-platform tick rates
PicoCalc plan phase P2, driven by measurements taken on the Lyra as a paired A/B (git archive HEAD vs the working tree, run side by side against the same venv). The headline is the database. Every packet the monitor hears is one durable commit, and on the SD card each was costing 33.78 ms of fsync. db._tune() opens in WAL with temp_store=MEMORY: 0.59 ms per commit, a 54x cut. synchronous=NORMAL is requested only once WAL is confirmed engaged - the pragma returns the mode it settled on rather than raising when a filesystem refuses it - because under WAL it risks the last transactions to a power cut, and under the rollback journal it risks the file itself. This device runs on a battery pack. Startup: bleak/dbus-fast were already lazy; the real finds were two cheap *values* dragging heavy subtrees. core/connection.py imports one constant from core/channels.py, which imported PyCryptodome at module level (224 ms of CPU-feature probing per run) - now deferred into the two functions that decrypt. And tools/map.py's register_cli, which runs for every tool at boot, reached into ui/map_screen.py for a --fraction default, dragging the basemap's urllib.request -> http.client -> ssl behind it; DEFAULT_VIEW_FRACTION moves to core/geo.py (pure arithmetic, already on the boot path) and is re-exported so existing importers are untouched. 26 modules and 316 ms of import self-time gone. Per-frame: the corner glow only ever recolours truecolor foregrounds, so on a 16-slot console it scanned every line of every frame to hand back the identical list - skipped outright where effects are off, along with the battery blink and the braille spinner cycle. _has_wide_glyph answers from the platform when no emoji can be drawn instead of scanning the composed frame (6.5-9.1 ms per repaint on its own). The header built its segments twice to measure the compact separator, on exactly the narrow terminals that take that branch every frame; it now builds once and measures arithmetically. Together: 101.2 -> 73.2 ms per frame at 53x26, 151.8 -> 110.4 at 53x40, and 72x24 unregressed at 91.7. That finally gave numbers to set the clocks against. refresh_interval becomes per-platform tick_s (2.0 s on picocalc: a 1 Hz idle tick alone was 7-11% of a core doing nothing, and only the header's per-minute pulse drifts, since screens push their own repaints via invalidate). The 0.12 s spinner was untenable - 84% of a core at 53x26, and at 53x40 it did not fit in its own interval at all. Five duplicate _SPINNER_INTERVAL = 0.12 constants across the UI collapse into one platform-aware spinner_interval() beside the Spinner it paces. The header refactor was verified equivalent over 540 renders, plain text and style spans both. The span check earned its keep: the first cut passed style= to the Text constructor, which makes it the object's base style and blankets everything appended after, so the version string would have rendered brand-under-muted. test_header.py only asserted on .plain and never saw it; it now pins the styling too. tests/test_performance.py pins each contract as behaviour rather than timing, including a subprocess guard that fails if Crypto, the network stack, or the map screen ever creep back onto the startup import graph. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
f5880bfc20 |
Device picker: list configured serial profiles (soldered platform UARTs)
A soldered SoC UART like the Luckfox Lyra's /dev/ttyS1 is never enumerated by pyserial's comports(), so a serial [profiles.*] entry pointing at one could only ever be reached via `meshterm --port` on the command line -- it never surfaced in the startup picker, which listed only scanned devices (and TCP profiles). Fold configured serial profiles into the picker too, mirroring the existing TCP-profile folding, de-duplicated by port so a port pyserial *does* enumerate keeps its richer scanned row. Also fix the liveness poll for the same ports: serial_port_present() now treats an existing /dev character device as present (platform UARTs aren't in comports() but their node persists exactly as long as the port does; a USB node vanishes on unplug, so this never masks a real disconnect). Without it the watcher would falsely report a soldered radio unplugged mid-session. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
19ac17a262 |
Heard ages: a sender's future clock no longer pins the list
A contact's last_advert is stamped by the advertising node's own clock; a mis-set one lands in the future, where the age clamp read it as a permanent "now" and the heard sort pinned it to the top — for as long as the bogus stamp stayed ahead of the wall clock, since the firmware only ever advances the field (its replay filter). advert_time (models.py) is now THE converter for every last_advert epoch — the live contact table and the cross-session store both pass through it — and refuses a stamp more than 5 minutes ahead as unknown. The devstate contacts fetch then fills the gap from our own recorded receptions (stamped by our clock), so a refused contact we really do hear shows an honest age, and one we never heard reads never. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
b143a6670d |
Empty states: lowercase muted, never parenthesized
The chat picker's no-contacts line and the CLI's no-serial-devices line were the last two wearing parentheses; the standard shape is bare prose with an em-dash explanation (housekeeping H-005). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
01ca242c98 |
Live feed: the lane is about the packet, whatever the packet is about
The NODE lane suited the two classes that name a node and left every other one reading a dash. On this mesh that is half the traffic: the direct messages, requests, responses, returned paths, acks and traces that relay past us naming no origin. So the lane asks each class its own question instead, and the header says SUBJECT — the word that stays true down the whole column. An advert or a telemetry frame is still about its node. A channel text is about its channel, named by the key whose MAC confirms the frame — never by the fingerprint alone, which 256 buckets make no proof at all; a channel we hold no key for reads as that fingerprint and says so. A direct message, request, response, returned path or anonymous request is about the two nodes it travels between, drawn sender → recipient on the hop-sequence widget, so endpoints read exactly as route hops do: resolved names, key-derived hues, our own node white the moment a frame is addressed to us. Too wide, and the sender drops to its hash — the frame is addressed, so the addressee is the half worth the cells. An ack is about the message it answers, a trace about its tag. And an unsigned channel post is filed under its channel rather than the bare word "channel", which named nothing. Half of that was unreadable before because nobody had opened the frame. The companion hands every overheard packet to the library, which decodes the body for exactly two classes — advert and channel text — and leaves the rest as bytes. Those bytes are not opaque: MeshCore addresses a frame in the first few of them, and core/frames.py now reads them, class by class, against the layouts the protocol's own docs/payloads.md publishes. The trace tag is the little-endian uint32 the firmware writes, so it reads as the same number a trace reply reports; an ack's checksum keeps wire order, the form the companion reports its own delivery acks in. Two checks guard every decode, because a wrong slice yields not an error but a plausible-looking hash: the frame's payload version must be v1 (the header reserves two bits for a v2 that widens both hash and MAC), and the body must be long enough for the layout its class promises. Either failing yields nothing at all. The feed opens seeded from history, so any of this that lived only in a live event's raw payload would leave the opening screen blank — the same problem the channel-text crypto trio had. Same answer: three columns (dest/src/tag), written on capture and restored to the very keys the event used, so a replayed frame and a fresh one read identically all the way up. Older rows carry NULL until re-heard. The viewer gained the matching rows: to, from, tag, acks, and a channel for a datagram — whose body is not text, but whose MAC still names it. Verified against the MeshCore protocol documentation and firmware source, then corroborated on the air: every frame captured off the radio has a body length that decomposes exactly into its documented layout, an anonymous request's 51 bytes (1 + 32 + 2 + one AES block) included. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
3b1718fa4d |
Paths: arrow the TX sweep title, drop dead path_str, hscroll the trophy browser
The sweep table title used ASCII ->, TraceResult.path_str was an unused ASCII-arrow renderer, and the trophy browser truncated long walks at the fold — SelectScreen's own hscroll now slides the highlighted row. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
3c38b366cf |
Contacts: purge stale contacts by how long since last heard
Add a "🗑 Purge stale contacts…" action at the foot of the Contacts list. It offers an age ladder (1 week → 1 year, plus a never-heard bucket), each rung showing a live count of how many contacts it would sweep, so the impact is visible before choosing; the pick is gated behind a typed "delete" confirm. A purge deletes each contact from the device table (new Device.remove_contact, over the meshcore remove_contact command) and forgets it from the cross-session contact store so a firmware-less bridge doesn't merge it back — but only the contact is dropped: each node's reception history in MeshTerm is untouched, and our own pinned node is never a candidate. The contacts cache is invalidated and the list rebuilt so swept contacts are gone from it. ContactListScreen gains a `tail` param (symmetric to `lead`) for the action and Back rows; age bucketing (stale_past / never_heard) is factored out pure and tested, alongside MockDevice.remove_contact and the screen's tail composition. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|
|
94e81a1b82 |
Contacts: remember heard contacts across sessions
A firmware-less radio bridge holds its contact table only in RAM, so the Contacts screen and the chat recipient list come up empty (or only as sparse as this session's adverts) after the bridge restarts, even though you were messaging those nodes last time. Record every contact MeshTerm reads, keyed by the device's own public key, and union any the device is no longer reporting back into the list at the one read chokepoint both lists share (DeviceState.contacts()). No device write is needed: a direct message addresses a node by a prefix of its public key, which the remembered contact carries, so a restored contact is messageable without being written back onto the device. The union is inert where it isn't needed — a firmware radio reports its whole table, so nothing is added, no device-type check required — and recording never removes a contact on an empty read, so a bridge that just restarted doesn't wipe what it knew. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|
|
842a58a515 |
Settings: remember MeshTerm-changed settings across sessions
A firmware-less radio bridge holds its configuration only in RAM, so the node name, radio parameters, and tuning set through MeshTerm are back to firmware defaults when the bridge process restarts. Record every setting changed through MeshTerm (editor, config CLI, and TOML restore all funnel through _apply_setting), keyed by the device's own public key. Unlike channels — silently replayed because filling an empty slot overwrites nothing — a setting is a single canonical value, so replaying a stale one could clobber a change made elsewhere. So the store never writes on its own: on connect it detects drift between what it remembers and what the device reports, and a startup offer lets the operator restore the saved values, adopt the device's current ones, or stop remembering the device (the "don't ask again" exit). The offer is quiet unless a connected device actually drifts, so a firmware radio you don't manage through MeshTerm is never interrupted. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|
|
711621d69e |
Channels: remember MeshTerm-created channels across sessions
A firmware-less radio bridge holds its channels only in RAM, so every one is lost when the bridge restarts — the Channels page came up empty each session even after you added channels. MeshTerm read channels live from the device and never remembered them. Add a durable, per-device channel store (<config_dir>/channels.json, keyed by the device's public key) that records every channel written through MeshTerm. On connect, reconcile() replays any remembered channel the device isn't reporting into a free slot — filling gaps, never overwriting an occupied slot. The gate is provenance, not device type: only channels you wrote through MeshTerm are recorded, so a firmware radio you never edit through MeshTerm keeps an empty record and does a single identity probe on connect (untouched). A bridge, where every channel is necessarily created through MeshTerm, gets its whole set back. Every mutation (create/join/import/edit/reorder/clear) now flows through a single write_channel() boundary that keeps the store faithful. Verified end to end against the live SPI bridge: write a channel, clear it off the device to mimic a restart, reconnect in a fresh session, and reconcile restores it with the right key. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|
|
62a2d76e8c |
Node detail: a full-screen page for each contact, reached by Enter
Pressing Enter on a contact now opens its whole story on one page instead of a bare row: identity (name in its hue, key with the routing hash lit, type, first/last heard, packet tally, reception SNR/RSSI), an inline location preview centred on the node (a small static basemap via the new MiniMap), the observed routes to it, and an action list (trace armed with the suggested best path, open full map, time machine). Contacts owns the show/open/reshow loop; topology.suggested answers "the best evidence-backed way to reach this node", wired ahead of the firmware route in the trace arming precedence. Timemachine and Trace grew the entry points the page opens. Four fixes fell out of driving it on real hardware: Slow open. Each located-node page built a fresh BasemapSource and resolved its TileJSON -- a blocking HTTPS round-trip (~100ms, up to the 12s timeout on a bad link) -- on every open. Hold one source for the session (ctx.basemap_source), shared by the map, the picker, and the preview, and warm it behind the menu at login, so the resolve is paid once, off the navigation path. Black map. A companion advertising nonsense coordinates (Homestead reports lat -97, lon -1042) flung the viewport off the world, leaving the map a screen of empty/water fill that reads as solid black -- both from "open full map" and from filtering to it and framing. The old guard only caught the 0/0 no-GPS null island; the new geo.usable_fix() rejects any out-of-range fix too, applied to the map markers and the location preview alike. Verified on-device: of 265 located contacts, only Homestead drops. Path to node. The route/suggest rows render through THE path widget with a 1-byte hash in parentheses (a "name (3d)" tag), so they cross-read hop for hop against the route graph's byte labels. Route graph. Draw us on the left and the target on the right (us to target, "how we reach it", left to right) via a local endpoint swap that leaves the shared route_graph_style untouched for its other callers, and give the fan a generous lane step and row budget so a well-connected node's candidate paths spread into separate, legible tracks instead of a cramped tangle -- the height stays adaptive, so a one- or two-route node still draws compact. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
40c46d3c75 |
Courier: direct messages go to companion contacts only
The recipient picker listed every contact, but a courier message is a direct message — and a DM to a repeater, room, or sensor is meaningless. Filter the recipient list to companions (an untyped contact gets the benefit of the doubt), and open it sorted A→Z by name instead of by heard, with heard/packets/key still a Ctrl+arrow away. Fold the rule the chat picker already applied inline into one shared predicate, is_direct_messageable(node_type), so "DMs go to companions only" is enforced in a single place and both pickers speak it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
733a68857c |
Contacts: rename the mislabeled Nodes feature; sharpen node vs contact
The "Nodes" menu was a contacts roster mislabeled — it lists the device's contacts (get_contacts), which upstream meshcore calls "contact" too. Rename throughout, no CLI alias: - tools/nodes.py -> tools/contacts.py (ContactsTool, `meshterm contacts`) - ui/nodes_screen.py -> ui/contacts_screen.py (ContactsScreen/open_contacts) - ui/nodelist.py -> ui/contactlist.py (ContactListScreen/ContactRow) - widgets: NodesSort->ContactsSort, nodes_table->contacts_table Courier's recipient is a contact you address, so its prose and CLI arg (`courier queue CONTACT ...`) follow; persisted node_key/node_name stay. The reception/hardware layer keeps "node" — HeardNode, heard_nodes(), observations.node, trace_hops.node, map/atlas participants, node types, admin targets, and the Time Machine's reception picker (its "Nodes" heading stands). CLAUDE.md's lexicon is rewritten to the refined definitions: node = any mesh radio; contact = a node your device knows (discovered or added). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
c4622d529a |
Watchtower: type glyphs, key-hued names, sideways scroll
Watchlist rows now lead with the shared node-type marker in its own colour (the type is stored at star time; legacy entries resolve through the contact table) with the name in its key-derived hue — silence keeps its ⚠ tail instead of tinting the glyph. Unacked alert labels resolve back to a key for their hue (contacts first, then the watchlist's own names, so a starred node colours even offline); acked rows recede to muted whole. The star-a-node picker draws the same glyph-and-hue rows. Long rows can now be read to the end: SelectScreen grows an opt-in hscroll flag — ←/→ slide every row under the pinned pointer via crop_cells, clamped at the widest row, surviving ↑↓ and resetting on filter edits — enabled only here, with the footer advertising it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
434ffda253 |
Observations: capture the full public key, keep node as the 12-hex id
Adverts carry the transmitting node's whole public key, but only its 12-hex prefix was ever stored (observation_from_event truncated it with [:12]). That prefix is the app's identity/join key — heard_nodes groups on it, and the map, nodes, and watchtower screens correlate it against contacts' 12-hex key_prefix — so it must stay short. Instead, record the whole key alongside it in a new observations.public_key column (schema v12) and keep the prefix as node. The Time Machine picker prefers the captured full key, then the live contact resolver, then the bare prefix — so a heard node's key now shows as fully as the hash lane fits, offline included. HeardNode surfaces the key from whichever row captured it; the simulator's observations carry it too. No backfill: the full keys past adverts arrived in were never persisted (the raw payload wasn't stored) and no local source has them, so old rows can't be completed. The database was wiped to start fresh under the new schema. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
5e8190d3b6 |
Time machine: add our own node, a self stats page, and a sortable picker
Add our own node to the subject picker — first in the Nodes list, always, matching the Nodes screen's own-node-first order — and give it a full activity page built from the outbound record, the one subject reception history can't describe since we never overhear ourselves: Activity (traces + messages sent), Reach (trace bottleneck SNR), Rhythm (by local time of day), and a Ledger. Backed by three new repository reads (self_transmissions, self_trace_reach, self_activity_ledger) and a SelfActivity model. Make the picker sortable and filterable: Ctrl+left/right pick the column (name / heard / packets / hash), Ctrl+up/down force direction, a two-colour header lighting the active sort. Supported by letting a Separator title be a Rich Text and mapping Ctrl+Up/Down to actions. Anchor the columns to the left: size the name lane to its content, not the terminal, so the columns stay put as the window widens, and flex the hash lane to fill the freed width — showing a heard node's full public key when a contact holds it (new make_key_resolver) instead of the stored 12-hex prefix. Truncate hashes on a byte boundary (even digit count) in the shared highlighted_hash widget, floor the picker hash lane at 8 cells. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
1edd4a3bf4 |
Remove Plotly and the TX-optimize HTML chart
The viz package existed solely to render one interactive HTML chart for tx-optimize sweeps, pulling in Plotly — a heavyweight dependency serving a single artifact while every other timeline renders in-terminal via braillechart. Drop it with no replacement: delete meshterm/viz, the --viz/--no-viz flag and its render call, the now-unused output_dir setting (config field, default, loader, example), the Plotly test, and the README and pyproject references. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
115fe6895d |
Dialogs: multi-layer floats, red data-loss tier, unknown-relay hashes
Three independent consistency passes: 1. **Message paths: unknown relays as grey full-hash** The message-paths dialog showed unnamed relay hops as a single lit byte (e.g. `e8`). Now they render at the device's path-hash-mode width, muted grey, and annotated with their addressed byte — `e839f2 (e8)` — so the rows stay readable and cross-reference the route graph's byte labels (matching named hops' trace presentation). Added `hash_as_name` flag to path_text widget. 2. **Dialogs: multi-layer compositor + backdrop for empty stack** Opening a confirm over a floating popup used to stretch that popup to full-frame (the single-float compositor's bug). Now the compositor maintains a pool of _MAX_DIALOG_LAYERS=8 centered-box floats, each rendering one layer above the background — so a popup and its confirm both stay their own size. Also: button_dialog/typed_confirm/autocomplete now float over a blank base when the stack is empty (via _run_dialog_screen), guaranteeing popups render as small boxes on an empty stack, not full-frame chrome. Simplified message_dialog to delegate its backdrop logic to button_dialog. 3. **Data-loss dialogs: red `destructive` tier** Added a second caution tier to the dialog API: danger=True stays amber (disruptive: discard edits, reboot), destructive=True is red (irreversible data loss). Updated: single-record delete, channel "clear slot", courier "clear finished" (new confirm), and startup "remove device" (splash confirm). Per UX spec: bulk/irreversible deletions gate behind typed_confirm (also red); single-record delete is a red Cancel/[verb] button dialog. All changes are backward-compatible. Full suite: 793 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
965783d276 |
Network (TCP) companions: connect, remember, and manage from the picker
Add TCP alongside serial and BLE as a first-class companion transport, end to end: discovery/connection/selection learn a tcp: stable_id and host:port target, --tcp and TCP config profiles reach a WiFi board or network proxy, and a network companion -- which isn't discoverable -- is rebuilt into the picker from its remembered endpoint. Device picker gains the network-device affordances: - "Add a network device" prompts for host:port, smoke-tests it, and remembers it. The row is marked "- experimental" in the cautionary hue. - Delete on a network row opens a chromeless Cancel/Remove confirm (Cancel left, Remove right and default: Enter removes, Esc cancels), then DeviceStore.forget prunes it and re-draws the list. Serial/BLE rows stay inert. - The "Del remove" footer atom now follows the highlight, surfacing on the box's bottom border only while the cursor sits on a deletable row; the box is sized to the fullest footer so it never widens mid-navigation. Folds in the accompanying courier, channels, and config refinements built along the way. Screens stay readable at 72 cols; full suite green (745 tests). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
d977aeb22a |
Channels: mute a channel's notifications from its detail screen
Some channels — an automated #wardriving beacon, a chatty public relay — carry traffic worth recording but not worth being notified about. Muting a channel now stops its new messages from raising the unread badge: the recorder skips the unread bump for a muted channel (its transcript is still written to history), and muting zeros whatever unread it had so the badge drops immediately. The mute lives in a new MuteStore (<config_dir>/mutes.json), keyed by the channel's intrinsic identity so it follows the channel across slot moves and survives restarts. The toggle is a state-reflecting row in the channel-detail subscreen (🔕 Mute / 🔔 Unmute), and the manager list marks a muted channel with a 🔕 in its (then always-empty) unread lane. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
6aecb58e59 |
Battery: use the standard BLE charging flag when a device exposes it
The companion protocol reports only a battery voltage, so charging is a voltage-trend inference. Some devices could instead expose the standard GATT Battery Service (0x180F) whose Battery Level Status characteristic (0x2BED, Battery Service 1.1) carries a real, firmware-reported charging flag. Dumping the GATT table shows no current MeshCore build implements it — the BLE profile is just the Nordic UART pipe plus DFU — but wire it up now so it lights up automatically the day one does. get_hw_charging() reads 0x2BED best-effort over BLE (reaching the bleak client the forced-teardown path already uses) and prefers its flag; any failure — service absent, read refused, short value, non-BLE transport — is a quiet None, so the poller falls back to the inference and every current device behaves exactly as before. Verified against a live device: the read resolves and returns a clean, steady None. The 0x2BED bitfield decode is a pure function unit-tested against the spec's Charge State enum so the parse is correct ahead of any hardware that populates it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
6823519503 |
Trace: size the reply-wait to the route length
A trace is one packet that must travel the whole path out and back before its reply reaches us, so a flat 10s wait cut long walks off mid-flight — the packet completed the circuit on the mesh, but our wait had already expired, so we logged a phantom "no reply" for a route that worked. run_trace now sizes the wait to the hop count (base + per-hop, capped) when the caller doesn't pin a timeout, counting the transmitted path (return leg included). An unknown path-less flood falls back to the old flat budget. run_traces and the mock thread the optional timeout through, so every trace surface — live screen, CLI, probe, TX optimizer — inherits the scaling. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
7d3e4b4412 |
Channels: bound the never-rejecting slot probe, cache the capacity
The channel manager still felt uncached: its capacity read walked all 64 slots one-by-one on firmware that never rejects an out-of-range index (the Waymarker), on every open, outside the session cache. Two fixes for the two slot probes: - read_channel_slots now stops after a run of MAX_CHANNELS consecutive empty slots. The manager packs channels from slot 0 up, so an unbroken empty run that long means every configured channel has been seen — safe against within-capacity gaps, which can't reach that length. This cuts every (re)probe on never-rejecting firmware from 64 reads to ~11, felt after each channel edit (a mutation invalidates + reprobes). - channel_capacity deliberately keeps walking to the firmware's rejection (it must discover a larger rejecting firmware's real ceiling — the empty-run guess would truncate an empty 12-slot device to 8). Its only slow case is never-rejecting firmware, bounded instead by caching: a new DeviceState.channel_capacity() holds it for the session (a hardware constant, dropped only on reconnect) and prewarm warms it after login, so the manager opens from cache like every other screen. 706 passed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |