Skip to content

Commit 5b41f50

Browse files
authored
Merge pull request #180 from chrisglein/copilot/fix-179
Fix menu item index sync issue after deleting chat entries
2 parents 690ca49 + 172215b commit 5b41f50

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/ChatSession.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,12 @@ function ChatSession(): JSX.Element {
144144
console.error(`Index ${index} is out of bounds`);
145145
} else {
146146
modifiedEntries.splice(index, 1);
147-
setEntries(modifiedEntries);
147+
// Re-index the remaining entries to maintain ID-to-index consistency
148+
const reindexedEntries = modifiedEntries.map((entry, newIndex) => ({
149+
...entry,
150+
id: newIndex
151+
}));
152+
setEntries(reindexedEntries);
148153
}
149154
},
150155
[entries],

0 commit comments

Comments
 (0)