Skip to content
45 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Chat and workspace agents: channels, DMs and named agents you talk to1import { Outlet, data, type ShouldRevalidateFunctionArgs } from "react-router";
2
3import type { ChatSidebar, WorkspaceAgent } from "@g1t/contracts";
4
5import type { Route } from "./+types/layout";
6import type { Mentionable } from "../../../lib/chat";
7import { sidebarOrNull, workspacePeople } from "../../../lib/chat.server";
8import { requireUser, roleIn } from "../../../lib/session.server";
9
10/**
11 * Chat mode: what its sidebar shows (the shell draws it, from this data)
12 * and who can be mentioned or messaged. Each part is empty rather than an
13 * error when its service does not answer.
14 */
15export type ChatLayoutData = {
16 slug: string;
Merge the workspace shell: navigation and phone shell, g1t as orchestrator, agents in roles with audience-checked reads, reactions and custom emoji, live notifications and browser push, the homepage tour (agents 0002, chat 0002)17 /** The viewer's role: owners may make agents. */
18 role: string;
Chat and workspace agents: channels, DMs and named agents you talk to19 me: { id: string; username: string; avatar: string | null };
20 sidebar: ChatSidebar | null;
21 people: Mentionable[];
22 agents: WorkspaceAgent[];
23};
24
25export async function loader({ params, context, request }: Route.LoaderArgs): Promise<ChatLayoutData> {
26 const viewer = requireUser(context, request);
Merge the workspace shell: navigation and phone shell, g1t as orchestrator, agents in roles with audience-checked reads, reactions and custom emoji, live notifications and browser push, the homepage tour (agents 0002, chat 0002)27 const role = roleIn(viewer, params.owner);
28 if (!role) throw data(null, { status: 404 });
Chat and workspace agents: channels, DMs and named agents you talk to29 const slug = params.owner.toLowerCase();
30 const [sidebar, { people, agents }] = await Promise.all([sidebarOrNull(slug, viewer), workspacePeople(slug, viewer)]);
Merge the workspace shell: navigation and phone shell, g1t as orchestrator, agents in roles with audience-checked reads, reactions and custom emoji, live notifications and browser push, the homepage tour (agents 0002, chat 0002)31 return { slug, role, me: { id: viewer.id, username: viewer.username, avatar: viewer.avatar ?? null }, sidebar, people, agents };
Chat and workspace agents: channels, DMs and named agents you talk to32}
33
34/**
35 * Moving between conversations keeps the sidebar: it refreshes itself
36 * (components/chat/sidebar.tsx) and after anything is sent.
37 */
38export function shouldRevalidate({ currentParams, nextParams, formMethod, defaultShouldRevalidate }: ShouldRevalidateFunctionArgs) {
39 if (formMethod && formMethod !== "GET") return defaultShouldRevalidate;
40 return currentParams.owner !== nextParams.owner;
41}
42
43export default function ChatLayout() {
44 return <Outlet />;
45}

This file's history is long; its oldest lines are credited to the oldest commit read.