#554 Keep emoji whole where stored text is cut short
–
- github
- github/openchronology/timeline-app
- github/openchronology/timeline-app#554
- pull request
- state:merged
Found while importing this repository for screenshots: `och-import-github --repo openchronology/timeline-app` failed with `500 Server request failed.` ## Cause Each duration's band keeps a notes preview of its first 2,000 characters in JSON (`durationOverview`). One pull request's text had an emoji (🤖) at exactly that point, so `description.slice(0, 2000)` kept half of its surrogate pair. `JSON.stringify` writes that as `\ud83e`, which PostgreSQL's jsonb refuses (`22P02 Unicode low surrogate must follow a high surrogate`), and the whole save failed. This affects any duration whose notes have an emoji at that point, not only mirrored ones. Text columns don't fail (a lone surrogate is sent as U+FFFD), but the text should still be cut whole. ## Fix - New core `clip(text, limit)` in `src/clip.ts`: it cuts at `limit` UTF-16 units, or one unit earlier when that would split a pair. - It now shortens: - band previews and titles (`durationOverview`); - suite descriptions; - syslog and log-mapping notes; - the search text, and overview titles; - hover previews; - every piece of text mirrored from GitHub, Forgejo and GitLab: notes, titles, tags, release, milestone and board-column titles, and commit messages. ## Tests - `test/search-postgres.mjs` saves a duration whose notes put an emoji right at 2,000. This fails with the error above without the fix and passes with it. - `test/github-source.test.mjs`: `text is cut short only between whole characters, never inside an emoji`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_011fFY8eruEi1xAkkMBni13B https://github.com/openchronology/timeline-app/pull/554
Related
Open #554 Keep emoji whole where stored text is cut short in the timeline