Skip to content

fix(contrib/windows): the supervised bridge runs headless, not in a terminal tab - #121

Open
erwin-wee wants to merge 1 commit into
AltanS:mainfrom
erwin-wee:windows-headless-task
Open

fix(contrib/windows): the supervised bridge runs headless, not in a terminal tab#121
erwin-wee wants to merge 1 commit into
AltanS:mainfrom
erwin-wee:windows-headless-task

Conversation

@erwin-wee

Copy link
Copy Markdown

What

Register-CollieTask registers the supervised bridge as Execute = powershell.exe under an
Interactive principal. That allocates a real console, and on Windows 11 the default console host is
Windows Terminal — so the bridge that is meant to run in the background shows up as a tab titled
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe.

It isn't only cosmetic. The tab owns the launcher, so closing it kills the bridge; RestartCount 999
/ RestartInterval PT1M then brings both the bridge and the tab back about a minute later. From the
operator's side it reads as a terminal window that refuses to stay closed.

This wraps the same command in conhost.exe --headless, which runs it on a pseudoconsole with no
window at all.

Why this shape

  • The launcher doesn't move. conhost --headless execs powershell as its child, so the $PID
    that _exec-bridge writes to $script:PidFile is still the powershell process, the
    Contains($controlScript) / Contains("_exec-bridge") check in Stop-RecordedCollieProcesses
    still matches it, and taskkill /PID … /T /F still reaches bun through it. conhost exits with its
    child, so Task Scheduler's restart policy is unaffected.
  • Not -WindowStyle Hidden — the console is allocated before the script can hide it, so it
    flashes.
  • Not the task's Hidden setting — that hides the task from the Task Scheduler UI, not the
    window.
  • Not an S4U / session-0 principal. It would also remove the window, but it changes where the
    bridge runs; the Interactive principal is load-bearing for reaching Herdr's socket in the user
    session and resolving bun from the user's PATH.
  • Falls back to the previous bare action when conhost.exe is absent.

Verified on

Windows 11 Pro 26200, Windows Terminal 1.24, Herdr plugin herdr.collie, PowerShell 5.1 launcher.
Before: WindowsTerminal.exe → powershell.exe → bun.exe with a visible tab. After:
conhost.exe --headless → powershell.exe → bun.exe, no window handle on any process in the chain,
bridge reachable as usual. contrib\windows\collie-ctl.test.ps1 passes (OK Windows lifecycle tests); two assertions added for the wrap.

Notes

  • Per CLAUDE.md, no version bump and no CHANGELOG.md entry — fork PR. Suggested line if you want
    one: Fixed — Windows: the supervised bridge no longer opens a Windows Terminal tab (conhost --headless).
  • Happy to add an .adr/ entry if you think "why not -WindowStyle Hidden / S4U" is the kind of
    question that will come back; I left the reasoning as a comment at the registration site instead.

…erminal tab

Register-CollieTask set Execute=powershell.exe under an Interactive principal, which allocates a
real console. On Windows 11 the default console host is Windows Terminal, so the bridge that is
supposed to run in the background instead surfaces as a tab titled with the full powershell.exe
path — and closing that tab kills the bridge, after which the restart policy brings the tab
straight back a minute later.

Wrapping the same command in `conhost.exe --headless` gives it a pseudoconsole with no window.
Nothing else moves: the launcher is still the powershell child, so the PID that _exec-bridge
records in the pidfile and the command-line check in Stop-RecordedCollieProcesses both still see
what they expect, and taskkill /T reaches bun through it. Falls back to the bare action if
conhost.exe is missing.
@erwin-wee
erwin-wee force-pushed the windows-headless-task branch from 9c3c940 to 9f46026 Compare August 20, 2026 03:03
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.

1 participant