Skip to content

Fix misleading command.exit_code.native capability - #11

Merged
wheresoli merged 4 commits into
mainfrom
fix/exit-code-capability-accuracy
Jul 10, 2026
Merged

Fix misleading command.exit_code.native capability#11
wheresoli merged 4 commits into
mainfrom
fix/exit-code-capability-accuracy

Conversation

@wheresoli

@wheresoli wheresoli commented Jul 10, 2026

Copy link
Copy Markdown
Owner

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).

`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>
Copilot AI review requested due to automatic review settings July 10, 2026 21:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.native to command.exit_code.
  • Add details to command.exit_code indicating whether the exit code is native or sentinel_parsed per 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.

Comment thread src/liveshell/capabilities.py Outdated
Comment thread tests/test_capabilities.py Outdated
…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
wheresoli and others added 2 commits July 10, 2026 14:14
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>
@wheresoli
wheresoli merged commit 6882f96 into main Jul 10, 2026
8 checks passed
@wheresoli
wheresoli deleted the fix/exit-code-capability-accuracy branch July 10, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants