Skip to content

feat(mail): open recognized HWPX text from email attachments - #1406

Draft
seonghobae wants to merge 20 commits into
cursor/hwpx-recognized-text-preview-b246from
cursor/mail-hwpx-attachment-preview-7b5e
Draft

feat(mail): open recognized HWPX text from email attachments#1406
seonghobae wants to merge 20 commits into
cursor/hwpx-recognized-text-preview-b246from
cursor/mail-hwpx-attachment-preview-7b5e

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Current authority

This mail HWPX preview slice remains valid product work, but it is Draft and not merge-ready.

Parent adoption

The earlier child lineage had newer #1404 tree content without the current parent ancestry. 40594758c1f1791a1d679fb0ee0da0d1c8b2cf06 non-force merged current #1404 into this branch; cc7d2cefd41aff24bac1a1a94d3a0205984816c1 then exact-adopted the three current parent blobs that the initial merge tree had left stale. The branch therefore inherits the current #1404 preview authority without force-push, destructive rebase, or parent-source rollback.

Review repairs completed on this child

Attachment-body overfetch

RED contract 63fd00a9382c47f8e530a8c47b43f2988f80f9f7 captures the real PostgreSQL attachment SELECTs for both mail detail and thread and rejects any email_attachments.content projection. Causal fix 6d3bcc5afe0e6e0ccea9c03e03f2e7496f81947a replaces unrestricted relationship loading with selectinload(...).load_only(Attachment.filename, Attachment.parser_key, raiseload=True). The P1 review thread is resolved on source/contract evidence; no PostgreSQL GREEN is claimed because this stacked head has no repository-owned run.

PostgreSQL smoke cleanup

7615754fb9a49b3378db6d73f5093e9f53660e19 explicitly removes the seeded attachment row and then the email row before engine disposal, preserving the shared test database. The corresponding P2 thread is resolved; hosted PostgreSQL execution remains pending stacked-base workflow availability.

Out-of-order preview responses

Test-first bc24bf682ff6998610db39c90dc644cfeb8baad5 creates two same-asset requests, resolves the newer response first as recognized, then delivers an older pending response and requires the recognized result to remain. Causal fix 298bbba1fd8f3b4dcb9cdc7ac50bb6f2dd3e472e gives each asset a monotonically increasing request sequence and ignores stale success or failure completions. b0ba575... and c5fde35... only restore final newlines. The stale-response P2 thread is resolved on source/contract evidence, not executed frontend GREEN.

Signed-session evidence path

501d019e1ae0efde3b5df333047fda4fdd88b971 adds backend coverage that uses the real HMAC bearer verifier rather than dev_auth_dependency_overrides, plus a negative case proving public identity headers alone remain 401. edd3134a197fe819df366b469a2a4a1c5b27b4f7 adds Playwright coverage that requires naruon_session on both mail-detail and attachment-preview browser requests and rejects browser Authorization plus public identity headers. The authentication-evidence P2 thread is resolved on the presence of the correct contract/evidence path; no exact-head backend/browser GREEN is claimed.

Remaining live finding

One #1406 review thread remains unresolved: duplicate filename attachment identity. Two MIME parts with the same filename still receive the same opaque key because attachment identity is not part of the digest. This is the same canonical preview-key defect already open on parent #1404. It must be repaired once in #1404 and then inherited here; this child must not invent competing key semantics.

#1404 itself remains Draft with additional parent obligations, including #1345 prerequisite adoption, attachment workspace isolation, and remaining preview UI/runtime findings. #1406 must not bypass those obligations.

Evidence and merge boundary

This is a non-default stacked branch. Stacked-base workflow activation is canonically owned by Draft #1562 and is not protected-integrated; exact head edd3134... currently has 0 repository-owned pull-request workflow runs. No predecessor check or review transfers. Keep Draft until the parent/prerequisite stack is healthy, the duplicate-key owner finding is repaired and inherited, exact-head backend/frontend/PostgreSQL/browser/signed-session evidence is terminal-success, and a qualifying independent post-last-push approval applies. No force push, destructive rebase, self-approval, dummy requeue, bypass, or gate weakening.

List the current email's attachments with the same opaque asset_key as
the Data preview contract so a buyer can read ordered HWPX paragraphs
from mail without treating missing text as empty content.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a1f7f21f-f9c3-4897-978d-a596a8e1c1ac

📥 Commits

Reviewing files that changed from the base of the PR and between f218113 and b83a0da.

📒 Files selected for processing (11)
  • AGENTS.md
  • backend/api/emails.py
  • backend/tests/test_email_attachment_preview.py
  • docs/doctoring/hwp-hwpx-attachment-recognition.md
  • frontend/src/components/EmailDetail.test.tsx
  • frontend/src/components/EmailDetail.tsx
  • frontend/src/components/MailAttachmentPreview.test.tsx
  • frontend/src/components/MailAttachmentPreview.tsx
  • frontend/src/lib/email-threading.ts
  • frontend/tests/e2e/dashboard-flows.spec.ts
  • frontend/tests/e2e/helpers.ts

Included review availability: Your plan includes up to 1 review per rolling hour; 0 remain after this review.


Important

Approval pending

CodeRabbit has no unresolved comments, but it skipped the latest review.

