Skip to content

chore(widget): cross-stream bk-flash tracing + console cleanup#761

Merged
paddymul merged 2 commits into
mainfrom
chore/widget-bk-flash-logging
May 17, 2026
Merged

chore(widget): cross-stream bk-flash tracing + console cleanup#761
paddymul merged 2 commits into
mainfrom
chore/widget-bk-flash-logging

Conversation

@paddymul
Copy link
Copy Markdown
Collaborator

Summary

Extracted from #749. The JS side already had an opt-in [bk-flash …] tracer; this adds the Python counterpart and harmonizes the timestamp format so the two streams can be grep'd and interleaved when debugging the search → request → response round-trip.

What's in

  • Python _bk_flash (buckaroo/buckaroo_widget.py): wall-clock [bk-flash-py HH:MM:SS.mmm] to stderr, gated by BUCKAROO_BK_FLASH=1. Call sites in _buckaroo_state, _handle_widget_change, _handle_payload_args (pandas + polars).
  • JS bkLog harmonization: swap performance.now() for wall-clock bkTs() in BuckarooWidgetInfinite.tsx and DFViewerInfinite.tsx so JS lines align with Python timestamps. Gate is now runtime-checkable (bkFlashOn() per call), so globalThis.__BK_FLASH__ = true works in DevTools without a bundle reload.
  • New boundary logs at model.send infinite_request → Python and model.on infinite_resp ← Python.
  • Trim: removed unconditional render-time bkLog calls (BuckarooInfiniteWidget render, makeStaticInfiniteDs, fakeDs.getRows, getDataWrapper, DFViewer{,Inner} render, datasource useMemo, AgGrid onModelUpdated/onSortChanged/onGridReady, view_name effect when from===to). Keeps signal-to-noise usable when the flag is on.
  • Drop debugger; in SmartRowCache.ts:461.

Enabling the trace

In the kernel:

BUCKAROO_BK_FLASH=1 jupyter lab

In DevTools:

globalThis.__BK_FLASH__ = true

Then re-run the widget cell and grep [bk-flash in both the browser console and kernel output.

Test plan

  • pnpm run build:tsc clean
  • pnpm test — 233 pass
  • pytest tests/unit/ — 987 pass (1 unrelated build-artifact failure on test_mcp_uvx_install.py::test_view_data_call reproduces on plain main and is deselected)
  • BUCKAROO_BK_FLASH=1 pytest tests/unit/test_xorq_buckaroo_widget.py tests/unit/polars_basic_widget_test.py — 49 pass (verifies guards around len(processed_df) don't blow up on xorq Ibis exprs)
  • Manual: enable both flags, type into the search box, see the round-trip timeline (qca → buckaroo_state ← JS → handle_widget_change → infinite_request → infinite_resp → onRowDataUpdated)

🤖 Generated with Claude Code

…cleanup

Search-path debugging needs Python and JS log lines on the same timeline.
The JS side already had an opt-in `[bk-flash …]` tracer; this adds the
Python counterpart and harmonizes the timestamp format so the two
streams can be grep'd and interleaved.

- buckaroo/buckaroo_widget.py: `_bk_flash` helper gated by
  `BUCKAROO_BK_FLASH` env var. Call sites in `_buckaroo_state`,
  `_handle_widget_change`, `_handle_payload_args`.
- buckaroo/polars_buckaroo.py: `_bk_flash` in polars `_handle_payload_args`.
- BuckarooWidgetInfinite.tsx, DFViewerInfinite.tsx: switch
  `performance.now()` to wall-clock `bkTs()` so JS lines line up with
  Python's `[bk-flash-py HH:MM:SS.mmm]`. Make the gate runtime-checkable
  (`bkFlashOn()`) so `globalThis.__BK_FLASH__ = true` works in DevTools
  without a bundle reload. Add request/response boundary logs at
  `model.send infinite_request` and `model.on infinite_resp`.
- SmartRowCache.ts: drop stray `debugger;` at verifyResp.
- Trim unconditional render-time bkLog calls (BuckarooInfiniteWidget
  render, makeStaticInfiniteDs, fakeDs.getRows, getDataWrapper,
  DFViewer{,Inner} render, datasource useMemo, AgGrid onModelUpdated /
  onSortChanged / onGridReady, view_name effect when from===to) so the
  signal-to-noise stays usable when the flag is on.

To enable: set `BUCKAROO_BK_FLASH=1` in the kernel env and
`globalThis.__BK_FLASH__ = true` in DevTools, then grep `[bk-flash` in
the browser console + kernel output.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 17, 2026

📦 TestPyPI package published

pip install --index-strategy unsafe-best-match --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ buckaroo==0.14.0.dev25998518773

or with uv:

uv pip install --index-strategy unsafe-best-match --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ buckaroo==0.14.0.dev25998518773

MCP server for Claude Code

claude mcp add buckaroo-table -- uvx --from "buckaroo[mcp]==0.14.0.dev25998518773" --index-strategy unsafe-best-match --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ buckaroo-table

📖 Docs preview

🎨 Storybook preview

paddymul added a commit that referenced this pull request May 17, 2026
CI's Python / Lint job runs `ruff check` + `paddy_format.py --check` over
the entire `buckaroo/ tests/ scripts/` tree, but the local `paddy-format`
pre-commit hook only sees staged files. Drift introduced by a recent
merge to main (e.g. an unrelated PR that didn't run the formatter) only
surfaces on CI for the next person to push, even if their own staged
files are clean — exactly what happened to PR #761.

Add a pre-push stage that mirrors CI's lint job, so the same full-tree
check runs locally before push:

  - ruff-check-full: `uv run ruff check` (no file filter)
  - paddy-format-check-full: `--check` over the same find expression
    CI uses

To activate locally, run `pre-commit install --hook-type pre-push` once
(or `pre-commit install --install-hooks --hook-type pre-commit --hook-type pre-push`).

Also reformat `tests/unit/dataflow/autocleaning_pl_test.py` which was
the file CI flagged on #761.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@paddymul paddymul added this pull request to the merge queue May 17, 2026
Merged via the queue into main with commit 72bcf2a May 17, 2026
27 checks passed
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