Skip to content

feat: make notebook output display limit configurable via - #325792

Open
pandupan wants to merge 5 commits into
microsoft:mainfrom
pandupan:fix/notebook-output-configurable-limit
Open

feat: make notebook output display limit configurable via #325792
pandupan wants to merge 5 commits into
microsoft:mainfrom
pandupan:fix/notebook-output-configurable-limit

Conversation

@pandupan

Copy link
Copy Markdown

Description

This PR adds a new setting notebook.output.maxItems that allows users to configure the maximum number of output items rendered per notebook cell.

Problem

The notebook output display limit is hard-coded to 500 output items. When a cell produces more outputs than this limit, a message appears:

"There are more than 500 outputs, show more (open the raw output data in a text editor)"

This affects many real-world use cases:

  • ML training loops — printing epoch/loss metrics each iteration
  • Data processing pipelines — logging progress for thousands of items
  • Debugging with logging — cells mixing print() and logging
  • Progress bars (tqdm) — each update creates a new output item

Additionally, the "show more" link often fails with an error (#226261), leaving users with no way to view their truncated output.

Solution

Add a new configurable setting:

"notebook.output.maxItems": 500
Property Value
Type number
Default 500 (backward compatible)
Minimum 1
Maximum 10000
Tags notebookOutputLayout

Implementation

The hard-coded outputDisplayLimit = 500 constant is preserved as a fallback default. Each usage site now reads from the configuration service first:

const outputDisplayLimit = configurationService.getValue<number>(NotebookSetting.outputDisplayLimit) || defaultOutputDisplayLimit;

Files Changed

File Change
notebookCommon.ts Add outputDisplayLimit key to NotebookSetting enum
notebook.contribution.ts Register setting schema with description, type, default, min, max
codeCell.ts Read limit from IConfigurationService
notebookEditorWidget.ts Read limit from IConfigurationService
viewportWarmup.ts Inject IConfigurationService, read limit from config

Testing

  1. Open VS Code with a notebook
  2. Add "notebook.output.maxItems": 1000 to settings
  3. Run a cell that produces >500 outputs:
    for i in range(1000):
        print(f"Iteration {i}")
  4. Verify all 1000 outputs are rendered without truncation
  5. Verify default behavior (500) still works when setting is not configured

Related Issues


Note: The npm install step timed out during local testing due to the large repo size. The CI pipeline will handle the full build verification. The changes follow the exact same patterns used by other notebook output settings (e.g., notebook.output.textLineLimit, notebook.output.scrolling).

Add new setting 'notebook.output.maxItems' (default: 500) to allow users
to configure the maximum number of output items rendered per notebook cell.

Previously, the output display limit was hard-coded to 500 with no way to
increase it. This caused issues for users with cells that produce many
outputs (e.g., ML training loops, data processing pipelines, logging).

The new setting:
- Default: 500 (backward compatible)
- Minimum: 1
- Maximum: 10000
- Tagged under 'notebookOutputLayout'

Files changed:
- notebookCommon.ts: Add setting key to NotebookSetting enum
- notebook.contribution.ts: Register setting schema
- codeCell.ts: Read limit from configuration service
- notebookEditorWidget.ts: Read limit from configuration service
- viewportWarmup.ts: Inject IConfigurationService, read limit from config

Fixes microsoft#325786
Related: microsoft#228857, microsoft#226261
Copilot AI review requested due to automatic review settings July 14, 2026 13:11

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.

Pull request overview

Adds a configurable notebook cell output-rendering limit while preserving the existing default of 500.

Changes:

  • Registers notebook.output.maxItems with bounds of 1–10,000.
  • Applies the configured limit to cell rendering and output warmup paths.

Reviewed changes

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

Show a summary per file
File Description
notebookCommon.ts Defines the setting key.
codeCell.ts Passes the configured limit to output rendering.
notebookEditorWidget.ts Applies the limit during output warmup.
notebook.contribution.ts Registers the setting schema.
viewportWarmup.ts Applies the limit during viewport warmup.

Comment on lines +76 to 77
const outputDisplayLimit = this.configurationService.getValue<number>(NotebookSetting.outputDisplayLimit) || defaultOutputDisplayLimit;
this._outputContainerRenderer = this.instantiationService.createInstance(CellOutputContainer, notebookEditor, viewCell, templateData, { limit: outputDisplayLimit });
},
[NotebookSetting.outputDisplayLimit]: {
markdownDescription: nls.localize('notebook.output.maxItems', "Controls the maximum number of output items to render per notebook cell. When a cell produces more outputs than this limit, a \"show more\" message is displayed. Increase this value if your cell outputs are being truncated."),
type: 'number',
@pandupan

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Address Copilot review: change type from 'number' to 'integer'
since output item count must be a whole number. Fractional values
would cause inconsistent behavior between rendering paths.
@pandupan

Copy link
Copy Markdown
Author

Thanks for the review, Copilot!

Comment 1 (integer type): Fixed! Changed type: 'number' to type: 'integer' since output item count must be a whole number.

Comment 2 (construction-time read): Good observation. I followed the same pattern as the existing notebook.output.textLineLimit setting, which is also read at construction time in the same CodeCell constructor and doesn't have a dynamic update subscription. The setting takes effect on newly rendered cells — consistent with how other notebook output settings work. Users can also reload the window to apply to all cells immediately.

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.

Make notebook cell output item limit (500) configurable via setting

3 participants