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

Function generateFallback

coderd/taskname/taskname.go:144–162  ·  view source on GitHub ↗

generateFallback generates a random task name when other methods fail. Uses Docker-style name generation with a collision-resistant suffix.

()

Source from the content-addressed store, hash-verified

142// generateFallback generates a random task name when other methods fail.
143// Uses Docker-style name generation with a collision-resistant suffix.
144func generateFallback() TaskName {
145 // We have a 32 character limit for the name.
146 // We have a 5 character suffix `-ffff`.
147 // This leaves us with 27 characters for the name.
148 name := namesgenerator.NameWith("-")
149 name = name[:min(len(name), 27)]
150 name = strings.TrimSuffix(name, "-")
151
152 taskName := fmt.Sprintf("%s-%s", name, generateSuffix())
153 displayName := strings.ReplaceAll(name, "-", " ")
154 if len(displayName) > 0 {
155 displayName = strings.ToUpper(displayName[:1]) + displayName[1:]
156 }
157
158 return TaskName{
159 Name: taskName,
160 DisplayName: displayName,
161 }
162}
163
164// generateFromPrompt creates a task name directly from the prompt by sanitizing it.
165// This is used as a fallback when Claude fails to generate a name.

Callers 2

GenerateFunction · 0.85
TestGenerateFallbackFunction · 0.85

Calls 2

NameWithFunction · 0.92
generateSuffixFunction · 0.85

Tested by 1

TestGenerateFallbackFunction · 0.68