Skip to content

Add temporaryConsoleWindowActionOnDebugEnd option #5255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jborean93
Copy link
Contributor

PR Summary

Adds a new option temporaryConsoleWindowActionOnDebugEnd to both the attach and launch configurations which can be used to specify what happens with the temporary integrated console when a debug session ends. The option can be set to keep, current behaviour and default, that will keep the active terminal as the temporary console. It can be set to close which closes the terminal and removes it from the selection pane or hide which keeps the terminal window alive but changes the active terminal to the previous one before the debug session started.

Issue for this feature was opened under PowerShell/PowerShellEditorServices#2247 but the actual implementation needs to be done here.

PR Checklist

  • PR has a meaningful title
  • Summarized changes
  • PR has tests - not sure if I can test this out?
  • This PR is ready to merge and is not work in progress
    • If the PR is work in progress, please add the prefix WIP: to the beginning of the title and remove the prefix when the PR is ready

Adds a new option `temporaryConsoleWindowActionOnDebugEnd` to both the
attach and launch configurations which can be used to specify what
happens with the temporary integrated console when a debug session ends.
The option can be set to `keep`, current behaviour and default, that
will keep the active terminal as the temporary console. It can be set to
`close` which closes the terminal and removes it from the selection
pane or `hide` which keeps the terminal window alive but changes the
active terminal to the previous one before the debug session started.
@Copilot Copilot AI review requested due to automatic review settings August 4, 2025 00:23
Copy link

@Copilot 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 adds a new configuration option temporaryConsoleWindowActionOnDebugEnd that controls the behavior of temporary console windows when PowerShell debug sessions end. The feature provides three options: "keep" (default, maintains current behavior), "close" (removes the terminal), and "hide" (restores the previous active terminal).

  • Adds the new configuration option to both attach and launch debug configurations
  • Implements event handling to manage terminal state when debug sessions terminate
  • Provides configurable behavior for temporary console cleanup with backward compatibility

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/features/DebugSession.ts Implements the core logic for handling terminal state changes and debug session event listening
package.json Defines the new configuration schema with enum values and descriptions for both attach and launch configurations

Copy link
Collaborator

@JustinGrote JustinGrote left a comment

Choose a reason for hiding this comment

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

LGTM and tested working. Thanks Jordan.

@andyleejordan
Copy link
Member

Patrick and I just have the question: what do we need hide for, is there any user request for that or was it just "an option available?" Closing and keeping seem to be enough (and we'd almost err on closing being the correct default, and that's perhaps a bug that it's not what currently happens).

@jborean93
Copy link
Contributor Author

jborean93 commented Aug 5, 2025

Hide is useful if you want the active window to go back to what was there before it was launched but still want the temp console window available to either see the history or in a launch scenario to run further commands in that runspace state, e.g. get vars, run functions defined in the launch script, etc.

The reason I didn't go with close (or hide) by default is one that's not how it works today and a user may still want to go back in the history/output to see what has happened after the debug session ended. I also thought it might be a bit confusing if a launch session had a different default to attach so decided to just align them to the same default.

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