~bigbes/lethe

ref: 8d80e8710e89cc83560ea26681ed80eb6c4b169d lethe/web/src/features/session/Transcript.tsx -rw-r--r-- 1.8 KiB
8d80e871 — Eugene Blikh savedsearch: reject ?owner= on DELETE; cover all write paths in test (IV2) a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import React from 'react'
import ReactMarkdown from 'react-markdown'
import type { Turn } from './useSession'

interface TranscriptProps {
  turns: Turn[]
  selected: number
  onSelect: (seq: number) => void
}

export function Transcript({
  turns,
  selected,
  onSelect,
}: TranscriptProps): React.JSX.Element {
  return (
    <main className="transcript">
      {turns.map((t) => {
        const isSel = t.i === selected
        return (
          <div
            key={t.i}
            id={`turn-${t.i}`}
            className={`turn ${t.role}${isSel ? ' selected' : ''}`}
            onClick={() => onSelect(t.i)}
          >
            <div className="turn-meta">
              <span className={`role-${t.role.toUpperCase()}`}>
                {t.role.toUpperCase()}
              </span>
              {t.toolKind != null && (
                <span className="tag" style={{ fontSize: 9.5 }}>
                  {t.toolKind}
                </span>
              )}
              {t.toolName != null && (
                <span className="mono" style={{ color: 'var(--ink-3)' }}>
                  {t.toolName}
                </span>
              )}
              {t.model != null && (
                <span className="mono">{t.model}</span>
              )}
              {t.tokensIn != null && t.tokensOut != null && (
                <span className="mono">
                  {t.tokensIn}{t.tokensOut}
                </span>
              )}
              <span style={{ flex: 1 }} />
              <span className="mono" style={{ opacity: 0.5 }}>
                #{t.i}
              </span>
            </div>
            <div className="turn-body">
              {t.role === 'tool' ? (
                t.body
              ) : (
                <ReactMarkdown>{t.body}</ReactMarkdown>
              )}
            </div>
          </div>
        )
      })}
    </main>
  )
}