chatwait: return immediately when session is idle

Fixes a race where the client starts a new chatwait read after the
turn has ended (EnsureTrailingNewline already fired), causing a
5-second blocking delay before the shell prompt reappears.
This commit is contained in:
Levi Neely 2026-05-08 12:15:36 +02:00
parent 46c57923ec
commit 323ae311fe
1 changed files with 3 additions and 0 deletions

View File

@ -198,6 +198,9 @@ func (h *sessionHelper) fileSpec(name string, mode os.FileMode) FileSpec {
ctx, cancel := context.WithCancel(connCtx)
defer cancel()
context.AfterFunc(h.sess.Ctx, cancel)
if h.sess.Core.State() == "idle" {
return nil, nil
}
offset := 0
if base == "" {
n, _ := h.sess.LogInfo()