Add /review contract review shell
From the PR description
Summary
Adds a frontend-only Contract Review flow that reuses every existing backend route - no new endpoints, no API contract changes.
What's new
- New route
/review-frontend/src/app/(pages)/review/page.tsx. Three-step lawyer-friendly UI with a stepper at the top.- Step 1 - Choose contract. Reuses
useDirectoryData+FileDirectory(single-select) so the user can pick from their existing documents. Also exposes an inline "Upload contract" button that calls the existinguploadStandaloneDocument. On selection or upload, advances to Step 2. - Step 2 - Ready to review. Shows the selected contract chip, an 11-bullet checklist of what Gary will look for (Parties, Important dates, Governing law, Payment terms, Termination, Indemnity, Confidentiality, Assignment, Dispute resolution, Unusual or risky clauses, Missing clauses), the citation expectation note, and a primary Start Review button.
- Step 3 - Review key terms. Lives in the existing assistant chat. Stepper visualises it but the actual content is rendered by the assistant chat page after handoff.
- Step 1 - Choose contract. Reuses
- Default review prompt baked into the frontend bundle: "Review this contract. Identify the parties, important dates, governing law, payment terms, termination rights, indemnity, confidentiality, assignment, dispute resolution, unusual or risky clauses, and missing clauses. Cite the document for each finding."
- Citation expectation visible in the UI: "Gary will cite the document so you can check each finding. AI can make mistakes - answers are not legal advice."
How the handoff works
Start Review builds a MikeMessage with the prompt and the selected {filename, document_id}, calls useAssistantChat().handleNewChat(message), then router.push("/assistant/chat/{newChatId}"). That's the same path the Gary-mode home InitialView already uses - no new chat plumbing, no new context. The chat page picks up newChatMessages from ChatHistoryContext and auto-sends to the existing streamChat endpoint, which already supports per-message file attachments and citations.
Where the Review Contract button now points
- Before:
router.push("/tabular-reviews")(the cross-document tabular review feature). - After:
router.push("/review")- the new shell. /tabular-reviewsis unchanged and still reachable from the sidebar.
Reuse of existing functionality
Yes, end to end:
- Upload: existing
uploadStandaloneDocumentfrommikeApi.ts. - Document picker: existing
useDirectoryData+FileDirectory. - Assistant chat startup: existing
useAssistantChat.handleNewChat+ChatHistoryContext. - Streaming, citations, and rendering: existing assistant chat view.
Backend files touched
None. git diff main..HEAD -- backend/ is empty.
Limitations / TODOs
- No saved "review" object yet. The review lives as a normal chat thread; it shows up in the sidebar Assistant History. A future PR can persist a typed review with status, but that needs backend work and is out of scope.
- Single document per review. The contract review picker is single-select. Multi-doc cross-review is what
/tabular-reviewsalready does, so we route the lawyer there if they want it. - Stepper Step 3 is illustrative. The actual chat happens on
/assistant/chat/{id}, not on this page. The stepper sets expectations rather than driving navigation. - No explicit progress UI for "Reading the document...". That's already handled inside the assistant chat (PreResponseWrapper "Working" / reasoning block), so we don't duplicate it.
/reviewis not in the sidebar nav. Entry point is the Gary-mode home card. That keeps the sidebar (per the brief: don't redesign the full app) intact.- Provider/model selection is not exposed on
/review. PR #6 already hid the model dropdown on the home empty state; the review handoff inherits the user's last-selected model. The dropdown still appears once the user lands on/assistant/chat/{id}. - No "review failed" state distinct from chat failures. If the underlying
streamChaterrors, the assistant chat shows the existing "Something went wrong. Try asking again." (PR #7), which is appropriate.
Build / lint / tests
npx tsc --noEmit- clean.npm run lint- 107 problems onmain, 107 after (identical baseline; nothing new in/review/page.tsxor the InitialView edit).npm run build- samefonts.googleapis.comsandbox network failure onmainand on this branch; not a code issue. Cloudflare Workers Builds will run the real build on the PR.- No test scripts in either
package.json.
Test plan
- Workers Build for this PR succeeds.
- On the preview Worker URL, log in. From the Gary-mode home, click Review Contract → lands on
/reviewStep 1. - Pick an existing document → advances to Step 2 with the doc shown in the chip and the 11-bullet "Gary will look for" list visible.
- Click Choose a different document → returns to Step 1 with the picker.
- Click Upload contract, pick a small PDF or DOCX → uploads with "Uploading your document..." feedback, lands on Step 2.
- Click Start Review → button shows "Starting review...", routes to
/assistant/chat/{id}and the assistant streams a response that cites the document. - Try with no internet / a 500 - friendly error appears in step UI.
- Verify
/tabular-reviewsis still reachable from the sidebar and unchanged.
https://claude.ai/code/session_019pRkhcGDRKQWHjzAnV5yCL
Generated by Claude Code
Our analysis
Wire a guided contract review flow over existing chat plumbing — read the full analysis →
Think the analysis missed something the PR description covers?
Commits in this PR (1)
| SHA | Subject | Author | Date | |
|---|---|---|---|---|
16c7bffd | Add /review contract review shell | Claude | 2026-05-07 | ↗ GitHub |
commit bodyBuilds a frontend-only Contract Review flow that reuses the existing
upload, document picker, and assistant chat plumbing - no new backend
routes.
- New route at /review with a 3-step lawyer-friendly UI:
1. Choose contract (existing FileDirectory single-select +
upload via uploadStandaloneDocument)
2. Confirm review (selected doc, what Gary will look for,
citation expectation, "answers are not legal advice")
3. Review key terms (handed off to the assistant chat)
- Start Review builds a MikeMessage with a fixed review prompt and
the chosen document, then reuses useAssistantChat.handleNewChat
+ router.push("/assistant/chat/{id}"), the same path used by
the Gary-mode home InitialView. The new chat page auto-sends
the prefilled message and streams the cited response.
- Updates the Gary-mode "Review Contract" card to point at /review
instead of /tabular-reviews. /tabular-reviews is unchanged and
still reachable from the sidebar.
No backend changes, no API contract changes, no auth/billing/teams,
no new providers. License unchanged.
https://claude.ai/code/session_019pRkhcGDRKQWHjzAnV5yCL
| ||||
Capture this PR into my fork
Download a Markdown prompt that tells Claude how to port every
commit in this PR into your working tree. Run it via
claude -p < capture-pull-8.md from
inside the repo you want the changes in.