Fix: REPL /remote command hang in scripted/non-TTY environment#2722
Conversation
Greptile code reviewThis repo uses Greptile for automated review. Before merge, aim for Confidence Score: 5/5 with zero unresolved review threads — see CONTRIBUTING.md. Run a review — add a PR comment with: Give it ~5-10 minutes (sometimes longer) for results, then fix feedback and re-trigger until you reach Confidence Score: 5/5. Optional: automate with the greploop skill. |
Greptile SummaryThis PR fixes a hang/freeze in the
Confidence Score: 5/5Safe to merge — the fix is a clean parameter propagation through an existing call chain with no behavioural changes to interactive paths. The change is well-scoped: is_tty is threaded mechanically through every dispatch layer and run_initial_input correctly hardwires is_tty=False. The non-TTY guards added to remote.py are additive and do not affect the interactive code path. Unit tests verify both the parameter forwarding and the is_tty=False contract on the scripted entry-point. The only known fragility — the del os.environ in the finally block — has already been flagged in a prior review cycle and does not affect normal operation. app/cli/interactive_shell/command_registry/init.py — the finally cleanup still uses del rather than os.environ.pop(None). Important Files Changed
Sequence DiagramsequenceDiagram
participant RI as run_initial_input
participant DOT as dispatch_one_turn
participant ERT as execute_routed_turn
participant DS as dispatch_slash
participant ENV as os.environ
participant RC as remote (Click cmd)
RI->>DOT: "dispatch_one_turn('/remote', is_tty=False)"
DOT->>ERT: "execute_routed_turn(..., is_tty=False)"
ERT->>DS: "dispatch_slash('/remote', is_tty=False)"
DS->>ENV: "set OPENSRE_INTERACTIVE=0"
DS->>RC: cmd.handler(session, console, args)
RC->>RC: ctx.invoked_subcommand is None?
RC->>RC: not is_interactive_env() True
RC-->>DS: raise OpenSREError No subcommand provided
DS->>ENV: restore OPENSRE_INTERACTIVE (finally)
DS-->>ERT: exception propagates / handled
Reviews (3): Last reviewed commit: "Relax Click option error assertion" | Re-trigger Greptile |
f8d1ac7 to
ef82dd3
Compare
|
@greptileai review |
9cec1e0 to
99419e6
Compare
|
Can u provide demo , like any screenshot |
|
Hi @Devesh36 , I've updated the Pull Request description to include the demo proof. |
|
🍕 @PrakharJain345's PR: crispy edges, no unnecessary toppings, delivered on time. Understood the assignment. 🔥 👋 Join us on Discord - OpenSRE : hang out, contribute, or hunt for features and issues. Everyone's welcome. |

Fixes #2707
Describe the changes you have made in this PR -
This PR fixes the hang/freeze when running the
/remoteslash command without arguments in a non-TTY / scripted / test-harness environment:_dispatch_one_turninloop.pyto accept the optionalis_ttyparameter and forward bothconfirm_fnandis_ttytodispatch_slash.is_tty=Falsefrom_run_initial_input(scripted test path) down to the turn dispatcher.is_interactive_env()check to handle theOPENSRE_INTERACTIVEenvironment variable override appropriately, preventing the child cli process from invoking_run_remote_interactivewhen stdin is not a TTY.test_dispatch_one_turn_passes_is_tty_and_confirm_fn_to_dispatch_slashto assert correct parameter forwarding.Demo/Screenshot for feature changes and bug fixes -
Screen.Recording.2026-06-04.222019.mp4
Verification via unit tests:
Code Understanding and AI Usage
Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?
If you used AI assistance:
Explain your implementation approach:
In scripted/seeded runs (like
_run_initial_inputin tests), the environment isn't interactive and stdin is not a TTY. However, becauseis_tty=Falsewas never propagated from the REPL turn runner (loop.py) to the slash command dispatcher (dispatch_slash), theOPENSRE_INTERACTIVEenvironment override (os.environ["OPENSRE_INTERACTIVE"] = "0") was never set. As a result, the/remotecommand invoked a child subprocess that inherited the interactive setting and attempted to display the interactivequestionarypicker, hanging the terminal.We resolved this by propagating the
is_ttyparameter through_dispatch_one_turnand passingis_tty=Falsewhen calling it from_run_initial_input. We also added a unit test to verify that bothis_ttyandconfirm_fnare forwarded correctly.Checklist before requesting a review