A desktop coding agent with free access to frontier models.
TypeScript
fix: calmer start screen
ogsamratea28d2e20fbf
diff --git a/apps/app/src/react-app/domains/session/chat/session-empty-hero.tsx b/apps/app/src/react-app/domains/session/chat/session-empty-hero.tsxindex 9c926fb4..f1bc2c23 100644--- a/apps/app/src/react-app/domains/session/chat/session-empty-hero.tsx+++ b/apps/app/src/react-app/domains/session/chat/session-empty-hero.tsx@@ -7,7 +7,7 @@ import { CODING_STARTER_CARDS, resolveOrganizationPromptCardContent } from "@/coimport { useCheckDesktopRestriction, useOrgRestrictions } from "@/react-app/domains/cloud/desktop-config-provider";import { BuildathonPromoCard } from "@/react-app/domains/buildathon/buildathon-promo";import { PlacementHomeCard } from "@/react-app/domains/placements/placements";-import { HomeRecent, type HomeViewContext } from "@/react-app/domains/session/home/home-recent";+import { HomeContinue, type HomeViewContext } from "@/react-app/domains/session/home/home-recent";import {NewTaskComposer,type NewTaskComposerContext,@@ -156,9 +156,9 @@ export function SessionEmptyHero(props: SessionEmptyHeroProps) {</button>) : null}- {props.home?.sessions.length ? <HomeRecent context={props.home} /> : null}+ {props.home ? <HomeContinue context={props.home} /> : null}- {props.home?.sessions.length ? null : <div className="grid grid-cols-2 gap-1.5">+ <div className="grid grid-cols-2 gap-1.5">{suggestions.map((suggestion) => (<buttonkey={suggestion.title}@@ -174,7 +174,7 @@ export function SessionEmptyHero(props: SessionEmptyHeroProps) {</span></button>))}- </div>}+ </div><BuildathonPromoCard />diff --git a/apps/app/src/react-app/domains/session/home/home-recent.tsx b/apps/app/src/react-app/domains/session/home/home-recent.tsxindex a53f3ba0..87f16d6e 100644--- a/apps/app/src/react-app/domains/session/home/home-recent.tsx+++ b/apps/app/src/react-app/domains/session/home/home-recent.tsx@@ -1,165 +1,105 @@/** @jsxImportSource react */-import { useEffect, useMemo, useState } from "react";-import { FolderGit2, Loader2, MessageSquare, Search } from "lucide-react";+import { useLayoutEffect, useMemo, useRef, useState } from "react";+import { Search } from "lucide-react";import { formatRelativeTime } from "@/app/utils";-import { Input } from "@/components/ui/input";-import {- createSessionSearcher,- searchableSessionKey,- type SearchableSession,- type SessionMessageFetcher,- type SessionSearchSnippet,-} from "@/react-app/domains/session/search/session-search";-import { homeChatTitle, recentChats, recentProjects, titleMatches, type HomeWorkspace } from "./home-view-model";+import type { SearchableSession } from "@/react-app/domains/session/search/session-search";+import { homeChatTitle, recentChats, type HomeWorkspace } from "./home-view-model";-const MIN_QUERY_LENGTH = 2;-const DEBOUNCE_MS = 200;-const RESULT_LIMIT = 8;+/** How many recent chats the start screen offers to continue. */+export const HOME_CONTINUE_CHATS = 3;-/** What the home screen needs; every read is of chats already on this computer. */+/** What the start screen needs; every read is of chats already on this computer. */export type HomeViewContext = {sessions: SearchableSession[];workspaces: HomeWorkspace[];- fetchMessages: SessionMessageFetcher | null;onOpenSession: (workspaceId: string, sessionId: string) => void;+ /** Opens the app's chat search (the same dialog as Cmd/Ctrl+Shift+F). */+ onOpenSearch?: () => void;};-type SearchResult = { session: SearchableSession; snippet?: SessionSearchSnippet };--function useLocalChatSearch(context: HomeViewContext, query: string) {- const searcher = useMemo(() => (context.fetchMessages ? createSessionSearcher(context.fetchMessages) : null), [context.fetchMessages]);- const [debounced, setDebounced] = useState("");- const [results, setResults] = useState<SearchResult[]>([]);- const [searching, setSearching] = useState(false);-- useEffect(() => {- const timer = window.setTimeout(() => setDebounced(query.trim()), DEBOUNCE_MS);- return () => window.clearTimeout(timer);- }, [query]);-- useEffect(() => {- if (debounced.length < MIN_QUERY_LENGTH) {- setResults([]);- setSearching(false);- return;- }- const found = new Map<string, SearchResult>();- for (const session of titleMatches(context.sessions, debounced)) found.set(searchableSessionKey(session), { session });- setResults([...found.values()].slice(0, RESULT_LIMIT));- if (!searcher) return;- setSearching(true);- const run = searcher.search({- query: debounced,- sessions: context.sessions,- onMatch: (match) => {- const key = searchableSessionKey(match.session);- if (found.has(key) || found.size >= RESULT_LIMIT) return;- found.set(key, { session: match.session, snippet: match.snippet });- setResults([...found.values()]);- },- onProgress: (progress) => setSearching(!progress.done),- });- return () => run.cancel();- }, [context.sessions, debounced, searcher]);-- return { results, searching, active: debounced.length >= MIN_QUERY_LENGTH };+function searchShortcut(): string {+ const isMac = typeof navigator !== "undefined" && /Mac/i.test(navigator.platform);+ return isMac ? "⇧⌘F" : "Ctrl+Shift+F";}-export function HomeRecent({ context }: { context: HomeViewContext }) {- const [query, setQuery] = useState("");- const search = useLocalChatSearch(context, query);- const projects = useMemo(() => recentProjects(context.sessions, context.workspaces), [context.sessions, context.workspaces]);- const chats = useMemo(() => recentChats(context.sessions), [context.sessions]);- if (!context.sessions.length) return null;+/**+ * One quiet line under the composer: "Continue" with the latest chats as+ * text-like pills (chat · project) on the left, the chat search on the right.+ * Never wraps: a pill that does not fit whole is left out. The projects live+ * in the sidebar, past chats in the search.+ */+export function HomeContinue({ context }: { context: HomeViewContext }) {+ const chats = useMemo(() => {+ const tasks = new Set(context.workspaces.filter((workspace) => workspace.task).map((workspace) => workspace.id));+ return recentChats(context.sessions.filter((session) => !tasks.has(session.workspaceId)), HOME_CONTINUE_CHATS);+ }, [context.sessions, context.workspaces]);+ const listRef = useRef<HTMLDivElement | null>(null);+ const [fits, setFits] = useState(HOME_CONTINUE_CHATS);- return (- <div className="space-y-4" data-testid="home-recent">- <div className="relative">- <Search className="pointer-events-none absolute top-1/2 left-3 size-3.5 -translate-y-1/2 text-muted-foreground" aria-hidden="true" />- <Input- value={query}- onChange={(event) => setQuery(event.target.value)}- placeholder="Search your past chats"- aria-label="Search your past chats"- className="h-9 ps-8 text-[13px]"- data-testid="home-search"- />- {search.searching ? <Loader2 className="absolute top-1/2 right-3 size-3.5 -translate-y-1/2 animate-spin text-muted-foreground" aria-label="Searching" /> : null}- </div>+ useLayoutEffect(() => {+ const list = listRef.current;+ if (!list) return;+ const measure = () => {+ const available = list.clientWidth;+ const pills = [...list.querySelectorAll<HTMLElement>("[data-pill]")];+ let used = 0;+ let count = 0;+ for (const pill of pills) {+ used += pill.scrollWidth + (count ? 2 : 0);+ if (available > 0 && used > available) break;+ count += 1;+ }+ setFits(available > 0 ? count : pills.length);+ };+ measure();+ if (typeof ResizeObserver === "undefined") return;+ const observer = new ResizeObserver(measure);+ observer.observe(list);+ return () => observer.disconnect();+ }, [chats]);- {search.active ? (- <section aria-label="Search results" className="space-y-1">- {search.results.length ? search.results.map((result) => (- <ChatRow key={searchableSessionKey(result.session)} session={result.session} snippet={result.snippet} onOpen={context.onOpenSession} />- )) : (- <p className="px-1 py-2 text-[12px] text-muted-foreground">{search.searching ? "Searching your chats…" : "No chat matches."}</p>- )}- </section>- ) : (- <>- {projects.length ? (- <section aria-label="Recent projects" className="space-y-1.5">- <h3 className="px-1 text-[11px] font-medium tracking-wide text-muted-foreground uppercase">Recent projects</h3>- <div className="grid grid-cols-2 gap-1.5 sm:grid-cols-3">- {projects.map((project) => (- <button- key={project.workspaceId}- type="button"- className="flex min-w-0 flex-col items-start gap-0.5 rounded-lg border border-border/80 bg-background px-3 py-2 text-left transition-colors hover:bg-accent"- onClick={() => context.onOpenSession(project.workspaceId, project.lastSessionId)}- title={`Open the latest chat in ${project.name}`}- data-testid="home-project"- >- <span className="flex w-full min-w-0 items-center gap-1.5 text-[12px] font-medium text-foreground">- <FolderGit2 className="size-3.5 shrink-0 text-muted-foreground" aria-hidden="true" />- <span className="truncate">{project.name}</span>- </span>- <span className="text-[11px] text-muted-foreground">- {project.chats} chat{project.chats === 1 ? "" : "s"} · {formatRelativeTime(project.updatedAt)}- </span>- </button>- ))}- </div>- </section>- ) : null}- <section aria-label="Recent chats" className="space-y-1">- <h3 className="px-1 text-[11px] font-medium tracking-wide text-muted-foreground uppercase">Recent chats</h3>- {chats.map((session) => (- <ChatRow key={searchableSessionKey(session)} session={session} onOpen={context.onOpenSession} />- ))}- </section>- </>- )}- </div>- );-}+ if (!chats.length) return null;-function ChatRow(props: { session: SearchableSession; snippet?: SessionSearchSnippet; onOpen: (workspaceId: string, sessionId: string) => void }) {- const { session, snippet } = props;return (- <button- type="button"- className="flex w-full min-w-0 items-start gap-2 rounded-lg px-2 py-1.5 text-left transition-colors hover:bg-accent"- onClick={() => props.onOpen(session.workspaceId, session.sessionId)}- data-testid="home-chat"- >- <MessageSquare className="mt-0.5 size-3.5 shrink-0 text-muted-foreground" aria-hidden="true" />- <span className="min-w-0 flex-1">- <span className="flex min-w-0 items-baseline gap-2">- <span className="truncate text-[12px] font-medium text-foreground">{homeChatTitle(session.title)}</span>- <span className="ml-auto shrink-0 text-[11px] text-muted-foreground">{formatRelativeTime(session.updatedAt)}</span>- </span>- <span className="block truncate text-[11px] text-muted-foreground">- {snippet ? (- <>- {snippet.before}- <mark className="rounded-sm bg-amber-3 px-0.5 text-foreground">{snippet.match}</mark>- {snippet.after}- </>- ) : session.workspaceTitle}- </span>- </span>- </button>+ <nav aria-label="Recent chats" className="-mt-2 flex h-6 items-center gap-2 pb-1 text-[12px] text-muted-foreground" data-testid="home-continue">+ <span className="shrink-0 opacity-80">Continue</span>+ <div ref={listRef} className="flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden">+ {chats.map((session, index) => {+ const title = homeChatTitle(session.title);+ return (+ <button+ key={`${session.workspaceId}/${session.sessionId}`}+ type="button"+ data-pill=""+ className={`group inline-flex h-6 max-w-[180px] shrink-0 items-center gap-1 rounded-md px-2 transition-colors hover:bg-accent focus-visible:bg-accent focus-visible:outline-none ${index < fits ? "" : "invisible absolute"}`}+ onClick={() => context.onOpenSession(session.workspaceId, session.sessionId)}+ title={`${title} \u2014 ${session.workspaceTitle} \u00b7 ${formatRelativeTime(session.updatedAt)}`}+ aria-label={`Continue ${title} in ${session.workspaceTitle}`}+ aria-hidden={index < fits ? undefined : true}+ tabIndex={index < fits ? undefined : -1}+ data-testid="home-chat"+ >+ <span className="max-w-[130px] truncate group-hover:text-foreground">{title}</span>+ <span aria-hidden="true" className="shrink-0 opacity-50">·</span>+ <span className="shrink-0 opacity-70">{session.workspaceTitle}</span>+ </button>+ );+ })}+ </div>+ {context.onOpenSearch ? (+ <button+ type="button"+ className="inline-flex h-6 shrink-0 items-center gap-1 rounded-md px-2 transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:outline-none"+ onClick={context.onOpenSearch}+ aria-label={`Search chats (${searchShortcut()})`}+ data-testid="home-search"+ >+ <Search className="size-3" aria-hidden="true" />+ <span>Search</span>+ <span className="ml-1.5 text-[11px] opacity-60">{searchShortcut()}</span>+ </button>+ ) : null}+ </nav>);}diff --git a/apps/app/src/react-app/domains/session/home/home-view-model.ts b/apps/app/src/react-app/domains/session/home/home-view-model.tsindex 23334fb7..b606d997 100644--- a/apps/app/src/react-app/domains/session/home/home-view-model.ts+++ b/apps/app/src/react-app/domains/session/home/home-view-model.ts@@ -1,8 +1,7 @@import type { SearchableSession } from "@/react-app/domains/session/search/session-search";-/** Same limits and titles as the shared home view (apps/server/src/workspace/home-view.mjs). */+/** Same titles as the shared home view (apps/server/src/workspace/home-view.mjs). */export const HOME_RECENT_CHATS = 8;-export const HOME_RECENT_PROJECTS = 6;export type HomeWorkspace = {id: string;@@ -11,14 +10,6 @@ export type HomeWorkspace = {task: boolean;};-export type HomeProject = {- workspaceId: string;- name: string;- updatedAt: number;- chats: number;- lastSessionId: string;-};-/** A chat's title for lists (the engine's default "New session - <date>" reads "Untitled chat"). */export function homeChatTitle(title: string | null | undefined): string {const text = String(title ?? "").replace(/\s+/g, " ").trim();@@ -30,33 +21,3 @@ export function homeChatTitle(title: string | null | undefined): string {export function recentChats(sessions: SearchableSession[], limit = HOME_RECENT_CHATS): SearchableSession[] {return [...sessions].sort((a, b) => b.updatedAt - a.updatedAt).slice(0, limit);}--/**- * The projects with the newest chats, each with its latest chat (one click- * opens it). Task workspaces are left out: their repository's board lists them.- */-export function recentProjects(sessions: SearchableSession[], workspaces: HomeWorkspace[], limit = HOME_RECENT_PROJECTS): HomeProject[] {- const byId = new Map(workspaces.map((workspace) => [workspace.id, workspace]));- const projects = new Map<string, HomeProject>();- for (const session of recentChats(sessions, Number.POSITIVE_INFINITY)) {- const workspace = byId.get(session.workspaceId);- if (!workspace || workspace.task) continue;- const known = projects.get(session.workspaceId);- if (known) known.chats += 1;- else projects.set(session.workspaceId, {- workspaceId: session.workspaceId,- name: workspace.name || session.workspaceTitle,- updatedAt: session.updatedAt,- chats: 1,- lastSessionId: session.sessionId,- });- }- return [...projects.values()].slice(0, limit);-}--/** Chats whose title contains the query (the message text is searched separately, on this computer). */-export function titleMatches(sessions: SearchableSession[], query: string): SearchableSession[] {- const needle = query.trim().toLowerCase();- if (!needle) return [];- return recentChats(sessions, Number.POSITIVE_INFINITY).filter((session) => session.title.toLowerCase().includes(needle));-}diff --git a/apps/app/src/react-app/shell/session-route.tsx b/apps/app/src/react-app/shell/session-route.tsxindex b2a29e91..c2091422 100644--- a/apps/app/src/react-app/shell/session-route.tsx+++ b/apps/app/src/react-app/shell/session-route.tsx@@ -2860,18 +2860,18 @@ export function SessionRoute() {};}, [client, endpointForWorkspace, workspaces]);- // The home screen (no chat open): recent projects and chats across workspaces, searched on this computer.+ // The start screen (no chat open): a quiet row of recent chats to continue and the chat search.const homeView = useMemo<HomeViewContext>(() => ({sessions: paletteSessionOptions,workspaces: workspaces.map((workspace) => ({ id: workspace.id, name: workspace.displayNameResolved, task: Boolean(workspace.task) })),- fetchMessages: sessionSearchFetcher,+ onOpenSearch: () => setSessionSearchOpen(true),onOpenSession: (workspaceId, sessionId) => {setLegacySelectedWorkspaceId(workspaceId);writeActiveWorkspaceId(workspaceId);writeLastSessionFor(workspaceId, sessionId);navigateToWorkspaceSession(workspaceId, sessionId);},- }), [navigateToWorkspaceSession, paletteSessionOptions, sessionSearchFetcher, setLegacySelectedWorkspaceId, workspaces]);+ }), [navigateToWorkspaceSession, paletteSessionOptions, setLegacySelectedWorkspaceId, setSessionSearchOpen, workspaces]);const tasksPaletteItems = useMemo<PaletteItem[]>(() => tasksAvailable ? [{id: "tasks.open",diff --git a/apps/app/tests/home-recent.test.tsx b/apps/app/tests/home-recent.test.tsxindex e46fefbe..64f1de05 100644--- a/apps/app/tests/home-recent.test.tsx+++ b/apps/app/tests/home-recent.test.tsx@@ -2,7 +2,6 @@import { afterAll, describe, expect, test } from "bun:test";import { GlobalRegistrator } from "@happy-dom/global-registrator";-import type { OmniRushSessionMessage } from "../src/app/lib/omnirush-server";import type { SearchableSession } from "../src/react-app/domains/session/search/session-search";const registered = typeof globalThis.window === "undefined";@@ -14,8 +13,8 @@ afterAll(async () => {const { act } = await import("react");const { createRoot } = await import("react-dom/client");-const { HomeRecent } = await import("../src/react-app/domains/session/home/home-recent");-const { homeChatTitle, recentChats, recentProjects, titleMatches } = await import("../src/react-app/domains/session/home/home-view-model");+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[] = [@@ -30,81 +29,52 @@ const workspaces = [{ id: "ws_task", name: "app › add-a-greeting-ab12", task: true },];-function message(id: string, role: "user" | "assistant", text: string): OmniRushSessionMessage {- return {- info: { id, role, sessionID: "x" },- parts: [{ id: `${id}_p`, type: "text", text, sessionID: "x", messageID: id }],- } as unknown as OmniRushSessionMessage;-}-describe("home view model", () => {- test("recent chats are newest first across workspaces; projects open their latest chat and leave task copies out", () => {+ test("recent chats are newest first across workspaces", () => {expect(recentChats(sessions).map((s) => s.sessionId)).toEqual(["ses_t1", "ses_a1", "ses_s1", "ses_a0"]);- expect(recentProjects(sessions, workspaces)).toEqual([- { workspaceId: "ws_app", name: "app", updatedAt: now - 60_000, chats: 2, lastSessionId: "ses_a1" },- { workspaceId: "ws_site", name: "site", updatedAt: now - 120_000, chats: 1, lastSessionId: "ses_s1" },- ]);});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");- expect(titleMatches(sessions, "LOGIN").map((s) => s.sessionId)).toEqual(["ses_a1"]);});});-describe("home screen", () => {- test("shows recent projects and chats, opens one in a click, and searches past chats on this computer", async () => {+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[] = [];- const fetched: string[] = [];- const fetchMessages = async (_workspaceId: string, sessionId: string) => {- fetched.push(sessionId);- return sessionId === "ses_a0" ? [message("m1", "user", "please add a rate limiter to the upload handler")] : [];- };+ let searched = 0;document.body.innerHTML = "<div id=root></div>";const root = createRoot(document.getElementById("root")!);await act(async () => {- root.render(<HomeRecent context={{ sessions, workspaces, fetchMessages, onOpenSession: (w, s) => opened.push(`${w}/${s}`) }} />);+ root.render(<HomeContinue context={{ sessions, workspaces, onOpenSession: (w, s) => opened.push(`${w}/${s}`), onOpenSearch: () => { searched += 1; } }} />);});- const projects = [...document.querySelectorAll<HTMLButtonElement>("[data-testid=home-project]")];- expect(projects.map((p) => p.textContent)).toEqual([expect.stringContaining("app"), expect.stringContaining("site")]);- expect(projects[0]!.textContent).toContain("2 chats");+ // 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("Add a greeting"),expect.stringContaining("Fix the login redirect"),expect.stringContaining("Untitled chat"),expect.stringContaining("Older chat"),]);- await act(async () => { projects[0]!.click(); });- await act(async () => { chats[2]!.click(); });- expect(opened).toEqual(["ws_app/ses_a1", "ws_site/ses_s1"]);- expect(fetched).toEqual([]);-- const input = document.querySelector<HTMLInputElement>("[data-testid=home-search]")!;- await act(async () => {- Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value")!.set!.call(input, "rate limiter");- input.dispatchEvent(new Event("input", { bubbles: true }));- });- await act(async () => { await new Promise((resolve) => setTimeout(resolve, 400)); });- const results = [...document.querySelectorAll<HTMLButtonElement>("[data-testid=home-chat]")];- expect(results.length).toBe(1);- expect(results[0]!.textContent).toContain("Older chat");- expect(results[0]!.querySelector("mark")?.textContent).toBe("rate limiter");- expect(document.querySelector("[data-testid=home-project]")).toBeNull();- expect(fetched.sort()).toEqual(["ses_a0", "ses_a1", "ses_s1", "ses_t1"]);- await act(async () => { results[0]!.click(); });- expect(opened.at(-1)).toBe("ws_app/ses_a0");+ 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("nothing is shown before the first chat", async () => {+ 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(<HomeRecent context={{ sessions: [], workspaces, fetchMessages: null, onOpenSession: () => undefined }} />);+ root.render(<HomeContinue context={{ sessions: [], workspaces, onOpenSession: () => undefined, onOpenSearch: () => undefined }} />);});- expect(document.querySelector("[data-testid=home-recent]")).toBeNull();+ expect(document.querySelector("[data-testid=home-continue]")).toBeNull();await act(async () => root.unmount());});});