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: bucket related instance features under a group toggle

tzioupfe4b26dbd4c0
diff --git a/AGENTS.md b/AGENTS.md
index da0e8b6e48..8e1a3b4d99 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -121,6 +121,8 @@ Client- and server-specific conventions live in nested memory files that load wh
**Optional features gate navigation, not routes.** `server/lib/instanceFeatureRegistry.js` declares the optional per-install features (`post`, `datadog`, `jira`) the user toggles in **Settings > Features**; `server/services/instanceFeatures.js` resolves each one as stored override → auto-detection of the integration it fronts → `defaultEnabled`. A nav entry tagged `feature: '<id>'` (or living in a section listed in navManifest's `SECTION_FEATURE` map) drops out of `⌘K` and the sidebar while that feature is off — **the `<Route>` keeps working, so bookmarks, direct links, and voice `ui_navigate` still resolve**. The gate is applied CLIENT-side (`useInstanceFeatures` + `client/src/lib/navFeatures.js`), not by filtering the manifest response: `⌘K` and the voice widget each fetch `/api/palette/manifest` once per session and it is HTTP-cached, so a server-side filter would both defeat that cache and still show hidden pages until a reload. Tag the sidebar row in `client/src/components/Layout.jsx` with the same id; `navManifest.test.js` scrapes both lists and fails when they drift, when a tag names an unregistered feature, or when a `SECTION_FEATURE` key stops matching a live section.
+**Feature groups bucket related features under one toggle, additively.** `INSTANCE_FEATURE_GROUPS` in `server/lib/instanceFeatureRegistry.js` declares the groups (today: `comms`, holding FaceTime Audio, iMessage, Signal, X, Stacker News and Beeper); a feature joins one by carrying `group: '<groupId>'` on its descriptor, which is the whole edit. `resolveOne` in `server/services/instanceFeatures.js` resolves a grouped feature as **its own stored override → the group flag → the detector → `defaultEnabled`**: an explicit per-feature override always wins, and only a feature left on "inherit" answers to its group (group off hides it, group on hands it straight back to its normal resolution). Setting an override back to inherit deletes the stored key rather than writing a third sentinel, so it reads exactly like a feature nobody ever touched. **A group's own `enabled` defaults to `true` when no group state is stored** — that default is the parity guarantee: an install with no `instanceFeatureGroups` in settings resolves every member exactly as it did before the group existed, so registering a group is never a silent hide and needs no settings migration. Malformed group settings fail toward `false`, matching the per-feature override's own posture. An ungrouped feature is completely unaffected.
+
### Slashdo Commands (`lib/slashdo`)
PortOS bundles [slashdo](https://github.com/atomantic/slashdo) as a git submodule at `lib/slashdo`, providing slash commands (`/do:next`, `/do:review`, `/do:pr`, `/do:push`, `/do:release`, …) without a separate global install. The `.claude/commands/do/` symlinks expose them as project-level slash commands. `/do:next` claims the next PLAN.md item (or GitHub issue with `--issues`) in an isolated worktree and ships a PR. CoS agents use the shared slashdo renderer: file-tool hosts receive a short entrypoint with supporting files read by phase; `loadSlashdoCommand(name)` from `server/services/subAgentSpawner.js` remains the eager, self-contained form for other consumers.
diff --git a/client/src/components/settings/InstanceFeaturesTab.jsx b/client/src/components/settings/InstanceFeaturesTab.jsx
index 650bb1619f..291440c52a 100644
--- a/client/src/components/settings/InstanceFeaturesTab.jsx
+++ b/client/src/components/settings/InstanceFeaturesTab.jsx
@@ -7,7 +7,7 @@ import RiggingRuntimeCard from './RiggingRuntimeCard';
import { useInstanceFeatures, publishInstanceFeatures } from '../../hooks/useInstanceFeatures.js';
import { isGitHubRepoUrl, parseGitHubUrl } from '../../lib/repoUrl.js';
import { getPrimaryLaunchUrl } from '../../services/appUrls.js';
-import { installEidoverseFeature, updateEidoverseWorldsSource, updateInstanceFeature } from '../../services/api';
+import { installEidoverseFeature, updateEidoverseWorldsSource, updateInstanceFeature, updateInstanceFeatureGroup } from '../../services/api';
// How the current value was decided, so a user who never touched the toggle can
// see that the install picked it up from a configured integration rather than
@@ -19,6 +19,13 @@ const sourceHint = (feature) => {
: `Detected automatically — no ${feature.label} instance is configured yet.`;
};
+// A grouped feature's own tri-state override, inferred from the resolved
+// `source`/`enabled` the server already sends — no separate field needed.
+// `source === 'explicit'` is the only way an override is stored (see
+// resolveOne in server/services/instanceFeatures.js); anything else (`auto`,
+// `default`, `detect-failed`, `group-off`) means the feature is inheriting.
+const overrideOf = (feature) => (feature.source === 'explicit' ? (feature.enabled ? 'on' : 'off') : 'inherit');
+
const normalizeGitHubRepo = (url) => {
const parsed = parseGitHubUrl(url);
if (!parsed) return null;
@@ -55,7 +62,7 @@ const SourceChoiceButton = ({ active, children, disabled = false, onClick }) =>
);
export function InstanceFeaturesTab() {
- const { features, error, reload } = useInstanceFeatures();
+ const { features, groups, error, reload } = useInstanceFeatures();
const [savingId, setSavingId] = useState(null);
const [eidoverseRepoUrl, setEidoverseRepoUrl] = useState(null);
const [updatingEidoverseSource, setUpdatingEidoverseSource] = useState(false);
@@ -74,7 +81,43 @@ export function InstanceFeaturesTab() {
return null;
});
- if (result) publishInstanceFeatures(result.features, { featureId: feature.id, enabled });
+ if (result) publishInstanceFeatures(result.features, { featureId: feature.id, enabled, groups: result.groups });
+ setSavingId(null);
+ };
+
+ // A grouped feature's three-way control (#40): 'inherit' clears the stored
+ // override (enabled: null) rather than writing a boolean, so the feature goes
+ // back to answering its group/detector/default exactly as if never touched.
+ const handleOverrideChange = async (feature, nextOverride) => {
+ if (!feature?.id || savingId || overrideOf(feature) === nextOverride) return;
+ const enabled = nextOverride === 'inherit' ? null : nextOverride === 'on';
+ setSavingId(feature.id);
+
+ const result = await updateInstanceFeature(feature.id, enabled, { silent: true }).catch((err) => {
+ toast.error(err.message || `Could not update ${feature.label}`);
+ return null;
+ });
+
+ if (result) publishInstanceFeatures(result.features, { featureId: feature.id, enabled, groups: result.groups });
+ setSavingId(null);
+ };
+
+ // The group's own toggle (#40). Namespaced with a `group:` prefix in
+ // `savingId` only to keep single-flight saving state shared with the
+ // per-feature controls — group ids and feature ids never collide today, but
+ // this keeps that assumption from mattering.
+ const handleGroupToggle = async (group) => {
+ if (!group?.id || savingId) return;
+ const enabled = !group.enabled;
+ const savingKey = `group:${group.id}`;
+ setSavingId(savingKey);
+
+ const result = await updateInstanceFeatureGroup(group.id, enabled, { silent: true }).catch((err) => {
+ toast.error(err.message || `Could not update ${group.label}`);
+ return null;
+ });
+
+ if (result) publishInstanceFeatures(result.features, { groups: result.groups });
setSavingId(null);
};
@@ -140,6 +183,293 @@ export function InstanceFeaturesTab() {
if (features === null) return <BrailleSpinner text="Loading instance features" />;
+ // Ungrouped features render unchanged, one card each. A grouped feature
+ // renders once, as part of its group's card, at the position of the first
+ // member the registry lists — so the overall order still follows the
+ // registry. When the group's own record isn't in `groups` (still loading,
+ // or a response that carries `features` but an empty/missing `groups`
+ // list), fall back to rendering each member as its own ungrouped card
+ // instead of a group row with nothing to key off — a feature must never
+ // vanish from the tab just because its group's metadata didn't load.
+ const groupsById = new Map((groups || []).map((group) => [group.id, group]));
+ const renderedGroupIds = new Set();
+ const rows = [];
+ for (const feature of features) {
+ if (feature.group && groupsById.has(feature.group)) {
+ if (renderedGroupIds.has(feature.group)) continue;
+ renderedGroupIds.add(feature.group);
+ rows.push({ kind: 'group', group: groupsById.get(feature.group), members: features.filter((f) => f.group === feature.group) });
+ } else {
+ rows.push({ kind: 'feature', feature });
+ }
+ }
+
+ const renderFeatureCard = (feature) => {
+ const hint = sourceHint(feature);
+ const isEidoverse = feature.id === 'eidoverse';
+ // Rigging's "configured" state is a machine-local runtime rather than a
+ // config file, so its row carries the probe's answer (installed/absent, the
+ // resolved interpreter, the module version, the install command).
+ const isRigging = feature.id === 'rigging';
+ const setup = isEidoverse ? feature.setup : null;
+ const needsInstall = isEidoverse && setup?.installed !== true;
+ const installing = savingId === feature.id;
+ const selectedRepoUrl = eidoverseRepoUrl ?? setup?.worldsRepoUrl ?? '';
+ const selectedRepo = parseGitHubUrl(selectedRepoUrl);
+ const selectedTransport = eidoverseTransport(selectedRepoUrl);
+ const selfOwner = setup?.sourceOwners?.self || null;
+ const upstreamOwner = setup?.sourceOwners?.upstream || 'anima-research';
+ const worldsBrowseUrl = githubBrowseUrl(setup?.worldsRepoUrl);
+ const repoIsValid = isGitHubRepoUrl(selectedRepoUrl);
+ const canInstall = repoIsValid && setup?.registryAvailable !== false;
+ const canUpdateSource = repoIsValid
+ && normalizeGitHubRepo(selectedRepoUrl) !== setup?.worldsRepoUrl
+ && setup?.registryAvailable !== false;
+ const launchUrl = setup?.appId && setup?.uiPort
+ ? getPrimaryLaunchUrl({ id: setup.appId, uiPort: setup.uiPort })
+ : null;
+ return (
+ <div
+ key={feature.id}
+ className="flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4 bg-port-card border border-port-border rounded-lg p-4"
+ >
+ <div className="min-w-0">
+ <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 ${feature.enabled ? 'text-port-success' : 'text-gray-500'}`}>
+ {needsInstall
+ ? (setup?.partial ? 'Installation needs to be resumed' : 'Not installed')
+ : (feature.enabled
+ ? 'Active on this instance'
+ : (isEidoverse ? 'Installed but disabled on this instance' : 'Not used on this instance'))}
+ </p>
+ {hint && !isRigging && <p className="text-xs text-gray-500 mt-1">{hint}</p>}
+ {/* Rigging's own card states the runtime's status precisely; the
+ generic "no <label> instance is configured" hint would talk about
+ an integration this feature does not have. */}
+ {isRigging && <RiggingRuntimeCard />}
+ {isEidoverse && (
+ <div className="mt-3 space-y-1 text-xs text-gray-400">
+ {needsInstall && <p>
+ PortOS will install Bun if needed, clone your selected Worlds repository and the upstream video runtime as separate AGPL-3.0 repositories, install their dependencies, and register Worlds under Apps. It will not start the server automatically.
+ </p>}
+ <div className="pt-2">
+ <label className="block text-gray-300 mb-1" htmlFor="eidoverse-worlds-repo">
+ Worlds GitHub repository
+ </label>
+ <span className="flex flex-wrap gap-2 mb-2">
+ <span role="group" aria-label="Worlds repository owner" className="inline-flex gap-1 rounded-lg border border-port-border p-1">
+ <SourceChoiceButton
+ active={Boolean(selfOwner) && selectedRepo?.owner?.toLowerCase() === selfOwner.toLowerCase()}
+ disabled={savingId !== null || !selfOwner}
+ onClick={() => setEidoverseRepoUrl(buildEidoverseRepoUrl(selfOwner, selectedTransport))}
+ >
+ Self
+ </SourceChoiceButton>
+ <SourceChoiceButton
+ active={selectedRepo?.owner?.toLowerCase() === upstreamOwner.toLowerCase()}
+ disabled={savingId !== null}
+ onClick={() => setEidoverseRepoUrl(buildEidoverseRepoUrl(upstreamOwner, selectedTransport))}
+ >
+ Upstream
+ </SourceChoiceButton>
+ </span>
+ <span role="group" aria-label="Worlds repository protocol" className="inline-flex gap-1 rounded-lg border border-port-border p-1">
+ <SourceChoiceButton
+ active={selectedTransport === 'http'}
+ disabled={savingId !== null || !selectedRepo}
+ onClick={() => setEidoverseRepoUrl(buildEidoverseRepoUrl(selectedRepo.owner, 'http'))}
+ >
+ HTTP
+ </SourceChoiceButton>
+ <SourceChoiceButton
+ active={selectedTransport === 'ssh'}
+ disabled={savingId !== null || !selectedRepo}
+ onClick={() => setEidoverseRepoUrl(buildEidoverseRepoUrl(selectedRepo.owner, 'ssh'))}
+ >
+ SSH
+ </SourceChoiceButton>
+ </span>
+ </span>
+ <input
+ id="eidoverse-worlds-repo"
+ type="text"
+ required
+ value={selectedRepoUrl}
+ onChange={(event) => setEidoverseRepoUrl(event.target.value)}
+ disabled={savingId !== null}
+ aria-invalid={!repoIsValid}
+ aria-describedby={!repoIsValid ? 'eidoverse-worlds-repo-error' : undefined}
+ 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 disabled:opacity-50"
+ placeholder="https://github.com/example-owner/eidoverse-worlds"
+ />
+ </div>
+ {!repoIsValid && (
+ <p id="eidoverse-worlds-repo-error" role="alert" className="text-port-error">
+ {selectedRepoUrl === ''
+ ? 'Enter a GitHub repository URL.'
+ : 'Enter a valid GitHub repository URL.'}
+ </p>
+ )}
+ <p>
+ {needsInstall
+ ? 'Use your own fork if you want PortOS agents to prepare changes and PRs against it.'
+ : 'Changing this updates the installed checkout’s Git origin in place. Local work, the managed-app path, and world data stay untouched.'}
+ </p>
+ {!needsInstall && (
+ <button
+ type="button"
+ onClick={() => handleEidoverseSourceUpdate(feature)}
+ disabled={savingId !== null || !canUpdateSource}
+ className="inline-flex items-center justify-center min-h-[44px] px-3 mt-2 text-sm bg-port-accent hover:bg-port-accent/80 disabled:opacity-50 disabled:cursor-not-allowed text-white rounded transition-colors"
+ >
+ {updatingEidoverseSource ? 'Updating source…' : 'Update source'}
+ </button>
+ )}
+ {needsInstall && <>
+ {setup?.bunAvailable === false && (
+ <p className="text-port-warning">
+ Bun is not installed. PortOS will install it automatically when you install and enable Eidoverse Worlds.
+ </p>
+ )}
+ {setup?.registryAvailable === false && (
+ <p className="text-port-error">The managed-app registry could not be read. Repair that before installing to avoid a duplicate app record.</p>
+ )}
+ {setup?.registryAvailable === false && (
+ <button
+ type="button"
+ onClick={handleEidoverseRecheck}
+ disabled={recheckingEidoverse}
+ className="inline-flex items-center justify-center min-h-[44px] px-3 mt-2 text-sm bg-port-border hover:bg-port-border/70 disabled:opacity-50 text-white rounded transition-colors"
+ >
+ {recheckingEidoverse ? 'Rechecking…' : 'Recheck requirements'}
+ </button>
+ )}
+ </>}
+ </div>
+ )}
+ {setup?.installed && (
+ <div className="flex flex-wrap items-center gap-3 mt-3 text-xs">
+ {worldsBrowseUrl && (
+ <a className="text-port-accent hover:text-white transition-colors" href={worldsBrowseUrl} target="_blank" rel="noreferrer">
+ Worlds repository
+ </a>
+ )}
+ {setup.appId && (
+ <Link className="text-port-accent hover:text-white transition-colors" to={`/apps/${setup.appId}`}>
+ Manage app
+ </Link>
+ )}
+ {feature.enabled && setup.runtimeStatus === 'online' && launchUrl && (
+ <a className="text-port-accent hover:text-white transition-colors" href={launchUrl} target="_blank" rel="noreferrer">
+ Open world
+ </a>
+ )}
+ {feature.enabled && setup.runtimeStatus !== 'online' && (
+ <span className="text-gray-500">Start it from the managed app to enter the world.</span>
+ )}
+ </div>
+ )}
+ </div>
+ {needsInstall ? (
+ <button
+ type="button"
+ onClick={() => handleEidoverseInstall(feature)}
+ disabled={savingId !== null || !canInstall}
+ className="shrink-0 inline-flex items-center justify-center min-h-[44px] px-3 text-sm bg-port-accent hover:bg-port-accent/80 disabled:opacity-50 disabled:cursor-not-allowed text-white rounded transition-colors"
+ >
+ {installing ? 'Installing…' : (setup?.partial ? 'Resume install' : 'Install & enable')}
+ </button>
+ ) : (
+ <ToggleSwitch
+ enabled={feature.enabled}
+ onChange={() => handleToggle(feature)}
+ disabled={savingId !== null}
+ ariaLabel={`${feature.enabled ? 'Disable' : 'Enable'} ${feature.label} on this instance`}
+ className="mt-1"
+ />
+ )}
+ </div>
+ );
+ };
+
+ // Settings > Features renders groups (#40): a group row with its own toggle,
+ // member rows beneath it showing effective state and a three-way override
+ // control. `group` can be undefined for one render if `groups` hasn't loaded
+ // yet even though `features` has (they load together in practice) — render
+ // nothing rather than crash on a lookup miss.
+ const renderGroupCard = (group, members) => {
+ if (!group) return null;
+ return (
+ <div key={`group-${group.id}`} className="bg-port-card border border-port-border rounded-lg p-4 space-y-3">
+ <div className="flex items-start justify-between gap-4">
+ <div className="min-w-0">
+ <h3 className="text-sm font-semibold text-white">{group.label}</h3>
+ <p className="text-sm text-gray-400 mt-1">{group.description}</p>
+ <p className={`text-xs mt-2 ${group.enabled ? 'text-port-success' : 'text-gray-500'}`}>
+ {group.enabled
+ ? 'Group active — each member below follows its own state'
+ : 'Group off — members stay hidden unless individually overridden to On'}
+ </p>
+ </div>
+ <ToggleSwitch
+ enabled={group.enabled}
+ onChange={() => handleGroupToggle(group)}
+ disabled={savingId !== null}
+ ariaLabel={`${group.enabled ? 'Disable' : 'Enable'} the ${group.label} feature group`}
+ className="mt-1"
+ />
+ </div>
+ <div className="pl-4 border-l border-port-border space-y-3">
+ {members.map((feature) => {
+ const hint = sourceHint(feature);
+ const override = overrideOf(feature);
+ return (
+ <div key={feature.id} className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
+ <div className="min-w-0">
+ <h4 className="text-sm font-medium text-white">{feature.label}</h4>
+ <p className="text-xs text-gray-400 mt-0.5">{feature.description}</p>
+ <p className={`text-xs mt-1 ${feature.enabled ? 'text-port-success' : 'text-gray-500'}`}>
+ {feature.enabled ? 'Active on this instance' : 'Not used on this instance'}
+ {feature.source === 'group-off' && ' — hidden by the group toggle above'}
+ </p>
+ {hint && <p className="text-xs text-gray-500 mt-1">{hint}</p>}
+ </div>
+ <div
+ role="group"
+ aria-label={`${feature.label} override`}
+ className="inline-flex gap-1 rounded-lg border border-port-border p-1 shrink-0"
+ >
+ <SourceChoiceButton
+ active={override === 'inherit'}
+ disabled={savingId !== null}
+ onClick={() => handleOverrideChange(feature, 'inherit')}
+ >
+ Inherit
+ </SourceChoiceButton>
+ <SourceChoiceButton
+ active={override === 'on'}
+ disabled={savingId !== null}
+ onClick={() => handleOverrideChange(feature, 'on')}
+ >
+ On
+ </SourceChoiceButton>
+ <SourceChoiceButton
+ active={override === 'off'}
+ disabled={savingId !== null}
+ onClick={() => handleOverrideChange(feature, 'off')}
+ >
+ Off
+ </SourceChoiceButton>
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ </div>
+ );
+ };
+
return (
<div className="space-y-6 max-w-3xl">
<div>
@@ -150,194 +480,9 @@ export function InstanceFeaturesTab() {
</div>
<div className="space-y-3">
- {features.map((feature) => {
- const hint = sourceHint(feature);
- const isEidoverse = feature.id === 'eidoverse';
- // Rigging's "configured" state is a machine-local runtime rather than a
- // config file, so its row carries the probe's answer (installed/absent, the
- // resolved interpreter, the module version, the install command).
- const isRigging = feature.id === 'rigging';
- const setup = isEidoverse ? feature.setup : null;
- const needsInstall = isEidoverse && setup?.installed !== true;
- const installing = savingId === feature.id;
- const selectedRepoUrl = eidoverseRepoUrl ?? setup?.worldsRepoUrl ?? '';
- const selectedRepo = parseGitHubUrl(selectedRepoUrl);
- const selectedTransport = eidoverseTransport(selectedRepoUrl);
- const selfOwner = setup?.sourceOwners?.self || null;
- const upstreamOwner = setup?.sourceOwners?.upstream || 'anima-research';
- const worldsBrowseUrl = githubBrowseUrl(setup?.worldsRepoUrl);
- const repoIsValid = isGitHubRepoUrl(selectedRepoUrl);
- const canInstall = repoIsValid && setup?.registryAvailable !== false;
- const canUpdateSource = repoIsValid
- && normalizeGitHubRepo(selectedRepoUrl) !== setup?.worldsRepoUrl
- && setup?.registryAvailable !== false;
- const launchUrl = setup?.appId && setup?.uiPort
- ? getPrimaryLaunchUrl({ id: setup.appId, uiPort: setup.uiPort })
- : null;
- return (
- <div
- key={feature.id}
- className="flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4 bg-port-card border border-port-border rounded-lg p-4"
- >
- <div className="min-w-0">
- <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 ${feature.enabled ? 'text-port-success' : 'text-gray-500'}`}>
- {needsInstall
- ? (setup?.partial ? 'Installation needs to be resumed' : 'Not installed')
- : (feature.enabled
- ? 'Active on this instance'
- : (isEidoverse ? 'Installed but disabled on this instance' : 'Not used on this instance'))}
- </p>
- {hint && !isRigging && <p className="text-xs text-gray-500 mt-1">{hint}</p>}
- {/* Rigging's own card states the runtime's status precisely; the
- generic "no <label> instance is configured" hint would talk about
- an integration this feature does not have. */}
- {isRigging && <RiggingRuntimeCard />}
- {isEidoverse && (
- <div className="mt-3 space-y-1 text-xs text-gray-400">
- {needsInstall && <p>
- PortOS will install Bun if needed, clone your selected Worlds repository and the upstream video runtime as separate AGPL-3.0 repositories, install their dependencies, and register Worlds under Apps. It will not start the server automatically.
- </p>}
- <div className="pt-2">
- <label className="block text-gray-300 mb-1" htmlFor="eidoverse-worlds-repo">
- Worlds GitHub repository
- </label>
- <span className="flex flex-wrap gap-2 mb-2">
- <span role="group" aria-label="Worlds repository owner" className="inline-flex gap-1 rounded-lg border border-port-border p-1">
- <SourceChoiceButton
- active={Boolean(selfOwner) && selectedRepo?.owner?.toLowerCase() === selfOwner.toLowerCase()}
- disabled={savingId !== null || !selfOwner}
- onClick={() => setEidoverseRepoUrl(buildEidoverseRepoUrl(selfOwner, selectedTransport))}
- >
- Self
- </SourceChoiceButton>
- <SourceChoiceButton
- active={selectedRepo?.owner?.toLowerCase() === upstreamOwner.toLowerCase()}
- disabled={savingId !== null}
- onClick={() => setEidoverseRepoUrl(buildEidoverseRepoUrl(upstreamOwner, selectedTransport))}
- >
- Upstream
- </SourceChoiceButton>
- </span>
- <span role="group" aria-label="Worlds repository protocol" className="inline-flex gap-1 rounded-lg border border-port-border p-1">
- <SourceChoiceButton
- active={selectedTransport === 'http'}
- disabled={savingId !== null || !selectedRepo}
- onClick={() => setEidoverseRepoUrl(buildEidoverseRepoUrl(selectedRepo.owner, 'http'))}
- >
- HTTP
- </SourceChoiceButton>
- <SourceChoiceButton
- active={selectedTransport === 'ssh'}
- disabled={savingId !== null || !selectedRepo}
- onClick={() => setEidoverseRepoUrl(buildEidoverseRepoUrl(selectedRepo.owner, 'ssh'))}
- >
- SSH
- </SourceChoiceButton>
- </span>
- </span>
- <input
- id="eidoverse-worlds-repo"
- type="text"
- required
- value={selectedRepoUrl}
- onChange={(event) => setEidoverseRepoUrl(event.target.value)}
- disabled={savingId !== null}
- aria-invalid={!repoIsValid}
- aria-describedby={!repoIsValid ? 'eidoverse-worlds-repo-error' : undefined}
- 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 disabled:opacity-50"
- placeholder="https://github.com/example-owner/eidoverse-worlds"
- />
- </div>
- {!repoIsValid && (
- <p id="eidoverse-worlds-repo-error" role="alert" className="text-port-error">
- {selectedRepoUrl === ''
- ? 'Enter a GitHub repository URL.'
- : 'Enter a valid GitHub repository URL.'}
- </p>
- )}
- <p>
- {needsInstall
- ? 'Use your own fork if you want PortOS agents to prepare changes and PRs against it.'
- : 'Changing this updates the installed checkout’s Git origin in place. Local work, the managed-app path, and world data stay untouched.'}
- </p>
- {!needsInstall && (
- <button
- type="button"
- onClick={() => handleEidoverseSourceUpdate(feature)}
- disabled={savingId !== null || !canUpdateSource}
- className="inline-flex items-center justify-center min-h-[44px] px-3 mt-2 text-sm bg-port-accent hover:bg-port-accent/80 disabled:opacity-50 disabled:cursor-not-allowed text-white rounded transition-colors"
- >
- {updatingEidoverseSource ? 'Updating source…' : 'Update source'}
- </button>
- )}
- {needsInstall && <>
- {setup?.bunAvailable === false && (
- <p className="text-port-warning">
- Bun is not installed. PortOS will install it automatically when you install and enable Eidoverse Worlds.
- </p>
- )}
- {setup?.registryAvailable === false && (
- <p className="text-port-error">The managed-app registry could not be read. Repair that before installing to avoid a duplicate app record.</p>
- )}
- {setup?.registryAvailable === false && (
- <button
- type="button"
- onClick={handleEidoverseRecheck}
- disabled={recheckingEidoverse}
- className="inline-flex items-center justify-center min-h-[44px] px-3 mt-2 text-sm bg-port-border hover:bg-port-border/70 disabled:opacity-50 text-white rounded transition-colors"
- >
- {recheckingEidoverse ? 'Rechecking…' : 'Recheck requirements'}
- </button>
- )}
- </>}
- </div>
- )}
- {setup?.installed && (
- <div className="flex flex-wrap items-center gap-3 mt-3 text-xs">
- {worldsBrowseUrl && (
- <a className="text-port-accent hover:text-white transition-colors" href={worldsBrowseUrl} target="_blank" rel="noreferrer">
- Worlds repository
- </a>
- )}
- {setup.appId && (
- <Link className="text-port-accent hover:text-white transition-colors" to={`/apps/${setup.appId}`}>
- Manage app
- </Link>
- )}
- {feature.enabled && setup.runtimeStatus === 'online' && launchUrl && (
- <a className="text-port-accent hover:text-white transition-colors" href={launchUrl} target="_blank" rel="noreferrer">
- Open world
- </a>
- )}
- {feature.enabled && setup.runtimeStatus !== 'online' && (
- <span className="text-gray-500">Start it from the managed app to enter the world.</span>
- )}
- </div>
- )}
- </div>
- {needsInstall ? (
- <button
- type="button"
- onClick={() => handleEidoverseInstall(feature)}
- disabled={savingId !== null || !canInstall}
- className="shrink-0 inline-flex items-center justify-center min-h-[44px] px-3 text-sm bg-port-accent hover:bg-port-accent/80 disabled:opacity-50 disabled:cursor-not-allowed text-white rounded transition-colors"
- >
- {installing ? 'Installing…' : (setup?.partial ? 'Resume install' : 'Install & enable')}
- </button>
- ) : (
- <ToggleSwitch
- enabled={feature.enabled}
- onChange={() => handleToggle(feature)}
- disabled={savingId !== null}
- ariaLabel={`${feature.enabled ? 'Disable' : 'Enable'} ${feature.label} on this instance`}
- className="mt-1"
- />
- )}
- </div>
- );
- })}
+ {rows.map((row) => (
+ row.kind === 'group' ? renderGroupCard(row.group, row.members) : renderFeatureCard(row.feature)
+ ))}
{features.length === 0 && (
<div className="bg-port-card border border-port-border rounded-lg p-4 text-sm text-gray-400">
No optional features are registered for this version of PortOS.
diff --git a/client/src/components/settings/InstanceFeaturesTab.test.jsx b/client/src/components/settings/InstanceFeaturesTab.test.jsx
index d159bac1bb..116c570537 100644
--- a/client/src/components/settings/InstanceFeaturesTab.test.jsx
+++ b/client/src/components/settings/InstanceFeaturesTab.test.jsx
@@ -1,10 +1,11 @@
import { describe, expect, it, beforeEach, vi } from 'vitest';
-import { fireEvent, render, screen, waitFor } from '@testing-library/react';
+import { fireEvent, render, screen, waitFor, within } from '@testing-library/react';
import { MemoryRouter } from 'react-router';
const mock = vi.hoisted(() => ({
getInstanceFeatures: vi.fn(),
updateInstanceFeature: vi.fn(),
+ updateInstanceFeatureGroup: vi.fn(),
installEidoverseFeature: vi.fn(),
updateEidoverseWorldsSource: vi.fn(),
}));
@@ -51,6 +52,37 @@ const EIDOVERSE_FEATURE = {
},
};
+// #40 — Comms feature group fixtures: FaceTime Audio, iMessage and Signal
+// bucketed under one `comms` group toggle with per-feature tri-state overrides.
+const COMMS_GROUP = { id: 'comms', label: 'Comms', description: 'Chat and calling integrations.', enabled: true };
+
+const IMESSAGE_FEATURE = {
+ id: 'imessage',
+ label: 'iMessage',
+ description: 'Machine-local iMessage and SMS reading.',
+ enabled: true,
+ source: 'default',
+ group: 'comms',
+};
+
+const SIGNAL_FEATURE = {
+ id: 'signal',
+ label: 'Signal',
+ description: 'Machine-local Signal Desktop message reading.',
+ enabled: true,
+ source: 'default',
+ group: 'comms',
+};
+
+const FACETIME_FEATURE = {
+ id: 'facetime',
+ label: 'FaceTime Audio',
+ description: 'Machine-local FaceTime Audio call controls.',
+ enabled: false,
+ source: 'default',
+ group: 'comms',
+};
+
describe('InstanceFeaturesTab', () => {
beforeEach(() => {
vi.clearAllMocks();
@@ -300,4 +332,131 @@ describe('InstanceFeaturesTab', () => {
expect(await screen.findByRole('switch', { name: 'Disable POST on this instance' })).toBeInTheDocument();
});
+
+ // #40 — Comms feature group: a group row with its own toggle, member rows
+ // beneath it with a three-way override control; ungrouped rows unchanged.
+ describe('feature groups', () => {
+ beforeEach(() => {
+ mock.getInstanceFeatures.mockResolvedValue({
+ features: [POST_FEATURE, IMESSAGE_FEATURE, SIGNAL_FEATURE, FACETIME_FEATURE],
+ groups: [COMMS_GROUP],
+ });
+ });
+
+ it('renders a group toggle and a per-feature override control for each member, leaving ungrouped rows unchanged', async () => {
+ render(<InstanceFeaturesTab />);
+
+ // Ungrouped POST keeps its plain on/off switch, untouched by grouping.
+ expect(await screen.findByRole('switch', { name: 'Disable POST on this instance' })).toBeInTheDocument();
+
+ // The group itself gets one toggle, labeled by the group (not a member).
+ const groupToggle = screen.getByRole('switch', { name: 'Disable the Comms feature group' });
+ expect(groupToggle).toHaveAttribute('aria-checked', 'true');
+
+ // Every member gets a three-way override control instead of a switch.
+ for (const label of ['iMessage', 'Signal', 'FaceTime Audio']) {
+ const control = screen.getByRole('group', { name: `${label} override` });
+ expect(within(control).getByRole('button', { name: 'Inherit' })).toBeInTheDocument();
+ expect(within(control).getByRole('button', { name: 'On' })).toBeInTheDocument();
+ expect(within(control).getByRole('button', { name: 'Off' })).toBeInTheDocument();
+ expect(screen.queryByRole('switch', { name: new RegExp(label, 'i') })).toBeNull();
+ }
+
+ // Effective state and the inherited default both show through.
+ expect(screen.getByText('FaceTime Audio')).toBeInTheDocument();
+ const facetimeRow = screen.getByRole('group', { name: 'FaceTime Audio override' }).closest('div.flex');
+ expect(within(facetimeRow).getByRole('button', { name: 'Inherit' })).toHaveAttribute('aria-pressed', 'true');
+ const imessageRow = screen.getByRole('group', { name: 'iMessage override' }).closest('div.flex');
+ expect(within(imessageRow).getByText('Active on this instance')).toBeInTheDocument();
+ });
+
+ it('toggles the feature group off and persists it', async () => {
+ mock.updateInstanceFeatureGroup.mockResolvedValue({
+ features: [
+ POST_FEATURE,
+ { ...IMESSAGE_FEATURE, enabled: false, source: 'group-off' },
+ { ...SIGNAL_FEATURE, enabled: false, source: 'group-off' },
+ { ...FACETIME_FEATURE, enabled: false, source: 'group-off' },
+ ],
+ groups: [{ ...COMMS_GROUP, enabled: false }],
+ });
+ render(<InstanceFeaturesTab />);
+
+ const groupToggle = await screen.findByRole('switch', { name: 'Disable the Comms feature group' });
+ fireEvent.click(groupToggle);
+
+ await waitFor(() => expect(mock.updateInstanceFeatureGroup).toHaveBeenCalledWith('comms', false, { silent: true }));
+ expect(await screen.findByRole('switch', { name: 'Enable the Comms feature group' })).toHaveAttribute('aria-checked', 'false');
+ // All three members are hidden by the off group with no override of their own.
+ expect(screen.getAllByText('hidden by the group toggle above', { exact: false })).toHaveLength(3);
+ });
+
+ it('sets a grouped feature override to On', async () => {
+ mock.updateInstanceFeature.mockResolvedValue({
+ features: [POST_FEATURE, IMESSAGE_FEATURE, SIGNAL_FEATURE, { ...FACETIME_FEATURE, enabled: true, source: 'explicit' }],
+ groups: [COMMS_GROUP],
+ });
+ render(<InstanceFeaturesTab />);
+
+ const control = await screen.findByRole('group', { name: 'FaceTime Audio override' });
+ fireEvent.click(within(control).getByRole('button', { name: 'On' }));
+
+ await waitFor(() => expect(mock.updateInstanceFeature).toHaveBeenCalledWith('facetime', true, { silent: true }));
+ expect(within(control).getByRole('button', { name: 'On' })).toHaveAttribute('aria-pressed', 'true');
+ });
+
+ it('sets a grouped feature override to Off', async () => {
+ mock.updateInstanceFeature.mockResolvedValue({
+ features: [POST_FEATURE, { ...IMESSAGE_FEATURE, enabled: false, source: 'explicit' }, SIGNAL_FEATURE, FACETIME_FEATURE],
+ groups: [COMMS_GROUP],
+ });
+ render(<InstanceFeaturesTab />);
+
+ const control = await screen.findByRole('group', { name: 'iMessage override' });
+ fireEvent.click(within(control).getByRole('button', { name: 'Off' }));
+
+ await waitFor(() => expect(mock.updateInstanceFeature).toHaveBeenCalledWith('imessage', false, { silent: true }));
+ expect(within(control).getByRole('button', { name: 'Off' })).toHaveAttribute('aria-pressed', 'true');
+ });
+
+ it('clears an explicit override back to Inherit with enabled: null', async () => {
+ mock.getInstanceFeatures.mockResolvedValue({
+ features: [POST_FEATURE, { ...IMESSAGE_FEATURE, enabled: false, source: 'explicit' }, SIGNAL_FEATURE, FACETIME_FEATURE],
+ groups: [COMMS_GROUP],
+ });
+ mock.updateInstanceFeature.mockResolvedValue({
+ features: [POST_FEATURE, IMESSAGE_FEATURE, SIGNAL_FEATURE, FACETIME_FEATURE],
+ groups: [COMMS_GROUP],
+ });
+ render(<InstanceFeaturesTab />);
+
+ const control = await screen.findByRole('group', { name: 'iMessage override' });
+ expect(within(control).getByRole('button', { name: 'Off' })).toHaveAttribute('aria-pressed', 'true');
+ fireEvent.click(within(control).getByRole('button', { name: 'Inherit' }));
+
+ await waitFor(() => expect(mock.updateInstanceFeature).toHaveBeenCalledWith('imessage', null, { silent: true }));
+ expect(within(control).getByRole('button', { name: 'Inherit' })).toHaveAttribute('aria-pressed', 'true');
+ });
+
+ // Regression: a response that carries grouped features but an
+ // empty/missing `groups` list must not silently drop those features from
+ // the tab. `renderGroupCard` returns null for an unresolved group, so
+ // without the row-building fallback every comms member vanished here.
+ it('falls back to rendering a grouped feature as its own ungrouped card when the groups list is empty', async () => {
+ mock.getInstanceFeatures.mockResolvedValue({
+ features: [POST_FEATURE, IMESSAGE_FEATURE, SIGNAL_FEATURE, FACETIME_FEATURE],
+ groups: [],
+ });
+ render(<InstanceFeaturesTab />);
+
+ // Every grouped member still renders — as a plain on/off switch, since
+ // there's no resolved group to attach a three-way override control to.
+ expect(await screen.findByRole('switch', { name: 'Disable POST on this instance' })).toBeInTheDocument();
+ expect(screen.getByRole('switch', { name: 'Disable iMessage on this instance' })).toBeInTheDocument();
+ expect(screen.getByRole('switch', { name: 'Disable Signal on this instance' })).toBeInTheDocument();
+ expect(screen.getByRole('switch', { name: 'Enable FaceTime Audio on this instance' })).toBeInTheDocument();
+ // No group toggle or group heading rendered — there's no group record to render one from.
+ expect(screen.queryByRole('switch', { name: /the Comms feature group/ })).not.toBeInTheDocument();
+ });
+ });
});
diff --git a/client/src/hooks/useInstanceFeatures.js b/client/src/hooks/useInstanceFeatures.js
index 655e36ccbd..8f2aa459f1 100644
--- a/client/src/hooks/useInstanceFeatures.js
+++ b/client/src/hooks/useInstanceFeatures.js
@@ -30,11 +30,19 @@ const loadInstanceFeatures = () => {
if (!inFlight || inFlightGeneration !== generation) {
const requested = generation;
const request = api.getInstanceFeatures({ silent: true })
- .then((data) => ({ features: Array.isArray(data?.features) ? data.features : [], error: null }))
+ .then((data) => ({
+ features: Array.isArray(data?.features) ? data.features : [],
+ // Feature GROUPS (#40) — Settings > Features is the only consumer that
+ // reads this; the sidebar, ⌘K, and voice keep reading `features[].enabled`
+ // exactly as before, since a grouped feature's `enabled` already carries
+ // its group's effect.
+ groups: Array.isArray(data?.groups) ? data.groups : [],
+ error: null,
+ }))
.catch((error) => {
// Fail OPEN: an unreadable feature list must not blank out navigation.
console.warn(`⚠️ instance features fetch failed: ${error?.message || error}`);
- return { features: null, error };
+ return { features: null, groups: null, error };
})
.then((result) => {
if (inFlight === request) {
@@ -56,6 +64,7 @@ const loadInstanceFeatures = () => {
/**
* @returns {{
* features: Array|null, // null while loading or after a failed fetch
+ * groups: Array|null, // feature GROUPS (#40) — null while loading or after a failed fetch
* error: Error|null,
* isFeatureEnabled: (featureId: string) => boolean,
* reload: () => Promise<void>,
@@ -66,9 +75,13 @@ const loadInstanceFeatures = () => {
* (an unknown gate must never erase a page)
* - loading → false, so a gated row appears once rather than flashing away
* - errored → true, so a server hiccup shows everything instead of hiding it
+ *
+ * `groups` is consumed by the Settings > Features tab only — every other
+ * consumer (sidebar, ⌘K, voice) keeps reading `features[].enabled`, which
+ * already carries a grouped feature's effective (group-aware) state.
*/
export function useInstanceFeatures() {
- const [state, setState] = useState(() => cached || { features: null, error: null });
+ const [state, setState] = useState(() => cached || { features: null, groups: null, error: null });
useEffect(() => {
let active = true;
@@ -78,9 +91,14 @@ export function useInstanceFeatures() {
const onFeaturesChanged = (event) => {
const features = event?.detail?.features;
+ const groups = event?.detail?.groups;
+ // A publisher that doesn't know about groups (e.g. a caller only
+ // announcing a `featureId`/`enabled` pair) must not wipe the groups this
+ // hook already knows — keep the previous value rather than resetting it.
+ const previousGroups = cached?.groups ?? null;
generation += 1;
if (Array.isArray(features)) {
- cached = { features, error: null };
+ cached = { features, groups: Array.isArray(groups) ? groups : previousGroups, error: null };
sync(cached);
return;
}
@@ -95,7 +113,7 @@ export function useInstanceFeatures() {
};
}, []);
- const { features, error } = state;
+ const { features, groups, error } = state;
const isFeatureEnabled = useCallback((featureId) => {
if (!featureId) return true;
@@ -112,21 +130,28 @@ export function useInstanceFeatures() {
generation += 1;
cached = null;
return loadInstanceFeatures().then((result) => {
- if (result.features) publishInstanceFeatures(result.features);
+ if (result.features) publishInstanceFeatures(result.features, { groups: result.groups });
else setState(result);
});
}, []);
- return { features, error, isFeatureEnabled, reload };
+ return { features, groups, error, isFeatureEnabled, reload };
}
/**
* Announce a feature change on the shared channel. Pass the server's fresh
* `features` list so every listener applies it without a second round-trip.
+ * `groups` is optional — most publishers (a plain feature toggle) don't carry
+ * it, and listeners fall back to whatever groups they already have cached.
*/
-export const publishInstanceFeatures = (features, { featureId, enabled } = {}) => {
+export const publishInstanceFeatures = (features, { featureId, enabled, groups } = {}) => {
window.dispatchEvent(new CustomEvent(INSTANCE_FEATURES_CHANGED, {
- detail: { featureId, enabled, features: Array.isArray(features) ? features : undefined },
+ detail: {
+ featureId,
+ enabled,
+ features: Array.isArray(features) ? features : undefined,
+ groups: Array.isArray(groups) ? groups : undefined,
+ },
}));
};
diff --git a/client/src/hooks/useInstanceFeatures.test.jsx b/client/src/hooks/useInstanceFeatures.test.jsx
index 0ab32e3911..74366b25cc 100644
--- a/client/src/hooks/useInstanceFeatures.test.jsx
+++ b/client/src/hooks/useInstanceFeatures.test.jsx
@@ -118,4 +118,56 @@ describe('useInstanceFeatures', () => {
expect(screen.getByTestId('a')).toHaveTextContent('on');
});
+
+ // Feature GROUPS (#40) — only the Settings > Features tab reads `groups`, but
+ // the shared hook has to carry it alongside `features` for that consumer.
+ describe('feature groups (#40)', () => {
+ function GroupsProbe() {
+ const { groups } = useInstanceFeatures();
+ return <output data-testid="groups">{groups === null ? 'loading' : JSON.stringify(groups)}</output>;
+ }
+
+ it('carries the groups list from the same fetch as features', async () => {
+ mock.getInstanceFeatures.mockResolvedValue({
+ features: JIRA_OFF,
+ groups: [{ id: 'comms', label: 'Comms', enabled: true }],
+ });
+ render(<GroupsProbe />);
+ await act(async () => {});
+
+ expect(screen.getByTestId('groups')).toHaveTextContent('"id":"comms"');
+ });
+
+ it('keeps the previously known groups when a publisher only announces a plain feature change', async () => {
+ mock.getInstanceFeatures.mockResolvedValue({
+ features: JIRA_OFF,
+ groups: [{ id: 'comms', label: 'Comms', enabled: true }],
+ });
+ render(<GroupsProbe />);
+ await act(async () => {});
+
+ // No `groups` in this publish — the plain shape every existing caller sends.
+ act(() => publishInstanceFeatures(JIRA_ON, { featureId: 'jira', enabled: true }));
+
+ expect(screen.getByTestId('groups')).toHaveTextContent('"id":"comms"');
+ });
+
+ it('applies a freshly published groups list without refetching', async () => {
+ mock.getInstanceFeatures.mockResolvedValue({
+ features: JIRA_OFF,
+ groups: [{ id: 'comms', label: 'Comms', enabled: true }],
+ });
+ render(<GroupsProbe />);
+ await act(async () => {});
+
+ act(() => publishInstanceFeatures(JIRA_ON, {
+ featureId: 'jira',
+ enabled: true,
+ groups: [{ id: 'comms', label: 'Comms', enabled: false }],
+ }));
+
+ expect(screen.getByTestId('groups')).toHaveTextContent('"enabled":false');
+ expect(mock.getInstanceFeatures).toHaveBeenCalledTimes(1);
+ });
+ });
});
diff --git a/client/src/services/apiSystem.js b/client/src/services/apiSystem.js
index 00152bf09a..551297b867 100644
--- a/client/src/services/apiSystem.js
+++ b/client/src/services/apiSystem.js
@@ -69,11 +69,18 @@ export const syncPortosFork = (opts = {}, requestOpts = {}) => request('/update/
export const getSettings = (options) => request('/settings', options);
export const getInstanceFeatures = (options) => request('/settings/features', options);
export const getCredentialInventory = (options) => request('/settings/credentials', options);
+// `enabled` accepts `null` — the tri-state override going back to "inherit" for
+// a grouped feature (see instanceFeatureUpdateSchema on the server).
export const updateInstanceFeature = (featureId, enabled, options = {}) => request(`/settings/features/${encodeURIComponent(featureId)}`, {
method: 'PUT',
body: JSON.stringify({ enabled }),
...options,
});
+export const updateInstanceFeatureGroup = (groupId, enabled, options = {}) => request(`/settings/features/groups/${encodeURIComponent(groupId)}`, {
+ method: 'PUT',
+ body: JSON.stringify({ enabled }),
+ ...options,
+});
export const installEidoverseFeature = (worldsRepoUrl, options = {}) => request('/settings/features/eidoverse/install', {
method: 'POST',
body: JSON.stringify({ worldsRepoUrl }),
diff --git a/server/lib/instanceFeatureRegistry.js b/server/lib/instanceFeatureRegistry.js
index f0f971e262..b9d479c405 100644
--- a/server/lib/instanceFeatureRegistry.js
+++ b/server/lib/instanceFeatureRegistry.js
@@ -10,13 +10,25 @@
// Adding a feature:
// 1. add a descriptor here;
// 2. tag its pages in navManifest.js (`feature: '<id>'`, or a SECTION_FEATURE
-// entry when a whole sidebar section belongs to it) and the matching rows
-// in client/src/components/Layout.jsx;
+// entry when a whole sidebar section belongs to it) — a sidebar row also
+// needs its own NAV_PRESENTATION entry in client/src/components/Layout.jsx
+// (path → icon): feature, section and label are inherited from
+// NAV_COMMANDS, so the path is the one thing declared twice — the icon
+// lives only in NAV_PRESENTATION;
// 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 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.
+//
+// A feature may carry `group: '<groupId>'` to bucket it under one of
+// INSTANCE_FEATURE_GROUPS below. A grouped feature keeps its own tri-state
+// override (inherit/on/off, same stored-`enabled` shape every feature already
+// uses) but ALSO inherits its group's `enabled` flag when its own override is
+// untouched: group off hides every member that has not overridden on, group on
+// hands each member back to its own normal resolution (detector, then
+// `defaultEnabled`). See resolveOne in services/instanceFeatures.js. An
+// ungrouped feature is completely unaffected — this is additive.
export const INSTANCE_FEATURES = Object.freeze([
Object.freeze({
id: 'post',
@@ -76,11 +88,68 @@ export const INSTANCE_FEATURES = Object.freeze([
label: 'FaceTime Audio',
description: 'Machine-local FaceTime Audio call controls and setup checks.',
defaultEnabled: false,
+ group: 'comms',
+ }),
+ Object.freeze({
+ id: 'imessage',
+ label: 'iMessage',
+ description: 'Machine-local iMessage and SMS reading, spam blocklist, and Tribe sync.',
+ defaultEnabled: true,
+ group: 'comms',
+ }),
+ Object.freeze({
+ id: 'signal',
+ label: 'Signal',
+ description: 'Machine-local Signal Desktop message reading and Tribe sync.',
+ defaultEnabled: true,
+ group: 'comms',
+ }),
+ Object.freeze({
+ id: 'x',
+ label: 'X',
+ description: 'X (Twitter) reach and health tracking, draft posts, and account safety controls.',
+ defaultEnabled: true,
+ group: 'comms',
+ }),
+ Object.freeze({
+ id: 'stacker-news',
+ label: 'Stacker News',
+ description: 'Stacker News community monitoring, triage queue, and draft composition.',
+ defaultEnabled: true,
+ group: 'comms',
+ }),
+ Object.freeze({
+ id: 'beeper',
+ label: 'Beeper',
+ description: 'Local Beeper Desktop bridge — WhatsApp, Discord, Telegram, and other bridged networks, mirrored machine-local.',
+ // No detector, by design (fork issue #11 decision): a token-presence gate
+ // can't bootstrap the very screen that sets the token. A plain manual
+ // toggle, off by default, like every other feature with no detector.
+ defaultEnabled: false,
+ group: 'comms',
}),
]);
export const INSTANCE_FEATURE_IDS = Object.freeze(INSTANCE_FEATURES.map((feature) => feature.id));
+// Buckets features under one group toggle with per-feature overrides (#40).
+// Membership: comms (FaceTime Audio, iMessage, Signal, X, Stacker News, Beeper
+// — #30 joined Beeper to the group #40 stood up, and X/Stacker News joined
+// after). Widening membership is a one-line change to a feature's `group`
+// above; adding a new group is a one-line addition here. A group's own
+// `enabled` flag defaults to true (see storedGroupEnabled in
+// services/instanceFeatures.js) so registering this never hides a feature an
+// existing install already saw with no settings write required.
+export const INSTANCE_FEATURE_GROUPS = Object.freeze([
+ Object.freeze({
+ id: 'comms',
+ label: 'Comms',
+ description: 'Chat and calling integrations, bucketed under one group toggle.',
+ }),
+]);
+
+export const INSTANCE_FEATURE_GROUP_IDS = Object.freeze(INSTANCE_FEATURE_GROUPS.map((group) => group.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.
diff --git a/server/lib/instanceFeatureRegistry.test.js b/server/lib/instanceFeatureRegistry.test.js
index a50857007d..43a7309217 100644
--- a/server/lib/instanceFeatureRegistry.test.js
+++ b/server/lib/instanceFeatureRegistry.test.js
@@ -1,5 +1,12 @@
import { describe, expect, it } from 'vitest';
-import { APP_FEATURE_IDS, INSTANCE_FEATURES, INSTANCE_FEATURE_IDS, countConfiguredInstances } from './instanceFeatureRegistry.js';
+import {
+ APP_FEATURE_IDS,
+ INSTANCE_FEATURES,
+ INSTANCE_FEATURE_IDS,
+ INSTANCE_FEATURE_GROUPS,
+ INSTANCE_FEATURE_GROUP_IDS,
+ countConfiguredInstances,
+} from './instanceFeatureRegistry.js';
describe('instance feature registry', () => {
it('declares an id, label, description and default for every feature', () => {
@@ -27,6 +34,60 @@ describe('instance feature registry', () => {
});
});
+describe('instance feature groups (#40)', () => {
+ it('declares an id, label and description for every group, with unique ids', () => {
+ for (const group of INSTANCE_FEATURE_GROUPS) {
+ expect(group.id).toBeTruthy();
+ expect(group.label).toBeTruthy();
+ expect(group.description).toBeTruthy();
+ }
+ expect(INSTANCE_FEATURE_GROUP_IDS).toEqual(INSTANCE_FEATURE_GROUPS.map((g) => g.id));
+ expect(new Set(INSTANCE_FEATURE_GROUP_IDS).size).toBe(INSTANCE_FEATURE_GROUP_IDS.length);
+ });
+
+ it('keeps every feature `group` reference pointed at a declared group', () => {
+ const declared = new Set(INSTANCE_FEATURE_GROUP_IDS);
+ for (const feature of INSTANCE_FEATURES) {
+ if (feature.group === undefined) continue;
+ expect(declared.has(feature.group), `feature "${feature.id}" names unregistered group "${feature.group}"`).toBe(true);
+ }
+ });
+
+ it('still lists every feature in INSTANCE_FEATURE_IDS regardless of grouping', () => {
+ expect(INSTANCE_FEATURE_IDS).toContain('facetime');
+ expect(INSTANCE_FEATURE_IDS).toContain('imessage');
+ expect(INSTANCE_FEATURE_IDS).toContain('signal');
+ expect(INSTANCE_FEATURE_IDS).toContain('x');
+ expect(INSTANCE_FEATURE_IDS).toContain('stacker-news');
+ expect(INSTANCE_FEATURE_IDS).toContain('beeper');
+ });
+
+ it('buckets the comms group as FaceTime Audio, iMessage, Signal, X, Stacker News and Beeper', () => {
+ expect(INSTANCE_FEATURE_GROUP_IDS).toContain('comms');
+ const members = INSTANCE_FEATURES.filter((feature) => feature.group === 'comms').map((feature) => feature.id);
+ expect(members.sort()).toEqual(['beeper', 'facetime', 'imessage', 'signal', 'stacker-news', 'x']);
+ });
+
+ it('defaults iMessage, Signal, X and Stacker News to enabled with no detector, like the existing manual toggles', () => {
+ for (const id of ['imessage', 'signal', 'x', 'stacker-news']) {
+ expect(INSTANCE_FEATURES.find((feature) => feature.id === id)).toMatchObject({
+ defaultEnabled: true,
+ group: 'comms',
+ });
+ }
+ });
+
+ // Beeper deliberately defaults OFF with no detector (fork issue #11): a
+ // token-presence gate can't bootstrap the very screen that sets the token,
+ // unlike iMessage/Signal which are always readable once enabled.
+ it('defaults Beeper to disabled with no detector', () => {
+ expect(INSTANCE_FEATURES.find((feature) => feature.id === 'beeper')).toMatchObject({
+ defaultEnabled: false,
+ group: 'comms',
+ });
+ });
+});
+
describe('countConfiguredInstances', () => {
it('counts the declared instances', () => {
expect(countConfiguredInstances({ instances: {} })).toBe(0);
diff --git a/server/lib/navManifest.js b/server/lib/navManifest.js
index d04492b71c..928672b857 100644
--- a/server/lib/navManifest.js
+++ b/server/lib/navManifest.js
@@ -148,16 +148,26 @@ const RAW_NAV_COMMANDS = [
{ id: 'nav.messages.inbox', path: '/messages/inbox', label: 'Inbox', section: 'Comms', tabGroup: 'messages', tabId: 'inbox', aliases: ['messages', 'comms', 'comms-inbox'], keywords: ['comms', 'email', 'inbox'] },
{ id: 'nav.messages.drafts', path: '/messages/drafts', label: 'Drafts', section: 'Comms', tabGroup: 'messages', tabId: 'drafts', aliases: ['drafts', 'comms-drafts'], keywords: ['comms'] },
- { id: 'nav.messages.imessage', path: '/messages/imessage', label: 'iMessage', section: 'Comms', tabGroup: 'messages', tabId: 'imessage', previousPaths: ['/imessage'], aliases: ['imessage', 'i-message', 'apple-messages', 'comms-imessage'], keywords: ['comms', 'imessage', 'sms', 'text messages', 'chat.db', 'blocklist', 'spam'] },
- { id: 'nav.messages.signal', path: '/messages/signal', label: 'Signal', section: 'Comms', tabGroup: 'messages', tabId: 'signal', previousPaths: ['/settings/signal'], aliases: ['signal', 'signal-desktop', 'comms-signal', 'signal-settings'], keywords: ['comms', 'signal', 'signal desktop', 'messages', 'sqlcipher', 'chat', 'tribe', 'timeline', 'encrypted', 'keychain'] },
+ // Comms feature group (#40): iMessage and Signal join the existing FaceTime
+ // Audio toggle under the `comms` group in instanceFeatureRegistry.js. The
+ // `<Route>` itself keeps resolving with the feature off, so bookmarks, direct
+ // links, and voice `ui_navigate` still land — only ⌘K/sidebar visibility gates.
+ // `feature` rides through `getPageNavTabs` onto the Messages tab strip, so the
+ // pill is gated by the same field the sidebar reads.
+ { id: 'nav.messages.imessage', path: '/messages/imessage', label: 'iMessage', section: 'Comms', tabGroup: 'messages', tabId: 'imessage', feature: 'imessage', previousPaths: ['/imessage'], aliases: ['imessage', 'i-message', 'apple-messages', 'comms-imessage'], keywords: ['comms', 'imessage', 'sms', 'text messages', 'chat.db', 'blocklist', 'spam'] },
+ { id: 'nav.messages.signal', path: '/messages/signal', label: 'Signal', section: 'Comms', tabGroup: 'messages', tabId: 'signal', feature: 'signal', previousPaths: ['/settings/signal'], aliases: ['signal', 'signal-desktop', 'comms-signal', 'signal-settings'], keywords: ['comms', 'signal', 'signal desktop', 'messages', 'sqlcipher', 'chat', 'tribe', 'timeline', 'encrypted', 'keychain'] },
{ id: 'nav.messages.contacts', path: '/messages/contacts', label: 'Contacts', section: 'Comms', tabGroup: 'messages', tabId: 'contacts', previousPaths: ['/settings/contacts'], aliases: ['contacts', 'address-book', 'comms-contacts', 'settings-contacts'], keywords: ['comms', 'contacts', 'address book', 'phone', 'email', 'tribe', 'imessage', 'names', 'resolve'] },
// Ingestion config is a drawer over the iMessage manager (?settings=1), not a
// Settings page — the settings-* aliases stay so "open iMessage settings" still lands.
- { id: 'nav.messages.imessage-settings', path: '/messages/imessage?settings=1', label: 'iMessage Settings', section: 'Comms', aliases: ['settings-imessage', 'imessage-settings', 'imessage-sync'], keywords: ['imessage', 'sync', 'chat.db', 'sms', 'texts', 'tribe', 'timeline', 'full disk access'] },
+ { id: 'nav.messages.imessage-settings', path: '/messages/imessage?settings=1', label: 'iMessage Settings', section: 'Comms', feature: 'imessage', aliases: ['settings-imessage', 'imessage-settings', 'imessage-sync'], keywords: ['imessage', 'sync', 'chat.db', 'sms', 'texts', 'tribe', 'timeline', 'full disk access'] },
{ id: 'nav.messages.sync', path: '/messages/sync', label: 'Sync', section: 'Comms', tabGroup: 'messages', tabId: 'sync', aliases: ['messages-sync', 'comms-sync'], keywords: ['comms'] },
{ id: 'nav.messages.config', path: '/messages/config', label: 'Config', section: 'Comms', tabGroup: 'messages', tabId: 'config', aliases: ['messages-config', 'comms-config'], keywords: ['comms'] },
- { id: 'nav.stacker-news', path: '/stacker-news', label: 'Stacker News', section: 'Comms', aliases: ['stacker-news', 'stacker', 'sn'], keywords: ['comms', 'community', 'territory', 'moderation', 'stewardship'] },
- { id: 'nav.x', path: '/x', label: 'X', section: 'Comms', aliases: ['x', 'x-com', 'twitter', 'comms-x'], keywords: ['comms', 'social', 'reach', 'engagement', 'shadowban', 'diagnostics'] },
+ // X and Stacker News join the Comms feature group alongside iMessage,
+ // Signal, and Beeper — default ON, so an existing install sees no change;
+ // only ⌘K/sidebar visibility gates on the flag, the `<Route>` itself keeps
+ // resolving with the feature off.
+ { id: 'nav.stacker-news', path: '/stacker-news', label: 'Stacker News', section: 'Comms', feature: 'stacker-news', aliases: ['stacker-news', 'stacker', 'sn'], keywords: ['comms', 'community', 'territory', 'moderation', 'stewardship'] },
+ { id: 'nav.x', path: '/x', label: 'X', section: 'Comms', feature: 'x', aliases: ['x', 'x-com', 'twitter', 'comms-x'], keywords: ['comms', 'social', 'reach', 'engagement', 'shadowban', 'diagnostics'] },
{ id: 'nav.timeline', path: '/timeline', label: 'Timeline', section: 'Brain', aliases: ['activity-timeline', 'activity', 'my-day', 'life-log', 'life-timeline'], keywords: ['human activity', 'life log', 'timeline', 'messages', 'calendar', 'history', 'what did i do', 'daily', 'import', 'backfill', 'whatsapp', 'spotify', 'discord', 'youtube'] },
{ id: 'nav.tribe', path: '/tribe', label: 'Tribe', section: 'Brain', aliases: ['tribe', 'relationships', 'relationship-manager', 'people'], keywords: ['dunbar', 'friends', 'family', 'network', 'social graph', 'care cadence'] },
diff --git a/server/lib/navManifest.test.js b/server/lib/navManifest.test.js
index 55adc00048..befcf2d969 100644
--- a/server/lib/navManifest.test.js
+++ b/server/lib/navManifest.test.js
@@ -209,6 +209,25 @@ describe('nav contract — instance-feature gating', () => {
expect(command).toMatchObject({ path: '/eidoverse', feature: 'eidoverse' });
});
+ // Comms feature group (#40): iMessage, Signal, X and Stacker News join
+ // FaceTime Audio and Beeper under the `comms` group. Nav gating stays
+ // per-entry (unlike Health's whole-section SECTION_FEATURE gate) because
+ // Comms holds ungated siblings — Inbox, Drafts, Contacts.
+ it('gates the iMessage, Signal, X, Stacker News and Beeper pages on their own instance features', () => {
+ const byId = Object.fromEntries(NAV_COMMANDS.map((c) => [c.id, c.feature]));
+ expect(byId['nav.messages.imessage']).toBe('imessage');
+ expect(byId['nav.messages.imessage-settings']).toBe('imessage');
+ expect(byId['nav.messages.signal']).toBe('signal');
+ expect(byId['nav.x']).toBe('x');
+ expect(byId['nav.stacker-news']).toBe('stacker-news');
+ expect(byId['nav.messages.beeper']).toBe('beeper');
+ expect(byId['nav.messages.beeper-settings']).toBe('beeper');
+ // Contacts spans both networks (and every other message source) so it stays
+ // ungated even though it lives in the same Comms section.
+ expect(byId['nav.messages.contacts']).toBeUndefined();
+ expect(byId['nav.messages.inbox']).toBeUndefined();
+ });
+
it('gates the complete Health section and MortalLoom settings', () => {
const byId = Object.fromEntries(NAV_COMMANDS.map((c) => [c.id, c.feature]));
expect([...SECTION_FEATURE]).toContainEqual(['Health', 'health']);
diff --git a/server/lib/validation.js b/server/lib/validation.js
index 91ae169a40..51d0bca1a2 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -4,7 +4,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 { APP_FEATURE_IDS, INSTANCE_FEATURE_IDS } from './instanceFeatureRegistry.js';
+import { APP_FEATURE_IDS, INSTANCE_FEATURE_IDS, INSTANCE_FEATURE_GROUP_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';
@@ -975,7 +975,28 @@ export const instanceFeatureSettingsSchema = z.object(
export const instanceFeatureIdSchema = z.enum([...INSTANCE_FEATURE_IDS]);
+// `enabled: null` is the tri-state override going back to "inherit" — it clears
+// the stored value rather than writing a third sentinel, so a grouped feature's
+// resolution falls through to its group's `enabled` flag (see resolveOne in
+// services/instanceFeatures.js). Every existing caller sends a real boolean;
+// only the grouped-feature override control in Settings > Features sends null.
export const instanceFeatureUpdateSchema = z.object({
+ enabled: z.boolean().nullable(),
+}).strict();
+
+// Install-local feature GROUP participation flags. A group has no inherit
+// state of its own — just an on/off default-true toggle — so unlike
+// instanceFeatureUpdateSchema above this stays non-nullable.
+export const instanceFeatureGroupSettingsSchema = z.object(
+ Object.fromEntries(INSTANCE_FEATURE_GROUP_IDS.map((id) => [
+ id,
+ z.object({ enabled: z.boolean().optional() }).strict().optional(),
+ ]))
+).strict();
+
+export const instanceFeatureGroupIdSchema = z.enum([...INSTANCE_FEATURE_GROUP_IDS]);
+
+export const instanceFeatureGroupUpdateSchema = z.object({
enabled: z.boolean(),
}).strict();
diff --git a/server/routes/settings.js b/server/routes/settings.js
index eade9da86d..e7ede70985 100644
--- a/server/routes/settings.js
+++ b/server/routes/settings.js
@@ -12,7 +12,7 @@ import {
CODEX_PARALLEL_DEFAULT,
} from '../services/mediaJobQueue/index.js';
import { assertMediaRoutingConfig } from '../services/federatedMedia/routingPolicy.js';
-import { assertConfiguredEidoverseInstalled, getInstanceFeatures, updateEidoverseWorldsRepo, updateEidoverseWorldsSource, updateInstanceFeature } from '../services/instanceFeatures.js';
+import { assertConfiguredEidoverseInstalled, getInstanceFeatures, updateEidoverseWorldsRepo, updateEidoverseWorldsSource, updateInstanceFeature, updateInstanceFeatureGroup } from '../services/instanceFeatures.js';
import { getCredentialInventory } from '../services/credentialInventory.js';
import { installEidoverse } from '../services/eidoverse.js';
import { ensureEidoverseHost } from '../services/eidoverseHost.js';
@@ -22,7 +22,7 @@ import { isPlainObject } from '../lib/objects.js';
import { DEFAULT_UNTRUSTED_CONTENT_POLICY, untrustedContentSettingsSchema } from '../lib/untrustedContent.js';
import { agentContextSettingsSchema } from '../lib/agentContextValidation.js';
import { EFFORT_LEVELS } from '../lib/providerModels.js';
-import { privateCredentialParamsSchema, privateCredentialInputSchema, backupConfigSchema, sharingSettingsPatchSchema, featureProviderConfigSchema, autofixerSettingsSchema, codeReviewSettingsSchema, locationSettingsSchema, hideFirstRunCardSchema, networkSetupPreferenceSchema, settingsEmbeddingsSchema, localLlmSettingsSchema, imessageConfigSchema, signalConfigSchema, spotifyConfigSchema, youtubeConfigSchema, apiAccessSettingsSchema, instanceFeatureSettingsSchema, instanceFeatureIdSchema, instanceFeatureUpdateSchema, loraTrainingConfigSchema, pipelineEditorialChecksSettingsSchema, creativeDirectorSettingsSchema, musicSettingsSchema, federationSettingsSchema, privacySettingsSchema, seriesAutopilotSettingsSchema, layeredIntelligenceSettingsSchema, imageGenGrokSettingsSchema, imageGenAgySettingsSchema, renderDefaultsSettingsSchema, videoGenSettingsSchema, subscriptionCostsMapSchema, usageApiBilledInstanceIdsSchema, namedOrchestrationProfileSchema, orchestrationProfilesSettingsSchema, validateRequest } from '../lib/validation.js';
+import { privateCredentialParamsSchema, privateCredentialInputSchema, backupConfigSchema, sharingSettingsPatchSchema, featureProviderConfigSchema, autofixerSettingsSchema, codeReviewSettingsSchema, locationSettingsSchema, hideFirstRunCardSchema, networkSetupPreferenceSchema, settingsEmbeddingsSchema, localLlmSettingsSchema, imessageConfigSchema, signalConfigSchema, spotifyConfigSchema, youtubeConfigSchema, apiAccessSettingsSchema, instanceFeatureSettingsSchema, instanceFeatureIdSchema, instanceFeatureUpdateSchema, instanceFeatureGroupSettingsSchema, instanceFeatureGroupIdSchema, instanceFeatureGroupUpdateSchema, loraTrainingConfigSchema, pipelineEditorialChecksSettingsSchema, creativeDirectorSettingsSchema, musicSettingsSchema, federationSettingsSchema, privacySettingsSchema, seriesAutopilotSettingsSchema, layeredIntelligenceSettingsSchema, imageGenGrokSettingsSchema, imageGenAgySettingsSchema, renderDefaultsSettingsSchema, videoGenSettingsSchema, subscriptionCostsMapSchema, usageApiBilledInstanceIdsSchema, namedOrchestrationProfileSchema, orchestrationProfilesSettingsSchema, validateRequest } from '../lib/validation.js';
const router = Router();
@@ -222,12 +222,21 @@ router.post('/features/eidoverse/host', asyncHandler(async (_req, res) => {
}));
// PUT /api/settings/features/:featureId
+// `enabled` is nullable: null clears a grouped feature's override back to
+// "inherit" (see instanceFeatureUpdateSchema and updateInstanceFeature).
router.put('/features/:featureId', asyncHandler(async (req, res) => {
const featureId = validateRequest(instanceFeatureIdSchema, req.params.featureId);
const { enabled } = validateRequest(instanceFeatureUpdateSchema, req.body || {});
res.json(await updateInstanceFeature(featureId, enabled));
}));
+// PUT /api/settings/features/groups/:groupId (#40)
+router.put('/features/groups/:groupId', asyncHandler(async (req, res) => {
+ const groupId = validateRequest(instanceFeatureGroupIdSchema, req.params.groupId);
+ const { enabled } = validateRequest(instanceFeatureGroupUpdateSchema, req.body || {});
+ res.json(await updateInstanceFeatureGroup(groupId, enabled));
+}));
+
// PUT /api/settings/ai-assignments/:id
router.put('/ai-assignments/:id', asyncHandler(async (req, res) => {
const payload = validateRequest(aiAssignmentUpdateSchema, req.body || {});
@@ -369,6 +378,11 @@ router.put('/', asyncHandler(async (req, res) => {
if (req.body?.instanceFeatures !== undefined) {
validateRequest(instanceFeatureSettingsSchema, req.body.instanceFeatures);
}
+ // Instance feature GROUP participation (#40) — same shape guard as the
+ // per-feature slice above, keyed on the separate group id list.
+ if (req.body?.instanceFeatureGroups !== undefined) {
+ validateRequest(instanceFeatureGroupSettingsSchema, req.body.instanceFeatureGroups);
+ }
// Local MCP agent-context opt-in. Validate the whole strict slice so an
// unknown scope/profile cannot silently broaden what the server exposes.
if (req.body?.agentContext !== undefined) {
diff --git a/server/services/instanceFeatures.js b/server/services/instanceFeatures.js
index a6e03a6fa6..7612e222e8 100644
--- a/server/services/instanceFeatures.js
+++ b/server/services/instanceFeatures.js
@@ -1,7 +1,7 @@
import { ServerError } from '../lib/errorHandler.js';
import { getOriginInfo } from '../lib/gitRemote.js';
import { parseGitHubUrl } from '../lib/repoUrl.js';
-import { INSTANCE_FEATURES, INSTANCE_FEATURE_IDS } from '../lib/instanceFeatureRegistry.js';
+import { INSTANCE_FEATURES, INSTANCE_FEATURE_IDS, INSTANCE_FEATURE_GROUPS } from '../lib/instanceFeatureRegistry.js';
import { isPlainObject } from '../lib/objects.js';
import {
assertEidoverseInstalled,
@@ -64,11 +64,15 @@ const DETECTORS = {
};
const FEATURE_BY_ID = new Map(INSTANCE_FEATURES.map((feature) => [feature.id, feature]));
+const GROUP_BY_ID = new Map(INSTANCE_FEATURE_GROUPS.map((group) => [group.id, group]));
// The stored override for one feature: `true`/`false` when the user has toggled
// it, `null` when they never have. `null` is the signal that detection (and then
// `defaultEnabled`) decides — distinct from a stored `false`, which must keep
-// the feature off even once the integration is configured.
+// the feature off even once the integration is configured. Setting a grouped
+// feature's override back to "inherit" (updateInstanceFeature(id, null)) drops
+// the stored key entirely, so it reads `null` here exactly like a feature that
+// was never touched — no third sentinel value for this function to learn.
const storedOverride = (feature, settings) => {
const instanceFeatures = settings?.instanceFeatures;
if (instanceFeatures === undefined) return null;
@@ -82,10 +86,35 @@ const storedOverride = (feature, settings) => {
return typeof stored === 'boolean' ? stored : false;
};
+// A feature group's own on/off flag (#40), default `true` — opt-out, not
+// opt-in — so registering a group never hides a feature an existing install
+// already saw with no settings write required. Malformed shapes fail toward
+// `false`, the same posture as storedOverride above: untrustworthy settings
+// must not be read as a confident "on".
+const storedGroupEnabled = (groupId, settings) => {
+ const groups = settings?.instanceFeatureGroups;
+ if (groups === undefined) return true;
+ if (!isPlainObject(groups)) return false;
+ if (!Object.prototype.hasOwnProperty.call(groups, groupId)) return true;
+
+ const groupSettings = groups[groupId];
+ if (!isPlainObject(groupSettings)) return false;
+ const stored = groupSettings.enabled;
+ if (stored === undefined) return true;
+ return typeof stored === 'boolean' ? stored : false;
+};
+
const resolveOne = (feature, settings, detected) => {
const override = storedOverride(feature, settings);
if (override !== null) return { enabled: override, source: 'explicit' };
+ // No override: a grouped feature still answers to its group. Group OFF hides
+ // every member that hasn't overridden on (handled above); group ON — the
+ // default — hands the feature back to its own normal resolution below.
+ if (feature.group && !storedGroupEnabled(feature.group, settings)) {
+ return { enabled: false, source: 'group-off' };
+ }
+
const configured = detected?.[feature.id];
if (typeof configured === 'boolean') return { enabled: configured, source: 'auto' };
@@ -102,6 +131,17 @@ const resolveOne = (feature, settings, detected) => {
return { enabled: feature.defaultEnabled, source: 'default' };
};
+// The resolved list Settings > Features renders for the group toggles
+// themselves — parallel to resolveInstanceFeatures below, but there is no
+// detection or `corrupt`-settings special case beyond storedGroupEnabled's own
+// fail-closed-on-malformed-shape handling.
+export const resolveInstanceFeatureGroups = (settings = {}) => (
+ INSTANCE_FEATURE_GROUPS.map((group) => ({
+ ...group,
+ enabled: storedGroupEnabled(group.id, settings),
+ }))
+);
+
// One feature's detector: `true`/`false` when it answered, `null` when the
// feature has no detector or the probe threw — so the caller falls back to
// `defaultEnabled` rather than reading a failed probe as "not configured".
@@ -172,7 +212,14 @@ export async function getInstanceFeatures() {
getSettingsWithStatus(),
detectFeatureConfiguration(),
]);
- return { features: await attachSetupStatus(resolveInstanceFeatures(settings, { corrupt, detected }), settings) };
+ const features = await attachSetupStatus(resolveInstanceFeatures(settings, { corrupt, detected }), settings);
+ // Corrupt settings already fail every feature closed above; mirror that for
+ // groups rather than reading storedGroupEnabled's absent-key default of
+ // `true` off of settings we know are untrustworthy.
+ const groups = corrupt
+ ? INSTANCE_FEATURE_GROUPS.map((group) => ({ ...group, enabled: false }))
+ : resolveInstanceFeatureGroups(settings);
+ return { features, groups };
}
export async function updateEidoverseWorldsRepo(worldsRepoUrl) {
@@ -208,6 +255,9 @@ export async function isInstanceFeatureEnabled(featureId) {
const override = storedOverride(feature, settings);
if (override !== null) return override;
+ // Same short-circuit as the override check above: a grouped feature whose
+ // group is off never needs the detector run either.
+ if (feature.group && !storedGroupEnabled(feature.group, settings)) return false;
return resolveOne(feature, settings, { [featureId]: await runDetector(featureId) }).enabled;
}
@@ -222,6 +272,22 @@ export async function updateInstanceFeature(featureId, enabled) {
const settings = await updateSettingsWith((current) => {
const instanceFeatures = isPlainObject(current.instanceFeatures) ? current.instanceFeatures : {};
const currentFeature = isPlainObject(instanceFeatures[featureId]) ? instanceFeatures[featureId] : {};
+
+ // `enabled === null` is the tri-state override going back to "inherit":
+ // drop the stored `enabled` key (keeping any other co-stored key, e.g.
+ // eidoverse's worldsRepoUrl) rather than writing a third sentinel value, so
+ // storedOverride's existing "key absent" path picks it up unchanged.
+ if (enabled === null) {
+ const { enabled: _drop, ...rest } = currentFeature;
+ const nextInstanceFeatures = { ...instanceFeatures };
+ if (Object.keys(rest).length > 0) {
+ nextInstanceFeatures[featureId] = rest;
+ } else {
+ delete nextInstanceFeatures[featureId];
+ }
+ return { ...current, instanceFeatures: nextInstanceFeatures };
+ }
+
return {
...current,
instanceFeatures: {
@@ -248,5 +314,32 @@ export async function updateInstanceFeature(featureId, enabled) {
}
const detected = await detectFeatureConfiguration();
- return { features: await attachSetupStatus(resolveInstanceFeatures(settings, { detected }), settings) };
+ return {
+ features: await attachSetupStatus(resolveInstanceFeatures(settings, { detected }), settings),
+ groups: resolveInstanceFeatureGroups(settings),
+ };
+}
+
+export async function updateInstanceFeatureGroup(groupId, enabled) {
+ if (!GROUP_BY_ID.has(groupId)) {
+ throw new ServerError(`Unknown instance feature group: ${groupId}`, { status: 404, code: 'NOT_FOUND' });
+ }
+
+ const settings = await updateSettingsWith((current) => {
+ const groups = isPlainObject(current.instanceFeatureGroups) ? current.instanceFeatureGroups : {};
+ const currentGroup = isPlainObject(groups[groupId]) ? groups[groupId] : {};
+ return {
+ ...current,
+ instanceFeatureGroups: {
+ ...groups,
+ [groupId]: { ...currentGroup, enabled },
+ },
+ };
+ });
+
+ const detected = await detectFeatureConfiguration();
+ return {
+ features: await attachSetupStatus(resolveInstanceFeatures(settings, { detected }), settings),
+ groups: resolveInstanceFeatureGroups(settings),
+ };
}
diff --git a/server/services/instanceFeatures.test.js b/server/services/instanceFeatures.test.js
index a3ebdb24dc..4a9f65a8ad 100644
--- a/server/services/instanceFeatures.test.js
+++ b/server/services/instanceFeatures.test.js
@@ -67,7 +67,9 @@ import {
getInstanceFeatures,
isInstanceFeatureEnabled,
resolveInstanceFeatures,
+ resolveInstanceFeatureGroups,
updateInstanceFeature,
+ updateInstanceFeatureGroup,
updateEidoverseWorldsSource,
} from './instanceFeatures.js';
@@ -304,8 +306,10 @@ describe('instance features', () => {
mock.datadogConfigured = true;
const { features } = await getInstanceFeatures();
- expect(Object.fromEntries(features.map((f) => [f.id, f.enabled])))
- .toEqual({ post: true, datadog: true, jira: false, eidoverse: false, gsd: false, openclaw: false, health: true, rigging: false, facetime: false });
+ expect(Object.fromEntries(features.map((f) => [f.id, f.enabled]))).toEqual({
+ post: true, datadog: true, jira: false, eidoverse: false, gsd: false, openclaw: false, health: true,
+ rigging: false, facetime: false, imessage: true, signal: true, x: true, 'stacker-news': true, beeper: false,
+ });
});
it('rejects an unknown feature id', async () => {
@@ -313,6 +317,142 @@ describe('instance features', () => {
expect(await isInstanceFeatureEnabled('nope')).toBe(false);
});
+ // #40 — Comms feature group: FaceTime Audio, iMessage and Signal bucketed
+ // under a `comms` group toggle with per-feature tri-state overrides. Nested
+ // inside this describe (rather than a sibling) so it inherits the shared
+ // `beforeEach` that resets `mock.settings` between tests.
+ describe('instance feature groups (#40)', () => {
+ it('parity: an install with no stored group state resolves exactly as before this change', async () => {
+ // No instanceFeatureGroups key at all — the shape every existing install has
+ // today. iMessage and Signal must resolve enabled with no settings write.
+ const { features, groups } = await getInstanceFeatures();
+ expect(byId(features, 'imessage')).toMatchObject({ enabled: true, source: 'default' });
+ expect(byId(features, 'signal')).toMatchObject({ enabled: true, source: 'default' });
+ expect(byId(features, 'x')).toMatchObject({ enabled: true, source: 'default' });
+ expect(byId(features, 'stacker-news')).toMatchObject({ enabled: true, source: 'default' });
+ expect(await isInstanceFeatureEnabled('imessage')).toBe(true);
+ expect(await isInstanceFeatureEnabled('signal')).toBe(true);
+ expect(await isInstanceFeatureEnabled('x')).toBe(true);
+ expect(await isInstanceFeatureEnabled('stacker-news')).toBe(true);
+ // FaceTime Audio keeps answering to its own detector exactly as before
+ // grouping existed — a group with no stored state never overrides it. This
+ // suite doesn't mock voice/facetimeBridge.js, so the source depends on
+ // whatever the real probe finds on the machine running the test.
+ expect(['auto', 'default', 'detect-failed']).toContain(byId(features, 'facetime').source);
+
+ expect(byId(groups, 'comms')).toMatchObject({ id: 'comms', enabled: true });
+ });
+
+ it('lists every registered group, defaulting to enabled', async () => {
+ expect(resolveInstanceFeatureGroups({})).toEqual([
+ { id: 'comms', label: 'Comms', description: expect.any(String), enabled: true },
+ ]);
+ });
+
+ // Resolver truth table: group on/off × feature override inherit/on/off ×
+ // feature default true/false (imessage defaults true; facetime's detector
+ // answer is pinned via an explicit `detected` map — resolveInstanceFeatures
+ // is a pure function of its `detected` argument, so this doesn't depend on
+ // whatever the real facetimeBridge probe finds on the test machine).
+ describe('resolver truth table', () => {
+ const detected = { facetime: false };
+
+ it('group on, override inherit → feature default', () => {
+ const settings = {};
+ expect(byId(resolveInstanceFeatures(settings, { detected }), 'imessage')).toMatchObject({ enabled: true, source: 'default' });
+ expect(byId(resolveInstanceFeatures(settings, { detected }), 'facetime')).toMatchObject({ enabled: false, source: 'auto' });
+ });
+
+ it('group on, override on → on regardless of default', () => {
+ const settings = { instanceFeatures: { facetime: { enabled: true } } };
+ expect(byId(resolveInstanceFeatures(settings, { detected }), 'facetime')).toMatchObject({ enabled: true, source: 'explicit' });
+ });
+
+ it('group on, override off → off regardless of default', () => {
+ const settings = { instanceFeatures: { imessage: { enabled: false } } };
+ expect(byId(resolveInstanceFeatures(settings, { detected }), 'imessage')).toMatchObject({ enabled: false, source: 'explicit' });
+ });
+
+ it('group off, override inherit → off (hidden), for every default', () => {
+ const settings = { instanceFeatureGroups: { comms: { enabled: false } } };
+ expect(byId(resolveInstanceFeatures(settings, { detected }), 'imessage')).toMatchObject({ enabled: false, source: 'group-off' });
+ expect(byId(resolveInstanceFeatures(settings, { detected }), 'signal')).toMatchObject({ enabled: false, source: 'group-off' });
+ expect(byId(resolveInstanceFeatures(settings, { detected }), 'facetime')).toMatchObject({ enabled: false, source: 'group-off' });
+ });
+
+ it('group off, override on → the override wins, hands the feature back', () => {
+ const settings = {
+ instanceFeatureGroups: { comms: { enabled: false } },
+ instanceFeatures: { imessage: { enabled: true } },
+ };
+ expect(byId(resolveInstanceFeatures(settings, { detected }), 'imessage')).toMatchObject({ enabled: true, source: 'explicit' });
+ // A sibling with no override of its own stays hidden.
+ expect(byId(resolveInstanceFeatures(settings, { detected }), 'signal')).toMatchObject({ enabled: false, source: 'group-off' });
+ });
+
+ it('group off, override off → off (redundant with the group, still explicit)', () => {
+ const settings = {
+ instanceFeatureGroups: { comms: { enabled: false } },
+ instanceFeatures: { signal: { enabled: false } },
+ };
+ expect(byId(resolveInstanceFeatures(settings, { detected }), 'signal')).toMatchObject({ enabled: false, source: 'explicit' });
+ });
+
+ it('ungrouped features are unaffected by group state', () => {
+ const settings = { instanceFeatureGroups: { comms: { enabled: false } } };
+ expect(byId(resolveInstanceFeatures(settings, { detected }), 'post')).toMatchObject({ enabled: true, source: 'default' });
+ });
+ });
+
+ it('fails closed for a malformed group flag', () => {
+ const settings = { instanceFeatureGroups: { comms: { enabled: 'nope' } } };
+ expect(byId(resolveInstanceFeatures(settings), 'imessage')).toMatchObject({ enabled: false, source: 'group-off' });
+ expect(resolveInstanceFeatureGroups(settings)).toContainEqual(
+ expect.objectContaining({ id: 'comms', enabled: false }),
+ );
+ });
+
+ it('fails closed for every feature and every group when settings cannot be read', async () => {
+ mock.corrupt = true;
+ const { groups } = await getInstanceFeatures();
+ expect(byId(groups, 'comms')).toMatchObject({ enabled: false });
+ });
+
+ it('clears a per-feature override back to inherit rather than writing a third sentinel value', async () => {
+ mock.settings = { instanceFeatures: { facetime: { enabled: true } } };
+
+ const result = await updateInstanceFeature('facetime', null);
+
+ expect(mock.settings).toEqual({ instanceFeatures: {} });
+ // Storage is what this test pins; facetime's resolved source afterward
+ // depends on the real (unmocked) detector, asserted separately above.
+ expect(byId(result.features, 'facetime').source).not.toBe('explicit');
+ });
+
+ it('keeps a co-stored key when clearing just the enabled override', async () => {
+ // Not a real shape any grouped feature stores today, but the merge must not
+ // assume `enabled` is the only key ever co-stored under a feature id.
+ mock.settings = { instanceFeatures: { facetime: { enabled: true, note: 'keep' } } };
+
+ await updateInstanceFeature('facetime', null);
+
+ expect(mock.settings).toEqual({ instanceFeatures: { facetime: { note: 'keep' } } });
+ });
+
+ it('toggles a group and reports it back on both features and groups', async () => {
+ const result = await updateInstanceFeatureGroup('comms', false);
+
+ expect(mock.settings).toEqual({ instanceFeatureGroups: { comms: { enabled: false } } });
+ expect(byId(result.groups, 'comms')).toMatchObject({ enabled: false });
+ expect(byId(result.features, 'imessage')).toMatchObject({ enabled: false, source: 'group-off' });
+ expect(await isInstanceFeatureEnabled('imessage')).toBe(false);
+ });
+
+ it('rejects an unknown group id', async () => {
+ await expect(updateInstanceFeatureGroup('nope', false)).rejects.toMatchObject({ status: 404 });
+ });
+ });
+
it('records instance-feature.toggle with { id, enabled } and skips settings.update', async () => {
await updateInstanceFeature('post', false);
expect(mock.updateSettingsWith).toHaveBeenCalledWith(expect.any(Function), { actor: 'user', skipUserAction: true });