Skip to content

fix(sp): clamp generated posts to each platform's hard char limit - #34

Merged
ralyodio merged 2 commits into
masterfrom
fix/social-post-char-limits
Jun 1, 2026
Merged

ralyodio merged 2 commits into
masterfrom
fix/social-post-char-limits

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

Problem

Generated social posts could exceed a platform's hard character limit and get rejected at post time:

bluesky: Bluesky posts max 300 chars (got 323).

assemblePostText truncated only the rendered body against the soft cap (280 for Bluesky), then appended the article URL and hashtags and newline separators — none of which were counted. So a body rendered near 280 + url + #tags landed at 323.

Fix

  • Add a hardcoded PLATFORM_HARD_LIMIT map (the real per-platform maxima — same values enforced in lib/sp/platforms/* and the postViaAccount guard).
  • New clampAssembled() guarantees the final assembled string (body + url + hashtags + separators) fits the limit:
    • URL is always preserved (it's the point of the post).
    • Hashtags are dropped before the URL is sacrificed.
    • Body is trimmed on a word boundary with an ellipsis.
  • Applies to every platform that flows through the renderer — both the manual /social action and feed autopost.

Tests

Adds tests/sp/render-post.test.ts (5 cases): short post untouched, over-limit Bluesky clamped ≤300, hashtags dropped under tight room, X clamped ≤280, long-form (LinkedIn) left intact. tsc --noEmit clean.

🤖 Generated with Claude Code

assemblePostText truncated only the rendered body against the soft cap,
then appended the URL and hashtags + newline separators that weren't
counted — so a Bluesky post rendered near the 280 soft cap ended up at
323 chars and was rejected ("Bluesky posts max 300 chars (got 323)").

Add a hardcoded PLATFORM_HARD_LIMIT map (the real per-platform maxima)
and a clampAssembled() that guarantees the final assembled string —
body + URL + hashtags + separators — fits the limit. The URL is always
preserved; hashtags are dropped before the URL is sacrificed; the body
is trimmed on a word boundary with an ellipsis. Covers every platform
that goes through the renderer (manual action + feed autopost).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

vu1nz Security Review

0 finding(s) in PR #?

No security issues found.

Add ability for project owners to invite teammates by email. Invitees
receive a branded email with a secure token link; accepting creates a
project_members row and grants full project read access via RLS.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ralyodio
ralyodio merged commit 1dcca8a into master Jun 1, 2026
8 checks passed
@ralyodio
ralyodio deleted the fix/social-post-char-limits branch June 1, 2026 13:35
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