zz_

app/tui/types.ts

zzmq.dev@gmail.com/zz / app / tui / types.ts @ bce62350 Download
Ladder Summary
  • file The module defines two data‑shape interfaces—**LaneSnapshot** (a repository name paired with a `Lane` object) and **FlatEvent** (a repository name, lane ID, and a single `HistoryEntry`). It also exports the **flattenEvents** function, which iterates over an array of `LaneSnapshot`s, extracts every history entry, builds a flat array of `FlatEvent`s, and sorts them chronologically by the entry’s timestamp.
 // Shared data shapes fed into app/tui/'s components by both `zz work`
 // and `zz top` -- different arrangements of the same two building
 // blocks (a lane list, a filtered scrolling history feed), not two
 // separate UIs with their own data model.
 import type { HistoryEntry, Lane } from "../engine/types.js";
 
 export interface LaneSnapshot {
  repo: string;
  lane: Lane;
 }
 
 export interface FlatEvent {
  repo: string;
  laneId: string;
  entry: HistoryEntry;
 }
 
 export function flattenEvents(snapshots: LaneSnapshot[]): FlatEvent[] {
  const out: FlatEvent[] = [];
  for (const { repo, lane } of snapshots) {
  for (const entry of lane.history) {
  out.push({ repo, laneId: lane.id, entry });
  }
  }
  out.sort((a, b) => a.entry.at.localeCompare(b.entry.at));
  return out;
 }