MCPcopy Create free account
hub / github.com/coder/coder / Test_buildManualTitleContext

Function Test_buildManualTitleContext

coderd/x/chatd/quickgen_internal_test.go:175–285  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

173}
174
175func Test_buildManualTitleContext(t *testing.T) {
176 t.Parallel()
177
178 longConversationText := strings.Repeat("a", 3500)
179 longLatestUserText := strings.Repeat("z", 1200)
180
181 tests := []struct {
182 name string
183 turns []manualTitleTurn
184 selected []int
185 wantConversation string
186 wantConversationEmpty bool
187 wantConversationHasGap bool
188 wantConversationRunes int
189 wantLatestUser string
190 wantLatestUserRunes int
191 wantLatestUserContains string
192 wantLatestUserNotEmpty bool
193 }{
194 {
195 name: "adds gap marker when selected turns skip earlier context",
196 turns: []manualTitleTurn{
197 {role: "user", text: "open pull request"},
198 {role: "assistant", text: "checked CI"},
199 {role: "user", text: "review logs"},
200 {role: "assistant", text: "found flaky test"},
201 {role: "user", text: "update chat title"},
202 },
203 selected: []int{0, 3, 4},
204 wantConversationHasGap: true,
205 wantLatestUser: "update chat title",
206 },
207 {
208 name: "omits gap marker for contiguous selection",
209 turns: []manualTitleTurn{
210 {role: "user", text: "open pull request"},
211 {role: "assistant", text: "checked CI"},
212 {role: "user", text: "update chat title"},
213 },
214 selected: []int{0, 1, 2},
215 wantConversation: "[user]: open pull request\n[assistant]: checked CI\n[user]: update chat title",
216 wantConversationHasGap: false,
217 wantLatestUser: "update chat title",
218 },
219 {
220 name: "single useful user turn returns empty conversation block",
221 turns: []manualTitleTurn{{role: "user", text: "rename helper"}},
222 selected: []int{0},
223 wantConversationEmpty: true,
224 wantLatestUser: "rename helper",
225 },
226 {
227 name: "truncates conversation block at six thousand runes",
228 turns: []manualTitleTurn{
229 {role: "user", text: longConversationText},
230 {role: "assistant", text: longConversationText},
231 {role: "user", text: "latest"},
232 },

Callers

nothing calls this directly

Calls 7

buildManualTitleContextFunction · 0.85
NotEmptyMethod · 0.80
RunMethod · 0.65
EmptyMethod · 0.45
EqualMethod · 0.45
ContainsMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected