fix(MessageList): guard against possibly-undefined message in lookup

`session.messages[i]` is typed as `Message | undefined` under
noUncheckedIndexedAccess. Optional-chain the role check so the
agent's lastUserIdx scan type-checks again — the runtime semantics
are identical (loop only runs while `i` is in range).
This commit is contained in:
Eliot M 2026-05-01 14:06:14 +00:00
parent f380008659
commit f8c0b5fa69

View file

@ -34,7 +34,7 @@ export function MessageList({ session }: MessageListProps) {
// pulsing-gradient + glow state while the assistant is busy).
let lastUserIdx = -1;
for (let i = session.messages.length - 1; i >= 0; i--) {
if (session.messages[i].role === 'user') {
if (session.messages[i]?.role === 'user') {
lastUserIdx = i;
break;
}