Skip to content

Commit 1d28589

Browse files
committed
don't count a jupyter notebook as opened until cells appear -- i.e., make the metric we're tracking much harsher to improve user experience; making opening notebooks faster
1 parent c27351f commit 1d28589

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

src/packages/frontend/jupyter/browser-actions.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,7 @@ export class JupyterActions extends JupyterActions0 {
153153
}
154154
});
155155

156-
// Put an entry in the project log once the jupyter notebook gets opened.
157-
// NOTE: Obviously, the project does NOT need to put entries in the log.
158-
this.syncdb.once("change", () =>
159-
this.redux?.getProjectActions(this.project_id).log_opened_time(this.path),
160-
);
156+
this.initOpenLog();
161157

162158
// project doesn't care about cursors, but browser clients do:
163159
this.syncdb.on("cursor_activity", this.syncdb_cursor_activity);
@@ -176,6 +172,23 @@ export class JupyterActions extends JupyterActions0 {
176172
}
177173
}
178174

175+
initOpenLog = () => {
176+
// Put an entry in the project log once the jupyter notebook gets opened and
177+
// shows cells.
178+
const reportOpened = () => {
179+
if (this._state == "closed") {
180+
return;
181+
}
182+
if (this.syncdb.get_one({ type: "cell" }) != null) {
183+
this.redux
184+
?.getProjectActions(this.project_id)
185+
.log_opened_time(this.path);
186+
this.syncdb.removeListener("change", reportOpened);
187+
}
188+
};
189+
this.syncdb.on("change", reportOpened);
190+
};
191+
179192
initUsageInfo = async () => {
180193
while (this._state != "closed") {
181194
try {

src/packages/sync/editor/generic/sync-doc.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,14 +1027,11 @@ export class SyncDoc extends EventEmitter {
10271027
this.assert_table_is_ready("syncstring");
10281028
this.dbg("set_initialized")({ error, read_only, size });
10291029
const init = { time: this.client.server_time(), size, error };
1030-
for (let i = 0; i < 3; i++) {
1031-
await this.set_syncstring_table({
1032-
init,
1033-
read_only,
1034-
last_active: this.client.server_time(),
1035-
});
1036-
await delay(1000);
1037-
}
1030+
await this.set_syncstring_table({
1031+
init,
1032+
read_only,
1033+
last_active: this.client.server_time(),
1034+
});
10381035
};
10391036

10401037
/* List of logical timestamps of the versions of this string in the sync
@@ -1463,7 +1460,7 @@ export class SyncDoc extends EventEmitter {
14631460
log("update interest");
14641461
this.initInterestLoop();
14651462

1466-
log("ensure syncstring exists in database (if not using NATS)");
1463+
log("ensure syncstring exists");
14671464
this.assert_not_closed("initAll -- before ensuring syncstring exists");
14681465
await this.ensure_syncstring_exists_in_db();
14691466

src/packages/util/smc-version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
/* autogenerated by the update_version script */
2-
exports.version=1752418521;
2+
exports.version=1752527312;

0 commit comments

Comments
 (0)