Skip to content

Add Pretext for reflow-free text measurement#242

Open
hudsonhrh wants to merge 2 commits intomainfrom
hudsonhrh/pretext-optimization
Open

Add Pretext for reflow-free text measurement#242
hudsonhrh wants to merge 2 commits intomainfrom
hudsonhrh/pretext-optimization

Conversation

@hudsonhrh
Copy link
Copy Markdown
Member

Summary

  • Adds @chenglou/pretext and a new usePretext.js hooks module with cached useTextHeight, useTextTruncation, useAutoTextHeight, and useBatchTextHeights utilities
  • Replaces arbitrary character-count truncation with width-aware Pretext measurement in TaskCard, HistoryCard, VoteCard, and OrgStructureCard
  • Pre-sizes typing animation containers in SpeechBubble to eliminate layout thrashing during character-by-character rendering
  • Uses Pretext-estimated scroll height in ConversationLog for instant initial scroll without forced DOM reflow

Test plan

  • Verify TaskCard descriptions truncate correctly at different viewport widths
  • Verify HistoryCard and VoteCard proposal descriptions show proper ellipsis
  • Verify OrgStructureCard role badges truncate long names
  • Verify SpeechBubble typing animation doesn't cause layout jumping
  • Verify ConversationLog auto-scrolls to bottom on load and new messages

🤖 Generated with Claude Code

hudsonhrh and others added 2 commits April 1, 2026 15:30
Replace character-count truncation and scrollHeight polling with
Pretext-based width-aware text measurement across six components:
SpeechBubble, ConversationLog, TaskCard, OrgStructureCard,
HistoryCard, and VoteCard. Introduces usePretext hooks with caching.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Main's PR #232 refactored TaskCard to accept a task object prop and
removed useDisclosure. Keep that refactor while preserving our
Pretext width-aware truncation in place of character-count truncation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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