Skip to content

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

address review (codex): don't 400 goal edits on forward-unknown featureAreas ids

[._.]/ Adam Eivy3091db35d935
diff --git a/client/src/components/goals/GoalDetailPanel.test.jsx b/client/src/components/goals/GoalDetailPanel.test.jsx
index d537d7a9da..eb82bdecf2 100644
--- a/client/src/components/goals/GoalDetailPanel.test.jsx
+++ b/client/src/components/goals/GoalDetailPanel.test.jsx
@@ -189,4 +189,41 @@ describe('GoalDetailPanel Daily Driver feature-area override (issue #2679)', ()
expect.objectContaining({ featureAreas: [] })
);
});
+
+ it('omits featureAreas from the payload when the override was not touched (forward-compat)', async () => {
+ // Editing an unrelated field must NOT round-trip featureAreas — otherwise a
+ // goal synced from a newer federated peer carrying a forward-unknown area id
+ // would 400 against the strict updateGoalInputSchema enum. Omitting the key
+ // lets the service preserve the stored value (unknown ids included).
+ await renderPanel({ ...baseGoal, featureAreas: ['someFutureAreaFromANewerPeer'] });
+ fireEvent.click(screen.getByText('Edit'));
+ // Change only the title; never touch the feature-area buttons.
+ const titleInput = screen.getByDisplayValue('Master the craft');
+ fireEvent.change(titleInput, { target: { value: 'Master the craft, revised' } });
+ await act(async () => {
+ fireEvent.click(screen.getByText('Save'));
+ await Promise.resolve();
+ });
+ const [, payload] = api.updateGoal.mock.calls[0];
+ expect(payload).not.toHaveProperty('featureAreas');
+ expect(payload.title).toBe('Master the craft, revised');
+ });
+
+ it('strips locally-unknown ids when the override IS changed', async () => {
+ // A goal carries a forward-unknown id plus a known one; the user toggles a
+ // known area, so the override is "changed" and gets sent — but the unknown
+ // id (invisible in this install's UI) must be stripped so the update still
+ // validates.
+ await renderPanel({ ...baseGoal, featureAreas: ['someFutureAreaFromANewerPeer', 'universes'] });
+ fireEvent.click(screen.getByText('Edit'));
+ // Toggle a different known area on → override changed.
+ fireEvent.click(screen.getByRole('button', { name: /Tribe/ }));
+ await act(async () => {
+ fireEvent.click(screen.getByText('Save'));
+ await Promise.resolve();
+ });
+ const [, payload] = api.updateGoal.mock.calls[0];
+ expect(payload.featureAreas).toEqual(['universes', 'tribe']);
+ expect(payload.featureAreas).not.toContain('someFutureAreaFromANewerPeer');
+ });
});
diff --git a/client/src/hooks/useGoalDetail.js b/client/src/hooks/useGoalDetail.js
index 754da80e35..d0d285ae31 100644
--- a/client/src/hooks/useGoalDetail.js
+++ b/client/src/hooks/useGoalDetail.js
@@ -1,6 +1,7 @@
import { useState, useEffect } from 'react';
import * as api from '../services/api';
import { MAX_TAGS, MAX_TAG_LENGTH } from '../components/goals/goalConstants';
+import { FEATURE_AREA_IDS } from '../lib/goalFeatureMap';
// State + handlers backing GoalDetailPanel. Extracted so the panel can stay a
// thin composition shell; behavior is identical to the prior inline logic.
@@ -68,12 +69,29 @@ export function useGoalDetail({ goal, allGoals, onClose, onRefresh }) {
};
const saveEdit = async () => {
- await api.updateGoal(goal.id, {
- ...form,
+ // Forward-compat across federated installs (issue #2679): a goal synced
+ // from a newer peer can carry a `featureAreas` id this install doesn't know
+ // yet, and `updateGoalInputSchema`'s strict enum would 400 if we sent it.
+ // So only include `featureAreas` in the payload when the user actually
+ // changed the override — when unchanged, omit it and let the service
+ // preserve the stored value (unknown ids included). On the changed path,
+ // strip to locally-known ids so the update always validates.
+ const { featureAreas, ...rest } = form;
+ const original = goal.featureAreas || [];
+ const current = featureAreas || [];
+ const featureAreasChanged =
+ current.length !== original.length ||
+ current.some((id, i) => id !== original[i]);
+ const payload = {
+ ...rest,
parentId: form.parentId || null,
targetDate: form.targetDate || null,
timeBlockConfig: form.timeBlockConfig || null
- });
+ };
+ if (featureAreasChanged) {
+ payload.featureAreas = current.filter(id => FEATURE_AREA_IDS.includes(id));
+ }
+ await api.updateGoal(goal.id, payload);
setEditing(false);
onRefresh();
};