Skip to content

feat(computers): sync account settings across linked computers - #157

Merged
nixuuu merged 1 commit into
devfrom
feat/linked-shared-config-1
Nov 5, 2026
Merged

nixuuu merged 1 commit into
devfrom
feat/linked-shared-config-1

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 5, 2026

Copy link
Copy Markdown
Member

Stage 1 of 7 of shared configuration across linked computers. The design is in docs/linked-computers.md ("Konfiguracja", "Udostępnianie per łącze", "Konkretny protokół: wspólna konfiguracja"). This stack stays a draft until all stages are done.

Sync engine

  • config_items holds per-field versions with hybrid logical clocks; the latest change wins per field.
  • config_history keeps the losing values. A notice offers Restore or Dismiss.
  • Deleted items are kept as tombstones.
  • ConfigSyncService.WatchConfig sends changes over the existing mTLS link: first catch-up from a cursor, then a live stream, with a full resend when a peer's cursor is too old. Each computer passes on what it merged, so the group converges.
  • A new config_sync capability handles version differences.

Account settings are the first shared kind. Existing opt-in settings data (0050) is converted.

Per-link "Share configuration"

  • On by default and shown in the pairing dialog.
  • Both sides must agree. The shared group is the set of computers joined through links with sharing on.
  • Sync requests over a link that is off are refused before anything is sent.
  • Turning sharing off keeps all data on both sides. Only the side that turned it off can turn it back on.

Migration: 0073_config_sync. All proto changes are additive.

Tests: gateway↔gateway integration with three databases:

  • convergence and notices;
  • cursor catch-up and full resend;
  • restarts;
  • nothing crossing a link that is off;
  • refusal before sending;
  • stopping mid-stream;
  • the split keeps data;
  • re-enable without duplicates;
  • only the side that turned sharing off can turn it back on;
  • owner scoping;
  • the migration.

Copy audit (docs/copy.md §8): the per-item "Share with linked computers" text is replaced with per-link and group text. Statuses: "Configuration up to date", "Syncing configuration…", "Needs an update to share configuration".

@nixuuu
nixuuu added this pull request to stack #165 November 5, 2026 10:12
@nixuuu
nixuuu force-pushed the feat/linked-shared-config-1 branch from 36d6281 to c199188 Compare November 5, 2026 12:22
@nixuuu
nixuuu force-pushed the feat/linked-shared-config-1 branch from c199188 to ab88c3e Compare November 5, 2026 14:43
@nixuuu
nixuuu marked this pull request as ready for review November 5, 2026 14:43
@nixuuu
nixuuu merged commit 2fea9a6 into dev Nov 5, 2026
16 of 18 checks passed
@nixuuu
nixuuu deleted the feat/linked-shared-config-1 branch November 5, 2026 14:51
nixuuu added a commit that referenced this pull request Nov 5, 2026
Settings → Linked computers no longer shows amber route failures for a
computer that is connected, and the configuration sharing note says
which computer needs an update.

**Why routes showed "Failed" while connected**
- A gateway dials a partner only when it has no link to it. When the
partner dialled first, failures from an earlier dial pass (for example
while the partner slept or restarted) stayed stored, and the UI showed
them in amber whatever the link status.
- The listener port is stable, but two gaps around announced addresses
also existed:
  - announced addresses were never retired;
  - addresses that changed during a handshake were not re-announced.

**What the card shows now**
- **Status:** "Connected · incoming" when only the partner dialled.
- **Routes:**
  - the route the outgoing link runs over: "In use · 4 ms";
- a failed route while the link is up, in neutral tone: "Not needed
while connected · failed 14 minutes ago";
  - amber only while the link is down.
- **Old addresses:** an address the partner no longer announces gets an
"Old address" badge. It is tried last, and it is removed once a current
route works or after 7 days. An empty announcement (listener off) marks
nothing as old. Changed addresses are announced right after the
handshake.

**Configuration sharing**
- The capability check was right: `config_sync` first shipped in
nightly.67, so a nightly.65 partner cannot share yet. The note now names
the computer:
- "{name} runs 0.2.0-nightly.65 and needs an update to share
configuration."
  - "This computer needs an update to share configuration."
- The switch shows this computer's saved choice and stays usable. A line
that is always there says "Sharing starts after the update." or "Sharing
stays off after the update.", so nothing moves. Turning it off while
waiting needs no confirmation.

**Contracts**
- Proto (additive): `LinkedComputer.connection_direction` (26),
`config_update_node_id` (27), `ComputerRoute.in_use` (7) and
`withdrawn_at_ms` (8).
- Migration `0082_computer_route_withdrawn`, renumbered after #204's
0081.

**Tests**
`tests/integration/linked-routes-status.test.ts`:
- an incoming-only link with failed outgoing routes;
- the dialling side marks its route "In use";
- a reconnect clears a route's failure;
- a partner on a new port, where the old address is marked, tried last,
then removed;
- a re-announced address that loses the "Old address" badge.

`config-sync.test.ts` checks that both sides name the older computer.
The `lan-routes` and `linked-computers` tests pass. `check:tmp`: 1348
passed, 0 failed.

**Checked** in a browser with two gateways and fixture names and
addresses: light and dark, desktop and phone, with long names and
addresses.

**Copy audit (§8)**
- "Connected · incoming", "In use · 4 ms" and "Not needed while
connected · failed …".
- "Old address".
- The update notes and "Sharing starts / stays off after the update."
- One idea per sentence, active voice, and failures always say "Failed",
not colour alone.

Related: #35, #157
nixuuu added a commit that referenced this pull request Nov 5, 2026
Linked computers now show the real provider status of each other's
workers, and no longer report equal shared settings as conflicts.

**1. A remote worker's instance status was dropped** (introduced by
#176)

On each Mac, the other computer's worker showed only "Available", with
no auth, version or connection details. So each Mac looked as if the
other used the device login, though both used the proxy.

- **Fix:** overview snapshots and updates carry the home worker's
report: auth kind, CLI version, effective connection kind (with
per-worker overrides) and check time.
- **Older peer:** a peer that does not send the report gets an explicit
"unavailable" status instead.

**2. Conflicts were recorded for equal values** (introduced by #164)

Conflict detection compared stored representations:
- re-encrypted secrets, whose ciphertext differs on each computer;
- proxy aliases;
- defaults versus explicit values.

So almost every field looked different. It now compares effective
values: the secret plaintext inside the gateway, canonical proxy aliases
and effective defaults. HLC ordering is unchanged, and a reused clock
with a different value is still rejected.

**3. Stale notices stayed open** (introduced by #157)

Notices whose values have converged are now dismissed automatically,
including stored legacy notices and after a restart. Real conflicts keep
Restore and Dismiss. No migration is needed.

**Tests:** 8 new regression tests across two linked gateways:
- remote provider rows on both sides;
- identical encrypted values give no notice;
- a real divergent edit gives exactly one notice;
- convergence clears notices, also after a restart;
- version skew and clock ties.

`check:tmp`: 1406 passed, 0 failed.

**Checked** in a browser with two linked gateways: light and dark,
desktop, narrow and phone width, with long names, real conflict notices
and automatic clearing.

**Copy audit (§8):** explicit unknown states, sentence case, no
duplicated "Proxy" label, and no meaning carried by colour alone.

**After updating both Macs:** both provider rows should show Proxy with
auth, version and check time, and the equal stale notices should
disappear. `native` stays the instance id; "Proxy" names its connection.

Fixes: #176
Fixes: #164
Fixes: #157
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant