Skip to content

fix(agent-display): remove zero-width sort prefixes from runtime names#3352

Open
LeekJay wants to merge 1 commit intocode-yeongyu:devfrom
LeekJay:fix/remove-zwsp-agent-prefixes
Open

fix(agent-display): remove zero-width sort prefixes from runtime names#3352
LeekJay wants to merge 1 commit intocode-yeongyu:devfrom
LeekJay:fix/remove-zwsp-agent-prefixes

Conversation

@LeekJay
Copy link
Copy Markdown
Contributor

@LeekJay LeekJay commented Apr 11, 2026

Summary

  • Removes AGENT_LIST_SORT_PREFIXES entirely to prevent string corruption (like missing 'U' in 'Ultraworker') when OpenCode renders labels in its TUI.
  • Updates getAgentRuntimeName to return identical clean strings as getAgentDisplayName.
  • Implements a defense-in-depth layer in the CLI terminal output renderer (stripInvisibleAgentCharacters) to ensure no residual invisible characters are printed.

Changes

  • Modified src/shared/agent-display-names.ts to remove the ZWSP-based prefix injection, relying strictly on the existing order property injection via CANONICAL_CORE_AGENT_ORDER for agent list sorting.
  • Modified src/cli/run/output-renderer.ts to aggressively clean the agent string before printing it with picocolors.
  • Added new regression test src/cli/run/output-renderer.test.ts.
  • Updated test snapshots in src/shared/agent-display-names.test.ts, src/plugin-handlers/agent-key-remapper.test.ts and src/plugin-handlers/command-config-handler.test.ts to assert that zero-width space characters are no longer present.

Testing

bun run typecheck
bun test

Summary by cubic

Removed zero-width sort prefixes from agent names to fix truncated TUI labels. Runtime and list display names are now clean and consistent, and the CLI strips invisible characters before printing.

  • Bug Fixes
    • Removed ZWSP prefixes; getAgentRuntimeName and getAgentListDisplayName now match getAgentDisplayName.
    • Sorting relies only on CANONICAL_CORE_AGENT_ORDER.
    • CLI sanitizes labels via stripInvisibleAgentCharacters and falls back to color profiles by clean name before styling with picocolors; added a renderAgentHeader test and updated related tests to assert no zero-width chars.

Written for commit f5927e4. Summary will update on new commits.

    The zero-width spaces (\u200B) used to force core agents to sort first in the UI
    were causing string corruption (like missing 'U' in 'Ultraworker') when
    OpenCode rendered the labels in its TUI.

    Changes:
    - Removed AGENT_LIST_SORT_PREFIXES entirely.
    - getAgentRuntimeName now returns identical to getAgentDisplayName.
    - Added defense-in-depth stripInvisibleAgentCharacters to CLI terminal
      output renderer to ensure clean strings.
    - Updated related tests to assert ZWSP is no longer present.

    Impact:
    - Fixes TUI label corruption where characters were visually truncated.
    - Agent sorting now relies strictly on the order property injection via
      CANONICAL_CORE_AGENT_ORDER rather than locale string comparison.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 6 files

Confidence score: 5/5

  • This PR looks low risk to merge because the only reported issue is a low-severity documentation/comment mismatch (2/10) rather than a behavioral or runtime defect.
  • The note in src/shared/agent-display-names.ts should be updated so the comment matches current behavior (no runtime sort prefixes from getAgentRuntimeName()), which helps prevent future confusion during maintenance.
  • Pay close attention to src/shared/agent-display-names.ts - align the outdated comment with the new no-prefix behavior.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/shared/agent-display-names.ts">

<violation number="1" location="src/shared/agent-display-names.ts:63">
P3: Update this comment to match the new no-prefix behavior; it still says `getAgentRuntimeName()` adds runtime sort prefixes.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment on lines +63 to +64
* This must stay human-readable. Runtime sort prefixes belong only in the
* agent `name` field via getAgentRuntimeName().
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Update this comment to match the new no-prefix behavior; it still says getAgentRuntimeName() adds runtime sort prefixes.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/shared/agent-display-names.ts, line 63:

<comment>Update this comment to match the new no-prefix behavior; it still says `getAgentRuntimeName()` adds runtime sort prefixes.</comment>

<file context>
@@ -56,25 +46,25 @@ export function getAgentRuntimeName(configKey: string): string {
- * Runtime-facing agent name used for OpenCode list ordering.
+ * List-facing agent display name.
+ *
+ * This must stay human-readable. Runtime sort prefixes belong only in the
+ * agent `name` field via getAgentRuntimeName().
  */
</file context>
Suggested change
* This must stay human-readable. Runtime sort prefixes belong only in the
* agent `name` field via getAgentRuntimeName().
* This must stay human-readable.
* Runtime and list display names are intentionally identical here.
Fix with Cubic

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 2 files (changes from recent commits).

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

@LeekJay LeekJay force-pushed the fix/remove-zwsp-agent-prefixes branch from 87a8eac to f5927e4 Compare April 11, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant