Skip to content

fix(core): reject open() on system teardown via cancelAll#30

Merged
SutuSebastian merged 3 commits into
mainfrom
fix/layer-cancelled-error
Jul 19, 2026
Merged

fix(core): reject open() on system teardown via cancelAll#30
SutuSebastian merged 3 commits into
mainfrom
fix/layer-cancelled-error

Conversation

@SutuSebastian

@SutuSebastian SutuSebastian commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add LayerCancelledError / isLayerCancelledError and LayerStack/LayerClient.cancelAll for system teardown (Query-style cancel reject)
  • Parent-dismiss child drain, layer-group dispose, Lit disconnect, and Devtools clear-without-response use cancelAll instead of dismissAll(undefined)
  • dismissAll(response) still resolves with R (void stays unambiguous)

Breaking note

Apps that awaited child/group open() through parent dismiss or group unmount previously got undefined. They now reject with LayerCancelledError — narrow with isLayerCancelledError and do not treat cancel as user “No”.

Test plan

  • bun test layerStack / layerGroup / live-actions cancel paths
  • Pre-commit typecheck + unit/DOM across touched packages
  • docs:check --isolated
  • CI green

Summary by CodeRabbit

  • New Features

    • Added cancelAll support for clearing layer stacks.
    • Layer openings now reject with LayerCancelledError when cancelled during teardown, parent dismissal, group disposal, or disconnect.
    • Added cancellation reasons and isLayerCancelledError for handling cancellation safely.
    • User-driven dismissals continue resolving with their response values.
  • Documentation

    • Updated API references and guides to explain cancellation, blockers, nested layers, and error handling.

Add LayerCancelledError and cancelAll so parent-dismiss drains, group dispose, and host disconnect reject callers instead of resolving undefined. dismissAll(response) still completes with R.
@SutuSebastian SutuSebastian added the docs Merged PRs with this label deploy the /layers docs site label Jul 19, 2026
@changeset-bot

changeset-bot Bot commented Jul 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a31df36

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@stainless-code/layers Patch
@stainless-code/react-layers Patch
@stainless-code/preact-layers Patch
@stainless-code/vue-layers Patch
@stainless-code/solid-layers Patch
@stainless-code/angular-layers Patch
@stainless-code/svelte-layers Patch
@stainless-code/alpine-layers Patch
@stainless-code/lit-layers Patch
@stainless-code/layers-devtools Patch
@stainless-code/react-layers-devtools Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@SutuSebastian, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 35 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f760074e-be20-44de-8161-e4bba60744c9

📥 Commits

Reviewing files that changed from the base of the PR and between def96f3 and a31df36.

