Repository navigation
fix(app): keep saved hosts when one entry can't be read - #9847
Conversation
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.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
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.tsfails withmain'shost-runtime.tsandhost-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
minimumSecurityModeand theroutedkind).mainlists 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.
There was a problem hiding this comment.
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
- Does it fix what was reported? Yes. On main,
loadFromStorageread the whole list with one strict schema, andreadValidatedJsonremoved 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 theHostRuntimeStoretests check the behavior the user sees (listed hosts, stored key), not internals. - Is it the right fix? Yes. The change is in the loader,
packages/app/src/runtime/host-runtime.tswithpackages/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.readValidatedJsonstays 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 relayminimumSecurityMode. - Does it do anything else? No protocol, schema, setting, dependency or
design.mdchange. 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. - 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)
- 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.
- Regression tests: PASS.
host-connection.test.tsandhost-runtime.test.tshave 8 failures on base sources and pass on head (154 tests).e2e/browser/saved-host-registry.spec.tsfails on base and passes on head. The app typecheck is clean. - 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.
- 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.
- 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.
- 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.
- Unreadable value: PASS.
{not jsonand{"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.1direct endpoints are rewritten tolocalhoston the first save.normalizeLoopbackToLocalhostalready 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
:unreadablecopy 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
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)
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
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:unreadablebefore the next save overwrites the key.Goals
@paseo:daemon-registry:unreadableinstead of being removed.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.docs/data-model.mddescribes the stored host list and why its key is never removed.Non-goals
readValidatedJsonand the other stored keys keep their current behaviour. The host list now has its own read inhost-runtime.ts.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-registrywith three fake entries and marked onboarding complete:127.0.0.1:18650, and a second connection of an unknownfutureKind.127.0.0.1:18659, with the fake passwordqa-fake-password.futureKindconnection.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.tsandhost-connection.tstoupstream/main(fa8ba1bd3) and restarted Metro.@paseo:daemon-registryreadnullafter the reload: both readable hosts and the password were gone.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 itsfutureKindconnection, and "Host from a newer build" was unchanged.Script output:
The stored list after the rename, one line per host (serverId | label | password | connections):
@paseo:daemon-registrySeeded list, the same for both runs:
Fixed, after the rename:
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.tsandpackages/app/src/types/host-connection.tstoupstream/main(fa8ba1bd3) and kept the new tests. Then I restored the fix for green. Commands ran frompackages/appwithNODE_ENV=test. Red ran without--bailso every failure shows.src/types/host-connection.test.tsadds:The last three call the new
readHostRegistryandwriteHostRegistry, so on main they fail withTypeError: readHostRegistry is not a function.src/runtime/host-runtime.test.tsboots aHostRuntimeStoreon in-memory storage and adds: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.
e2e/browser/saved-host-registry.spec.tsuses 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.In both runs Metro logs a React error from
host-picker.tsx:93, aPressableinside the host row'sPressable, whenever the hosts list shows a host. That is the open #7309; this PR doesn't touch that code.Repository checks.
npm run typechecknpm run build:server)npm run lint -- <5 changed .ts files>npm run format:check:files -- <6 changed files>HostRuntimeStorecode over AsyncStorageHostRuntimeStorecode over AsyncStorageI did not run a real newer build that writes a new connection kind. The seeded
futureKindentries stand in for one.Checklist
npm run typecheckpassesnpm run lintpasses (changed files)npm run formatpasses (format:filesandformat:check:fileson changed files)