Conversation

andyleejordan

Wow this was a mess. Needs PowerShell/PowerShellEditorServices#2130, and I'm a little worried about breaking changes but supplying "current" to processId is special-cased to still work (well, throw an appropriate warning), since the launch configuration types only generate warnings.

Ok so we removed the notion of IDs (which are integers) being strings because that broke serialization with recent updates. But on inspection we realized the whole point was to be able to say "current" and have the attach configuration attach to the currently running Extension Terminal. Except that this was an unsupported, half-baked scenario (sure, it attached, but it couldn't actually be debugged properly). So now that throws warnings in both the client and server. The defaults for processId and runspaceId where changed to null (again, now they're just integers) which means to query for them. The supplied but half-baked configuration was removed.

Fixes #4843

@andyleejordanandyleejordan force-pushed the andyleejordan/fixup-debug-configs branch from 5dcc6d7 to e9cb397 Compare January 17, 2024 01:35
@andyleejordanandyleejordan changed the title WIP: Fix up debug config resolution stuff Fix up debugger configuration resolvers Jan 17, 2024
@andyleejordanandyleejordan marked this pull request as ready for review January 17, 2024 01:36
@andyleejordanandyleejordan requested review from a team and JustinGrote January 17, 2024 01:36

Choose a reason for hiding this comment

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

LGTM

@andyleejordanandyleejordan force-pushed the andyleejordan/fixup-debug-configs branch from e9cb397 to 5678505 Compare January 22, 2024 18:33
@JustinGrote

Still happening to me in a code --profile-temp with the extension installed from vsix. I checked the source zip and the JS looks to match the PR

  async pickPSHostProcess() {
    await this.getLanguageClient();
    const items = [];
    const response = await this.languageClient?.sendRequest(GetPSHostProcessesRequestType, {});
    for (const process3 of response ?? []) {
      let windowTitle = "";
      if (process3.mainWindowTitle) {
        windowTitle = `, ${process3.mainWindowTitle}`;
      }
      items.push({
        label: process3.processName,
        description: `PID: ${process3.processId.toString()}${windowTitle}`,
        processId: process3.processId
      });
    }

Let me try it in extension debug

Choose a reason for hiding this comment

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

From Code Review

@andyleejordan

Now also resolves the root of #4699.

@JustinGroteJustinGrote self-requested a review January 24, 2024 00:24
@andyleejordanandyleejordan force-pushed the andyleejordan/fixup-debug-configs branch from eb87b2e to e1b63cc Compare January 24, 2024 18:39
Ok so we removed the notion of IDs (which are integers) being strings
because that broke serialization with recent updates. But on inspection
we realized the whole point was to be able to say "current" and have the
attach configuration attach to the currently running Extension Terminal.
Except that this was an unsupported, half-baked scenario (sure, it
attached, but it couldn't actually be debugged properly). So now that
throws warnings in both the client and server. The defaults for
`processId` and `runspaceId` where changed to `null` (again, now they're
just integers) which means to query for them. The supplied but
half-baked configuration was removed.
This makes a lot more sense and fixes a long-standing bug.  Also cleaned up a
lot while at it.

1. `SessionManager` is created and the features are injected into the session
manager with the intention of them being able to "register" their language
client event handlers in the period between when the client is created and when
it is started.

2. For each feature, if it gets to a point where it needs the language client,
we want them to wait on a promise for the "started" client to be provided from
the session manager before continuing.

3. Once it is started, the session manager passes the client to
`LanguageClientConsumer` which resolves the promise for the features so they can
continue.
@andyleejordanandyleejordan force-pushed the andyleejordan/fixup-debug-configs branch from e1b63cc to d429beb Compare January 24, 2024 21:04
@andyleejordanandyleejordan added this pull request to the merge queue Jan 24, 2024
Merged via the queue into main with commit 0dceec3 Jan 24, 2024
@andyleejordanandyleejordan deleted the andyleejordan/fixup-debug-configs branch January 24, 2024 21:17
Sign up for free to join this conversation on . Already have an account? Sign in to comment
Area-Debugging Issue-BugA bug to squash.
Status: Done

Successfully merging this pull request may close these issues.

Cannot attach debugger to PS 7.4.0 processes