Adopt useActionLock in remaining double-submit-prone handlers
Nobody has claimed this yet.
- Dominant language
- Elixir
- Stars
- 296
- Forks
- 86
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 50
Description
**This work depends on the work done in AI First epic #4848 and must be implemented after **
Follow-up to PR #4912. We extracted useActionLock
(assets/js/collaborative-editor/hooks/useActionLock.ts) from
TemplateBrowserModalWrapper's re-entrancy guard so double-submit protection
can be standardised across modals/handlers instead of drifting (see Stu's
review comment on #4912).
useActionLock wraps an async action with a synchronous useRef lock (so a
fast double-click can't slip through between render flushes), resets in a
single finally, and returns a useCallback-stable run plus an isPending
flag for disabling UI.
Not a fit for useRunRetry or the AI apply path - those locks aren't
promise-scoped and solve a different cross-user problem (noted in the hook's
doc comment).
Spots to bring in line as we touch them, roughly in priority order:
-
components/GitHubSyncModal.tsx:73-78- priority: Cmd/Ctrl+Enter
callshandleSaveAndSyncwith no guard and the textarea is never
disabled, so holding the shortcut fires concurrent save-and-syncs.
User-reachable today. -
components/inspector/TemplatePublishPanel.tsx:78-140- disable-only,
no early-return guard; in create mode a double-fire of
publish_templatecould create duplicate templates (nothing upserts
it the way workflow saves are protected). -
components/inspector/trigger/TriggerEditWizard.tsx:89-95-finish
has no guard and the button isn't disabled duringcommit(), so a
double-click double-commits. -
SelectedDataclipView.tsx:39-58- lower risk, near-zero-cost to adopt. -
WorkflowSettings.tsx:81-99- lower risk, near-zero-cost to adopt.
Each item can be its own small PR (swap manual flag/guard for
useActionLock), done opportunistically rather than as one big sweep.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with assets/js/collaborative-editor/hooks/useActionLock.ts, then inspect the listed handlers, prioritising components/GitHubSyncModal.tsx:73-78. Apply the hook to one handler at a time, preserving the existing action behavior and disabling its UI while pending; each item is complete when its handler cannot double-submit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100