fix(stringutil): operate on runes instead of bytes in Truncate by johnstcn · Pull Request #22388 · coder/coder

Skip to content

Navigation Menu

Sign in

Appearance settings

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Conversation

@johnstcn

Copy link

Member

@johnstcn johnstcn commented

Feb 27, 2026

edited

Loading

Fixes #22375

Updates stringutil.Truncate to properly handle multi-byte UTF-8 characters.
Adds tests for multi-byte truncation with word boundary.

Created by Mux using Opus 4.6

@johnstcn johnstcn self-assigned this

Feb 27, 2026

@johnstcn johnstcn requested a review from mafredri

February 27, 2026 16:22
Replace byte-slicing capitalization (displayName[:1]) with a
capitalize() helper using utf8.DecodeRuneInString + unicode.ToUpper
in generateFromPrompt and generateFromAnthropic.

@johnstcn johnstcn enabled auto-merge (squash)

February 27, 2026 17:43

@johnstcn johnstcn merged commit 0cfa037 into main

Feb 27, 2026

25 checks passed

@johnstcn johnstcn deleted the cj/stringutil-fix branch

February 27, 2026 17:46

@github-actions github-actions bot locked and limited conversation to collaborators

Feb 27, 2026

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@kylecarbs kylecarbs kylecarbs approved these changes

@mafredri mafredri Awaiting requested review from mafredri

Assignees

@johnstcn johnstcn

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Task creation fails with invalid UTF-8 from Truncate splitting multi-byte runes

2 participants

@johnstcn @kylecarbs