Skip to content

feat: static rendering - #67

Merged
trungleduc merged 13 commits into
mainfrom
snapshot
Aug 19, 2026
Merged

trungleduc merged 13 commits into
mainfrom
snapshot

Conversation

@trungleduc

@trungleduc trungleduc commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Static Rendering

By default Specta starts a kernel and re-executes the notebook every time a reader opens it. If the interactive features of the notebook are not important, you can save time and bandwidth by using the static rendering mode

Static rendering removes the kernel from the rendering process. You execute the notebook once while authoring and save a render cache: the outputs, plus the state of any ipywidgets in the document, are stored inside the notebook itself. When a reader later opens that notebook, Specta rebuilds the rendered document directly from the cache and never starts a kernel.

@trungleduc
trungleduc marked this pull request as ready for review August 18, 2026 12:22
@trungleduc
trungleduc requested a review from martinRenou August 18, 2026 12:22
@trungleduc

Copy link
Copy Markdown
Collaborator Author

@martinRenou @Yahiewi could you test this PR using instruction in the readme here. The blog.ipynb has a render cache already

@trungleduc
trungleduc requested a review from Yahiewi August 18, 2026 12:24
Comment thread src/snapshot/hash.ts
@martinRenou

martinRenou commented Aug 18, 2026

Copy link
Copy Markdown
Member

It seems to work nicely! I like the approach.

Of course, blog.ipynb through specta now will look "broken" since the buttons are not reactive anymore. So I wonder if you really want to keep the cache as part of this PR, or maybe in that notebook we remove the buttons.

</button>
<button
className="jp-mod-styled jp-mod-accept"
onClick={createSnapshot}

@martinRenou martinRenou Aug 18, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We may want to warn the user that anything that is callback-based will not work in pre-rendered notebooks. Through a tooltip or confirmation dialog

@Yahiewi Yahiewi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I've been testing and it works great for me. I have a few comments:
-It appears that when you click 'Save Cache', static rendering is automatically turned on next time you open the notebook. Wouldn't it be better to have a toggle between static rendering and kernel rendering because users may want to save cache but keep using the kernel?
-I agree with @martinRenou that we should have a warning if our notebook contains interactive widgets. We could have a confirmation dialog when selecting 'render statically' (or 'Save cache' as it is now) or we could also simply have a warning in the specta menu (maybe a little '?' icon to the right of 'Static rendering: On/Off').

@trungleduc

Copy link
Copy Markdown
Collaborator Author

Thanks for the feedback. I wanted to get the rendering mechanism part in first and address the QoLs later

@trungleduc

Copy link
Copy Markdown
Collaborator Author

It seems to work nicely! I like the approach.

Of course, blog.ipynb through specta now will look "broken" since the buttons are not reactive anymore. So I wonder if you really want to keep the cache as part of this PR, or maybe in that notebook we remove the buttons.

indeed, i will add another example for static rendering

@trungleduc
trungleduc merged commit 18d1e76 into main Aug 19, 2026
3 checks passed
@trungleduc
trungleduc deleted the snapshot branch August 19, 2026 07:52
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.

3 participants