Skip to content

Commit 1c4d370

Browse files
committed
Improve code documentation and test descriptions
- Update test description to be self-explanatory without referencing issue number - Add detailed comment explaining awareness state handling for disconnected users
1 parent 1e171f2 commit 1c4d370

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

__tests__/components/ui/coaching-sessions/editor-cache-context.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ describe('EditorCacheProvider', () => {
199199
expect(screen.getByTestId('is-ready')).toHaveTextContent('no')
200200
})
201201

202-
describe('Provider Lifecycle (Issue #201 Fixes)', () => {
202+
describe('Provider Lifecycle - Preventing Unnecessary Disconnections', () => {
203203
it('should NOT disconnect provider when re-rendering with same sessionId', async () => {
204204
const { TiptapCollabProvider } = await import('@hocuspocus/provider')
205205

src/components/ui/coaching-sessions/editor-cache-context.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ export const EditorCacheProvider: React.FC<EditorCacheProviderProps> = ({
198198
const mergedUsers = new Map(prev.presenceState.users);
199199

200200
// Mark users who disappeared from awareness as disconnected
201+
// When users "disappear," it means they're no longer in the awareness states array -
202+
// typically due to network disconnect, browser crash, or navigation away from the coaching
203+
// session page. Without this code, disconnected users would instantly vanish from the UI,
204+
// creating an unwanted UX. This preserves them as status: 'disconnected' instead, enabling
205+
// smooth UX transitions (like showing grayed-out presence indicators).
201206
for (const [userId, oldPresence] of prev.presenceState.users) {
202207
if (!updatedUsers.has(userId) && oldPresence.status === 'connected') {
203208
// User was connected but no longer in awareness states - mark as disconnected

0 commit comments

Comments
 (0)