MCPcopy
hub / github.com/docker/docker-agent / messageModel

Struct messageModel

pkg/tui/components/message/message.go:43–80  ·  view source on GitHub ↗

messageModel implements Model

Source from the content-addressed store, hash-verified

41
42// messageModel implements Model
43type messageModel struct {
44 message *types.Message
45 previous *types.Message
46
47 width int
48 height int
49 focused bool
50 selected bool
51 hovered bool
52 expanded bool
53 spinner spinner.Spinner
54
55 // renderCache memoizes the output of Render(width) keyed by the inputs
56 // that affect its output. During streaming, View() and Height() are called
57 // in pairs for each new chunk, and the chat list also re-renders for hover
58 // tracking and scroll updates; without this cache each call would re-parse
59 // the entire accumulated markdown from scratch.
60 renderCache renderCache
61
62 // codeBlocks holds the fenced code blocks emitted by the last call to
63 // render() for assistant messages, with Line indices translated into the
64 // messageModel's own View() output coordinate system (i.e. zero-indexed
65 // from the first line of View()).
66 codeBlocks []markdown.CodeBlock
67
68 // mdRenderer is reused across renders of an assistant message so that
69 // streamed-in chunks only re-render the trailing block instead of the whole
70 // accumulated markdown each time.
71 mdRenderer *markdown.IncrementalRenderer
72
73 // finalized is set by Finalize() once the message is no longer the active
74 // streaming view. After it is set, Render() still produces correct output,
75 // but does not store anything in renderCache and does not retain an
76 // IncrementalRenderer between calls — both are pure caches whose memory
77 // dominates a long session, and they are not worth keeping for messages
78 // that are unlikely to be re-rendered hot.
79 finalized bool
80}
81
82// renderCache stores the most recent Render result keyed by the inputs that
83// can change its output. The key is small enough (a string and a few flags)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected