Skip to content

Commit 4226cd2

Browse files
committed
Merge main and address hook-routing review findings
Preserve upstream lifecycle, cancellation and settings changes while retaining master-owned hook routing. Resolve the event-dispatch conflict using consistent LF endings. Reconcile shell prompts in the ordered master COM stream so a helper exit cannot overtake a queued birth. Preserve exponential retry delays across unstable subscriptions and measure stability only after readiness. Count all E2E processing records and require currently subscribed helper listeners. Allocate fresh hook checklist IDs C296-C298 without changing upstream IDs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: c6ef3e46-71af-4e5a-82af-a172700ca3ce
2 parents 21f7843 + efd10cf commit 4226cd2

420 files changed

Lines changed: 31268 additions & 15327 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/skills/pr-integration-test/SKILL.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ checklist.
2020

2121
- Read `test/e2e/README.md` and reuse the ItE2E framework instead of creating a
2222
parallel harness.
23+
- Treat the source revision and deployed package as separate decisions. For a
24+
PR, test the intended PR head/feature-branch revision through a Dev build by
25+
default; a previously installed Dev package is not proof that the PR code ran.
26+
- Before running any live integration test, identify the target package from
27+
the user's request. If the user did not explicitly choose **Dev** or
28+
**Store/production**, use `ask_user` and wait for the answer. In a PR context,
29+
make **Dev built from the PR head/feature branch** the recommended/default
30+
choice. Never select a package solely from installed-package discovery.
31+
- Use Store only when the user explicitly asks to test the production/shipped
32+
build. Store results establish a production baseline; they do not validate
33+
unshipped changes in the PR.
34+
- Pin the chosen package through `$env:ITE2E_PACKAGE = 'Dev'` or
35+
`$env:ITE2E_PACKAGE = 'Store'` for every live validation command.
2336
- Run `pwsh -File test/e2e/bootstrap.ps1 -Check` before live E2E validation.
2437

2538
## Workflow
@@ -73,12 +86,20 @@ Do not call the work complete until all of these are true:
7386

7487
- Pre-fix evidence identifies the regression, and the fixed path crosses the
7588
real integration boundary.
89+
- For PR validation against Dev, the tested package is proven to contain the
90+
intended PR head/feature-branch revision.
7691
- Relevant false positives, replay risks, and existing behavior are covered.
7792
- The correct build passes related suites and marks new checklist IDs `[x]`;
7893
every skip is explained.
7994

8095
## Gotchas
8196

97+
- **Never run a live integration test with an implicit or `Auto` package
98+
selector.** Ask first, then pin `ITE2E_PACKAGE`. Installed-package discovery
99+
cannot establish user intent or prove that a Dev package contains PR code.
100+
- **Do not use Store to validate a PR's unshipped code.** Prefer a Dev package
101+
built and deployed from the PR head/feature branch. Use Store only for an
102+
explicitly requested production baseline and label the result accordingly.
82103
- **Do not test only the implementation detail named in the PR.** Reconstruct
83104
the end-to-end user path and assert the observable contract.
84105
- **Do not duplicate a unit test at E2E level.** Add the missing process,

.github/skills/pr-integration-test/references/workflow.md

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ Choose the branch deliberately:
3434
Verify merge state and a clean worktree before deleting a branch. Squash-merged
3535
branches may require `git branch -D` because Git cannot infer ancestry.
3636

37+
Record the exact revision whose behavior should be validated. For an open PR,
38+
prefer the PR head/feature branch, or a validation branch created from that
39+
head. Do not test an unrelated installed Dev package and describe the result as
40+
PR validation.
41+
3742
## 2. Reconstruct the Behavioral Contract
3843

3944
Describe the full path as components and observable handoffs:
@@ -165,16 +170,30 @@ Update the suite table in `test/e2e/README.md` when adding a new feature file.
165170

166171
## 7. Validate Tests and Report Mapping
167172

173+
Before any live command, resolve the package target:
174+
175+
- If the user explicitly requested Dev or Store/production, use that choice.
176+
- Otherwise call `ask_user` with exactly those choices and wait.
177+
- In a PR context, label Dev as **built from the PR head/feature branch**, make
178+
it the recommended/default choice, and explain that Store is the currently
179+
installed production baseline. Outside a PR context, do not infer a choice.
180+
- Use Store only when the user explicitly selects production. A Store run
181+
compares against shipped behavior; it cannot validate unshipped PR code.
182+
- Set `$env:ITE2E_PACKAGE = 'Dev'` or `'Store'` in the same PowerShell process
183+
that invokes the test runner.
184+
168185
Verify prerequisites:
169186

