MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / CompressionBars

Function CompressionBars

dashboard/lcm/src/components.tsx:200–242  ·  view source on GitHub ↗
(props: { groups?: any[]; onPick?: (g: any) => void })

Source from the content-addressed store, hash-verified

198
199/** Per-group compression (kept vs saved), rendered as a small inline SVG. */
200export function CompressionBars(props: { groups?: any[]; onPick?: (g: any) => void }): React.ReactElement {
201 const groups = props.groups || [];
202 const onPick = props.onPick;
203 if (!groups.length) return <EmptyState className="hermes-lcm-empty">No compression data</EmptyState>;
204 const maxSrc = groups.reduce((acc, g) => Math.max(acc, Number(g.source_token_count) || 0), 0) || 1;
205 return (
206 <div className="hermes-lcm-comp">
207 {groups.map(function (g, idx) {
208 const src = Number(g.source_token_count) || 0;
209 const out = Number(g.token_count) || 0;
210 const totalW = Math.max(0.5, (src / maxSrc) * 100);
211 const keptW = src > 0 ? (out / src) * totalW : 0;
212 const sid = g.session_id != null ? g.session_id : g.key;
213 const label = (typeof sid === "string" && /^\d{8}_/.test(sid))
214 ? sessionLabel(sid)
215 : (g.depth != null ? `node #${g.key} (D${g.depth})` : String(g.key));
216 const clickable = typeof onPick === "function";
217 return (
218 <div
219 key={String(g.key) + idx}
220 className={"hermes-lcm-comp-row" + (clickable ? " hermes-lcm-clk" : "")}
221 onClick={clickable ? function () { onPick!(g); } : undefined}
222 >
223 <div className="hermes-lcm-comp-head">
224 <span className="hermes-lcm-k">{label}</span>
225 <span className="hermes-lcm-v">{`${g.ratio || 0}× · ${fmtInt(src)}→${fmtInt(out)}`}</span>
226 </div>
227 <svg
228 viewBox="0 0 100 8"
229 preserveAspectRatio="none"
230 width="100%"
231 height={8}
232 className="hermes-lcm-svgbar"
233 >
234 <rect x={0} y={0} width={totalW} height={8} rx={1.5} className="hermes-lcm-svg-saved" />
235 <rect x={0} y={0} width={keptW} height={8} rx={1.5} className="hermes-lcm-svg-kept" />
236 </svg>
237 </div>
238 );
239 })}
240 </div>
241 );
242}
243
244// --- tool-result rendering. Known tools get bespoke components; any other
245// JSON falls back to a clean key/value view; non-JSON to markdown. -----------

Callers

nothing calls this directly

Calls 3

sessionLabelFunction · 0.90
fmtIntFunction · 0.90
testMethod · 0.80

Tested by

no test coverage detected