Files
meshcore-analyzer/public/account.css
T
efitenandClaude Opus 5.5 c2a590b741 feat(companions): linked-only ingest, account Companions and My coverage (#2176)
Part 3 of 3 for #2173 (companion linking): the optional linked-only
ingest filter, the account page and the "My coverage" toggle, plus the
docs. Builds on #2174 and #2175 (both merged); `upstream/master` is
merged in, so the diff shows only this part.

## Changes in this PR

**Ingestor: linked-only ingest** (`cmd/ingestor/linked_companions.go`)
- With `clientRxCoverage.requireLinkedCompanion` on (default off) and
user management enabled, every `meshcore/client/<pubkey>/...` message
whose pubkey is not in `companion_links` is dropped before any client
handler runs, and counted (`client_unlinked_dropped` in the stats file).
- The ingestor opens `users.db` read-only (`mode=ro`, raw SQL, no
`internal/users` import), like the approved-channels reader, so the
#1283 write invariant holds. `TestLinkedCompanionSetIsReadOnly` pins it.
- The set refreshes every 60 s. A miss re-reads at most once per 5 s, so
a companion linked a moment ago is accepted within seconds while a flood
of unknown pubkeys costs one read per 5 s.
- It passes everything until its first successful read, and when
`users.db` has no `companion_links` table yet (a server older than
this). After the first read it keeps the last set on a read error. It is
a filter, not a security boundary: anyone with the shared broker
credential can still publish under a linked pubkey.

**Frontend**
- Account page: device tokens show under Devices as "CoreDrive RX" with
their label; a new Companions section lists linked companions (name,
short key, linked since, last seen) with an Unlink button.
- Coverage page (`#/rx-coverage`): a "My coverage" toggle for logged-in
users (`mine=1`). Only the newest coverage reply is drawn, and a refused
`mine=1` turns the toggle off. Under "My coverage" the page does not ask
for the "nothing received" cells from #2172, and their legend entry is
hidden.

**Docs**: user guide (accounts: devices, companions),
`docs/client-rx-coverage.md` (linking, linked-only ingest, the CORS
exception), `config.example.json`, and the spec status.

## Performance

The filter runs on every client message. Benchmarks with 1000 linked
companions (12-core dev box, `go test -bench`, 3 runs each):

| Path | Time | Allocations |
|---|---|---|
| linked pubkey (lock-free map lookup) | 54 ns/op | 0 |
| linked pubkey, parallel | 11-14 ns/op | 0 |
| unlinked pubkey inside the 5 s miss gap | 85-95 ns/op | 0 |
| one `users.db` re-read | 0.38 ms | 3030 |

The unlinked benchmark asserts that no extra `users.db` read happens. A
re-read happens at most once per 5 s on a miss and once a minute from
the refresh loop.

## Verification

- `cmd/ingestor`: 15 new tests (filter off changes nothing, linked
passes, unlinked dropped before every handler, miss refresh accepts a
new link, the 5 s cap holds under a flood, unlink honoured after the
periodic refresh, missing table and missing file, fail-closed only after
the first read, read-only open, startup, stats counter) and 4
benchmarks. Full ingestor suite green.
- Frontend unit tests for the account page (device tokens, companions
list escaping, empty state, Unlink confirm and cancel, load errors) and
`tests/unit/test-rx-coverage-mine.js`.
- E2E `tests/e2e/test-user-management-e2e.js` gains a companion step
(device token under Devices, a companion linked with a real Ed25519
signature under Companions, Unlink). Run locally against the e2etest
build: 28/28. The coverage suites (`test-rx-coverage-gaps-e2e.js`,
`-noise-`, `-viewport-`) still pass.
- Frontend unit suite (`test-all.sh`) green.

## Not in this PR

- Narrowing the "nothing received" cells to the caller's companions
under "My coverage" (the track query takes one companion today).
- Per-user broker credentials or ACLs, which would turn the filter into
an access control (non-goal in the spec).

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-10 18:38:27 +02:00

111 lines
8.8 KiB
CSS

/* Optional user management: header control, account pages, admin table. */
.nav-account-wrap { position: relative; }
.nav-account-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; min-width: 48px; padding: 6px 12px;
background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--nav-text-muted); font: inherit; font-size: 14px;
text-decoration: none; cursor: pointer; touch-action: manipulation; transition: background .15s, color .15s; }
.nav-account-btn:hover { background: var(--nav-bg2); color: var(--nav-text); }
.nav-account-label { max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); }
.nav-account-menu { position: fixed; right: 0; top: 100%; min-width: 160px; z-index: 1200;
background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 4px 0; }
.nav-account-menu[hidden] { display: none; }
.nav-account-menu a, .nav-account-menu button { display: flex; align-items: center; width: 100%; text-align: left; padding: 8px 14px; min-height: 48px;
color: var(--text); background: none; border: 0; font: inherit; text-decoration: none; cursor: pointer; box-sizing: border-box; }
.nav-account-menu a:hover, .nav-account-menu button:hover { background: var(--row-hover); }
.account-page { display: flex; justify-content: center; padding: var(--space-md); }
.account-card { width: 100%; max-width: 520px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 20px; }
.account-card h2 { margin-top: 0; }
.account-card h3 { margin: 24px 0 8px; font-size: 1rem; }
.account-form { display: flex; flex-direction: column; gap: 12px; }
.account-field { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); color: var(--text-muted); }
.account-field input { padding: 8px 10px; min-height: 48px; border: 1px solid var(--border); border-radius: 6px;
background: var(--input-bg); color: var(--text); font: inherit; box-sizing: border-box; }
/* The global .btn-primary is white on --accent (2.75:1), so account forms use
their own buttons: --text-on-accent on --accent-strong, as .tab-btn.active does. */
.account-btn { align-self: flex-start; min-height: 48px; padding: 8px 20px; border-radius: 6px; font: inherit; cursor: pointer; touch-action: manipulation; }
.account-btn-primary { background: var(--accent-strong); color: var(--text-on-accent); border: 1px solid var(--accent-strong); }
.account-btn-primary:hover { background: var(--palette-blue-700); }
.account-btn-secondary { background: var(--surface-1); color: var(--text); border: 1px solid var(--border); }
.account-btn-secondary:hover { background: var(--row-hover); }
.account-hint { font-size: var(--fs-sm); color: var(--text-muted); margin: 0; }
.account-msg { margin: 0; min-height: 1.2em; font-size: var(--fs-sm); }
.account-msg.ok { color: var(--status-green-text); }
.account-msg.err { color: var(--status-red-text); }
.account-links { font-size: var(--fs-sm); }
.account-links a { color: var(--link-color); }
.account-mail { text-align: center; padding: 32px 20px; }
.account-card.account-mail .account-mail-icon { display: block; width: 4.5rem; height: 4.5rem; font-size: 4.5rem; margin: 0 auto 12px; color: var(--accent-strong); }
.account-mail-title { margin: 0 0 12px; font-size: var(--fs-2xl); }
.account-mail-title:focus { outline: none; }
.account-mail-intro { font-size: var(--fs-lg); margin: 0 0 12px; }
.account-mail .account-links { font-size: var(--fs-md); }
.account-sessions { list-style: none; padding: 0; margin: 0; }
.account-sessions li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.um-chip-device { margin-left: 4px; font-size: var(--fs-xs, 11px); color: var(--text-muted); }
.account-sessions li.account-empty { color: var(--text-muted); }
.cs-auth-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 2000; opacity: 0; pointer-events: none;
background: var(--card-bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px 16px; transition: opacity .2s; }
.cs-auth-toast.visible { opacity: 1; }
.um-page { padding: var(--space-md); }
.um-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.um-filters input, .um-filters select { padding: 6px 8px; min-height: 48px; border: 1px solid var(--border); border-radius: 6px; background: var(--input-bg); color: var(--text); box-sizing: border-box; }
.um-table-wrap { overflow-x: auto; }
.um-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.um-table th, .um-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.um-table tr:hover td { background: var(--row-hover); }
.um-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.um-actions button { min-height: 48px; padding: 4px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-1); color: var(--text); cursor: pointer; touch-action: manipulation; }
.um-status, .um-chip { display: inline-block; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--border); white-space: nowrap; }
.um-status-active, .um-chip-delivered, .um-chip-opened, .um-chip-clicked { color: var(--status-green-tint-text); }
.um-status-pending, .um-chip-sent, .um-chip-deferred, .um-chip-soft_bounce { color: var(--status-yellow-text); }
.um-status-disabled, .um-chip-hard_bounce, .um-chip-invalid_email, .um-chip-blocked, .um-chip-spam, .um-chip-error, .um-chip-bouncing { color: var(--status-red-text); }
.um-chip-unsubscribed { color: var(--text-muted); }
.um-status-approved { color: var(--status-green-tint-text); }
.um-status-rejected, .um-status-revoked { color: var(--status-red-text); }
.account-proposals { list-style: none; padding: 0; margin: 0; }
.account-proposals li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.account-proposals li .account-hint { flex-basis: 100%; margin: 0; }
.um-detail { margin-top: 16px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.um-detail ol { padding-left: 18px; }
@media (max-width: 760px) { .um-col-optional { display: none; } }
.account-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
a.account-btn { display: inline-flex; align-items: center; text-decoration: none; box-sizing: border-box; }
.um-detail-close { float: right; }
/* Compact controls on precise pointers; touch keeps the 48px targets above. */
@media (pointer: fine) {
.nav-account-btn { min-height: 36px; min-width: 36px; padding: 3px 10px; }
.nav-account-menu a, .nav-account-menu button { min-height: 36px; padding: 4px 14px; }
.account-field input { min-height: 36px; padding: 4px 10px; }
.account-btn { min-height: 36px; padding: 4px 16px; }
.um-filters input, .um-filters select { min-height: 36px; padding: 3px 8px; }
.um-actions button { min-height: 36px; padding: 2px 12px; }
}
/* Settings sync dialogs (settings-sync.js) on the shared .modal. */
.cs-dialog { display: flex; flex-direction: column; gap: 8px; color: var(--text); }
.cs-dialog h3 { margin: 0; }
.cs-dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
/* Node notifications toggle (notifications.js) on the node side pane and full page. */
.node-notify-slot { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-left: 4px; }
.node-notify-slot:empty { display: none; }
.node-notify-btn { white-space: nowrap; }
/* Sized like the neighbouring buttons, which carry inline sizes in nodes.js
(side pane: Details/Analytics/Reach; full page: Copy URL/Reach). */
#nodeNotifySlot .node-notify-btn { font-size: 11px; padding: 2px 8px; }
#nodeNotifySlotFull { margin-left: 0; } /* the full page row spaces its buttons with gap */
#nodeNotifySlotFull .node-notify-btn { font-size: 12px; padding: 4px 10px; }
.node-notify-btn[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--status-green-text); }
.node-notify-hint { color: var(--text-muted); font-size: var(--fs-sm); }
.node-notify-hint:empty { display: none; }
/* Notifications section (notifications.js) on the account page. */
.account-check { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); }
.account-fieldset { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; }
#notifyForm + h4 { margin-top: var(--space-lg); }
.account-watches { list-style: none; padding: 0; margin: 0 0 8px; }
.account-watches li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }