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: distinguish LI outcome tracking-off from an empty history (#2689)

[._.]/ Adam Eivy7295c3d39ba6
diff --git a/client/src/components/apps/LayeredIntelligenceOutcomes.jsx b/client/src/components/apps/LayeredIntelligenceOutcomes.jsx
index 802383746f..8550d9f709 100644
--- a/client/src/components/apps/LayeredIntelligenceOutcomes.jsx
+++ b/client/src/components/apps/LayeredIntelligenceOutcomes.jsx
@@ -82,15 +82,24 @@ export default function LayeredIntelligenceOutcomes({ appId }) {
);
}
- const { stats, rejections, recent } = state.data;
+ const { stats, rejections, recent, tracked = true } = state.data;
if (!stats || stats.total === 0) {
return (
<div className="space-y-2">
{heading}
- <p className="text-xs text-gray-500">
- No proposals filed yet. Once the loop files improvement issues, their outcomes (merge rate + why any were rejected) appear here.
- </p>
+ {tracked ? (
+ <p className="text-xs text-gray-500">
+ No proposals filed yet. Once the loop files improvement issues, their outcomes (merge rate + why any were rejected) appear here.
+ </p>
+ ) : (
+ // The store is only written while the outcomes source is on, so an empty
+ // history here doesn't mean the loop hasn't filed — it means nothing was
+ // recorded. Say that instead of implying nothing was filed.
+ <p className="text-xs text-gray-500">
+ Outcome tracking is off for this app, so filed proposals aren&apos;t being recorded. Enable the <span className="text-gray-400">Proposal outcomes</span> telemetry source below to start tracking how they fare.
+ </p>
+ )}
</div>
);
}
@@ -109,6 +118,14 @@ export default function LayeredIntelligenceOutcomes({ appId }) {
<div className="space-y-3 bg-port-bg border border-port-border rounded-lg px-3 py-3">
{heading}
+ {!tracked && (
+ // Records exist but the source is off now, so nothing new is recorded and
+ // still-open proposals won't be reconciled — flag the data as possibly stale.
+ <p className="text-xs text-port-warning">
+ Outcome tracking is currently off — these may be stale. Re-enable the Proposal outcomes source below to keep them current.
+ </p>
+ )}
+
<div className="flex items-baseline gap-2">
<span className="text-2xl font-semibold text-white">{mergeRateText}</span>
<span className="text-xs text-gray-500">
diff --git a/client/src/components/apps/LayeredIntelligenceOutcomes.test.jsx b/client/src/components/apps/LayeredIntelligenceOutcomes.test.jsx
index 4d2bd554b0..64be8685de 100644
--- a/client/src/components/apps/LayeredIntelligenceOutcomes.test.jsx
+++ b/client/src/components/apps/LayeredIntelligenceOutcomes.test.jsx
@@ -10,6 +10,7 @@ import { getAppLayeredIntelligenceOutcomes } from '../../services/api';
const ready = (overrides = {}) => ({
read: true,
+ tracked: true,
stats: { total: 4, merged: 1, rejected: 1, abandoned: 1, pending: 1, resolved: 3, mergeRate: 100 / 3 },
rejections: { entries: [{ reason: 'user-rejected', count: 1 }], unknown: 1, unclassified: 0, diagnosed: 1, total: 2 },
recent: [
@@ -66,6 +67,28 @@ describe('LayeredIntelligenceOutcomes', () => {
expect(await screen.findByText(/No proposals filed yet/)).toBeInTheDocument();
});
+ it('distinguishes tracking-off from an empty history when nothing is recorded', async () => {
+ getAppLayeredIntelligenceOutcomes.mockResolvedValue(ready({
+ tracked: false,
+ stats: { total: 0, merged: 0, rejected: 0, abandoned: 0, pending: 0, resolved: 0, mergeRate: null },
+ rejections: { entries: [], unknown: 0, unclassified: 0, diagnosed: 0, total: 0 },
+ recent: []
+ }));
+ render(<LayeredIntelligenceOutcomes appId="app-001" />);
+
+ expect(await screen.findByText(/Outcome tracking is off for this app/)).toBeInTheDocument();
+ expect(screen.queryByText(/No proposals filed yet/)).not.toBeInTheDocument();
+ });
+
+ it('flags existing records as possibly stale when tracking is currently off', async () => {
+ getAppLayeredIntelligenceOutcomes.mockResolvedValue(ready({ tracked: false }));
+ render(<LayeredIntelligenceOutcomes appId="app-001" />);
+
+ expect(await screen.findByText(/these may be stale/)).toBeInTheDocument();
+ // The data still renders alongside the stale note.
+ expect(screen.getByText('33%')).toBeInTheDocument();
+ });
+
it('surfaces an error (and retries) when the store is unreadable', async () => {
getAppLayeredIntelligenceOutcomes.mockResolvedValue({ read: false, stats: null, rejections: null, recent: [] });
render(<LayeredIntelligenceOutcomes appId="app-001" />);
diff --git a/server/routes/apps/taskTypes.js b/server/routes/apps/taskTypes.js
index dfbc2becb2..680b0b0f73 100644
--- a/server/routes/apps/taskTypes.js
+++ b/server/routes/apps/taskTypes.js
@@ -90,9 +90,18 @@ router.get('/:id/layered-intelligence', loadApp, asyncHandler(async (req, res) =
// collapse into an empty history).
router.get('/:id/layered-intelligence/outcomes', loadApp, asyncHandler(async (req, res) => {
const app = req.loadedApp;
+ // Outcomes are only RECORDED + reconciled while the app's `outcomes` telemetry
+ // source is enabled (off by default for managed apps — see the effective-config
+ // defaults in layeredIntelligence.js). Surface that so the UI can distinguish
+ // "tracking is off" from a genuinely empty history: without it, a managed app
+ // that has filed real proposals reads as "nothing filed yet", and records left
+ // from when it was on look permanently open. Same absent-vs-empty discipline the
+ // rest of this feature keeps.
+ const config = await appsService.getAppLayeredIntelligenceConfig(app.id);
+ const tracked = !!config?.sources?.outcomes;
const { read, outcomes } = await listOutcomesResult({ appId: app.id });
if (!read) {
- return res.json({ appId: app.id, appName: app.name, read: false, stats: null, rejections: null, recent: [] });
+ return res.json({ appId: app.id, appName: app.name, read: false, tracked, stats: null, rejections: null, recent: [] });
}
const { total, merged, rejected, abandoned, pending, resolved, rawMergeRate } = summarizeOutcomeStats(outcomes);
const rejections = summarizeRejectionReasons(outcomes);
@@ -110,6 +119,7 @@ router.get('/:id/layered-intelligence/outcomes', loadApp, asyncHandler(async (re
appId: app.id,
appName: app.name,
read: true,
+ tracked,
// `mergeRate` is the raw 0–100 percentage over RESOLVED proposals, or null when
// none have resolved (still-pending ≠ 0% merged). The client rounds for display.
stats: { total, merged, rejected, abandoned, pending, resolved, mergeRate: rawMergeRate },
diff --git a/server/routes/apps/taskTypes.test.js b/server/routes/apps/taskTypes.test.js
index 280aa3bc61..b3a8e68523 100644
--- a/server/routes/apps/taskTypes.test.js
+++ b/server/routes/apps/taskTypes.test.js
@@ -73,6 +73,7 @@ describe('Apps Task-Type Routes', () => {
describe('GET /api/apps/:id/layered-intelligence/outcomes', () => {
it('composes stats + rejection tally + recent list from the store', async () => {
appsService.getAppById.mockResolvedValue({ id: 'app-001', name: 'App' });
+ appsService.getAppLayeredIntelligenceConfig.mockResolvedValue({ sources: { outcomes: true } });
listOutcomesResult.mockResolvedValue({
read: true,
outcomes: [
@@ -95,9 +96,22 @@ describe('Apps Task-Type Routes', () => {
expect(response.body.rejections.unclassified).toBe(0);
expect(response.body.recent).toHaveLength(4);
expect(response.body.recent[0]).toMatchObject({ slug: 'add-metrics', outcome: 'merged' });
+ expect(response.body.tracked).toBe(true);
expect(listOutcomesResult).toHaveBeenCalledWith({ appId: 'app-001' });
});
+ it('reports tracked:false when the outcomes source is off (records may be stale)', async () => {
+ appsService.getAppById.mockResolvedValue({ id: 'app-001', name: 'App' });
+ appsService.getAppLayeredIntelligenceConfig.mockResolvedValue({ sources: { outcomes: false } });
+ listOutcomesResult.mockResolvedValue({ read: true, outcomes: [] });
+
+ const response = await request(app).get('/api/apps/app-001/layered-intelligence/outcomes');
+
+ expect(response.status).toBe(200);
+ expect(response.body.read).toBe(true);
+ expect(response.body.tracked).toBe(false);
+ });
+
it('reports read:false when the store is unreadable (not an empty history)', async () => {
appsService.getAppById.mockResolvedValue({ id: 'app-001', name: 'App' });
listOutcomesResult.mockResolvedValue({ read: false, outcomes: [] });