Skip to content

fix(app): keep saved hosts when one entry can't be read - #9847

Merged
paseo-bot[bot] merged 1 commit into
getpaseo:mainfrom
ragokan:fix/keep-saved-hosts
Nov 16, 2026
Merged

paseo-bot[bot] merged 1 commit into
getpaseo:mainfrom
ragokan:fix/keep-saved-hosts

Conversation

@ragokan

@ragokan ragokan commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Linked issue

No issue reports this. #9122 (open) also recovers saved hosts, but for a host that rejects its password. This PR is about the stored list itself.

Type of change

  • Bug fix
  • New feature
  • Enhancement
  • Refactor
  • Docs

Reasoning

The app keeps your saved hosts and their passwords in one stored list, @paseo:daemon-registry. Every app build on the device reads and writes that list. The app reads it with a strict schema, so one host or connection this build can't read fails the whole list. The loader then removes the key, and every saved host and password goes with it. The next launch opens on "Welcome to Paseo", and you have to pair every host again.

You reach that state after a downgrade, when the newer build saved a connection kind this build doesn't know. A list that isn't valid JSON is also removed.

The app now reads each host and connection on its own. It lists the hosts it can read and skips the rest. Skipped entries stay in storage and are written back on every save, so the build that wrote them still finds them. A value that isn't a JSON array is copied to @paseo:daemon-registry:unreadable before the next save overwrites the key.

Goals

  • One host or connection this build can't read no longer removes the others. Every readable host loads with its password.
  • A host keeps its readable connections when one of its connections can't be read.
  • Saving the list, for example after renaming a host, keeps the entries this build couldn't read.
  • Removing a host also drops what this build couldn't read for it. Pairing that host again replaces the unreadable entry instead of storing a second entry with the same server id.
  • A stored value that isn't a JSON array is copied to @paseo:daemon-registry:unreadable instead of being removed.
  • The COMPAT(connectionPassword) migration still moves a stored connection password to its host and saves it, including when the host also has a connection this build can't read.
  • No protocol change.
  • docs/data-model.md describes the stored host list and why its key is never removed.

Non-goals

  • Lists that an earlier build already removed can't be recovered.
  • readValidatedJson and the other stored keys keep their current behaviour. The host list now has its own read in host-runtime.ts.
  • A host whose connections are all unreadable stays hidden in this build, because it has no way to connect. It stays in storage.
  • A connection of a known kind with an invalid value, such as an empty socket path, is still dropped, as before.
  • Trade-off: when a host's preferred connection is one this build can't read, the host prefers a readable connection, and a save writes that choice back.

QA

Web app, before and after. I ran a dev daemon from this branch on 127.0.0.1:18650, with every real agent provider, the relay, dictation and voice mode disabled in its config, and the Expo web app on port 18651 (npm run start:expo --workspace=@getpaseo/app -- --port 18651). A Playwright script (not part of this PR) drove headless Chromium 145 against it. In a fresh browser profile it seeded @paseo:daemon-registry with three fake entries and marked onboarding complete:

  • "QA daemon": the dev daemon's server id, a direct connection to 127.0.0.1:18650, and a second connection of an unknown futureKind.
  • "Saved remote host": an unreachable direct connection on 127.0.0.1:18659, with the fake password qa-fake-password.
  • "Host from a newer build": only a futureKind connection.

Then it reloaded, opened the sidebar's hosts list, and on the fixed build renamed "Saved remote host" from Settings → Host → Overview. For the base run I restored host-runtime.ts and host-connection.ts to upstream/main (fa8ba1bd3) and restarted Metro.

  • Base: the app opened on "Welcome to Paseo" with no hosts. @paseo:daemon-registry read null after the reload: both readable hosts and the password were gone.
  • Fixed: the hosts list showed "QA daemon" (online, localhost:18650) and "Saved remote host". The key was unchanged after the reload. After the rename the key held all three hosts. "Saved remote host" had its new name and its password, "QA daemon" still had its futureKind connection, and "Host from a newer build" was unchanged.

