Skip to content

Render term color - #15

Merged
Pajn merged 1 commit into
mainfrom
term-color
Jul 10, 2026
Merged

Render term color#15
Pajn merged 1 commit into
mainfrom
term-color

Conversation

@Pajn

@Pajn Pajn commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Terminal visible snapshots and scrollback now carry per-character styling (indexed/true-color, bold, underline, strikeout, reverse, hidden, and wide-character-aware rendering), improving ANSI/glyph output fidelity.
    • Search and selection overlays now highlight by re-styling existing grid cells.
  • Bug Fixes
    • Fullscreen/alternate-screen rendering detection was improved for more reliable state transitions.
  • Documentation
    • Updated render/capture contract docs to distinguish styled visible lines from plain-text full capture/helpers.
  • Tests
    • Expanded renderer/protocol/e2e coverage, including indexed color SGR emission and styled overlay behavior.

Stack

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 026ce90d-0ff5-404f-905f-3b8956bb09a5

📥 Commits

Reviewing files that changed from the base of the PR and between b4fe359 and bb06a79.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (24)
  • crates/embers-cli/tests/interactive.rs
  • crates/embers-client/src/grid.rs
  • crates/embers-client/src/lib.rs
  • crates/embers-client/src/renderer.rs
  • crates/embers-client/src/scripting/context.rs
  • crates/embers-client/src/state.rs
  • crates/embers-client/tests/configured_client.rs
  • crates/embers-client/tests/e2e.rs
  • crates/embers-client/tests/reducer.rs
  • crates/embers-client/tests/renderer.rs
  • crates/embers-client/tests/support/mod.rs
  • crates/embers-core/Cargo.toml
  • crates/embers-core/src/lib.rs
  • crates/embers-core/src/snapshot.rs
  • crates/embers-protocol/schema/embers.fbs
  • crates/embers-protocol/src/codec.rs
  • crates/embers-protocol/src/types.rs
  • crates/embers-protocol/tests/family_round_trip.rs
  • crates/embers-server/src/buffer_runtime.rs
  • crates/embers-server/src/server.rs
  • crates/embers-server/src/terminal_backend.rs
  • crates/embers-test-support/tests/buffer_runtime.rs
  • docs/render-source-contract.md
  • docs/terminal-capture-model.md

📝 Walkthrough

Walkthrough

Introduces per-cell terminal styling through SnapshotLine runs, transports styles across the protocol, captures them from terminal grids, renders them in the client, and updates tests and documentation.

Changes

Styled snapshot line pipeline

