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

fix(apps): show failed Layered Intelligence and DataDog reads in Edit App as errors

[._.]/ Adam Eivy5605d27522bd
diff --git a/client/src/components/apps/EditAppDrawer.jsx b/client/src/components/apps/EditAppDrawer.jsx
index d827643a1d..88743b220a 100644
--- a/client/src/components/apps/EditAppDrawer.jsx
+++ b/client/src/components/apps/EditAppDrawer.jsx
@@ -7,7 +7,9 @@ import { PORTOS_APP_ID } from '../../services/apiCore';
import toast from '../ui/Toast';
import Drawer from '../Drawer';
import Banner from '../ui/Banner';
+import ListLoadError from '../ui/ListLoadError';
import useDrawerTab from '../../hooks/useDrawerTab';
+import useListResource from '../../hooks/useListResource';
import { copyToClipboard } from '../../lib/clipboard';
import LayeredIntelligenceTab, { buildLayeredIntelligenceUpdate, buildLayeredIntelligenceScheduleUpdate } from './LayeredIntelligenceTab';
import { PROVIDER_TYPES } from '../../utils/providers';
@@ -37,6 +39,10 @@ const TABS = [
];
const TAB_IDS = TABS.map(t => t.id);
+// Silent: the DataDog section renders its own error row with Retry.
+const loadDatadogInstances = () => api.getDatadogInstances({ silent: true })
+ .then(data => (data?.instances ? Object.values(data.instances) : []));
+
// Port fields that must be validated on save even when their tab is unmounted.
const PORT_FIELDS = [
['uiPort', 'UI Port'],
@@ -135,13 +141,7 @@ export default function EditAppDrawer({ app, onClose, onSave }) {
}
};
const [workTrackerInfo, setWorkTrackerInfo] = useState(null);
- const [datadogInstances, setDatadogInstances] = useState([]);
-
- useEffect(() => {
- api.getDatadogInstances()
- .then(data => setDatadogInstances(data?.instances ? Object.values(data.instances) : []))
- .catch(() => setDatadogInstances([]));
- }, []);
+ const datadogInstances = useListResource(loadDatadogInstances);
useEffect(() => {
let cancelled = false;
@@ -162,12 +162,14 @@ export default function EditAppDrawer({ app, onClose, onSave }) {
setLiError(false);
Promise.all([
api.getAppLayeredIntelligence(app.id),
- api.getProviders({ silent: true }).catch(() => ({ providers: [] })),
+ api.getProviders({ silent: true }),
// Scheduling (enabled/interval/provider/model) lives in the per-app task
// override now (#2322); behavior (sources/scopes/rules/handoff) stays in the
// layeredIntelligence config. Merge the override on top so the tab shows the
- // scheduling source of truth.
- api.getAppTaskTypes(app.id).catch(() => ({ taskTypeOverrides: {} }))
+ // scheduling source of truth. A failed override read fails the whole tab:
+ // defaulting it would show a running loop as off, and toggling "off" then
+ // diffs as no change, so the loop could not be stopped from here.
+ api.getAppTaskTypes(app.id, { silent: true })
]).then(([li, provData, taskTypes]) => {
if (cancelled) return;
const behavior = li?.config || null;
@@ -836,7 +838,11 @@ export default function EditAppDrawer({ app, onClose, onSave }) {
{formData.datadogEnabled && (
<>
- {datadogInstances.length === 0 ? (
+ {datadogInstances.state === 'error' ? (
+ <ListLoadError what="DataDog instances" error={datadogInstances.error} onRetry={datadogInstances.retry} />
+ ) : datadogInstances.state === 'loading' ? (
+ <p className="text-sm text-gray-500">Loading DataDog instances…</p>
+ ) : datadogInstances.items.length === 0 ? (
<Banner tone="warning" size="md">
No DataDog instances configured. <Link to="/devtools/datadog" className="underline hover:text-white">Configure DataDog</Link> first.
</Banner>
@@ -851,7 +857,7 @@ export default function EditAppDrawer({ app, onClose, onSave }) {
className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden"
>
<option value="">Select instance...</option>
- {datadogInstances.map(inst => (
+ {datadogInstances.items.map(inst => (
<option key={inst.id} value={inst.id}>{inst.name} ({inst.site})</option>
))}
</select>
diff --git a/client/src/components/apps/EditAppDrawer.test.jsx b/client/src/components/apps/EditAppDrawer.test.jsx
index dd38ebc025..c27304c2b9 100644
--- a/client/src/components/apps/EditAppDrawer.test.jsx
+++ b/client/src/components/apps/EditAppDrawer.test.jsx
@@ -9,6 +9,7 @@ vi.mock('../../services/api', () => ({
getInstanceFeatures: vi.fn(),
getAppWorkTracker: vi.fn(),
getAppLayeredIntelligence: vi.fn(),
+ getAppLayeredIntelligenceOutcomes: vi.fn(),
getAppTaskTypes: vi.fn(),
updateAppTaskTypeOverride: vi.fn(),
getProviders: vi.fn(),
@@ -73,6 +74,7 @@ beforeEach(() => {
allowedScopes: ['app-improvement', 'app-data-gap'],
},
});
+ api.getAppLayeredIntelligenceOutcomes.mockResolvedValue({ stats: {}, recent: [] });
api.getProviders.mockResolvedValue({ providers: [] });
// Scheduling (enabled/interval/provider/model) is read from the per-app task
// override now (#2322); default to an empty override.
@@ -350,3 +352,33 @@ describe('EditAppDrawer required-field validation across tabs', () => {
expect(await screen.findByLabelText('UI Port')).toBeInTheDocument();
});
});
+
+describe('EditAppDrawer failed reads', () => {
+ it('fails the Intelligence tab, not the loop state, when the schedule override read fails', async () => {
+ // A defaulted override would render an enabled loop as off, and unticking it
+ // would then diff as no change — the loop could not be stopped from here.
+ api.getAppTaskTypes.mockRejectedValueOnce(new Error('boom'));
+ api.getAppTaskTypes.mockResolvedValue({ taskTypeOverrides: { 'layered-intelligence': { enabled: true } } });
+ renderDrawer();
+ await openTab('Intelligence');
+
+ expect(await screen.findByText(/Couldn.t load the Layered Intelligence config/)).toBeInTheDocument();
+ expect(screen.queryByLabelText('Enable the self-improvement loop for this app')).not.toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole('button', { name: 'Retry' }));
+ expect(await screen.findByLabelText('Enable the self-improvement loop for this app')).toBeChecked();
+ });
+
+ it('shows a retryable error instead of "no instances configured" when the DataDog read fails', async () => {
+ api.getDatadogInstances.mockRejectedValueOnce(new Error('boom'));
+ api.getDatadogInstances.mockResolvedValue({ instances: { dd1: { id: 'dd1', name: 'Prod', site: 'datadoghq.com' } } });
+ renderDrawer({ app: { ...APP, datadog: { enabled: true, instanceId: 'dd1' } } });
+ await openTab('Features');
+
+ expect(await screen.findByText(/Could not load DataDog instances/)).toBeInTheDocument();
+ expect(screen.queryByText(/No DataDog instances configured/)).not.toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole('button', { name: 'Retry' }));
+ expect(await screen.findByLabelText('DataDog Instance')).toHaveValue('dd1');
+ });
+});
diff --git a/client/src/listFetchConventions.test.js b/client/src/listFetchConventions.test.js
index e4d1c3fbff..c732edad0d 100644
--- a/client/src/listFetchConventions.test.js
+++ b/client/src/listFetchConventions.test.js
@@ -56,7 +56,6 @@ export const LIST_COLLAPSE = /\.catch\(\s*\(\s*\)\s*=>\s*(?:\[\]|\{?\s*set[A-Z]\
const KNOWN = Object.freeze({
'src/components/FeatureProviderPicker.jsx': 1,
'src/components/QuickTaskWidget.jsx': 2,
- 'src/components/apps/EditAppDrawer.jsx': 2,
'src/components/apps/JiraConfigPanel.jsx': 1,
'src/components/brain/IdeaLoomLists.jsx': 1,
'src/components/brain/YoutubeIngestSettings.jsx': 1,
diff --git a/client/src/services/apiSystem.js b/client/src/services/apiSystem.js
index 74078d0533..ed24a91ac7 100644
--- a/client/src/services/apiSystem.js
+++ b/client/src/services/apiSystem.js
@@ -516,7 +516,7 @@ export const updateTool = (id, data, options) => request(`/tools/${id}`, {
});
// DataDog
-export const getDatadogInstances = () => request('/datadog/instances');
+export const getDatadogInstances = (options) => request('/datadog/instances', options);
export const searchDatadogErrors = (instanceId, serviceName, environment, fromTime, options) =>
request(`/datadog/instances/${instanceId}/search-errors`, {
method: 'POST',