Skip to content

fix(native): match web shell command highlighting - #132

Merged
rynfar merged 2 commits into
nativefrom
nw/64-shell-grammars
Nov 3, 2026
Merged

rynfar merged 2 commits into
nativefrom
nw/64-shell-grammars

Conversation

@rynfar

@rynfar rynfar commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Native shell command details fell back to plain text or shell string colors for PowerShell, Perl, Ruby and XML. This ports the web's language requests into the existing cached background highlighter shared by command rows and raw inspectors.

The pinned web Highlights engine renders fish, AppleScript and Prolog as plain text. Native now does the same, clearing the surrounding shell string style. The fish and AppleScript grammar dependencies and registrations were removed.

Refs #64 and #78; follows #110. TR-CMDOUT and TR-INSPECT remain partial: the web's broader filename catalog (including C/C++/Java and other plain-file targets) and lexer constructs beyond the covered cases still need parity work. The ledger records filename inference and unported web lexers as remaining work.

Review corrections

All six findings at 1c742e2f84303914bb61c8062385109eb8dfaa02 were reproduced and accepted.

  1. Ported statement scanning from commandLabel.ts so comments, heredoc bodies, substitutions, parameter expansions and PowerShell here strings do not become standalone PowerShell statements. Multiple/quoted/tab-stripped heredocs and statements following them are covered.
  2. Adapted Ruby's installed query: identifiers retain variable styles, binary/unary operators are captured, booleans use the boolean role, escapes use string.escape, and instance/class variables use variable.special. The pinned highlighter emits local.* metadata as paint captures; command Ruby uses explicit syntax captures with an empty locals query to avoid erasing identifier colors.
  3. The command style resolver retains the generated palette's full capture roles, including variable.parameter, which gpui-component's smaller SyntaxColors struct drops. PowerShell parameters now match the web in light and dark appearances.
  4. XML equals signs use punctuation, quoted values keep string colors, and entities use the escape color. Tests assert the final winning color of every token byte after overlapping captures resolve.
  5. Filename inference maps .pl to unsupported Prolog/plain text, .pm to Perl, and .rake/.gemspec/Rakefile plus the web's other Ruby aliases to Ruby.
  6. Removed fish and AppleScript grammars; detection remains and the script bodies render plain as on the pinned web engine.

The six new production-path tests call cached_command with the real production theme configuration. They exercise language selection, installed highlight/locals queries, embedded byte remapping and final theme-resolved colors. All six failed at the reviewed head. The additional Ruby instance-variable case also failed before its mapping fix. Core detection/query tests remain in place. Highlighting stays off the UI thread with the existing 64-entry/64-KiB cache and recursion budget.

Dependencies and size

Ruby uses the pinned gpui-component feature. Its other requested supported languages have no feature in that pin, so they use dedicated grammar crates and the existing tree-sitter 0.26.13 runtime.

Grammar Dependency choice Compiled grammar __TEXT, MiB
Ruby gpui-component tree-sitter-ruby feature, 0.23.1; core dev dependency tests its adapted query 2.005
PowerShell tree-sitter-powershell 0.26.6, dedicated command/variable grammar 0.966
Perl ts-parser-perl 2.0.3, maintained grammar with highlight queries; the similarly named tree-sitter-perl crate omits the queries 4.498
XML tree-sitter-xml 0.7.0, XML tags/attributes/entities/comments; its archive also contains DTD 0.068

The refreshed snapshot development binary is 174,958,552 bytes: +7.69 MiB against the original base's 166,896,488 bytes, and 0.33 MiB smaller than the reviewed head's 175,306,808 bytes. Linked __TEXT is 95,846,400 bytes (+7.56 MiB against the base; 0.36 MiB smaller than the reviewed head). nm confirms no fish or AppleScript grammar entry points remain. Release binary size was not measured.

Verification

  • cargo test --workspace: 1,183 passed, including all six production-path regression cases.
  • cargo clippy --workspace --all-targets -- -D warnings passed.
  • Snapshot build, theme generator check, 42 parity tests, conformance generator check, and vp run check:changed native passed.
  • fork/native was fetched and remained c5820e2; no rebase was needed.
  • Offscreen native captures use a copied smoke home and synthetic projection items. No turns or server writes. The dark captures retain streaming capability; fake command IDs intentionally show a missing-command output message. Light captures exercise the non-streaming raw inspector with fixture output.
  • Real-window rendering was not attempted under the offscreen-only requirement. Release size remains unverified.

Local evidence (factory instructions require local paths rather than uploads):

Language Dark command row Light raw inspector
PowerShell /private/tmp/native-64-r2-powershell-command.png /private/tmp/native-64-r2-powershell-inspector.png
fish/plain /private/tmp/native-64-r2-fish-command.png /private/tmp/native-64-r2-fish-inspector.png
Ruby /private/tmp/native-64-r2-ruby-command.png /private/tmp/native-64-r2-ruby-inspector.png
XML /private/tmp/native-64-r2-xml-command.png /private/tmp/native-64-r2-xml-inspector.png

Heredoc regression: /private/tmp/native-64-r2-perl-inspector.png. AppleScript/plain: /private/tmp/native-64-r2-applescript-inspector.png.

Original before captures: /private/tmp/native-64-powershell-before.png, /private/tmp/native-64-fish-before.png, /private/tmp/native-64-ruby-before.png. Failing production tests: /private/tmp/native-64-review-failing.log. Final gate transcripts: /private/tmp/native-64-r2-workspace.log, /private/tmp/native-64-r2-clippy.log, /private/tmp/native-64-r2-check-changed.log.

Built with GPT-6.1 Sol in Codex

@rynfar rynfar changed the title fix(native): highlight remaining shell command languages fix(native): match web shell command highlighting Nov 3, 2026
@rynfar
rynfar merged commit 8c126fa into native Nov 3, 2026
@rynfar rynfar mentioned this pull request Nov 3, 2026
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