Skip to content

Commit 4c44e89

Browse files
committed
Count planning text by code point
1 parent 9312e84 commit 4c44e89

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎test/browser/plans-authoring.spec.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ test('accepts complete payloads for every edit operation', async ({ page }) => {
106106
field: null, value: null, file: null, check: null, check_index: null, depends_on: null, new_item: null, ...payload,
107107
}) as EditReply['edits'][number];
108108
const newItem = { ...structuredClone(current.items[0]!), id: 'P4', depends_on: ['P1'] };
109-
const reply: EditReply = { ...suggestions(), edits: [
109+
const reply: EditReply = { ...suggestions(), reply: '😀'.repeat(4000), edits: [
110110
card('add_item', { new_item: newItem }, 'P4'),
111111
card('set_field', { field: 'intent', value: 'Explain the bounded retry behavior.' }),
112112
card('add_file', { file: { path: 'added.ts', kind: 'add', renamed_from: null, change: 'Add the helper.' } }),
@@ -128,7 +128,9 @@ test('accepts complete payloads for every edit operation', async ({ page }) => {
128128
}));
129129
await page.getByRole('button', { name: 'Suggest edits' }).click();
130130
await expect(page.getByRole('status').filter({ hasText: 'Suggestions ready for r1.' })).toBeVisible();
131+
await expect(page.locator('.plan-author-reply')).toHaveText(reply.reply);
131132
await expect(page.locator('.suggestion-row')).toHaveCount(9);
133+
await expect(page.getByRole('button', { name: 'Suggest edits' })).not.toHaveAttribute('aria-disabled', 'true');
132134
});
133135

134136
test('renders a whole next-revision draft without changing the current plan', async ({ page }) => {

‎web/public/app.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,12 @@ function exactObject(value, keys) {
955955
Object.keys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key));
956956
}
957957
function boundedText(value, minimum, maximum) {
958-
return typeof value === "string" && value.length >= minimum && value.length <= maximum;
958+
if (typeof value !== "string") return false;
959+
let length = 0;
960+
for (const _point of value) {
961+
if (++length > maximum) return false;
962+
}
963+
return length >= minimum;
959964
}
960965
function validPlanId(value) {
961966
return typeof value === "string" && /^P[1-9][0-9]{0,2}$/.test(value);

0 commit comments

Comments
 (0)