Files
oh-my-opencode/src/plugin-handlers/agent-key-remapper.ts
T
YeonGyu-Kim 333ad3aadd refactor(agents): drop ZWSP prefixes from agent display names
The sort shim from the previous commit enforces canonical core ordering at runtime, so ZWSP prefixes are no longer needed. Removing them eliminates the Bun.stringWidth vs terminal-width drift that broke the TUI status bar (#3259).

Drop AGENT_LIST_SORT_PREFIXES and getAgentRuntimeName from agent-display-names; switch all call sites to getAgentDisplayName. getAgentListDisplayName stays as a thin alias for external importers.

Keep stripInvisibleAgentCharacters and the ZWSP regex paths so legacy session state and configs from v3.14.0-v3.16.0 still resolve.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-27 18:59:49 +09:00

39 lines
1.2 KiB
TypeScript

import { getAgentListDisplayName } 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: getAgentListDisplayName(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 = getAgentListDisplayName(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
}