Skip to content

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

fix(i18n): show the failed backup resend line in the thread's language

AdityaUmalebff6d1dc286a
diff --git a/server/host/peer-limit-resend.test.ts b/server/host/peer-limit-resend.test.ts
index 9a2a150339..75c8498c7f 100644
--- a/server/host/peer-limit-resend.test.ts
+++ b/server/host/peer-limit-resend.test.ts
@@ -57,7 +57,7 @@ function fixture(rows: Message[] = [], overrides: Partial<PeerLimitResendDeps<Op
guest: () => false,
generation: () => generation,
blocked: () => false,
- settle, release: vi.fn(), startTurn,
+ settle, release: vi.fn(), failedLine: (_threadId: string, detail: string) => `Could not resend this to the backup AI: ${detail}`, startTurn,
...overrides,
} as unknown as PeerLimitResendDeps<Opts, Outcome>;
const resend = createPeerLimitResend<Opts, Outcome>(deps);
diff --git a/server/host/peer-limit-resend.ts b/server/host/peer-limit-resend.ts
index f4e01e4119..c9eff33fcf 100644
--- a/server/host/peer-limit-resend.ts
+++ b/server/host/peer-limit-resend.ts
@@ -67,6 +67,8 @@ export interface PeerLimitResendDeps<Opts, Outcome> {
generation(threadId: string): string | undefined;
/** A busy thread, queued steering or the person's Stop: a resend never runs over them. */
blocked(botId: string, threadId: string): boolean;
+ /** The status row, in the thread's language, saying the resend could not run and why. */
+ failedLine(threadId: string, detail: string): string;
/** Reports a hand-off's outcome (settleDirectCoordination). */
settle(generation: string, outcome: Outcome): void;
/** Lets go of the failed attempt's hand-off: the resend owns its result. */
@@ -138,8 +140,8 @@ export function createPeerLimitResend<Opts extends PeerTurnOpts<Outcome>, Outcom
function resend(threadId: string): boolean {
const turn = take(threadId);
if (!turn) return false;
- const giveUp = (why?: string): false => {
- if (why && store.taskByThread(turn.botId, threadId)) store.appendMessage(threadId, { role: "bot", kind: "activity", tool: { name: why, ok: false } });
+ const giveUp = (detail?: string): false => {
+ if (detail && store.taskByThread(turn.botId, threadId)) store.appendMessage(threadId, { role: "bot", kind: "activity", tool: { name: deps.failedLine(threadId, detail), ok: false } });
if (turn.held) deps.settle(turn.generation, turn.held);
return false;
};
@@ -163,19 +165,19 @@ export function createPeerLimitResend<Opts extends PeerTurnOpts<Outcome>, Outcom
: deps.policyModelRefusal(target) ?? (instance ? recoveryCapabilityError(
{ driverKind: instance.driverKind, capabilities: instance.adapter.capabilities },
{ driverKind: target.driverKind, capabilities: target.adapter.capabilities }) : undefined);
- if (refusal || !checked.ok) return giveUp(refusal && `Could not resend this to the backup AI: ${refusal}`);
+ if (refusal || !checked.ok) return giveUp(refusal);
try {
deps.assertWithinBudget();
store.switchTaskModel(turn.botId, threadId, checked.selection, false, false, { ...deps.hostedModels?.resetTask(from, checked.selection), rewound: true });
} catch (error) {
- return giveUp(`Could not resend this to the backup AI: ${error instanceof Error ? error.message : String(error)}`);
+ return giveUp(error instanceof Error ? error.message : String(error));
}
for (const tool of deps.takeover().carriedOn(current, threadId, from, checked.selection, { scope: turn.scope })) store.appendMessage(threadId, { role: "bot", kind: "activity", tool });
deps.release(turn.generation);
void deps.startTurn(turn.botId, turn.text, { ...turn.opts, threadId, userMessage: turn.userMessage, editedMessageId: undefined, peerLimitResent: true }).catch(error => {
- const why = `Could not resend this to the backup AI: ${error instanceof Error ? error.message : String(error)}`;
+ const detail = error instanceof Error ? error.message : String(error), why = `Could not resend this to the backup AI: ${detail}`;
(turn.opts.coordination?.settle ?? turn.opts.onSettled)?.({ ok: false, text: turn.held ? `${turn.held.text} ${why}` : why } as Outcome);
- if (store.taskByThread(turn.botId, threadId)) store.appendMessage(threadId, { role: "bot", kind: "activity", tool: { name: why, ok: false } });
+ if (store.taskByThread(turn.botId, threadId)) store.appendMessage(threadId, { role: "bot", kind: "activity", tool: { name: deps.failedLine(threadId, detail), ok: false } });
});
});
return true;
diff --git a/server/index.ts b/server/index.ts
index 5da86b1c7d..cbc1e09c70 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -4980,7 +4980,7 @@ const TURN_STALL_MS = Math.max(60_000, stallLimitMs(process.env.OMB_TURN_STALL_M
const TOOL_STALL_MS = Math.max(TURN_STALL_MS, stallLimitMs(process.env.OMB_TOOL_STALL_MS, 2 * 60 * 60_000));
const COMPUTER_WAIT_MAX_MS = Math.max(1_000, Number(process.env.OMB_COMPUTER_WAIT_MAX_MS) || 30 * 60_000);
const roomStallCompletions = new RoomTurnStallRegistry();
-const turnStops = new TurnStops(); const peerLimitResend = createPeerLimitResend<NonNullable<Parameters<typeof startTurn>[2]>, DirectTurnOutcome>({ store, registry, takeover: () => limitTakeover, turnStops, hostedModels, providerConfigs, quotaSwitchEnabled: () => quotaSwitchEnabled(), policyModelRefusal, checkedTaskModelSwitch, assertWithinBudget: () => assertWithinBudget(cfg, DATA_DIR), handedOff: (id) => coordinator.node(id)?.parentId !== undefined, guest: (threadId) => guestDrivenTurns.has(threadId) || cloudGuestDriven(threadId), generation: (threadId) => directTurnGenerationByThread.get(threadId), blocked: (botId, threadId) => threadBusy(botId, threadId) || hasQueuedSteeredMessages(botId, threadId) || Boolean(directRequestOwners.get(threadId)?.stopped), settle: settleDirectCoordination, release: (generation) => directCoordinationSettlers.delete(generation), startTurn }); // bot-to-bot turns whose AI met its usage limit before anything ran go once to the backup AI
+const turnStops = new TurnStops(); const peerLimitResend = createPeerLimitResend<NonNullable<Parameters<typeof startTurn>[2]>, DirectTurnOutcome>({ store, registry, takeover: () => limitTakeover, turnStops, hostedModels, providerConfigs, quotaSwitchEnabled: () => quotaSwitchEnabled(), policyModelRefusal, checkedTaskModelSwitch, assertWithinBudget: () => assertWithinBudget(cfg, DATA_DIR), handedOff: (id) => coordinator.node(id)?.parentId !== undefined, guest: (threadId) => guestDrivenTurns.has(threadId) || cloudGuestDriven(threadId), generation: (threadId) => directTurnGenerationByThread.get(threadId), blocked: (botId, threadId) => threadBusy(botId, threadId) || hasQueuedSteeredMessages(botId, threadId) || Boolean(directRequestOwners.get(threadId)?.stopped), settle: settleDirectCoordination, release: (generation) => directCoordinationSettlers.delete(generation), failedLine: (threadId, detail) => serverLine(threadLanguage(threadId), "server.peerResend.failed", { detail }), startTurn }); // bot-to-bot turns whose AI met its usage limit before anything ran go once to the backup AI
function stoppedTurnText(threadId: string, turnId: string | undefined, cause?: string, stopReason?: string | null): string {
const stop = turnStops.read(threadId, turnId);
const reason = cause ?? stop?.cause ?? stop?.error ?? `The turn did not complete (${stopReason?.trim() || "no reason given"})`;
diff --git a/src/locales/de.json b/src/locales/de.json
index fca145e1ad..2cd4ea3d27 100644
--- a/src/locales/de.json
+++ b/src/locales/de.json
@@ -298,6 +298,7 @@
"server.teammates.briefCovers.one": "Die Übersicht von {bot} über die letzte Arbeit umfasst {count} privaten Chat mit dir",
"server.teammates.briefCovers.many": "Die Übersicht von {bot} über die letzte Arbeit umfasst {count} private Chats mit dir",
"server.teammates.closedBy": "Geschlossen von @{bot}",
+ "server.peerResend.failed": "Konnte das nicht an die Ersatz-KI erneut senden: {detail}",
"server.teammates.sendFailed": "Senden fehlgeschlagen: {detail}",
"server.teammates.resultWithheld": "Ergebnis zurückgehalten: {problem}",
"server.teammates.replied": "{bot} hat geantwortet",
diff --git a/src/locales/en.json b/src/locales/en.json
index 8e7141ff4f..96e50138d9 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -434,6 +434,7 @@
"server.teammates.briefCovers.one": "{bot}'s recent-work brief covers {count} private chat with you",
"server.teammates.briefCovers.many": "{bot}'s recent-work brief covers {count} private chats with you",
"server.teammates.closedBy": "Closed by @{bot}",
+ "server.peerResend.failed": "Could not resend this to the backup AI: {detail}",
"server.teammates.sendFailed": "Send failed — {detail}",
"server.teammates.resultWithheld": "Result withheld: {problem}",
"server.teammates.replied": "{bot} replied",
diff --git a/src/locales/pt-br.json b/src/locales/pt-br.json
index 5d4d4cdca4..0cde1a82c1 100644
--- a/src/locales/pt-br.json
+++ b/src/locales/pt-br.json
@@ -417,6 +417,7 @@
"server.teammates.briefCovers.one": "O resumo do trabalho recente de {bot} inclui {count} conversa privada com você",
"server.teammates.briefCovers.many": "O resumo do trabalho recente de {bot} inclui {count} conversas privadas com você",
"server.teammates.closedBy": "Conversa encerrada por @{bot}",
+ "server.peerResend.failed": "Não foi possível reenviar isto para a IA de reserva: {detail}",
"server.teammates.sendFailed": "Não foi possível enviar — {detail}",
"server.teammates.resultWithheld": "Resultado não repassado: {problem}",
"server.teammates.replied": "{bot} respondeu",