Use the checkbox below to review the latest commit. CodeRabbit will approve the changes if it finds no blocking issues.

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Email detail and thread responses now expose opaque attachment references. The dashboard renders selected attachments through the repository preview endpoint and handles HWPX recognition states without exposing internal identifiers.

Changes

Mail attachment preview

Layer / File(s) Summary
Attachment API contract
backend/api/emails.py, AGENTS.md
Email detail and thread responses include opaque asset keys, sanitized filenames, parser metadata, and empty attachment lists when applicable.
Attachment preview UI
frontend/src/lib/email-threading.ts, frontend/src/components/EmailDetail.tsx, frontend/src/components/MailAttachmentPreview.tsx
The selected email exposes typed attachments. MailAttachmentPreview loads and caches repository previews and renders recognized, pending, failed, and unavailable states.
Preview behavior validation and traceability
backend/tests/test_email_attachment_preview.py, frontend/src/components/*.test.tsx, frontend/tests/e2e/*, docs/doctoring/hwp-hwpx-attachment-recognition.md
Tests cover opaque metadata, scoped previews, HWPX paragraph rendering, empty attachments, recognition states, generic 404 handling, and end-to-end opening. Documentation records the preview slice and preserved error behavior.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to b83a0

This PR adds recognized HWPX attachment previews to email while preserving existing preview behavior and unavailable/pending states. No actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant EmailDetail
  participant MailAttachmentPreview
  participant RepositoryAssetPreviewPanel
  User->>EmailDetail: select email
  EmailDetail->>MailAttachmentPreview: provide attachment references
  MailAttachmentPreview->>RepositoryAssetPreviewPanel: request preview by asset_key
  RepositoryAssetPreviewPanel-->>MailAttachmentPreview: return preview state and paragraphs
  MailAttachmentPreview-->>User: display selected attachment
Loading
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: opening recognized HWPX text from email attachments.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/mail-hwpx-attachment-preview-7b5e

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

PR governance metadata gate is not ready for b83a0da03b46a447f9710b5f91d245f5b1783dfa:

  • Draft PR: merge automation is paused.

cursoragent and others added 2 commits August 18, 2026 00:02
Bring Draft #1406 onto exact current #1404 f218113 so mail-attachment
reachability stays stacked on the live recognized-text preview parent.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
Wire the inherited 다시 확인 control to re-fetch the same opaque mail
attachment preview so the stacked parent refresh stays reachable.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
cursor Bot pushed a commit that referenced this pull request Aug 18, 2026
Bring Draft #1407 onto independently resolved live #1406
b83a0da. Previous parent 304d5af is stale.

Keep #1404/#1406 pending 다시 확인 refresh and mail reachability together
with the fail-closed Inkspan edit handoff. No rebase, squash, or force-push.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
@seonghobae
seonghobae marked this pull request as ready for review August 18, 2026 01:32
@cursor

cursor Bot commented Aug 18, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@seonghobae
seonghobae marked this pull request as draft August 18, 2026 02:06
@seonghobae

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

The rolling-hour window from #1404 f2181137 (finished 04:14 UTC) has elapsed. Please review exact current head b83a0da03b46a447f9710b5f91d245f5b1783dfa, stacked on live #1404 f2181137. Predecessor evidence does not transfer. Keep Draft. This comment is not an approval.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

@seonghobae Fresh review requested for exact head b83a0da03b46a447f9710b5f91d245f5b1783dfa. I will keep #1406 as Draft. I will not approve or merge it.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@opencode-agent opencode-agent Bot added priority: medium Normal-priority or P2 work status: draft Draft pull request type: feature New or expanded product capability labels Aug 22, 2026
@seonghobae
seonghobae marked this pull request as ready for review September 5, 2026 05:47
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 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-05T05:55:44.568649Z 1ff9fc7 Draft marked ready
ℹ️ 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: 1ff9fc7a1d

ℹ️ 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 backend/api/emails.py
file_name = _safe_email_display_text(getattr(attachment, "filename", None))
refs.append(
EmailAttachmentRef(
asset_key=_opaque_asset_key(email, attachment),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include attachment identity in each opaque asset key

When one email contains two attachments with the same filename—which the attachment schema permits—both references receive the same key because _opaque_asset_key hashes only the owner, message ID, and filename. MailAttachmentPreview subsequently uses that key for React identity, selection, and caching, while the preview endpoint returns the first matching row, so clicking either attachment can display the wrong document. Include an immutable attachment-specific value in the key and lookup, then add a duplicate-filename case to backend/tests/test_email_attachment_preview.py.

AGENTS.md reference: AGENTS.md:L449-L454

Useful? React with 👍 / 👎.

Comment thread backend/tests/test_email_attachment_preview.py
Comment thread backend/api/emails.py Outdated
Comment thread frontend/src/components/MailAttachmentPreview.tsx Outdated
Comment thread backend/tests/test_email_attachment_preview.py
@seonghobae
seonghobae marked this pull request as draft September 5, 2026 17:50
@seonghobae seonghobae added the enhancement New feature or request label Sep 7, 2026 — with ChatGPT Codex Connector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request priority: medium Normal-priority or P2 work status: draft Draft pull request type: feature New or expanded product capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants