feat(HAI-002): add maxWorktrees setting to limit total git worktrees

- Add maxWorktrees field to Settings interface with default of 4
- Enforce worktree limit in Scheduler.schedule() alongside maxConcurrent
- Wire setting through dashboard startup from persisted settings
- Include maxWorktrees in /api/config response
- Add Max Worktrees input to Settings Modal UI
- Backward compatible: existing configs without maxWorktrees use default
This commit is contained in:
Dustin Byrne
2026-03-25 20:32:07 -04:00
parent 93651835b6
commit 6fbf3519b5
5 changed files with 48 additions and 6 deletions

View File

@@ -9,7 +9,7 @@ interface SettingsModalProps {
}
export function SettingsModal({ onClose, addToast }: SettingsModalProps) {
const [form, setForm] = useState<Settings>({ maxConcurrent: 2, pollIntervalMs: 15000 });
const [form, setForm] = useState<Settings>({ maxConcurrent: 2, maxWorktrees: 4, pollIntervalMs: 15000 });
const [loading, setLoading] = useState(true);
useEffect(() => {
@@ -75,6 +75,20 @@ export function SettingsModal({ onClose, addToast }: SettingsModalProps) {
}
/>
</div>
<div className="form-group">
<label htmlFor="maxWorktrees">Max Worktrees</label>
<input
id="maxWorktrees"
type="number"
min={1}
max={20}
value={form.maxWorktrees}
onChange={(e) =>
setForm((f) => ({ ...f, maxWorktrees: Number(e.target.value) }))
}
/>
<small>Limits total git worktrees including in-review tasks</small>
</div>
<div className="form-group">
<label htmlFor="pollIntervalMs">Poll Interval (ms)</label>
<input

View File

@@ -10,9 +10,12 @@ export function createApiRoutes(store: TaskStore, options?: ServerOptions): Rout
router.get("/config", async (_req, res) => {
try {
const settings = await store.getSettings();
res.json({ maxConcurrent: settings.maxConcurrent ?? options?.maxConcurrent ?? 2 });
res.json({
maxConcurrent: settings.maxConcurrent ?? options?.maxConcurrent ?? 2,
maxWorktrees: settings.maxWorktrees ?? 4,
});
} catch {
res.json({ maxConcurrent: options?.maxConcurrent ?? 2 });
res.json({ maxConcurrent: options?.maxConcurrent ?? 2, maxWorktrees: 4 });
}
});