-
Notifications
You must be signed in to change notification settings - Fork 0
fix: harden Therapy Compass recovery and error accessibility #758
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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| "use client"; | ||
|
|
||
| import { useEffect, useState } from "react"; | ||
| import { useCallback, useEffect, useState } from "react"; | ||
|
|
||
| import type { Pathway, ReferenceData, Therapy, TherapyDataset } from "./types"; | ||
|
|
||
|
|
@@ -32,10 +32,17 @@ export type TherapyDataState = { | |
| data: TherapyDataset | null; | ||
| loading: boolean; | ||
| error: string | null; | ||
| retry: () => void; | ||
| }; | ||
|
|
||
| export function useTherapyData(): TherapyDataState { | ||
| const [state, setState] = useState<TherapyDataState>({ data: null, loading: true, error: null }); | ||
| const [state, setState] = useState<Omit<TherapyDataState, "retry">>({ data: null, loading: true, error: null }); | ||
| const [attempt, setAttempt] = useState(0); | ||
| const retry = useCallback(() => { | ||
| cache = null; | ||
| setState({ data: null, loading: true, error: null }); | ||
| setAttempt((value) => value + 1); | ||
| }, []); | ||
|
Comment on lines
+41
to
+45
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. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
rg -n -P '\buseTherapyData\s*\(' srcRepository: BigSimmo/Database Length of output: 375 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== use-therapy-data.ts ==\n'
cat -n src/components/therapy-compass/data/use-therapy-data.ts | sed -n '1,240p'
printf '\n== bindings.tsx (relevant range) ==\n'
cat -n src/components/therapy-compass/bindings.tsx | sed -n '180,250p'
printf '\n== all useTherapyData references ==\n'
rg -n -P '\buseTherapyData\s*\(' srcRepository: BigSimmo/Database Length of output: 7157 🏁 Script executed: #!/bin/bash
set -euo pipefail
cat -n src/components/therapy-compass/data/use-therapy-data.ts | sed -n '1,220p'Repository: BigSimmo/Database Length of output: 2786 Guard 🤖 Prompt for AI Agents |
||
|
|
||
| useEffect(() => { | ||
| let active = true; | ||
|
|
@@ -53,7 +60,7 @@ export function useTherapyData(): TherapyDataState { | |
| return () => { | ||
| active = false; | ||
| }; | ||
| }, []); | ||
| }, [attempt]); | ||
|
|
||
| return state; | ||
| return { ...state, retry }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,15 +44,27 @@ function TherapyCompassShell() { | |
| > | ||
| <TherapyCompassNav /> | ||
| <main className="tc-main" style={s(`min-width:0;padding:32px 40px 40px;`)}> | ||
| {b.isHome && <HomeScreen />} | ||
| {b.isSearch && <SearchScreen />} | ||
| {b.isDetail && <DetailScreen />} | ||
| {b.isCompare && <CompareScreen />} | ||
| {b.isRecommend && <RecommendScreen />} | ||
| {b.isPathways && <PathwaysScreen />} | ||
| {b.isBrief && <BriefScreen />} | ||
| {b.isSheets && <SheetsScreen />} | ||
| {b.isOther && <OtherScreen />} | ||
| {b.error ? ( | ||
| <section role="alert" aria-live="assertive" style={s(`max-width:42rem;margin:40px auto;padding:24px;border:1px solid var(--danger);border-radius:16px;background:var(--danger-soft);`)}> | ||
| <h1 style={s(`margin:0 0 8px;color:var(--text-heading);font-size:20px;`)}>Therapy Compass could not load</h1> | ||
| <p style={s(`margin:0 0 16px;color:var(--text-muted);line-height:1.5;`)}>The therapy catalogue is unavailable. No results are being shown as a substitute.</p> | ||
| <button type="button" className="tc-btn" onClick={b.retryData} style={s(`padding:10px 14px;border:0;border-radius:8px;background:var(--clinical-accent);color:var(--clinical-accent-contrast);font-weight:650;`)}> | ||
| Retry | ||
| </button> | ||
| </section> | ||
| ) : ( | ||
|
Comment on lines
+47
to
+55
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 | 🟡 Minor | ⚡ Quick win Preserve focus when Retry starts loading. Clicking Retry clears 🤖 Prompt for AI Agents |
||
| <> | ||
| {b.isHome && <HomeScreen />} | ||
| {b.isSearch && <SearchScreen />} | ||
| {b.isDetail && <DetailScreen />} | ||
| {b.isCompare && <CompareScreen />} | ||
| {b.isRecommend && <RecommendScreen />} | ||
| {b.isPathways && <PathwaysScreen />} | ||
| {b.isBrief && <BriefScreen />} | ||
| {b.isSheets && <SheetsScreen />} | ||
| {b.isOther && <OtherScreen />} | ||
| </> | ||
| )} | ||
| <TherapyCompassFooter /> | ||
| </main> | ||
| </div> | ||
|
|
||
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: BigSimmo/Database
Length of output: 8716
🏁 Script executed:
Repository: BigSimmo/Database
Length of output: 50373
🏁 Script executed:
Repository: BigSimmo/Database
Length of output: 386
Restore a visible focus style on the error headings.
Both boundaries move focus to the
<h1>, butoutline: "none"/focus:outline-noneremoves the only visible focus indicator. Add a visible outline instead.src/app/global-error.tsx#L49src/components/route-error-boundary.tsx#L59-L61📍 Affects 2 files
src/app/global-error.tsx#L49-L49(this comment)src/components/route-error-boundary.tsx#L59-L61🤖 Prompt for AI Agents