Files
cobble/src/layouts/bots/(partials)/rail-crew-list.tsx
T
tbenandClaude Opus 5.5 7b762fd384 Let workers ask each other through the coordinator in chatrooms
A worker asks for another bot's help with ask_crew. The coordinator
reads the request, asks the right bot (in a workspace, only its
members), and sends the answer back into the asking bot's
conversation, waking it. Each exchange is kept as a read-only
chatroom: listed in the main rail after the workspaces, or in the
workspace's rail for requests made there, with live status rows for
each bot while it's open and a Stop button.

Room sessions are hidden from every conversation list, other bots'
words reach the model fenced as data, and turns, nesting and open
rooms are capped. Closed rooms are pruned after a retention period
and past a cap per place (Settings > General).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 18:57:34 +01:00

62 lines
2.5 KiB
TypeScript

import { useContext } from "react";
import { AddFlowContext } from "../(data)/add-flow-context";
import { AppContext } from "@/src/pages/__root";
import canManageCrew from "@/src/utils/rbac/can-manage-crew";
import type { BotWithLastMessage, WorkspaceWithActivity } from "@/src/types";
import CoordinatorRow from "./coordinator-row";
import RailBotCard from "./rail-bot-card";
import RailBotSessions from "./rail-bot-sessions";
import RailBotsSection from "./rail-bots-section";
import RailSectionAddButton from "./rail-section-add-button";
import RailWorkspacesSection from "./rail-workspaces-section";
import RailChatroomsSection from "./rail-chatrooms-section";
type Props = {
bots: BotWithLastMessage[];
workspaces: WorkspaceWithActivity[];
selected_id?: number;
};
/**
* The rail outside workspaces: the pinned coordinator, the crew (the
* latest few, then "See all bots"), then the workspaces, then the
* chatrooms.
*/
export default function RailCrewList({ bots, workspaces, selected_id }: Props) {
const { openForm } = useContext(AddFlowContext);
const { pageProps } = useContext(AppContext);
const coordinator = bots.find((bot) => bot.kind === "coordinator");
const workers = bots.filter((bot) => bot.kind !== "coordinator");
return (
<>
{coordinator ? (
<RailBotCard selected={coordinator.id === selected_id}>
<CoordinatorRow
bot={coordinator}
bots={bots}
selected={coordinator.id === selected_id}
/>
{coordinator.id === selected_id ? (
<RailBotSessions key={coordinator.id} bot={coordinator} />
) : null}
</RailBotCard>
) : null}
<RailBotsSection
action={<RailSectionAddButton title="Add a bot" onClick={() => openForm({ kind: "bot" })} />}
title="Bots"
workers={workers}
selected_id={selected_id}
hrefFor={(bot) => `/admin/bots/${bot.id}`}
empty={
canManageCrew({ user_types: pageProps?.user_types })
? "No bots yet. Add one for a job you hand out often."
: "No bots for you yet. An admin assigns them."
}
/>
<RailWorkspacesSection workspaces={workspaces} />
<RailChatroomsSection />
</>
);
}