feat(shared): add sanitizeAgentNameForDisplay helper#3518
Open
CoderLuii wants to merge 2 commits intocode-yeongyu:devfrom
Open
feat(shared): add sanitizeAgentNameForDisplay helper#3518CoderLuii wants to merge 2 commits intocode-yeongyu:devfrom
CoderLuii wants to merge 2 commits intocode-yeongyu:devfrom
Conversation
Contributor
|
All contributors have signed the CLA. Thank you! ✅ |
There was a problem hiding this comment.
No issues found across 3 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: This PR is purely additive, introducing an opt-in helper function and tests without modifying any existing code paths or logic, which guarantees no regressions.
Author
|
I have read the CLA Document and I hereby sign the CLA |
This was referenced Apr 24, 2026
This was referenced Apr 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt in display helper so downstream code can strip invisible codepoints (
U+200B,U+200C,U+200D,U+FEFF) from agent names before rendering them to any end user surface. The existing ordering contract is untouched.getAgentRuntimeName,getAgentListDisplayName,AGENT_LIST_SORT_PREFIXES, andreorderAgentsByPriorityare all unchanged.Changes
src/shared/agent-display-names.ts:sanitizeAgentNameForDisplay(agentName: string): string. It delegates to the existingstripInvisibleAgentCharacters, so there is no new regex and no new dependency.describe("sanitizeAgentNameForDisplay", ...)block insrc/shared/agent-display-names.test.tswith 8 given when then cases covering single prefix strip, all four invisible codepoints, passthrough, idempotency, empty string, all invisibles, scattered invisibles, and mid word ZWSP.src/plugin-handlers/AGENTS.mdthat points display layer callers at the new helper and reaffirms the existing Forbidden Patterns block. No existing text is modified.Screenshots
Not applicable. This PR adds a library function and docs; there is no visual surface to capture.
Testing
From
oh-my-openagent-upstream/:Result on my branch:
typecheckexits 0.agent-display-names.test.tsreports 38 pass / 0 fail (27 preexisting + 8 new tests + 3 additional existing in the file after my diff).A runtime smoke of the new helper:
Full
bun test(running the whole repo in one process) has preexisting cross test mock pollution that is unrelated to this change. None of the failing tests touch any file in this PR. Every failing file passes when run in isolation on cleandev. This matches the repo's documented behavior aboutmock.module()and why CI usesscript/run-ci-tests.tsinstead of a single barebun testinvocation.Related
Permanent fix at the root cause is in a separate PR against OpenCode core: anomalyco/opencode#23377, which closes the tracking issue I filed at anomalyco/opencode#23376. That PR teaches the TUI renderer to handle invisible codepoints correctly in width and truncation math. Once it merges and ships, every downstream plugin (including this one) gets correct rendering automatically.
Scope
This PR is strictly additive and opt in. No existing caller is migrated. The ordering contract in
src/plugin-handlers/AGENTS.mdis respected. NogetAgentSortKey, no alternative ordering constant, no runtime sort shim.Summary by cubic
Add
sanitizeAgentNameForDisplayto strip invisible codepoints (U+200B, U+200C, U+200D, U+FEFF) from agent names before rendering. Opt-in; sorting and existing name helpers remain unchanged.sanitizeAgentNameForDisplay(agentName: string)insrc/shared/agent-display-names.ts(delegates tostripInvisibleAgentCharacters).AGENTS.mdto reference the helper; added tests covering invisibles, passthrough, idempotency, and edge cases.Written for commit d49b755. Summary will update on new commits.