Skip to content

fix: shorten overlong Summary titles instead of discarding the generation - #511

Merged
xinyao27 merged 3 commits into
mainfrom
fix/summary-title-overflow
Jul 27, 2026
Merged

fix: shorten overlong Summary titles instead of discarding the generation#511
xinyao27 merged 3 commits into
mainfrom
fix/summary-title-overflow

Conversation

@johnjyang

Copy link
Copy Markdown
Contributor

Problem

spool share threw away a complete local-Agent Summary when the front-matter title or title_zh ran past 96 characters:

▲  Could not generate or upload the Summary
■  Claude Code returned an invalid bilingual Summary: `title` and `title_zh` must each be at most 96 characters

The whole generation — minutes of provider usage — was discarded and never written anywhere, over the tail of one line. That contract was also inconsistent: every reader already bounds titles to 96 characters through parseSummaryFrontMatterboundTitle, so the overflow was never going to reach a reader.

Change

repairOverlongSummaryTitles (apps/cli/src/commands/share.ts) runs before validation and rewrites only the leading front-matter:

  • Cuts back to the last word boundary (floor at half the budget) so English titles don't end mid-word.
  • Falls back to a codepoint slice for space-free scripts — the usual title_zh case.
  • Strips trailing whitespace/punctuation and appends , landing at ≤96 characters.
  • Reports it after upload: Shortened `title` to the 96-character Session title limit.

Bodies are left byte-identical. Structural defects — missing delimiters, missing titles, a body repeating the title as its H1, >64 KiB — stay hard failures. The validator keeps its overflow branch as a backstop and now derives the number from the shared SUMMARY_TITLE_CHAR_LIMIT.

Tests

  • Unit test of the repair: English word-boundary shortening, Chinese codepoint shortening, bodies untouched, conforming and legacy no-front-matter Summaries returned unchanged.
  • End-to-end flow test: an Agent returning a 130-character title now exits 0 with the shortened title uploaded. Verified this test reproduces the reported failure (exit 1) against the pre-fix code before restoring the fix.

Full CLI suite green (254 tests / 26 files), tsc --noEmit clean, lint and format clean.

Known gap

The "Summary bodies must not repeat the Session title as their first H1" rule is the same class of cosmetic-but-fatal check and is equally mechanical to repair (drop the duplicate heading line). Left out to keep this scoped to the reported failure.

🤖 Generated with Claude Code

…tion

`spool share` rejected a local-Agent Summary whose front-matter `title` or
`title_zh` ran past 96 characters, throwing away the whole generation over
the tail of one line. Every reader already bounds titles to 96 characters
via `boundTitle`, so the overflow never reached a reader anyway.

Repair the front-matter before validation: cut back to a word boundary for
space-delimited titles, slice by codepoint otherwise, and mark the cut with
an ellipsis. Bodies are left byte-identical, and the CLI reports which title
was shortened. Structural defects stay hard failures.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Comment thread apps/cli/src/commands/share.ts Fixed
@xinyao27
xinyao27 added this pull request to the merge queue Jul 27, 2026
Merged via the queue into main with commit 4c94d68 Jul 27, 2026
5 checks passed
@xinyao27
xinyao27 deleted the fix/summary-title-overflow branch July 27, 2026 13:19
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.

3 participants