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(apps): app icon detection, alphabetical sorting, and icon display

Adam Eivy21ec6e118299
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 5b022fa79b..1b866d2354 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -7,6 +7,8 @@
- **POST Deep Routes & Elements Expansion** — POST section now uses deep-linkable routes (`/post/launcher`, `/post/memory`, `/post/history`, `/post/config`, `/post/memory/elements`) instead of internal state switching. Sidebar nav expanded to collapsible section with sub-pages. Added 16 missing elements (103-118, Lawrencium through Oganesson) to the periodic table and element map. New appendix verse set for memorizing the post-Lehrer elements. Fixed missing Mercury (Hg) in periodic table grid. Period 7 now shows all elements. Interactive periodic table with hover tooltips, click-to-highlight verse, search filter, mastery/category view toggle, and element category color coding.
+- **App Icon Detection** — Apps can now display their actual project icon (favicon, Xcode AppIcon, etc.) instead of generic SVG icons. Auto-detects icons from well-known paths during app import and config refresh. Supports Xcode/iOS AppIcon.appiconset, web favicons, logos, and common icon locations. Icon served via `GET /api/apps/:id/icon` with fallback to SVG icons. Bulk "Detect Icons" button on Apps page. Apps sorted alphabetically on both Dashboard and Apps pages. App icons shown in Apps list rows.
+
## Changed
- **CoS feature-ideas task** — Agents now implement the next unchecked PLAN.md item instead of inventing features. When user clarification is needed, agents create a `.plan-questions.md` marker and a `plan_question` notification linking to the Documents tab. Added `{appId}` template variable for prompt linking.
diff --git a/client/src/components/AppIcon.jsx b/client/src/components/AppIcon.jsx
index 5f0c57d38e..bcd2ae3b8f 100644
--- a/client/src/components/AppIcon.jsx
+++ b/client/src/components/AppIcon.jsx
@@ -1,6 +1,8 @@
// App icons - SVG icons for different app types
// Each icon follows the 24x24 viewBox pattern used by lucide-react
+import { useState } from 'react';
+
const icons = {
// PortOS - portal/gateway logo (from Logo.jsx)
portos: ({ size, className }) => (
@@ -166,10 +168,42 @@ const icons = {
// List of available icon names for the picker
export const iconNames = Object.keys(icons);
-export default function AppIcon({ icon, size = 24, className = '', ariaLabel }) {
+/**
+ * Construct the API URL for an app's icon image.
+ * Uses window.location to work across Tailscale.
+ */
+function getAppIconUrl(appId) {
+ const protocol = window.location.protocol;
+ const hostname = window.location.hostname;
+ const port = window.location.port;
+ const base = port ? `${protocol}//${hostname}:${port}` : `${protocol}//${hostname}`;
+ return `${base}/api/apps/${appId}/icon`;
+}
+
+export default function AppIcon({ icon, appId, hasAppIcon, size = 24, className = '', ariaLabel }) {
+ const [imgError, setImgError] = useState(false);
+
+ // Show real app icon image if the app has one detected
+ // Image fills its parent container completely (parent controls size)
+ if (hasAppIcon && appId && !imgError) {
+ const imgEl = (
+ <img
+ src={getAppIconUrl(appId)}
+ alt={ariaLabel || ''}
+ className={`w-full h-full rounded object-cover ${className}`}
+ onError={() => setImgError(true)}
+ />
+ );
+
+ if (ariaLabel) {
+ return <span role="img" aria-label={ariaLabel}>{imgEl}</span>;
+ }
+ return <span aria-hidden="true">{imgEl}</span>;
+ }
+
+ // Fall back to SVG icon
const IconComponent = icons[icon] || icons.package;
- // If ariaLabel is provided, make it accessible; otherwise treat as decorative
if (ariaLabel) {
return (
<span role="img" aria-label={ariaLabel}>
@@ -178,7 +212,6 @@ export default function AppIcon({ icon, size = 24, className = '', ariaLabel })
);
}
- // Decorative icon - hidden from assistive technology
return (
<span aria-hidden="true">
<IconComponent size={size} className={className} />
diff --git a/client/src/components/AppTile.jsx b/client/src/components/AppTile.jsx
index 6d9178a85a..147536e70d 100644
--- a/client/src/components/AppTile.jsx
+++ b/client/src/components/AppTile.jsx
@@ -50,10 +50,10 @@ const AppTile = memo(function AppTile({ app, onUpdate }) {
{/* Header */}
<div className="flex items-start justify-between mb-2">
<div className="flex items-center gap-2 min-w-0">
- <div className={`w-8 h-8 rounded shrink-0 flex items-center justify-center ${
- app.archived ? 'bg-port-border/50 text-gray-500' : 'bg-port-border text-port-accent'
+ <div className={`w-8 h-8 rounded shrink-0 overflow-hidden ${
+ app.appIconPath ? '' : `flex items-center justify-center ${app.archived ? 'bg-port-border/50 text-gray-500' : 'bg-port-border text-port-accent'}`
}`} aria-hidden="true">
- <AppIcon icon={app.icon || 'package'} size={18} />
+ <AppIcon icon={app.icon || 'package'} appId={app.id} hasAppIcon={!!app.appIconPath} size={18} />
</div>
<div className="min-w-0">
<div className="flex items-center gap-1.5">
diff --git a/client/src/components/cos/tabs/ScheduleTab.jsx b/client/src/components/cos/tabs/ScheduleTab.jsx
index 2f9d07e1ad..0f653e0ea2 100644
--- a/client/src/components/cos/tabs/ScheduleTab.jsx
+++ b/client/src/components/cos/tabs/ScheduleTab.jsx
@@ -503,7 +503,7 @@ function AppOverrideRow({ app, taskType, globalIntervalType, globalTaskMetadata,
return (
<div className="flex items-center gap-3 py-2 px-3 rounded hover:bg-port-card/30">
<div className="flex items-center gap-2 min-w-0 flex-1">
- <AppIcon icon={app.icon || 'package'} size={16} className="text-gray-400 shrink-0" />
+ <AppIcon icon={app.icon || 'package'} appId={app.id} hasAppIcon={!!app.appIconPath} size={16} className="text-gray-400 shrink-0" />
<span className="text-sm text-white truncate">{app.name}</span>
</div>
diff --git a/client/src/components/instances/PeerAppsList.jsx b/client/src/components/instances/PeerAppsList.jsx
index 652c1c72b6..2e20d01e5e 100644
--- a/client/src/components/instances/PeerAppsList.jsx
+++ b/client/src/components/instances/PeerAppsList.jsx
@@ -10,7 +10,7 @@ export default function PeerAppsList({ apps, peerAddress }) {
<div className="space-y-1">
{apps.map(app => (
<div key={app.id} className="flex items-center gap-2 text-xs">
- <AppIcon icon={app.icon || 'package'} size={14} className="text-gray-400 shrink-0" />
+ <AppIcon icon={app.icon || 'package'} appId={app.id} hasAppIcon={!!app.appIconPath} size={14} className="text-gray-400 shrink-0" />
{app.uiPort && app.overallStatus === 'online' ? (
<a
href={`http://${peerAddress}:${app.uiPort}`}
diff --git a/client/src/pages/Apps.jsx b/client/src/pages/Apps.jsx
index 1210471bfb..6beb710431 100644
--- a/client/src/pages/Apps.jsx
+++ b/client/src/pages/Apps.jsx
@@ -1,7 +1,8 @@
import { useState, useEffect, useCallback } from 'react';
import { Link } from 'react-router-dom';
-import { ExternalLink, Play, Square, RotateCcw, FolderOpen, Terminal, Code, RefreshCw, Wrench, Archive, ArchiveRestore, ChevronDown, ChevronUp, Ticket, GitBranch, Download, Hammer, Smartphone } from 'lucide-react';
+import { ExternalLink, Play, Square, RotateCcw, FolderOpen, Terminal, Code, RefreshCw, Wrench, Archive, ArchiveRestore, ChevronDown, ChevronUp, Ticket, GitBranch, Download, Hammer, Smartphone, Image } from 'lucide-react';
import toast from 'react-hot-toast';
+import AppIcon from '../components/AppIcon';
import BrailleSpinner from '../components/BrailleSpinner';
import KanbanBoard from '../components/KanbanBoard';
import StatusBadge from '../components/StatusBadge';
@@ -128,10 +129,21 @@ export default function Apps() {
toast.success(`${app.name} unarchived - included in COS tasks`);
};
+ const [detectingIcons, setDetectingIcons] = useState(false);
+ const handleDetectIcons = async () => {
+ setDetectingIcons(true);
+ const result = await api.detectAppIcons().catch(() => null);
+ setDetectingIcons(false);
+ if (result) {
+ toast.success(`Detected icons for ${result.detected} of ${result.total} apps`);
+ }
+ };
+
// Filter apps based on archive status
const activeApps = apps.filter(app => !app.archived);
const archivedApps = apps.filter(app => app.archived);
- const displayedApps = showArchived ? archivedApps : activeApps;
+ const displayedApps = (showArchived ? archivedApps : activeApps)
+ .slice().sort((a, b) => a.name.localeCompare(b.name));
if (loading) {
return (
@@ -150,6 +162,15 @@ export default function Apps() {
<p className="text-gray-500 text-sm sm:text-base">Manage registered applications</p>
</div>
<div className="flex items-center gap-3">
+ <button
+ onClick={handleDetectIcons}
+ disabled={detectingIcons}
+ className="px-3 py-2 rounded-lg text-sm flex items-center gap-2 bg-port-border text-gray-400 hover:text-white transition-colors disabled:opacity-50"
+ title="Detect app icons from project directories"
+ >
+ <Image size={16} />
+ {detectingIcons ? 'Detecting...' : 'Detect Icons'}
+ </button>
{/* Archive Toggle */}
{archivedApps.length > 0 && (
<button
@@ -214,6 +235,11 @@ export default function Apps() {
>
<span aria-hidden="true" className={`inline-block transition-transform ${expandedId === app.id ? 'rotate-90' : ''}`}>▶</span>
</button>
+ <div className={`w-8 h-8 rounded shrink-0 overflow-hidden ${
+ app.appIconPath ? '' : `flex items-center justify-center ${app.archived ? 'bg-port-border/50 text-gray-500' : 'bg-port-border text-port-accent'}`
+ }`}>
+ <AppIcon icon={app.icon || 'package'} appId={app.id} hasAppIcon={!!app.appIconPath} size={18} />
+ </div>
<div className="min-w-0 flex-1">
<div className="flex flex-wrap items-center gap-2">
<Link to={`/apps/${app.id}`} className={`font-medium hover:underline ${app.archived ? 'text-gray-400' : 'text-white'}`}>{app.name}</Link>
diff --git a/client/src/pages/CreateApp.jsx b/client/src/pages/CreateApp.jsx
index 35ebc02072..b166a78c65 100644
--- a/client/src/pages/CreateApp.jsx
+++ b/client/src/pages/CreateApp.jsx
@@ -17,6 +17,7 @@ const DETECTION_STEPS_PM2 = [
{ id: 'config', label: 'Checking configs' },
{ id: 'pm2', label: 'Checking PM2' },
{ id: 'readme', label: 'Reading README' },
+ { id: 'icon', label: 'Detecting app icon' },
{ id: 'standardize', label: 'Standardizing PM2 config' }
];
@@ -25,7 +26,8 @@ const DETECTION_STEPS_NON_PM2 = [
{ id: 'files', label: 'Scanning files' },
{ id: 'package', label: 'Reading project config' },
{ id: 'config', label: 'Checking configs' },
- { id: 'readme', label: 'Reading README' }
+ { id: 'readme', label: 'Reading README' },
+ { id: 'icon', label: 'Detecting app icon' }
];
export default function CreateApp() {
@@ -52,6 +54,7 @@ export default function CreateApp() {
const [pm2Names, setPm2Names] = useState('');
const [pm2Status, setPm2Status] = useState(null);
const [icon, setIcon] = useState('package');
+ const [appIconPath, setAppIconPath] = useState(null);
const [appType, setAppType] = useState('unknown');
// Submit state
@@ -116,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(', '));
+ if (result.appIconPath) setAppIconPath(result.appIconPath);
} else if (err) {
setError(err);
}
@@ -185,6 +189,7 @@ export default function CreateApp() {
repoPath,
type: appType !== 'unknown' ? appType : undefined,
icon,
+ appIconPath: appIconPath || undefined,
uiPort: uiPort ? parseInt(uiPort, 10) : null,
devUiPort: devUiPort ? parseInt(devUiPort, 10) : null,
apiPort: apiPort ? parseInt(apiPort, 10) : null,
@@ -221,6 +226,7 @@ export default function CreateApp() {
setPm2Names('');
setPm2Status(null);
setIcon('package');
+ setAppIconPath(null);
setError(null);
setStandardizing(false);
setStandardizeResult(null);
diff --git a/client/src/pages/Dashboard.jsx b/client/src/pages/Dashboard.jsx
index 4c2b490494..00a16db176 100644
--- a/client/src/pages/Dashboard.jsx
+++ b/client/src/pages/Dashboard.jsx
@@ -48,9 +48,13 @@ export default function Dashboard() {
};
}, [fetchData]);
- // Sort apps: active first, archived last
+ // Sort apps: active first, archived last, alphabetical within each group
const sortedApps = useMemo(() =>
- [...apps].sort((a, b) => (a.archived ? 1 : 0) - (b.archived ? 1 : 0)),
+ [...apps].sort((a, b) => {
+ const archiveDiff = (a.archived ? 1 : 0) - (b.archived ? 1 : 0);
+ if (archiveDiff !== 0) return archiveDiff;
+ return a.name.localeCompare(b.name);
+ }),
[apps]
);
diff --git a/client/src/services/api.js b/client/src/services/api.js
index c008f614f2..2ad6fa3b65 100644
--- a/client/src/services/api.js
+++ b/client/src/services/api.js
@@ -157,6 +157,7 @@ export const bulkUpdateAppTaskTypeOverride = (taskType, { enabled }) => request(
method: 'PUT',
body: JSON.stringify({ enabled })
});
+export const detectAppIcons = () => request('/apps/detect-icons', { method: 'POST' });
export const getAppLogs = (id, lines = 100, processName) => {
const params = new URLSearchParams({ lines: String(lines) });
if (processName) params.set('process', processName);
diff --git a/server/lib/validation.js b/server/lib/validation.js
index 01d833cf71..3989703603 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -187,6 +187,7 @@ export const appSchema = z.object({
processes: z.array(processSchema).optional(), // Per-process port configs from ecosystem.config
envFile: z.string().optional(),
icon: z.string().nullable().optional(),
+ appIconPath: z.string().nullable().optional(), // Absolute path to detected app icon image
editorCommand: z.string().optional(),
description: z.string().optional(),
archived: z.boolean().optional().default(false),
diff --git a/server/routes/apps.js b/server/routes/apps.js
index 546663d693..686bbd1913 100644
--- a/server/routes/apps.js
+++ b/server/routes/apps.js
@@ -15,6 +15,7 @@ import * as git from '../services/git.js';
import { asyncHandler, ServerError } from '../lib/errorHandler.js';
import { safeJSONParse } from '../lib/fileUtils.js';
import { parseEcosystemFromPath, usesPm2 } from '../services/streamingDetect.js';
+import { detectAppIcon, getIconContentType } from '../services/appIconDetect.js';
const router = Router();
@@ -182,6 +183,31 @@ router.get('/:id', loadApp, asyncHandler(async (req, res) => {
res.json({ ...app, uiPort, devUiPort, apiPort, overallStatus, pm2Status: statuses, appVersion });
}));
+// GET /api/apps/:id/icon - Serve the app's detected icon image
+router.get('/:id/icon', loadApp, asyncHandler(async (req, res) => {
+ const app = req.loadedApp;
+
+ // Use stored appIconPath, or detect on-the-fly
+ let iconPath = app.appIconPath;
+ if (!iconPath || !existsSync(iconPath)) {
+ iconPath = await detectAppIcon(app.repoPath, app.type);
+ // Persist the detected path for future requests
+ if (iconPath && iconPath !== app.appIconPath) {
+ await appsService.updateApp(app.id, { appIconPath: iconPath });
+ }
+ }
+
+ if (!iconPath || !existsSync(iconPath)) {
+ return res.status(404).json({ error: 'No app icon found' });
+ }
+
+ const contentType = getIconContentType(iconPath);
+ const iconData = await readFile(iconPath);
+ res.set('Content-Type', contentType);
+ res.set('Cache-Control', 'public, max-age=3600');
+ res.send(iconData);
+}));
+
// POST /api/apps - Create new app
router.post('/', asyncHandler(async (req, res, next) => {
const data = validateRequest(appSchema, req.body);
@@ -258,6 +284,29 @@ router.put('/bulk-task-type/:taskType', asyncHandler(async (req, res) => {
res.json({ success: true, taskType: req.params.taskType, enabled, appsUpdated: result.count });
}));
+// POST /api/apps/detect-icons - Detect and persist app icons for all apps
+router.post('/detect-icons', asyncHandler(async (req, res) => {
+ const apps = await appsService.getAllApps();
+ let detected = 0;
+
+ for (const app of apps) {
+ if (!app.repoPath || !existsSync(app.repoPath)) continue;
+ // Skip apps that already have a valid icon path
+ if (app.appIconPath && existsSync(app.appIconPath)) continue;
+
+ const iconPath = await detectAppIcon(app.repoPath, app.type);
+ if (iconPath) {
+ await appsService.updateApp(app.id, { appIconPath: iconPath });
+ detected++;
+ console.log(`🎨 Detected icon for ${app.name}: ${iconPath.split('/').pop()}`);
+ }
+ }
+
+ if (detected > 0) notifyAppsChanged('detect-icons');
+ console.log(`🎨 Icon detection complete: ${detected}/${apps.length} apps`);
+ res.json({ success: true, detected, total: apps.length });
+}));
+
// GET /api/apps/:id/task-types - Get per-app task type overrides
router.get('/:id/task-types', loadApp, asyncHandler(async (req, res) => {
const app = req.loadedApp;
@@ -754,6 +803,12 @@ router.post('/:id/refresh-config', loadApp, asyncHandler(async (req, res) => {
updates.uiPort = deriveUiPort(updates.uiPort, updates.apiPort, updates.devUiPort || app.devUiPort);
}
+ // Detect app icon if not already set
+ if (!app.appIconPath || !existsSync(app.appIconPath)) {
+ const detectedIcon = await detectAppIcon(app.repoPath, app.type);
+ if (detectedIcon) updates.appIconPath = detectedIcon;
+ }
+
// Only update if we have changes
if (Object.keys(updates).length > 0) {
const updatedApp = await appsService.updateApp(req.params.id, updates);
diff --git a/server/services/appIconDetect.js b/server/services/appIconDetect.js
new file mode 100644
index 0000000000..b33bdb68ee
--- /dev/null
+++ b/server/services/appIconDetect.js
@@ -0,0 +1,187 @@
+import { existsSync } from 'fs';
+import { readFile, readdir } from 'fs/promises';
+import { join, extname } from 'path';
+
+/**
+ * Well-known icon paths to check, ordered by priority.
+ * Paths are relative to the app's repoPath.
+ */
+const ICON_SEARCH_PATHS = [
+ // Web app favicons/logos
+ 'public/favicon.svg',
+ 'public/favicon.png',
+ 'public/favicon.ico',
+ 'public/logo.svg',
+ 'public/logo.png',
+ 'public/icon.svg',
+ 'public/icon.png',
+ 'public/logo192.png',
+ 'public/logo512.png',
+ 'client/public/favicon.svg',
+ 'client/public/favicon.png',
+ 'client/public/favicon.ico',
+ 'client/public/logo.svg',
+ 'client/public/logo.png',
+ 'client/public/logo192.png',
+ 'client/public/logo512.png',
+ 'static/favicon.svg',
+ 'static/favicon.png',
+ 'static/favicon.ico',
+ // Electron / desktop
+ 'build/icon.png',
+ 'resources/icon.png',
+ 'resources/icon.icns',
+ // Root-level
+ 'icon.png',
+ 'icon.svg',
+ 'logo.png',
+ 'logo.svg',
+];
+
+const CONTENT_TYPES = {
+ '.png': 'image/png',
+ '.jpg': 'image/jpeg',
+ '.jpeg': 'image/jpeg',
+ '.svg': 'image/svg+xml',
+ '.ico': 'image/x-icon',
+ '.icns': 'image/x-icns',
+ '.webp': 'image/webp',
+};
+
+/**
+ * Find the best Xcode AppIcon image from an asset catalog.
+ * Looks for the largest available PNG in the appiconset.
+ * @param {string} repoPath
+ * @returns {Promise<string|null>} Relative path to the icon, or null
+ */
+async function findXcodeAppIcon(repoPath) {
+ // Common locations for Assets.xcassets
+ const assetDirs = [
+ '', // root
+ ];
+
+ // First, find all .xcassets directories
+ const entries = await readdir(repoPath, { withFileTypes: true }).catch(() => []);
+ for (const entry of entries) {
+ if (entry.isDirectory()) {
+ assetDirs.push(entry.name);
+ }
+ }
+
+ for (const dir of assetDirs) {
+ const base = dir ? join(repoPath, dir) : repoPath;
+
+ // Check for Assets.xcassets/AppIcon.appiconset
+ const appIconSetPaths = [
+ join(base, 'Assets.xcassets', 'AppIcon.appiconset'),
+ // Some projects nest assets inside a subfolder matching the app name
+ ];
+
+ // Also scan one level deeper for nested project structures
+ if (dir) {
+ const subEntries = await readdir(base, { withFileTypes: true }).catch(() => []);
+ for (const sub of subEntries) {
+ if (sub.isDirectory() && sub.name === 'Assets.xcassets') {
+ appIconSetPaths.push(join(base, 'Assets.xcassets', 'AppIcon.appiconset'));
+ }
+ if (sub.isDirectory()) {
+ appIconSetPaths.push(join(base, sub.name, 'Assets.xcassets', 'AppIcon.appiconset'));
+ }
+ }
+ }
+
+ for (const iconSetPath of appIconSetPaths) {
+ if (!existsSync(iconSetPath)) continue;
+
+ // Read Contents.json to find actual icon filenames and sizes
+ const contentsPath = join(iconSetPath, 'Contents.json');
+ if (existsSync(contentsPath)) {
+ const contents = await readFile(contentsPath, 'utf-8').catch(() => null);
+ if (contents) {
+ const parsed = JSON.parse(contents).images || [];
+ // Find the largest icon by parsing size (prefer 1024x1024, then smaller)
+ let bestIcon = null;
+ let bestSize = 0;
+
+ for (const img of parsed) {
+ if (!img.filename) continue;
+ const filePath = join(iconSetPath, img.filename);
+ if (!existsSync(filePath)) continue;
+
+ // Parse size from the "size" field (e.g., "1024x1024")
+ const sizeMatch = img.size?.match(/(\d+)x(\d+)/);
+ const scale = parseFloat(img.scale) || 1;
+ const size = sizeMatch ? parseInt(sizeMatch[1]) * scale : 0;
+
+ if (size > bestSize) {
+ bestSize = size;
+ bestIcon = filePath;
+ }
+ }
+
+ // If Contents.json didn't yield results, fall back to scanning files
+ if (!bestIcon) {
+ const files = await readdir(iconSetPath).catch(() => []);
+ const pngs = files.filter(f => f.endsWith('.png')).sort().reverse();
+ if (pngs.length > 0) {
+ bestIcon = join(iconSetPath, pngs[0]);
+ }
+ }
+
+ if (bestIcon) return bestIcon;
+ }
+ }
+
+ // Fallback: just grab the largest PNG by filename
+ const files = await readdir(iconSetPath).catch(() => []);
+ const pngs = files.filter(f => f.endsWith('.png')).sort().reverse();
+ if (pngs.length > 0) {
+ return join(iconSetPath, pngs[0]);
+ }
+ }
+ }
+
+ return null;
+}
+
+/**
+ * Detect the app icon path for a given project directory.
+ * Returns the absolute path to the icon file, or null if none found.
+ * @param {string} repoPath - Absolute path to the app's repository
+ * @param {string} [appType] - Optional app type hint (ios-native, xcode, etc.)
+ * @returns {Promise<string|null>}
+ */
+export async function detectAppIcon(repoPath, appType) {
+ if (!repoPath || !existsSync(repoPath)) return null;
+
+ // For Xcode/iOS projects, check AppIcon.appiconset first
+ if (['ios-native', 'macos-native', 'xcode', 'swift'].includes(appType)) {
+ const xcodeIcon = await findXcodeAppIcon(repoPath);
+ if (xcodeIcon) return xcodeIcon;
+ }
+
+ // Check well-known paths
+ for (const relPath of ICON_SEARCH_PATHS) {
+ const fullPath = join(repoPath, relPath);
+ if (existsSync(fullPath)) return fullPath;
+ }
+
+ // For any project type, also try Xcode icon detection as a fallback
+ // (some monorepos might have an iOS subfolder)
+ if (!['ios-native', 'macos-native', 'xcode', 'swift'].includes(appType)) {
+ const xcodeIcon = await findXcodeAppIcon(repoPath);
+ if (xcodeIcon) return xcodeIcon;
+ }
+
+ return null;
+}
+
+/**
+ * Get the content type for an icon file based on its extension.
+ * @param {string} filePath
+ * @returns {string}
+ */
+export function getIconContentType(filePath) {
+ const ext = extname(filePath).toLowerCase();
+ return CONTENT_TYPES[ext] || 'application/octet-stream';
+}
diff --git a/server/services/streamingDetect.js b/server/services/streamingDetect.js
index bd93cab84c..17788632e4 100644
--- a/server/services/streamingDetect.js
+++ b/server/services/streamingDetect.js
@@ -4,6 +4,7 @@ import { join, basename } from 'path';
import { homedir } from 'os';
import { execPm2 } from './pm2.js';
import { safeJSONParse } from '../lib/fileUtils.js';
+import { detectAppIcon } from './appIconDetect.js';
/** App types that do not use PM2 for process management */
export const NON_PM2_TYPES = new Set(['ios-native', 'macos-native', 'xcode', 'swift']);
@@ -371,7 +372,8 @@ export async function streamDetection(socket, dirPath) {
pm2Status: null,
processes: [],
pm2Home: null,
- type: 'unknown'
+ type: 'unknown',
+ appIconPath: null
};
// Step 1: Validate path
@@ -678,6 +680,16 @@ export async function streamDetection(socket, dirPath) {
emit('readme', 'skipped', { message: 'Description already found in package.json' });
}
+ // Step 7: Detect app icon
+ emit('icon', 'running', { message: 'Looking for app icon...' });
+ const detectedIcon = await detectAppIcon(dirPath, result.type);
+ if (detectedIcon) {
+ result.appIconPath = detectedIcon;
+ emit('icon', 'done', { message: `Found: ${basename(detectedIcon)}`, appIconPath: detectedIcon });
+ } else {
+ emit('icon', 'done', { message: 'No app icon found' });
+ }
+
// Complete
socket.emit('detect:complete', {
success: true,