diff --git a/AGENTS.md b/AGENTS.md index 457b4ee..4a3f9db 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -137,13 +137,13 @@ Done in rc-jav catalog loading. Catalog CSV/XML paths are normalized from Window 5. **Recent Activity + Search Troubleshooting moved to new Debug Tools pane.** Verified Recent Activity is search-trigger-only by reading `background.js` — `recordActivity()` is NOT called from `delete-file` handler. No audit-value split needed. New sidebar entry "Debug Tools" under System group; new `pane-debug` houses both fieldsets. 6. **options.js split — Cache & Scans + Duplicate Review paired extraction.** `options.js` 3133 → 2356 lines. New files: `options-cache.js` (161 lines, Cache & Scans block), `options-dupe-review.js` (616 lines, Dup Review + Keep Ranking incl. bottom `loadKeepRanking()` call). Script-tag order in `options.html`: cache → dupe-review → options.js (body bottom). Cross-script binding visibility (vanilla classic scripts share global declarative env): Library Issues code still in options.js reads `_configuredScanRoots` / `_cacheSkippedByRemote` / calls `rememberConfiguredScanRoots` from cache file by bare reference. Calls to `escapeHtml` / `openModal` / `closeModal` / `keepActionViewport` / `clearNativeRepairCard` / `renderNativeMessagingFailure` from extracted files all occur inside event handlers (resolved at call time, after options.js parses). Repo `git init`'d before this step; baseline commit `f8e781f` is the rollback point. Verified by `node --check` on each file and on concatenated script. 6b. **options.js split — Library Issues extraction.** `options.js` 2356 → 1903 lines. New file: `options-library-issues.js` (453 lines) — covers `lastLibraryIssues`, `_libraryIssuesDirty`, `renderLibraryIssues`, `_closeLibraryIssues`, and the bottom IIFE that wraps `_optScanTimer` / `_setOptScanningState` / `_pollOptProgress` for optimization-scan progress polling. Block was fully self-contained (no external callers of its identifiers). Reads `_configuredScanRoots` / `_cacheSkippedByRemote` / calls `rememberConfiguredScanRoots` from `options-cache.js` — same cross-file binding pattern proven in step 6. Script-tag order in `options.html`: cache → dupe-review → library-issues → options.js. `node --check` passes on each file and on concatenation; line count of concat (3133) matches pre-split total exactly. +7a. **Bulk Check standalone window.** New `bulk-check.{html,js,css}` opened as detached `chrome.windows.create({ type: 'popup', width: 640, height: 540 })`. Launcher = 📋 icon button in popup header next to ⚙ Options; click sends `open-bulk-check` message to background and closes the popup. Background owns the lifecycle: `openBulkCheckWindow()` reads `chrome.storage.session.bulkCheckWindowId`; existing id → `chrome.windows.update({ focused, drawAttention })`; failure or no id → create new window + stash id. `chrome.windows.onRemoved` clears the stale id on close. Last-paste persisted to `chrome.storage.local.bulkCheckLastPaste` (debounced 500ms), restored on window open. `quickMode` read from settings on each run (parity with old options behavior). Removed the Bulk ID Check fieldset from `options.html` (Library Review pane description updated to note the relocation) and its handlers from `options.js` (1903 → 1852 lines). No manifest permission changes needed. (Step 4 in the plan is a paired-extraction sub-task of step 6; folded into step 6 ship.) **Pending (in execution order):** -- **Step 6c — finish options.js split (optional).** Remaining options.js (1903 lines) still holds: settings load/save, backup/restore, recent activity, search test bench, bulk ID check, adapters, ID normalizers, part detectors, element picker, overlay previews, diagnostics, profiles, paths, and the bottom-entry IIFE. Candidates for extraction: Diagnostics (~250 lines, 1354–1603 in current options.js), Profiles (~265 lines), Adapters + ID normalizers + Part detectors as a "rules editors" file (~330 lines combined). Diminishing returns past this point — bottom IIFE + load/save core should stay in `options.js` as the entry point. -- **Step 7a — Bulk Check standalone window.** New `bulk-check.html` opened as detached `chrome.windows.create({ type: 'popup', width: 640, height: 540 })` from a "Bulk Check" launcher button in the popup. Single canonical entry path — NOT a Console sidebar tab. Window dedup via `chrome.storage.session`, last-paste persisted via `chrome.storage.local`. +- **Step 6c — finish options.js split (optional).** Remaining options.js (1852 lines) still holds: settings load/save, backup/restore, recent activity, search test bench, adapters, ID normalizers, part detectors, element picker, overlay previews, diagnostics, profiles, paths, and the bottom-entry IIFE. Candidates for extraction: Diagnostics (~250 lines), Profiles (~265 lines), Adapters + ID normalizers + Part detectors as a "rules editors" file (~330 lines combined). Diminishing returns past this point — bottom IIFE + load/save core should stay in `options.js` as the entry point. - **Step 8 — Shared fixture corpus.** Top-level `D:\DEV\Project\rclone-jav\fixtures\` (neutral location, NOT inside Python or extension repo). JSON cases for query-ID extraction (extension), filename ID extraction (Python), shared normalization. - **Step 9 — Cache contract design.** CACHE_VERSION already exists (currently 3). Add ID_RULES_VERSION concept: schema bump = force rebuild, rules bump = warn-and-mark-stale. - **Step 10 — `rc-jav.py` module split** into `rcjav/` package (ids, cache, dupes, catalog, rclone_io, output, cli). Keep `rc-jav.py` as thin entrypoint that imports from `rcjav.cli.main`. diff --git a/background.js b/background.js index d086f83..741288c 100644 --- a/background.js +++ b/background.js @@ -692,6 +692,11 @@ chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => { })(); return true; } + if (msg.type === "open-bulk-check") { + openBulkCheckWindow(); + sendResponse({ ok: true }); + return false; + } if (msg.type === "dupe-review") { (async () => { try { @@ -1075,3 +1080,44 @@ chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => { // On install / startup, build context menu chrome.runtime.onInstalled.addListener(() => ensureContextMenu()); chrome.runtime.onStartup.addListener(() => ensureContextMenu()); + +// ---------- Bulk Check standalone window ---------- +const BULK_CHECK_WIN_KEY = "bulkCheckWindowId"; + +async function openBulkCheckWindow() { + const session = chrome.storage.session; + try { + const stored = session ? await session.get(BULK_CHECK_WIN_KEY) : {}; + const existingId = stored?.[BULK_CHECK_WIN_KEY]; + if (existingId) { + try { + await chrome.windows.update(existingId, { focused: true, drawAttention: true }); + return; + } catch { + if (session) await session.remove(BULK_CHECK_WIN_KEY); + } + } + const win = await chrome.windows.create({ + url: chrome.runtime.getURL("bulk-check.html"), + type: "popup", + width: 640, + height: 540, + }); + if (session && win?.id != null) { + await session.set({ [BULK_CHECK_WIN_KEY]: win.id }); + } + } catch (e) { + console.warn("openBulkCheckWindow failed:", e); + } +} + +chrome.windows.onRemoved.addListener(async (windowId) => { + const session = chrome.storage.session; + if (!session) return; + try { + const stored = await session.get(BULK_CHECK_WIN_KEY); + if (stored?.[BULK_CHECK_WIN_KEY] === windowId) { + await session.remove(BULK_CHECK_WIN_KEY); + } + } catch { /* ignore */ } +}); diff --git a/bulk-check.css b/bulk-check.css new file mode 100644 index 0000000..3543034 --- /dev/null +++ b/bulk-check.css @@ -0,0 +1,102 @@ +body { + font-family: -apple-system, Segoe UI, sans-serif; + font-size: 13px; + margin: 0; + padding: 12px; + background: #1a1a1a; + color: #ddd; +} + +#header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 8px; +} +#header strong { font-size: 15px; } + +#mode-pill { + font-size: 11px; + font-weight: 700; + letter-spacing: 0.4px; + background: #1a2a3a; + color: #6ec1ff; + padding: 2px 8px; + border-radius: 3px; + border: 1px solid #2a4a6a; +} +#mode-pill[data-mode="CACHE"] { + background: #1a3a1a; + color: #afa; + border-color: #2a5a2a; +} + +.help { + font-size: 12px; + color: #aaa; + line-height: 1.4; + margin-bottom: 8px; +} +.help code { + background: #0d0d0d; + padding: 1px 4px; + border-radius: 2px; + font-family: Consolas, monospace; + color: #ddd; +} +.dim { color: #777; } + +textarea#bulk-id-input { + width: 100%; + height: 140px; + resize: vertical; + background: #0d0d0d; + color: #ddd; + border: 1px solid #444; + border-radius: 3px; + padding: 6px 8px; + font-size: 12px; + font-family: Consolas, monospace; + box-sizing: border-box; +} +textarea#bulk-id-input:focus { outline: none; border-color: #6ec1ff; } + +.button-row { + display: flex; + align-items: center; + gap: 6px; + margin: 8px 0; +} + +button { + background: #333; + color: #ddd; + border: 1px solid #555; + border-radius: 3px; + padding: 4px 10px; + cursor: pointer; + font-size: 12px; +} +button:hover { background: #444; } +button:disabled { opacity: 0.5; cursor: default; } +button.running { background: #3a1a1a; border-color: #722; color: #faa; } + +#count-pill { + margin-left: auto; + font-size: 11px; +} + +.mono-output { + background: #0d0d0d; + border: 1px solid #333; + border-radius: 3px; + padding: 8px 10px; + font-family: Consolas, monospace; + font-size: 12px; + line-height: 1.5; + max-height: 260px; + overflow-y: auto; + white-space: pre-wrap; + word-break: break-word; +} +.mono-output:empty { display: none; } diff --git a/bulk-check.html b/bulk-check.html new file mode 100644 index 0000000..3ea26cc --- /dev/null +++ b/bulk-check.html @@ -0,0 +1,32 @@ + + +
+ +BLK-474, FC2-4865786, PRTD-[027-030]
+