All files / src/apps/user/pages/knowledge/map SourceMapLegend.tsx

100% Statements 4/4
100% Branches 0/0
100% Functions 2/2
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                        4x   4x 27x                                                             90x                            
import type { SourceMapKind } from "@/objects/Knowledge";
import { TriangleAlert } from "lucide-react";
import React from "react";
 
/**
 * How to read the source map: the marks, then each kind of evidence a
 * connection can rest on (svc-core's registry, served with the map) with
 * the most it can weigh. A connection's weight is the kinds together —
 * `1 − Π(1 − strength × score)` — so two kinds read stronger than either,
 * and none passes 100%.
 */
 
const swatch = "inline-block shrink-0 border-2 bg-white dark:bg-gray-800";
 
const SourceMapLegend: React.FC<{ kinds: SourceMapKind[] }> = ({ kinds }) => (
  <div className="grid gap-4 text-[11px] text-gray-500 dark:text-gray-400 sm:grid-cols-2">
    <ul className="space-y-1.5" aria-label="Marks">
      <li className="flex items-center gap-2">
        <span className={`${swatch} size-3.5 rounded-full border-emerald-600`} />
        <span>
          A source here, sized by what it holds; its ring is its health, and{" "}
          <TriangleAlert
            className="inline size-3 align-[-2px] text-amber-600"
            aria-label="a warning sign"
          />{" "}
          marks one that needs attention
        </span>
      </li>
      <li className="flex items-center gap-2">
        <span className={`${swatch} size-3.5 rounded-full border-dashed border-gray-400`} />
        A source of this workspace the evidence ties to it, not in it
      </li>
      <li className="flex items-center gap-2">
        <span className={`${swatch} size-3.5 rounded border-gray-300 dark:border-gray-600`} />
        An agent granted it; dotted lines are its share of citations
      </li>
      <li className="flex items-center gap-2">
        <span className="inline-flex w-3.5 shrink-0 flex-col gap-0.5">
          <span className="h-px bg-gray-400" />
          <span className="h-1 bg-gray-400" />
        </span>
        A connection, as wide as it is strong
      </li>
    </ul>
    <dl className="space-y-1.5">
      {kinds.map((kind) => (
        <div key={kind.key}>
          <dt className="inline font-medium text-gray-700 dark:text-gray-200">
            {kind.label}
          </dt>{" "}
          <dd className="inline">
            — {kind.description} Weighs up to {Math.round(kind.strength * 100)}%.
          </dd>
        </div>
      ))}
    </dl>
  </div>
);
 
export default SourceMapLegend;