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

feat: add managed app feature controls

[._.]/ Adam Eivy851834ff22e7
diff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsx
index 98de01c788..a6243a8daa 100644
--- a/client/src/components/Layout.jsx
+++ b/client/src/components/Layout.jsx
@@ -283,6 +283,7 @@ export const NAV_PRESENTATION = {
'/settings/backup': { icon: Download },
'/settings/code-reviewers': { icon: ShieldCheck },
'/settings/database': { icon: Database },
+ '/settings/features': { icon: ListChecks },
'/settings/general': { icon: Settings },
'/settings/mortalloom': { icon: Activity },
'/openclaw': { icon: MessagesSquare },
diff --git a/client/src/components/Layout.test.jsx b/client/src/components/Layout.test.jsx
index ede8afd38c..3a2f4b6d3c 100644
--- a/client/src/components/Layout.test.jsx
+++ b/client/src/components/Layout.test.jsx
@@ -52,13 +52,14 @@ vi.mock('../services/socket', () => ({
// --- API: every sidebar fetch resolves empty so the dynamic sections stay bare
// and the single rows are the only top-level leaves under test. ---
-// Instance features gate sidebar rows (POST / DataDog / JIRA). Default every
+// Instance features gate sidebar rows (POST / DataDog / JIRA / GSD). Default every
// feature ON so these tests see the full sidebar; the gating itself is covered
// by 'Layout — instance feature gating' below.
const allFeaturesOn = () => [
{ id: 'post', label: 'POST', enabled: true },
{ id: 'datadog', label: 'DataDog', enabled: true },
{ id: 'jira', label: 'JIRA', enabled: true },
+ { id: 'gsd', label: 'GSD', enabled: true },
];
const featureMock = vi.hoisted(() => ({ features: null }));
@@ -197,6 +198,12 @@ describe('Layout — instance feature gating', () => {
expect(screen.getByRole('button', { name: 'POST' })).toBeTruthy();
});
+ it('shows Settings > Features in the primary navigation', async () => {
+ await renderLayout('/settings/features');
+
+ expect(screen.getByRole('link', { name: 'Features' })).toHaveAttribute('href', '/settings/features');
+ });
+
it('drops the whole POST section when POST is off', async () => {
featureMock.features = allFeaturesOn()
.map((f) => (f.id === 'post' ? { ...f, enabled: false } : f));
diff --git a/client/src/components/apps/AppDetailView.jsx b/client/src/components/apps/AppDetailView.jsx
index f482c4d26c..f2956cdcd9 100644
--- a/client/src/components/apps/AppDetailView.jsx
+++ b/client/src/components/apps/AppDetailView.jsx
@@ -9,7 +9,8 @@ import StatusBadge from '../StatusBadge';
import * as api from '../../services/api';
import { getLaunchUrls } from '../../services/appUrls';
import socket from '../../services/socket';
-import { APP_DETAIL_TABS, NON_PM2_TYPES, getAppTypeLabel, resolveLaunchPanelProcess } from './constants';
+import { APP_DETAIL_TABS, NON_PM2_TYPES, getAppTypeLabel, isAppFeatureEnabled, resolveLaunchPanelProcess } from './constants';
+import { useInstanceFeatures } from '../../hooks/useInstanceFeatures.js';
import DesktopLaunchProgress from './DesktopLaunchProgress';
import OverviewTab from './tabs/OverviewTab';
import TasksTab from './tabs/TasksTab';
@@ -46,6 +47,7 @@ export default function AppDetailView() {
// (Vite ≥5 blocks unknown hosts). `null` = not yet checked.
const [viteHostStatus, setViteHostStatus] = useState(null);
const [viteFixing, setViteFixing] = useState(null); // 'allow-all' | 'ai' while a fix is in flight
+ const { features: instanceFeatures, error: instanceFeaturesError } = useInstanceFeatures();
const fetchApp = useCallback(async () => {
const data = await api.getApp(appId).catch(() => null);
@@ -218,10 +220,18 @@ export default function AppDetailView() {
setViteHostStatus((prev) => prev ? { ...prev, hostAllowed: true } : prev);
};
- const visibleTabs = useMemo(() =>
- APP_DETAIL_TABS.filter(t => (t.visibleWhen ? t.visibleWhen(app) : true)),
- [app]
- );
+ const visibleTabs = useMemo(() => APP_DETAIL_TABS.filter((entry) => {
+ if (entry.visibleWhen && !entry.visibleWhen(app)) return false;
+ if (!entry.feature) return true;
+ // A feature read is ancillary to the app detail request. Keep tabs visible
+ // during loading or a failed read so a transient settings outage cannot
+ // strand the user; a loaded false is the only affirmative hide signal.
+ const globalFeature = instanceFeatures?.find(feature => feature?.id === entry.feature);
+ const globalEnabled = instanceFeaturesError || instanceFeatures === null
+ ? undefined
+ : globalFeature?.enabled;
+ return isAppFeatureEnabled(app, entry.feature, globalEnabled);
+ }), [app, instanceFeatures, instanceFeaturesError]);
if (loading) {
return (
diff --git a/client/src/components/apps/AppDetailView.test.jsx b/client/src/components/apps/AppDetailView.test.jsx
index 996e6cd244..db86ed9411 100644
--- a/client/src/components/apps/AppDetailView.test.jsx
+++ b/client/src/components/apps/AppDetailView.test.jsx
@@ -3,6 +3,14 @@ import { act, render, screen } from '@testing-library/react';
import { MemoryRouter, Route, Routes, useLocation } from 'react-router';
const socketHandlers = new Map();
+const instanceFeatureMock = vi.hoisted(() => ({
+ features: [
+ { id: 'datadog', enabled: true },
+ { id: 'jira', enabled: true },
+ { id: 'gsd', enabled: true },
+ ],
+ error: null,
+}));
vi.mock('../../services/api', () => ({
PORTOS_APP_ID: 'portos-default',
@@ -18,6 +26,10 @@ vi.mock('../../services/socket', () => ({
},
}));
+vi.mock('../../hooks/useInstanceFeatures.js', () => ({
+ useInstanceFeatures: () => instanceFeatureMock,
+}));
+
vi.mock('../../services/appUrls', () => ({
getLaunchUrls: vi.fn(() => ({ https: null, http: null, dev: null })),
}));
@@ -77,6 +89,12 @@ describe('AppDetailView app-removal socket handling', () => {
beforeEach(() => {
vi.clearAllMocks();
socketHandlers.clear();
+ instanceFeatureMock.features = [
+ { id: 'datadog', enabled: true },
+ { id: 'jira', enabled: true },
+ { id: 'gsd', enabled: true },
+ ];
+ instanceFeatureMock.error = null;
api.getApp.mockResolvedValue(APP);
});
@@ -95,3 +113,45 @@ describe('AppDetailView app-removal socket handling', () => {
expect(api.getApp).toHaveBeenCalledTimes(1);
});
});
+
+describe('AppDetailView managed-app feature tabs', () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ socketHandlers.clear();
+ api.getApp.mockResolvedValue(APP);
+ });
+
+ it('hides globally disabled feature tabs', async () => {
+ instanceFeatureMock.features = [
+ { id: 'datadog', enabled: false },
+ { id: 'jira', enabled: false },
+ { id: 'gsd', enabled: false },
+ ];
+
+ renderDetail();
+
+ await screen.findByRole('heading', { name: 'Example App' });
+ expect(screen.queryByRole('button', { name: 'DataDog' })).toBeNull();
+ expect(screen.queryByRole('button', { name: 'JIRA' })).toBeNull();
+ expect(screen.queryByRole('button', { name: 'GSD' })).toBeNull();
+ });
+
+ it('lets app overrides show or hide tabs independently of global settings', async () => {
+ instanceFeatureMock.features = [
+ { id: 'datadog', enabled: false },
+ { id: 'jira', enabled: false },
+ { id: 'gsd', enabled: true },
+ ];
+ api.getApp.mockResolvedValue({
+ ...APP,
+ featureOverrides: { datadog: true, jira: true, gsd: false },
+ });
+
+ renderDetail();
+
+ await screen.findByRole('heading', { name: 'Example App' });
+ expect(screen.getByRole('button', { name: 'DataDog' })).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'JIRA' })).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: 'GSD' })).toBeNull();
+ });
+});
diff --git a/client/src/components/apps/EditAppDrawer.jsx b/client/src/components/apps/EditAppDrawer.jsx
index efd56f9fb5..0543658395 100644
--- a/client/src/components/apps/EditAppDrawer.jsx
+++ b/client/src/components/apps/EditAppDrawer.jsx
@@ -12,24 +12,28 @@ import { copyToClipboard } from '../../lib/clipboard';
import LayeredIntelligenceTab, { buildLayeredIntelligenceUpdate, buildLayeredIntelligenceScheduleUpdate } from './LayeredIntelligenceTab';
import { PROVIDER_TYPES } from '../../utils/providers';
import { DEFAULT_PR_COMPLETION, PR_COMPLETION_OPTIONS, prCompletionOption } from '../cos/constants';
-import { WORK_TRACKER_OPTIONS, WORK_TRACKER_LABELS, appUsesJira } from './constants';
-
-// JIRA is deliberately absent: its config moved to the app detail page's JIRA
-// tab (/apps/:id/jira), where it sits next to the sprint board it drives and has
-// the width the instance/project/board pickers need. This drawer therefore never
-// sends a `jira` key — the PUT shallow-merges server-side, so the stored config
-// is preserved untouched.
-// The Workflow tab's work-tracker picker is the ONLY entry point into that tab
-// for an app that has never had JIRA turned on — the tab itself is hidden until
-// `appUsesJira(app)` holds (see constants.js), so choosing JIRA here is what
-// reveals it.
+import {
+ APP_FEATURES,
+ APP_FEATURE_IDS,
+ WORK_TRACKER_OPTIONS,
+ WORK_TRACKER_LABELS,
+ appUsesJira,
+ getAppFeatureOverride,
+ isAppFeatureEnabled,
+} from './constants';
+import { useInstanceFeatures } from '../../hooks/useInstanceFeatures.js';
+
+// JIRA configuration remains on the app detail page's JIRA tab (/apps/:id/jira),
+// where it sits next to the sprint board it drives. This drawer owns only the
+// per-app feature visibility overrides; it never sends a `jira` key, so saving
+// an unrelated field cannot clobber the detail tab's configuration.
const TABS = [
{ id: 'general', label: 'General' },
{ id: 'ports', label: 'Ports & TLS' },
{ id: 'commands', label: 'Commands' },
{ id: 'workflow', label: 'Workflow' },
{ id: 'intelligence', label: 'Intelligence' },
- { id: 'datadog', label: 'DataDog' }
+ { id: 'features', label: 'Features' }
];
const TAB_IDS = TABS.map(t => t.id);
@@ -65,11 +69,17 @@ export default function EditAppDrawer({ app, onClose, onSave }) {
defaultUseWorktree: app.defaultUseWorktree || app.defaultOpenPR || false,
// Unset means ON server-side, so an app that has never been saved shows checked.
verifyRepoStateOnCompletion: app.verifyRepoStateOnCompletion !== false,
+ featureOverrides: Object.fromEntries(
+ APP_FEATURE_IDS.map(featureId => [featureId, getAppFeatureOverride(app, featureId)])
+ ),
+ featureOverridesTouched: false,
datadogEnabled: app.datadog?.enabled || false,
datadogInstanceId: app.datadog?.instanceId || '',
datadogServiceName: app.datadog?.serviceName || '',
- datadogEnvironment: app.datadog?.environment || ''
+ datadogEnvironment: app.datadog?.environment || '',
+ datadogConfigTouched: false,
});
+ const { features: instanceFeatures, error: instanceFeaturesError } = useInstanceFeatures();
const [saving, setSaving] = useState(false);
const [error, setError] = useState(null);
// Layered Intelligence (self-improvement loop) config lives in its own slice —
@@ -257,13 +267,24 @@ export default function EditAppDrawer({ app, onClose, onSave }) {
defaultOpenPR: formData.defaultOpenPR,
defaultPrCompletion: formData.defaultPrCompletion,
verifyRepoStateOnCompletion: formData.verifyRepoStateOnCompletion,
- datadog: formData.datadogEnabled ? {
+ };
+
+ // Do not stamp an all-null map during an unrelated edit. Leaving the map
+ // absent preserves the legacy JIRA-work-tracker bootstrap and keeps future
+ // global changes flowing to apps whose feature controls were never touched.
+ if (formData.featureOverridesTouched) data.featureOverrides = formData.featureOverrides;
+
+ // Keep the integration slice out of unrelated saves. The new feature map
+ // handles tab visibility, while this legacy slice holds DataDog's runtime
+ // connection details; omitting it preserves an existing configuration.
+ if (formData.datadogConfigTouched) {
+ data.datadog = formData.datadogEnabled ? {
enabled: true,
instanceId: formData.datadogInstanceId || undefined,
serviceName: formData.datadogServiceName || undefined,
environment: formData.datadogEnvironment || undefined
- } : { enabled: false }
- };
+ } : { enabled: false };
+ }
// Only send layeredIntelligence when the user actually changed a BEHAVIOR
// field (sources/scopes/rules/handoff) — the server merges the PATCH over the
@@ -680,70 +701,136 @@ export default function EditAppDrawer({ app, onClose, onSave }) {
/>
)}
- {activeTab === 'datadog' && (
- <div className="space-y-3">
- <label className="flex items-center gap-2 cursor-pointer">
- <input
- type="checkbox"
- checked={formData.datadogEnabled}
- onChange={e => setFormData({ ...formData, datadogEnabled: e.target.checked })}
- className="rounded border-port-border bg-port-bg text-port-accent focus:ring-port-accent"
- />
- <span className="text-sm text-white">Enable DataDog Monitoring</span>
- </label>
+ {activeTab === 'features' && (
+ <div className="space-y-4">
+ <div>
+ <h2 className="text-lg font-semibold text-white">App features</h2>
+ <p className="text-sm text-gray-400 mt-1">
+ Each app inherits the install-wide setting from Settings &gt; Features unless you choose an override here.
+ </p>
+ </div>
- {formData.datadogEnabled && (
- <>
- {datadogInstances.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>
- ) : (
- <>
- <div>
- <label htmlFor="edit-app-datadog-instance" className="block text-sm text-gray-400 mb-1">DataDog Instance</label>
+ {APP_FEATURES.map(feature => {
+ const override = formData.featureOverrides?.[feature.id] ?? null;
+ const globalFeature = instanceFeatures?.find(item => item?.id === feature.id);
+ const globalStatus = instanceFeaturesError
+ ? 'unavailable'
+ : instanceFeatures === null
+ ? 'loading'
+ : globalFeature?.enabled === false ? 'off' : 'on';
+ const effectiveEnabled = isAppFeatureEnabled(
+ { ...app, featureOverrides: formData.featureOverrides },
+ feature.id,
+ globalFeature?.enabled,
+ );
+
+ return (
+ <div key={feature.id} className="bg-port-card border border-port-border rounded-lg p-3 space-y-3">
+ <div className="flex flex-col sm:flex-row sm:items-start gap-3">
+ <div className="min-w-0 flex-1">
+ <h3 className="text-sm font-semibold text-white">{feature.label}</h3>
+ <p className="text-sm text-gray-400 mt-1">{feature.description}</p>
+ <p className={`text-xs mt-2 ${effectiveEnabled ? 'text-port-success' : 'text-gray-500'}`}>
+ {override === null
+ ? `Inherited from global settings (currently ${globalStatus})`
+ : `${feature.label} is ${effectiveEnabled ? 'enabled' : 'disabled'} for this app`}
+ </p>
+ </div>
+ <div className="sm:w-52">
+ <label htmlFor={`edit-app-feature-${feature.id}`} className="block text-xs text-gray-400 mb-1">{feature.label} availability</label>
<select
- id="edit-app-datadog-instance"
- value={formData.datadogInstanceId}
- onChange={e => setFormData({ ...formData, datadogInstanceId: e.target.value })}
+ id={`edit-app-feature-${feature.id}`}
+ value={override === true ? 'enabled' : override === false ? 'disabled' : 'inherit'}
+ onChange={e => setFormData(prev => ({
+ ...prev,
+ featureOverridesTouched: true,
+ featureOverrides: {
+ ...prev.featureOverrides,
+ [feature.id]: e.target.value === 'inherit' ? null : e.target.value === 'enabled',
+ },
+ }))}
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 => (
- <option key={inst.id} value={inst.id}>{inst.name} ({inst.site})</option>
- ))}
+ <option value="inherit">Use global setting</option>
+ <option value="enabled">Enabled for this app</option>
+ <option value="disabled">Disabled for this app</option>
</select>
</div>
+ </div>
- <div>
- <label htmlFor="edit-app-datadog-service" className="block text-sm text-gray-400 mb-1">Service Name</label>
- <input
- id="edit-app-datadog-service"
- type="text"
- value={formData.datadogServiceName}
- onChange={e => setFormData({ ...formData, datadogServiceName: e.target.value })}
- 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"
- placeholder="e.g., my-app-service"
- />
- <p className="text-xs text-gray-500 mt-1">The &quot;service&quot; tag your app reports to DataDog RUM/APM (not the Application ID)</p>
- </div>
-
- <div>
- <label htmlFor="edit-app-datadog-env" className="block text-sm text-gray-400 mb-1">Environment</label>
- <input
- id="edit-app-datadog-env"
- type="text"
- value={formData.datadogEnvironment}
- onChange={e => setFormData({ ...formData, datadogEnvironment: e.target.value })}
- 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"
- placeholder="e.g., production"
- />
- <p className="text-xs text-gray-500 mt-1">The &quot;env&quot; tag (e.g., production, qa, staging)</p>
+ {feature.id === 'datadog' && (
+ <div className="border-t border-port-border/60 pt-3 space-y-3">
+ <div>
+ <h3 className="text-sm font-semibold text-white">DataDog monitoring</h3>
+ <p className="text-xs text-gray-500 mt-1">Configure the monitoring connection separately from the DataDog tab visibility above.</p>
+ </div>
+ <label className="flex items-center gap-2 cursor-pointer">
+ <input
+ type="checkbox"
+ checked={formData.datadogEnabled}
+ onChange={e => setFormData(prev => ({ ...prev, datadogEnabled: e.target.checked, datadogConfigTouched: true }))}
+ className="rounded border-port-border bg-port-bg text-port-accent focus:ring-port-accent"
+ />
+ <span className="text-sm text-white">Enable DataDog Monitoring</span>
+ </label>
+
+ {formData.datadogEnabled && (
+ <>
+ {datadogInstances.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>
+ ) : (
+ <>
+ <div>
+ <label htmlFor="edit-app-datadog-instance" className="block text-sm text-gray-400 mb-1">DataDog Instance</label>
+ <select
+ id="edit-app-datadog-instance"
+ value={formData.datadogInstanceId}
+ onChange={e => setFormData(prev => ({ ...prev, datadogInstanceId: e.target.value, datadogConfigTouched: true }))}
+ 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 => (
+ <option key={inst.id} value={inst.id}>{inst.name} ({inst.site})</option>
+ ))}
+ </select>
+ </div>
+
+ <div>
+ <label htmlFor="edit-app-datadog-service" className="block text-sm text-gray-400 mb-1">Service Name</label>
+ <input
+ id="edit-app-datadog-service"
+ type="text"
+ value={formData.datadogServiceName}
+ onChange={e => setFormData(prev => ({ ...prev, datadogServiceName: e.target.value, datadogConfigTouched: true }))}
+ 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"
+ placeholder="e.g., my-app-service"
+ />
+ <p className="text-xs text-gray-500 mt-1">The &quot;service&quot; tag your app reports to DataDog RUM/APM (not the Application ID)</p>
+ </div>
+
+ <div>
+ <label htmlFor="edit-app-datadog-env" className="block text-sm text-gray-400 mb-1">Environment</label>
+ <input
+ id="edit-app-datadog-env"
+ type="text"
+ value={formData.datadogEnvironment}
+ onChange={e => setFormData(prev => ({ ...prev, datadogEnvironment: e.target.value, datadogConfigTouched: true }))}
+ 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"
+ placeholder="e.g., production"
+ />
+ <p className="text-xs text-gray-500 mt-1">The &quot;env&quot; tag (e.g., production, qa, staging)</p>
+ </div>
+ </>
+ )}
+ </>
+ )}
</div>
- </>
- )}
- </>
- )}
+ )}
+ </div>
+ );
+ })}
</div>
)}
diff --git a/client/src/components/apps/EditAppDrawer.test.jsx b/client/src/components/apps/EditAppDrawer.test.jsx
index 284a497d7d..14c15afd51 100644
--- a/client/src/components/apps/EditAppDrawer.test.jsx
+++ b/client/src/components/apps/EditAppDrawer.test.jsx
@@ -6,6 +6,7 @@ import { MemoryRouter } from 'react-router';
// resolver and the update path used on save.
vi.mock('../../services/api', () => ({
getDatadogInstances: vi.fn(),
+ getInstanceFeatures: vi.fn(),
getAppWorkTracker: vi.fn(),
getAppLayeredIntelligence: vi.fn(),
getAppTaskTypes: vi.fn(),
@@ -16,6 +17,7 @@ vi.mock('../../services/api', () => ({
}));
import * as api from '../../services/api';
+import { __resetInstanceFeatureCache } from '../../hooks/useInstanceFeatures.js';
import EditAppDrawer from './EditAppDrawer';
const APP = {
@@ -42,7 +44,15 @@ async function openTab(name) {
}
beforeEach(() => {
+ __resetInstanceFeatureCache();
api.getDatadogInstances.mockResolvedValue({ instances: {} });
+ api.getInstanceFeatures.mockResolvedValue({
+ features: [
+ { id: 'datadog', label: 'DataDog', enabled: true },
+ { id: 'jira', label: 'JIRA', enabled: true },
+ { id: 'gsd', label: 'GSD', enabled: true },
+ ],
+ });
api.getAppWorkTracker.mockResolvedValue({
configured: 'auto',
resolved: 'github',
@@ -86,7 +96,7 @@ describe('EditAppDrawer tabbed layout', () => {
it('renders all six section tabs', async () => {
renderDrawer();
- for (const label of ['General', 'Ports & TLS', 'Commands', 'Workflow', 'Intelligence', 'DataDog']) {
+ for (const label of ['General', 'Ports & TLS', 'Commands', 'Workflow', 'Intelligence', 'Features']) {
expect(await screen.findByRole('tab', { name: label })).toBeInTheDocument();
}
});
@@ -96,6 +106,26 @@ describe('EditAppDrawer tabbed layout', () => {
await screen.findByRole('tab', { name: 'General' });
expect(screen.queryByRole('tab', { name: 'JIRA' })).not.toBeInTheDocument();
});
+
+ it('lets each managed-app feature inherit or override the global setting', async () => {
+ renderDrawer();
+ await openTab('Features');
+
+ expect(screen.getByLabelText('DataDog availability')).toHaveValue('inherit');
+ expect(screen.getByLabelText('JIRA availability')).toHaveValue('inherit');
+ expect(screen.getByLabelText('GSD availability')).toHaveValue('inherit');
+
+ fireEvent.change(screen.getByLabelText('JIRA availability'), { target: { value: 'enabled' } });
+ fireEvent.change(screen.getByLabelText('GSD availability'), { target: { value: 'disabled' } });
+ fireEvent.click(screen.getByRole('button', { name: 'Save Changes' }));
+
+ await waitFor(() => expect(api.updateApp).toHaveBeenCalled());
+ expect(api.updateApp.mock.calls[0][1].featureOverrides).toEqual({
+ datadog: null,
+ jira: true,
+ gsd: false,
+ });
+ });
});
describe('EditAppDrawer work tracker selector', () => {
@@ -151,6 +181,7 @@ describe('EditAppDrawer work tracker selector', () => {
await waitFor(() => expect(api.updateApp).toHaveBeenCalled());
expect(api.updateApp.mock.calls[0][1]).not.toHaveProperty('jira');
+ expect(api.updateApp.mock.calls[0][1]).not.toHaveProperty('datadog');
});
it('saves the selected default PR completion policy', async () => {
diff --git a/client/src/components/apps/constants.js b/client/src/components/apps/constants.js
index 39eee572d6..eb76526e39 100644
--- a/client/src/components/apps/constants.js
+++ b/client/src/components/apps/constants.js
@@ -2,6 +2,7 @@
// test (streamingDetect's DESKTOP_TYPES parity check), where apiCore's React
// dependency doesn't resolve.
import { PORTOS_APP_ID } from '../../lib/appIdentity.js';
+import { APP_FEATURE_IDS, INSTANCE_FEATURES } from '../../../../server/lib/instanceFeatureRegistry.js';
export const NON_PM2_TYPES = new Set(['ios-native', 'macos-native', 'xcode', 'swift']);
@@ -107,32 +108,80 @@ export const workItemNoun = (tracker) =>
* - `jira.enabled` — the integration is switched on (the JIRA tab's own config panel)
* - `workTracker === 'jira'` — the app's work items live in JIRA (Edit App → Workflow)
*
- * The second clause is the bootstrap path: JIRA's config panel lives ON the JIRA
- * tab, so gating the tab on `jira.enabled` alone would make a never-configured app
- * unable to ever reach it. Picking JIRA as the work tracker in the Edit App drawer
- * reveals the tab, and the panel there does the rest. `'auto'` never resolves to
- * JIRA (it classifies the git origin host → github/gitlab/plan), so an app only
- * lands here by an explicit choice.
+ * The second clause remains the bootstrap path for existing app records: JIRA's
+ * config panel lives on the JIRA detail tab, so selecting JIRA as the work
+ * tracker is still an app-local signal even before integration config exists.
+ * `'auto'` never resolves to JIRA (it classifies the git origin host →
+ * github/gitlab/plan), so an app only lands here by an explicit choice.
*/
export const appUsesJira = (app) => !!app?.jira?.enabled || app?.workTracker === 'jira';
+export const APP_FEATURES = Object.freeze(
+ APP_FEATURE_IDS.map(id => INSTANCE_FEATURES.find(feature => feature.id === id)).filter(Boolean)
+);
+
+export { APP_FEATURE_IDS };
+
+const hasOwn = (value, key) => Object.hasOwn(value, key);
+
+// Read a new explicit override without collapsing an intentional null (inherit)
+// into an absent key. Invalid values from hand-edited legacy records inherit so
+// one malformed app flag cannot hide a tab forever.
+const readFeatureOverride = (app, featureId) => {
+ const overrides = app?.featureOverrides;
+ if (!overrides || typeof overrides !== 'object' || Array.isArray(overrides) || !hasOwn(overrides, featureId)) {
+ return undefined;
+ }
+ const value = overrides[featureId];
+ return typeof value === 'boolean' || value === null ? value : null;
+};
+
+// Older app records used integration config as the only app-local signal. Keep
+// those records meaningful while allowing a new null override to deliberately
+// switch them back to the install-wide setting.
+const readLegacyFeatureOverride = (app, featureId) => {
+ if (featureId === 'datadog' && typeof app?.datadog?.enabled === 'boolean') {
+ return app.datadog.enabled;
+ }
+ if (featureId === 'jira') {
+ if (app?.workTracker === 'jira') return true;
+ if (typeof app?.jira?.enabled === 'boolean') return app.jira.enabled;
+ }
+ return undefined;
+};
+
+/** The app-local choice, or null when this app inherits the global setting. */
+export const getAppFeatureOverride = (app, featureId) => {
+ const override = readFeatureOverride(app, featureId);
+ if (override !== undefined) return override;
+ return readLegacyFeatureOverride(app, featureId) ?? null;
+};
+
+/** Resolve an app tab against its app override and the install-wide value. */
+export const isAppFeatureEnabled = (app, featureId, globalEnabled) => {
+ const override = readFeatureOverride(app, featureId);
+ if (override === true || override === false) return override;
+ if (override === null) return globalEnabled !== false;
+ const legacy = readLegacyFeatureOverride(app, featureId);
+ return legacy ?? (globalEnabled !== false);
+};
+
// Overview first, then alphabetical. Every id is a real route segment
// (`/apps/:appId/:tab`) so each tab is linkable, bookmarkable, and reachable
// from ⌘K — see the routing rules in client/src/AGENTS.md.
//
-// `visibleWhen(app)` gates a tab that only some apps earn; omit it for the tabs
-// every app gets. Keeping the predicate on the entry means adding a conditional
-// tab is one edit here rather than a second id-string case in the detail view.
+// `feature` gates a tab against the install-wide feature setting, with an
+// app-level `featureOverrides` choice taking precedence. `visibleWhen(app)` is
+// reserved for structural conditions that are not feature participation.
export const APP_DETAIL_TABS = [
{ id: 'overview', label: 'Overview' },
{ id: 'automation', label: 'Automation' },
- { id: 'datadog', label: 'DataDog', visibleWhen: (app) => !!app?.datadog?.enabled },
+ { id: 'datadog', label: 'DataDog', feature: 'datadog' },
{ id: 'documents', label: 'Documents' },
{ id: 'git', label: 'Git' },
- { id: 'gsd', label: 'GSD' },
+ { id: 'gsd', label: 'GSD', feature: 'gsd' },
{ id: 'issues', label: 'Issues' },
- // JIRA config is only meaningful for an app wired to JIRA — see appUsesJira.
- { id: 'jira', label: 'JIRA', visibleWhen: appUsesJira },
+ { id: 'jira', label: 'JIRA', feature: 'jira' },
{ id: 'processes', label: 'Processes' },
{ id: 'references', label: 'References' },
// Only repos that declare submodules (a .gitmodules file) get the tab — most
diff --git a/client/src/components/apps/constants.test.js b/client/src/components/apps/constants.test.js
index 51521d1247..29b6ffc53a 100644
--- a/client/src/components/apps/constants.test.js
+++ b/client/src/components/apps/constants.test.js
@@ -1,8 +1,7 @@
import { describe, it, expect } from 'vitest';
-import { APP_DETAIL_TABS, appUsesJira } from './constants';
+import { APP_DETAIL_TABS, appUsesJira, getAppFeatureOverride, isAppFeatureEnabled } from './constants';
-const visibleIds = (app) =>
- APP_DETAIL_TABS.filter(t => (t.visibleWhen ? t.visibleWhen(app) : true)).map(t => t.id);
+const featureEntry = (id) => APP_DETAIL_TABS.find(tab => tab.id === id);
describe('appUsesJira', () => {
it('is false for an app with no JIRA config at all', () => {
@@ -26,21 +25,37 @@ describe('appUsesJira', () => {
});
});
-describe('APP_DETAIL_TABS jira visibility', () => {
- it('hides the JIRA tab for an app that is not wired to JIRA', () => {
- expect(visibleIds({ id: 'a', workTracker: 'github' })).not.toContain('jira');
+describe('managed-app feature overrides', () => {
+ it('marks DataDog, JIRA, and GSD as feature-gated detail tabs', () => {
+ expect(featureEntry('datadog').feature).toBe('datadog');
+ expect(featureEntry('jira').feature).toBe('jira');
+ expect(featureEntry('gsd').feature).toBe('gsd');
});
- it('shows the JIRA tab when the integration is enabled', () => {
- expect(visibleIds({ id: 'a', jira: { enabled: true } })).toContain('jira');
+ it('inherits the global setting when no app override exists', () => {
+ expect(getAppFeatureOverride({ id: 'a' }, 'datadog')).toBeNull();
+ expect(isAppFeatureEnabled({ id: 'a' }, 'datadog', true)).toBe(true);
+ expect(isAppFeatureEnabled({ id: 'a' }, 'datadog', false)).toBe(false);
});
- it('shows the JIRA tab when JIRA is the work tracker', () => {
- expect(visibleIds({ id: 'a', workTracker: 'jira' })).toContain('jira');
+ it('lets true and false app overrides outrank the global setting', () => {
+ const app = { id: 'a', featureOverrides: { datadog: true, jira: false } };
+ expect(isAppFeatureEnabled(app, 'datadog', false)).toBe(true);
+ expect(isAppFeatureEnabled(app, 'jira', true)).toBe(false);
+ expect(getAppFeatureOverride(app, 'datadog')).toBe(true);
+ expect(getAppFeatureOverride(app, 'jira')).toBe(false);
});
- it('leaves the unconditional tabs alone', () => {
- const ids = visibleIds({ id: 'a' });
- expect(ids).toEqual(expect.arrayContaining(['overview', 'automation', 'documents', 'git', 'gsd', 'issues', 'processes', 'references', 'tasks']));
+ it('uses a null app override to return to the global setting', () => {
+ const app = { id: 'a', datadog: { enabled: true }, featureOverrides: { datadog: null } };
+ expect(getAppFeatureOverride(app, 'datadog')).toBeNull();
+ expect(isAppFeatureEnabled(app, 'datadog', false)).toBe(false);
+ });
+
+ it('keeps legacy integration and JIRA-tracker signals working', () => {
+ expect(isAppFeatureEnabled({ datadog: { enabled: true } }, 'datadog', false)).toBe(true);
+ expect(isAppFeatureEnabled({ jira: { enabled: true } }, 'jira', false)).toBe(true);
+ expect(isAppFeatureEnabled({ workTracker: 'jira' }, 'jira', false)).toBe(true);
+ expect(isAppFeatureEnabled({ jira: { enabled: false }, workTracker: 'github' }, 'jira', true)).toBe(false);
});
});
diff --git a/client/src/hooks/README.md b/client/src/hooks/README.md
index 38bc251c3f..032d425291 100644
--- a/client/src/hooks/README.md
+++ b/client/src/hooks/README.md
@@ -144,7 +144,7 @@ grep -i "what you want to do" client/src/hooks/README.md
| Hook | Purpose | Use when |
|---|---|---|
| `useFocusRefreshedList` | Load-once-then-refresh-on-focus list fetcher: debounces focus refreshes to 30s, sorts by name, and skips re-render when an `id\|name` signature is unchanged. Owns its own warn-on-error. | Any sidebar/nav list that should refresh when the user returns to the tab without hammering the API. Pass a stable `api.*` fetch fn. |
-| `useInstanceFeatures` | Shared read of Settings > Features with a module-level cache, so the sidebar, ⌘K, and the Features tab collapse to one fetch. Returns `isFeatureEnabled(id)`; `publishInstanceFeatures` announces a toggle on the existing `INSTANCE_FEATURES_CHANGED` window event (the channel the reminder toast and the dashboard widgets already use). Fails open on a fetch error so navigation is never blanked. | Gating a sidebar row, page, palette entry, or widget on an optional instance feature (`post`, `datadog`, `jira`). Pair with `lib/navFeatures.js` for manifest entries. |
+| `useInstanceFeatures` | Shared read of Settings > Features with a module-level cache, so the sidebar, ⌘K, and the Features tab collapse to one fetch. Returns `isFeatureEnabled(id)`; `publishInstanceFeatures` announces a toggle on the existing `INSTANCE_FEATURES_CHANGED` window event (the channel the reminder toast and the dashboard widgets already use). Fails open on a fetch error so navigation is never blanked. | Gating a sidebar row, page, palette entry, or widget on an optional instance feature (`post`, `datadog`, `jira`, `gsd`). Pair with `lib/navFeatures.js` for manifest entries. |
| `useSidebarApps` | Apps list for sidebar nav: socket-driven (`apps:changed`), archived filtered out, name-sorted. | The sidebar apps section. |
| `useSidebarSeries` | Pipeline series for the Create > Pipeline grandchildren (built on `useFocusRefreshedList`). | The sidebar pipeline-series section. |
| `useSidebarUniverses` | Universes for the Create > Universes grandchildren (built on `useFocusRefreshedList`). | The sidebar universes section. |
diff --git a/client/src/lib/README.md b/client/src/lib/README.md
index bf0625f32e..b79fa0e29d 100644
--- a/client/src/lib/README.md
+++ b/client/src/lib/README.md
@@ -17,7 +17,7 @@ is the contract.
grep -i "what you want to do" client/src/lib/README.md
```
-| `navFeatures.js` | `filterNavByFeatures(navEntries, isFeatureEnabled)` — drops nav-manifest entries whose optional instance feature (`post`, `datadog`, `jira`) is off. The single gate for BROWSE surfaces (sidebar, ⌘K); routes stay reachable by URL, bookmark, and voice. Pair with `useInstanceFeatures`. |
+| `navFeatures.js` | `filterNavByFeatures(navEntries, isFeatureEnabled)` — drops nav-manifest entries whose optional instance feature (`post`, `datadog`, `jira`, `gsd`) is off. The single gate for BROWSE surfaces (sidebar, ⌘K); routes stay reachable by URL, bookmark, and voice. Pair with `useInstanceFeatures`. |
| `postQuickSession.js` | Pure Quick POST duration presets, local-observation estimator, deterministic budget composer, and preview metadata. |
---
diff --git a/server/lib/README.md b/server/lib/README.md
index cfd72b6c0a..b81eefdebc 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -147,7 +147,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `modelPricing.js` | Per-model API billing rates for the /devtools/usage cost estimates — `resolveModelRates(providerId, model)` (exact → family regex → provider default → blended fallback, with a `matched` tier; also derives `cacheReadPer1M`/`cacheWritePer1M` from the input rate via per-family multipliers), `isFreeProvider` (ollama/lmstudio/`ollamaBacked`/localhost = free), `estimateCostUsd(tokensIn, tokensOut, rates, cache?)` — `tokensIn` is UNCACHED input; cache tiers are priced separately via the optional 4th arg — and `PRICING_AS_OF`. Informational only (PortOS runs on subscriptions); still excludes batch/long-context tiers. |
| `usageRange.js` | `resolveUsageRange({ period, from, to })` — pure period→inclusive-YYYY-MM-DD range resolution for the usage cost report (explicit dates win; `all` unbounded; default 7d). |
| `subscriptionSavings.js` | Subscription-vs-API savings math for the usage page — `resolveSavingsWindow` (clamps an open-ended report range to today / first activity day), `prorateMonthlyCost` (monthly plan price → this window's share, `DAYS_PER_MONTH`, capped by `MAX_MONTHLY_COST`), `savingsPercent` / `costMultiplier` (null, never 0, when the comparison is undefined), `attributeReportCostToFamilies` (groups report rows by their stamped `family`), `roundCents` (the one money rounder), and `buildSubscriptionSavings({ entries, range, unmatchedApiCost })` → per-family rows + totals. Pure. |
-| `instanceFeatureRegistry.js` | The registry of optional per-install features (`INSTANCE_FEATURES`, `INSTANCE_FEATURE_IDS`, `isInstanceFeatureId`) — pure data, so `validation.js` derives its feature schemas from it and `navManifest.js` can be checked against it without a service→lib inversion. Runtime resolution (stored override → auto-detection → `defaultEnabled`) lives in `services/instanceFeatures.js`. A feature id tagged on a nav entry hides that page from ⌘K and the sidebar when the feature is off. |
+| `instanceFeatureRegistry.js` | The registry of optional per-install features (`INSTANCE_FEATURES`, `INSTANCE_FEATURE_IDS`, `APP_FEATURE_IDS`) — pure data, so `validation.js` derives its feature schemas from it and `navManifest.js` can be checked against it without a service→lib inversion. Runtime resolution (stored override → auto-detection → `defaultEnabled`) lives in `services/instanceFeatures.js`. A feature id tagged on a nav entry hides that page from ⌘K and the sidebar when the feature is off. |
| `providerFamilies.js` | Subscription-quota FAMILY identity — `PROVIDER_FAMILIES` (`{ id, label, matches }` for claude/codex/agy/grok), `PROVIDER_FAMILY_IDS`, `familyLabel`, `familyForProvider(config)` → family id or null (local-runtime wrappers and API-only providers belong to none). The pure half of the registry `services/providerUsage.js` attaches quota `fetch`ers to, so cost attribution and route validation can ask "which plan is this provider on?" without importing the PTY-scrape graph. Distinct from `providerVendors.js`, which is argv-shaped and includes vendors with no subscription quota. |
| `providerGateways.js` | `PROVIDER_GATEWAYS` — one row per hosted OpenAI-compatible gateway an OpenCode CLI/TUI wrapper can front-end (`orcarouter`, `openrouter`), plus `PROVIDER_GATEWAY_IDS`, `gatewayById`, `isGatewayNamespace(ns)` and `gatewayForProvider(config)` → row or null. Each row's `id` is simultaneously the OpenCode provider namespace, the `gatewayBacked` marker value, and the id of the sibling `api` record that owns the key — so the sibling lookup is `providers[gateway.id]` and an OrcaRouter key can never satisfy an OpenRouter wrapper. Replaces the `orcarouterBacked` boolean + literal `'orcarouter'` that had been hand-copied across ~15 server and client files (namespace resolution, the OpenCode config builder, both zod schemas, the model-fetcher table, the sibling-key attach, the prerequisite check, and the two "not a local runtime" carve-outs in `cliChildEnv.js`/`localProviderRuntime.js`). Reads the legacy per-gateway boolean FOREVER, so stored records are never rewritten. Distinct from a local runtime (`ollamaBacked`, `vllmBacked`, …): remote, always authenticating, and no thinking toggle. Deliberately mirrored in `aiToolkit/internal/gateways.js` (the vendored toolkit may not import out) and `client/src/utils/providers.js` (the browser cannot import server code) — `providerGateways.parity.test.js` fails when the first two drift. Dependency-light: imports nothing. |
| `providerTranscriptUsage.js` | Parsers for the real per-message token counts the coding CLIs write to disk (0 tokens to read) — `parseClaudeTranscript` (`~/.claude/projects/<cwd-slug>/*.jsonl`), `parseCodexRollout` (`~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl`), `claudeProjectSlug`, `totalTranscriptTokens`. Both de-duplicate a format hazard that otherwise inflates counts badly: Claude repeats one response across several lines sharing a `message.id`, and Codex's `total_token_usage` is cumulative and repeated. Each parser returns per-model buckets (`byModel`) plus the message keys it counted (`countedKeys`), and accepts an `exclude` set — that is what stops two overlapping PortOS runs from both billing the same messages. Tolerant of truncated (mid-write) files; consumed by `services/usageReconciler.js`. |
diff --git a/server/lib/instanceFeatureRegistry.js b/server/lib/instanceFeatureRegistry.js
index 7ac15bd967..5c82ddc0fe 100644
--- a/server/lib/instanceFeatureRegistry.js
+++ b/server/lib/instanceFeatureRegistry.js
@@ -14,7 +14,9 @@
// in client/src/components/Layout.jsx;
// 3. add a `detect` hook in services/instanceFeatures.js when a fresh install
// should infer the default from whether the integration is configured.
-// The validation schemas and the Features tab pick it up with no further edit.
+// The validation schemas and the install-wide Features tab pick it up with no
+// further edit; managed-app tabs opt into the separate APP_FEATURE_IDS list
+// below when they need an app-level inherit/override control.
export const INSTANCE_FEATURES = Object.freeze([
Object.freeze({
id: 'post',
@@ -34,10 +36,21 @@ export const INSTANCE_FEATURES = Object.freeze([
description: 'Sprint boards, ticket triage, and JIRA reports for apps wired to a JIRA instance.',
defaultEnabled: false,
}),
+ Object.freeze({
+ id: 'gsd',
+ label: 'GSD',
+ description: 'Get Stuff Done project planning and progress tracking for managed apps.',
+ defaultEnabled: true,
+ }),
]);
export const INSTANCE_FEATURE_IDS = Object.freeze(INSTANCE_FEATURES.map((feature) => feature.id));
+// These are the feature tabs shown on a managed app. POST is install-wide only;
+// it has no app-level tab or override. Keep this list next to the registry so
+// the app schema and client resolver cannot drift from the feature catalog.
+export const APP_FEATURE_IDS = Object.freeze(['datadog', 'jira', 'gsd']);
+
/**
* How many instances an integration's config file declares — the signal every
* `detect` hook is built on.
diff --git a/server/lib/instanceFeatureRegistry.test.js b/server/lib/instanceFeatureRegistry.test.js
index 8d95b9eff7..488c546a3e 100644
--- a/server/lib/instanceFeatureRegistry.test.js
+++ b/server/lib/instanceFeatureRegistry.test.js
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
-import { INSTANCE_FEATURES, INSTANCE_FEATURE_IDS, countConfiguredInstances } from './instanceFeatureRegistry.js';
+import { APP_FEATURE_IDS, INSTANCE_FEATURES, INSTANCE_FEATURE_IDS, countConfiguredInstances } from './instanceFeatureRegistry.js';
describe('instance feature registry', () => {
it('declares an id, label, description and default for every feature', () => {
@@ -12,6 +12,12 @@ describe('instance feature registry', () => {
expect(INSTANCE_FEATURE_IDS).toEqual(INSTANCE_FEATURES.map((f) => f.id));
expect(new Set(INSTANCE_FEATURE_IDS).size).toBe(INSTANCE_FEATURE_IDS.length);
});
+
+ it('keeps managed-app feature overrides inside the registered catalog', () => {
+ expect(APP_FEATURE_IDS).toEqual(['datadog', 'jira', 'gsd']);
+ expect(APP_FEATURE_IDS.every((id) => INSTANCE_FEATURE_IDS.includes(id))).toBe(true);
+ expect(new Set(APP_FEATURE_IDS).size).toBe(APP_FEATURE_IDS.length);
+ });
});
describe('countConfiguredInstances', () => {
diff --git a/server/lib/navManifest.js b/server/lib/navManifest.js
index 6cdf463d21..94f82d3992 100644
--- a/server/lib/navManifest.js
+++ b/server/lib/navManifest.js
@@ -152,7 +152,7 @@ const RAW_NAV_COMMANDS = [
{ id: 'nav.cos.config', path: '/cos/config', label: 'Config', section: 'Chief of Staff', aliases: ['cos-config'] },
{ id: 'nav.cos.digest', path: '/cos/digest', label: 'Digest', section: 'Chief of Staff', aliases: ['cos-digest'] },
{ id: 'nav.feature-agents', path: '/feature-agents', label: 'Feature Agents', section: 'Chief of Staff', aliases: ['feature-agents'] },
- { id: 'nav.cos.gsd', path: '/cos/gsd', label: 'GSD', section: 'Chief of Staff', aliases: ['gsd', 'cos-gsd'] },
+ { id: 'nav.cos.gsd', path: '/cos/gsd', label: 'GSD', section: 'Chief of Staff', feature: 'gsd', aliases: ['gsd', 'cos-gsd'] },
{ id: 'nav.cos.health', path: '/cos/health', label: 'Health', section: 'Chief of Staff', aliases: ['cos-health', 'health'] },
{ id: 'nav.cos.learning', path: '/cos/learning', label: 'Learning', section: 'Chief of Staff', aliases: ['cos-learning'] },
{ id: 'nav.cos.memory', path: '/cos/memory', label: 'Memory', section: 'Chief of Staff', aliases: ['cos-memory'] },
diff --git a/server/lib/navManifest.test.js b/server/lib/navManifest.test.js
index 0d3a257a31..6a07842efd 100644
--- a/server/lib/navManifest.test.js
+++ b/server/lib/navManifest.test.js
@@ -165,11 +165,12 @@ describe('nav contract — instance-feature gating', () => {
}
});
- it('gates the DataDog and JIRA Dev Tools pages', () => {
+ it('gates the DataDog, JIRA, and GSD feature pages', () => {
const byId = Object.fromEntries(NAV_COMMANDS.map((c) => [c.id, c.feature]));
expect(byId['nav.devtools.datadog']).toBe('datadog');
expect(byId['nav.devtools.jira']).toBe('jira');
expect(byId['nav.devtools.jira-reports']).toBe('jira');
+ expect(byId['nav.cos.gsd']).toBe('gsd');
});
it('leaves ungated pages untagged', () => {
diff --git a/server/lib/validation.js b/server/lib/validation.js
index 18c9e23110..e0aa0ab82b 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -3,7 +3,7 @@ import { ServerError } from './errorHandler.js';
import { partialWithoutDefaults, emptyToUndefined, emptyToNull, optionalBooleanMap } from './zodCompat.js';
import { WORK_TRACKERS } from './workTracker.js';
import { PROVIDER_FAMILY_IDS } from './providerFamilies.js';
-import { INSTANCE_FEATURE_IDS } from './instanceFeatureRegistry.js';
+import { APP_FEATURE_IDS, INSTANCE_FEATURE_IDS } from './instanceFeatureRegistry.js';
import { MAX_MONTHLY_COST } from './subscriptionSavings.js';
import { QUEUEABLE_IMAGE_MODES, VIDEO_GEN_MODES } from './generationModes.js';
import { RENDER_TARGETS, RENDER_TARGET_BACKEND_AUTO } from './renderTargets.js';
@@ -92,6 +92,13 @@ export const datadogConfigSchema = z.object({
environment: z.string().optional()
});
+// Per-managed-app feature participation. An absent key or null means inherit
+// the install-wide Settings > Features value; true/false is an app override.
+// The app-level list intentionally excludes POST, which has no managed-app tab.
+export const appFeatureOverridesSchema = z.object(
+ Object.fromEntries(APP_FEATURE_IDS.map((id) => [id, z.boolean().nullable().optional()]))
+).strict();
+
// POST /api/datadog/instances. API keys may be empty when updating an
// existing instance because the route preserves the stored secret in that
// case.
@@ -292,6 +299,7 @@ export const appSchema = z.object({
// task when it diverges. See lib/repoStateExpectations.js. Unset = ON: an install
// that never hears about a leaked branch just accumulates them.
verifyRepoStateOnCompletion: z.boolean().optional(),
+ featureOverrides: appFeatureOverridesSchema.optional(),
jira: jiraConfigSchema.optional().nullable(),
datadog: datadogConfigSchema.optional().nullable(),
// Where this app's autonomous work items live (single source per app).
diff --git a/server/lib/validation.test.js b/server/lib/validation.test.js
index d1ffa9bf35..6608f74124 100644
--- a/server/lib/validation.test.js
+++ b/server/lib/validation.test.js
@@ -499,6 +499,17 @@ describe('validation.js', () => {
expect(result.success).toBe(true);
});
+ it('accepts nullable managed-app feature overrides and rejects unknown features', () => {
+ const app = {
+ name: 'Feature App',
+ repoPath: '/path',
+ featureOverrides: { datadog: true, jira: null, gsd: false },
+ };
+ expect(appSchema.safeParse(app).success).toBe(true);
+ expect(appSchema.safeParse(app).data.featureOverrides).toEqual(app.featureOverrides);
+ expect(appSchema.safeParse({ ...app, featureOverrides: { post: true } }).success).toBe(false);
+ });
+
it('accepts a safe native launch target and rejects an unsafe process name', () => {
const app = {
name: 'Mixed App',
@@ -628,6 +639,11 @@ describe('validation.js', () => {
const result = appUpdateSchema.safeParse(update);
expect(result.success).toBe(true);
});
+
+ it('accepts partial managed-app feature overrides', () => {
+ expect(appUpdateSchema.safeParse({ featureOverrides: { jira: false } }).success).toBe(true);
+ expect(appUpdateSchema.safeParse({ featureOverrides: { gsd: null } }).success).toBe(true);
+ });
});
describe('providerSchema', () => {
diff --git a/server/routes/settings.test.js b/server/routes/settings.test.js
index 01122dba45..aba7345f94 100644
--- a/server/routes/settings.test.js
+++ b/server/routes/settings.test.js
@@ -107,6 +107,9 @@ describe('Settings routes — instance feature participation', () => {
// they resolve off, which is what hides their nav entries.
expect(res.body.features).toContainEqual(expect.objectContaining({ id: 'datadog', enabled: false }));
expect(res.body.features).toContainEqual(expect.objectContaining({ id: 'jira', enabled: false }));
+ // GSD remains enabled by default so existing app planning tabs stay
+ // available unless the install explicitly opts out.
+ expect(res.body.features).toContainEqual(expect.objectContaining({ id: 'gsd', enabled: true }));
});
it('updates one feature without replacing unrelated settings', async () => {
diff --git a/server/services/apps.js b/server/services/apps.js
index aca5c12d7d..9e3e8d743a 100644
--- a/server/services/apps.js
+++ b/server/services/apps.js
@@ -7,6 +7,7 @@ import { NON_PM2_TYPES, usesPm2, isDesktopType } from './streamingDetect.js';
import { listProcessesStrict } from './pm2.js';
import { SELF_IMPROVEMENT_TASK_TYPES } from './taskScheduleRegistry.js';
import { sanitizeTaskMetadata } from '../lib/validation.js';
+import { isPlainObject } from '../lib/objects.js';
import { resolveAppWorkTracker } from '../lib/workTracker.js';
import { PORTS } from '../lib/ports.js';
import { hasTailscaleCert } from '../../lib/tailscale-https.js';
@@ -439,6 +440,13 @@ export async function createApp(appData) {
app.layeredIntelligence = appData.layeredIntelligence;
}
+ // An absent map means every managed-app feature inherits the install-wide
+ // setting. Preserve an explicitly supplied (possibly empty) map so create
+ // and update have the same override contract.
+ if (isPlainObject(appData.featureOverrides)) {
+ app.featureOverrides = appData.featureOverrides;
+ }
+
data.apps[id] = app;
await saveApps(data);
diff --git a/server/services/apps.test.js b/server/services/apps.test.js
index 477e902bfa..fdb027f91b 100644
--- a/server/services/apps.test.js
+++ b/server/services/apps.test.js
@@ -251,6 +251,20 @@ describe('portless / desktop apps (#2991)', () => {
expect(atomicWrite.mock.calls.at(-1)[1].apps[unset.id]).not.toHaveProperty('verifyRepoStateOnCompletion');
});
+ it('createApp preserves managed-app feature overrides', async () => {
+ readJSONFile.mockResolvedValue({ apps: { [PORTOS_APP_ID]: { name: 'PortOS' } } });
+ const featureOverrides = { datadog: true, jira: null, gsd: false };
+
+ const created = await createApp({
+ name: 'Feature App',
+ repoPath: '/tmp/feature-app',
+ featureOverrides,
+ });
+
+ expect(created.featureOverrides).toEqual(featureOverrides);
+ expect(atomicWrite.mock.calls.at(-1)[1].apps[created.id].featureOverrides).toEqual(featureOverrides);
+ });
+
it('createApp preserves web ports when a separate native target is present', async () => {
readJSONFile.mockResolvedValue({ apps: { [PORTOS_APP_ID]: { name: 'PortOS' } } });
const nativeLaunch = {
diff --git a/server/services/instanceFeatures.test.js b/server/services/instanceFeatures.test.js
index 3f4812513f..fcab90bcad 100644
--- a/server/services/instanceFeatures.test.js
+++ b/server/services/instanceFeatures.test.js
@@ -171,7 +171,7 @@ describe('instance features', () => {
const { features } = await getInstanceFeatures();
expect(Object.fromEntries(features.map((f) => [f.id, f.enabled])))
- .toEqual({ post: true, datadog: true, jira: false });
+ .toEqual({ post: true, datadog: true, jira: false, gsd: true });
});
it('rejects an unknown feature id', async () => {