The Collaboration Audit That Fixed 18 Things at Once
You've got a team. Your team has documents. Those documents need to stay in sync, permissions need to actually work, and nobody should lose their changes at 4pm on a Friday.
We spent the last sprint doing something unsexy but essential: a comprehensive audit of AiFiler's collaboration system. We found 18 bugs—some obvious, some hiding in edge cases that only show up when three people edit the same document simultaneously while someone's connection flickers.
All 18 are fixed. Here's what that means for you.
What Actually Broke (And Now Works)
Our collaboration layer handles three critical things: real-time sync, permission enforcement, and conflict resolution. When any of these fail silently, users don't notice until something's already wrong.
Real-time sync was our biggest issue. When multiple users edited the same document, changes sometimes arrived out of order. Imagine User A adds a paragraph, User B deletes a sentence, and User C's view shows the deletion before the addition. The document state becomes inconsistent. We rebuilt the sync queue to use timestamp-based ordering with Supabase's RLS (Row Level Security) as the source of truth. Now changes apply in the correct sequence, every time.
Permission enforcement had gaps. A user with "view only" access could sometimes trigger actions that should require "edit" permissions. This happened because we were checking permissions in the UI layer instead of at the database level. We moved all permission checks to Supabase RLS policies. The database now enforces permissions before any data leaves the server. If you don't have permission, the query fails at the source.
Conflict resolution was our third major fix. When two users edited the same section simultaneously, AiFiler would sometimes ask which version to keep. But the UI for choosing wasn't clear, and some users accidentally discarded their own work. We implemented operational transformation (OT) for text conflicts—the same approach Google Docs uses. Now when two edits overlap, both changes merge intelligently instead of forcing a choice.
How the Fixes Work Under the Hood
If you're curious about the technical side:
Timestamp-based sync ordering means every change gets a server-generated timestamp. When User A's edit and User B's edit arrive at the server, we apply them in timestamp order, not arrival order. This prevents the "out of order" problem entirely.
Database-level RLS policies mean permission checks happen before data is fetched. Instead of checking permissions in the Next.js API route, Supabase checks them before returning rows. This is faster and more secure—no permission data ever reaches the client if you shouldn't see it.
Operational transformation for text conflicts works like this: if User A inserts "urgent " at position 10 and User B deletes characters 8-12, the system transforms both operations so they work together. User A's insertion happens, then User B's deletion adjusts for the new text. Both users see the same final result.
How to Try It
You don't need to do anything. These fixes are live for all AiFiler accounts.
If you want to test the improvements:
- Open a document with your team. Use the share button (top-right corner of the editor) to invite a colleague.
- Edit simultaneously. Both of you make changes to the same paragraph at the same time. Watch the sync happen in real-time—no conflicts, no lost work.
- Check permissions. Have your colleague switch to "view only" mode. Try to edit. The editor will lock, and you'll see "You don't have permission to edit this document."
- Test with poor connection. Open the document on mobile with WiFi, then switch to cellular mid-edit. Changes still sync correctly when connection returns.
The fixes are most noticeable when you're working with a team on the same document. Single-user workflows won't see much difference, but the reliability improvements benefit everyone.
What's Coming Next
We're working on two things that build on this foundation:
Presence indicators will show you exactly where your teammates are editing. Instead of just seeing "Sarah is viewing this document," you'll see a cursor with her name, so you know which paragraph she's working on.
Comment threads will let you discuss changes without leaving the document. Highlight text, add a comment, and your team can reply. Comments resolve when you address them.
Both features depend on the collaboration system being rock-solid, which is why we fixed those 18 bugs first. We're not shipping presence or comments until we're certain the underlying sync is bulletproof.
Why This Matters
Collaboration features are invisible when they work. You edit, your teammate sees the change, everyone's happy. But when they break, they break catastrophically—lost work, conflicting versions, permission nightmares.
We could have shipped new features instead of auditing the old ones. But new features on a broken foundation just create more problems. So we did the boring, essential work first.
If you've had collaboration issues in the past—documents going out of sync, permissions not working, conflicts losing your edits—try again. It's fixed.
Enjoyed this article?
Get more articles like this delivered to your inbox. No spam, unsubscribe anytime.

