(item: ConversationItem)
| 33 | ]); |
| 34 | |
| 35 | export function normalizeItem(item: ConversationItem): ConversationItem { |
| 36 | if (item.kind === "message") { |
| 37 | return { ...item, text: truncateText(item.text) }; |
| 38 | } |
| 39 | if (item.kind === "userInput") { |
| 40 | return { |
| 41 | ...item, |
| 42 | questions: item.questions.map((question) => ({ |
| 43 | ...question, |
| 44 | header: truncateText(question.header, 300), |
| 45 | question: truncateText(question.question, 2000), |
| 46 | answers: question.answers.map((answer) => truncateText(answer, 2000)), |
| 47 | })), |
| 48 | }; |
| 49 | } |
| 50 | if (item.kind === "explore") { |
| 51 | return item; |
| 52 | } |
| 53 | if (item.kind === "reasoning") { |
| 54 | return { |
| 55 | ...item, |
| 56 | summary: truncateText(item.summary), |
| 57 | content: truncateText(item.content), |
| 58 | }; |
| 59 | } |
| 60 | if (item.kind === "diff") { |
| 61 | return { ...item, diff: truncateText(item.diff) }; |
| 62 | } |
| 63 | if (item.kind === "tool") { |
| 64 | return { |
| 65 | ...item, |
| 66 | title: truncateText(item.title, 200), |
| 67 | detail: truncateText(item.detail, 2000), |
| 68 | output: item.output |
| 69 | ? truncateToolText(item.toolType, item.output) |
| 70 | : item.output, |
| 71 | changes: item.changes |
| 72 | ? item.changes.map((change) => ({ |
| 73 | ...change, |
| 74 | diff: change.diff |
| 75 | ? truncateToolText(item.toolType, change.diff) |
| 76 | : change.diff, |
| 77 | })) |
| 78 | : item.changes, |
| 79 | }; |
| 80 | } |
| 81 | return item; |
| 82 | } |
| 83 | |
| 84 | function cleanCommandText(commandText: string) { |
| 85 | if (!commandText) { |
no test coverage detected