11import { partial_ratio } from "fuzzball"
22import type { WithParts } from "../state"
33import type { Logger } from "../logger"
4+ import { isIgnoredUserMessage } from "../messages/utils"
45
56export interface FuzzyConfig {
67 minScore : number
@@ -25,6 +26,9 @@ function extractMessageContent(msg: WithParts): string {
2526
2627 for ( const part of parts ) {
2728 const p = part as Record < string , unknown >
29+ if ( ( part as any ) . ignored ) {
30+ continue
31+ }
2832
2933 switch ( part . type ) {
3034 case "text" :
@@ -81,6 +85,9 @@ function findExactMatches(messages: WithParts[], searchString: string): MatchRes
8185
8286 for ( let i = 0 ; i < messages . length ; i ++ ) {
8387 const msg = messages [ i ]
88+ if ( isIgnoredUserMessage ( msg ) ) {
89+ continue
90+ }
8491 const content = extractMessageContent ( msg )
8592 if ( content . includes ( searchString ) ) {
8693 matches . push ( {
@@ -104,6 +111,9 @@ function findFuzzyMatches(
104111
105112 for ( let i = 0 ; i < messages . length ; i ++ ) {
106113 const msg = messages [ i ]
114+ if ( isIgnoredUserMessage ( msg ) ) {
115+ continue
116+ }
107117 const content = extractMessageContent ( msg )
108118 const score = partial_ratio ( searchString , content )
109119 if ( score >= minScore ) {
@@ -145,7 +155,7 @@ export function findStringInMessages(
145155 const fuzzyMatches = findFuzzyMatches ( searchableMessages , searchString , fuzzyConfig . minScore )
146156
147157 if ( fuzzyMatches . length === 0 ) {
148- if ( lastMessage ) {
158+ if ( lastMessage && ! isIgnoredUserMessage ( lastMessage ) ) {
149159 const lastMsgContent = extractMessageContent ( lastMessage )
150160 const lastMsgIndex = messages . length - 1
151161 if ( lastMsgContent . includes ( searchString ) ) {
0 commit comments