Skip to content

fix(editor): highlight Justfiles and Terraform variables - #11256

Closed
bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:bbingz/fix-justfile-tfvars-highlighting
Closed

bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:bbingz/fix-justfile-tfvars-highlighting

Conversation

@bbingz

@bbingz bbingz commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

justfile and *.tfvars currently render as plaintext in the file preview on desktop and mobile. This maps them to shell and HCL.

  • Detect .tfvars files as HCL in desktop and mobile file previews.
  • Detect justfile, Justfile, .justfile, and .just as shell syntax on both clients.
  • Keep mobile highlighting effective by resolving HCL to the bundled INI grammar and shell to Bash.

Closes #11215

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test — under the required Node 24 runtime, 39,603 tests passed and 64 skipped; one SSH system-transport integration test failed only in the full concurrent suite and passed 3/3 when rerun alone (pre-existing and unrelated: this diff touches only language-detection lookup tables, no transport code)
  • pnpm build — desktop, web, relay, CLI, and both macOS Swift architecture builds completed; the final universal-binary step failed because lipo could not find the architecture outputs at its expected paths (pre-existing: that step lives in config/scripts/build-computer-macos.mjs, which is unchanged on main and untouched by this PR)
  • cd mobile && ./node_modules/.bin/vitest run --config vitest.config.ts — 352 files passed; 2,597 tests passed and 2 skipped
  • cd mobile && ./node_modules/.bin/tsc --noEmit
  • cd mobile && ./node_modules/.bin/oxlint src app
  • Added desktop and mobile regression tests for Unix and Windows paths, canonical Justfile names, case-insensitive .tfvars, grammar resolution, and semantic token output

AI Review Report

The review traced both runtime paths before choosing language IDs. Monaco 0.55.1 bundles HCL and shell but not Makefile; mobile lowlight bundles INI, Makefile, and Bash but not HCL. The implementation therefore uses native HCL on desktop, shell for Justfiles on both clients, and the existing INI grammar as the mobile HCL fallback.

Cross-platform review covered macOS, Linux, and Windows path separators and extension casing. The change does not touch shortcuts, labels, shell execution, Electron platform behavior, SSH transport, git providers, agents, or integrations. Lookups remain constant-time map accesses, and there is no meaningful performance risk or UI layout change.

CodeRabbit and Greptile both reviewed the branch and raised no actionable findings.

Security Audit

The change adds no dependency, command execution, filesystem access, IPC, authentication, secret handling, or network surface. File paths are used only for in-memory filename and extension matching; no path is opened or executed by the new logic.

Notes

  • Mobile HCL highlighting is an intentional approximation using the bundled INI grammar; it colors comments, assignments, and strings without adding a grammar dependency.
  • Shell is used for Justfiles because it is available on both clients and covers comments and recipe bodies; desktop Monaco does not ship a Makefile language.
  • X handle: not provided.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Language detection now recognizes .tfvars files as hcl and Justfile variants as shell in desktop and mobile code. Mobile syntax resolution aliases hcl to ini and verifies Terraform and Justfile highlighting. Tests cover Windows paths, mixed-case names, dot-prefixed variants, grammar selection, and semantic token output.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy issue #11215 by detecting .tfvars and canonical Justfile names on desktop and mobile with regression tests.
Out of Scope Changes check ✅ Passed All changes directly support the linked issue objectives and add only related language detection, grammar mapping, and regression tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly summarizes the primary user-visible change: syntax highlighting for Justfiles and Terraform variable files.
Description check ✅ Passed The description covers the required summary, screenshots, testing, AI review, security audit, and platform-specific notes.

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.

@greptile-apps

greptile-apps Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR adds syntax highlighting support for Terraform variable files (.tfvars → hcl) and Justfiles (justfile, Justfile, .justfile, .just → shell) across both the desktop Monaco editor and the mobile lowlight-based highlighter. Mobile HCL is intentionally aliased to the bundled INI grammar, and Justfiles are aliased to Bash since lowlight's common bundle does not include a Makefile grammar.

  • .tfvars extension and the four canonical Justfile names are added to EXT_TO_LANGUAGE/FILENAME_TO_LANGUAGE maps in both language-detect.ts and mobile-file-language.ts, keeping both clients in sync.
  • hcl: 'ini' is prepended to the mobile LANGUAGE_ALIASES table so that HCL is routed to a bundled grammar rather than silently falling back to plaintext.
  • Regression tests are added for Unix and Windows paths, case-insensitive extension matching, and grammar resolution on both clients.

Confidence Score: 5/5

Safe to merge — the change is additive map entries and one alias; no existing detection paths are modified.

All five files touch only lookup tables and one alias entry. The new entries are consistent with the patterns already in both clients, the mobile HCL-to-INI alias correctly routes through resolveMobileSyntaxLanguage before reaching the grammar check, and the tests cover Unix paths, Windows paths, uppercase extensions, and end-to-end grammar application. No runtime behavior outside syntax highlighting is affected.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
src/renderer/src/lib/language-detect.ts Adds .tfvars → hcl to EXT_TO_LANGUAGE and four canonical Justfile names → shell to FILENAME_TO_LANGUAGE; logic is straightforward and consistent with existing patterns.
mobile/src/session/mobile-file-language.ts Mirrors the desktop changes — .tfvars added to EXT_TO_LANGUAGE and the four Justfile names added to FILENAME_TO_LANGUAGE; parity with desktop is maintained.
mobile/src/session/mobile-file-syntax.ts Adds hcl: 'ini' alias so that .tfvars files are routed to the bundled INI grammar instead of plaintext; alias placement and lookup order are correct.
src/renderer/src/lib/language-detect.test.ts Adds two new test cases for .tfvars (including Windows uppercase path) and all four Justfile name variants; covers both Unix and Windows separators.
mobile/src/session/mobile-file-syntax.test.ts Adds detection and grammar-resolution tests for .tfvars and Justfiles, including end-to-end highlightMobileCode assertions that verify INI and Bash grammars are actually applied.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[filePath input] --> B[split on / or backslash, extract filename]
    B --> C{filename in FILENAME_TO_LANGUAGE?}
    C -- yes --> D[return language e.g. justfile/Justfile/.justfile/.just → shell]
    C -- no --> E[extname filename lowercase]
    E --> F{ext in EXT_TO_LANGUAGE?}
    F -- yes --> G[return language e.g. .tfvars → hcl]
    F -- no --> H[return plaintext]

    subgraph Mobile extra step
        G --> I{language in LANGUAGE_ALIASES?}
        I -- hcl --> J[ini grammar]
        I -- shell --> K[bash grammar]
        I -- not found --> L{lowlight.registered?}
        L -- yes --> M[use detected grammar]
        L -- no --> N[plaintext]
    end
Loading

Reviews (3): Last reviewed commit: "fix(editor): highlight Justfiles and Ter..." | Re-trigger Greptile

@bbingz
bbingz force-pushed the bbingz/fix-justfile-tfvars-highlighting branch 2 times, most recently from 3554be2 to ac913a8 Compare July 31, 2026 01:25
@bbingz
bbingz force-pushed the bbingz/fix-justfile-tfvars-highlighting branch from ac913a8 to 726be2a Compare August 5, 2026 23:44
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@bbingz

bbingz commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main last night (head 726be2a, no conflicts). The Actions suites are sitting at action_required — same shape and file as #11294 and #11322, which both merged after a quick workflow approval. One "Approve and run workflows" click would give a full green rollup here too.

@bbingz

bbingz commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Closing as part of fork PR backlog cleanup.

This branch is long-conflicted (DIRTY) against current main and is not on the active campaign rebase list. Feel free to reopen or cut a fresh PR from an updated branch if the change is still needed.

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.

[Bug]: justfiles and .tfvars files have no syntax highlighting

2 participants