Repository navigation
Open a new terminal in HOME when the focused window is not a terminal - #15007
Conversation
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>
[Medium impact] The PR appears safe to merge; no blocking issues were found. SummaryThe PR checks that a shell leads its own session and has a controlling terminal before using its directory.
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>
|
Reviewed and verified at 69e866f against Reproduced on a fresh Omarchy worker VM with a real Hyprland session, using the focused window as Pushed: 69e866f adds a fixture to Suite: the full Second opinion: Codex Medium, over two rounds. It found no defect in the fix, and it checked the Related pull requests touching
None of them is a competing fix for #10840. This one waits on the maintainer. |
…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>
…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)
…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.
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
bashin~/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-cwdtakes 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>/statshows 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.shnow runs its stand-in terminal's shell underscript(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 inDownloads, 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