Commit Graph

2921 Commits

Author SHA1 Message Date
spencrmartin c6475e7ea7 fix: Matrix invitation user ID formatting
Fixed MatrixError: Expected UserID string to start with '@'

The issue was that Matrix user IDs must always start with '@' but the
inviteToRoom method was not ensuring proper formatting.

Changes:
- Added user ID formatting in MatrixService.inviteToRoom()
- Ensures userId starts with '@' before sending to Matrix client
- Added logging to show original vs formatted user ID
- Handles cases where user IDs come without '@' prefix

This fixes invitation failures when user IDs don't have proper Matrix format.
2025-11-17 16:29:35 -05:00
spencrmartin e6656b9288 feat: add @goose off commands to disable AI
Added support for turning AI off after enabling it:

useChatEngine.ts:
- Added detection for @goose off/disable/stop/quiet/sleep commands
- When AI is enabled and user sends @goose off, AI gets disabled
- Message is added to chat without triggering AI response
- Console logging shows when AI is disabled

EnhancedMentionPopover.tsx:
- Added multiple @goose command options in autocomplete:
  - @goose (enable AI)
  - @goose off (disable AI)
  - @goose stop (stop AI)
  - @goose quiet (make AI quiet)
- Updated icons to show different emojis for off commands (🦆💤)
- All goose commands get green styling and 'Mention' action hint

Now users can:
1. Start DM (AI disabled by default)
2. Send @goose to enable AI
3. Send @goose off to disable AI again
4. Autocomplete shows all available @goose commands
2025-11-17 16:26:52 -05:00
spencrmartin 8e84a0c1f9 fix: DM history loading by properly loading backend session
The issue was that Matrix DMs were being initialized with empty messages
instead of loading the backend session. This prevented any previously
saved messages from appearing.

Changes:
- Matrix DM initialization now calls loadCurrentChat() to load backend session
- This ensures any existing messages from previous conversations are loaded
- Still sets aiEnabled=false for Matrix DMs after loading
- Maintains all the new AI toggle functionality

Now DMs should show their full history from both Matrix and backend sources.
2025-11-17 16:23:22 -05:00
spencrmartin 72f2753c78 feat: redesign DM session architecture with AI toggle
Major changes:
- Added aiEnabled field to ChatType interface
- Matrix DMs now create backend sessions with aiEnabled=false by default
- Regular chats have aiEnabled=true by default
- @goose mentions enable AI persistently for the session
- Removed collaborative session blocking logic
- All sessions now save to backend and appear in history
- DMs work like regular chats but with AI disabled until @goose is used

This allows DMs to have full backend functionality (history, saving, etc.)
while keeping AI responses disabled by default for collaboration.
2025-11-17 16:21:36 -05:00
spencrmartin d633cdcd1f fix: improve Matrix session detection to prevent API calls in DMs
- Fixed hasMatrixMapping logic to properly detect Matrix-backed sessions
- Matrix room IDs check for direct mappings
- Regular session IDs check if they're mapped FROM Matrix rooms
- This prevents DM sessions from making OpenAI API calls
- Only @goose mentions should trigger AI responses in DMs
2025-11-17 16:17:24 -05:00
spencrmartin f1db6c2dc3 fix: enable message stream for @goose mentions in collaborative sessions
- Never disable useMessageStream completely - handle blocking in append function
- This allows @goose mentions to properly trigger AI responses
- Regular messages in collaborative sessions still blocked to prevent rate limits
- @goose mentions now properly reinitialize LLM in DM conversations
2025-11-17 16:15:24 -05:00
spencrmartin d25b81468f feat: add @goose autocomplete in mention popover
- Add 'goose' as special mention option in EnhancedMentionPopover
- Show goose with duck emoji and green styling for distinction
- Handle @goose selection in ChatInput to insert mention text
- Prioritize @goose with highest match score (100+ boost)
- Display 'Reinitialize AI assistance' as description
- Now typing @ shows goose as autocomplete option for easy access
2025-11-17 16:13:27 -05:00
spencrmartin c527799f34 feat: add @goose mention support for AI reinitialization in DMs
- Add onGooseMention event handler to MatrixContext
- Update useChatEngine to allow AI responses when @goose is mentioned
- DMs now support @goose mentions to reinitialize AI assistance
- Maintains collaborative session blocking for regular messages
- Enables selective AI engagement in Matrix DM conversations
2025-11-17 16:10:34 -05:00
spencrmartin fb9c1bdcba fix: enhance collaborative session detection to prevent all Matrix DM backend calls
- Add hasMatrixMapping check to detect sessions created for Matrix collaboration
- Expand isCollaborativeSession logic to catch all Matrix-backed sessions
- Add detailed logging for debugging session detection
- This should prevent rate limit errors in Matrix DMs that have backend sessions
2025-11-17 15:57:02 -05:00
spencrmartin c12e49f3ab Latest updates to vision branch - UI improvements, Matrix service updates, and debug utilities 2025-11-17 15:51:21 -05:00
spencrmartin 99e40cd44c fix: improve collaborative session detection to prevent provider errors
- Detect collaborative sessions by checking both Matrix room IDs and mapped sessions
- Block all backend calls for any collaborative session (not just Matrix rooms)
- This should prevent provider errors when users join or are invited to collaborative sessions
- Collaborative sessions now work purely through Matrix without requiring LLM providers
2025-11-17 15:36:33 -05:00
spencrmartin c0135811a0 debug: add detailed session ID logging to identify Matrix room detection issues 2025-11-17 15:33:29 -05:00
spencrmartin 8ea6a9a0dc debug: re-add extensive logging to AgentManager provider configuration
- Add detailed debugging to configure_default_provider method
- Add warnings when provider configuration fails
- Add debugging to get_or_create_agent provider setting
- This will help identify why the system is falling back to OpenAI
- Should reveal if Databricks provider configuration is failing
2025-11-17 15:22:38 -05:00
spencrmartin f9de1c225c fix: completely disable backend calls for Matrix rooms to prevent provider errors
- Set disabled: isMatrixRoom in useMessageStream to prevent all backend interactions
- Skip session token fetching for Matrix rooms in useChatEngine
- Prevents 'provider not set' errors when users send messages in collaborative sessions
- Matrix rooms now work purely as message display/sync without requiring backend sessions
- Users without provider configuration can still participate in collaborative sessions
2025-11-17 15:14:30 -05:00
spencrmartin 88316eb9cc fix: remove await from dynamic import in ChatInput component
- Remove the await import() statement that was causing build error
- sessionMappingService is already imported statically at the top of the file
- Fixes 'await can only be used inside an async function' error
2025-11-17 14:50:41 -05:00
spencrmartin c987b33bc3 fix: resolve Matrix room ID for useSessionSharing in mapped sessions
- Import sessionMappingService to resolve Matrix room IDs
- Check if sessionId is mapped from a Matrix room using getMatrixRoomId()
- Pass actual Matrix room ID to useSessionSharing instead of mapped Goose session ID
- Add debug logging for Matrix room ID resolution
- Fixes message filtering issue where messages were rejected due to wrong room ID
2025-11-17 14:33:14 -05:00
spencrmartin f6e447d25f debug: add detailed logging to useSessionSharing room ID and message filtering
- Add comprehensive state logging to track room ID changes
- Add detailed debugging to handleGooseSessionSync message filtering
- Include hasCurrentRoomId, roomIdMatch, and shouldProcess flags
- Help identify why messages are being filtered out despite room ID setup
2025-11-17 14:30:51 -05:00
spencrmartin 0295b51479 fix: allow history loading while blocking new LLM requests for Matrix rooms
- Change approach from completely disabling useMessageStream to selective blocking
- Allow conversation history to load from backend for Matrix rooms
- Block only new user messages from triggering LLM responses
- Allow Matrix messages and assistant messages to be added normally
- Fixes missing conversation history after app reload
2025-11-17 14:25:22 -05:00
spencrmartin 1a5eb50a35 debug: enhance Matrix message flow debugging
- Add detailed logging to onMessageSync callback in ChatInput
- Include timestamp and full message JSON in logs
- Add custom event dispatch for message tracking
- Helps debug if messages are being received but not displayed
2025-11-17 14:21:48 -05:00
spencrmartin cb11d7d044 fix: disable backend API calls for collaborative Matrix sessions
- Add disabled parameter to useMessageStream to skip API calls
- Detect collaborative sessions in useChatEngine and disable backend calls
- Prevents OpenAI quota errors when joining collaborative sessions
- Collaborative sessions now only consume Matrix messages without creating backend sessions
2025-11-17 14:17:58 -05:00
spencrmartin 7e1d067d1c debug: add extensive logging to AgentManager provider configuration
- Add debug logging to configure_default_provider to track provider creation
- Add error handling and logging to provider setting on agents
- Make provider configuration failures visible instead of silent
- This will help identify why Databricks provider isn't being used
2025-11-17 14:00:44 -05:00
spencrmartin 8ccb9a45ff fix: make session description generation non-blocking to prevent Matrix chat failures
- Add error handling to maybe_update_description to catch provider errors
- Log session description generation failures as warnings instead of blocking
- Prevents OpenAI quota errors from breaking Matrix chat functionality
- Session creation/updates continue even if description generation fails
2025-11-17 13:54:24 -05:00
spencrmartin 66f76bce33 Fix Matrix chat invite error by exposing inviteToRoom in MatrixContext
- Add inviteToRoom to MatrixContextType interface
- Create wrapper function for matrixService.inviteToRoom
- Expose inviteToRoom in contextValue object
- Fixes 'TypeError: inviteToRoom is not a function' error when inviting users to existing Matrix chats
- Resolves issue in useSessionSharing.ts where inviteToRoom was undefined
2025-11-17 13:28:50 -05:00
spencrmartin b7b4979407 feat: add distinct visual styling for Matrix DM sessions in chat history
- Add green color scheme for Matrix DM sessions (border, background, icons, labels)
- Add purple color scheme for collaborative Matrix sessions
- Keep blue color scheme for regular Matrix group chats
- Add MessageCircle icon specifically for DM sessions
- Update labels to be more descriptive: 'Direct Message', 'Collaborative', 'Group Chat'
- Maintain existing functionality while improving visual distinction

Matrix session types now have clear visual hierarchy:
🟢 Green: Direct Messages (1:1 chats with full Goose integration)
🟣 Purple: Collaborative Sessions (multi-user with Goose participation)
🔵 Blue: Group Chats (regular Matrix rooms)
⚪ Default: Regular Goose sessions
2025-11-17 12:52:30 -05:00
spencrmartin e45bad59d4 feat: add full backend session support for Matrix DM rooms
- Fix backend session creation for Matrix rooms (instructions as string, not array)
- Add automatic session mapping creation for all Matrix rooms including DMs
- Enhance auto-rejoin logic to ensure session mappings for all joined rooms
- Increase Matrix history limit from 100 to 1000 messages for better DM support
- Add DM-specific session naming and instructions
- Improve error handling and logging for session creation failures
- Enable full chat history persistence for Matrix DM conversations

Matrix DM rooms now work as complete Goose chat sessions with:
- Full conversation history loading
- Backend session persistence
- Proper session ID mapping between Matrix and Goose
- Seamless integration with existing chat functionality
2025-11-17 12:49:57 -05:00
spencrmartin b8c9ac3b50 feat: update message notifications for dark mode compatibility
- Replace hardcoded colors with design system tokens
- Update background from bg-white to bg-background-default
- Change borders from border-blue-200 to border-border-default
- Update text colors to use text-text-default and text-text-muted
- Replace blue accent colors with bg-background-accent and text-text-on-accent
- Ensure proper contrast and readability in both light and dark themes
- Maintain consistent styling with rest of application
2025-11-17 12:10:17 -05:00
spencrmartin 3c67bd110d feat: position unread indicator below avatar with consistent styling
- Move unread indicator to appear directly below the avatar (top-14)
- Use text-xs text-text-muted styling to match user ID text appearance
- Remove duplicate indicator that was positioned at bottom of tile
- Create more integrated design within the avatar section
- Maintain clean, minimal appearance without background
2025-11-17 12:08:20 -05:00
spencrmartin e0ed8eaef9 feat: make unread indicator left-aligned without background
- Position unread indicator on left side (left-6) instead of centered
- Remove pill background for cleaner, more subtle appearance
- Change text color to text-text-default for proper contrast without background
- Maintain accent dot for visual emphasis
- Create more integrated look with tile design
2025-11-17 12:07:23 -05:00
spencrmartin d4bfaf1033 feat: simplify unread message indicator to show count only
- Replace detailed message preview bubble with simple '1 unread' pill
- Use clean rounded design with accent background and contrasting text
- Include small visual dot for emphasis
- Maintain proper dark mode compatibility with design system tokens
- Reduce visual clutter while keeping clear unread indication
2025-11-17 12:06:45 -05:00
spencrmartin b112858fe2 fix: improve dark mode styling for unread message bubble in peers tile
- Replace hardcoded bg-white/90 with bg-background-default/95 for proper dark mode support
- Change unread indicator dot from bg-blue-500 to bg-background-accent for theme consistency
- Ensures proper contrast and readability in both light and dark modes
2025-11-17 12:05:48 -05:00
spencrmartin 901b1d62d2 fix: resolve persistent collaboration invite notifications
- Add 2-minute age filter to ignore old messages from session history
- Improve self-message detection by comparing sender with current Matrix user ID
- Add membership check for goose.collaboration.invite messages to skip already-joined rooms
- Prevent processing of old goose.chat and goose.collaboration.invite messages on app startup

