def test_long_running_command_followed_by_execute(windows_bash_session):
    """Tests behavior when a new command is sent while another is running after timeout."""
    # Start a slow command
    action = CmdRunAction('1..3 | ForEach-Object { Write-Output $_; Start-Sleep 3 }')
    action.set_hard_timeout(2.5)
    obs = windows_bash_session.execute(action)
    assert '1' in obs.content  # First number should appear before timeout
    assert obs.metadata.exit_code == -1  # -1 indicates command is still running
    assert '[The command timed out after 2.5 seconds.' in obs.metadata.suffix
    assert obs.metadata.prefix == ''

    # Continue watching output
    action = CmdRunAction('')
    action.set_hard_timeout(2.5)
    obs = windows_bash_session.execute(action)
    assert '2' in obs.content
    assert obs.metadata.prefix == '[Below is the output of the previous command.]\n'
    assert '[The command timed out after 2.5 seconds.' in obs.metadata.suffix
    assert obs.metadata.exit_code == -1  # -1 indicates command is still running

    # Test command that produces no output
    action = CmdRunAction('sleep 15')
    action.set_hard_timeout(2.5)
    obs = windows_bash_session.execute(action)
    assert '3' not in obs.content
    assert obs.metadata.prefix == '[Below is the output of the previous command.]\n'
    assert 'The previous command is still running' in obs.metadata.suffix
    assert obs.metadata.exit_code == -1  # -1 indicates command is still running

    # Finally continue again
    action = CmdRunAction('')
    obs = windows_bash_session.execute(action)
    assert '3' in obs.content
    assert '[The command completed with exit code 0.]' in obs.metadata.suffix
Tests behavior when a new command is sent while another is running after timeout.
tests/unit/test_windows_bash.py