Skip to content

fix(tasks): prevent duplicate Add Task submissions while a request is pending - #486

Open
WiseShrestha wants to merge 1 commit into
CCExtractor:mainfrom
WiseShrestha:fix/add-task-duplicate-submit
Open

WiseShrestha wants to merge 1 commit into
CCExtractor:mainfrom
WiseShrestha:fix/add-task-duplicate-submit

Conversation

@WiseShrestha

Copy link
Copy Markdown

Description

Clicking Add Task again before the backend responded sent the same task more than once, because the button called onSubmit on every click without waiting.

The dialog now tracks the pending submission when onSubmit returns a promise:

  • further clicks are ignored until the request settles
  • the button is disabled and shows "Adding..." meanwhile (aria-busy is set too)
  • a ref, alongside the state, blocks a second click that lands before React re-renders

AddTaskDialogProps.onSubmit is now typed (task) => void | Promise<void>, which matches the existing async handleAddTask in Tasks.tsx. A synchronous onSubmit behaves as before.

Checklist

  • Ran Prettier on the changed files (npx prettier --check reports them as formatted)
  • Ran gofmt -w . (for Go backend): not applicable, no Go changes
  • Ran npm test (for JS/TS testing): 59 suites, 754 tests pass
  • Added unit tests, if applicable
  • Verified all tests pass
  • Updated documentation, if needed: not needed

Additional Notes

  • Two new tests in AddTaskDialog.test.tsx: one checks that clicks during a pending submission are ignored and the button is disabled; the other checks that the button works again once the submission settles. The first test fails against the old code.
  • tsc --noEmit is clean.
  • This change was written with the help of an AI coding assistant (Claude); I reviewed and tested it.

… pending

The Add Task button called onSubmit on every click, so clicking it again
before the backend responded sent the same task more than once.

The dialog now tracks the pending submission when onSubmit returns a
promise: further clicks are ignored, and the button is disabled and shows
"Adding..." until the request settles. A ref blocks a second click that
lands before React re-renders.

Fixes CCExtractor#482

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013TjiucazWUjDoYj1dsAmKB

This branch has not been deployed

No deployments
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.

Add Task sends duplicate requests while the first submission is pending

2 participants