Layer / File(s) Summary
Core styling types
crates/embers-core/src/snapshot.rs, crates/embers-core/src/lib.rs, crates/embers-core/Cargo.toml
Adds TermColor, CellAttrs, StyledRun, styled SnapshotLine values, serialization compatibility, public re-exports, and unit coverage.
Wire protocol and codec
crates/embers-protocol/schema/embers.fbs, crates/embers-protocol/src/codec.rs, crates/embers-protocol/src/types.rs, crates/embers-protocol/tests/family_round_trip.rs
Adds sparse styled-line fields and codec support for visible snapshots and scrollback slices, with lenient decoding and round-trip tests.
Terminal backend capture
crates/embers-server/src/terminal_backend.rs
Projects terminal cells into styled lines while handling colors, attributes, tabs, wide characters, combining marks, painted backgrounds, visible snapshots, and scrollback.
Server and buffer runtime wiring
crates/embers-server/src/buffer_runtime.rs, crates/embers-server/src/server.rs
Propagates styled runtime snapshots, reconstructs scrollback runs, and drops styles when the configured payload budget is exceeded.
Client state and grid rendering
crates/embers-client/src/state.rs, crates/embers-client/src/scripting/context.rs, crates/embers-client/src/lib.rs, crates/embers-client/src/grid.rs
Changes client visible lines to SnapshotLine, renders styled runs, supports indexed/RGB colors and strikeout, and restyles existing cell ranges.
Renderer overlays
crates/embers-client/src/renderer.rs
Renders snapshot lines directly and applies search and selection overlays by composing or toggling cell styles.
Tests and documentation
crates/embers-client/tests/*, crates/embers-cli/tests/interactive.rs, crates/embers-test-support/tests/buffer_runtime.rs, docs/*
Updates structured-line fixtures and assertions, adds ANSI and styling coverage, adjusts PTY expectations, and documents styled capture semantics.

Estimated code review effort: 4 (Complex) | ~75 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TerminalBackend
  participant Server
  participant Codec
  participant Client
  participant Renderer

  TerminalBackend->>Server: produce styled SnapshotLine values
  Server->>Codec: encode visible or scrollback lines
  Codec->>Client: transmit text and sparse styles
  Client->>Codec: decode styled lines
  Codec->>Client: restore SnapshotLine runs
  Client->>Renderer: provide visible SnapshotLine values
  Renderer->>Renderer: render cells and apply overlays
Loading

Poem

A rabbit hops through terminal grass,
Painting each glyph as colors pass.
Styled runs cross the wire bright,
Then overlays glow in client light.
Plain lines still keep their start—
Hop, decode, and render art! 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and directly matches the main theme of the change: adding styled terminal color rendering support.
Docstring Coverage ✅ Passed Docstring coverage is 98.44% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Pajn

Pajn commented Jul 10, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Pajn

Pajn commented Jul 10, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/embers-protocol/src/codec.rs`:
- Around line 475-493: Reduce per-line overhead in encode_styled_lines by
encoding only lines with non-empty runs, using a sparse representation that
preserves each styled line’s original index for decoding. Update the
corresponding FlatBuffer schema, generated bindings, and decode logic to handle
indexed styled entries, while retaining the existing None result when no lines
are styled.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: aa572f57-602e-4b5e-b8d4-a3bd2a235b2f

📥 Commits

Reviewing files that changed from the base of the PR and between f3167ac and 39fc7eb.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (24)
  • crates/embers-cli/tests/interactive.rs
  • crates/embers-client/src/grid.rs
  • crates/embers-client/src/lib.rs
  • crates/embers-client/src/renderer.rs
  • crates/embers-client/src/scripting/context.rs
  • crates/embers-client/src/state.rs
  • crates/embers-client/tests/configured_client.rs
  • crates/embers-client/tests/e2e.rs
  • crates/embers-client/tests/reducer.rs
  • crates/embers-client/tests/renderer.rs
  • crates/embers-client/tests/support/mod.rs
  • crates/embers-core/Cargo.toml
  • crates/embers-core/src/lib.rs
  • crates/embers-core/src/snapshot.rs
  • crates/embers-protocol/schema/embers.fbs
  • crates/embers-protocol/src/codec.rs
  • crates/embers-protocol/src/types.rs
  • crates/embers-protocol/tests/family_round_trip.rs
  • crates/embers-server/src/buffer_runtime.rs
  • crates/embers-server/src/server.rs
  • crates/embers-server/src/terminal_backend.rs
  • crates/embers-test-support/tests/buffer_runtime.rs
  • docs/render-source-contract.md
  • docs/terminal-capture-model.md

Comment thread crates/embers-protocol/src/codec.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/embers-client/src/grid.rs`:
- Around line 205-290: Add direct unit tests in the grid module for
put_snapshot_line and restyle_range, covering truncation with a trailing
default-styled ~, hidden-run blanking while preserving the grapheme’s width, and
restyle_range snapping both sides of a wide grapheme so its lead and
continuation receive the restyled style. Assert cell contents, styles, and
continuation behavior directly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 20c06c5f-0b62-4817-b41e-825c0130e22b

📥 Commits

Reviewing files that changed from the base of the PR and between 39fc7eb and b4fe359.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (24)
  • crates/embers-cli/tests/interactive.rs
  • crates/embers-client/src/grid.rs
  • crates/embers-client/src/lib.rs
  • crates/embers-client/src/renderer.rs
  • crates/embers-client/src/scripting/context.rs
  • crates/embers-client/src/state.rs
  • crates/embers-client/tests/configured_client.rs
  • crates/embers-client/tests/e2e.rs
  • crates/embers-client/tests/reducer.rs
  • crates/embers-client/tests/renderer.rs
  • crates/embers-client/tests/support/mod.rs
  • crates/embers-core/Cargo.toml
  • crates/embers-core/src/lib.rs
  • crates/embers-core/src/snapshot.rs
  • crates/embers-protocol/schema/embers.fbs
  • crates/embers-protocol/src/codec.rs
  • crates/embers-protocol/src/types.rs
  • crates/embers-protocol/tests/family_round_trip.rs
  • crates/embers-server/src/buffer_runtime.rs
  • crates/embers-server/src/server.rs
  • crates/embers-server/src/terminal_backend.rs
  • crates/embers-test-support/tests/buffer_runtime.rs
  • docs/render-source-contract.md
  • docs/terminal-capture-model.md

Comment thread crates/embers-client/src/grid.rs
@Pajn

Pajn commented Jul 10, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Pajn
Pajn merged commit c7cafe6 into main Jul 10, 2026
4 checks passed
@Pajn
Pajn deleted the term-color branch July 10, 2026 12:42
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