Skip to content

fix(contracts): avoid Intl.Segmenter in monogram validation (Hermes crash) - #11984

Merged
juliusmarminge merged 1 commit into
pingdotgg:mainfrom
bompus:fix/mobile-hermes-monogram-segmenter-crash
Sep 15, 2026
Merged

juliusmarminge merged 1 commit into
pingdotgg:mainfrom
bompus:fix/mobile-hermes-monogram-segmenter-crash

Conversation

@bompus

@bompus bompus commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #11983.

What

packages/contracts/src/orchestration.ts constructed new Intl.Segmenter(...) at module scope. Hermes (Android/iOS) does not implement Intl.Segmenter, so every mobile build since #11845 crashed during startup bundle evaluation — splash, then dead, before any screen. Web/desktop (V8) were unaffected.

Change

Replace the Segmenter-based grapheme count with a small countGraphemes approximation (combining marks, joiners, variation selectors, emoji modifiers, and post-ZWJ code points continue the current cluster). Deliberately runtime-independent rather than typeof Intl.Segmenter feature detection, so this shared contract validates identically on server, web, and mobile.

Verification

  • pnpm --filter @t3tools/contracts exec vp test run src/orchestration.test.ts: 60/60 pass, including the existing monogram cases (Devanagari clusters like किखि, combining marks like é).
  • Built a release preview APK from this branch and cold-launched it on an Android 16 (API 36) emulator: previously reproduced the exact startup crash (TypeError: undefined cannot be used as a constructor, symbolicated to orchestration.ts:462); with this fix the app stays alive with zero fatals and renders the home screen (screenshot in [Bug]: Mobile app crashes on launch — Intl.Segmenter is not available on Hermes #11983 discussion if needed).

Summary by CodeRabbit

  • Bug Fixes
    • Improved project monogram validation compatibility on Hermes-based mobile runtimes.
    • Preserved the existing two-character limit and character-pattern validation.

…rash)

Hermes (Android/iOS) does not implement Intl.Segmenter, so the
module-scope constructor in orchestration.ts threw during startup
bundle evaluation and the mobile app died right after the splash on
every launch. Count grapheme clusters with a small runtime-independent
approximation instead, so the shared contract validates identically on
server, web, and mobile.

