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

fix(schedule): improve badge styling with consistent pill design

Adam Eivy286f34457be6
diff --git a/client/src/components/cos/tabs/ScheduleTab.jsx b/client/src/components/cos/tabs/ScheduleTab.jsx
index cea2aad103..16e4d3150c 100644
--- a/client/src/components/cos/tabs/ScheduleTab.jsx
+++ b/client/src/components/cos/tabs/ScheduleTab.jsx
@@ -28,6 +28,26 @@ const INTERVAL_DESCRIPTIONS = {
cron: 'Cron expression schedule'
};
+const BADGE_COLORS = {
+ accent: 'bg-port-accent/15 text-port-accent border-port-accent/30',
+ purple: 'bg-purple-500/15 text-purple-400 border-purple-500/30',
+ warning: 'bg-port-warning/15 text-port-warning border-port-warning/30',
+ gray: 'bg-gray-600/30 text-gray-400 border-gray-500/30',
+ cyan: 'bg-cyan-500/15 text-cyan-400 border-cyan-500/30',
+ success: 'bg-port-success/15 text-port-success border-port-success/30',
+ error: 'bg-port-error/15 text-port-error border-port-error/30',
+};
+
+const badge = (variant) => `text-xs font-medium px-2.5 py-1 rounded-full border ${BADGE_COLORS[variant] || BADGE_COLORS.gray}`;
+
+const INTERVAL_BADGE_VARIANT = {
+ daily: 'accent',
+ weekly: 'purple',
+ once: 'warning',
+ 'on-demand': 'gray',
+ cron: 'cyan',
+};
+
// Toggle a global taskMetadata field, enforcing the openPR→useWorktree invariant.
// Persists both true and false values so explicit overrides survive the server-side
// merge with task-type defaults (e.g., feature-ideas defaults openPR to true).
@@ -51,14 +71,7 @@ function IntervalBadge({ type, cronExpression }) {
? describeCron(cronExpression) || cronExpression
: INTERVAL_LABELS[type] || type;
return (
- <span className={`text-xs px-2 py-0.5 rounded ${
- type === 'daily' ? 'bg-port-accent/20 text-port-accent' :
- type === 'weekly' ? 'bg-purple-500/20 text-purple-400' :
- type === 'once' ? 'bg-port-warning/20 text-port-warning' :
- type === 'on-demand' ? 'bg-gray-500/20 text-gray-400' :
- type === 'cron' ? 'bg-cyan-500/20 text-cyan-400' :
- 'bg-port-success/20 text-port-success'
- }`} title={type === 'cron' && cronExpression ? cronExpression : undefined}>
+ <span className={badge(INTERVAL_BADGE_VARIANT[type] || 'success')} title={type === 'cron' && cronExpression ? cronExpression : undefined}>
{label}
</span>
);
@@ -599,10 +612,10 @@ function AppTaskTypeRow({ taskType, config, onUpdate, onTrigger, onReset, provid
<div className="flex items-center gap-2">
<span className="font-mono text-sm text-white">{taskType}</span>
{!config.enabled && (
- <span className="text-xs px-2 py-0.5 bg-gray-600/50 text-gray-400 rounded">Disabled</span>
+ <span className={badge('gray')}>Disabled</span>
)}
{config.status?.reason === 'waiting-on-dependencies' && (
- <span className="text-xs px-2 py-0.5 bg-port-warning/20 text-port-warning rounded" title={`Waiting for: ${config.status.pendingDeps?.join(', ')}`}>
+ <span className={badge('warning')} title={`Waiting for: ${config.status.pendingDeps?.join(', ')}`}>
Waiting on deps
</span>
)}
@@ -617,13 +630,12 @@ function AppTaskTypeRow({ taskType, config, onUpdate, onTrigger, onReset, provid
</div>
</div>
- <div className="flex items-center gap-2">
+ <div className="flex items-center gap-2 shrink-0">
{totalCount > 0 && (
- <span className={`text-xs px-2 py-0.5 rounded ${
- enabledCount === totalCount ? 'bg-port-success/20 text-port-success' :
- enabledCount === 0 ? 'bg-port-error/20 text-port-error' :
- 'bg-port-warning/20 text-port-warning'
- }`}>
+ <span className={badge(
+ enabledCount === totalCount ? 'success' :
+ enabledCount === 0 ? 'error' : 'warning'
+ )}>
{enabledCount}/{totalCount} apps
</span>
)}
diff --git a/server/routes/git.js b/server/routes/git.js
index c93b4e121d..4f99c828f1 100644
--- a/server/routes/git.js
+++ b/server/routes/git.js
@@ -1,8 +1,23 @@
import { Router } from 'express';
import * as git from '../services/git.js';
import * as appsService from '../services/apps.js';
+import { getAgents } from '../services/cos.js';
import { asyncHandler, ServerError } from '../lib/errorHandler.js';
+/**
+ * Collect branch names actively used by running CoS agents.
+ * Includes worktree branches and workspace branches from agent metadata.
+ */
+async function getActiveAgentBranches() {
+ const agents = await getAgents().catch(() => []);
+ const branches = new Set();
+ for (const agent of agents) {
+ if (agent.status !== 'running') continue;
+ if (agent.metadata?.worktreeBranch) branches.add(agent.metadata.worktreeBranch);
+ }
+ return branches;
+}
+
const router = Router();
// GET /api/git/:appId - Get git info for an app
@@ -243,7 +258,8 @@ router.post('/cleanup-merged', asyncHandler(async (req, res) => {
throw new ServerError('path is required', { status: 400, code: 'VALIDATION_ERROR' });
}
- const result = await git.deleteMergedBranches(path);
+ const excludeBranches = await getActiveAgentBranches();
+ const result = await git.deleteMergedBranches(path, { excludeBranches });
res.json(result);
}));
@@ -259,7 +275,8 @@ router.post('/delete-branch', asyncHandler(async (req, res) => {
throw new ServerError('at least one of local or remote must be true', { status: 400, code: 'VALIDATION_ERROR' });
}
- const result = await git.deleteBranch(path, branch, { local, remote });
+ const excludeBranches = await getActiveAgentBranches();
+ const result = await git.deleteBranch(path, branch, { local, remote, excludeBranches });
res.json(result);
}));
diff --git a/server/services/cos.js b/server/services/cos.js
index d76c31aa79..9e7bf15a0e 100644
--- a/server/services/cos.js
+++ b/server/services/cos.js
@@ -628,7 +628,7 @@ export async function start() {
await runHealthCheck();
cosEvents.emit('status', { running: true });
- emitLog('success', 'CoS daemon started successfully');
+ emitLog('success', 'CoS daemon started');
// Queue due improvement tasks shortly after startup (not during initial eval
// to avoid overwhelming fresh installs, but soon enough to not stall)
diff --git a/server/services/git.js b/server/services/git.js
index 4e8cfc650f..4d434a06d9 100644
--- a/server/services/git.js
+++ b/server/services/git.js
@@ -2,6 +2,7 @@ import { spawn } from 'child_process';
import { existsSync } from 'fs';
import { join } from 'path';
import { safeJSONParse } from '../lib/fileUtils.js';
+import { listWorktrees } from './worktreeManager.js';
const PROTECTED_BRANCHES = ['main', 'master', 'dev', 'develop', 'release'];
@@ -726,6 +727,21 @@ export async function getRemoteBranches(dir) {
return { branches: remoteBranches, defaultBranch };
}
+/**
+ * Get branch names that are checked out in git worktrees.
+ * Delegates to worktreeManager's listWorktrees to avoid duplicating porcelain parsing.
+ * @param {string} dir - Working directory (main repo root)
+ * @returns {Promise<Set<string>>} Set of branch names in active worktrees
+ */
+export async function getWorktreeBranches(dir) {
+ const worktrees = await listWorktrees(dir).catch(() => []);
+ return new Set(
+ worktrees
+ .filter(wt => wt.branch)
+ .map(wt => wt.branch.replace(/^refs\/heads\//, ''))
+ );
+}
+
/**
* Delete a branch locally, remotely, or both.
* @param {string} dir - Working directory
@@ -733,8 +749,9 @@ export async function getRemoteBranches(dir) {
* @param {object} options
* @param {boolean} options.local - Delete local branch
* @param {boolean} options.remote - Delete remote branch
+ * @param {Set<string>} options.excludeBranches - Additional branches to protect (e.g., active agent branches)
*/
-export async function deleteBranch(dir, branchName, { local = false, remote = false } = {}) {
+export async function deleteBranch(dir, branchName, { local = false, remote = false, excludeBranches } = {}) {
const { baseBranch } = await getRepoBranches(dir);
const protectedSet = new Set(PROTECTED_BRANCHES);
if (baseBranch) protectedSet.add(baseBranch);
@@ -748,6 +765,19 @@ export async function deleteBranch(dir, branchName, { local = false, remote = fa
throw new Error(`Cannot delete the currently checked-out branch: ${branchName}`);
}
+ // Safety: don't delete branches checked out in worktrees (active agent workspaces)
+ if (local) {
+ const worktreeBranches = await getWorktreeBranches(dir);
+ if (worktreeBranches.has(branchName)) {
+ throw new Error(`Cannot delete branch checked out in a worktree: ${branchName}`);
+ }
+ }
+
+ // Safety: don't delete branches explicitly excluded (e.g., active CoS agent branches)
+ if (excludeBranches?.has(branchName)) {
+ throw new Error(`Cannot delete branch in active use by an agent: ${branchName}`);
+ }
+
const results = {};
if (local) {
@@ -795,19 +825,29 @@ export async function checkoutRemoteBranch(dir, branchName) {
/**
* Delete all merged branches (local and remote) in one operation.
- * Skips protected branches (main, master, dev, develop, release) and the current branch.
+ * Skips protected branches (main, master, dev, develop, release), the current branch,
+ * branches checked out in worktrees, and any explicitly excluded branches.
* @param {string} dir - Working directory
+ * @param {object} options
+ * @param {Set<string>} options.excludeBranches - Additional branches to protect (e.g., active agent branches)
* @returns {Promise<{deleted: Array<{name: string, local: string, remote: string}>, skipped: string[], defaultBranch: string}>}
*/
-export async function deleteMergedBranches(dir) {
- const [{ baseBranch }, currentBranch] = await Promise.all([
+export async function deleteMergedBranches(dir, { excludeBranches } = {}) {
+ const [{ baseBranch }, currentBranch, worktreeBranches] = await Promise.all([
getRepoBranches(dir),
- getBranch(dir)
+ getBranch(dir),
+ getWorktreeBranches(dir)
]);
const defaultBranch = baseBranch || 'main';
const protectedSet = new Set(PROTECTED_BRANCHES);
if (baseBranch) protectedSet.add(baseBranch);
+ // Worktree and agent branches are only protected from local deletion
+ const localOnlyProtected = new Set([...worktreeBranches]);
+ if (excludeBranches) {
+ for (const b of excludeBranches) localOnlyProtected.add(b);
+ }
+
await execGit(['fetch', 'origin', '--prune'], dir, { ignoreExitCode: true });
const [localMerged, remoteMerged] = await Promise.all([
@@ -816,7 +856,7 @@ export async function deleteMergedBranches(dir) {
]);
const mergedLocalNames = localMerged.stdout.trim().split('\n').filter(Boolean)
- .filter(name => !protectedSet.has(name) && name !== currentBranch);
+ .filter(name => !protectedSet.has(name) && !localOnlyProtected.has(name) && name !== currentBranch);
const mergedRemoteNames = remoteMerged.stdout.trim().split('\n').filter(Boolean)
.filter(ref => ref.startsWith('origin/'))
@@ -835,7 +875,6 @@ export async function deleteMergedBranches(dir) {
const hasRemote = remoteSet.has(name);
const result = { name, local: null, remote: null };
- // Local deletes are instant; remote deletes are sequential to avoid git lock contention
if (hasLocal) {
const r = await execGit(['branch', '-d', name], dir, { ignoreExitCode: true });
result.local = r.exitCode === 0 ? 'deleted' : 'failed';