Skip to content

[Bug]: CSV/TSV and large-text previews say "1 rows", "1 columns" and "1 lines" #34939

Closed

Description

@coygeek

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web

Steps to reproduce

Use the commit under Version or commit with dependencies installed and the repo's browser test setup available. Save the probe below as apps/web/src/components/files/CountLabels.browser.test.tsx and run vp test run apps/web/src/components/files/CountLabels.browser.test.tsx --maxWorkers=1 --reporter=verbose --silent=false. It renders the real AttachmentFilePreview with local Blob attachments and the real indexing worker, waits for indexing to finish, and prints each status line. It asserts the current labels, so a pass means the defect is present and the two-count controls are correct.

  • one.csv and one.tsv: a header plus one data row, one column (name\nAda\n); the header is correctly excluded from the row count.
  • one.txt: exactly 1,048,576 ASCII a characters plus one newline (1,048,577 bytes), which crosses the attachment preview's 1 MiB streaming threshold. Small plain-text attachments use a different source viewer with no line-count label, so a short one-line file does not show this.
  • Controls: a two-row, two-column CSV and TSV, and a large two-line text file.
Probe: CountLabels.browser.test.tsx
import { expect, it, vi } from "vite-plus/test";
import { render } from "../../../test/render";
import { AttachmentFilePreview } from "./AttachmentFilePreview";
import "~/index.css";

it("independently observes singular defects beside plural controls through attachment previews", async () => {
  const cases = [
    { name: "one.csv", mime: "text/csv", text: "name\nAda\n", label: "1 rows · 1 columns" },
    { name: "control.csv", mime: "text/csv", text: "name,count\nAda,1\nGrace,2\n", label: "2 rows · 2 columns" },
    { name: "one.tsv", mime: "text/tab-separated-values", text: "name\nAda\n", label: "1 rows · 1 columns" },
    { name: "control.tsv", mime: "text/tab-separated-values", text: "name\tcount\nAda\t1\nGrace\t2\n", label: "2 rows · 2 columns" },
    { name: "one.txt", mime: "text/plain", text: "a".repeat(1024 * 1024) + "\n", label: "1 lines" },
    { name: "control.txt", mime: "text/plain", text: ("a".repeat(512 * 1024) + "\n").repeat(2), label: "2 lines" },
  ];
  for (const item of cases) {
    const file = new Blob([item.text], { type: item.mime });
    const container = document.createElement("div");
    container.style.cssText = "display:flex;flex-direction:column;width:700px;height:500px";
    await using screen = await render(<AttachmentFilePreview name={item.name} mimeType={item.mime} sizeBytes={file.size} file={file} />, { container });
    const status = () => screen.container.querySelector('[role="status"]')?.textContent ?? "";
    await vi.waitFor(() => {
      expect(status()).toContain(item.label);
      expect(status()).not.toContain("Indexing");
    }, 10_000);
    console.log(`${item.name}: ${status()}`);
    expect(screen.container.textContent).not.toContain("Could not");
  }
});

The probe above is the CSV/TSV/text case of the run whose output is under Logs or stack traces; that run's test file also held sibling-viewer cases already covered by #31885 and #31886, which are omitted here.

Expected behavior

A count of one uses the singular noun: 1 row · 1 column for the one-row, one-column CSV/TSV and 1 line for the one-line text file, with the plural kept for the two-count controls. This is the convention the project already applies in neighbouring file previews: merged #31868 (#31868) corrected the Office previews, the OfficeViewer row/column status branches on a count of one, and the existing ODS browser test expects 1 row · 2 columns.

Actual behavior

Summary. The status line of the CSV/TSV table preview and the streaming plain-text preview uses plural nouns for a count of one: a CSV or TSV with one data row and one column shows 1 rows · 1 columns, and a plain-text file large enough for the streaming viewer with one line shows 1 lines. Counts of two read correctly. This is a wording defect only; the counts themselves are right. Merged #31868 fixed the same wording in the Office previews, and open #31885 and #31886 cover the PDF, SQLite, archive and notebook previews; none of them changes this viewer.

Observed in Chromium through the real attachment preview components and worker; the run passed (1 file, 5 tests, exit 0), confirming the singular-count labels and the correct plural controls. The printed status lines are under Logs or stack traces.

CSV/TSV reach the viewer through AttachmentFilePreview's table branch and DelimitedTablePreview; large plain text reaches it through the size guard and streaming branch. The LargeTextViewer status JSX appends fixed rows, lines and columns after the worker's counts. Project files also reach LargeTextViewer through the file preview panel; that route was traced in source, not run. The browser run used the baseline commit; it was not repeated in a full app on current main.

Related, not duplicates: merged #31868 changed only the Office viewers. Open #31885 changes only the PDF viewer and open #31886 only the SQLite, archive and notebook viewers. Open #28841 redesigns the panels and touches LargeTextViewer, but its current head still uses the fixed plural nouns.

Evidence

  • Expected source: merged fix(web): Office previews say "1 page", "1 sheet", "1 slide" and "1 row" #31868 and the OfficeViewer status and ODS browser test linked under Expected behavior.
  • Failure source: the observed probe output under Logs or stack traces and the LargeTextViewer.tsx status JSX at lines 211-225.
  • Evidence provenance: observed
  • Local verification: reproduced
  • Reproduction completeness: complete

Restoration check

With the probe's inputs, one.csv and one.tsv show 1 row · 1 column and one.txt shows 1 line, while the controls still show 2 rows · 2 columns and 2 lines, the CSV/TSV row count still excludes the header, and the size suffix and Indexing… state are unchanged. The probe's expected labels need updating to the singular forms for this check.

Impact

Cosmetic issue

Version or commit

d9805b2 (the four viewer, wrapper and worker files are byte-identical on main at 8024e50)

Environment

macOS 27.2 arm64, Node v26.12.1, Playwright 1.64.1, Chromium headless shell revision 1254 (Chrome for Testing 158.0.8127.18) supplied through Playwright launch options because the provider's default revision was not installed

Logs or stack traces

one.csv: 1 rows · 1 columns · 1 KB
control.csv: 2 rows · 2 columns · 1 KB
one.tsv: 1 rows · 1 columns · 1 KB
control.tsv: 2 rows · 2 columns · 1 KB
one.txt: 1 lines · 1.0 MB
control.txt: 2 lines · 1.0 MB
Test Files  1 passed (1)
Tests       5 passed (5)

Screenshots, recordings, or supporting files

No response

Workaround

No change is needed to keep using the preview; the count is correct, so a reader can read the plural noun after a count of one as singular.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions