Extend agent editor with department and budget fields

UpdateAgentInput now includes department and budgetCents. The edit dialog
on the Team page shows department and monthly budget alongside the
existing role, title, seniority, provider, and model fields.
This commit is contained in:
ZacharyZhang-NY committed 2026-06-07 17:39:47 -04:00
1 parent 22568866e8
commit a7fff3a122
4 files changed
+15 -4

No files matched your search

@@ -226,11 +226,13 @@ export class OrganizationService {
.get(input.modelProviderId, input.orgId) as { id: string } | undefined;
if (!provider) throw new Error("Agent provider was not found.");
}
const department = input.department.trim();
const budgetCents = Math.max(0, Math.round(input.budgetCents));
const result = this.db.prepare(`
update agents
set role = ?, title = ?, role_level = ?, model_provider_id = ?, model_id = ?
set role = ?, title = ?, role_level = ?, department = ?, budget_cents = ?, model_provider_id = ?, model_id = ?
where id = ? and org_id = ?
`).run(role, input.title.trim() || role, input.roleLevel.trim() || "staff", input.modelProviderId, input.modelId, input.agentId, input.orgId);
`).run(role, input.title.trim() || role, input.roleLevel.trim() || "staff", department || "General", budgetCents, input.modelProviderId, input.modelId, input.agentId, input.orgId);
if (result.changes === 0) throw new Error("Agent update failed.");
this.audit.record({
orgId: input.orgId,
@@ -83,6 +83,8 @@ export function TeamPage({ snapshot, actions }: PageProps) {
role: text(form, "role"),
title: text(form, "title") || text(form, "role"),
roleLevel: text(form, "roleLevel") || "staff",
department: text(form, "department") || editingAgent.department,
budgetCents: Math.max(0, Math.round(Number(text(form, "budget")) * 100)),
modelProviderId: optional(form, "modelProviderId"),
modelId: optional(form, "modelId"),
})).then((result) => { if (result) setEditAgentId(null); });
@@ -163,6 +165,8 @@ export function TeamPage({ snapshot, actions }: PageProps) {
<Dialog key={editingAgent.id} title={`Edit ${editingAgent.name}`} open submitLabel="Save" onClose={() => setEditAgentId(null)} onSubmit={submitEdit}>
<Field label="Role"><input className="input" name="role" defaultValue={editingAgent.role} required /></Field>
<Field label="Title"><input className="input" name="title" defaultValue={editingAgent.title} /></Field>
<Field label="Department"><input className="input" name="department" defaultValue={editingAgent.department} required /></Field>
<Field label="Monthly budget"><input className="input" name="budget" type="number" min="0" step="1" defaultValue={editingAgent.budgetCents / 100} /></Field>
<Field label="Provider">
<select className="input" name="modelProviderId" defaultValue={editingAgent.modelProviderId ?? ""}>
<option value="">Unassigned</option>
@@ -71,7 +71,7 @@ export function WorkspacePanel({
<div className="card" style={{ padding: 18 }}>
<div className="row" style={{ marginBottom: 12 }}>
<div className="section-label">Workspaces</div>
<Button tone="ghost" onClick={() => setCreateOpen(true)} style={{ marginLeft: "auto" }}><Icon name="plus" size={13} /> Add</Button>
<span style={{ marginLeft: "auto" }}><Button tone="ghost" onClick={() => setCreateOpen(true)}><Icon name="plus" size={13} /> Add</Button></span>
</div>
{workspaces.map((workspace) => (
<div key={workspace.id} className="row" style={{ padding: "8px 0", borderBottom: "1px solid var(--border-soft)" }}>
@@ -92,7 +92,10 @@ export function WorkspacePanel({
<Field label="Local path">
<div className="row" style={{ gap: 6 }}>
<input className="input" name="localPath" required style={{ flex: 1 }} />
<Button tone="ghost" onClick={(e) => { const form = (e.target as HTMLElement).closest("form"); if (form) void chooseDirectory(form); }}>
<Button tone="ghost" onClick={() => {
const form = document.querySelector<HTMLFormElement>("form:has([name='localPath'])");
if (form) void chooseDirectory(form);
}}>
<Icon name="folder" size={13} /> Browse
</Button>
</div>
+2
View File
@@ -42,6 +42,8 @@ export interface UpdateAgentInput {
role: string;
title: string;
roleLevel: string;
department: string;
budgetCents: number;
modelProviderId: string | null;
modelId: string | null;
}