Repository navigation
Keep Ghostty terminals in the active working directory - #8033
sebishogun wants to merge 10 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Ensures new Ghostty windows inherit the active terminal’s working directory by avoiding shared-process launches.
Changes:
- Disables Ghostty single-instance mode and provides an Omarchy desktop entry.
- Updates selection, installation, refresh, and migration flows.
- Adds integration and migration coverage.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 6 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
config/ghostty/config |
Disables single-instance mode. |
default/ghostty/com.mitchellh.ghostty.desktop |
Adds the multi-process desktop entry. |
bin/omarchy-default-terminal |
Installs the entry and clears terminal cache. |
bin/omarchy-install-terminal |
Integrates the entry during installation. |
bin/omarchy-refresh-applications |
Restores a missing Ghostty entry. |
migrations/1787566169.sh |
Migrates existing Ghostty users safely. |
test/shell.d/default-apps-test.sh |
Tests selection and installation flows. |
test/shell.d/ghostty-cwd-test.sh |
Tests configuration and desktop contracts. |
test/shell.d/ghostty-cwd-migration-test.sh |
Tests migration behavior and idempotency. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 9 changed files in this pull request and generated no new comments.
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
migrations/1787566169.sh:10
- This migration only recognizes Ghostty's legacy
~/.config/ghostty/configpath. Ghostty 1.3.1 also uses~/.config/ghostty/config.ghosttyas its primary config path (while still loading the legacy file), so an existing user with only the current-format config is treated as a non-user: the migration exits before installing the desktop override, and the packaged--gtk-single-instance=truebehavior remains. Collect both existing config paths, preserve an explicit setting found in either, and append the default to the later-loaded current-format file when present.
ghostty_config="$HOME/.config/ghostty/config"
ghostty_desktop="$HOME/.local/share/applications/com.mitchellh.ghostty.desktop"
[[ -f $ghostty_config ]] || exit 0
|
Addressed Copilot's suppressed Ghostty 1.3.1 loads both XDG config filenames in this order:
The migration now collects both existing files in that order, preserves an explicit Coverage now includes current-format-only users, both-file precedence, explicit settings in either file, idempotence, and users with no Ghostty config. The focused tests and all 192 shell test files pass. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 9 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
migrations/1787566169.sh:16
- Ghostty 1.3.1 does not load these files in sequence: it uses the first non-empty
config.ghostty, otherwise the first non-empty legacyconfig. Grepping both files can therefore let a setting in the ignored legacy file suppress the required setting in the active current file. Worse, whenconfig.ghosttyexists but is empty, appending here makes it active and causes Ghostty to stop loading the user's non-empty legacy configuration. Select the same single non-empty file Ghostty selects, then inspect and update only that file.
if ! grep -Eq '^[[:space:]]*gtk-single-instance[[:space:]]*=' "${ghostty_configs[@]}"; then
printf '\ngtk-single-instance = false\n' >>"${ghostty_configs[-1]}"
|
Reviewed at 4dfcbdd and reproduced on a disposable Omarchy worker (Hyprland 0.56.2, Ghostty 1.3.1-2 installed on top, Ghostty set as the default terminal). Two Ghostty windows sat in On
Codex Medium reviewed it separately. It agreed that the problem is real and that the desktop entry is the essential part, though its independence is not guaranteed. It also pointed out something the tests miss: This now waits on the maintainer. Separate processes per window cost memory and startup time in exchange for correct directories and crash isolation, which is also what #5447 and #6567 ask for. Owning a copy of Ghostty's desktop entry means later upstream changes to it will not reach users without another migration. |
quattro moved omarchy-default-terminal's notification to omarchy-i18n; keep that alongside this branch's xdg-terminal-exec cache invalidation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I reproduced it again at 1ff1028 on a disposable Omarchy worker with Ghostty 1.3.1-2, using the same setup as before: two Ghostty windows opened the way Super+Enter opens them, in
Codex Medium reviewed the merged head separately and found no defects. It agreed the resolution is correct, the migration's older timestamp is harmless because This waits on the maintainer. The trade-offs from the previous comment still stand: one process per window, a copy of Ghostty's desktop entry to maintain, and the migration running for foot-only users. |
quattro dropped the mise.sh call from omarchy-refresh-applications (omacom#9596); keep that removal and the Ghostty desktop entry copy this branch adds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I reproduced it again at f353065 on a disposable Omarchy worker with Ghostty 1.3.1-3, using the same setup as before: two Ghostty windows in
Codex Medium reviewed the merged head separately and found no defects. It agreed that the resolution is correct and loses nothing from either side, that the fix is proportionate, and that the older migration timestamp is harmless because This PR collides with #15780, opened today for #15779, where Ghostty does not launch from the app menu. Both PRs install This waits on the maintainer: whether to take it, given the trade-offs from the earlier comments (one process per window, a copy of Ghostty's desktop entry to maintain, a migration that also runs for foot-only users), and how to order it against #15780. |
[Medium impact] The PR appears safe to merge; no actionable issues remain. SummaryGhostty launches now use separate processes by default so Omarchy can find the active window’s working directory.
No new actionable issues were found. This review inspected the code; it did not rerun tests. Reviews (3) · Last reviewed commit: "Consolidate Ghostty desktop entry tests" · Reviewed by Greptile |
The only conflict was in the default-apps test's package stub, where quattro added plain beside this branch's ghostty; both stay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Omarchy's AGENTS.md rules out a test for a migration, since it runs once and is frozen once it ships, and a test that greps the config or the desktop entry for the line just added. What stays tests the guards in the bin/ commands that install the desktop entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I reproduced it again at f61fbf0 on a disposable Omarchy worker, now with Ghostty 1.4.0-1, using two Ghostty windows in
Codex Medium and muse-wonder (via pi, thinking high) reviewed f61fbf0 separately. Neither found a defect in the merge, the code as it stands on today's Both reviewers also named an interaction to settle before any of these land. #9917 and #17257 each make This waits on the maintainer: whether to give up Ghostty's single-instance mode for one process per window, which means a copy of Ghostty's desktop entry to maintain, and how to order this against #15780, #9917 and #17257. |
|
Thanks @sebishogun. 660923e moves the On a fresh disposable Omarchy worker with Ghostty 1.4.0-1, installed by
Codex Medium and muse-wonder (via pi, thinking high) reviewed this head. Neither found a defect. Both found the moved tests correctly scoped to the test home and checkout, and found that between them the three checks pin the existing-file-or-symlink guard. Both agreed the problem is real and the change is proportionate. Their independence is not guaranteed. muse-wonder suggested the refresh run now makes the later "picking an editor installs the editor handler" check unable to fail. That check could not fail on Nothing else has changed since the last comment. This still waits on the maintainer: whether to give up Ghostty's single-instance mode for one process per window, which means keeping a copy of Ghostty's desktop entry, and how to order this against #15780, #9917 and #17257, which would each undo it as they stand. |
|
@dhh, this PR has been open since August 24 and has gone through several rounds of review by Copilot, Greptile, and Omarchybot’s Codex and muse-wonder reviewers. The latest commit has no outstanding actionable review findings, and Omarchybot has reverified both the bug and the fix on a fresh worker. Could you weigh in on the remaining maintainer decision: whether separate Ghostty processes per window are an acceptable tradeoff for correct working-directory detection, and how this should coordinate with #15780, #9917 and #17257? Happy to make further changes if needed. |
Keep Ghostty terminals in the active working directory
Problem
Super+Enterlaunches the selected terminal with the directory returned byomarchy-cmd-terminal-cwd. Ghostty's packaged desktop entry forces--gtk-single-instance=true, so all top-level windows share one process and Hyprland reports the same PID for each of them. Omarchy can then select a shell belonging to a different window, and Ghostty's single-instance activation also drops the--working-directoryargument for a plain new window.The result is that a new Ghostty window can open in another terminal's directory instead of the active terminal's directory.
Context
Working-directory inheritance predates Ghostty. It was introduced in
2cca0269while Alacritty was the shipped default, before Omarchy moved terminal launching toxdg-terminal-execin4c97a31cand later made Ghostty the default inb6ba588f.The reported setup previously used Kitty as its selected default terminal, where this behavior worked because current Omarchy can query Kitty's focused window through the per-window remote-control socket. Ghostty's packaged desktop entry changes the process model underneath the same Omarchy feature by forcing all top-level windows into one process.
Reproduction on the affected machine
Super+Enter.On this machine, the packaged
/usr/share/applications/com.mitchellh.ghostty.desktoplaunched both actions with--gtk-single-instance=trueand enabled D-Bus activation. The independent windows therefore shared one Ghostty PID.omarchy-cmd-terminal-cwdstarts from the PID reported byhyprctl activewindowand selects a child shell, so that shared PID did not uniquely identify the focused window's shell.The local fix was to set
gtk-single-instance = false, install a user desktop entry with bare GhosttyExeclines and no D-Bus activation, and remove thexdg-terminal-execcache. After opening new top-level Ghostty windows,Super+Enterinherited the focused window's directory again. This patch makes that repair the Omarchy default and applies it to existing users through an idempotent migration.Affected machine (original report)
omarchy-dev 4.0.0.r1791.ged7bae4-10.56.2-11.3.1-20.14.2-10.26.6-1Fix
gtk-single-instance = false, giving independently launched top-level windows distinct processes that Omarchy can map to their shells.--gtk-single-instance=trueoverride and withDBusActivatable=false, so the user configuration controls the process model.xdg-terminal-execcache after a successful terminal selection or installation so the next launch resolves the selected entry immediately.configand currentconfig.ghosttypaths while preserving an explicitgtk-single-instancesetting and any existing desktop override.Tradeoff
Each independently launched Ghostty window now starts a GTK process, which uses more memory and has more startup overhead than sharing one process. This is required for Omarchy's current PID-based working-directory detection.
Ghostty tabs and splits still share their window's process. Omarchy cannot reliably distinguish their focused shell until Ghostty exposes focused-surface process or working-directory information through IPC.
Compatibility with other Ghostty PRs
This fix preserves existing user desktop entries and explicit
gtk-single-instancesettings, including a deliberate opt-in to single-instance mode.The following PRs remain open as of 2026-11-16:
--gtk-single-instance=true. That command-line flag overrides this PR's config default and would restore the working-directory bug; those launch paths need to let the config control single-instance mode.--gtk-single-instance=trueflag. If it lands first, this PR preserves that entry and the working-directory bug remains. These fixes need a shared desktop entry that also omits the forced single-instance flag.Tests
Updated against
quattroatfad23cf8on 2026-11-16. Focused validation on the updated branch:bash test/shell.d/default-apps-test.sh: 30 checks passed. Ghostty selection, direct installation, and application refresh install missing desktop entries, preserve existing entries and dangling symlinks, and invalidate the terminal cache where applicable. Refresh coverage is in this existing suite alongside the installation and selection coverage.bash test/shell.d/terminal-cwd-test.sh: 6 checks passed../test/cli: passed.desktop-file-validate default/ghostty/com.mitchellh.ghostty.desktop: passed.git diff --check: passed.The full shell suite was not rerun for this update. The latest full-suite report records five failures that also reproduce on
quattro; the focused passes above do not establish a green full suite. That report also documents a live reproduction and successful fix with Ghostty 1.4.0-1 on a disposable worker.Fixes #3963
Related to #5447 and #6567