Skip to content

fix(scripts): hide the console window for team scripts on Windows - #1845

Merged
SaulMoro merged 2 commits into
Tencent:mainfrom
Walternater:fix/windows-team-script-console
Nov 12, 2026
Merged

SaulMoro merged 2 commits into
Tencent:mainfrom
Walternater:fix/windows-team-script-console

Conversation

@Walternater

@Walternater Walternater commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

prePull, postPull, postInit and postDeploy all run through one of two spawnScript helpers, and neither passed windowsHide. When the pull is started by a git hook (post-merge → git-pull, or session start) there is no terminal, so Windows opens a console window for every team script and keeps it open for the script's whole runtime — the 4–13 s empty window reported in #1805.

Both helpers now set windowsHide: true. Nothing about stdio changes: a prompted script still inherits the caller's stdio, so a member who launched teamai pull from a terminal sees exactly what they saw before; only the extra window is gone.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Real-CLI record

Build: Build 65805f8e66ff, teamai 0.22.0, sha256 beba71b8159d (verify world 20261112T083814-e18d6b, macOS arm64, Node v24.13.0).

The team repo declares scripts.postPull.path: scripts/postpull.mjs; the script prints one line to stdout and writes a marker file.

$ npm run verify:world
20261112T083814-e18d6b

$ npm run -s verify -- teamai 20261112T083814-e18d6b init https://teamai.test/team/repo.git --provider git --agent claude
✔ teamai initialized successfully!

# 1. the terminal-driven pull: fire-and-forget, output on the caller's terminal
$ npm run -s verify -- sh 20261112T083814-e18d6b bash -lc "printf 'hello-from-term\n' | teamai pull --verbose"
[debug] postPull: launched path=.../team-repo/scripts/postpull.mjs budget=90s (unawaited, terminal attached)
POSTPULL-RAN stdin=""

# 2. the hook-driven pull: awaited under the budget, same script, same exit
$ npm run -s verify -- sh 20261112T083814-e18d6b bash -lc "TEAMAI_GIT_HOOK=post-merge teamai pull --silent"
$ tail ~/.teamai/debug.log
[DEBUG] postPull: launched path=.../team-repo/scripts/postpull.mjs budget=90s
[DEBUG] postPull: exited 0 in 29ms

$ npm run -s verify -- ledger 20261112T083814-e18d6b
Ledger: CLEAN

Verdicts, named with the entry point:

  • VERIFIED — claude x git x workspace scope via teamai pull, terminal-driven: the script is launched with stdio: inherit and prints on the terminal, as before.
  • VERIFIED — same world, hook-shaped pull (TEAMAI_GIT_HOOK=post-merge, --silent, which is how hook-handlers.ts starts a pull): the script is awaited and exits 0 inside the existing budget.
  • UNVERIFIABLE — the Windows console window itself: no Windows machine here, so the observable this PR removes could not be watched. The other half of the claim (stdio, terminal behaviour, exit path) is covered above.

One correction to expectations: the interactive shape spawns with ['ignore', 'inherit', 'inherit'], so a postPull script does not receive stdin at all — stdin="" above is that design, unchanged by this PR. The script still prints to the terminal, which is what "behaves as before" means here.

The ledger needed one cleanup of mine: a self-mode init attempt had left a manual origin remote in the world's project, which showed up as 2 project/.git/config leaks. Removed, re-ran the ledger: CLEAN (the remaining known: lines are #1808, not new).

Test Plan

  • npx tsc --noEmit passes
  • npm run lint passes
  • npx vitest run src/__tests__/team-scripts.test.ts src/__tests__/post-pull.test.ts (20 tests)
  • Added/updated tests for the change
  • One representative real-CLI run in a verify world, recorded above

The three new assertions (prompted script, interactive postPull, in-process postPull) fail when the option is removed — deleting windowsHide: true from both helpers made 3 tests fail; restored, they pass.

Related Issues

Fixes #1805

Notes for Reviewers

  • fix(windows): keep background work alive and hide every child process window #1775 enables teamai/windows-hide as an error, and its diff does not touch these two helpers; this change is what keeps that rule green once both land.
  • The interactive shapes keep stdio: inherit, so hiding the window does not take the terminal away from a prompted script — the child reads and writes the handles it already had. It only stops a hook-launched pull from creating a console.
  • The CHANGELOG entry is under Unreleased → 🐛 Bug Fixes.

Disclosure

This PR was written with AI assistance: DeepSeek Harness (deepseek-v4.1-flash) drafted the change, the tests and this description.

I am wangchongfei. I reviewed every line of this diff and ran the checks above myself before opening it. I take full responsibility for the change.

I am stating this here, and on my profile, because a maintainer should know who — and what — they are reviewing.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This was generated by AI during triage.

The change is right. Both spawnScript helpers (src/post-pull.ts and src/team-scripts.ts) now pass windowsHide: true and leave stdio alone, so a prompted script still gets the caller's terminal. The new assertions cover the prompted, interactive and in-process shapes.

[P1 blocking] No real-CLI record. This changes runtime behaviour, and the description has only unit tests. The repo asks for one representative real-CLI run of the changed behaviour in a verify world (npm run verify:world; npm run -s verify -- help). Ideally that's on Windows: a pull started the way #1805 describes, from post-merge or session start, with a postPull script that sleeps a few seconds, and no console window opening. If you have no Windows machine, a run on macOS or Linux still covers the other half of the claim, and you should say Windows wasn't run. The run would show:

  • teamai pull from a terminal with a prompted postPull script that reads input and prints, behaving exactly as before;
  • a hook-started pull running the script.

[P3 nit] The two comments mostly restate the fix. If you keep one, it only needs the Windows quirk, for example "Windows opens a console for a child of a process without one."

@github-actions

Copy link
Copy Markdown
  • [P1 blocking] Missing real-CLI verification record — src/team-scripts.ts:251 and src/post-pull.ts:152 change runtime behavior, but the PR description records only type checking, lint, and unit tests. The Code Review Rules require an end-to-end / real-CLI verification record for runtime changes. Run one representative scenario in a verify world and add the result to the PR description; a full tool × provider matrix is not required.

No other confident findings in the specified diff. No earlier findings were supplied.

@github-actions

Copy link
Copy Markdown
  • [P1 blocking] Missing real-CLI verification record — src/team-scripts.ts:251 and src/post-pull.ts:151 change runtime behavior, but the PR description records only type checking, lint, and unit tests. The Code Review Rules require a representative end-to-end / real-CLI run in a verify world. Add that verification record; a full tool × provider matrix is unnecessary. This earlier finding remains unresolved.

No other confident findings in the specified diff.

@Walternater

Copy link
Copy Markdown
Collaborator Author

Real-CLI record added to the description, and the P3 nit is applied in 65805f8.

  • VERIFIED — terminal-driven teamai pull in a verify world: the script is launched (unawaited, terminal attached) and prints on the caller's terminal.
  • VERIFIED — the same world with a hook-shaped pull (TEAMAI_GIT_HOOK=post-merge, --silent, the way hook-handlers.ts starts one): postPull: exited 0 in 29ms under the existing budget.
  • UNVERIFIABLE — the Windows console window itself: no Windows machine here, so the observable this PR removes could not be watched.

One thing the record corrected for me: the interactive shape spawns with ["ignore", "inherit", "inherit"], so a postPull script never receives stdin — stdin="" in the log is that design, unchanged here. What a member sees is the script's output on their terminal, and that still works.

Ledger: CLEAN (after removing an origin remote a failed self-mode init of mine had left in the world; the remaining known: lines are #1808).

prePull, postPull, postInit and postDeploy are started through one of two
spawnScript helpers, and neither passed windowsHide. A pull started by a git
hook has no terminal, so Windows created a console window for each script and
kept it open for the whole run (Tencent#1805).

Both helpers now set windowsHide: true. The child still inherits whatever
stdio the caller passed, so a prompted run shows its output where it did
before; only the extra window goes.

Tests assert the option on both shapes (prompted and in-process); each fails
with the option removed.

Refs Tencent#1805
Review nit: the two comments restated the fix. One line each now says only
what a reader cannot derive from `windowsHide: true` (Tencent#1805).

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This was generated by AI during triage.

Thanks, that covers it. The record shows:

  • a terminal-driven pull: the script is launched with the terminal attached and its output reaches it;
  • a hook-shaped pull (TEAMAI_GIT_HOOK=post-merge, --silent): the script is awaited and exits 0 within the budget.

The verify world ends CLEAN, and you say plainly that the Windows window itself wasn't observed. The comment is down to the Windows quirk. Approving at 65805f8e.

@Walternater
Walternater force-pushed the fix/windows-team-script-console branch from 65805f8 to f1d0141 Compare November 12, 2026 08:48
@github-actions

Copy link
Copy Markdown

No confident findings in the specified diff.

The earlier [P1 blocking] missing real-CLI verification record finding is resolved: the current PR description records representative terminal-driven and hook-shaped pulls in a verify world, with a clean ledger.

The Windows console behavior remains explicitly unverified, but that disclosed platform limitation does not block merge under the review rules. No PR code was run, built, or installed.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This was generated by AI during triage.

Re-approving at f1d0141a. It is the same change rebased onto main.

@SaulMoro
SaulMoro merged commit e4f5ab2 into Tencent:main Nov 12, 2026
20 checks passed
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] Windows: prePull/postPull team scripts open visible console windows

3 participants