From 9c66a01101880f1f6bde571c242c8d17b158700a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=81=D0=B5=D0=BB=D1=8C?= Date: Mon, 16 Nov 2026 20:58:43 +0500 Subject: [PATCH 1/3] =?UTF-8?q?PEP-176:=20the=20superadmin=20moves=20a=20s?= =?UTF-8?q?ubscription's=20agents=20by=20hand=20=E2=80=94=20to=20a=20chose?= =?UTF-8?q?n=20working=20subscription=20of=20the=20pool=20or=20to=20any=20?= =?UTF-8?q?free=20one?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- apps/web/app/(app)/subscriptions/actions.ts | 12 ++++++- apps/web/app/(app)/subscriptions/page.tsx | 31 ++++++++++++++-- packages/runner/src/rotation.ts | 39 ++++++++++++++++++--- packages/shared/src/i18n/en/admin.ts | 9 +++++ packages/shared/src/i18n/kk/admin.ts | 9 +++++ packages/testkit/test/rotation.test.ts | 20 +++++++++++ 6 files changed, 113 insertions(+), 7 deletions(-) diff --git a/apps/web/app/(app)/subscriptions/actions.ts b/apps/web/app/(app)/subscriptions/actions.ts index 69106286..975ce5db 100644 --- a/apps/web/app/(app)/subscriptions/actions.ts +++ b/apps/web/app/(app)/subscriptions/actions.ts @@ -2,7 +2,7 @@ // «Подписки» (PEP-67): every action is superadmin-only (others get "not found"). import { createPool, deletePool, getProject, lendSubscription, PeppaError, returnLoanNow, requireSuperadmin, setProjectPool, updatePool, updateSubscription, type SubscriptionProvider } from "@peppa/core"; -import { addPoolSubscription, addSubscription, cancelLogin, checkSubscription, finishClaudeLogin, removeSubscription, startClaudeLogin, startCodexLogin } from "@peppa/runner"; +import { addPoolSubscription, addSubscription, switchAgents, cancelLogin, checkSubscription, finishClaudeLogin, removeSubscription, startClaudeLogin, startCodexLogin } from "@peppa/runner"; import { revalidatePath } from "next/cache"; import { redirect } from "next/navigation"; import { asWebActor, requireUser } from "@/lib/auth"; @@ -60,6 +60,16 @@ export async function addPoolSubscriptionAction(f: FormData) { }); } +/** PEP-176: the superadmin moves the agents off a subscription by hand. */ +export async function switchAgentsAction(f: FormData) { + await attempt(f, async () => { + const fromId = Number(str(f, "fromId")); + const to = str(f, "toId"); + const r = await switchAgents(db, { fromId, toId: to ? Number(to) : null }); + return `${BASE}?switched=${r.moved}&left=${r.skipped}#s-${fromId}`; + }); +} + export async function reconnectSubscription(f: FormData) { await attempt(f, async () => { const id = Number(str(f, "id")); diff --git a/apps/web/app/(app)/subscriptions/page.tsx b/apps/web/app/(app)/subscriptions/page.tsx index 320fe248..8db4c00c 100644 --- a/apps/web/app/(app)/subscriptions/page.tsx +++ b/apps/web/app/(app)/subscriptions/page.tsx @@ -23,6 +23,7 @@ import { deletePoolAction, deleteSubscriptionAction, addPoolSubscriptionAction, + switchAgentsAction, returnLoanAction, reconnectSubscription, submitLoginCode, @@ -136,6 +137,25 @@ function SetCard({ o, subs, t }: { o: PoolOverview; subs: SubscriptionView[]; t: o={o} action={(s) => ( <> + {/* PEP-176: move this subscription's agents by hand — to one of the pool's working subscriptions or to any free one. */} + {s.activeSessions > 0 && ( +
+ + + + {o.subscriptions + .filter((x) => x.id !== s.id && x.usable) + .map((x) => ( + + ))} + + + + )}