Repository navigation
feat(app): see the paired phones, and lock one out - #831
Conversation
"3 phones paired" counted every key that ever completed a pairing — test runs included — with no way to see them or show one the door. Settings → The FTW app now lists the devices: a short key prefix, paired and last-seen stamps, most recently seen first. The phone in daily use floats to the top with a fresh stamp; a key that paired once and vanished sinks, and that is the row someone wants to remove. Remove is immediate on both fronts — the key is forgotten, so the next handshake meets the same refusal as any stranger's, and every live session that key holds is terminated with reason "revoked", which the app already renders as "your access was withdrawn by its owner". The stored list gains timestamps, stamped on pairing and on every reconnect. The previous bare-string file still reads — an update must never silently unpair a house — and legacy rows simply carry unknown stamps until they reconnect. The status endpoint's "a count, never a list" stance is reversed on purpose: the settings page can already mint a pairing code, the strictly stronger power, so hiding key prefixes from whoever holds it protected nothing — and it made locking a device out impossible, which is a control a household actually needs. Rows carry prefixes, never keys. Co-Authored-By: Claude Opus 5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f976b8f08
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // which is exactly the row someone wants to revoke. | ||
| meta.lastSeenMs = i.now().UnixMilli() | ||
| i.mu.Unlock() | ||
| if err := i.save(); err != nil { |
There was a problem hiding this comment.
Serialize reconnect stamp saves with revokes
When a paired phone reconnects while its row is being removed, this new last-seen save can race with Revoke's save. save() snapshots the whole authorized map under i.mu but writes a shared .tmp file after releasing it, so an older reconnect snapshot can overwrite the tmp after the revoke snapshot and still be the bytes that the revoke successfully renames; the DELETE then returns 200 and drops the live session, but applink.json still contains the key, so the phone is paired again after restart. Serialize these durable writes or make stale snapshots unable to overwrite a later revoke.
Useful? React with 👍 / 👎.
"3 phones paired" counted every key that ever completed a pairing — the
webapp's live-test runs included — with no way to see them or show one the
door.
The list
Settings → The FTW app now shows the paired devices: a short key prefix,
paired/last-seen stamps, most recently seen first. The phone in daily use
floats to the top with a fresh stamp; a key that paired once and vanished
sinks — and that is the row someone wants to remove. Reconnects stamp
last-seen, so the distinction maintains itself.
Remove is immediate, on both fronts
The key is forgotten (next handshake meets the same refusal as any
stranger's) and every live session that key holds is terminated with
reason
revoked— which the app already renders as "your access waswithdrawn by its owner". Without the second half, "remove" quietly means
"remove within the hour", since the relay's handle rotation forces a
reconnect eventually. The uplink tracks the current connection's sessions
so the API can reach in.
Storage migrates, never unpairs
applink.jsongains per-key timestamps. The previous bare-string liststill reads (custom UnmarshalJSON), so an update never silently unpairs a
house — legacy rows carry unknown stamps until their next reconnect.
Saves are key-sorted so a diff of the file says something.
A deliberate reversal
The status endpoint carried "a count, never a list — a device list on an
unauthenticated LAN endpoint is a household inventory." Reversed, with the
reasoning in the code: this page can already mint a pairing code, the
strictly stronger power, so hiding key prefixes from whoever holds it
protected nothing — and it made locking a stray key out impossible, which
is a control a household actually needs. Rows carry prefixes, never keys,
and the endpoints sit behind the same LAN-only guard as pairing.
Tests
Device list ordering, last-seen stamping on reconnect, revoke by row id
(returns the key for session teardown; refuses ghosts), legacy-file
migration, and the API's guard behaviour via the existing stub.
🤖 Generated with Claude Code