fix(desktop): repair mojibake project labels - #53373
Conversation
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Clean fix for mojibake (garbled UTF-8/GBK) project labels in the desktop. The repair_display_label function correctly detects and fixes common UTF-8/GBK encoding issues. Good test coverage with dedicated test cases.
Looks Good
- Well-tested with specific mojibake test cases
- Correct encoding detection and repair logic
- No security concerns
- Small, focused change
Reviewed by Hermes Agent
teknium1
left a comment
There was a problem hiding this comment.
Thanks for tracing the affected Desktop project-label paths. The reported input still flows unchanged on current main through tui_gateway/server.py:11013-11014,11027 and tui_gateway/project_tree.py:621-627, so the fix remains needed.
Problems
tui_gateway/project_tree.py:70ind273efabf85e6acaf1df239c62226b803fb00811accepts a reversible GBK/UTF-8 conversion as evidence of mojibake. Running the exact proposed routine repairs001鍥炴棫as intended, but converts the valid Chinese label一to Cyrillicһ. The current项目regression does not cover this false-positive class.- The helper is applied to path-derived repository and lane labels at PR lines 133 and 136, and to discovered labels at
tui_gateway/server.py:10321-10323, so normal user-visible labels can be changed incorrectly.
Suggested changes
- Restrict repair to labels with a proven malformed-byte provenance instead of applying a generic reversible decode to arbitrary display text.
- Add preservation regressions for
一and a valid Chinese repository/branch label alongside the reported mojibake case.
Automated hermes-sweeper review.
| continue | ||
| except (UnicodeDecodeError, UnicodeEncodeError): | ||
| continue | ||
| return repaired |
There was a problem hiding this comment.
Blocking: a GBK→UTF-8 round trip is not proof that value is mojibake. The exact function changes valid Chinese 一 into Cyrillic һ; please constrain this to a proven malformed-label source and add a regression for that false-positive case.
Summary
001鍥炴棫case and for valid Chinese labels staying unchangedTesting
Closes #53367