Restores two pieces of vanilla behavior the React port silently dropped: 1. The output divs were contenteditable in vanilla — clinicians fix AI mistakes inline before saving the encounter or copying out. The early React port rendered the output as a read-only div, so any edit forced a copy-paste workflow. 2. correctionTracker.js (public/js/correctionTracker.js) saved every meaningful inline edit to user_memories under category correction_<section> so the AI learns user preferences. Settings → Corrections still showed them, but nothing in React was *writing* them — the loop was broken. New EditableResult component wraps the result body in a textarea, captures the AI baseline on first render / after refine|shorten, and on blur posts to /api/memories/correction (only when the edit clears the noise threshold from vanilla — wordDiff ≥ 2 OR charDiff ≥ 20 on outputs > 100 chars). Wired into all 7 note pages: Encounter → section: 'encounter' Dictation → section: 'hpi' SOAP → section: 'soap' SickVisit → section: 'sickvisit' WellVisit → section: 'wellvisit' HospitalCourse → section: null (server enum has no correction_hospital) ChartReview → section: null (server enum has no correction_chart) Tests: shared/clinical/correction-tracker.ts (+ .test.ts) — pure heuristic with vectors covering the noise floor (single-word swap on long text → skipped; new sentence → tracked; large char diff → tracked). Lives in shared/ so the root vitest config picks it up; the React component imports from there. |
||
|---|---|---|
| .. | ||
| public | ||
| src | ||
| .gitignore | ||
| components.json | ||
| eslint.config.js | ||
| index.html | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| tsconfig.app.json | ||
| tsconfig.json | ||
| tsconfig.node.json | ||
| vite.config.ts | ||
React + TypeScript + Vite
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- @vitejs/plugin-react uses Oxc
- @vitejs/plugin-react-swc uses SWC
React Compiler
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see this documentation.
Expanding the ESLint configuration
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Remove tseslint.configs.recommended and replace with this
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,
// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
You can also install eslint-plugin-react-x and eslint-plugin-react-dom for React-specific lint rules:
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])