Skip to content

feat: add true color (24-bit RGB) support to MicronColor via FT/BT commands#673

Open
torlando-tech wants to merge 2 commits into
mainfrom
claude/microncolor-true-color-support-MM1cm
Open

feat: add true color (24-bit RGB) support to MicronColor via FT/BT commands#673
torlando-tech wants to merge 2 commits into
mainfrom
claude/microncolor-true-color-support-MM1cm

Conversation

@torlando-tech

Copy link
Copy Markdown
Owner

Extend Micron markup to support full 24-bit true color alongside the
existing 3-char (12-bit) hex and grayscale formats. The new syntax uses
FTrrggbb for foreground and BTrrggbb for background, keeping full
backward compatibility with existing Fxxx/Bxxx shorthand.

https://claude.ai/code/session_015rjJisX2XNt331xgXdFbB9

…mmands

Extend Micron markup to support full 24-bit true color alongside the
existing 3-char (12-bit) hex and grayscale formats. The new syntax uses
`FTrrggbb` for foreground and `BTrrggbb` for background, keeping full
backward compatibility with existing `Fxxx`/`Bxxx` shorthand.

https://claude.ai/code/session_015rjJisX2XNt331xgXdFbB9
@sentry

sentry Bot commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@greptile-apps

greptile-apps Bot commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR extends Micron inline markup with 24-bit true color via FTrrggbb / BTrrggbb commands, keeping full backward compatibility with the existing 3-char shorthand and grayscale formats.

  • MicronColor gains parseTrueColor() and exposes TRUE_COLOR_LEN = 6 as internal so the parser can share the constant rather than duplicate it.
  • MicronParser extracts the color-parsing logic into parseForegroundOrBackground(), which checks for a T prefix, dispatches to true-color parsing, and returns null immediately on a malformed true-color marker — the T-leaks-into-output issue flagged in the previous review round is now correctly handled.
  • Test coverage is thorough: boundary values, multi-line style persistence, reset commands, mixed format use, and direct unit tests of parseTrueColor.

Confidence Score: 5/5

Safe to merge — the change is additive, backward-compatible, and the previously identified T-leak and constant-duplication concerns are both resolved.

The true-color dispatch is correct, the malformed-command fallback returns null cleanly instead of leaking T into the output, TRUE_COLOR_LEN is now a single internal constant shared between files, and the 13 new tests cover the important cases. No regressions to the existing 3-char or grayscale paths were introduced.

No files require special attention.

Important Files Changed

Filename Overview
micron/src/main/java/com/lxmf/messenger/micron/MicronColor.kt Adds parseTrueColor() for 6-char hex strings and promotes TRUE_COLOR_LEN to internal so MicronParser can reference a single source of truth.
micron/src/main/java/com/lxmf/messenger/micron/MicronParser.kt Refactors F/B color branches into parseForegroundOrBackground(), which dispatches to the true-color path on T and correctly gates the 3-char fallback so a T prefix never leaks into the output stream.
micron/src/test/java/com/lxmf/messenger/micron/MicronParserTest.kt Adds 13 targeted tests covering foreground/background true color, boundary values (black/white), multi-line persistence, reset commands, mixed 3-char/6-char use, and parseTrueColor edge cases directly.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["backtick command: F or B"] --> B["parseForegroundOrBackground()"]
    B --> C{next char == 'T'?}
    C -- yes --> D{colorStart + 6 <= line.length?}
    D -- yes --> E["extract 6 chars\nMicronColor.parseTrueColor()"]
    E --> F{color != null?}
    F -- yes --> G["FormatResult with\ntrue-color Hex(r,g,b)"]
    F -- no --> H["return null\n(malformed FTxxxxxx)"]
    D -- no --> H
    C -- no --> I{afterCmd + 3 <= line.length?}
    I -- yes --> J["extract 3 chars\nMicronColor.parse()"]
    J --> K{color != null?}
    K -- yes --> L["FormatResult with\n3-char Hex or Grayscale"]
    K -- no --> M["return null"]
    I -- no --> M
Loading

Reviews (2): Last reviewed commit: "chore(greptile): iteration 1 — applied 2..." | Re-trigger Greptile

Comment thread micron/src/main/java/com/lxmf/messenger/micron/MicronParser.kt
Comment thread micron/src/main/java/com/lxmf/messenger/micron/MicronParser.kt Outdated
- MicronParser.parseForegroundOrBackground: when 'T' is committed as a
  true-color marker but the 6-char hex parse fails (length too short or
  bad digit), return null directly instead of falling through to the
  3-char branch with a substring starting at 'T'. T is never a valid
  hex digit, so the fallback always failed; the early return makes the
  intent explicit and avoids a pointless second parse attempt.
- Deduplicate TRUE_COLOR_LEN: it was defined as a private const in
  both MicronColor.companion (line 44) and MicronParser (line 373).
  Promote MicronColor's to internal and drop MicronParser's copy so
  there is a single source of truth for the true-color hex length.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants