Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: use local dates for new health measurements
Adam Eivy5f609d9d4b52
diff --git a/client/src/components/meatspace/BloodPressureCard.jsx b/client/src/components/meatspace/BloodPressureCard.jsxindex 77da6c7ad3..4adec3ea8d 100644--- a/client/src/components/meatspace/BloodPressureCard.jsx+++ b/client/src/components/meatspace/BloodPressureCard.jsx@@ -7,7 +7,7 @@ import * as api from '../../services/api';import BrailleSpinner from '../BrailleSpinner';import LoadFailureNotice from './LoadFailureNotice';import useChartColors from '../../hooks/useChartColors.js';-import { formatMonthDay } from '../../utils/formatters.js';+import { formatMonthDay, localDateKey } from '../../utils/formatters.js';import { classifyBP, bpLongevityImpact, BP_CATEGORIES } from './bpClassification';// Stage 1 hypertension reference line sits between the warning (elevated) and@@ -43,7 +43,7 @@ export default function BloodPressureCard() {useEffect(() => { fetchData(); }, [fetchData]);const openForm = () => {- setForm({ ...EMPTY_FORM, date: new Date().toISOString().split('T')[0] });+ setForm({ ...EMPTY_FORM, date: localDateKey() });setShowForm(true);};diff --git a/client/src/components/meatspace/tabs/BodyTab.jsx b/client/src/components/meatspace/tabs/BodyTab.jsxindex 9cb94cc469..65fab18fef 100644--- a/client/src/components/meatspace/tabs/BodyTab.jsx+++ b/client/src/components/meatspace/tabs/BodyTab.jsx@@ -5,6 +5,7 @@ import BrailleSpinner from '../../BrailleSpinner';import LoadFailureNotice from '../LoadFailureNotice';import ConfirmButtonPair from '../../ui/ConfirmButtonPair';import { useConfirmDelete } from '../../../hooks/useConfirmDelete';+import { localDateKey } from '../../../utils/formatters';import BodyCompChart from '../BodyCompChart';import BloodPressureCard from '../BloodPressureCard';@@ -119,7 +120,7 @@ export default function BodyTab() {</div>{!showEyeForm && editingEyeId == null && (<button- onClick={() => { setShowEyeForm(true); setEyeForm({ ...EMPTY_EYE_FORM, date: new Date().toISOString().split('T')[0] }); }}+ onClick={() => { setShowEyeForm(true); setEyeForm({ ...EMPTY_EYE_FORM, date: localDateKey() }); }}className="flex items-center gap-1 text-xs text-port-accent hover:text-port-accent/80 transition-colors"><Plus size={14} /> Add Examdiff --git a/client/src/components/meatspace/tabs/BodyTab.test.jsx b/client/src/components/meatspace/tabs/BodyTab.test.jsxnew file mode 100644index 0000000000..8d6de70f1c--- /dev/null+++ b/client/src/components/meatspace/tabs/BodyTab.test.jsx@@ -0,0 +1,88 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import { act, cleanup, fireEvent, render, screen } from '@testing-library/react';++vi.mock('../../../services/api', () => ({+ getBodyHistory: vi.fn(), getBloodPressure: vi.fn(), addBloodPressure: vi.fn(),+ getEyeExams: vi.fn(), addEyeExam: vi.fn(), updateEyeExam: vi.fn(),+}));+vi.mock('../../../hooks/useChartColors.js', () => ({ default: () => ({}) }));+// Charts do not participate in date entry and require browser layout.+vi.mock('recharts', () => ({+ ResponsiveContainer: () => null, LineChart: () => null, Line: () => null,+ XAxis: () => null, YAxis: () => null, CartesianGrid: () => null,+ Tooltip: () => null, Legend: () => null, ReferenceLine: () => null,+}));++import * as api from '../../../services/api';+import BodyTab from './BodyTab';++const EXISTING_EXAM = { id: 'exam-1', date: '2026-02-10', leftSphere: -1 };++beforeEach(() => {+ // At this instant a UTC-7 browser is still on March 14. Scope its calendar+ // getters to this test rather than changing the process-wide TZ environment.+ vi.useFakeTimers({ toFake: ['Date'] });+ vi.setSystemTime(new Date('2026-03-15T00:30:00Z'));+ for (const part of ['FullYear', 'Month', 'Date']) {+ vi.spyOn(Date.prototype, `get${part}`).mockImplementation(function () {+ return new Date(this.getTime() - 7 * 60 * 60 * 1000)[`getUTC${part}`]();+ });+ }+ api.getBodyHistory.mockResolvedValue([]);+ api.getBloodPressure.mockResolvedValue({ readings: [] });+ api.getEyeExams.mockResolvedValue({ exams: [EXISTING_EXAM] });+ api.addBloodPressure.mockImplementation(async input => input);+ api.addEyeExam.mockImplementation(async input => ({ id: 'exam-2', ...input }));+ api.updateEyeExam.mockImplementation(async (id, input) => ({ id, ...input }));+});++afterEach(() => {+ cleanup();+ vi.restoreAllMocks();+ vi.useRealTimers();+});++const changeField = (label, value) => fireEvent.change(screen.getByLabelText(label), { target: { value } });+const click = async name => {+ await act(async () => { fireEvent.click(screen.getByRole('button', { name, exact: true })); });+};++describe('BodyTab measurement dates', () => {+ it('shows and saves the browser-local day for new blood pressure readings and eye exams', async () => {+ await act(async () => { render(<BodyTab />); });+ await click('Add Reading');+ expect(screen.getByLabelText('Date')).toHaveValue('2026-03-14');+ changeField('Systolic', '120');+ changeField('Diastolic', '80');+ await click('Save Reading');+ expect(api.addBloodPressure).toHaveBeenCalledWith({ date: '2026-03-14', systolic: 120, diastolic: 80 });++ await click('Add Exam');+ expect(screen.getByLabelText('Date')).toHaveValue('2026-03-14');+ changeField('L SPH', '-1.25');+ await click('Add');+ expect(api.addEyeExam).toHaveBeenCalledWith({ date: '2026-03-14', leftSphere: -1.25 });+ });++ it('preserves backdated entries and the stored date when editing an existing exam', async () => {+ await act(async () => { render(<BodyTab />); });+ await click('Edit');+ expect(screen.getByLabelText('Date')).toHaveValue(EXISTING_EXAM.date);+ changeField('L SPH', '-1.5');+ await click('Save');+ expect(api.updateEyeExam).toHaveBeenCalledWith('exam-1', { date: '2026-02-10', leftSphere: -1.5 });++ await click('Add Reading');+ changeField('Date', '2026-03-01');+ changeField('Systolic', '118');+ changeField('Diastolic', '78');+ await click('Save Reading');+ expect(api.addBloodPressure).toHaveBeenCalledWith({ date: '2026-03-01', systolic: 118, diastolic: 78 });++ await click('Add Exam');+ changeField('Date', '2026-03-02');+ changeField('R SPH', '-0.75');+ await click('Add');+ expect(api.addEyeExam).toHaveBeenCalledWith({ date: '2026-03-02', rightSphere: -0.75 });+ });+});