Skip to content

Consolidate the reply-prefill readers into one shared helper - #384

Merged
jeremy merged 3 commits into
mainfrom
refactor/shared-prefill-reader
Sep 1, 2026
Merged

Consolidate the reply-prefill readers into one shared helper#384
jeremy merged 3 commits into
mainfrom
refactor/shared-prefill-reader

Conversation

@jeremy

@jeremy jeremy commented Sep 1, 2026

Copy link
Copy Markdown
Member

Follow-up from #370 and #372, carded and approved as [CLI][TUI] Consolidate the reply-prefill readers into one helper.

The CLI (hey reply, hey compose --thread-id) and the TUI reply form each parsed the reply prefill (GET /entries/{id}/replies/new.json) — subject, acting sender, recipients — with its own reader. Reviewers on those PRs nudged four times toward a shared helper; declined there to keep each PR single-concern, and carded as a follow-up instead. This PR is that card.

What moved:

  • New mail.ReplyPrefillFromServer (internal/mail/reply_prefill.go) is the one reader: it parses subject, acting sender, and recipients from HEY's prefill, and answers false — routing the caller to its local fallback — on a failed read or an empty recipient list, still carrying the subject and sender it did get.
  • resolveThreadReply in internal/cmd/thread_reply.go now calls it; the package-local replyPrefill type and replyPrefillFromServer reader are gone. replyRecipients is now an alias of mail.ReplyRecipients, so the local fallback and the existing tests read unchanged.
  • The TUI's loadReplyContext in internal/tui/compose.go drops its inline parsing block for the same call.

Pure refactor: no wire changes, and the existing reply tests in cmd and tui pass unchanged as the behavior lock, joined by a focused test for the helper itself. The auto_quoting invariant stays visibly intact and is now documented on the shared type: the prefill's quoted content is never carried or echoed back — HEY appends the quote at delivery.

One normalization note: the two readers disagreed only on degenerate prefill addresses (the CLI kept HEY's lists verbatim minus blanks; the TUI trimmed and case-deduped). The shared reader keeps HEY's computed lists verbatim, dropping blanks — identical output for anything HEY actually serves, and the tests lock that.


Summary by cubic

Consolidates the CLI and TUI reply-prefill readers into one shared helper in internal/mail, so both reply flows parse HEY's prefill identically. Pure refactor — no wire changes; existing reply tests pass unchanged.

Refactors

  • mail.ReplyPrefillFromServer reads subject, acting sender, and recipients, and returns false to trigger the caller's local fallback when the read fails or recipients are empty.
  • internal/cmd/thread_reply.go and internal/tui/compose.go now call it; their package-local readers are deleted.
  • The helper keeps HEY's recipient lists verbatim minus blanks; the TUI previously trimmed and case-deduped them, but output is identical for anything HEY actually serves.
  • The prefill's quoted content is never carried; that invariant is now documented on the shared type.
  • The reply-flow guide in AGENTS.md now points at the shared helper.

Written for commit af22ba0. Summary will update on new commits.

Review in cubic

Copilot AI balanced review requested due to automatic review settings September 1, 2026 20:35
@jeremy
jeremy requested a review from a team as a code owner September 1, 2026 20:35
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-01T21:07:37.171303Z af22ba0 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8e84aacfe3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/mail/reply_prefill.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Consolidates reply-prefill parsing into the shared internal/mail domain package for consistent CLI and TUI behavior.

Changes:

  • Adds shared reply-prefill types and reader.
  • Migrates CLI and TUI reply flows to the helper.
  • Adds focused tests for success, fallback, and failure paths.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
internal/mail/reply_prefill.go Implements shared prefill parsing.
internal/mail/reply_prefill_test.go Tests parsing and fallback behavior.
internal/cmd/thread_reply.go Adopts the shared helper for CLI replies.
internal/tui/compose.go Adopts the shared helper for TUI replies.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions github-actions Bot added the docs label Sep 1, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread internal/mail/reply_prefill.go
Comment thread internal/mail/reply_prefill_test.go
Comment thread internal/mail/reply_prefill.go
Comment thread internal/mail/reply_prefill.go
@jeremy

jeremy commented Sep 1, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: af22ba0e42

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jeremy
jeremy merged commit 313a811 into main Sep 1, 2026
23 checks passed
@jeremy
jeremy deleted the refactor/shared-prefill-reader branch September 1, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants