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
4 changes: 4 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
- UI/router/search-state: targeted tests + `npm run lint`.
- Larger changes: `npm run test:once` + `npm run build`.
- Go changes: `make lint`.
- User-facing changes (features, bug fixes, behavior changes): add an
`Unreleased` changelog entry in `CHANGELOG.md` under the correct section.
- Changelog entries for user-facing changes should include a PR reference
link using project convention: `[PR #XXX](https://github.com/riverqueue/riverui/pull/XXX)`.

## Commits
- Title <= 50 chars (max 72); wrap body ~72.
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Prevent double slash in URLs for root path prefix. Thanks [Jan Kott](https://github.com/boostvolt)! [PR #487](https://github.com/riverqueue/riverui/pull/487)
- Prevent double slash in URLs for root path prefix. Thanks [Jan Kott](https://github.com/boostvolt)! [PR #487](https://github.com/riverqueue/riverui/pull/487).
- Serve UI HTML for wildcard or missing Accept headers and return 406 for explicit non-HTML requests. Fixes #485. [PR #493](https://github.com/riverqueue/riverui/pull/493).
- Prevent jobs detail navigation from bouncing back to `/jobs/` on slow networks due to stale filter-sync URL updates. Fixes #495. [PR #504](https://github.com/riverqueue/riverui/pull/504).

## [v0.14.0] - 2026-01-02

Expand Down
20 changes: 20 additions & 0 deletions src/components/job-search/JobSearch.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,26 @@ describe("JobSearch", () => {
}),
]);
});

it("does not notify parent on unrelated rerenders", async () => {
const onFiltersChange = vi.fn();
const { rerender } = render(
<JobSearch onFiltersChange={onFiltersChange} />,
);

await act(async () => {
await new Promise((resolve) => setTimeout(resolve, 250));
});
onFiltersChange.mockClear();

rerender(<JobSearch onFiltersChange={onFiltersChange} />);

await act(async () => {
await new Promise((resolve) => setTimeout(resolve, 250));
});

expect(onFiltersChange).not.toHaveBeenCalled();
});
});

describe("Suggestion System", () => {
Expand Down
7 changes: 5 additions & 2 deletions src/components/job-search/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useEffect, useRef, useState } from "react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";

import {
analyzeAutocompleteContext,
Expand Down Expand Up @@ -50,7 +50,10 @@ export function useFilterInput({
} | null>(null);

const debounceTimeoutRef = useRef<number | undefined>(undefined);
const currentFilters = parseFiltersFromText(inputValue);
const currentFilters = useMemo(
() => parseFiltersFromText(inputValue),
[inputValue],
);

const {
clearSuggestions,
Expand Down
30 changes: 29 additions & 1 deletion src/routes/jobs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ const minimumLimit = 20;
const defaultLimit = 20;
const maximumLimit = 200;

const areStringArraysEqual = (a?: string[], b?: string[]) => {
if (a === b) return true;
if (!a && !b) return true;
if (!a || !b) return false;
if (a.length !== b.length) return false;
return a.every((value, index) => value === b[index]);
};

export const Route = createFileRoute("/jobs/")({
validateSearch: jobSearchSchema,
// Strip default values from URLs and retain important params across navigation
Expand Down Expand Up @@ -165,6 +173,26 @@ function JobsIndexComponent() {
}
});

const currentSearchParams = {
id: id?.map(String),
kind,
priority: priority?.map(String),
queue,
};

// Avoid no-op navigations that can race with route transitions.
if (
areStringArraysEqual(currentSearchParams.id, searchParams.id) &&
areStringArraysEqual(currentSearchParams.kind, searchParams.kind) &&
areStringArraysEqual(
currentSearchParams.priority,
searchParams.priority,
) &&
areStringArraysEqual(currentSearchParams.queue, searchParams.queue)
) {
return;
}

// Update route search params, preserving other existing ones
navigate({
replace: true,
Expand All @@ -179,7 +207,7 @@ function JobsIndexComponent() {
},
});
},
[navigate],
[id, kind, navigate, priority, queue],
);

// Convert current search params to initial filters
Expand Down
Loading