An open-source, faster Devin alternative
TypeScript
Merge remote-tracking branch 'origin/main' into flue-native
Igor Zalutskic7c7694847f3
diff --cc web/src/pages/SessionDetail.tsxindex 67b8da4d,e481dc58..b45b0f5e--- a/web/src/pages/SessionDetail.tsx+++ b/web/src/pages/SessionDetail.tsx@@@ -1,16 -1,8 +1,17 @@@- import { useEffect, useMemo, useState } from 'react'- import { Link, useParams } from 'react-router-dom'+ import { useEffect, useMemo, useRef, useState } from 'react'+ import { Link, useParams, useLocation } from 'react-router-dom'import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'-import { ArrowLeft, Send, Wrench, CircleAlert, Sparkles } from 'lucide-react'+import {+ ArrowLeft,+ Send,+ Wrench,+ CircleAlert,+ Brain,+ CheckCircle2,+ XCircle,- FileWarning,++ Sparkles,+} from 'lucide-react'+ import { GuidedTour, type GuideStep } from '@/components/guided-tour'import { notifyError } from '@/lib/errors'import { useHalted } from '@/hooks/useHalted'import {@@@ -37,50 -26,18 +38,46 @@@ import { SessionWebhooks } from '@/compimport { ApiHint } from '@/components/api-hint'import { MessagesSquare } from 'lucide-react'import { cn } from '@/lib/utils'+import { formatSpend, usageTokens } from '@/lib/usage'+ import {+ MessageBubble,+ TurnConversation,+ } from '@/components/session-conversation'+ import { bodyText, groupIntoTurns, isOutOfCredits } from '@/lib/session-turns'- // body is unknown (inline JSON ≤32KB); pull the common shapes defensively.- function bodyText(ev: SessionEvent): string | null {- const b = ev.body- if (- b &&- typeof b === 'object' &&- typeof (b as Record<string, unknown>).text === 'string'- ) {- return (b as Record<string, string>).text- }- return null- }function toolSummary(ev: SessionEvent): string {const b = (ev.body ?? {}) as Record<string, unknown>const tool = typeof b.tool === 'string' ? b.tool : 'tool'const input = typeof b.input === 'string' ? b.input : ''return input ? `${tool} · ${input}` : tool}+// A tool RESULT — brain-box emits `exec.completed`, the flue tailer emits `tool.result`;+// both land here so flue + brain-box render identically.+function isToolResult(ev: SessionEvent): boolean {+ return ev.type === 'exec.completed' || ev.type === 'tool.result'+}+function toolResult(ev: SessionEvent): { text: string; isError: boolean } {+ const b = (ev.body ?? {}) as Record<string, unknown>+ const tool = typeof b.tool === 'string' ? b.tool : 'tool'+ const isError = b.is_error === true || b.error != null+ const summary =+ (typeof b.summary === 'string' && b.summary) ||+ (typeof b.output === 'string' && b.output) ||+ (typeof b.text === 'string' && b.text) ||+ ''+ const dur = typeof b.duration_ms === 'number' ? ` · ${b.duration_ms}ms` : ''- return { text: summary ? `${tool} → ${summary}${dur}` : `${tool} →${dur}`, isError }++ return {++ text: summary ? `${tool} → ${summary}${dur}` : `${tool} →${dur}`,++ isError,++ }+}+// The body spilled to blob storage (event > 32KB) — surface an affordance instead of+// rendering an empty bubble.+function truncationNote(ev: SessionEvent): string | null {+ if (!ev.body_truncated && !ev.content_ref) return null+ const kb = ev.body_bytes ? ` (${Math.round(ev.body_bytes / 1024)} KB)` : ''+ return `Output too large to inline${kb} — stored in blob`+}function humanizeType(t: string): string {return t.replace(/[._]/g, ' ').replace(/^\w/, (c) => c.toUpperCase())}@@@ -236,10 -338,10 +378,10 @@@ for await (const event of session.event</Link>{/* Header */}- <Panel className="mb-4 p-5">+ <Panel ref={headerRef} className="mb-4 p-5"><div className="flex flex-wrap items-start justify-between gap-4"><div className="min-w-0 space-y-1.5">- <div className="flex items-center gap-2.5">+ <div className="flex flex-wrap items-center gap-2.5"><code className="text-foreground font-mono text-sm">{sessionId}</code>@@@ -310,23 -418,8 +461,23 @@@</div></Panel>+ {/* Spend / usage — derived from the session's opaque usage object (no dedicated+ spend endpoint). Tokens shown only when the runtime reports them (flue meters+ at the gateway and reports none here). */}+ <div className="mb-4 grid grid-cols-2 gap-4 sm:grid-cols-3">+ <MetricCard label="Spend" value={formatSpend(session?.usage)} />+ <MetricCard+ label="Tokens"+ value={usageTokens(session?.usage)?.toLocaleString() ?? '—'}+ />+ <MetricCard+ label="Events"+ value={(session?.head ?? 0).toLocaleString()}+ />+ </div>+{/* Event stream */}- <Panel className="overflow-hidden">+ <Panel ref={eventsRef} className="overflow-hidden"><div className="flex items-center justify-between border-b px-4 py-2.5"><div className="flex items-center gap-2"><h2 className="text-sm font-semibold">Events</h2>@@@ -451,54 -558,52 +625,64 @@@)}- function EventRow({ ev }: { ev: SessionEvent }) {+ function EventRow({+ ev,+ pending,+ bounds,+ }: {+ ev: SessionEvent+ pending: Set<number>+ bounds: Map<string, TurnStartInfo>+ }) {const text = bodyText(ev)+ const trunc = truncationNote(ev)++ // Reasoning — muted, set apart from the answer. (flue tailer + brain-box both emit this.)+ if (ev.type === 'agent.thinking') {+ if (!text && !trunc) return null+ return (+ <li className="text-muted-foreground flex gap-2 px-4 py-2 text-xs italic">+ <Brain className="mt-0.5 size-3.5 shrink-0 opacity-60" />+ <span className="whitespace-pre-wrap">{text ?? trunc}</span>+ </li>+ )+ }// Conversation messages — the signal.if (ev.type === 'user.message' || ev.type === 'agent.message') {const isUser = ev.type === 'user.message'- // Out-of-credits notice (from the runtime's failPreExec) → make the "top up" actionable.- const outOfCredits =- ev.type === 'agent.message' &&- (ev.body as Record<string, unknown> | null | undefined)?.code ===- 'insufficient_credits'return (<li className="px-4 py-3">- <div className="mb-1 flex items-center gap-2">- <span className="text-foreground text-xs font-semibold">- {ev.actor?.display ?? (isUser ? 'You' : 'Agent')}- </span>- <span className="text-muted-foreground/70 font-mono text-[10px]">- #{ev.seq}- </span>- </div>- {text ? (- <p className="text-foreground/90 text-sm whitespace-pre-wrap">- {text}- </p>- ) : trunc ? (- <p className="text-muted-foreground flex items-center gap-1.5 text-xs italic">- <FileWarning className="size-3.5 shrink-0" />- {trunc}- </p>- ) : null}- {outOfCredits && (- <Button asChild size="sm" className="mt-2">- <Link to="/billing">Top up</Link>- </Button>- )}+ <MessageBubble+ label={ev.actor?.display ?? (isUser ? 'You' : 'Agent')}- text={text}++ text={text ?? trunc}+ seq={ev.seq}+ // Input typed while a turn was running but not yet claimed by a turn.+ meta={+ isUser && pending.has(ev.seq) ? (+ <span className="text-muted-foreground text-[10px]">+ · queued+ </span>+ ) : undefined+ }+ outOfCredits={isOutOfCredits(ev)}+ />+ </li>+ )+ }++ // Turn started — de-orphaned: self-describing with its seq range + input preview.+ if (ev.type === 'turn.started') {+ const info = bounds.get(ev.turn_id ?? '')+ const range =+ info && info.from != null+ ? ` · running #${info.from}${info.to != null && info.to > info.from ? `–#${info.to}` : ''}`+ : ''+ const preview = info?.preview ? ` : "${info.preview}"` : ''+ return (+ <li className="text-muted-foreground flex items-center gap-2 px-4 py-1.5 text-xs">+ <span className="bg-border h-px w-4 shrink-0" />+ {`Turn started${range}${preview}`}</li>)}