Open new terminals in the focused session's directory - #250
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
jiweiyuan
force-pushed
the
fix/new-terminal-cwd
branch
from
August 12, 2026 08:59
9254102 to
e16e69d
Compare
jiweiyuan
force-pushed
the
fix/new-terminal-cwd
branch
from
August 12, 2026 09:40
e16e69d to
e756aa4
Compare
New Terminal (⌘T) starts the shell where the user already is — the cwd the focused session last reported over OSC 7, falling back to that session's own spawn anchor and then $HOME — and lands the row beside that session, in its project and worktree bucket. ⌘⇧T keeps the always-$HOME terminal as its own File menu verb. Closes #243
jiweiyuan
force-pushed
the
fix/new-terminal-cwd
branch
from
August 12, 2026 09:46
e756aa4 to
744e627
Compare
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.
New Terminal always started a shell at
$HOME, so the shortcut people reach for to "open another shell right here" threw away where they were.⌘T now opens the terminal in the focused session's working directory and lands it beside that session — same project, same worktree bucket — instead of creating a project-less scratch session. The directory is the cwd the session last reported over OSC 7 (
workingDirectory(for:)); when no shell integration ever reported one, or the reported path isn't a local directory (an SSH terminal reports a remote path), it falls back to the session's own spawn anchor, then to the project root, and finally to$HOMEwhen nothing is focused at all.The seeded directory rides on a new
Session.spawnDirectory, persisted so a relaunched shell reopens where it was opened. A loose terminal's ownlastWorkingDirectorystill wins over it — a shell that reported its cwd knows better than the seed.A shell never lands in the Chats funnel: ⌘T from a scratch chat opens the terminal in the Terminals section, seeded with the chat's directory.
The old behavior stays available as its own verb, New Terminal at Home, in the File menu and in the sidebar's
+pull-down.Which entry points follow the focus
The
+pull-down is context-free by construction — New Chat always lands in the Chats funnel, New SSH Connection always in Terminals, none of them read the selection — and it sits in the sidebar's toolbar, where "here" has no clear meaning. So its terminal entry is the$HOMEone, named for where it starts. The directory-following New Terminal is reached where the terminal is actually in front of you: ⌘T, the File menu, and the Command Palette (which lists it with its ⌘T binding, alongside its other selection-dependent verbs). The Terminals section header keeps its own local "New Terminal", which adds to that container as before.How this compares to the neighbours
niltoghostty_surface_new, which falls back to the process CWD —/for a Finder-launched app. This ladder never ends innil, which is the same trapProject.firstRunProjects()already documents.window-inherit-working-directoryto true, needs shell integration for it, and falls back to a configured default otherwise — the same three rungs.terminal.working_directory, defaultcurrent_project_directory) and never follows acd. That is the editor answer; termio is terminal-first, and the report behind New Terminal starts in $HOME, not the focused session's directory #243 was a user expecting terminal semantics.On the second binding
The issue proposed ⌘⇧T for New Terminal at Home. It ships unbound instead, for the reason
splitLeft/splitUpalready ship unbound: opening a shell at~when your work is in a project is the rare direction, and ⌘⇧T is "reopen closed tab" muscle memory everywhere else on the Mac — worth keeping free for a session-shaped command later. The verb stays in the File menu and in Settings ▸ Keyboard, so it is one binding away for anyone who wants it. Reverting is one line inKeyCommandCatalog.Worth noting that ghostty and cmux both spell this escape hatch as a config key rather than a verb, and cmux#177 is what that costs when the key isn't plumbed through: five confused users and an open bug. A menu item calling
addScratchTerminal()— a function that already had three call sites — can't fail that way.Known limit
For a session in a real project, right after an app relaunch and before the shell's first OSC 7, ⌘T lands at the project root rather than the subdirectory the shell was in. That is deliberate: a project session's anchor is the project (
docs/design/loose-terminal-entity.md), and only loose terminals persist their own cwd. It can never land at~. cmux has the same gap without the floor — after a restore, its ⌘T drops to~(last comment on #177).Docs
web/landing/src/data/keybindings.jsonis regenerated withpnpm keybindings:sync; the shortcut tables are not hand-written. The one prose paragraph added tokeyboard.mdxis translated inkeyboard.zh-CN.mdxand re-stamped.docs:checkpasses.Verification
swift build,swift test(172 tests), andpnpm docs:checkpass. CI is green.cdinside a project session then ⌘T (new terminal starts there, row lands beside it), ⌘T from a loose terminal (sibling in Terminals at the same cwd), File ▸ New Terminal at Home (starts at~, no shortcut shown), and Settings ▸ Keyboard listing it under File as unbound.Closes #243
Release Notes: