File size: 5,372 Bytes
5e17e07 6c0127c 5e17e07 ac50275 5e17e07 ac50275 5e17e07 ac50275 6c0127c ac50275 5e17e07 ac50275 5e17e07 6c0127c ac50275 5e17e07 ac50275 5e17e07 ac50275 5e17e07 ac50275 5e17e07 ac50275 6c0127c ac50275 5e17e07 ac50275 eb89325 ac50275 eb89325 ac50275 eb89325 ac50275 eb89325 ac50275 5e17e07 6c0127c 5e17e07 ac50275 5e17e07 ac50275 5e17e07 ac50275 5e17e07 ac50275 5e17e07 ac50275 5e17e07 ac50275 6c0127c 5e17e07 6c0127c 5e17e07 ac50275 6c0127c 5e17e07 ac50275 5e17e07 ac50275 6c0127c ac50275 5e17e07 ac50275 5e17e07 ac50275 5e17e07 ac50275 eb89325 ac50275 eb89325 ac50275 eb89325 ac50275 eb89325 5e17e07 | 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | import type { ExpandedQuery } from '../types';
import { InfoTooltip } from './PipelineView';
interface ExpansionColumnState {
status: 'idle' | 'running' | 'done' | 'error';
data?: ExpandedQuery;
error?: string;
}
interface ExpansionColumnProps {
state: ExpansionColumnState;
accent: string;
info: string;
}
function Spinner({ color }: { color: string }) {
return (
<span style={{
display: 'inline-block',
width: '14px',
height: '14px',
border: '2px solid var(--border)',
borderTopColor: color,
borderRadius: '50%',
animation: 'spin 0.7s linear infinite',
}} />
);
}
function CompactCard({ label, content }: { label: string; content: string | string[] }) {
const text = Array.isArray(content) ? content.join('\n') : content;
return (
<div style={{
background: 'var(--bg-card)',
border: '1px solid var(--border)',
borderRadius: '5px',
padding: '0.4rem 0.6rem',
marginBottom: '0.3rem',
}}>
<div style={{
fontSize: '0.65rem',
fontWeight: 700,
fontFamily: 'system-ui, -apple-system, sans-serif',
color: 'var(--text-muted)',
textTransform: 'uppercase',
letterSpacing: '0.06em',
marginBottom: '0.2rem',
}}>
{label}
</div>
<div style={{
fontFamily: "'SF Mono', 'Fira Code', 'Cascadia Code', monospace",
fontSize: '0.68rem',
color: 'var(--text)',
lineHeight: 1.5,
whiteSpace: 'pre-wrap',
wordBreak: 'break-word',
}}>
{text}
</div>
</div>
);
}
function VariantSummary({ data }: { data: ExpandedQuery }) {
const count =
(data.lex.trim() ? 1 : 0) +
data.vec.length +
(data.hyde.trim() ? 1 : 0);
if (count === 0) return null;
return (
<div style={{
fontSize: '0.72rem',
fontFamily: 'system-ui, -apple-system, sans-serif',
color: 'var(--text-secondary)',
marginBottom: '0.4rem',
padding: '0.3rem 0.5rem',
background: 'var(--bg-card)',
border: '1px solid var(--border)',
borderRadius: '5px',
}}>
Expanded into <strong style={{ color: 'var(--text)' }}>{count}</strong> search variant{count !== 1 ? 's' : ''}
</div>
);
}
export default function ExpansionColumn({ state, accent, info }: ExpansionColumnProps) {
const isIdle = state.status === 'idle';
const isRunning = state.status === 'running';
const isDone = state.status === 'done';
const isError = state.status === 'error';
return (
<div style={{ opacity: isIdle ? 0.45 : 1, transition: 'opacity 0.3s' }}>
<div style={{
display: 'flex',
alignItems: 'center',
gap: '0.4rem',
marginBottom: '0.75rem',
paddingBottom: '0.5rem',
borderBottom: '1px solid var(--stage-divider)',
}}>
<span style={{
width: '3px',
height: '14px',
borderRadius: '2px',
background: accent,
flexShrink: 0,
}} />
<h3 style={{
margin: 0,
fontSize: '0.78rem',
fontFamily: 'system-ui, -apple-system, sans-serif',
fontWeight: 700,
color: accent,
textTransform: 'uppercase',
letterSpacing: '0.05em',
}}>
Query Expansion
</h3>
{isRunning && <Spinner color={accent} />}
<InfoTooltip text={info} />
</div>
{isIdle && (
<p style={{
fontFamily: 'system-ui, -apple-system, sans-serif',
fontSize: '0.75rem',
color: 'var(--text-muted)',
margin: 0,
}}>
Awaiting query...
</p>
)}
{isRunning && (
<p style={{
fontFamily: 'system-ui, -apple-system, sans-serif',
fontSize: '0.75rem',
color: 'var(--text-secondary)',
margin: 0,
fontStyle: 'italic',
}}>
Generating...
</p>
)}
{isError && (
<div style={{
padding: '0.45rem 0.6rem',
background: 'var(--error-bg)',
border: '1px solid var(--error-border)',
borderRadius: '5px',
fontFamily: 'system-ui, -apple-system, sans-serif',
fontSize: '0.75rem',
color: '#c62828',
}}>
{state.error}
</div>
)}
{isDone && state.data && (
<>
{state.data.note && (
<div style={{
padding: '0.35rem 0.5rem',
marginBottom: '0.3rem',
background: 'var(--bg-card)',
border: '1px solid var(--border)',
borderRadius: '5px',
fontFamily: 'system-ui, -apple-system, sans-serif',
fontSize: '0.72rem',
color: 'var(--text-secondary)',
lineHeight: 1.45,
}}>
{state.data.note}
</div>
)}
<VariantSummary data={state.data} />
{state.data.lex.trim() && (
<CompactCard label="Lex" content={state.data.lex} />
)}
{state.data.vec.length > 0 && (
<CompactCard label="Vec" content={state.data.vec} />
)}
{state.data.hyde.trim() && (
<CompactCard label="HyDE" content={state.data.hyde} />
)}
</>
)}
</div>
);
}
|