we got a user report that using lazygit broke the interactive "Link this commit to…
Private research annotation
Sign in to add a private research label or note.
- User
we got a user report that using lazygit broke the interactive "Link this commit to session context" question when using entire for the first time on a new repo. Can we detect lazygit in the same way we detect already other none interactive sessions?
Assistant
Let me verify empirically what a git hook actually sees, since that decides which signal is usable.
- Assistant· <synthetic>
API Error: 529 Overloaded. This is a server-side issue, usually temporary — try again in a moment. If it persists, check https://status.claude.com.
- User
we got a user report that using lazygit broke the interactive "Link this commit to session context" question when using entire for the first time on a new repo. Can we detect lazygit in the same way we detect already other none interactive sessions?
Assistant
Confirmed the key signal. Let me check the other hook-context prompt sites and how tests force interactivity.
Assistant
The fd-based signal may vary by git version, so let me test a more robust one: whether the controlling terminal is in raw mode (i.e. a TUI owns the screen).
Assistant
Both signals separate cleanly. The termios one is the right primitive (git's hook fd plumbing varies by version; terminal ownership doesn't). Let me check available deps.
Assistant
Now implementing. First the platform seam:
Assistant
Now wire it into the detection precedence:
Assistant
Both directions pass on a real pty. Now let me verify the full production predicate in a real process under a cooked vs raw terminal:
Assistant
Now the docs and a lint/test pass:
Assistant
Yes — but not through an env var, and the fix lands in the same central place as the other signals.
- User
simplify /simplify
Assistant
I'll gather the diff and launch the four review agents.
Assistant
Now launching the four review agents in parallel.
Assistant
All four review agents are running. Waiting for their findings before applying fixes.
Assistant
Efficiency came back clean. Waiting on the remaining three.
Assistant
Confirmed
defer func() { _ = x.Close() }()is the established repo convention (transcript.go:167, api_cmd.go:125, login.go:270), so that part matches. Still waiting on the reuse, simplification, and altitude agents.Assistant
I'll hold here until the remaining three agents report.
Assistant
Holding for the three remaining agents — their completion notifications will re-invoke me automatically.
Assistant
Altitude verdict: right layer, no lazygit-specific leak, one flagged side effect I'll weigh (stderr-warning sites in
checkpoint_policy.go/hooks_git_cmd.gonow also suppressed under a TUI). Note that lazygit pipes git's stderr, so the agent's suggestedIsTerminalWriter(os.Stderr)swap would suppress those warnings too — I'll factor that in during Phase 2. Waiting on the reuse and simplification agents.Assistant
Verified both claims:
unix.IoctlGetTermioshas the same signature on darwin and linux (the signed variant is aix/solaris only), andcharmbracelet/x/termios.GetTermiosdoes hide the OS split. Waiting on the last agent before I restructure, so the edits land in one pass.Assistant
All four reports are in. Applying the fixes:
Assistant
Now trimming the duplicated rationale in
interactive.goand simplifying the deferredClose:Assistant
--fix/gofmt -stouched three unrelated files, and staticcheck is reporting nondeterministically (182 vs 187 on identical runs). Checking both:Assistant
--fixstripped deliberate//nolint:staticchecksuppressions from three unrelated files — that's what unleashed the extra staticcheck noise. Reverting them and re-linting:Assistant
Cache artifact from the
--fixrun — aftercache clean, my tree is 0 issues. Now re-verifying behavior and tests after the restructure:Assistant
- User
can you commit meaningful and open a PR?
- Assistant· <synthetic>
No response requested.
- User
This is failing only on linux os not on macos because of: Not the hook code — the controlling-terminal inheritance differs:
- macOS: child git (and its hook) commonly keeps the login shell's controlling terminal through the process group. Opening /dev/tty resolves to the real terminal. Hook works.
- Linux: with lazygit's pipe/session setup the child loses the controlling terminal. open("/dev/tty") with no controlling tty returns ENXIO / the read blocks forever. Hook fails or hangs.
Right now, you are running inside a docker image os linux. lazygit is installed and I tested this fix and lazygit keeps bloking because entire keeps prompting on git hooks. Please, test this fix using real tools and propose a proper fix for this.
Assistant
The environment has changed — I'm on Linux now with real lazygit available, so let me reproduce it properly instead of reasoning about it.
Assistant
tmux and go are available through mise. Let me get their paths and build.
Assistant
No tmux binary, but Go is there and
creack/ptyis already a dependency — I'll drive real lazygit through a real pty from Go. First, the ground truth about what's installed:Assistant
Installed binary is built from the fix commit, so it's not a stale-binary issue. Time to instrument what the hook actually sees under real lazygit. Writing a probe + a pty driver:
Assistant
Reproduced the bug with real lazygit — and the probe shows my raw-mode assumption was simply wrong on Linux:
codeancestry: probe <- prepare-commit- <- git(pid=9553 sid=9553 tty_nr=34818) <- lazygit(pid=9492 sid=9492 tty_nr=34817) /dev/tty termios: icanon echo isig ← canonical, NOT raw CanPromptInteractively() = true ← still promptslazygit gives
git commita brand-new pty in a new session (note the differenttty_nrandgitbeing its own session leader). That pty is canonical, so the raw-mode check can't see it. Let me measure the genuine human case for comparison, with more fields:Assistant
lazygit's capture pty has no window size (0x0) and
gitis its own session leader. Now the genuine human case for comparison — a real interactive shell on a real pty:Assistant
Two clean discriminators. Now let me check lazygit's source to know why the size is 0x0 and whether that's stable:
Assistant
Critical finding — lazygit master sets
StartPty(cmd, 80, 24)("avoids a zero-size pty"), so winsize is not a stable signal; it would fix 0.48 and break on the next release. The stable discriminator is structural: in case Asid == pgrp(git is its own session leader, private pty), in case Bsid != pgrp(the shell's job control gave git its own process group). Let me verify that holds for bash too:Assistant
Job-control invariant confirmed with bash too (
pgrp=9786,sid=9784). Implementing the structural fix:Assistant
Now re-running all three real-world shapes against the patched predicate:
Assistant
Fix confirmed against real lazygit. Now the end-to-end proof with the real
entirebinary, real hooks and a real session. Let me find the cheapest way to create an active session:Assistant
Now the full end-to-end: real
entire, real hooks, a real agent session, real lazygit — old binary vs patched:Assistant
The old-binary run didn't even commit — my
akeystroke unstaged the already-staged files, and vogon'ssession-endleft no active session. Let me fix both:Assistant
Bug reproduced end-to-end with the old binary: the prompt painted into lazygit's captured pty and no commit was ever created. Let me see it, then run the patched binary:
Assistant
Exact user-reported symptom, reproduced verbatim. Now the patched binary:
Assistant
End-to-end proven: patched binary commits cleanly with
Entire-Checkpointauto-linked and zero prompt leakage. Before I finalize the scope, one design question — whether this check should be global:Assistant
versioncheckruns on every command including hooks (protected only by a second stderr check). That settles the scoping question — let me look at the hook command choke point:Assistant
Now scoping the new signal to the git-hook context (so
ssh -t host entire enableanddocker run -itkeep prompting), using thehooks gitchoke point:Assistant
Now the hook-context latch:
Assistant
Now automated tests for the new primitive, using controlled process shapes:
Assistant
Scoping changed, so the end-to-end must be re-proven with a rebuilt binary — this also verifies
MarkGitHookContextis actually reached:Assistant
Now the mirror-image check: a human in a real terminal must still get the prompt with the patched binary:
Assistant
Both directions verified with real tools. Now updating the docs and running full verification:
Assistant
Both pre-existing on clean HEAD (root-in-Docker artifacts), not from my change. Now integration + canary, invoked directly since mise's tmux install is broken here:
Assistant
Also pre-existing. Now the E2E canary:
Assistant
Canary needs
tmux, which can't install in this container — I'll flag that as unrun. Checking branch/PR state before committing:Assistant
ghisn't installed and there's no token here, so I can commit and push but can't open the PR programmatically. Committing first:Assistant
Push failed — no GitHub credentials in this container. Checking whether any auth path exists before I hand it back:
Assistant