- return shortest(lines), nil
-}
-
-// viewParts returns the parts of the compaction view context: the opening tag,
-// one part for each whole block of viewBlock lines, and the rest of the lines
-// with the closing tag and a newline. Joined, the parts are context and a
-// newline.
-func viewParts(context string) []string {
- lines := strings.SplitAfter(strings.TrimPrefix(context, "<chat>\n"), "\n")
- whole := len(lines) - 1 - (len(lines)-1)%viewBlock
- parts := []string{"<chat>\n"}
- for n := 0; n < whole; n += viewBlock {
- parts = append(parts, strings.Join(lines[n:n+viewBlock], ""))
- }
-
- return append(parts, strings.Join(lines[whole:], "")+"\n")