mirror of
https://github.com/block/goose.git
synced 2026-07-17 12:56:20 +02:00
Fix Matrix room history message type detection
- Ensure user messages from self are properly categorized as 'user' type - Only categorize messages as 'assistant' if they have explicit Goose markers or are from other users - This fixes the issue where user's own messages weren't appearing in conversation history - Improved message type detection logic to be more precise and reliable
This commit is contained in:
@@ -2372,7 +2372,7 @@ export class MatrixService extends EventEmitter {
|
||||
sessionData = JSON.parse(sessionJson);
|
||||
actualContent = sessionData.content || actualContent;
|
||||
|
||||
// FIXED: Better role detection for session messages
|
||||
// Better role detection for session messages
|
||||
if (sessionData.role === 'assistant' || sessionData.role === 'ai' || sessionData.role === 'goose') {
|
||||
messageType = 'assistant';
|
||||
} else if (sessionData.role === 'system') {
|
||||
@@ -2386,19 +2386,33 @@ export class MatrixService extends EventEmitter {
|
||||
console.warn('Failed to parse session message:', error);
|
||||
}
|
||||
}
|
||||
// Check if this is a regular Goose/AI message
|
||||
else if (content['goose.message.type'] || content['goose.type'] ||
|
||||
this.isGooseInstance(sender, senderInfo.displayName) ||
|
||||
this.looksLikeGooseMessage(actualContent)) {
|
||||
// Check if this is a regular Goose/AI message (but NOT from self unless it has explicit Goose markers)
|
||||
else if (content['goose.message.type'] || content['goose.type']) {
|
||||
// Explicit Goose message markers - always treat as assistant
|
||||
messageType = 'assistant';
|
||||
} else if (content.msgtype === 'm.notice' || sender.includes('bot')) {
|
||||
}
|
||||
// Check if message is from a known Goose instance (not self)
|
||||
else if (!isFromSelf && this.isGooseInstance(sender, senderInfo.displayName)) {
|
||||
messageType = 'assistant';
|
||||
}
|
||||
// Check if message content looks like a Goose message (not self)
|
||||
else if (!isFromSelf && this.looksLikeGooseMessage(actualContent)) {
|
||||
messageType = 'assistant';
|
||||
}
|
||||
// System messages
|
||||
else if (content.msgtype === 'm.notice' || sender.includes('bot')) {
|
||||
messageType = 'system';
|
||||
}
|
||||
|
||||
// ADDITIONAL FIX: Check if message is from self but contains AI response patterns
|
||||
else if (isFromSelf && this.looksLikeGooseMessage(actualContent)) {
|
||||
// This handles cases where the user's own messages contain AI responses
|
||||
messageType = 'assistant';
|
||||
// CRITICAL FIX: Messages from self that don't have explicit Goose markers should be 'user'
|
||||
// This ensures user's own messages are properly categorized as 'user' type
|
||||
else {
|
||||
// Default to 'user' for all other messages, including messages from self
|
||||
messageType = 'user';
|
||||
|
||||
// Log for debugging
|
||||
if (isFromSelf) {
|
||||
console.log('📜 Message from self categorized as user:', actualContent.substring(0, 50) + '...');
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user