Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.
TypeScript ai-agentai-resume-analyzerapplication-trackerapplication-tracking-systematscareerjob-applicationjob-automationjob-huntingjob-searchjob-seeker-toolsjob-trackerjob-trackingjobsearchjobseekersmcpollamaresumeresume-reviewself-hosted
fix(notifications): pair light-mode colours with the dark tints in the bell popover and rows; stop refreshing the bell when the log stream ends, before finalizeRun records notifications
Khuram Niaz84c968dec327
diff --git a/__tests__/notificationColors.spec.tsx b/__tests__/notificationColors.spec.tsxnew file mode 100644index 0000000..f5f221c--- /dev/null+++ b/__tests__/notificationColors.spec.tsx@@ -0,0 +1,54 @@+import { render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { NotificationRow } from "@/components/notifications/NotificationRow";+import { NotificationBell } from "@/components/notifications/NotificationBell";++vi.mock("@/actions/notification.actions", () => ({+ getPopoverNotifications: vi.fn(),+ markNotificationRead: vi.fn(),+ markAllNotificationsRead: vi.fn(),+ dismissNotification: vi.fn(),+}));+vi.mock("@/context/NotificationContext", () => ({+ useNotifications: () => ({ summary: { unread: 2, unreadErrors: 1 }, refresh: vi.fn() }),+}));+import * as actions from "@/actions/notification.actions";++const at = new Date();+const run = {+ id: "r1", kind: "run", occurrences: 1, occurredAt: at, createdAt: at, readAt: null, dismissedAt: null,+ automation: { id: "a-1", name: "Remote Frontend" },+ payload: { status: "completed", jobsSearched: 38, jobsSaved: 12, belowThreshold: 0, boardsFailed: 0, aiError: null },+};+const board = {+ ...run, id: "b1", kind: "board",+ payload: { provider: "Greenhouse", token: "northwind", companyName: "Northwind", code: "not_found", reason: "Board 'northwind' returned 404" },+};+const readRun = { ...run, id: "r2", readAt: at };++// A dark-mode tint without a light pair is unreadable on a white popover.+const darkOnlyTints = (root: HTMLElement) =>+ Array.from(root.querySelectorAll("[class]"))+ .flatMap((el) => el.getAttribute("class")!.split(/\s+/))+ .filter((c) => /^(hover:)?(bg|text|border)-(red|green|blue)-(300|400|900|950)/.test(c));++it("rows pair every dark tint with a light one", () => {+ const { container } = render(+ <ul>+ {[run, board, readRun].flatMap((item) =>+ (["popover", "page"] as const).map((variant) => (+ <NotificationRow key={item.id + variant} item={item as any} variant={variant} onRemove={vi.fn()} onOpenLink={vi.fn()} />+ )),+ )}+ </ul>,+ );+ expect(darkOnlyTints(container)).toEqual([]);+});++it("the bell popover pairs every dark tint with a light one", async () => {+ (actions.getPopoverNotifications as any).mockResolvedValue({ success: true, data: [board, run] });+ render(<NotificationBell />);+ await userEvent.click(screen.getByRole("button", { name: /notifications/i }));+ await screen.findByText("Job board unreachable");+ expect(darkOnlyTints(document.body)).toEqual([]);+});diff --git a/__tests__/useAutomationRunNotifications.spec.tsx b/__tests__/useAutomationRunNotifications.spec.tsxnew file mode 100644index 0000000..1b2c718--- /dev/null+++ b/__tests__/useAutomationRunNotifications.spec.tsx@@ -0,0 +1,42 @@+import { act, renderHook } from "@testing-library/react";+import { useAutomationRun } from "@/components/automations/automation-detail-container/useAutomationRun";++const refresh = vi.fn();+vi.mock("@/context/NotificationContext", () => ({+ useNotifications: () => ({ refresh }),+}));+vi.mock("@/actions/automation.actions", () => ({ getAutomationRuns: vi.fn() }));+vi.mock("@/lib/toast", () => ({ toastSuccess: vi.fn(), toastError: vi.fn() }));++class FakeEventSource {+ static last: FakeEventSource;+ onmessage: ((e: { data: string }) => void) | null = null;+ constructor() {+ FakeEventSource.last = this;+ }+ close() {}+}++beforeEach(() => {+ vi.stubGlobal("EventSource", FakeEventSource);+});+afterEach(() => vi.unstubAllGlobals());++const emit = (data: object) =>+ act(() => FakeEventSource.last.onmessage?.({ data: JSON.stringify(data) }));++// The stream reports done before finalizeRun writes the notifications.+it("does not refresh notifications when only the log stream reports the end", () => {+ renderHook(() =>+ useAutomationRun({+ automationId: "a1",+ automation: null,+ latestRunId: null,+ loadData: vi.fn().mockResolvedValue(undefined),+ refreshJobs: vi.fn().mockResolvedValue(undefined),+ }),+ );+ emit({ logs: [], isRunning: true });+ emit({ logs: [], isRunning: false, completedAt: new Date().toISOString() });+ expect(refresh).not.toHaveBeenCalled();+});diff --git a/src/components/automations/automation-detail-container/useAutomationRun.ts b/src/components/automations/automation-detail-container/useAutomationRun.tsindex 9b0c8df..ffdb578 100644--- a/src/components/automations/automation-detail-container/useAutomationRun.ts+++ b/src/components/automations/automation-detail-container/useAutomationRun.ts@@ -101,10 +101,11 @@ export function useAutomationRun({wasRunningRef.current = true;} else if (wasRunningRef.current) {wasRunningRef.current = false;+ // No bell refresh here: the stream ends before finalizeRun records+ // notifications. The run watcher below refreshes once the row is terminal.if (!runNowLoading) loadData();- refreshNotifications();}- }, [logData.isRunning, runNowLoading, loadData, refreshNotifications]);+ }, [logData.isRunning, runNowLoading, loadData]);const handleClearLogs = useCallback(async () => {try {diff --git a/src/components/notifications/NotificationBell.tsx b/src/components/notifications/NotificationBell.tsxindex 15bb9a1..4921f0c 100644--- a/src/components/notifications/NotificationBell.tsx+++ b/src/components/notifications/NotificationBell.tsx@@ -94,7 +94,7 @@ export function NotificationBell() {<Buttonvariant="ghost"size="sm"- className="h-auto gap-1 px-1 py-1.5 text-[13px] font-medium text-blue-400 hover:text-blue-300"+ className="h-auto gap-1 px-1 py-1.5 text-[13px] font-medium text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300"onClick={onMarkAll}><CheckCheck className="h-3.5 w-3.5" />@@ -118,7 +118,7 @@ export function NotificationBell() {>{t.label}{t.id === "errors" && errorCount > 0 && (- <span className="rounded-full bg-red-950 px-1.5 text-[11px] font-semibold text-red-300">+ <span className="rounded-full bg-red-100 px-1.5 text-[11px] font-semibold text-red-700 dark:bg-red-950 dark:text-red-300">{errorCount}</span>)}@@ -146,7 +146,7 @@ export function NotificationBell() {<Linkhref="/dashboard/notifications"onClick={() => setOpen(false)}- className="font-medium text-blue-400 hover:text-blue-300 hover:underline"+ className="font-medium text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 hover:underline">View all notifications</Link>diff --git a/src/components/notifications/NotificationRow.tsx b/src/components/notifications/NotificationRow.tsxindex 0303031..d60694b 100644--- a/src/components/notifications/NotificationRow.tsx+++ b/src/components/notifications/NotificationRow.tsx@@ -32,7 +32,7 @@ export function NotificationRow({ item, variant, onRemove, onOpenLink }: Notific<liclassName={cn("flex gap-3 py-3 pl-4 pr-2",- unread && (isError ? "bg-red-950/40" : "bg-blue-950/40"),+ unread && (isError ? "bg-red-50 dark:bg-red-950/40" : "bg-blue-50 dark:bg-blue-950/40"),)}>{isPage && (@@ -45,9 +45,9 @@ export function NotificationRow({ item, variant, onRemove, onOpenLink }: Notific"flex shrink-0 items-center justify-center rounded-full",isPage ? "h-[34px] w-[34px]" : "h-8 w-8",isError- ? "bg-red-950 text-red-400"+ ? "bg-red-100 text-red-700 dark:bg-red-950 dark:text-red-400": unread- ? "bg-green-950 text-green-400"+ ? "bg-green-100 text-green-700 dark:bg-green-950 dark:text-green-400": "bg-muted text-muted-foreground",)}>@@ -88,7 +88,11 @@ export function NotificationRow({ item, variant, onRemove, onOpenLink }: Notific<bclassName={cn("font-semibold",- isError ? "text-red-300" : unread ? "text-green-400" : "text-foreground",+ isError+ ? "text-red-700 dark:text-red-300"+ : unread+ ? "text-green-700 dark:text-green-400"+ : "text-foreground",)}>{d.lead}@@ -96,7 +100,7 @@ export function NotificationRow({ item, variant, onRemove, onOpenLink }: Notific{d.detail}</span>{d.code && (- <code className="self-start rounded border border-red-900 bg-background px-1.5 py-1 font-mono text-[11.5px] text-red-300">+ <code className="self-start rounded border border-red-200 bg-background px-1.5 py-1 font-mono text-[11.5px] text-red-700 dark:border-red-900 dark:text-red-300">{d.code}</code>)}@@ -104,7 +108,7 @@ export function NotificationRow({ item, variant, onRemove, onOpenLink }: Notific<Linkhref={d.link.href}onClick={() => onOpenLink(item.id)}- className="self-start pt-1 text-[13px] font-medium text-blue-400 hover:text-blue-300 hover:underline"+ className="self-start pt-1 text-[13px] font-medium text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 hover:underline">{d.link.label}</Link>