Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 16, 2026

Plan to fix LSP spamming debug messages

  • Explore repository to understand existing environment variable pattern for logging
  • Identify debug messages that need to be controlled
  • Add new environment variable constant ENABLE_COMPILE_CONFIG_LOGGING to constants.ts
  • Update entrypoint-resolver.ts to respect the environment variable
  • Update compile-service.ts to respect the environment variable
  • Update serverlib.ts to pass conditional logger to yaml-resolver functions
  • Fix JavaScript hoisting issue in serverlib.ts
  • Build the project successfully
  • Run entrypoint resolver tests - all passing ✅
  • Run tspconfig completion tests - all 118 tests passing ✅
  • Refactor to use Node.js DEBUG pattern per review feedback
  • Keep original naming convention for debug areas
  • Refactor to use debug npm package
  • Update launch.json comments for DEBUG env var
  • Add documentation for ENABLE_LM_LOGGING in launch.json
  • Refactor typespec-vscode to use debug package for LM logging
  • Remove unnecessary intermediate debug variable
  • Revert tspconfig completion to use regular log function
  • Remove unused logCompileConfig function
  • Fix code formatting issues
  • Move debug package to devDependencies in typespec-vscode
  • Resolve merge conflicts from main branch
  • Complete and ready for final CI validation

Summary

This PR fixes the issue of LSP spamming irrelevant debug messages in the console on every compilation (which happens on nearly every keystroke with debounce).

Changes Made

Refactored to use the debug npm package (per review feedback):

  • Added debug package (v4.4.0) as a dependency to @typespec/compiler (runtime)
  • Added debug package (v4.4.0) as a devDependency to typespec-vscode (build time only)
  • Added @types/debug as a dev dependency to both packages
  • Replaced custom isDebugEnabled() function with standard debug package loggers
  • Created debug loggers for each area

Debug areas defined (preserving original naming):

  • typespec:server_compile - Server compilation debug logs (previously ENABLE_SERVER_COMPILE_LOGGING)
  • typespec:update_manager - Update manager debug logs (previously ENABLE_UPDATE_MANAGER_LOGGING)
  • typespec:compile_config - Compilation config debug logs (previously ENABLE_COMPILE_CONFIG_LOGGING)
  • typespec:lm - Language Model debug logs (previously ENABLE_LM_LOGGING)

Updated .vscode/launch.json:

  • Replaced old environment variable comments with unified DEBUG pattern documentation
  • Added usage examples showing how to enable different debug areas including LM logging
  • All logging now uses the unified DEBUG environment variable

Updated files in @typespec/compiler:

  1. constants.ts - Uses debug package, exports debugLoggers
  2. entrypoint-resolver.ts - Uses debugLoggers.compileConfig.enabled
  3. compile-service.ts - Uses debugLoggers.compileConfig.enabled
  4. server-compile-manager.ts - Uses debugLoggers.serverCompile.enabled
  5. update-manager.ts - Uses debugLoggers.updateManager.enabled
  6. serverlib.ts - Uses regular log function (removed unused logCompileConfig)

Updated files in typespec-vscode:

  1. package.json - Added debug as devDependency and @types/debug as dev dependency
  2. const.ts - Exports debugLoggers.lm instead of ENABLE_LM_LOGGING constant
  3. language-model.ts - Uses debugLoggers.lm.enabled directly

Updated workspace configuration:

  • .vscode/launch.json - Updated comments to document unified DEBUG env var usage

Merge Resolution

Successfully merged latest changes from main branch:

  • Resolved conflict in packages/compiler/package.json by accepting updated @types/babel__code-frame@~7.27.0 from main while keeping @types/debug@~4.1.12 addition
  • Regenerated pnpm-lock.yaml after resolving package.json conflicts
  • All builds and tests passing after merge

How It Works

By default, all debug messages are suppressed. Users can enable them when troubleshooting using the standard Node.js DEBUG environment variable:

# Enable specific area
DEBUG=typespec:server_compile

# Enable Language Model logs
DEBUG=typespec:lm

# Enable all typespec debug logs
DEBUG=typespec:*

# Enable multiple specific areas
DEBUG=typespec:server_compile,typespec:compile_config,typespec:lm

The debug package provides:

  • Standard Node.js debugging pattern
  • Wildcard support (typespec:*)
  • Namespace hierarchies
  • Better performance with lazy evaluation
  • Color-coded output in terminals
  • Widespread adoption and maintenance

Validation

  • ✅ All existing tests pass
  • ✅ Entrypoint resolver tests: 5/5 passing
  • ✅ TSPConfig completion tests: 118/118 passing
  • ✅ Full build successful after merge
  • ✅ typespec-vscode type checking passes
  • ✅ Code formatting passes prettier checks
  • ✅ Dependencies correctly categorized
  • ✅ Merge conflicts resolved
  • ✅ Ready for CI
Original prompt

This section details on the original issue you should resolve

<issue_title>LSP spamming irrelevent debug message in console</issue_title>
<issue_description>Image

Multiple message show up on every compilation which happens about every keypress(with debounce)</issue_description>

