Commit Graph
295 Commits
Author SHA1 Message Date
Evie Gauthier f846695d8e refactor: remove timeline pruning — unsubscribe on leave is sufficient 2026-03-18 23:32:19 -04:00
Evie Gauthier 67c66bb769 chore: fix prettier formatting and TypeScript type error in test 2026-03-18 23:19:30 -04:00
Evie Gauthier b98fa45820 feat: auto-unsubscribe and prune timeline when local user leaves a room
Wire onMembershipLeave to RoomMemberEvent.Membership in attach()/dispose().
When the local user leaves or is banned from a subscribed room, calls
unsubscribeFromRoom() which prunes timelines exceeding PRUNE_TIMELINE_THRESHOLD.

Previously, unsubscribeFromRoom() was dead code — nothing in the app called it.

Also add 5 unit tests covering: leave, ban, other-user leave, join (no-op),
and non-subscribed room (no-op).
2026-03-18 15:22:56 -04:00
Evie Gauthier 0f6067e04c refactor: remove adaptive timeline limits, stop unsubscribing on navigation
Replace the adaptive 50/100/150 timeline limit system with a flat
ACTIVE_ROOM_TIMELINE_LIMIT=50, matching Element Web approach.
Stop calling unsubscribeFromRoom() on room navigation so subscriptions
accumulate across the session for instant room switching.

Element Web SlidingSyncManager.setRoomVisible() never removes subscriptions
at all -- no pruning whatsoever. Our PRUNE_TIMELINE_THRESHOLD=100 guard
is more conservative than their approach.

- Remove AdaptiveSignals type, readAdaptiveSignals(),
  resolveAdaptiveRoomTimelineLimit(), applyRoomTimelineLimit()
- Remove adaptiveTimeline and configuredTimelineLimit class fields
- Remove adaptiveTimeline from SlidingSyncDiagnostics type and UI
- Stop unsubscribing on nav in useSlidingSyncActiveRoom
- Lower PRUNE_TIMELINE_THRESHOLD from 150 to 100
2026-03-18 14:31:18 -04:00
Evie Gauthier 023bf2a325 feat: persist room timeline to IndexedDB before pruning from memory 2026-03-17 18:22:14 -04:00
Evie Gauthier 67c626c6b2 fix: correct IndexedDB persistence claim in pruneRoomTimeline comment 2026-03-17 18:11:03 -04:00
Evie Gauthier 1df87084a0 fix: stop sliding sync on dispose and prune inactive room timelines
Two memory management issues fixed:

1. SlidingSyncManager.dispose() now calls this.slidingSync.stop() before
   removing listeners. Without this the SDK's internal Promise loop keeps
   polling the sliding sync proxy even after the client is disposed, leaking
   network connections and preventing garbage collection.

2. pruneRoomTimeline() is called from unsubscribeFromRoom(). When a room
   leaves the active subscription its EventTimeline chain can hold hundreds of
   events in memory. Once the event count exceeds PRUNE_TIMELINE_THRESHOLD
   (= ACTIVE_ROOM_TIMELINE_LIMIT_HIGH = 150) the live timeline is reset via
   EventTimelineSet.resetLiveTimeline(). The full history remains on disk in
   IndexedDBStore and is re-fetched via the active-room subscription on next
   open, so there is no user-visible change.

Adds 5 unit tests: 1 for dispose, 4 for the pruning threshold boundary.
2026-03-17 17:57:04 -04:00
Evie Gauthier 9d0851856a fix: trigger scroll after stay-at-bottom range expansion from subscription batch
The scroll queued at TimelineReset fires when range.end=0 (SDK fires Reset
before populating the fresh timeline), so the DOM is empty and the scroll
is a no-op. The stay-at-bottom effect then correctly expands the range but
never re-queues a scroll, leaving the user at the wrong position.

Fix: increment scrollToBottomRef.count in the stay-at-bottom effect before
calling setTimeline. The next render sees the new count, the useLayoutEffect
fires, and scroll-to-bottom runs against the now-populated DOM.

Also adds monitoring:
- Sentry breadcrumb (ui.scroll) recording each range expansion + scroll,
  with rangeGap, eventsLength, and wasReset fields for Replay analysis.
- slidingSync onFirstRoomData now records the live-timeline event count at
  subscription activation time as a Sentry metric and breadcrumb, making
  the list-to-subscription page size visible in dashboards.
2026-03-15 23:56:29 -04:00
Evie Gauthier d57ebdd4a3 feat(sentry): detailed timeline and scroll instrumentation, sync batch monitoring, and anomaly detection
RoomTimeline.tsx:
- atBottom transition breadcrumbs (ui.scroll) with rapid-flip detection:
  true→false within 200ms captures warning (IntersectionObserver false-positive)
- Virtual paginator window shift breadcrumbs (ui.timeline)
- scroll-to-bottom trigger breadcrumb; captures warning when fired while
  user is scrolled up without a pending reset
- eventsLength batch monitoring: breadcrumb on every batch with delta,
  batchSize label (single/small/medium/large), rangeGap, atBottom
- Large batch warning (>50 events, liveTimelineLinked=true) for sliding
  sync adaptive load detection

slidingSync.ts / initMatrix.ts:
- sync.sliding breadcrumb in onFirstRoomData with latency + event count
- sable.sync.room_sub_event_count distribution metric

Message interaction metrics (IncomingCallModal, MessageDelete, MessageForward,
MessageReport, RoomTimeline reaction handler):
- sable.call.answered/declined, sable.message.delete/forward/report/reaction.*
2026-03-15 23:40:58 -04:00
Evie Gauthier 3ce9e54145 feat(sentry): initialize SDK, performance instrumentation, developer settings, and error capture
Adds Sentry error tracking, performance monitoring, and session replay:

- Environment-based sampling: production 10%, preview/dev 100%
- Session replay with full privacy masking (text, media, inputs)
- Hashed MXID as anonymous user ID with homeserver tag
- Error rate limiting (50 events/session) to protect quota

Performance spans and metrics across all critical paths: auth login,
message send, timeline jump-load, per-event decryption, sliding sync
cycles, key backup, store wipe, UTD failures, sync degradation,
background notification clients, media uploads.

Developer settings panel (Settings → General → Diagnostics & Privacy):
error reporting toggle, session replay opt-in, breadcrumb category
controls, debug log export.

Crash page shows Sentry event ID with one-click feedback dialog.
Bug report modal sends structured reports to Sentry feedback API
with optional debug log attachment.

CI: Sentry env vars injected into preview (100% sampling) and
production (10% sampling) builds. Source maps uploaded via
@sentry/vite-plugin.
2026-03-15 23:40:58 -04:00
Evie Gauthier 79e4e09436 fix(lint): resolve react-hooks/exhaustive-deps, arrow-body-style, and no-plusplus errors 2026-03-13 22:17:13 -04:00
Evie Gauthier 54ac93c39a chore: fix formatting and linting issues for CI 2026-03-13 22:10:36 -04:00
Evie Gauthier 83262b3593 feat: enhance debug logging and fix background notifications
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
2026-03-13 21:25:34 -04:00
Evie Gauthier 9c017b85cf feat(debug-logging): enhance sync logging and fix filter button issue
- 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
2026-03-13 21:25:34 -04:00
Evie Gauthier 44029b6a5c fix(debug-logger): Fix PopOut component pattern and state management
- 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
2026-03-13 21:25:34 -04:00
Evie Gauthier c647d561c1 fix build issue 2026-03-13 21:25:34 -04:00
Evie Gauthier bcf5a84220 feat: add internal debug logging system
- 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
2026-03-13 21:25:34 -04:00
Evie Gauthier 3b98dfc89f fix: auto-format sliding sync files with prettier
- All TypeScript and ESLint checks passing
2026-03-12 14:54:45 -04:00
Evie Gauthier a38b519f15 perf: optimize sliding sync with progressive loading and improved timeline management 2026-03-12 14:26:16 -04:00
Evie Gauthier d1e002ac6d feat(sliding-sync): tie presence extension into sendPresence setting 2026-03-09 23:26:52 -04:00
Evie Gauthier 6271bb79ee fix(lint): fix ESLint errors in ExtensionPresence and add changeset 2026-03-09 23:22:41 -04:00
Evie Gauthier 8f8502a536 feat(sliding-sync): register ExtensionPresence for live presence updates
Register a custom MSC4186 presence extension with the SlidingSync object so
that m.presence events delivered via extensions.presence.events are processed
into the SDK's User model on every poll.

Without this, the SlidingSync object only auto-registers ExtensionToDevice and
ExtensionAccountData (via SlidingSyncSdk), so presence payloads from the server
were silently discarded. Components using useUserPresence (Profile, MembersDrawer,
UserRoomProfile, UserHero, Presence) would always show stale/default presence.

