Repository navigation
Session drops from the daemon when a commented file leaves a --watch diff #1138
Description
Activity
Still reproduces on 0.23.0 (Linux, mise install, fresh daemon, no extensions loaded). Two additions:
It isn't specific to
--watch. Any reload that leaves out a noted file does it, including pressingr. The everyday version is a review note like "drop this change" that the fix answers by reverting the file:git init -q -b main repro && cd repro for f in a b c; do printf '%s1\n%s2\n%s3\n' $f $f $f > $f.txt; done git add . && git commit -qm base git switch -qc feature sed -i 's/b2/b2 feature/' b.txt && sed -i 's/c2/c2 feature/' c.txt git commit -qam "feature work" # In another terminal, in the same directory: hunk diff "$(git merge-base main HEAD)" hunk session comment add --repo . --file b.txt --new-line 2 --summary "drop this change" git checkout main -- b.txt # the fix: revert b.txt to base # press r in the Hunk window hunk session list --json # {"sessions": []} hunk session comment list --repo . --json # hunk: protocol-validation-failed (exit 1)
The new status-line hint doesn't recover the window. 0.23.0 shows
Session daemon rejected this window. Run `hunk daemon restart`.Afterhunk daemon restart --yes, the window stayed out ofhunk session list(checked 20+ seconds later) and kept showing the same hint. I think that's the "window whose snapshot gets rejected stays disconnected" limitation #1131 lists as follow-up work. Until that lands, it might be worth not suggesting the restart when the rejection was a snapshot validation failure, since it can't help there.For context: we use Hunk as the human side of an agent review loop. The agent annotates the plan, the reviewer leaves notes, and the agent reads them with
hunk session comment list, fixes, and replies withcomment add. The revert case comes up all the time in that loop, and the drop lands right when the agent posts its replies. For now we tell people to open Hunk on the fork point, leave--watchoff, and reload by hand after the agent is done. #1131 would make most of that unnecessary.A correction to my comment above: the trigger is narrower than "a noted file". In my script the note on
b.txtcame fromhunk session comment add, so it was a live (agent) comment. A note typed in the TUI on a file that later leaves the diff does not drop the session. I checked that on 0.23.0 with the same revert-and-rsteps. This matches the diagnosis in #1131:liveCommentCountcounts live comments only.So in an agent review loop, the trigger is the agent's own reply on a file that the fix then reverts. Removing those replies with
hunk session comment rmbefore the revert keeps the session connected. That's the workaround we use until #1131 lands.@shllg sharp catch on live comments only, that's the bug #1131 fixes
after the revert, the window still holds the agent's note on
b.txt, so its snapshot sendsliveCommentCount: 1.liveCommentsonly lists files still in the diff, so it's empty. the daemon rejects a snapshot where those two disagree and closes the window's socket#1131 counts the list instead. the note stays in the window and comes back if
b.txtreturns to the diffi ran both repros from this thread on
mainand on #1131. onmainthe window drops out ofhunk session listafterrand after the--watchcommit. on #1131 it stays listed andcomment listworksagreed on the
hunk daemon restarthint: it can't recover a rejected window. i think that's follow-up work- added 2 commits that reference this issue
on Oct 6, 2026
When a file that has comments drops out of a
--watchreview (for example, right after committing it), Hunk's session disappears from the daemon. The TUI keeps running and still shows the comments, but agents can no longer reach the session.Steps to Reproduce
Expected
The session stays registered, and the comment on the file that left the diff is either kept or dropped, without taking the session with it.
Actual
The session vanishes from
hunk session list, and everyhunk sessioncommand against the repository fails. The TUI gives no sign that anything went wrong.Environment