Skip to content

fix: keep derived session titles from splitting emoji surrogate pairs - #981

Open
soumojit-D48 wants to merge 1 commit into
truefoundry:mainfrom
soumojit-D48:fix/session-title-emoji-boundary
Open

soumojit-D48 wants to merge 1 commit into
truefoundry:mainfrom
soumojit-D48:fix/session-title-emoji-boundary

Conversation

@soumojit-D48

@soumojit-D48 soumojit-D48 commented Oct 6, 2026 •

Copy link
Copy Markdown

Summary

Derived session titles could end in a lone surrogate when the 50-character cap landed inside an emoji, storing malformed Unicode (visible as a replacement character in the session list). This PR backs off one unit when the cut would split a surrogate pair, so titles stay well-formed while keeping the existing length limit.

Closes #980

Changes

  • packages/trueforge/src/apis/turns.ts: route deriveSessionTitle through a new truncateSessionTitle helper that drops a trailing high surrogate after capping.
  • packages/trueforge/tests/unit/apis/turns.test.ts: new deriveSessionTitle block (cap behavior, short/empty inputs, intact pair inside the cap, split-pair back-off asserting the exact result).
  • .changeset/session-title-surrogate-boundary.md: patch bump for @truefoundry/trueforge.

How was this tested?

  • pnpm --filter @truefoundry/trueforge test -- tests/unit/apis/turns.test.ts: 14/14 pass (9 pre-existing + 5 new).
  • pnpm --filter @truefoundry/trueforge typecheck: exit 0 (src + tests projects).
  • eslint on the changed source file: clean (test files are eslint-ignored per repo config).
  • prettier --check on all changed/added files: pass.
  • Full-workspace pnpm build, pnpm test, and pnpm smoke were NOT run in this environment (Windows); CI covers the rest.

Checklist

  • I have read the contributing guidelines
  • pnpm build, pnpm test, pnpm typecheck, pnpm lint:ci, and pnpm format:check pass locally (package-level test/typecheck/eslint/prettier pass; full workspace gates pending CI — see above)
  • Tests added/updated where it makes sense
  • No hand-edits to generated code (packages/trueforge-sdk, python/trueforge_sdk, .github/fern/openapi/openapi.json, docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge
  • Docs / .env.example updated if configuration or behavior changed (not needed: no config or operator-visible behavior change beyond the bug fix)

@changeset-bot

changeset-bot Bot commented Oct 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f9e2f71

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@truefoundry/trueforge Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
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.

Session title corrupted when the first message has an emoji near the length limit

1 participant