Skip to content

Commit dbdf60d

Browse files
owenconticlaude
andcommitted
viewer: fix e editor handoff never returning to the viewer
Running the editor via `$SHELL -ic` let the interactive shell enable job control and take over the TTY's foreground process group; when it exited it left the TTY pointing at a dead group, so the relaunched Ink viewer died with `setRawMode failed with errno: 5` instead of coming back. Run the editor via a plain non-interactive `-c` shell, which never touches the foreground group. Env vars like $EDITOR still resolve in the template; rc-file aliases no longer do (docs updated). Also replace a stray NUL byte in src/pr.mjs (inside latestChecks' dedup key, clearly meant to be a space) that made git/grep treat the file as binary. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent d649aaa commit dbdf60d

4 files changed

Lines changed: 16 additions & 10 deletions

File tree

index.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,13 @@ while (true) {
171171
// released the terminal, so stdio "inherit" hands the real TTY to a terminal
172172
// editor (vi/nano) and blocks until it exits; then we re-read the working tree
173173
// (they may have edited the file) and re-launch the viewer on the fresh diff.
174+
// The shell must NOT be interactive (`-i`): an interactive shell enables job
175+
// control, moves the TTY's foreground process group to itself, and leaves it
176+
// pointing at a dead group on exit — the relaunched viewer then dies with
177+
// `setRawMode failed with errno: 5` instead of coming back.
174178
if (handoff.edit) {
175179
const shell = process.env.SHELL || "/bin/sh";
176-
const res = spawnSync(shell, ["-ic", handoff.edit.cmd], { stdio: "inherit" });
180+
const res = spawnSync(shell, ["-c", handoff.edit.cmd], { stdio: "inherit" });
177181
if (res.error) console.error(`\norbit-diff: couldn't launch editor: ${res.error.message}`);
178182
let next;
179183
try {

orbit-diff.config.example.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ export default {
1818
model: "claude-opus-4-8", // any model id Pi knows for the provider above
1919
thinkingLevel: "medium", // off | minimal | low | medium | high | xhigh
2020
// Pressing `e` on a file in the diff viewer opens it in this editor. The {file}
21-
// token becomes the file's absolute path (shell-quoted) and the command runs in
22-
// your login shell (aliases/functions work). Terminal editors are fine — the
23-
// viewer hands over the terminal while the editor runs and reloads the diff when
24-
// you exit it. Empty disables `e`.
21+
// token becomes the file's absolute path (shell-quoted) and the command runs via
22+
// your shell non-interactively (env vars like $EDITOR resolve; rc-file aliases
23+
// don't). Terminal editors are fine — the viewer hands over the terminal while
24+
// the editor runs and reloads the diff when you exit it. Empty disables `e`.
2525
editor: "", // e.g. "vi {file}" · "code {file}" · "$EDITOR {file}"
2626
review: {
2727
concurrency: 4, // how many files to review in parallel (1–8)

src/ai/config.mjs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ export const DEFAULTS = {
2828
thinkingLevel: "medium",
2929
// Command run when you press `e` on a file in the diff viewer to open it in your
3030
// editor. The `{file}` token is substituted with the file's absolute path
31-
// (shell-quoted); the command runs in your login shell so aliases/functions
32-
// resolve. Terminal editors work — the viewer hands over the terminal while it
33-
// runs and reloads the diff when you exit. Empty = `e` is disabled.
31+
// (shell-quoted); the command runs via your shell non-interactively (env vars
32+
// like $EDITOR resolve; rc-file aliases don't). Terminal editors work — the
33+
// viewer hands over the terminal while it runs and reloads the diff when you
34+
// exit. Empty = `e` is disabled.
3435
// e.g. "vi {file}" · "code {file}" · "$EDITOR {file}"
3536
editor: "",
3637
review: { concurrency: 4 },
@@ -79,8 +80,9 @@ export default {
7980
model: "claude-opus-4-8", // any model id Pi knows for the provider above
8081
thinkingLevel: "medium", // off | minimal | low | medium | high | xhigh
8182
// Pressing \`e\` on a file opens it in this editor. {file} = the file's absolute
82-
// path (shell-quoted); runs in your login shell. Terminal editors work — the
83-
// viewer hands over the terminal and reloads the diff when you exit. Empty = off.
83+
// path (shell-quoted); runs via your shell ($EDITOR etc. resolve). Terminal
84+
// editors work — the viewer hands over the terminal and reloads the diff when
85+
// you exit. Empty = off.
8486
editor: "", // e.g. "vi {file}" · "code {file}" · "$EDITOR {file}"
8587
review: {
8688
concurrency: 4, // how many files to review in parallel (1–8)

src/pr.mjs

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)