Skip to content

fix: stop variables search from matching internal cell IDs - #11895

Merged
mscolnick merged 2 commits into
marimo-team:mainfrom
burrows99:fix/variables-search-cell-ids
Nov 17, 2026
Merged

mscolnick merged 2 commits into
marimo-team:mainfrom
burrows99:fix/variables-search-cell-ids

Conversation

@burrows99

@burrows99 burrows99 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

This pull request was authored by a coding agent.

📝 Summary

The search box in the Variables panel also matches the internal IDs of the cells that declare or use a variable. Those IDs are four random letters and are never shown, so a search returns variables that have nothing visibly in common with what was typed.

To reproduce, open a notebook with at least seven cells and search for ref (the seventh cell's ID is Xref):

import marimo as mo                              # cell 0
prices = [12.5, 8.0, 21.75]                      # cell 1
reference = "ORDER-1042"                         # cell 2
tax_rate = 0.2                                   # cell 3
subtotal = sum(prices)                           # cell 4
Total = round(subtotal * (1 + tax_rate), 2)      # cell 5
summary = mo.md(f"Amount due: **{Total}**")      # cell 6

On main, ref lists mo, reference, Total and summary. Only reference contains those letters; the other three are declared in or used by the cell with ID Xref. IDs are generated from a fixed seed when a notebook is loaded, so the first cell is Hbol and bol matches every variable of the first cell.

The cause is globalFilterFn: "auto". It stringifies each column's accessor value, and those values are arrays that hold the cell IDs next to the text.

The fix replaces it with a small function that searches what the table shows: variable name, type, value, and the names of the declaring and using cells. The cell names were already added for searching; they move from the column accessor into that function. Matching stays case-insensitive.

I did not find an existing issue or pull request for this. I noticed it while using the panel in a local editor.

flowchart TD
    A[Seventh cell has hidden ID Xref] --> B{Search variables for ref}
    B -->|Before| C[Four variables listed]
    B -->|After| D[Only reference listed]
Loading

Narrated recording, before then after (sound on):

evidence.mp4

Edge cases and unchanged behavior checked

Checked in the running editor (Vite dev server and marimo edit from main at 9bdfb76, then this branch, same notebook) and shown in the recording:

  • Before: ref lists mo, reference, Total and summary.
  • After: ref lists only reference.
  • Edge case: typing the cell ID itself in capitals (XREF) finds nothing. On main it lists mo, Total and summary.
  • Edge case: an uppercase search (TOTAL) still finds Total and subtotal.
  • Unchanged: searching by value (order) still finds reference.
  • Unchanged: searching by cell name (cell-6) still lists mo, Total and summary.
  • Unchanged: clearing the search restores all seven variables.

The last four searches return the same rows on main; I ran them there too, outside the recording.

Checked by the new component tests only (variables-table.test.tsx):

  • Searching by type (float), by a custom cell name, and by the ID of the first cell (Hbol).

Tests run

$ pnpm exec vitest --run src/components/variables/__tests__/variables-table.test.tsx   (in frontend)
Test Files  1 passed (1)
     Tests  3 passed (3)

With the change to variables-table.tsx reverted and the tests kept, the ID test fails: expected [ 'reference', 'Total', 'summary' ] to deeply equal [ 'reference' ].

oxfmt --check and oxlint pass on the two changed files, and tsgo (the frontend typecheck) reports nothing.

Not run: the full frontend suite, the Python tests, the end-to-end suite and a production frontend build.

👋 First time contributor introduction

Hi, I'm Raunak, an AI software engineer in London with an MSc in Artificial Intelligence and about five years of production engineering, mostly Python and TypeScript. I build LLM agent systems and the evaluation pipelines around them. This is my first contribution to marimo.

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable). Not applicable: a small bug fix with no API change.
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes.

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes. No documentation covers this behavior.
  • Tests have been added for the changes made.

