Daily use 7: [chat] and [navigation] persistence: drafts, chat settings, recent searches, search UTC offset, selected channels, recent visits (#491) #538

Closed
charles wants to merge 0 commits from dailyuse-7-chat-navigation-persistence into dailyuse
Owner

What was built

  • [chat] table in settings.toml (#371): hide_crosspost_nudge, trusted_domains (still read and written locally; Daily use 22c migrates them), [chat.drafts] (channel id → text), [chat.settings] value by value through the new ChatSettings::stored() / from_stored(..) (like VoiceSettings), [chat.recent_searches] ("guild:<id>" / "channel:<id>" → [{query, ts}]).
  • Recent searches per scope (spec §3.1, §17 Q3 recommended): LocalChatSettings.recent_searches and app.chat.search.recent are BTreeMap<RecentSearchScope, Vec<RecentSearch { query, ts }>>; guild id for guild channels, channel id for DMs/groups (getChannelSearchContextId), 10 kept, 5 shown, a repeated query moves to the front. Loaded at startup, saved on submit, kept across a logout.
  • Search UTC offset (#315): LocalSettings::utc_offset_minutes (runtime-only, never saved) is computed by fluxer-platform at load; LocalSettings::utc_offset() becomes app.chat.search.utc_offset.
  • [navigation] table: NavigationStored { selected_channels, recent_visits }, ChannelVisit { channel_id, guild_id, ts }, MAX_RECENTLY_VISITED_CHANNELS = 20, NavigationStored::normalized() (newest first, one per channel, 20 kept), LocalSettings::navigation, PersistOp::Navigation(NavigationStored) (platform rewrites only that table: settings::save_navigation). LocalSettings::set_navigation(nav) -> Option<PersistOp> is the hook Tasks 19/20 call; nothing writes navigation yet.
  • Bad entries in either table are dropped and the rest kept; a chat/navigation key that is not a table loads defaults (no .bad file).

How it was tested

  • crates/fluxer-core/tests/chat_persist.rs and crates/fluxer-platform/tests/settings_chat.rs: every test named in the plan (chat_settings_stored_round_trip_every_field, one_bad_value_keeps_the_rest, drafts_round_trip_with_unicode_and_newlines, recent_searches_per_scope_10_kept_5_shown_dedup_front, navigation_round_trip_and_20_visits_kept, bad_navigation_entry_dropped_rest_kept, old_file_without_chat_or_navigation_loads_defaults, new_file_loads_in_previous_settings_file_shape with a copy of the previous SettingsFile, search_dates_use_local_offset), written first and seen failing.
  • FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green locally. No display tests involved (none run with FLUXER_DESKTOP_TESTS=1).

Deviations from the plan

  • RecentSearchScope instead of SearchScope: chat::SearchScope already exists (the proto search-scope menu enum re-exported by chat::port), so the new enum is chat::search::RecentSearchScope::{Guild, Channel}.
  • New direct dependency chrono (0.4, clock only) in fluxer-platform: the plan names none, but the local offset needs a time zone reader. chrono 0.4.45 is already in Cargo.lock via the LiveKit SDK (lockfile only gains an edge); time's local-offset refuses in a multi-threaded process on Linux. Reviewer: please confirm this is acceptable.
  • Small touches outside the Files list: fluxer-core/src/{app.rs,chat/state.rs,lib.rs} (load the searches and the offset, keep both across logout, re-exports), fluxer-platform/src/lib.rs (the PersistOp::Navigation arm), apps/fluxer/src/runtime.rs (the op's log name), existing tests in chat_search.rs/chat_settings.rs adjusted to the new map type, docs/parity/textchat.md notes for #371/#315.
  • The ephemeral (devserver) persistence keeps UTC as its offset.

Closes #491
Closes #371
Closes #315

🤖 Generated with Claude Code

## What was built - **`[chat]` table** in `settings.toml` (#371): `hide_crosspost_nudge`, `trusted_domains` (still read and written locally; Daily use 22c migrates them), `[chat.drafts]` (channel id → text), `[chat.settings]` value by value through the new `ChatSettings::stored()` / `from_stored(..)` (like `VoiceSettings`), `[chat.recent_searches]` (`"guild:<id>"` / `"channel:<id>"` → `[{query, ts}]`). - **Recent searches per scope** (spec §3.1, §17 Q3 recommended): `LocalChatSettings.recent_searches` and `app.chat.search.recent` are `BTreeMap<RecentSearchScope, Vec<RecentSearch { query, ts }>>`; guild id for guild channels, channel id for DMs/groups (`getChannelSearchContextId`), 10 kept, 5 shown, a repeated query moves to the front. Loaded at startup, saved on submit, kept across a logout. - **Search UTC offset** (#315): `LocalSettings::utc_offset_minutes` (runtime-only, never saved) is computed by `fluxer-platform` at load; `LocalSettings::utc_offset()` becomes `app.chat.search.utc_offset`. - **`[navigation]` table**: `NavigationStored { selected_channels, recent_visits }`, `ChannelVisit { channel_id, guild_id, ts }`, `MAX_RECENTLY_VISITED_CHANNELS = 20`, `NavigationStored::normalized()` (newest first, one per channel, 20 kept), `LocalSettings::navigation`, `PersistOp::Navigation(NavigationStored)` (platform rewrites only that table: `settings::save_navigation`). `LocalSettings::set_navigation(nav) -> Option<PersistOp>` is the hook Tasks 19/20 call; nothing writes navigation yet. - Bad entries in either table are dropped and the rest kept; a `chat`/`navigation` key that is not a table loads defaults (no `.bad` file). ## How it was tested - `crates/fluxer-core/tests/chat_persist.rs` and `crates/fluxer-platform/tests/settings_chat.rs`: every test named in the plan (`chat_settings_stored_round_trip_every_field`, `one_bad_value_keeps_the_rest`, `drafts_round_trip_with_unicode_and_newlines`, `recent_searches_per_scope_10_kept_5_shown_dedup_front`, `navigation_round_trip_and_20_visits_kept`, `bad_navigation_entry_dropped_rest_kept`, `old_file_without_chat_or_navigation_loads_defaults`, `new_file_loads_in_previous_settings_file_shape` with a copy of the previous `SettingsFile`, `search_dates_use_local_offset`), written first and seen failing. - `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green locally. No display tests involved (none run with `FLUXER_DESKTOP_TESTS=1`). ## Deviations from the plan - **`RecentSearchScope` instead of `SearchScope`**: `chat::SearchScope` already exists (the proto search-scope menu enum re-exported by `chat::port`), so the new enum is `chat::search::RecentSearchScope::{Guild, Channel}`. - **New direct dependency `chrono` (0.4, `clock` only) in `fluxer-platform`**: the plan names none, but the local offset needs a time zone reader. `chrono` 0.4.45 is already in `Cargo.lock` via the LiveKit SDK (lockfile only gains an edge); `time`'s `local-offset` refuses in a multi-threaded process on Linux. Reviewer: please confirm this is acceptable. - Small touches outside the Files list: `fluxer-core/src/{app.rs,chat/state.rs,lib.rs}` (load the searches and the offset, keep both across logout, re-exports), `fluxer-platform/src/lib.rs` (the `PersistOp::Navigation` arm), `apps/fluxer/src/runtime.rs` (the op's log name), existing tests in `chat_search.rs`/`chat_settings.rs` adjusted to the new map type, `docs/parity/textchat.md` notes for #371/#315. - The ephemeral (devserver) persistence keeps UTC as its offset. Closes #491 Closes #371 Closes #315 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Refs #491

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
settings.toml gains a [chat] table (drafts, hide_crosspost_nudge, trusted_domains,
[chat.settings] value by value through ChatSettings::stored/from_stored, recent searches
per guild or DM as the original's SearchHistory) and a [navigation] table (the original's
persisted SelectedChannel: selected channels and up to 20 recent visits). The system's
UTC offset is computed at load (chrono::Local, already in the tree) and search dates are
read in it.

Refs #491

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

Independent review: Daily use 7 (diff f2de7cd..9de440d)

Local gate: FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci in a clean review worktree: all steps passed.

Plan tests: all nine named tests exist and assert what the plan asks, with the spec's values: 10 kept, 5 shown, a repeat moves to the front, guild scope for guild channels and channel scope for DMs, 20 visits newest first, bad entries dropped, old file loads defaults, the new file parses with a faithful copy of the f2de7cd SettingsFile, and the offset is computed at load and never saved. There are extra core tests for normalisation on load, logout keeping state, and set_navigation being carried by the next SaveSettings.

Interfaces: ChatSettings::stored() / from_stored(..), RecentSearch { query, ts }, LocalChatSettings.recent_searches: BTreeMap<_, Vec<RecentSearch>>, NavigationStored { selected_channels, recent_visits }, ChannelVisit, MAX_RECENTLY_VISITED_CHANNELS = 20, PersistOp::Navigation(NavigationStored), LocalSettings::utc_offset_minutes, LocalSettings::navigation and set_navigation all exist. selected_channels uses the same Option<Snowflake> key as ui.rs's last_channel_per_guild, as Tasks 19 and 20 need.

Invariants: fluxer-core gains only time::UtcOffset and BTreeMap, with no I/O. Both tables are read as plain toml::Value and entry by entry, so a bad value never sets the file aside (tests check that no .bad file appears). Nothing can panic: every conversion is try_from/ok(). There are no secrets or paths in logs, and the token strings in the tests are fake.

Parity spot-checks (fluxer-soundboard): SearchHistory.ts:8-9,41-58 (limits 10 and 5, trim, splice then unshift) matches. ChannelSearch.ts:169-179 getChannelSearchContextId (guild id, else channel id) matches. SelectedChannel.ts:19-30,170-190 (ChannelVisit {channelId, guildId, timestamp}, max 20, dedupe on the (channel, guild) pair, sort newest first, @me) matches.

Review Focus 6: covered by old_file_without_chat_or_navigation_loads_defaults and new_file_loads_in_previous_settings_file_shape.

Findings

  1. minor: the plan names SearchScope::{Guild, Channel}, but the code has chat::search::RecentSearchScope::{Guild, Channel}. The rename is justified, because chat::SearchScope is already the proto scope-menu enum. No other task in the plan names this type, so nothing downstream breaks.
  2. minor: a new direct dependency, chrono 0.4 with default-features = false, features = ["clock"], which Task 7 does not name (CLAUDE.md asks that a new dependency come from a task that names it). The impact is nil. chrono 0.4.45 with iana-time-zone was already in the lock graph through LiveKit, the lock only gains one edge, and cargo deny is green. time's local-offset really does refuse in a multi-threaded process on Unix. I find it acceptable, but Charles should confirm it as a plan amendment.
  3. minor: settings::save_navigation does load, then edit, then save. When the file is missing, that load creates a new installation id and status token, and the next SaveSettings from the core then overwrites them. The same happens when the file has been set aside, which is existing startup behaviour. This only matters on a file deleted mid-session. No action needed now. Worth remembering when Tasks 19 and 20 start emitting the op.
  4. minor: NavigationStored::normalized() always sorts and dedupes, while the original only sorts and splices once there are more than 20 visits. Observable order is the same, because sortedRecentVisits sorts anyway. Not a divergence the spec cares about.

Verdict: APPROVED. No blocking findings, and local CI is green.

## Independent review: Daily use 7 (diff f2de7cd..9de440d) **Local gate:** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` in a clean review worktree: **all steps passed**. **Plan tests:** all nine named tests exist and assert what the plan asks, with the spec's values: 10 kept, 5 shown, a repeat moves to the front, guild scope for guild channels and channel scope for DMs, 20 visits newest first, bad entries dropped, old file loads defaults, the new file parses with a faithful copy of the f2de7cd `SettingsFile`, and the offset is computed at load and never saved. There are extra core tests for normalisation on load, logout keeping state, and `set_navigation` being carried by the next `SaveSettings`. **Interfaces:** `ChatSettings::stored()` / `from_stored(..)`, `RecentSearch { query, ts }`, `LocalChatSettings.recent_searches: BTreeMap<_, Vec<RecentSearch>>`, `NavigationStored { selected_channels, recent_visits }`, `ChannelVisit`, `MAX_RECENTLY_VISITED_CHANNELS = 20`, `PersistOp::Navigation(NavigationStored)`, `LocalSettings::utc_offset_minutes`, `LocalSettings::navigation` and `set_navigation` all exist. `selected_channels` uses the same `Option<Snowflake>` key as `ui.rs`'s `last_channel_per_guild`, as Tasks 19 and 20 need. **Invariants:** fluxer-core gains only `time::UtcOffset` and `BTreeMap`, with no I/O. Both tables are read as plain `toml::Value` and entry by entry, so a bad value never sets the file aside (tests check that no `.bad` file appears). Nothing can panic: every conversion is `try_from`/`ok()`. There are no secrets or paths in logs, and the token strings in the tests are fake. **Parity spot-checks (fluxer-soundboard):** `SearchHistory.ts:8-9,41-58` (limits 10 and 5, trim, splice then unshift) matches. `ChannelSearch.ts:169-179` `getChannelSearchContextId` (guild id, else channel id) matches. `SelectedChannel.ts:19-30,170-190` (`ChannelVisit {channelId, guildId, timestamp}`, max 20, dedupe on the (channel, guild) pair, sort newest first, `@me`) matches. **Review Focus 6:** covered by `old_file_without_chat_or_navigation_loads_defaults` and `new_file_loads_in_previous_settings_file_shape`. ### Findings 1. **minor**: the plan names `SearchScope::{Guild, Channel}`, but the code has `chat::search::RecentSearchScope::{Guild, Channel}`. The rename is justified, because `chat::SearchScope` is already the proto scope-menu enum. No other task in the plan names this type, so nothing downstream breaks. 2. **minor**: a new direct dependency, `chrono` 0.4 with `default-features = false, features = ["clock"]`, which Task 7 does not name (CLAUDE.md asks that a new dependency come from a task that names it). The impact is nil. `chrono` 0.4.45 with `iana-time-zone` was already in the lock graph through LiveKit, the lock only gains one edge, and `cargo deny` is green. `time`'s `local-offset` really does refuse in a multi-threaded process on Unix. I find it acceptable, but Charles should confirm it as a plan amendment. 3. **minor**: `settings::save_navigation` does load, then edit, then save. When the file is missing, that `load` creates a new installation id and status token, and the next `SaveSettings` from the core then overwrites them. The same happens when the file has been set aside, which is existing startup behaviour. This only matters on a file deleted mid-session. No action needed now. Worth remembering when Tasks 19 and 20 start emitting the op. 4. **minor**: `NavigationStored::normalized()` always sorts and dedupes, while the original only sorts and splices once there are more than 20 visits. Observable order is the same, because `sortedRecentVisits` sorts anyway. Not a divergence the spec cares about. **Verdict: APPROVED.** No blocking findings, and local CI is green.
Author
Owner

Merged into dailyuse at 863726f (combined merge of the first twelve Daily use tasks).

Merged into `dailyuse` at 863726f (combined merge of the first twelve Daily use tasks).
charles closed this pull request 2026-11-14 13:04:01 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.