Skip to content

fix: remove hardcoded theme colors and rely on semanticTokenScopes#9

Merged
setu4993 merged 6 commits into
salesforce:mainfrom
marcelinollano:semantic-token-scopes
Apr 23, 2026
Merged

fix: remove hardcoded theme colors and rely on semanticTokenScopes#9
setu4993 merged 6 commits into
salesforce:mainfrom
marcelinollano:semantic-token-scopes

Conversation

@marcelinollano
Copy link
Copy Markdown
Contributor

Summary

The VS Code extension was hardcoding dark hex colors in configurationDefaults using exact theme name matching. Anyone on a light theme or any third-party theme got dark colors on a white background. This removes all hardcoded colors and lets the active theme supply them automatically via semanticTokenScopes.

The semanticTokenScopes table in package.json maps each semantic token type (emitted by the LSP) to a standard TextMate scope name. VS Code looks those scopes up in the active theme and applies the theme's own colors — so any light, dark, high contrast, or third-party theme just works.

Also removes buildVscodeRules from the Monaco package and the sync-theme script, which were only needed to generate the now-deleted hardcoded color block.

Before

  • Light theme users and third-party theme users see dark hex colors hardcoded by the extension, overriding their theme
  • Theme name matching only covered Default Light+, Default Light Modern, Default High Contrast Light — any other light theme broke

After

  • Colors are sourced from the active theme automatically for any theme
  • semanticTokenScopes covers all 13 token types the LSP emits with well-supported standard TM scope names
  • ~250 lines of hardcoded color configuration deleted

Testing

Manual verification:

  1. Install the extension from the .vsix in packages/vscode/publish/ after building:
    pnpm --filter @agentscript/vscode build
    cd packages/vscode && node esbuild.mjs --stage
    cd staging && vsce package --no-dependencies -o ../publish/
    code --install-extension publish/agent-script-language-client-*.vsix
    
  2. Open any .agent file
  3. Switch between themes via Cmd+K Cmd+T and verify:
    • Default Dark+: keywords purple, strings orange, comments green
    • Default Light+: keywords purple, strings red-brown, comments grey-green
    • Any third-party light theme (e.g. GitHub Light, Ayu Light): colors match the theme's own palette instead of dark colors on white background

marcelinollano and others added 4 commits April 21, 2026 19:34
Adds packages/vscode/syntaxes/agentscript.tmLanguage.json with proper
standard TextMate scope names so any VS Code theme (light or dark) colors
AgentScript correctly without extension-defined overrides.

- Add TextMate grammar covering all language constructs with standard scopes
- Register grammar in package.json under contributes.grammars
- Fix semanticTokenScopes to use correct standard scope names (string,
  comment, namespace, decorator were wrong)
- Remove editor.semanticTokenColorCustomizations from configurationDefaults
- Remove scripts/sync-vscode-theme.ts (no longer needed for VS Code)
- Add syntaxes/ to esbuild staging so grammar is included in VSIX

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ization

- Remove buildVscodeRules from theme.ts and its re-export from index.ts;
  its only consumer (sync-vscode-theme.ts) was deleted in the prior commit
- Fix TM grammar template pattern to consume lone { not followed by !,
  preventing tokenizer stall on plain braces in template text
TextMate grammar was rejected as it cannot fully describe the AgentScript
language. Syntax highlighting now relies entirely on semanticTokenScopes
to map semantic token types to standard TM scope names, letting the active
theme supply colors automatically for any light or dark theme.

Also fixes the decorator scope from punctuation.definition.decorator to
support.function so themes consistently color @action references.
darkThemeColors,
lightThemeColors,
buildMonacoRules,
buildVscodeRules,
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.

I hope this isn't used in Monaco

@setu4993 setu4993 merged commit 5366538 into salesforce:main Apr 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants