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:
1 parent
9d166e3fc9
commit
459dcf0ea2
3 files changed
+16
-1
No files matched your search
@@ -1,3 +1,4 @@
|
|||||||
|
import { newestRuns } from "./runs/newest-runs";
|
||||||
import { isBusinessTask } from "./work/task-helpers";
|
import { isBusinessTask } from "./work/task-helpers";
|
||||||
import { useMemo, useState, type CSSProperties } from "react";
|
import { useMemo, useState, type CSSProperties } from "react";
|
||||||
import { Avatar, Button, Icon, Pill } from "../shared/ui";
|
import { Avatar, Button, Icon, Pill } from "../shared/ui";
|
||||||
@@ -222,7 +223,7 @@ function RunActivityCard({
|
|||||||
agents: AgentRecord[];
|
agents: AgentRecord[];
|
||||||
onViewAll: () => void;
|
onViewAll: () => void;
|
||||||
}) {
|
}) {
|
||||||
const recent = taskRuns.slice(0, 6);
|
const recent = newestRuns(taskRuns, 6);
|
||||||
return (
|
return (
|
||||||
<section className="card">
|
<section className="card">
|
||||||
<div className="row" style={{ marginBottom: 12 }}>
|
<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();
|
||||||
|
}
|
||||||
@@ -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"]);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in new issue
Block a user