Skip to content

feat(highlight): color diff, Kotlin, Dart and SQL code blocks - #16

Draft
shivamhwp wants to merge 2 commits into
pingdotgg:fork/t3-mobilefrom
shivamhwp:fix/code-highlight-diff-kotlin-dart-sql
Draft

shivamhwp wants to merge 2 commits into
pingdotgg:fork/t3-mobilefrom
shivamhwp:fix/code-highlight-diff-kotlin-dart-sql

Conversation

@shivamhwp

@shivamhwp shivamhwp commented Nov 10, 2026 •

Copy link
Copy Markdown

Carries software-mansion#1153 on the T3 mobile archive branch. The upstream branch contains only the highlighting changes; this branch preserves the existing T3 fork changes.

Fenced diff blocks currently have no highlighting, and Kotlin, Dart and SQL have no compiled grammar option. Add bounded diff-line highlighting and opt-in pinned grammars for those languages, with inserted/deleted token colors across the native renderers. Existing code-block layout, selection, copy and wrapping remain in their native containers.

The shared C++ regression suite covers aliases, Unicode offsets, diff headers and hunks, size limits, and the new languages. The final focused run on the archive source passed 10 cases and 579 assertions; the new keyword/function assertions failed before their fix. Android verification is complete in the T3 Code consumer at d973d8f2fd845d23925e68589a5aaf8878796496, using archive source 23ce6af473d93ce8fc66fb760d447c36a11ba18e. A physical POCO F4 on Android 14 shows diff, Kotlin, Swift, Dart and SQL colors in both themes. Wrap and Copy work, ordinary Markdown selection still works, and a free Replay turn streams and finishes. Before/after captures, recordings and test output include the exact build provenance. The upstream and archive changes have matching stable patch IDs.

The consumer opts into Swift plus the three new grammars. Its ARM64 debug APK grew by 9.97 MiB. Release size and iOS runtime remain unverified. SQL strings can still receive the number color because existing query predicates are not evaluated. Android code-block long press retains Copy menus; it did not provide selection handles before this change. Streaming verification is a smoke pass, not continuous observation of an open fence.

Swift already has an opt-in grammar. This change leaves the default grammar set unchanged. Query predicates remain unsupported; Dart's predicate-dependent identifier heuristics are skipped so structural function/type captures retain their colors.

The docs and CI runs at 23ce6af473d93ce8fc66fb760d447c36a11ba18e require repository maintainer approval before jobs can start. Both runs contain zero jobs; this account has read-only repository permissions.

Refs pingdotgg/t3code#33638.

Implemented by Claude Opus 5.5 in Claude Code; investigated and reviewed by GPT-6.1 Sol in Codex.

Note

Add Kotlin, Dart, SQL grammar highlighting and grammar-free diff/patch coloring

  • Adds Kotlin, Dart, and SQL tree-sitter grammars as opt-in languages with pinned versions in grammar-versions.json; the React Native package vendors them and the example apps enable all three
  • Adds new Inserted and Deleted token types for diff lines with default colors (#3FB950 / #F85149), wired through the core enum, Android, iOS, and React Native style APIs
  • Implements line-based diff and patch highlighting in CodeBlockHighlighter.cpp without a tree-sitter grammar; it colors file headers, hunk ranges, added and removed lines, and no-newline markers, and skips context lines
  • Adds a highlight C++ test target with grammar vendoring, plus tests for aliases, new languages, diff tokenization, UTF-16 ranges, and size limits
  • Risk: token-type count changed from 14 to 16; the JNI pinned token-order array in HighlightJni.cpp and the Swift/C++ assertion in SwiftHighlightShim.cpp were updated to match — any out-of-tree consumer of the enum must add the two new values

Macroscope summarized 23ce6af.

shivamhwp and others added 2 commits November 10, 2026 02:13
Fenced diff, Kotlin, Dart and SQL blocks rendered as plain text: no grammar
covered them, and Swift only by opt-in.

Diffs are line-oriented, so the shared seam classifies them line by line
instead of with a grammar: added and removed lines get two new token types,
inserted and deleted, hunk ranges the function color and file headers the
constant color. Inside a hunk whose header gives line counts, "--- x" and
"+++ x" are changed lines, not headers. The existing size caps apply.

Kotlin (tree-sitter-kotlin 0.3.8), Dart (tree-sitter-dart 1.0.0) and SQL
(@derekstride/tree-sitter-sql 0.3.11) join the opt-in grammar tier, with
kt/kts and mysql/postgres/postgresql/pgsql/sqlite aliases and diff/patch
fences. Host doctest coverage for the seam lands in packages/core/cpp/tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 10, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant