Files
oh-my-opencode/src/plugin-handlers/agent-key-remapper.ts
T

39 lines
1.2 KiB
TypeScript
Raw Normal View History

import { getAgentDisplayName } from "../shared/agent-display-names"
function rewriteAgentNameForListDisplay(
key: string,
value: unknown,
): unknown {
if (typeof value !== "object" || value === null) {
return value
}
const agent = value as Record<string, unknown>
return {
...agent,
name: getAgentDisplayName(key),
}
}
export function remapAgentKeysToDisplayNames(
agents: Record<string, unknown>,
): Record<string, unknown> {
const result: Record<string, unknown> = {}
for (const [key, value] of Object.entries(agents)) {
const displayName = getAgentDisplayName(key)
if (displayName && displayName !== key) {
result[displayName] = rewriteAgentNameForListDisplay(key, value)
// Regression guard: do not also assign result[key].
// This line was repeatedly re-added and caused duplicate agent rows in the UI.
// Runtime callers that previously depended on config-key aliases were fixed in:
// - hooks/atlas/boulder-continuation-injector.ts (prompt agent normalization)
// - features/claude-code-session-state/state.ts (dual registration for display + config forms)
} else {
result[key] = value
}
}
return result
}