orca icon indicating copy to clipboard operation
orca copied to clipboard

[Bug]: proto files have no syntax highlighting (wrong Monaco language id)

Open nasagong opened this issue 4 months ago • 0 comments

Operating system

macOS

Orca version

v1.4.145-rc.3

Details

Details

Short summary: Opening a .proto (Protocol Buffers) file in the editor shows flat, uncolored text. Monaco ships a Protocol Buffers grammar, so this is a wiring bug rather than a missing language.

What happened?

src/renderer/src/lib/language-detect.ts maps .proto to the language id 'protobuf'. Monaco registers Protocol Buffers under the id 'proto' — 'protobuf' is only an alias:

// monaco-editor/esm/vs/basic-languages/protobuf/protobuf.contribution.js
registerLanguage({
  id: "proto",
  extensions: [".proto"],
  aliases: ["protobuf", "Protocol Buffers"],
  loader: () => import('./protobuf.js')
});

Monaco matches ids and never resolves aliases, and it degrades silently rather than erroring, so every surface that passes the id explicitly loses highlighting:

  • File editor and diff viewer. @monaco-editor/react calls monaco.editor.createModel(value, language, uri). With an explicit language, Monaco uses createById(), which falls back to plaintext when the id is unregistered. It only guesses from the file path when no language is passed — and Orca always passes one (EditorContent derives it via detectLanguage, MonacoEditor forwards it as language={...}).
  • PR/issue review comment code excerpts. MonacoCodeExcerpt calls monaco.editor.colorize(code, language), which fails isRegisteredLanguageId and returns uncolored output.

How can we reproduce it?

  1. Open any repo containing a .proto file, or create api/v1/service.proto with a syntax = "proto3"; line, a message, and a service block.
  2. Open it from the file explorer.
  3. The file renders with no syntax coloring — syntax, message, service, rpc are the same color as everything else. A .ts file in the same repo colors normally.

Verification:

Asking Monaco directly what each id resolves to:

createModel(sample, 'protobuf', Uri.file('x.proto')).getLanguageId()  ->  "plaintext"
createModel(sample, 'proto',    Uri.file('x.proto')).getLanguageId()  ->  "proto"
createModel(sample, undefined,  Uri.file('x.proto')).getLanguageId()  ->  "proto"

And for the excerpt path, comparing distinct mtk* token classes in the colorized HTML:

language id passed registered? token classes produced
protobuf (current) no mtk1 — uncolored
proto (fix) yes mtk1, mtk6, mtk7, mtk20, mtk22

Anything else that might help:

  • Not platform-specific. The mapping table is plain renderer code with no platform branches, so macOS, Linux, and Windows are affected identically, and it behaves the same for local and SSH worktrees.
  • No git-provider-specific behavior; the excerpt components are shared across providers.
  • The fix is a one-line change in the extension map ('.proto': 'proto'). Monaco lazy-loads the tokenizer on first use, so no bundling or worker change is needed.

nasagong avatar Jul 18 '26 05:07 nasagong