feat(terminal): add a default directory setting for new terminals - #3890
feat(terminal): add a default directory setting for new terminals#3890lukebaber-posthog wants to merge 5 commits 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 folder picker that accepts any path. Once set, new terminals open there with no prompt; a "Terminal in..." entry stays available to pick a different folder 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 |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
👋 Visual changes detected for this PR. Review and approve in PostHog Visual Review If these changes are unexpected, they may be caused by a flaky test or a broken snapshot on master. Don't approve — rerun the job or wait for a fix. |
|
Hey @lukebaber-posthog, we've migrated this repo into the PostHog/posthog monorepo, so this PR needs to be recreated there. Easiest path: check out the monorepo and run the Shout if you get stuck. |
Problem
There's no way to tell PostHog Desktop which directory a new terminal should open in. Today the working directory is inferred: one registered folder gets used automatically, several means a folder prompt every time, and nothing registered falls back to the home directory. On top of that, the directory has to be a registered project folder — so a plain notes/scripts directory can't be the default at all.
Raised by a teammate who wanted new terminals to consistently open in one personal working directory.
Changes
ShellService.resolveWorkingDirnow expands a leading~before itsexistsSynccheck. Previously a tilde path failed that check and was silently discarded in favour of the home directory — which also quietly affected thecwd="~"used by the CLI onboarding step.The preference lives in the existing persisted
settingsStorealongside the other terminal settings; no new tRPC procedure or host-side store. The row is hidden on hosts without local workspaces, since there's no local pty there.How did you test this?
Ran locally:
pnpm --filter @posthog/workspace-server exec vitest run src/services/shell/shell.test.ts— 14 passed, including new cases covering tilde expansion and the fallbacks for empty/missing/undefined cwd.pnpm --filter @posthog/ui exec vitest run src/features/settings/settingsStore.test.ts— 37 passed, including new persistence/rehydration cases for the setting.pnpm --filter @posthog/ui exec vitest run src/features/command-center— 33 passed.biome checkclean on all touched files.pnpm --filter @posthog/ui typecheckreports 69 errors, all pre-existing — identical count on a stashed tree, caused by unbuilt@posthog/agent/@posthog/enricherdists in this sandbox. None are in the touched files.From my local inspection, behavior is as expected and new terminal sessions open in the selected directory. Here is a screenshot of the change to the terminal settings section:

Automatic notifications
Created with PostHog Code