Skip to content

git error printed over TUI input line #189

Closed

Description

@bertalanv

Symptom

When a pi session is rooted inside a git repository, any bash command that
cds into a directory that is not a git repository prints


fatal: not a git repository (or any of the parent directories): .git

directly onto the terminal — on top of the TUI input line. The text is not part
of the tool result, not in the session file, and disappears on the next TUI
redraw (first keystroke), which makes it look like the input box was
temporarily corrupted.

It happens on every such command, even when the command contains no git
invocation at all (e.g. cd <non-repo-dir> && ls).

Reproduction

  1. Root a pi session in a git repository (so the inGitRepo(sessionRoot) bail
    in the tool_call hook does not trigger).
  2. Run any bash command of the form cd <path> && … where <path> exists but
    is not a git repository (a scratch dir, /tmp, a work directory, …).
  3. Observe the fatal painted over the TUI, while the tool result shows only the
    command's normal output.

Reproduced on bigpowers 2.88.17 and confirmed still present in 2.90.0.
Platform-independent (Node stdio inheritance, not a terminal quirk).

Root cause

In extensions/omp-hooks.ts, the tool_call handler resolves the branch of
the command's target directory:

const pushBranch = currentBranch(commandGitCwd(command, command.length, sessionRoot));

commandGitCwd() follows the last cd / git -C in the
command. currentBranch(cwd) then runs

  execSync("git rev-parse --abbrev-ref HEAD", { encoding: "utf-8", timeout: 3000, cwd });

without a stdio option. Node's execSync inherits the parent's stderr by
default, so when the target directory is not a repository, git writes the
fatal to the agent process's stderr — i.e. straight onto the TTY the TUI is
rendering. The catch that returns "unknown" swallows the exception but not
the already-written stderr.

The inGitRepo() probe just above uses stdio: "ignore" and is silent; the
early bail in the handler only covers process.cwd() (the session root), not
the per-command target directory introduced by #154.

Context

This exact leak was reported and fixed before:

The per-command-target branch resolution from #154 reintroduced the uncaptured
probe, so the #146/#147 protection no longer applies when the session root is
a repo and the command cds elsewhere.

Suggested fix (not validated)

One line in currentBranch() — capture/ignore the child's stdio, mirroring
inGitRepo():

  execSync("git rev-parse --abbrev-ref HEAD", {
    encoding: "utf-8",
    timeout: 3000,
    cwd,
    stdio: ["ignore", "pipe", "ignore"],
  });

Optionally also short-circuit with if (!inGitRepo(cwd)) return "unknown" to
avoid spawning git at all for non-repo targets.

Impact

  • Cosmetic but frequent TUI corruption for anyone whose session root is a repo
    and whose commands cd outside it (scratch dirs, temp dirs, sibling
    projects) — every such command prints the fatal.
  • The leak is invisible to the agent and to the session transcript, which
    makes the symptom confusing and hard to self-diagnose.

Activity

  1. bertalanv commented on Nov 3, 2026

    @bertalanv
    ContributorAuthor

    Hi Daniel,
    I found the issue and validated it, but the report is written by my local model (Qwen3.8-27B-FP8), I hope this feedback is useful in this format, if not pls tell me.
    Bertalan

  2. added a commit that references this issue on Nov 3, 2026
  3. github-actions commented on Nov 3, 2026

    @github-actions

    🎉 This issue has been resolved in version 2.90.1 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions