From c8175c053f717152dbce30de21c1cd5c19017591 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 4 Jun 2026 10:43:43 +0200 Subject: [PATCH] Fire queued ReadToEnd callbacks when the initial read reaches EOF A task's read loop processes one LinesToRead request at a time. The initial request has a large line count and no Then callback; if the content is shorter than that, the loop hits EOF on the initial request and breaks out, abandoning any further requests still sitting in the readLines channel. So a ReadToEnd call that races a still-loading-but-shorter-than-its-initial-read view has its Then silently dropped: it isn't fired immediately (the channel was non-nil at call time) and it's never dequeued. On EOF, drain the queued requests and fire their Then callbacks before breaking out, since reaching EOF trivially satisfies any "read more" request. Co-Authored-By: Claude Opus 4.8 (1M context) --- pkg/tasks/tasks.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/tasks/tasks.go b/pkg/tasks/tasks.go index 059bf2173..e010a77b5 100644 --- a/pkg/tasks/tasks.go +++ b/pkg/tasks/tasks.go @@ -401,6 +401,21 @@ func (self *ViewBufferManager) NewCmdTask(start func() (Cmd, io.Reader), prefix // means a newer task is taking over and is still loading. self.loading.Store(false) callThen() + // Any read requests that were queued while we were reading are + // now trivially satisfied, since we've read everything. Fire + // their callbacks instead of dropping them when we break out of + // the loop below (and nil out readLines). + drain: + for { + select { + case queued := <-*self.readLines.Load(): + if queued.Then != nil { + queued.Then() + } + default: + break drain + } + } break outer } writeToView(append(line, '\n'))