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

Function TruncateLabel

coderd/x/chatd/chatdebug/summary.go:27–33  ·  view source on GitHub ↗

TruncateLabel whitespace-normalizes and truncates text to maxLen runes. Returns "" if input is empty or whitespace-only.

(text string, maxLen int)

Source from the content-addressed store, hash-verified

25// TruncateLabel whitespace-normalizes and truncates text to maxLen runes.
26// Returns "" if input is empty or whitespace-only.
27func TruncateLabel(text string, maxLen int) string {
28 normalized := strings.TrimSpace(whitespaceRun.ReplaceAllString(text, " "))
29 if normalized == "" {
30 return ""
31 }
32 return stringutil.Truncate(normalized, maxLen, stringutil.TruncateWithEllipsis)
33}
34
35// SeedSummary builds a base summary map with a first_message label.
36// Returns nil if label is empty.

Callers 4

prepareChatTurnDebugRunFunction · 0.92
TestTruncateLabelFunction · 0.92

Calls

no outgoing calls

Tested by 1

TestTruncateLabelFunction · 0.74