Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add toggle to hide reusable functions from dependency graph#8228

Merged
mscolnick merged 5 commits intomarimo-team:mainfrom
AhmadYasser1:feat/hide-reusable-functions-graph
Feb 10, 2026
Merged

feat: add toggle to hide reusable functions from dependency graph#8228
mscolnick merged 5 commits intomarimo-team:mainfrom
AhmadYasser1:feat/hide-reusable-functions-graph

Conversation

Copy link
Contributor

AhmadYasser1 commented Feb 8, 2026

Summary

Adds a Hide reusable functions checkbox to the dependency graph settings panel, following the existing Hide pure markdown pattern. When enabled, cells whose code starts with def (reusable function cells) without edges are hidden from the graph.

Closes #5007

Test Plan

  • Checkbox toggles visibility in graph settings panel
  • Follows existing hidePureMarkdown pattern

zilto reacted with heart emoji
AhmadYasser1 and others added 2 commits February 8, 2026 03:27
Add a "Hide reusable functions" checkbox to the dependency graph settings
panel, following the same pattern as the existing "Hide pure markdown"
toggle. Cells whose code starts with `def ` (i.e., @app.function cells)
can now be hidden from the graph to reduce visual complexity.

Closes marimo-team#5007
AhmadYasser1 requested review from Light2Dark and manzt as code owners February 8, 2026 20:04
Copy link

vercel bot commented Feb 8, 2026 *
edited
Loading

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Preview, Comment Feb 10, 2026 2:35am

...lass

Use a regex to match `def `, `async def `, and `class ` at the start
of cell code, covering all reusable definition types.
vercel bot deployed to Preview February 8, 2026 20:10 View deployment
mscolnick reviewed Feb 9, 2026
if (hasEdge || !isMarkdown) {
nodes.push(this.createNode(cellId, cellAtom));
const isMarkdown = code.startsWith("mo.md");
const isReusableFunction = /^(async\s+def|def|class)\s/.test(code);
Copy link
Contributor

mscolnick Feb 9, 2026

Choose a reason for hiding this comment

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

there is better indicators to go off of to check if its re-usable. we can check the serialization from the cellRuntime.

i think we can check cellRuntime.serialization.toLowercase() === "valid"

Replace regex-based detection with cellRuntime.serialization check
as suggested by maintainer. A cell is considered reusable when its
serialization status is "valid", which is more reliable than pattern
matching on the code text.
Copy link
Contributor Author

AhmadYasser1 commented Feb 10, 2026

good call, switched to checking `cellRuntime.serialization?.toLowerCase() === "valid"` instead of the regex. much more reliable.

vercel bot deployed to Preview February 10, 2026 02:33 View deployment
vercel bot deployed to Preview February 10, 2026 02:35 View deployment
mscolnick requested a review from Copilot February 10, 2026 03:00
Copilot started reviewing on behalf of mscolnick February 10, 2026 03:01 View session
mscolnick added the enhancement New feature or request label Feb 10, 2026
Copy link
Contributor

mscolnick commented Feb 10, 2026

great addition, thank you @AhmadYasser1 !

AhmadYasser1 reacted with heart emoji

Copilot AI reviewed Feb 10, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new dependency-graph setting to optionally hide "reusable" definition cells (based on the existing "Hide pure markdown" pattern) to reduce graph clutter and improve readability.

Changes:

  • Extends GraphSettings with hideReusableFunctions and wires it through the dependency graph components.
  • Adds a new checkbox to the dependency graph settings popover.
  • Updates the tree elements builder to filter out reusable-definition cells (when enabled) that have no edges.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
frontend/src/components/dependency-graph/types.ts Extends GraphSettings with hideReusableFunctions.
frontend/src/components/dependency-graph/panels.tsx Adds "Hide reusable functions" checkbox to the settings panel UI.
frontend/src/components/dependency-graph/elements.ts Implements filtering logic for markdown-only and reusable-definition cells without edges.
frontend/src/components/dependency-graph/dependency-graph.tsx Initializes the new setting with a default value.
frontend/src/components/dependency-graph/dependency-graph-tree.tsx Threads the new setting into element creation and effect dependencies.

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +183 to +186
const isMarkdown = code.startsWith("mo.md");
const runtime = cellRuntime[cellId];
const isReusable = runtime?.serialization?.toLowerCase() === "valid";

Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

isReusable is inferred from cellRuntime.serialization === "valid", but serialization hints are only broadcast in the post-execution hook (render_toplevel_defs). This means the new setting won't hide reusable-definition cells until after they've been executed at least once, and it also diverges from the PR description ("code starts with def "). Consider deriving the filter from the cell's source code (e.g., first top-level def/class) or otherwise ensuring the reusable-ness signal is available without relying on post-execution runtime state.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

mscolnick Feb 10, 2026

Choose a reason for hiding this comment

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

ignore

Comment on lines 91 to +108
useEffect(() => {
syncChanges(
elementsBuilder.createElements(
cellIds,
cellAtoms,
variables,
settings.hidePureMarkdown,
settings.hideReusableFunctions,
),
);
}, [cellIds, variables, cellAtoms, syncChanges, settings.hidePureMarkdown]);
}, [
cellIds,
variables,
cellAtoms,
syncChanges,
settings.hidePureMarkdown,
settings.hideReusableFunctions,
]);
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

TreeElementsBuilder.createElements now depends on cellRuntime (via getNotebook()), but this component doesn't subscribe to runtime changes. As a result, when a cell's serialization hint updates (e.g., after executing a cell), the graph won't recompute/filter nodes unless some other dependency changes. Consider wiring cellsRuntimeAtom (or equivalent) into the dependency graph component tree and including it as an input to createElements / effect deps so the graph stays in sync.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

mscolnick Feb 10, 2026

Choose a reason for hiding this comment

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

this is ok to ignore

}
/>
Hide reusable functions
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

The UI label and setting name say "Hide reusable functions", but the underlying signal (serialization === "Valid") is used for both reusable functions and reusable classes (the editor tooltip explicitly says "function or class"). Consider renaming the setting/label to "Hide reusable definitions" (or similar) to match the actual behavior and avoid confusing users.

Suggested change
Hide reusable functions
Hide reusable definitions

Copilot uses AI. Check for mistakes.
Copy link
Contributor

mscolnick Feb 10, 2026

Choose a reason for hiding this comment

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

this is ok to ignore as well

mscolnick merged commit 6981ab7 into marimo-team:main Feb 10, 2026
31 of 32 checks passed
AhmadYasser1 deleted the feat/hide-reusable-functions-graph branch February 10, 2026 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

mscolnick mscolnick left review comments

Copilot code review Copilot Copilot left review comments

manzt Awaiting requested review from manzt manzt is a code owner

Light2Dark Awaiting requested review from Light2Dark Light2Dark is a code owner

Assignees

No one assigned

Labels

enhancement New feature or request

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Hide reusable function from dependency graph.

3 participants