feat(ui): interactive graph, strip context menus, days by activity, message times, limit status words

This commit is contained in:
hh
2026-09-02 04:24:15 +02:00
parent 256b2a68d6
commit d41f18504c
27 changed files with 1619 additions and 381 deletions
+53 -14
View File
@@ -6,6 +6,8 @@ export interface DayGroup {
branches: ConversationSummary[];
day: string;
deep: ConversationSummary[];
forks: ConversationSummary[];
jobs: ConversationSummary[];
label: string;
live: boolean;
master: ConversationSummary | null;
@@ -43,15 +45,16 @@ function activityOf(row: ConversationSummary): string {
return row.last_activity_at ?? row.created_at ?? "";
}
// Days as the operator remembers them: a master per day, its branches
// under it, deep chats by the day they last moved, forks with their
// parent's day. Jobs never enter the rail.
// Days as the operator remembers them: the master that began that day,
// and under it everything that last moved that day - branches, deep
// chats, forks, job runs. Open branches follow the master through the
// rotation, so their parent says nothing about when they were alive;
// the day of their last word does.
export function groupByDay(
rows: ConversationSummary[],
now = new Date()
): DayGroup[] {
const groups = new Map<string, DayGroup>();
const dayOfMaster = new Map<string, string>();
const group = (day: string): DayGroup => {
let found = groups.get(day);
if (!found) {
@@ -59,6 +62,8 @@ export function groupByDay(
branches: [],
day,
deep: [],
forks: [],
jobs: [],
label: dayLabel(day, now),
live: false,
master: null,
@@ -72,9 +77,7 @@ export function groupByDay(
.filter((row) => row.kind === "master")
.sort((a, b) => (b.created_at ?? "").localeCompare(a.created_at ?? ""));
for (const master of masters) {
const day = localDay(master.created_at);
dayOfMaster.set(master.id, day);
const g = group(day);
const g = group(localDay(master.created_at));
if (!g.master || master.status === "open") {
g.master = master;
} else {
@@ -82,16 +85,18 @@ export function groupByDay(
}
}
for (const row of rows) {
if (row.kind === "master" || row.kind === "job") {
if (row.kind === "master") {
continue;
}
const parentDay = row.parent ? dayOfMaster.get(row.parent) : undefined;
const day = parentDay ?? localDay(activityOf(row));
const g = group(day);
const g = group(localDay(activityOf(row)));
if (row.kind === "branch") {
g.branches.push(row);
} else if (row.kind === "deep") {
g.deep.push(row);
} else if (row.kind === "fork") {
g.forks.push(row);
} else if (row.kind === "job") {
g.jobs.push(row);
} else {
g.others.push(row);
}
@@ -100,10 +105,44 @@ export function groupByDay(
for (const g of out) {
g.branches.sort(byActivity);
g.deep.sort(byActivity);
g.forks.sort(byActivity);
g.jobs.sort(byActivity);
g.others.sort(byActivity);
g.live = [g.master, ...g.branches, ...g.deep, ...g.others].some(
(row) => row && (row.running_turn || row.pending_question)
);
g.live = [
g.master,
...g.branches,
...g.deep,
...g.forks,
...g.jobs,
...g.others,
].some((row) => row && (row.running_turn || row.pending_question));
}
return out.sort((a, b) => b.day.localeCompare(a.day));
}
// One phrase for the day header: what the day held, and whether its
// master is still the live one.
export function daySummary(group: DayGroup, today: boolean): string {
const parts: string[] = [];
if (group.master?.status === "open" && !today) {
parts.push("master still open");
}
const count = (n: number, one: string, many = `${one}s`) =>
`${n} ${n === 1 ? one : many}`;
if (group.branches.length) {
parts.push(count(group.branches.length, "branch", "branches"));
}
if (group.deep.length) {
parts.push(count(group.deep.length, "deep", "deep"));
}
if (group.forks.length) {
parts.push(count(group.forks.length, "fork"));
}
if (group.jobs.length) {
parts.push(count(group.jobs.length, "job run"));
}
if (group.others.length) {
parts.push(count(group.others.length, "more", "more"));
}
return parts.join(" · ");
}