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(submodules): add submodule management page and auto-update in update scripts

Adam Eivyaec0ab61ff10
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index a9e9fd2f5c..a3db96a45a 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -2,6 +2,8 @@
## Added
+- Submodules management page under Dev Tools — view status, check for updates, and update individual or all git submodules from the dashboard
+- Update scripts (`update.sh`, `update.ps1`) now auto-update submodules (including slash-do) during PortOS updates
- Slash-do agent operations panel on app detail Overview tab — buttons for `/do:push`, `/do:review`, `/do:release`, `/do:better`, and `/do:better-swift` that queue CoS agent tasks with the full command instructions
- Multi-line task context now renders as a dedicated `### Task Context` section in agent prompts instead of inline
- Enter key submits the task add form (Shift+Enter for newline)
diff --git a/client/src/App.jsx b/client/src/App.jsx
index b32724a1e1..7b278474aa 100644
--- a/client/src/App.jsx
+++ b/client/src/App.jsx
@@ -63,6 +63,7 @@ const CalendarPage = lazyWithReload(() => import('./pages/Calendar'));
const Messages = lazyWithReload(() => import('./pages/Messages'));
const Goals = lazyWithReload(() => import('./pages/Goals'));
const OpenClawPage = lazyWithReload(() => import('./pages/OpenClaw'));
+const Submodules = lazyWithReload(() => import('./pages/Submodules'));
// Loading fallback for lazy-loaded pages
const PageLoader = () => (
@@ -91,6 +92,7 @@ export default function App() {
<Route path="devtools/history" element={<HistoryPage />} />
<Route path="devtools/runs" element={<RunsHistoryPage />} />
<Route path="devtools/runner" element={<RunnerPage />} />
+ <Route path="devtools/submodules" element={<Submodules />} />
<Route path="devtools/usage" element={<UsagePage />} />
<Route path="devtools/processes" element={<ProcessesPage />} />
<Route path="devtools/agents" element={<AgentsPage />} />
diff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsx
index 3e7211084e..c5c49ddb59 100644
--- a/client/src/components/Layout.jsx
+++ b/client/src/components/Layout.jsx
@@ -54,6 +54,7 @@ import {
Scale,
LayoutDashboard,
Lightbulb,
+ GitBranch,
Github,
Link2,
Database,
@@ -157,6 +158,7 @@ const navItems = [
{ to: '/devtools/jira/reports', label: 'JIRA Reports', icon: FileText },
{ to: '/devtools/processes', label: 'Processes', icon: Activity },
{ to: '/shell', label: 'Shell', icon: SquareTerminal },
+ { to: '/devtools/submodules', label: 'Submodules', icon: GitBranch },
{ to: '/devtools/usage', label: 'Usage', icon: BarChart3 }
]
},
diff --git a/client/src/pages/Submodules.jsx b/client/src/pages/Submodules.jsx
new file mode 100644
index 0000000000..8e127686a7
--- /dev/null
+++ b/client/src/pages/Submodules.jsx
@@ -0,0 +1,151 @@
+import { useState, useEffect, useRef } from 'react';
+import { RefreshCw, ArrowUpCircle, GitBranch, ExternalLink, Check } from 'lucide-react';
+import toast from '../components/ui/Toast';
+import * as api from '../services/api';
+import BrailleSpinner from '../components/BrailleSpinner';
+
+export default function Submodules() {
+ const [submodules, setSubmodules] = useState([]);
+ const [loading, setLoading] = useState(true);
+ const [refreshing, setRefreshing] = useState(false);
+ const [updating, setUpdating] = useState(null);
+ const batchUpdating = useRef(false);
+
+ const loadSubmodules = async (showSpinner = true) => {
+ if (showSpinner) setLoading(true);
+ else setRefreshing(true);
+ const data = await api.getSubmodules().catch(() => []);
+ setSubmodules(data);
+ setLoading(false);
+ setRefreshing(false);
+ };
+
+ useEffect(() => { loadSubmodules(); }, []);
+
+ const handleUpdate = async (subPath) => {
+ setUpdating(subPath);
+ const result = await api.updateSubmodule(subPath).catch(() => null);
+ if (result?.success) {
+ toast.success(`Updated ${subPath} to ${result.newCommit}`);
+ setSubmodules(prev => prev.map(s =>
+ s.path === subPath
+ ? { ...s, currentCommit: result.newCommit, behind: 0, outOfSync: false }
+ : s
+ ));
+ } else {
+ toast.error(`Failed to update ${subPath}`);
+ }
+ if (!batchUpdating.current) setUpdating(null);
+ };
+
+ const handleUpdateAll = async () => {
+ const outdated = submodules.filter(s => s.behind > 0);
+ if (outdated.length === 0) {
+ toast.success('All submodules are up to date');
+ return;
+ }
+ batchUpdating.current = true;
+ for (const sub of outdated) {
+ await handleUpdate(sub.path);
+ }
+ batchUpdating.current = false;
+ setUpdating(null);
+ };
+
+ if (loading) {
+ return <div className="text-center py-8"><BrailleSpinner text="Loading submodules" /></div>;
+ }
+
+ const hasUpdates = submodules.some(s => s.behind > 0);
+
+ return (
+ <div className="space-y-6">
+ <div className="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
+ <h1 className="text-2xl font-bold text-white">Submodules</h1>
+ <div className="flex gap-2">
+ {hasUpdates && (
+ <button
+ onClick={handleUpdateAll}
+ disabled={!!updating}
+ className="px-3 sm:px-4 py-2 bg-port-success hover:bg-port-success/80 text-white rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 text-sm sm:text-base"
+ >
+ <ArrowUpCircle size={16} />
+ <span className="hidden sm:inline">Update All</span>
+ <span className="sm:hidden">All</span>
+ </button>
+ )}
+ <button
+ onClick={() => loadSubmodules(false)}
+ disabled={refreshing}
+ className="px-3 sm:px-4 py-2 bg-port-card hover:bg-port-border text-white rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 text-sm sm:text-base border border-port-border"
+ >
+ <RefreshCw size={16} className={refreshing ? 'animate-spin' : ''} />
+ <span className="hidden sm:inline">Refresh</span>
+ </button>
+ </div>
+ </div>
+
+ {submodules.length === 0 ? (
+ <div className="bg-port-card border border-port-border rounded-lg p-8 text-center text-gray-400">
+ No git submodules found in this repository.
+ </div>
+ ) : (
+ <div className="grid gap-4">
+ {submodules.map(sub => (
+ <div key={sub.path} className="bg-port-card border border-port-border rounded-lg p-4 sm:p-5">
+ <div className="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-3">
+ <div className="flex-1 min-w-0">
+ <div className="flex items-center gap-2 mb-1">
+ <GitBranch size={16} className="text-port-accent shrink-0" />
+ <h3 className="text-lg font-semibold text-white truncate">{sub.name}</h3>
+ {sub.behind > 0 ? (
+ <span className="px-2 py-0.5 text-xs rounded-full bg-port-warning/20 text-port-warning shrink-0">
+ {sub.behind} behind
+ </span>
+ ) : (
+ <span className="px-2 py-0.5 text-xs rounded-full bg-port-success/20 text-port-success shrink-0 flex items-center gap-1">
+ <Check size={10} /> up to date
+ </span>
+ )}
+ </div>
+ <p className="text-sm text-gray-400 font-mono truncate">{sub.path}</p>
+ <div className="flex flex-wrap gap-x-4 gap-y-1 mt-2 text-xs text-gray-500">
+ <span>Current: <span className="font-mono text-gray-400">{sub.currentCommit}</span></span>
+ {sub.latestCommit && (
+ <span>Latest: <span className="font-mono text-gray-400">{sub.latestCommit}</span></span>
+ )}
+ </div>
+ {sub.latestMessage && (
+ <p className="text-sm text-gray-400 mt-1 truncate">{sub.latestMessage}</p>
+ )}
+ {sub.url && (
+ <a
+ href={sub.url.replace(/\.git$/, '')}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="inline-flex items-center gap-1 text-xs text-port-accent hover:underline mt-1"
+ >
+ <ExternalLink size={10} /> Repository
+ </a>
+ )}
+ </div>
+ <button
+ onClick={() => handleUpdate(sub.path)}
+ disabled={!!updating || sub.behind === 0}
+ className="px-3 py-2 bg-port-accent hover:bg-port-accent/80 text-white rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 text-sm shrink-0 min-h-[40px]"
+ >
+ {updating === sub.path ? (
+ <RefreshCw size={14} className="animate-spin" />
+ ) : (
+ <ArrowUpCircle size={14} />
+ )}
+ {updating === sub.path ? 'Updating...' : 'Update'}
+ </button>
+ </div>
+ </div>
+ ))}
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/client/src/services/apiGit.js b/client/src/services/apiGit.js
index de443354b1..ef3b310200 100644
--- a/client/src/services/apiGit.js
+++ b/client/src/services/apiGit.js
@@ -82,3 +82,8 @@ export const checkoutRemoteBranch = (path, branch) => request('/git/checkout-rem
method: 'POST',
body: JSON.stringify({ path, branch })
});
+export const getSubmodules = () => request('/git/submodules/status');
+export const updateSubmodule = (path) => request('/git/submodules/update', {
+ method: 'POST',
+ body: JSON.stringify({ path })
+});
diff --git a/server/routes/git.js b/server/routes/git.js
index fa0f9c5b3a..08c0eaa04c 100644
--- a/server/routes/git.js
+++ b/server/routes/git.js
@@ -20,6 +20,22 @@ async function getActiveAgentBranches() {
const router = Router();
+// GET /api/git/submodules/status - Get all submodule statuses
+router.get('/submodules/status', asyncHandler(async (req, res) => {
+ const submodules = await git.getSubmodules();
+ res.json(submodules);
+}));
+
+// POST /api/git/submodules/update - Update a specific submodule
+router.post('/submodules/update', asyncHandler(async (req, res) => {
+ const { path } = req.body;
+ if (!path) {
+ throw new ServerError('path is required', { status: 400, code: 'VALIDATION_ERROR' });
+ }
+ const newCommit = await git.updateSubmodule(path);
+ res.json({ success: true, newCommit });
+}));
+
// GET /api/git/:appId - Get git info for an app
router.get('/:appId', asyncHandler(async (req, res) => {
const { appId } = req.params;
diff --git a/server/services/git.js b/server/services/git.js
index 962bbee218..3ff16d9d80 100644
--- a/server/services/git.js
+++ b/server/services/git.js
@@ -1,7 +1,7 @@
import { spawn } from 'child_process';
import { existsSync } from 'fs';
import { join } from 'path';
-import { safeJSONParse } from '../lib/fileUtils.js';
+import { safeJSONParse, PATHS } from '../lib/fileUtils.js';
import { listWorktrees } from './worktreeManager.js';
const PROTECTED_BRANCHES = ['main', 'master', 'dev', 'develop', 'release'];
@@ -16,6 +16,7 @@ const PROTECTED_BRANCHES = ['main', 'master', 'dev', 'develop', 'release'];
function execGit(args, cwd, options = {}) {
return new Promise((resolve, reject) => {
const maxBuffer = options.maxBuffer || 10 * 1024 * 1024;
+ const timeout = options.timeout || 30000;
const child = spawn('git', args, {
cwd,
shell: process.platform === 'win32',
@@ -26,10 +27,19 @@ function execGit(args, cwd, options = {}) {
let stderr = '';
let killed = false;
+ const timer = setTimeout(() => {
+ if (!killed) {
+ killed = true;
+ child.kill();
+ reject(new Error(`git command timed out after ${timeout / 1000}s: git ${args.join(' ')}`));
+ }
+ }, timeout);
+
child.stdout.on('data', (data) => {
stdout += data.toString();
if (stdout.length + stderr.length > maxBuffer && !killed) {
killed = true;
+ clearTimeout(timer);
child.kill();
reject(new Error(`git output exceeded maxBuffer (${maxBuffer} bytes)`));
}
@@ -39,12 +49,14 @@ function execGit(args, cwd, options = {}) {
stderr += data.toString();
if (stdout.length + stderr.length > maxBuffer && !killed) {
killed = true;
+ clearTimeout(timer);
child.kill();
reject(new Error(`git output exceeded maxBuffer (${maxBuffer} bytes)`));
}
});
child.on('close', (code) => {
+ clearTimeout(timer);
if (killed) return;
if (code !== 0 && !options.ignoreExitCode) {
reject(new Error(stderr || `git exited with code ${code}`));
@@ -54,11 +66,16 @@ function execGit(args, cwd, options = {}) {
});
child.on('error', (err) => {
+ clearTimeout(timer);
reject(err);
});
});
}
+// Like execGit but catches rejections (e.g. timeout) into a failed-result shape
+const execGitSafe = (args, cwd, options) =>
+ execGit(args, cwd, options).catch(err => ({ exitCode: 1, stdout: '', stderr: err.message }));
+
/**
* Get git status for a directory
*/
@@ -745,17 +762,19 @@ export async function deleteBranch(dir, branchName, { local = false, remote = fa
throw new Error(`Cannot delete branch in active use by an agent: ${branchName}`);
}
- const results = {};
+ const opts = { ignoreExitCode: true };
+ const [localResult, remoteResult] = await Promise.all([
+ local ? execGitSafe(['branch', '-D', branchName], dir, opts) : null,
+ remote ? execGitSafe(['push', 'origin', '--delete', branchName], dir, opts) : null
+ ]);
- if (local) {
- const localResult = await execGit(['branch', '-D', branchName], dir, { ignoreExitCode: true });
+ const results = {};
+ if (localResult) {
results.local = localResult.exitCode === 0
? 'deleted'
: localResult.stderr?.includes('not found') ? 'not found' : `failed: ${localResult.stderr?.trim()}`;
}
-
- if (remote) {
- const remoteResult = await execGit(['push', 'origin', '--delete', branchName], dir, { ignoreExitCode: true });
+ if (remoteResult) {
results.remote = remoteResult.exitCode === 0
? 'deleted'
: remoteResult.stderr?.includes('not found') || remoteResult.stderr?.includes('does not exist')
@@ -815,7 +834,7 @@ export async function deleteMergedBranches(dir, { excludeBranches } = {}) {
for (const b of excludeBranches) localOnlyProtected.add(b);
}
- await execGit(['fetch', 'origin', '--prune'], dir, { ignoreExitCode: true });
+ await execGitSafe(['fetch', 'origin', '--prune'], dir, { ignoreExitCode: true });
const [localMerged, remoteMerged] = await Promise.all([
execGit(['branch', '--merged', defaultBranch, '--format=%(refname:short)'], dir, { ignoreExitCode: true }),
@@ -836,6 +855,7 @@ export async function deleteMergedBranches(dir, { excludeBranches } = {}) {
const deleted = [];
const skipped = [];
+ const opts = { ignoreExitCode: true };
for (const name of allMerged) {
const hasLocal = localSet.has(name);
@@ -843,13 +863,13 @@ export async function deleteMergedBranches(dir, { excludeBranches } = {}) {
const result = { name, local: null, remote: null };
if (hasLocal) {
- const r = await execGit(['branch', '-d', name], dir, { ignoreExitCode: true });
+ const r = await execGitSafe(['branch', '-d', name], dir, opts);
result.local = r.exitCode === 0 ? 'deleted' : 'failed';
if (r.exitCode !== 0) skipped.push(`${name} (local: ${r.stderr?.trim()})`);
}
if (hasRemote) {
- const r = await execGit(['push', 'origin', '--delete', name], dir, { ignoreExitCode: true });
+ const r = await execGitSafe(['push', 'origin', '--delete', name], dir, opts);
result.remote = r.exitCode === 0 ? 'deleted' : 'failed';
if (r.exitCode !== 0) skipped.push(`${name} (remote: ${r.stderr?.trim()})`);
}
@@ -888,3 +908,99 @@ export async function getGitInfo(dir) {
hasChangelog: hasChangelogDir(dir)
};
}
+
+const SUBMODULE_STATUS_RE = /^([+ -])([0-9a-f]+)\s+(\S+)/;
+
+function parseSubmoduleStatusLine(line) {
+ const match = line.match(SUBMODULE_STATUS_RE);
+ if (!match) return null;
+ return { statusChar: match[1], commit: match[2], path: match[3] };
+}
+
+/**
+ * Get submodule status for the PortOS repo
+ */
+export async function getSubmodules() {
+ const root = PATHS.root;
+ const result = await execGit(['submodule', 'status'], root);
+ const lines = result.stdout.trim().split('\n').filter(Boolean);
+
+ const parsed = lines.map(parseSubmoduleStatusLine).filter(Boolean);
+
+ const submodules = await Promise.all(parsed.map(async ({ statusChar, commit, path: subPath }) => {
+ const name = subPath.split('/').pop();
+ const fullPath = join(root, subPath);
+ const exists = existsSync(fullPath);
+
+ // Run independent git queries concurrently
+ const [urlResult, remoteInfo] = await Promise.all([
+ execGitSafe(['config', `submodule.${subPath}.url`], root),
+ exists ? fetchRemoteInfo(fullPath, commit) : Promise.resolve({ latestCommit: null, behind: 0, latestMessage: null })
+ ]);
+
+ return {
+ name,
+ path: subPath,
+ currentCommit: commit.substring(0, 7),
+ ...remoteInfo,
+ outOfSync: statusChar === '+',
+ url: urlResult.stdout.trim() || null
+ };
+ }));
+
+ return submodules;
+}
+
+async function fetchRemoteInfo(fullPath, currentCommit) {
+ await execGitSafe(['fetch', 'origin'], fullPath, { timeout: 15000 });
+
+ const [latestResult, msgResult] = await Promise.all([
+ execGitSafe(['rev-parse', 'origin/HEAD'], fullPath),
+ execGitSafe(['log', '-1', '--format=%s', 'origin/HEAD'], fullPath)
+ ]);
+
+ let latestCommit = null;
+ let behind = 0;
+ if (latestResult.exitCode === 0) {
+ latestCommit = latestResult.stdout.trim().substring(0, 7);
+ const countResult = await execGitSafe(
+ ['rev-list', '--count', `${currentCommit}..origin/HEAD`],
+ fullPath
+ );
+ behind = parseInt(countResult.stdout.trim(), 10) || 0;
+ }
+
+ return {
+ latestCommit,
+ behind,
+ latestMessage: msgResult.stdout.trim() || null
+ };
+}
+
+/**
+ * Get known submodule paths
+ */
+export async function getSubmodulePaths() {
+ const root = PATHS.root;
+ const result = await execGit(['submodule', 'status'], root);
+ return result.stdout.trim().split('\n').filter(Boolean)
+ .map(parseSubmoduleStatusLine).filter(Boolean).map(s => s.path);
+}
+
+/**
+ * Update a specific submodule to the latest remote version
+ */
+export async function updateSubmodule(subPath) {
+ const root = PATHS.root;
+ // Validate subPath is a known submodule
+ const knownPaths = await getSubmodulePaths();
+ if (!knownPaths.includes(subPath)) {
+ throw new Error(`Unknown submodule path: ${subPath}`);
+ }
+ console.log(`📦 Updating submodule ${subPath}...`);
+ await execGit(['submodule', 'update', '--init', '--recursive', '--remote', subPath], root, { timeout: 60000 });
+ console.log(`✅ Submodule ${subPath} updated`);
+ const statusResult = await execGit(['submodule', 'status', subPath], root);
+ const parsed = parseSubmoduleStatusLine(statusResult.stdout);
+ return parsed ? parsed.commit.substring(0, 7) : null;
+}
diff --git a/update.ps1 b/update.ps1
index e9137b6773..1e571514fc 100644
--- a/update.ps1
+++ b/update.ps1
@@ -108,6 +108,12 @@ if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
Step "git-pull" "done" "Latest changes pulled"
Write-SafeHost ""
+# Update submodules (slash-do and any others)
+Step "submodules" "running" "Updating submodules..."
+Invoke-Logged git submodule update --init --recursive --remote
+Step "submodules" "done" "Submodules updated"
+Write-SafeHost ""
+
# Stop PM2 apps to release file locks before updating
Step "pm2-stop" "running" "Stopping PortOS apps..."
Invoke-Logged npm run pm2:stop
diff --git a/update.sh b/update.sh
index 93aa165428..5fe0e2b99a 100755
--- a/update.sh
+++ b/update.sh
@@ -70,6 +70,12 @@ run git pull --rebase --autostash
step "git-pull" "done" "Latest changes pulled"
log ""
+# Update submodules (slash-do and any others)
+step "submodules" "running" "Updating submodules..."
+run git submodule update --init --recursive --remote
+step "submodules" "done" "Submodules updated"
+log ""
+
# Stop PM2 apps to release file locks before updating
step "pm2-stop" "running" "Stopping PortOS apps..."
run npm run pm2:stop || true