This eliminates the persistent 'Chat Session 20251114' and other old collaboration
notifications that were appearing every time the app loaded, even for rooms the
user had already joined.
2025-11-17 12:04:43 -05:00
spencrmartin 4282bf88b6 Fix persistent UI notifications by adding force-clear mechanism
PROBLEM: CollaborationInviteNotification component was showing stale notifications because its React state (pendingInvites) wasn't syncing with backend invite state changes made via console commands.

ROOT CAUSE: The component only removes notifications when users manually click Accept/Decline in the UI. When invite states are cleared via console commands, the UI component doesn't know about it and continues showing stale notifications.

SOLUTION:
- Added clearUINotifications() function that dispatches a custom 'clearNotifications' event
- Updated CollaborationInviteNotification to listen for this event and clear its state
- Provides a way to force-sync UI state with backend state

This resolves the issue where 15+ stale collaboration invite notifications persisted even after backend invite states were cleared.
2025-11-17 11:33:50 -05:00
spencrmartin f83e18cee1 Add comprehensive debugging tools for Matrix room persistence issues
- Exposed sessionMappingService globally for debugging
- Enhanced findChatSession20251114() to work with exposed services
- Added fixChatSession20251114() function to handle the specific issue:
  - Declines all pending invites for duplicate Chat Session rooms
  - Creates session mappings for joined rooms that lack them
  - Cleans up stale invite states for joined rooms
  - Forces cleanup to sync everything

This addresses the issue where 50 duplicate rooms with identical names
cause persistent notifications and auto-rejoin failures.
2025-11-17 11:24:39 -05:00
spencrmartin 50d4ad06fa Fix UI not respecting MatrixInviteStateService shouldShowInvite logic
PROBLEM: The CollaborationInviteNotification component was showing Matrix room invitation notifications even when MatrixInviteStateService.shouldShowInvite() returned false.

ROOT CAUSE: The UI component was directly converting matrixRoomInvitation events to notifications without checking if the invite should actually be displayed according to the backend state management.

SOLUTION: Added critical shouldShowInvite() check in handleMatrixRoomInvitation before displaying notifications. Now the UI properly respects the backend logic that handles invite cooldowns, duplicate detection, and state management.

This should finally resolve the persistent collaboration invite notification spam issue.
2025-11-17 11:09:04 -05:00
spencrmartin aaedf54012 Fix Matrix room invitations being misclassified as Goose messages
PROBLEM: Matrix room invitations were showing as 'Received Goose chat message - offering collaboration' instead of proper Matrix room invitation notifications.

ROOT CAUSE: The looksLikeGooseMessage() function had a pattern '/collaboration.*invite/i' that was catching legitimate Matrix room invitations and routing them through the Goose message handler instead of the Matrix room invitation handler.

SOLUTION: Removed the problematic '/collaboration.*invite/i' pattern from the Goose message detection logic. Matrix room invitations should now be properly handled by handleMatrixRoomInvitation() and emit 'matrixRoomInvitation' events instead of being misclassified as Goose messages.

This should resolve the persistent 'collaboration invite' notifications issue.
2025-11-17 10:57:56 -05:00
spencrmartin 385e8005f7 Add comprehensive Matrix invite state debugging tools
- Added debugInviteStates() global function for detailed invite state analysis
- Added clearAllInviteStates() global function for nuclear option cleanup
- Made cleanupJoinedRoomInvites() public for manual debugging
- Enhanced debugging shows invite states vs current room memberships
- Provides tools to manually trigger cleanup and state clearing

This helps diagnose persistent invite notification issues.
2025-11-17 10:55:24 -05:00
spencrmartin ccc7dcb73b Fix Matrix invite notification cleanup to prevent duplicate notifications
- Enhanced cleanupJoinedRoomInvites() with comprehensive invite state management
- Added detailed logging for invite cleanup process with room membership checks
- Mark invite states as accepted when auto-rejoining rooms during startup
- Mark invite states as accepted when manually joining rooms
- Handle edge cases: left/banned rooms marked as declined, missing rooms kept pending
- Cross-check all current rooms to ensure invite states are properly marked
- Added invite statistics logging for debugging

This resolves the issue where users saw persistent collaboration invite notifications for rooms they had already joined.
2025-11-17 10:50:15 -05:00
spencrmartin 2266a42e21 Add Matrix room auto-rejoin functionality
- Implemented autoRejoinStoredRooms() method to automatically rejoin Matrix rooms on app startup
- Called auto-rejoin after Matrix sync is prepared
- Checks stored room states and rejoins rooms where user was previously joined
- Updates stored participant states if rejoin fails
- Provides comprehensive logging for debugging rejoin process
- Emits roomsRejoined event to notify UI components

This resolves the issue where users had to manually rejoin Matrix rooms after app reloads.
2025-11-17 10:47:21 -05:00
spencrmartin 253c5936ff Enhance Matrix room state persistence and session history UI
- Extended SessionMappingService with comprehensive room state tracking
- Added Matrix room metadata, participant tracking, and membership history
- Enhanced MatrixService to update room states on membership events
- Added Matrix collaboration info component to SessionHistoryView
- Shows room details, participants, join status, and rejoin button
- Tracks room join/leave events with timestamps and event history
- Serializes Map objects properly for localStorage persistence

This addresses the foundation for Matrix room join state persistence across app reloads.
2025-11-17 10:46:31 -05:00
spencrmartin 472642edbf Fix duplicate notifications for already-joined Matrix rooms
## Bug Fix
- Added membership checking before showing invite notifications
- Skip notifications for rooms where user already has 'join' membership
- Automatically mark joined rooms as 'accepted' in invite state service
- Added cleanup function to process existing invite states on sync

## Technical Details
- handleMatrixRoomInvitation() now checks room.getMyMembership() === 'join'
- cleanupJoinedRoomInvites() runs on Matrix sync PREPARED state
- Prevents duplicate notifications from earlier invite state reset
- Only shows notifications for actual pending invites

## Result
- No more notifications for rooms you've already joined
- Only legitimate pending invites will show notifications
- Automatic cleanup of stale invite states

Fixes duplicate invite notifications issue
2025-11-17 10:27:19 -05:00
spencrmartin 678ec72b72 Fix Matrix sync ERROR - remove invalid filter configuration
## Bug Fix
- Removed invalid filter configuration that was causing Matrix sync to fail
- Matrix client was throwing 'filter.getDefinition is not a function' error
- Kept optimized sync settings (50 message limit, 30s polling) without filter

## Technical Details
- Matrix-js-sdk expects specific filter object format
- Invalid filter was preventing successful sync initialization
- Now relies on increased sync limits for performance instead of custom filters

## Result
- Matrix sync should now work properly without ERROR state
- Real-time notifications should be faster due to increased limits
- Eliminates the sync failure that was blocking message delivery

Fixes Matrix sync ERROR and improves notification performance
2025-11-17 10:25:14 -05:00
spencrmartin 54b946d508 Optimize Matrix sync settings for faster real-time notifications
## Performance Improvements
- Increased initialSyncLimit from 10 to 50 messages for better context
- Added 30-second long polling (pollTimeout) for faster message delivery
- Increased timeline limit to 20 messages per room for better sync
- Added filter configuration for optimized sync performance

## Technical Details
- Matrix client now syncs more recent messages on startup
- Longer polling timeout reduces notification delays
- Better sync filters improve real-time message delivery
- Should significantly reduce the delay in message notifications

Addresses slow Matrix notification performance issue
2025-11-17 10:24:06 -05:00
spencrmartin 6c676f7886 Fix Matrix invite notifications not appearing in Goose app
## Issue Resolution
- Fixed Matrix room invitations not showing up in Goose desktop app
- Root cause: MatrixInviteStateService was hiding invites seen within 5 minutes
- Pending invites were being processed but filtered out by 'recently seen' logic

## Changes Made

### Core Fixes
- Reduced invite cooldown from 5 minutes to 1 minute in MatrixInviteStateService
- Added temporary global debugging access for MatrixService and MatrixInviteStateService
- Improved invite state management and debugging capabilities

### Matrix Integration Improvements
- Enhanced Matrix authentication UI in PeersView
- Added Matrix logo and dancing lines SVG assets
- Created MatrixLogo and MatrixDancingLines React components
- Improved Matrix connection status display

### Debugging Enhancements
- Added comprehensive debugging methods to MatrixService
- Exposed services globally for console debugging (temporary)
- Enhanced logging for invite processing pipeline

## Technical Details
- Matrix rooms with 'Invalid Date' lastActivity are pending invites
- shouldShowInvite() method was preventing legitimate invites from displaying
- All invite processing logic working correctly, issue was in UI filtering

## Testing
- Verified 4 pending invites now display correctly after refresh
- Confirmed Matrix connection and sync working properly
- Validated invite state service tracking and management

Fixes #matrix-invites
2025-11-17 10:13:33 -05:00
spencrmartin 80a572a3d3 feat: complete Matrix session collaboration backend implementation
- Add Matrix session services (MatrixInviteStateService, MatrixSessionService, UnifiedSessionService)
- Implement Matrix chat components and session management
- Add comprehensive Matrix integration across UI components
- Update session handling and message streaming for Matrix compatibility
- Enhance chat input and base chat components for Matrix collaboration
- Add Matrix notification and session list view support
- Integrate Matrix services with existing Goose chat infrastructure

This completes the huge backend change that allows Matrix sessions to be written to the backend as a session.
2025-11-14 22:50:20 -05:00
spencrmartin 43852b2a7a fix: prevent duplicate Matrix messages with simple content+time deduplication
- Add createMessageKey() helper for simple deduplication based on content + sender + timestamp
- Apply deduplication in both handleGooseSessionSync and handleRegularMessage handlers
- Round timestamps to nearest second to catch near-simultaneous duplicates
- Maintain all existing functionality (role detection, sender attribution, metadata)
- Fixes issue where single user message from other Goose instances appeared twice in chat

