Task 10: Messages, typing, read state #10

Closed
opened 2026-11-11 08:01:23 +00:00 by charles · 0 comments
Owner

Files:

  • Create: crates/fluxer-core/src/{messages.rs,typing.rs,read_state.rs,selectors/messages.rs}
  • Test: crates/fluxer-core/tests/messages.rs

Interfaces:

  • Produces: Messages { by_channel: HashMap<Snowflake, ChannelMessages> }, ChannelMessages { items: BTreeMap<Snowflake, MessageRecord>, oldest_loaded: Option<Snowflake>, reached_start: bool, loading: Option<EffectId>, pending: Vec<PendingMessage { nonce, content, created_at }> }; MessageRecord { message: Message, state: Sent | Pending | Failed }.
  • Reducers: SelectChannel → if no items, Api FetchMessages{limit: 50, before: None}; ScrolledToOldest → fetch before: oldest_loaded unless reached_start or loading; ApiResult::Messages (<50 items ⇒ reached_start); MessageCreate (for unknown channel: ignore with tracing::debug; if nonce matches pending → replace), MessageUpdate (merge content/edited_timestamp/embeds), MessageDelete(Bulk); SendDraft → nonce = Snowflake-like u64 string, push Pending, Api SendMessage; EffectFailed for a send → mark Failed (retry via UserAction::RetrySend(nonce)); DraftChanged → Api Typing at most every 8 s per channel.
  • TypingState: HashMap<Snowflake(channel), HashMap<Snowflake(user), Instant>> expiring after 10 s via Schedule.
  • ReadStates: from ready.read_states, MessageAck; unread(app, channel) -> bool = channel.last_message_id > read_state.last_message_id; mention_count(app, channel); MarkRead(channel) → Api Ack{last message} + local update; MessageCreate in a non-selected channel increments nothing locally (server-driven mention_count), but sets unread via last_message_id.
  • Selector: fn timeline(app, channel) -> Vec<TimelineItem { DaySeparator(Date) | Message { record, grouped_with_previous: bool } }> — grouped when same author, within 7 minutes, previous not a system message, no reply.

Plan: https://git.forked.io/charles/fluxer-native/src/branch/foundation/docs/superpowers/plans/2026-11-11-foundation.md (section "Task 10")

**Files:** - Create: `crates/fluxer-core/src/{messages.rs,typing.rs,read_state.rs,selectors/messages.rs}` - Test: `crates/fluxer-core/tests/messages.rs` **Interfaces:** - Produces: `Messages { by_channel: HashMap<Snowflake, ChannelMessages> }`, `ChannelMessages { items: BTreeMap<Snowflake, MessageRecord>, oldest_loaded: Option<Snowflake>, reached_start: bool, loading: Option<EffectId>, pending: Vec<PendingMessage { nonce, content, created_at }> }`; `MessageRecord { message: Message, state: Sent | Pending | Failed }`. - Reducers: `SelectChannel` → if no items, `Api FetchMessages{limit: 50, before: None}`; `ScrolledToOldest` → fetch `before: oldest_loaded` unless `reached_start` or loading; `ApiResult::Messages` (<50 items ⇒ `reached_start`); `MessageCreate` (for unknown channel: ignore with `tracing::debug`; if `nonce` matches pending → replace), `MessageUpdate` (merge content/edited_timestamp/embeds), `MessageDelete(Bulk)`; `SendDraft` → `nonce = Snowflake-like u64 string`, push `Pending`, `Api SendMessage`; `EffectFailed` for a send → mark `Failed` (retry via `UserAction::RetrySend(nonce)`); `DraftChanged` → `Api Typing` at most every 8 s per channel. - `TypingState`: `HashMap<Snowflake(channel), HashMap<Snowflake(user), Instant>>` expiring after 10 s via `Schedule`. - `ReadStates`: from `ready.read_states`, `MessageAck`; `unread(app, channel) -> bool` = `channel.last_message_id > read_state.last_message_id`; `mention_count(app, channel)`; `MarkRead(channel)` → `Api Ack{last message}` + local update; `MessageCreate` in a non-selected channel increments nothing locally (server-driven `mention_count`), but sets unread via `last_message_id`. - Selector: `fn timeline(app, channel) -> Vec<TimelineItem { DaySeparator(Date) | Message { record, grouped_with_previous: bool } }>` — grouped when same author, within 7 minutes, previous not a system message, no reply. --- Plan: https://git.forked.io/charles/fluxer-native/src/branch/foundation/docs/superpowers/plans/2026-11-11-foundation.md (section "Task 10")
charles added this to the Foundation milestone 2026-11-11 08:01:23 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/fluxer-native#10
No description provided.