Add /draft Draft Something workflow shell

✅ merged · #9 · foolish-bandit/gary ← foolish-bandit/gary · opened 19d ago by foolish-bandit · merged 19d ago by foolish-bandit · self · +562-1 across 2 files · ↗ on GitHub

From the PR description

Summary

Adds a frontend-only Draft Something flow that mirrors the /review pattern from PR #8. Reuses the existing assistant chat plumbing end-to-end - no new backend routes, no API contract changes.

What's new

  • New route /draft - frontend/src/app/(pages)/draft/page.tsx. Three-step lawyer-friendly UI with a stepper.
    • Step 1 - Choose draft type. 8-card grid with plain-English helper copy.
    • Step 2 - Add details. Description textarea with the suggested placeholder, optional Audience / Tone single-line inputs, optional "Attach a document" (via existing uploadStandaloneDocument), lawyer-facing caution box, and a primary Start Drafting button.
    • Step 3 - Review draft. Handed off to the assistant chat at /assistant/chat/{id}; stepper shows it for context.

Drafting options added

Option Helper copy
Email Draft a clear email to a client, opposing counsel, or another lawyer.
Letter Draft a formal letter using the facts and tone you provide.
Memo Draft a legal or business memo with organized sections.
Clause Draft or revise a contract clause.
Summary Summarize a document or issue in plain English.
Demand letter Draft a structured demand letter based on the facts you provide.
Client update Draft a short update explaining status, next steps, and risks.
Custom draft Anything else - describe what you need below.

Where the Draft Something card now points

  • Before: router.push("/workflows").
  • After: router.push("/draft") - the new shell.
  • /workflows is unchanged and still reachable from the sidebar.

Default drafting instruction (frontend-only)

Every drafting prompt is composed client-side as:

{opening for the chosen type}.

What I need:
{description}

Audience: {audience}        ← only if non-empty
Tone: {tone}                ← only if non-empty

Draft the requested legal document using the facts provided. Be clear,
organized, and practical. Do not invent facts. Flag any missing
information that would be needed before finalizing.

If a document is attached, the message includes its {filename, document_id} in the existing MikeMessage.files array - same shape that the home InitialView and the /review flow already use, so streaming and citations work out of the box.

Lawyer-facing caution

Step 2 shows: "Review the draft before using it. Gary may help organize and revise, but the lawyer is responsible for the final work."

Reuse of existing chat behavior

Yes, fully:

  • Upload: existing uploadStandaloneDocument from mikeApi.ts.
  • Chat handoff: existing useAssistantChat.handleNewChat() + ChatHistoryContext.newChatMessages + router.push("/assistant/chat/{id}").
  • Streaming, citations, and rendering: existing assistant chat view.
  • Empty validation: requires a non-empty description before allowing Start Drafting.

Backend files touched

None. git diff main..HEAD -- backend/ is empty.

Limitations / TODOs

  • No persisted "draft" entity. Each draft is a normal chat thread that shows up in the sidebar Assistant History. Persisting a typed draft (with status, version) would require backend work.
  • Custom draft option doesn't add structure beyond the description. Power users who want full control can keep using /workflows directly, which is unchanged.
  • Optional metadata is freeform text. No dropdowns for tone/audience - keeps the surface tight, matches the brief's "do not overbuild".
  • Stepper Step 3 is illustrative. Actual drafting happens on /assistant/chat/{id}.
  • /draft is not in the sidebar nav. Entry is the home card, by design.
  • No model/provider selection on /draft. Inherits the user's last-selected model. The dropdown still appears on the in-chat ChatInput and at /account/models.
  • Attachment is single-document. For multi-doc drafting (e.g. summarising several documents), the user can keep using /assistant with multiple chips or /workflows.

Build / lint / tests

  • npx tsc --noEmit - clean.
  • npm run lint - 107 problems on main, 107 after (identical baseline; nothing new in /draft/page.tsx or the InitialView edit).
  • npm run build - same fonts.googleapis.com sandbox network failure on main and on this branch; environmental, not code. Cloudflare Workers Builds will run the real build.
  • 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 Draft Something → lands on /draft Step 1.
  • Click each option in turn → advances to Step 2 with the right title in the chip; Choose a different type returns to Step 1.
  • In Step 2, click Start Drafting with an empty description → friendly inline error appears, no submission.
  • Type a description and click Start Drafting → routes to /assistant/chat/{id}; the assistant streams a draft.
  • Add an Audience and Tone, then start → those lines appear in the user message in chat.
  • Click Attach a document, upload a small PDF/DOCX → chip appears with a remove ×; start the draft → the chat shows the file attached.
  • Verify /workflows is still reachable from the sidebar and unchanged.

https://claude.ai/code/session_019pRkhcGDRKQWHjzAnV5yCL


Generated by Claude Code

Our analysis

Add a Draft Something shell that reuses the assistant chat — read the full analysis →

Think the analysis missed something the PR description covers?

Commits in this PR (1)

SHA Subject Author Date
7c520d4f Add /draft Draft Something workflow shell Claude 2026-05-07 ↗ GitHub
commit body
Adds a frontend-only drafting flow that mirrors the /review pattern
from PR #8. Reuses the existing assistant chat plumbing - no new
backend routes, no API contract changes.

- New route at /draft with a 3-step lawyer-friendly UI:
    1. Choose draft type (8 cards: Email, Letter, Memo, Clause,
       Summary, Demand letter, Client update, Custom draft, each
       with plain-English helper copy)
    2. Add details (description textarea with the suggested
       placeholder; optional Audience / Tone single-line fields;
       optional Attach a document via existing
       uploadStandaloneDocument; lawyer-facing caution box)
    3. Review draft (handed off to the assistant chat)
- Start Drafting builds a MikeMessage from the option's opening
  line + the user's description + optional metadata, appended with
  the default tail instruction:
    "Draft the requested legal document using the facts provided.
     Be clear, organized, and practical. Do not invent facts.
     Flag any missing information that would be needed before
     finalizing."
  Then reuses useAssistantChat.handleNewChat + router.push to the
  same /assistant/chat/{id} path used by /review and the home.
- Updates the Gary-mode "Draft Something" card to point at /draft
  instead of /workflows. /workflows is unchanged.

No backend 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-9.md from inside the repo you want the changes in.

⬇ Download capture-pull-9.md