Skip to content

Commit 2d0fef2

Browse files
authored
Hide progress indicator once interactive window has loaded (#11143)
* Hide progress when UI loads * News * Address code review
1 parent 5ae1861 commit 2d0fef2

File tree

6 files changed

+26
-2
lines changed

6 files changed

+26
-2
lines changed

news/2 Fixes/11065.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hide progress indicator once `Interactive Window` has loaded.

src/client/datascience/interactive-window/interactiveWindow.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,17 @@ export class InteractiveWindow extends InteractiveBase implements IInteractiveWi
274274
}
275275
return undefined;
276276
}
277+
protected async addSysInfo(reason: SysInfoReason): Promise<void> {
278+
await super.addSysInfo(reason);
279+
280+
// If `reason == Start`, then this means UI has been updated with the last
281+
// pience of informaiotn (which was sys info), and now UI can be deemed as having been loaded.
282+
// Marking a UI as having been loaded is done by sending a message `LoadAllCells`, even though we're not loading any cells.
283+
// We're merely using existing messages (from NativeEditor).
284+
if (reason === SysInfoReason.Start) {
285+
this.postMessage(InteractiveWindowMessages.LoadAllCells, { cells: [] }).ignoreErrors();
286+
}
287+
}
277288
protected async onViewStateChanged(args: WebViewViewChangeEventArgs) {
278289
super.onViewStateChanged(args);
279290
this._onDidChangeViewState.fire();

src/datascience-ui/history-react/interactivePanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class InteractivePanel extends React.Component<IInteractivePanelProps> {
5151
fontFamily: this.props.font.family
5252
};
5353

54-
const progressBar = this.props.busy && !this.props.testMode ? <Progress /> : undefined;
54+
const progressBar = (this.props.busy || !this.props.loaded) && !this.props.testMode ? <Progress /> : undefined;
5555

5656
// If in test mode, update our count. Use this to determine how many renders a normal update takes.
5757
if (this.props.testMode) {

src/datascience-ui/history-react/redux/reducers/creation.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,15 @@ export namespace Creation {
183183
editCellVM: undefined
184184
};
185185
}
186+
187+
export function loaded(arg: InteractiveReducerArg<{ cells: ICell[] }>): IMainState {
188+
postActionToExtension(arg, InteractiveWindowMessages.LoadAllCellsComplete, {
189+
cells: []
190+
});
191+
return {
192+
...arg.prevState,
193+
loaded: true,
194+
busy: false
195+
};
196+
}
186197
}

src/datascience-ui/history-react/redux/reducers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const reducerMap: Partial<IInteractiveActionMapping> = {
3434
[CommonActionType.SUBMIT_INPUT]: Execution.submitInput,
3535
[InteractiveWindowMessages.ExpandAll]: Effects.expandAll,
3636
[CommonActionType.EDITOR_LOADED]: Transfer.started,
37+
[InteractiveWindowMessages.LoadAllCells]: Creation.loaded,
3738
[CommonActionType.SCROLL]: Effects.scrolled,
3839
[CommonActionType.CLICK_CELL]: Effects.clickCell,
3940
[CommonActionType.UNFOCUS_CELL]: Effects.unfocusCell,

src/datascience-ui/native-editor/nativeEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class NativeEditor extends React.Component<INativeEditorProps> {
7979
}
8080

8181
// Update the state controller with our new state
82-
const progressBar = this.props.busy && !this.props.testMode ? <Progress /> : undefined;
82+
const progressBar = (this.props.busy || !this.props.loaded) && !this.props.testMode ? <Progress /> : undefined;
8383
const addCellLine =
8484
this.props.cellVMs.length === 0 ? null : (
8585
<AddCellLine

0 commit comments

Comments
 (0)