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 <noreply@anthropic.com>
This commit is contained in:
Levi Neely 2026-04-16 22:14:42 +02:00
parent de1bf9612d
commit 261fa547fb
1 changed files with 5 additions and 3 deletions

View File

@ -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()
}
}