Skip to content

Commit ef4e181

Browse files
committed
fix(session-turn): last-message-only pending guard
session-turn.tsx::pending used findLast over the full message list, treating any older assistant message without time.completed as the pending one. Combined with active() and pendingUser() derivations, that meant the wrong turn could show as 'active' (drove the 'Thinking' shimmer in session-turn) for sessions with DB residue from a previously-crashed stream. Tighten to last-message-only: only the final message in the list can legitimately be the pending assistant message. Matches the pattern in upstream PR anomalyco#17593's commit 060f482. Combined with 3e7acb8, 91ae391, and 347095d, this closes the client-side stuck-Thinking / stuck-busy bug end-to-end: - timeline working derivation: trusts status (3e7acb8) - session.tsx::busy() helper: trusts status (91ae391) - sidebar SessionItem.isWorking: trusts status (347095d) - session-turn.tsx::pending: last-message-only (this commit) The persistent DB residue (12 incomplete assistant messages in the live aai.db) is now ignored by all UI working-state derivations. Server-side fix to stop NEW residue from accumulating is a separate follow-up (see docs/plans/stuck-session-status.md commit 2). Refs upstream PR anomalyco#17593.
1 parent 347095d commit ef4e181

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎packages/ui/src/components/session-turn.tsx‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,16 @@ export function SessionTurn(
201201
const pending = createMemo(() => {
202202
if (typeof props.active === "boolean") return
203203
const messages = allMessages() ?? emptyMessages
204-
return messages.findLast(
205-
(item): item is AssistantMessage => item.role === "assistant" && typeof item.time.completed !== "number",
206-
)
204+
// Only the LAST message can legitimately indicate pending work for the
205+
// active turn. findLast over the full array would return any older
206+
// assistant message stuck without time.completed (DB residue from a
207+
// crashed stream), making sessions show 'active' on the wrong turn
208+
// forever. If the last message exists, is an assistant message, and
209+
// hasn't been finalized — it's pending. Otherwise nothing is.
210+
const last = messages[messages.length - 1]
211+
if (!last || last.role !== "assistant") return
212+
if (typeof last.time.completed === "number") return
213+
return last as AssistantMessage
207214
})
208215

209216
const pendingUser = createMemo(() => {

0 commit comments

Comments
 (0)