Skip to content

bug: 2000-character chat cap and chat send errors - #610

Merged
lukepolo merged 5 commits into
mainfrom
bug/chat-message-cap
Sep 29, 2026
Merged

lukepolo merged 5 commits into
mainfrom
bug/chat-message-cap

Conversation

@lukepolo

@lukepolo lukepolo commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Caps website chat messages at 2000 characters and shows the api's chat:error, so an over-long message no longer silently vanishes.

  • The composer refuses a message over 2000 trimmed characters with a toast and keeps the text (no maxlength, so a paste isn't cut).
  • A countdown beside Send over the last 200 characters, red once over the cap.
  • Socket listens for chat:error and toasts it through utilities/chatErrors.ts (too_long names the limit, anything else is a generic failure).
  • Message grouping compares sender ids as strings, since older stored lines hold steam_id as a number.
  • chat.message_too_long and chat.send_failed in all 16 locales.

Merge/deploy: pairs with 5stackgg/api#435; deploy the api first.

Tests: the over-cap refusal, the chat:error toast and numeric-id grouping each fail with their fix reverted. Based on DEAFCS 29c30a425

The api now refuses a website chat message over 2000 characters and tells
the sender why with chat:error. The chat box refuses an over-length
message up front, keeps the text, and counts down over the last 200
characters. chat:error codes become a toast; not_allowed and unknown
codes read as a failed send.

ChatMessage compares sender steam ids as strings, since new messages
carry a string steam_id and older history can carry a number.
chatErrorMessage takes the translate function and calls t() with literal
keys, so check-translations no longer reports chat.message_too_long and
chat.send_failed as unused. The zod schema trims before measuring, like
the send check and the api. French send_failed matches the formal
wording around it. Tests for the trimmed countdown, the text kept after
an Enter refusal, and ChatMessage grouping.
Every other destructive toast leads with a short sentence-case title,
so a chat send error now reads "Failed to send message" as its title,
with the length limit as the description when that is the reason. The
send_failed strings drop their trailing period to read as titles.
@lukepolo

Copy link
Copy Markdown
Contributor Author

Design-consistency follow-up (style: give chat send errors a toast title like the rest of the app):

  • Chat send errors now use the app's destructive-toast shape: a short sentence-case title ("Failed to send message"), plus the length limit as the description when that's the reason. Before this, the toast had a description only, while every other destructive toast in the app leads with a title. The other 16 locales keep their wording, minus the trailing period, so they read as titles.
  • chatErrorMessage is renamed chatErrorDescription and returns undefined for a plain failed send. Tests are updated to match.
  • I checked the near-limit countdown and left it as is. It already reads like the chat's own hover timestamp micro-label (font-mono, text-muted-foreground/70), goes text-destructive over the limit, and has no motion.

yarn test passes (47 files, 301 tests), and check-translations reports 16/16.

Lines stored before the api stamped from.steam_id as a string can hold
it as a number. The test fails without the String() comparison in
ChatMessage's isSameSender.
# Conflicts:
#	tests/web-sockets/Socket.spec.ts
@lukepolo
lukepolo merged commit 9c1d325 into main Sep 29, 2026
2 checks passed
@lukepolo
lukepolo deleted the bug/chat-message-cap branch September 29, 2026 01:05
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.

1 participant