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

Function SearchResultCard

dashboard/lcm/src/components.tsx:449–501  ·  view source on GitHub ↗
(props: {
  key?: React.Key;
  item: any;
  kind: string;
  query: any;
  selected?: boolean;
  resultRef?: (el: HTMLElement | null) => void;
  onFocus: () => void;
  onOpen: () => void;
})

Source from the content-addressed store, hash-verified

447// --- list rows -------------------------------------------------------------
448
449export function SearchResultCard(props: {
450 key?: React.Key;
451 item: any;
452 kind: string;
453 query: any;
454 selected?: boolean;
455 resultRef?: (el: HTMLElement | null) => void;
456 onFocus: () => void;
457 onOpen: () => void;
458}): React.ReactElement {
459 const item = props.item;
460 const isMessage = props.kind === "message";
461 const title = isMessage
462 ? short(item.session_id || "", 42)
463 : short(summaryTitle(item.summary || ""), 90);
464 const preview = isMessage
465 ? renderSearchSnippet(item.snippet || short(item.content, 240), props.query)
466 : renderSearchSnippet(item.snippet || short(stripMd(item.summary), 240), props.query);
467 const keyValue = props.kind + ":" + String(isMessage ? item.store_id : item.node_id);
468 return (
469 <button
470 type="button"
471 ref={props.resultRef as any}
472 className={"hermes-lcm-result hermes-lcm-result-btn" + (props.selected ? " hermes-lcm-selected" : "")}
473 onClick={props.onOpen}
474 onFocus={props.onFocus}
475 onMouseEnter={props.onFocus}
476 >
477 <div className="hermes-lcm-row-meta">
478 <span className="hermes-lcm-pill hermes-lcm-pill-accent">
479 {isMessage ? (item.role || "message") : ("D" + item.depth)}
480 </span>
481 {!isMessage && item.category ? <span className="hermes-lcm-pill">{item.category}</span> : null}
482 {isMessage && item.source ? <span className="hermes-lcm-pill">{item.source}</span> : null}
483 {isMessage && item.tool_name ? <span className="hermes-lcm-pill">{short(item.tool_name, 24)}</span> : null}
484 <span className="hermes-lcm-dim">{keyValue}</span>
485 {isMessage
486 ? <TimeText className="hermes-lcm-dim" epoch={item.timestamp} />
487 : <TimeText className="hermes-lcm-dim" epoch={item.latest_at || item.created_at} />}
488 </div>
489 <div className="hermes-lcm-row-title">{title}</div>
490 <div className="hermes-lcm-msg-body">{preview}</div>
491 <div className="hermes-lcm-result-foot">
492 <span className="hermes-lcm-dim">
493 {isMessage
494 ? `${fmtInt(item.token_estimate)} tok · ${sessionLabel(item.session_id)}`
495 : `${fmtInt(item.source_token_count)}→${fmtInt(item.token_count)} tok · ${sessionLabel(item.session_id)}`}
496 </span>
497 <span className="hermes-lcm-dim">{isMessage ? "Open full message" : "Open source links"}</span>
498 </div>
499 </button>
500 );
501}
502
503export function MessageItem(props: {
504 key?: React.Key;

Callers

nothing calls this directly

Calls 6

shortFunction · 0.90
summaryTitleFunction · 0.90
stripMdFunction · 0.90
fmtIntFunction · 0.90
sessionLabelFunction · 0.90
renderSearchSnippetFunction · 0.85

Tested by

no test coverage detected