feat: code block with built-in syntax highlighting - #12
Merged
Conversation
Own regex highlighter rather than a dependency on syntax_highlight: its super_clipboard chain would put a native plugin and an Android minSdk 23 floor into every consumer, and its asset-loaded grammars force an async setup call. One alternated regex per language, colored in a single synchronous pass; languages are host-extensible via FlowCodeLanguage.register. Syntax palette values and block metrics are picked to sit with the shipped themes pending the design file's code-block frame.
FlowCodeLanguage gains caseSensitive (default true), compiled into the table's regex — SQL keywords come in either case, and Dart regexes have no inline (?i).
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
There are 3 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 34b69ce. Configure here.
8 tasks
rahulbisht25
previously approved these changes
Aug 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Roadmap row 21. Adds
FlowCodeBlockand aFlowCodePartmessage part, with copy intent threaded throughFlowMessageandFlowThread(onCodeCopy,copiedCodePart,codeCopyTooltip).Highlighting is built in and synchronous: each language is an ordered regex rule table compiled into one alternation and colored in a single pass. No assets, no init call. Ships
dart,json,javascript/typescript,python,bash,yaml,html,css,sql,plain. Hosts add languages withFlowCodeLanguage.register;caseSensitive: falsecompiles a table like SQL's case-insensitively.Also in this PR:
FlowSyntaxColorstheme tokens (eight roles, light and dark presets) onFlowTheme.syntax.codeandcodeInlinetypography roles.withFontFamily()no longer touches the mono roles;withCodeFontFamily()swaps them.Notes for review:
syntax_highlightpackage: itssuper_clipboardchain adds a native Rust plugin, an Android minSdk 23 floor, and a build-time binary download to every consumer, and its asset grammars force an async init.dependencies:in pubspec.yaml is unchanged.flow_message.dartlines with feat: error state with retry #13. Whichever merges second resolves trivial conflicts.Screenshots
Code Blockstage: 8 variants)How this was verified
Playground
Code Blockstage on Chrome (web), both themes. All 8 variant pills render (Dart, JSON, YAML, HTML, CSS, SQL colored; Plain uncolored; Streaming grows without restart flicker). Copy click passed the full source throughnavigator.clipboard.writeTextand flashed the check state. Long lines scroll inside the block, not the page. Thread stage shows a code part in an assistant turn with the text reveal above it. Docs site builds clean.Checklist
flutter analyze libandflutter analyzeinexample/andplayground/are cleandart format .applieddependencies:inpubspec.yaml(Flutter SDK and flutter.dev packages only)lib/flow_ui.dartand documented indocs/and the README tableCHANGELOG.mdupdated for user-facing changes, with breaking changes called outfeat:,fix:,refactor:,docs:,chore:)Note
Medium Risk
New public message/theme API and a regex highlighter that runs in
buildon streamed source.withFontFamily()behavior change for mono roles can surprise hosts who already swapped the whole type scale.Overview
Ships fenced code as a first-class message part:
FlowCodeBlockplusFlowCodePart, rendered byFlowMessage/FlowThreadwith copy intent ononCodeCopy(host owns the clipboard). Unknown languages render plain; streaming trailing code re-highlights whole and hides copy.Highlighting is a synchronous regex engine (no extra deps): ordered rule tables compiled to one alternation. Built-ins cover Dart, JSON, JS/TS, Python, shell, YAML, HTML, CSS, SQL, and plain; hosts extend via
FlowCodeLanguage.register.Theme adds
FlowSyntaxColors(eight token roles, light/dark) and Geist Mono behind newcode/codeInlineroles.withFontFamily()no longer retargets the mono face — usewithCodeFontFamily().Reviewed by Cursor Bugbot for commit d25b7e8. Bugbot is set up for automated code reviews on this repo. Configure here.