Start on the place that was on screen at the last quit (#615) #708

Closed
charles wants to merge 0 commits from fix-615-start-on-last-view into textchat
Owner

Closes #615

Cause. Daily use 7 persisted the last channel per community ([navigation] selected_channels), so opening a community went back to its channel. Nothing kept the place that was on screen, though, and the store always starts with no guild and no channel selected. That meant every start showed the home view.

What the original does (~/src/fluxer-soundboard): Location.lastLocation (Location.ts) is persisted and updated on every channel route (useLastLocationPersistence.ts). Once authenticated, RootComponent.tsx navigates to it once, and only if the current route is still /channels/@me. After the first READY, abandonUnreachableLastLocation (ChannelRouteReachability.ts) clears it and goes home in two cases: the guild is gone (not merely unavailable), or a DM no longer exists. If the guild is still there, a guild route resolves to its default channel (GuildChannelRouter.tsx). A fresh profile has nothing stored and lands on @me.

Fix.

  • NavigationStored.last_location: Option<LastLocation { guild_id, channel_id }>, stored in [navigation.last_location] (guild_id "@me" for the DM list). If it cannot be read, it loads as none.
  • New fluxer-core/src/start_place.rs, plus a StartPlace state in UiState that resets on logout:
    • Restore: once logged in, the app goes to the stored place at the first READY that has it, as long as the home is still on screen. With a cache, that is the cached READY, and the live one checks the place again. A place the cache does not have (for example a guild joined after the cache was written) waits for the live READY.
    • Fallbacks: a guild left or a DM gone gives the home. A channel that is gone or no longer viewable in a guild that is still there opens the guild on its default channel, through the existing OpenGuild. A guild in an outage is kept.
    • Saving: the place is not written until the restore has happened, so the start cannot overwrite it with the home.
  • The quick switcher's navigation write carries last_location along.

Verified.

  • crates/fluxer-core/tests/start_location.rs, 18 tests:

    • saving the place (guild+channel, DM, home);
    • starting on a guild channel, on a DM, and on the home;
    • a fresh profile;
    • nothing written before the restore;
    • a guild left, a DM gone, a channel gone, a channel no longer viewable, an outage, a guild with no channel open;
    • restoring once per start, and again after a new login;
    • the cached-READY restore, the live-READY fallbacks after it, and a place missing from the cache.

    With the restore stubbed out, the 12 tests that depend on it fail.

  • crates/fluxer-platform/tests/settings_chat.rs::last_location_round_trip: the file round trip, and unreadable values.

  • apps/fluxer/tests/dailyuse_acceptance.rs::starts_on_the_channel_it_was_closed_on, against the devserver: quit on Big's #chatter (the second community; not its default channel), start again on the same settings, and #chatter is on screen with its messages and no click. It fails with the restore stubbed out.

  • FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci: all steps passed.

Not covered. The friends page opened over a DM is local view state in fluxer-ui. The stored place there is that DM, so the next start opens the DM, whereas the original would open @me.

🤖 Generated with Claude Code

Closes #615 **Cause.** Daily use 7 persisted the last channel *per community* (`[navigation] selected_channels`), so opening a community went back to its channel. Nothing kept the place that was on screen, though, and the store always starts with no guild and no channel selected. That meant every start showed the home view. **What the original does** (`~/src/fluxer-soundboard`): `Location.lastLocation` (`Location.ts`) is persisted and updated on every channel route (`useLastLocationPersistence.ts`). Once authenticated, `RootComponent.tsx` navigates to it once, and only if the current route is still `/channels/@me`. After the first `READY`, `abandonUnreachableLastLocation` (`ChannelRouteReachability.ts`) clears it and goes home in two cases: the guild is gone (not merely unavailable), or a DM no longer exists. If the guild is still there, a guild route resolves to its default channel (`GuildChannelRouter.tsx`). A fresh profile has nothing stored and lands on `@me`. **Fix.** - `NavigationStored.last_location: Option<LastLocation { guild_id, channel_id }>`, stored in `[navigation.last_location]` (`guild_id` `"@me"` for the DM list). If it cannot be read, it loads as none. - New `fluxer-core/src/start_place.rs`, plus a `StartPlace` state in `UiState` that resets on logout: - **Restore:** once logged in, the app goes to the stored place at the first `READY` that has it, as long as the home is still on screen. With a cache, that is the cached `READY`, and the live one checks the place again. A place the cache does not have (for example a guild joined after the cache was written) waits for the live `READY`. - **Fallbacks:** a guild left or a DM gone gives the home. A channel that is gone or no longer viewable in a guild that is still there opens the guild on its default channel, through the existing `OpenGuild`. A guild in an outage is kept. - **Saving:** the place is not written until the restore has happened, so the start cannot overwrite it with the home. - The quick switcher's navigation write carries `last_location` along. **Verified.** - `crates/fluxer-core/tests/start_location.rs`, 18 tests: - saving the place (guild+channel, DM, home); - starting on a guild channel, on a DM, and on the home; - a fresh profile; - nothing written before the restore; - a guild left, a DM gone, a channel gone, a channel no longer viewable, an outage, a guild with no channel open; - restoring once per start, and again after a new login; - the cached-`READY` restore, the live-`READY` fallbacks after it, and a place missing from the cache. With the restore stubbed out, the 12 tests that depend on it fail. - `crates/fluxer-platform/tests/settings_chat.rs::last_location_round_trip`: the file round trip, and unreadable values. - `apps/fluxer/tests/dailyuse_acceptance.rs::starts_on_the_channel_it_was_closed_on`, against the devserver: quit on Big's `#chatter` (the second community; not its default channel), start again on the same settings, and `#chatter` is on screen with its messages and no click. It fails with the restore stubbed out. - `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci`: all steps passed. **Not covered.** The friends page opened over a DM is local view state in `fluxer-ui`. The stored place there is that DM, so the next start opens the DM, whereas the original would open `@me`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The per-guild last channels were restored, but nothing kept the place itself, so every
start showed the home. As the original's Location.lastLocation, the place on screen
(guild and channel, DM, or the home) is kept in [navigation] last_location, and once
logged in the start goes back to it at the first READY that has it (the cached one,
checked again by the live one), only while the home is still shown. Unreachable places
fall back as abandonUnreachableLastLocation: a guild left or a DM gone is the home; a
channel gone or not viewable opens the guild on its default channel; an outage keeps the
guild. Nothing is written before the restore, so the start cannot overwrite the place.

Closes #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-15 19:46:10 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.