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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v2.2.1 - 2026-09-08

- Replaced incremental result-table chunking with fixed 50-row pages, retaining global filters, search, sorting, and full exports while bounding mounted result rows.
- Centralized workflow request tokens and session deletion handling, and made HTML export limit messages use stable US-English numeric grouping across runtimes.

## v2.2.0 - 2026-07-13

- Hardened the resource and concurrency lore so CSV, session, result, and snapshot limits fail before mutation; overlapping load, compare, and restore work obeys latest-issued-wins claims; and per-session locks keep unrelated sessions moving while blocking desktop work leaves the command thread.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "csv-align"
version = "2.2.0"
version = "2.2.1"
edition = "2024"
description = "CSV file comparison tool with modern web UI"
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "csv-align-frontend",
"private": true,
"version": "2.2.0",
"version": "2.2.1",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
94 changes: 38 additions & 56 deletions frontend/src/components/ResultsTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { expect, test } from 'vitest';
import { ResultsTable } from './ResultsTable';
import type { ResultResponse } from '../types/api';

// Rendering hundreds of rows through jsdom exceeds the 5s default on slower CI runners.
const LARGE_RENDER_TEST_TIMEOUT_MS = 20_000;

const RESULTS: ResultResponse[] = [
{
Expand Down Expand Up @@ -323,7 +321,7 @@ test('filters visible rows by search query across keys and values', () => {
expect(screen.getByText('C-3')).toBeInTheDocument();
expect(screen.queryByText('A-1')).not.toBeInTheDocument();
expect(screen.queryByText('B-2')).not.toBeInTheDocument();
expect(screen.getByText('1 of 4 rows shown')).toBeInTheDocument();
expect(screen.getByText('1 of 4 rows match')).toBeInTheDocument();
});

test('filters visible rows by the selected search field', () => {
Expand All @@ -347,7 +345,7 @@ test('filters visible rows by the selected search field', () => {
fireEvent.change(search, { target: { value: 'C-3' } });

expect(screen.getByText('C-3')).toBeInTheDocument();
expect(screen.getByText('1 of 4 rows shown')).toBeInTheDocument();
expect(screen.getByText('1 of 4 rows match')).toBeInTheDocument();
});

test('closes the search field picker with keyboard and outside click', async () => {
Expand Down Expand Up @@ -572,7 +570,7 @@ test('updates the controlled search input value synchronously on each keystroke'

fireEvent.change(search, { target: { value: 'gamma' } });
expect(search).toHaveValue('gamma');
expect(screen.getByText('1 of 4 rows shown')).toBeInTheDocument();
expect(screen.getByText('1 of 4 rows match')).toBeInTheDocument();
});

test('updates sort state from the transition-driven header action', () => {
Expand All @@ -588,7 +586,7 @@ test('updates sort state from the transition-driven header action', () => {
expect(keyHeader).toHaveAttribute('aria-sort', 'ascending');
});

test('renders a repeatable large-results fixture without expanding detail panels eagerly', async () => {
test('paginates large results while keeping filtering and sorting global', async () => {
const largeResults: ResultResponse[] = Array.from({ length: 120 }, (_, index) => ({
result_type: index % 2 === 0 ? 'match' : 'mismatch',
key: [`ROW-${index.toString().padStart(3, '0')}`],
Expand All @@ -603,64 +601,48 @@ test('renders a repeatable large-results fixture without expanding detail panels

render(<ResultsTable results={largeResults} comparisonColumnsA={COMPARISON_COLUMNS_A} comparisonColumnsB={COMPARISON_COLUMNS_B} />);

expect(screen.getByText('120 of 120 rows shown')).toBeInTheDocument();
expect(screen.getByText('Showing 120 results. Use filters, search, or sorting to narrow down.')).toBeInTheDocument();
expect(screen.getByText('120 of 120 rows match')).toBeInTheDocument();
expect(screen.getByText('Showing 1–50 of 120 results')).toBeInTheDocument();
expect(screen.getByText('Page 1 of 3')).toBeInTheDocument();
expect(screen.getAllByRole('row')).toHaveLength(51);
expect(screen.getByText('ROW-000')).toBeInTheDocument();
expect(screen.getByText('ROW-049')).toBeInTheDocument();
expect(screen.queryByText('ROW-050')).not.toBeInTheDocument();
expect(screen.queryByText('Paired Values')).not.toBeInTheDocument();

fireEvent.change(screen.getByLabelText('Search comparison results'), { target: { value: 'ROW-119' } });

await waitFor(() => expect(screen.getByText('1 of 120 rows shown')).toBeInTheDocument());
expect(screen.getByText('ROW-119')).toBeInTheDocument();
});
fireEvent.click(screen.getByRole('button', { name: 'Next results page' }));
expect(screen.getByText('Showing 51–100 of 120 results')).toBeInTheDocument();
expect(screen.getByText('ROW-050')).toBeInTheDocument();
expect(screen.getByText('ROW-099')).toBeInTheDocument();
expect(screen.queryByText('ROW-000')).not.toBeInTheDocument();

test('renders very large result sets in chunks with a control to reveal more rows', () => {
const manyResults: ResultResponse[] = Array.from({ length: 450 }, (_, index) => ({
result_type: 'match',
key: [`CHUNK-${index.toString().padStart(3, '0')}`],
values_a: ['same'],
values_b: ['same'],
duplicate_values_a: [],
duplicate_values_b: [],
differences: [],
}));

render(<ResultsTable results={manyResults} comparisonColumnsA={COMPARISON_COLUMNS_A} comparisonColumnsB={COMPARISON_COLUMNS_B} />);

expect(screen.getByText('450 of 450 rows shown')).toBeInTheDocument();
expect(screen.getAllByText(/^CHUNK-/)).toHaveLength(200);
expect(screen.getByText('Showing 200 of 450 results. Use filters, search, or sorting to narrow down.')).toBeInTheDocument();

fireEvent.click(screen.getByRole('button', { name: 'Show 200 more rows (250 remaining)' }));
expect(screen.getAllByText(/^CHUNK-/)).toHaveLength(400);

fireEvent.click(screen.getByRole('button', { name: 'Show 50 more rows (50 remaining)' }));
expect(screen.getAllByText(/^CHUNK-/)).toHaveLength(450);
expect(screen.queryByRole('button', { name: /more rows/ })).not.toBeInTheDocument();
}, LARGE_RENDER_TEST_TIMEOUT_MS);

test('resets the render window when the search query changes', async () => {
const manyResults: ResultResponse[] = Array.from({ length: 250 }, (_, index) => ({
result_type: 'match',
key: [`CHUNK-${index.toString().padStart(3, '0')}`],
values_a: ['same'],
values_b: ['same'],
duplicate_values_a: [],
duplicate_values_b: [],
differences: [],
}));
const secondPageMismatch = screen.getByText('ROW-051').closest('tr') as HTMLElement;
fireEvent.click(within(secondPageMismatch).getByRole('button', { name: /1 diff/i }));
expect(screen.getByText('Value Differences')).toBeInTheDocument();

render(<ResultsTable results={manyResults} comparisonColumnsA={COMPARISON_COLUMNS_A} comparisonColumnsB={COMPARISON_COLUMNS_B} />);
const nextButton = screen.getByRole('button', { name: 'Next results page' });
fireEvent.click(nextButton);
expect(screen.queryByText('Value Differences')).not.toBeInTheDocument();
expect(screen.getByText('Showing 101–120 of 120 results')).toBeInTheDocument();
expect(screen.getByText('ROW-119')).toBeInTheDocument();
expect(nextButton).toBeDisabled();

fireEvent.click(screen.getByRole('button', { name: 'Show 50 more rows (50 remaining)' }));
expect(screen.getAllByText(/^CHUNK-/)).toHaveLength(250);
fireEvent.click(screen.getByRole('button', { name: 'Previous results page' }));
expect(screen.getByText('Showing 51–100 of 120 results')).toBeInTheDocument();

fireEvent.change(screen.getByLabelText('Search comparison results'), { target: { value: 'CHUNK-1' } });
await waitFor(() => expect(screen.getByText('100 of 250 rows shown')).toBeInTheDocument());
fireEvent.change(screen.getByLabelText('Search comparison results'), { target: { value: 'ROW-119' } });
await waitFor(() => expect(screen.getByText('Showing 1–1 of 1 results')).toBeInTheDocument());
expect(screen.getByText('ROW-119')).toBeInTheDocument();
expect(screen.queryByRole('navigation', { name: 'Results pages' })).not.toBeInTheDocument();

fireEvent.change(screen.getByLabelText('Search comparison results'), { target: { value: '' } });
await waitFor(() => expect(screen.getByText('250 of 250 rows shown')).toBeInTheDocument());
expect(screen.getAllByText(/^CHUNK-/)).toHaveLength(200);
}, LARGE_RENDER_TEST_TIMEOUT_MS);
await waitFor(() => expect(screen.getByText('Showing 1–50 of 120 results')).toBeInTheDocument());
fireEvent.click(screen.getByRole('button', { name: /key/i }));
expect(screen.getByText('ROW-000')).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: /key/i }));
expect(screen.getByText('ROW-119')).toBeInTheDocument();
});


test('renders long diff column names with the larger wrapped header treatment', () => {
render(<ResultsTable results={RESULTS} comparisonColumnsA={COMPARISON_COLUMNS_A} comparisonColumnsB={COMPARISON_COLUMNS_B} />);
Expand Down
96 changes: 61 additions & 35 deletions frontend/src/components/ResultsTable.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Fragment, useDeferredValue, useMemo, useState, useTransition } from 'react';
import { Fragment, useDeferredValue, useEffect, useMemo, useState, useTransition } from 'react';
import type { MappingDto, ResultFilter, ResultResponse } from '../types/api';
import {
buildExpandableDetail,
Expand All @@ -22,10 +22,9 @@ import {
import { ChevronRightIcon, MagnifyingGlassIcon, RectangleStackIcon } from './icons';
import { SearchFieldPicker } from './results/SearchFieldPicker';
import { SectionCard } from './ui/SectionCard';
import { NavButton } from './ui/NavButton';

/// Rows rendered per chunk. Large comparisons stay responsive because the DOM
/// only grows when the user explicitly asks for more rows.
const RENDER_CHUNK = 200;
const RESULTS_PAGE_SIZE = 50;

interface ResultsTableProps {
results: ResultResponse[];
Expand Down Expand Up @@ -178,9 +177,9 @@ export function ResultsTable({
const [searchFieldId, setSearchFieldId] = useState<SearchableFieldId>(SEARCHABLE_FIELD_ALL);
const [sortColumn, setSortColumn] = useState<ResultSortColumn | null>(null);
const [sortDirection, setSortDirection] = useState<ResultSortDirection>('asc');
const [currentPage, setCurrentPage] = useState(0);
const [isPending, startTransition] = useTransition();
const deferredQuery = useDeferredValue(query);

const comparisonColumns = useMemo(
() => ({ fileA: comparisonColumnsA, fileB: comparisonColumnsB, mappings }),
[comparisonColumnsA, comparisonColumnsB, mappings],
Expand All @@ -206,28 +205,37 @@ export function ResultsTable({
[deferredQuery, filter, normalizedSearchFieldId, resultRows, sortColumn, sortDirection],
);

// Reset the render window whenever the visible set changes shape; adjusting
// state during render avoids an extra effect-driven render pass.
const renderWindowKey = `${deferredQuery}|${filter}|${normalizedSearchFieldId}|${sortColumn}|${sortDirection}`;
const [renderWindow, setRenderWindow] = useState({ key: renderWindowKey, limit: RENDER_CHUNK });
if (renderWindow.key !== renderWindowKey) {
setRenderWindow({ key: renderWindowKey, limit: RENDER_CHUNK });
}
const renderLimit = renderWindow.key === renderWindowKey ? renderWindow.limit : RENDER_CHUNK;
const renderedResults = visibleResults.slice(0, renderLimit);
const remainingCount = visibleResults.length - renderedResults.length;
const pageCount = Math.ceil(visibleResults.length / RESULTS_PAGE_SIZE);
const effectivePage = pageCount === 0 ? 0 : Math.min(currentPage, pageCount - 1);
const pageStart = effectivePage * RESULTS_PAGE_SIZE;
const pagedResults = visibleResults.slice(pageStart, pageStart + RESULTS_PAGE_SIZE);

useEffect(() => {
setCurrentPage((page) => (pageCount === 0 ? 0 : Math.min(page, pageCount - 1)));
}, [pageCount]);

useEffect(() => {
setCurrentPage(0);
setExpandedRow(null);
}, [results, filter, query, deferredQuery, normalizedSearchFieldId, sortColumn, sortDirection]);

const resetPageAndExpansion = () => {
setCurrentPage(0);
setExpandedRow(null);
};

const handleSearchQueryChange = (nextQuery: string) => {
setQuery(nextQuery);
setExpandedRow(null);
resetPageAndExpansion();
};

const handleSearchFieldChange = (nextFieldId: SearchableFieldId) => {
setSearchFieldId(nextFieldId);
setExpandedRow(null);
resetPageAndExpansion();
};

const handleSort = (column: ResultSortColumn) => {
resetPageAndExpansion();
startTransition(() => {
if (sortColumn === column) {
setSortDirection((current) => (current === 'asc' ? 'desc' : 'asc'));
Expand Down Expand Up @@ -299,7 +307,7 @@ export function ResultsTable({
<SectionCard
eyebrow="Detailed results"
title="Comparison results"
description={`${visibleResults.length} of ${results.length} rows shown`}
description={`${visibleResults.length} of ${results.length} rows match`}
className="overflow-hidden"
icon={<RectangleStackIcon className="h-5 w-5" />}
action={
Expand Down Expand Up @@ -343,7 +351,7 @@ export function ResultsTable({
</tr>
</thead>
<tbody className="divide-y divide-app-border">
{renderedResults.map((row: ResultRowViewModel) => {
{pagedResults.map((row: ResultRowViewModel) => {
const isExpanded = expandedRow === row.id;
const expandedDetail = isExpanded
? buildExpandableDetail(row.result, row.fileAValues, row.fileBValues, comparisonColumns)
Expand Down Expand Up @@ -401,22 +409,40 @@ export function ResultsTable({
</div>
)}

{remainingCount > 0 ? (
<div className="app-surface-subtle border-t border-app-border px-4 py-3 text-center">
<button
type="button"
className="btn btn-ghost px-3 py-1.5 text-sm"
onClick={() => setRenderWindow({ key: renderWindowKey, limit: renderLimit + RENDER_CHUNK })}
>
Show {Math.min(RENDER_CHUNK, remainingCount)} more rows ({remainingCount} remaining)
</button>
<p className="app-muted mt-2 text-sm">
Showing {renderedResults.length} of {visibleResults.length} results. Use filters, search, or sorting to narrow down.
</p>
</div>
) : visibleResults.length > 50 && (
<div className="app-surface-subtle border-t border-app-border px-4 py-3 text-center">
<p className="app-muted text-sm">Showing {visibleResults.length} results. Use filters, search, or sorting to narrow down.</p>
{visibleResults.length > 0 && (
<div className="app-surface-subtle border-t border-app-border px-4 py-3">
<div className="flex flex-wrap items-center justify-between gap-3">
<p className="app-muted text-sm">
Showing {pageStart + 1}–{Math.min(pageStart + RESULTS_PAGE_SIZE, visibleResults.length)} of {visibleResults.length} results
</p>
{pageCount > 1 && (
<nav aria-label="Results pages" className="flex items-center gap-2">
<NavButton
direction="back"
aria-label="Previous results page"
disabled={effectivePage === 0}
onClick={() => {
setCurrentPage((page) => Math.max(0, page - 1));
setExpandedRow(null);
}}
>
Previous
</NavButton>
<span className="app-muted text-sm">Page {effectivePage + 1} of {pageCount}</span>
<NavButton
direction="forward"
aria-label="Next results page"
disabled={effectivePage === pageCount - 1}
onClick={() => {
setCurrentPage((page) => Math.min(pageCount - 1, page + 1));
setExpandedRow(null);
}}
>
Next
</NavButton>
</nav>
)}
</div>
</div>
)}
</div>
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/features/results/htmlExportLimits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ export class HtmlExportLimitError extends Error {
readonly limit: number,
) {
const description = kind === 'rows'
? `HTML export supports at most ${limit.toLocaleString()} rows; this result set has ${actual.toLocaleString()}.`
: `HTML export ${kind} exceeds the ${formatMiB(limit)} MiB limit (${actual.toLocaleString()} UTF-8 bytes).`;
? `HTML export supports at most ${limit.toLocaleString('en-US')} rows; this result set has ${actual.toLocaleString('en-US')}.`
: `HTML export ${kind} exceeds the ${formatMiB(limit)} MiB limit (${actual.toLocaleString('en-US')} UTF-8 bytes).`;

super(`${description} Use CSV export or reduce the result set.`);
}
}

function formatMiB(bytes: number): string {
return (bytes / (1024 * 1024)).toLocaleString();
return (bytes / (1024 * 1024)).toLocaleString('en-US');
}

export function utf8ByteLength(value: string): number {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/hooks/useComparisonWorkflow.auto-pair.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ vi.mock('../services/tauri', () => ({
DIALOG_CANCELLED: 'cancelled',
compareFiles: compareFilesMock,
createSession: createSessionMock,
deleteSession: vi.fn().mockResolvedValue(undefined),
downloadBlob: vi.fn(),
exportResults: vi.fn(),
isTauri: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ vi.mock('../services/tauri', () => ({
DIALOG_CANCELLED: 'cancelled',
compareFiles: compareFilesMock,
createSession: createSessionMock,
deleteSession: vi.fn().mockResolvedValue(undefined),
exportResults: vi.fn(),
isTauri: false,
loadComparisonSnapshot: vi.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ vi.mock('../services/tauri', () => ({
DIALOG_CANCELLED: 'cancelled',
compareFiles: compareFilesMock,
createSession: createSessionMock,
deleteSession: vi.fn().mockResolvedValue(undefined),
exportResults: vi.fn(),
isTauri: false,
loadComparisonSnapshot: loadComparisonSnapshotMock,
Expand Down
Loading
Loading