Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ VITE_SUPABASE_ANON_KEY=sb_publishable_c8YdrT2-abKdW1Kl7FDKyA_v5OwqLdY
# google, azure (Microsoft), apple. Defaults to `google` when unset. Only list
# providers you have configured in the Supabase dashboard, or the button 400s.
VITE_AUTH_PROVIDERS=google

# Google OAuth client id for the Drive storage connector (Phase 6.3). Pure
# client OAuth via Google Identity Services (independent of Supabase — the
# connector works in 100%-local mode too). When unset, the Drive "From cloud" /
# "Save to Drive" buttons stay hidden. Uses the drive.file scope only. See
# docs/cloud.md §13 for the Google Cloud console setup.
# VITE_GOOGLE_CLIENT_ID=xxxxxxxx.apps.googleusercontent.com
5 changes: 5 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ jobs:
VITE_SUPABASE_URL: ${{ vars.VITE_SUPABASE_URL || secrets.VITE_SUPABASE_URL || secrets.SUPABASE_URL }}
VITE_SUPABASE_ANON_KEY: ${{ vars.VITE_SUPABASE_ANON_KEY || secrets.VITE_SUPABASE_ANON_KEY }}
VITE_AUTH_PROVIDERS: ${{ vars.VITE_AUTH_PROVIDERS || secrets.VITE_AUTH_PROVIDERS }}
# Google Drive connector (Phase 6.3) — pure client OAuth, independent of
# Supabase. Public by design (a Web OAuth client id is not a secret; it is
# gated by the console's authorised-origins allow-list). Unset -> the
# Drive buttons stay hidden.
VITE_GOOGLE_CLIENT_ID: ${{ vars.VITE_GOOGLE_CLIENT_ID || secrets.VITE_GOOGLE_CLIENT_ID }}
- uses: actions/upload-pages-artifact@v3
with:
path: dist
Expand Down
44 changes: 44 additions & 0 deletions docs/cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,47 @@ first. With a project_manager, a translator, and a revisor on one cloud project:
- [ ] **Local-only unchanged**: a project with no cloud link behaves as
"PM-of-self" — direct editing, suggesting, and accept/reject all available,
exactly as before roles existed.

## 13. Google Drive connector (Phase 6.3)

The Drive connector is **pure client OAuth** via Google Identity Services (GIS)
— it does **not** use Supabase, so it works for 100%-local users too. It uses
the narrow `drive.file` scope (only files the app creates or the user explicitly
opens through the Google picker/consent), which avoids Google's restricted-scope
verification burden. The access token lives in memory only (gone on reload).

### One-time setup (Google Cloud console)

1. Create (or reuse) a project at <https://console.cloud.google.com/>.
2. **APIs & Services → Library** → enable the **Google Drive API**.
3. **APIs & Services → OAuth consent screen** → configure (External is fine for
testing; add yourself as a test user). Add the scope
`https://www.googleapis.com/auth/drive.file`.
4. **APIs & Services → Credentials → Create credentials → OAuth client ID →
Web application**. Under *Authorised JavaScript origins* add the exact
origins the app runs on, e.g. `http://localhost:5173` and
`https://verbalis.britx.me`. (No redirect URI is needed — GIS uses the token
flow, not a redirect.)
5. Copy the client id into `VITE_GOOGLE_CLIENT_ID` (build-time env; see §1). In
`deploy.yml` add it as a repo **Variable** the same way as the Supabase vars.

Leaving `VITE_GOOGLE_CLIENT_ID` unset keeps the Drive buttons hidden — no GIS
script is loaded and the connector code stays out of the initial bundle.

### Manual verification

With `VITE_GOOGLE_CLIENT_ID` set:

