Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(team-setup): say a "new" team already exists when a Chief proposes it
AdityaUmale5e24d3d7a4e5
diff --git a/server/team-setup-requests.test.ts b/server/team-setup-requests.test.tsindex 51fa3f42e7..8400634006 100644--- a/server/team-setup-requests.test.ts+++ b/server/team-setup-requests.test.ts@@ -98,6 +98,16 @@ describe("reviewed Chief team setup", () => {expect(card.detail).not.toContain("peer coordination");expect(card.detail).not.toContain("approval levels");});+ it("explains at proposal time that a team listed as new already exists, instead of the stale-card message", async () => {+ const h = harness();+ const before = h.messages.length;+ expect(() => h.propose([specialist("Mira", "Private")], ["Private"]))+ .toThrow(/^Team "Private" already exists, so it can't be a new team\. That is the Private department, which Clive is not in charge of\. .*Nothing was proposed\.$/);+ expect(() => h.propose([specialist("Mira", "Engineering")], ["Engineering"]))+ .toThrow(/^Team "Engineering" already exists, so it can't be a new team\. Leave it out of newTeams and use it as an existing team\. Nothing was proposed\.$/);+ await expect(h.submit([specialist("Mira", "Private")], ["Private"])).rejects.toThrow(/already exists/);+ expect(h.messages.length).toBe(before);+ });it("creates a Chief in a new team and permits explicit replacement regardless of operation order", async () => {const h = harness();const next = specialist("Mira", "Research");diff --git a/server/team-setup-requests.ts b/server/team-setup-requests.tsindex 4c13d8120e..a28521ed59 100644--- a/server/team-setup-requests.ts+++ b/server/team-setup-requests.ts@@ -164,7 +164,11 @@ export class TeamSetupRequestService {if (confirming && teamSetupRevision(chief, this.requesterScope(request)) !== request.requesterRevision) throw new TeamSetupError("The Chief's settings changed. This setup was cancelled; review a new proposal.", 409);const existingTeams = new Set(this.options.teams().map(section));if (new Set([...(chief.managedSections ?? []), ...request.newTeams]).size > 100) throw new TeamSetupError("A Chief may coordinate at most 100 additional teams", 409);- for (const name of request.newTeams) if (existingTeams.has(name)) throw new TeamSetupError(`Team ${JSON.stringify(name)} now exists. Review a new proposal.`, 409);+ for (const name of request.newTeams) if (existingTeams.has(name)) throw new TeamSetupError(confirming+ ? `Team ${JSON.stringify(name)} now exists. Review a new proposal.`+ // At proposal time no card exists yet, so the stale-card wording above reads as "a review is pending".+ : `Team ${JSON.stringify(name)} already exists, so it can't be a new team. ${this.options.hasTeamAuthority(chief, name)+ ? "Leave it out of newTeams and use it as an existing team." : outsideDepartmentReason(chief, { section: name })} Nothing was proposed.`, 409);const allowed = (name?: string) => request.newTeams.includes(section(name)) || this.options.hasTeamAuthority(chief, name);const targets = new Set<string>();const projected = this.options.store.bots.map((bot) => ({ id: bot.id, name: bot.name, section: section(bot.section), chiefOfStaff: bot.chiefOfStaff, hidden: bot.hidden, createdBy: bot.createdBy, reportsTo: bot.reportsTo }));