Skip to content

fix: use ASCII record separator for multiline draft content in queries#1

Open
tofagerl wants to merge 1 commit intonerveband:mainfrom
tofagerl:fix/multiline-content-query
Open

fix: use ASCII record separator for multiline draft content in queries#1
tofagerl wants to merge 1 commit intonerveband:mainfrom
tofagerl:fix/multiline-content-query

Conversation

@tofagerl
Copy link
Copy Markdown

@tofagerl tofagerl commented May 2, 2026

Summary

  • list/Query silently drops or garbles any draft whose content contains newlines, because queryDrafts uses \n as both the record separator between drafts and it appears verbatim in multi-line content
  • Switches the AppleScript record separator from linefeed to ASCII character 30 (Record Separator, 0x1E) — a control character designed for this purpose that won't appear in user-authored text
  • Adds TestQueryMultilineContent which creates a multi-line draft, queries for it, and verifies both discovery and content integrity

How to reproduce the bug

# Create a multiline draft
drafts new "Line one
Line two
Line three"

# List inbox — the draft is missing or garbled
drafts list --filter inbox

drafts get <uuid> works fine because it queries a single draft without using newline as a record separator.

Test plan

  • TestQueryMultilineContent fails on main, passes with fix
  • All 19 other passing tests remain green (only TestWorkspaces fails, pre-existing)

🤖 Generated with Claude Code

The list/query command uses newline as a record separator between drafts
in the AppleScript output, but draft content can itself contain newlines.
This causes parseDraftFromAppleScript to split records mid-content,
silently dropping or garbling any draft with multiline content.

Switch to ASCII Record Separator (0x1E) which won't appear in
user-authored text. Includes a regression test that creates a multiline
draft and verifies Query returns it with content intact.

Co-Authored-By: Claude Opus 4.6 (1M context) <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