Repository navigation
fix(mobile): count a bot's name and role in code points (#112) - #145
Conversation
dbejarano820
left a comment
There was a problem hiding this comment.
Thanks a lot for picking this up, Tariq. The change is small and focused, and it does what #112 asks: names are capped in code points on both HM-BOT-03 and HM-BOT-04, maxLength is gone from both name fields, and the role is now counted the way the store counts it. Thanks also for being open about the test order and what you couldn't run.
I ran every gate on your branch (pnpm check:privacy, pnpm typecheck, pnpm lint, pnpm test and the PR guard), and all of them pass. I also checked that the new tests fail without the fix: without capBotName the test file won't load, and with the old role check the "800 emoji" test fails with role_too_long. So they test the right thing.
Before merge
- Phone check and screenshots (step 3 of the issue and its "Done when"). Since you don't have a device, we'll do this on our side: type and save a 40 emoji name on HM-BOT-03, check that a 41st isn't added, do the same on HM-BOT-04, and take the four screenshots (light and Deep sea, es-419 and en). Nothing for you to change unless that turns something up.
Optional nits, none blocking
apps/mobile/src/bot-form-view.ts:25: slicing by code point can split a grapheme at the limit (a flag keeps only its first regional indicator, and "❤️" loses its variation selector). That matches the store's rule, and the issue keeps code points on purpose, so it's fine. A short note in the doc comment would help the next reader.- The cap counts the untrimmed text while the store trims first, so leading spaces use part of the 40. That's harmless, because it is stricter than the store, never looser.
- For next time: AGENTS.md asks for the failing test in a commit before the fix. Here the tests do fail without the fix, so the result is the same. Signing off commits (
git commit -s) is recommended in CONTRIBUTING.md, though not required.
Thanks again, this is a nice first fix.
Unit tests for base64ToBytes, utf8Decode and decodeBase64Text, decodeEntities, htmlToText, plainText, clip and splitAddresses, with made-up people and example.com addresses. oneLine() stays out (its own issue) and text.ts is unchanged. Closes DojoCodingLabs#37
utf8Decode() decoded overlong sequences (C0 80 to U+0000) and encoded surrogates (ED A0 80 to a lone U+D800). Only the shortest form is UTF-8 and it never encodes U+D800 to U+DFFF (RFC 3629), so each byte of such a sequence now becomes U+FFFD, as a standard decoder answers. The vault's decoder in packages/core already refuses both. Closes DojoCodingLabs#142
A small voseo matcher with its own tests, and a test that no value in
es-419.json matches. Only forms that can't be read another way are
listed. Word edges are (?<!\p{L}) and (?!\p{L}) with the u and i flags,
since \b doesn't count accented letters as letters. No locale changes.
Closes DojoCodingLabs#38
The site's Spanish now calls the lab "Laboratorio del teléfono" and its report an "informe", as the app does. The lab's kicker is tested against the app's HM-SET-10.title in both languages. common.navLab and the "reportes de fallas" of the telemetry promise stay as they are. Closes DojoCodingLabs#36
…table.mjs Both scripts now parse their command line with node:util parseArgs in strict mode. --help and -h print the usage from each file's header and exit 0. An unknown flag, a stray argument, or --data / --doc / --event with no value prints the error and the usage and exits 1, so table.mjs no longer rewrites docs/devices.md on a typo and validate.mjs no longer tries to open a file named --help. The workflow's --event, --github-output and --comment call works as before. Closes DojoCodingLabs#35 Signed-off-by: RibeiroMD <174728106+Ribeiro-MD@users.noreply.github.com>
Updated role validation to trim whitespace and count code points correctly.
Updated bot name handling to use capBotName function and removed MAX_BOT_NAME_CHARS constant.
0e1174d to
dfeb147
Compare
|
Merged, thanks! One thing for next time: tick "I read and ran everything in this pull request, and I can explain it" in the template. 🦀 |
What and why
Closes #112
A bot name is at most 40 characters, and an emoji counts as one character. The store and
formProblemscount code points, but the name fields on HM-BOT-03 and HM-BOT-04 passedmaxLength: 40to the text input, and React Native'smaxLengthcounts UTF-16 units, so a name of 40 emoji stopped at 20. This adds acapBotNamehelper that caps typed text at 40 code points, dropsmaxLengthfrom both name fields and caps in theironChange, and counts the role in code points informProblems.Vision fit
Principle 7, "Small, typed and tested": the change is small plain TypeScript with tests on Node, written to the issue's steps. Also principle 4, "Honest about limits": the field now enforces the same 40-code-point limit the store does, instead of stopping an emoji name at 20.
Non-negotiables
Checklist
acceptedproposal.capBotName, the role test fails on the old UTF-16 length check) and pass with it.pnpm check:privacy,pnpm typecheck,pnpm lint,pnpm testandnode scripts/guard/check.mjs --patterns scripts/guard/patterns.txt. — I could not run these locally; please let CI verify.packages/copy, in es-419 and en, with matching keys and placeholders, and no em or en dashes. — No UI strings were added or changed.Model path
packages/model,agent,skillsoreval, the prompt, the router, tool descriptions, normalizers, examples or the model file.Screenshots
The name field looks the same; only its length cap changed. I could not take phone screenshots (no device access), so the HM-BOT-03 screenshots in both themes and both languages are not included — please verify on a phone that a name of 40 emoji can be typed and saved, and a 41st is not added.
New dependencies and network calls
n/a
AI agents
capBotNamehelper, the tests, and the two screen edits, following the issue's steps. I reviewed every line.How to test:
(cd apps/mobile && node --test --experimental-strip-types src/bot-form-view.test.ts)pnpm --filter @hermit/mobile testpnpm typecheck