Script output:

before: hosts picker visible false
before: listed host rows []
before: @paseo:daemon-registry after reload null

after: hosts picker visible true
after: listed host rows ["sidebar-host-row-srv_Nqh9t9GxJ9YS","sidebar-host-row-srv_qa_saved_remote"]

The stored list after the rename, one line per host (serverId | label | password | connections):

srv_Nqh9t9GxJ9YS | QA daemon | - | directTcp:localhost:18650, futureKind:garage.example
srv_qa_saved_remote | Renamed remote host | qa-fake-password | directTcp:localhost:18659
srv_qa_newer_build_only | Host from a newer build | - | futureKind:roof.example
Base Fixed
App after reload base, welcome screen with no hosts fixed, both hosts listed
@paseo:daemon-registry base, key removed fixed, after renaming a host

Seeded list, the same for both runs:

seeded registry

Fixed, after the rename:

renamed host

The storage images render the key's value read from the page after each step.

Regression tests. For red I restored only packages/app/src/runtime/host-runtime.ts and packages/app/src/types/host-connection.ts to upstream/main (fa8ba1bd3) and kept the new tests. Then I restored the fix for green. Commands ran from packages/app with NODE_ENV=test. Red ran without --bail so every failure shows.

src/types/host-connection.test.ts adds:

  • "drops a connection kind this build doesn't know and keeps the host"
  • "writes back every entry it could not read"
  • "writes a host saved again by this build in place of the entry it could not read"
  • "moves a stored direct TCP password to its host next to a connection it can't read"

The last three call the new readHostRegistry and writeHostRegistry, so on main they fail with TypeError: readHostRegistry is not a function.

$ npx vitest run src/types/host-connection.test.ts
     × drops a connection kind this build doesn't know and keeps the host 6ms
     × writes back every entry it could not read 1ms
     × writes a host saved again by this build in place of the entry it could not read 1ms
     × moves a stored direct TCP password to its host next to a connection it can't read 0ms
 FAIL  |unit| src/types/host-connection.test.ts > normalizeStoredHostProfile > drops a connection kind this build doesn't know and keeps the host
AssertionError: expected undefined to be 'secret' // Object.is equality

- Expected:
"secret"

+ Received:
undefined

 ❯ src/types/host-connection.test.ts:104:31
 FAIL  |unit| src/types/host-connection.test.ts > readHostRegistry and writeHostRegistry > writes back every entry it could not read
TypeError: readHostRegistry is not a function
 ❯ src/types/host-connection.test.ts:220:35
 ...
 Test Files  1 failed (1)
      Tests  4 failed | 31 passed (35)

Green:
$ npx vitest run src/types/host-connection.test.ts --bail=1
 Test Files  1 passed (1)
      Tests  35 passed (35)

src/runtime/host-runtime.test.ts boots a HostRuntimeStore on in-memory storage and adds:

  • "keeps readable hosts when the registry holds entries this build can't read"
  • "keeps the entries it can't read when it saves the registry"
  • "moves a stored connection password to its host and keeps the connection it can't read"
  • "forgets an entry it can't read once that host is paired again and removed"
  • "copies a registry that isn't JSON aside instead of deleting it"

The fourth passes on main too, because main drops the unreadable entry at load. It checks that the write-back doesn't bring a removed host back.

$ npx vitest run src/runtime/host-runtime.test.ts
       × keeps readable hosts when the registry holds entries this build can't read 12ms
       × keeps the entries it can't read when it saves the registry 3ms
       × moves a stored connection password to its host and keeps the connection it can't read 1ms
       × copies a registry that isn't JSON aside instead of deleting it 1ms
 FAIL  |unit| src/runtime/host-runtime.test.ts > HostRuntimeStore > keeps readable hosts when the registry holds entries this build can't read
AssertionError: expected [] to deeply equal [ [ 'srv_a', 'secret-a' ], …(1) ]
 ❯ src/runtime/host-runtime.test.ts:2745:76
 FAIL  |unit| src/runtime/host-runtime.test.ts > HostRuntimeStore > keeps the entries it can't read when it saves the registry
AssertionError: expected [] to match object [ { serverId: 'srv_a', …(2) }, …(2) ]
 ❯ src/runtime/host-runtime.test.ts:2762:41
 FAIL  |unit| src/runtime/host-runtime.test.ts > HostRuntimeStore > moves a stored connection password to its host and keeps the connection it can't read
AssertionError: expected [] to deeply equal [ [ 'srv_legacy', 'old-secret' ] ]
 ❯ src/runtime/host-runtime.test.ts:2788:76
 FAIL  |unit| src/runtime/host-runtime.test.ts > HostRuntimeStore > copies a registry that isn't JSON aside instead of deleting it
AssertionError: expected null to be '{not json' // Object.is equality
 ❯ src/runtime/host-runtime.test.ts:2828:65
 Test Files  1 failed (1)
      Tests  4 failed | 115 passed (119)

Green:
$ npx vitest run src/runtime/host-runtime.test.ts --bail=1
 Test Files  1 passed (1)
      Tests  119 passed (119)

e2e/browser/saved-host-registry.spec.ts uses the shared fixture's seeded host. It adds an unknown connection to that host, plus a readable offline host with a fake password and a host with only an unknown connection, then reloads. It checks that both readable hosts are listed, renames the offline host in Settings, and checks the stored list: the new name, the password and both unknown entries.

$ npx playwright test --project=browser e2e/browser/saved-host-registry.spec.ts

Red:
  ✘  1 [browser] › e2e/browser/saved-host-registry.spec.ts:74:5 › saved hosts survive a registry entry this build can't read, and saving keeps it (18.1s)
  1) [browser] › e2e/browser/saved-host-registry.spec.ts:74:5 › … › both readable hosts are listed
    Error: expect(locator).toBeVisible() failed
    Locator: getByTestId('sidebar-host-row-srv_e2e_worker_0')
    Expected: visible
    Error: element(s) not found
    > 82 |     await expect(page.getByTestId(`sidebar-host-row-${getServerId()}`)).toBeVisible();
  1 failed

Green:
  ✓  1 [browser] › e2e/browser/saved-host-registry.spec.ts:74:5 › saved hosts survive a registry entry this build can't read, and saving keeps it (10.0s)
  1 passed (30.3s)

In both runs Metro logs a React error from host-picker.tsx:93, a Pressable inside the host row's Pressable, whenever the hosts list shows a host. That is the open #7309; this PR doesn't touch that code.

Repository checks.

Command Result
npm run typecheck Passed in all workspaces (after npm run build:server)
npm run lint -- <5 changed .ts files> Found 0 warnings and 0 errors
npm run format:check:files -- <6 changed files> All matched files use the correct format
Platform Tested Notes
iOS No Not run. Same HostRuntimeStore code over AsyncStorage
Android No Not run. Same HostRuntimeStore code over AsyncStorage
Web Yes Expo web dev build in headless Chromium 145 on Debian 13 (arm64), Node 26.13.1, against a dev daemon from this branch; Playwright's headless Chromium for the spec
Desktop macOS No Not available
Desktop Windows No Not available
Desktop Linux No Electron not run; Linux browser covered under Web

I did not run a real newer build that writes a new connection kind. The seeded futureKind entries stand in for one.

Checklist

  • Plugin changes follow the SDK import boundaries (if applicable)
  • One focused change
  • npm run typecheck passes
  • npm run lint passes (changed files)
  • npm run format passes (format:files and format:check:files on changed files)
  • QA evidence
  • Tests added or updated where it made sense

The host registry was parsed with a strict array schema, so one host or
connection this build couldn't read failed the whole array. The loader then
removed @paseo:daemon-registry, and every saved host and password with it.
That happens after a downgrade, or once a newer build saves a connection kind
this build doesn't know.

- Hosts and connections are read one at a time. One this build can't read
  is skipped, and the other hosts load.
- Skipped entries are written back on every save, so the build that wrote
  them still finds them. Removing a host also drops what this build couldn't
  read for it.
- A value that isn't a JSON array is copied to
  @paseo:daemon-registry:unreadable instead of being removed.
- The stored-password migration still moves a connection password to its
  host when that host also has an unreadable connection.
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-16T08:23:15.406317Z
We couldn’t complete this review. Comment @codex review to try again.
38fc36b PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@paseo-bot

paseo-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

This is tracked as #9849. Work on Paseo is organized by issue rather than by pull request: #9849 is picked up when it is reached, and a fix that builds on yours credits you as a co-author. Updates go on #9849.

Thanks for the pull request.

@paseo-bot paseo-bot Bot added bug Reproducible unintended behavior triaged Reviewed by maintainer triage labels Nov 16, 2026

@paseo-bot paseo-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reproduced #9849 locally and this pull request fixes it. It is labeled diagnosed, so it goes to the merge queue from here.

What I ran on 38fc36b:

  • Your browser spec e2e/browser/saved-host-registry.spec.ts fails with main's host-runtime.ts and host-connection.ts (no host rows listed after the reload) and passes with this branch.
  • Your unit test "keeps readable hosts when the registry holds entries this build can't read" fails on main (expected [] to deeply equal ...) and passes here. Both test files pass in full (155 tests).
  • I also tried a host whose relay connection has a field this build doesn't know, which is what v0.12.x sees after a downgrade from v0.13.0 or later (v0.13.0 added minimumSecurityMode and the routed kind). main lists no hosts. This branch lists the other host with its password and leaves the stored list unchanged.
  • CI is green.

Your cause held: the strict read of the whole list removes @paseo:daemon-registry when any one entry fails it.

Not tested: a real downgrade between two installed builds, and the desktop and mobile apps. Those use the same HostRuntimeStore code.

@paseo-bot paseo-bot Bot added the diagnosed The diagnose bot investigated this; on a PR, the bot authored it label Nov 16, 2026
@paseo-bot
paseo-bot Bot merged commit a8cadae into getpaseo:main Nov 16, 2026
21 checks passed

@paseo-bot paseo-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged. Thanks, @ragokan. Your cause and your fix both held, and the squash commit is a8cadae. I closed #9849 against it.

Product delta: before, one saved host or connection the app couldn't read (for example after a downgrade from a build with a newer connection kind) deleted every saved host and password, and the app opened on "Welcome to Paseo". After, the hosts it can read stay listed with their passwords. Entries it can't read are hidden in that build but kept, and written back on every save.
Protocol delta: none. The stored host list keeps the same shape. A stored value that isn't a JSON array is now copied to @paseo:daemon-registry:unreadable instead of being deleted.

What it does

HostRuntimeStore reads the saved-host list one host and one connection at a time. It keeps whatever this build can't read and writes it back when it saves. Removing a host drops those entries for that host, and pairing that host again replaces its unreadable entry.

Review

  1. Does it fix what was reported? Yes. On main, loadFromStorage read the whole list with one strict schema, and readValidatedJson removed the key when any entry failed it. The diagnose bot reproduced that in the web app (repro 4/5, diagnosis 5/5), and QA reproduced it below. The browser spec and the HostRuntimeStore tests check the behavior the user sees (listed hosts, stored key), not internals.
  2. Is it the right fix? Yes. The change is in the loader, packages/app/src/runtime/host-runtime.ts with packages/app/src/types/host-connection.ts, which is the only reader and writer of the key. The decision to delete the key is removed, not guarded. readValidatedJson stays as it is for the other keys. Known kinds are still parsed strictly, so a connection with a field this build doesn't know is skipped rather than used without that field. That matters for fields like the relay minimumSecurityMode.
  3. Does it do anything else? No protocol, schema, setting, dependency or design.md change. The only behavior change outside the fix is that a host whose connections are all unreadable stays hidden in that build (the PR names this as a non-goal), and before this change it was deleted.
  4. Is it worth shipping? Yes. Losing every saved host and password is data loss on every platform, and the fix is about 140 lines in one module.

