Skip to content

Preserve output channel visibility on restart - #1849

Open
Pradeep Ramola (pradeep-ramola) wants to merge 3 commits into
microsoft:mainfrom
pradeep-ramola:pradeep-ramola/preserve-output-channel-on-restart
Open

Preserve output channel visibility on restart#1849
Pradeep Ramola (pradeep-ramola) wants to merge 3 commits into
microsoft:mainfrom
pradeep-ramola:pradeep-ramola/preserve-output-channel-on-restart

Conversation

@pradeep-ramola

@pradeep-ramola Pradeep Ramola (pradeep-ramola) commented Sep 2, 2026

Copy link
Copy Markdown

Summary

Preserves a language client's output channel visibility across LanguageClient.restart().

If the output channel is already visible before restart, the client shows it again after restart succeeds using show(true) so focus is preserved. If the output channel is hidden or has not been created, restart behavior is unchanged.

The visibility detector matches VS Code log output resources by normalized log-channel resource suffix instead of using a broad substring match. This avoids treating another visible output channel as a match when, for example, the extension id contains the channel name, and it handles channel names that VS Code sanitizes in log file names.

This moves the behavior requested in microsoft/vscode-eslint#2206 into the shared LSP client library so other clients can benefit from it too.

Validation

  • npm run compile:client
  • npm run compile:client-node-tests
  • npm run lint --prefix client
  • npm run lint --prefix client-node-tests
  • npm run test --prefix client-node-tests (208 passing)

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

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

Output-channel matching is unreliable, and the tests bypass that detection logic.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Preserves a language client’s output-channel visibility across successful restarts.

Changes:

  • Detects whether the output channel is visible before stopping.
  • Restores visible channels without stealing focus.
  • Adds restart sequencing tests.
File summaries
File Description
client/src/node/main.ts Captures and restores visibility around restart.
client/src/common/client.ts Implements visibility detection and restoration.
client-node-tests/src/integration.test.ts Adds restart behavior tests.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • 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 client/src/common/client.ts Outdated
Comment thread client-node-tests/src/integration.test.ts Outdated
@dbaeumer

Copy link
Copy Markdown
Member

Pradeep Ramola (@pradeep-ramola) can you have a look at the copilot comments.

@pradeep-ramola

Copy link
Copy Markdown
Author

Addressed the Copilot review comments in 77348094.

What changed:

  • Replaced the substring-based output-channel visibility check with a normalized log resource suffix match. This uses the same invalid filename character removal VS Code applies when creating log output channel resources.
  • Added a protected getVisibleTextEditors() wrapper so tests can exercise the real isOutputChannelVisible() detector without overriding it.
  • Expanded restart/detector coverage for a matching visible output document, a hidden channel with another visible output document whose extension id contains the channel name, and a sanitized channel name such as C/C++.

Validated locally with:

  • npm run compile:client
  • npm run compile:client-node-tests
  • npm run lint --prefix client
  • npm run lint --prefix client-node-tests
  • npm run test --prefix client-node-tests (207 passing)

@pradeep-ramola

Copy link
Copy Markdown
Author

Resolved the merge conflict with current main in 892c8683.

The conflict was in client-node-tests/src/integration.test.ts; I kept both the restart coverage from this PR and the upstream socket transport test added on main.

Validation after resolving conflicts:

  • npm run compile:client
  • npm run compile:client-node-tests
  • npm run lint --prefix client
  • npm run lint --prefix client-node-tests
  • npm run test --prefix client-node-tests (208 passing)

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.

3 participants