Skip to content

Bug: Terminal Silently Drops Consecutive Duplicate Commands #105

@Jayant-kernel

Description

@Jayant-kernel

Describe the bug

When using the debug control buttons (e.g., clicking "Next" or "Step" twice in a row), the second click is completely ignored by the terminal and backend.

Root Cause

In TerminalComp.jsx, the useEffect that triggers commands relies on toggling commandPress to run:

  useEffect(() => {
    if (terminalOutput) {
      defaultHandler(terminalOutput);
    }
  }, [commandPress]); 

However, since commandPress is a boolean toggle, if you click the SAME button multiple times, the state toggles back and forth. But because the terminalOutput is kept the same, and React batches the state update or fails to fire the effect appropriately, duplicate button clicks are dropped.


Expected behaviour

Clicking "Next" three times should execute the next GDB command three times.

To Reproduce

  1. Start a debugging session.
  2. Click the "Next" (arrow right) button in the DebugHeader.
  3. The terminal executes next.
  4. Click the same "Next" button again.
  5. Bug: Nothing happens. The command is ignored.

Suggested Fix

Refactor the global state to replace the boolean toggle commandPress with an incrementing counter (e.g., setCommandCount(prev => prev + 1)) so the dependency array always sees a new, unique value on every click.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions