Skip to content

fix(#192): keep the Modal action pending state through a rejection - #193

Draft
lablup-quill[bot] wants to merge 7 commits into
mainfrom
fix/gh-192-modal-action-promise
Draft

lablup-quill[bot] wants to merge 7 commits into
mainfrom
fix/gh-192-modal-action-promise

Conversation

@lablup-quill

@lablup-quill lablup-quill Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #192

Summary

Modal and DeleteConfirmModal hold the action button pending while a promise returned from onAction is in flight: the generated action button's clickAction awaits the result (src/components/Modal/Modal.tsx). That part already works. The rejection path is what this PR adds.

  • Modal.tsx: the action button's clickAction catches a rejected onAction. This is not swallowing it quietly: a rejection left uncaught is not propagated to a caller. Astryx Button runs clickAction inside startTransition and chains the returned promise into the transition's finished state, so React rethrows the rejection during the render that would clear the pending state. Verified with a probe against React 19.3.1: the button stays aria-busy and disabled, and with no error boundary the subtree is unmounted — the modal disappears instead of staying open. Catching keeps the transition able to finish, so the pending state clears and the modal stays open, and the failure is reported through devError (the same channel Astryx uses for a plugin that throws), which reaches error telemetry. A caller that needs its own message catches it in onAction.
  • Modal.tsx / DeleteConfirmModal.tsx: the onAction JSDoc on both components states this contract, and the README says the same.
  • No prop type change: onAction stays () => unknown. Narrowing it to () => void | Promise<void> would reject a handler that returns a value (e.g. () => list.push(item) or async () => 3), a breaking change under CONTRIBUTING's versioning table; the JSDoc carries the promise contract instead.
  • Tests:
    • Modal: resolve clears the pending state (existing), reject clears it and leaves the modal open, isActionLoading still shows the pending state on its own, and repeated clicks while pending call onAction once.
    • DeleteConfirmModal: a pending promise shows the loading state, and repeated clicks dedupe.
  • CHANGELOG [Unreleased] Fixed entry.

Verification

pnpm run verify passes (2576 tests passed, 16 skipped).

Risk tier: High — src/components/DeleteConfirmModal/DeleteConfirmModal.test.tsx, src/components/DeleteConfirmModal/DeleteConfirmModal.tsx
Suggested human approvals: 2 (branch protection decides)

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

GitHub Pages may take up to a minute to hydrate after the deploy.

🧩 Changed Components

Component Changed Stories Open
DeleteConfirmModal source 8 Storybook ↗
Modal source 9 Storybook ↗

📦 Bundle Size

Group Gzip Δ Gzip vs base
components/Modal 5.1 kB +0.0 kB

Total gzip (JS + CSS): 220.4 kB (+0.0 kB vs origin/main)


Generated by the PR Preview workflow for 93e4089 · Storybook · CI run

github-actions Bot added a commit that referenced this pull request Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Preview published under the pr-193 dist-tag (npmjs): 0.2.1-pr-193-20261203134244-93e408945

pnpm add @lablup/ui-common@0.2.1-pr-193-20261203134244-93e408945
pnpm add -D @lablup/ui-common-cli@0.2.1-pr-193-20261203134244-93e408945

In backend.ai-webui: pnpm run ui-common:pin pr-193. A consumer PR pinned to a preview cannot merge; repin to canary after this PR merges.

@lablup-quill lablup-quill Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ready-gate agent review — 5 findings — 1 Important, 3 Nit, 1 Pre-existing. The summary comment on this PR lists every finding and its outcome.

Comment thread CHANGELOG.md Resolved
Comment thread src/components/Modal/Modal.test.tsx Resolved
Comment thread src/components/Modal/Modal.test.tsx Resolved
label={actionLabel ?? t("uic.common.ok")}
isLoading={isActionLoading ?? actionButtonProps?.isLoading}
isDisabled={isActionDisabled ?? actionButtonProps?.isDisabled}
clickAction={async () => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[Pre-existing]

Only this call site guards its clickAction; ConfirmPopover.tsx:158 and DataGridExportModal.tsx:210 (and any future one) still await a caller's promise bare, so they keep producing the same uncaught error this PR removes from Modal.

How to show it fails: Make ConfirmPopover's onAction or DataGridExportModal's onExport reject: React reports an uncaught error, exactly as Modal did before this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

needs-human — confirmed: ConfirmPopover.tsx:158 and DataGridExportModal.tsx:210 await a caller's promise in clickAction with no catch, so they keep the same uncaught-error path. Fixing them here (with tests), factoring a shared helper, or taking a follow-up is a scope call for the owner, so this thread stays open for that decision.

Comment thread src/components/Modal/Modal.tsx Resolved
@lablup-quill

lablup-quill Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor Author

4 findings — 1 Important, 3 Nit, 0 Pre-existing

Round 2 — d6259d9

# Tag File:line Finding Outcome
1 Nit README.md:364 The docs say the button "returns to rest" on rejection, which is false when the caller drives the button with isActionLoading: the prop keeps it pending whatever the promise did. fixed c22a40a
2 Nit src/components/DeleteConfirmModal/DeleteConfirmModal.test.tsx:85 The new rejection test mocks console.error but never asserts it was called, so the documented "reported through devError" behavior is unverified on the DeleteConfirmModal path that the changelog claims covers it. fixed c22a40a
3 Nit src/components/Modal/Modal.test.tsx:913 The containment guard listens only for a window error event, while an escaped rejection can also surface as unhandledrejection; with only the former observed the assertion cannot detect the regression it names on a runner that reports rejections that way. fixed c22a40a
4 Important src/components/Modal/Modal.test.tsx:993 The new isActionLoading test never invokes onAction: rendering with the prop true makes the Astryx Button busy-only, so user.click returns at handleClick without calling the action and the captured resolve stays the initial no-op. The test would still pass if isActionLoading stopped overriding the settled-promise state, which is the behavior its title and the changelog claim it covers. fixed c22a40a

Security review: not re-run (round 2)

Posted inline: 4 · already inline from this round: 0 · table only (outside the diff): 0 · repeats of an earlier round dropped: 0 · Nits over the cap of 3 dropped: 1 · not posted (no file:line, or style-only): 0

Round 1 — 1f495b4

# Tag File:line Finding Outcome
1 Nit CHANGELOG.md:27 The changelog says tests cover resolve, reject and isActionLoading "on both components", but DeleteConfirmModal has no rejection test and no isActionLoading case. fixed d6259d9
2 Nit src/components/Modal/Modal.test.tsx:876 The rejection test's assertions (aria-busy cleared, onOpenChange not called) also hold without the fix, because Astryx Button clears pending in its own finally; it only fails on the old code because Vitest fails on React's globally reported error. It does not encode the containment it guards, so a runner or config that ignores reported errors would let the bug return untested. fixed d6259d9
3 Nit src/components/Modal/Modal.test.tsx:910 The isActionLoading test drops the prop before clicking, so it never checks the combined state the contract describes (busy while either the prop is true or a promise is pending); a regression that cancels a still-true isActionLoading when the promise settles would pass. fixed d6259d9
4 Important src/components/Modal/Modal.tsx:36 The @example above the new contract still shows a bare await in onAction, and so do DeleteConfirmModal's example and the README. A developer copying them now gets a failed action swallowed silently: the new JSDoc says the caller reports the error but never shows how, and the README's onAction paragraph says nothing about a rejection. (outside the diff — not inline) fixed d6259d9
5 Pre-existing src/components/Modal/Modal.tsx:519 Only this call site guards its clickAction; ConfirmPopover.tsx:158 and DataGridExportModal.tsx:210 (and any future one) still await a caller's promise bare, so they keep producing the same uncaught error this PR removes from Modal. needs-human
6 Important src/components/Modal/Modal.tsx:522 The new catch discards a rejected onAction with no log and no telemetry, so a failed action becomes completely invisible: the spinner stops, the modal stays open with no message, and nothing reaches error reporting. devError from @astryxdesign/core/utils exists for exactly this (it reports a thrown callback in production too). The comment beside the catch also misstates the failure: the rejection is reported as a global error event out of React's transition, and the button clears its own pending state in a finally, so the catch suppresses the report rather than repairing the pending state. fixed d6259d9

Security review: 0 findings

Posted inline: 5 · already inline from this round: 0 · table only (outside the diff): 1 · repeats of an earlier round dropped: 0 · Nits over the cap of 3 dropped: 1 · not posted (no file:line, or style-only): 0

github-actions Bot added a commit that referenced this pull request Dec 3, 2026

@lablup-quill lablup-quill Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ready-gate agent review — 4 findings — 1 Important, 3 Nit, 0 Pre-existing. The summary comment on this PR lists every finding and its outcome.

Comment thread README.md Resolved
Comment thread src/components/Modal/Modal.test.tsx Resolved
Comment thread src/components/Modal/Modal.test.tsx Resolved
github-actions Bot added a commit that referenced this pull request Dec 3, 2026
Stop catching a rejected onAction: the button's transition drops the promise it starts, so the rejection has no caller and reaches React as an uncaught error. Catching it only turned that into a console line. Document the contract in the onAction JSDoc of Modal and DeleteConfirmModal and in the README, and cover the pending state, isActionLoading and the repeated-click dedupe with tests.
@lablup-quill lablup-quill Bot changed the title fix(#192): handle a rejected Modal action and cover the pending state test(#192): pin the Modal action button pending state Dec 3, 2026
github-actions Bot added a commit that referenced this pull request Dec 3, 2026
Revert the experiment that let a rejected onAction escape its clickAction. React chains the transition promise into the finished state and rethrows the rejection during the render that would clear the pending state: a probe against React 19.3.1 shows the button left aria-busy and disabled, with the tree unmounted when nothing catches the render error. Catching it keeps the modal open and reports the failure through devError; a caller that wants its own message catches it in onAction.
@lablup-quill lablup-quill Bot changed the title test(#192): pin the Modal action button pending state fix(#192): keep the Modal action pending state through a rejection Dec 3, 2026
github-actions Bot added a commit that referenced this pull request Dec 3, 2026
The changelog said the transition drops the promise and the rejection reached no one; the real pre-fix failure is React rethrowing it during render. The component JSDoc now also says a caller-set isActionLoading still keeps the button pending after the rejection.
github-actions Bot added a commit that referenced this pull request Dec 3, 2026
github-actions Bot added a commit that referenced this pull request Dec 3, 2026

This branch was successfully deployed

1 active deployment
release — 93e40894 Deployed Dec 3, 2026 by lablup-quill[bot] via npmjs #252
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.

Show a pending state on the Modal / DeleteConfirmModal action button while a promise returned from onAction is pending

0 participants