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
address review (codex): keep a corrupt integration config from hiding its navigation
[._.]/ Adam Eivy9f1da6b9b57b
diff --git a/client/src/components/settings/InstanceFeaturesTab.test.jsx b/client/src/components/settings/InstanceFeaturesTab.test.jsxindex 6a695366cc..232f3d2cf5 100644--- a/client/src/components/settings/InstanceFeaturesTab.test.jsx+++ b/client/src/components/settings/InstanceFeaturesTab.test.jsx@@ -8,6 +8,7 @@ const mock = vi.hoisted(() => ({vi.mock('../../services/api', () => mock);+import { INSTANCE_FEATURES_CHANGED } from '../../constants/events.js';import { __resetInstanceFeatureCache } from '../../hooks/useInstanceFeatures.js';import InstanceFeaturesTab from './InstanceFeaturesTab';@@ -73,6 +74,27 @@ describe('InstanceFeaturesTab', () => {expect(await screen.findByText(/no JIRA instance is configured yet/i)).toBeInTheDocument();});+ // The sidebar and ⌘K read the same module cache; a retry that updated only+ // this tab would leave them in the fail-open state until a full reload.+ it('broadcasts a successful retry to the other consumers', async () => {+ mock.getInstanceFeatures.mockRejectedValueOnce(new Error('offline'));+ const heard = [];+ const listen = (event) => heard.push(event.detail);+ window.addEventListener(INSTANCE_FEATURES_CHANGED, listen);++ try {+ render(<InstanceFeaturesTab />);+ const retry = await screen.findByRole('button', { name: 'Retry' });+ mock.getInstanceFeatures.mockResolvedValue({ features: [POST_FEATURE] });+ fireEvent.click(retry);++ await screen.findByRole('switch', { name: 'Disable POST on this instance' });+ expect(heard.some((detail) => Array.isArray(detail?.features))).toBe(true);+ } finally {+ window.removeEventListener(INSTANCE_FEATURES_CHANGED, listen);+ }+ });+it('offers a retry when the feature list cannot be read', async () => {mock.getInstanceFeatures.mockRejectedValueOnce(new Error('offline'));render(<InstanceFeaturesTab />);diff --git a/client/src/hooks/useInstanceFeatures.js b/client/src/hooks/useInstanceFeatures.jsindex 9a10aaa685..7eec29ab09 100644--- a/client/src/hooks/useInstanceFeatures.js+++ b/client/src/hooks/useInstanceFeatures.js@@ -88,9 +88,15 @@ export function useInstanceFeatures() {return feature ? feature.enabled !== false : true;}, [features, error]);+ // Announced rather than applied locally: after a failed first fetch every+ // consumer is sitting in the fail-open error state, and a retry that updated+ // only the Settings tab would leave the sidebar and ⌘K stale until a reload.const reload = useCallback(() => {cached = null;- return loadInstanceFeatures().then((result) => setState(result));+ return loadInstanceFeatures().then((result) => {+ if (result.features) publishInstanceFeatures(result.features);+ else setState(result);+ });}, []);return { features, error, isFeatureEnabled, reload };@@ -106,6 +112,16 @@ export const publishInstanceFeatures = (features, { featureId, enabled } = {}) =}));};+/**+ * Announce that the state a feature's AUTO-detection reads has changed — the+ * integration pages call this after adding or removing an instance, because the+ * DataDog/JIRA gates are derived from whether one is configured. Carries no+ * feature list, so every listener re-fetches the freshly-resolved answer.+ */+export const invalidateInstanceFeatures = (featureId) => {+ publishInstanceFeatures(null, { featureId });+};+// Test-only: drop the module cache so suites don't leak state between tests.export const __resetInstanceFeatureCache = () => {cached = null;diff --git a/client/src/pages/DataDog.jsx b/client/src/pages/DataDog.jsxindex 96cd8504ae..9134baaeea 100644--- a/client/src/pages/DataDog.jsx+++ b/client/src/pages/DataDog.jsx@@ -4,6 +4,7 @@ import { FormField } from '../components/ui/FormField';import PageSkeleton from '../components/ui/PageSkeleton';import Modal from '../components/ui/Modal';import api from '../services/api';+import { invalidateInstanceFeatures } from '../hooks/useInstanceFeatures.js';const SITE_OPTIONS = [{ value: 'api.datadoghq.com', label: 'US1 (api.datadoghq.com)' },@@ -105,6 +106,10 @@ export default function DataDog() {const saved = await api.post('/datadog/instances', payload, { silent: true });+ // The DataDog nav entries are auto-gated on whether any instance is+ // configured, so saving the FIRST one is what reveals them — without this+ // they stay hidden until a full reload.+ invalidateInstanceFeatures('datadog');toast.success(`DataDog instance "${payload.name}" saved successfully`);setInstances(prev => ({ ...prev, [saved.id]: saved }));handleCancel();@@ -127,6 +132,8 @@ export default function DataDog() {try {await api.delete(`/datadog/instances/${instanceId}`, { silent: true });+ // Removing the LAST instance re-hides the nav entries (see the save path).+ invalidateInstanceFeatures('datadog');toast.success(`DataDog instance "${instanceId}" deleted`);setInstances(prev => {const next = { ...prev };diff --git a/client/src/pages/Jira.jsx b/client/src/pages/Jira.jsxindex c7ec9a8f23..0a7e491758 100644--- a/client/src/pages/Jira.jsx+++ b/client/src/pages/Jira.jsx@@ -5,6 +5,7 @@ import PageSkeleton from '../components/ui/PageSkeleton';import { FormField } from '../components/ui/FormField';import Modal from '../components/ui/Modal';import api from '../services/api';+import { invalidateInstanceFeatures } from '../hooks/useInstanceFeatures.js';// PAT lifetimes aren't a fixed platform constant — Cloud API tokens typically don't// expire on a schedule at all, and Server/DC PAT expiration is chosen per-token by@@ -109,6 +110,10 @@ export default function Jira() {const saved = await api.post('/jira/instances', payload, { silent: true });+ // The JIRA nav entries are auto-gated on whether any instance is+ // configured, so saving the FIRST one is what reveals them — without this+ // they stay hidden until a full reload.+ invalidateInstanceFeatures('jira');toast.success(`JIRA instance "${payload.name}" saved successfully`);setInstances(prev => ({ ...prev, [saved.id]: saved }));handleCancel();@@ -131,6 +136,8 @@ export default function Jira() {try {await api.delete(`/jira/instances/${instanceId}`, { silent: true });+ // Removing the LAST instance re-hides the nav entries (see the save path).+ invalidateInstanceFeatures('jira');toast.success(`JIRA instance "${instanceId}" deleted`);setInstances(prev => {const next = { ...prev };diff --git a/server/services/datadog.js b/server/services/datadog.jsindex c73e6df2a3..a073392b5d 100644--- a/server/services/datadog.js+++ b/server/services/datadog.js@@ -32,8 +32,14 @@ export async function getInstances() {// Whether this install has any DataDog instance configured — the signal the// instance-feature registry uses to decide whether the DataDog nav entries// should appear before the user has toggled the feature explicitly.+//+// Deliberately NOT getInstances(): `strict` makes a PRESENT-but-corrupt config+// throw instead of reading as the empty default, so the caller records+// "detection failed" and falls back to the shipped default rather than a+// confident "no instances" that would silently hide the DataDog navigation. An+// absent file still returns the empty default — absent is a trustworthy empty.export async function hasConfiguredInstances() {- const config = await getInstances();+ const config = await readJSONFile(DATADOG_CONFIG_FILE, { instances: {} }, { logError: false, strict: true });return Object.keys(config?.instances || {}).length > 0;}diff --git a/server/services/instanceFeatures.test.js b/server/services/instanceFeatures.test.jsindex 0fd7d11721..a4ef5ba7b9 100644--- a/server/services/instanceFeatures.test.js+++ b/server/services/instanceFeatures.test.js@@ -140,6 +140,17 @@ describe('instance features', () => {expect(await isInstanceFeatureEnabled('datadog')).toBe(false);});+ // A PRESENT-but-corrupt config file is the case that fails silently: the+ // detector must throw so this resolves to the shipped default, NOT report a+ // confident "no instances" that would hide the navigation.+ it('treats a corrupt integration config as detection failure, not "unconfigured"', async () => {+ mock.datadogThrows = true;+ mock.settings = {};++ expect((await detectFeatureConfiguration()).datadog).toBeNull();+ expect(byId((await getInstanceFeatures()).features, 'datadog')).toMatchObject({ source: 'default' });+ });+it('reports no detection for a feature with no detector', async () => {expect(await detectFeatureConfiguration()).toMatchObject({ post: null });expect(byId((await getInstanceFeatures()).features, 'post')).toMatchObject({ source: 'default' });diff --git a/server/services/jira.js b/server/services/jira.jsindex 076caddbff..e3eda4557c 100644--- a/server/services/jira.js+++ b/server/services/jira.js@@ -15,8 +15,14 @@ const JIRA_CONFIG_FILE = path.join(PATHS.data, 'jira.json');// unlike getInstances() it never seeds an empty config file, because the// instance-feature registry calls it just to decide whether the JIRA nav// entries should appear on a fresh install.+//+// `strict` so a PRESENT-but-corrupt config throws instead of reading as the+// empty default. The caller turns a throw into "detection failed" and falls back+// to the shipped default; without it an unparseable jira.json would report a+// confident "no instances" and silently hide the JIRA navigation. A genuinely+// absent file still returns the empty default — absent is a trustworthy empty.export async function hasConfiguredInstances() {- const config = await readJSONFile(JIRA_CONFIG_FILE, { instances: {} }, { logError: false });+ const config = await readJSONFile(JIRA_CONFIG_FILE, { instances: {} }, { logError: false, strict: true });return Object.keys(config?.instances || {}).length > 0;}