Skip to content

Synchronously create cell-scoped context key service#13797

Open
seeM wants to merge 1 commit into
mainfrom
refactor/cell-context-key-service
Open

Synchronously create cell-scoped context key service#13797
seeM wants to merge 1 commit into
mainfrom
refactor/cell-context-key-service

Conversation

@seeM
Copy link
Copy Markdown
Contributor

@seeM seeM commented May 27, 2026

Toward #10466

The main change here is to create the cell-scoped context key in the callback ref i.e. synchronously during render, rather than async via React state & effects. While doing that, I took the opportunity to move cell context key management out of the React layer and into the model layer. (Let me know if you disagree.)

I believe callback refs synchronously block rendering, but the work done here is super cheap and shouldn't degrade performance. It will, however, let us scope the cell editor's context key service to the cell without having to wait a few render cycles for the cell context key service to become available (which is the fix for #10466). I'll make that fix in a separate PR.

Release Notes

New Features

  • N/A

Bug Fixes

  • N/A

Validation Steps

@:positron-notebooks @:web

  1. Open a notebook with multiple cells
  2. Run cells and verify context-dependent actions (action bar, right-click menus) still reflect correct state
  3. Verify cell selection, move up/down, and output collapse still work

@seeM seeM requested a review from nstrayer May 27, 2026 14:33
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 27, 2026

E2E Tests 🚀
This PR will run tests tagged with: @:critical @:positron-notebooks @:web

readme  valid tags

nstrayer
nstrayer previously approved these changes May 27, 2026
Copy link
Copy Markdown
Contributor

@nstrayer nstrayer left a comment

Choose a reason for hiding this comment

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

I like this. Part of me wants to complete the migration and put outputFocused, outputOverflows, outputImageTargeted and outputJsonTargeted into this class as well but I think that wouldnt actually improve the abstraction, just add more forwarding code.

Seems good to me!

Base automatically changed from refactor/extract-context-key-declarations to main May 27, 2026 19:50
@seeM seeM dismissed nstrayer’s stale review May 27, 2026 19:50

The base branch was changed.

@seeM seeM force-pushed the refactor/cell-context-key-service branch from 3d6b004 to 523ba5e Compare May 27, 2026 19:51
@seeM
Copy link
Copy Markdown
Contributor Author

seeM commented May 27, 2026

Ah good point. It might be possible to push that logic (or at least some it) into the class too. I'll take a look

Replaces the useCellContextKeys hook with a CellContextKeyManager that is
created when the cell container is attached. This moves context key lifecycle
management out of the React layer and into the cell model, keeping the scoped
context key service on the cell instance for consumers to access directly.
@seeM seeM force-pushed the refactor/cell-context-key-service branch from 523ba5e to 357e4f8 Compare May 28, 2026 15:50
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.

2 participants