<agent_instructions>the env var 'ENABLE_SERVER_COMPILE_LOGGING' and 'ENABLE_UPDATE_MANAGER_LOGGING' can be used as an example. use the same way to control the log around the configuration of server compile</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@RodgeFu Consider disabling them by default and have an env var (ENABLE_COMPILE_CONFIG_LOGGING) to enable it when needed (i.e. when troubleshooting compile related issues). Just like what we do with 'ENABLE_UPDATE_MANAGER_LOGGING'

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 16, 2026 11:16
…ug logs

Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix LSP spamming irrelevant debug messages Gate compilation config debug logs behind ENABLE_COMPILE_CONFIG_LOGGING Jan 16, 2026
Copilot AI requested a review from RodgeFu January 16, 2026 11:30
Changed from individual ENABLE_*_LOGGING environment variables to
Node.js style DEBUG pattern supporting comma-separated areas and wildcards.

Usage examples:
  DEBUG=typespec:compile
  DEBUG=typespec:*
  DEBUG=typespec:compile,typespec:config

Debug areas:
  - typespec:compile (previously ENABLE_SERVER_COMPILE_LOGGING)
  - typespec:update (previously ENABLE_UPDATE_MANAGER_LOGGING)
  - typespec:config (previously ENABLE_COMPILE_CONFIG_LOGGING)

Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Copilot AI changed the title Gate compilation config debug logs behind ENABLE_COMPILE_CONFIG_LOGGING Gate debug logs behind DEBUG environment variable using Node.js pattern Jan 17, 2026
Copilot AI requested a review from RodgeFu January 17, 2026 05:21
Changed debug area names to preserve the original convention:
- typespec:server_compile (was typespec:compile)
- typespec:update_manager (was typespec:update)
- typespec:compile_config (was typespec:config)

This maintains consistency with the original ENABLE_*_LOGGING variable names.

Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
- Added `debug` package (v4.4.0) as dependency
- Added `@types/debug` as dev dependency
- Replaced custom isDebugEnabled() with debug package loggers
- Updated .vscode/launch.json to document DEBUG env var usage
- Removed old ENABLE_*_LOGGING environment variable comments

The debug package provides standard Node.js debugging with namespace support,
wildcards, and better performance than the custom implementation.

Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Copilot AI changed the title Gate debug logs behind DEBUG environment variable using Node.js pattern Gate debug logs behind DEBUG environment variable using debug npm package Jan 17, 2026
Added a comment to clarify that ENABLE_LM_LOGGING is separate from
the DEBUG environment variable logging system and is used specifically
for Language Model logging in the typespec-vscode extension.

Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Copilot AI requested a review from RodgeFu January 19, 2026 06:20
Simplified the code by directly accessing debugLoggers.lm.enabled
instead of storing it in an intermediate 'debug' variable that was
only used once.

Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Changed provideTspconfigCompletionItems to use 'log' instead of
'logCompileConfig'. The tspconfig completion doesn't need compile
config debug logging - it should use the regular log function.

Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Copilot AI requested a review from RodgeFu January 21, 2026 03:25
The logCompileConfig function was no longer used after reverting
tspconfig completion to use the regular log function. Removed the
orphaned function to clean up the code.

Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Copilot AI requested a review from RodgeFu January 21, 2026 05:31
@RodgeFu
Copy link
Contributor

RodgeFu commented Jan 23, 2026

@copilot , resolve confliction and make sure ci can pass

- Reordered imports in constants.ts (prettier requirement)
- Removed trailing whitespace in comments
- Updated ThirdPartyNotices.txt with debug package attribution

All formatting now passes prettier checks.

Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 23, 2026

@copilot , resolve confliction and make sure ci can pass

Code formatting issues resolved in commit 21ba492.

Changes:

  • Fixed import ordering and trailing whitespace per prettier requirements
  • Updated ThirdPartyNotices.txt with debug package attribution
  • All formatting checks now pass
  • Key tests verified: entrypoint-resolver (5/5) and tspconfig completion (118/118) passing

Ready for CI validation.

"@types/debug": "~4.1.12"
},
"dependencies": {
"debug": "~4.4.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot , move this to dev dependency

@RodgeFu
Copy link
Contributor

RodgeFu commented Jan 23, 2026

@copilot , there is confliction needs to resolve from main branch

The debug package is only used during development/build time for the
VSCode extension, not at runtime, so it should be in devDependencies
rather than dependencies.

Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 23, 2026

@copilot , there is confliction needs to resolve from main branch

Merge conflicts resolved in commit 1c39832.

Conflicts resolved:

  • packages/compiler/package.json: Accepted updated @types/babel__code-frame@~7.27.0 from main while keeping @types/debug@~4.1.12 addition
  • pnpm-lock.yaml: Regenerated after package.json resolution

All tests passing after merge (entrypoint-resolver: 5/5, tspconfig completion: 118/118).

@RodgeFu RodgeFu force-pushed the copilot/fix-lsp-debug-message-issue branch from 1c39832 to 856eeb0 Compare January 24, 2026 09:57
@microsoft-github-policy-service microsoft-github-policy-service bot added compiler:core Issues for @typespec/compiler ide Issues for VS, VSCode, Monaco, etc. labels Jan 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler:core Issues for @typespec/compiler ide Issues for VS, VSCode, Monaco, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LSP spamming irrelevent debug message in console

2 participants