fs: remove dead streamChat and mergeCtx

This commit is contained in:
Levi Neely 2026-08-13 21:09:53 +02:00
parent 4bb08e860b
commit 324247b6a5
1 changed files with 0 additions and 42 deletions

View File

@ -4,7 +4,6 @@ package fs
import (
"bytes"
"context"
"fmt"
"strings"
"sync"
@ -14,13 +13,6 @@ import (
"ollie/virtfs"
)
// mergeCtx returns a context that cancels when either parent or child cancels.
func mergeCtx(parent, child context.Context) (context.Context, context.CancelFunc) {
merged, cancel := context.WithCancel(parent)
stop := context.AfterFunc(child, func() { cancel() })
return merged, func() { stop(); cancel() }
}
// wireAgentEvents sets the state change callback on an agent.
func wireAgentEvents(sessID string, ag *agent.Agent) {
ag.SetOnStateChange(func(agentID, state string) {
@ -42,40 +34,6 @@ func dispatch(handlers map[string]func([]string) ([]byte, error), data []byte) (
return h(parts[1:])
}
// streamChat blocks until new data is available in the agent's chat log.
func streamChat(ag *agent.Agent, cctx context.Context, base string) ([]byte, string, error) {
ctx, cancel := context.WithCancel(cctx)
defer cancel()
context.AfterFunc(ctx, func() { ag.ChatCond().Broadcast() })
mu := ag.ChatMu()
var offset int
if base != "" {
fmt.Sscanf(base, "%d", &offset)
} else {
mu.RLock()
offset = len(ag.ChatLog())
mu.RUnlock()
}
mu.RLock()
for len(ag.ChatLog()) <= offset {
if ctx.Err() != nil {
mu.RUnlock()
return nil, "", nil
}
ag.ChatCond().Wait()
}
log := ag.ChatLog()
data := make([]byte, len(log)-offset)
copy(data, log[offset:])
newOffset := len(log)
mu.RUnlock()
return data, fmt.Sprintf("%d", newOffset), nil
}
// stripMarkers removes [[[...]]] marker lines and source fence delimiter lines
// from raw chat data. Content inside fences is preserved — only the ``` lines
// themselves are stripped.