diff --git a/CHANGELOG.md b/CHANGELOG.md index b06ca726..e5e0bfbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,9 @@ notes. Entries describe what users experience, not internal refactors. so language, GitHub and brand links remain reachable past the first screen. - Nightly CI now runs the API surface, keyboard shortcut, and seeded monkey sweeps (previously documented as nightly but never scheduled). +- Canvas PDF exports skip unnecessary PDF/A conversion for ordinary `.pdf` + downloads, reuse warm x2t worker fonts, and scale export timeouts by file size + ([#317](https://github.com/ranuts/document/pull/317)). ### Removed @@ -43,6 +46,17 @@ notes. Entries describe what users experience, not internal refactors. - Read-only documents now look read-only: the toolbar keeps only the File and View tabs, editing buttons such as paste and macros are hidden, and the side panels are locked, while search, zoom and navigation stay available. Switching read-only off restores the full toolbar. - Exporting a PDF or another format keeps unsaved changes in the editable original visible until the original is saved. - Failed file opens restore usable file controls, including keyboard access. +- Legacy Office files with non-canonical OLE stream casing, East-Asian Word 95 + FIB headers, malformed PPT slide persist IDs, broken embedded PNG color chunks, + or deeply nested DOCX tables now open instead of failing with `-82` or crashing + the renderer ([#313](https://github.com/ranuts/document/pull/313)). +- Window-level editor iframe guards now install synchronously before OnlyOffice + scripts execute, preventing spurious `-82` errors during recoverable open + retries ([#322](https://github.com/ranuts/document/pull/322), + [#323](https://github.com/ranuts/document/pull/323)). +- Landing-page idle prefetch preserves the `window` receiver when calling + `requestIdleCallback`, avoiding strict-mode `Illegal invocation` errors + ([#321](https://github.com/ranuts/document/pull/321)). - Document history search keeps focus and ignores outdated results while typing. - Chat history conflicts offer an explicit way to keep local copies and restore saved conversations. - Dictation reaching its time limit finishes normally and preserves the final recognized words. diff --git a/docs/changelogs/2026-12-04-ci-analytics-and-smoke-hardening.md b/docs/changelogs/2026-12-04-ci-analytics-and-smoke-hardening.md index b6b59f8d..bad511be 100644 --- a/docs/changelogs/2026-12-04-ci-analytics-and-smoke-hardening.md +++ b/docs/changelogs/2026-12-04-ci-analytics-and-smoke-hardening.md @@ -2,40 +2,58 @@ Date: 2026-12-04 · PRs: [#316](https://github.com/ranuts/document/pull/316), [#319](https://github.com/ranuts/document/pull/319) · Upstream: [chaxus/ran#567](https://github.com/chaxus/ran/pull/567) -## Background - -1. **Analytics spike**: Cloudflare analytics showed a recurring ~2.51k request spike at - 04:00 CST caused by `Production smoke` running daily on a cron schedule against the live - site while executing real browser loads that fired GA4 and Cloudflare Web Analytics. -2. **Beacon SRI failure**: Fulfilling `cloudflareinsights.com` with an empty HTTP `204` - inside Playwright caused Chromium's Subresource Integrity check on `beacon.min.js` to - log `Failed to find a valid digest in the 'integrity' attribute`, turning - `Production smoke` red under L0 console checks. -3. **Semantic Pull Request `startup_failure`**: `.github/workflows/semantic-pull-request.yml` - triggered on `pull_request_target`, which failed before job startup on PRs in both - `ranuts/document` and `chaxus/ran`. - -## Commits - -| SHA | PR | Summary | -| ---------- | ---- | --------------------------------------------------------------------------------- | -| `3966698c` | #316 | Remove daily `prod-smoke` schedule and exclude E2E traffic from analytics | -| `af1d815b` | #319 | Abort Cloudflare beacon before SRI check and switch Semantic PR to `pull_request` | - -## Key Changes - -- **`.github/workflows/prod-smoke.yml`**: removed the daily `schedule` trigger (smoke now - runs on push to `main` and manual dispatch only). -- **`test/e2e/lib/l0.ts`**: +## 1. Context + +1. Cloudflare Web Analytics showed a recurring ~2.51k request spike at 04:00 CST with no + corresponding organic user surge. Investigation traced it to + `.github/workflows/prod-smoke.yml`, which ran on a daily cron schedule against live + production while firing GA4 and Cloudflare analytics requests. +2. After `#316` intercepted analytics requests with HTTP `204`, `Production smoke` turned + red on `main` (run `#47254625679`) due to Chromium SRI verification failing on the + empty Cloudflare beacon script. +3. `.github/workflows/semantic-pull-request.yml` in both `ranuts/document` and + `chaxus/ran` was failing with `startup_failure` on every PR. + +## 2. Thinking and evaluation + +| Option | Decision | Reason | +| ------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------- | +| Keep daily `prod-smoke.yml` cron and filter analytics only in Cloudflare dashboard | **Rejected** | Still wastes CI minutes and pollutes edge request counts every morning | +| Remove daily `schedule` from `prod-smoke.yml` (keep push-to-main + `workflow_dispatch`) and block analytics in Playwright | **Chosen** | Eliminates recurring fake traffic while preserving post-deploy verification | +| Fulfill `cloudflareinsights.com` with HTTP `204` | **Rejected** | Cloudflare injects `` immediately after + `` (strictly before all vendor `<script>` tags) in: + - `public/web-apps/apps/documenteditor/main/index.html` + - `public/web-apps/apps/spreadsheeteditor/main/index.html` + - `public/web-apps/apps/presentationeditor/main/index.html` + - `public/web-apps/apps/pdfeditor/main/index.html` +- `lib/onlyoffice/iframe-guards.ts`: exported `bootstrapEditorFrame(win)` (runs + `installOpenFailureGuard`, `shadowSharedWorker`, `installUnloadPagehide`, + `injectLocalChromeCss` synchronously) and `registerEditorFrameBootstrapHost()`. +- `lib/onlyoffice-editor.ts`: calls `registerEditorFrameBootstrapHost()` immediately + before constructing `DocsAPI.DocEditor`. +- `test/unit/vendor-contract.test.ts`: pinned that `editor-frame-bootstrap.js` exists and + is the first `<script` tag in all 4 editor entry HTML files. +- `test/unit/editor-frame-bootstrap.test.ts`: executes the real bootstrap script against a + standard WHATWG `EventTarget` frame to verify pre-vendor guard installation and + `AT_TARGET` precedence even over `addEventListener('unhandledrejection')`. + +## 4. Problems and fixes + +1. **Multi-app coverage**: initially considered only Word/Cell/Slide (`documenteditor`, + `spreadsheeteditor`, `presentationeditor`); checking `vendor-contract.test.ts` revealed + `pdfeditor/main/index.html` uses the same layout. **Fix**: wired all 4 apps and pinned + all 4 in `vendor-contract.test.ts`. +2. **Base-path portability**: hardcoded `/editor-frame-bootstrap.js` would 404 on GitHub + Pages `/document/`. **Fix**: placed under `public/web-apps/apps/common/` and referenced + via relative `../../common/editor-frame-bootstrap.js`. + +## 5. Verification + +- Local: `vitest run test/unit/editor-frame-bootstrap.test.ts test/unit/vendor-contract.test.ts test/unit/onlyoffice-editor.test.ts test/unit/onlyoffice-open-failure.test.ts` + — 4/4 files, 127/127 passed; `oxlint --deny-warnings` 0 warnings/errors; `prettier --check` + passed. +- Remote CI: all checks passed and auto-rebased onto `main`. + +## 6. Leftovers + +- SDK-dependent guards (`AscCommon.x2t`, `DrawingDocument`, `fetchFonts`, save semantics) + intentionally remain on `prepareEditorIframe()` because those vendor globals do not + exist at `<head>` parse time. diff --git a/docs/changelogs/2026-12-04-ranuts-0.5.7-dedup-and-hardening.md b/docs/changelogs/2026-12-04-ranuts-0.5.7-dedup-and-hardening.md index cde7f406..528a81ab 100644 --- a/docs/changelogs/2026-12-04-ranuts-0.5.7-dedup-and-hardening.md +++ b/docs/changelogs/2026-12-04-ranuts-0.5.7-dedup-and-hardening.md @@ -2,82 +2,100 @@ Date: 2026-12-04 · PRs: [#318](https://github.com/ranuts/document/pull/318), [#320](https://github.com/ranuts/document/pull/320), [#321](https://github.com/ranuts/document/pull/321), [#322](https://github.com/ranuts/document/pull/322) · Companion: [2026-12-04-editor-frame-pre-vendor-bootstrap.md](./2026-12-04-editor-frame-pre-vendor-bootstrap.md) ([#323](https://github.com/ranuts/document/pull/323)) · Upstream: [chaxus/ran#561](https://github.com/chaxus/ran/pull/561), [#562](https://github.com/chaxus/ran/pull/562), [#565](https://github.com/chaxus/ran/pull/565), [#568](https://github.com/chaxus/ran/pull/568) -## Summary - -Following a repository-wide audit of reusable zero-dependency primitives and runtime -bottlenecks, five binary/network/stream utilities were upstreamed to `chaxus/ran` and -published as `ranuts@0.5.7`. `ranuts/document` then upgraded to `0.5.7` (removing ~605 net -lines of duplicated code), hardened `<think>` stripping, save-lock errors, IndexedDB and -markdown rendering paths, `requestIdleCallback` receiver safety, and OnlyOffice -open-recovery `unhandledrejection` ordering. - -## Commits & PRs - -| SHA | PR | Summary | -| ---------- | ---- | ---------------------------------------------------------------------------------------- | -| `3498d3ff` | #318 | Unify regex-free `<think>` stripping, typed `SaveInProgressError`, IDB/markdown perf, CI | -| `46ac5e4a` | #318 | Preserve empty-only `<think>` stripping in action-plan and detached session exports | -| `4ebf0a41` | #320 | Upgrade `ranuts` to `0.5.7` and deduplicate CFB, PNG, XML, fetch, and utility helpers | -| `7c642b24` | #321 | Preserve `window` receiver when calling `window.requestIdleCallback` in landing prefetch | -| `87c67658` | #322 | Re-seat pre-existing vendor `onunhandledrejection` behind `installOpenFailureGuard` | - -## Detailed Changes - -### 1. Upstream to `ranuts@0.5.7` (`chaxus/ran#561`, `#562`, `#565`, `#568`) - -- Added `cfb` (`openCfb`, `listCfbEntries`, `readCfbStream`, `writeCfbEntryName`, - `isOleCompound`), `png` (`isBrokenChrmChunk`, `isBrokenIccpChunk`, `sanitizePngChunks`, - `sanitizeEmbeddedPngs`), `xml` (`nextXmlTag`), `fetchWithRetry` / `fetchBounded`, and - `ranuts/stream` `parseNdjsonStream`. -- Published `ranuts@0.5.7` to npm. -- Fixed `ranui` button SSR double icon paint (`chaxus/ran#565`). -- Hardened `ranuts/utils` `whenIdle` to preserve `window` receiver and add a concurrent - `setTimeout` guard (`chaxus/ran#568`). - -### 2. Wave 4 Runtime & CI Hardening (`#318`) - -- **Regex-free `<think>` stripping**: introduced `stripThinkingPrefix` and - `stripEmptyThinkingPrefix` in `packages/agent-core/src/llm/thinking.ts` to replace - duplicated regex stripping while preserving empty-only behavior for action plans and - session exports. -- **Typed save-in-progress error**: replaced error-message string matching between - `lib/onlyoffice/save-stream.ts` and `lib/history/autosave.ts` with typed - `SaveInProgressError`. -- **Rendering & storage perf**: added fast paths in `StreamingMarkdown` and IndexedDB - connection caching in `conversation-db.ts`. -- **CI hygiene**: unblocked `browsers-serial` in `nightly-corpus.yml` (`needs: [gate]`) - and added `concurrency` cancellation to `docker.yml`. - -### 3. Wave 3 `ranuts@0.5.7` Deduplication (`#320`) - -- Upgraded `ranuts` from `0.5.2` to `0.5.7` in `package.json`, - `packages/{converter,chat-ui,shared}/package.json`, and `pnpm-lock.yaml`. -- Deleted `packages/converter/src/ole-cfb.ts` (-318 lines) and - `packages/converter/src/png-sanitize.ts` (-171 lines), delegating all callers and - `@ranuts/converter` re-exports to `ranuts/utils`. -- Replaced local `nextXmlTag` (`packages/converter/src/docx-zip.ts`) and retry loop - (`packages/converter/src/x2t-loading.ts`) with `nextXmlTag` and `fetchWithRetry` from - `ranuts/utils` (preserving exact x2t error text and 1-argument `fetch(url)` contract). -- Replaced duplicate helpers in `lib/history-page.ts`, `lib/history/relative-time.ts`, - `lib/embed-api.ts`, and `lib/prefetch.ts` with `formatBytes`, `formatRelative`, - `base64ToBytes`, `isInIframe`, `queryFlag`, and `networkAllowsDownload`. - -### 4. Browser Compatibility & Open-Retry Ordering (`#321`, `#322`) - -- **`public/landing-prefetch.js` (`#321`)**: replaced detached - `var idle = window.requestIdleCallback || ...` with a wrapper calling - `window.requestIdleCallback(fn)` directly to prevent `TypeError: Illegal invocation` in - strict-mode / Safari WebKit engines, locked by a regression test in - `test/unit/landing-prefetch.test.ts`. -- **`lib/onlyoffice/open-failure.ts` (`#322`)**: per WHATWG DOM, `unhandledrejection` - dispatches at `AT_TARGET` on `window` strictly in registration order regardless of - `capture`. Re-seating any pre-existing `win.onunhandledrejection` (`null` then original) - after registering our listener prevents the vendor SDK from emitting a spurious `-82` - before retry when `sdk-all-min.js` wins the iframe poll race. Paired with the permanent - pre-vendor `<head>` bootstrap in [#323](https://github.com/ranuts/document/pull/323). - -## Verification - -- Full unit test suite on `#320`: 264/264 files, 7,268 passed, 0 failed. -- Scoped unit tests, `oxlint --deny-warnings`, and `prettier --check` passed on every PR. -- `#318`, `#320`, and `#321` passed all 19/19 CI checks and rebased onto `main`. +## 1. Context + +A repository-wide audit of `ranuts/document` found: + +1. Five zero-dependency primitives built for corpus open-path fixes (`#313`) and streaming + belonged in `ranuts` rather than staying duplicated locally (OLE CFB reader, broken PNG + chunk sanitizer, quoted-attribute-aware XML tag scanner, retry/bounded fetch, NDJSON + stream parser), alongside several `lib/` helpers already shipped by `ranuts/utils`. +2. Wave 4 code-quality gaps: duplicated regex `<think>` stripping across agent modules, + string-matched save-lock errors between `save-stream.ts` and `autosave.ts`, uncached + IndexedDB connections in `conversation-db.ts`, missing `StreamingMarkdown` fast paths, + blocked `browsers-serial` in `nightly-corpus.yml`, and missing `concurrency` in + `docker.yml`. +3. Two subtle browser-compat/DOM-spec bugs surfaced during review and CI: + - Detached `window.requestIdleCallback` in `public/landing-prefetch.js` and + `ranuts/utils` `whenIdle` risking `TypeError: Illegal invocation` under strict mode / + Safari WebKit. + - Intermittent `open-retry.spec.ts:186` `-82` failure caused by `installOpenFailureGuard` + relying on `{ capture: true }` at `AT_TARGET`. + +## 2. Thinking and evaluation + +| Option | Decision | Reason | +| --------------------------------------------------------------------------------------------------------------------- | ------------ | --------------------------------------------------------------------------------------------------------------------- | +| Keep `ole-cfb.ts`, `png-sanitize.ts`, `nextXmlTag` local in `@ranuts/converter` | **Rejected** | Duplicates ~550 lines of reusable zero-dep binary/XML utilities across repos | +| Upstream 5 modules to `chaxus/ran`, publish `ranuts@0.5.7`, then deduplicate `document` in Wave 3 | **Chosen** | Single maintained owner in `ranuts`; net -605 LOC in `ranuts/document` (`#320`) | +| Replace `lib/agent-plugin/ui/history-idle.ts` with `ranuts/utils` `whenIdle` | **Deferred** | `history-idle.ts` has a bespoke `idle: boolean` + 120ms concurrent timer contract; kept local to avoid semantic drift | +| Add `ranuts` dependency to standalone `@ranuts/agent-core` for `provider-stream.ts` | **Deferred** | Avoids adding a new runtime dependency to an editor-agnostic package for a 40-line adapter | +| Suppress `-82` in `Asc.editor.sendEvent` during `openRetryInFlight` | **Rejected** | Masks the symptom after vendor `onunhandledrejection` already ran and collides with L0's `sendEvent` hook | +| Re-seat pre-existing `win.onunhandledrejection` behind our listener (`#322`) + pre-vendor `<head>` bootstrap (`#323`) | **Chosen** | Minimal spec-compliant immediate fix (`#322`) paired with permanent architectural fix (`#323`) | + +## 3. Approach + +- **Wave 4 (`#318`, `3498d3ff`, `46ac5e4a`)**: + - `packages/agent-core/src/llm/thinking.ts`: added regex-free `stripThinkingPrefix` and + `stripEmptyThinkingPrefix`. + - `lib/onlyoffice/save-stream.ts`, `lib/history/autosave.ts`: replaced string-matched + save-lock check with typed `SaveInProgressError`. + - `StreamingMarkdown` fast paths & `conversation-db.ts` IDB connection caching. + - `.github/workflows/nightly-corpus.yml` (`needs: [gate]` on `browsers-serial`) and + `.github/workflows/docker.yml` (`concurrency` group). +- **Wave 3 (`#320`, `4ebf0a41`)**: + - Upgraded `ranuts` `0.5.2` → `0.5.7` in `package.json`, + `packages/{converter,chat-ui,shared}/package.json`, and `pnpm-lock.yaml`. + - Deleted `packages/converter/src/ole-cfb.ts` (-318 LOC) and + `packages/converter/src/png-sanitize.ts` (-171 LOC); switched callers and + `@ranuts/converter` exports to `ranuts/utils`. + - Delegated `nextXmlTag` (`packages/converter/src/docx-zip.ts`) and `fetchWasmResponse` + (`packages/converter/src/x2t-loading.ts`) to `ranuts/utils`. + - Replaced local helpers in `lib/history-page.ts`, `lib/history/relative-time.ts`, + `lib/embed-api.ts`, and `lib/prefetch.ts` with `ranuts/utils` equivalents. +- **`requestIdleCallback` receiver (`#321`, `7c642b24`)**: + - `public/landing-prefetch.js`: wrapped `window.requestIdleCallback(fn)` in a named + function instead of detaching it; added strict-receiver regression test in + `test/unit/landing-prefetch.test.ts`. +- **Open-failure handler ordering (`#322`, `87c67658`)**: + - `lib/onlyoffice/open-failure.ts`: re-seated any pre-existing `win.onunhandledrejection` + (`null` then original) after `win.addEventListener('unhandledrejection', ...)` so HTML + event-handler semantics move the vendor handler behind ours under `AT_TARGET` ordering; + added spec-compliant `EventTarget` test in `test/unit/onlyoffice-open-failure.test.ts`. + +## 4. Problems and fixes + +1. **Empty-only `<think></think>` contract (`#318`)**: `agent-action-plan.test.ts` and + `agent-sessions.test.ts` failed when full `<think>...</think>` stripping was applied + uniformly because those exports intentionally strip only empty markers. **Fix + (`46ac5e4a`)**: added `stripEmptyThinkingPrefix` for those two callers. +2. **`fetchWithRetry` 2-argument call broke `converter-wasm-loading.test.ts:69` (`#320`)**: + `fetchWithRetry` invokes `fetchImpl(url, init)` with `(url, undefined)`, failing + `toHaveBeenCalledWith(expect.stringContaining('x2t.wasm.br'))`. **Fix (`4ebf0a41`)**: + passed `fetchImpl: (url) => fetch(url)` in `packages/converter/src/x2t-loading.ts`. +3. **Intermittent `-82` in `open-retry.spec.ts:186` during `#320` CI**: traced to WHATWG + DOM `AT_TARGET` ordering — `unhandledrejection` dispatches on `window` itself in + registration order regardless of `{ capture: true }` (jsdom masked this with a + non-standard capture-first quirk). **Fix (`#322` + `#323`)**: re-seated + `win.onunhandledrejection` in `lib/onlyoffice/open-failure.ts` and added pre-vendor + `<head>` bootstrap in `#323`. + +## 5. Verification + +- `#318`: 18/18 GitHub Actions checks passed, rebased onto `main`. +- `#320`: local full unit suite 264/264 files (7,268 passed, 0 failed, 2 corpus-skipped), + `tsc --noEmit` 0 errors, `oxlint --deny-warnings` 0 warnings/errors, `prettier --check`; + remote CI 19/19 passed, rebased onto `main`. +- `#321`: `test/unit/landing-prefetch.test.ts` 16/16 passed; remote CI 19/19 passed, + rebased onto `main`. +- `#322`: `onlyoffice-open-failure.test.ts` + `onlyoffice-editor.test.ts` passed; remote + CI passed, rebased onto `main`. + +## 6. Leftovers + +- Remaining low-priority cleanup candidates identified in the audit (not yet scheduled): + deduplicating `MIME_MAP` between `docx-zip.ts` and `file-meta.ts`, removing dead + `convertCsvDirectly` / revoking converter media `blob:` URLs, replacing `'source-'` + prefix error checks in `lib/agent-plugin/references/` with typed errors, and replacing + remaining regex XML passes in `unwrapRubyXml` / `preprocessPptx`. +- `ranui@0.5.7` upgrade and `overrides.dompurify` removal tracked in `#325`. diff --git a/docs/changelogs/2026-12-04-web-mcp-all-formats-and-selection.md b/docs/changelogs/2026-12-04-web-mcp-all-formats-and-selection.md index 4203802e..9d835133 100644 --- a/docs/changelogs/2026-12-04-web-mcp-all-formats-and-selection.md +++ b/docs/changelogs/2026-12-04-web-mcp-all-formats-and-selection.md @@ -1,34 +1,47 @@ # WebMCP: Read Spreadsheets, Presentations, PDFs, and Selection -Date: 2026-12-04 · PR: [#315](https://github.com/ranuts/document/pull/315) +Date: 2026-12-04 · PR: [#315](https://github.com/ranuts/document/pull/315) · Commits: `efc778d0`, `0c5b44fd`, `7db7dfc9` -## Summary +## 1. Context -Expanded the browser-side WebMCP tool surface (`lib/web-mcp.ts`) from Word-only reads to -full multi-format inspection (spreadsheets, presentations, PDFs, and active editor -selection) with structured editor-state responses and explicit precondition checks. +`lib/web-mcp.ts` previously exposed read tools only for Word documents. Agents interacting +with spreadsheets, presentations, PDFs, or active editor selections had no WebMCP tool to +inspect content, and error responses were unstructured strings. -## Commits +## 2. Thinking and evaluation -| SHA | Summary | -| ---------- | ------------------------------------------------------------------------------------ | -| `efc778d0` | Add spreadsheet, presentation, PDF, selection read tools and structured state/errors | -| `0c5b44fd` | Fix TS spread type on `getPdfTextTool` result and Prettier formatting | -| `7db7dfc9` | Fix dynamic import paths and replace regex error classification with explicit checks | +| Option | Decision | Reason | +| ------------------------------------------------------------------------------------------ | ------------ | --------------------------------------------------------------------------------------------------- | +| Reuse existing `agent-plugin/office-tools` and `agent-plugin/pdf-tools` via dynamic import | **Chosen** | Single source of truth for reading XLSX/PPTX/PDF/selection; keeps initial bundle lazy | +| Classify caught errors by regex matching `error.message` (`classifyError`) | **Rejected** | Brittle against error-text refactors and locale changes; violates repo no-regex-error-matching rule | +| Validate preconditions explicitly (`checkReady()`, `new URL()`) before dispatching | **Chosen** | Deterministic structured error codes (`code`, `suggestedAction`) without parsing free-form strings | -## Key Changes +## 3. Approach -- **New WebMCP read tools**: wired spreadsheet, presentation, PDF text extraction, and - current-selection readers into `lib/web-mcp.ts`, importing from - `./agent-plugin/office-tools` and `./agent-plugin/pdf-tools`. -- **No brittle regex error matching**: removed regex-based `classifyError` on caught error - messages; readiness and URL validation now use explicit `checkReady()` and `new URL()` - checks before dispatching tool execution. -- **Structured state & errors**: tools return consistent structured payloads when no - document is open, when an unsupported format is active, or when a URL parameter is - invalid. +- `lib/web-mcp.ts`: added read tools for spreadsheets, presentations, PDF text, and active + selection; marked read tools with `readOnlyHint: true`; added structured editor-state + reporting and explicit precondition checks (`checkReady()` and `new URL()`). +- Dynamic imports wired to `./agent-plugin/office-tools` and `./agent-plugin/pdf-tools`. -## Verification +## 4. Problems and fixes -- All 18 GitHub Actions checks (unit tests, `tsc --noEmit`, `oxlint --deny-warnings`, - Playwright E2E, Cloudflare Pages semantics, Docker E2E) passed and rebased onto `main`. +1. **Missing dynamic import paths** (`lib/web-mcp.ts`): initial draft referenced wrong + relative paths for office/pdf tools. **Fix (`7db7dfc9`)**: pointed dynamic imports to + `./agent-plugin/office-tools` and `./agent-plugin/pdf-tools`. +2. **Regex `classifyError` on error strings** (`lib/web-mcp.ts`): initial review flagged + regex matching on caught error messages. **Fix (`7db7dfc9`)**: removed regex + classification and replaced with explicit `checkReady()` and `new URL()` guards. +3. **TypeScript spread error & Prettier line length** (`lib/web-mcp.ts`): `getPdfTextTool` + return spread failed strict TS check. **Fix (`0c5b44fd`)**: narrowed spread type and + formatted with Prettier. + +## 5. Verification + +- Local: `tsc --noEmit`, `oxlint --deny-warnings`, `prettier --check`, and unit tests + passed. +- CI: all 18/18 GitHub Actions checks (unit, lint, Playwright E2E, Cloudflare Pages + semantics, Docker E2E) passed; rebased and merged into `main`. + +## 6. Leftovers + +- Write/edit WebMCP tools remain intentionally out of scope for this read-only pass. diff --git a/docs/changelogs/README.md b/docs/changelogs/README.md index 634942fd..9f5b5bcf 100644 --- a/docs/changelogs/README.md +++ b/docs/changelogs/README.md @@ -1,20 +1,47 @@ -# Changelogs - -Chronological index of notable architectural changes, bug-fix campaigns, performance passes, -and CI/delivery hardening in `ranuts/document`. - -| Date | Document | PR / Issue | Focus | -| ---------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------- | -| 2026-12-04 | [2026-12-04-editor-frame-pre-vendor-bootstrap.md](./2026-12-04-editor-frame-pre-vendor-bootstrap.md) | [#323](https://github.com/ranuts/document/pull/323) | Pre-vendor `<head>` iframe bootstrap eliminating window-level guard boot races | -| 2026-12-04 | [2026-12-04-ranuts-0.5.7-dedup-and-hardening.md](./2026-12-04-ranuts-0.5.7-dedup-and-hardening.md) | [#318](https://github.com/ranuts/document/pull/318), [#320](https://github.com/ranuts/document/pull/320), [#321](https://github.com/ranuts/document/pull/321), [#322](https://github.com/ranuts/document/pull/322) | `ranuts@0.5.7` upgrade & dedup, Wave 4 hardening, `rIC` receiver & `-82` ordering fix | -| 2026-12-04 | [2026-12-04-ci-analytics-and-smoke-hardening.md](./2026-12-04-ci-analytics-and-smoke-hardening.md) | [#316](https://github.com/ranuts/document/pull/316), [#319](https://github.com/ranuts/document/pull/319) | Remove daily prod-smoke schedule, exclude E2E from analytics, fix beacon SRI & SemPR | -| 2026-12-04 | [2026-12-04-web-mcp-all-formats-and-selection.md](./2026-12-04-web-mcp-all-formats-and-selection.md) | [#315](https://github.com/ranuts/document/pull/315) | WebMCP multi-format read tools (XLSX/PPTX/PDF/selection) & explicit error handling | -| 2026-11-30 | [2026-11-30-pdf-export-perf.md](./2026-11-30-pdf-export-perf.md) | [#317](https://github.com/ranuts/document/pull/317) | Canvas PDF export speedup, warm x2t worker font reuse, `.pdfa` support | -| 2026-11-30 | [2026-11-30-corpus-open-path-fixes.md](./2026-11-30-corpus-open-path-fixes.md) | [#313](https://github.com/ranuts/document/pull/313) | Nightly POI corpus open-path fixes (OLE case/FIB/PPT persistId, DOCX tables, PNG strip) | -| 2026-10-17 | [2026-10-17-open-retry-reporting.md](./2026-10-17-open-retry-reporting.md) | `ac2dcade` | Prevent duplicate `-82` reporting during recoverable open retries | -| 2026-10-16 | [2026-10-16-site-token-consistency.md](./2026-10-16-site-token-consistency.md) | — | Site design token consistency | -| 2026-08-22 | [2026-08-22-font-licensing.md](./2026-08-22-font-licensing.md) | — | Font licensing & catalog audit | -| 2026-08-20 | [2026-08-20-issue-144-memory-and-delivery.md](./2026-08-20-issue-144-memory-and-delivery.md) | #144 | x2t WASM streaming instantiation, memory relief, and delivery hardening | -| 2026-08-16 | [2026-08-16-roadmap-sprint.md](./2026-08-16-roadmap-sprint.md) | — | Roadmap sprint summary | -| 2026-08-15 | [2026-08-15-v9-regression-campaign.md](./2026-08-15-v9-regression-campaign.md) | — | v9 regression campaign & vendor contract coverage | -| 2026-06-23 | [2026-06-23-agent-collab.md](./2026-06-23-agent-collab.md) | — | Agent collaboration & initial plugin architecture | +# Changelogs: process log + +This directory records `ranuts/document` work **as it happened**: why we did it, what +options we evaluated, what changed, every pitfall and root cause we hit, how we verified +it, and what remains. Outcomes live in code and git history; process lives here. + +## Naming + +`YYYY-MM-DD-<short-english-slug>.md`; date is when the work landed (merged). + +File names sort by date only; order within a day is in the index table below. + +## Structure per entry (exhaustive / 事无巨细) + +1. **Context**: why we did it, starting state, related prior entries +2. **Thinking and evaluation**: options table with Chosen / Rejected / Deferred and reasons +3. **Approach**: what changed (file paths), key design choices +4. **Problems and fixes**: every pitfall in the session, root cause, fix (file-level) +5. **Verification**: what we ran, exact numbers, what we did not verify +6. **Leftovers**: unfinished work, known gaps, next steps + +One-line summaries are not done. Record facts and judgments at the time only; mark +speculation explicitly. + +### Never put privacy or security material here + +No API tokens, OAuth client secrets/private keys, passwords, personal emails, account/user +IDs, raw cookies, or private console fields. OK: public URLs, cookie **names**, config +paths, secret slot names. Never paste secret values. + +## Index + +| Date | File | PR / Issue | One-liner | +| ---------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------- | +| 2026-12-04 | [2026-12-04-editor-frame-pre-vendor-bootstrap.md](./2026-12-04-editor-frame-pre-vendor-bootstrap.md) | [#323](https://github.com/ranuts/document/pull/323) | Install window-level iframe guards synchronously in `<head>` before any OnlyOffice vendor script executes | +| 2026-12-04 | [2026-12-04-ranuts-0.5.7-dedup-and-hardening.md](./2026-12-04-ranuts-0.5.7-dedup-and-hardening.md) | [#318](https://github.com/ranuts/document/pull/318), [#320](https://github.com/ranuts/document/pull/320), [#321](https://github.com/ranuts/document/pull/321), [#322](https://github.com/ranuts/document/pull/322) | Upgrade `ranuts@0.5.7` (-605 LOC dedup), Wave 4 hardening, `rIC` receiver fix, and `-82` AT_TARGET re-seat | +| 2026-12-04 | [2026-12-04-ci-analytics-and-smoke-hardening.md](./2026-12-04-ci-analytics-and-smoke-hardening.md) | [#316](https://github.com/ranuts/document/pull/316), [#319](https://github.com/ranuts/document/pull/319) | Remove daily prod-smoke schedule, isolate E2E from GA4/Cloudflare analytics, fix beacon SRI & Semantic PR | +| 2026-12-04 | [2026-12-04-web-mcp-all-formats-and-selection.md](./2026-12-04-web-mcp-all-formats-and-selection.md) | [#315](https://github.com/ranuts/document/pull/315) | Expand WebMCP to spreadsheets, presentations, PDFs, and active selection with explicit precondition validation | +| 2026-11-30 | [2026-11-30-pdf-export-perf.md](./2026-11-30-pdf-export-perf.md) | [#317](https://github.com/ranuts/document/pull/317) | Speed up canvas PDF export, reuse warm x2t worker fonts, and fix `.pdfa` export | +| 2026-11-30 | [2026-11-30-corpus-open-path-fixes.md](./2026-11-30-corpus-open-path-fixes.md) | [#313](https://github.com/ranuts/document/pull/313) | Repair Nightly POI corpus open failures (OLE case/FIB/PPT persistId, DOCX table depth, broken PNG chunks) | +| 2026-10-17 | [2026-10-17-open-retry-reporting.md](./2026-10-17-open-retry-reporting.md) | `ac2dcade` | Prevent duplicate `-82` error reporting during recoverable open retries | +| 2026-10-16 | [2026-10-16-site-token-consistency.md](./2026-10-16-site-token-consistency.md) | — | Align site design tokens across landing and app surfaces | +| 2026-08-22 | [2026-08-22-font-licensing.md](./2026-08-22-font-licensing.md) | — | Audit font catalog licensing and sprite coverage | +| 2026-08-20 | [2026-08-20-issue-144-memory-and-delivery.md](./2026-08-20-issue-144-memory-and-delivery.md) | #144 | Stream x2t WASM instantiation, cut open-path memory peak, and harden delivery | +| 2026-08-16 | [2026-08-16-roadmap-sprint.md](./2026-08-16-roadmap-sprint.md) | — | Roadmap sprint summary | +| 2026-08-15 | [2026-08-15-v9-regression-campaign.md](./2026-08-15-v9-regression-campaign.md) | — | v9 regression campaign and vendor contract coverage | +| 2026-06-23 | [2026-06-23-agent-collab.md](./2026-06-23-agent-collab.md) | — | Agent collaboration and initial plugin architecture |