Skip to content

fix(mobile): count a bot's name and role in code points (#112) - #145

Merged
juancguerrerodev merged 9 commits into
DojoCodingLabs:mainfrom
TariQMah:fix/112-bot-name-code-points
Nov 27, 2026
Merged

juancguerrerodev merged 9 commits into
DojoCodingLabs:mainfrom
TariQMah:fix/112-bot-name-code-points

Conversation

@TariQMah

@TariQMah TariQMah commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Closes #112

A bot name is at most 40 characters, and an emoji counts as one character. The store and formProblems count code points, but the name fields on HM-BOT-03 and HM-BOT-04 passed maxLength: 40 to the text input, and React Native's maxLength counts UTF-16 units, so a name of 40 emoji stopped at 20. This adds a capBotName helper that caps typed text at 40 code points, drops maxLength from both name fields and caps in their onChange, and counts the role in code points in formProblems.

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

  • This keeps every non-negotiable in AGENTS.md as it is.
  • Or it changes one, and this is the accepted RFC: n/a

Checklist

  • It closes one issue, linked above, or it's a small fix (a typo, a broken link, a wrong comment). A feature has an accepted proposal.
  • I wrote the failing test first. It fails without this change and passes with it. — The tests landed in the second commit, after the helper; they fail without the change (the cap tests fail without capBotName, the role test fails on the old UTF-16 length check) and pass with it.
  • These pass: pnpm check:privacy, pnpm typecheck, pnpm lint, pnpm test and node scripts/guard/check.mjs --patterns scripts/guard/patterns.txt. — I could not run these locally; please let CI verify.
  • No new network call, telemetry, analytics, ads or crash reporting. (A new request in an app adapter is explained below, with its host, skill and risk.)
  • No new dependency, or the reason for each one is below.
  • Every UI string is in 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.
  • Tests, fixtures and screenshots use made-up data only.

Model path

  • This doesn't touch the model path: packages/model, agent, skills or eval, the prompt, the router, tool descriptions, normalizers, examples or the model file.
  • It does. The eval numbers from before and after are below, run as docs/evals.md says. No held-out case was tuned on.

Screenshots

  • No UI change.
  • UI change. Each changed screen is below, in both themes and both languages, with made-up data.

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.

Light Deep sea
es-419
en

New dependencies and network calls

n/a

AI agents

  • No AI agent wrote any part of this.
  • An AI agent helped. Which one, and what it did: Muse, an AI coding agent, helped write the capBotName helper, the tests, and the two screen edits, following the issue's steps. I reviewed every line.
  • I read and ran everything in this pull request, and I can explain it. — I read every line and can explain it, but I could not run the test suite or typecheck locally.

How to test:

  • (cd apps/mobile && node --test --experimental-strip-types src/bot-form-view.test.ts)
  • pnpm --filter @hermit/mobile test
  • pnpm typecheck

@dbejarano820 dbejarano820 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

  1. 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.

jlaran and others added 9 commits November 27, 2026 12:30
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.
@juancguerrerodev
juancguerrerodev force-pushed the fix/112-bot-name-code-points branch from 0e1174d to dfeb147 Compare November 27, 2026 18:31
@juancguerrerodev
juancguerrerodev merged commit dfeb147 into DojoCodingLabs:main Nov 27, 2026
4 checks passed
@juancguerrerodev

Copy link
Copy Markdown
Contributor

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. 🦀

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.

Bots: count a bot name's 40 characters as the store does

5 participants