~bigbes/lethe

ref: ac34df37e95365f0737b4eb4834e9d60e21256db lethe/web/src/features/session/TurnList.tsx -rw-r--r-- 1.6 KiB
ac34df37 — Eugene Blikh docs(lethe-web-ui-palette-savedsearch): record review pass + conclusion 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
import React from 'react'
import type { Turn } from './useSession'

const ROLE_GLYPH: Record<Turn['role'], string> = {
  user: '▸',
  assistant: '◆',
  tool: '·',
}

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

export function TurnList({
  turns,
  selected,
  onSelect,
}: TurnListProps): React.JSX.Element {
  return (
    <aside className="session-aside">
      <div
        className="thead"
        style={{ gridTemplateColumns: '24px 14px 1fr 36px', padding: '4px 10px' }}
      >
        <span>#</span>
        <span />
        <span>preview</span>
        <span className="right">tok</span>
      </div>
      {turns.map((t) => {
        const isSel = t.i === selected
        const tokens = (t.tokensIn ?? 0) + (t.tokensOut ?? 0)
        const preview = t.body.length > 32 ? t.body.slice(0, 32) + '…' : t.body
        return (
          <div
            key={t.i}
            className={`session-aside-row${isSel ? ' selected' : ''}`}
            onClick={() => onSelect(t.i)}
          >
            <span className="mono muted">{t.i}</span>
            <span
              style={{
                color:
                  t.role === 'assistant' ? 'var(--accent-ink)' : 'var(--ink-3)',
                fontWeight: 700,
                fontFamily: 'var(--mono)',
              }}
            >
              {ROLE_GLYPH[t.role]}
            </span>
            <span className="truncate">{preview}</span>
            <span className="right mono muted" style={{ fontSize: 10 }}>
              {tokens > 0 ? tokens : '—'}
            </span>
          </div>
        )
      })}
    </aside>
  )
}