Repository navigation
Table Copy: keep a fetched copy while the table's content is unchanged - #461
Conversation
The Copy button's two steps reset whenever the table answer object was replaced, even by an identical answer (a re-render, a page turn), so a first click's fetch could be dropped and "Copy Ready!" never appear. This flaked the tables e2e once on CI (#457). The reset now keys on what the copied text depends on (copyTableKey: the query, the column ids, each study's row counts), so a sort, a column or a row change still drops it. The e2e waits for the table to settle before the first click, retries the first click once if the button fell back to "Copy", and names the button's label and the status text when it fails. Tests: test/table-copy-key.test.ts (C1-C7, written by a separate agent from the spec table); two planted bugs in table-copy.ts, each failing the suites that import lib/table-tsv.ts. npm test passes; e2e tables passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q3ezTXaZDnWotHSveqDGjf
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| * or a page turn, and is dropped when the query, the columns or the rows change. | ||
| */ | ||
| export function copyTableKey(t: { query: unknown; columns: { id: string }[]; lists: { cohort: string; study: string; total: number; all: number }[]; total: number; all: number }): string { | ||
| return JSON.stringify([t.query, t.columns.map((c) => c.id), t.lists.map((l) => [l.cohort, l.study, l.total, l.all]), t.total, t.all]); |
There was a problem hiding this comment.
Blocking: the key leaves out things that change the copied text, so a kept copy can paste stale rows.
The key covers the table query, the column ids and the row counts. But the table.tsv that fetchCopy posts is built from the whole view doc (docJson(), vi, table). Several parts of the doc change the rows or their text without changing any of those:
drivers(the page's driver settings):lib/views/mutations/run.ts:103passes them tomutationValue, so they change each row's driver-call/Annotation cell and the default order. Every count stays the same, so the key stays the same.gene: switching the view's gene to one with the same per-study counts keeps the key. In a small study, two genes with one mutation each is ordinary. Copy Ready! then pastes the old gene's mutations.- the cohort's members: swapping one sample for another with the same number of mutations keeps the per-study
total/all.lists[].cohortis the cohort's name, not its definition. - the OncoKB/Genome Nexus pins (
oncokbPin,variantPins) change cell text the same way.
Before this PR, any new answer reset the copy, so none of these could leak. That's the stale-copy bug #413's generation counter was there to prevent.
Suggested fix: build the key from what the fetch actually sends, e.g. docJson?.() plus vi and table. That only works if the doc doesn't carry the page offset. Alternatively, keep the counts key but add the doc string to it. C1–C7 are good, but please add a case where the same counts come from a different doc (the gene or driver settings), and a planted bug that drops the doc from the key.
|
Review: changes requested Blocking:
Not blocking: the generation check still drops answers from a superseded fetch. The e2e retry and the failure diagnostics look fine. CI was still pending at review time. |
Review fix. copyTableKey keyed only on the answer's query, columns and row counts, but the copy is fetched from the whole view document. A change to the document alone (the drivers setting, a gene or cohort swap with equal counts, the OncoKB or Genome Nexus pins) kept a stale copy, so Copy Ready! could paste the old rows. The key now starts from docJson(), the view's index and its table. Tests: C8-C11 in test/table-copy-key.test.ts (a separate agent); C1-C7 pass the same source on both sides. Planted bug copy-key-ignores-doc; the three copy-key planted bugs each fail the suites that import lib/table-tsv.ts. npm test passes; e2e tables passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q3ezTXaZDnWotHSveqDGjf
|
Re-review: pass. 162d5fc fixes the blocking finding. nit: |
Summary
The Mutations table's Copy (#413) flaked once in CI on #457's run: the first click never reached "Copy Ready!". It passed on the re-run.
The cause in the app: the Copy state reset whenever the table's answer object was replaced, even by an identical answer (a re-render, a page turn). That could drop a first click's fetch while it was still running.
The fix:
copyTableKeyinlib/table-tsv.ts):docJson()), with the view's index and table;The e2e (
test/e2e/tables.cjs):Review fix (since 00557aa)
The key now starts from the document, the view's index and its table. Before, a change to the document alone (the drivers setting, a gene or cohort swap with equal counts, the OncoKB or Genome Nexus pins) kept a stale copy. Added C8–C11 and the planted bug
copy-key-ignores-doc.Spec table
allchanges, totals the sametotalchangesVerification
test/table-copy-key.test.ts(C1–C11) from the table.copy-key-ignores-rows,copy-key-ignores-sortandcopy-key-ignores-docare inscripts/mutants/mutations/table-copy.ts. Each fails the suites that importlib/table-tsv.ts.npm testpasses, and the e2e tables area passes (Copy: identical to table.tsv).Tracker
None. This fixes the reliability of #413's feature and ticks nothing.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Q3ezTXaZDnWotHSveqDGjf