Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@
"view/item/context": [
{
"command": "deepnote.revealInExplorer",
"when": "view == deepnoteExplorer",
"when": "view == deepnoteExplorer && viewItem != loading",
"group": "inline@2"
}
]
Expand Down
38 changes: 37 additions & 1 deletion src/notebooks/deepnote/deepnoteTreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
workspace,
RelativePattern,
Uri,
FileSystemWatcher
FileSystemWatcher,
ThemeIcon
} from 'vscode';
import * as yaml from 'js-yaml';

Expand All @@ -26,6 +27,8 @@ export class DeepnoteTreeDataProvider implements TreeDataProvider<DeepnoteTreeIt

private fileWatcher: FileSystemWatcher | undefined;
private cachedProjects: Map<string, DeepnoteProject> = new Map();
private isInitialScanComplete: boolean = false;
private initialScanPromise: Promise<void> | undefined;

constructor() {
this.setupFileWatcher();
Expand All @@ -38,6 +41,8 @@ export class DeepnoteTreeDataProvider implements TreeDataProvider<DeepnoteTreeIt

public refresh(): void {
this.cachedProjects.clear();
this.isInitialScanComplete = false;
this.initialScanPromise = undefined;
this._onDidChangeTreeData.fire();
}

Expand All @@ -51,6 +56,15 @@ export class DeepnoteTreeDataProvider implements TreeDataProvider<DeepnoteTreeIt
}

if (!element) {
if (!this.isInitialScanComplete) {
if (!this.initialScanPromise) {
this.initialScanPromise = this.performInitialScan();
}

// Show loading item
return [this.createLoadingTreeItem()];
}

return this.getDeepnoteProjectFiles();
}

Expand All @@ -61,6 +75,28 @@ export class DeepnoteTreeDataProvider implements TreeDataProvider<DeepnoteTreeIt
return [];
}

private createLoadingTreeItem(): DeepnoteTreeItem {
const loadingItem = new DeepnoteTreeItem(
DeepnoteTreeItemType.Loading,
{ filePath: '', projectId: '' },
null,
TreeItemCollapsibleState.None
);
loadingItem.label = 'Scanning for Deepnote projects...';
loadingItem.iconPath = new ThemeIcon('loading~spin');
return loadingItem;
}

private async performInitialScan(): Promise<void> {
try {
await this.getDeepnoteProjectFiles();
} finally {
this.isInitialScanComplete = true;
this.initialScanPromise = undefined;
this._onDidChangeTreeData.fire();
}
}

private async getDeepnoteProjectFiles(): Promise<DeepnoteTreeItem[]> {
const deepnoteFiles: DeepnoteTreeItem[] = [];

Expand Down
17 changes: 11 additions & 6 deletions src/notebooks/deepnote/deepnoteTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import type { DeepnoteProject, DeepnoteNotebook } from '../../platform/deepnote/
*/
export enum DeepnoteTreeItemType {
ProjectFile = 'projectFile',
Notebook = 'notebook'
Notebook = 'notebook',
Loading = 'loading'
}

/**
Expand All @@ -25,16 +26,20 @@ export class DeepnoteTreeItem extends TreeItem {
constructor(
public readonly type: DeepnoteTreeItemType,
public readonly context: DeepnoteTreeItemContext,
public readonly data: DeepnoteProject | DeepnoteNotebook,
public readonly data: DeepnoteProject | DeepnoteNotebook | null,
collapsibleState: TreeItemCollapsibleState
) {
super('', collapsibleState);

this.contextValue = this.type;
this.tooltip = this.getTooltip();
this.iconPath = this.getIcon();
this.label = this.getLabel();
this.description = this.getDescription();

// Skip initialization for loading items as they don't have real data
if (this.type !== DeepnoteTreeItemType.Loading) {
this.tooltip = this.getTooltip();
this.iconPath = this.getIcon();
this.label = this.getLabel();
this.description = this.getDescription();
}

if (this.type === DeepnoteTreeItemType.Notebook) {
this.resourceUri = this.getNotebookUri();
Expand Down