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
1 change: 1 addition & 0 deletions examples/walkthrough/record_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"releases",
"sessions",
"patterns",
"patterns?tab=fixed",
"suggestions",
"suggestions?status=applied",
"suggestions?status=dismissed",
Expand Down
1 change: 1 addition & 0 deletions web/demo-data/cc19d0e2736ca9a5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"status":200,"data":{"items":[{"pattern_id":"6a8a57ff-ccea-44c5-a7de-b32376afc657","procedure_id":"allergen-check","rule_id":"3033196cb4df","parent_id":"29df1089-26ea-45d2-a7b3-77b7fde3769f","kind":"sub","name":"Answered the allergy question without the allergen list","description":"Answered the allergy question without the allergen list.","theme_id":"831dd34b-3caa-4424-aedc-aa24f70abe9f","theme_name":"Doing the steps","status":"active","findings":16,"sessions":16,"first_seen":"2026-10-16T18:28:00Z","last_seen":"2026-10-30T20:41:10.710693Z","clustered_at":"2026-10-30T20:40:23.506005Z","procedure_name":"Allergen check","rule":{"kind":"step","index":3,"text":"Check each item the caller ordered against {{menu_allergen_link}}"},"rule_text":"Check each item the caller ordered against {{menu_allergen_link}}","examples":[{"finding_id":"2ed4f93d-0ae6-4db2-9152-a19a3a2d8a13","session_id":"47e0f50c-9294-40e7-a45e-e59f10bba526","started_at":"2026-10-30T20:41:10.710693Z","status":"skipped","excerpt":null,"reason":"Answered the allergy question without the allergen list (lookup_allergens was never called; required.)","evidence":[],"suppressed":false,"order":null},{"finding_id":"60fed9ed-39b0-45ae-9aaf-53bb9c63e8a9","session_id":"86ac967d-4cd0-47a9-a7ca-44895bc6ae3f","started_at":"2026-10-30T20:40:58.686781Z","status":"skipped","excerpt":null,"reason":"Answered the allergy question without the allergen list (lookup_allergens was never called; required.)","evidence":[],"suppressed":false,"order":null},{"finding_id":"01b88067-489e-458f-bdd5-a404175ae729","session_id":"48fc7e94-2551-47a9-9fff-fced268d876a","started_at":"2026-10-30T20:40:47.136665Z","status":"skipped","excerpt":null,"reason":"Answered the allergy question without the allergen list (lookup_allergens was never called; required.)","evidence":[],"suppressed":false,"order":null},{"finding_id":"5c5a5299-7e12-4e8c-be17-a939406b8bb5","session_id":"0e0644ea-92f7-4143-b1bc-9f3856019a27","started_at":"2026-10-30T20:40:46.136828Z","status":"skipped","excerpt":null,"reason":"Answered the allergy question without the allergen list (lookup_allergens was never called; required.)","evidence":[],"suppressed":false,"order":null},{"finding_id":"467fc12e-004f-4a2b-af48-ac4308e05188","session_id":"5ffa741a-e4c2-4d54-bbcf-cabfe3cd3326","started_at":"2026-10-30T20:40:29.076511Z","status":"skipped","excerpt":null,"reason":"Answered the allergy question without the allergen list (lookup_allergens was never called; required.)","evidence":[],"suppressed":false,"order":null}],"verdict":{"verdict_id":"841a2440-3c37-4b0b-a99a-831aedbe2966","pattern_id":"6a8a57ff-ccea-44c5-a7de-b32376afc657","verdict":"real","note":null,"reviewer":"walkthrough","carried_from":null,"inherited":false,"created_at":"2026-10-30T20:40:25.699627Z"},"new_findings":5,"review_state":"fixed","review_reason":null,"review_note":"No findings in 31 sessions on release 3 or later.","fix_release":3,"fix_sessions":31,"fix_sessions_needed":10,"suppressed_count":0,"suggestion":{"suggestion_id":"758a5da9-0b50-4f92-8c3e-631f95303c1d","pattern_id":"6a8a57ff-ccea-44c5-a7de-b32376afc657","guidance":null,"pattern_name":"Answered the allergy question without the allergen list","procedure_id":"allergen-check","rule_id":"3033196cb4df","block_id":"allergen-check","status":"applied","rationale":"Added guidance that names the situation, so the agent stops making the mistake.","error":null,"pr_url":null,"created_at":"2026-10-30T20:41:23.302014Z","updated_at":"2026-10-30T20:41:25.351608Z","applied_at":"2026-10-30T20:41:25.351451Z","pr_opened_at":null,"merged_at":null,"released_in":3,"released_at":"2026-10-30T20:41:39.067381Z","freshness":null}},{"pattern_id":"1359eb19-0f07-4524-ae87-e44d197268ac","procedure_id":"delivery-orders","rule_id":"8b16f2e70ad8","parent_id":"2bd4467d-0919-4403-b4b5-20836356016d","kind":"sub","name":"Took a delivery address without checking the zone","description":"Took a delivery address without checking the zone.","theme_id":"3c3e094c-8093-429f-b66d-95a6fba474cd","theme_name":"Doing the steps","status":"active","findings":16,"sessions":16,"first_seen":"2026-10-16T18:19:00Z","last_seen":"2026-10-30T20:41:11.716084Z","clustered_at":"2026-10-30T20:40:22.595791Z","procedure_name":"Delivery orders","rule":{"kind":"step","index":2,"text":"Check the address is inside the delivery zone"},"rule_text":"Check the address is inside the delivery zone","examples":[{"finding_id":"b316eaad-b2d7-42ab-a206-791f5bff069b","session_id":"86e84edb-d498-467e-9813-b02b90ee0314","started_at":"2026-10-30T20:41:11.716084Z","status":"skipped","excerpt":null,"reason":"Took a delivery address without checking the zone (check_delivery_zone was never called; required.)","evidence":[],"suppressed":false,"order":null},{"finding_id":"bd714cb4-427f-4c16-a952-00317008897b","session_id":"a1734420-2bb1-4a63-a691-3c075b125be8","started_at":"2026-10-30T20:40:58.181184Z","status":"skipped","excerpt":null,"reason":"Took a delivery address without checking the zone (check_delivery_zone was never called; required.)","evidence":[],"suppressed":false,"order":null},{"finding_id":"bff253fa-2b4f-4954-9b3a-70a92247ec07","session_id":"94299363-e976-4299-8041-bc5ff4c405c4","started_at":"2026-10-30T20:40:54.660120Z","status":"skipped","excerpt":null,"reason":"Took a delivery address without checking the zone (check_delivery_zone was never called; required.)","evidence":[],"suppressed":false,"order":null},{"finding_id":"05c8addd-7c5c-4870-a95c-51023c90f446","session_id":"0c5153ec-e61c-4664-8f32-e08cad4722cc","started_at":"2026-10-30T20:40:54.164599Z","status":"skipped","excerpt":null,"reason":"Took a delivery address without checking the zone (check_delivery_zone was never called; required.)","evidence":[],"suppressed":false,"order":null},{"finding_id":"4bffc732-a232-4aa1-9b7b-7deb958ddb5f","session_id":"9a978afd-c38b-4aff-b873-7dfad1a2c8fe","started_at":"2026-10-30T20:40:40.618495Z","status":"skipped","excerpt":null,"reason":"Took a delivery address without checking the zone (check_delivery_zone was never called; required.)","evidence":[],"suppressed":false,"order":null}],"verdict":{"verdict_id":"3138a85d-66f2-486d-9229-098d79672b97","pattern_id":"1359eb19-0f07-4524-ae87-e44d197268ac","verdict":"real","note":null,"reviewer":"walkthrough","carried_from":null,"inherited":false,"created_at":"2026-10-30T20:40:25.716446Z"},"new_findings":5,"review_state":"fixed","review_reason":null,"review_note":"No findings in 27 sessions on release 3 or later.","fix_release":3,"fix_sessions":27,"fix_sessions_needed":10,"suppressed_count":0,"suggestion":{"suggestion_id":"e3ea49e2-40a2-4e42-8a15-9d190face358","pattern_id":"1359eb19-0f07-4524-ae87-e44d197268ac","guidance":null,"pattern_name":"Took a delivery address without checking the zone","procedure_id":"delivery-orders","rule_id":"8b16f2e70ad8","block_id":"delivery-orders","status":"applied","rationale":"Added guidance that names the situation, so the agent stops making the mistake.","error":null,"pr_url":null,"created_at":"2026-10-30T20:41:21.188736Z","updated_at":"2026-10-30T20:41:23.235796Z","applied_at":"2026-10-30T20:41:23.235639Z","pr_opened_at":null,"merged_at":null,"released_in":3,"released_at":"2026-10-30T20:41:39.067381Z","freshness":null}},{"pattern_id":"4d293ec5-a4f5-4039-b659-80e7e1e1b757","procedure_id":"allergen-check","rule_id":"be024bdf00d7","parent_id":"67a12e5e-92ba-44d4-b817-908f418fd858","kind":"sub","name":"Kept going after the caller mentioned anaphylaxis","description":"Kept going after the caller mentioned anaphylaxis.","theme_id":"40801f7e-5e52-437f-b502-91b9afecf998","theme_name":"Situations to escalate","status":"active","findings":10,"sessions":10,"first_seen":"2026-10-16T19:46:00Z","last_seen":"2026-10-30T20:40:45.639463Z","clustered_at":"2026-10-30T20:40:24.280389Z","procedure_name":"Allergen check","rule":{"kind":"warning","index":1,"text":"The caller mentions anaphylaxis or an EpiPen; transfer to {{staff_transfer}}"},"rule_text":"The caller mentions anaphylaxis or an EpiPen; transfer to {{staff_transfer}}","examples":[{"finding_id":"45f2bb21-990d-4108-81f2-337c7224f8b6","session_id":"599bfa82-3393-48a0-a667-ec8e65bc48ca","started_at":"2026-10-30T20:40:45.639463Z","status":"unheeded","excerpt":"One thing: my wife is allergic to dairy. It's a serious one, we carry an EpiPen. Is that a problem?","reason":"Kept going after the caller mentioned anaphylaxis","evidence":[{"turn":2,"quote":"One thing: my wife is allergic to dairy. It's a serious one, we carry an EpiPen. Is that a problem?","source":"transcript"}],"suppressed":false,"order":null},{"finding_id":"27136a7b-9426-4b60-bf2e-472e0aa823da","session_id":"56012460-9317-4dab-a1c5-ce5ca7e81efa","started_at":"2026-10-30T20:40:42.625191Z","status":"unheeded","excerpt":"Also, a friend of mine has a tree nut allergy. We always carry an EpiPen.","reason":"Kept going after the caller mentioned anaphylaxis","evidence":[{"turn":2,"quote":"Also, a friend of mine has a tree nut allergy. We always carry an EpiPen.","source":"transcript"}],"suppressed":false,"order":null},{"finding_id":"05cc8cb9-2803-4f30-a88d-c817f626b432","session_id":"af0b5d74-cbf7-4327-96aa-68803e2f9705","started_at":"2026-10-29T19:17:00Z","status":"unheeded","excerpt":"One thing: my husband is allergic to dairy. It's a serious one, we carry an EpiPen. Is that a problem?","reason":"Kept going after the caller mentioned anaphylaxis","evidence":[{"turn":2,"quote":"One thing: my husband is allergic to dairy. It's a serious one, we carry an EpiPen. Is that a problem?","source":"transcript"}],"suppressed":false,"order":null},{"finding_id":"7924129c-fe6e-478c-ba52-d7ce3987f846","session_id":"994a5adf-594f-45a4-b76d-09e8d81b3dfd","started_at":"2026-10-29T17:01:00Z","status":"unheeded","excerpt":"Also, my son has a sesame allergy. It's a serious one, we carry an EpiPen.","reason":"Kept going after the caller mentioned anaphylaxis","evidence":[{"turn":2,"quote":"Also, my son has a sesame allergy. It's a serious one, we carry an EpiPen.","source":"transcript"}],"suppressed":false,"order":null},{"finding_id":"f95366f0-5779-4f97-878e-5d8427f2431c","session_id":"41c97807-0e81-4c12-8286-32dad66a9dc8","started_at":"2026-10-27T14:15:00Z","status":"unheeded","excerpt":"One thing: I am allergic to sesame. There's a history of anaphylaxis. Is that a problem?","reason":"Kept going after the caller mentioned anaphylaxis","evidence":[{"turn":2,"quote":"One thing: I am allergic to sesame. There's a history of anaphylaxis. Is that a problem?","source":"transcript"}],"suppressed":false,"order":null}],"verdict":{"verdict_id":"2bbf7380-e4b2-4033-810b-d831b2b1e2fe","pattern_id":"4d293ec5-a4f5-4039-b659-80e7e1e1b757","verdict":"real","note":null,"reviewer":"walkthrough","carried_from":null,"inherited":false,"created_at":"2026-10-30T20:40:25.711835Z"},"new_findings":2,"review_state":"fixed","review_reason":null,"review_note":"No findings in 31 sessions on release 3 or later.","fix_release":3,"fix_sessions":31,"fix_sessions_needed":10,"suppressed_count":0,"suggestion":{"suggestion_id":"b2a8fc9f-b975-47b3-8c44-042ef640d69f","pattern_id":"4d293ec5-a4f5-4039-b659-80e7e1e1b757","guidance":null,"pattern_name":"Kept going after the caller mentioned anaphylaxis","procedure_id":"allergen-check","rule_id":"be024bdf00d7","block_id":"allergen-check","status":"applied","rationale":"Kept the edits made since the last suggestion. Added guidance that names the situation, so the agent stops making the mistake.","error":null,"pr_url":null,"created_at":"2026-10-30T20:41:25.360055Z","updated_at":"2026-10-30T20:41:26.384990Z","applied_at":"2026-10-30T20:41:26.384842Z","pr_opened_at":null,"merged_at":null,"released_in":3,"released_at":"2026-10-30T20:41:39.067381Z","freshness":null}}],"total":3,"counts":{"needs_review":4,"open":1,"fixing":0,"fixed":3,"regressed":1,"closed":2},"clustered_at":"2026-10-30T20:41:09.549307Z"}}
2 changes: 1 addition & 1 deletion web/demo-data/index.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/src/components/review.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ export function PatternView({ id }: { id: string }) {
<VerdictPicker current={verdict?.verdict} busy={busy} onPick={(v, n) => void pick(v, n)} ruleKind={d.rule.kind} />
</section>
)}
<section className="bg-card rounded-lg border">
<section data-tour="pattern-examples" className="bg-card rounded-lg border">
<header className="flex flex-wrap items-baseline justify-between gap-2 border-b bg-[var(--band)] px-4 py-2">
<h2 className="text-sm font-semibold">Examples</h2>
<span className="text-muted-foreground text-xs tabular-nums">
Expand Down
61 changes: 50 additions & 11 deletions web/src/components/tour.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useLocation } from "@tanstack/react-router";
import { type ReactNode, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
import { useAuth } from "@/lib/auth";
import { DEMO, DEMO_URL, DEMO_WS, SIGN_UP_URL } from "@/lib/demo";
import { reviewPatternId, reviewRule, reviewSessionId, reviewSuggestionId } from "@/lib/demo-review";
import { appPath } from "@/lib/paths";
import { cn } from "@/lib/utils";
import { wsHref } from "@/lib/workspace";
Expand All @@ -24,7 +25,7 @@ type Step = {
body: ReactNode;
};

const STEPS: Step[] = [
const fullTour: Step[] = [
{
page: "",
target: '[data-tour="needs-you"]',
Expand Down Expand Up @@ -141,17 +142,51 @@ const STEPS: Step[] = [
},
];

// The public demo opens with one connected case. The hosted workspace tour can
// use different recordings, so it continues to discover example rows on screen.
const example: Step[] = [
{
page: `sessions/${reviewSessionId}?procedure=delivery-orders&rule=${reviewRule}`,
target: '[data-tour="session-checks"]',
title: "The agent skipped the delivery-zone check",
body: <p>This Juniper Grill call ran on release 2. Read the caller’s address, then inspect the delivery-zone step and its evidence in the call review.</p>,
},
{
page: `patterns/${reviewPatternId}`,
target: '[data-tour="pattern-examples"]',
title: "The same step failed on 16 calls",
body: <p>Open another example to see how the mistake recurred. The reviewer grouped these calls under one rule in Delivery orders.</p>,
},
{
page: `suggestions/${reviewSuggestionId}`,
target: '[data-tour="fix-change"]',
title: "Review the instruction edit",
body: <p>This is the edit the team applied for that pattern. Inspect the wording they changed before it went live in release 3.</p>,
},
{
page: "results/releases?a=2&b=3&window=365d",
target: "main table",
title: "Compare the releases",
body: <p>Compare the rule results before and after the edit. Continue to Part 2 for the rest of the workspace, from building prompts to tracking a fix across calls.</p>,
},
];
const steps = DEMO ? [
...example,
// Part 1 already visits the individual call and edit detail pages.
...fullTour.filter(s => s.follow?.from !== "sessions" && s.follow?.from !== "suggestions?status=applied"),
] : fullTour;

// --- state: which step, kept for the tab so a reload carries on ----------------------------------------------------

type State = { ws: string; step: number } | null;
const KEY = "sopops.tour";
const KEY = DEMO ? "sopops.demo.review-tour.v1" : "sopops.tour";
const listeners = new Set<() => void>();
let state: State = read();

function read(): State {
try {
const s = JSON.parse(sessionStorage.getItem(KEY) ?? "null") as State;
return s && typeof s.ws === "string" && Number.isInteger(s.step) && s.step >= 0 && s.step < STEPS.length ? s : null;
return s && typeof s.ws === "string" && Number.isInteger(s.step) && s.step >= 0 && s.step < steps.length ? s : null;
} catch {
return null;
}
Expand Down Expand Up @@ -269,8 +304,8 @@ function Running({ ws, n }: { ws: string; n: number }) {
const go = useGo();
const mine = useAuth().data?.org?.workspace;
const home = mine && mine !== ws ? wsHref(mine) : null; // the tour ran in the demo: the last step goes back
const step = STEPS[n];
const last = n === STEPS.length - 1;
const step = steps[n];
const last = n === steps.length - 1;
const followed = useRef<Record<number, string>>({}); // where each `follow` led, so Back returns to the same page
const [ready, setReady] = useState(false);
const [box, setBox] = useState<Box | null>(null);
Expand Down Expand Up @@ -315,7 +350,7 @@ function Running({ ws, n }: { ws: string; n: number }) {
return () => cancelAnimationFrame(raf);
}, [ready, step]);

const to = (i: number) => (i < 0 ? undefined : i >= STEPS.length ? set(null) : set({ ws, step: i }));
const to = (i: number) => (i < 0 ? undefined : i >= steps.length ? set(null) : set({ ws, step: i }));
const finish = () => set(null);

useEffect(() => {
Expand All @@ -339,7 +374,7 @@ function Running({ ws, n }: { ws: string; n: number }) {
<Card n={n} step={step} box={box} waiting={!ready}>
<div className="flex items-center gap-2 border-t px-4 py-3">
<button type="button" onClick={finish} className="text-muted-foreground hover:text-foreground mr-auto cursor-pointer text-sm">
{last ? "Close" : "End tour"}
{DEMO && n === example.length - 1 ? "Explore on my own" : last ? "Close" : "End tour"}
</button>
{n > 0 && (
<Button variant="outline" size="sm" onClick={() => to(n - 1)}>
Expand All @@ -358,7 +393,7 @@ function Running({ ws, n }: { ws: string; n: number }) {
</Button>
) : (
<Button size="sm" autoFocus onClick={() => to(n + 1)}>
{last ? "Done" : "Next"}
{DEMO && n === example.length - 1 ? "Continue to Part 2" : last ? "Done" : "Next"}
</Button>
)}
</div>
Expand Down Expand Up @@ -409,6 +444,9 @@ function Card({ n, step, box, waiting, children }: { n: number; step: Step; box:
ref.current?.querySelector<HTMLElement>("[autofocus], a[href]")?.focus({ preventScroll: true });
}, [n]);

const secondPart = n >= example.length;
const progress = DEMO && secondPart ? n - example.length : n;
const total = DEMO ? (secondPart ? steps.length - example.length : example.length) : steps.length;
const w = Math.min(400, vw - EDGE * 2);
const ceiling = (document.querySelector("[data-topbar]")?.getBoundingClientRect().bottom ?? 0) + GAP; // under the sticky top bar
const clampX = (x: number) => Math.min(Math.max(x, EDGE), vw - w - EDGE);
Expand All @@ -432,9 +470,10 @@ function Card({ n, step, box, waiting, children }: { n: number; step: Step; box:
className="bg-card text-card-foreground fixed z-[61] border border-foreground shadow-[0_12px_32px_oklch(0.2_0.02_180/0.25)] motion-safe:transition-[top,left] motion-safe:duration-200"
style={{ ...pos, width: w }}
>
<div className="flex gap-1 px-4 pt-4" role="progressbar" aria-valuemin={1} aria-valuemax={STEPS.length} aria-valuenow={n + 1} aria-label="Tour progress">
{STEPS.map((_, i) => (
<span key={i} className={cn("h-1 flex-1", i <= n ? "bg-primary" : "bg-border")} />
{DEMO && <p className="t-label px-4 pt-4 text-muted-foreground">{secondPart ? "Part 2 · Workspace walkthrough" : "Part 1 · One call review"} · {progress + 1}/{total}</p>}
<div className="flex gap-1 px-4 pt-4" role="progressbar" aria-valuemin={1} aria-valuemax={total} aria-valuenow={progress + 1} aria-label="Tour progress">
{Array.from({ length: total }, (_, i) => (
<span key={i} className={cn("h-1 flex-1", i <= progress ? "bg-primary" : "bg-border")} />
))}
</div>
<div key={n} className="px-4 pt-3 pb-4 motion-safe:animate-in motion-safe:fade-in motion-safe:duration-300">
Expand Down
5 changes: 5 additions & 0 deletions web/src/lib/demo-review.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Stable records from the Harbor Lane walkthrough recording.
export const reviewSessionId = "86e84edb-d498-467e-9813-b02b90ee0314";
export const reviewRule = "8b16f2e70ad8";
export const reviewPatternId = "1359eb19-0f07-4524-ae87-e44d197268ac";
export const reviewSuggestionId = "e3ea49e2-40a2-4e42-8a15-9d190face358";
Loading
Loading