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.

778 B
Raw Blame
import type { WorkbenchProject } from '../context/ApiContext';

/** Operation defaults follow recency, independently of the navigation order. */
export function sortProjectsByRecent(projects: readonly WorkbenchProject[]): WorkbenchProject[] {
  return [...projects].sort((a, b) =>
    (b.last_active_at || b.created_at).localeCompare(a.last_active_at || a.created_at) || a.id.localeCompare(b.id),
  );
}

/** Apply only order, preserving current row data and appending new projects. */
export function orderProjects<T extends { id: string }>(projects: T[], order: readonly string[]): T[] {
  const positions = new Map(order.map((id, index) => [id, index]));
  return [...projects].sort((a, b) => (positions.get(a.id) ?? order.length) - (positions.get(b.id) ?? order.length));
}