170187
```powershell
188+
$env:ITE2E_PACKAGE = 'Dev' # or 'Store', as explicitly selected
171189
pwsh -NoProfile -File test/e2e/bootstrap.ps1 -Check
172190
```
173191

174192
Run the new suite through the report driver:
175193

176194
```powershell
177195
$suite = 'test/e2e/tests/Feature.AutofixParser.Tests.ps1'
196+
$env:ITE2E_PACKAGE = 'Dev' # or 'Store', as explicitly selected
178197
pwsh -NoProfile -File test/e2e/Invoke-ItE2EReport.ps1 `
179198
-Path $suite `
180199
-UpdateReport
@@ -216,11 +235,17 @@ regressions or the PR changes common harness/product infrastructure.
216235

217236
## 8. Prove the Correct Build Ran
218237

219-
Build and deploy the changed area. For WTA changes, build the explicit target
220-
matching the package architecture before the C++ package, deploy it, select it
221-
with `ITE2E_PACKAGE` or `-Package Dev`, and verify a runtime version, path, log,
222-
or changed observable. Compilation alone does not prove the deployed package
223-
contains the new `wta.exe` or generated shell integration.
238+
For PR validation, check out the intended PR head/feature-branch revision,
239+
record its commit, then build and deploy the changed area into the Dev package.
240+
Verify a runtime version, path, log, or changed observable that ties the
241+
deployed package to that revision. A previously installed Dev package or a
242+
successful compilation does not prove the PR code ran.
243+
244+
For WTA changes, build the explicit target matching the package architecture
245+
before the C++ package, deploy it, select it with `ITE2E_PACKAGE=Dev`, and prove
246+
the deployed package contains the refreshed `wta.exe` and generated shell
247+
integration. Do not substitute a Store run unless the user explicitly asked for
248+
a production baseline.
224249

225250
## 9. Deliver the Test PR
226251

.github/workflows/winget.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ jobs:
1515
runs-on: windows-latest # Action can only run on Windows
1616
if: ${{ !github.event.release.prerelease }} # Only publish stable releases to WinGet
1717
steps:
18+
- name: Sync winget-pkgs fork with upstream
19+
continue-on-error: true # wingetcreate also attempts a sync; don't fail the run on a transient API error
20+
env:
21+
GH_TOKEN: ${{ secrets.WINGET_TOKEN }}
22+
run: |
23+
# wingetcreate can only fast-forward a fork that is not too far behind upstream.
24+
# A fork left untouched between releases falls thousands of commits behind and the
25+
# submit step then fails with "The forked repository could not be synced with the
26+
# upstream commits." Sync it up front so wingetcreate always sees a current fork.
27+
$owner = (gh api user --jq '.login')
28+
Write-Host "Syncing $owner/winget-pkgs with microsoft/winget-pkgs..."
29+
$branch = (gh api "repos/$owner/winget-pkgs" --jq '.default_branch')
30+
Write-Host "Default branch is $branch"
31+
gh api -X POST "repos/$owner/winget-pkgs/merge-upstream" -f branch=$branch
32+
1833
- name: Publish Intelligent Terminal
1934
run: |
2035
$assets = '${{ toJSON(github.event.release.assets) }}' | ConvertFrom-Json

build/scripts/Verify-AgentHooks.ps1

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
supported agent CLIs (Copilot, Claude, Gemini, Codex).
66
77
.DESCRIPTION
8-
Wrapper around `wta hooks status --json` / `wta install-hooks` /
9-
`wta hooks uninstall --json`. Same JSON contract that the Settings
10-
UI's "AI agents → Agent Hooks" section consumes — so the script and
11-
the UI can never disagree about install state.
8+
Wrapper around `wta hooks status --json` / `wta hooks install` /
9+
`wta hooks uninstall --json`. Uses the JSON contracts defined in
10+
tools/wta/src/agent_hooks_installer.rs for status and diagnostics.
1211
1312
Internals are factored into named functions
1413
(Resolve-WtaPath, Get-AgentHooksStatus, Format-AgentHooksTable,
@@ -20,7 +19,7 @@
2019
.PARAMETER Mode
2120
Check — print a colored status table and exit non-zero if any CLI
2221
is in an inconsistent state.
23-
Install — run `wta install-hooks`, then run Check.
22+
Install — run `wta hooks install`, then run Check.
2423
Uninstall— run `wta hooks uninstall --cli=<filter> --json`, then Check.
2524
2625
.PARAMETER CliFilter
@@ -73,8 +72,7 @@ $ErrorActionPreference = 'Stop'
7372
Set-StrictMode -Version Latest
7473

7574
# Schema version this script understands. Mirrors STATUS_SCHEMA_VERSION
76-
# in tools/wta/src/agent_hooks_installer.rs and SupportedStatusSchemaVersion
77-
# in src/cascadia/inc/AgentHooksStatus.h. Bump in lockstep.
75+
# in tools/wta/src/agent_hooks_installer.rs. Bump in lockstep.
7876
$script:SupportedStatusSchemaVersion = 4
7977

8078
$script:CliDisplayNames = @{
@@ -350,10 +348,10 @@ function Invoke-HooksInstall {
350348
param([Parameter(Mandatory)][string]$WtaPath)
351349

352350
Write-Host ''
353-
Write-Host '→ Running: wta install-hooks' -ForegroundColor Cyan
354-
& $WtaPath install-hooks
351+
Write-Host '→ Running: wta hooks install' -ForegroundColor Cyan
352+
& $WtaPath hooks install
355353
if ($LASTEXITCODE -ne 0) {
356-
throw "wta install-hooks exited with code $LASTEXITCODE"
354+
throw "wta hooks install exited with code $LASTEXITCODE"
357355
}
358356
}
359357

doc/faq.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ The package manifest sets `MinVersion="10.0.19041.0"` (Windows 10, version 2004)
1919

2020
## 3. I installed a new agent CLI after the FRE — why isn't it tracked in agent session management?
2121

22-
You completed the FRE with one agent (say, Copilot), then later installed Claude or Codex (or another bring-your-own ACP-compatible CLI) and switched the **agent pane** to it in Settings. The agent pane may not work, or **agent session management** doesn't track its sessions.
22+
You completed the FRE with one agent (say, Copilot), then later installed Claude or Codex and switched the **agent pane** to it in Settings.
2323

24-
The FRE only sets up the session-tracking hooks for the agents you went through it with. Agents installed *after* the FRE need a one-time manual setup. (The ACP wrapper itself is auto-fetched on demand via `npx`, so there is no wrapper "install" to run — see [Step 3.2.3](./installing-dependencies.md#step-323--acp-wrapper-no-install-action-required) / [Step 3.3.3](./installing-dependencies.md#step-333--acp-wrapper-no-install-action-required) — but you do need to make sure the prerequisites the wrapper depends on are in place.)
24+
The FRE installs session-tracking hooks only for the agent selected there. With **Session management** enabled, Intelligent Terminal automatically installs or updates hooks for newly detected built-in agents when `wta-master` starts and when you select a different built-in agent.
2525

26-
**Workaround:**
26+
If the new agent is not tracked:
2727

2828
1. **Make sure the prerequisites are in place.** Follow the steps in [`installing-dependencies.md`](./installing-dependencies.md) that match your agent — install Node.js LTS and the agent's own CLI (via `npm install -g <package>`):
2929
- Claude: [Steps 3.2.1 – 3.2.3](./installing-dependencies.md#32-claude-code-bring-your-own) — Intelligent Terminal launches Claude through an ACP wrapper that is fetched automatically via `npx` on first launch.
3030
- Codex: [Steps 3.3.1 – 3.3.3](./installing-dependencies.md#33-openai-codex-bring-your-own) — same wrapper-via-`npx` pattern as Claude.
3131
- Gemini: [Section 3.4](./installing-dependencies.md#34-gemini-cli-bring-your-own) — Gemini speaks ACP natively, so no wrapper is needed; just install the CLI itself.
3232

33-
2. **Re-install the session-tracking hooks.** Open Intelligent Terminal **Settings → Agent**, scroll to the **Agent session tracking (hooks)** row ("Track sessions across agents. Required for agent session management."), expand it, and click the **Install hooks** button next to *Install agent hook script*. This wires the newly installed CLI into agent session management so its sessions show up in the panel.
33+
2. Open a fresh Intelligent Terminal window so the new CLI is on `PATH`, confirm **Settings → Agent → Sessions** is on, and select the new built-in agent. Automatic reconciliation runs in the background. For manual repair, run `wta hooks install --cli <agent>`.
3434

3535
## 4. Can I use a custom ACP-compatible agent (Qwen, Cline, Goose, Cursor, …)?
3636

doc/installing-dependencies.md

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,18 @@ up the new credentials.
337337
parallel conversations on the same tab — is powered by a small bundle of
338338
**agent hooks** (`wt-agent-hooks`) that the agent CLI loads as a plugin /
339339
extension. The first-run experience installs these hooks for you the
340-
first time you save the FRE with **Session management** enabled.
340+
first time you save the FRE with **Session management** enabled. FRE installs
341+
only the selected agent's hooks. After FRE, Intelligent Terminal automatically
342+
reconciles hooks at `wta-master` startup, when Session management changes from
343+
off to on, and when you select a different built-in agent.
341344

342345
You only need to follow this section if:
343346

344347
- The FRE reported that hooks installation failed (for example because
345348
the agent CLI was not yet on `PATH`, or your network blocked the agent
346349
CLI's plugin store).
347-
- You installed the agent CLI **after** completing the FRE and now want
348-
to enable session management.
350+
- Automatic reconciliation failed and you need to repair the installation
351+
manually.
349352

350353
#### Step 3.6.1 — Make sure the agent CLI is installed and on PATH
351354

@@ -362,13 +365,17 @@ sub-section above before continuing:
362365
Verify the CLI you intend to use prints a version number, then close and
363366
reopen your terminal so any new install directory is on `PATH`.
364367

365-
#### Step 3.6.2 — Run `wta hooks install`
368+
#### Step 3.6.2 — Let Intelligent Terminal reconcile hooks
366369

367-
Intelligent Terminal ships a `wta hooks install` command that runs the
368-
same installer the FRE uses. Open a **new** Intelligent Terminal window
369-
(so `wta` and the agent CLI both pick up the current `PATH`) and run
370-
**one** of the following — whichever matches the agent you selected in
371-
the FRE:
370+
Open a **new** Intelligent Terminal window so `wta-master` and the agent CLI
371+
pick up the current `PATH`. In **Settings → AI Agents**, turn **Sessions** on
372+
and select the installed built-in agent. Intelligent Terminal
373+
checks the agent asynchronously and installs missing hooks or upgrades stale
374+
ones.
375+
376+
If automatic reconciliation fails, `wta hooks install` remains the supported
377+
manual retry command. It applies the same smart reconciliation used by
378+
automatic triggers:
372379

373380
```powershell
374381
wta hooks install --cli copilot
@@ -384,8 +391,8 @@ Or install for every agent CLI that is currently on `PATH` in one go:
384391
wta hooks install
385392
```
386393

387-
Under the hood this runs each agent CLI's native plugin / extension
388-
command against the `wt-agent-hooks` bundle shipped inside the
394+
When reconciliation selects Install, it runs the agent CLI's native plugin /
395+
extension command against the `wt-agent-hooks` bundle shipped inside the
389396
Intelligent Terminal package:
390397

391398
| Agent | Native commands invoked by `wta hooks install` |
@@ -406,6 +413,17 @@ You do not need to run these directly — `wta hooks install` is the
406413
supported entry point and handles bundle staging, idempotency, and
407414
diagnostic logging for you.
408415

416+
If status looks healthy but the hooks still do not run, use the explicit
417+
force-recovery path:
418+
419+
```powershell
420+
wta hooks install --force --cli codex
421+
```
422+
423+
`--force` reruns the first-install flow even when the hook bridge already
424+
appears installed. Close running sessions for that agent first so its plugin
425+
manager cannot overwrite the registration while it is being repaired.
426+
409427
> [!IMPORTANT]
410428
> **Codex needs a one-time `/hooks` trust step.** After
411429
> `wta hooks install --cli codex` succeeds, hook events will not fire
@@ -414,7 +432,7 @@ diagnostic logging for you.
414432
> requirement that no external installer can satisfy on your behalf;
415433
> the other four CLIs do not need this step.
416434
417-
#### Step 3.6.3 — Verify the install and re-enable session management
435+
#### Step 3.6.3 — Verify the install
418436

419437
Check the status report to confirm each agent CLI is wired up:
420438

@@ -427,10 +445,7 @@ installed hook version (for example `v0.1.5`). When a CLI's hooks were
427445
registered by a different build, the row also names the version this
428446
Intelligent Terminal ships — `v0.1.4 (bundle v0.1.5)` means the CLI is
429447
loading older hooks and should be reinstalled with `wta hooks install`.
430-
Then, back in
431-
**Settings → AI Agents**, turn **Session management** back on (the FRE
432-
turns it off when hooks installation fails so you can save and continue
433-
without it) and restart Intelligent Terminal once.
448+
If Session management is off, turn it on to retry automatic reconciliation.
434449

435450
> [!TIP]
436451
> If `wta hooks install` still fails, diagnostics are written to
@@ -451,9 +466,9 @@ without it) and restart Intelligent Terminal once.
451466
> [!WARNING]
452467
> If your organization disables agent session hooks through Group
453468
> Policy, the **Session management** toggle in the FRE and in
454-
> **Settings → AI Agents** is locked off and the FRE will not run the
455-
> hooks installer for you. Contact your IT administrator if you
456-
> believe this is in error.
469+
> **Settings → AI Agents** is locked off and neither FRE nor automatic
470+
> reconciliation will run the hooks installer. Contact your IT administrator
471+
> if you believe this is in error.
457472
458473
---
459474

0 commit comments

Comments
 (0)