Resolves Matrix collaboration message duplication issue.
2025-11-14 22:47:29 -05:00
spencrmartin 4d1cc38c4f Implement backend session creation for Matrix rooms
MAJOR ARCHITECTURAL IMPROVEMENT: Matrix sessions now create real backend sessions

Key Changes:
- Added createMappingWithBackendSession() to SessionMappingService
- Matrix rooms now call startAgent API to create actual backend sessions
- Session mappings use real backend session IDs instead of generated ones
- Updated MatrixService.createAISession() to use backend session creation
- Updated MatrixService.ensureSessionMapping() to create backend sessions
- Added fallback to old method if backend session creation fails

Benefits:
- Matrix sessions are now fully compatible with backend APIs
- No more 'Failed to read session: Session not found' errors
- Session token counting works correctly for Matrix sessions
- SSE streams work properly with Matrix sessions
- Full session persistence and reload functionality
- Eliminates the need for frontend-only workarounds

This resolves the fundamental issue where Matrix sessions existed only in the frontend
but had no corresponding backend session data. Now Matrix collaborative sessions
are treated as first-class citizens with proper backend integration.
2025-11-14 21:55:26 -05:00
spencrmartin 025aefcf6a Fix SSE Finish session mapping error in useMessageStream
- Enhanced SSE Finish case to properly handle session ID mapping
- Added comprehensive logging for session ID mapping decisions
- Improved error handling to prevent SSE stream interruption
- Renamed sessionId to originalSessionId for clarity
- Added detailed error logging with session context

This resolves the persistent 'Failed to read session: Session not found' error
at line 335 by ensuring proper session mapping before getSession API calls.
2025-11-14 21:51:39 -05:00
spencrmartin fd0b9d0fe3 Improve Matrix media error handling for HTTP2 protocol issues
- Enhanced getAuthenticatedMediaBlob with timeout and better error handling
- Added specific handling for HTTP2 protocol errors and timeouts
- Improved error messages to distinguish between different failure types
- Added 10-second timeout to prevent hanging requests

This addresses the 'net::ERR_HTTP2_PROTOCOL_ERROR' errors when fetching
Matrix user avatars and other media from the Matrix server.
2025-11-14 21:49:29 -05:00
spencrmartin d4aebaf07e Force rebuild of Matrix session hooks with enhanced error handling
- Added timestamp comments to force rebuild of useMessageStream.ts and useChatEngine.ts
- Enhanced error handling for Matrix session SSE stream processing
- Improved logging for Matrix session mapping debugging
- Ensures proper handling of Matrix room IDs vs Goose session IDs

This addresses the persistent 'Failed to read session: Session not found' errors
by forcing a fresh build of the hooks with the latest session mapping logic.
2025-11-14 21:48:49 -05:00
spencrmartin d63d945681 Fix Matrix chat history loading and backend compatibility
Enhanced Session Mapping Service:
- Modified getBackendSessionId to return null for Matrix sessions without mappings
- Added shouldMakeBackendCalls method to check if backend calls should be made
- Added ensureMappingExists method for creating mappings for existing Matrix rooms
- Prevents 404 errors when loading Matrix chat history without existing mappings

Updated Backend Integration:
- useChatEngine now skips session token fetching for Matrix sessions without mappings
- useMessageStream SSE handling skips session data fetching for unmapped Matrix sessions
- Proper null checking prevents backend API calls with Matrix room IDs
- Comprehensive logging for debugging session mapping decisions

Matrix Chat History Support:
- Matrix sessions loaded from history no longer cause backend 404 errors
- Sessions without mappings gracefully skip backend calls while maintaining Matrix functionality
- Future enhancement: can create mappings on-demand for existing Matrix rooms
- Maintains full compatibility with existing Goose sessions

This resolves the 'GET /sessions/!roomId 404 Not Found' errors when loading Matrix chat history
while preserving all Matrix collaborative features and backend compatibility for mapped sessions.
2025-11-14 21:42:05 -05:00