gt feed --plain -f goes silent after gt krc prune replaces .events.jsonl
Bug Description
gt feed --plain -f goes silent after gt krc prune runs. The process stays alive, prints nothing to stderr and never exits, so it looks like a quiet town.
Follow mode (PrintGtEvents in internal/tui/feed/print_events.go) tails .events.jsonl through the file descriptor it opened at startup. The pruner replaces the file through a temp file and os.Rename (Pruner.pruneFile in internal/krc/krc.go, and internal/krc/autoprune.go) on every run, including runs that print No expired events to prune. After the rename the follower keeps reading the old, unlinked inode and never sees new events.
Steps to Reproduce
- In a town, run
gt feed --plain -f. - In another shell, run
gt krc prune. The file's inode changes (checked withstat -f %i .events.jsonl). - Append an event line to
.events.jsonl.
Expected Behavior
The new event prints, as events did before step 2.
Actual Behavior
Nothing prints after the prune. gt feed --plain -f keeps running with no output and no error.
Environment
- OS: macOS 27.0 (arm64)
- Go version: go1.27.1
- Gas Town version: HEAD-649b832 (Homebrew), identical to current
main - tmux version: 3.7c
Logs / Error Output
Reproduced on a build of 649b832 in a throwaway town. After a real gt krc prune the inode went from 70821045 to 70821072. The original build streamed nothing further (events B1 and B2 never appeared) while the process stayed alive. A build with the change below streamed both.
Additional Context
A fix is available as a branch with 4 new tests, with go test ./internal/tui/feed ./internal/krc and -race passing. It follows by path, drains the open file, reopens on an inode change or a shrink, skips events already printed and reassembles split lines. I can open a PR if that is welcome.
Two smaller things found while tracing this:
gt feed --helpsays--plainusesbd activity, but it tails.events.jsonldirectly.krc prunecan drop events appended between its read of the file and its rename.
Source: gastownhall/gastown