Skip to content

fix(editor): detect open-ended dotenv filenames - #13239

Open
innocarpe wants to merge 2 commits into
stablyai:mainfrom
innocarpe:fix/env-file-language-detection
Open

fix(editor): detect open-ended dotenv filenames#13239
innocarpe wants to merge 2 commits into
stablyai:mainfrom
innocarpe:fix/env-file-language-detection

Conversation

@innocarpe

Copy link
Copy Markdown
Contributor

Description

Dotenv files with scoped names such as .env.functions.local, .env.staging, and .env.test.example now receive INI syntax highlighting when no more specific language mapping applies.
The desktop and mobile filename detectors share the same fallback rule while preserving explicit language extensions and excluding .envrc.

Focused fix

  • In scope: recognize open-ended .env and .env.* filenames after exact-name and extension-specific lookups miss.
  • Out of scope (explicit): changing syntax highlighting for .env.sh, .envrc, or other explicitly mapped file types.

Preserves

  • Exact filename mappings continue to win.
  • Extension mappings continue to win for files whose suffix has a known language.

Evidence

  • Test: pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/lib/language-detect.test.ts mobile/src/session/mobile-file-language.test.ts
  • Regression: tests cover scoped dotenv names, explicit shell extensions, and .envrc exclusion.

User-regression-tradeoffs

  • Unmapped .env.* files are intentionally treated as dotenv/INI content; a future language-specific extension mapping will continue to take precedence.

Fixes #13028

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9a158dfa-759b-45de-af01-46d3580290f0

📥 Commits

Reviewing files that changed from the base of the PR and between 4309e79 and d05bcae.

📒 Files selected for processing (2)
  • mobile/src/session/mobile-file-syntax.test.ts
  • src/renderer/src/lib/language-detect.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/lib/language-detect.test.ts
  • mobile/src/session/mobile-file-syntax.test.ts

📝 Walkthrough

Walkthrough

Added .env.* filename detection to mobile and renderer language detection. These filenames now resolve to ini after exact filename and extension lookups fail. .envrc remains plaintext, and .env.sh remains shell. Tests cover nested paths and Windows-style paths.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the fix and tests, but it omits required template sections for screenshots, AI review, security audit, notes, and test checklist status. Add the required template headings, state whether there is a visual change, complete the testing checklist, and include AI review, security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: detecting open-ended dotenv filenames in the editor.
Linked Issues check ✅ Passed The changes satisfy issue #13028 by detecting scoped dotenv filenames on desktop and mobile while preserving explicit mappings and excluding .envrc.
Out of Scope Changes check ✅ Passed The changes are limited to dotenv language detection and regression tests described by issue #13028.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
mobile/src/session/mobile-file-syntax.test.ts (1)

23-29: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover case-insensitive dotenv detection in both test suites.

Both implementations lowercase filenames, but neither test suite verifies an uppercase .ENV.* filename.

  • mobile/src/session/mobile-file-syntax.test.ts#L23-L29: add detectMobileFileLanguage('.ENV.STAGING') and expect ini.
  • src/renderer/src/lib/language-detect.test.ts#L73-L82: add detectLanguage('.ENV.STAGING') and expect ini.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7ac69f5a-1e47-474f-9312-2189c3714bd7

📥 Commits

Reviewing files that changed from the base of the PR and between 6da7b8e and 4309e79.

📒 Files selected for processing (4)
  • mobile/src/session/mobile-file-language.ts
  • mobile/src/session/mobile-file-syntax.test.ts
  • src/renderer/src/lib/language-detect.test.ts
  • src/renderer/src/lib/language-detect.ts

@innocarpe
innocarpe force-pushed the fix/env-file-language-detection branch from 4309e79 to d05bcae Compare August 9, 2026 01:17
@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (d05bcae2cf)

Address review: added uppercase dotenv regression coverage for .ENV.STAGING in renderer and mobile language detection. Validation: renderer vitest src/renderer/src/lib/language-detect.test.ts passed (15 tests); mobile vitest src/session/mobile-file-syntax.test.ts passed (9 tests); oxfmt --check, oxlint, and git diff --check passed. Commit: d05bcae.

@AmethystLiang AmethystLiang added the P1 High priority: bug or day-to-day user frustration label Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 High priority: bug or day-to-day user frustration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Non-standard .env files (.env.functions.local, .env.staging, …) render as plaintext

3 participants