Skip to content

test(core): add native watcher command reload test - #39216

Merged
kitlangton merged 2 commits into
v2from
command-watch-test
Jul 28, 2026
Merged

test(core): add native watcher command reload test#39216
kitlangton merged 2 commits into
v2from
command-watch-test

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

What

Adds the end-to-end native watcher integration test for command reload — the last unmet acceptance criterion on #37429. A real markdown file write must reach the live command registry through the full production chain: parcel native watcher → Config's watch topology → config.changes()isCommandSource filter → debounced reload → Command.Event.Updated.

The merged reload work (#39160, #39171, #39174, and the agent equivalent) is covered by deterministic tests that drive a mocked change feed (Config.testLayer + emitChange); none of them prove Config's real watch reconciliation actually observes command directories. The issue's original repro was a real Vim :saveas, so the end-to-end proof is the point.

Closes #37429.

How

  • packages/core/test/config/command.test.ts: new describeNative block (gated on Watcher.hasNativeBinding() && !process.env.CI, matching the existing live watcher suites) building the real Command + Config + Bus + FSUtil node graph with the default native Watcher — no watcher replacement. Covers create and edit, each awaited through a Command.Event.Updated bus barrier.
  • watchReady helper: native directory watches start asynchronously, so the test probes the global config root with unrelated files until config.changes() delivers, guaranteeing later command edits cannot be missed. Probe files don't match isCommandSource and don't change the discovered config, so they cause no spurious reloads.
  • packages/core/test/fixture/config-nodes.ts: emptyCredentialNode / emptyWellknownNode stubs extracted from config.test.ts (now shared by both test files).

Scope

  • Test-only; no runtime changes.
  • Configured local plugin source watching remains out of scope (needs the versioned-source design).

Testing

From packages/core:

  • bun run test test/config/command.test.ts — 8/8, including the new native test; the native test passed 5/5 consecutive runs.
  • bun run test test/config/config.test.ts — 27/27 (fixture extraction).
  • bun typecheck — clean.

Flow

sequenceDiagram
    participant T as Test
    participant FS as Real filesystem
    participant W as Parcel watcher
    participant C as Config
    participant P as ConfigCommandPlugin
    participant R as Command registry

    T->>FS: probe writes until watch is live
    W-->>C: probe event → changes() delivers (ready)
    T->>FS: write commands/review.md
    W-->>C: native event
    C-->>P: changes() → isCommandSource → debounce
    P->>R: reload
    R-->>T: Command.Event.Updated (read barrier)
    T->>R: get("review") → "Review native"
Loading

@kitlangton
kitlangton force-pushed the command-watch-test branch from 5cfa3ce to 078e4a4 Compare July 28, 2026 00:57
@kitlangton
kitlangton merged commit 775f24f into v2 Jul 28, 2026
7 checks passed
@kitlangton
kitlangton deleted the command-watch-test branch July 28, 2026 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant