Skip to content

Open a new terminal in HOME when the focused window is not a terminal - #15007

Merged
omarchybot merged 2 commits into
quattrofrom
fix/issue-10840
Oct 31, 2026
Merged

omarchybot merged 2 commits into
quattrofrom
fix/issue-10840

Conversation

@omarchybot

@omarchybot omarchybot commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

With a window that is not a terminal focused, SUPER+RETURN can open the new terminal in whatever directory one of that app's helper processes happens to sit in. In #10840 it was Microsoft Edge, whose download left a helper bash in ~/Downloads, so every new terminal opened there. Files, which this helper also opens in the focused terminal's directory, has the same problem.

omarchy-cmd-terminal-cwd takes the focused window's newest child process and uses its directory whenever its executable is listed in /etc/shells. Nothing checks that the window is a terminal, so any app with a shell child qualifies.

A terminal's shell is different from such a helper in a way the kernel records: the terminal starts it as the leader of a new session with the terminal's pty as its controlling tty. Alacritty, Ghostty, kitty, foot and WezTerm all set this up before running the shell. A helper spawned by a browser or any other GUI app has no controlling tty, and is not the leader of its session even when that app was launched from a terminal. So the child's directory is now used only when /proc/<pid>/stat shows it leads its own session with a controlling tty; otherwise the new terminal opens in $HOME. Matching the terminal against a list of window classes would also work, but it needs a list to keep current and a class the Lua binding does not pass.

test/shell.d/terminal-cwd-test.sh now runs its stand-in terminal's shell under script(1), which gives it a pty and its own session the way a real terminal does. It adds a stand-in browser that keeps a helper shell in Downloads, and asserts that this browser gets $HOME. Each fixture is waited for until its shell is actually running in its directory, so neither assertion can pass because a fixture never started.

Fixes #10840

omarchy-cmd-terminal-cwd took the newest child of the focused window and used its directory whenever its executable was a shell, without asking whether the window was a terminal at all. A browser keeping a helper shell in ~/Downloads therefore sent SUPER+RETURN, and Files, to ~/Downloads. A terminal's shell leads its own session on the terminal's pty, which every terminal Omarchy supports sets up before exec'ing the shell; a helper some other app spawned does neither, so the child must now be a session leader with a controlling tty before its directory is used.

The test's stand-in terminal now runs its shell under script(1), which gives it a pty and session as a real terminal does, and a stand-in browser keeps a helper shell in Downloads. Each fixture is waited for until its shell is actually running in its directory, so neither assertion can pass on a fixture that never started.

Fixes #10840

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@greptile-apps

greptile-apps Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

The PR checks that a shell leads its own session and has a controlling terminal before using its directory.

  • New terminals use HOME when the focused app has only a helper shell.

Reviews (2) · Last reviewed commit: "Test an app sharing a terminal's pty, no..." · Reviewed by Greptile

A browser started from a terminal's shell inherits that shell's pty, and so does its helper shell, so a controlling tty alone does not tell a terminal's shell from a helper. The new fixture runs a stand-in browser under script(1) and asserts its helper still gets HOME; it fails if the check is reduced to tty_nr != 0, which the existing fixtures did not catch when the suite runs without a pty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 17, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator Author

Reviewed and verified at 69e866f against quattro. Nothing wrong with the fix; one test case added.

Reproduced on a fresh Omarchy worker VM with a real Hyprland session, using the focused window as hyprctl reports it. An imv window started detached, with a helper bash sitting in a Downloads-style directory, sent a new terminal to that directory on quattro and to $HOME on this branch. The same holds when imv is started from a terminal's shell, so it and its helper share that shell's pty. foot, Alacritty, Ghostty and kitty still open the new terminal in their shell's directory, both before and after; each of their shells leads its own session with a controlling tty, as the check expects.

Pushed: 69e866f adds a fixture to test/shell.d/terminal-cwd-test.sh for an app started from a terminal, whose helper shares its pty. A controlling tty alone cannot tell that helper from a terminal's shell, and when the suite runs without a pty, the existing fixtures did not catch the check being reduced to tty_nr != 0. The new case fails under that reduction, the browser case fails with the script reverted to quattro, and the whole test passes five times out of five, including when run under a pty.

Suite: the full ./test/shell on the worker gave 5590 passed and 7 failed. All 7 fail the same way on quattro (ascii, branding animation, default agent, passwordless grant, runtime smoke, shell shortcuts, unowned system paths), so none come from this change. ./test/cli passes, and CI is green.

Second opinion: Codex Medium, over two rounds. It found no defect in the fix, and it checked the /proc/<pid>/stat parse, including a comm containing ) . It also checked the source of Alacritty, Ghostty, kitty, WezTerm, Konsole, xterm and Rio, and each gives its shell its own session and pty. It raised the missing inherited-pty case, which is the commit above, and its second round on that commit found nothing. Where it agrees with my reading, independence is not guaranteed.

Related pull requests touching bin/omarchy-cmd-terminal-cwd:

None of them is a competing fix for #10840. This one waits on the maintainer.

@omarchybot omarchybot removed verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 17, 2026
@omarchybot
omarchybot merged commit 65f629e into quattro Oct 31, 2026
2 checks passed
omarchybot added a commit to vaknin/omarchy that referenced this pull request Oct 31, 2026
…er resolver

The tree walk now starts only from the window's children that lead their own session on a pty, as omacom#15007 requires, so a browser's helper shell -- with no tty, or sharing the pty of the shell that started the browser -- can no longer answer for a terminal. Its two tests are carried into this file's style.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@emirb emirb added this to the 4.5 milestone Nov 5, 2026
berenddeboer pushed a commit to berenddeboer/omarchy that referenced this pull request Nov 6, 2026
…omacom#15007)

* Open a new terminal in HOME when the focused window is not a terminal

omarchy-cmd-terminal-cwd took the newest child of the focused window and used its directory whenever its executable was a shell, without asking whether the window was a terminal at all. A browser keeping a helper shell in ~/Downloads therefore sent SUPER+RETURN, and Files, to ~/Downloads. A terminal's shell leads its own session on the terminal's pty, which every terminal Omarchy supports sets up before exec'ing the shell; a helper some other app spawned does neither, so the child must now be a session leader with a controlling tty before its directory is used.

The test's stand-in terminal now runs its shell under script(1), which gives it a pty and session as a real terminal does, and a stand-in browser keeps a helper shell in Downloads. Each fixture is waited for until its shell is actually running in its directory, so neither assertion can pass on a fixture that never started.

Fixes omacom#10840

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>

* Test an app sharing a terminal's pty, not only a detached one

A browser started from a terminal's shell inherits that shell's pty, and so does its helper shell, so a controlling tty alone does not tell a terminal's shell from a helper. The new fixture runs a stand-in browser under script(1) and asserts its helper still gets HOME; it fails if the check is reduced to tty_nr != 0, which the existing fixtures did not catch when the suite runs without a pty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>

---------

Co-authored-by: Omarchybot <317366263+omarchybot@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Codex Medium <noreply@openai.com>
(cherry picked from commit 65f629e)
dividendsolo added a commit to dividendsolo/omarchy4mac that referenced this pull request Nov 11, 2026
…at on a monitor move, Bitwarden floats (#39) (#64)

alt-enter runs bin/omarchy-terminal: Ghostty opens in the folder of the
focused terminal's shell (the shell on a pty of its own, under the app's
login or as session leader), else in HOME (omacom/omarchy#15007).
cmd-ctrl-shift-arrow runs bin/omarchy-move-to-monitor, which centres a
floating window on the monitor it lands on via Hammerspoon (#14549).
Bitwarden and 1Password 7 float (#11704); the float rules are listed at
their head. Floating workspaces (#16143) and the backward window cycle
(#8576) already behave in AeroSpace; tests hold both.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SUPER+ENTER abre terminal no cwd de um processo auxiliar da janela focada (ex: download do Edge em ~/Downloads)

2 participants