Skip to content

feat(languagetool): 'Check this scene' grammar panel (PR-C1 MVP)#236

Merged
qnbs merged 3 commits into
mainfrom
feat/languagetool-scene-check-panel
Jun 24, 2026
Merged

feat(languagetool): 'Check this scene' grammar panel (PR-C1 MVP)#236
qnbs merged 3 commits into
mainfrom
feat/languagetool-scene-check-panel

Conversation

@qnbs

@qnbs qnbs commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Summary

PR-C1 of the LanguageTool program — the on-demand grammar/spell MVP wired into the Writer tools sidebar, built on the tested languageToolService (#235). Deterministic, self-hosted, no AI tokens, separate from the AI generation flow.

What's new

  • hooks/useLanguageToolCheck.ts — orchestration. Resolves the active locale → LanguageTool code from the SSOT (getLanguageToolCode, feat(i18n): LanguageTool registry metadata + Phase-0 report (Workstream B) #234), enforces the privacy gate (assertLanguageToolAllowed), runs checkText on the active section (abortable; a rapid re-trigger cancels the prior run). Apply is offset-safe and re-checks (offsets shift after an edit); add-to-dictionary persists to advancedEditor.customDictionary (reused — no new settings field) and drops the word's spelling matches; ignore dismisses one match.
  • components/writing/GrammarCheckPanel.tsx — "Check this scene" button + diagnostics list (category, message, flagged span, replacement chips → one-click apply, ignore, add-to-dictionary). Hidden entirely for LanguageTool-unsupported locales (tr/he/fi/hu/is/eu/ko); shows an enable hint when the integration is off; offline/error degrade quietly so typing is never blocked.
  • Wired into ToolsPanel below the AI tools (bordered section).
  • i18n: 14 writer.grammar.* keys across all 19 locales (core-5 hand-translated: en/de/es/fr/it; others English-seeded for parity, bulk-MT later) + rebuilt bundles.
  • Tests (GrammarCheckPanel.test.tsx, 5): check→list, apply→dispatch+re-check, ignore removes, unsupported-locale hidden, disabled hint. Service core covered by feat(languagetool): real grammar-check service (checkText + offset-safe apply) #235's 13 tests; gating by languageToolClient.test.

Test plan

  • pnpm run lint ✅ · pnpm run typecheck ✅ · pnpm run i18n:check ✅ (+14 keys/bundle, parity OK) · pnpm run suppressions:check ✅ (no new suppressions)
  • pnpm exec vitest run tests/unit/GrammarCheckPanel.test.tsx tests/unit/languageToolService.test.ts tests/unit/i18nPlaceholders.test.ts ✅ (55)

Verification (manual, later)

Run a local LanguageTool (docker run -p 8010:8010 erikvl87/languagetool), enable it in Settings → Connections, then "Check this scene" on a section with a planted error → fix applies offset-safe; add-to-dictionary suppresses a flagged name; server-down degrades silently.

Next in the stack

PR-C2 — live inline underlines on the ManuscriptEditor overlay + suggestion popover.

🤖 Generated with Claude Code

On-demand, self-hosted LanguageTool grammar/spell check wired into the Writer
tools sidebar — deterministic, no AI tokens, separate from the AI generation flow.

- hooks/useLanguageToolCheck.ts — orchestration: resolves locale→LT code from the
  SSOT (getLanguageToolCode), enforces the privacy gate (assertLanguageToolAllowed),
  runs checkText on the active section (abortable), and applies/ignores/dictionaries
  results. Apply is offset-safe and re-checks (offsets shift); add-to-dictionary
  persists to advancedEditor.customDictionary and drops the word's spelling matches.
- components/writing/GrammarCheckPanel.tsx — button + diagnostics list (category,
  message, flagged span, replacement chips → one-click apply, ignore, add-to-
  dictionary). Hidden entirely for LanguageTool-unsupported locales (tr/he/fi/hu/
  is/eu/ko); enable hint when the integration is off; offline/error degrade quietly.
- i18n: 14 writer.grammar.* keys across all 19 locales (core-5 hand-translated,
  others English-seeded for parity; bulk-MT later) + rebuilt bundles.
- Tests: GrammarCheckPanel integration (check→list, apply→dispatch+recheck, ignore,
  unsupported-locale hidden, disabled hint) — 5; service core already covered.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
worldscript-studio Ready Ready Preview, Comment Jun 24, 2026 10:07pm

@deepsource-io

deepsource-io Bot commented Jun 24, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 80ed2e1...0a36f07 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Docker Jun 24, 2026 10:06p.m. Review ↗
JavaScript Jun 24, 2026 10:06p.m. Review ↗
CSS Jun 24, 2026 10:06p.m. Review ↗
Rust Jun 24, 2026 10:06p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

Comment thread components/writing/GrammarCheckPanel.tsx
…nel test + JS-0357

- useLanguageToolCheck: defensive ?? defaults on settings.integrations/advancedEditor
  so the panel never crashes on a partial persisted-settings object (project convention)
  — fixes the Quality Gate failure where WriterView/WriterViewUI tests render ToolsPanel.
- ToolsPanel.test: stub GrammarCheckPanel (it pulls in Redux) to keep ToolsPanel's unit
  test isolated, matching the existing ToolInputs/Select stubs.
- GrammarCheckPanel: declare GrammarMatchItem before use (DeepSource JS-0357).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
components/writing/GrammarCheckPanel.tsx 86.66% 1 Missing and 3 partials ⚠️
hooks/useLanguageToolCheck.ts 95.08% 0 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

…ov/patch)

Add a dedicated useLanguageToolCheck hook test (unsupported/disabled/unknown-
section/offline/error in check, apply + stale no-op, dictionary add/dedup/blank,
ignore, clear) and panel display tests (noIssues/offline/error/add-to-dictionary/
no-suggestions). Lifts patch coverage of the hook+panel from ~67% to ~99% lines.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
qnbs added a commit that referenced this pull request Jun 24, 2026
…e loop (#237)

* docs(deepsource): inline review threads now resolvable — reply+resolve loop (§1/§3a/§11)

DeepSource began posting inline PR review comments in resolvable threads
(deepsource-io[bot]) on code PRs #235/#236 — the earlier 'no resolveReviewThread
step' note is obsolete. Update the loop to: fix → status green → reply citing the
commit + resolveReviewThread, 0 unresolved (mirrors CodeAnt). Add §3a GraphQL
snippet, correct the status-vs-check-run reality (read commits/$SHA/status +
target_url), and log the JS-C1002/JS-0357 + tests/unit-is-analyzed + codecov/patch
lessons.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* docs(deepsource): termination condition also requires 0 unresolved threads

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@qnbs qnbs merged commit 358327f into main Jun 24, 2026
31 of 32 checks passed
@qnbs qnbs deleted the feat/languagetool-scene-check-panel branch June 24, 2026 22:52
qnbs added a commit that referenced this pull request Jun 25, 2026
* docs(languagetool): feature guide + ADR 0010 + CHANGELOG + README

Document the shipped LanguageTool integration (registry metadata #234, service
#235, on-demand panel #236, live inline overlay #238): docs/LANGUAGETOOL.md
(setup, privacy model, locale coverage, architecture), ADR 0010 (self-hosted +
overlay-reuse + locale-mapping rationale), CHANGELOG [Unreleased] entry, README
feature line + Documentation Hub row. Locale-addition rollout (pl/nl/tr/uk/ro)
is tracked separately and intentionally not covered here.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* docs(i18n): dedicated TODO for the LanguageTool new-locale rollout (deferred)

Self-contained plan for the remaining program tail — adding pl/nl/tr/uk/ro UI
locales (per-locale recipe, LT metadata, sequencing, gotchas) + the
locale-dependent closing docs (README 19→24, handover report). Deferred for
later execution after other planned work.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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