fix: retain shell errors and offer built-in debug recovery - #608
Merged
Merged
Conversation
Preserve failed command status and stderr after the terminal resumes. Offer the existing debug workflow for the original container when the runtime reports a missing shell, with image selection and guardrail checks. Closes #606
Greptile Summarysofka now keeps failed shell commands visible and lets users recover missing shells with the built-in debug flow. It captures useful error output, restores the terminal promptly, and keeps recovery subject to read-only mode and debug guardrails.
Confidence Score: 5/5The PR appears safe to merge. No new issue remains in the changed recovery or stderr paths. The latest changes bind recovery errors to Important Files Changed
Sequence DiagramsequenceDiagram
actor User
participant App
participant Terminal
participant Command
User->>App: Press s
App->>Terminal: Suspend TUI and run shell
Terminal->>Command: Start kubectl exec
Command-->>Terminal: stderr and exit status
Terminal->>Terminal: Keep last 16 KiB
Terminal-->>App: Restore TUI and return result
alt command failed
App-->>User: Show scrollable error
alt missing sh and user presses d
App-->>User: Ask for debug image
App->>App: Check read-only mode and guardrails
App-->>User: Ask for required confirmation
User->>App: Accept
App->>Terminal: Run kubectl debug
Terminal-->>App: Return debug result
alt debug failed
App-->>User: Show original and recovery errors
else debug succeeded
App-->>User: Clear error
end
end
else command succeeded
App-->>User: Show completion message
end
Reviews (3): Last reviewed commit: "fix: drain ready errors and bind recover..." | Re-trigger Greptile |
Keep the original missing-shell error if debug creation fails. Stop reading stderr shortly after the command exits so a descendant that retains the pipe cannot block terminal restoration.
Read available stderr before the idle deadline, and limit output from descendants that keep writing. Carry the original failure with each recovery command so an unrelated command cannot reuse its error or pod target.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
sfails in a container withoutsh, sofka now keeps the failure in a scrollable dialog. The command exit status and the last 16 KiB of standard error remain available until dismissal.For a runtime error that identifies a missing shell,
dopens the existing debug image prompt for the original pod and container. Creation requires acceptance and obeys read-only mode and debug guardrails, including typed confirmation. Canceling the prompt returns to the original error. Other failures do not offer missing-shell recovery.Closes #606.
Agreed discussion: #604 (comment)
If debug creation fails, the original error remains available with the recovery error. The recovery command carries that error explicitly, so unrelated commands cannot inherit the old target. After the direct command exits, capture drains available stderr before honoring the 100 ms deadline for an idle pipe. A 1 MiB drain limit also bounds descendants that keep writing. These changes address Greptile's review findings.
Validation:
just checkand the final commit hooks passed withRUST_TEST_THREADS=1. Tests cover error retention, target selection, cancellation, guardrails, and terminal restoration after failure or an inherited stderr pipe, ready output at an expired deadline, continuous writers, and unrelated command failures.just fmt-checkpassed after the hooks. A parallel run exposed an existing port-allocation test failure; that test passed alone and in the serial suite. No live-cluster test was run.