Yjs: it feels like the shared state has diverged?

I believe you need to change this line.

-const document = titleText || "New project";
+const document = titleText.toString() || "New project";