Skip to content

Support per-folder enable/disable for the singleton server in multi-root workspaces - #62

Draft
Eduardo Villalpando Mello (edvilme) with Copilot wants to merge 4 commits into
mainfrom
copilot/support-singleton-server-instance
Draft

Eduardo Villalpando Mello (edvilme) with Copilot wants to merge 4 commits into
mainfrom
copilot/support-singleton-server-instance

Conversation

Copilot AI commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Refresh this existing draft onto current main after the S1–S9 refactoring. Keep the existing singleton language client/server; provide explicit opt-in per-folder participation mechanics related to #49, without changing consumer execution policy or adopting them in any extension.

The earlier draft's disabled-folder omission was unsafe: Python could route an omitted root's documents to enabled fallback settings. This revision removes the folder-filter helpers and retains settings and routing identities for every enabled and disabled root.

Supported contract

  • ToolConfig.workspaceEnablementSetting?: string, also available through ToolDefinition<TSettings>, maps a contributed resource-scoped boolean key such as enabled, enable, or runTools.
  • Only opted-in configurations emit the reserved _toolEnabled boolean in workspace/global settings. Only literal boolean false disables; missing or other wire values stay enabled. Existing consumer-owned settings such as Pylint's enabled are not replaced.
  • getWorkspaceSettings, getExtensionSettings, and getGlobalSettings agree on this wire contract. Common activation subscriptions automatically track the configured key and restart the singleton with refreshed settings; manually composed lifecycles must arrange their own refresh.
  • Python's ToolServer.is_document_enabled(document) supplies the participation decision through get_settings_by_document. A handler must consult it before tool work. The unchanged legacy get_settings_by_path lookup is not enablement-aware and must not be used to infer participation. This does not automatically gate execute_tool, register handlers, clear diagnostics, or change existing/manual consumers.
  • Document routing uses the most-specific retained filesystem root, including nested roots. Opted-in matching also handles Windows path casing and filesystem-root workspaces, with terminal filesystem-root matching limited to absolute paths so relative documents do not incorrectly inherit server CWD settings. Outside-workspace documents use global defaults; absent/pathless documents retain first-workspace/CWD fallback semantics. Notebook callers must supply the actual notebook filesystem path through the existing synthetic document. Virtual roots without local filesystem paths are not matched.

See the supported opt-in contract.

Validation

  • Node 24 baseline: npm run build; npm test -- --reporter dot — 207 passing, including settings and real activation/restart paths with and without per-project environments.
  • Isolated Python environment: python -m pytest tests -q — 364 passed, 2 skipped before the independent-review follow-up. Follow-up validation: python -m pytest tests\test_server.py tests\test_server_stdio.py -q — 138 passed, including the Windows-only casing regression; changed-file Python linters pass. Full suites and TypeScript were not rerun for this Python-only follow-up.
  • Python flake8, Black, and isort checks pass.
  • TypeScript ESLint: no errors; two pre-existing unused-disable warnings in untouched vscodeapi.ts.
  • npm run format-check still reports the same 15/15 source-file failures independently reproduced from untouched current main; no unrelated formatting cleanup.
  • Extend the existing cross-language JSON fixture and real LSP stdio harness. Tests cover explicit opt-in/custom keys, legacy enabled:false, all-disabled and mixed roots, nested re-enablement, global/absent-document fallbacks, notebook filesystem paths, live settings updates, consumer-owned execution gating, relative-document/CWD fallback, Windows case-differing paths and adjacent-prefix nonmatching, and false-like wire values.

No VS Code extension-host/Pylint smoke test, consumer updates, package-version changes, PR merge, or draft-state change is included. This is shared participation plumbing, not a claim that all of #49 or consumer adoption is complete.

Copilot AI changed the title [WIP] Add support for singleton server instance in multi-root workspaces Support per-folder enable/disable for the singleton server in multi-root workspaces Jun 17, 2026
…eton-server-instance

# Conflicts:
#	typescript/src/settings.ts

Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Omitted folders still receive enabled server defaults, and a duplicate import prevents test compilation.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds per-folder tool enablement for singleton LSP servers in multi-root workspaces.

Changes:

  • Adds enablement helpers and workspace filtering.
  • Exports and documents the new APIs.
  • Adds multi-root tests.
File summaries
File Description
typescript/src/settings.ts Implements enablement filtering.
typescript/src/index.ts Exports new helpers.
typescript/tests/settingsWorkspace.test.ts Adds enablement tests.
README.md Documents multi-root behavior.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 3
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread typescript/src/settings.ts Outdated
Comment on lines +346 to +347
workspaces.filter((w) => isToolEnabledForWorkspace(namespace, w)).map((w) =>
getWorkspaceSettings(namespace, w, toolConfig, resolveInterpreter),
Comment thread README.md Outdated
Comment on lines +75 to +77
- `getExtensionSettings(namespace, toolConfig, resolveInterpreter)` automatically
omits folders where the tool is disabled, so the shared server never lints
opted-out folders.
Merge current main and retain disabled workspace settings for explicit participation checks.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 85ef72cc-9e26-4bc4-b1c3-55256d9bef91
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