Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

2.3 KB
Raw Blame
import clsx from 'clsx';
import { Loader2, Pin } from 'lucide-react';
import type { MouseEventHandler } from 'react';

import { SESSION_ROW_ACTION_BUTTON_CLASS, SESSION_ROW_PIN_POSITION_CLASS } from './sessionRowLayout';

interface SessionPinActionProps {
  pinned: boolean;
  pending: boolean;
  pinLabel: string;
  unpinLabel: string;
  onToggle: () => void;
  className?: string;
}

// Direct pin control for desktop sidebar rows. The shared session action model
// still owns persistence; this component only restores the compact row affordance.
export const SessionPinAction: React.FC<SessionPinActionProps> = ({
  pinned,
  pending,
  pinLabel,
  unpinLabel,
  onToggle,
  className,
}) => {
  const label = pinned ? unpinLabel : pinLabel;
  const handleClick: MouseEventHandler<HTMLButtonElement> = (event) => {
    event.stopPropagation();
    onToggle();
  };

  return (
    <span className={clsx('absolute inset-y-0 flex items-center', SESSION_ROW_PIN_POSITION_CLASS, className)}>
      <button
        type="button"
        disabled={pending}
        aria-label={label}
        aria-pressed={pinned}
        title={label}
        onClick={handleClick}
        className={clsx(
          'group/pin grid shrink-0 place-items-center transition-[opacity,transform,background-color,color,box-shadow] duration-150 ease-out',
          SESSION_ROW_ACTION_BUTTON_CLASS,
          'hover:-translate-y-px hover:scale-105 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-cyan/60 motion-reduce:transform-none',
          pending
            ? 'cursor-wait text-muted opacity-100 hover:translate-y-0 hover:scale-100'
            : pinned
              ? 'text-cyan-ink opacity-100 hover:bg-cyan/[0.18] hover:ring-1 hover:ring-cyan/30'
              : 'text-muted opacity-0 hover:bg-foreground/[0.08] hover:text-foreground group-hover/sess:opacity-100 group-focus-within/sess:opacity-100 pointer-coarse:opacity-100',
        )}
      >
        {pending ? (
          <Loader2 className="size-3 animate-spin" aria-hidden="true" />
        ) : (
          <Pin
            className="size-3 transition-transform duration-150 group-hover/pin:-rotate-12 group-hover/pin:scale-110 motion-reduce:transform-none"
            aria-hidden="true"
          />
        )}
      </button>
    </span>
  );
};