Skip to content

feat: binlog-to-page correlation CLI and web UI#205

Merged
ringo380 merged 2 commits intomasterfrom
feat/binlog-correlate-cli-webui
Mar 30, 2026
Merged

feat: binlog-to-page correlation CLI and web UI#205
ringo380 merged 2 commits intomasterfrom
feat/binlog-correlate-cli-webui

Conversation

@ringo380
Copy link
Copy Markdown
Owner

Summary

Changes

CLI (--correlate)

  • src/cli/app.rs — new correlate: Option<String> arg on Binlog variant
  • src/cli/binlog.rsexecute_correlated() with CorrelatedBinlogAnalysis JSON struct, enriched text/CSV output with Page and PK columns
  • src/main.rs — wire correlate through dispatch

Web UI (correlation view)

  • web/src/components/binlog.js — dropzone for .ibd file, WASM correlate_binlog_events() call, enriched events table with Page/PK columns, clickable page navigation, clear button
  • web/src/main.jsbinlogCorrelationTs state, save/restore binlog context on page navigation, "Back to Binlog" banner
  • web/src/utils/help.js — updated tab description with correlation tips

Test plan

  • cargo clippy -- -D warnings passes
  • cargo test passes (982 tests including 3 new correlation output tests)
  • cargo check --target wasm32-unknown-unknown --no-default-features passes
  • cd web && npm run build succeeds
  • Manual: inno binlog -f <binlog> --correlate <table.ibd> shows Page/PK columns
  • Manual: inno binlog -f <binlog> --correlate <table.ibd> --json includes correlated_events array
  • Manual: web UI — drop binlog, drop .ibd on correlation zone, verify page column, click page number navigates to Pages tab, "Back to Binlog" restores state

…180)

Add --correlate <tablespace> flag to `inno binlog` that maps row events
to specific B+Tree leaf pages via PK lookup. Supports text, JSON, and
CSV output with page number and primary key columns.

Enhance the web UI Binlog tab with a correlation dropzone: drop a .ibd
file to annotate row events with page numbers. Clickable page links
navigate to the Pages tab with full tablespace context and a "Back to
Binlog" banner for easy return.
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@ringo380
Copy link
Copy Markdown
Owner Author

Code review

Found 3 issues:

  1. Tailwind dynamic class bg-innodb-green/5 constructed via string interpolation will be purged by JIT (CLAUDE.md says "Never construct class names via string interpolation... Tailwind's JIT scanner does static analysis -- use literal full class strings or the classes will be purged from production CSS")

const ce = hasCorrelation ? correlatedMap.get(evt.offset) : null;
return `
<tr class="border-b border-gray-800/30 hover:bg-surface-2/50${ce ? ' bg-innodb-green/5' : ''}">
<td class="py-1 pr-3 text-innodb-cyan">${evt.offset}</td>
<td class="py-1 pr-3 text-gray-300">${esc(evt.event_type)}</td>

The correlated row highlight (bg-innodb-green/5) only appears inside a ternary interpolation -- Tailwind cannot detect it statically and will not generate the CSS rule. Fix by using two complete literal class strings.

  1. savedBinlogState not reset in onFile() -- stale "Back to Binlog" banner appears after loading a new file

idb-utils/web/src/main.js

Lines 158 to 168 in b5733ee

function onFile(name, data) {
fileName = name;
fileData = data;
diffData = null;
isRedoLog = false;
isBinlog = false;
decryptedData = null;
encryptionInfo = null;
auditFiles = null;
binlogCorrelationTs = null;

All other module-level state variables are reset in onFile() (diffData, isRedoLog, isBinlog, decryptedData, encryptionInfo, auditFiles, binlogCorrelationTs), but savedBinlogState is not. If a user loads a new file while in the "viewing tablespace from binlog correlation" state, the banner persists with stale state. Fix: add savedBinlogState = null alongside the other resets.

  1. restoreBinlogState() does not reset currentTab to the binlog tab index -- "Back to Binlog" renders the wrong tab

idb-utils/web/src/main.js

Lines 306 to 316 in b5733ee

function restoreBinlogState() {
if (!savedBinlogState) return;
fileData = savedBinlogState.fileData;
fileName = savedBinlogState.fileName;
isBinlog = savedBinlogState.isBinlog;
binlogCorrelationTs = savedBinlogState.binlogCorrelationTs;
savedBinlogState = null;
pageCount = 0;
renderAnalyzer();
}

After onBinlogPageClick() navigates to the Pages tab (changing currentTab), clicking "Back to Binlog" calls restoreBinlogState() which restores isBinlog = true but leaves currentTab pointing at the old Pages tab index. Since the binlog tab set has only 1 tab (index 0), getTabId(currentTab) returns undefined and renderTab() falls through the switch without rendering anything. Fix: add currentTab = 0 before renderAnalyzer() in restoreBinlogState.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

- Use literal full class strings for bg-innodb-green/5 to prevent
  Tailwind JIT purging the correlated row highlight
- Reset savedBinlogState in onFile() alongside other state variables
- Set currentTab = 0 in restoreBinlogState() so "Back to Binlog"
  correctly renders the binlog tab
@ringo380 ringo380 merged commit ee9798c into master Mar 30, 2026
8 of 15 checks passed
@ringo380 ringo380 deleted the feat/binlog-correlate-cli-webui branch March 30, 2026 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant