Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat: add native launch actions to managed apps

[._.]/ Adam Eivy11731c5ac920
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 1b893dfd70..62039e946e 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -49,6 +49,7 @@
## Managed apps
+- **Mixed web/native apps now keep their standard browser Launch and get a separate game action** — PortOS detects Godot projects without replacing their existing web ports or processes, then shows a configurable **Godot** button that starts the game once with live launch output and leaves it stopped when its window closes.
- **[issue-3025] Managed-app logs now follow the PM2 instance that actually owns them** — an app configured with its own PM2 home no longer shows an empty log in the Apps detail page or its HTTP log views. The selected app carries its identity into the Processes tab, and older process-only log requests still find a registered app's custom home automatically; ordinary default-home apps behave exactly as before.
- **[issue-3024] Live app logs can now appear in both the Processes tab and launch panel** — a managed desktop app no longer hides its launch-progress panel when you open **Processes**. Each panel now owns its named PM2 log stream, so closing one leaves the other tailing normally; replacing or closing a stream also cannot orphan a background `pm2 logs` process.
- **[issue-2991] Starting a desktop app now shows what it's doing, and quitting it stays quit** — pressing **Start** on a managed desktop app (a game binary) opens a live panel showing the build output as it compiles and imports assets, so a launch that takes a minute before a window appears no longer looks like nothing happened. The panel switches from "Launching" to "Running" once the app is up, and you can dismiss it any time without stopping the app. Closing or force-quitting the app's window is now treated as the normal end of a session everywhere: PortOS will no longer silently relaunch the window you just closed, and quitting no longer shows up as an errored process, flips your dashboard or CyberCity health to critical, or raises a failure alert. An app that runs in its own PM2 instance streams its build output into that panel correctly, rather than showing it empty.
diff --git a/client/src/components/AppTile.jsx b/client/src/components/AppTile.jsx
index 616ca385ed..8a9876568f 100644
--- a/client/src/components/AppTile.jsx
+++ b/client/src/components/AppTile.jsx
@@ -13,12 +13,17 @@ const AppTile = memo(function AppTile({ app, onUpdate }) {
const handleAction = async (action) => {
setLoading(action);
const actionFn = {
+ native: api.launchNativeApp,
start: api.startApp,
stop: api.stopApp,
restart: api.restartApp
}[action];
- const result = await actionFn(app.id);
+ const result = await actionFn(app.id).catch(() => null);
+ if (!result) {
+ setLoading(null);
+ return;
+ }
if (result?.selfRestart) {
api.handleSelfRestart();
@@ -97,6 +102,18 @@ const AppTile = memo(function AppTile({ app, onUpdate }) {
</a>
)}
+ {app.nativeLaunch && (
+ <button
+ onClick={() => handleAction('native')}
+ disabled={loading === 'native'}
+ className="px-2.5 py-1 text-xs rounded bg-port-success hover:bg-port-success/80 text-white transition-colors disabled:opacity-50"
+ aria-label={`Launch ${app.nativeLaunch.label} for ${app.name}`}
+ aria-busy={loading === 'native'}
+ >
+ {loading === 'native' ? '...' : app.nativeLaunch.label}
+ </button>
+ )}
+
{!isOnline && isDegraded && (
<button
onClick={() => onUpdate?.()}
diff --git a/client/src/components/apps/AppDetailView.jsx b/client/src/components/apps/AppDetailView.jsx
index 36dbd6b3d3..00d3ef9a31 100644
--- a/client/src/components/apps/AppDetailView.jsx
+++ b/client/src/components/apps/AppDetailView.jsx
@@ -1,6 +1,6 @@
import { useState, useEffect, useCallback, useMemo } from 'react';
import { Link, useParams, useNavigate, useSearchParams } from 'react-router-dom';
-import { ArrowLeft, Play, Square, RotateCcw, ExternalLink, Hammer, RefreshCw, Pencil, AlertTriangle, Sparkles } from 'lucide-react';
+import { ArrowLeft, Play, Square, RotateCcw, ExternalLink, Gamepad2, Hammer, RefreshCw, Pencil, AlertTriangle, Sparkles } from 'lucide-react';
import DeployPanel from './DeployPanel';
import EditAppDrawer from './EditAppDrawer';
import toast from '../ui/Toast';
@@ -34,6 +34,8 @@ export default function AppDetailView() {
const [actionLoading, setActionLoading] = useState(null);
// PM2 process whose live output the desktop launch panel is tailing (null = hidden).
const [launchProcess, setLaunchProcess] = useState(null);
+ const [nativeLaunchLoading, setNativeLaunchLoading] = useState(false);
+ const [nativeLaunchOnline, setNativeLaunchOnline] = useState(false);
const [buildLoading, setBuildLoading] = useState(false);
const [editing, setEditing] = useState(false);
// Vite Dev-UI host guard: when an online app exposes a Vite dev server, check
@@ -97,6 +99,42 @@ export default function AppDetailView() {
setActionLoading(null);
};
+ const handleNativeLaunch = async () => {
+ setNativeLaunchLoading(true);
+ const result = await api.launchNativeApp(appId).catch(() => null);
+ setNativeLaunchLoading(false);
+ if (!result?.processName) return;
+ setLaunchProcess(result.processName);
+ setNativeLaunchOnline(true);
+ };
+
+ // Native launch status is independent of the web app's overall PM2 state.
+ // Poll only while its live-output panel is open so closing the game moves the
+ // panel from Running to Exited without disturbing the standard web controls.
+ useEffect(() => {
+ if (!launchProcess || launchProcess !== app?.nativeLaunch?.processName) return;
+ let cancelled = false;
+ const refresh = () => {
+ api.getNativeLaunchStatus(appId, { silent: true })
+ .then(result => {
+ if (cancelled) return;
+ if (['online', 'launching'].includes(result?.status)) {
+ setNativeLaunchOnline(true);
+ } else if (['stopped', 'errored', 'not_found', 'not_started'].includes(result?.status)) {
+ setNativeLaunchOnline(false);
+ }
+ })
+ // A failed status read is unknown, not evidence that the game exited.
+ .catch(() => {});
+ };
+ refresh();
+ const timer = setInterval(refresh, 1500);
+ return () => {
+ cancelled = true;
+ clearInterval(timer);
+ };
+ }, [appId, app?.nativeLaunch?.processName, launchProcess]);
+
const handleStop = async () => {
setActionLoading('stop');
await api.stopApp(appId).catch(() => null);
@@ -357,6 +395,18 @@ export default function AppDetailView() {
</div>
);
})()}
+ {app.nativeLaunch && (
+ <button
+ onClick={handleNativeLaunch}
+ disabled={nativeLaunchLoading}
+ className="px-2 py-1 bg-port-success/20 text-port-success enabled:hover:bg-port-success/30 transition-colors rounded-lg border border-port-border flex items-center gap-1 disabled:opacity-50"
+ aria-label={`Launch ${app.nativeLaunch.label} for ${app.name}`}
+ aria-busy={nativeLaunchLoading}
+ >
+ <Gamepad2 size={14} />
+ <span className="text-xs">{nativeLaunchLoading ? 'Launching…' : app.nativeLaunch.label}</span>
+ </button>
+ )}
{app.buildCommand && (
<button
onClick={handleBuild}
@@ -449,7 +499,12 @@ export default function AppDetailView() {
<DesktopLaunchProgress
appId={appId}
processName={launchProcess}
- online={app.overallStatus === 'online'}
+ online={launchProcess === app.nativeLaunch?.processName
+ ? nativeLaunchOnline
+ : app.overallStatus === 'online'}
+ relaunchLabel={launchProcess === app.nativeLaunch?.processName
+ ? app.nativeLaunch.label
+ : 'Start'}
onDismiss={() => setLaunchProcess(null)}
/>
)}
diff --git a/client/src/components/apps/DesktopLaunchProgress.jsx b/client/src/components/apps/DesktopLaunchProgress.jsx
index c4552bfa79..b5b654db31 100644
--- a/client/src/components/apps/DesktopLaunchProgress.jsx
+++ b/client/src/components/apps/DesktopLaunchProgress.jsx
@@ -5,7 +5,7 @@ import ProcessLogLines from '../ui/ProcessLogLines';
import { useProcessLogs } from '../../hooks/useProcessLogs';
/**
- * Live build/launch output for a desktop (portless GUI) app.
+ * Live build/launch output for a desktop app or native GUI launch target.
*
* A web server binds its port in milliseconds; a desktop app's start command
* compiles the project and imports assets first, so the window can be tens of
@@ -23,9 +23,10 @@ import { useProcessLogs } from '../../hooks/useProcessLogs';
* @param {boolean} props.online Whether the process is up — drives the header
* copy through launching → running → exited so a finished launch reads as done
* and a closed window reads as a normal end rather than a launch still running.
+ * @param {string} [props.relaunchLabel='Start'] Button label used in exited copy.
* @param {() => void} props.onDismiss Close the panel (does not stop the app).
*/
-export default function DesktopLaunchProgress({ appId, processName, online, onDismiss }) {
+export default function DesktopLaunchProgress({ appId, processName, online, relaunchLabel = 'Start', onDismiss }) {
const { logs, subscribed } = useProcessLogs(processName, { lines: 200, appId });
const scrollRef = useRef(null);
// `online` is two-state, but the panel has three phases. Without remembering
@@ -64,7 +65,7 @@ export default function DesktopLaunchProgress({ appId, processName, online, onDi
{phase === 'running'
? 'The app is running. Closing its window stops it — that is a normal exit, not a crash.'
: phase === 'exited'
- ? 'The app has exited. Closing its window is a normal end to a session — press Start to launch it again.'
+ ? `The app has exited. Closing its window is a normal end to a session — press ${relaunchLabel} to launch it again.`
: 'Building and importing assets. The window opens when this finishes — this can take a while on a cold build.'}
</p>
diff --git a/client/src/components/apps/DesktopLaunchProgress.test.jsx b/client/src/components/apps/DesktopLaunchProgress.test.jsx
index 5db60393cb..643214deaa 100644
--- a/client/src/components/apps/DesktopLaunchProgress.test.jsx
+++ b/client/src/components/apps/DesktopLaunchProgress.test.jsx
@@ -88,6 +88,21 @@ describe('DesktopLaunchProgress', () => {
expect(screen.queryByText(/Building and importing assets/)).not.toBeInTheDocument();
});
+ it('names the separate native action in the relaunch copy', () => {
+ const { rerender } = renderPanel({ online: true, relaunchLabel: 'Godot' });
+ rerender(
+ <DesktopLaunchProgress
+ appId="app-1"
+ processName="game"
+ online={false}
+ relaunchLabel="Godot"
+ onDismiss={() => {}}
+ />
+ );
+
+ expect(screen.getByText(/press Godot to launch it again/)).toBeInTheDocument();
+ });
+
it('dismisses without stopping the app', () => {
const onDismiss = vi.fn();
renderPanel({ onDismiss });
@@ -117,6 +132,7 @@ describe('desktop type mirror', () => {
expect(isDesktopType('express')).toBe(false);
expect(isDesktopType(undefined)).toBe(false);
});
+
});
// The start endpoint answers 200 `{ success: true, results }` even when every
diff --git a/client/src/components/apps/EditAppDrawer.jsx b/client/src/components/apps/EditAppDrawer.jsx
index 86372653d6..e8b4e299c1 100644
--- a/client/src/components/apps/EditAppDrawer.jsx
+++ b/client/src/components/apps/EditAppDrawer.jsx
@@ -61,6 +61,10 @@ export default function EditAppDrawer({ app, onClose, onSave }) {
buildCommand: app.buildCommand || '',
startCommands: (app.startCommands || []).join('\n'),
pm2ProcessNames: (app.pm2ProcessNames || []).join(', '),
+ nativeLaunchEnabled: !!app.nativeLaunch,
+ nativeLaunchLabel: app.nativeLaunch?.label || 'Desktop',
+ nativeLaunchCommand: app.nativeLaunch?.command || '',
+ nativeLaunchProcessName: app.nativeLaunch?.processName || '',
editorCommand: app.editorCommand || 'code .',
workTracker: app.workTracker || 'auto',
defaultOpenPR: app.defaultOpenPR || false,
@@ -351,6 +355,25 @@ export default function EditAppDrawer({ app, onClose, onSave }) {
}
}
+ if (formData.nativeLaunchEnabled) {
+ const nativeFields = [
+ ['nativeLaunchLabel', 'Native button label'],
+ ['nativeLaunchProcessName', 'Native PM2 process name'],
+ ['nativeLaunchCommand', 'Native launch command']
+ ];
+ const missing = nativeFields.find(([key]) => !formData[key]?.trim());
+ if (missing) {
+ setActiveTab('commands');
+ setError(`${missing[1]} is required.`);
+ return;
+ }
+ if (!/^[a-zA-Z0-9._-]+$/.test(formData.nativeLaunchProcessName.trim())) {
+ setActiveTab('commands');
+ setError('Native PM2 process name may contain only letters, numbers, dots, underscores, and hyphens.');
+ return;
+ }
+ }
+
setSaving(true);
const data = {
@@ -366,6 +389,11 @@ export default function EditAppDrawer({ app, onClose, onSave }) {
pm2ProcessNames: formData.pm2ProcessNames
? formData.pm2ProcessNames.split(',').map(s => s.trim()).filter(Boolean)
: undefined,
+ nativeLaunch: formData.nativeLaunchEnabled ? {
+ label: formData.nativeLaunchLabel.trim(),
+ command: formData.nativeLaunchCommand.trim(),
+ processName: formData.nativeLaunchProcessName.trim()
+ } : null,
editorCommand: formData.editorCommand || undefined,
workTracker: formData.workTracker || 'auto',
defaultUseWorktree: formData.defaultUseWorktree || formData.defaultOpenPR,
@@ -624,6 +652,62 @@ export default function EditAppDrawer({ app, onClose, onSave }) {
/>
</div>
+ <div className="bg-port-bg/50 border border-port-border rounded-lg p-3 space-y-3">
+ <label htmlFor="edit-app-native-enabled" className="flex items-center gap-2 cursor-pointer">
+ <input
+ id="edit-app-native-enabled"
+ type="checkbox"
+ checked={formData.nativeLaunchEnabled}
+ onChange={e => setFormData(prev => ({ ...prev, nativeLaunchEnabled: e.target.checked }))}
+ className="rounded border-port-border bg-port-bg text-port-accent focus:ring-port-accent"
+ />
+ <span className="text-sm text-white">Separate native launch action</span>
+ </label>
+ <p className="text-xs text-gray-500">
+ Adds a button beside the standard web Launch. The native process runs once and stays stopped when its window closes.
+ </p>
+ {formData.nativeLaunchEnabled && (
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
+ <div>
+ <label htmlFor="edit-app-native-label" className="block text-sm text-gray-400 mb-1">Button Label</label>
+ <input
+ id="edit-app-native-label"
+ type="text"
+ value={formData.nativeLaunchLabel}
+ onChange={e => setFormData(prev => ({ ...prev, nativeLaunchLabel: e.target.value }))}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden"
+ placeholder="Godot"
+ required
+ />
+ </div>
+ <div>
+ <label htmlFor="edit-app-native-process" className="block text-sm text-gray-400 mb-1">PM2 Process Name</label>
+ <input
+ id="edit-app-native-process"
+ type="text"
+ value={formData.nativeLaunchProcessName}
+ onChange={e => setFormData(prev => ({ ...prev, nativeLaunchProcessName: e.target.value }))}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden"
+ placeholder="my-app-game"
+ required
+ />
+ </div>
+ <div className="sm:col-span-2">
+ <label htmlFor="edit-app-native-command" className="block text-sm text-gray-400 mb-1">Native Launch Command</label>
+ <input
+ id="edit-app-native-command"
+ type="text"
+ value={formData.nativeLaunchCommand}
+ onChange={e => setFormData(prev => ({ ...prev, nativeLaunchCommand: e.target.value }))}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden font-mono text-sm"
+ placeholder="./scripts/game run"
+ required
+ />
+ </div>
+ </div>
+ )}
+ </div>
+
<div>
<label htmlFor="edit-app-editor-command" className="block text-sm text-gray-400 mb-1">Editor Command</label>
<input
diff --git a/client/src/components/apps/EditAppDrawer.test.jsx b/client/src/components/apps/EditAppDrawer.test.jsx
index a816701396..5782d880f1 100644
--- a/client/src/components/apps/EditAppDrawer.test.jsx
+++ b/client/src/components/apps/EditAppDrawer.test.jsx
@@ -151,6 +151,37 @@ describe('EditAppDrawer work tracker selector', () => {
});
});
+describe('EditAppDrawer native launch target', () => {
+ it('edits the separate native action without changing standard web fields', async () => {
+ renderDrawer({
+ app: {
+ ...APP,
+ uiPort: 3000,
+ nativeLaunch: {
+ label: 'Godot',
+ command: './scripts/game run',
+ processName: 'my-app-game'
+ }
+ }
+ });
+ await openTab('Commands');
+
+ expect(screen.getByLabelText('Separate native launch action')).toBeChecked();
+ fireEvent.change(screen.getByLabelText('Button Label'), { target: { value: 'Play Game' } });
+ fireEvent.click(screen.getByRole('button', { name: 'Save Changes' }));
+
+ await waitFor(() => expect(api.updateApp).toHaveBeenCalled());
+ expect(api.updateApp.mock.calls[0][1]).toMatchObject({
+ uiPort: 3000,
+ nativeLaunch: {
+ label: 'Play Game',
+ command: './scripts/game run',
+ processName: 'my-app-game'
+ }
+ });
+ });
+});
+
describe('EditAppDrawer required-field validation across tabs', () => {
// The required Name/Repository Path inputs live on the General tab and are
// unmounted while another tab is active, so browser `required` validation
diff --git a/client/src/components/apps/tabs/OverviewTab.jsx b/client/src/components/apps/tabs/OverviewTab.jsx
index 6cd505dcc9..1ed2e8669b 100644
--- a/client/src/components/apps/tabs/OverviewTab.jsx
+++ b/client/src/components/apps/tabs/OverviewTab.jsx
@@ -1,6 +1,6 @@
import { useState, useEffect, useMemo } from 'react';
import { Link } from 'react-router-dom';
-import { FolderOpen, Terminal, Code, RefreshCw, Wrench, Archive, ArchiveRestore, Ticket, Download, Tag, AlertTriangle, Rocket, Camera, Image, Sparkles } from 'lucide-react';
+import { FolderOpen, Gamepad2, Terminal, Code, RefreshCw, Wrench, Archive, ArchiveRestore, Ticket, Download, Tag, AlertTriangle, Rocket, Camera, Image, Sparkles } from 'lucide-react';
import toast from '../../ui/Toast';
import { NON_PM2_TYPES } from '../constants';
import BrailleSpinner from '../../BrailleSpinner';
@@ -201,6 +201,18 @@ export default function OverviewTab({ app, onRefresh }) {
</div>
)}
+ {app.nativeLaunch && (
+ <div>
+ <div className="text-xs text-gray-500 uppercase tracking-wide mb-2">Native Launch</div>
+ <div className="flex flex-wrap items-center gap-2 bg-port-card border border-port-border rounded-lg p-3">
+ <Gamepad2 size={14} className="text-port-success shrink-0" />
+ <span className="text-sm text-white">{app.nativeLaunch.label}</span>
+ <code className="text-sm text-cyan-300 font-mono break-all">{app.nativeLaunch.command}</code>
+ <span className="text-xs text-gray-500 font-mono">{app.nativeLaunch.processName}</span>
+ </div>
+ </div>
+ )}
+
{/* PM2 Processes Status */}
{app.pm2Status && Object.keys(app.pm2Status).length > 0 && (
<div>
diff --git a/client/src/pages/Apps.jsx b/client/src/pages/Apps.jsx
index e80ed3cb36..9be304b071 100644
--- a/client/src/pages/Apps.jsx
+++ b/client/src/pages/Apps.jsx
@@ -1,6 +1,6 @@
import { useState, useEffect, useCallback } from 'react';
import { Link } from 'react-router-dom';
-import { ExternalLink, Play, Square, RotateCcw, FolderOpen, Terminal, Code, RefreshCw, Wrench, Archive, ArchiveRestore, Ticket, Download, Hammer, Smartphone } from 'lucide-react';
+import { ExternalLink, Gamepad2, Play, Square, RotateCcw, FolderOpen, Terminal, Code, RefreshCw, Wrench, Archive, ArchiveRestore, Ticket, Download, Hammer, Smartphone } from 'lucide-react';
import toast from '../components/ui/Toast';
import ConfirmButtonPair from '../components/ui/ConfirmButtonPair';
import AppIcon from '../components/AppIcon';
@@ -21,6 +21,7 @@ export default function Apps() {
const [confirmingDelete, setConfirmingDelete] = useState(null);
const [expandedId, setExpandedId] = useState(null);
const [actionLoading, setActionLoading] = useState({});
+ const [nativeLaunchLoading, setNativeLaunchLoading] = useState({});
const [refreshingConfig, setRefreshingConfig] = useState({});
const [building, setBuilding] = useState({});
const [archiving, setArchiving] = useState({});
@@ -78,6 +79,13 @@ export default function Apps() {
setActionLoading(prev => ({ ...prev, [app.id]: null }));
};
+ const handleNativeLaunch = async (app) => {
+ setNativeLaunchLoading(prev => ({ ...prev, [app.id]: true }));
+ const result = await api.launchNativeApp(app.id).catch(() => null);
+ setNativeLaunchLoading(prev => ({ ...prev, [app.id]: false }));
+ if (result?.success) toast.success(`${app.nativeLaunch.label} is running`);
+ };
+
const handleUpdate = (app) => startUpdate(app.id);
const handleBuild = async (app) => {
@@ -317,9 +325,9 @@ export default function Apps() {
)}
{/* Launch buttons grouped together */}
- {app.overallStatus === 'online' && (app.uiPort || app.devUiPort) && (
+ {(app.nativeLaunch || (app.overallStatus === 'online' && (app.uiPort || app.devUiPort))) && (
<div className="inline-flex rounded-lg overflow-hidden border border-port-border divide-x divide-port-border">
- {app.uiPort && (
+ {app.overallStatus === 'online' && app.uiPort && (
<button
onClick={() => window.open(`${window.location.protocol}//${window.location.hostname}:${app.uiPort}`, '_blank')}
className="px-3 py-1.5 min-h-[40px] sm:min-h-0 bg-port-accent/20 text-port-accent enabled:hover:bg-port-accent/30 transition-colors flex items-center gap-1"
@@ -329,7 +337,7 @@ export default function Apps() {
<span className="text-xs">Launch</span>
</button>
)}
- {app.devUiPort && (
+ {app.overallStatus === 'online' && app.devUiPort && (
<button
onClick={() => window.open(`${window.location.protocol}//${window.location.hostname}:${app.devUiPort}`, '_blank')}
className="px-3 py-1.5 min-h-[40px] sm:min-h-0 bg-port-warning/20 text-port-warning enabled:hover:bg-port-warning/30 transition-colors flex items-center gap-1"
@@ -339,6 +347,20 @@ export default function Apps() {
<span className="text-xs">Dev UI</span>
</button>
)}
+ {app.nativeLaunch && (
+ <button
+ onClick={() => handleNativeLaunch(app)}
+ disabled={nativeLaunchLoading[app.id]}
+ className="px-3 py-1.5 min-h-[40px] sm:min-h-0 bg-port-success/20 text-port-success enabled:hover:bg-port-success/30 transition-colors flex items-center gap-1 disabled:opacity-50"
+ aria-label={`Launch ${app.nativeLaunch.label} for ${app.name}`}
+ aria-busy={nativeLaunchLoading[app.id]}
+ >
+ <Gamepad2 size={14} aria-hidden="true" />
+ <span className="text-xs">
+ {nativeLaunchLoading[app.id] ? 'Launching…' : app.nativeLaunch.label}
+ </span>
+ </button>
+ )}
</div>
)}
@@ -606,4 +628,3 @@ export default function Apps() {
</div>
);
}
-
diff --git a/client/src/pages/CreateApp.jsx b/client/src/pages/CreateApp.jsx
index 11b9d79bff..89ee3fc2b1 100644
--- a/client/src/pages/CreateApp.jsx
+++ b/client/src/pages/CreateApp.jsx
@@ -52,6 +52,7 @@ export default function CreateApp() {
const [startCommands, setStartCommands] = useState('');
const [pm2Names, setPm2Names] = useState('');
const [pm2Status, setPm2Status] = useState(null);
+ const [nativeLaunch, setNativeLaunch] = useState(null);
const [icon, setIcon] = useState('package');
const [appIconPath, setAppIconPath] = useState(null);
const [appType, setAppType] = useState('unknown');
@@ -118,6 +119,7 @@ export default function CreateApp() {
if (result.buildCommand) setBuildCommand(result.buildCommand);
if (result.startCommands?.length) setStartCommands(result.startCommands.join('\n'));
if (result.pm2ProcessNames?.length) setPm2Names(result.pm2ProcessNames.join(', '));
+ setNativeLaunch(result.nativeLaunch || null);
if (result.appIconPath) setAppIconPath(result.appIconPath);
} else if (err) {
setError(err);
@@ -198,7 +200,8 @@ export default function CreateApp() {
? []
: pm2Names
? pm2Names.split(',').map(s => s.trim()).filter(Boolean)
- : [name.toLowerCase().replace(/[^a-z0-9]/g, '-')]
+ : [name.toLowerCase().replace(/[^a-z0-9]/g, '-')],
+ nativeLaunch
};
const result = await api.createApp(data).catch(err => {
@@ -224,6 +227,7 @@ export default function CreateApp() {
setStartCommands('');
setPm2Names('');
setPm2Status(null);
+ setNativeLaunch(null);
setIcon('package');
setAppIconPath(null);
setError(null);
@@ -407,6 +411,15 @@ export default function CreateApp() {
</p>
</div>
+ {nativeLaunch && (
+ <Banner tone="info" size="md">
+ <p className="font-medium">Separate {nativeLaunch.label} action detected</p>
+ <p className="text-xs text-gray-400 mt-1">
+ Standard Launch will keep opening the web UI. A second button will run <code>{nativeLaunch.command}</code>.
+ </p>
+ </Banner>
+ )}
+
{/* PM2 process names - only for PM2/server apps */}
{!isNonPm2 && (
<div>
diff --git a/client/src/services/apiApps.js b/client/src/services/apiApps.js
index 1737b37270..ccecb3e192 100644
--- a/client/src/services/apiApps.js
+++ b/client/src/services/apiApps.js
@@ -35,6 +35,10 @@ export const updateApp = (id, data) => request(`/apps/${id}`, {
export const deleteApp = (id) => request(`/apps/${id}`, { method: 'DELETE' });
// App actions
+export const launchNativeApp = (id, options = {}) =>
+ request(`/apps/${id}/native-launch`, { method: 'POST', ...options });
+export const getNativeLaunchStatus = (id, options = {}) =>
+ request(`/apps/${id}/native-launch/status`, options);
export const startApp = (id) => request(`/apps/${id}/start`, { method: 'POST' });
export const stopApp = (id) => request(`/apps/${id}/stop`, { method: 'POST' });
export const restartApp = (id) => request(`/apps/${id}/restart`, { method: 'POST' });
diff --git a/server/lib/validation.js b/server/lib/validation.js
index 73348f6683..528b3ae237 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -205,6 +205,12 @@ export const layeredIntelligenceSettingsSchema = z.object({
trustShellSources: z.boolean().optional()
});
+export const nativeLaunchSchema = z.object({
+ label: z.string().trim().min(1).max(40),
+ command: z.string().trim().min(1).max(500),
+ processName: z.string().regex(/^[a-zA-Z0-9._-]+$/).max(120)
+});
+
export const appSchema = z.object({
name: z.string().min(1).max(100),
repoPath: z.string().min(1),
@@ -220,6 +226,9 @@ export const appSchema = z.object({
uiUrl: z.string().url().optional(),
startCommands: z.array(z.string()).optional(),
pm2ProcessNames: z.array(z.string()).optional(),
+ // Optional native/GUI action shown alongside the standard browser Launch.
+ // Its PM2 process exits normally when the user closes the app window.
+ nativeLaunch: nativeLaunchSchema.nullable().optional(),
processes: z.array(processSchema).optional(), // Per-process port configs from ecosystem.config
envFile: z.string().optional(),
icon: z.string().nullable().optional(),
diff --git a/server/lib/validation.test.js b/server/lib/validation.test.js
index 196bbeb76f..49eb555f7f 100644
--- a/server/lib/validation.test.js
+++ b/server/lib/validation.test.js
@@ -299,6 +299,24 @@ describe('validation.js', () => {
expect(result.success).toBe(true);
});
+ it('accepts a safe native launch target and rejects an unsafe process name', () => {
+ const app = {
+ name: 'Mixed App',
+ repoPath: '/path',
+ nativeLaunch: {
+ label: 'Godot',
+ command: './scripts/game run',
+ processName: 'mixed-game'
+ }
+ };
+
+ expect(appSchema.safeParse(app).success).toBe(true);
+ expect(appSchema.safeParse({
+ ...app,
+ nativeLaunch: { ...app.nativeLaunch, processName: 'mixed game; bad' }
+ }).success).toBe(false);
+ });
+
it('should accept valid devUiPort', () => {
const app = { name: 'Test', repoPath: '/path', devUiPort: 5554 };
const result = appSchema.safeParse(app);
diff --git a/server/routes/apps/lifecycle.js b/server/routes/apps/lifecycle.js
index 6b134c6496..62fd84dc59 100644
--- a/server/routes/apps/lifecycle.js
+++ b/server/routes/apps/lifecycle.js
@@ -2,6 +2,8 @@
* App runtime lifecycle: PM2 start/stop/restart, update, build, status, logs,
* and ecosystem-config refresh.
*
+ * POST /:id/native-launch → { success, processName, result }
+ * GET /:id/native-launch/status → { processName, status }
* POST /:id/start → { success, results }
* POST /:id/stop → { success, results }
* POST /:id/restart → { success, results } (self-restart for PortOS)
@@ -31,6 +33,61 @@ const router = Router();
// Delay before restarting PortOS itself so the JSON response reaches the client
const SELF_RESTART_RESPONSE_DELAY_MS = 500;
+// POST /api/apps/:id/native-launch - Launch an optional native/GUI target
+router.post('/:id/native-launch', loadApp, asyncHandler(async (req, res) => {
+ const app = req.loadedApp;
+ const target = app.nativeLaunch;
+ if (!target) {
+ throw new ServerError('No native launch target is configured', { status: 400, code: 'NATIVE_LAUNCH_NOT_CONFIGURED' });
+ }
+ if (!await pathExists(app.repoPath)) {
+ throw new ServerError('App repo path does not exist', { status: 400, code: 'PATH_NOT_FOUND' });
+ }
+
+ const current = await pm2Service.getAppStatus(target.processName, app.pm2Home).catch(() => null);
+ if (['online', 'launching'].includes(current?.status)) {
+ return res.json({
+ success: true,
+ processName: target.processName,
+ result: { success: true, alreadyRunning: true }
+ });
+ }
+
+ const result = await pm2Service.startWithCommand(
+ target.processName,
+ app.repoPath,
+ target.command,
+ { autorestart: false }
+ ).catch(err => ({ success: false, error: err.message }));
+ const success = result.success !== false;
+ await logAction('native-launch', app.id, app.name, { processName: target.processName, label: target.label }, success);
+ notifyAppsChanged('native-launch');
+
+ if (!success) {
+ throw new ServerError(`Could not launch ${target.label}: ${result.error}`, {
+ status: 500,
+ code: 'NATIVE_LAUNCH_FAILED'
+ });
+ }
+
+ res.json({ success: true, processName: target.processName, result });
+}));
+
+// GET /api/apps/:id/native-launch/status - Read the optional target's PM2 state
+router.get('/:id/native-launch/status', loadApp, asyncHandler(async (req, res) => {
+ const app = req.loadedApp;
+ const target = app.nativeLaunch;
+ if (!target) {
+ throw new ServerError('No native launch target is configured', { status: 400, code: 'NATIVE_LAUNCH_NOT_CONFIGURED' });
+ }
+
+ const current = await pm2Service.getAppStatus(target.processName, app.pm2Home).catch(() => null);
+ res.json({
+ processName: target.processName,
+ status: current?.status || 'not_started'
+ });
+}));
+
// POST /api/apps/:id/start - Start app via PM2
router.post('/:id/start', loadApp, asyncHandler(async (req, res) => {
const app = req.loadedApp;
diff --git a/server/routes/apps/lifecycle.test.js b/server/routes/apps/lifecycle.test.js
index 3d45362869..9a36704bf7 100644
--- a/server/routes/apps/lifecycle.test.js
+++ b/server/routes/apps/lifecycle.test.js
@@ -55,6 +55,74 @@ describe('Apps Lifecycle Routes', () => {
vi.clearAllMocks();
});
+ describe('native launch target', () => {
+ const mockApp = {
+ id: 'app-001',
+ name: 'Mixed App',
+ type: 'express',
+ repoPath: '/tmp',
+ pm2ProcessNames: ['mixed-web'],
+ nativeLaunch: {
+ label: 'Godot',
+ command: './scripts/game run',
+ processName: 'mixed-game'
+ }
+ };
+
+ it('launches the native target without replacing the web lifecycle', async () => {
+ appsService.getAppById.mockResolvedValue(mockApp);
+ pm2Service.getAppStatus.mockResolvedValue({ status: 'stopped' });
+ pm2Service.startWithCommand.mockResolvedValue({ success: true });
+ history.logAction.mockResolvedValue();
+
+ const response = await request(app).post('/api/apps/app-001/native-launch');
+
+ expect(response.status).toBe(200);
+ expect(response.body.processName).toBe('mixed-game');
+ expect(pm2Service.startWithCommand).toHaveBeenCalledWith(
+ 'mixed-game', '/tmp', './scripts/game run', { autorestart: false }
+ );
+ expect(pm2Service.startFromEcosystem).not.toHaveBeenCalled();
+ expect(history.logAction).toHaveBeenCalledWith(
+ 'native-launch',
+ 'app-001',
+ 'Mixed App',
+ { processName: 'mixed-game', label: 'Godot' },
+ true
+ );
+ });
+
+ it('does not open a second native window while one is launching', async () => {
+ appsService.getAppById.mockResolvedValue(mockApp);
+ pm2Service.getAppStatus.mockResolvedValue({ status: 'launching' });
+
+ const response = await request(app).post('/api/apps/app-001/native-launch');
+
+ expect(response.status).toBe(200);
+ expect(response.body.result.alreadyRunning).toBe(true);
+ expect(pm2Service.startWithCommand).not.toHaveBeenCalled();
+ });
+
+ it('reports the native process status independently of the web app', async () => {
+ appsService.getAppById.mockResolvedValue(mockApp);
+ pm2Service.getAppStatus.mockResolvedValue({ status: 'online' });
+
+ const response = await request(app).get('/api/apps/app-001/native-launch/status');
+
+ expect(response.status).toBe(200);
+ expect(response.body).toEqual({ processName: 'mixed-game', status: 'online' });
+ });
+
+ it('rejects native launch when the app has no target', async () => {
+ appsService.getAppById.mockResolvedValue({ ...mockApp, nativeLaunch: null });
+
+ const response = await request(app).post('/api/apps/app-001/native-launch');
+
+ expect(response.status).toBe(400);
+ expect(response.body.code).toBe('NATIVE_LAUNCH_NOT_CONFIGURED');
+ });
+ });
+
describe('POST /api/apps/:id/start', () => {
it('should start an app', async () => {
const mockApp = {
diff --git a/server/services/apps.js b/server/services/apps.js
index abd19dedee..c34a83ab00 100644
--- a/server/services/apps.js
+++ b/server/services/apps.js
@@ -177,7 +177,8 @@ export async function getActiveApps() {
}
/**
- * PM2 process names belonging to desktop (portless GUI) apps.
+ * PM2 process names whose exit is expected: desktop apps and optional native
+ * launch targets attached to otherwise web-based apps.
*
* A desktop process is launched with `autorestart: false` because the user
* closing the window is a normal exit — but that alone does NOT stop every
@@ -196,8 +197,10 @@ export async function getDesktopProcessNames() {
const apps = await getAllApps();
const names = new Set();
for (const app of apps) {
- if (!isDesktopType(app.type)) continue;
- for (const name of app.pm2ProcessNames || []) names.add(name);
+ if (isDesktopType(app.type)) {
+ for (const name of app.pm2ProcessNames || []) names.add(name);
+ }
+ if (app.nativeLaunch?.processName) names.add(app.nativeLaunch.processName);
}
return names;
}
@@ -214,7 +217,10 @@ export async function getDesktopProcessNames() {
*/
export async function resolvePm2HomeForProcess(processName) {
const apps = await getAllApps();
- const app = apps.find(candidate => candidate.pm2ProcessNames?.includes(processName));
+ const app = apps.find(candidate =>
+ candidate.pm2ProcessNames?.includes(processName)
+ || candidate.nativeLaunch?.processName === processName
+ );
return app?.pm2Home || null;
}
@@ -223,10 +229,11 @@ export async function resolvePm2HomeForProcess(processName) {
* concept rather than each re-deriving it from a name set.
*
* `expectedExit: true` means "this process stopping is a normal outcome, not a
- * failure" — today that is exactly the desktop (GUI) apps, where the user
- * closing the window ends the process (cleanly as `stopped`, or as `errored`
- * on a force-quit / non-zero exit). Consumers that auto-restart or alert on
- * `errored` must skip these. Current consumers:
+ * failure" — today that covers desktop (GUI) app processes and the optional
+ * native launch targets attached to web apps. The user closing either window
+ * ends its process (cleanly as `stopped`, or as `errored` on a force-quit /
+ * non-zero exit). Consumers that auto-restart or alert on `errored` must skip
+ * these. Current consumers:
* - services/cosHealthMonitor.js — auto-restarts errored processes
* - services/proactiveAlerts.js — alerts on errored / crash-looping processes
* - routes/systemHealth.js — drives overallHealth + the dashboard/city HUD
@@ -385,6 +392,7 @@ export async function createApp(appData) {
buildCommand: appData.buildCommand || undefined,
startCommands: appData.startCommands || ['npm run dev'],
pm2ProcessNames: appData.pm2ProcessNames || [appData.name.toLowerCase().replace(/\s+/g, '-')],
+ nativeLaunch: appData.nativeLaunch || null,
envFile: appData.envFile || '.env',
icon: appData.icon || null,
appIconPath: appData.appIconPath || null,
diff --git a/server/services/apps.test.js b/server/services/apps.test.js
index a10315eb68..9ae9d79385 100644
--- a/server/services/apps.test.js
+++ b/server/services/apps.test.js
@@ -227,6 +227,32 @@ describe('portless / desktop apps (#2991)', () => {
expect(stored.devUiPort).toBeNull();
});
+ it('createApp preserves web ports when a separate native target is present', async () => {
+ readJSONFile.mockResolvedValue({ apps: { [PORTOS_APP_ID]: { name: 'PortOS' } } });
+ const nativeLaunch = {
+ label: 'Godot',
+ command: './scripts/game run',
+ processName: 'mixed-game',
+ };
+
+ const created = await createApp({
+ name: 'Mixed App',
+ repoPath: '/tmp/mixed-app',
+ type: 'express',
+ uiPort: 3000,
+ pm2ProcessNames: ['mixed-web'],
+ nativeLaunch,
+ });
+
+ expect(created).toMatchObject({
+ type: 'express',
+ uiPort: 3000,
+ pm2ProcessNames: ['mixed-web'],
+ nativeLaunch,
+ });
+ expect(atomicWrite.mock.calls.at(-1)?.[1].apps[created.id].nativeLaunch).toEqual(nativeLaunch);
+ });
+
it('reports a portless desktop app from supervisor state alone (no HTTP probe)', async () => {
readJSONFile.mockResolvedValue({
apps: {
@@ -287,7 +313,23 @@ describe('portless / desktop apps (#2991)', () => {
expect(names.has('portos-server')).toBe(false);
});
- it('is empty when no desktop app is registered', async () => {
+ it('also exempts a native target attached to a web app', async () => {
+ readJSONFile.mockResolvedValue({
+ apps: {
+ [PORTOS_APP_ID]: { name: 'PortOS', type: 'express', pm2ProcessNames: ['portos-server'] },
+ mixed: {
+ name: 'Mixed App',
+ type: 'express',
+ pm2ProcessNames: ['mixed-web'],
+ nativeLaunch: { label: 'Godot', command: './scripts/game run', processName: 'mixed-game' }
+ },
+ },
+ });
+
+ expect(await getDesktopProcessNames()).toEqual(new Set(['mixed-game']));
+ });
+
+ it('is empty when no desktop app or native target is registered', async () => {
readJSONFile.mockResolvedValue({
apps: { [PORTOS_APP_ID]: { name: 'PortOS', type: 'express', pm2ProcessNames: ['portos-server'] } },
});
@@ -385,6 +427,21 @@ describe('resolvePm2HomeForProcess', () => {
await expect(resolvePm2HomeForProcess('example-api')).resolves.toBe('/tmp/example-pm2');
});
+ it('resolves the custom home for an app native launch process', async () => {
+ readJSONFile.mockResolvedValue({
+ apps: {
+ [PORTOS_APP_ID]: { name: 'PortOS', type: 'express' },
+ mixed: {
+ name: 'Mixed App',
+ pm2Home: '/tmp/example-pm2',
+ nativeLaunch: { label: 'Godot', command: './scripts/game run', processName: 'mixed-game' }
+ },
+ },
+ });
+
+ await expect(resolvePm2HomeForProcess('mixed-game')).resolves.toBe('/tmp/example-pm2');
+ });
+
it('returns null when the matching app uses the default PM2 home', async () => {
readJSONFile.mockResolvedValue({
apps: {
diff --git a/server/services/streamingDetect.js b/server/services/streamingDetect.js
index 425a4559a8..0443786bc6 100644
--- a/server/services/streamingDetect.js
+++ b/server/services/streamingDetect.js
@@ -1,6 +1,6 @@
import { readFile, readdir, stat } from 'fs/promises';
import { existsSync } from 'fs';
-import { join, basename } from 'path';
+import { join, basename, dirname } from 'path';
import { homedir } from 'os';
import { execPm2 } from './pm2.js';
import { safeJSONParse, tryReadFile, atomicWrite } from '../lib/fileUtils.js';
@@ -22,6 +22,40 @@ export const DESKTOP_TYPES = new Set(['desktop']);
/** Check if an app type is a portless GUI/desktop process. */
export const isDesktopType = (type) => DESKTOP_TYPES.has(type);
+/**
+ * Detect an optional native Godot launch target alongside the repo's normal
+ * web-process configuration.
+ *
+ * Mixed repos keep their ecosystem/Vite ports as the standard browser Launch,
+ * while this target opens the game through a separate autorestart-off process.
+ */
+export function detectGodotNativeLaunch(dirPath) {
+ const launcherPath = join(dirPath, 'scripts', 'game');
+ const hasLauncher = existsSync(launcherPath);
+ let projectPath = null;
+ if (existsSync(join(dirPath, 'project.godot'))) {
+ projectPath = 'project.godot';
+ } else if (hasLauncher && existsSync(join(dirPath, 'game', 'project.godot'))) {
+ projectPath = join('game', 'project.godot');
+ }
+ if (!projectPath) return null;
+
+ const projectDir = dirname(projectPath);
+ const slug = basename(dirPath)
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
+ .toLowerCase()
+ .replace(/[^a-z0-9]+/g, '-')
+ .replace(/^-|-$/g, '');
+
+ return {
+ label: 'Godot',
+ command: hasLauncher
+ ? './scripts/game run'
+ : `godot --path ${projectDir === '.' ? '.' : projectDir}`,
+ processName: `${slug || 'godot'}-game`
+ };
+}
+
/**
* Ecosystem config filenames in the order they're resolved. The READER
* (parseEcosystemFromPath) and the WRITER (writeEcosystemPorts) must agree on
@@ -1043,6 +1077,7 @@ export async function streamDetection(socket, dirPath) {
processes: [],
pm2Home: null,
type: 'unknown',
+ nativeLaunch: null,
appIconPath: null
};
@@ -1070,6 +1105,7 @@ export async function streamDetection(socket, dirPath) {
const entries = await readdir(dirPath, { withFileTypes: true }).catch(() => []);
const files = entries.map(e => e.name);
emit('files', 'done', { message: `Found ${files.length} files`, files: files.slice(0, 20) });
+ const godotNativeLaunch = detectGodotNativeLaunch(dirPath);
// Detect Swift/Xcode projects from directory contents
const hasXcodeproj = files.some(f => f.endsWith('.xcodeproj') || f.endsWith('.xcworkspace'));
@@ -1158,6 +1194,10 @@ export async function streamDetection(socket, dirPath) {
emit('package', 'done', { message: 'No package.json found' });
}
+ // Native game launch is additive: web ports/processes remain the standard
+ // managed app while the game gets its own explicit action.
+ if (godotNativeLaunch) result.nativeLaunch = godotNativeLaunch;
+
// Step 4: Check config files for ports
emit('config', 'running', { message: 'Checking configuration files...' });
const configFiles = [];
diff --git a/server/services/streamingDetect.test.js b/server/services/streamingDetect.test.js
index 2263a753ca..e73a7cd7af 100644
--- a/server/services/streamingDetect.test.js
+++ b/server/services/streamingDetect.test.js
@@ -1,8 +1,39 @@
import { describe, it, expect, afterEach } from 'vitest';
-import { mkdtempSync, writeFileSync, readFileSync, rmSync } from 'fs';
+import { mkdirSync, mkdtempSync, writeFileSync, readFileSync, rmSync } from 'fs';
import { tmpdir } from 'os';
import { join } from 'path';
-import { parseEcosystemConfig, rewriteEcosystemPorts, rewriteEcosystemPortsByProcess, writeEcosystemPorts, writeEcosystemPortsByProcess, writeEcosystemPortEdits, DESKTOP_TYPES, NON_PM2_TYPES } from './streamingDetect.js';
+import { detectGodotNativeLaunch, parseEcosystemConfig, rewriteEcosystemPorts, rewriteEcosystemPortsByProcess, writeEcosystemPorts, writeEcosystemPortsByProcess, writeEcosystemPortEdits, DESKTOP_TYPES, NON_PM2_TYPES } from './streamingDetect.js';
+
+describe('detectGodotNativeLaunch', () => {
+ let dir;
+ afterEach(() => { if (dir) rmSync(dir, { recursive: true, force: true }); dir = null; });
+
+ it('prefers the repo game launcher for a nested Godot project', () => {
+ dir = mkdtempSync(join(tmpdir(), 'godot-desktop-'));
+ const appDir = join(dir, 'ExampleProject');
+ mkdirSync(join(appDir, 'game'), { recursive: true });
+ mkdirSync(join(appDir, 'scripts'), { recursive: true });
+ writeFileSync(join(appDir, 'game', 'project.godot'), '[application]\n');
+ writeFileSync(join(appDir, 'scripts', 'game'), '#!/usr/bin/env bash\n');
+
+ expect(detectGodotNativeLaunch(appDir)).toEqual({
+ label: 'Godot',
+ command: './scripts/game run',
+ processName: 'example-project-game'
+ });
+ });
+
+ it('falls back for a root Godot project without misclassifying an unlaunched nested demo', () => {
+ dir = mkdtempSync(join(tmpdir(), 'godot-fallback-'));
+ writeFileSync(join(dir, 'project.godot'), '[application]\n');
+
+ expect(detectGodotNativeLaunch(dir)?.command).toBe('godot --path .');
+ rmSync(join(dir, 'project.godot'));
+ mkdirSync(join(dir, 'game'), { recursive: true });
+ writeFileSync(join(dir, 'game', 'project.godot'), '[application]\n');
+ expect(detectGodotNativeLaunch(dir)).toBeNull();
+ });
+});
describe('parseEcosystemConfig', () => {
it('captures arbitrary *_PORT env vars and labels them by camelCased stem', () => {