Skip to content

Dim BAML namespace prefixes in editors - #4168

Merged
aaronvg merged 1 commit into
canaryfrom
codex/dim-baml-namespace-prefixes
Jul 24, 2026
Merged

aaronvg merged 1 commit into
canaryfrom
codex/dim-baml-namespace-prefixes

Conversation

@aaronvg

@aaronvg aaronvg commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • classify resolved namespace separators as namespace semantic tokens
  • guarantee semantic tokens are emitted in document order so Monaco accepts them
  • apply adaptive, semi-transparent namespace styling in VS Code and PromptFiddle

Why

Namespace prefixes should recede so type and function names stay visually prominent. Monaco previously discarded the semantic token stream because qualified type tokens could be emitted out of order, producing wrapped negative column deltas.

Impact

root.blah.Hi and baml.json.json dim their namespace prefixes and dots. Member and enum dots remain unchanged. The neutral alpha color adapts across light and dark themes and remains user-overridable.

Validation

  • cargo nextest run -p baml_lsp2_actions_tests 'test_files::semantic_tokens::' (80 passed)
  • cargo nextest run -p baml_lsp2_actions_tests 'range_tokens_test::tests::' (2 passed)
  • pnpm --filter app-promptfiddle typecheck
  • pnpm --filter app-promptfiddle build
  • pnpm --filter baml-language build

Note

Low Risk
Changes are confined to LSP semantic token classification, ordering, and editor theme defaults; no runtime, auth, or data-path impact.

Overview
Namespace path segments and their separating dots are now classified as namespace semantic tokens when resolution confirms a real namespace prefix (value paths and qualified type names). Dots before members, enums, or non-namespace segments stay operators.

Document order: Full-file and in-range semantic token results are sorted by span after the walk. That fixes Monaco rejecting streams when qualified type highlighting emitted segment tokens before their dots (invalid LSP deltas).

Editors: VS Code and the PromptFiddle Monaco embed enable semantic highlighting and apply a semi-transparent gray rule for namespace:baml so prefixes like baml.json recede while type and function names stay prominent.

Reviewed by Cursor Bugbot for commit 3b5b407. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • New Features

    • Improved semantic highlighting for qualified names and namespace paths, including clearer punctuation coloring.
    • Enabled BAML semantic highlighting in VS Code and Monaco editors.
    • Added consistent styling for BAML namespace tokens.
  • Bug Fixes

    • Ensured semantic tokens are returned in source order for reliable editor rendering and navigation.
  • Tests

    • Updated semantic-token coverage across namespace, type, member-access, and intrinsic-call scenarios.

@vercel

vercel Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
beps Ready Ready Preview, Comment Jul 23, 2026 11:54pm
promptfiddle Ready Ready Preview, Comment Jul 23, 2026 11:54pm
promptfiddle2 Ready Ready Preview, Comment Jul 23, 2026 11:54pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 23, 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: c339a9cc-a606-44b7-a138-4cbb5198e0a2

📥 Commits

Reviewing files that changed from the base of the PR and between c534bbc and 3b5b407.

📒 Files selected for processing (16)
  • baml_language/crates/baml_lsp2_actions/src/tokens.rs
  • baml_language/crates/baml_lsp2_actions_tests/src/range_tokens_test.rs
  • baml_language/crates/baml_lsp2_actions_tests/test_files/semantic_tokens/cancel_token.baml
  • baml_language/crates/baml_lsp2_actions_tests/test_files/semantic_tokens/interfaces_inferred_generic_type_args.baml
  • baml_language/crates/baml_lsp2_actions_tests/test_files/semantic_tokens/interfaces_sort_comparable.baml
  • baml_language/crates/baml_lsp2_actions_tests/test_files/semantic_tokens/iterator.baml
  • baml_language/crates/baml_lsp2_actions_tests/test_files/semantic_tokens/json_parse_stringify_intrinsics.baml
  • baml_language/crates/baml_lsp2_actions_tests/test_files/semantic_tokens/ns_ansi.baml
  • baml_language/crates/baml_lsp2_actions_tests/test_files/semantic_tokens/ns_game_clients.baml
  • baml_language/crates/baml_lsp2_actions_tests/test_files/semantic_tokens/stream_llm_inferred_typeargs.baml
  • baml_language/crates/baml_lsp2_actions_tests/test_files/semantic_tokens/task_group.baml
  • baml_language/crates/baml_lsp2_actions_tests/test_files/semantic_tokens/testset.baml
  • baml_language/crates/baml_lsp2_actions_tests/test_files/semantic_tokens/testset_vibes_nested.baml
  • baml_language/crates/baml_lsp2_actions_tests/test_files/semantic_tokens/with_keyword.baml
  • typescript2/app-vscode-ext/package.json
  • typescript2/pkg-editor/src/MonacoEditor.tsx

📝 Walkthrough

Walkthrough

Qualified path separators are now emitted as namespace semantic tokens when resolvable, semantic-token results are sorted by source range, tests update expected streams, and VS Code/Monaco semantic highlighting is enabled for BAML namespaces.

Changes

Semantic token classification

Layer / File(s) Summary
Qualified path classification and ordering
baml_language/crates/baml_lsp2_actions/src/tokens.rs
Value and type paths classify resolvable . separators as namespace tokens, preserve operator fallback behavior, and sort returned tokens by source range.
Semantic token validation
baml_language/crates/baml_lsp2_actions_tests/src/range_tokens_test.rs, baml_language/crates/baml_lsp2_actions_tests/test_files/semantic_tokens/*
Tests and fixtures verify document-order ranges and standalone namespace tokens across qualified BAML paths.
Editor semantic highlighting
typescript2/app-vscode-ext/package.json, typescript2/pkg-editor/src/MonacoEditor.tsx
VS Code and Monaco enable semantic highlighting and configure the BAML namespace token color.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • BoundaryML/baml#3867: Both changes modify qualified-name separator classification in the LSP2 semantic-token pipeline.
  • BoundaryML/baml#4002: Both changes update token emission and ordering for qualified separators.
  • BoundaryML/baml#4011: Both changes touch CST path/type classification and emitted semantic tokens.

Suggested reviewers: rossirpaulo

Poem

I hop through dots in a namespace lane,
Sorting each token like drops of rain.
Types find their paths, operators stay,
Golden tests sparkle in proper array.
BAML shines gray in the editor bright—
A tidy trail for every byte!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main user-visible change: dimming BAML namespace prefixes in editors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/dim-baml-namespace-prefixes

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.

@github-actions

Copy link
Copy Markdown

⏭️ Performance benchmarks were skipped

Perf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to canary/main.

To run them on this PR, do any of the following, then push a commit (or re-run CI):

  • Add RUN_CODSPEED=1 to the PR description, or
  • Include run-perf or /perf in the PR title or any commit message.

@vercel
vercel Bot temporarily deployed to Preview – beps July 23, 2026 23:33 Inactive
@aaronvg
aaronvg marked this pull request as ready for review July 23, 2026 23:33
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 23, 2026 23:40 Inactive
@github-actions

Copy link
Copy Markdown

Binary size checks passed

✅ 7 passed

Artifact Platform File Gzip Gated on Baseline Delta Status
✅ baml-cli Linux 🔒 27.0 MB 11.5 MB file 26.2 MB +759.9 KB (+2.9%) OK
✅ packed-program Linux 🔒 17.4 MB 7.2 MB file 17.0 MB +401.1 KB (+2.4%) OK
✅ baml-cli macOS 🔒 20.9 MB 10.0 MB file 20.3 MB +596.1 KB (+2.9%) OK
✅ packed-program macOS 🔒 13.6 MB 6.3 MB file 13.2 MB +347.4 KB (+2.6%) OK
✅ baml-cli Windows 🔒 22.6 MB 10.2 MB file 21.9 MB +650.2 KB (+3.0%) OK
✅ packed-program Windows 🔒 14.5 MB 6.4 MB file 14.2 MB +348.9 KB (+2.5%) OK
✅ bridge_wasm WASM 16.4 MB 🔒 4.5 MB gzip 4.4 MB +74.7 KB (+1.7%) OK

🔒 = the size this artifact is GATED on (ceiling + delta). Binaries gate on file size (installed binary); WASM gates on gzip (download size). The other size is shown for information only.


Generated by cargo size-gate · workflow run

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 23, 2026 23:54 Inactive
@aaronvg
aaronvg added this pull request to the merge queue Jul 24, 2026
Merged via the queue into canary with commit ed20356 Jul 24, 2026
72 checks passed
@aaronvg
aaronvg deleted the codex/dim-baml-namespace-prefixes branch July 24, 2026 04:04

This branch was previously deployed

3 inactive deployments
Preview – promptfiddle — 3b5b407e Deployed Jul 23, 2026 by vercel[bot]
Preview – promptfiddle2 — 3b5b407e Deployed Jul 23, 2026 by vercel[bot]
Preview – beps — 3b5b407e Deployed Jul 23, 2026 by vercel[bot]
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