Limits
When a turn stops on the plan's usage limit or on an overloaded model, the chat says so until the next turn. The composer draws LimitDock itself; LimitPill is for a header that shows the chat without its thread.
import { LimitDock, LimitPill, ResumeCompactionDock } from '@adecore/agents-react/chat/ui';import { LimitDock, LimitPill, ResumeCompactionDock } from '@adecore/agents-react/chat/ui';
import { useChatRow } from '@adecore/agents-react/state';
import { useState } from 'react';
import { NOW, chatInfo, chatItems } from '../shared/agents-data.ts';
import { DEMO_CHAT } from '../shared/agents-host.ts';
import { AgentDemo } from '../shared/agents.tsx';
/* The demo chat after its last turn ran into the plan's limit, which lifts in two hours. */
function limitedChat() {
return {
[DEMO_CHAT]: {
info: chatInfo(DEMO_CHAT, { status: 'error', limit: { kind: 'usage' as const, resetsAt: NOW + 2 * 3_600_000 }, resumeAt: NOW + 2 * 3_600_000 }),
items: chatItems()
}
};
}
function Docks() {
const info = useChatRow(DEMO_CHAT, (row) => row?.info);
const [offer, setOffer] = useState(true);
return (
<div className="flex w-full max-w-2xl flex-col gap-4">
<div className="flex items-center gap-2">
<LimitPill chatId={DEMO_CHAT} />
</div>
<div className="overflow-hidden rounded-lg border border-border bg-surface">
{info && <LimitDock chatId={DEMO_CHAT} info={info} />}
{offer && <ResumeCompactionDock tokens={142_000} onCompact={() => setOffer(false)} onDismiss={() => setOffer(false)} />}
<p className="px-3.5 py-3 text-sm text-text-faint">The composer goes here.</p>
</div>
</div>
);
}
export default function LimitsDemo() {
return (
<AgentDemo chats={limitedChat}>
<Docks />
</AgentDemo>
);
}LimitDock and LimitPill
LimitDock({ chatId, info }) sits at the top of the composer. It says what stopped the turn and when the limit lifts, with a switch to resume then. LimitPill({ chatId }) says the same in a few words, from the status every client gets. Both draw nothing while a turn runs or after a normal stop. limitView(info, now) returns their words: a pill, a title and when it goes on.
The switch sets the chat's resumeAtReset through configure, and shows only while the host's useResumeAtReset(scopeId) allows it. The host decides whether and when the chat resumes.
When another account of the CLI is on, signed in and has room, the dock offers to continue there (continueOn). The host decides whether that takes the chat over or forks it. The button names the account with the most session left; with several, a chevron opens a menu of all of them. The menu marks an account that cannot read the conversation as continuing in a fork. Nothing switches without a press.
ResumeCompactionDock
ResumeCompactionDock({ tokens, onCompact, onDismiss }) offers to compact a long context before an idle chat resumes. The composer shows it past RESUME_COMPACTION_TOKENS after RESUME_COMPACTION_IDLE_MS without a turn, on a CLI that can compact; resumeCompactionOffer decides. Sending without answering keeps the whole history.