Skip to content

Fix run button state management and prevent concurrent computations#3964

Open
ayolab wants to merge 1 commit into
mainfrom
ayolab/fix-run-button-state-management-and-prevent-concurrent-computations
Open

Fix run button state management and prevent concurrent computations#3964
ayolab wants to merge 1 commit into
mainfrom
ayolab/fix-run-button-state-management-and-prevent-concurrent-computations

Conversation

@ayolab

@ayolab ayolab commented May 28, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: Ayoub LABIDI <ayoub.labidi@protonmail.com>
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR introduces RunningStatus.UNKNOWN as a distinct state to track computations that have not yet loaded their initial status, updates initial Redux state to use this new value, and refactors button components to derive loading/running states from the status enum rather than a separate boolean prop.

Changes

Computation Status Initialization and State Handling

Layer / File(s) Summary
RunningStatus enum and initial state
src/components/utils/running-status.ts, src/redux/reducer.ts
RunningStatus enum now includes UNKNOWN = 'UNKNOWN'. All computation type entries in the reducer's initialState.computingStatus are changed from RunningStatus.IDLE to RunningStatus.UNKNOWN.
Hook parameter update guard for UNKNOWN status
src/components/computing-status/use-computing-status.ts
useComputingStatus now gates parameter fetching/updating to skip when computationStatus is RunningStatus.UNKNOWN (in addition to existing exclusion for IDLE).
RunButtonContainer state refactoring
src/components/run-button-container.jsx
The internal computationStopped state is removed and replaced with runWithDebug state. computationStopped state updates are deleted from the startComputationAsync execution path and runnable stop handling. The computationStopped prop is no longer passed to RunButton.
RunButton prop removal and state derivation
src/components/run-button.jsx
The computationStopped prop is removed from the signature and propTypes. New useMemo values compute runningRunnable (first active runnable with RUNNING status) and isLoaded (all active runnables not UNKNOWN). The selectedRunnable effect now prefers following the running runnable, and SplitButton is wired so button disabled and text visibility are driven by isLoaded.
SplitButton prop removal and menu disabled logic
src/components/utils/split-button.tsx
The computationStopped prop is removed from SplitButtonProps interface and destructuring. The disabledOption computation that combined computationStarting with a RUNNING + computationStopped condition is deleted, and menu item disabled state now depends only on computationStarting.

Suggested reviewers

  • souissimai
  • sBouzols
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess whether the description relates to the changeset. Add a pull request description explaining the changes, their rationale, and impact on run button state management and computation handling.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: refactoring run button state management by removing the computationStopped prop and introducing runWithDebug state, plus updating RunningStatus enum and initial status values to prevent concurrent computations.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/utils/split-button.tsx`:
- Line 257: The Stop/menu action currently only uses
disabled={computationStarting}, allowing repeated stop requests while runnable
remains RUNNING; update the guard so the UI and handler both prevent duplicates
by disabling the control when computationStarting is true OR runnable?.status
=== 'RUNNING' (e.g., change disabled to computationStarting || runnable?.status
=== 'RUNNING' on the menu item/button) and add an early return in
actionOnRunnable() to no-op if computationStarting || runnable?.status ===
'RUNNING' to ensure clicks cannot trigger duplicate stop requests.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 86c1a6ff-961b-4490-bd7f-ffa7a580ee34

📥 Commits

Reviewing files that changed from the base of the PR and between 2d9c628 and d538d15.

📒 Files selected for processing (6)
  • src/components/computing-status/use-computing-status.ts
  • src/components/run-button-container.jsx
  • src/components/run-button.jsx
  • src/components/utils/running-status.ts
  • src/components/utils/split-button.tsx
  • src/redux/reducer.ts
💤 Files with no reviewable changes (1)
  • src/components/run-button-container.jsx

Comment thread src/components/utils/split-button.tsx

@Mathieu-Deharbe Mathieu-Deharbe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is not because of your dev but very close and I encountered this while testing : I start a security analysis, then I stop it quickly. Then I try to unbuild the node and I can't : the node is stuck :

Image

This is a quite big problem. If you don't know where it is coming from maybe we should create another anomaly ticket.

(The bug is on dev opf as well)

@Mathieu-Deharbe Mathieu-Deharbe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your code looks good and corrects the bug so I should approve it, but those 2 bugs are worrying me.

Comment on lines +33 to +36
const runningRunnable = useMemo(
() => activeRunnables.find((r) => getStatus(r) === RunningStatus.RUNNING) ?? null,
[activeRunnables, getStatus]
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn't there a risk that this will return an array ?

Comment on lines -222 to -225
const disabledOption =
computationStarting || // disable if fetch starting a computation is pending
(runningStatus === RunningStatus.RUNNING && computationStopped); // disable if already stopped once

@Mathieu-Deharbe Mathieu-Deharbe May 28, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought that code was here in order to prevent a restart of a computation before a stop is handled in the back but it looks like I was wrong because even with that code I have this bug :

Image
  1. start a computation
  2. cancel it immediately
  3. restart the same computation quickly
  4. fails (and then "succeeds" sometimes because the computation finished in the back and its result is returned)

So it looks like you are right to remove this, but I am a bit lost. One more bug ?

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.

2 participants