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.
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
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.
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.
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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.
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.
- 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.
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.
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.
- 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.
- 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.
- 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.
- 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.
## 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
## 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
## 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
- 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.
- 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.
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.
- 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.
- 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.
- 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.
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.