Skip to content
Merged
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
1 change: 1 addition & 0 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ vi.mock("./lib/tauri", async (importOriginal) => {
return {
...actual,
authGetStatus: vi.fn().mockResolvedValue({ connected: true, username: "test-user", error: null }),
listNotifications: vi.fn().mockResolvedValue([]),
};
});

Expand Down
37 changes: 37 additions & 0 deletions src/components/Sidebar/Sidebar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,38 @@ vi.mock("../../lib/tauri", () => ({
lastSyncAt: "2026-03-28T10:00:00Z",
},
]),
listNotifications: vi.fn().mockResolvedValue([
{
id: "notif-1",
title: "Unread review request",
url: "https://github.com/acme/frontend/pull/1",
unread: true,
updatedAt: "2026-03-28T10:00:00Z",
repo: "acme/frontend",
reason: "review_requested",
Comment thread
greptile-apps[bot] marked this conversation as resolved.
notificationType: "pullRequest",
},
{
id: "notif-2",
title: "Unread issue mention",
url: "https://github.com/acme/frontend/issues/2",
unread: true,
updatedAt: "2026-03-28T11:00:00Z",
repo: "acme/frontend",
reason: "mention",
notificationType: "issue",
},
{
id: "notif-3",
title: "Read merge comment",
url: "https://github.com/acme/frontend/pull/3",
unread: false,
updatedAt: "2026-03-28T12:00:00Z",
repo: "acme/frontend",
reason: "comment",
notificationType: "pullRequest",
},
Comment thread
greptile-apps[bot] marked this conversation as resolved.
]),
setRepoEnabled: vi.fn().mockResolvedValue({}),
authGetStatus: vi.fn().mockResolvedValue({
connected: true,
Expand Down Expand Up @@ -109,6 +141,11 @@ describe("Sidebar", () => {
expect(screen.getByText("3")).toBeInTheDocument();
});

it("should show unread notification count", async () => {
renderSidebar();
expect(await screen.findByRole("button", { name: /notifications \(2\)/i })).toBeInTheDocument();
});

it("should show workspace dots with state colors", () => {
const { container } = renderSidebar();
const dots = container.querySelectorAll("[data-state]");
Expand Down
21 changes: 19 additions & 2 deletions src/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { DashboardView } from "../../stores/dashboard";
import { useWorkspacesStore } from "../../stores/workspaces";
import { useGitHubData } from "../../hooks/useGitHubData";
import { FOCUS_RING } from "../../lib/a11y";
import { listRepos, setRepoEnabled, authGetStatus } from "../../lib/tauri";
import { listNotifications, listRepos, setRepoEnabled, authGetStatus } from "../../lib/tauri";
import { NavItem } from "./NavItem";
import { WorkspaceList } from "./WorkspaceList";
import { RepoList } from "./RepoList";
Expand Down Expand Up @@ -54,6 +54,15 @@ export function Sidebar(): ReactElement {
refetchOnWindowFocus: false,
});

const isGitHubConnected = authQuery.data?.connected === true;

const notificationsQuery = useQuery({
queryKey: ["github", "notifications"],
queryFn: listNotifications,
staleTime: 60_000,
enabled: isGitHubConnected,
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.

const toggleRepoMutation = useMutation({
mutationFn: ({ repoId, enabled }: { repoId: string; enabled: boolean }) =>
setRepoEnabled(repoId, enabled),
Expand Down Expand Up @@ -87,6 +96,8 @@ export function Sidebar(): ReactElement {
const repos = reposQuery.data ?? [];
const enabledRepos = repos.filter((r) => r.enabled);
const username = authQuery.data?.username ?? null;
const unreadNotificationsCount =
notificationsQuery.data?.filter((item) => item.unread).length ?? 0;

useEffect(() => {
if (typeof document !== "undefined" && navGroupRef.current?.contains(document.activeElement)) {
Expand Down Expand Up @@ -173,7 +184,13 @@ export function Sidebar(): ReactElement {
}}
label={item.label}
view={item.view}
count={item.countKey && stats ? stats[item.countKey] : undefined}
count={
item.view === "notifications"
? unreadNotificationsCount
: item.countKey && stats
? stats[item.countKey]
: undefined
}
isActive={currentView === item.view}
tabIndex={focusedView === item.view ? 0 : -1}
onClick={handleNavClick}
Expand Down
Loading