Skip to content

Color sight console input the way the VS Code editor colors the same code - #450

Merged
jbearak merged 4 commits into
mainfrom
t3/align-console-colors
Nov 26, 2026
Merged

jbearak merged 4 commits into
mainfrom
t3/align-console-colors

Conversation

@jbearak

@jbearak jbearak commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

sight console colored the same Stata code differently from the editor. Strings were green there and orange/red in the editor, macros magenta instead of light blue, comments gray instead of green, and quietly/if blue instead of purple. Nothing was broken, but switching between the editor and the console meant reading two different color schemes.

The console still uses only the terminal's 16 base colors, so it keeps following the user's terminal theme. Each kind of token now gets the base color closest to the hue that VS Code's default Dark+/Light+ themes give its grammar scope:

Token Before After Editor scope
command bold blue bold blue keyword (blue)
prefixes, if, else, foreach, while, … blue / bold blue magenta keyword.control (purple)
in blue blue keyword (blue)
string green yellow string (orange / dark red)
number cyan green constant.numeric (pale / teal green)
macro magenta cyan variable (light blue / navy)
comment dim dim green comment (green)

Strings get yellow because ANSI has no orange and red is already used for error output.

Proof: a new test pins the exact escape codes and fails on the old table. Control-flow tests cover if x {, quietly if x {, foreach, } else { and } else if x {. I also rendered before/after samples with VS Code's default terminal palette next to the editor's Dark+/Light+ token colors. Typecheck, lint and bun test ./tests pass.

Reviewed with sol-loop: 3 rounds with gpt-6.2-sol. Sol verdict: approved

Created with Claude Opus 5.5 in Claude Code (T3 Code); reviewed by gpt-6.2-sol.

Summary by CodeRabbit

  • New Features
    • Updated console syntax highlighting to better match VS Code’s default themes: strings are yellow, numbers green, macros cyan, and comments dim green. Prefixes and control-flow keywords are magenta; other commands remain bold blue, and in is blue.
    • Red remains reserved for errors.
  • Documentation
    • Documented the updated syntax colors.

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Next included review available in 55 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 77 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 1544d420-85d0-4104-8c4a-191ef739d5be
Commits

Reviewing files that changed from the base of the PR and between bd0c7d8 and e94d530.

Files selected for processing: 1

  • tests/integration/console/console-pty.test.ts

No actionable comments were generated in the recent review.

Walkthrough

The console highlighter changes colors for strings, numbers, macros, comments, prefixes, and control-flow keywords. It also updates command-position handling after a closing brace. Unit tests and console documentation reflect the updated color mapping.

Changes: Console syntax highlighting

Layer / File(s) Summary
Color mapping and command scope
src/console/highlighter.ts, tests/unit/console/text-processing.test.ts, docs/console.md
The highlighter assigns updated colors to token types and command keywords. It leaves command-position state unchanged after RBRACE. Tests check the updated colors and command scope. The console documentation lists the syntax colors.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Possibly related PRs

  • jbearak/sight#367: Changes lexer tokenization for // and ///, which can affect which token type the highlighter colors.
Merge Risk: Minimal · previous review bd0c7

This change recolors console syntax highlighting to match the VS Code editor. It has no functional or data impact and is easy to revert, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the sight console input colors are changed to match how the VS Code editor colors the same Stata code. The raw summary shows the changes to highlighter.ts, its tests, …
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.
Full details: Title check

Explanation

The title names the main change: the sight console input colors are changed to match how the VS Code editor colors the same Stata code. The raw summary shows the changes to highlighter.ts, its tests, and docs/console.md that implement this color mapping. The title is concise and specific, and it matches the PR objectives.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Team
  • Run ID: a9f7f971-001f-49d6-bf8d-6846eecb199d
Commits

Reviewing files that changed from the base of the PR and between c23d188 and bd0c7d8.

Files selected for processing: 3

  • docs/console.md
  • src/console/highlighter.ts
  • tests/unit/console/text-processing.test.ts

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

@jbearak
jbearak merged commit e21c155 into main Nov 26, 2026
17 checks passed
@jbearak
jbearak deleted the t3/align-console-colors branch November 26, 2026 17:57
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