Task 8: fluxer-core store skeleton and session domain #8

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

Files:

  • Create: crates/fluxer-core/src/{lib.rs,app.rs,event.rs,effect.rs,ids.rs,session.rs,error.rs}
  • Test: crates/fluxer-core/tests/session.rs

Interfaces:

  • Produces: pub struct App { pub session: Session, pub guilds: Guilds, pub channels: Channels, pub messages: Messages, pub presence: PresenceState, pub read_state: ReadStates, pub ui: UiState, next_effect_id: u64 } (domains stubbed as empty structs until their tasks); fn App::new(config: CoreConfig) -> App; fn apply(&mut self, event: CoreEvent) -> Vec<Effect>.
  • enum CoreEvent { Gateway(GatewayEvent), GatewayState(GatewayState), Api(ApiResult), User(UserAction), Timer(TimerId), EffectFailed { id: EffectId, error: CoreError }, Persisted(PersistResult) }.
  • enum Effect { Api { id: EffectId, req: ApiRequest }, ConnectGateway { url: Url, token: SecretString }, DisconnectGateway, SendGateway(Envelope), Persist(PersistOp), Notify(Notification), Schedule { id: TimerId, after: Duration }, OpenUrl(Url) }.
  • enum AuthError { InvalidCredentials, CaptchaRequired, IpAuthorizationRequired, Network(String), SessionExpired, Other(String) } (mapped from ApiError in the session reducer; the UI renders the strings in Task 17).
  • enum ApiRequest { Discover, Login { login, password }, LoginTotp { ticket, code }, Logout, Me, FetchMessages { channel_id, before: Option<Snowflake>, limit: u8 }, SendMessage { channel_id, content, nonce }, EditMessage {..}, DeleteMessage {..}, Typing { channel_id }, Ack { channel_id, message_id } }; enum ApiResult { Discover(WellKnown), Login(LoginResponse), LoginTotp(AuthToken), LoggedOut, Me(UserPrivate), Messages { channel_id, before, items: Vec<Message> }, Sent { nonce, message: Message }, Edited(Message), Deleted { channel_id, message_id }, TypingOk, AckOk }.
  • enum UserAction { SetInstance(Url), SubmitLogin { login, password }, SubmitTotp { code }, Logout, SelectGuild(Option<Snowflake>), SelectChannel(Snowflake), ScrolledToOldest(Snowflake), DraftChanged { channel_id, text }, SendDraft(Snowflake), RetrySend { nonce: String }, MarkRead(Snowflake), ToggleMemberList, SidebarResized(u16), WindowFocus(bool), OpenSettings(Option<SettingsTab>), CloseSettings, OpenUrl(Url), RegenerateStatusToken, SetStatusApiEnabled(bool), SetNotificationsEnabled(bool) }.
  • Session states: enum Auth { LoggedOut { error: Option<AuthError> }, Discovering, LoggingIn, AwaitingTotp { ticket }, LoggedIn { token, user: UserPrivate, endpoints: Endpoints } }. Flow: SubmitLogin → Api Discover (if endpoints unknown) then Api Login → Ok ⇒ Persist(SaveToken) + ConnectGateway ; Mfa ⇒ AwaitingTotp; ApiError::Unauthorized on any call while logged in ⇒ LoggedOut{error: SessionExpired} + DisconnectGateway + Persist(ClearToken); GatewayState::AuthFailed likewise.

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

**Files:** - Create: `crates/fluxer-core/src/{lib.rs,app.rs,event.rs,effect.rs,ids.rs,session.rs,error.rs}` - Test: `crates/fluxer-core/tests/session.rs` **Interfaces:** - Produces: `pub struct App { pub session: Session, pub guilds: Guilds, pub channels: Channels, pub messages: Messages, pub presence: PresenceState, pub read_state: ReadStates, pub ui: UiState, next_effect_id: u64 }` (domains stubbed as empty structs until their tasks); `fn App::new(config: CoreConfig) -> App`; `fn apply(&mut self, event: CoreEvent) -> Vec<Effect>`. - `enum CoreEvent { Gateway(GatewayEvent), GatewayState(GatewayState), Api(ApiResult), User(UserAction), Timer(TimerId), EffectFailed { id: EffectId, error: CoreError }, Persisted(PersistResult) }`. - `enum Effect { Api { id: EffectId, req: ApiRequest }, ConnectGateway { url: Url, token: SecretString }, DisconnectGateway, SendGateway(Envelope), Persist(PersistOp), Notify(Notification), Schedule { id: TimerId, after: Duration }, OpenUrl(Url) }`. - `enum AuthError { InvalidCredentials, CaptchaRequired, IpAuthorizationRequired, Network(String), SessionExpired, Other(String) }` (mapped from `ApiError` in the session reducer; the UI renders the strings in Task 17). - `enum ApiRequest { Discover, Login { login, password }, LoginTotp { ticket, code }, Logout, Me, FetchMessages { channel_id, before: Option<Snowflake>, limit: u8 }, SendMessage { channel_id, content, nonce }, EditMessage {..}, DeleteMessage {..}, Typing { channel_id }, Ack { channel_id, message_id } }`; `enum ApiResult { Discover(WellKnown), Login(LoginResponse), LoginTotp(AuthToken), LoggedOut, Me(UserPrivate), Messages { channel_id, before, items: Vec<Message> }, Sent { nonce, message: Message }, Edited(Message), Deleted { channel_id, message_id }, TypingOk, AckOk }`. - `enum UserAction { SetInstance(Url), SubmitLogin { login, password }, SubmitTotp { code }, Logout, SelectGuild(Option<Snowflake>), SelectChannel(Snowflake), ScrolledToOldest(Snowflake), DraftChanged { channel_id, text }, SendDraft(Snowflake), RetrySend { nonce: String }, MarkRead(Snowflake), ToggleMemberList, SidebarResized(u16), WindowFocus(bool), OpenSettings(Option<SettingsTab>), CloseSettings, OpenUrl(Url), RegenerateStatusToken, SetStatusApiEnabled(bool), SetNotificationsEnabled(bool) }`. - `Session` states: `enum Auth { LoggedOut { error: Option<AuthError> }, Discovering, LoggingIn, AwaitingTotp { ticket }, LoggedIn { token, user: UserPrivate, endpoints: Endpoints } }`. Flow: `SubmitLogin` → `Api Discover` (if endpoints unknown) then `Api Login` → `Ok` ⇒ `Persist(SaveToken)` + `ConnectGateway` ; `Mfa` ⇒ `AwaitingTotp`; `ApiError::Unauthorized` on any call while logged in ⇒ `LoggedOut{error: SessionExpired}` + `DisconnectGateway` + `Persist(ClearToken)`; `GatewayState::AuthFailed` likewise. --- Plan: https://git.forked.io/charles/fluxer-native/src/branch/foundation/docs/superpowers/plans/2026-11-11-foundation.md (section "Task 8")
charles added this to the Foundation milestone 2026-11-11 08:01:22 +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#8
No description provided.