diff --git a/modules/rdocs/components/folk-docs-app.ts b/modules/rdocs/components/folk-docs-app.ts index e2929980..6ddb0d89 100644 --- a/modules/rdocs/components/folk-docs-app.ts +++ b/modules/rdocs/components/folk-docs-app.ts @@ -690,6 +690,8 @@ Gear: EUR 400 (10%)
Maya is tracking expenses in rF
this.doc = null;
for (const unsub of this._offlineNotebookUnsubs) unsub();
this._offlineNotebookUnsubs = [];
+ // Clear viewId so overlay stops filtering cursors
+ window.dispatchEvent(new CustomEvent('rspace-view-change', { detail: { viewId: null } }));
}
/** Extract notebook + notes from Automerge doc into component state */
@@ -1477,6 +1479,10 @@ Gear: EUR 400 (10%) Maya is tracking expenses in rF
this.renderMeta();
this.mountEditor(this.selectedNote);
this.broadcastPresence();
+ // Notify overlay which sub-document we're viewing (scopes SVG cursors)
+ window.dispatchEvent(new CustomEvent('rspace-view-change', {
+ detail: { viewId: this.selectedNote.id, viewLabel: this.selectedNote.title },
+ }));
}
}
diff --git a/shared/components/rstack-collab-overlay.ts b/shared/components/rstack-collab-overlay.ts
index 03115141..56344859 100644
--- a/shared/components/rstack-collab-overlay.ts
+++ b/shared/components/rstack-collab-overlay.ts
@@ -34,6 +34,7 @@ interface PeerState {
lastSeen: number;
module?: string; // which rApp they're in
context?: string; // human-readable view label (e.g. "My Notebook > Note Title")
+ viewId?: string | null; // sub-document view (e.g. noteId) — cursors hidden when mismatched
}
export class RStackCollabOverlay extends HTMLElement {
@@ -60,6 +61,7 @@ export class RStackCollabOverlay extends HTMLElement {
#openActionsId: string | null = null; // which peer's actions dropdown is open
#spaceMembers: { did: string; displayName: string; role: string }[] = [];
#space: string | null = null;
+ #viewId: string | null = null; // sub-document view filter (e.g. noteId)
constructor() {
super();
@@ -102,12 +104,16 @@ export class RStackCollabOverlay extends HTMLElement {
this.#tryConnect();
}
+ // Listen for sub-document view changes (e.g. rDocs note navigation)
+ window.addEventListener('rspace-view-change', this.#onViewChange);
+
// Click-outside closes panel (listen on document, check composedPath for shadow DOM)
document.addEventListener('click', this.#onDocumentClick);
}
disconnectedCallback() {
document.removeEventListener('click', this.#onDocumentClick);
+ window.removeEventListener('rspace-view-change', this.#onViewChange);
if (!this.#externalPeers) {
window.removeEventListener('rspace-doc-subscribe', this.#onDocSubscribe);
this.#unsubAwareness?.();
@@ -171,6 +177,19 @@ export class RStackCollabOverlay extends HTMLElement {
}
};
+ #onViewChange = (e: Event) => {
+ const { viewId } = (e as CustomEvent).detail ?? {};
+ this.#viewId = viewId || null;
+ // Re-broadcast so peers learn our current viewId
+ this.#broadcastPresence(this.#lastCursor, undefined);
+ // Re-render cursors immediately (hides/shows based on new viewId)
+ if (!this.#badgeOnly) {
+ this.#renderCursors();
+ this.#renderFocusRings();
+ }
+ if (this.#panelOpen) this.#renderPanel();
+ };
+
// ── Runtime connection ──
#runtimePollInterval: ReturnType