feat(cli): enhance prompt handling and synthetic task follow-up#2797
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 consolidates synthetic-test failure handling into new
Confidence Score: 5/5Safe to merge — no production bugs introduced by this PR. The history-generation guard is now consistently applied in both No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant BG as Background Watcher Thread
participant Session as ReplSession
participant EventLoop as asyncio Event Loop
participant PT as prompt_toolkit App
Note over BG: Synthetic or CLI task exits non-zero
BG->>Session: suggest_synthetic_failure_follow_up(label)
Session->>Session: set pending_prompt_default
Session->>Session: notify_prompt_changed (1st)
Session-->>EventLoop: call_soon_threadsafe(_apply)
Session->>Session: _bind_last_synthetic_observation (blocks up to 480ms)
Session->>Session: notify_prompt_changed (2nd)
Session-->>EventLoop: call_soon_threadsafe(_apply)
EventLoop->>PT: _apply - set current_buffer.text
EventLoop->>PT: pt_app.invalidate
Note over EventLoop: Next prompt_async iteration
EventLoop->>Session: take_pending_prompt_default
Session-->>EventLoop: empty string (consumed by _apply)
EventLoop->>PT: prompt_async with default and placeholder callable
Reviews (3): Last reviewed commit: "fix(cli): join output streams before rea..." | Re-trigger Greptile |
…low-up logic - Updated prompt session initialization to use the session parameter. - Enhanced synthetic task follow-up to skip unnecessary notifications after session resets. - Refined scenario ID extraction logic to ensure valid synthetic scenario IDs. - Added tests to verify new behavior in background CLI task handling and scenario ID extraction.
|
@greptile-apps review again |
Mirror synthetic_tasks watcher: drain pump threads before read_diag so failure diagnostics are not read from a still-writing SpooledTemporaryFile. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@greptile-apps review again |
|
looks good to me |
|
🌊 Merged. @Devesh36 is now permanently woven into git history. No take-backs. 😄 👋 Join us on Discord - OpenSRE : hang out, contribute, or hunt for features and issues. Everyone's welcome. |
|
@Devesh36 did you check with /sessions also? these changes are being captured while switching btw sessions? also tasks are handled? |
Yeah tested /sessions /new and /resume with background synthetic everything works. No prefill leak on session switch tasks/placeholder behave correctly and failed synthetic prefills the prompt when you stay on the same session. |

This pull request introduces significant improvements to how the interactive CLI prompt behaves, especially in terms of contextual placeholder text, prompt prefill after synthetic test failures, and overall session state management. The changes enhance user experience by making the prompt more informative and responsive to session events, and by consolidating logic related to synthetic test follow-ups. Additionally, several code paths are refactored for clarity, and new tests are added to ensure correct behavior.
Prompt placeholder and refresh improvements:
resolve_prompt_placeholderto generate dynamic placeholder text based on session state (e.g., trust mode, running tasks, resumed session), replacing the previous static placeholder. [1] [2]wire_prompt_refresh, allowing the prompt to be programmatically refreshed/redrawn when session state changes. [1] [2]Synthetic test failure follow-up and session state management:
ReplSessionmethods:suggest_synthetic_failure_follow_upand_bind_last_synthetic_observation. This replaces the previous scattered logic and improves maintainability. [1] [2] [3] [4] [5]Task registry and session enhancements:
running_countmethod toTaskRegistryto efficiently count currently running tasks, supporting the new dynamic placeholder.prompt_refresh_fncallback, which is invoked to update the prompt when needed.Code cleanup and refactoring:
_scenario_id_from_synthetic_suite_name,_try_bind_synthetic_observation) fromsynthetic_tasks.pyand cleaned up related imports and exports. [1] [2] [3]_scenario_id_from_synthetic_label, which handles both flag and label formats.Testing improvements: