Commit Graph
308 Commits
Author SHA1 Message Date
hazre 4a99cc50f9 test: replace stale lint suppressions with type imports 2026-04-19 16:47:34 +02:00
hazre fecf22ad5a chore: drop stale oxlint suppressions 2026-04-19 16:47:28 +02:00
7w1 f2bd03f427 add promise to plugins
and disable always-return because its annoying
2026-04-17 16:36:47 -05:00
7w1 40bb35f34c linting awayy 2026-04-17 16:23:59 -05:00
7w1 144e148154 many lint fixes 2026-04-17 14:09:04 -05:00
7w1 27eaadf9ae typecheck and linting fixes 2026-04-17 00:37:15 -05:00
7w1 b13c9b61d4 formatting 2026-04-16 22:38:18 -05:00
7w1 1717ca872f migrate to oxlint and oxfmt
ran formatter
fixed lint issues, primarily getting rid of "any"s and swapping to .toSorted()
2026-04-16 22:15:13 -05:00
Evie Gauthier b3e434dbc2 feat(threads): thread drawer, thread browser, live reply counts, and unread badges 2026-04-06 12:51:03 -04:00
7w1 748794cedc fix: scroll-to-bottom regression and timeline pagination fixes (#529)
### Description

Fixes several timeline bugs introduced after the
timeline-reset-on-navigation refactor:

- Scroll-to-bottom no longer gets stuck after navigating to a room
- Timeline pagination no longer uses a stale timeline chain after a
sliding sync reset
- URL preview requests are deduplicated so the same URL only fires one
network request
- Removed a redundant spidering call that was generating an extra
sliding sync request per room visit

Fixes #

#### Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

### Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings

### AI disclosure:

- [x] Partially AI assisted (GitHub Copilot)

`RoomTimeline.tsx`: Added a `liveTimelineLinked` guard so the initial
scroll doesn't fire with stale data from the previous room, and a
`pendingReadyRef` that defers `setIsReady(true)` when `processedEvents`
is still empty (preventing the room opening at position 0).
`useTimelineSync.ts`: A `useEffect` resets the timeline state on room
change so revisited rooms aren't stuck with `liveTimelineLinked =
false`. Reads `linkedTimelines` fresh after each `await` in pagination
so a sliding sync reset mid-paginate doesn't cause count comparisons on
a detached chain. A `continuing` flag prevents two concurrent pagination
calls from racing on the lock. URL preview dedup uses a module-level
`Map` to share in-flight promises for the same URL. Removed a redundant
`startSpidering` subscription call in the sync setup path.
2026-03-28 10:23:55 -05:00
Evie Gauthier 38057ee9ce fix: reset live timeline on room navigation and reconnect
The Matrix SDK for sliding sync deliberately does not call resetLiveTimeline()
on limited:true (the handling is in a commented-out TODO block). This means
events from a previous visit remain in the live timeline and new events get
appended after them, with the backward pagination token pointing to the gap
between old and new events rather than to before all events. The result is
that new messages appear out of order or the gap is unreachable via the UI.

Two fixes:

1. useSlidingSyncActiveRoom: reset the live timeline synchronously before
   the subscription request is sent on room navigation. This ensures the
   fresh initial:true response populates a clean timeline, not one polluted
   with events from the previous visit. Also removes the 100ms delay that
   was added as an incomplete workaround for the same issue.

2. SlidingSyncManager.onLifecycle: in RequestFinished state (fires before
   any room data listeners run), reset the live timeline for active-room
   subscriptions that receive initial:true or limited:true. This covers the
   reconnect/background case where the pos token expires and all active rooms
   get a fresh initial:true in the same sync cycle.
2026-03-25 20:34:57 -04:00
Evie Gauthier 4460047365 feat: add room abbreviations with hover tooltips (#403)
- Add StateEvent.RoomAbbreviations ('moe.sable.room.abbreviations')
- Include abbreviations event in sliding sync required state
- Add AbbreviationsPage to RoomSettingsPage enum
- New RoomAbbreviations settings page (add/remove term+definition pairs)
- Wire page into RoomSettings.tsx menu
- New useRoomAbbreviations hook + RoomAbbreviationsContext
- Provide context in Room.tsx
- RenderBody.tsx: highlight defined terms in plain-text messages with
  TooltipProvider+abbr tooltip; HTML messages unaffected
2026-03-24 23:33:22 -04:00
Evie Gauthier ba99ef428b fix: remove redundant startSpidering call causing N+1 sync requests 2026-03-24 23:32:26 -04:00
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