Skip to content

Commit dfafa92

Browse files
committed
refactor: extract pluralizeTurns helper for goal toolcards
1 parent 20be880 commit dfafa92

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/browser/features/Tools/Goal/goalToolUtils.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ export function formatGoalElapsed(startedAtMs: number, nowMs: number = Date.now(
2222
return `${hours}h ${minutes % 60}m`;
2323
}
2424

25+
// Shared turn-count pluralization so the goal toolcards render "1 turn" /
26+
// "N turns" consistently (was open-coded in formatGoalTurns and the set_goal
27+
// toolcard's requested-turns formatter).
28+
export function pluralizeTurns(count: number): string {
29+
return `${count} turn${count === 1 ? "" : "s"}`;
30+
}
31+
2532
export function formatGoalTurns(turnsUsed: number, turnCap: number | null): string {
26-
return turnCap == null
27-
? `${turnsUsed} turn${turnsUsed === 1 ? "" : "s"}`
28-
: `${turnsUsed} / ${turnCap} turns`;
33+
return turnCap == null ? pluralizeTurns(turnsUsed) : `${turnsUsed} / ${turnCap} turns`;
2934
}
3035

3136
export function formatGoalBudgetSummary(costCents: number, budgetCents: number | null): string {

src/browser/features/Tools/SetGoalToolCall.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
extractGoalFromResult,
2121
formatGoalCents,
2222
formatGoalTurns,
23+
pluralizeTurns,
2324
} from "./Goal/goalToolUtils";
2425

2526
interface SetGoalToolCallProps {
@@ -43,7 +44,7 @@ function formatAppliedBudget(budgetCents: number | null): string {
4344
}
4445

4546
function formatOptionalTurnCap(turnCap: number | null | undefined): string {
46-
return turnCap == null ? "Workspace default" : `${turnCap} turn${turnCap === 1 ? "" : "s"}`;
47+
return turnCap == null ? "Workspace default" : pluralizeTurns(turnCap);
4748
}
4849

4950
export const SetGoalToolCall: React.FC<SetGoalToolCallProps> = ({

0 commit comments

Comments
 (0)