function processUserMessage()

in codex-cli/src/components/history-overlay.tsx [170:199]


function processUserMessage(item: ResponseItem): string | null {
  if (
    item.type === "message" &&
    (item as unknown as { role?: string }).role === "user"
  ) {
    // TODO: We're ignoring images/files here.
    const parts =
      (item as unknown as { content?: Array<unknown> }).content ?? [];
    const texts: Array<string> = [];
    if (Array.isArray(parts)) {
      for (const part of parts) {
        if (part && typeof part === "object" && "text" in part) {
          const t = (part as unknown as { text?: string }).text;
          if (typeof t === "string" && t.length > 0) {
            texts.push(t);
          }
        }
      }
    }

    if (texts.length > 0) {
      const fullPrompt = texts.join(" ");
      // Truncate very long prompts so the history view stays legible.
      return fullPrompt.length > 120
        ? `> ${fullPrompt.slice(0, 117)}…`
        : `> ${fullPrompt}`;
    }
  }
  return null;
}