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

Comment on lines +503 to +504
const previousActiveTerminal = window.activeTerminal;

Copy link
Preview

Copilot AI Aug 4, 2025

Choose a reason for hiding this comment

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

[nitpick] The previousActiveTerminal variable is captured at the start of the function but only used much later in the event handler. Consider moving this declaration closer to where the event handler is defined to improve code readability and reduce the scope of the variable.

Suggested change
const previousActiveTerminal = window.activeTerminal;

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It needs to be captured here as the temp console is created in the next step and takes over the active terminal.

@@ -600,6 +604,23 @@ export class DebugSessionFeature
);
}

const closeDebugEvent = debug.onDidTerminateDebugSession(
Copy link
Preview

Copilot AI Aug 4, 2025

Choose a reason for hiding this comment

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

The event listener is created for every debug session but only handles termination of the specific session. Consider whether this could lead to memory leaks if multiple debug sessions are created rapidly, as the event listener persists until the specific session terminates.

Copilot uses AI. Check for mistakes.

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.

1 participant