Text chat 25: Rich composer and autocomplete (#275) #391
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "textchat-25-ui-composer"
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 this builds
The rich composer of spec §3.2 / §9.1, wired to the Text chat 11 and 14 core.
screens::main::composer(new):model(&App, channel, &ComposerOptions) -> ComposerView,State,update(.., now) -> Vec<UserAction>,view,popup,edit_box,with_plus_menu,wanted.status_rail: typing on the left, slowmode on the right ("Slowmode is active (mm:ss)" / "Slowmode is enabled", clock icon, the original's tooltips), 1.5 rem above the box (InputWrapper.module.css .statusRail,SlowmodeIndicator.*).reply_bar: "Replying to {name}" (click jumps), "@ ON/OFF" toggle with its tooltip (hidden for own messages and DMs), Cancel reply (ChannelReplyBar.*).buttons: plus button, GIFs / Media / Stickers / Emojis / Send (2 rem, 1.375 rem Phosphor icons, tooltips), shown per the input-button settings, none without SEND_MESSAGES (TextareaButtons.tsx,TextareaButton.module.css).plus_menu: "Upload file", "Upload your message as a file" (with text), "Customize" submenu toggling the five buttons (SetChatSetting); two presses of + within 500 ms open the file dialog (OpenFileDialog(Attach)).autocomplete: the popup over the composer: headings (Members/Roles/Mentions, Channels, Emojis, Stickers, Media, Commands), dividers, rows with 24 px avatars (#211), 1.5 rem emoji (Text chat 8emoji::view), 2 rem stickers, descriptions ("Default emoji", guild name, the@everyone/@here/role strings), selected row highlighted, max 30.625 rem; click selects.highlighter: an icedHighlighterfor the text box: bold/italic/code/heading/subtext/links/code fences across lines, the store's mention spans in--text-link.edit: the inline edit box drawn in the message row with "Escape to cancel • Enter to save" (links do what the keys do) (EditingMessageInput.*).--status-dangerunder 50, tooltip "{n} characters left" / "Message is too long");@everyone/@hereconfirm card (MentionEveryonePopout.*); placeholder "You can't send messages in this channel." without permission.ComposerOptions { placeholder, send_on_enter, slash_commands, typing, draft_key }with today's behaviour as default (interface note for Text chat 44/46).widgets::composeris now the text area only:binding(KeyPress, &KeyContext)(Enter / Shift+Enter, Enter is a newline inside a code fence and Ctrl+Enter sends, Ctrl+B/I/U/Shift+S wrap the selection, Up on empty →EditLastMessage, Escape, arrows/Enter/Tab in the popup),text_area(..), cursor ↔ byte offset helpers.@everyoneconfirm → popup (ComposerAutocomplete(Dismiss)) →ComposerEscape(channel)(core: edit → sticker → attachments → reply); in the edit box →CancelEdit.WindowEvent::Keygainedtext); opening an inline edit focuses its box, closing it returns to the composer; Escape at window level closes the plus menu.media::wantedasks for the popup's emoji, sticker and avatar images.How it was tested
crates/fluxer-ui/tests/composer.rs(no renderer, runs on every runner):placeholder_by_channel_kind,ctrl_b_wraps_selection,enter_in_fence_is_newline,up_on_empty_emits_edit_last,escape_ladder,popup_keyboard_navigation,counter_shown_over_80_percent,buttons_follow_settings,plus_double_press_opens_dialog,edit_box_save_and_cancel, plusprintable_key_while_unfocused_types_into_the_composer. Unit tests for the highlighter and the slowmode strings.textchatscenario's READY:composer_reply,composer_autocomplete_mentions,composer_autocomplete_emoji,composer_edit_inline,composer_counter, documented indocs/screenshots/README.md. No Electron reference capture was possible from this agent (no access to a logged-in Electron app); dimensions come from the fork files named above and in each test's doc comment.main-general,code_block_highlighted,incoming_call,profile_popout_*,sidebar_*,stream_hover_card,stream_pip,voice_panel_*): only the composer area changed (the box is now 3.625 rem with the plus button and the four buttons; the typing rail is above it).ComposerEdited,SendRichMessage).FLUXER_SCREENSHOT_TESTS=1 cargo xtask cigreen locally. No desktop-only (FLUXER_DESKTOP_TESTS) tests in this task.Deviations / for the reviewer
ComposerEdited+SendDraft→ApiRequest::SendRichMessage), no longerDraftChanged; Text chat 21's runtime (now ontextchat) executes it.widgets/message_row.rs(Message::Editor+view_editing, "(edited)" hidden while editing),screens/main/mod.rs(pub mod composer, plus menu drawn at screen level),app.rs+message.rs(printable key → composer, focus follows the inline edit, Escape closes the plus menu),tests/{message_list,message_view,screenshots}.rs,docs/screenshots/README.md,docs/parity/settings.toml(note on "Message input buttons").context_menuhas none); "Send voice message" (spec §1) and "Send gift" (not on this instance) are left out; "Upload file" is absent without ATTACH_FILES instead of shown disabled with a hint.ComposerEditedto the edit while one is open). The autocomplete popup of an inline edit is drawn above the main composer.@everyoneconfirm counts the guild'smember_countfor both@everyoneand@here(the original counts online members for@here).Merge with textchat (Text chat 21–24)
origin/textchat(6113a8e) is merged into this branch. Conflicts resolved:widgets/message_row.rs(the inline edit box now replaces only the text in Text chat 24's row; attachments, embeds, stickers, forward and reactions stay below it; "(edited)" hidden while editing),screens/main/messages.rs(edit box plus the new row events),screens/main/media.rs(composer popup images plus attachments/embeds/lightbox),theme/icons.rs, the READMEs andtests/screenshots.rs(both sides' scenarios kept). The 13 goldens Text chat 22–24 added (attachment*,embed_*,message_*,reactors_modal) were regenerated on lavapipe (fluxer-native-shots:u2204container): only the message list's position changed, because the composer box is taller.FLUXER_SCREENSHOT_TESTS=1 cargo xtask cigreen again after the merge.Review findings 1–3 (draft echo race after Send, typing into the main box during an inline edit,
updateignoringComposerOptions) are not addressed here: follow-up #400.Closes #275
🤖 Generated with Claude Code
Independent review: Text chat 25 (ui-composer)
Reviewed
git diff fec9421c..origin/textchat-25-ui-composer(ef9f693) cold.Plan tests: all 10 named tests exist in
crates/fluxer-ui/tests/composer.rsand assert the plan/spec behaviour: placeholders "Message #general" / "Message @Ada L." / "Message Weekend plans", the Ctrl+B/I/U/Ctrl+Shift+S wraps (Ctrl+S alone is not a wrap), Enter/Shift+Enter/fence/Ctrl+Enter, Up on an empty box →EditLastMessage, the Escape ladder (plus menu → popup → store ladder → inline edit), popup Down/Up/Enter/Tab, the counter (hidden at 1600/2000, "399 characters left" at 1601, danger under 50, "Message is too long" over the limit), the buttons following the settings plus the Customize toggle, the plus double press within 500 ms, and the edit box with "Escape to cancel • Enter to save". There is 1 extra test (printable key). All 5composer_*screenshot goldens exist and pass.Interfaces (spec §9.1): everything is present: highlighter (Markdown plus
--text-linkmentions), key bindings, popup (sections, 24 px avatars #211, emoji 24 / sticker 32, max height 490 px = 30.625 rem), reply bar with toggle and tooltips, inline edit, status rail with typing and slowmode "Slowmode is active (mm:ss)", counter, button row, plus menu with Customize,@everyoneconfirm, and a printable key focusing the composer.Invariants: fluxer-ui gains no I/O path and has no new dependencies. fluxer-core is untouched. There are no new fixtures and no paths or secrets. Highlighter and autocomplete indexing runs only on local text or store spans (clamped, and only when they match the shown text), so server data cannot panic the client.
Local CI:
FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci→ exit 0 (357 test binaries ok, composer goldens ran on Vulkan).Findings
screens/main/composer/mod.rs,Mirror::sync): afterexpect_change()(Send, popup pick,@everyoneconfirm), any snapshot that differs from the box replaces it, andsentis cleared first. Example: the runtime is still behind (store at "hel" while the box shows "hello"), the user presses Enter, a late "hel" snapshot overwrites the box, and if the user types "x" before the clearing snapshot arrives,ComposerEdited("helx")lands after the send, so the next draft starts with stale text. It needs Enter within one snapshot latency of the last keystroke, so this is a narrow race. Suggest keepingsentacrossexpect_changeand treating a text found insentas an echo even whileexpecting.app.rsprintable key /State::type_text, andupdateforTextArea(Edit)while editing): text typed into the main box during an inline edit is not told to the store (toldis reset so that the next change tells it). The key handler also focusesEDITOR_IDrather than the edit box while editing. If the user then switches channel or presses Enter without another keystroke, those characters are dropped (Mirror::newfrom the store, orSendDraftof the store's older draft).composer::update): it rebuilds the view withComposerOptions::default()and always useschannel's draft, sosend_on_enter/draft_key/slash_commandsare not honoured on the update path. Text chat 44/46 will needupdateto take the options (or theComposerView). The current interface does not break, but it is worth knowing before 46 starts.SendDraft→SendRichMessage, which the runtime answers with "text chat requests are not wired yet (Text chat 21)". Until 21 merges, the app ontextchatshows "Failed to send" for every message (the content stays in the failed pending row). The plan's ordering allows this; mention it in the merge notes.None of these is blocking: no interface is broken, no invariant is violated and CI is green.
Verdict: APPROVE (0 blocking, 5 minor).
Independent review of Text chat 25 (rich composer), diff
6113a8e..e9a6952, read cold.Note: this PR was already merged into
textchat(220acce) before this review ran. The findings below apply totextchatas it stands now.Checks
crates/fluxer-ui/tests/composer.rs, plusprintable_key_while_unfocused_types_into_the_composer. They assert the values in spec §3.2: placeholders "Message #general", "Message @Ada L." and "Message Weekend plans"; Ctrl+B/I/U/Shift+S wrap and Ctrl+S alone does nothing; Enter in a fence makes a newline and Ctrl+Enter sends; Up on an empty box givesEditLastMessage; the counter is hidden at 1600 of 2000, shows "399 characters left" at 1601, turns danger under 50, and says "Message is too long" over the limit; a second plus press within 500 ms opens the dialog; the edit hint is "Escape to cancel • Enter to save". All 5 screenshot tests (composer_reply,composer_autocomplete_mentions,composer_autocomplete_emoji,composer_edit_inline,composer_counter) exist and arecfg(not(windows)).ComposerOptions { placeholder, send_on_enter, slash_commands, typing, draft_key: DraftKey }exists with today's behaviour as the defaults. It is taken bycomposer::model, andviewdraws the resultingComposerView. Tasks 44 and 46 can use it this way (see minor 1).fluxer-core,fluxer-proto,fluxer-emoji, anyCargo.tomlorCargo.lock. It adds no I/O tofluxer-ui: the composer images go throughmedia::wantedand the existing ImageLoader. No new fixtures. No secrets, URLs or paths. Every slice in the highlighter,position_ofandkey_contextis clamped to a char boundary.SendDraftand leaves the conversion to core.)FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciin a fresh worktree ate9a6952: exit 0, all steps passed. The screenshot tests ran on the host GPU.Merge resolution (
message_row::view_with): checked. The editor replaces only the text insidewith_render_ctx. Attachments, embeds, stickers, the forward, reactions and the failed footer still draw below it, and "(edited)" is hidden while editing. When a message is being edited, the "[system message]" placeholder is skipped. A system row returns before the editor is drawn, which is harmless because core only starts an edit on own DEFAULT or REPLY messages.messages.rssendsMessage::Editortocomposer::Message::EditArea.Findings
composer::updatestill builds its view withComposerOptions::default()and thechanneldraft, sosend_on_enter,draft_keyandslash_commandsare ignored when updating. Tasks 44 and 46 have to fix this. Tracked in #400 (3).Mirror::syncclearssentwhenexpect_changeis called) is still there. Tracked in #400 (1).EDITOR_ID, not the edit box. Tracked in #400 (2).highlighter::Settings::from_spansslices&text[..span.start]without checkingis_char_boundary. Today it is safe becausehighlight()only passes spans when the store's text equals the box's text, and core keeps the spans on boundaries. A.filter(|s| text.is_char_boundary(s.start) && text.is_char_boundary(s.end))would make it safe even if a corrupted persisted draft ever arrives.Verdict: approve. 0 blocking, 4 minor (3 already tracked in #400). CI green locally.