loops wizard: stop pulling bearer.ts into the client bundle
Same trap the pre-existing topology import comment warned about: importing from @/lib/api/team or @/lib/api/structure drags http.ts → bearer.ts (uses next/headers, server-only) into the client bundle and Turbopack refuses to build. Replace fetchClaws / fetchTeams / fetchOrgs with plain fetch() to /api/team/claws, /api/teams, /api/orgs. Types are inlined where they were only used for the shape of the JSON response.
This commit is contained in:
@@ -14,7 +14,17 @@ import { useEffect, useMemo, useState } from "react";
|
|||||||
import { Building2, User, Users } from "lucide-react";
|
import { Building2, User, Users } from "lucide-react";
|
||||||
|
|
||||||
import type { Agent } from "@/lib/api/schemas";
|
import type { Agent } from "@/lib/api/schemas";
|
||||||
import { fetchOrgs, fetchTeams, type GroupSummary } from "@/lib/api/structure";
|
// Do NOT import @/lib/api/structure — pulls bearer.ts (next/headers,
|
||||||
|
// server-only) into the client bundle and breaks the production build.
|
||||||
|
// Call /api/teams and /api/orgs with plain fetch instead.
|
||||||
|
|
||||||
|
interface GroupSummary {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
kind: string;
|
||||||
|
status: string;
|
||||||
|
created_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
const mono =
|
const mono =
|
||||||
"ui-monospace, SFMono-Regular, SF Mono, Menlo, Monaco, Consolas, monospace";
|
"ui-monospace, SFMono-Regular, SF Mono, Menlo, Monaco, Consolas, monospace";
|
||||||
@@ -50,8 +60,13 @@ export function LoopStaffingStep({
|
|||||||
let cancelled = false;
|
let cancelled = false;
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
const [t, o] = await Promise.all([fetchTeams(), fetchOrgs()]);
|
const [tRes, oRes] = await Promise.all([
|
||||||
|
fetch("/api/teams"),
|
||||||
|
fetch("/api/orgs"),
|
||||||
|
]);
|
||||||
if (cancelled) return;
|
if (cancelled) return;
|
||||||
|
const t = tRes.ok ? ((await tRes.json()) as GroupSummary[]) : [];
|
||||||
|
const o = oRes.ok ? ((await oRes.json()) as GroupSummary[]) : [];
|
||||||
setTeams(t);
|
setTeams(t);
|
||||||
setOrgs(o);
|
setOrgs(o);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ import {
|
|||||||
import type { CatalogEntry, TopologyGraph } from "@/lib/api/topology";
|
import type { CatalogEntry, TopologyGraph } from "@/lib/api/topology";
|
||||||
import { RepoPicker, type PickedRepo } from "./RepoPicker";
|
import { RepoPicker, type PickedRepo } from "./RepoPicker";
|
||||||
import { NoAgentsGate } from "./NoAgentsGate";
|
import { NoAgentsGate } from "./NoAgentsGate";
|
||||||
import { fetchClaws } from "@/lib/api/team";
|
// Do NOT import @/lib/api/team here — it transitively pulls bearer.ts
|
||||||
|
// (next/headers, server-only) into the client bundle and breaks the
|
||||||
|
// production build. Call /api/team/claws with plain fetch instead.
|
||||||
import type { Agent } from "@/lib/api/schemas";
|
import type { Agent } from "@/lib/api/schemas";
|
||||||
import {
|
import {
|
||||||
LoopStaffingStep,
|
LoopStaffingStep,
|
||||||
@@ -133,7 +135,9 @@ export function LoopsWizard({
|
|||||||
let cancelled = false;
|
let cancelled = false;
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
const claws = await fetchClaws();
|
const r = await fetch("/api/team/claws");
|
||||||
|
if (!r.ok) throw new Error(`${r.status}`);
|
||||||
|
const claws = (await r.json()) as Agent[];
|
||||||
if (cancelled) return;
|
if (cancelled) return;
|
||||||
setRosterAgents(claws);
|
setRosterAgents(claws);
|
||||||
if (agentsCount === undefined) setRosterCount(claws.length);
|
if (agentsCount === undefined) setRosterCount(claws.length);
|
||||||
|
|||||||
Reference in New Issue
Block a user