Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/buzz-help.md
Original file line number Diff line number Diff line change
Expand Up @@ -1216,8 +1216,8 @@ available rather than silently discarding it.
owner, must not disclose it elsewhere, and must not treat quoted, forwarded,
or other people's text as facts about the owner.
- Turning **Remembers you** off removes that guidance but does not delete stored
memory; the agent's core memory can still be included in every prompt. Clear
stored memory in the agent's **Memory** tab. If someone edited the guidance's
memory; the agent's core memory can still be included in every prompt. To
clear a memory, ask Bestie to forget it. If someone edited the guidance's
section markers in Instructions, the Bestie tab says it was edited instead of
adding a duplicate. **Restore** can put the standard guidance back when the
remaining markers still identify the section.
Expand Down Expand Up @@ -1672,7 +1672,7 @@ even when no session is connected; it asks you to confirm first. Full access req

### Reconnecting an old agent in a DM

On desktop, **Connect [agent name]** may appear inside a DM with an old agent you own that is available to import from this computer. It preselects compatible saved harness, provider and model choices, and preserves saved effort settings. Choose another harness if the old type is unavailable or does not support inline connection setup; settings that were not saved use the selected type’s defaults. Review the inline controls; **Connect** stays disabled until the harness has a resolved model and provider, including usable defaults. If a saved Codex model is unavailable, choose another model or harness to continue. Complete installation or sign-in if prompted, stop the agent in old Buzz, then choose **Connect**. Your agent keeps its identity and conversation. This does not resend earlier messages. The same private card can appear in a channel or thread after you send a new mention of an eligible agent you own while that conversation is open, if that agent is still a member of the channel. Loading older mentions does not show cards, and known-archived agents are excluded. Only you see it, once per agent in the loaded conversation. Choose the **X** in the card’s top-right corner to hide that agent’s card in this conversation; the dismissal survives reopening and reloads. After connecting, **Ask the agent to respond** explicitly queues a follow-up addressed only to that agent in the original message’s thread; it does not automatically replay your request. If no prompt appears, use **Agents → New agent → Import an agent**.
On desktop, **Connect [agent name]** may appear inside a DM with an old agent you own that is available to import from this computer. It preselects compatible saved harness, provider and model choices, and preserves saved effort settings. Choose another harness if the old type is unavailable or does not support inline connection setup; settings that were not saved use the selected type’s defaults. Review the inline controls; **Connect** stays disabled until the harness has a resolved model and provider, including usable defaults. If a saved Codex model is unavailable, choose another model or harness to continue. Complete installation or sign-in if prompted, stop the agent in old Buzz, then choose **Connect**. Your agent keeps its identity and conversation. This does not resend earlier messages. The same private card can appear in a channel or thread after you send a new mention of an eligible agent you own while that conversation is open, if that agent is still a member of the channel. Loading older mentions does not show cards, and known-archived agents are excluded. Only you see it, once per agent in the loaded conversation. Choose the **X** in the card’s top-right corner to hide that agent’s card in this conversation; the dismissal survives reopening and reloads. After connecting, **Ask the agent to respond** explicitly queues a follow-up addressed only to that agent in the original message’s thread; it does not automatically replay your request. If no prompt appears, use **Agents → New agent → Import an agent**. Import works only in the desktop app. If no harness that runs agents on this computer is available (a hosted type such as Builderlab doesn’t count, and a plugin that is on but failed to activate registers none), the dialog says so and links to **Manage plugins** to turn one on or retry it.

## Choosing a channel for a workflow

