Skip to content

Hide code input in CodeConsole when configured#18554

Merged
krassowski merged 3 commits intojupyterlab:mainfrom
agriyakhetarpal:jupyterlite-repl-code-hide-fix
Feb 25, 2026
Merged

Hide code input in CodeConsole when configured#18554
krassowski merged 3 commits intojupyterlab:mainfrom
agriyakhetarpal:jupyterlite-repl-code-hide-fix

Conversation

@agriyakhetarpal
Copy link
Copy Markdown
Member

@agriyakhetarpal agriyakhetarpal commented Feb 23, 2026

References

jupyterlite/jupyterlite#1866

Code changes

When creating a new cell in CodeConsole, I have added a this._config.hideCodeInput flag and hidden the cell's input area by calling cell.inputArea?.setHidden(true) before adding the cell. This should allow the console to hide cells that come from code URL parameters in JupyterLite when hideCodeInput is set.

cc: @jtpio @xess0fd00m

User-facing changes

Cells added via inject() were always visible regardless of the config, this should no longer be the case.

For testing, navigate to repl/index.html?kernel=python&hideCodeInput=1&code=import%20pandas%20as%20pd%0Afrom%20IPython.display%20import%20Markdown%2C%20display%0A%0Adisplay(Markdown(%27%27%27Loaded!!%27%27%27))

I tested this on Vivaldi 7.8.3925.73 (macOS arm64) based on Chromium version 144.0.7559.220.

Before

Screen.Recording.2026-02-24.at.03.49.35.mov

After

Screen.Recording.2026-02-24.at.03.51.34.mov

Backwards-incompatible changes

None; this PR makes no change to JupyterLab public APIs.

AI usage

  • NO: Some or all of the content of this PR was generated by AI.
  • YES: The human author has carefully reviewed this PR and run this code (keep this PR "draft" until the answer is YES)
  • AI tools and models used: None

@jupyterlab-probot
Copy link
Copy Markdown

Thanks for making a pull request to jupyterlab!
To try out this branch on binder, follow this link: Binder

@agriyakhetarpal
Copy link
Copy Markdown
Member Author

I have kept this PR as a draft for now because I have yet to test JupyterLite with this change. I'd like to ensure this is the right fix. Could I please receive some guidance about this? Perhaps we should have some instructions over in the JupyterLite repo...

@agriyakhetarpal
Copy link
Copy Markdown
Member Author

I have kept this PR as a draft for now because I have yet to test JupyterLite with this change. I'd like to ensure this is the right fix. Could I please receive some guidance about this? Perhaps we should have some instructions over in the JupyterLite repo...

Eventually, I ended up testing this by installing an editable version of JupyterLab into my JupyterLite deployment via jlpm build --scope @jupyterlab/services and then manually going into node_modules/@jupyterlab/console/lib/widget.js and adding this patch, as that turned out to be the quickest way 😅

Nevertheless, I can confirm this PR works (I added a video to the PR description). This is ready for review!

@agriyakhetarpal agriyakhetarpal marked this pull request as ready for review February 23, 2026 22:26
@jtpio jtpio added the bug label Feb 24, 2026
@jtpio jtpio added this to the 4.5.x milestone Feb 24, 2026
@krassowski
Copy link
Copy Markdown
Member

Would it be possible to cover it in test suite it by adding a test similar to:

it('should hide code input when hideCodeInput is true', async () => {
Widget.attach(widget, document.body);
await widget.sessionContext.initialize();
// Set config to hide input
widget.setConfig({ hideCodeInput: true });
// Execute some code
const cell = widget.promptCell!;
const testCode = 'print(1 + 1)';
cell.model.sharedModel.setSource(testCode);
await widget.execute(true);
// Check the input is not visible in the executed cells
for (const cell of widget.cells) {
expect(cell.inputArea!.node.classList.contains('lm-mod-hidden')).toBe(
true
);
}
});

@agriyakhetarpal
Copy link
Copy Markdown
Member Author

Yes, of course, done. Note that this is essentially the same test as the #setConfig() case, but for #inject().

Copy link
Copy Markdown
Member

@krassowski krassowski left a comment

Choose a reason for hiding this comment

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

Verified that the test fails before and passes after, thank you @agriyakhetarpal!

@krassowski krassowski merged commit c346846 into jupyterlab:main Feb 25, 2026
130 of 133 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/jupyterlab that referenced this pull request Feb 25, 2026
@agriyakhetarpal agriyakhetarpal deleted the jupyterlite-repl-code-hide-fix branch February 25, 2026 11:15
krassowski pushed a commit that referenced this pull request Feb 25, 2026
…` when configured) (#18565)

Backport PR #18554: Hide `code` input in `CodeConsole` when configured

Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants