Skip to content

Commit bb5a230

Browse files
committed
Fix bug in expireMessages
1 parent 73a0d35 commit bb5a230

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

backend/src/util/messages.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,15 @@ export function expireMessages(
296296
endOf: 'agentStep' | 'userPrompt',
297297
): CodebuffMessage[] {
298298
return messages.filter(
299-
(m) =>
300-
(m.timeToLive === undefined && true) ||
301-
(m.timeToLive === 'userPrompt' && endOf === 'agentStep') ||
302-
(m.timeToLive === 'agentStep' && false),
299+
(m) => {
300+
// Keep messages with no timeToLive
301+
if (m.timeToLive === undefined) return true
302+
303+
// Remove messages that have expired
304+
if (m.timeToLive === 'agentStep') return false
305+
if (m.timeToLive === 'userPrompt' && endOf === 'agentStep') return false
306+
307+
return true
308+
},
303309
)
304310
}

0 commit comments

Comments
 (0)