-
Notifications
You must be signed in to change notification settings - Fork 0
Fix(differentials): route "Compare selected" directly to resolved presentation workflow #882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,20 @@ | ||||||||||||||||||||||||||||||||
| import { getPresentationWorkflowSelectionForDiagnosisIds } from "@/lib/differentials"; | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the Useful? React with 👍 / 👎.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @codex resolve There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Summary
Testing
Status
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| export function differentialRouteWithQuery(path: string, query: string, selectedIds?: Iterable<string>) { | ||||||||||||||||||||||||||||||||
| const params = new URLSearchParams(); | ||||||||||||||||||||||||||||||||
| const trimmedQuery = query.trim(); | ||||||||||||||||||||||||||||||||
| if (trimmedQuery) params.set("q", trimmedQuery); | ||||||||||||||||||||||||||||||||
| const ids = selectedIds ? Array.from(selectedIds, (id) => id.trim()).filter(Boolean) : []; | ||||||||||||||||||||||||||||||||
| if (ids.length > 0) params.set("ids", ids.join(",")); | ||||||||||||||||||||||||||||||||
| const suffix = params.toString(); | ||||||||||||||||||||||||||||||||
| return suffix ? `${path}?${suffix}` : path; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| export function differentialSelectedCompareHref(query: string, selectedIds: Iterable<string>) { | ||||||||||||||||||||||||||||||||
| const selection = getPresentationWorkflowSelectionForDiagnosisIds(selectedIds); | ||||||||||||||||||||||||||||||||
| return differentialRouteWithQuery( | ||||||||||||||||||||||||||||||||
| `/differentials/presentations/${selection?.workflow.id ?? "acute-confusion-encephalopathy"}`, | ||||||||||||||||||||||||||||||||
| query, | ||||||||||||||||||||||||||||||||
| selection?.diagnosisIds, | ||||||||||||||||||||||||||||||||
|
Comment on lines
+13
to
+18
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Preserve selected IDs on the fallback route. If workflow resolution returns Proposed fix export function differentialSelectedCompareHref(query: string, selectedIds: Iterable<string>) {
- const selection = getPresentationWorkflowSelectionForDiagnosisIds(selectedIds);
+ const normalizedIds = Array.from(selectedIds, (id) => id.trim()).filter(Boolean);
+ const selection = getPresentationWorkflowSelectionForDiagnosisIds(normalizedIds);
return differentialRouteWithQuery(
`/differentials/presentations/${selection?.workflow.id ?? "acute-confusion-encephalopathy"}`,
query,
- selection?.diagnosisIds,
+ selection?.diagnosisIds ?? normalizedIds,
);
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import { differentialRouteWithQuery, differentialSelectedCompareHref } from "@/lib/differentials-navigation"; | ||
|
|
||
| describe("differentials navigation", () => { | ||
| it("builds same-origin relative query routes", () => { | ||
| expect(differentialRouteWithQuery("/differentials/diagnoses", " acute confusion ")).toBe( | ||
| "/differentials/diagnoses?q=acute+confusion", | ||
| ); | ||
| }); | ||
|
|
||
| it("wires selected comparison directly to a presentation page instead of the redirect endpoint", () => { | ||
| const href = differentialSelectedCompareHref("Pain", new Set(["anorexia-nervosa", "bulimia-nervosa-binge-purge-pattern"])); | ||
|
|
||
| expect(href).toMatch(/^\/differentials\/presentations\/[^?]+\?/); | ||
| expect(href).toContain("q=Pain"); | ||
| expect(href).toContain("ids=anorexia-nervosa%2Cbulimia-nervosa-binge-purge-pattern"); | ||
| expect(href).not.toContain("0.0.0.0"); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
DifferentialsHomevalue-imports this helper from the client component, this import follows@/lib/differentials→differential-fixtures→data/differentials-snapshot.json, so simply opening the differentials dashboard can pull the full ~1.2 MB generated catalogue into the browser bundle. That regresses the repo's fixture-free client boundary for the dashboard; the smallest proof is a production build plusnpm run check:bundle-budget, or extendingtests/client-performance-boundaries.test.tsto catch this transitive import. Keep this lookup server-side or move only the small diagnosis-to-workflow mapping needed for hrefs into a client-safe module.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@codex resolve
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
@/lib/differentialsimport with a client-safe workflow lookup module, so dashboard navigation no longer pulls the generated differential catalogue into the client graph. src/lib/differentials-navigation.tsL1-L4differential-fixturesand the snapshot JSON. src/lib/differentials-navigation-workflows.tsL1-L60@/lib/differentials,differential-fixtures,differentials-snapshot, orloadDifferentialSnapshot. tests/client-performance-boundaries.test.tsL18-L25dd4c1f6 fix(differentials): keep compare navigation client-safe.Fix(differentials): keep compare navigation client-safe.Testing
npm run test -- tests/differentials-navigation.test.ts tests/client-performance-boundaries.test.ts— initially could not run because dependencies were not installed andvitestwas missing fromnode_modules.npm ci— initially failed under Nodev20.20.2because the repo requires Node24.x.export PATH="$HOME/.nvm/versions/node/v24.15.0/bin:$PATH"; npm ciexport PATH="$HOME/.nvm/versions/node/v24.15.0/bin:$PATH"; npm run test -- tests/differentials-navigation.test.ts tests/client-performance-boundaries.test.tsexport PATH="$HOME/.nvm/versions/node/v24.15.0/bin:$PATH"; npm run typecheckexport PATH="$HOME/.nvm/versions/node/v24.15.0/bin:$PATH"; npm run lintgit diff --checkWorktree
work.View task →