QA (on 38fc36b, isolated daemon, Expo web app in a real browser)

  1. Reported scenario, base vs head: PASS. The seed was a live host plus an unknown-kind connection, an offline host with a password, a host with only an unknown-kind connection, and a host with only a relay connection carrying an unknown field. On head, the live and offline hosts are listed, the live one online, and the stored key is byte-for-byte unchanged after the reload. On base, the app shows the welcome screen and the key is gone. The relay host with the unknown field is kept but not listed. That matches #9849's expected result: the build can't read that entry, so it keeps it without showing it.
  2. Regression tests: PASS. host-connection.test.ts and host-runtime.test.ts have 8 failures on base sources and pass on head (154 tests). e2e/browser/saved-host-registry.spec.ts fails on base and passes on head. The app typecheck is clean.
  3. Save paths: PASS. I renamed a host, changed a color and badge, added a connection with a password, and removed a connection, all in the UI. After each step, the unknown connection, the unknown-only host and the relay entry were still stored.
  4. Remove and re-pair: PASS. Removing a host drops its unknown connection and it stays gone after a reload. Re-pairing a daemon whose stored entry was unreadable leaves exactly one entry for that server id.
  5. Normal use: PASS. I paired a fresh profile in the UI and reloaded. The stored entry has only known fields, and a Claude Code agent started from the app replied.
  6. Stored connection password migration: PASS. On a password-protected daemon, the password moved to the host, the connection worked, and the unknown connection was kept. Without the password, the same host fails as expected.
  7. Unreadable value: PASS. {not json and {"a":1} are copied to :unreadable, the app opens with no hosts, and pairing then writes a valid list. Base deletes the key.

Outside the checklist (considered, not counted)

  • Saved 127.0.0.1 direct endpoints are rewritten to localhost on the first save. normalizeLoopbackToLocalhost already does this on main, and this PR doesn't change it.
  • A non-array value stays in the main key until the next save. The PR documents this, and the copy is made before the overwrite.
  • A second unreadable value overwriting an earlier :unreadable copy was not exercised. It is hypothetical.
  • A re-paired host takes the daemon's label, not the hidden entry's. This is expected, because the readable entry replaces the unreadable one.

There were no review threads.

For the maintainer to weigh later, not a blocker: reading host-profile objects non-strictly would let an older build keep showing a host when a newer build adds a top-level field. Today such a host is kept but hidden.

Reviewed commit: 38fc36b

@paseo-bot paseo-bot Bot added the community-notified Merged work has been communicated to the people who reported or discussed it label Nov 16, 2026
x9x9x9x9x9x91 pushed a commit to x9x9x9x9x9x91/paseo that referenced this pull request Nov 18, 2026
The host registry was parsed with a strict array schema, so one host or
connection this build couldn't read failed the whole array. The loader then
removed @paseo:daemon-registry, and every saved host and password with it.
That happens after a downgrade, or once a newer build saves a connection kind
this build doesn't know.

- Hosts and connections are read one at a time. One this build can't read
  is skipped, and the other hosts load.
- Skipped entries are written back on every save, so the build that wrote
  them still finds them. Removing a host also drops what this build couldn't
  read for it.
- A value that isn't a JSON array is copied to
  @paseo:daemon-registry:unreadable instead of being removed.
- The stored-password migration still moves a connection password to its
  host when that host also has an unreadable connection.

(cherry picked from commit a8cadae)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Reproducible unintended behavior community-notified Merged work has been communicated to the people who reported or discussed it diagnosed The diagnose bot investigated this; on a PR, the bot authored it triaged Reviewed by maintainer triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

⌂ 换网址