Fix misleading command.exit_code.native capability - #11
Merged
Conversation
`command.exit_code.native` was reported True for all shells, but only hosted
PowerShell reads a native exit code (in-process $LASTEXITCODE + HadErrors via
the .NET runspace). cmd/bash surface the shell's real exit status but scrape it
from a stdout sentinel (process.py wrap_command / parse_sentinel), which is not
an OS-native process exit.
Renamed the capability to `command.exit_code` (exit codes ARE captured for every
backend) and moved the truth into details:
{"cmd": "sentinel_parsed", "bash": "sentinel_parsed", "powershell_hosted": "native"}
A single `.native` boolean cannot describe a per-backend distinction, so the
suffix is dropped rather than forced to a wrong True/False. Nothing keys on the
old name (declaration + README list only; no test asserted it). Updated the
README capability list and added a test asserting the per-backend mechanism.
Verification: python -m unittest discover -s tests -> 91 passing (was 90).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR corrects how LiveShell reports the “exit code capability” by replacing the misleading, unconditional command.exit_code.native capability with a new command.exit_code capability whose details describe the per-backend exit-code mechanism.
Changes:
- Rename capability from
command.exit_code.nativetocommand.exit_code. - Add
detailstocommand.exit_codeindicating whether the exit code isnativeorsentinel_parsedper backend. - Update README capability list and add a unit test asserting the new shape.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/liveshell/capabilities.py |
Renames the capability and adds per-backend mechanism details for exit code reporting. |
tests/test_capabilities.py |
Adds a regression test asserting the old capability name is gone and the new details mapping is present. |
README.md |
Updates the documented capability list to reflect the new capability name. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…s failed on macOS When cancel_command kills the process before the worker loop's cancel_event check runs, exec_thread finishes (non-zero exit from killed process) and the loop exits via exec_thread.is_alive() being False. Without a cancel_event check after the loop, the code fell through to _finish_failed, racing against _finish_canceled in cancel_command. Add a cancel_event.is_set() guard immediately after exec_thread.join() so the worker correctly marks the command as canceled rather than failed. Fixes: test_cancel_running_command_marks_terminal_canceled on macOS
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
command.exit_code.nativewas reported True for all shells, but only hosted PowerShell reads a native exit code (in-process $LASTEXITCODE + HadErrors via the .NET runspace). cmd/bash surface the shell's real exit status but scrape it from a stdout sentinel (process.py wrap_command / parse_sentinel), which is not an OS-native process exit.Renamed the capability to
command.exit_code(exit codes ARE captured for every backend) and moved the truth into details:{"cmd": "sentinel_parsed", "bash": "sentinel_parsed", "powershell_hosted": "native"}A single
.nativeboolean cannot describe a per-backend distinction, so the suffix is dropped rather than forced to a wrong True/False. Nothing keys on the old name (declaration + README list only; no test asserted it). Updated the README capability list and added a test asserting the per-backend mechanism.Verification: python -m unittest discover -s tests -> 91 passing (was 90).