Fixes pingdotgg#11983
@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Sep 15, 2026
let clusters = 0;
let prevJoiner = false;
for (const char of text) {
if (clusters > 0 && (prevJoiner || GRAPHEME_CONTINUATION.test(char))) {

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.

🟡 Medium src/orchestration.ts:475

countGraphemes counts A\u200dB\u200dC as one grapheme, so ProjectMonogramText accepts a three-grapheme monogram despite its two-grapheme limit. prevJoiner unconditionally suppresses the boundary after every ZWJ, whereas that rule only applies to the emoji ZWJ emoji sequence; use a standards-complete segmenter or restrict continuation to the full emoji-ZWJ context.

🤖 Copy this AI Prompt to have your agent fix this:
In file @packages/contracts/src/orchestration.ts around line 475:

`countGraphemes` counts `A\u200dB\u200dC` as one grapheme, so `ProjectMonogramText` accepts a three-grapheme monogram despite its two-grapheme limit. `prevJoiner` unconditionally suppresses the boundary after every ZWJ, whereas that rule only applies to the emoji ZWJ emoji sequence; use a standards-complete segmenter or restrict continuation to the full emoji-ZWJ context.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8edfe3c: ZWJ now joins backward only (GB9), so A-ZWJ-B-ZWJ-C counts 3 and is rejected; GB11 emoji-ZWJ joining needs Extended_Pictographic, which the monogram pattern rejects anyway. Verified against Intl.Segmenter (including a 20k-string fuzz over the monogram charset: 0 mismatches) and locked with schema-level tests.

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.

Sorry, I'm unable to act on this request because you do not have permissions within this repository.

let clusters = 0;
let prevJoiner = false;
for (const char of text) {
if (clusters > 0 && (prevJoiner || GRAPHEME_CONTINUATION.test(char))) {

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.

🟡 Medium src/orchestration.ts:475

ProjectMonogramText rejects the valid decomposed Korean monogram 가나 because countGraphemes counts its four Jamo code points as four graphemes instead of two. GRAPHEME_CONTINUATION does not implement the Unicode Hangul L/V/T no-break rules; add Hangul Jamo continuation handling so each L+V pair is counted as one grapheme.

🤖 Copy this AI Prompt to have your agent fix this:
In file @packages/contracts/src/orchestration.ts around line 475:

`ProjectMonogramText` rejects the valid decomposed Korean monogram `가나` because `countGraphemes` counts its four Jamo code points as four graphemes instead of two. `GRAPHEME_CONTINUATION` does not implement the Unicode Hangul L/V/T no-break rules; add Hangul Jamo continuation handling so each L+V pair is counted as one grapheme.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8edfe3c: Hangul L/V/T/LV/LVT compose per GB6-GB8, so decomposed Jamo pairs count as single graphemes. Known remaining scope: virama+ZWJ Indic conjuncts (an ICU-version-dependent behavior that contradicts published UAX-29 GB11); both readings stay on the same side of the 2-grapheme limit for realistic inputs, and behavior is uniform across runtimes, which is what this shared contract requires.

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.

Sorry, I'm unable to act on this request because you do not have permissions within this repository.

@juliusmarminge
juliusmarminge enabled auto-merge (squash) September 15, 2026 23:08
@macroscopeapp

macroscopeapp Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This one-file fix removes the Hermes startup crash, but replaces standard grapheme segmentation with custom shared validation logic whose Unicode behavior differs across existing callers. Unresolved ZWJ and Hangul edge cases add compatibility risk, warranting human review.

Not approved because:

  • 2 blocking correctness issues found at or above your repo's Minimum Blocking Severity

Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more.

@juliusmarminge
juliusmarminge merged commit 6f7aaff into pingdotgg:main Sep 15, 2026
20 of 21 checks passed
@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 731b5e92-beed-4e43-a035-e63816b8707c

📥 Commits

Reviewing files that changed from the base of the PR and between 87a12b5 and 57eaf36.

📒 Files selected for processing (1)
  • packages/contracts/src/orchestration.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Project monogram validation no longer constructs Intl.Segmenter at module load. It uses a runtime-independent grapheme-counting approximation and preserves the existing two-cluster limit and character-pattern validation.

Changes

Project monogram validation

Layer / File(s) Summary
Runtime-independent grapheme counting
packages/contracts/src/orchestration.ts
ProjectMonogramText now uses countGraphemes. The counter handles combining marks, joiners, variation selectors, emoji modifiers, and ZWJ-following code points while enforcing the two-cluster limit.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: t3dotgg

Merge Risk: ⚪ Minimal · up to 57eaf

The changed validation has no established merge-blocking risk and is ready for normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: removing Intl.Segmenter from monogram validation to prevent Hermes startup crashes.
Description check ✅ Passed The description clearly explains the problem, the implementation, the runtime impact, and verification results. It does not use the template headings exactly and omits the checklist, but it provides t…
Linked Issues check ✅ Passed The change satisfies #11983. It removes module-scope new Intl.Segmenter(), which prevents the Hermes startup exception. countGraphemes uses code-point iteration and Unicode matching without runtim…
Out of Scope Changes check ✅ Passed The reviewed change is limited to packages/contracts/src/orchestration.ts. The added approximation and comments directly address the shared contract crash and grapheme validation requirements in #11
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

aorwall added a commit to aorwall/t3code that referenced this pull request Sep 16, 2026
Merges `pingdotgg/t3code` at `0bf2d6b01` into the fork, from base
`5623089ae` — 45 upstream commits.

`255` files landed against `251` changed in the upstream range; the gap
of 4 reconciles exactly (five landed-not-in-range — the three fork docs
and the two fork-only files the typecheck fix touched — against one
in-range-not-landed, `SidebarChrome.tsx`, whose resolution is
byte-identical to `HEAD^1` because the fork's wordmark decision stands).
Fork delta against upstream is now 776 files.

Four conflicts, each resolved with the verdict `preflight.mjs` printed:

| Path | Verdict | Resolution |
| --- | --- | --- |
| `AGENTS.md` | `decide` (`agent-instructions`) | fork's rewrite kept;
upstream's new sentence folded into the existing bullet |
| `apps/web/src/state/threads.ts` | unlisted → `decide, then add an
entry` | the fork's `adoptedEnvironmentSnapshotAtom` graft moved up to
upstream's new snapshot argument (pingdotgg#8309) |
| `ProjectSettingsPanel.tsx` | unlisted → `decide, then add an entry` |
took upstream's `monogram` arm and its required `projectName`; kept the
fork's flag read and Workspace sections |
| `SidebarChrome.tsx` | `decide` (`sidebar-brand`) | upstream
reintroduced `T3Wordmark`; the fork's single `APP_BASE_NAME` span stands
|

`pnpm-lock.yaml` did not conflict this time. Owned-concern sweep: 2 of
27 upstream additions hit the pattern
(`client-runtime/src/connection/compatibility.ts` and its test —
upstream's own protocol check extracted whole by pingdotgg#11990, accepted
unmodified), plus the `@clerk/expo` patch rename at R100 with identical
content. Unsupported methods: ADD 0, DROP 0; 99 of 157 methods declare,
KEEP 2, five known exceptions unchanged.

## Usable as-is

- **Queue-or-steer follow-ups** (pingdotgg#11964, pingdotgg#11673). `followUpBehavior`
lands in `ClientSettingsSchema`, not `ServerSettings` — the queue is
client-side and a steer is an ordinary send, so this needs nothing from
the backend.
- **Monogram project icons** on the project page (pingdotgg#11845, pingdotgg#11993,
pingdotgg#11984), which ride `project.meta.update`. Note this is the *project*
surface only; see the Workspace caveat below.
- `a5da32750` cached turns and older-page loading (pingdotgg#8309); `3efdcc529`
diff tree order and collapsed folders; `9ea892e3b` thread state before
remote replies.
- Desktop fixes: `96bddf812` paste-as-text, `b20d29dc4` double startup,
`c1b221041` sidebar alignment.
- Web polish: `f0a0ead94`, `9a6b57be2`, `bf3be75c4`, `3c4c9a125`.
- `37a8ab2b2` Hermes API ban lint rule; `87a12b53f` usage-limit refresh.
- Dependency bumps: `844203d4f` Clerk, `b18a560bb` Reanimated/Worklets.
Mobile fixes land inert.

## Unsupported in Moatless / needs implementation

- **Monograms on Workspace icons.** This is the one upstream change that
broke something. `ProjectIconPickerDialog` is upstream's, the fork's
Workspace settings page borrows it, and upstream gave monograms their
own `ProjectIconOverride` arm — but the Workspace API's `WorkspaceIcon`
has only `lucide` and `emoji`, so there is no field for the letters.
`workspaceIconFromOverride` now returns `null` for a monogram, which
saves as no icon: the same automatic glyph the project drew before the
pick. Hiding the mode instead would mean threading a prop into an
upstream component, which the Stable Fork Rules exist to avoid. Recorded
in `docs/fork/gaps.md`, *Workspace icons cannot hold a monogram*; it
closes when the Workspace API's icon schema grows a monogram arm and
`packages/moatless-api/src/generated/model/workspaceIcon.ts`,
regenerated, carries it.
- Everything behind `FEATURES.connections: false` — pingdotgg#11990 discovery
compatibility, pingdotgg#11974 and pingdotgg#11862 mobile connection gating — lands inert.
- `b84f63bb1` legacy-launcher update blocking and `e6ae764f4` mobile v2
store builds are outside what this fork ships.

## Backend behavior to consider reproducing in Moatless

Eight upstream server fixes, all added to `docs/fork/gaps.md` under
*Runtime fixes upstream made to its own server*:

- pingdotgg#11954 — rewind against history whose length changed.
- pingdotgg#10792 — checkpoint capture reuses index metadata.
- pingdotgg#11633 — fetch/checkout correctness.
- pingdotgg#11405 — git processes capped at 8 by a semaphore, **with long
operations exempt**. The exemption is the easy half to miss; capping
without it stalls clones behind short status calls.
- pingdotgg#11381 — preview host released after an unanswered request.
- pingdotgg#11345 — a missing provider executable names the setting that points
at it.
- pingdotgg#12008 — health checks clean up `_MEI` folders.
- pingdotgg#11888 — GitHub GraphQL budget, rate-limit gate, and read cache.

Also worth noting: with `followUpBehavior: "steer"` a message is
dispatched mid-turn, which touches the existing gap *A message sent
during context compaction should be queued, not dropped*.

## Verification

`verify.mjs` — tripwires, resolution-check, unsupported-methods,
fmt:check, lint and typecheck all green; full test pass run sequentially
by package. Two caveats, both pre-existing and neither from this merge:

1. **`@t3tools/desktop` fails `scripts/browser-secret-native.test.mjs`**
— it shells out to `pkg-config` for `libsecret-1`, which the sandbox
does not have. The file is not in the merge diff and 106 of its 108
suites pass (1365 tests, 12 skipped). Standing entry in `gaps.md`.
2. **`duplicate-adds.mjs` exits 1 on
`packages/contracts/src/orchestration.test.ts`** — a false positive. The
fork's script-port test (line 644) and upstream's new monogram test
(line 1538) share `const command = yield* decodeOrchestrationCommand({`
and `assert.strictEqual(command.type, "project.meta.update");` at
different indentation, and the script trims whitespace before comparing.
Both tests are wanted; no edit is correct, and typecheck and lint both
pass over the file. The next merge's base moves past it.

## Inventory: a hole that this merge closed

`resolution-check.mjs` listed seven paths both sides changed with no
`pathPolicy` entry. Every one of them carries a real fork delta, which
means next merge's `theirs` fallback would have dropped it silently. All
seven are now covered — four entries extended and four added
(`branch-toolbar-gates`, `thread-adoption-graft`,
`project-settings-panel`, `git-vcs-driver-core-test`).

The last of those is the one worth reading:
`apps/server/src/vcs/GitVcsDriverCore.test.ts` is **the fork's only
delta in `apps/server` outside `auth.ts` and `rpc.ts`** — an SSH-wrapper
test rewritten to intercept `ChildProcessSpawner` because the sandbox
has neither a reliable `ssh` nor an executable temp dir — and it was
recorded nowhere.

`resolution-check` now reports 25 paths checked and each still differs
from upstream, 19 `theirs-verbatim` paths byte-identical to upstream,
and no unlisted paths both sides changed. `tripwires.mjs` reports `ok 3
active workflow(s), all allowed` — the previous merge's off-repo action
has been done, and **no off-repository action is outstanding for this
merge**.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---
Moatless task:
https://moatless.soaplabstest.com/tasks/e037ca6d-4fc5-4a9e-9341-2a2ba75ada8b
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Sep 16, 2026
## What's Changed
* feat(mobile): add v2 preview store builds by @juliusmarminge in pingdotgg/t3code#11966
* fix(mobile): block incompatible server connections by @juliusmarminge in pingdotgg/t3code#11974
* fix(web): keep PR controls readable in narrow panels by @Bil0000 in pingdotgg/t3code#11962
* fix(server): block updates under legacy service launchers by @Gigioxx in pingdotgg/t3code#11940
* fix: reduce GitHub quota use with sharing enabled by @Bil0000 in pingdotgg/t3code#11888
* fix(usage): refresh limits when the tab opens by @Bil0000 in pingdotgg/t3code#11928
* fix(contracts): avoid Intl.Segmenter in monogram validation (Hermes crash) by @bompus in pingdotgg/t3code#11984
* feat(lint): extend Hermes API bans with a configurable API list by @juliusmarminge in pingdotgg/t3code#11982
* fix(server): reuse Git index metadata during checkpoint capture by @im-kvijay in pingdotgg/t3code#10792
* refactor: give project monograms their own icon variant by @juliusmarminge in pingdotgg/t3code#11993
* fix(clients): disable incompatible environments during discovery by @juliusmarminge in pingdotgg/t3code#11990
* fix(antigravity): stop health checks from filling the disk with _MEI folders by @t3dotgg in pingdotgg/t3code#12008
* fix(mobile): bare t3code:// links no longer reset navigation to Home by @SunkenInTime in pingdotgg/t3code#12002
* fix(server): keep Claude rewind when fork history length changes by @maria-rcks in pingdotgg/t3code#11954
* fix(mobile): use native toolbar search for licenses by @juliusmarminge in pingdotgg/t3code#12011

## New Contributors
* @bompus made their first contribution in pingdotgg/t3code#11984
* @im-kvijay made their first contribution in pingdotgg/t3code#10792

**Full Changelog**: pingdotgg/t3code@v0.0.41-nightly.20260915.1780...v0.0.41-nightly.20260916.1795

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.41-nightly.20260916.1795
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Mobile app crashes on launch — Intl.Segmenter is not available on Hermes

2 participants