feat(desktop): add a default directory setting for new terminals - #76785
Draft
lukebaber-posthog wants to merge 1 commit into
Draft
feat(desktop): add a default directory setting for new terminals#76785lukebaber-posthog wants to merge 1 commit into
lukebaber-posthog wants to merge 1 commit into
Conversation
New standalone terminals inferred their working directory. One registered folder was used automatically, several meant a folder prompt every time, and nothing registered fell back to the home directory. There was no way to pin a directory, and it had to be a registered project folder at all. Adds Settings > Terminal > Default directory, a native directory picker that accepts any path. Once set, new terminals open there with no prompt, and a "Terminal in..." entry stays available to pick a different directory for one-offs. Behaviour is unchanged when the setting is empty. Also expands a leading "~" in ShellService.resolveWorkingDir before the existsSync check, so tilde paths are no longer silently discarded for home. Generated-By: PostHog Code Task-Id: 0f581bf1-c527-4e0c-9e73-eee5559a508f
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
New terminals in the desktop app pick their working directory implicitly. With one registered project folder that folder gets used, with several you get a folder prompt every time, and with none it falls back to your home directory. There is no way to pin a directory, and it has to be a registered project folder, so a plain notes or scratch directory cannot be the default at all.
Changes
Settings > Terminal now has a Default directory row: a native directory picker that accepts any path, not just a registered project folder. Once set, new terminals open there with no prompt. A "Terminal in..." entry stays in the new-terminal footer for one-off overrides, so folder choice is not lost. When the setting is empty, behaviour is exactly what it is today.
ShellService.resolveWorkingDirnow expands a leading~before itsexistsSynccheck. A tilde path previously failed that check and was silently swapped for the home directory, which also quietly affected thecwd="~"used by the CLI onboarding step.The preference lives in the existing persisted
settingsStorenext to the other terminal settings, so there is no new tRPC procedure or host-side store. The row is hidden on hosts without local workspaces, since there is no local pty there.No screenshots: I was not able to run the Electron app in this environment. See below for what that leaves unverified.
How did you test this code?
Automated only, all run by me (Claude) in this repo after porting the change:
packages/uisettingsStore.test.tspackages/uicommand-center(incl.TaskSelector.test.tsx)packages/workspace-servershell.test.tspackages/uitypecheck@posthog/agentdist in my sandbox), none in touched filesNew test groups, and the regression each one catches that no existing test did:
settingsStore.test.ts> "terminal default directory": the setting silently failing to persist. Adding a field to the store but omitting it frompartializestill type-checks and still passes every other test, and the value is then lost on restart.shell.test.ts> "createSession working directory": a tilde path being discarded in favour of the home directory, which is the exact bug fixed here, plus the empty, missing and undefined cwd fallbacks that nothing pinned before.TaskSelector.test.tsx> two new cases: the default being ignored so the folder prompt still appears, and the "Terminal in..." escape hatch vanishing once a default is set. The two existing cases in that file only cover popup width.Note
Not verified: I did not drive the running app, so the directory picker dialog and the new-terminal footer layout are unexercised. That footer can now show up to four buttons (New task, Terminal, Terminal in..., Brainrot) and may want a width check before this leaves draft.
Automatic notifications
Docs update
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Luke asked for new terminals to always open in a directory of his choosing. I (Claude, via PostHog Code) wrote all of the code here. No skills invoked.
This began as PostHog/code#3890. That repo froze on 1 August behind the monorepo migration, and a repo-wide ruleset now blocks every ref update there, so the finished branch could not be pushed. I rebased it onto
products/desktophere instead.terminalDefaultCwddid not exist in the monorepo yet, so nothing is duplicated.Decisions worth a reviewer's eye:
FolderPicker. Its "Open folder..." path callsaddFolder(), which registers the directory as a project repository. A default terminal directory should be able to be any directory, so this callsos.selectDirectorydirectly, matching "Default folders for new chats" inWorkspacesSettings.terminal_custom_font_family.Only
TaskSelector.tsxhad moved on in the monorepo (#76570 swapped a utility class for an inline style). No overlap with my hunks, and both changes coexist. ItsTaskSelector.test.tsxis new here and had no counterpart in the old repo, which is where the two component tests went.