- [ ] **Addon listed**: the Add-ons page shows **Google Drive** under *Storage
connectors* with Network / API key / Files permission chips and a working
on/off toggle.
- [ ] **Import from Drive**: in the Import dialog, **From Google Drive** opens the
Google consent popup, then a file list; picking a `.docx`/`.txt`/`.md`/XLIFF
imports it as a new project exactly as a local file would.
- [ ] **Save to Drive**: on a monolingual project, **Save to Drive** uploads the
exported `.docx` to your Drive (visible in <https://drive.google.com/>) and
shows a "Saved to Drive" confirmation.
- [ ] **Disable hides it**: turning the addon off on the Add-ons page hides both
the "From Google Drive" and "Save to Drive" buttons.
- [ ] **Unset ⇒ absent**: with `VITE_GOOGLE_CLIENT_ID` unset the buttons never
appear and `dist` contains no `gsi/client` reference in the entry chunk.
5 changes: 3 additions & 2 deletions docs/revamp/STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Rules for autonomous sessions:
| 5.2 | Role-gated editing workflow | M | 5.1, 1.6 | done (PR #61) |
| 5.3 | Approval workflow + attribution in versioning | S | 5.2 | done (PR #62) |
| 6.1 | Extension registry + MT providers as built-in addons | M | 0.1 | done (PR #63) |
| 6.2 | QA rules + formats as addons + Add-ons page | M | 6.1 | in-review (PR #64) |
| 6.3 | Google Drive connector | M | 6.1, 2.4 | pending |
| 6.2 | QA rules + formats as addons + Add-ons page | M | 6.1 | done (PR #64) |
| 6.3 | Google Drive connector | M | 6.1, 2.4 | in-review (PR #65) |
| 6.4 | OneDrive connector | S | 6.3 | pending |

## Log
Expand Down Expand Up @@ -80,3 +80,4 @@ Rules for autonomous sessions:
- 2026-07-21 — Phase 5.2 merged in PR #61. Phase 5.3 built: approval workflow + unified attribution in versioning (**Milestone 5 complete → web v2 launch candidate**). `ProjectVersion` gains `authorId?` (the stable `profile.identity` author id — the *same* identity tracked-change marks, comments, and presence use, so attribution is unified across the app, D8) and `approval?: { authorId, authorName, at }`. `versionRepo.capture` now stamps `authorId` on **every** version (via `ensureLocalAuthor()`), and a new `versionRepo.signOff(projectId, liveDoc?)` records a `named` version labeled `Approved by {name}` with the `approval` metadata set (its presence marks an approval milestone). Wiring: `useWorkflowStore` gains a `useCanReview()` selector (revisor/PM; local-only → PM-of-self → true); `VersionHistoryPanel` shows a **Sign off** button beside Save version only when `canReview`, and renders approval versions with an accent `BadgeCheck` + their `Approved by …` label. No migration + no schema bump (versions are local Dexie; `authorId`/`approval` are additive unindexed fields; pre-5.3 rows simply lack them). Deviations (noted): built on the designated session branch, not `claude/revamp-phase-5-3`; sign-off gating is client-enforced via the workflow rules at the call site (D8) — the append-only authored update log remains the tamper-evident audit trail. Tests: `versionRepo` extended (every capture stamps a stable authorId consistent across captures; `signOff` records a labeled approval version whose `approval.authorId`/`at` match the version's `authorId`/`createdAt`, while a plain `saveNamed` has no `approval`). Verified: flag-OFF `dist` has **zero** `GoTrueClient`; the version-history e2e still green. Green: 673 unit (+2) / 1 version e2e / build. No new e2e (ROADMAP §5.3 asks none). **Milestone 5 (roles & workflow) complete — the web v2 launch candidate.**
- 2026-07-21 — Phase 5.3 merged in PR #62. Phase 6.1 built: the typed extension registry + the four MT providers re-registered as built-in addons (start of **Milestone 6**, extensions & connectors; D9 — in-process registry now, sandboxed hosting later, but the manifest contract is **final**). `src/core/extensions/types.ts` — `ExtensionManifest {id, name, version, kinds, permissions, builtIn, description?}`; `ExtensionKind = mt-provider|qa-rule|panel|import-format|export-format|storage-connector`; `ExtensionPermission = network|credentials|storage|clipboard|filesystem`. `src/core/extensions/registry.ts` — a dependency-free (no storage/React imports) singleton `extensionRegistry`: `register`/`unregister`/`get`/`has`/`list(kind?)` (id-sorted), enablement as a **disabled set** so a registered extension is enabled by default and an unknown id is treated as enabled (behaviour unchanged until something is explicitly turned off), `isEnabled`/`setEnabled`/`getDisabledIds`/`setDisabledIds`, and `subscribe`. `src/core/extensions/builtins.ts` — the four MT manifests (`mt.mymemory`/`mt.libretranslate`/`mt.ollama`/`mt.claude`; permissions `network` + `credentials` for the keyed ones) + idempotent `registerBuiltinExtensions()`. `src/extensions/mt/index.ts` — thin **wrappers** pairing each manifest to its existing `core/mt` provider (**no provider logic moved** — the existing MT unit tests are untouched and keep proving behaviour) + `registryEnabledMtProviderIds()`. `core/mt/index.ts` gains `MT_EXTENSION_ID` + `isProviderExtensionEnabled(id)` (defaults enabled when the manifest isn't registered), and `enabledProviders` now ANDs the user setting with the registry — so **disabling the addon removes the provider**; `useMTSettings.enabledIds` does the same and re-derives via `useSyncExternalStore(extensionRegistry.subscribe)` so the MT panel updates live. Wiring: `features/addons/registryPersistence.ts` (`registerExtensions()` sync + `startExtensionRegistry()` hydrating the disabled set from the new device-local `extensions.disabled` settings key and persisting subsequent changes), started from `main.tsx` before render. Deviations (noted): built on the designated session branch, not `claude/revamp-phase-6-1`; no Add-ons **page** yet (that's 6.2) — 6.1 ships the registry + reactive resolution and proves the disable→panel path via unit tests. `docs/cloud.md` unchanged (no migration). Tests: `extensions.registry` (register/list-by-kind/default-enabled/toggle/unknown-id/hydrate+notify/unregister), `extensions.mt` (the four register as `mt-provider`; wrappers point at the real `MT_PROVIDERS`; **disabling `mt.claude` removes it from `enabledProviders` even with the user setting on** — the DoD — and re-enabling restores it). Verified: flag-OFF `dist` Supabase-free; the untouched MT unit tests + `mt-flow` e2e stay green. Green: 682 unit (+9) / 3 mt-flow e2e / build. No new e2e (ROADMAP §6.1 asks none).
- 2026-07-21 — Phase 6.1 merged in PR #63. Phase 6.2 built: QA rules + formats as addons + the Add-ons page. `core/extensions/builtins.ts` now also registers `QA_EXTENSION_MANIFESTS` (one `qa.<code>` per QA rule, kind `qa-rule`, no permissions — labels/descriptions from `QA_RULE_LABELS`) and `FORMAT_EXTENSION_MANIFESTS` (`format.xliff`/`format.docx`/`format.tmx`/`format.tbx`/`format.csv`, kinds `import-format`/`export-format`, `filesystem` permission); `BUILTIN_MANIFESTS` = MT + QA + formats, all registered by `registerBuiltinExtensions()`. `core/qa/registryRules.ts` — `isQaRuleEnabled(code)` (registry, **defaults on when the manifest isn't registered** so `runQA` stays pure and its tests are untouched) + `effectiveQaRules(toggles)` which ANDs the per-project rule toggles with the registry; `QAPanel` runs `runQA` with `effectiveQaRules(settings.qaRules)` and re-derives via `useSyncExternalStore(extensionRegistry.subscribe)` so toggling a QA addon changes QA output live. `features/addons/AddonsPage.tsx` — the `/addons` catalogue: sections per kind (Machine translation, Quality assurance, Import & export formats), each row showing the name, description, **permission chips**, and a Built-in badge; MT + QA rows get a working enable/disable toggle (enforced — MT panel + QA output react), formats are shown **Always on** (their round-trip logic stays in `core/*`; format-level gating is a follow-up, kept out to avoid touching every import/export path). New `/addons` route (lazy `AddonsPage`) + a Puzzle nav item. Deviations (noted): built on the designated session branch, not `claude/revamp-phase-6-2`; format addons are catalogue/display-only in v1 (no toggle) — only the DoD's QA + the 6.1 MT toggles are enforced. No migration. Tests: `qa.registryRules` (falls back all-on when unregistered; disabling `qa.double_space` forces it off + **removes the finding from `runQA` output** — the DoD; others unaffected), `AddonsPage` (lists MT + QA + format sections/rows; toggling a QA addon flips registry enablement; formats have no toggle). Verified: flag-OFF `dist` Supabase-free (AddonsPage its own lazy chunk); full e2e green after the nav/route addition. Green: 688 unit (+6) / 29 e2e / build. No new e2e (ROADMAP §6.2 asks none).
- 2026-07-21 — Phase 6.2 merged in PR #64. Phase 6.3 built: the Google Drive storage-connector addon (start of the connector half of **Milestone 6**). **Pure client OAuth** via Google Identity Services (GIS) — **independent of Supabase**, so the connector works for 100%-local users too (ROADMAP §6.3). New generic `src/extensions/connectors/types.ts` — a provider-agnostic `StorageConnector` (`isConfigured`/`listFiles`/`downloadFile`/`uploadFile`) + `ConnectorFile`/`ConnectorUpload` + a coarse `ConnectorError` (mirrors `MTError`), written once so 6.4's OneDrive reuses it. `src/extensions/connectors/gdrive/`: `config.ts` (lightweight gate — `googleClientId()` from `VITE_GOOGLE_CLIENT_ID`, `isGdriveConfigured()`, `isGdriveAvailable()` = configured AND registry-enabled; no GIS/REST imports so UI can decide whether to *offer* Drive without pulling the heavy code); `driveApi.ts` (the pure, unit-testable REST layer — `listDriveFiles`/`downloadDriveFile`/`uploadDriveFile`, each taking an OAuth token + an injectable `fetchImpl` like `core/mt/*`, using the narrow **`drive.file` scope** to dodge Google's restricted-scope verification, multipart upload, status→code error mapping); `gis.ts` (thin DOM boundary — injects the GSI script on first use, requests a `drive.file` token via popup, token held **in memory only**, never Dexie/localStorage); `index.ts` (`createGdriveConnector({getToken, fetchImpl})` factory pairing GIS+REST, tested with a fake token getter + fetch, plus the real `gdriveConnector` singleton). Generic `ConnectorFilePicker.tsx` lists a connector's files, filters by an `accept` predicate, and returns the downloaded `File`. `core/extensions/builtins.ts` registers `CONNECTOR_EXTENSION_MANIFESTS` (`connector.gdrive`, kind `storage-connector`, permissions `network`/`credentials`/`filesystem`); `BUILTIN_MANIFESTS` = MT + QA + formats + connectors. Wiring: `ImportDialog` gains a **From Google Drive** button (gated on `isGdriveAvailable()`; dynamically imports the connector on click → picker → sets the import file, then the existing import flow runs unchanged); `ExportDocxButton` gains **Save to Drive** (builds the same clean `.docx`, uploads via the connector); `AddonsPage` gains a **Storage connectors** section with a working enable/disable toggle (disabling hides both affordances). `deploy.yml` + `.env.example` carry `VITE_GOOGLE_CLIENT_ID` (public by design — a Web OAuth client id gated by the console's authorised-origins allow-list). Deviations (noted): built on the designated session branch, not `claude/revamp-phase-6-3`; the connector is intentionally **not** hidden behind the Supabase flag (it is pure client OAuth, so it ships in the entry like the collab leases — the heavy Drive REST is still code-split into a lazy chunk, and no connector code executes until the user clicks, via the dynamic `import()` + the `isGdriveAvailable()` gate). `docs/cloud.md` §13 (Google Cloud console setup + manual verification). Tests: `connectors.driveApi` (list builds the right query/Bearer + maps files; download `alt=media`; multipart upload asserts metadata+media in the body; 401→auth / 429→rate_limit / network-throw mapping), `connectors.gdrive` (config gating on the env var; manifest registration; `isGdriveAvailable` ANDs config with registry enablement; the factory lists/downloads-into-a-named-`File`/uploads through injected token+fetch), `ConnectorFilePicker` (lists accepted files, hides rejected, pick→download→onPick+close, error surfaced), `AddonsPage` extended (storage-connector section + `connector.gdrive` row + toggle). Verified: flag-OFF `dist` still **zero** `GoTrueClient`; the Drive REST is a separate lazy chunk. Green: 705 unit (+17) / build. No new e2e (ROADMAP §6.3 asks none; the real Drive round-trip is the `docs/cloud.md` §13 manual matrix — vitest never hits GIS or the network).
18 changes: 17 additions & 1 deletion src/core/extensions/builtins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,27 @@ export const FORMAT_EXTENSION_MANIFESTS: ExtensionManifest[] = [
},
]

/** Every built-in manifest, in catalogue order (MT, then QA, then formats). */
/** Storage connectors as addons (ROADMAP §6.3/§6.4). Pure client OAuth, so they
* work for local-only users too; disabling one hides its import/export
* affordances. `credentials` = it holds an OAuth token in memory. */
export const CONNECTOR_EXTENSION_MANIFESTS: ExtensionManifest[] = [
{
id: 'connector.gdrive',
name: 'Google Drive',
version: '1.0.0',
kinds: ['storage-connector'],
permissions: ['network', 'credentials', 'filesystem'],
builtIn: true,
description: 'Import files from and save exports to Google Drive.',
},
]

/** Every built-in manifest, in catalogue order (MT, QA, formats, connectors). */
export const BUILTIN_MANIFESTS: ExtensionManifest[] = [
...MT_EXTENSION_MANIFESTS,
...QA_EXTENSION_MANIFESTS,
...FORMAT_EXTENSION_MANIFESTS,
...CONNECTOR_EXTENSION_MANIFESTS,
]

let registered = false
Expand Down
Loading
Loading