Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(skills): name teammate skills a failed rollback left changed; show each teammate's change in the receipt

AdityaUmaled23997fc9257
diff --git a/server/host/teammate-skills-host.test.ts b/server/host/teammate-skills-host.test.ts
index 4a8fcdddaf..8c53e6c089 100644
--- a/server/host/teammate-skills-host.test.ts
+++ b/server/host/teammate-skills-host.test.ts
@@ -22,7 +22,7 @@ afterEach(async () => {
type Skill = { kind: SwitchableSkill["kind"]; enabled: boolean; text: string };
-function setup(options: { chief?: boolean; refuse?: string[]; failTurn?: string; room?: boolean } = {}) {
+function setup(options: { chief?: boolean; refuse?: string[]; failTurn?: string; failBack?: string; room?: boolean } = {}) {
const dataDir = mkdtempSync(join(tmpdir(), "teammate-skills-host-"));
dirs.push(dataDir);
const bots: Record<string, BotRecord> = {
@@ -55,6 +55,7 @@ function setup(options: { chief?: boolean; refuse?: string[]; failTurn?: string;
},
turn: (botId, name, on) => {
if (options.failTurn === `${botId}/${name}`) return { error: "disk full" };
+ if (options.failBack === `${botId}/${name}` && turns.includes(`${botId}/${name}=${!on}`)) return { error: "files changed" };
skills.get(`${botId}/${name}`)!.enabled = on;
turns.push(`${botId}/${name}=${on}`);
return { name, enabled: on };
@@ -142,6 +143,15 @@ describe("a Chief of Staff changing its teammates' skills", () => {
expect(t.messages).toEqual([]);
});
+ it("names the skills it could not put back instead of saying nothing was changed", () => {
+ const t = setup({ failTurn: "coder/lint", failBack: "writer/research" });
+ const result = t.host.stage(t.bots.chief!, "t1", both, "self");
+ expect(result).toMatchObject({ status: 422, body: { state: "failed" } });
+ expect(result.body.error).not.toContain("Nothing was changed");
+ expect(result.body.error).toContain('still changed: Writer, "research"');
+ expect(t.enabled("writer/research")).toBe(true);
+ });
+
it("waits on one card when changes wait for the person, and applies all on approval", () => {
const t = setup();
expect(t.host.stage(t.bots.chief!, "t1", both, null)).toMatchObject({ status: 201, body: { state: "pending" } });
diff --git a/server/host/teammate-skills-host.ts b/server/host/teammate-skills-host.ts
index 57ceda45bb..3280d351cf 100644
--- a/server/host/teammate-skills-host.ts
+++ b/server/host/teammate-skills-host.ts
@@ -65,8 +65,10 @@ export function createTeammateSkillsHost(deps: TeammateSkillsHostDeps) {
for (const step of all) {
const result = turnOne(step);
if ("error" in result) {
- for (const back of turned.reverse()) turnOne({ ...back, on: !back.on });
- return { error: `${botName(step.botId)}, "${step.name}": ${String(result.error)}. Nothing was changed.` };
+ const stuck = turned.reverse().filter((back) => "error" in turnOne({ ...back, on: !back.on }));
+ const failed = `${botName(step.botId)}, "${step.name}": ${String(result.error)}.`;
+ if (!stuck.length) return { error: `${failed} Nothing was changed.` };
+ return { error: `${failed} These could not be turned back and are still changed: ${stuck.map((back) => `${botName(back.botId)}, "${back.name}"`).join("; ")}.` };
}
turned.push(step);
}
diff --git a/src/components/ApprovalCard.test.ts b/src/components/ApprovalCard.test.ts
index a87adba2bd..68c5ed986d 100644
--- a/src/components/ApprovalCard.test.ts
+++ b/src/components/ApprovalCard.test.ts
@@ -2,7 +2,7 @@ import { createElement } from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it } from "vitest";
-import { ApprovalCard } from "./ApprovalCard";
+import { ApprovalCard, appliedDetails } from "./ApprovalCard";
import { pendingApprovals, PendingApprovalActions, PendingApprovalPanel, spokenApprovalPrompt, type Pending } from "./PendingApproval";
import { StoreProvider, type Bot, type Message } from "@/state/store";
import { skillRequestBehavior } from "../../shared/skill-request";
@@ -736,6 +736,17 @@ describe("ApprovalCard for a change that applied on its own", () => {
expect(teammates).toContain(">Undo<");
});
+ it("lists each teammate's change in an applied teammate skills receipt's details", () => {
+ const skillRequest = {
+ version: 1 as const, requestId: "s2", botId: "bot-1", threadId: "thread-1", stagedId: "teammates-s2", action: "enable" as const,
+ name: "research, lint", gist: "", warnings: [], createdAt: 1, preview: "Mira: turn on research\nAda: turn off lint",
+ teammates: [{ botId: "b2", botName: "Mira", name: "research", action: "enable" as const }, { botId: "b3", botName: "Ada", name: "lint", action: "disable" as const }],
+ };
+ const card = { title: "Changed 2 skills", subtitle: "Turns skills on or off for teammates.", options: [], skillRequest };
+ expect(appliedDetails(card as never, "Scout")).toBe("Mira: turn on research\nAda: turn off lint");
+ expect(appliedDetails({ ...card, skillRequest: { ...skillRequest, teammates: undefined } } as never, "Scout")).toBe(card.subtitle);
+ });
+
it("reads team setup and team memory as one line, with Undo except for a deletion", () => {
const setup = { version: 1 as const, requestId: "t", botId: "bot-1", threadId: "thread-1", reason: "asked", createdAt: 1, requesterRevision: "r", newTeams: [] };
const team = render(applied({ tool: "set_up_team", teamSetupRequest: { ...setup, operations: [], resumed: true,
diff --git a/src/components/ApprovalCard.tsx b/src/components/ApprovalCard.tsx
index a5a6af223d..00abd3c0aa 100644
--- a/src/components/ApprovalCard.tsx
+++ b/src/components/ApprovalCard.tsx
@@ -226,6 +226,12 @@ export function appliedChange(card: OptionCardData, name: string): { line: strin
return undefined;
}
+/** What Details shows under an applied change: for a teammate skills batch, each teammate's change. */
+export function appliedDetails(card: OptionCardData, name: string): string {
+ if (activeLocale() !== "en" && card.waitRequest) return t("approval.applied.waitFollowUp", { name, followUp: card.waitRequest.followUp ?? "" });
+ return card.skillRequest?.teammates && card.skillRequest.preview ? card.skillRequest.preview : card.subtitle;
+}
+
function AppliedChangeLine({
card,
name,
@@ -336,7 +342,7 @@ function AppliedChangeLine({
aria-label={t("approval.aria.appliedDetails")}
className="mt-1.5 max-h-40 overflow-auto whitespace-pre-wrap break-words rounded-2xl bg-inset px-4 py-3 font-mono text-[13px] leading-relaxed text-ink"
>
- {activeLocale() !== "en" && card.waitRequest ? t("approval.applied.waitFollowUp", { name: originalName ?? name, followUp: card.waitRequest.followUp ?? "" }) : card.subtitle}
+ {appliedDetails(card, originalName ?? name)}
</pre>
)}
</div>