MCPcopy Index your code
hub / github.com/coder/coder / buildManualTitleContext

Function buildManualTitleContext

coderd/x/chatd/quickgen.go:697–728  ·  view source on GitHub ↗
(
	turns []manualTitleTurn,
	selected []int,
)

Source from the content-addressed store, hash-verified

695}
696
697func buildManualTitleContext(
698 turns []manualTitleTurn,
699 selected []int,
700) (conversationBlock string, latestUserMsg string) {
701 userCount := 0
702 for _, turn := range turns {
703 if turn.role != string(database.ChatMessageRoleUser) {
704 continue
705 }
706 userCount++
707 latestUserMsg = turn.text
708 }
709
710 latestUserMsg = truncateRunes(latestUserMsg, maxLatestUserMessageRunes)
711 if userCount <= 1 || len(selected) == 0 {
712 return "", latestUserMsg
713 }
714
715 lines := make([]string, 0, len(selected)+1)
716 for i, idx := range selected {
717 if i == 1 {
718 if gap := idx - selected[i-1] - 1; gap > 0 {
719 lines = append(lines, fmt.Sprintf("[... %d earlier turns omitted ...]", gap))
720 }
721 }
722 lines = append(lines, fmt.Sprintf("[%s]: %s", turns[idx].role, turns[idx].text))
723 }
724
725 conversationBlock = strings.Join(lines, "\n")
726 conversationBlock = truncateRunes(conversationBlock, maxConversationContextRunes)
727 return conversationBlock, latestUserMsg
728}
729
730func renderManualTitlePrompt(
731 conversationBlock string,

Callers 2

generateManualTitleFunction · 0.85

Calls 1

truncateRunesFunction · 0.70

Tested by 1