The extension follows the same path as regular /sync: map raw events through
client.getEventMapper(), call user.setPresenceEvent() to update User state and
emit UserEvent.Presence, UserEvent.CurrentlyActive, UserEvent.LastPresenceTs,
then emit ClientEvent.Event on the client.
2026-03-09 23:22:41 -04:00
Evie Gauthier 1229bc0982 fix(lint): fix import order and suppress intentional await-in-loop 2026-03-09 23:22:41 -04:00
Evie Gauthier 6d00376164 chore: fix formatting (prettier) 2026-03-09 23:22:41 -04:00
Evie Gauthier 4a22e867ee fix(timeline): always reinit on TimelineRefresh to fix sliding sync hang 2026-03-09 23:22:41 -04:00
Evie Gauthier 62931d88ff feat: improve sliding sync to match Element Web approach
- Sort lists by notification level, recency, then name
- Add include_old_rooms for tombstoned room predecessor state
- Active-room custom subscription (timeline_limit=50) for the viewed room
- SlidingSyncManager.subscribeToRoom / unsubscribeFromRoom
- Export getSlidingSyncManager from initMatrix
- useSlidingSyncActiveRoom hook + SlidingSyncActiveRoomSubscriber component
- No changes to the classic sync path (startClassicSync / buildClient)
2026-03-09 23:20:19 -04:00
Evie Gauthier 6dcaea6bd8 fix(sliding-sync): prevent edit leakage, add required_state, re-render on Replace events, guard empty getContent() 2026-03-04 22:29:30 -05:00
Evie Gauthier ef706c96d0 fix hybrid cache logic 2026-03-03 12:59:11 -05:00
Evie Gauthier 92e0c3512e hybrid classic+sliding sync caching, and sticker/emoji fixes 2026-03-03 11:32:03 -05:00
Evie Gauthier a852db2f55 fix pending sent UI/UX, potential fix for large accounts 2026-03-03 10:51:48 -05:00
Evie Gauthier d95d31fd04 fix inbox notification/invite isues and add enhancements 2026-03-03 09:07:43 -05:00
Evie Gauthier 5e63931d61 refactor sliding sync startup checks and logic around starting sliding sync vs a classic client. 2026-03-03 07:03:12 -05:00
Evie Gauthier 22ff69fba0 fix code quality complaints 2026-03-03 01:20:17 -05:00
Evie Gauthier a01356a87b further enhancements to reduce state churn on low-power/limited-network devices 2026-03-03 01:15:26 -05:00
Evie Gauthier 6a76914010 add additional sliding sync diagnostics and dynamically set timeline limit to reduce state churn 2026-03-03 01:05:31 -05:00
Evie Gauthier 1c788c1e81 additional improvements to resolve potential future bugs 2026-03-03 00:59:20 -05:00
Evie Gauthier df1826850d add missing required events 2026-03-03 00:24:39 -05:00
Evie Gauthier 0e076485cd Various fixes for UI/Rendering issues in sliding sync 2026-03-03 00:05:46 -05:00
Evie Gauthier a6c7be6f64 fix sliding sync server requirements 2026-03-02 21:36:54 -05:00
Evie Gauthier 9a02d21967 enable sliding sync by default 2026-03-02 21:08:31 -05:00
Evie Gauthier e1b7844ff8 Add initial sliding sync support 2026-03-02 19:34:51 -05:00
7w1 08fa7cd67f make eslint happy 2026-03-02 15:10:21 -06:00
hazre bde1505ad4 refactor: normalize parent-relative imports to aliases 2026-03-02 20:00:26 +01:00
hazre 39c9d48443 fix: resolve initMatrix eslint violations 2026-03-02 18:27:29 +01:00
hazre b5e9dcb07e chore(lint): eslint autofix 2026-03-01 13:46:40 +01:00
hazre b8a998cab7 Merge remote-tracking branch 'sable/dev' into chore/cleanup-codebase-1 2026-02-26 19:04:09 +01:00
TastelessVoid d5027236ce Added account switcher with multi-account notifications 2026-02-21 18:32:51 +01:00
hazre 3df0ae96e2 chore: reformat files and align lint script with npm 2026-02-14 18:01:21 +01:00
hazre 71425f8644 refactor: route matrix-sdk imports through $types boundary
Centralize Matrix SDK imports behind a local compatibility module, migrate matrix subpath imports to the boundary, and switch to the $types alias. Upgrade TypeScript to latest so matrix-js-sdk typings resolve correctly before the next cleanup phase.
2026-02-14 17:24:46 +01:00
Ajay Bura 074c555294 Post session info to service worker instead of asking from sw (#2605)
post session info to service worker instead of asking from sw on each request
2026-02-14 17:11:36 +11:00