From 261fa547fbf72ce71adf65fd574c823405a4adc1 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Thu, 16 Apr 2026 22:14:42 +0200 Subject: [PATCH] 9p: fix offset to point past user prompt in chat Capture chatOffset after the user event is appended rather than before Submit, so tail -c +$((offset+1)) yields only the model response for that turn. Co-Authored-By: Claude Sonnet 4.6 --- internal/p9/sessionfilestore.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/p9/sessionfilestore.go b/internal/p9/sessionfilestore.go index ad14985..85070c5 100644 --- a/internal/p9/sessionfilestore.go +++ b/internal/p9/sessionfilestore.go @@ -104,9 +104,6 @@ func (s *SessionFileStore) Put(name string, data []byte) error { } switch name { case "prompt": - s.sess.mu.Lock() - s.sess.chatOffset = len(s.sess.chatLog) - s.sess.mu.Unlock() s.sess.core.Submit(s.sess.ctx, input, s.makePublish()) s.sess.trackMutable() @@ -199,6 +196,11 @@ func (s *SessionFileStore) makePublish() func(agent.Event) { } } s.sess.appendChat(formatEvent(ev)) + if ev.Role == "user" { + s.sess.mu.Lock() + s.sess.chatOffset = len(s.sess.chatLog) + s.sess.mu.Unlock() + } s.sess.trackMutable() } }