Skip to content

feat: Add internal debug logging system#245

Draft
Just-Insane wants to merge 10 commits intoSableClient:devfrom
Just-Insane:feat/internal-debug-logging
Draft

feat: Add internal debug logging system#245
Just-Insane wants to merge 10 commits intoSableClient:devfrom
Just-Insane:feat/internal-debug-logging

Conversation

@Just-Insane
Copy link
Contributor

Overview

This PR introduces a comprehensive internal debug logging system for Sable, providing detailed insights into application behavior across multiple subsystems.

Features

Core Debug Logger

  • 9 logging categories: sync, network, notification, message, call, ui, timeline, general, error
  • 5 log levels: debug, info, warn, error, fatal
  • Live logging: Real-time log capture with listener support
  • Filtering: Filter logs by category, level, and search text
  • Export: Export filtered logs to file for debugging

Debug Log Viewer UI

  • Located in Developer Tools settings
  • Real-time log display with automatic updates
  • Category and level filtering
  • Search functionality
  • Copy and export capabilities
  • Clear log history

Instrumented Components

  • Sliding Sync: Detailed sync lifecycle, list expansion, and performance tracking
  • Timeline: Mount/unmount tracking, live timeline linking, event loading
  • Room Input: Message sending, file uploads, errors
  • Background Notifications: Notification events and handling

Benefits

  • Debugging: Quickly identify issues without external tools
  • Performance: Track slow operations and bottlenecks
  • User Support: Users can export logs when reporting issues
  • Development: Better visibility into application behavior

Testing

  • ✅ Debug viewer updates in real-time
  • ✅ Filtering works correctly
  • ✅ Export functionality produces valid log files
  • ✅ No performance impact when not viewing logs
  • ✅ Logs are cleared on session start

Commits

  • feat: add internal debug logging system
  • feat: add UI and timeline debug logging
  • fix build issue
  • fix(debug-logger): Fix PopOut component pattern and state management
  • chore: Remove accidentally committed debug log file
  • fix(debug-logger): Fix TypeScript error with filters.since undefined check
  • feat(debug-logging): enhance sync logging and fix filter button issue
  • feat: enhance debug logging and fix background notifications

Evie Gauthier added 8 commits March 13, 2026 12:16
- Add comprehensive debug logger utility with circular buffer (1000 entries max)
- Add debug log state management with Jotai atoms
- Create DebugLogViewer UI component with real-time updates and filtering
- Integrate debug logger into Developer Tools settings
- Add logging for sync state changes (initMatrix, slidingSync)
- Add logging for authentication (login, logout, session management)
- Add logging for push notifications (permissions, subscriptions)
- Add logging for app lifecycle (visibility changes, backgrounding)
- Add logging for network connectivity (online/offline)
- Add logging for notifications (filtering, routing, mute decisions)
- Add logging for messages (send success/failure, uploads, scheduled)
- Add logging for calls (widget lifecycle, join/hangup, events)
- Support filtering by category and level
- Support exporting logs as JSON (all or filtered)
- Support copying logs to clipboard
- Add 'ui' and 'timeline' log categories to debugLogger
- Log Room component mount/unmount and drawer state changes
- Log RoomTimeline lifecycle events (mount, unmount, initialization)
- Track timeline pagination (start, complete, errors)
- Monitor live timeline linking state changes
- Log scroll position changes (at bottom, scrolled up)
- Track jump-to-event operations
- Log timeline refresh events
- Add UI and Timeline category filters in DebugLogViewer
- Update description to mention new categories

This provides comprehensive visibility into UI component lifecycle
and timeline visualization state for debugging issues with room
rendering, timeline scrolling, and UI element visibility.
- Change debugLoggerEnabledAtom from getter function to direct value atom to properly update UI
- Convert PopOut components from children function to anchor-based pattern
- Add click handlers for category and level filter menus
- Fix TypeScript errors with entry.data unknown type checks
- Filters should now display correctly when clicked
- Add comprehensive sync cycle logging in slidingSync.ts:
  - Track room count changes per list with deltas
  - Log initial sync completion with timing and room counts
  - Monitor list expansion progress with detailed stats
  - Detect slow sync cycles (>1s) and expansions (>500ms)
  - Track network connectivity changes with connection info
  - Log attach/dispose lifecycle with diagnostics
  - Add error logging for list operations

- Fix filter button closing settings dialog in DebugLogViewer:
  - Add stopPropagation to category/level menu button handlers
  - Prevents event bubbling that was closing parent dialog

- Add .envrc for automatic Node 24 environment activation via direnv
- Add .nvmrc to specify Node v24.14.0 requirement
Debug logging:
- Add logging to LeaveRoomPrompt, CreateRoom, Space, AccountSwitcherTab
- Add build version to debug log exports
- Add network/sync logging to initMatrix

Background notifications:
- Add explicit listener cleanup before stopping clients
- Add exponential backoff retry for failed background clients (5 attempts)
- Add 30s timeout to waitForSync to prevent indefinite hangs
- Use useMemo for inactive sessions array
- Track cleanup callbacks per client
@Just-Insane Just-Insane marked this pull request as draft March 13, 2026 16:28
Just-Insane pushed a commit to Just-Insane/Sable that referenced this pull request Mar 13, 2026
Evie Gauthier added 2 commits March 13, 2026 15:06
- Run Prettier on all modified files
- Fix variable declaration order in BackgroundNotifications.tsx (isHighlight and loudByRule used before declaration)
- Note: Lint errors are pre-existing (790 base → 703 with changes, net improvement of 87)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant