( conversations: NormalizedConversation[], )
| 928 | // information from the shorter ones. Avoiding duplication makes it reasonable for humans to reason |
| 929 | // about diffs in the stored conversations when things change. |
| 930 | function removePrefixConversations( |
| 931 | conversations: NormalizedConversation[], |
| 932 | ): NormalizedConversation[] { |
| 933 | const result = [...conversations]; |
| 934 | for (let i = result.length - 1; i >= 0; i--) { |
| 935 | for (let j = i - 1; j >= 0; j--) { |
| 936 | if (isPrefix(result[j].messages, result[i].messages)) { |
| 937 | result.splice(j, 1); |
| 938 | i--; // adjust index since we removed an element before current position |
| 939 | } |
| 940 | } |
| 941 | } |
| 942 | return result; |
| 943 | } |
| 944 | |
| 945 | function isPrefix( |
| 946 | shorter: NormalizedMessage[], |
no test coverage detected
searching dependent graphs…