Skip to content

feat(tui): syntax-highlight bash commands in permission prompt - #51851

Closed
OmentaElvis wants to merge 1 commit into
anomalyco:devfrom
OmentaElvis:shell-highlight-perms
Closed

OmentaElvis wants to merge 1 commit into
anomalyco:devfrom
OmentaElvis:shell-highlight-perms

Conversation

@OmentaElvis

Copy link
Copy Markdown

Issue for this PR

Closes #

Type of change

  • New feature

What does this PR do?

Adds syntax highlighting to shell commands in the TUI permission prompt. Previously, the full command was rendered as a single flat line of plain text, making it harder to quickly distinguish dangerous verbs (like rm, curl, or sudo) from their arguments at a glance.

The change renders bash commands with <code filetype="bash"> and uses a separate muted $ prefix to avoid having tree-sitter parse the bare $. A scoped generateCommandSyntax() override remaps function.call (the command name) to syntaxFunction and bolds it for shell context only. Arguments and other tokens remain unchanged relative to the existing theme. This keeps the global syntax table untouched so highlighting for other languages is unaffected.

The result is a small visual anchor: the verb pops while flags, paths, pipes, and operators remain in their existing theme colors. This makes it faster to scan a permission request and decide whether a command needs closer scrutiny.

How did you verify your code works?

  • bun test test/theme.test.ts in packages/tui (9/9 passing, 20 assertions). The new test verifies function.call is bolded and mapped to syntaxFunction in the shell-specific syntax, while variable.parameter (arguments) stays on syntaxVariable and the base syntax remains unchanged.
  • bun typecheck in packages/tui passes (tsgo --noEmit).
  • bunx prettier --check on the modified files passes.
  • bun test --only-failures in packages/tui still passes with no new failures.
  • Manual verification in the TUI permission prompt with sample commands (including ls, pipes, &&, here-doc style constructs, and rm -f) shows the command name is visually distinct from its arguments. Screenshots comparing before (unhighlighted) and after (highlighted across multiple themes) are included.

Screenshots / recordings

See attached comparison: one "before" screenshot (no highlighting) and multiple "after" screenshots showing shell commands highlighted across different themes. The highlighted versions make the command verb easier to spot at a glance, which helps with quick auditing of permission requests.

before:
Screenshot From 2026-09-28 12-31-06

after across various theme samples:
Screenshot From 2026-09-28 12-23-02
Screenshot From 2026-09-28 12-21-15
Screenshot From 2026-09-28 12-20-30
Screenshot From 2026-09-28 12-19-56
Screenshot From 2026-09-28 12-19-08
Screenshot From 2026-09-28 12-35-22

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

- Render bash permission commands with <code filetype="bash">
  and a separate muted `$` prefix to avoid tree-sitter parsing the bare `$`.
- Add `generateCommandSyntax()` to theme layer, which remaps
  `function.call` to `syntaxFunction` + bold for shell context only,
  leaving global syntax rules unchanged.
- Wire `commandSyntax` memo through theme context and use it in the permission prompt.
- Add unit test asserting the shell-specific override preserves arguments
  and distinguishes the command name.

This improves auditability of shell permission requests (e.g. `rm -f ...`
is immediately distinguishable from its arguments) without affecting
highlighting for other languages.
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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