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
11 changes: 10 additions & 1 deletion src/components/comboChecker/__tests__/comboData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,23 @@ describe("getCombo", () => {
});
});

it("falls back to the reverse pairing when only that direction is present", () => {
it("returns the same result in either order", () => {
const forward = getCombo("Alcohol", "GHB/GBL");
const reverse = getCombo("GHB/GBL", "Alcohol");
expect(forward).toEqual(reverse);
expect(forward.risk).toBe("dangerous");
expect(forward.note).not.toBe("");
});

it.each([
["DXM", "MXE"],
["MXE", "DXM"],
])("rates %s + %s as Unsafe", (first, second) => {
const result = getCombo(first, second);
expect(result.risk).toBe("unsafe");
expect(result.note).toMatch(/serotonin syndrome/i);
});

it("includes the note when the dataset provides one", () => {
expect(getCombo("LSD", "Cannabis")).toEqual({
risk: "caution",
Expand Down
17 changes: 10 additions & 7 deletions src/components/comboChecker/comboData.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Combo Checker data + interaction logic.
// Interaction data is TripSit's canonical combo dataset (comboInteractions.json,
// the same matrix used at combo.tripsit.me). The visual risk system (colors/glyphs)
// comes from the Claude Design "Combo Checker" handoff.
// Interaction data comes from the TripSit drug database.

import rawInteractions from "./comboInteractions.json";
import rawInteractions from "tripsit_drug_db/combos.json";

export type RiskKey =
| "synergy"
Expand All @@ -23,7 +21,7 @@ export interface RiskDef {
}

// Display order + grouping from TripSit's combo chart config (tableOrder / groupNames).
// Substance labels here are lowercased to look up keys in comboInteractions.json.
// Display labels are normalized to database keys when looking up a pair.
export const GROUPS: { name: string; substances: string[] }[] = [
{
name: "Psychedelics",
Expand Down Expand Up @@ -154,12 +152,17 @@ const STATUS_TO_RISK: Record<string, RiskKey> = {
const UNKNOWN_NOTE =
"There isn't enough reliable data on this combination. Treat it as potentially risky and research it thoroughly.";

function comboKey(substance: string): string {
const key = substance.toLowerCase();
return key === "dxm" ? "dextromethorphan" : key;
}

export function getCombo(
a: string,
b: string,
): { risk: RiskKey; note: string } {
const ka = a.toLowerCase();
const kb = b.toLowerCase();
const ka = comboKey(a);
const kb = comboKey(b);
const entry = INTERACTIONS[ka]?.[kb] ?? INTERACTIONS[kb]?.[ka];
if (!entry) return { risk: "unknown", note: UNKNOWN_NOTE };
return {
Expand Down
Loading
Loading