Expand Down
178 changes: 175 additions & 3 deletions src/bundled/agents/AgentBrowse.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type { ReadTransport } from "../../features/relay/transport";
import type {
Agent,
Agents,
AgentsSnapshot,
RegisteredAgentType,
} from "../../features/agents/service";
import type { Profile } from "../../features/relay/contracts";
Expand All @@ -32,6 +33,7 @@ function AgentBrowse(
props: ReturnType<typeof importing> & {
relay: RelayData;
onOpen?: (agent: Agent) => void;
openSettings?: (section: string) => void;
},
) {
const [selection, setSelection] = useState<SharedAgentSelection>();
Expand Down Expand Up @@ -72,13 +74,15 @@ const echo = {
} as RegisteredAgentType;
const notes = { key: "test/notes", title: "Notes" } as RegisteredAgentType;
const imported = { pubkey: "e".repeat(64), name: "Shared helper" } as Agent;
/** Import's props: one type, and an `agents` holding `own` whose `port`
* resolves. */
/** Import's props: one type, and an `agents` in `status` (with `error`)
* holding `own` whose `port` resolves. */
const importing = (
types: readonly RegisteredAgentType[] = [echo],
own: readonly Agent[] = [],
status: AgentsSnapshot["status"] = "ready",
error?: string,
) => {
const snapshot = { agents: own };
const snapshot = { status, error, agents: own };
return {
agents: {
subscribe: () => () => {},
Expand Down Expand Up @@ -530,6 +534,174 @@ it("does not silently replace an unavailable shared runtime", async () => {
expect(props.agents.port).not.toHaveBeenCalled();
});

/** Opens a shared agent's Import dialog with no type to import as, while
* Agents is in `status`. */
async function noTypes(
status: AgentsSnapshot["status"],
openSettings = vi.fn(),
error?: string,
) {
const read = vi.fn().mockResolvedValue([shared]);
const props = importing([], [], status, error);
render(
<AgentBrowse
relay={community(read)}
{...props}
openSettings={openSettings}
/>,
);
fireEvent.click(await screen.findByRole("button", { name: "Shared helper" }));
fireEvent.click(screen.getByRole("button", { name: "Import" }));
return screen.getByRole("dialog", { name: "Shared helper" });
}

// Desktop where no plugin registered a type that runs agents here: every
// agent plugin off, or one on that failed to activate. The component cannot
// tell these apart, so it names what is missing, not why.
it("says why a shared agent can't be imported here, and links Manage plugins", async () => {
const openSettings = vi.fn();
const dialog = await noTypes("ready", openSettings);
expect(
within(dialog).getByText(/No harness that runs agents on this computer/),
).toHaveTextContent(
"No harness that runs agents on this computer is available. Check Manage plugins.",
);
expect(within(dialog).getByRole("button", { name: "Import" })).toBeDisabled();
fireEvent.click(
within(dialog).getByRole("button", { name: "Manage plugins" }),
);
expect(openSettings).toHaveBeenCalledExactlyOnceWith("plugins");
// Settings opens in place of the dialog, not over it.
expect(
screen.queryByRole("dialog", { name: "Shared helper" }),
).not.toBeInTheDocument();
});

// Only a hosted type is on, so Manage plugins shows a plugin enabled. The
// page keeps hosted types out of Import, since an imported agent needs a key
// here, and the dialog must not claim no plugin is on.
it("does not say no plugin is on when only a hosted type is", async () => {
const read = vi.fn().mockResolvedValue([shared]);
const props = importing([], [], "ready");
const hosted = [
{ ...echo, key: "test/cloud", title: "Cloud", remote: {} },
] as unknown as RegisteredAgentType[];
props.agents.types = () => hosted;
const openSettings = vi.fn();
render(
<AgentBrowse
relay={community(read)}
{...props}
openSettings={openSettings}
/>,
);
fireEvent.click(await screen.findByRole("button", { name: "Shared helper" }));
fireEvent.click(screen.getByRole("button", { name: "Import" }));
const dialog = screen.getByRole("dialog", { name: "Shared helper" });
expect(
within(dialog).getByText(/No harness that runs agents on this computer/),
).toHaveTextContent(
"No harness that runs agents on this computer is available. Check Manage plugins.",
);
expect(within(dialog).queryByText(/plugin is turned on/)).toBeNull();
fireEvent.click(
within(dialog).getByRole("button", { name: "Manage plugins" }),
);
expect(openSettings).toHaveBeenCalledExactlyOnceWith("plugins");
});

it("keeps Manage plugins plain text while a shared agent is still importing", async () => {
const read = vi.fn().mockResolvedValue([shared]);
const props = importing();
let fail = () => {};
props.agents.port.mockImplementationOnce(
() =>
new Promise((_, reject) => {
fail = () => reject(new Error("Keychain access was denied"));
}),
);
const openSettings = vi.fn();
const view = render(
<AgentBrowse
relay={community(read)}
{...props}
openSettings={openSettings}
/>,
);
fireEvent.click(await screen.findByRole("button", { name: "Shared helper" }));
fireEvent.click(screen.getByRole("button", { name: "Import" }));
const dialog = screen.getByRole("dialog", { name: "Shared helper" });
fireEvent.click(within(dialog).getByRole("button", { name: "Import" }));
expect(props.agents.port).toHaveBeenCalledTimes(1);
// The last agent plugin goes off while the import is still running.
const gone = importing([]);
view.rerender(
<AgentBrowse
relay={community(read)}
{...props}
agents={gone.agents}
types={gone.types}
openSettings={openSettings}
/>,
);
expect(
within(dialog).getByText(/No harness that runs agents on this computer/),
).toHaveTextContent(
"No harness that runs agents on this computer is available. Check Manage plugins.",
);
// Opening Settings would close the dialog over the import, which Close
// may not do either, so the link waits as plain text.
expect(
within(dialog).queryByRole("button", { name: "Manage plugins" }),
).not.toBeInTheDocument();
expect(within(dialog).getByRole("button", { name: "Close" })).toBeDisabled();
await act(async () => {
fail();
});
// The import's outcome still lands in the dialog, and the link is back.
expect(within(dialog).getByRole("alert")).toHaveTextContent(
"Keychain access was denied",
);
fireEvent.click(
within(dialog).getByRole("button", { name: "Manage plugins" }),
);
expect(openSettings).toHaveBeenCalledExactlyOnceWith("plugins");
expect(
screen.queryByRole("dialog", { name: "Shared helper" }),
).not.toBeInTheDocument();
});

it("tells a browser that shared agents import only in the desktop app", async () => {
// Outside the desktop app Agents is unavailable and no type registers.
const dialog = await noTypes("unavailable");
expect(
within(dialog).getByText(
"Agents runs in the desktop app. Open Buzz there to import one.",
),
).toBeVisible();
expect(within(dialog).queryByText(/Manage plugins/)).not.toBeInTheDocument();
});

it("says a shared agent can't be imported while Agents could not load", async () => {
const dialog = await noTypes("error", vi.fn(), "Keychain is locked.");
expect(
within(dialog).getByText("Agents could not load. Keychain is locked."),
).toBeVisible();
expect(within(dialog).queryByText(/Manage plugins/)).not.toBeInTheDocument();
});

it("waits for agent types to register instead of asking for a plugin", async () => {
const dialog = await noTypes("loading");
// Loading feedback is delayed a second, as LoadingRegion does everywhere.
expect(
await within(dialog).findByRole("status", undefined, { timeout: 2000 }),
).toHaveTextContent("Loading agent types…");
expect(
within(dialog).queryByText(/No harness that runs agents on this computer/),
).not.toBeInTheDocument();
expect(within(dialog).queryByText(/Manage plugins/)).not.toBeInTheDocument();
});

it("collapses long instructions and expands them on request", async () => {
const read = vi.fn().mockResolvedValue([
{
Expand Down
60 changes: 57 additions & 3 deletions src/bundled/agents/AgentBrowse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ import { SurfaceButton } from "../../shared/design-system/ui/SurfaceButton";
import { PreferenceRow } from "../../shared/design-system/ui/PreferenceRow";
import { SettingsGroup } from "../../shared/design-system/ui/SettingsGroup";
import { InlineHeader } from "../../shared/design-system/ui/Header";
import { LoadingRegion } from "../../shared/design-system/ui/LoadingRegion";
import { AgentInstructions } from "../../features/agents/AgentInstructions";
import { SettingsSectionLink } from "../../features/navigation/SettingsSectionLink";
import { ProfileBackdrop } from "../../features/profiles/ProfileBackdrop";
import { agentAvatars } from "../../features/agents/avatar-packs";
import hero from "../../features/profiles/ProfileHero.module.css";
Expand All @@ -68,6 +70,8 @@ type Importing = Readonly<{
onImported(agent: Agent): void;
/** Opens an agent of yours that an import would only copy. */
onOpen?: ((agent: Agent) => void) | undefined;
/** Opens a Settings section, such as Manage plugins. */
openSettings?: ((section: string) => void) | undefined;
}>;

export type SharedAgentSelection = {
Expand Down Expand Up @@ -446,12 +450,52 @@ function copies(
}
}

/** Why Import has no type to import as: agents run only in the desktop app,
* they could not load, their types are still registering, or no harness that
* runs agents on this computer is available. Only the last has a remedy in
* Settings, and it has more than one cause: every agent plugin is off, only a
* hosted type (one its provider runs, so it cannot take an imported key) is
* on, or a plugin that is on failed to activate. The snapshot being ready
* says the inventory loaded, not that a plugin activated, so this names what
* is missing rather than why. */
export function NoImportTypes({
agents,
openSettings,
}: Pick<Importing, "agents" | "openSettings">) {
const { snapshot } = useAgents(agents);
if (snapshot.status === "loading")
return (
<LoadingRegion pending label="Loading agent types…">
{null}
</LoadingRegion>
);
return (
<p className="m-0 text-body-sm text-secondary">
{snapshot.status === "unavailable" ? (
// As the Agents page's own empty state words it.
"Agents runs in the desktop app. Open Buzz there to import one."
) : snapshot.status === "error" ? (
`Agents could not load. ${snapshot.error ?? "Try again."}`
) : (
<>
No harness that runs agents on this computer is available. Check{" "}
<SettingsSectionLink section="plugins" open={openSettings}>
Manage plugins
Comment thread
matt2e marked this conversation as resolved.
Resolved
</SettingsSectionLink>
.
</>
)}
</p>
);
}

export function SharedImportDialog({
shared,
agents,
types,
onImported,
onOpen,
openSettings,
onClose,
finalFocus,
}: Importing & {
Expand Down Expand Up @@ -586,9 +630,19 @@ export function SharedImportDialog({
{/* Laid out as the agent's Identity tab will show it once imported. */}
<div ref={body} className="grid gap-4">
{types.length === 0 ? (
<p className="m-0 text-body-sm text-secondary">
Enable an agent type plugin to import agents.
</p>
<NoImportTypes
agents={agents}
// Settings opens in place of the dialog, not over it, so while
// an import keeps the dialog open the link is plain text.
openSettings={
openSettings && !pending
? (section) => {
onClose();
openSettings(section);
}
: undefined
}
/>
) : (
<SettingsGroup>
<PreferenceRow
Expand Down
39 changes: 39 additions & 0 deletions src/bundled/agents/AgentCardAttachment.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,45 @@ it("names what it added, and opens it from there", async () => {
);
});

it("links Manage plugins from a card while no agent type plugin is on", async () => {
const user = userEvent.setup();
await serve(ada());
const none: RegisteredAgentType[] = [];
const navigator = { open: vi.fn(async () => ({})) };
render(
<AgentCardAttachment
attachment={card}
source="buzz-media://ada.png"
agents={{ ...agents, types: () => none }}
relay={relay}
navigator={navigator as unknown as Navigation}
canOpen={() => false}
open={() => false}
/>,
);
const button = await screen.findByRole("button", {
name: "Add agent: Ada",
});
await vi.waitFor(() => expect(button).toBeEnabled());
await user.click(button);
const dialog = screen.getByRole("dialog", { name: "Ada" });
expect(
within(dialog).getByText(/No harness that runs agents on this computer/),
).toHaveTextContent(
"No harness that runs agents on this computer is available. Check Manage plugins.",
);
await user.click(
within(dialog).getByRole("button", { name: "Manage plugins" }),
);
expect(navigator.open).toHaveBeenCalledExactlyOnceWith({
version: 1,
kind: "settings",
section: "plugins",
});
// Settings opens in place of the dialog, not over it.
expect(screen.queryByRole("dialog", { name: "Ada" })).not.toBeInTheDocument();
});

it("refuses a card larger than the limit without reading it all", async () => {
const chunk = new Uint8Array(1024 * 1024);
const chunks = Array.from({ length: 20 }, () => chunk);
Expand Down
5 changes: 4 additions & 1 deletion src/bundled/agents/AgentCardAttachment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export function AgentCardAttachment({
}: AttachmentRendererProps & {
agents: Agents;
relay: RelayData;
/** Opens an agent of yours on the Agents page; absent, nothing offers to. */
/** Opens an agent of yours on the Agents page, or a Settings section;
* absent, nothing offers to. */
navigator?: Navigation | undefined;
}) {
const connection = useRelayConnection(relay);
Expand Down Expand Up @@ -157,6 +158,8 @@ export function AgentCardAttachment({
setAdding(false);
opener(agent)?.();
},
openSettings: (section: string) =>
void navigator.open({ version: 1, kind: "settings", section }),
})}
onClose={() => setAdding(false)}
finalFocus={trigger}
Expand Down
Loading
Loading