Skip to content

Suppress CMake output focus for automatic triggers with new setting#4989

Open
hanniavalera wants to merge 2 commits into
mainfrom
dev/hanniavalera/issue-4988-output-focus
Open

Suppress CMake output focus for automatic triggers with new setting#4989
hanniavalera wants to merge 2 commits into
mainfrom
dev/hanniavalera/issue-4988-output-focus

Conversation

@hanniavalera

Copy link
Copy Markdown
Contributor

This pull request introduces a new setting to control the behavior of the CMake output channel during automatic or programmatic operations, such as configure-on-open or builds/tests triggered via the API (for example, by Copilot or other extensions). By default, the output channel will no longer take over the panel and hide your terminal during these operations, unless there is a failure. The previous behavior can be restored with the new setting. The implementation includes a refactor of the logic for revealing the output channel to make it more testable and configurable. Fixes #4988

The most important changes are:

User Experience Improvements:

  • Added a new setting cmake.revealLogOnAutomaticTrigger (default: false) that controls whether the CMake output channel is proactively revealed during automatic/programmatic configures, builds, or tests. When disabled, only failures are shown, and explicit user-initiated actions are unaffected. [1] [2] [3] [4]

Core Logic and API Changes:

  • Refactored the logic for deciding when to reveal the CMake output channel into a pure function decideReveal, allowing for better testability and configurability.
  • Updated the Logger.showChannel method and all relevant code paths in CMakeProject and CTestDriver to use the new reveal logic and respect the new setting for automatic operations. [1] [2] [3] [4] [5] [6]

Internal API and Type Changes:

  • Added the utility function isAutomaticConfigureTrigger to classify configure triggers as automatic or user-initiated, ensuring the new reveal logic is applied consistently.
  • Updated API wrapper and method signatures to propagate the new isAutomatic flag where needed for builds and tests.

These changes improve the usability of the extension for users who rely on terminals during development, while still surfacing important information when failures occur.

…gers (#4988)

The CMake output channel was unconditionally revealed at the start of every build
(cmakeProject.runBuild) and configure (cmakeProject.configureInternal). With the default
cmake.revealLog=always this preserves keyboard focus but still switches the shared bottom
panel from the user's Terminal to Output - disruptive when a build/configure is triggered
automatically (configure-on-open, reconfigure) or programmatically (a build/test invoked
through the CMake Tools API by the C/C++ DevTools companion on behalf of Copilot, which the
user did not directly request).

The reveal is entirely cmake-tools' responsibility - cmake-tools registers no Copilot/LM
surface; the companion drives builds via the exported build()/buildWithResult()/
ctestWithResult() API, which had no way to suppress the reveal.

Fix: classify each configure/build/test as user-initiated vs automatic/programmatic and only
suppress the proactive start reveal for automatic ones, gated by a new opt-in setting
cmake.revealLogOnAutomaticTrigger (default false, scope window). Explicit user-initiated
operations keep today's cmake.revealLog behavior, and build/configure/test failures always
surface regardless of the setting.

- src/logging.ts: extract pure decideReveal() helper; showChannel() takes an isAutomatic flag
  and reads cmake.revealLogOnAutomaticTrigger.
- src/cmakeProject.ts: add isAutomaticConfigureTrigger(); thread isAutomatic through
  runBuild/build/ctest; classify the configure-start reveal by ConfigureTrigger.
- src/ctest.ts: thread isAutomatic into runCTest's reveal.
- src/api.ts: mark build/buildWithResult/ctestWithResult as programmatic (isAutomatic=true).
- package.json/package.nls.json/docs/cmake-settings.md/CHANGELOG.md: new setting.
- test/unit-tests/backend/revealLog.test.ts: manifest guard + decideReveal and
  isAutomaticConfigureTrigger decision-matrix tests.
hanniavalera added a commit that referenced this pull request Jun 24, 2026
…en the build terminal promptly

Two adjustments to the colorized build-output reveal work, in anticipation of the
cmake.revealLogOnAutomaticTrigger PR (#4988 / #4989) merging first:

Layer on #4988 instead of diverging from it:
- Align logging.ts `decideReveal` and `Logger.showChannel` to the exact shape used by
  #4988 (`{ shouldShow, preserveFocus }`), so when that PR merges there is a single shared
  implementation rather than two competing ones. `revealLogDecision` remains the only
  colorization-specific addition: a thin wrapper that maps `decideReveal` to the
  `{ show, focus }` shape the colorized terminal reveal consumes. `isAutomaticConfigureTrigger`,
  the isAutomatic threading, the API marking, and the setting itself are unchanged and already
  match #4988. Updated the backend test to the aligned shape and added coverage for the
  revealLogDecision mapping.

Open the CMake Build terminal promptly (bug fix):
- Previously the colorized terminal was only created and revealed once the build actually
  started, which happens after the pre-build configure. With a fresh kit/preset (e.g. gcc) the
  first configure is slow, so the user was left looking at configuration progress with no
  terminal. Now the terminal is opened and revealed before the pre-build configure (showing a
  brief "Preparing build…"), gated on the same reveal decision so automatic/programmatic builds
  still stay quiet. Adds prepareForConfigure() to the build sink (terminal and the portability
  Output-channel sink).
hanniavalera added a commit that referenced this pull request Jun 24, 2026
…en the build terminal promptly

Two adjustments to the colorized build-output reveal work, in anticipation of the
cmake.revealLogOnAutomaticTrigger PR (#4988 / #4989) merging first:

Layer on #4988 instead of diverging from it:
- Align logging.ts `decideReveal` and `Logger.showChannel` to the exact shape used by
  #4988 (`{ shouldShow, preserveFocus }`), so when that PR merges there is a single shared
  implementation rather than two competing ones. `revealLogDecision` remains the only
  colorization-specific addition: a thin wrapper that maps `decideReveal` to the
  `{ show, focus }` shape the colorized terminal reveal consumes. `isAutomaticConfigureTrigger`,
  the isAutomatic threading, the API marking, and the setting itself are unchanged and already
  match #4988. Updated the backend test to the aligned shape and added coverage for the
  revealLogDecision mapping.

Open the CMake Build terminal promptly (bug fix):
- Previously the colorized terminal was only created and revealed once the build actually
  started, which happens after the pre-build configure. With a fresh kit/preset (e.g. gcc) the
  first configure is slow, so the user was left looking at configuration progress with no
  terminal. Now the terminal is opened and revealed before the pre-build configure (showing a
  brief "Preparing build…"), gated on the same reveal decision so automatic/programmatic builds
  still stay quiet. Adds prepareForConfigure() to the build sink (terminal and the portability
  Output-channel sink).
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.

[Bug] CMake Tools output window steals the focus when a build is done (by the user or Copilot)

1 participant