Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
fix: forked notes and offline notes
Chadpiha73cbf304b92a
diff --git a/src/components/notes/NoteEditor.tsx b/src/components/notes/NoteEditor.tsxindex 46d6b0b9b..447035a89 100644--- a/src/components/notes/NoteEditor.tsx+++ b/src/components/notes/NoteEditor.tsx@@ -25,7 +25,11 @@ import {Users,} from "lucide-react";import ShareNoteDialog from "./ShareNoteDialog";-import { noteCapabilities, resolveNotePermission } from "../../lib/notePermissions";+import {+ noteCapabilities,+ resolveNotePermission,+ type NoteAclState,+} from "../../lib/notePermissions";import SpaceMembersDialog from "./SpaceMembersDialog";import {useShareCacheEntry,@@ -241,6 +245,11 @@ export default function NoteEditor({const [isDiarizing, setIsDiarizing] = useState(false);const [shareDialogOpen, setShareDialogOpen] = useState(false);const [membersDialogOpen, setMembersDialogOpen] = useState(false);+ const [aclRetryVersion, setAclRetryVersion] = useState(0);+ const [aclRequest, setAclRequest] = useState<{+ cloudId: string;+ state: Extract<NoteAclState, "loading" | "unavailable">;+ } | null>(null);const { isSignedIn, user } = useAuth();const shareCache = useShareCacheEntry(note.cloud_id);const spaces = useSpaces();@@ -255,21 +264,31 @@ export default function NoteEditor({// Same gate as SyncService.canSyncSharedNotes: sharing needs a subscription.// An already-shared note stays manageable (unshare/revoke) after a lapse.const isSubscribed = useSyncExternalStore(subscribeIsSubscribed, readIsSubscribed);+ const aclState: NoteAclState = shareCache+ ? "loaded"+ : !note.cloud_id || !isSignedIn+ ? "unavailable"+ : aclRequest?.cloudId === note.cloud_id+ ? aclRequest.state+ : "loading";const shareCapabilities = noteCapabilities(resolveNotePermission({cachedPermission: shareCache?.access?.my_permission,- shareStateLoaded: shareCache !== null,+ aclState,isTeamNote,- hasCloudId: Boolean(note.cloud_id),}));const canShare =- isSignedIn && shareCapabilities.canShare && (isSubscribed || Boolean(note.is_shared));+ isSignedIn &&+ (!note.cloud_id || isTeamNote || aclState === "loaded") &&+ shareCapabilities.canShare &&+ (isSubscribed || Boolean(note.is_shared));const canEditNote = shareCapabilities.canEdit;useEffect(() => {if (!isSignedIn || !note.cloud_id || shareCache) return;const cloudId = note.cloud_id;let cancelled = false;+ setAclRequest({ cloudId, state: "loading" });NoteSharingService.getShareSettings(cloudId).then((res) => {if (cancelled) return;@@ -287,11 +306,29 @@ export default function NoteEditor({).catch((err) => console.error("Share flag persist failed:", err));}})- .catch((err) => console.error("Failed to load note permissions:", err));+ .catch((err) => {+ if (cancelled) return;+ setAclRequest({ cloudId, state: "unavailable" });+ console.error("Failed to load note permissions:", err);+ });return () => {cancelled = true;};- }, [isSignedIn, note.cloud_id, note.id, note.is_shared, shareCache]);+ }, [aclRetryVersion, isSignedIn, note.cloud_id, note.id, note.is_shared, shareCache]);+ useEffect(() => {+ if (+ !isSignedIn ||+ !note.cloud_id ||+ shareCache ||+ aclRequest?.cloudId !== note.cloud_id ||+ aclRequest.state !== "unavailable"+ ) {+ return;+ }+ const retryWhenOnline = () => setAclRetryVersion((version) => version + 1);+ window.addEventListener("online", retryWhenOnline);+ return () => window.removeEventListener("online", retryWhenOnline);+ }, [aclRequest, isSignedIn, note.cloud_id, shareCache]);// A newer cloud copy arrived while this note had unpushed edits (plan §7.3).const conflict = useNoteConflict(note.client_note_id);const [conflictEditorName, setConflictEditorName] = useState<string | null>(null);diff --git a/src/helpers/database.js b/src/helpers/database.jsindex 0507f6eb9..a69bf2e50 100644--- a/src/helpers/database.js+++ b/src/helpers/database.js@@ -2369,7 +2369,7 @@ class DatabaseManager {.map((row) => row.id);if (preservedIds.length > 0) {const relocateNote = this.db.prepare(- "UPDATE notes SET space_id = ?, folder_id = NULL, client_note_id = ?, cloud_id = NULL, sync_status = 'pending', left_team = 0, updated_at = datetime('now') WHERE id = ?"+ "UPDATE notes SET space_id = ?, folder_id = NULL, client_note_id = ?, cloud_id = NULL, sync_status = 'pending', left_team = 0, is_shared = 0, share_token = NULL, updated_at = datetime('now') WHERE id = ?");for (const noteId of preservedIds) {relocateNote.run(privateSpaceId, randomUUID(), noteId);@@ -3842,7 +3842,7 @@ class DatabaseManager {this._deleteSpeakerRowsForNotes(serverOwnedChildren, id);this.db.prepare(`DELETE FROM notes WHERE id IN (${serverOwnedChildren})`).run(id);const relocateNote = this.db.prepare(- "UPDATE notes SET space_id = ?, folder_id = ?, client_note_id = ?, cloud_id = NULL, sync_status = 'pending', left_team = 0, updated_at = datetime('now') WHERE id = ?"+ "UPDATE notes SET space_id = ?, folder_id = ?, client_note_id = ?, cloud_id = NULL, sync_status = 'pending', left_team = 0, is_shared = 0, share_token = NULL, updated_at = datetime('now') WHERE id = ?");for (const noteId of preservedIds) {relocateNote.run(privateSpaceId, preserveFolder ? id : null, randomUUID(), noteId);diff --git a/src/lib/notePermissions.ts b/src/lib/notePermissions.tsindex 697a4c7f7..f071d1c37 100644--- a/src/lib/notePermissions.ts+++ b/src/lib/notePermissions.ts@@ -9,6 +9,8 @@ export interface NoteCapabilities {canTransferOwnership: boolean;}+export type NoteAclState = "loading" | "loaded" | "unavailable";+const NO_ACCESS: NoteCapabilities = {canView: false,canEdit: false,@@ -55,20 +57,19 @@ export function noteCapabilities(export function resolveNotePermission({cachedPermission,- shareStateLoaded,+ aclState,isTeamNote,- hasCloudId,}: {cachedPermission?: NotePermission;- shareStateLoaded: boolean;+ aclState: NoteAclState;isTeamNote: boolean;- hasCloudId: boolean;}): NotePermission | null {if (cachedPermission) return cachedPermission;// A personal cloud note may belong to this user or may be a view-only grant.- // Until its ACL loads, fail closed instead of temporarily granting owner- // controls. A loaded legacy response has no ACL, so retain the old ownership- // fallback for compatibility with servers that predate note permissions.- if (hasCloudId && !isTeamNote && !shareStateLoaded) return null;+ // Fail closed only while an authenticated ACL request is active, rather+ // than making the local editor permanently read-only while signed out or+ // offline. Loaded legacy responses and unavailable ACLs retain the old+ // ownership fallback for compatibility and offline editing.+ if (!isTeamNote && aclState === "loading") return null;return isTeamNote ? "editor" : "owner";}diff --git a/test/helpers/notePermissions.test.js b/test/helpers/notePermissions.test.jsindex 056c45825..c2db3da47 100644--- a/test/helpers/notePermissions.test.js+++ b/test/helpers/notePermissions.test.js@@ -52,52 +52,47 @@ test("owners and administrators retain all capabilities", async () => {}});-test("personal cloud notes fail closed until their share state loads", async () => {+test("personal cloud notes fail closed only while their ACL is loading", async () => {const { resolveNotePermission } = await load();assert.equal(resolveNotePermission({- shareStateLoaded: false,+ aclState: "loading",isTeamNote: false,- hasCloudId: true,}),null);assert.equal(resolveNotePermission({cachedPermission: "viewer",- shareStateLoaded: true,+ aclState: "loaded",isTeamNote: false,- hasCloudId: true,}),"viewer");});-test("local, team, and legacy notes retain their compatibility defaults", async () => {+test("unavailable ACLs, team notes, and legacy notes retain their compatibility defaults", async () => {const { resolveNotePermission } = await load();assert.equal(resolveNotePermission({- shareStateLoaded: false,+ aclState: "unavailable",isTeamNote: false,- hasCloudId: false,}),"owner");assert.equal(resolveNotePermission({- shareStateLoaded: false,+ aclState: "loading",isTeamNote: true,- hasCloudId: true,}),"editor");assert.equal(resolveNotePermission({- shareStateLoaded: true,+ aclState: "loaded",isTeamNote: false,- hasCloudId: true,}),"owner");diff --git a/test/helpers/spacesDatabase.test.js b/test/helpers/spacesDatabase.test.jsindex 55d07ab92..2a60b8435 100644--- a/test/helpers/spacesDatabase.test.js+++ b/test/helpers/spacesDatabase.test.js@@ -662,6 +662,7 @@ test("relocateRevokedFolder preserves dirty children and hard-deletes server-ownconst dirty = db.saveNote("Edits", "unpushed work", "personal", null, null, folder.id).note;db.markNoteSynced(dirty.id, "cloud-note-2");db.updateNote(dirty.id, { content: "unpushed work v2" });+ db.updateNoteShareState(dirty.id, { is_shared: 1, share_token: "revoked-folder-token" });const draft = db.saveNote("Draft", "never synced", "personal", null, null, folder.id).note;db.db.prepare(@@ -693,6 +694,8 @@ test("relocateRevokedFolder preserves dirty children and hard-deletes server-ownassert.equal(survivor.sync_status, "pending");}assert.notEqual(db.getNote(dirty.id).client_note_id, dirty.client_note_id, "identity forked");+ assert.equal(db.getNote(dirty.id).is_shared, 0, "forked note is private");+ assert.equal(db.getNote(dirty.id).share_token, null, "forked note drops its share token");// Dirty folder: preserved in Personal with a forked identity, children keep// their folder link, and a name collision falls back to a suffixed rename.@@ -842,6 +845,7 @@ test("purgeSpace preserves dirty cloud-backed notes with forked identities", (t)).note;db.markNoteSynced(dirty.id, "cloud-dirty-note");db.updateNote(dirty.id, { content: "walrus intel v2" });+ db.updateNoteShareState(dirty.id, { is_shared: 1, share_token: "purged-space-token" });const errored = db.saveNote("Errored push","narwhal notes",@@ -874,6 +878,8 @@ test("purgeSpace preserves dirty cloud-backed notes with forked identities", (t)assert.equal(relocated.sync_status, "pending");assert.equal(relocated.left_team, 0);assert.notEqual(relocated.client_note_id, prior.client_note_id);+ assert.equal(relocated.is_shared, 0);+ assert.equal(relocated.share_token, null);}const count = (sql, ...args) => db.db.prepare(sql).get(...args).count;assert.equal(count("SELECT COUNT(*) as count FROM notes WHERE id = ?", clean.id), 0);