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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (claude): preserve Eidoverse checkout during source changes
[._.]/ Adam Eivy3496f1cb2a87
diff --git a/client/src/components/settings/InstanceFeaturesTab.jsx b/client/src/components/settings/InstanceFeaturesTab.jsxindex a5c4f1c088..8cc00f98ac 100644--- a/client/src/components/settings/InstanceFeaturesTab.jsx+++ b/client/src/components/settings/InstanceFeaturesTab.jsx@@ -4,7 +4,7 @@ import toast from '../ui/Toast';import BrailleSpinner from '../BrailleSpinner';import ToggleSwitch from '../ToggleSwitch';import { useInstanceFeatures, publishInstanceFeatures } from '../../hooks/useInstanceFeatures.js';-import { isGitHubRepoUrl } from '../../lib/githubRepoUrl.js';+import { isGitHubRepoUrl, parseGitHubUrl } from '../../lib/githubRepoUrl.js';import { getPrimaryLaunchUrl } from '../../services/appUrls.js';import { installEidoverseFeature, updateEidoverseWorldsSource, updateInstanceFeature } from '../../services/api';@@ -18,10 +18,16 @@ const sourceHint = (feature) => {: `Detected automatically — no ${feature.label} instance is configured yet.`;};+const normalizeGitHubRepo = (url) => {+ const parsed = parseGitHubUrl(url);+ return parsed ? `https://github.com/${parsed.owner}/${parsed.repo}` : null;+};+export function InstanceFeaturesTab() {const { features, error, reload } = useInstanceFeatures();const [savingId, setSavingId] = useState(null);const [eidoverseRepoUrl, setEidoverseRepoUrl] = useState(null);+ const [updatingEidoverseSource, setUpdatingEidoverseSource] = useState(false);const [recheckingEidoverse, setRecheckingEidoverse] = useState(false);// The toggle is announced on the shared INSTANCE_FEATURES_CHANGED channel, so@@ -62,6 +68,7 @@ export function InstanceFeaturesTab() {if (savingId) return;const worldsRepoUrl = eidoverseRepoUrl ?? feature?.setup?.worldsRepoUrl;if (!worldsRepoUrl || !isGitHubRepoUrl(worldsRepoUrl)) return;+ setUpdatingEidoverseSource(true);setSavingId(feature.id);const result = await updateEidoverseWorldsSource(worldsRepoUrl, { silent: true }).catch((err) => {toast.error(err.message || 'Could not update the Eidoverse Worlds source');@@ -73,6 +80,7 @@ export function InstanceFeaturesTab() {publishInstanceFeatures(result.features, { featureId: feature.id, enabled: feature.enabled });toast.success('Eidoverse Worlds GitHub origin updated');}+ setUpdatingEidoverseSource(false);setSavingId(null);};@@ -121,7 +129,7 @@ export function InstanceFeaturesTab() {const repoIsValid = isGitHubRepoUrl(selectedRepoUrl);const canInstall = repoIsValid && setup?.bunAvailable === true && setup?.registryAvailable !== false;const canUpdateSource = repoIsValid- && selectedRepoUrl.trim() !== setup?.worldsRepoUrl+ && normalizeGitHubRepo(selectedRepoUrl) !== setup?.worldsRepoUrl&& setup?.registryAvailable !== false;const launchUrl = setup?.appId && setup?.uiPort? getPrimaryLaunchUrl({ id: setup.appId, uiPort: setup.uiPort })@@ -181,7 +189,7 @@ export function InstanceFeaturesTab() {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">- {installing ? 'Updating source…' : 'Update source'}+ {updatingEidoverseSource ? 'Updating source…' : 'Update source'}</button>)}{needsInstall && <>diff --git a/client/src/components/settings/InstanceFeaturesTab.test.jsx b/client/src/components/settings/InstanceFeaturesTab.test.jsxindex 113ba8c66a..80e6c349ab 100644--- a/client/src/components/settings/InstanceFeaturesTab.test.jsx+++ b/client/src/components/settings/InstanceFeaturesTab.test.jsx@@ -171,6 +171,28 @@ describe('InstanceFeaturesTab', () => {expect(await screen.findByDisplayValue('https://github.com/example-owner/eidoverse-worlds')).toBeInTheDocument();});+ it('does not offer a source update for an equivalent repository URL', async () => {+ const installed = {+ ...EIDOVERSE_FEATURE,+ enabled: true,+ setup: {+ ...EIDOVERSE_FEATURE.setup,+ installed: true,+ appId: 'app-eidoverse',+ },+ };+ mock.getInstanceFeatures.mockResolvedValue({ features: [installed] });+ render(<MemoryRouter><InstanceFeaturesTab /></MemoryRouter>);++ fireEvent.change(+ await screen.findByRole('textbox', { name: 'Worlds GitHub repository' }),+ { target: { value: 'https://github.com/anima-research/eidoverse-worlds.git' } },+ );++ expect(screen.getByRole('button', { name: 'Update source' })).toBeDisabled();+ expect(mock.updateEidoverseWorldsSource).not.toHaveBeenCalled();+ });+it('keeps installation disabled for an invalid repository URL', async () => {mock.getInstanceFeatures.mockResolvedValue({ features: [EIDOVERSE_FEATURE] });render(<MemoryRouter><InstanceFeaturesTab /></MemoryRouter>);diff --git a/server/services/eidoverse.js b/server/services/eidoverse.jsindex d922fc91e9..c79dbb4329 100644--- a/server/services/eidoverse.js+++ b/server/services/eidoverse.js@@ -62,20 +62,36 @@ const envFileContents = (paths) => ['',].join('\n');-const isManagedEidoverseApp = (app) => app?.pm2ProcessNames?.includes(EIDOVERSE_PROCESS_NAME)- || app?.name === 'Eidoverse Worlds';+const isManagedEidoverseApp = (app) => Boolean(app?.pm2ProcessNames?.includes(EIDOVERSE_PROCESS_NAME));// 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;+// owner/repo path may no longer match the managed-app path. The process name is+// the stable PortOS-owned identifier across that source change.+const findManagedApp = (apps) => apps.find(isManagedEidoverseApp) || null;++async function resolveEidoverseInstallPaths(worldsRepoUrl) {+ const configuredPaths = getEidoversePaths(worldsRepoUrl);+ const registered = findManagedApp(await getAllApps());+ const existingWorldsPath = typeof registered?.repoPath === 'string' && registered.repoPath.trim()+ ? registered.repoPath+ : null;++ if (!existingWorldsPath+ || existingWorldsPath === configuredPaths.worlds+ || !await pathExists(join(existingWorldsPath, '.git'))) {+ return configuredPaths;+ }++ return Object.freeze({+ ...configuredPaths,+ worlds: existingWorldsPath,+ envFile: join(existingWorldsPath, '.env.portos'),+ });+}async function registerManagedApp(paths) {const apps = await getAllApps();- const existing = findManagedApp(apps, paths);+ const existing = findManagedApp(apps);const fields = managedAppFields(paths);const app = existing? await updateApp(existing.id, fields)@@ -101,9 +117,10 @@ async function performInstall(worldsRepoUrl) {});}- const paths = getEidoversePaths(worldsRepoUrl);+ const configuredPaths = getEidoversePaths(worldsRepoUrl);+ const paths = await resolveEidoverseInstallPaths(worldsRepoUrl);await Promise.all([- cloneRepo(worldsRepoUrl),+ paths.worlds === configuredPaths.worlds ? cloneRepo(worldsRepoUrl) : Promise.resolve(),cloneRepo(EIDOVERSE_VIDEO_REPO),]);@@ -153,7 +170,7 @@ export async function getEidoverseStatus({ worldsRepoUrl = DEFAULT_EIDOVERSE_WOR),]);- const app = registry.apps ? findManagedApp(registry.apps, configuredPaths) : null;+ const app = registry.apps ? findManagedApp(registry.apps) : null;const worldsPath = typeof app?.repoPath === 'string' && app.repoPath.trim()? app.repoPath: configuredPaths.worlds;@@ -208,7 +225,7 @@ export async function setEidoverseWorldsOrigin(worldsRepoUrl) {const normalizedRepoUrl = normalizeEidoverseWorldsRepo(worldsRepoUrl);const configuredPaths = getEidoversePaths(normalizedRepoUrl);const apps = await getAllApps();- const app = findManagedApp(apps, configuredPaths);+ const app = findManagedApp(apps);if (!app) {throw new ServerError('Install Eidoverse Worlds before changing its GitHub source.', {@@ -231,10 +248,17 @@ export async function setEidoverseWorldsOrigin(worldsRepoUrl) {{ 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',- });+ const added = await execGit(+ ['remote', 'add', 'origin', normalizedRepoUrl],+ repoPath,+ { ignoreExitCode: true },+ );+ if (added.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);diff --git a/server/services/eidoverse.test.js b/server/services/eidoverse.test.jsindex 699879b65e..7b924af43e 100644--- a/server/services/eidoverse.test.js+++ b/server/services/eidoverse.test.js@@ -97,6 +97,11 @@ describe('Eidoverse managed-app installer', () => {mock.apps.push(app);return app;});+ mock.updateApp.mockImplementation(async (id, fields) => {+ const index = mock.apps.findIndex((app) => app.id === id);+ mock.apps[index] = { ...mock.apps[index], ...fields };+ return mock.apps[index];+ });});it('clones separate licensed repos, installs Bun dependencies, and registers Worlds', async () => {@@ -125,6 +130,27 @@ describe('Eidoverse managed-app installer', () => {});});+ it('resumes an existing checkout 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.add(join(existingPaths.worlds, '.git'));++ const status = await installEidoverse({ worldsRepoUrl: SELECTED_WORLDS_REPO });++ expect(mock.cloneRepo).not.toHaveBeenCalledWith(SELECTED_WORLDS_REPO);+ expect(mock.spawn).toHaveBeenCalledWith('bun', ['install', '--frozen-lockfile'], expect.objectContaining({ cwd: existingPaths.worlds }));+ expect(mock.atomicWrite).toHaveBeenCalledWith(+ existingPaths.envFile,+ expect.stringContaining(`EIDOVERSE_DIR=${JSON.stringify(existingPaths.video)}`),+ );+ expect(status).toMatchObject({ installed: true, appId: 'app-eidoverse' });+ });+it('uses the canonical upstream by default and normalizes a selected fork URL', () => {expect(getEidoversePaths().worlds).toBe(join('/example/data/repos', 'anima-research', 'eidoverse-worlds'));expect(DEFAULT_EIDOVERSE_WORLDS_REPO).toBe('https://github.com/anima-research/eidoverse-worlds');@@ -218,4 +244,36 @@ describe('Eidoverse managed-app installer', () => {});expect(mock.execGit).not.toHaveBeenCalled();});++ it('adds origin when an existing checkout has no origin remote', async () => {+ const existingPaths = getEidoversePaths();+ mock.apps = [{+ id: 'app-eidoverse',+ repoPath: existingPaths.worlds,+ pm2ProcessNames: ['eidoverse-worlds'],+ }];+ mock.existing.add(join(existingPaths.worlds, '.git'));+ mock.execGit+ .mockResolvedValueOnce({ stdout: '', stderr: "error: No such remote 'origin'", exitCode: 2 })+ .mockResolvedValueOnce({ stdout: '', stderr: '', exitCode: 0 });++ await expect(setEidoverseWorldsOrigin(SELECTED_WORLDS_REPO)).resolves.toMatchObject({+ appId: 'app-eidoverse',+ worldsRepoUrl: SELECTED_WORLDS_REPO,+ });+ expect(mock.execGit).toHaveBeenNthCalledWith(+ 2,+ ['remote', 'add', 'origin', SELECTED_WORLDS_REPO],+ existingPaths.worlds,+ { ignoreExitCode: true },+ );+ });++ it('refuses to update a source with no registered managed app', async () => {+ await expect(setEidoverseWorldsOrigin(SELECTED_WORLDS_REPO)).rejects.toMatchObject({+ status: 409,+ code: 'EIDOVERSE_NOT_INSTALLED',+ });+ expect(mock.execGit).not.toHaveBeenCalled();+ });});