Commit Graph

12 Commits

Author SHA1 Message Date
55622368e3 Prioritize doctor instructions in AI report prompts
- Extract AI prompt construction into a tested utility for report editor generation.

- Make doctor instructions and structured report fields higher priority than old template body and target-region HTML.

- Tell the AI not to carry over default gallbladder or liver descriptions when the doctor asks for another procedure or body part.

- Limit old full-report context length to reduce anchoring on default template content.

- Update README, AGENTS, report editor, design, progress, and testing docs for the AI prompt priority model.

- Add unit tests covering AI prompt priority and old-content truncation.
2026-05-02 04:39:18 +08:00
44decaa396 Include field library metadata in template exports
- Add fieldLibrary metadata to HTML template packages, including form fields, custom time formats, multi-select options, and anesthesia options.

- Restore imported template field metadata into local compatibility caches and the backend field library API when available.

- Preserve legacy JSON template import compatibility while keeping user-facing exports on HTML packages.

- Prevent template field saves from overwriting stored multi-select and anesthesia options with empty values.

- Update README, AGENTS, feature, requirement, design, module, progress, component, and testing docs for complete template export behavior.

- Extend template export tests to cover field library metadata round-tripping.
2026-05-02 04:27:08 +08:00
03b54fe18b Remove frontend JSON export actions
- Remove user-visible JSON export options from report editor, report management, template management, bulk template export, and AI debug logs.

- Keep HTML template package and PDF/browser print exports as the supported frontend export formats.

- Change per-template export to generate reusable HTML template packages.

- Preserve legacy JSON template import compatibility without exposing new JSON export buttons.

- Update README, AGENTS, feature, requirement, design, module, API contract, progress, and testing docs for the export policy change.
2026-05-02 04:21:08 +08:00
7631ae34ce Sync inserted AI regions immediately
- Track report editor AI regions in React state instead of only scanning contentEditable DOM during render.

- Observe editor AI region mutations and refresh the AI writing target dropdown without requiring page navigation or refresh.

- Select newly inserted AI regions immediately after insertion and keep a live DOM fallback for generation.

- Harden AI region insertion so it still appends the region if execCommand has no active editor selection.

- Escape AI region names before injecting template HTML and add an accessible label for the insert button.

- Add Playwright coverage for inserting an AI region and seeing it immediately in the AI writing dropdown.

- Update report editor, feature, progress, testing, and AGENTS documentation for AI region synchronization.
2026-05-02 04:08:48 +08:00
5a4056d899 Add reusable HTML template export
- Add template export utilities for standard JSON packages and standalone HTML template packages.

- Make the top-level JSON export use the standard surclaw template package format so it can be imported again.

- Add an HTML template package export that embeds A4/print styling and template metadata for visual preview and round-trip import.

- Extend template import to accept both JSON and HTML template package files while keeping old raw template JSON compatible.

- Add tests for package creation, HTML round-trip import, legacy JSON import, and file name cleanup.

- Update template management, feature, progress, testing, and AGENTS documentation for the new export formats.
2026-05-02 03:49:21 +08:00
d61ee4f83a Fix new template disappearing after save
- Update TemplateManage save flows to use the current in-memory template list instead of stale localStorage as the source of truth.

- Merge current templates back into the compatibility cache so newly created backend templates are not dropped on content save.

- Add an accessible label for the new-template button to support reliable E2E coverage.

- Add template list merge unit tests covering stale-cache replacement and newly created templates.

- Add Playwright coverage for creating a template, saving template content, and confirming it remains visible and persisted.

- Update feature, progress, testing, and AGENTS documentation for the template management fix.
2026-05-02 03:42:41 +08:00
285dbd2023 Fix report draft save and microphone startup
- Allow draft reports to be saved without patient name or hospital ID while keeping completed reports strictly validated.

- Preserve completed-report identity validation when updating existing reports by checking merged old and new values.

- Show real API save errors in the report editor and send expired sessions back to login instead of reporting a generic backend outage.

- Guard speech startup for missing getUserMedia or AudioContext support and explain localhost/HTTPS microphone requirements.

- Add report schema tests covering draft identity fields and completed-report validation.

- Update AGENTS and docs for report editor behavior, feature status, progress, and testing coverage.
2026-05-02 03:21:45 +08:00
911b96b883 Add demo mode factory reset
- Align the backend seeded default surgery template with the report editor's default report content.

- Add backend demo defaults for the default template, Kimi provider, and Xunfei speech proxy configuration.

- Change system reset into a super-admin demo mode factory reset that clears reports, audit logs, files, custom templates, and non-default users.

- Keep only the default admin, manager, doctor, and default surgery template after demo reset.

- Replace the old local-only reset all data button with a two-confirmation backend reset flow.

- Add tests covering demo default alignment and database-backed demo reset behavior.

- Update docs to describe demo mode reset semantics and production credential cautions.
2026-05-02 02:52:30 +08:00
8de3a12dc1 Remove legacy settings secret migration
- Remove the super-admin one-time migration from browser local settings into backend AI and speech settings.

- Delete the migration-specific SystemSettings unit test that no longer matches the desired behavior.

- Restore feature, module, testing, and progress docs so settings secrets are documented as backend-managed only.
2026-05-02 02:26:21 +08:00
8e0332b3cf Migrate legacy AI and speech settings to backend
- Add a super-admin-only settings merge that copies legacy local AI provider keys into an empty backend settings record.

- Add matching migration for legacy Xunfei APPID, APIKey, and APISecret without overwriting existing backend secrets.

- Cover the migration and secret-preservation behavior with SystemSettings unit tests.

- Update feature, module, progress, and testing docs for the settings migration behavior.
2026-05-02 02:22:26 +08:00
750cf4129d Add audit log UI and backend API seeded E2E
- Add Auth Context route role guards so doctors cannot directly enter template management, user management, or audit logs.

- Add Audit Logs page, sidebar entry, frontend audit API client, and API client test.

- Add backend audit log query endpoint with super/admin visibility rules and query filtering.

- Extend PostgreSQL integration tests to cover audit log query permissions.

- Move Playwright E2E away from localStorage seed data to real backend API login and seed helpers.

- Add E2E coverage for route guards and audit log visibility.

- Run Playwright backend on port 3100 and proxy Vite API requests there to avoid local port conflicts.

- Make server:dev use the compiled NestJS server path, avoiding tsx parameter-property injection issues.

- Update README, AGENTS, feature, testing, security, deployment, progress, API, backendization, and auth/user module docs.
2026-05-02 02:04:56 +08:00
014aca8619 Initialize backendized SurClaw report system
- Add React/Vite frontend for login, dashboard, reports, templates, users, settings, AI, speech, and media workflows.

- Add NestJS/Prisma/PostgreSQL backend with auth, dashboard stats, reports, templates, users, departments, settings, files, AI, speech, audit logs, and HTML sanitization.

- Add Prisma schema, migrations, seed data, persistent app sessions, Docker/Nginx deployment files, and upload volume configuration.

- Add Vitest, Playwright, backend integration tests, and project documentation for requirements, design, permissions, API contracts, testing, deployment, security, and progress.

- Configure production local fallback switch and remove unused Gemini direct dependency/env wiring.
2026-05-02 01:41:57 +08:00