From 7f9ff18132ae1beeada689089115bb0e19da7fca Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Thu, 20 Aug 2026 12:01:45 +0200 Subject: [PATCH] chat: strip ... blocks in filtered output chat.raw includes everything; chat strips: - [[[...]]] markers - fence delimiters - ... blocks (user prompts) Text clients get clean output; GUI clients use chat.raw for full control. --- cmd/olliesrv/internal/fs/support.go | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/cmd/olliesrv/internal/fs/support.go b/cmd/olliesrv/internal/fs/support.go index 003fb27..5e7a1cf 100644 --- a/cmd/olliesrv/internal/fs/support.go +++ b/cmd/olliesrv/internal/fs/support.go @@ -43,21 +43,38 @@ func dispatch(handlers map[string]func([]string) ([]byte, error), data []byte) ( return h(args) } -// stripMarkers removes [[[...]]] marker lines and source fence delimiter lines -// from raw chat data. Content inside fences is preserved — only the ``` lines -// themselves are stripped. +// stripMarkers removes [[[...]]] marker lines, source fence delimiter lines, +// and ... blocks from raw chat data. Content inside fences +// is preserved — only the ``` lines themselves are stripped. func stripMarkers(data []byte) []byte { var out []byte + inContext := false for len(data) > 0 { nl := bytes.IndexByte(data, '\n') if nl < 0 { - out = append(out, data...) + if !inContext { + out = append(out, data...) + } break } line := data[:nl+1] data = data[nl+1:] trimmed := bytes.TrimRight(line, "\n") + + // Handle block start/end + if bytes.Equal(bytes.TrimSpace(trimmed), []byte("")) { + inContext = true + continue + } + if bytes.Equal(bytes.TrimSpace(trimmed), []byte("")) { + inContext = false + continue + } + if inContext { + continue + } + if len(trimmed) >= 7 && bytes.HasPrefix(trimmed, []byte("[[[")) && bytes.HasSuffix(trimmed, []byte("]]]")) { continue }