Skip to content

Commit c5a3c23

Browse files
Merge pull request #74 from microsoft/psl-bug-15446-agent-names
fix: Consistent agent naming
2 parents 9b0194b + 365738c commit c5a3c23

2 files changed

Lines changed: 33 additions & 13 deletions

File tree

src/frontend/src/api/utils.tsx

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,35 @@ export const determineFileStatus = (file) => {
294294
return "error";
295295
};
296296
// Function to format agent type strings
297-
export const formatAgent = (str = "Agents") => {
298-
if (!str) return "Agents";
299-
return str
297+
export const formatAgent = (str = "Agent") => {
298+
if (!str) return "agent";
299+
300+
const cleaned = str
300301
.replace(/[^a-zA-Z\s]/g, " ") // Remove non-alphabetic characters
301-
.replace(/\s+/g, " ") // Replace multiple spaces with a single space
302-
.trim() // Remove leading/trailing spaces
303-
.split(" ") // Split words
304-
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) // Capitalize first letter
305-
.join(" ") || "Agents"; // Ensure default "Agent" if empty
302+
.replace(/\s+/g, " ") // Collapse multiple spaces
303+
.trim()
304+
.replace(/\bAgents\b/i, "Agent"); // Singularize "Agents" if it's the only word
305+
306+
const words = cleaned
307+
.split(" ")
308+
.filter(Boolean)
309+
.map(w => w.toLowerCase());
310+
311+
const hasAgent = words.includes("agent");
312+
313+
// Capitalize all except "agent" (unless it's the only word)
314+
const result = words.map((word, index) => {
315+
if (word === "agent") {
316+
return words.length === 1 ? "Agent" : "agent"; // Capitalize if it's the only word
317+
}
318+
return word.charAt(0).toUpperCase() + word.slice(1);
319+
});
320+
321+
if (!hasAgent) {
322+
result.push("agent");
323+
}
324+
325+
return result.join(" ");
306326
};
307327

308328
// Function to handle rate limit errors and ensure descriptions end with a dot

src/frontend/src/pages/modernizationPage.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,11 @@ enum ProcessingStage {
425425
}
426426

427427
enum Agents {
428-
Verifier = "Semantic Verifier",
429-
Checker = "Syntax Checker",
430-
Picker = "Picker",
431-
Migrator = "Migrator",
432-
Agents = "Agents"
428+
Verifier = "Semantic Verifier agent",
429+
Checker = "Syntax Checker agent",
430+
Picker = "Picker agent",
431+
Migrator = "Migrator agent",
432+
Agents = "Agent"
433433
}
434434

435435

0 commit comments

Comments
 (0)