Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

973 B
Raw Blame
import { Show } from 'solid-js';
import { match } from 'ts-pattern';
import type { ContentHitData } from '../types/search';

interface SearchLocationProps {
  hit?: ContentHitData;
}

/**
 * Gets location description for a content hit
 */
function getLocationDescription(hit: ContentHitData): string | undefined {
  return match(hit)
    .with({ type: 'pdf' }, (h) => `Page ${h.location.searchPage}`)
    .with(
      { type: 'agent' },
      (h) =>
        `${h.location.author === 'user' ? 'User' : 'Agent'} · Turn ${h.location.messageTurn + 1}`
    )
    .otherwise(() => undefined);
}

/**
 * Displays the location information for a search hit
 */
export function SearchLocation(props: SearchLocationProps) {
  const locationText = () =>
    props.hit ? getLocationDescription(props.hit) : undefined;

  return (
    <Show when={locationText()}>
      {(text) => (
        <span class="ph-no-capture text-ink-muted text-xs">{text()}</span>
      )}
    </Show>
  );
}