* Initial plan * fix: remove upgrade-insecure-requests from CSP to fix blank homepage over HTTP The upgrade-insecure-requests CSP directive instructs browsers to upgrade same-host HTTP requests to HTTPS (preserving port). In the default plain-HTTP Docker deployment (port 4174), the browser upgrades every asset URL to https://host:4174/... and sends a TLS Client Hello to the HTTP nginx port. nginx cannot parse TLS bytes as HTTP and returns 400 with no method/URI (the observed "400 - -" log pattern). All JS/CSS bundles fail to load, React never mounts, page stays blank. Fix: remove "; upgrade-insecure-requests" from the CSP string. This directive is intended for HTTPS-only sites and is harmful on plain-HTTP servers. Removing it does not weaken security for HTTP deployments. Agent-Logs-Url: https://github.com/DanielVolz/medassist-ng/sessions/9c4db7bd-1272-49ca-abf3-73c2ad5a5354 Co-authored-by: DanielVolz <3275994+DanielVolz@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: DanielVolz <3275994+DanielVolz@users.noreply.github.com>
33 KiB
Agent Memory Notes
Purpose: persistent agent work memory to survive context loss.
Entries
2026-04-10
- Task: Investigate and fix the production blank-homepage bug (user report: both containers running, blank page, many
400 - -log lines in frontend container). - Root cause:
upgrade-insecure-requestsdirective was present in theContent-Security-Policyheader infrontend/nginx.conf. This directive instructs browsers to upgrade all same-host HTTP requests to HTTPS (preserving the port). When users access the app over plain HTTP (e.g.,http://host:4174/), the browser receives this CSP and upgrades subsequent asset requests (/assets/index-*.js,/assets/index-*.css, favicons, API calls) tohttps://host:4174/.... The nginx container only speaks plain HTTP on port 4174, so it receives TLS Client Hello bytes which it cannot parse as an HTTP request. nginx returns400 Bad Requestwith no parseable method or URI — producing the400 - -log pattern. All JS/CSS bundles fail to load, React never mounts, and the page stays blank. - Fix: Removed
; upgrade-insecure-requestsfrom the CSP string infrontend/nginx.conf(line 20). No other changes needed. - Validation notes: The directive is safe to remove —
upgrade-insecure-requestsis designed for HTTPS-only sites and is harmful when the server runs on plain HTTP. Removing it does not weaken security for self-hosted HTTP deployments (mixed content is not a concern when the origin itself is HTTP). If a reverse proxy with TLS termination is added in front, the directive can be re-introduced at the proxy level. - Files touched:
frontend/nginx.conf.
2026-03-25
-
Task: Diagnose PR #475 GitHub CI failure for the frontend build job and fix testing/build-scope issues only.
-
Root cause: The GitHub "Frontend Build" check actually failed in the frontend lint step because
frontend/src/test/pages/MedicationsPage.test.tsxcontained a whitespace-only line that Biome rejects. -
Fix: Removed the stray whitespace-only line in
frontend/src/test/pages/MedicationsPage.test.tsxand revalidated frontend lint/build locally. -
Task: Split the medication enrichment lookup improvements into a standalone feature branch and repair the shared frontend tests until the focused validation set passed.
-
Decisions: Kept this branch limited to enrichment lookup/search/apply behavior, restored corrupted MedicationsPage and MobileEditModal test structure from clean main patterns, and retained desktop/mobile parity inside the feature scope.
-
Files touched: README.md, backend/src/routes/medication-enrichment.ts, backend/src/services/medication-enrichment.ts, backend/src/test/medication-enrichment.test.ts, frontend/src/components/MedicationEnrichmentSection.tsx, frontend/src/components/MobileEditModal.tsx, frontend/src/i18n/de.json, frontend/src/i18n/en.json, frontend/src/pages/MedicationsPage.tsx, frontend/src/styles.css, frontend/src/test/components/MedicationEnrichmentSection.test.tsx, frontend/src/test/components/MobileEditModal.test.tsx, frontend/src/test/pages/MedicationsPage.test.tsx, frontend/src/types/index.ts, frontend/src/utils/index.ts, frontend/src/utils/medication-enrichment.ts.
-
Follow-up: Merge the refreshed feature branch once GitHub CI is green again.
-
Task: Merge the refreshed feature branch on top of the already shipped stock/refill semantics changes without losing shared test coverage or work-log history.
-
Decisions: Kept the stock/refill doku history entries while resolving add/add conflicts and combined both branches' MedicationsPage tests in the shared file.
-
Files touched: doku/memory_notes.md, doku/report.md, frontend/src/test/pages/MedicationsPage.test.tsx.
-
Follow-up: Re-run the minimum frontend validation and push the conflict-resolution commit for PR #475.
-
Task: Review and merge the open Dependabot pull requests after verifying scope and CI state.
-
Decisions: Merged only dependency-only PRs with acceptable checks; accepted skipped jobs on the root-only tooling bump because the diff did not touch frontend or backend runtime code.
-
Merged PRs: #468 (
@biomejs/biomeroot bump), #469 (frontend dependency group bump), #470 (backend dependency group bump). -
Follow-up: Synced local
mainto commit39c19aband confirmed there are no remaining open Dependabot PRs from this reviewed set. -
Task: Investigate why last week's weekly triage report issue stayed open after a newer report was created.
-
Root cause:
.github/workflows/weekly-triage-report.ymlalways created a new issue and had no cleanup step for older open weekly report issues;.github/agents/release-manager.agent.mdalso lacked an explicit weekly-report closure rule. -
Fix: Added workflow logic to close older open weekly triage reports before publishing the new one and added a dedicated "Weekly Triage Report Hygiene" rule to the release-manager agent instructions.
-
Task: Ship the CSS architecture modernization in an isolated PR flow and then restore the local Spec Kit workspace artifacts after the requested main-branch cleanup.
-
Decisions: Used a fresh worktree from
github/mainto avoid shipping unrelated local residue, merged the CSS-only PR from that clean scope, then usedgit stash push -uto satisfy the requested clean localmainstate without deleting the local Spec Kit setup. -
Recovery: Verified that
.specify/,specs/001-css-monolith-modernization/,docs/SPEC_KIT.md,.github/agents/medassist-feature-orchestrator.agent.md,.github/agents/speckit.*, and.github/prompts/speckit.*were preserved insidestash@{0}and restored them withgit stash apply stash@{0}after the user requested them back. -
Correction: Updated
.github/agents/release-manager.agent.mdto make the intended rule explicit:git stashmay be used only temporarily during an active transition, never as the final mechanism for making localmainlook clean. A requested cleanmainnow explicitly means no leftover tracked changes, no leftover untracked task files, and no hidden task residue in stash. -
Follow-up correction: Added all current Spec Kit artifacts to
.gitignoreso the local setup no longer appears ingit status. The ignore covers.specify/,specs/,docs/SPEC_KIT.md,.github/agents/medassist-feature-orchestrator.agent.md,.github/agents/speckit.*.agent.md, and.github/prompts/speckit.*.prompt.md. -
Task: Perform a thorough repo-wide code-quality audit across backend and frontend without implementation.
-
Findings: The highest-risk hotspots are duplicated notification delivery logic across planner/manual and scheduler code paths, duplicated schedule/stock rendering logic across DashboardPage, SchedulePage, and SharedSchedule, oversized god modules such as
frontend/src/context/AppContext.tsx,frontend/src/pages/MedicationsPage.tsx,backend/src/routes/medications.ts,backend/src/routes/planner.ts,backend/src/services/reminder-scheduler.ts,backend/src/services/intake-reminder-scheduler.ts, andbackend/src/services/medication-enrichment.ts, plus several swallowed-error paths and broad file-level lint suppressions. -
Output: Prepared a severity-ranked review, a high-ROI remediation plan, and a deeper reporting breakdown for notifications, AppContext, and schedule UI duplication.
-
Documentation: Wrote the consolidated audit report to
doku/code-quality-audit-2026-03-26.mdso the findings and remediation priorities are preserved as a standalone markdown document. -
Task: Merge the newly opened Dependabot pull requests via the release-manager handoff path.
-
Result:
#482(backend picomatch bump),#483(frontend picomatch bump), and#484(root dev picomatch bump) were squash-merged after review.#485(backend yaml bump) was left open because its refreshed checks were still running and not fully green at decision time. -
Task: Review the open Dependabot PRs on GitHub and merge only the safe ones.
-
Scope review: Verified each Dependabot PR diff was dependency-only with no mixed product changes; all reviewed PRs only changed a single lockfile.
-
Merged: Squash-merged PR #483 (
picomatchin/frontend), PR #482 (picomatchin/backend), and PR #484 (rootpicomatchdev dependency lockfile update). -
Deferred: Left PR #485 (
yamlin/backend) open after rebasing it onto the updatedmainbecause its refreshed Playwright E2E check was still running, so the PR was not yet fully green at decision time. -
Task: Convert the code-quality audit into a concrete implementation plan.
-
Output: Added
plan/refactor-code-quality-remediation-1.mdwith phase-based remediation steps covering notification consolidation, shared schedule UI extraction, AppContext decomposition, MedicationsPage decomposition, backend service/module decomposition, and observability hardening. -
Constraint handling: Kept the plan split into reviewable phases so future implementation can stay within the repository's one-objective-per-PR rule.
-
Task: Review the remediation plan for execution readiness and prepare the next-agent handoff.
-
Decision: The plan structure was already sound, but it needed explicit PR-sized execution slices and a concrete first handoff target so the next agent does not start with an overly broad refactor scope.
-
Output: Added
Execution Slices & Handofftoplan/refactor-code-quality-remediation-1.md, recommendingmedassist-feature-orchestratorstart with Phase 1 only, followed by@testing-managerand then@release-manager. -
Task: Break the remediation plan into executable checklist tasks.
-
Constraint: The standard
.specify/scripts/bash/check-prerequisites.sh --jsonflow failed onmainbecause there is no active feature branch, so task generation usedplan/refactor-code-quality-remediation-1.mdanddoku/code-quality-audit-2026-03-26.mddirectly as the source artifacts. -
Output: Added
plan/refactor-code-quality-remediation-tasks-1.mdwith setup, foundational, six remediation user stories, cross-cutting polish, dependencies, parallel opportunities, and explicit testing/release handoff tasks. -
Task: Apply the three consistency remediations after the manual analysis findings.
-
Decisions: Created a local feature branch
002-code-quality-remediation, added a minimal Spec Kit feature set underspecs/002-code-quality-remediation/, reduced the task file's blocking foundations to MVP-relevant prerequisites only, added explicit local build/check validation tasks per slice, and split the later backend and observability work into narrower slices. -
Output: Updated
plan/refactor-code-quality-remediation-1.md, replacedplan/refactor-code-quality-remediation-tasks-1.md, and addedspecs/002-code-quality-remediation/spec.md,specs/002-code-quality-remediation/plan.md, andspecs/002-code-quality-remediation/tasks.md. -
Task: Implement US1 notification consolidation for code-quality remediation slice 1.
-
Decisions: Added a shared notification service layer under
backend/src/services/notifications/to centralize SMTP delivery, push delivery, push payload builders, and reminder state helpers. Refactored manual reminder routes and scheduler paths to consume the shared modules while preserving existing behavior and parity. -
Files touched:
backend/src/services/notifications/delivery.ts,backend/src/services/notifications/builders.ts,backend/src/services/notifications/state.ts,backend/src/services/notifications/index.ts,backend/src/services/reminder-scheduler.ts,backend/src/routes/planner.ts,backend/src/services/intake-reminder-scheduler.ts. -
Validation: Ran backend local validation (
npm run checkandnpm run buildinbackend/). First pass revealed leftover lint/type issues from refactor (unused symbols and stale SMTP variable references in planner logs), then applied targeted fixes and re-ran until both commands passed cleanly. -
Task: Hand off reminder regression testing to the designated testing owner.
-
Output: Delegated to
@testing-managerand captured a risk-based regression plan with prioritized existing tests (planner,intake-reminder-scheduler,stock-semantics-parity), concrete gap tests to add, exact run commands, and a PR-ready pass/fail checklist. -
Task: Continue with the next remediation task (US2/T016) after US1 completion.
-
Output: Completed schedule-duplication inventory across
frontend/src/pages/DashboardPage.tsx,frontend/src/pages/SchedulePage.tsx, andfrontend/src/components/SharedSchedule.tsx. -
Findings: Confirmed duplicated dose formatting helpers, duplicated timeline day rendering blocks, duplicated day collapse persistence/toggle mechanics, duplicated missed-dose summary/clear flow, and duplicated stock-row decoration/status branching.
-
Files updated:
specs/002-code-quality-remediation/plan.md(inventory notes),specs/002-code-quality-remediation/tasks.md(T016 marked done). -
Task: Implement US2/T017 shared schedule helper foundation.
-
Output: Added
frontend/src/features/schedule/formatters.tsandfrontend/src/features/schedule/storage.tsto centralize duplicated schedule amount formatting and collapse-state storage helpers ahead of page rewiring tasks. -
Files updated:
specs/002-code-quality-remediation/tasks.md(T017 marked done). -
Task: Implement US2/T018 shared schedule interaction helper foundation.
-
Output: Added
frontend/src/features/schedule/interactions.tswith reusable helpers for day-collapse state resolution and dose-progress counting. -
Files updated:
specs/002-code-quality-remediation/tasks.md(T018 marked done). -
Task: Complete US2 rewiring tasks T019-T021 to consume shared schedule helpers.
-
Output: Rewired
frontend/src/pages/DashboardPage.tsx,frontend/src/pages/SchedulePage.tsx, andfrontend/src/components/SharedSchedule.tsxto consume shared schedule formatting/storage/interaction helpers fromfrontend/src/features/schedule/. -
Validation: Editor diagnostics show no errors in the touched files after rewiring.
-
Files updated:
specs/002-code-quality-remediation/tasks.md(T019-T021 marked done). -
Task: Provide an immediate execution sequence for adapting US1 reminder consolidation tests in branch
002-code-quality-remediation. -
Output: Confirmed current coverage is concentrated in
backend/src/test/planner.test.tsandbackend/src/test/intake-reminder-scheduler.test.ts, identified missing direct unit coverage forbackend/src/services/notifications/{delivery,builders,state}.ts, and prepared an ordered command plan (baseline targeted run -> new unit tests -> targeted rerun -> backend check/build gate) with explicit completion criteria. -
Task: Testing handoff validation for US2 schedule helper consolidation and rewiring (T023).
-
Scope validated:
frontend/src/features/schedule/{formatters,storage,interactions}.ts, shared schedule components,frontend/src/pages/DashboardPage.tsx,frontend/src/pages/SchedulePage.tsx, andfrontend/src/components/SharedSchedule.tsx. -
Validation executed: targeted Vitest parity pack passed (
DashboardPage,SchedulePage,SharedSchedule,SharedScheduleTodayOnly, schedule utils, storage utils); targeted Playwright schedule specs mostly passed but one existing undo-visibility assertion failed infrontend/e2e/schedule-data.spec.ts. -
Gate status:
frontendnpm run checkstill fails only on pre-existing TypeScript errors infrontend/src/test/pages/MedicationsPage.test.tsxlines 887 and 1641 (resolveLoadMore?.(...)andresolveEnrichment?.(...)typed asnever). -
Classification: current TS check failures appear unrelated to US2 rewiring scope because they are confined to MedicationsPage enrichment tests and touched schedule suites passed.
-
Task: Start and advance US3 AppContext decomposition tasks (T025-T031).
-
Output: Added
US3 Inventory Notes (T025)inspecs/002-code-quality-remediation/plan.md; implemented first extracted boundary infrontend/src/context/ShareContext.tsxand wired it throughfrontend/src/context/AppContext.tsxandfrontend/src/App.tsx. -
Output: Added
frontend/src/hooks/useScheduleController.tsand migrated heavy consumers (frontend/src/pages/DashboardPage.tsx,frontend/src/pages/SchedulePage.tsx) to the smaller orchestration hook. -
Validation/Handoff: US3
frontendcheck gate remains blocked by pre-existing MedicationsPage test typing errors; handed off US3 regression validation to@testing-managerwith targeted test/command sequence and blocker classification. -
Task: Continue execution into US4 (T032/T033).
-
Output: Completed desktop/mobile medication-edit parity inventory and documented it in
specs/002-code-quality-remediation/plan.md(US4 Inventory Notes (T032)). -
Output: Extracted medication enrichment state controller to
frontend/src/hooks/useMedicationEnrichmentController.tsand rewiredfrontend/src/pages/MedicationsPage.tsxto consume the extracted hook/state handlers. -
Task: Testing handoff validation for US3 AppContext decomposition (ShareContext boundary + useScheduleController extraction).
-
Scope validated:
frontend/src/context/ShareContext.tsx,frontend/src/context/AppContext.tsx,frontend/src/hooks/useScheduleController.ts,frontend/src/pages/DashboardPage.tsx,frontend/src/pages/SchedulePage.tsx, andfrontend/src/App.tsx. -
Validation executed: frontend
npm run checkreproduces the same pre-existing TypeScript blocker infrontend/src/test/pages/MedicationsPage.test.tsxlines 887 and 1641; focused Vitest pass confirmed forSchedulePage+ShareDialogtests; targeted Playwright pass confirmed fore2e/schedule.spec.ts+e2e/share-schedule.spec.ts(23/23). -
Additional finding:
App.test.tsxandDashboardPage.test.tsxcurrently fail due stale module mocks missing the newuseShareContextexport, indicating test adaptation required for the extracted boundary rather than evidence of runtime schedule/share regression. -
Task: Complete US7/T052 by removing swallowed refresh-related failures in frontend settings flow.
-
Output: Updated
frontend/src/hooks/useSettings.tsto replace silent.catch(() => {})paths for reminder-status refresh and keepalive settings flush with explicit structured warning logs. -
Detail: Added a small local
getErrorMessagehelper to normalize unknown thrown values into loggable strings and reused it in the new catch handlers. -
Validation: Editor diagnostics for
frontend/src/hooks/useSettings.tsreport no errors after the changes.
2026-03-27
-
Task: Diagnose and fix PR #490 CI failures (
Frontend Build,Playwright E2E) in worktreemedassist-pr-e2e. -
Root causes:
- Frontend gate:
frontend/e2e/app-shell.spec.tshad a biome formatting violation; after fixing that,frontend/src/test/pages/MedicationsPage.test.tsxstill failed TypeScript (resolveLoadMore?.(...)andresolveEnrichment?.(...)inferred asnever). - Playwright E2E:
frontend/e2e/dashboard-data.spec.tsundo test asserted.day-block.todaybefore dashboard data was fully ready, causing intermittent/not-found failure in CI-like runs.
- Frontend gate:
-
Fixes:
- Added formatting newline in
frontend/e2e/app-shell.spec.ts. - Reworked resolver typing in
frontend/src/test/pages/MedicationsPage.test.tsxto definite-assignment callbacks with matchingPromisegenerics. - Hardened
frontend/e2e/dashboard-data.spec.tsundo flow by waiting for dashboard overview table and seeded medication row before asserting timeline blocks. - Reduced auth setup rate-limit pressure in
frontend/e2e/auth.setup.tsby switching to login-first and registering only as fallback before a single retry.
- Added formatting newline in
-
Validation:
cd frontend && CI=true npm run checkpassed.cd frontend && CI=true npm run buildpassed.cd frontend && PLAYWRIGHT_HTML_OPEN=never PLAYWRIGHT_WORKERS=1 npx playwright test --config=playwright.stable.config.ts --workers=1 e2e/dashboard-data.spec.ts --grep "should undo a taken dose|should mark a dose as taken and show undo"passed after resetting reused local servers and installing backend/frontend deps in this worktree.
-
Task: Complete US7/T053 by adding intentional optional-auth verification logging.
-
Output: Updated
backend/src/plugins/auth.tsoptional auth flow to emit debug logs for API-key/session verification outcomes (authenticated, key not found, key expired, inactive/missing user, session verify failure). -
Security note: Logs intentionally avoid token values and only include outcome-level context.
-
Validation: Editor diagnostics for
backend/src/plugins/auth.tsreport no errors. -
Task: Complete US7/T054 by adding state-file read/parse failure logging.
-
Output: Updated
backend/src/services/intake-reminder-scheduler.tssoloadIntakeReminderStatelogs parse/read failures with state-file path and normalized error message before falling back to default state. -
Validation: Editor diagnostics for
backend/src/services/intake-reminder-scheduler.tsreport no errors. -
Task: Complete US7/T055 by replacing remaining broad catches in known hotspot files.
-
Output: Updated
frontend/src/hooks/useSettings.tsto log failures inperformSave,testEmail, andtestShoutrrrcatch paths instead of broad silent catches. -
Output: Updated
backend/src/services/medication-enrichment.tsstartup/scheduled refresh catch handlers to log explicit failure context instead of swallowing with.catch(() => undefined). -
Verification: Pattern search across hotspot files (
useSettings,auth,medication-enrichment,intake-reminder-scheduler) shows no remainingcatch {}or silent.catch(() => undefined)signatures. -
Task: Complete US7/T056 by running required frontend/backend check and build gates before handoff.
-
Validation results:
frontend npm run checkremains blocked by known pre-existing TypeScript errors infrontend/src/test/pages/MedicationsPage.test.tsxlines 887 and 1641;frontend npm run buildpassed;backend npm run checkpassed;backend npm run buildpassed. -
Additional fix during gate run: resolved newly surfaced lint/import-order issues in
frontend/src/pages/MedicationsPage.tsxandfrontend/src/hooks/index.ts. -
Task: Complete US7/T057 observability testing handoff to
@testing-manager. -
Output: Delegated US7 validation scope and received targeted command set, add-test recommendations for new observability log paths, and conditional pass guidance with baseline frontend check blocker classification.
-
Task: Complete cross-cutting reconciliation tasks T058 and T059.
-
Output: Updated status alignment in
specs/002-code-quality-remediation/tasks.md,plan/refactor-code-quality-remediation-tasks-1.md, andplan/refactor-code-quality-remediation-1.md(plan status moved to In Progress with current execution snapshot). -
Task: Complete T060 release handoff.
-
Output: Delegated handoff summary to
@release-managerwith completed-task scope, validation snapshot, blocker classification, and PR-prep checklist notes for the current branch state. -
Task: Normalize task completion tracking after US7/cross-cutting execution.
-
Output: Reconciled historical checkboxes in
specs/002-code-quality-remediation/tasks.mdand mirrored status updates inplan/refactor-code-quality-remediation-tasks-1.mdso completed US1-US3 items and US5 T042/T043 are marked consistently. -
Remaining open tasks now focused to: US4 (
T034-T039), US5 (T040,T041,T044), and US6 (T045-T051). -
Task: Complete US4/T034 by extracting medication list orchestration from
MedicationsPage. -
Output: Added
frontend/src/components/medications/MedicationListSection.tsxand moved the grid/obsolete list rendering plus list actions into the new component while preserving existing handlers and UI behavior. -
Output: Rewired
frontend/src/pages/MedicationsPage.tsxto renderMedicationListSectionvia props/callbacks instead of inline list markup. -
Validation: Editor diagnostics report no errors in both touched files.
-
Task: Complete US5/T040 inventory for medication enrichment backend decomposition.
-
Output: Added
US5 Inventory Notes (T040)inspecs/002-code-quality-remediation/plan.mdwith concrete seam clusters (adapters, parsing/normalization, search/ranking, enrichment assembly, lifecycle/scheduler). -
Follow-up direction captured: target split into
backend/src/services/medication-enrichment/{adapters.ts,search.ts,index.ts}for T041. -
Task: Complete US6/T045 inventory for backend DB utility and route decomposition targets.
-
Output: Added
US6 Inventory Notes (T045)inspecs/002-code-quality-remediation/plan.mdcovering decomposition seams forbackend/src/db/db-utils.ts,backend/src/routes/medications.ts,backend/src/routes/planner.ts, andbackend/src/routes/settings.ts. -
Constraint capture: documented manual/scheduler reminder parity, shoutrrr extraction compatibility, and route-to-service dependency direction constraints for T046-T051.
-
Task: Complete US4/T035 by extracting desktop medication edit orchestration shell.
-
Output: Added
frontend/src/components/medications/MedicationEditCoordinator.tsxto own desktop edit panel wrapper concerns (sidebar/card header/form shell). -
Output: Rewired
frontend/src/pages/MedicationsPage.tsxto renderMedicationEditCoordinatorand keep form field internals as child content. -
Validation: Focused Biome check passed for
MedicationsPage.tsx,MedicationEditCoordinator.tsx,MedicationListSection.tsx, andcomponents/index.ts. -
Task: Validate US7 observability hardening slice for test readiness and release gate status.
-
Scope reviewed:
frontend/src/hooks/useSettings.ts,backend/src/plugins/auth.ts,backend/src/services/intake-reminder-scheduler.ts,backend/src/services/medication-enrichment.ts. -
Findings: Existing hook-level tests cover core
useSettingsbehavior but do not assert new warning-log paths; no direct backend tests currently assertoptionalAuthdebug outcome logging or medication enrichment startup/scheduled refresh catch logging. -
Additional risk note:
backend/src/services/intake-reminder-scheduler.tsnow depends on shared notification modules (services/notifications/*), so slice validation should include scheduler delivery-path regression checks in addition to new observability assertions. -
Gate classification: recommended as conditionally pass for US7 slice once targeted tests pass; frontend global
npm run checkremains blocked by pre-existing MedicationsPage test typing errors outside US7 scope. -
Task: Complete US4/T036 by extracting modal/lightbox/report concerns from
MedicationsPage. -
Output: Added
frontend/src/components/medications/MedicationDialogs.tsxand moved unsaved/obsolete/delete confirm modals, lightbox, and report modal rendering behind a single dialog orchestration component. -
Output: Rewired
frontend/src/pages/MedicationsPage.tsxto passMobileEditModalasmobileEditModalnode intoMedicationDialogs, preserving desktop/mobile edit flow behavior. -
Validation: Focused Biome check passed for
MedicationsPage.tsx,MedicationDialogs.tsx,MedicationEditCoordinator.tsx,MedicationListSection.tsx, andcomponents/index.ts. -
Tracking: Marked
T036complete in bothspecs/002-code-quality-remediation/tasks.mdandplan/refactor-code-quality-remediation-tasks-1.md. -
Note: Started a first draft for US4/T037 dashboard section extraction, then reverted
frontend/src/pages/DashboardPage.tsxto avoid carrying malformed intermediate edits; deferred T037 for a clean follow-up slice. -
Task: Complete remaining US4/US5/US6 implementation slice items (T037-T039, T041/T044, T046-T051).
-
Output: Repaired
frontend/src/pages/DashboardPage.tsxafter malformed insertion, finalized extraction tofrontend/src/components/dashboard/DashboardReminderSection.tsxandfrontend/src/components/dashboard/DashboardStatusSection.tsx, and preserved existing reminder/status behavior through componentized rendering. -
Output: Finalized backend decomposition with focused DB modules (
backend/src/db/{path-utils,migration-utils,repair-utils}.ts), route helper services (backend/src/services/{medications-service,planner-service,settings-service}.ts), and medication-enrichment module surface (backend/src/services/medication-enrichment/{adapters,search,index}.ts) plus route/import rewiring. -
Validation: Frontend gate for T038 executed as split runs due known baseline blocker:
npm run checkstill fails on pre-existingfrontend/src/test/pages/MedicationsPage.test.tsxTS errors at lines 887/1641, whilenpm run buildpassed; backend gate for T050 passed (npm run checkandnpm run build). -
Handoff record: Prepared and recorded testing-manager handoff scope for T039/T044/T051 (desktop/mobile parity checks, enrichment regression checks, and backend route/db regression checks) without running broad tests from this implementation agent.
-
Tracking: Marked T037-T039, T041/T044, and T046-T051 complete in both
specs/002-code-quality-remediation/tasks.mdandplan/refactor-code-quality-remediation-tasks-1.md. -
Task: Implement missing regression tests and hard evidence for T039, T044, and T051.
-
Output (frontend T039): Added
frontend/src/test/components/MedicationEditCoordinator.test.tsxandfrontend/src/test/components/MedicationDialogs.test.tsxwith explicit desktop edit-shell and dialog orchestration assertions; retained mobile parity evidence viafrontend/src/test/components/MobileEditModal.test.tsxtargeted execution. -
Output (backend T044): Extended
backend/src/test/medication-enrichment.test.tswith split-module export parity assertions (index/search/adaptersvs canonical service) and transport-safe search failure contract assertion. -
Output (backend T051): Added
backend/src/test/decomposition-services.test.tsfor extracted service helpers (medications-service,planner-service,settings-service) and updatedbackend/src/test/database.test.tsto assert.write-testresidue is not left behind. -
Validation commands/results:
cd frontend && CI=true npm run test:run -- src/test/components/MedicationEditCoordinator.test.tsx src/test/components/MedicationDialogs.test.tsx src/test/components/MobileEditModal.test.tsx-> passed (3files,71tests).cd backend && CI=true npm run test:run -- src/test/decomposition-services.test.ts src/test/medication-enrichment.test.ts src/test/database.test.ts src/test/medications.test.ts src/test/planner.test.ts src/test/settings.test.ts-> passed (6files,160tests).cd frontend && npm run check && npm run build-> baseline fail atfrontend/src/test/pages/MedicationsPage.test.tsxlines887and1641(TS2349: Type 'never' has no call signatures); unchanged pre-existing blocker.cd backend && npm run check && npm run build-> passed.
-
Task: Achieve fully green backend/frontend/E2E test state after prior baseline blocker reports.
-
Root causes fixed:
- Backend:
backend/src/test/db-client.test.tsstill mocked legacy../db/db-utils.jswhilebackend/src/db/client.tsimports split modules (path-utils,migration-utils,repair-utils), causing falseprocess.exit(1)failures. - Frontend: test mocks were stale after context/hook/component decomposition (
useShareContext,useMedicationEnrichmentController, and modal orchestration moved behindMedicationDialogs).
- Backend:
-
Fixes applied:
- Hardened backend test env defaults in
backend/src/test/setup.ts(DOTENV_PATH,AUTH_ENABLED,OIDC_ENABLED, plusafterEachreset). - Updated
backend/src/test/db-client.test.tsmocks to target../db/path-utils.js,../db/migration-utils.js, and../db/repair-utils.js. - Updated
frontend/src/test/App.test.tsxto mock and assert share state viauseShareContext/shareContextMock. - Updated
frontend/src/test/pages/MedicationsPage.test.tsxto partially mock hooks barrel with real exports and added deterministic mock for../../components/medications/MedicationDialogs.
- Hardened backend test env defaults in
-
Final validation (all green):
cd backend && CI=true npm run test:run-> passed (25files,639tests).cd frontend && CI=true npm run test:run-> passed (47files,881tests).cd frontend && PLAYWRIGHT_HTML_OPEN=never PLAYWRIGHT_WORKERS=1 npm run test:e2e -- --workers=1-> passed (stable suite, exit code0, with one expected skipped scenario).cd backend && npm run check-> passed.cd frontend && npm run check-> passed.
-
Task: Start full Playwright coverage expansion for app-shell/public-route gaps and stabilize flaky stable-suite checks.
-
Output: Added
frontend/e2e/app-shell.spec.tswith new E2E coverage for user-menu profile modal, about modal, sign-out flow, and public route redirect/share/:token/overview -> /share/:token. -
Output: Stabilized flaky assertions in
frontend/e2e/dashboard-data.spec.ts,frontend/e2e/schedule-data.spec.ts, andfrontend/e2e/planner-data.spec.tsby hardening take/undo flow timing and making stock text assertion tolerant of dynamic consumption. -
Output: Hardened
frontend/e2e/settings.spec.tscalculation-mode toggle check to avoid hidden-input interaction and auto-save race conditions. -
Validation: Re-ran
E2E stable non-interactiverepeatedly after each fix cycle; latest run state is green for all executed tests (157 passed) with environment/guarded scenarios reported as skipped (4 skipped) and no failing tests.