AI tools (Claude Code) assisted with this change; the bug was reproduced and the fix verified manually in the running app.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@burrows99

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@burrows99
burrows99 marked this pull request as ready for review November 16, 2026 11:08
Copilot AI balanced review requested due to automatic review settings November 16, 2026 11:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@mscolnick mscolnick added the bug Something isn't working label Nov 17, 2026
@Light2Dark

Copy link
Copy Markdown
Member

@burrows99 would you mind rebasing on main. It might resolve the CI issues.

@mscolnick
mscolnick merged commit af731ac into marimo-team:main Nov 17, 2026
4 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.25.3-dev416

@burrows99
burrows99 deleted the fix/variables-search-cell-ids branch November 17, 2026 23:25
Light2Dark pushed a commit that referenced this pull request Nov 23, 2026
**This pull request was authored by a coding agent.**

## 📝 Summary

Closes #11896

The table search in the Data sources panel filtered on the raw search
text. A trailing space (`orders `) emptied the list, and a search of
only a space hid every table while the clear button stayed hidden,
because that button already checks the trimmed value.

`TableList` now trims the search before matching, the same way the
schema and database expansion in `components/datasources/utils.ts`
already does. A whitespace-only search shows every table, like an empty
search, and `isSearching` follows the trimmed value too. Matching stays
case-insensitive. `TableList` renders both the Python dataframes and the
tables of each SQL schema, so both paths get the fix.

```mermaid
flowchart TD
    A[Search tables for orders plus a space] --> B{Table list}
    B -->|Before| C[No tables shown]
    B -->|After| D[orders shown]
```

Narrated recording, before then after (sound on):


https://github.com/user-attachments/assets/6795d57b-f46a-4885-9199-f9bfe7f66ccc

### Edge cases and unchanged behavior checked

Checked in the running editor (Vite dev server and `marimo edit` from
`main` at 9bdfb76, then this branch, same notebook with three polars
dataframes) and shown in the recording:

- Before: `orders` lists `orders`; `orders ` lists nothing; a single
space lists nothing and shows no clear button.
- After: `orders ` lists `orders`; a single space lists all three
tables.
- Edge case: leading spaces and capitals (` ORDER`) list `orders` and
`order_items`.
- Edge case: spaces on both sides (` customers `) list `customers`.
- Unchanged: a search with no match (`invoices`) lists no tables.
- Unchanged: the clear button empties the search and restores every
table.
- Unchanged: the Variables search below the Data sources section still
filters variables.

Covered by tests only: the SQL schema tables path, which renders the
same `TableList`.

### Tests

- `vitest run src/components/datasources/__tests__/table-list.test.tsx`:
6 passed. The two new tests fail on `main` (trailing and leading
whitespace, whitespace-only search) and pass on this branch.
- `vitest run src/components/datasources/`: 9 files, 82 tests passed.
- `oxfmt --check` and `oxlint` on the two changed files: clean.
- Not run: the full frontend suite, `make check` and the typecheck.

AI assistance (Claude Code) was used for this change; the bug was
reproduced and the fix verified manually in the running editor.

## 👋 First time contributor introduction

Hi, I'm Raunak, an AI software engineer in London with an MSc in
Artificial Intelligence and about five years of production engineering,
mostly Python and TypeScript. I build LLM agent systems and the
evaluation pipelines around them. My first marimo PR is #11895.

## 📋 Pre-Review Checklist
<!-- These checks need to be completed before a PR is reviewed -->

- [x] For large changes, or changes that affect the public API: this
change was discussed or approved through an issue, on
[Discord](https://marimo.io/discord?ref=pr), or the community
[discussions](https://github.com/marimo-team/marimo/discussions) (Please
provide a link if applicable). Not applicable: a small bug fix with no
API change.
- [x] Any AI generated code has been reviewed line-by-line by the human
PR author, who stands by it.
- [x] Video or media evidence is provided for any visual changes. <!--
PR is more likely to be merged if functionality is tested thoroughly -->

## ✅ Merge Checklist

- [x] I have read the [contributor
guidelines](https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md).
- [x] Documentation has been updated where applicable, including
docstrings for API changes. No documentation covers this behavior.
- [x] Tests have been added for the changes made.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants