From 7e076f7587c8cbaf244ce1fa262523c4364d6542 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 21 Jul 2026 20:11:01 +0000 Subject: [PATCH] Organise & polish: welcome hero, docs refresh, theming fixes, audit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Consolidation pass after the revamp (Milestone 6). No behavioural regressions — typecheck + 717 unit tests + production build all green. Docs - README: fix the "Website" link (pointed at a different project) to the live app; correct the stale commercial-contact email to the canonical in-app one (features/about/links.ts); document the shipped revamp feature set (tracked changes, collaboration, roles, connectors) it never mentioned. - architecture.md: refresh the storage-schema table from a stale v3 to the real v7; cross-link the revamp record and cloud docs. - Add docs/refactor-audit.md: an honest health snapshot plus a prioritised backlog (add a linter, pin the package manager, OG image, decompose the three largest components, dead-code detection, docs consolidation). UX - Elevate the first-run welcome screen (what a new verbalis.britx.me visitor lands on) into a proper hero — brand mark, value props, three-step flow, clear CTAs — all in the existing design tokens. - index.html: add Open Graph / Twitter Card / canonical / keyword meta and a light+dark theme-color so shared links and PWA installs render properly. Fixes / refactor - Theming: the sidebar + status-filter active background hardcoded the dark-theme accent (rgba(0,194,204,0.08)) in four places and did not adapt in light mode; replace with a new per-theme --color-accent-subtle token. - Dedup three copy-pasted sidebar NavLink blocks into one SidebarLink. - Complete the TopBar breadcrumb labels (/corpora, /addons, /guide, /about) so they stop rendering as raw paths. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_013kzE8hPSJxu19tzs7kuMMa --- README.md | 45 ++++-- docs/architecture.md | 34 ++-- docs/refactor-audit.md | 200 ++++++++++++++++++++++++ index.html | 39 ++++- src/components/layout/Sidebar.tsx | 86 +++++----- src/components/layout/TopBar.tsx | 6 +- src/features/editor/StatusFilterBar.tsx | 2 +- src/features/projects/index.tsx | 188 +++++++++++++++------- src/styles/tokens.css | 3 + 9 files changed, 479 insertions(+), 124 deletions(-) create mode 100644 docs/refactor-audit.md diff --git a/README.md b/README.md index 4caa797..40d2cc6 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ **Local-first CAT tool for translators who can't afford to leak a sentence.** -[Website](https://pedrobritx.github.io/EwP/) · +[Launch the app](https://verbalis.britx.me/) · [GitHub](https://github.com/pedrobritx/verbalis) · -[LinkedIn](https://www.linkedin.com/in/pedrobritx/) · +[License](LICENSE.md) · [Buy me a coffee](https://buymeacoffee.com/pedrobritx) @@ -37,8 +37,8 @@ isn't a setting you toggle — it's the architecture. (IndexedDB). Nothing is uploaded; works fully offline as an installable PWA. - 🛡️ **Built for confidential work** — designed for security-sensitive translation where the source text cannot leave the machine. -- 🔁 **Industry interoperable** — round-trips XLIFF 1.2, TMX, TBX, OmegaT and - MultiTerm, so it drops into existing CAT pipelines. +- 🔁 **Industry interoperable** — round-trips XLIFF 1.2, TMX, TBX, OmegaT, + MultiTerm and clean DOCX, so it drops into existing CAT pipelines. - 🧠 **Smart assist** — translation memory, glossary matching and optional on-device semantic search to reuse past work. - 📚 **Bundled corpora** — install pre-curated PT→EN legal, competition @@ -47,23 +47,50 @@ isn't a setting you toggle — it's the architecture. built-in translation guide covers the workflow and British-English/ABNT conventions. +## For teams who want more (all opt-in) + +Everything above works with **no account and no network**. Sign in — with +Google, Microsoft, Apple or a magic link — and Verbalis unlocks a collaborative +layer, still built on the same local-first foundation: + +- ✍️ **Tracked changes & comments** — Google-Docs/Word-style inline suggestions, + accept/reject, and range-anchored threaded comments, entirely local. +- 👥 **Real-time collaboration** — live multi-user projects with per-segment edit + leases, remote cursors, and project roles (project manager / translator / + revisor) with a review-and-approve workflow. +- ☁️ **Sync & cloud projects** — synced preferences, a personal term bank and TM, + and shared projects backed by Supabase — the signed-in code never loads at all + in local-only mode. +- 🧩 **Extensions & connectors** — MT providers, QA rules and formats are + addons in a typed registry, plus Google Drive and OneDrive storage connectors + (pure client-side OAuth, no Supabase required). + ## Tech -React + TypeScript + Vite, Tailwind, Dexie (IndexedDB), `vite-plugin-pwa`, and -`@xenova/transformers` for on-device embeddings. See -[`docs/architecture.md`](docs/architecture.md). +React 18 + TypeScript + Vite, Tailwind CSS, Dexie (IndexedDB), Yjs CRDTs, +Lexical (rich segment editor), `vite-plugin-pwa` (Workbox), and +`@xenova/transformers` for on-device embeddings. The optional signed-in mode is +powered by Supabase (Auth + Postgres/RLS + Realtime), loaded lazily and only +when configured. See [`docs/architecture.md`](docs/architecture.md) and +[`docs/cloud.md`](docs/cloud.md). ## Develop ```bash pnpm install pnpm dev # start the dev server -pnpm test # unit tests (vitest) +pnpm test # unit tests (vitest, watch) +pnpm test:unit # unit tests (single run) pnpm test:e2e # end-to-end (playwright) +pnpm typecheck # tsc, no emit pnpm build # production build pnpm generate-icons # regenerate favicon / PWA icons from public/icons/icon.svg ``` +Verbalis runs 100% locally out of the box. To enable the optional signed-in +mode, copy `.env.example` to `.env.local` and set the `VITE_SUPABASE_*` vars — +see [`docs/cloud.md`](docs/cloud.md) for the full setup. + ## License Verbalis is **source-available** (not OSI "open source"), under a two-tier @@ -73,7 +100,7 @@ license — see [`LICENSE.md`](LICENSE.md): **credit the developer** and keep the link back to this project. - **Organizations — get in touch.** Any team or company larger than one person needs a commercial license. Pricing is set individually and fairly — - contact **pedrobritx@gmail.com**. + contact **pedrohbrito@me.com**. --- diff --git a/docs/architecture.md b/docs/architecture.md index eb51a60..d588438 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -39,20 +39,28 @@ src/ └── workers/ — Web Workers via Comlink ``` -## Storage Schema (v3) +## Storage Schema (v7) -| Table | Indexes | -|---|---| -| projects | id, name, updatedAt | -| segments | id, projectId, index, status | -| tm | id, source, sourceLang, targetLang, projectId, corpusId | -| glossary | id, term, projectId | -| settings | &key | -| embeddings | id, tmId, model, [tmId+model] | -| corpusTerms | id, corpusId | -| corpusPacks | id | - -Migrations are handled by Dexie's versioning system (`this.version(N).stores(...)`). Always increment, never modify existing version blocks. v3 adds the bundled-corpora tables and a `corpusId` index on `tm` (so TM entries seeded from a corpus can be removed when the pack is uninstalled). +| Table | Indexes | Since | +|---|---|---| +| projects | id, name, updatedAt | v1 | +| segments | id, projectId, index, status, [projectId+status], [projectId+index] | v1 (compound idx v4) | +| tm | id, source, sourceLang, targetLang, projectId, corpusId, updatedAt | v1 | +| glossary | id, term, projectId, updatedAt | v1 | +| settings | &key | v2 | +| embeddings | id, tmId, model, [tmId+model] | v2 | +| corpusTerms | id, corpusId | v3 | +| corpusPacks | id | v3 | +| projectTemplates | projectId | v4 | +| versions | id, projectId, createdAt, [projectId+createdAt] | v5 | +| documents | id, projectId | v6 | +| blocks | id, documentId, projectId, [documentId+index] | v6 | +| assets | id, documentId, projectId | v6 | +| syncTombstones | [resource+rowId], resource, deletedAt | v7 | + +Migrations are handled by Dexie's versioning system (`this.version(N).stores(...)`). Always increment, never modify existing version blocks. Notable steps: v3 adds the bundled-corpora tables + a `corpusId` index on `tm`; v4 adds compound segment indexes and moves the XLIFF template blob to its own table; v5 adds version snapshots; v6 adds the document/block model (backfilled from `sourceMeta.blockIndex`); v7 adds `updatedAt` indexes on `tm`/`glossary` and the `syncTombstones` table for the personal-resource cloud reconciler. + +> The v2 "Translation IDE" revamp (tracked changes, comments, accounts, real-time collaboration, roles, extensions and connectors) is delivered on top of this foundation and recorded milestone-by-milestone in [`docs/revamp/STATUS.md`](revamp/STATUS.md) and [`docs/revamp/ROADMAP.md`](revamp/ROADMAP.md); the optional cloud layer is documented in [`docs/cloud.md`](cloud.md). ## Deployment diff --git a/docs/refactor-audit.md b/docs/refactor-audit.md new file mode 100644 index 0000000..5ed63dc --- /dev/null +++ b/docs/refactor-audit.md @@ -0,0 +1,200 @@ +# Verbalis — Repository Audit & Refactor Plan + +_Last reviewed: 2026-07-21 · against `main` @ PR #66 (revamp Milestone 6 complete)_ + +A consolidation/polish pass now that the six-milestone "Translation IDE" revamp +has landed. This document is the scan the maintainer asked for: an honest health +snapshot, the safe fixes shipped alongside it, and a prioritized backlog of +everything else — so the rest can be picked up one slice at a time. + +--- + +## 1. Executive summary + +**Verbalis is in excellent health.** ~30,900 lines across 309 TS/TSX files, a +clean feature/core/storage separation, `tsc -b` passes, and **717/717 unit tests ++ ~29 e2e tests are green**. There are **zero** `TODO`/`FIXME`/`HACK` markers, +only 5 `console.*` calls, and disciplined code-splitting keeps the optional +cloud/AI/DOCX code out of the initial bundle. This is not a codebase that needs +rescuing — it needs *organising and finishing touches*. + +The findings below are therefore mostly **polish, tooling, and documentation**, +not structural rework. They are ranked by value ÷ risk so the highest-leverage, +lowest-danger items come first. + +### Health snapshot + +| Signal | Value | Notes | +|---|---|---| +| Source size | ~30,900 LOC / 309 files | Well-factored | +| Unit tests | 717 passing / 118 files | Excellent coverage of `core/*` + `storage/*` | +| E2E tests | ~29 (Playwright) | Cover the real user journeys | +| Typecheck | ✅ clean | Strict mode | +| `TODO`/`FIXME`/`HACK` | 0 | — | +| `console.*` | 5 | Acceptable; a couple could be dropped | +| `any` / `ts-ignore` | 22 | Mostly legit (markdown/docx AST walkers) | +| Dexie schema | v7 | Migrations are additive & tested | +| Linter | ❌ none | See §3.1 | +| Bundler | Vite 6, aggressive lazy chunks | Cloud/AI/DOCX all code-split | + +--- + +## 2. Shipped in this pass + +Small, safe, high-value changes made directly (all green under typecheck + unit +tests): + +- **README** — fixed the "Website" link (pointed at a different project) to the + live app, corrected the stale commercial-contact email to the canonical one + used in-app (`src/features/about/links.ts`), and documented the completed + revamp feature set (tracked changes, collaboration, roles, connectors) that + the README previously never mentioned. +- **`index.html`** — added Open Graph + Twitter Card + canonical + keyword meta + and a light/dark `theme-color`, so shared links and PWA installs render + properly. (An OG **image** is still a follow-up — see §3.3.) +- **Welcome screen** — the first-run screen (what a new visitor to + `verbalis.britx.me` actually lands on) is now a proper hero: brand mark, value + proposition, four benefit cards (privacy / offline / formats / smart assist), + the three-step flow, and clear CTAs — all in the existing design tokens. +- **Theming bug** — the sidebar and status-filter "active" background hardcoded + the **dark-theme** accent (`rgba(0,194,204,0.08)`) in four places, so it did + not adapt in light mode. Replaced with a new `--color-accent-subtle` token + (defined per theme in `tokens.css`). +- **Sidebar dedup** — three copy-pasted `NavLink` blocks collapsed into one + `SidebarLink` component (single source of truth for active styling). +- **Breadcrumb** — `TopBar` `ROUTE_LABELS` was missing `/corpora`, `/addons`, + `/guide`, `/about`, so the top-bar breadcrumb showed the raw path. Completed. +- **`architecture.md`** — the storage-schema table was frozen at v3; refreshed + to the real v7 schema and cross-linked to the revamp record. + +--- + +## 3. Backlog — prioritized + +### P1 — high value, low risk + +**3.1 Add a linter (and wire it into CI).** +There is no ESLint config, no `lint` script, and no eslint dependency. The code +is consistent today (clearly hand-disciplined), but nothing *enforces* it — no +guard against unused vars/imports, `react-hooks/exhaustive-deps` mistakes, +floating promises, or accidental `console.log`s. Add a flat-config ESLint +(`typescript-eslint`, `eslint-plugin-react-hooks`, `eslint-plugin-react-refresh`) +plus a `pnpm lint` step in `ci.yml`. Low risk, compounding value. + +**3.2 Pin the package manager.** +`package.json` has no `packageManager` field, and its `pnpm.onlyBuiltDependencies` +lives in the location **pnpm 11 no longer reads** (it warns and ignores it), while +CI pins `pnpm/action-setup@v3` to v9. So a fresh local checkout (corepack → pnpm +11) and CI (pnpm 9) resolve builds differently. Add `"packageManager": "pnpm@9.x"` +(matching CI) and move `onlyBuiltDependencies` to `pnpm-workspace.yaml` if you +bump to pnpm ≥10. Reconcile the two workflow files at the same time (action-setup +warns if both `version:` and `packageManager` are set). + +**3.3 Ship a real Open Graph image.** +The new meta references `icons/icon-512.png` (square) as the share image. A +purpose-built 1200×630 card (`public/og.png`, referenced absolutely) would make +links look intentional on LinkedIn/Slack/X. Small design task. + +**3.4 Consolidate the docs (the "wiki").** +`docs/` is thorough but now mixes three eras (see §4). Recommendation: keep +`architecture.md` + `cloud.md` as the living reference, fold the revamp +`ROADMAP`/`STATUS` into a short "history" note, and either delete or clearly mark +`docs/revamp/prompts/` (build scaffolding, 30 files) and the pre-revamp +`docs/vision/*` + `roadmap-professional-features.md` as historical. A short +`docs/README.md` index (or a GitHub Wiki mirror) would make the set navigable. + +### P2 — medium value + +**3.5 Decompose the three largest components.** +`EditorPage.tsx` (708), `SegmentRow.tsx` (597) and `TranslateWorkspace.tsx` (497) +are the only files that meaningfully exceed the ~300-line norm. None are broken, +but they carry a lot of state and effects; extracting sub-hooks +(`useEditorKeyboard`, `useSegmentActions`, …) and presentational sub-components +would improve testability and review speed. Do this incrementally, one panel/hook +per PR, behind the existing e2e coverage. + +**3.6 Add dead-code / dependency detection.** +No automated check exists for unused exports, files, or dependencies. Add +[`knip`](https://knip.dev) as a `pnpm knip` step. Expect a small first-run +cleanup (barrel re-exports like `features/translation/index.tsx`, any orphaned +helpers) and ongoing protection. + +**3.7 Quiet the bundle-size warning (cosmetic).** +`vite build` warns about a >500 kB chunk. It is **not** the entry — it is the +opt-in on-device ML stack (`onnxruntime-web` ~1.7 MB + `transformers` ~812 kB), +correctly split into lazy chunks that only load when a user enables semantic TM; +the initial bundle stays ~120 kB gzip. The code-splitting is doing its job. If +the warning is noise, either raise `build.chunkSizeWarningLimit` or add explicit +`manualChunks` for `onnxruntime-web`/`transformers` — a cosmetic tidy, not a real +regression. + +**3.8 Tighten the remaining `any`s.** +The 22 `any`/`ts-ignore` sites are concentrated in `core/documents/toDocx.ts` and +`features/guide/Markdown.tsx` (AST walkers). Most can take a real `mdast`/`docx` +node type. Not urgent, but it removes the last untyped seams. + +**3.9 Accessibility & UX polish.** +- The theme toggle and several icon buttons rely on `aria-label` only — good, but + a visible focus ring audit across the new hero + cards is worth one pass. +- Consider `prefers-reduced-motion` for the sidebar/topbar transitions (the CSS + reset covers animations globally, but the inline `transition-*` styles bypass + it). +- The command palette (`Ctrl/⌘+K`) is the power surface — surface it more visibly + in the welcome hero for discoverability. + +### P3 — larger / strategic (maintainer's call) + +**3.10 A dedicated marketing landing page.** +Today the app *is* the landing page (Excalidraw-style), and the elevated welcome +hero now serves that well for first-run. If you want SEO/marketing reach (feature +tour, screenshots, pricing, testimonials) without loading the app, a separate +static route or a small companion site is the way — but it is a product decision, +not a refactor. + +**3.11 Desktop (Tauri) follow-through.** The `src-tauri/` scaffold + mDNS LAN +transport are documented but outside CI. Finishing the desktop peer story is the +roadmap tail. + +**3.12 MT enhancements.** Streaming responses and "translate all empty segments" +were explicitly deferred (see `architecture.md` Phase 6). Natural next addons. + +--- + +## 4. Documentation inventory + +| Path | Role | Recommendation | +|---|---|---| +| `README.md` | Front door | ✅ refreshed this pass | +| `docs/architecture.md` | Living architecture | ✅ refreshed; keep current | +| `docs/cloud.md` | Cloud/signed-in setup | Living; keep | +| `docs/refactor-audit.md` | This file | Living backlog | +| `docs/revamp/ROADMAP.md` + `STATUS.md` | Revamp record | Keep as history; link from architecture | +| `docs/revamp/prompts/*` (30 files) | Build scaffolding | Archive or delete — served their purpose | +| `docs/vision/*` (6 files) | Pre-build product vision | Mark historical; superseded by shipped app | +| `docs/roadmap-professional-features.md` | Pre-revamp plan | Mark historical; largely delivered | + +The revamp is done, so several planning docs are now historical rather than +directive. Nothing here is *wrong* — it just needs a clear "this was the plan / +this is the current state" boundary so a newcomer isn't misled. + +--- + +## 5. What is deliberately good (don't "fix" it) + +- **Inline `style={{ ... var(--color-*) }}` + Tailwind for layout.** 650+ sites, + but it's a consistent, intentional theming system (CSS custom properties drive + light/dark). Not tech debt. +- **Additive, env-gated cloud.** The signed-in code genuinely tree-shakes out + when unconfigured (verified repeatedly in `STATUS.md`). Don't collapse the + seams that make this possible. +- **The per-segment Lexical contract** ("Lexical state is truth, `richStateToPlain` + derives plain `target`"). Load-bearing; every tracked-change/comment/CRDT + feature depends on it. Refactors near `core/editor/richText.ts` need care. +- **Pure `core/*` with injected `fetchImpl`/clients.** Why the test suite is so + strong. Keep new logic pure and push I/O to the edges. + +--- + +_This audit is intentionally conservative: it ships only what is safe to ship +unattended and leaves judgement calls (marketing page, component splits, tooling +choices) as clearly-scoped tickets for the maintainer to sequence._ diff --git a/index.html b/index.html index 74dbae9..06ba739 100644 --- a/index.html +++ b/index.html @@ -9,12 +9,47 @@ - + + + + + + Verbalis — local-first CAT tool - Verbalis — local-first CAT tool + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/components/layout/Sidebar.tsx b/src/components/layout/Sidebar.tsx index da12b18..75c5317 100644 --- a/src/components/layout/Sidebar.tsx +++ b/src/components/layout/Sidebar.tsx @@ -1,9 +1,45 @@ import { useEffect, useState } from 'react' import { NavLink, useLocation } from 'react-router-dom' import { PanelLeftClose, PanelLeft, Info, BookOpen } from 'lucide-react' +import type { LucideIcon } from 'lucide-react' import { cn } from '@/lib/utils' import { NAV_ITEMS } from './navItems' +interface SidebarLinkProps { + to: string + icon: LucideIcon + label: string + end?: boolean + collapsed: boolean +} + +/** A single sidebar entry — one source of truth for the active-state styling + * shared by the primary nav and the pinned Guide / About links. The active + * background uses `--color-accent-subtle` so it adapts to the light theme + * instead of hardcoding the dark-theme accent. */ +function SidebarLink({ to, icon: Icon, label, end, collapsed }: SidebarLinkProps) { + return ( + + cn( + 'flex items-center gap-3 px-2 py-2 rounded text-sm transition-colors', + isActive ? 'font-medium' : 'hover:opacity-80', + ) + } + style={({ isActive }) => ({ + color: isActive ? 'var(--color-accent)' : 'var(--color-muted)', + background: isActive ? 'var(--color-accent-subtle)' : 'transparent', + })} + > + + {!collapsed && {label}} + + ) +} + export function Sidebar() { const { pathname } = useLocation() // Collapse automatically while inside a project editor so the translation @@ -35,53 +71,15 @@ export function Sidebar() { }} > - ({ - color: isActive ? 'var(--color-accent)' : 'var(--color-muted)', - background: isActive ? 'rgba(0,194,204,0.08)' : 'transparent', - })} - > - - {!collapsed && Translation guide} - - - ({ - color: isActive ? 'var(--color-accent)' : 'var(--color-muted)', - background: isActive ? 'rgba(0,194,204,0.08)' : 'transparent', - })} - > - - {!collapsed && About & License} - +
+ + +
+ + + +

+ No sign-up required. Works fully offline.

-
    - } - number={1} - title="Import" - body="TXT, MD, DOCX or XLIFF (memoQ / OmegaT). Pick a source and target language (including regional variants like pt-BR or en-GB)." - /> - } - number={2} - title="Translate" - body="Confirm segments with Ctrl + Enter. TM, glossary and MT suggestions sit in the right-hand panel." - /> - } - number={3} - title="Re-use" - body="Translation memory and glossary build up as you work and can be exported as TMX, CSV or TBX." - /> -
+ {/* Value props */} +
+ {VALUE_PROPS.map(({ icon: Icon, title, body }) => ( +
+
+ +
+
+

+ {title} +

+

+ {body} +

+
+
+ ))} +
-
- - + {/* How it works */} +
+

+ How it works +

+
    + {STEPS.map(({ icon, title, body }, i) => ( + + ))} +
) } function Step({ - icon, + icon: Icon, number, title, body, }: { - icon: React.ReactNode + icon: typeof Upload number: number title: string body: string @@ -200,7 +280,7 @@ function Step({ {number} - {icon} +