Skip to content

[Fix] Add GatewayDispatcher error-dedup and lifecycle-buffer tests - #563

Open
YuriNachos wants to merge 1 commit into
clawwork-ai:mainfrom
YuriNachos:YuriNachos/w3-clawwork
Open

[Fix] Add GatewayDispatcher error-dedup and lifecycle-buffer tests#563
YuriNachos wants to merge 1 commit into
clawwork-ai:mainfrom
YuriNachos:YuriNachos/w3-clawwork

Conversation

@YuriNachos

Copy link
Copy Markdown

Summary

Adds the first tests for the GatewayDispatcher error-display paths called out in
#227: isSameFailure (runId and code+source branches), shouldDisplayError
(incl. the DEDUP_FALLBACK_WINDOW_MS fallback), and the lifecycleErrorBuffer
2s buffer-and-clear behavior. No production code changes — test-only.

Type of change

  • [Fix] bug fix (test coverage for an existing untested error path; no behavior change)

Why is this needed?

The error-dedup and lifecycle-buffer logic in packages/core/src/services/gateway-dispatcher.ts
had zero tests (#227). A silent regression there means users either get spammed
with duplicate errors or see no errors at all. This locks down the behaviors that
decide whether an error reaches the user.

What changed?

  • New packages/core/test/gateway-dispatcher.test.ts (vitest). It drives the
    public createGatewayDispatcher via a harness that mirrors
    packages/desktop/test/gateway-dispatcher-subagent.test.ts and covers:
    1. isSameFailure suppresses a repeat with same taskId+code+source, and
      displays when the code differs;
    2. isSameFailure suppresses a repeat with same taskId+runId, and displays
      when the runId differs;
    3. shouldDisplayError shows the first error for a task, suppresses an
      identical repeat;
    4. the DEDUP_FALLBACK_WINDOW_MS (2000 ms) fallback suppresses a same
      rawMessage+source repeat inside the window and re-displays after it
      elapses (vi.useFakeTimers + advanceTimersByTime);
    5. the agent lifecycle error is buffered for 2000 ms then released as a system
      message, and is cleared when a chat error for the same task arrives first.

Architecture impact

  • Owning layer: core (test-only; no production code touched)
  • Cross-layer impact: none
  • Invariants touched: none — no behavior, signature, or visibility change
  • Why those invariants remain protected: only a new test file under
    packages/core/test/; dependency direction (shared ← core) and layer
    ownership are unchanged.

Linked issues

Fixes #227

Validation

  • pnpm lint (ran pnpm eslint on the new file — clean; full repo lint not run)
  • pnpm test (ran pnpm --filter @clawwork/core test — 117/117 green, incl. the 8 new tests)
  • pnpm build
  • pnpm check:ui-contract
  • Manual smoke test
  • Not run (full pnpm check not run: it stops at the repo's pre-existing
    format:check baseline red (~539 files) that reproduces on untouched main.
    The new file passes prettier --check, eslint, and the core test typecheck
    (tsc -p tsconfig.test.json — exit 0).)
$ pnpm --filter @clawwork/core test
 Test Files  7 passed (7)
      Tests  117 passed (117)

$ pnpm prettier --check packages/core/test/gateway-dispatcher.test.ts
All matched files use Prettier code style!

$ pnpm --filter @clawwork/core exec tsc -p tsconfig.test.json --noEmit   # clean
$ pnpm eslint packages/core/test/gateway-dispatcher.test.ts              # clean

First tests for the GatewayDispatcher error-display paths flagged in clawwork-ai#227: isSameFailure (runId and code+source branches), shouldDisplayError (incl. DEDUP_FALLBACK_WINDOW_MS fallback), and the lifecycleErrorBuffer 2s buffer-and-clear behavior. No production code changes.

Fixes clawwork-ai#227

Signed-off-by: Yurii Chukhlib <yurii.chukhlib@viber.com>
@YuriNachos
YuriNachos requested a review from samzong as a code owner August 8, 2026 14:49
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Hi @YuriNachos,
Thanks for your pull request!
If the PR is ready, use the /auto-cc command to assign Reviewer to Review.
We will review it shortly.

Details

Instructions for interacting with me using comments are available here.
If you have questions or suggestions related to my behavior, please file an issue against the gh-ci-bot repository.

@YuriNachos

Copy link
Copy Markdown
Author

/auto-cc

@github-actions
github-actions Bot requested a review from mvanhorn August 8, 2026 14:49
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.

[Enhancement] Add unit tests for GatewayDispatcher error handling logic

1 participant