Agent context
A session’s environment in a popover from the context meter in the composer: how full the context is and what fills it with a way to compact it, the connectors with the one to reconnect, the files and the document the session produced, and the pull request it opened.
A panel opens over any screen and keeps its own look in every direction: it has no direction of its own.
npx wideset add block-agent-context
Import the default export from @/blocks/wideset/agent-context. The files below are relative to your project's source directory.
Installed with this block
app-shellavatarblock-stylesbreadcrumbsbuttonchipdividerdropdown-menuicon-buttonlist-itempopupprogress-barradio-buttonsegmented-controlselectsidebarstatus-badgetext-inputtooltiputils
blocks/wideset/agent-context/index.tsx
'use client';
import '@/styles/wideset-blocks.css';
import { RiRestartLine } from '@remixicon/react';
import { AppShell } from '@/components/ui/wideset/app-shell/AppShell';
import { Button } from '@/components/ui/wideset/button/Button';
import { useId, useState } from 'react';
import {
account,
chatGroups,
efforts,
fallback,
models,
permissions,
product,
workspace,
} from './canon';
import { CodeTools } from './code-tools';
import { ContextPopover } from './context-popover';
import { codeGroups, OPEN_SESSION } from './data';
import type { Mode, TranscriptView } from './model';
import { ModelMenu } from './model-menu';
import { Session } from './session';
import { AgentSidebar } from './sidebar';
import { ThreadMenu } from './thread-menu';
import { TopBar } from './top-bar';
import { useSession } from './use-session';
const GROUPS = { chat: chatGroups, code: codeGroups };
const repository = codeGroups.find((group) =>
group.threads.some((thread) => thread.id === OPEN_SESSION),
)!;
const opened = repository.threads.find((thread) => thread.id === OPEN_SESSION)!;
/**
* Agent context (a panel over the Inset agent shell): the session's environment, open on load as
* a popover from the context meter in the composer. Behind it is a quiet Code session in
* Tandem's shell: the sessions by repository on the grey frame, one raised card with the top bar,
* a short transcript at rest and the composer, whose tools end with the meter (29% used). The
* popover says how full the context is and what fills it, offers to compact the conversation,
* lists the connectors with Reconnect beside the one whose sign-in ran out, then what the session
* produced and the pull request it opened.
*
* The session works as in every agent block (send, Replay, the transcript views). The other
* sessions are listed, not opened, and the Chat | Code switch changes the sidebar's list only:
* this block is the one session and its popover.
*/
export default function AgentContext() {
const sidebarId = useId();
const [collapsed, setCollapsed] = useState(false);
const [mode, setMode] = useState<Mode>('code');
const [turns, setTurns] = useState(opened.turns);
const [view, setView] = useState<TranscriptView>('normal');
const session = useSession({ turns, onChange: setTurns, reply: fallback });
return (
<AppShell className="ws-block-utility" direction="inset">
<AgentSidebar
id={sidebarId}
collapsed={collapsed}
onCollapsedChange={setCollapsed}
product={product}
workspace={workspace}
account={account}
mode={mode}
onModeChange={setMode}
groups={GROUPS[mode]}
openId={OPEN_SESSION}
workingId={session.running ? OPEN_SESSION : undefined}
onOpen={() => {}}
onNew={() => {}}
/>
<AppShell.Main className="flex-row overflow-hidden">
<div className="flex min-w-0 flex-1 flex-col">
<TopBar
sidebarId={sidebarId}
collapsed={collapsed}
onCollapsedChange={setCollapsed}
crumbs={[repository.label, opened.title]}
>
<Button variant="secondary" preset="ghost" size="sm" onClick={() => session.replay()}>
<Button.Icon icon={RiRestartLine} />
Replay
</Button>
<Button variant="secondary" preset="border" size="sm">
Share
</Button>
<ThreadMenu view={view} onViewChange={setView} />
</TopBar>
<Session
session={session}
threadId={OPEN_SESSION}
agent={product}
view={view}
// The tools end with the context meter, which here opens the session's environment.
tools={<CodeTools permissions={permissions} meter={<ContextPopover />} />}
model={<ModelMenu models={models} efforts={efforts} />}
/>
</div>
</AppShell.Main>
</AppShell>
);
}