A desktop coding agent with free access to frontier models.
TypeScript
/** @jsxImportSource react */
import { afterAll, describe, expect, test } from "bun:test";
import { GlobalRegistrator } from "@happy-dom/global-registrator";
import type { SearchableSession } from "../src/react-app/domains/session/search/session-search";
const registered = typeof globalThis.window === "undefined";
if (registered) GlobalRegistrator.register({ url: "http://localhost/" });
Object.defineProperty(globalThis, "IS_REACT_ACT_ENVIRONMENT", { configurable: true, value: true });
afterAll(async () => {
if (registered) await GlobalRegistrator.unregister();
});
const { act } = await import("react");
const { createRoot } = await import("react-dom/client");
const { HomeContinue } = await import("../src/react-app/domains/session/home/home-recent");
const { homeChatTitle, recentChats } = await import("../src/react-app/domains/session/home/home-view-model");
const now = Date.now();
const sessions: SearchableSession[] = [
{ workspaceId: "ws_app", sessionId: "ses_a1", title: "Fix the login redirect", workspaceTitle: "app", updatedAt: now - 60_000 },
{ workspaceId: "ws_site", sessionId: "ses_s1", title: "New session - 2026-10-19T10:00:00.000Z", workspaceTitle: "site", updatedAt: now - 120_000 },
{ workspaceId: "ws_app", sessionId: "ses_a0", title: "Older chat", workspaceTitle: "app", updatedAt: now - 3_600_000 },
{ workspaceId: "ws_task", sessionId: "ses_t1", title: "Add a greeting", workspaceTitle: "app › add-a-greeting-ab12", updatedAt: now - 30_000 },
];
const workspaces = [
{ id: "ws_app", name: "app", task: false },
{ id: "ws_site", name: "site", task: false },
{ id: "ws_task", name: "app › add-a-greeting-ab12", task: true },
];
describe("home view model", () => {
test("recent chats are newest first across workspaces", () => {
expect(recentChats(sessions).map((s) => s.sessionId)).toEqual(["ses_t1", "ses_a1", "ses_s1", "ses_a0"]);
});
test("titles read like the CLI's: the engine's default title is an untitled chat", () => {
expect(homeChatTitle("New session - 2026-10-19T10:00:00.000Z")).toBe("Untitled chat");
expect(homeChatTitle(" Fix it ")).toBe("Fix it");
});
});
describe("start screen row", () => {
test("a quiet row: at most three recent chats to continue (task copies left out) and the chat search", async () => {
const opened: string[] = [];
let searched = 0;
document.body.innerHTML = "<div id=root></div>";
const root = createRoot(document.getElementById("root")!);
await act(async () => {
root.render(<HomeContinue context={{ sessions, workspaces, onOpenSession: (w, s) => opened.push(`${w}/${s}`), onOpenSearch: () => { searched += 1; } }} />);
});
// One line: no section headers, project cards or long lists on the start screen.
expect(document.querySelector("[data-testid=home-continue]")!.className).not.toContain("flex-wrap");
expect(document.querySelector("h3")).toBeNull();
expect(document.querySelector("[data-testid=home-project]")).toBeNull();
const chats = [...document.querySelectorAll<HTMLButtonElement>("[data-testid=home-chat]")];
expect(chats.map((c) => c.textContent)).toEqual([
expect.stringContaining("Fix the login redirect"),
expect.stringContaining("Untitled chat"),
expect.stringContaining("Older chat"),
]);
expect(chats[0]!.textContent).toContain("app");
expect(chats[0]!.getAttribute("aria-label")).toBe("Continue Fix the login redirect in app");
await act(async () => { chats[1]!.click(); });
expect(opened).toEqual(["ws_site/ses_s1"]);
await act(async () => { document.querySelector<HTMLButtonElement>("[data-testid=home-search]")!.click(); });
expect(searched).toBe(1);
await act(async () => root.unmount());
});
test("before the first chat the row is not shown at all (the hero stays as it was)", async () => {
document.body.innerHTML = "<div id=root></div>";
const root = createRoot(document.getElementById("root")!);
await act(async () => {
root.render(<HomeContinue context={{ sessions: [], workspaces, onOpenSession: () => undefined, onOpenSearch: () => undefined }} />);
});
expect(document.querySelector("[data-testid=home-continue]")).toBeNull();
await act(async () => root.unmount());
});
});