Skip to content

fix(providers): restore an instance's connection as one change - #706

Merged
nixuuu merged 1 commit into
devfrom
fix/restore-provider-conflicts
Nov 14, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/restore-provider-conflicts

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 14, 2026

Copy link
Copy Markdown
Member

Problem

Settings → Providers → Grok on two linked computers showed Changed on two computers with two rows: "Connects with" (Endpoint) and "Proxy" (A different proxy). Restore failed with "Computer link operation failed. Check the address, code and Network access settings." The link itself was fine.

Root cause

Not #696. The remote policy and the device-login refusal are not involved: Restore runs locally (manageConfigNotice).

  • Restore wrote kind or proxy alone (one history row per field). For example, the instance ended up native while still pointing at the proxy. applyInstance stored proxy_id on a native instance. instanceSync then copied the proxy's base URL and key onto it (UPDATE provider_instances … FROM proxies), and Postgres refused the row: provider_instances_endpoint (non-endpoint instances must have no base URL and no key).
  • computerGuard turned every error that is not a ConnectError (here a SqlError) into the pairing message.

The field-by-field Restore of instance records comes from #164 (already on stable), so this PR uses Related: and not Fixes:. Linking #164 would hold everything merged since 2026-11-05.

Change

  • One connection notice. An instance's kind, proxy, baseUrl and apiKey that were lost in the same merge with the same computer are one notice, field = "connection". Its value is a JSON object (the key shows only as "A different key"). Restore, Use the other’s and Keep this computer’s write those fields together, taking the newest lost version of each.
  • Defence in depth. applyInstance sets proxy_id only on endpoint instances. A record that combines native with a proxy (from Restore or from a field-by-field merge) can no longer break the worker sync.
  • Whose value. New additive field ConfigNotice.own_value = 11: the kept value was set on this computer.
  • Errors. computerGuard(run, failure): only pairing and the link service keep "Check the address, code and Network access settings". The other actions name what failed (see the copy audit).
  • fix(providers): show rejected logins and sign in again from the app #696 untouched. StartProviderLogin stays out of SERVED/WORKER_SETTINGS.
  • Docs: docs/linked-computers.md (notices).

