Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix outputarea package from not detecting updates #15642

Merged
merged 4 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/outputarea/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,9 @@ export class OutputArea extends Widget {
}
const panel = this.layout.widgets[index] as Panel;
const renderer = (
panel.widgets ? panel.widgets[1] : panel
panel.widgets
? panel.widgets.filter(it => 'renderModel' in it).pop()
: panel
) as IRenderMime.IRenderer;
// Check whether it is safe to reuse renderer:
// - Preferred mime type has not changed
Expand Down
24 changes: 23 additions & 1 deletion packages/outputarea/test/widget.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { createSessionContext } from '@jupyterlab/apputils/lib/testutils';
import {
IOutputAreaModel,
OutputArea,
OutputAreaModel
OutputAreaModel,
SimplifiedOutputArea
} from '@jupyterlab/outputarea';
import { KernelManager } from '@jupyterlab/services';
import { JupyterServer } from '@jupyterlab/testing';
Expand Down Expand Up @@ -436,6 +437,27 @@ describe('outputarea/widget', () => {
widget1.dispose();
await ipySessionContext.shutdown();
});

it('should continuously render delayed outputs', async () => {
const model0 = new OutputAreaModel({ trusted: true });
const widget0 = new SimplifiedOutputArea({
model: model0,
rendermime: rendermime
});
let ipySessionContext: SessionContext;
ipySessionContext = await createSessionContext({
kernelPreference: { name: 'python3' }
});
await ipySessionContext.initialize();
const code = [
'import time',
'for i in range(3):',
' print(f"Hello Jupyter! {i}")',
' time.sleep(1)'
].join('\n');
await SimplifiedOutputArea.execute(code, widget0, ipySessionContext);
expect(model0.toJSON()[0].text).toBe(widget0.node.textContent);
});
});

describe('.ContentFactory', () => {
Expand Down