Skip to content

Commit 41e4f63

Browse files
fix(contracts): simplify monogram length validation
1 parent dc073d8 commit 41e4f63

4 files changed

Lines changed: 11 additions & 14 deletions

File tree

‎packages/contracts/package.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
"test": "vp test run"
2626
},
2727
"dependencies": {
28-
"effect": "catalog:",
29-
"unicode-segmenter": "0.17.3"
28+
"effect": "catalog:"
3029
},
3130
"devDependencies": {
3231
"@effect/vitest": "catalog:",

‎packages/contracts/src/mobile-runtime.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ it("loads contracts and validates monograms without Intl.Segmenter", async () =>
1313
const Schema = await import("effect/Schema");
1414
const isMonogram = Schema.is(ProjectMonogramText);
1515

16-
for (const text of ["A", "T3", "e\u0301", "किखि", "\u1100\u1161\u11a8"]) {
16+
for (const text of ["A", "T3", "e\u0301", "किखि", "\u1100\u1161\u11a8", "𐐀𐐁", "A\u200dB"]) {
1717
expect(isMonogram(text), text).toBe(true);
1818
}
1919
for (const text of ["", "ABC", "किखिगि", "\u0301", "A B", "🚀"]) {
2020
expect(isMonogram(text), text).toBe(false);
2121
}
22+
23+
// The lightweight limit counts consonants separately in complex Indic conjuncts.
24+
expect(isMonogram("क्ष्म")).toBe(false);
25+
expect(isMonogram("A\u200dB\u200dC")).toBe(false);
2226
});

‎packages/contracts/src/orchestration.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as Schema from "effect/Schema";
33
import * as SchemaIssue from "effect/SchemaIssue";
44
import * as SchemaTransformation from "effect/SchemaTransformation";
55
import * as Struct from "effect/Struct";
6-
import { countGraphemes } from "unicode-segmenter/grapheme";
76
import { OrchestrationMessageContext } from "./composerContext.ts";
87
import { ProviderOptionSelections } from "./model.ts";
98
import { RepositoryIdentity, ThreadEnvMode } from "./environment.ts";
@@ -463,8 +462,11 @@ const ProjectEmoji = TrimmedNonEmptyString.check(Schema.isMaxLength(32));
463462
export const ProjectMonogramText = TrimmedNonEmptyString.check(
464463
Schema.isMaxLength(32),
465464
Schema.isPattern(/^[\p{L}\p{N}][\p{L}\p{N}\p{M}\u200c\u200d]*$/u),
466-
// These contracts also load in Hermes, which does not provide Intl.Segmenter.
467-
Schema.makeFilter((text) => countGraphemes(text) <= 2),
465+
// Approximate monogram length without Intl.Segmenter, which Hermes lacks.
466+
// Normalize composed letters and ignore marks/joiners; complex conjuncts may count as multiple letters.
467+
Schema.makeFilter(
468+
(text) => [...text.normalize("NFC").replace(/[\p{M}\u200c\u200d]/gu, "")].length <= 2,
469+
),
468470
);
469471

470472
export const ProjectIconOverride = Schema.Union([

‎pnpm-lock.yaml‎

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)