Task 19: rich_text widget from the Markdown AST (#19) #41
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "task/19-ui-rich-text"
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?
Stacked on: task/16-ui-theme-fonts-icons
What this builds
fluxer_ui::widgets::rich_text:parse_message(content) -> Vec<Node>: the fork'sfluxer_markdown_parserwithParserFlags::ALLminus headings, lists, tables and alerts,EmojiContext::default(). A parser error returns the content as one literal text node.blocks(nodes, ctx) -> Vec<Block>andspans(nodes, ctx) -> Vec<SpanModel>: the span model (text, bold, italic, strike, underline, mono, color, background, link, spoiler, hidden). Paragraphs, code blocks and block quotes are blocks;spansis the flat view of them.rich_text(nodes, ctx) -> Element<Message, Theme>: iced rich text spans for paragraphs, a mono block with language label for code blocks, a 4 px bar for block quotes. Strong is weight 600, mentions are pills (role mentions take the role colour), spoilers are hidden until clicked, links usetext_link,<t:...>timestamps are formatted in the offset the caller passes, custom emoji show as:name:, any other node shows its plain text viarender_ast_to_plaintext.RenderCtx { resolve_user, resolve_channel, resolve_role, resolve_role_color, revealed_spoilers, utc_offset, now_unix }.How it was tested
crates/fluxer-ui/tests/rich_text.rs, 21 tests on the span model, written first and seen failing: the five the plan names (bold_italic_nest,inline_code_is_mono,mention_user_resolves_name,link_has_url,unsupported_node_falls_back_to_plaintext) plus spoilers, masked links, code blocks, block quotes, every timestamp style, role/everyone/here mentions, unparseable mention ids, and hostile input (must not panic, including building the widget).cargo xtask ciis green locally. The widget has not been looked at on screen: nothing onfoundationcan host it yet (no app shell), so there are no side-by-side screenshots; that falls to Task 20 / Task 24.Deviations from the plan
charles/fluxeris public, so the dependency ishttps://git.forked.io/charles/fluxer.gitat revba98441binstead of the SSH URL; noFORK_DEPLOY_KEYsecret and no CI change are needed. Not verified on the runners from here: they must be able to reachgit.forked.ioover HTTPS. Cost to know about: cargo clones the whole fork (about 1.2 GB, close to 3 minutes locally), on every Linux run since that container is not cached (#27). If that is too slow or the runner cannot reach the host, the plan's fallback (vendoring intothird_party/) applies.deny.tomlgets a per-crate exception. Linking it makes the client binary AGPL.Element<rich_text::Message, Theme>, notElement<UiMessage>.UiMessageis Task 17's and is not onfoundation; the caller mapsMessage::{LinkClicked(String), SpoilerToggled(usize)}.Effect::OpenUrlis not added.fluxer-coreis still empty onfoundation(Task 8 unmerged). Tracked in #40 together with theUiMessagemapping and the spoiler state.RenderCtx::revealed_spoilers, indexed per spoiler in document order), since the UI-local state struct is Task 17's.--bg-code/--text-code(notbackground_secondary_alt), mentions use--markup-mention-text/--markup-mention-fill(notbrand_primary), perMarkup.module.css.RenderCtxfields beyond the three the plan lists:resolve_role,revealed_spoilers,utc_offset,now_unix.spanstakes the ctx as second argument.Intlformatter gives for en-US); the client has no locale setting yet.crates/fluxer-ui/src/widgets/mod.rs(Task 17 creates it too; add/add conflict is one line),pub mod widgets;inlib.rs,deny.toml,Cargo.lock, the crate README.fluxer-uinow depends onfluxer-proto(Snowflake) and the workspace'stime.Closes #19
🤖 Generated with Claude Code
Independent review: Task 19 (
rich_text), head7227637Scope:
git diff 301b889..origin/task/19-ui-rich-text(10 files, +1268). Read cold; the implementer's notes were verified, not trusted.Verdict: APPROVED. 0 blocking, 5 minor. Local
cargo xtask ci: green (fmt, clippy-D warnings, deny, tests; 21/21 intests/rich_text.rs; screenshot step skipped locally becauseFLUXER_SCREENSHOT_TESTSis not 1). Remote runners were not checked by me.What I checked
bold_italic_nest,inline_code_is_mono,mention_user_resolves_name,link_has_url,unsupported_node_falls_back_to_plaintext(builds aTablenode by hand) all exist and assert what the plan says. Test-first commit order is there (6f059d0before7227637).parse_message(&str) -> Vec<Node>exact; flags areALL & !(HEADINGS|LISTS|TABLES|ALERTS),EmojiContext::default(). Inline code radius 3 px, quote bar 4 px, custom emoji:name:, unknown nodes viarender_ast_to_plaintext. Deviations are listed under minor 1.fluxer-ui(the UTC offset and "now" are passed in, nothing is read from the OS);fluxer-coreuntouched; no secrets in code or tests. Panic safety: besides the branch's ownhostile_input_never_panics, I ran a throwaway probe (not committed): 20 000 pseudo-random Markdown strings throughparse_message/spans/rich_text, plus 2 000-deep> > > …quotes. No panic. The parser flattens nested quotes to depth 1 and bounds inline depth at 10, so the unguarded recursion inwalk/tidy/view_blocksis bounded for parser output.charles/fluxeranswers anonymously (API 200,git ls-remotewith no credential helper returnsba98441b…), so the HTTPS pin needs no deploy key. Longest path in the fork at that rev is 124 characters, so the Windows checkout stays under MAX_PATH. The parser only produceshttp(s):,fluxer:,mailto:,tel:andsms:link URLs;javascript:andfile:stay literal text.Findings
widgets/rich_text/mod.rs):rich_textreturnsElement<'a, rich_text::Message, Theme>, notElement<'a, UiMessage>;RenderCtxhas four fields beyond the plan's three (resolve_role,revealed_spoilers,utc_offset,now_unix);spanstakes the ctx as a second argument. Unavoidable today (UiMessageandLocalare Task 17's, not onfoundation) and tracked in #40, but Task 20's implementer has to read the merged code, not the plan block.Effect::OpenUrlis not added (core is a 3-line stub on this base); also #40.Message::LinkClicked(String)carries the parser's URL as is, includingfluxer:,mailto:,tel:,sms:. Whoever implementsEffect::OpenUrlshould decide which schemes go to the system opener; worth adding to #40.git.forked.ioover HTTPS. If either bites, the plan's vendoring fallback applies. Integrator to confirm on both runners.deny.tomlgains anAGPL-3.0-or-laterexception forfluxer_markdown_parser; linking it makes the client binary AGPL. The workspace declares no licence of its own yet. Not a code defect, but it is a decision that should be acknowledged before merge.foundationcan host the widget, so pixels (pill padding, theLength::Fillquote bar inside aShrinkrow, transparent text for hidden spoilers) are untested until Task 20 / 24.paragraphalso readstokens::DARKdirectly rather than the active theme, which is fine while dark is the only theme.Process: commits carry
Refs #19and the co-author trailer; PR title and body follow the contract (Closes #19,Stacked on:), follow-up #40 is open and labelled.