← Back to Pull requests

Boost the active OpenConsole host and associate its window QoS #20963

Closed
unknown closed this pull request without merging on Dec 01, 2026 23:38 UTC
View on GitHub
unknown unknown commented on Nov 25, 2026 00:59 UTC
Author

Summary of the Pull Request

Apply window-associated QoS and foreground scheduling boosts to the same list of root clients and OpenConsole hosts, following Terminal's existing pane/tab policy.

References and Relevant Issues

This is a separate, narrower alternative to https://github.com/microsoft/terminal/pull/20948. It does not modify that branch or PR.

  • SetAdditionalForegroundBoostProcesses

  • Windows Quality of Service
  • No issue is closed by this PR.

    Detailed Description of the Pull Request / Additional comments

  • Add ConptyDuplicateHostProcessHandle to obtain an owned host process handle with the rights needed for QoS and boost registration.

  • Retain that handle in ConptyConnection and expose it through HostProcessHandle() while the connection is connected. Failure to obtain it is logged without failing the connection.

  • Aggregate up to 32 process handles in the existing throttled update: each selected pane contributes its root client and OpenConsole host. Select panes in the current tab while focused and across all tabs while unfocused.

  • Pass the same array/count to TerminalTrySetWindowAssociatedProcesses and SetAdditionalForegroundBoostProcesses. Check support independently and skip pane collection when neither is available. The QoS wrapper has no capability query, so it is probed once with an empty list. Unsupported APIs do not block the supported one; failed supported operations remain retryable. Keep the per-window cache and update it when supported operations succeed.

  • Reuse the existing WIL GetProcAddressByFunctionDeclaration wrapper for the runtime API lookup.

  • Keep separate registration diagnostics: CalledNewQoSAPI for QoS and WindowProcessForegroundBoost for priority boosting, including the window, process count, and API result. Attempt to clear stale foreground membership if boost registration fails.
  • Windows applies and removes the scheduling boost as Terminal's top-level window becomes foreground or background. The window-associated QoS target is High/Important while focused and Medium while visible but unfocused, subject to Windows' classification rules. QoS and scheduling priority are separate.

    No enumeration of additional attached clients, shared-memory transport, input-request checks, environment flags, standalone console policy, process-priority-class changes, or UI-thread +1 are introduced. Existing root-client selection and the 100 ms debounce are retained. The selected root clients now receive explicit foreground registration alongside their hosts, using one shared 32-handle list.

    AI assistance was used for implementation and validation. The contributor supplied the original host/focus/QoS design and confirmed personal review and application testing during implementation. The shared process list and independent API support follow subsequent maintainer guidance.

    Validation Steps Performed

    Release x64 build during implementation:

    & $env:ComSpec /d /c 'call "C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Auxiliary\Build\vcvars64.bat" >nul && msbuild "C:\Work\terminal\OpenConsole.slnx" "/t:Conhost\Host_EXE;Conhost\winconptydll;Conhost\winconpty_FeatureTests;Terminal\TerminalApp" /p:Configuration=Release /p:Platform=x64 /m:2 /nologo /v:minimal'
    

    Passed, after restoring the test dependency required by the updated main branch:

    & "C:\Work\terminal\dep\nuget\nuget.exe" restore "C:\Work\terminal\dep\nuget\packages.config" -PackagesDirectory "C:\Work\terminal\packages" -NonInteractive -Verbosity quiet
    

    Passed.

    Focused regression command, rerun before publication from C:\Work\terminal\bin\x64\Release:

    & "C:\Work\terminal\packages\Microsoft.Taef.11.0.260925001\build\Binaries\x64\te.exe" ".\winconpty.Feature.Tests.dll" "/name:*ConPtyTests*"
    

    Passed: 10 existing tests, 0 failed, rerun after the reviewer-requested cleanup. The added handle-duplication test was removed; the test suite no longer calls the foreground-boost API.

    git -c core.whitespace=cr-at-eol diff --check
    

    Passed.

    A local ETW comparison showed the rebuilt Terminal-hosted OpenConsole receiving foreground-boost transitions and Important QoS while its Terminal was focused, with MediumImportant observed in a background interval. This is diagnostic evidence, not a claim of measured typing-latency improvement or a fixed numerical priority. Multiple-pane/reparenting, unsupported-OS, and permission-restricted handoff scenarios have not been comprehensively validated.

    Latest shared-list/support update: Release x64 compilation/linking and unpackaged runtime refresh passed with:

    & $env:ComSpec /d /c 'call "C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Auxiliary\Build\vcvars64.bat" >nul && msbuild "C:\Work\terminal\src\cascadia\WindowsTerminal\WindowsTerminal.vcxproj" "/t:Build;_WTPrepareUnpackagedLayoutForRun" /p:SolutionDir=C:\Work\terminal\ /p:Configuration=Release /p:Platform=x64 /m:2 /nologo /v:minimal "/flp:logfile=C:\Users\hanemati\.copilot\session-state\6cf84a44-63f1-4f16-b366-e454240539a5\files\shared-policy-runtime-build.log;verbosity=normal"'
    

    Verified that runtime OpenConsole, TerminalApp, and TerminalConnection hashes match the latest outputs. Formatting and whitespace checks passed. The existing ConPTY test results above predate this latest window-policy-only update; no new native boost-dependent test was added. Actual multi-pane focus/QoS transitions for this revision still require a fresh ETW capture.

    The existing building guide is unchanged. No settings schema changes are required.

    PR Checklist


  • Closes #xxx

  • Tests added/passed

  • Documentation updated

  • - If checked, please file a pull request on our docs repo and link it here: #xxx
  • Schema updated (if necessary)
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: DHowett Review duration: 9999m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #20963"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.5% · Safe to merge
    22.5%