📒 Files selected for processing (60)
  • .agents/skills/harden-pr/LEDGER.md
  • .changeset/layer-cancelled-error.md
  • apps/docs/content/concepts/identity-and-types.mdx
  • apps/docs/content/examples/nested-confirm.mdx
  • apps/docs/content/guides/awaiting-results.mdx
  • apps/docs/content/guides/devtools.mdx
  • apps/docs/content/guides/nested-overlays.mdx
  • apps/docs/content/integrations/base-ui/index.mdx
  • apps/docs/content/integrations/react-aria/index.mdx
  • apps/docs/islands/BlockersForceExample.tsx
  • apps/docs/islands/HeroDemo.tsx
  • apps/docs/islands/NestedConfirmExample.tsx
  • apps/docs/recipes/blockers-force/angular.ts
  • apps/docs/recipes/blockers-force/preact.tsx
  • apps/docs/recipes/blockers-force/react.tsx
  • apps/docs/recipes/blockers-force/react.wiring.tsx
  • apps/docs/recipes/blockers-force/solid.tsx
  • apps/docs/recipes/blockers-force/svelte-runes.svelte
  • apps/docs/recipes/blockers-force/svelte-store.svelte
  • apps/docs/recipes/blockers-force/vue.vue
  • apps/docs/recipes/nested-confirm/angular.ts
  • apps/docs/recipes/nested-confirm/preact.tsx
  • apps/docs/recipes/nested-confirm/react.baseui.tsx
  • apps/docs/recipes/nested-confirm/react.rac.tsx
  • apps/docs/recipes/nested-confirm/react.tsx
  • apps/docs/recipes/nested-confirm/react.wiring.tsx
  • apps/docs/recipes/nested-confirm/solid.tsx
  • apps/docs/recipes/nested-confirm/svelte-runes.svelte
  • apps/docs/recipes/nested-confirm/svelte-store.svelte
  • apps/docs/recipes/nested-confirm/vue.vue
  • docs/architecture.md
  • packages/alpine/src/index.ts
  • packages/angular/skills/angular-layers/SKILL.md
  • packages/angular/src/index.ts
  • packages/core/skills/layers/SKILL.md
  • packages/core/src/errors.ts
  • packages/core/src/layerClient.ts
  • packages/core/src/layerGroup.test.ts
  • packages/core/src/layerGroup.ts
  • packages/core/src/layerStack.test.ts
  • packages/core/src/layerStack.ts
  • packages/core/src/types.ts
  • packages/devtools/src/components/StackActions.tsx
  • packages/devtools/src/index.ts
  • packages/devtools/src/live-actions.test.ts
  • packages/devtools/src/live-actions.ts
  • packages/devtools/src/production.ts
  • packages/lit/src/index.test.ts
  • packages/lit/src/index.ts
  • packages/preact/skills/preact-layers/SKILL.md
  • packages/preact/src/index.ts
  • packages/react/skills/react-layers/SKILL.md
  • packages/react/src/index.tsx
  • packages/solid/skills/solid-layers/SKILL.md
  • packages/solid/src/index.ts
  • packages/svelte/skills/svelte-layers/SKILL.md
  • packages/svelte/src/index.ts
  • packages/svelte/src/store.ts
  • packages/vue/skills/vue-layers/SKILL.md
  • packages/vue/src/index.ts
📝 Walkthrough

Walkthrough

Adds cancelAll to layer clients and stacks, introducing LayerCancelledError for rejected pending opens. Parent dismissal, group disposal, host disconnect, and devtools teardown now use reasoned cancellation while user dismissal continues to resolve normally.

Changes

Layer cancellation semantics

Layer / File(s) Summary
Cancellation contract and stack execution
packages/core/src/errors.ts, packages/core/src/index.ts, packages/core/src/types.ts, packages/core/src/layerStack.ts, packages/core/src/layerStack.test.ts
Adds cancellation reasons, error narrowing, public exports, stack-wide cancellation, blocker bypass, cleanup, notifications, and coverage for active and queued opens.
Cancellation orchestration and teardown integrations
packages/core/src/layerClient.ts, packages/*/src/*, packages/devtools/src/*, packages/core/src/layerGroup.test.ts
Routes parent cascades, group disposal, disconnect cleanup, and devtools force actions through cancelAll with explicit reasons.
API and lifecycle documentation
apps/docs/content/**, docs/**, packages/core/skills/layers/SKILL.md, .changeset/layer-cancelled-error.md
Documents cancellation APIs, rejection behavior, blocker handling, error narrowing, lifecycle semantics, and the patch release.
Estimated code review effort: 4 (Complex) ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant LayerClient
  participant LayerStack
  Caller->>LayerClient: open()
  LayerClient->>LayerStack: create active or queued layer
  LayerClient->>LayerStack: cancelAll(reason)
  LayerStack-->>Caller: reject with LayerCancelledError
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: system teardown now rejects open() via cancelAll in core.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/layer-cancelled-error

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Restore Dismiss all → dismissAll (resolve) and Force clear → cancelAll
(reject); tighten JSDoc/skills/docs and cancelAll fail-safety coverage.
Swallow isLayerCancelledError in nested/blocker demos; align createLayerGroup
and Alpine dispose docs; fail-safe drainChildStacks; lit rebind uses groupDispose.
@SutuSebastian
SutuSebastian merged commit 9d804c2 into main Jul 19, 2026
17 checks passed
@SutuSebastian
SutuSebastian deleted the fix/layer-cancelled-error branch July 19, 2026 10:40
@github-actions github-actions Bot mentioned this pull request Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Merged PRs with this label deploy the /layers docs site

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant