Text chat 16: core navigation, read markers and media playback (#266) #316
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "textchat-16-core-navigation-read"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Text chat spec §6.2 "Navigation and read" (#60) and inline media, in
fluxer-core:ViewportAtBottom { channel_id, at_bottom }. After every event (once the selection and window focus have taken it in),ReadStates::follow_viewacks the selected channel when the window is focused, its list is at the bottom, its loaded history reaches the newest message, and it was not marked unread since it was opened. This is the original'sshouldAutoAck. Nothing is acked until the UI reports the bottom, so nothing changes until Text chat 33 emitsViewportAtBottom.app.chat.nav.markers[channel]to the read state's last read id. The marker stays while the channel is open.MarkUnreadmoves the marker and the local read state to the previous loaded message (previousReadableMessageId) and blocks auto-ack until another channel is opened (manualAck). TheAckManualrequest belongs to Text chat 15.selectors::timelineaddsTimelineItem::NewMessagesMarkerand ahighlightedfield on message rows.selectors::new_messages_bar(&App, channel) -> Option<NewMessagesBar { count, since }>andselectors::jump_to_present(&App, channel) -> boolare new.JumpToMessageemitsFetchMessages { around: Some(id), limit: 50 }, answered with the newApiResult::MessagesAround, which replaces the loaded run. The target is highlighted for 2000 ms (Effect::Schedule) once it is shown. Away from the present (ChannelMessages::away_from_present), live messages are not stored and nothing is acked.JumpToPresentreloads the newest page.PlayAttachmentfetches the audio file (FetchMedia,MediaPurpose::Clip { key: attachment_clip_key(id) }) and plays it withAudioCommand::PlayClip. One attachment plays at a time: starting another orStopAttachmentsets the current clip's gain to 0.selectors::media_playbackreturns aPlaybackModel.OpenMedia/CloseMediadrive the lightbox over the message's image and video attachments (chat::media::media_count). The lightbox closes when its message is deleted.Testing
crates/fluxer-core/tests/chat_navigation.rs:ack_only_when_bottom_visible_and_focused,no_ack_for_unselected_channel,marker_set_from_read_state_on_open,mark_unread_moves_marker,jump_loads_around_and_highlights_2000ms,jump_to_present_reloads_newest,history_capped_at_200_trim_to_100,new_messages_bar_count.crates/fluxer-core/tests/chat_media.rs:play_attachment_one_at_a_time,lightbox_index_navigation.FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciis green locally on Linux. All 32 screenshot goldens are unchanged. No desktop-only tests apply to this task.Deviations from the plan
PlayClip { source: PlaybackSource::Attachment(url), .. }, but the mergedPlayClipis{ clip: ClipRef, gain, tag }. So playback uses the soundboard's clip path:FetchMediafirst, thenPlayClipwith keyattachment:<id>. Clip tags start atchat::media::TAG_BASE(2^62) so they never collide with the soundboard's tags. Stopping a clip sets its gain to 0, which is the only stop the audio port has.PlaybackSource::Attachmentis not used by the core.effect.rs: thearoundfield onFetchMessages.event.rs:ApiResult::MessagesAround.app.rs: one call toread_state.follow_viewafterui.reduce.selectors/{messages.rs,mod.rs}: the timeline rows and re-exports.apps/fluxer/src/runtime.rs: passesaroundand returnsMessagesAround.fluxer-uiscreens/main/messages.rsandwidgets/message_list.rs: new match arms. The divider is filtered out of the drawn list until Text chat 33 draws it.tests/messages.rs:around: Nonein two patterns and adescribearm.tests/chat_ports.rs:stubs_emit_nothingskips the navigation actions, as Text chat 12 and 14 did for theirs.Closes #266
🤖 Generated with Claude Code
Independent review: Text chat 16 (core navigation, read markers, media playback)
Reviewed
git diff 9fcc13d..origin/textchat-16-core-navigation-read(headbba7b4e) cold.Checked and fine
chat_navigation.rs: 8,chat_media.rs: 2) and assert the spec's values:around+ limit 50, highlightEffect::Schedule2000 ms, cap 200 / trim to 100 on both sides, marker = read state's last read id on open, bar count/since, one clip at a time, lightbox index bounds.selectors::{new_messages_bar -> Option<NewMessagesBar { count, since }>, jump_to_present -> bool, media_playback -> Option<PlaybackModel { message_id, attachment_id, position_ms, playing }>},TimelineItem::NewMessagesMarker+highlightedon message rows,ApiRequest::FetchMessages { around },OpenMedia/CloseMedialightbox state all present.fluxer-core, no bytes/paths/URLs logged, no new fixtures (thearoundanswer reuses the messages list shape), server data paths do not panic (no indexing on server input; trim indices are bounded by the length check).fluxer-uichanges are match arms only.PlayClip { clip, gain, tag }deviation (FetchMedia underattachment:<id>, then PlayClip; tags from 2^62) is sound against the merged voice port and the existing runtimeFetchMediaarm (32 MiB cap).Findings
[blocking] Auto-ack ignores what covers the list (Review Focus #6).
Navigation::being_read(chat/navigation.rs) claims parity with the original'sshouldAutoAck, but drops itsblockingModalOpen: isModalOpen || MediaViewer.isOpenandtextChatVisibleterms (fluxer_app/src/features/read_state/utils/AutoAckPredicate.ts,ChannelMessages.tsx:207-214). The core already holds two of those states:app.ui.settings.is_some()(the settings screen replaces the main view,fluxer-ui/src/app.rs:143) andapp.chat.media.lightbox.is_some(). Scenario: user at the bottom of #general, window focused, opens Settings (or the lightbox); new messages arrive and are acked viafollow_viewalthough the user never sees them, i.e. "acks a channel the user is not looking at". Fix: requireui.settings.is_none()andchat.media.lightbox.is_none()inbeing_read(pass&MediaPlaybackor a bool), plus a test case for each.[minor]
on_aroundmarks the start reached on any short answer.channel.reached_start = items.len() < PAGE_SIZE(messages.rs,on_around). A shortaroundanswer usually means the newer side is short (target near the newest message), not the older side. Jumping (e.g. from search) to a message within ~25 of the newest in a channel not loaded yet gives ~30 items →reached_start = trueandaway_from_present = false, soScrolledToOldestnever loads older history and "Jump to present" does nothing: history above stays unreachable until a reconnect. The original counts the older side separately (MessagePaginationUtils.ts:36-53,hasMoreBefore = messagesOlder >= expectedOlder). Suggest:reached_start= (messages older thanaround) < 25 (limit/2), and a test for it.[minor] New-messages bar gated on the open-time marker.
new_messages_barreturnsNonewithout a marker, but the original shows the bar wheneverunreadCount > 0in stream phase (ChannelMessages.tsx:634). A channel opened while read, then scrolled up while messages arrive, shows no bar here. Task 33 can take this, or open a follow-up.[minor] Plan/Task 21 drift.
PlaybackSource::Attachment(String)(from Text chat 10) is now unused, and Task 21's Interfaces still say "PlaybackSource::Attachmentfetch + play". Please note in the plan (or a follow-up issue) that Task 21 has nothing to wire for attachment playback, so it does not add a dead runtime arm.[minor] Stop only silences.
stopsets the clip's gain to 0; the decoded file keeps playing silently to the end (up to 32 MiB of audio). Acceptable given noStopClipinAudioCommand, but worth a follow-up issue so a stop actually ends the source.Local CI: not completed in this review run (
FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciwas still compiling when the review had to be returned and was stopped); the implementer reports it green onbba7b4e, unverified here.Verdict: Changes requested: 1 blocking (auto-ack while settings or the lightbox covers the list), 4 minor.
Review round 1 addressed in
897fcb8(cargo xtask cigreen locally withFLUXER_SCREENSHOT_TESTS=1).Blocking: auto-ack under Settings / lightbox (
chat/navigation.rs):Navigation::being_readnow also requiresui.settings.is_none()andchat.media.lightbox.is_none();ReadStates::follow_viewtakes the media state. Module docs updated. Testno_ack_while_settings_or_lightbox_cover_the_list: a message arriving while Settings or the lightbox is open is not acked, and closing either acks it.Minor:
on_aroundreached_start (messages.rs): the start is now reached only when the older side is short, counted on its own (messages older than the target <limit - 1 - limit/2= 24), ascalculateAroundPaginationState. Testjump_near_newest_keeps_older_history(45-message answer near the newest keeps older loading; a short older side is the start).Minor: new-messages bar without a marker (
chat/navigation.rs):new_messages_barnow shows whenever the channel is unread (unreadCount > 0), counting loaded messages after the last read one (all when there is none). Extendednew_messages_bar_countwith a channel opened while read.Minor:
PlaybackSource::Attachmentunused: Task 21 Interfaces in the plan now say attachment playback isFetchMedia+PlayClipand to add no arm forPlaybackSource::Attachment; the variant doc says the same.Minor: Stop leaves the clip playing silently: cross-crate (
AudioCommand::StopClipin core, fluxer-audio and the app runtime), so deferred to follow-up #352.Merged origin/textchat (
cfcec2a) into the branch inaa3c218to clear the conflicts: kept both sides inmessages.rs(upload-awareRetrySend/CancelUpload/DeleteMessagefrom textchat plusJumpToMessage/JumpToPresent), both re-export lines inselectors/mod.rs, and the navigation actions as one more filter inchat_ports.rs::stubs_emit_nothing.tests/chat_threads.rs(Task 18) needed aTimelineItem::NewMessagesMarkerarm in its match.FLUXER_SCREENSHOT_TESTS=1 cargo xtask cigreen locally.Independent review, Task 16 (core navigation, read markers, media), round 2 (head
aa3c218, diff cfcec2a..aa3c218)Tests (plan Step 1): all 10 tests are present and assert the spec values. They are
ack_only_when_bottom_visible_and_focused,no_ack_for_unselected_channel,marker_set_from_read_state_on_open,mark_unread_moves_marker,jump_loads_around_and_highlights_2000ms(around, limit 50,Schedule2000 ms),jump_to_present_reloads_newest,history_capped_at_200_trim_to_100(both trim directions),new_messages_bar_count,play_attachment_one_at_a_timeandlightbox_index_navigation. Extra tests (no_ack_while_settings_or_lightbox_cover_the_list,jump_near_newest_keeps_older_history) are welcome.Interfaces: these match the block exactly:
TimelineItem::NewMessagesMarker, thehighlightedfield,new_messages_bar -> Option<NewMessagesBar { count, since }>,jump_to_present -> bool,FetchMessages { around },media_playback -> Option<PlaybackModel { message_id, attachment_id, position_ms, playing }>,OpenMedia/CloseMediawith index, and the 200/100 cap.Invariants: fluxer-core gains no dependency and no I/O. The clip key is
attachment:{id}, so no URL ends up in the key. Server data cannot cause a panic: the trims index within checked bounds, a foreignchannel_idin a page is skipped, and an unknown attachment, a non-audio attachment or an attachment without a URL is ignored. The test JSON uses example.com/media.example and has no secrets. No new fixture files.Review Focus 6 (#60): satisfied.
being_readrequires all of these: the channel is selected, the window is focused, neither settings nor the lightbox is open, the channel was not marked unread by hand, the UI reported the bottom, and the loaded run reaches the present with no jump in flight. A channel the user is not looking at is never acked (tested). Acks are idempotent through the local mark.FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci: green in the review worktree ("all steps passed"). The branch also merges cleanly with the current origin/textchat (b87bcd9).Findings
PlayClip { source: PlaybackSource::Attachment(url) }. The mergedAudioCommand::PlayCliphas nosourcefield (clip, gain, tag), so the attachment is played as the soundboard plays its clips (FetchMediaunderattachment_clip_key, thenPlayClip). The deviation is documented in the plan's Task 21 Produces line and in thePlaybackSource::Attachmentdoc. Task 21 must follow the amended line. The stopgapPlaybackSource::Attachmentarm inapps/fluxer/src/audio_rt.rs(from textchat) is now dead and can go with Task 21.away_from_present(after a jump or a top-side trim), the echo drops the pending record butconfirmdoes not store the message, so the user's own message disappears from the view until "Jump to present". The original jumps to the present on send. Suggest a follow-up, or have Task 25/33 dispatchJumpToPresenton send.mark_unreadchanges nothing locally. Task 15'sAckManualrequest still goes out, so local and server read state differ until the next READY or MESSAGE_ACK. This is an edge case and does not lose data.apps/fluxer/src/runtime.rs,fluxer-ui(messages.rs,message_list.rs) andtests/chat_threads.rs, all outside the Files list. Each change is the mechanical consequence of the newaroundfield and the newTimelineItemvariant, with no new behaviour beyond routingaroundtoMessagesAround. Acceptable.Verdict: approve. No blocking findings and local CI is green.