Registry Mirror
Skip to content

Conversation

@lpiedade

@lpiedade lpiedade commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Closes #982

Summary

The general system prompt's field in Settings → AI tools now shows a live character counter under the text area and
blocks a save past the 20,000-character limit, as the issue's settled answers ask.

  • Counter: 1,234 / 20,000, numbers formatted for the interface's language, updated on every change, a paste
    included. It counts Unicode code points (Array.from(text).length), as the daemon's utf8.RuneCountInString does,
    so an emoji outside the BMP counts as one. There is no maxLength, which counts UTF-16 units.
  • No hold at the limit: typing and a paste both go in whole, past the limit too. The only guard is the over-limit
    state: the field is marked in red (field--error, aria-invalid), with a message saying to shorten the text, and
    Save is disabled until the text is trimmed. That covers a value saved before this change or set through the API.
  • Style only at the limit: below 20,000 the counter keeps its normal style, with no warning style. At or over the
    limit it takes the error style, and its text says so in words (· limit reached, · over the limit), so the cue
    does not rely on color alone. At exactly 20,000 characters only the counter changes: the field stays unmarked and
    Save stays enabled.
  • i18n: four new keys beside the field's strings (settings.systemPromptCount, …CountAtLimit, …CountOver,
    …TooLong) in en-US, pt-BR, and es-ES. Placeholders are {{used}} and {{limit}}, not {{count}}, which i18next
    would read as a plural selector.
  • Styles: .field__count and .field__count--error in app.css, from the design tokens only.

The issue names SettingsScreen.tsx, but SystemPromptField now lives in screens/settings/AgentsSection.tsx, so
the change is there. The daemon's refusal is still shown on the field, but over-limit text can no longer reach it
through Save. The test of that path now has api.updateSettings reject, so it no longer relies on the stand-in
daemon's length check.

Tests

Tests: passed

  • pnpm -C desktop typecheck: passed.
  • pnpm -C desktop test (the interface's whole unit suite, run once): 54 files, 1077 tests passed. These include the
    new cases in SettingsScreen.test.tsx:
    • the counter in code points after typing and after a paste of 10 characters with a non-BMP emoji (3, then 13), and
      no maxlength attribute;
    • normal style at 19,999; at exactly 20,000 emoji (40,000 UTF-16 units), the counter alone in the error style, the
      field unmarked, Save enabled, and the text saved;
    • typing one character past 20,000: the text goes in, the field is marked, Save is disabled and sends nothing, and
      deleting the character unmarks it;
    • a paste from 19,990 to 20,010 goes in whole and is marked with Save disabled, and trimming to 20,000 enables Save;
    • an over-limit text saved before is marked with Save disabled until trimmed;
    • a refusal from the daemon is shown on the field and stays a draft.
  • i18n.test.ts (same keys and placeholders in every locale) and design.test.ts (token-only styles) ran in that
    suite and passed.

Pending

Nothing.

Managed by HarmFlow task queue-implement.

- The field gave no feedback on the 20,000-character limit: a user
  learned of it only from the daemon's error after pressing Save, with
  no way to tell how far over a pasted text was.
- The counter counts Unicode code points, as the daemon does, so an
  emoji outside the BMP counts as one and the two never disagree; a
  maxLength attribute counts UTF-16 units and would cut a paste.
- Neither typing nor a paste is held at the limit: the field marked in
  red with Save disabled is the only guard, as triage settled, and a
  text of exactly 20,000 characters stays savable, with only the
  counter in the error style.
- The counter's text names the limit in words at and over it, so the
  error style does not rely on color alone.

Closes #982
@lpiedade lpiedade added the harmflow Managed by a HarmFlow task label Nov 16, 2026
@lpiedade

Copy link
Copy Markdown
Contributor Author

Approve.

No blocking finding. Each acceptance criterion of #982 and each point the owner settled in its triage is met:

  • Live counter under the text area, 1,234 / 20,000, formatted for the interface's language and updated on every
    change (AgentsSection.tsx, field__count).
  • Counted in code points (Array.from(text).length), as the daemon counts; no maxLength.
  • Neither typing nor a paste is held at the limit; the over-limit state is the only guard: the field marked
    (field--error, aria-invalid), a message to shorten it, and Save disabled, a value saved before included.
  • Normal style below 20,000; error style at or over it, with words (· limit reached, · over the limit) so the cue
    does not rely on color; at exactly 20,000 only the counter changes and Save stays enabled.
  • Four new keys in en-US, pt-BR, and es-ES, beside the field's strings.
  • SettingsScreen.test.tsx covers the counter, a non-BMP character, typing and a paste past the limit, the exact
    limit, and a value saved before. The issue named SettingsScreen.tsx; the field now lives in
    screens/settings/AgentsSection.tsx, which the body explains.

Standards: styles use design tokens only, no animation, file names unchanged, nothing cites a private record. Checks
are green at this head, and the testing heading lists commands that ran.

Notes:

  • desktop/ui/src/screens/settings/AgentsSection.tsx:132 — the counter sits inside the field's <label>, so its text
    joins the text area's accessible name, as the hint and the error already do. Linking it with aria-describedby
    instead would be cleaner, but Field sets that pattern, so this is no finding.

@lpiedade
lpiedade marked this pull request as ready for review November 16, 2026 13:48
@lpiedade

Copy link
Copy Markdown
Contributor Author

Merging at 7df1ce8ea44a: approved at this head, checks green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

harmflow Managed by a HarmFlow task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Show a character counter and enforce the 20,000-character limit on the general system prompt

1 participant