π File detail
utils/messagePredicates.ts
π― Use case
This file lives under βutils/β, which covers cross-cutting helpers (shell, tempfiles, settings, messages, process input, β¦). On the API surface it exposes isHumanTurn β mainly functions, hooks, or classes. It composes internal code from types (relative imports). What the file header says: tool_result messages share type:'user' with human turns; the discriminant is the optional toolUseResult field. Four PRs (#23977, #24016, #24022, #24025) independently fixed miscounts from checking type==='user' alone.
Generated from folder role, exports, dependency roots, and inline comments β not hand-reviewed for every path.
π§ Inline summary
tool_result messages share type:'user' with human turns; the discriminant is the optional toolUseResult field. Four PRs (#23977, #24016, #24022, #24025) independently fixed miscounts from checking type==='user' alone.
π€ Exports (heuristic)
isHumanTurn
π₯οΈ Source preview
import type { Message, UserMessage } from '../types/message.js'
// tool_result messages share type:'user' with human turns; the discriminant
// is the optional toolUseResult field. Four PRs (#23977, #24016, #24022,
// #24025) independently fixed miscounts from checking type==='user' alone.
export function isHumanTurn(m: Message): m is UserMessage {
return m.type === 'user' && !m.isMeta && m.toolUseResult === undefined
}