Repository navigation
fix(web): show only the latest edition of each instrument in the repository view - #1823
Merged
Merged
Conversation
…sitory view A sync keeps superseded editions attached to a repository, since records may still reference them, so a form whose edition was bumped appeared once per edition in the repository's instrument list and inflated its count. Co-Authored-By: Claude Opus 5.5 <[email protected]>
joshunrau
requested changes
Oct 25, 2026
joshunrau
left a comment
Collaborator
There was a problem hiding this comment.
The lint-and-test CI check is failing on this branch, so review is on hold.
tsc in apps/web reports four TS2322 errors in src/routes/_app/admin/instrument-repos/__tests__/index.test.tsx (lines 283, 287, 302 and 306): each fixture object passes an internal property, and TranslatedInstrumentInfo does not declare one ("Object literal may only specify known properties, and 'internal' does not exist in type …").
Please fix the fixtures, or the type they are checked against, so pnpm lint passes, then push. Review resumes once CI is green.
Failing run: https://github.com/DouglasNeuroInformatics/OpenDataCapture/actions/runs/39824053917/job/119982511911
Reviewed at commit 362b134.
…review-latest-edition
…verriding it Spreading `scalarFixture` and re-adding `internal` makes the property fresh, so it was checked against the series branch of `TranslatedInstrumentInfo`, which has none: four TS2322 errors that stopped `tsc` in apps/web. The internal name is now a parameter, so nothing is overridden after the spread.
The lookup held instruments keyed by internal name for scalars and by id for series, so narrowing the stored value back off `kind` was needed to compare editions — a branch no test can reach, since a series id would have to equal a scalar's internal name. It now maps each internal name to its highest edition and filters, which also keeps the view in the order the API returned.
joshunrau
approved these changes
Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The admin Instrument Repositories view (eye icon) listed every edition an instrument repository
had ever contributed. Sync deliberately unions instrument ids so superseded editions keep their
provenance for existing records, but the view should show what the repository currently provides.
Example: CPPQ's
CPP_GENERAL_INFORMATIONshowed as both edition 4 and edition 5 after a bump.instruments, which have no edition, are kept individually).
(falls back to
instrumentIds.lengthotherwise).instrumentIdsare unchanged.Addressing the review
The four
TS2322errors are fixed at the root rather than patched. SpreadingscalarFixtureandre-adding
internalmakes the property fresh, so it was excess-property-checked against theseries branch of
TranslatedInstrumentInfo, which has nointernal. The internal name is now aparameter of the fixture, so nothing is overridden after the spread and no cast is needed.
Two follow-up commits, typed
testandrefactorso this PR still produces exactly one changelogentry:
current.kind !== 'SERIES'guard to compare editions — a branch no test can reach, since a seriesid would have to equal a scalar's internal name. It now maps each internal name to its highest
edition and filters, which removes the guard, removes the key-space collision, and keeps the view
in the order the API returned.
"superseded edition arrives second" comparison was never exercised. Added a descending-order case.
No end-to-end test
admin-instrument-repos.spec.tsalready documents why: creating anInstrumentRepois onlypossible through
POST /v1/instrument-repos, which downloads a zipball from GitHub, andSetupServiceskips seeding the default repository underNODE_ENV=test. With no repository row,the view dialog and the instruments count cannot be reached from a spec, and there is no seeding
path that avoids the network. Flagging this rather than adding a test that cannot assert the
behaviour.
Test plan
pnpm lint— 34/34 tasks,tscclean inapps/webpnpm test:coverage— 412 files, 4723 tests, 100% statements/branches/functions/linespnpm test:e2e— 288/292. Two pre-existing failures unrelated to this change:record-file-deletion(local.envhasSTORAGE_ENABLED=false; CI generates from.env.template, which has it on) andsubject-detail, which passes on its own and fails onlyunder local parallelism — CI runs
workers: 1.index.tsxand watching it fail.🤖 Generated with Claude Code