Q159: the home page's recent runs are the newest ones

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-09 02:33:37 -04:00
1 parent 9d166e3fc9
commit 459dcf0ea2
3 files changed
+16 -1

No files matched your search

+2 -1
View File
@@ -1,3 +1,4 @@
import { newestRuns } from "./runs/newest-runs";
import { isBusinessTask } from "./work/task-helpers";
import { useMemo, useState, type CSSProperties } from "react";
import { Avatar, Button, Icon, Pill } from "../shared/ui";
@@ -222,7 +223,7 @@ function RunActivityCard({
agents: AgentRecord[];
onViewAll: () => void;
}) {
const recent = taskRuns.slice(0, 6);
const recent = newestRuns(taskRuns, 6);
return (
<section className="card">
<div className="row" style={{ marginBottom: 12 }}>
@@ -0,0 +1,4 @@
/** The newest `count` runs, newest first; the snapshot lists runs oldest first (time, then insertion). */
export function newestRuns<T>(runs: T[], count: number): T[] {
return runs.slice(-count).reverse();
}
+10
View File
@@ -0,0 +1,10 @@
import { describe, expect, test } from "vitest";
import { newestRuns } from "../../src/renderer/src/pages/runs/newest-runs";
describe("the home page's recent runs", () => {
test("are the newest ones, newest first, from the snapshot's oldest-first list", () => {
const runs = Array.from({ length: 10 }, (_, index) => ({ id: `run_${index}` }));
expect(newestRuns(runs, 3).map((run) => run.id)).toEqual(["run_9", "run_8", "run_7"]);
expect(newestRuns(runs.slice(0, 2), 6).map((run) => run.id)).toEqual(["run_1", "run_0"]);
});
});