From 755df8b1a6600f110c02175481fa995289169a8c Mon Sep 17 00:00:00 2001 From: Clay Delk Date: Thu, 5 Nov 2026 09:56:09 -0500 Subject: [PATCH 01/11] feat(bestie): add Inbox access and refine settings Group Behavior and reading access, clarify guest-only channel additions, and expose the owner's bounded Inbox to their selected local Bestie. Keep check-ins hourly; leave contextual asks and navigation separate. Work in progress: Inbox reconciliation, complete-section authorization, and post-await runtime invalidation still need safety follow-up before live use. Private-conversation restrictions are currently prompt policy. Signed-off-by: Clay Delk Co-authored-by: goose Signed-off-by: Clay Delk --- docs/buzz-help.md | 15 +++ src/bundled/bestie/BestieTab.test.tsx | 104 +++++++++++++--- src/bundled/bestie/BestieTab.tsx | 52 +++++--- src/bundled/bestie/PrivateChannels.test.tsx | 51 +++++--- src/bundled/bestie/PrivateChannels.tsx | 30 ++--- src/bundled/bestie/README.md | 35 ++++-- src/bundled/bestie/features.ts | 27 ++++- src/bundled/bestie/former.test.ts | 22 +++- src/bundled/bestie/former.ts | 23 ++-- src/bundled/bestie/index.tsx | 6 +- src/buzz-mcp/app-client.ts | 11 ++ src/buzz-mcp/client.ts | 7 ++ src/buzz-mcp/tools.test.ts | 41 +++++++ src/buzz-mcp/tools.ts | 30 +++++ src/features/agents/runner.ts | 10 ++ src/features/agents/service.ts | 49 ++++++++ tests/browser/bestie-tab.spec.mjs | 33 ++++- tests/fixtures/bestie-tab.tsx | 128 ++++++++++++++++---- 18 files changed, 535 insertions(+), 139 deletions(-) diff --git a/docs/buzz-help.md b/docs/buzz-help.md index 5cad4d8354..58edd0b585 100644 --- a/docs/buzz-help.md +++ b/docs/buzz-help.md @@ -810,6 +810,21 @@ available rather than silently discarding it. Bestie whose provider holds its instructions (Builderlab does) shows a **Bestie** tab where **Remembers you** edits them through the provider; check-ins stay unavailable for hosted agents. +- In your agent's **Bestie** tab, **Behavior** groups **Remembers you** and + **Checks in**. Check-ins need memory on and run once an hour while Buzz is open + and the Watching plugin is on. Each wake uses tokens. +- In that tab, **What your Bestie can read** separates Inbox + access from private-channel membership. **Inbox** lets a local Bestie + help triage notifications, including those from private channels and DMs. It + does not join those conversations, grant their history, or allow replies there. + It starts on when you make a local agent Bestie on this device; an existing + Bestie's choice stays as it is. Private-channel rows let you remove Bestie, + add it to one channel, or add it to all your currently eligible private + channels—not future ones. Added here, it joins as a guest and cannot post; + existing participants keep their roles. A channel owner or admin can change + its access to **Participating** to let it post. This panel does not add it to DMs. + Changing Inbox access does not change membership, + and removing channel membership does not turn off Inbox access. - **Settings → Agent setup → Harness defaults** is where supported agent types offer installation, sign-in, and default-model controls. Available controls depend on the type. Do not assume a provider is configured or signed in. diff --git a/src/bundled/bestie/BestieTab.test.tsx b/src/bundled/bestie/BestieTab.test.tsx index ee2d8845a9..88531d4ee4 100644 --- a/src/bundled/bestie/BestieTab.test.tsx +++ b/src/bundled/bestie/BestieTab.test.tsx @@ -15,7 +15,7 @@ import { startHostedRead, } from "./former"; import { validateObject } from "../../features/agents/attention"; -import { checkinHourly, memory, withFeature } from "./features"; +import { checkinHourly, inbox, memory, withFeature } from "./features"; afterEach(() => { cleanup(); @@ -430,7 +430,7 @@ it("asks before making a remote former Bestie your Bestie again, and Cancel chan await act(async () => { render(); }); - const again = screen.getByRole("button", { name: "Make my Bestie again" }); + const again = screen.getByRole("button", { name: "Make your Bestie again" }); expect(again).toBeEnabled(); await user.click(again); const ask = await screen.findByRole("alertdialog", { @@ -486,7 +486,7 @@ it("turns memory on and off as a marked section of the instructions", async () = const remembers = screen.getByRole("switch", { name: "Remembers you" }); expect(remembers).not.toBeChecked(); expect( - screen.getByText(/Nothing Bestie remembered is deleted/), + screen.getByText(/Turning this off removes the rules, not its memories/), ).toBeVisible(); await user.click(remembers); @@ -512,6 +512,45 @@ it("turns memory on and off as a marked section of the instructions", async () = }); }); +it("keeps Inbox consent in read access, separate from memory and channel membership", async () => { + const user = userEvent.setup(); + const { relay } = community(ada.pubkey); + const { agents, save } = host(); + const Tab = bestieTab(relay, agents).component; + const instructions = withFeature("Be brief.", memory, true); + const agent = { ...ada, config: { instructions } } as Agent; + const { rerender } = render(); + const access = screen.getByRole("region", { + name: "What your Bestie can read", + }); + const readInbox = within(access).getByRole("switch", { + name: "Inbox", + }); + expect(readInbox).not.toBeChecked(); + expect( + within(access).queryByRole("switch", { name: "Remembers you" }), + ).toBeNull(); + expect( + within(access).getByRole("heading", { name: "Private channels" }), + ).toBeVisible(); + expect(access).toHaveTextContent( + "Adding it to a private channel here gives it read-only access.", + ); + expect(readInbox).toHaveAccessibleDescription( + "Let Bestie help triage notifications in your Inbox, including those from private channels and DMs. This doesn’t add it to those conversations or let it reply there.", + ); + await user.click(readInbox); + const on = withFeature(instructions, inbox, true); + expect(save).toHaveBeenLastCalledWith(ada.key, { + config: { instructions: on }, + }); + rerender(); + expect(readInbox).toBeChecked(); + await user.click(readInbox); + expect(save).toHaveBeenLastCalledWith(ada.key, { config: { instructions } }); + expect(screen.getByRole("switch", { name: "Remembers you" })).toBeChecked(); +}); + it("keeps memory on through the owner's edits, and offers Restore for edited markers", async () => { const user = userEvent.setup(); const { relay } = community(ada.pubkey); @@ -550,7 +589,7 @@ it("keeps memory on through the owner's edits, and offers Restore for edited mar expect(screen.queryByRole("button", { name: "Restore" })).toBeNull(); expect(screen.getByText(/Fix its start and end lines there/)).toBeVisible(); // Check-ins wait on memory. - expect(screen.getByRole("switch", { name: "Every hour" })).toHaveAttribute( + expect(screen.getByRole("switch", { name: "Checks in" })).toHaveAttribute( "aria-disabled", "true", ); @@ -591,11 +630,12 @@ it("offers no switch while the agent's instructions can't be read here", () => { } />, ); - expect(screen.queryByRole("switch", { name: "Remembers you" })).toBeNull(); - // Each setting's row says why, check-ins too. + expect(screen.queryAllByRole("switch")).toEqual([]); expect( - screen.getAllByText("This agent's instructions could not be read"), - ).toHaveLength(2); + within( + screen.getByRole("region", { name: "What your Bestie can read" }), + ).getByText("This agent's instructions could not be read"), + ).toBeVisible(); expect(save).not.toHaveBeenCalled(); }); @@ -612,7 +652,12 @@ it("checks in every hour only while memory is on, with a timer in the owner's DM configBase: base, }; const { rerender } = render(); - const hourly = () => screen.getByRole("switch", { name: "Every hour" }); + const behavior = screen.getByRole("region", { name: "Behavior" }); + expect( + within(behavior).getByRole("switch", { name: "Remembers you" }), + ).toBeVisible(); + const hourly = () => + within(behavior).getByRole("switch", { name: "Checks in" }); // Memory is off, so check-ins can't be turned on. expect(hourly()).toHaveAttribute("aria-disabled", "true"); expect(screen.getByText("Turn on Remembers you first.")).toBeVisible(); @@ -704,7 +749,7 @@ it("checks in every hour only while memory is on, with a timer in the owner's DM expect(hourly()).not.toHaveAttribute("aria-disabled", "true"); }); -/** Ada with memory on and check-ins off, ready to turn Every hour on. */ +/** Ada with memory on and check-ins off, ready to turn Checks in on. */ function remembering(attentionEnabled = false) { return { ...ada, @@ -721,7 +766,7 @@ it("undoes a failed check-in's timer, so none runs behind a switch that reads of const { agents, save } = host(); const Tab = bestieTab(relay, agents).component; render(); - const hourly = screen.getByRole("switch", { name: "Every hour" }); + const hourly = screen.getByRole("switch", { name: "Checks in" }); save .mockResolvedValueOnce() .mockRejectedValueOnce(new Error("Instructions changed elsewhere")); @@ -743,6 +788,23 @@ it("undoes a failed check-in's timer, so none runs behind a switch that reads of expect(screen.queryByRole("alert")).toBeNull(); }); +it("leaves Attention on after a failed check-in when it was already on", async () => { + const user = userEvent.setup(); + const { relay } = community(ada.pubkey); + const { agents, save } = host(); + const Tab = bestieTab(relay, agents).component; + render(); + save + .mockResolvedValueOnce() + .mockRejectedValueOnce(new Error("Instructions changed elsewhere")); + await user.click(screen.getByRole("switch", { name: "Checks in" })); + await screen.findByRole("alert"); + expect(save.mock.calls[2]).toEqual([ + ada.key, + { attention: { [INTEREST]: null, [TIMER]: null } }, + ]); +}); + it("offers to remove a timer left without its section when undoing fails too", async () => { const user = userEvent.setup(); const { relay } = community(ada.pubkey); @@ -753,7 +815,7 @@ it("offers to remove a timer left without its section when undoing fails too", a .mockResolvedValueOnce() .mockRejectedValueOnce(new Error("Instructions changed elsewhere")) .mockRejectedValueOnce(new Error("Offline")); - await user.click(screen.getByRole("switch", { name: "Every hour" })); + await user.click(screen.getByRole("switch", { name: "Checks in" })); expect(await screen.findByRole("alert")).toHaveTextContent( "Instructions changed elsewhere Its timer may still be saved; remove it below.", ); @@ -770,12 +832,12 @@ it("offers to remove a timer left without its section when undoing fails too", a ), } as unknown as Agent; rerender(); - expect(screen.getByRole("switch", { name: "Every hour" })).not.toBeChecked(); + expect(screen.getByRole("switch", { name: "Checks in" })).not.toBeChecked(); save.mockClear(); await user.click( screen.getByRole("button", { name: "Remove", - description: "Every hour's timer is still saved", + description: "Check-in timer is still saved", }), ); expect(save.mock.calls[0]).toEqual([ @@ -804,12 +866,12 @@ it("says a check-in paused in Attention is paused, and how to restart it", async }, } as unknown as Agent; render(); - const hourly = screen.getByRole("switch", { name: "Every hour" }); + const hourly = screen.getByRole("switch", { name: "Checks in" }); // Still on, so Off still removes it. expect(hourly).toBeChecked(); expect( screen.getByText( - "Paused in Attention. Turn Every hour off and on again to restart it.", + "Paused in Attention. Turn check-ins off and on again to restart.", ), ).toBeVisible(); await user.click(hourly); @@ -843,13 +905,15 @@ it("shows a Former Bestie tab while a former Bestie has a setting on, with a way screen.getByText("Ada is no longer your Bestie. These are still on."), ).toBeVisible(); expect(screen.getByRole("switch", { name: "Remembers you" })).toBeChecked(); - const hourly = screen.getByRole("switch", { name: "Every hour" }); + const hourly = screen.getByRole("switch", { name: "Checks in" }); expect(hourly).toHaveAttribute("aria-disabled", "true"); expect(screen.getByText("Only your Bestie checks in.")).toBeVisible(); - expect(screen.getByText("Private channels Ada can read")).toBeVisible(); + expect( + screen.getByRole("heading", { name: "Private channels" }), + ).toBeVisible(); await user.click( - screen.getByRole("button", { name: "Make my Bestie again" }), + screen.getByRole("button", { name: "Make your Bestie again" }), ); const confirmation = await screen.findByRole("alertdialog", { name: "Make Ada your bestie?", @@ -1254,7 +1318,7 @@ it("lets a former Bestie's leftover check-in be turned off", async () => { }, } as unknown as Agent; render(); - const hourly = screen.getByRole("switch", { name: "Every hour" }); + const hourly = screen.getByRole("switch", { name: "Checks in" }); expect(hourly).toBeChecked(); expect(hourly).not.toHaveAttribute("aria-disabled", "true"); await user.click(hourly); diff --git a/src/bundled/bestie/BestieTab.tsx b/src/bundled/bestie/BestieTab.tsx index 6f6b178566..21f3c1049b 100644 --- a/src/bundled/bestie/BestieTab.tsx +++ b/src/bundled/bestie/BestieTab.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef, useState } from "react"; +import { useEffect, useId, useRef, useState } from "react"; import { watchSlug } from "../../features/agents/attention"; import type { Agent, @@ -10,7 +10,7 @@ import type { RelayData } from "../../features/relay/service"; import type { RelaySession } from "../../features/relay/session"; import { BestieIcon } from "../../shared/design-system/icons"; import { Button } from "../../shared/design-system/ui/Button"; -import { InlineHeader } from "../../shared/design-system/ui/Header"; +import { Header } from "../../shared/design-system/ui/Header"; import { MenuGroup, MenuGroupLabel, @@ -25,6 +25,7 @@ import { SwitchPreferenceRow } from "../../shared/design-system/ui/SwitchPrefere import { bestieName, useBestieChoice } from "../agents/BestieChoice"; import { FEATURES, + inbox, type Feature, featureState, restoredFeature, @@ -191,6 +192,8 @@ function BestieTab({ (choice) => choice.pubkey !== agent.pubkey, ); const name = agent.name || "This agent"; + const accessHeading = useId(); + const behaviorHeading = useId(); const switches = (features: readonly Feature[]) => features.map((feature) => ( bestie.make(agent.pubkey)} > - Make my Bestie again + Make your Bestie again } /> @@ -259,7 +262,7 @@ function BestieTab({ {!former && bestie.remove && ( (