Text chat 11: core composer (#261) #309
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "textchat-11-core-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
Text chat 11, the rich composer in
fluxer-core(spec §6.2 Content conversion, Send, Edit, Typing, Autocomplete; spec §3.2):chat::content::to_wire(&Draft, &App) -> WireContent { content, allowed_mentions, length_utf16 }: mention spans become<@id>,<@&id>,<#id>,@everyone/@here,<:n:id>/<a:n:id>; typed:name:and:name::skin-tone-N:convert to Unicode or a usable custom emoji of the channel's guild; emoticons convert when the setting is on and they stand alone; code spans, fences, links and existing markup stay untouched; length in UTF-16 units;allowed_mentionsis{replied_user}with a reply only.chat::autocomplete::query(text, cursor) -> Option<Trigger>with the patterns and priority ofSlashCommandUtils.ts; results in sections of at most 10 (recent authors first, roles by position,@everyone/@hereonly with MENTION_EVERYONE, viewable text channels, emoji frecency first, stickers, saved media, commands); Up/Down/Select/Dismiss.ToggleReplyMention, inline edit (StartEdit,EditLastMessageon Up in an empty composer,SaveEdit->PatchMessage, empty edit asks delete unless attachments are kept), the escape ladder (edit, sticker, attachments, reply), the@everyoneconfirm, over-limit/blank sends blocked,+:name:reacts to the last message.MessagesasSendRichMessage(pending +RetrySendresends the same request); the FoundationDraftChanged/SendDraftpath keeps working for text inui.drafts.typing::RollingTyping): first 1500 ms after the first keystroke, then every 8 s, at once after 16 s idle; never while editing or for commands. Slowmode countdown from the typing answer and from sends.LocalSettings::chat.drafts400 ms after the last edit viaEffect::Schedule.selectors::composer(&App, channel) -> ComposerModelwith the plan's fields.Tests
New
crates/fluxer-core/tests/{chat_composer.rs,chat_content.rs,chat_autocomplete.rs}with every test named in the plan (to_wire_casesis a table of more than 20 cases) plus a few extras. Tests were committed first and failed to compile before the implementation.FLUXER_SCREENSHOT_TESTS=1 cargo xtask cipasses locally on Linux after merging the currentorigin/textchat. No desktop tests apply to this task.Deviations from the plan
event.rsgainsApiResult::TypingCooldown { channel_id, message_send_cooldown_ms }(the server's 200 answer to typing under slowmode; Text chat 21 maps it) andUserAction::ComposerEscape(channel)for the escape ladder;chat/{mod.rs,state.rs}andapp.rsroute the composer actions and splitlimitsintolimits_of(...)so reducers can call it with borrowed parts;selectors/{mod.rs,composer.rs}hold the composer selector;tests/chat_ports.rsno longer expects the composer actions to be stubs; the crate README documents the composer.max_message_lengthis the instance/default value.Follow-ups: #347 (minor review findings 1-3 deferred).
Closes #261
🤖 Generated with Claude Code
Independent review: Text chat 11 (core composer)
I reviewed
git diff 53fbd6f..origin/textchat-11-core-composer(head7ca5a5c).Plan tests: all 18 named tests exist.
to_wire_caseshas 24 cases. The values match the spec: 1500/8000/16000 ms typing, the 400 ms draft save, 10 results per kind and the 50-member confirm threshold.Interfaces: these exist as the plan writes them:
content::to_wire(&Draft, &App) -> WireContent { content, allowed_mentions, length_utf16 }autocomplete::query(text, cursor) -> Option<Trigger>with all 8 variantsselectors::composer(&App, channel) -> ComposerModelwith every listed field, plusCounter { remaining, over }andSlowmode { remaining_s, active }LocalSettings::chat.drafts, written throughEffect::Schedule400 ms after the last editInvariants:
convert,protected_len,typed_emoji,needs_mention_confirmandreplace/adjust_spansstays on char boundaries, so server or user text cannot panic it.TypingCooldownuses the server'smessage_send_cooldown_ms(api/channel/services/ChannelService.ts:40,219).Review Focus 2:
convert()matchesEmoticonConversionUtils.ts: the leading boundary is\s, the trailing boundary is a space or the end of the text, and backtick runs close only on a run of the same length.useTextareaSubmit.ts:461does.allowed_mentionsis sent only with a reply, as{replied_user}. This matchesbuildMessageCreateRequest/shouldIncludeAllowedMentions, andAllowedMentionsskips empty lists when it serializes.SlashCommandUtils.ts:5-14./kick|ban|msgcommand arguments are not handled; the plan does not ask for them.Findings
chat/content.rsprotected_lenprotects only barehttp(s)://URLs. It does not protect Markdown links[text](url), which the original'sfindMarkdownLinkEnddoes. So[see :) here](https://x)with emoticons on converts the:), and the original leaves it. The module doc and the README also say "links" are untouched, which overstates it. Suggest a follow-up issue.chat/autocomplete.rsmentions()sorts recent authors first even when the query is not empty. Spec §3.2 says recent speakers come first "when the query is empty". This changes ranking only, not correctness.app.rsloads drafts back only on the not-logged-in to logged-in transition, and only ifPersisted::Loadedhas already arrived. If a login could finish before the settings file loads, the first draft save would overwrite the stored drafts with only the in-memory ones. Startup loads first today, so I don't think this can happen now. A guard such as loading drafts onLoadedwhile logged in would make it robust.message_referencefor replies is built withguild_id: None, while the original also sends the guild id. The server accepts this; noting it for parity only.limits_ofresolves guild features fromui.selected_channel, not from the draft's channel. Premium limits are still not modelled, as the PR says.CI
I ran
FLUXER_SCREENSHOT_TESTS=1 cargo xtask cilocally in a clean review worktree. Result: "all steps passed", exit 0.chat_composer,chat_contentandchat_autocompleteall ran and passed.Verdict: APPROVED. There are no blocking findings, and local CI is green. Findings 1 to 3 could become
follow-upissues.Independent review: Text chat 11 (core composer), second pass, head
1ea0a32, diffcfbc399..origin/textchat-11-core-composerChecks
to_wire_casesin chat_content.rs has 20+ rows covering user/role/channel spans,@everyone/@here, usable and unusable custom emoji,:name:with skin tone, emoticons on/off and inside words, code spans and fences, UTF-16 length). The values match the spec: 1500/8000/16000 ms typing, 400 ms draft save, at most 10 results, the reply-mention default (off for own messages and DMs).content::to_wire(&Draft, &App) -> WireContent { content, allowed_mentions, length_utf16 },autocomplete::query(text, cursor) -> Option<Trigger::{Mention, Channel, Emoji, Command, Gif, Sticker, Saved, React}>, andselectors::composer(&App, channel) -> ComposerModel { placeholder, text, reply, editing, counter{remaining, over}, slowmode{remaining_s, active}, can_send, can_attach, autocomplete{sections, selected}, everyone_confirm }all match the plan.LocalSettings::chat.draftsis written 400 ms after the last change throughEffect::Schedule. The deviations listed in the PR (ApiResult::TypingCooldown,UserAction::ComposerEscape,limits_of, the legacySendDraftrouting) are additive and break no interface.convert,protected_len,typed_emoji,detect,replaceandadjust_spansstays on char boundaries, and a cursor sent by the UI is clamped, so server data and UI input cannot panic. No secrets or paths appear anywhere.SlashCommandUtils.ts:5-14.allowed_mentionsis{replied_user}only when the message is a reply, as inMessageRequestUtils.ts(DEFAULT_ALLOWED_MENTIONS = {replied_user: true}).@everyone/@hereand roles reaching more than 50 members go through the confirm. Code spans, fences, existing markup and bare URLs are left untouched. Length counts UTF-16 code units.FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciin the review worktree: all steps passed (exit 0).Findings (no blocking findings; the earlier minor findings are tracked in #347)
take_due_drafts), without their mention spans. After a restart, a draft with a mention pill (@Ada L.) is sent as the literal text, not<@id>, unless the user picks the mention again.settings.chat.draftsis not keyed by account. After a logout and a login with another account on the same machine, the earlier account's drafts are loaded into the composer (they are shown only where the channel ids match, but the text stays in the file).needs_mention_confirmsearches the converted content withcontains("@everyone"), so@everyoneinside a code span still asks for confirmation.Verdict: APPROVED. No blocking findings, local CI is green.
🤖 Generated with Claude Code