Skip to content

Fix flaky exit code reporting in run_in_terminal (fallback handling) #313601#314368

Open
zmo2s wants to merge 2 commits intomicrosoft:mainfrom
zmo2s:fix/313601-run-in-terminal-exit-code
Open

Fix flaky exit code reporting in run_in_terminal (fallback handling) #313601#314368
zmo2s wants to merge 2 commits intomicrosoft:mainfrom
zmo2s:fix/313601-run-in-terminal-exit-code

Conversation

@zmo2s
Copy link
Copy Markdown

@zmo2s zmo2s commented May 5, 2026

Fix flaky exit code reporting in run_in_terminal

Related to #313601

Problem

The integration test non-zero exit code is reported is flaky because
shell integration does not always report the exit code before the result
is returned.

This change improves exit code handling by ensuring a fallback when
shell integration has not yet populated the exit code.

Copilot AI review requested due to automatic review settings May 5, 2026 11:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 aims to reduce flakiness in the chat.runInTerminal integration test that validates non-zero exit code reporting by adding a fallback exit code derivation when rich shell integration hasn’t populated finishedCommand.exitCode yet.

Changes:

  • Add a helper to derive an exit code from the command text (exit <n> pattern).
  • Use the command-text-derived exit code as a fallback when finishedCommand.exitCode is undefined.

Comment on lines +242 to 247
let exitCode =
finishedCommand?.exitCode
?? this.extractExitCodeFromCommandLine(commandLine);
if (exitCode === undefined && onDoneResult && onDoneResult.type === 'processExit') {
exitCode = extractExitCode(onDoneResult.exitCodeOrError);
}
@zmo2s
Copy link
Copy Markdown
Author

zmo2s commented May 5, 2026

@microsoft-github-policy-service agree

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