Skip to content

Draft review view: accept/reject changes in-app + full review-state reads#172

Open
mhurhangee wants to merge 8 commits into
mainfrom
feat/draft-review-panel
Open

Draft review view: accept/reject changes in-app + full review-state reads#172
mhurhangee wants to merge 8 commits into
mainfrom
feat/draft-review-panel

Conversation

@mhurhangee

Copy link
Copy Markdown
Owner

First slice of the draft-review-panel fast-follow (living-docs/draft-review-panel.md, items 2 + 3). Addresses the feedback from the first real drafting sessions: the plain-text preview was a mistake, and read_draft was blind to its own redlines + comments.

Review view (replaces the plain preview)

DraftPanel is now a review surface. Default Review mode condenses the draft to just the changed and commented paragraphs, each a card with the redlined text (real ins/del marks) and Accept / Reject buttons that resolve the change in place — no need to open Word. A change queued behind an open Word lock shows a "queued — close the draft to apply" badge. A Document mode toggle keeps the full-text read. Comments render on the card of the paragraph they anchor to.

  • resolveParagraphRevision (adapter) — accept/reject Patrick's redline in one paragraph. The paragraph is the change unit (the adapter supersedes, so a paragraph only ever holds one round of Patrick's revisions). Mirror DOM surgery of the reject path: accept unwraps w:ins / drops w:del.
  • Rides the dance as a resolve op — parks while the draft is open in Word, drains on close, persists across restart, serialized like every other mutation.

read_draft full review state (agent visibility)

read_draft now shows pending redlines inline as {++inserted++} / {--deleted--} (tagged with the author when it isn't Patrick), and lists comments under the paragraph they anchor to. The agent no longer reads past its own tracked changes and the attorney's comments as if the document were clean — the observed "ignores existing changes/comments" problem.

Supporting

  • docx-text returns runs (each carrying its w:id + author) + comments in one fetch; listComments reports each comment's anchor paragraph; DraftStatus.parkedOps summarises what's queued.

Testing

64 tests green (new: resolve accept/reject round-trips + no-op refusal, run revision-id/author, comment anchor paragraph, parked-op summaries, a resolve op through the dance). Routes smoke-tested end-to-end against a redlined USPTO fixture (docx-text → runs+comments, resolve accept → change goes permanent).

Manual check to do: drive a real drafting session in pnpm dev — accept/reject cards, the queued badge while Word holds the draft open, the Review/Document toggle.

Next in the plan: quick-edit + adjust/comment cards, overlap-aware attorney-revision editing, re-lock.

The backend for the draft review panel:
- read_draft now shows the FULL review state — pending redlines inline
  as {++inserted++}/{--deleted--} (tagged with the author when it isn't
  Patrick), and comments listed under the paragraph they anchor to. The
  agent no longer reads past its own tracked changes and the attorney's
  comments as if the document were clean.
- resolveParagraphRevision accepts/rejects Patrick's redline in ONE
  paragraph in place (the paragraph IS the change unit — the adapter
  supersedes, so a paragraph only ever holds one round). Mirror DOM
  surgery of the reject path: accept unwraps w:ins / drops w:del. Rides
  the dance as a 'resolve' op (parks while the draft is open in Word).
- docx-text returns runs (each carrying its w:id + author) + comments in
  one fetch; listComments reports each comment's anchor paragraph;
  DraftStatus.parkedOps summarises what's queued.
DraftPanel becomes a review surface: a Review mode (default) condensing
the draft to just the changed and commented paragraphs, each a card with
the redlined text and Accept / Reject buttons that resolve the change in
place through the dance — no need to open Word. A change queued behind an
open Word lock shows a 'queued — close the draft to apply' badge (parsed
from the dance's parkedOps). A Document mode toggle keeps the full-text
read. Comments render on the card of the paragraph they anchor to.
@vercel

vercel Bot commented Jul 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
patrick-web Skipped Skipped Jul 4, 2026 10:15pm

relockDocument flips an unlocked original back to read-only — it drops
out of the draft world (still readable/pinnable). The pristine backup
stays, so re-unlocking reuses it rather than re-snapshotting; any of
Patrick's tracked changes already in the file remain for review in Word.
Surfaced as a 'Lock (stop editing)' item in the document kebab menu,
mirroring 'Unlock for editing'.
Working through the semantics showed the living-doc's 'accept then
redline' shortcut breaks reject-to-original (collapses the change chain,
loses the original text) — so both edit directions need the bespoke
stacking splice, not superseding. Captured the algorithm + overlap rules
+ test matrix so it's implementation-ready.
mhurhangee added a commit that referenced this pull request Jul 4, 2026
Correctness:
- resolveParagraphRevision is content-addressed (expectedText) + verified
  before write, not bare-index — a Word-side save or list-rewrite that
  shifts paragraph indices can no longer accept/reject the wrong change
- re-lock discards the draft's parked ops (dance.discardParked) — the
  attorney locked it to STOP editing; queued edits must not drain in
- the review card only offers Accept/Reject on Patrick's own redline
  (docx-text now marks paragraphs ); the attorney's own
  tracked changes show a 'resolve in Word' note instead of no-op buttons
- unanchored comments (no resolvable paragraph anchor) surface in a
  trailing section instead of being silently dropped
- a failed/refused resolve now shows an error in the panel

Robustness:
- read_draft hands the agent an explicit target_text line on revised
  paragraphs (no lossy reconstruction from CriticMarkup)

Cleanup:
- parkedOps carry a structured paragraphIndex (no regex on a display
  string for the queued badge)
- one shared collectByAuthor helper for accept/reject surgery
- readDraftReview loads+parses the docx once for runs + comments (the
  polled review path no longer double-unzips)
Correctness:
- resolveParagraphRevision is content-addressed (expectedText) + verified
  before write, not bare-index — a Word-side save or list-rewrite that
  shifts paragraph indices can no longer accept/reject the wrong change
- re-lock discards the draft's parked ops (dance.discardParked) — the
  attorney locked it to STOP editing; queued edits must not drain in
- the review card only offers Accept/Reject on Patrick's own redline
  (docx-text now marks paragraphs resolvable); the attorney's own tracked
  changes show a "resolve in Word" note instead of no-op buttons
- unanchored comments (no resolvable paragraph anchor) surface in a
  trailing section instead of being silently dropped
- a failed/refused resolve now shows an error in the panel

Robustness:
- read_draft hands the agent an explicit target_text line on revised
  paragraphs (no lossy reconstruction from CriticMarkup)

Cleanup:
- parkedOps carry a structured paragraphIndex (no regex on a display
  string for the queued badge)
- one shared collectByAuthor helper for accept/reject surgery
- readDraftReview loads+parses the docx once for runs + comments (the
  polled review path no longer double-unzips)
@mhurhangee mhurhangee force-pushed the feat/draft-review-panel branch from 0715cb3 to b524504 Compare July 4, 2026 22:15
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