Repository navigation
Fix prompt capability checks for redirected consoles - #5581
Ahmed Muhsin (ahmedmuhsin) merged 3 commits into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The capability gating changes are well-covered by new tests and align with the reported redirection crash scenario, with only a minor warning-message wording nit noted.
Pull request overview
This PR fixes prompt capability checks to avoid Spectre prompt crashes when stdout or stderr is redirected (Issue #5511). It refines IInteractionService/SpectreInteractionService to base interactivity on the actual injected consoles (stdin + ANSI capabilities per target stream) and adds targeted tests to cover the redirection/capability matrix across prompts and key consumers.
Changes:
- Update
SpectreInteractionServiceinteractivity logic so selection prompts gate on the stderr console’s ANSI + input capabilities, while confirmation/text prompts gate on their own target console. - Clarify
IInteractionServicedocumentation around output routing and whatIsInteractiverepresents at the command level. - Add comprehensive tests (including capability matrices and consumer coverage for
new,init, first-run coordination, and dashboard output mode resolution).
File summaries
| File | Description |
|---|---|
| test/Func.Tests/Console/SpectreInteractionServiceTests.cs | Adds matrix-driven tests for IsInteractive and each prompt method’s capability gating, cancellation, and fallback behavior. |
| test/Func.Tests/Console/PromptCapabilityConsumerTests.cs | Validates key command/service consumers behave correctly under redirected/non-ANSI scenarios (no prompt crashes, correct fallbacks). |
| test/Func.Tests/Console/BufferedConsole.cs | Introduces a buffered Spectre console test double with scripted key input and captured output. |
| src/Func/Console/SpectreInteractionService.cs | Implements per-target capability checks (stdout vs stderr) and updates prompt methods to honor cancellation early and gate selection prompts correctly. |
| src/Func/Console/IInteractionService.cs | Updates contract docs for routing and interactivity semantics to match the new behavior. |
| src/Func/Commands/Start/StartCommand.cs | Adjusts the downgrade warning message when compact mode is unsafe. |
| src/Func/Commands/Start/Dashboard/Rendering/OutputModeResolver.cs | Updates docs to describe the revised capability-based downgrade rule. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🟢 Approval recommended
The capability checks are corrected in the core interaction service and are backed by thorough matrix + consumer-level tests covering the reported redirected-console failure modes.
Review details
- Files reviewed: 9/9 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
Flagging a potential regression for your review:
Both InitCommand.ConfirmClearDirectoryAsync and QuickstartCommand.ConfirmClearDirectoryAsync return For example, with |
Fixes #5511.
Use injected stdout/stderr input and ANSI capabilities for command-level interactivity. Each prompt checks its actual target console, preserving non-ANSI text and confirmation input, defaults, and cancellation.
Verified failing baseline regressions, capability matrices, a warning-free Release build, all 2,051 solution tests, and redirected new/init CLI smoke checks.