Final options.js split. Three new files:
options-diagnostics.js 245 lines
options-profiles.js 265 lines
options-rules-editors.js 328 lines (adapters + ID normalizers
+ custom part detectors)
options.js: 1852 → 1014 lines (838 extracted, ~45% reduction).
Script-tag order in options.html now (load order matters for
top-level let bindings shared across files, e.g. _configuredScanRoots):
options-cache.js
options-dupe-review.js
options-library-issues.js
options-diagnostics.js
options-profiles.js
options-rules-editors.js
options.js (entry: IIFE bottom, escapeHtml, overlay previews,
element picker, paths)
The picker, overlay-preview, and no-match overlay code stays in
options.js — those are tightly intertwined with multiple settings
panes and not worth further splitting today.
node --check passes on each file individually and on the concatenated
load-order stream. Line count of concat (3144) matches the pre-split
sum exactly.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Completes the two-tier cache contract from step 9 / docs/CACHE_CONTRACT.md
on the extension side. The Python side shipped in the Python repo at
33c495a.
Host (rcjav-host.py):
- fetch_rules_info() memoizes per-script-path calls to
`rc-jav.py --print-rules-info` so handle_cache_status doesn't pay
the Python startup cost on every poll.
- _cache_freshness_fields(data, rules_info) computes the new
cache_schema / id_rules / id_rules_signature trio + their three
*_match booleans + cache_state ('fresh' / 'stale_by_rules' /
'schema_mismatch' / 'missing'). Legacy version:3 caches still on
disk report as stale_by_rules with cache_schema_match=True (we'll
migrate them at next load_cache).
- New handle_reextract_ids() action forwards to
`rc-jav.py --reextract --format json` with a 5-minute timeout.
background.js:
- New `reextract-ids` message forwards to host with a 300s timeout.
options-cache.js + options-library-issues.js:
- renderCacheContractBanner() paints a three-state banner above the
per-remote list: green ✓ fresh / amber ! stale-by-rules (with
"Re-extract IDs (fast, no rescan)" chip button) / red ✗ schema
mismatch. Includes a snippet of the cache signature for diagnostics.
- Delegated click handler in options-library-issues.js catches
.cache-reextract, sends the message, shows transient
"Re-extracting…" state, and replaces the button with a per-summary
line ("Re-extracted N IDs · X changed · Y unchanged · Z dropped").
- rules_info_error from the host surfaces as its own amber line above
the banner.
node --check passes on background.js, options-cache.js,
options-library-issues.js individually and on the concatenation of all
four script files. python -m py_compile passes on rcjav-host.py.
Behavioral verification requires reloading the unpacked extension and
running through:
- Check Cache → banner shows "stale by rules" amber (legacy v3 cache)
- Click "Re-extract IDs" → fast path runs, summary appears
- Check Cache again → banner now shows "Cache up to date" green
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds docs/CACHE_CONTRACT.md defining the two-tier replacement for
today's single CACHE_VERSION=3 constant:
cache_schema force rebuild on mismatch (today's semantics)
id_rules mark stale, allow lazy re-extract w/o rescan
id_rules_signature sha256 over canonical text of all extraction
rule sources (regexes, normalizers, part
detectors, FC2 handling, user-config rules)
as a belt-and-braces drift check
Documents:
- new cache.json header shape
- one-shot in-place migration for legacy `version: 3` users (no
forced rescan)
- behavior matrix for the three resulting states
- extension UX: fresh / stale-by-rules amber / schema-mismatch red
- new "Re-extract IDs" action that walks files[] in place and
never touches rclone
- what counts as a rules change vs. unrelated code change
- open questions deferred to step 10 (per-remote tracking,
custom-rules signature handling, host wiring)
No code changes — step 10 implements. This commit only locks the
contract so step 10 has a single source of truth for both the
Python and extension sides.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds a shared JAV-ID fixture corpus at the Python repo root (conceptually
joint with this extension). Three JSON files:
filename-extraction.json 12 cases — Python extract_id contract
query-extraction.json 10 cases — extension content.js normalizeId
shared-normalization.json 5 cases — both sides must agree
Plus a README.md documenting format, ownership, and one intentional
cross-side divergence (the compact `FC2PPV1841460` form: extension
normalizes it from page titles, Python `extract_id` does not — it
doesn't realistically appear in filenames on disk).
A self-contained Python runner at fixtures/run.py exercises extract_id
and normalize_id against the relevant corpora. No third-party deps,
loads rc-jav.py in place. All 17 Python-side cases pass against the
current rc-jav.py. Output uses ASCII separators (`->`, `|`) instead of
unicode arrows/middots so the runner works on Windows cp1252 consoles.
No Node-side runner today: content.js lives inside an injected IIFE
and a Node runner would have to duplicate the regexes. The JSON corpus
is the canonical spec until content.js is refactored to be importable.
This commit only updates AGENTS.md in this repo — the fixture files
themselves live in the Python repo at D:\DEV\Project\rclone-jav\fixtures\
which is not currently git-tracked.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
New files:
bulk-check.html, bulk-check.js, bulk-check.css
Popup gains a 📋 launcher button next to the ⚙ Options gear. Clicking
it sends `open-bulk-check` to background.js and closes the popup;
background.js owns window lifecycle:
- chrome.storage.session.bulkCheckWindowId stashes the open window id
- existing id → chrome.windows.update({ focused, drawAttention })
- missing or stale id → chrome.windows.create({ type:'popup',
width:640, height:540 }) and stash the new id
- chrome.windows.onRemoved clears the stale id on close
Last-paste persisted to chrome.storage.local.bulkCheckLastPaste,
debounced 500ms on input, restored on window open. quickMode is read
from settings at run time, matching previous behavior. Ctrl/Cmd+Enter
inside the textarea triggers the check.
Options page no longer carries the Bulk ID Check fieldset: removed
from options.html (Library Review pdesc updated to note the
relocation) and the matching handlers from options.js
(1903 → 1852 lines). No manifest permission changes — own-page
chrome.windows.create needs no extra permission.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Continues the options.js split. New file:
options-library-issues.js 453 lines
After this step:
options-cache.js 161 lines
options-dupe-review.js 616 lines
options-library-issues.js 453 lines
options.js 1903 lines (was 2356 after step 6)
Library Issues block was fully self-contained (lastLibraryIssues,
_libraryIssuesDirty, renderLibraryIssues, _closeLibraryIssues, and the
bottom IIFE wrapping _optScanTimer / _setOptScanningState /
_pollOptProgress for optimization-scan progress polling). No external
callers of its identifiers.
Reads _configuredScanRoots / _cacheSkippedByRemote and calls
rememberConfiguredScanRoots from options-cache.js by bare reference —
same cross-file binding pattern proven in step 6.
node --check passes on each file and on the concatenation of all four
files in load order. Concat = 3133 lines, matching pre-split total.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Splits the 3133-line options.js into three vanilla scripts loaded in
order at the bottom of options.html:
options-cache.js 161 lines (Cache & Scans block)
options-dupe-review.js 616 lines (Duplicate Review + Keep Ranking)
options.js 2356 lines (everything else)
No behavior change. Cross-file references work because classic <script>
tags share the global declarative environment: top-level `let` bindings
in options-cache.js (_configuredScanRoots, _cacheSkippedByRemote) are
visible by bare reference in options.js, where Library Issues still
reads them. Calls into options.js from the extracted files
(escapeHtml, openModal/closeModal, keepActionViewport,
clearNativeRepairCard, renderNativeMessagingFailure) all occur inside
event handlers, resolved at call time after options.js parses.
node --check passes on each file individually and on the concatenation
of all three in load order. Brace counts balanced.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>