Start place: stored-session start test, restore logging, thread waits for live READY (#615) #742

Closed
charles wants to merge 0 commits from fix-615-restore-on-stored-session-start into textchat
Owner

Refs #615

The user's failure (stored session + cached READY → home instead of the last community/channel) is not reproduced on current textchat. This PR adds the missing end-to-end test of that path, INFO log lines for the restore, and fixes one case the new test did find.

Reproduction rig (test-only)

  • Runtime::with_devserver_session() (hidden, for tests): with --devserver, keeps the token in a plain file (<data_dir>/devserver-token, no OS keyring) and the SQLite cache under the test's Paths, beside the settings file. A start that finds a stored token restores the session from it (GET /users/@me + cached READY) instead of the demo login.
  • apps/fluxer/tests/start_place_session.rs: run 1 logs in, opens a place, quits (token, cached READY and [navigation.last_location] + selected_channels checked on disk). Run 2 starts like an installed client: no /auth/login, /users/@me asked, the cached READY first, the live READY after. It checks the place on the cached READY, after the live READY, 3 s later (messages, op 14 threads, passive updates), and that no logged-in snapshot showed another place.
    • Big's #chatter (a non-default channel): passes on unchanged textchat. That is why the user's report is not reproduced.
    • A thread opened in full view (Forked's "Release checklist"): fails on textchat. The app lands on #general.

Thread place: cause and fix

The cached READY puts guilds and channels in the store, not threads (they reach Channels through chat.threads, which only the live READY fills). start_place::go_to saw a guild present and a channel missing, so it treated the channel as gone and opened the guild's default channel at once. The state went to Checking, the place on screen (#general) overwrote the stored one, and the live READY found #general viewable and kept it.
Fix: in the cached phase, a guild place whose channel is not in the store returns None. The restore then waits for the live READY, the same way a guild missing from the cache already did (new StartPlace::WaitingLive, so the wait is logged once). The original's fallbacks are unchanged: community gone → home, channel gone → community's default channel (now decided by the live READY), nothing stored → home.

Logging (INFO, guild/channel ids only)

start place restored (guild, channel, from = cached/live READY), start place: none stored; starting on the home, start place given up: another place was opened before the data came, start place not in the cached READY; waiting for the live one, start place given up; starting on the home (reason: community gone / DM gone), start place's channel is gone …; opening the community's default channel, start place confirmed by the live READY. The app test asserts the restore line.

Tests

  • Core (crates/fluxer-core/tests/start_location.rs): a_thread_waits_for_the_live_ready (failed before the fix), starts_on_the_thread_it_was_closed_on, starts_on_the_voice_channel_it_was_closed_on (live and cached).
  • App: both start_place_session tests. The thread one failed before the fix. The existing starts_on_the_channel_it_was_closed_on still passes.
  • FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci: all steps passed.

Other conditions checked

  • Home shown briefly before the live READY: not reproduced. Before /users/@me answers, the login screen is shown. From the first logged-in snapshot on, the place is shown (the test asserts this).
  • Voice channel as the place: not reproduced (core test passes).
  • Restart by the updater / close button: the place is written on every change (PersistOp::Navigation), and shutdown drains the persist queue. Covered by the first run's shutdown. A kill within milliseconds of a change could lose that change. Reasoned, not tested.
  • Friends page last: the friends page is the home, so the home is restored, as in the original. Exception: the friends page opened over a DM keeps that DM selected (UI-only opened_over), so the next start shows the DM, not the friends page. Not changed here.

🤖 Generated with Claude Code

Refs #615 The user's failure (stored session + cached READY → home instead of the last community/channel) is **not reproduced** on current `textchat`. This PR adds the missing end-to-end test of that path, INFO log lines for the restore, and fixes one case the new test did find. ### Reproduction rig (test-only) - `Runtime::with_devserver_session()` (hidden, for tests): with `--devserver`, keeps the token in a plain file (`<data_dir>/devserver-token`, no OS keyring) and the SQLite cache under the test's `Paths`, beside the settings file. A start that finds a stored token restores the session from it (`GET /users/@me` + cached READY) instead of the demo login. - `apps/fluxer/tests/start_place_session.rs`: run 1 logs in, opens a place, quits (token, cached READY and `[navigation.last_location]` + `selected_channels` checked on disk). Run 2 starts like an installed client: no `/auth/login`, `/users/@me` asked, the cached READY first, the live READY after. It checks the place on the cached READY, after the live READY, 3 s later (messages, op 14 threads, passive updates), and that no logged-in snapshot showed another place. - Big's #chatter (a non-default channel): **passes on unchanged textchat**. That is why the user's report is not reproduced. - A thread opened in full view (Forked's "Release checklist"): **fails on textchat**. The app lands on #general. ### Thread place: cause and fix The cached READY puts guilds and channels in the store, not threads (they reach `Channels` through `chat.threads`, which only the live READY fills). `start_place::go_to` saw a guild present and a channel missing, so it treated the channel as gone and opened the guild's default channel at once. The state went to `Checking`, the place on screen (#general) overwrote the stored one, and the live READY found #general viewable and kept it. Fix: in the cached phase, a guild place whose channel is not in the store returns `None`. The restore then waits for the live READY, the same way a guild missing from the cache already did (new `StartPlace::WaitingLive`, so the wait is logged once). The original's fallbacks are unchanged: community gone → home, channel gone → community's default channel (now decided by the live READY), nothing stored → home. ### Logging (INFO, guild/channel ids only) `start place restored` (guild, channel, from = cached/live READY), `start place: none stored; starting on the home`, `start place given up: another place was opened before the data came`, `start place not in the cached READY; waiting for the live one`, `start place given up; starting on the home` (reason: community gone / DM gone), `start place's channel is gone …; opening the community's default channel`, `start place confirmed by the live READY`. The app test asserts the restore line. ### Tests - Core (`crates/fluxer-core/tests/start_location.rs`): `a_thread_waits_for_the_live_ready` (failed before the fix), `starts_on_the_thread_it_was_closed_on`, `starts_on_the_voice_channel_it_was_closed_on` (live and cached). - App: both `start_place_session` tests. The thread one failed before the fix. The existing `starts_on_the_channel_it_was_closed_on` still passes. - `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci`: all steps passed. ### Other conditions checked - Home shown briefly before the live READY: not reproduced. Before `/users/@me` answers, the login screen is shown. From the first logged-in snapshot on, the place is shown (the test asserts this). - Voice channel as the place: not reproduced (core test passes). - Restart by the updater / close button: the place is written on every change (`PersistOp::Navigation`), and shutdown drains the persist queue. Covered by the first run's `shutdown`. A kill within milliseconds of a change could lose that change. Reasoned, not tested. - Friends page last: the friends page is the home, so the home is restored, as in the original. Exception: the friends page opened *over a DM* keeps that DM selected (UI-only `opened_over`), so the next start shows the DM, not the friends page. Not changed here. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The start's return to the last place (#615) had no end-to-end test of the path an
installed client takes: a stored token and a cached READY, no login screen. The
devserver rig can now keep a session (`Runtime::with_devserver_session`: the token in
a plain file and the SQLite cache under the test's paths; a stored token skips the
demo login), and `start_place_session` quits on a channel and starts again on it.
That path restores the place on current textchat; it did not reproduce the report.

It found one case that fails: a thread opened in full view as the last place. The
cached READY puts guilds and channels in the store, not threads, so the restore
gave way to the community's default channel at once and the live READY kept it.
A channel the cache does not have now waits for the live READY, as a guild the cache
does not have already did.

The restore and its fallbacks are logged at INFO with the guild and channel ids.

Refs #615

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Merged into textchat by hand (the merge API returns 405); the commits are in the branch.

Merged into `textchat` by hand (the merge API returns 405); the commits are in the branch.
charles closed this pull request 2026-11-16 03:56:47 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.