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: manage Eidoverse Worlds GitHub source

[._.]/ Adam Eivy7c8955f6dc2a
diff --git a/client/src/components/settings/InstanceFeaturesTab.jsx b/client/src/components/settings/InstanceFeaturesTab.jsx
index a55f29b622..a5c4f1c088 100644
--- a/client/src/components/settings/InstanceFeaturesTab.jsx
+++ b/client/src/components/settings/InstanceFeaturesTab.jsx
@@ -6,7 +6,7 @@ import ToggleSwitch from '../ToggleSwitch';
import { useInstanceFeatures, publishInstanceFeatures } from '../../hooks/useInstanceFeatures.js';
import { isGitHubRepoUrl } from '../../lib/githubRepoUrl.js';
import { getPrimaryLaunchUrl } from '../../services/appUrls.js';
-import { installEidoverseFeature, updateInstanceFeature } from '../../services/api';
+import { installEidoverseFeature, updateEidoverseWorldsSource, updateInstanceFeature } 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
@@ -58,6 +58,24 @@ export function InstanceFeaturesTab() {
setSavingId(null);
};
+ const handleEidoverseSourceUpdate = async (feature) => {
+ if (savingId) return;
+ const worldsRepoUrl = eidoverseRepoUrl ?? feature?.setup?.worldsRepoUrl;
+ if (!worldsRepoUrl || !isGitHubRepoUrl(worldsRepoUrl)) return;
+ setSavingId(feature.id);
+ const result = await updateEidoverseWorldsSource(worldsRepoUrl, { silent: true }).catch((err) => {
+ toast.error(err.message || 'Could not update the Eidoverse Worlds source');
+ return null;
+ });
+
+ if (result) {
+ setEidoverseRepoUrl(null);
+ publishInstanceFeatures(result.features, { featureId: feature.id, enabled: feature.enabled });
+ toast.success('Eidoverse Worlds GitHub origin updated');
+ }
+ setSavingId(null);
+ };
+
const handleEidoverseRecheck = () => {
if (recheckingEidoverse) return;
setRecheckingEidoverse(true);
@@ -102,6 +120,9 @@ export function InstanceFeaturesTab() {
const selectedRepoUrl = eidoverseRepoUrl ?? setup?.worldsRepoUrl ?? '';
const repoIsValid = isGitHubRepoUrl(selectedRepoUrl);
const canInstall = repoIsValid && setup?.bunAvailable === true && setup?.registryAvailable !== false;
+ const canUpdateSource = repoIsValid
+ && selectedRepoUrl.trim() !== setup?.worldsRepoUrl
+ && setup?.registryAvailable !== false;
const launchUrl = setup?.appId && setup?.uiPort
? getPrimaryLaunchUrl({ id: setup.appId, uiPort: setup.uiPort })
: null;
@@ -121,11 +142,11 @@ export function InstanceFeaturesTab() {
: (isEidoverse ? 'Installed but disabled on this instance' : 'Not used on this instance'))}
</p>
{hint && <p className="text-xs text-gray-500 mt-1">{hint}</p>}
- {needsInstall && (
+ {isEidoverse && (
<div className="mt-3 space-y-1 text-xs text-gray-400">
- <p>
+ {needsInstall && <p>
PortOS will clone your selected Worlds repository and the upstream video runtime as separate AGPL-3.0 repositories, install their Bun dependencies, and register Worlds under Apps. It will not start the server automatically.
- </p>
+ </p>}
<label className="block pt-2" htmlFor="eidoverse-worlds-repo">
<span className="block text-gray-300 mb-1">Worlds GitHub repository</span>
<input
@@ -148,25 +169,41 @@ export function InstanceFeaturesTab() {
: 'Enter a valid GitHub repository URL.'}
</p>
)}
- <p>Use your own fork if you want PortOS agents to prepare changes and PRs against it.</p>
- {setup?.bunAvailable === false && (
- <p className="text-port-warning">
- Bun is required. <a className="underline hover:text-white" href="https://bun.sh" target="_blank" rel="noreferrer">Install Bun</a>, then retry.
- </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?.bunAvailable === false || setup?.registryAvailable === false) && (
+ <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={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"
+ 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"
>
- {recheckingEidoverse ? 'Rechecking…' : 'Recheck requirements'}
+ {installing ? 'Updating source…' : 'Update source'}
</button>
)}
+ {needsInstall && <>
+ {setup?.bunAvailable === false && (
+ <p className="text-port-warning">
+ Bun is required. <a className="underline hover:text-white" href="https://bun.sh" target="_blank" rel="noreferrer">Install Bun</a>, then retry.
+ </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?.bunAvailable === false || 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 && (
diff --git a/client/src/components/settings/InstanceFeaturesTab.test.jsx b/client/src/components/settings/InstanceFeaturesTab.test.jsx
index 05fcee345b..113ba8c66a 100644
--- a/client/src/components/settings/InstanceFeaturesTab.test.jsx
+++ b/client/src/components/settings/InstanceFeaturesTab.test.jsx
@@ -6,6 +6,7 @@ const mock = vi.hoisted(() => ({
getInstanceFeatures: vi.fn(),
updateInstanceFeature: vi.fn(),
installEidoverseFeature: vi.fn(),
+ updateEidoverseWorldsSource: vi.fn(),
}));
vi.mock('../../services/api', () => mock);
@@ -65,6 +66,20 @@ describe('InstanceFeaturesTab', () => {
setup: { ...EIDOVERSE_FEATURE.setup, installed: true, appId: 'app-eidoverse', runtimeStatus: 'not_started' },
}],
});
+ mock.updateEidoverseWorldsSource.mockResolvedValue({
+ features: [{
+ ...EIDOVERSE_FEATURE,
+ enabled: true,
+ source: 'explicit',
+ setup: {
+ ...EIDOVERSE_FEATURE.setup,
+ installed: true,
+ appId: 'app-eidoverse',
+ worldsRepoUrl: 'https://github.com/example-owner/eidoverse-worlds',
+ runtimeStatus: 'not_started',
+ },
+ }],
+ });
});
it('shows the instance-local feature switch', async () => {
@@ -130,6 +145,32 @@ describe('InstanceFeaturesTab', () => {
));
});
+ it('updates the origin of an installed Worlds checkout in place', async () => {
+ const installed = {
+ ...EIDOVERSE_FEATURE,
+ enabled: true,
+ source: 'explicit',
+ setup: {
+ ...EIDOVERSE_FEATURE.setup,
+ installed: true,
+ appId: 'app-eidoverse',
+ runtimeStatus: 'not_started',
+ },
+ };
+ mock.getInstanceFeatures.mockResolvedValue({ features: [installed] });
+ render(<MemoryRouter><InstanceFeaturesTab /></MemoryRouter>);
+
+ const repoInput = await screen.findByRole('textbox', { name: 'Worlds GitHub repository' });
+ fireEvent.change(repoInput, { target: { value: 'https://github.com/example-owner/eidoverse-worlds' } });
+ fireEvent.click(screen.getByRole('button', { name: 'Update source' }));
+
+ await waitFor(() => expect(mock.updateEidoverseWorldsSource).toHaveBeenCalledWith(
+ 'https://github.com/example-owner/eidoverse-worlds',
+ { silent: true },
+ ));
+ expect(await screen.findByDisplayValue('https://github.com/example-owner/eidoverse-worlds')).toBeInTheDocument();
+ });
+
it('keeps installation disabled for an invalid repository URL', async () => {
mock.getInstanceFeatures.mockResolvedValue({ features: [EIDOVERSE_FEATURE] });
render(<MemoryRouter><InstanceFeaturesTab /></MemoryRouter>);
diff --git a/client/src/services/apiSystem.js b/client/src/services/apiSystem.js
index 0ad39e3f5f..d0c29892c3 100644
--- a/client/src/services/apiSystem.js
+++ b/client/src/services/apiSystem.js
@@ -78,6 +78,11 @@ export const installEidoverseFeature = (worldsRepoUrl, options = {}) => request(
body: JSON.stringify({ worldsRepoUrl }),
...options,
});
+export const updateEidoverseWorldsSource = (worldsRepoUrl, options = {}) => request('/settings/features/eidoverse/source', {
+ method: 'PUT',
+ body: JSON.stringify({ worldsRepoUrl }),
+ ...options,
+});
export const startEidoverseHost = (options = {}) => request('/settings/features/eidoverse/host', {
method: 'POST',
...options,
diff --git a/docs/features/eidoverse.md b/docs/features/eidoverse.md
index d7f1a3d5da..f7cc2ba891 100644
--- a/docs/features/eidoverse.md
+++ b/docs/features/eidoverse.md
@@ -24,6 +24,11 @@ at its durable world store. PortOS does not copy either project's source into
the PortOS repository, combine the codebases, or relicense them; each checkout
retains its own upstream license and git history.
+After installation, the **Worlds GitHub repository** field remains available on
+**Settings → Features**. Updating it changes the installed checkout's `origin`
+in place, so the managed-app path, local working tree, and world data stay
+untouched. The companion video checkout remains on its upstream repository.
+
## Runtime and data ownership
The managed app uses port `8940` and starts with:
diff --git a/server/lib/apiRouteCatalog.generated.json b/server/lib/apiRouteCatalog.generated.json
index 21cc0a3e71..63c4e4e074 100644
--- a/server/lib/apiRouteCatalog.generated.json
+++ b/server/lib/apiRouteCatalog.generated.json
@@ -19246,7 +19246,7 @@
"sources": [
{
"source": "server/routes/settings.js",
- "line": 139
+ "line": 143
}
]
},
@@ -19257,7 +19257,7 @@
"sources": [
{
"source": "server/routes/settings.js",
- "line": 202
+ "line": 214
}
]
},
@@ -19268,7 +19268,7 @@
"sources": [
{
"source": "server/routes/settings.js",
- "line": 158
+ "line": 162
}
]
},
@@ -19279,7 +19279,7 @@
"sources": [
{
"source": "server/routes/settings.js",
- "line": 196
+ "line": 208
}
]
},
@@ -19290,7 +19290,7 @@
"sources": [
{
"source": "server/routes/settings.js",
- "line": 163
+ "line": 167
}
]
},
@@ -19301,7 +19301,7 @@
"sources": [
{
"source": "server/routes/settings.js",
- "line": 189
+ "line": 201
}
]
},
@@ -19312,7 +19312,7 @@
"sources": [
{
"source": "server/routes/settings.js",
- "line": 183
+ "line": 195
}
]
},
@@ -19323,7 +19323,18 @@
"sources": [
{
"source": "server/routes/settings.js",
- "line": 170
+ "line": 174
+ }
+ ]
+ },
+ {
+ "method": "PUT",
+ "path": "/api/settings/features/eidoverse/source",
+ "mountPath": "/api/settings",
+ "sources": [
+ {
+ "source": "server/routes/settings.js",
+ "line": 185
}
]
},
@@ -19334,7 +19345,7 @@
"sources": [
{
"source": "server/routes/settings.js",
- "line": 152
+ "line": 156
}
]
},
@@ -23554,8 +23565,8 @@
],
"stats": {
"mounts": 145,
- "operations": 2125,
- "declarations": 2128,
+ "operations": 2126,
+ "declarations": 2129,
"sourceFiles": 225
}
}
diff --git a/server/routes/settings.js b/server/routes/settings.js
index 17e4778f0c..3647d8051e 100644
--- a/server/routes/settings.js
+++ b/server/routes/settings.js
@@ -10,7 +10,7 @@ import {
CODEX_PARALLEL_DEFAULT,
} from '../services/mediaJobQueue/index.js';
import { assertMediaRoutingConfig } from '../services/federatedMedia/routingPolicy.js';
-import { assertConfiguredEidoverseInstalled, getInstanceFeatures, updateEidoverseWorldsRepo, updateInstanceFeature } from '../services/instanceFeatures.js';
+import { assertConfiguredEidoverseInstalled, getInstanceFeatures, updateEidoverseWorldsRepo, updateEidoverseWorldsSource, updateInstanceFeature } from '../services/instanceFeatures.js';
import { installEidoverse } from '../services/eidoverse.js';
import { ensureEidoverseHost } from '../services/eidoverseHost.js';
import { isGitHubRepoUrl } from '../lib/githubRepoUrl.js';
@@ -28,6 +28,10 @@ const aiAssignmentUpdateSchema = z.object({
effort: z.enum(EFFORT_LEVELS).nullable().optional(),
}).strict();
+const eidoverseRepoSchema = z.object({
+ worldsRepoUrl: z.string().trim().max(500).refine(isGitHubRepoUrl, 'Must be a GitHub repository URL'),
+}).strict();
+
// Server-authoritative bounds the client UI can render directly so the form
// clamp never drifts away from what the queue actually enforces. Stitched
// under `imageGen.codex.parallelLimitBounds` since that's where the field
@@ -168,14 +172,22 @@ router.get('/features', asyncHandler(async (_req, res) => {
// Explicit consent boundary: no Eidoverse checkout or dependency install occurs
// until the user presses Install in Settings > Features.
router.post('/features/eidoverse/install', asyncHandler(async (req, res) => {
- const { worldsRepoUrl } = validateRequest(z.object({
- worldsRepoUrl: z.string().trim().max(500).refine(isGitHubRepoUrl, 'Must be a GitHub repository URL'),
- }).strict(), req.body || {});
+ const { worldsRepoUrl } = validateRequest(eidoverseRepoSchema, req.body || {});
const normalizedRepoUrl = await updateEidoverseWorldsRepo(worldsRepoUrl);
await installEidoverse({ worldsRepoUrl: normalizedRepoUrl });
res.status(201).json(await updateInstanceFeature('eidoverse', true));
}));
+// PUT /api/settings/features/eidoverse/source
+// Update the origin of the existing Worlds checkout in place. The working tree,
+// managed-app path, and world data remain untouched; future app updates pull
+// from the newly selected repository.
+router.put('/features/eidoverse/source', asyncHandler(async (req, res) => {
+ const { worldsRepoUrl } = validateRequest(eidoverseRepoSchema, req.body || {});
+ await updateEidoverseWorldsSource(worldsRepoUrl);
+ res.json(await getInstanceFeatures());
+}));
+
// POST /api/settings/features/eidoverse/host
// Lazily opens PortOS's TLS/WebSocket bridge. The external runtime stays a
// separately managed app; this listener only makes its existing web UI safe to
diff --git a/server/routes/settings.test.js b/server/routes/settings.test.js
index 44db984213..aaf229f62a 100644
--- a/server/routes/settings.test.js
+++ b/server/routes/settings.test.js
@@ -49,6 +49,7 @@ vi.mock('../services/eidoverse.js', () => ({
normalizeEidoverseWorldsRepo: vi.fn((url) => url),
getEidoverseStatus: vi.fn(async () => ({ installed: false, bunAvailable: true, registryAvailable: true })),
assertEidoverseInstalled: vi.fn(async () => ({ installed: true })),
+ setEidoverseWorldsOrigin: vi.fn(async () => ({ appId: 'app-eidoverse' })),
installEidoverse: vi.fn(async () => ({ installed: true })),
}));
vi.mock('../services/eidoverseHost.js', () => ({
@@ -58,7 +59,7 @@ vi.mock('../services/eidoverseHost.js', () => ({
import settingsRoutes from './settings.js';
import { hasConfiguredInstances as hasConfiguredDatadogInstances } from '../services/datadog.js';
import { hasConfiguredInstances as hasConfiguredJiraInstances } from '../services/jira.js';
-import { assertEidoverseInstalled, installEidoverse } from '../services/eidoverse.js';
+import { assertEidoverseInstalled, installEidoverse, setEidoverseWorldsOrigin } from '../services/eidoverse.js';
import { ensureEidoverseHost } from '../services/eidoverseHost.js';
const buildApp = () => {
@@ -193,6 +194,28 @@ describe('Settings routes — instance feature participation', () => {
expect(res.body.features).toContainEqual(expect.objectContaining({ id: 'eidoverse', enabled: true }));
});
+ it('updates the installed Eidoverse source without changing feature participation', async () => {
+ const worldsRepoUrl = 'https://github.com/example-owner/eidoverse-worlds';
+ store = { instanceFeatures: { eidoverse: { enabled: true } } };
+
+ const res = await request(buildApp())
+ .put('/api/settings/features/eidoverse/source')
+ .send({ worldsRepoUrl });
+
+ expect(res.status).toBe(200);
+ expect(setEidoverseWorldsOrigin).toHaveBeenCalledWith(worldsRepoUrl);
+ expect(store.instanceFeatures.eidoverse).toMatchObject({ enabled: true, worldsRepoUrl });
+ });
+
+ it('rejects an invalid Eidoverse source update before mutating the checkout', async () => {
+ const res = await request(buildApp())
+ .put('/api/settings/features/eidoverse/source')
+ .send({ worldsRepoUrl: 'https://example.com/not-github' });
+
+ expect(res.status).toBe(400);
+ expect(setEidoverseWorldsOrigin).not.toHaveBeenCalled();
+ });
+
it('opens the Eidoverse host bridge only after verifying the managed app installation', async () => {
const res = await request(buildApp()).post('/api/settings/features/eidoverse/host');
diff --git a/server/services/eidoverse.js b/server/services/eidoverse.js
index 7d194f52ef..d922fc91e9 100644
--- a/server/services/eidoverse.js
+++ b/server/services/eidoverse.js
@@ -2,6 +2,7 @@ import { join } from 'path';
import { ServerError } from '../lib/errorHandler.js';
import { bufferedSpawnOrThrow } from '../lib/bufferedSpawn.js';
import { commandExists } from '../lib/commandExists.js';
+import { execGit } from '../lib/execGit.js';
import { atomicWrite, ensureDir, pathExists, PATHS } from '../lib/fileUtils.js';
import { parseGitHubUrl } from '../lib/githubRepoUrl.js';
import { cloneRepo } from './githubCloner.js';
@@ -61,7 +62,16 @@ const envFileContents = (paths) => [
'',
].join('\n');
-const findManagedApp = (apps, paths) => apps.find((app) => app.repoPath === paths.worlds) || null;
+const isManagedEidoverseApp = (app) => app?.pm2ProcessNames?.includes(EIDOVERSE_PROCESS_NAME)
+ || app?.name === 'Eidoverse Worlds';
+
+// A source switch keeps the existing checkout in place, so the configured
+// owner/repo path may no longer match the managed-app path. Prefer the exact
+// path for fresh installs, then fall back to the stable Eidoverse process name
+// for an already-registered checkout whose origin is being changed.
+const findManagedApp = (apps, paths) => apps.find((app) => (
+ app.repoPath === paths.worlds && isManagedEidoverseApp(app)
+)) || apps.find(isManagedEidoverseApp) || null;
async function registerManagedApp(paths) {
const apps = await getAllApps();
@@ -132,31 +142,29 @@ export async function installEidoverse({ worldsRepoUrl = DEFAULT_EIDOVERSE_WORLD
*/
export async function getEidoverseStatus({ worldsRepoUrl = DEFAULT_EIDOVERSE_WORLDS_REPO } = {}) {
const normalizedRepoUrl = normalizeEidoverseWorldsRepo(worldsRepoUrl);
- const paths = getEidoversePaths(normalizedRepoUrl);
- const [
- bunAvailable,
- worldsRepo,
- videoRepo,
- rootDependencies,
- clientDependencies,
- configured,
- worldDataReady,
- registry,
- ] = await Promise.all([
+ const configuredPaths = getEidoversePaths(normalizedRepoUrl);
+ const [bunAvailable, videoRepo, worldDataReady, registry] = await Promise.all([
commandExists('bun'),
- pathExists(join(paths.worlds, '.git')),
- pathExists(join(paths.video, '.git')),
- pathExists(join(paths.worlds, 'node_modules')),
- pathExists(join(paths.worlds, 'client', 'node_modules')),
- pathExists(paths.envFile),
- pathExists(paths.worldData),
+ pathExists(join(configuredPaths.video, '.git')),
+ pathExists(configuredPaths.worldData),
getAllApps().then(
(apps) => ({ apps, error: null }),
(error) => ({ apps: null, error: error.message }),
),
]);
- const app = registry.apps ? findManagedApp(registry.apps, paths) : null;
+ const app = registry.apps ? findManagedApp(registry.apps, configuredPaths) : null;
+ const worldsPath = typeof app?.repoPath === 'string' && app.repoPath.trim()
+ ? app.repoPath
+ : configuredPaths.worlds;
+ const worldsEnvFile = join(worldsPath, '.env.portos');
+ const [worldsRepo, rootDependencies, clientDependencies, configured] = await Promise.all([
+ pathExists(join(worldsPath, '.git')),
+ pathExists(join(worldsPath, 'node_modules')),
+ pathExists(join(worldsPath, 'client', 'node_modules')),
+ pathExists(worldsEnvFile),
+ ]);
+
const runtime = app
? await getAppStatusStrict(EIDOVERSE_PROCESS_NAME, app.pm2Home).catch(() => null)
: null;
@@ -191,6 +199,48 @@ export async function getEidoverseStatus({ worldsRepoUrl = DEFAULT_EIDOVERSE_WOR
};
}
+/**
+ * Change the Worlds checkout's fetch origin without moving the checkout or
+ * touching its working tree. This is intentionally separate from installation:
+ * changing a remote must not silently clone a second copy or delete local work.
+ */
+export async function setEidoverseWorldsOrigin(worldsRepoUrl) {
+ const normalizedRepoUrl = normalizeEidoverseWorldsRepo(worldsRepoUrl);
+ const configuredPaths = getEidoversePaths(normalizedRepoUrl);
+ const apps = await getAllApps();
+ const app = findManagedApp(apps, configuredPaths);
+
+ if (!app) {
+ throw new ServerError('Install Eidoverse Worlds before changing its GitHub source.', {
+ status: 409,
+ code: 'EIDOVERSE_NOT_INSTALLED',
+ });
+ }
+
+ const repoPath = typeof app.repoPath === 'string' && app.repoPath.trim() ? app.repoPath : null;
+ if (!repoPath || !await pathExists(join(repoPath, '.git'))) {
+ throw new ServerError('The registered Eidoverse Worlds checkout could not be found.', {
+ status: 409,
+ code: 'EIDOVERSE_CHECKOUT_MISSING',
+ });
+ }
+
+ const result = await execGit(
+ ['remote', 'set-url', 'origin', normalizedRepoUrl],
+ repoPath,
+ { ignoreExitCode: true },
+ );
+ if (result.exitCode !== 0) {
+ throw new ServerError('The Eidoverse Worlds checkout has no usable Git origin.', {
+ status: 422,
+ code: 'EIDOVERSE_ORIGIN_UPDATE_FAILED',
+ });
+ }
+
+ notifyAppsChanged('update', app.id);
+ return { appId: app.id, worldsRepoUrl: normalizedRepoUrl };
+}
+
export async function assertEidoverseInstalled(options) {
const status = await getEidoverseStatus(options);
if (status.installed) return status;
diff --git a/server/services/eidoverse.test.js b/server/services/eidoverse.test.js
index 85c14b63ad..699879b65e 100644
--- a/server/services/eidoverse.test.js
+++ b/server/services/eidoverse.test.js
@@ -7,6 +7,7 @@ const mock = vi.hoisted(() => ({
apps: [],
registryError: null,
cloneRepo: vi.fn(),
+ execGit: vi.fn(),
spawn: vi.fn(),
atomicWrite: vi.fn(),
ensureDir: vi.fn(),
@@ -26,6 +27,10 @@ vi.mock('../lib/commandExists.js', () => ({
commandExists: vi.fn(async () => mock.bunAvailable),
}));
+vi.mock('../lib/execGit.js', () => ({
+ execGit: mock.execGit,
+}));
+
vi.mock('../lib/bufferedSpawn.js', () => ({
bufferedSpawnOrThrow: mock.spawn,
}));
@@ -56,6 +61,7 @@ import {
getEidoverseStatus,
installEidoverse,
normalizeEidoverseWorldsRepo,
+ setEidoverseWorldsOrigin,
} from './eidoverse.js';
const SELECTED_WORLDS_REPO = 'https://github.com/example-owner/eidoverse-worlds';
@@ -68,6 +74,7 @@ describe('Eidoverse managed-app installer', () => {
mock.bunAvailable = true;
mock.apps = [];
mock.registryError = null;
+ mock.execGit.mockResolvedValue({ stdout: '', stderr: '', exitCode: 0 });
__resetEidoverseInstallForTests();
mock.cloneRepo.mockImplementation(async (url) => {
@@ -150,4 +157,65 @@ describe('Eidoverse managed-app installer', () => {
registryError: 'Managed-app registry unavailable',
});
});
+
+ it('changes the origin of an existing checkout without moving or cloning it', async () => {
+ const existingPaths = getEidoversePaths();
+ mock.apps = [{
+ id: 'app-eidoverse',
+ name: 'Eidoverse Worlds',
+ repoPath: existingPaths.worlds,
+ pm2ProcessNames: ['eidoverse-worlds'],
+ }];
+ mock.existing.add(join(existingPaths.worlds, '.git'));
+
+ await expect(setEidoverseWorldsOrigin(SELECTED_WORLDS_REPO)).resolves.toEqual({
+ appId: 'app-eidoverse',
+ worldsRepoUrl: SELECTED_WORLDS_REPO,
+ });
+ expect(mock.execGit).toHaveBeenCalledWith(
+ ['remote', 'set-url', 'origin', SELECTED_WORLDS_REPO],
+ existingPaths.worlds,
+ { ignoreExitCode: true },
+ );
+ expect(mock.cloneRepo).not.toHaveBeenCalled();
+ });
+
+ it('keeps the registered checkout installed after its configured source changes', async () => {
+ const existingPaths = getEidoversePaths();
+ mock.apps = [{
+ id: 'app-eidoverse',
+ name: 'Eidoverse Worlds',
+ repoPath: existingPaths.worlds,
+ pm2ProcessNames: ['eidoverse-worlds'],
+ }];
+ mock.existing = new Set([
+ join(existingPaths.worlds, '.git'),
+ join(existingPaths.worlds, 'node_modules'),
+ join(existingPaths.worlds, 'client', 'node_modules'),
+ existingPaths.envFile,
+ join(existingPaths.video, '.git'),
+ existingPaths.worldData,
+ ]);
+
+ await expect(getEidoverseStatus({ worldsRepoUrl: SELECTED_WORLDS_REPO })).resolves.toMatchObject({
+ installed: true,
+ worldsRepoUrl: SELECTED_WORLDS_REPO,
+ appId: 'app-eidoverse',
+ });
+ });
+
+ it('refuses to update a source when the managed checkout is missing', async () => {
+ mock.apps = [{
+ id: 'app-eidoverse',
+ name: 'Eidoverse Worlds',
+ repoPath: getEidoversePaths().worlds,
+ pm2ProcessNames: ['eidoverse-worlds'],
+ }];
+
+ await expect(setEidoverseWorldsOrigin(SELECTED_WORLDS_REPO)).rejects.toMatchObject({
+ status: 409,
+ code: 'EIDOVERSE_CHECKOUT_MISSING',
+ });
+ expect(mock.execGit).not.toHaveBeenCalled();
+ });
});
diff --git a/server/services/instanceFeatures.js b/server/services/instanceFeatures.js
index a8ad35583e..c7be425b97 100644
--- a/server/services/instanceFeatures.js
+++ b/server/services/instanceFeatures.js
@@ -7,6 +7,7 @@ import {
DEFAULT_EIDOVERSE_WORLDS_REPO,
getEidoverseStatus,
normalizeEidoverseWorldsRepo,
+ setEidoverseWorldsOrigin,
} from './eidoverse.js';
import { getSettingsWithStatus, updateSettingsWith } from './settings.js';
@@ -162,6 +163,12 @@ export async function updateEidoverseWorldsRepo(worldsRepoUrl) {
return normalizedRepoUrl;
}
+export async function updateEidoverseWorldsSource(worldsRepoUrl) {
+ const normalizedRepoUrl = normalizeEidoverseWorldsRepo(worldsRepoUrl);
+ await setEidoverseWorldsOrigin(normalizedRepoUrl);
+ return updateEidoverseWorldsRepo(normalizedRepoUrl);
+}
+
// The same precedence ladder as `resolveInstanceFeatures`, but probing only this
// feature's detector — the single-feature callers (reminders, metrics, signal
// readers) must not pay for the others' disk reads.
diff --git a/server/services/instanceFeatures.test.js b/server/services/instanceFeatures.test.js
index edea212df4..845ace5c9a 100644
--- a/server/services/instanceFeatures.test.js
+++ b/server/services/instanceFeatures.test.js
@@ -9,6 +9,7 @@ const mock = vi.hoisted(() => ({
datadogThrows: false,
eidoverseInstalled: false,
assertEidoverseInstalled: vi.fn(),
+ setEidoverseWorldsOrigin: vi.fn(),
}));
vi.mock('./settings.js', () => ({
@@ -38,6 +39,7 @@ vi.mock('./eidoverse.js', () => ({
registryAvailable: true,
})),
assertEidoverseInstalled: mock.assertEidoverseInstalled,
+ setEidoverseWorldsOrigin: mock.setEidoverseWorldsOrigin,
}));
import {
@@ -46,6 +48,7 @@ import {
isInstanceFeatureEnabled,
resolveInstanceFeatures,
updateInstanceFeature,
+ updateEidoverseWorldsSource,
} from './instanceFeatures.js';
const byId = (features, id) => features.find((feature) => feature.id === id);
@@ -59,6 +62,7 @@ describe('instance features', () => {
mock.datadogThrows = false;
mock.eidoverseInstalled = false;
mock.assertEidoverseInstalled.mockReset().mockResolvedValue({ installed: true });
+ mock.setEidoverseWorldsOrigin.mockReset().mockResolvedValue({ appId: 'app-eidoverse' });
mock.updateSettingsWith.mockReset();
mock.updateSettingsWith.mockImplementation(async (mutate) => {
mock.settings = await mutate(structuredClone(mock.settings));
@@ -98,6 +102,14 @@ describe('instance features', () => {
expect(mock.updateSettingsWith).not.toHaveBeenCalled();
});
+ it('changes the installed source before persisting the normalized setting', async () => {
+ const selected = 'https://github.com/example-owner/eidoverse-worlds';
+
+ await expect(updateEidoverseWorldsSource(selected)).resolves.toBe(selected);
+ expect(mock.setEidoverseWorldsOrigin).toHaveBeenCalledWith(selected);
+ expect(mock.settings.instanceFeatures.eidoverse.worldsRepoUrl).toBe(selected);
+ });
+
it('resolves an explicit disable without changing POST configuration', () => {
expect(byId(resolveInstanceFeatures({ instanceFeatures: { post: { enabled: false } } }), 'post')).toMatchObject({
id: 'post',