]> git.giacomolli.uk - onechat/blobdiff - view.go
Run the turns of an agent in a loop
[onechat] / view.go
diff --git a/view.go b/view.go
index 70182d0114470f36df90543f70a7faab103a086b..8e71eeca205a4f83052c5c91a8fabf7486fc321e 100644 (file)
--- a/view.go
+++ b/view.go
@@ -280,9 +280,19 @@ func (v *View) lineSize(line nodeKey) int {
 // Render returns the view as the model reads it: one line "id+n|text" for each
 // node inside <chat> tags, with the newlines of the text as spaces.
 func (v *View) Render() string {
+       return v.RenderWithout(nil)
+}
+
+// RenderWithout returns the view as Render does, without the leaf lines of the
+// messages in skip. A line that merges such a message with others stays.
+func (v *View) RenderWithout(skip map[int]bool) string {
        var text strings.Builder
        text.WriteString("<chat>\n")
        for _, line := range v.lines {
+               if line.level == 0 && skip[line.index] {
+                       continue
+               }
+
                v.renderLine(&text, line)
        }