Verification

  • New tests/integration/config-sync-connection.test.ts (two linked gateways):
    • A: Grok native → endpoint through a proxy. B: endpoint → back to device login. After linking, B has one connection notice (choice, own_value=false). Restore on B: both computers are endpoint through the proxy, both workers get its address and key, and no notices are left on either computer.
    • A merged connection in A's history (as left by an earlier link): one notice (own_value=true, "Studio B"). Restore: both converge, no notices are left. Keep current (Dismiss) clears it and leaves both on device login.
    • Before the fix, the same scenario failed on the second Restore with the provider_instances_endpoint violation, which the user saw as the generic link message.
  • The device-login refusal still holds: config-sync-workers (a linked computer can't start StartProviderLogin through its API or directly over the link), 9/9.
  • Multi-gateway files run one at a time: config-sync-connection 2/2, -workers 9/9, -providers 7/7, -intent 3/3, -identity 4/4, -recovery 6/6, -bootstrap 4/4, config-sync 7/7, -environment 8/8.
  • bun install, gen:check, typecheck, lint, format:check, web build: clean. check:tmp (full run) was not run; only the focused files above.
  • Not checked in a browser: the change only replaces text in the existing notice row, which already wraps (break-words, flex-wrap buttons). Mobile still shows its plain notice list (field name and raw value); the connection field shows there as raw JSON, as other fields already do.

Copy audit (docs/copy.md §8)

Where Before → after Why
Instance notice title Connects with + Proxy (two rows) → Connects with (one row) One thing changed: how the instance connects. "Connection" is a banned synonym for instance, so the title keeps "Connects with".
Connection value Endpoint / A different proxy → This computer’s value: Endpoint through a different proxy (also Device login, Endpoint at <url>, … with a different key) Says what differs and whose value it is; proxies are never shown as ids.
Merged notice Merged with <computer>. → Replaced when this computer linked with <computer>. / Not used when this computer linked with <computer>. Says what happened; active voice; ≤ 10 words.
Restore button (merged/concurrent) Restore → Restore this computer’s / Use the other’s Verb first; says what Restore does; same wording as the existing choice notice.
Dismiss button (merged/concurrent) Dismiss → Keep current Says the effect instead of hiding a notice.
Notice action failed Computer link operation failed. Check the address, code and Network access settings. → Could not apply this value on this computer. Try again, or change it in its settings. What happened, then what to do; the link message fits only pairing.
Other linked-computer actions same generic link message → Could not load linked computers. Try again., Could not change this linked computer. Try again., Could not move the threads. Check that the other computer is online, then try again., Could not load moves. Try again., Could not load workers of linked computers. Try again., Could not read thread sync diagnostics. Try again. Each names the failed action and ends with an action.
Settings → Linked computers fallback Computer link operation failed → Could not update linked computers. Try again. Ends with an action.

Glossary: "instance", "proxy", "computer" used as defined; no new terms; no "soul" sentences. Long computer names wrap (break-words).

Related: #164, #696

Restore of a "Changed on two computers" notice wrote kind or proxy alone.
A native instance then kept the proxy id, the worker sync copied the
proxy's address onto it and Postgres refused the row
(provider_instances_endpoint). The guard turned that into the pairing
message "Check the address, code and Network access settings".

- Kind, proxy, endpoint and key of an instance are one notice
  ("Connects with") and are restored or chosen together.
- A native instance never gets a proxy_id.
- Notices say whose value they keep (ConfigNotice.own_value).
- Unexpected failures outside pairing name what failed.

Related: #164, #696
@nixuuu
nixuuu merged commit 9703ae5 into dev Nov 14, 2026
9 checks passed
@nixuuu
nixuuu deleted the fix/restore-provider-conflicts branch November 14, 2026 11:42
nixuuu added a commit that referenced this pull request Nov 14, 2026
Share notice formatting and actions with web, including saved connection values and ownership. Refresh settings after partial bulk resolution and show an actionable apply error.

Related: #706
nixuuu added a commit that referenced this pull request Nov 14, 2026
Mobile configuration notices previously showed serialized values and
internal field names. They now use the same domain presentation as web:
readable fields and values, value ownership, connection summaries, and
the corresponding restore, choice, deletion and dismissal actions.
Failed actions show an actionable apply error; bulk actions refresh
settings even after partial success.

Related: #706

Validation:
- 35 domain tests cover all 12 notice kinds, saved-value ownership,
choices, deletion/resurrection, connection summaries and redacted
credentials.
- Passed with `nice` and temporary files under `/var/tmp`: install,
gen:check, typecheck, lint, format:check, web build, Android export and
iOS export.
- Fingerprints unchanged: iOS
`138e0c6b171c82b4933e86808cdfef56da73b8c6`; Android
`906dc944f94eb8333fa384ed9f198834fdd30d13`. No native configuration or
dependency changes. OTA delivery uses the normal release workflow after
merge.

Copy audit (§8):
- Raw JSON/internal field names → shared readable field/value text;
users can identify the changed setting.
- Node/reason strings → the web descriptions, including “Replaced when
this computer linked with …” and whose saved value is shown.
- Generic Restore/Dismiss → the same context-specific verbs as web,
including “Restore this computer’s”, “Use the other’s” and “Keep
current”.
- Generic save failure → “Could not apply this value on this computer.
Try again, or change it in its settings.” No transport details or
secrets.
- Checked sentence case, punctuation, glossary, verb-led actions,
non-colour cues, no duplicate facts, no new empty states or humour.
Reviewed source layout for short/long names: text wraps and actions wrap
within their container. Rendered light/dark and device-width acceptance
remains unverified; no UI suites or E2E were run.
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