[PR #15280] Use a "virtual CWD" for each terminal window #30568

Closed
opened 2026-01-31 09:41:35 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/15280

State: closed
Merged: Yes


Before process model v3, each Terminal window was running in its own process, each with its own CWD. This allowed startingDirectory: . to work relative to the terminal's own CWD. However, now all windows share the same process, so there can only be one CWD. That's not great - folks who right-click "open in terminal", then "Use parent process directory" are only ever going to be able to use the CWD of the first terminal opened.

This PR remedies this issue, with a theory we had for another issue. Essentially, we'll give each Terminal window a "virtual" CWD. The Terminal isn't actually in that CWD, the terminal is in system32. This also will prevent the Terminal from locking the directory it was originally opened in.

Many more notes on this topic in https://github.com/microsoft/terminal/issues/4637#issuecomment-1531979200

Warning

Breaking change‼️

This will break a profile like

{
    "commandline": "media-test.exe",
    "name": "Use CWD for media-test",
    "startingDirectory": "."
},

if the user right-clicks "open in terminal", then attempts to open that profile. There's some theoretical work we could do in a follow up to fix this, but I'm inclined to say that relative paths for commandlines were already dangerous and should have been avoided.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/15280 **State:** closed **Merged:** Yes --- Before process model v3, each Terminal window was running in its own process, each with its own CWD. This allowed `startingDirectory: .` to work relative to the terminal's own CWD. However, now all windows share the same process, so there can only be one CWD. That's not great - folks who right-click "open in terminal", then "Use parent process directory" are only ever going to be able to use the CWD of the _first_ terminal opened. This PR remedies this issue, with a theory we had for another issue. Essentially, we'll give each Terminal window a "virtual" CWD. The Terminal isn't actually in that CWD, the terminal is in `system32`. This also will prevent the Terminal from locking the directory it was originally opened in. * Closes #5506 * There wasn't a 1.18 issue for "Use parent process directory is broken" yet, presumably selfhosters aren't using that feature * Related to #14957 Many more notes on this topic in https://github.com/microsoft/terminal/issues/4637#issuecomment-1531979200 > **Warning** > ## Breaking change‼️ This will break a profile like ```json { "commandline": "media-test.exe", "name": "Use CWD for media-test", "startingDirectory": "." }, ``` if the user right-clicks "open in terminal", then attempts to open that profile. There's some theoretical work we could do in a follow up to fix this, but I'm inclined to say that relative paths for `commandline`s were already dangerous and should have been avoided.
claunia added the pull-request label 2026-01-31 09:41:35 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#30568