Skip to content

Add Coach: an in-editor writing coach for drafts#205

Draft
leomattic wants to merge 2 commits into
trunkfrom
test/leo-branch
Draft

Add Coach: an in-editor writing coach for drafts#205
leomattic wants to merge 2 commits into
trunkfrom
test/leo-branch

Conversation

@leomattic
Copy link
Copy Markdown

@leomattic leomattic commented May 20, 2026

Closes #189

What this adds

Coach is a new right-rail mode in the draft editor that reviews a draft and helps improve it, aimed at people writing in a non-native language and anyone who wants coaching beyond a spell check.

Coach mode

Open it from the rail. Three sections:

Review (whole document)

Scans the draft into three lenses, each with its own editor underline and a teaching popover on click:

  • Grammar (red): real errors (agreement, tense, articles, plurals, spelling).
  • Style (amber): wordiness, filler, weak word choice, unnatural collocations ("make a photo" → "take a photo"), repetition, weak verbs, unnecessary passive.
  • AI tells (violet): machine-sounding constructions (false contrasts, stock phrases, empty tricolons) so the writer learns to spot them.

Each finding explains why, not just what to change. Pills toggle each lens. The scan auto-runs on entering the tab when the draft changed since the last scan; "Rescan" forces it. A one-line summary shows register (from the scan) plus reading level (Flesch grade, computed locally and live).

Rewrite (selection)

Selection driven, falling back to the current sentence. Six actions, two per line: Beautify, Natural, Fix, Simpler, Rephrase, Humanize. Each returns one suggestion as a before/after diff before you apply. My voice is a placeholder for a later samples-based feature.

Structure (whole document, opt-in)

A separate heavier pass (Sonnet) on organization and flow: buried ledes, paragraphs doing two jobs, weak openings/endings, abrupt transitions. Notes link to the paragraph. Opt-in so the fast loop stays cheap.

Hover popover

Hovering a word shows a definition, the meaning in context, tappable synonyms, and a one-line sentence rewrite. Synonyms and the rewrite apply in place.

Notes

  • Coach flags em dashes and other AI tells, so its own output is de-dashed; it never emits what it warns about.
  • Reuses the checks pipeline (offset anchoring, decorations, bulk apply) and the language-aid hover from an earlier iteration.
  • New helpers (deDash, wordDiff, readability) and the shared model-JSON parser are unit tested.

Testing

  • tsc, ESLint, Stylelint clean; 482 unit tests pass.
  • Verified end to end via Playwright: each lens flags and applies, Beautify vs Simpler differ clearly, the rewrite diff/apply work, auto-rescan fires only when stale, structure notes jump to the right paragraph, hover popover is rich. Synced onto latest trunk (History tab + voice work); both coexist, no console errors.

Known rough edges

  • Register can vary between scans on short drafts (Haiku judgment).
  • Category bucketing is occasionally loose (a passive finding once landed under Grammar). Detection is solid; the bucket is tunable with prompt work.

🤖 Generated with Claude Code

leomattic and others added 2 commits May 20, 2026 17:12
A right-rail Coach tab that reviews a draft and helps improve it, aimed at
foreign-language writers and anyone who wants coaching:

- Review: scans the draft for grammar, style (collocations, repetition,
  filler, passive voice) and AI-tell issues, underlines them in the editor,
  and explains each in a teaching popover. Auto-runs on entering the tab when
  results are stale.
- Rewrite: selection-driven actions (Beautify, Natural, Fix, Simpler,
  Rephrase, Humanize) returning one suggestion, shown as a before/after diff
  before you apply.
- Structure: opt-in paragraph-level review (organization, transitions, weak
  openings/endings) with click-to-jump.
- A "how this reads" summary (AI register + local readability) and a richer
  hover popover (definition, synonyms, sentence rewrite).

Generated prose is de-dashed so the tool that flags AI tells doesn't emit
them itself. New pure helpers (deDash, wordDiff, readability) and the JSON
parser are unit-tested.

Closes #189

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
# Conflicts:
#	src/main/channels/ui-prefs-set.ts
#	src/renderer/components/DraftSidebar.tsx
#	src/renderer/screens/DraftEditorScreen.tsx
leomattic added a commit that referenced this pull request May 20, 2026
@leomattic leomattic self-assigned this May 20, 2026
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.

Add "Coach" writing-aid panel for foreign-language writers

1 participant