refactor: unify unit-type switch statements into lookup map (#1273)
This commit is contained in:
parent
84b556908c
commit
0b4510398d
1 changed files with 20 additions and 26 deletions
|
|
@ -48,40 +48,34 @@ export interface AutoDashboardData {
|
|||
|
||||
// ─── Unit Description Helpers ─────────────────────────────────────────────────
|
||||
|
||||
/** Canonical verb and phase label for each known unit type. */
|
||||
const UNIT_TYPE_INFO: Record<string, { verb: string; phaseLabel: string }> = {
|
||||
"research-milestone": { verb: "researching", phaseLabel: "RESEARCH" },
|
||||
"research-slice": { verb: "researching", phaseLabel: "RESEARCH" },
|
||||
"plan-milestone": { verb: "planning", phaseLabel: "PLAN" },
|
||||
"plan-slice": { verb: "planning", phaseLabel: "PLAN" },
|
||||
"execute-task": { verb: "executing", phaseLabel: "EXECUTE" },
|
||||
"complete-slice": { verb: "completing", phaseLabel: "COMPLETE" },
|
||||
"replan-slice": { verb: "replanning", phaseLabel: "REPLAN" },
|
||||
"rewrite-docs": { verb: "rewriting", phaseLabel: "REWRITE" },
|
||||
"reassess-roadmap": { verb: "reassessing", phaseLabel: "REASSESS" },
|
||||
"run-uat": { verb: "running UAT", phaseLabel: "UAT" },
|
||||
};
|
||||
|
||||
export function unitVerb(unitType: string): string {
|
||||
if (unitType.startsWith("hook/")) return `hook: ${unitType.slice(5)}`;
|
||||
switch (unitType) {
|
||||
case "research-milestone":
|
||||
case "research-slice": return "researching";
|
||||
case "plan-milestone":
|
||||
case "plan-slice": return "planning";
|
||||
case "execute-task": return "executing";
|
||||
case "complete-slice": return "completing";
|
||||
case "replan-slice": return "replanning";
|
||||
case "rewrite-docs": return "rewriting";
|
||||
case "reassess-roadmap": return "reassessing";
|
||||
case "run-uat": return "running UAT";
|
||||
default: return unitType;
|
||||
}
|
||||
return UNIT_TYPE_INFO[unitType]?.verb ?? unitType;
|
||||
}
|
||||
|
||||
export function unitPhaseLabel(unitType: string): string {
|
||||
if (unitType.startsWith("hook/")) return "HOOK";
|
||||
switch (unitType) {
|
||||
case "research-milestone": return "RESEARCH";
|
||||
case "research-slice": return "RESEARCH";
|
||||
case "plan-milestone": return "PLAN";
|
||||
case "plan-slice": return "PLAN";
|
||||
case "execute-task": return "EXECUTE";
|
||||
case "complete-slice": return "COMPLETE";
|
||||
case "replan-slice": return "REPLAN";
|
||||
case "rewrite-docs": return "REWRITE";
|
||||
case "reassess-roadmap": return "REASSESS";
|
||||
case "run-uat": return "UAT";
|
||||
default: return unitType.toUpperCase();
|
||||
}
|
||||
return UNIT_TYPE_INFO[unitType]?.phaseLabel ?? unitType.toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Describe the expected next step after the current unit completes.
|
||||
* Unit types here mirror the keys in UNIT_TYPE_INFO above.
|
||||
*/
|
||||
function peekNext(unitType: string, state: GSDState): string {
|
||||
// Show active hook info in progress display
|
||||
const activeHookState = getActiveHook();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue