Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion frontend/src/renderer/components/Sidebar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { Sidebar } from "./Sidebar";
import type { WorkspaceSummary } from "../types/workspace";
import type { WorkspaceSession, WorkspaceSummary } from "../types/workspace";

const { navigateMock } = vi.hoisted(() => ({ navigateMock: vi.fn() }));

Expand All @@ -25,6 +25,21 @@ const workspace: WorkspaceSummary = {
sessions: [],
};

function workerSession(overrides: Partial<WorkspaceSession>): WorkspaceSession {
return {
id: "reverbcode-2",
workspaceId: "proj-1",
workspaceName: "Project One",
title: "reverbcode-2",
provider: "claude-code",
kind: "worker",
branch: "session/reverbcode-2",
status: "working",
updatedAt: "2026-06-17T00:00:00Z",
...overrides,
};
}

function renderSidebar(onRemoveProject = vi.fn().mockResolvedValue(undefined)) {
render(
<SidebarProvider>
Expand Down Expand Up @@ -74,6 +89,40 @@ describe("Sidebar", () => {
expect(onRemoveProject).not.toHaveBeenCalled();
});

it("does not repeat the session id under the title when the title is the id", () => {
const sessions = [workerSession({ id: "reverbcode-2", title: "reverbcode-2" })];
render(
<SidebarProvider>
<Sidebar
daemonStatus={{ state: "running" }}
onCreateProject={vi.fn()}
onRemoveProject={vi.fn()}
workspaces={[{ ...workspace, sessions }]}
/>
</SidebarProvider>,
);

// Title renders once; the id subtitle is suppressed because it would duplicate it.
expect(screen.getAllByText("reverbcode-2")).toHaveLength(1);
});

it("shows the session id under a distinct display name", () => {
const sessions = [workerSession({ id: "reverbcode-2", title: "fix the sidebar" })];
render(
<SidebarProvider>
<Sidebar
daemonStatus={{ state: "running" }}
onCreateProject={vi.fn()}
onRemoveProject={vi.fn()}
workspaces={[{ ...workspace, sessions }]}
/>
</SidebarProvider>,
);

expect(screen.getByText("fix the sidebar")).toBeInTheDocument();
expect(screen.getByText("reverbcode-2")).toBeInTheDocument();
});

it("hides the worker count in every state that reveals project actions", () => {
renderSidebar();

Expand Down
8 changes: 7 additions & 1 deletion frontend/src/renderer/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,13 @@ function ProjectItem({
>
{session.title}
</span>
<span className="block truncate font-mono text-[10px] text-passive">{session.id}</span>
{/* The id is a secondary handle; when the worker has no
displayName/issueId the title already falls back to the
id (useWorkspaceQuery), so skip the line rather than
repeat the same string twice. */}
{session.title !== session.id && (
<span className="block truncate font-mono text-[10px] text-passive">{session.id}</span>
)}
</span>
</button>
</SidebarMenuSubButton>
Expand Down