Skip to content

fix: avoid rich live conflicts in warp connect and hide ctrl-c tip in daemon - #4

Merged
vispar-tech merged 1 commit into
mainfrom
fix/warp-live-daemon-log
Sep 2, 2026
Merged

vispar-tech merged 1 commit into
mainfrom
fix/warp-live-daemon-log

Conversation

@vispar-tech

@vispar-tech vispar-tech commented Sep 2, 2026 •

Copy link
Copy Markdown
Owner

What

Two fixes found while summarizing the project logs:

  1. rich.errors.LiveError: Only one live display may be active at once (19 tracebacks in openrot-bridge.log)

    • warp.connect() used console.status(...), which starts a rich Live.
    • When the bridge rotates WARP from within a request thread (do_POST → _handle → cascade.rotate() → warp.rotate() → connect()), a concurrent request can start a second Live on the same Console → crash of the handler thread.
    • Fix: replace the console.status block with a plain console.print + polling loop. Thread-safe, same foreground UX.
  2. Ctrl-C to stop. appearing in daemon logs

    • bridge.serve() printed the tip unconditionally. The daemon child re-runs start bridge with stdout redirected to the log file, so the misleading interactive tip landed in openrot-bridge.log.
    • Fix: print the tip only when sys.stdout.isatty() (daemon child / redirected runs have a non-TTY stdout).

Tests

  • test_warp.py: connect() must not start a rich Live (returns True even when console.status would explode) and still emits the plain waiting message.
  • test_bridge.py: Ctrl-C to stop. absent when stdout is not a TTY, present when it is.

Verify

  • ruff check / ruff format --check pass
  • mypy openrot/ clean
  • pytest: 300 passed, coverage 86%

Summary by Sourcery

Prevent concurrent WARP connection attempts from crashing the bridge and keep daemon logs free of interactive-only messages.

Bug Fixes:

  • Prevent WARP connection polling from starting conflicting Rich live displays during concurrent bridge requests.
  • Suppress the interactive Ctrl-C shutdown tip when the bridge runs with redirected or non-terminal output.

Tests:

  • Add coverage for WARP connection behavior without Rich Live displays and for terminal-dependent bridge shutdown messaging.

… daemon

warp.connect() used console.status (a rich Live), which crashes with
'Only one live display may be active at once' when the bridge rotates WARP
from a concurrent request thread. Replace it with a plain print + polling
loop that is thread-safe and keeps the foreground UX.

serve() printed 'Ctrl-C to stop.' unconditionally, so the daemon child
(re-runs 'start bridge' with stdout redirected to the log file) wrote a
misleading interactive tip into openrot-bridge.log. Gate it on
sys.stdout.isatty() and add regression tests for both fixes.
@sourcery-ai

sourcery-ai Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR removes Rich Live usage from WARP connection polling to prevent concurrent live-display conflicts, makes the bridge’s Ctrl-C hint TTY-aware for cleaner daemon logs, and adds focused tests covering both behaviors.

Sequence diagram for thread-safe WARP connection polling

sequenceDiagram
    participant Request as Request thread
    participant Cascade
    participant Warp as warp.connect()
    participant Console
    participant WARP

    Request->>Cascade: cascade.rotate()
    Cascade->>Warp: warp.rotate()
    Warp->>WARP: _run(connect)
    Warp->>Console: console.print(waiting message)
    loop up to 120 attempts
        Warp->>WARP: is_connected()
        WARP-->>Warp: connection status
        alt connected
            Warp-->>Cascade: True
        else not connected
            Warp->>Warp: time.sleep(0.5)
        end
    end
Loading

Flow diagram for TTY-aware bridge Ctrl-C hint

flowchart TD
    A["bridge.serve()"] --> B["console.print listening message"]
    B --> C{"sys.stdout.isatty()"}
    C -->|yes| D["console.print Ctrl-C to stop."]
    C -->|no| E["omit interactive hint"]
    D --> F["continue serving"]
    E --> F
Loading

File-Level Changes

Change Details Files
Replace Rich Live status rendering with non-interactive polling to make WARP connection handling safe across concurrent request threads.
  • Print the waiting message once, then poll connection state with the existing timeout and interval.
  • Preserve successful and timed-out connection results without creating a per-console Live display.
openrot/providers/warp.py
Suppress the interactive shutdown hint when the bridge runs with redirected output.
  • Gate the Ctrl-C message on stdout being a TTY.
  • Keep the hint visible for interactive terminal sessions.
openrot/core/bridge.py
Add regression coverage for both concurrency-related output behaviors.
  • Verify WARP connect succeeds without invoking console.status and emits the waiting message.
  • Verify the bridge hides or shows the Ctrl-C hint based on TTY detection.
tests/unit/providers/test_warp.py
tests/unit/core/test_bridge.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai 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.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@vispar-tech
vispar-tech merged commit 1557f62 into main Sep 2, 2026
9 checks passed
@vispar-tech
vispar-tech deleted the fix/warp-live-daemon-log branch September 2, 2026 08:57
vispar-tech added a commit that referenced this pull request Oct 13, 2026
fix: avoid rich live conflicts in warp connect and hide ctrl-c tip in daemon
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.

1 participant