🔕 feat: Let an Owner Stop Per-Use Approval Under a Whole-Agent Authorization (#18534)

With the whole agent ticked the dialog only named the tools a schedule still asked
about. For a server its agents select as a whole there is no tool box to untick, so
the owner had no way to stop it short of revoking. The note is now a checkbox.
This commit is contained in:
Danny Avila 2026-11-19 13:19:57 -05:00 • committed by GitHub
parent 012cc1c200
commit 216aae5a14
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 62 additions and 10 deletions

View file

@ -95,11 +95,17 @@ export interface GrantChoice {
standing: boolean;
/** The whole agent is chosen: nothing is ticked one by one, and nothing added later is left out. */
everything: boolean;
/**
* Under the whole agent: the tools the stored grant asks about stay asked about. Unticked,
* the confirmation says so, and they run unattended.
*/
keepsAsking: boolean;
/** Something is allowed, so there is a grant to confirm. */
some: boolean;
/** What a confirmation sends for this choice. */
request: Pick<ConfirmScheduleMCPConsent, 'allow' | 'ask' | 'tools' | 'everything'>;
setEverything: (everything: boolean) => void;
setKeepsAsking: (keeps: boolean) => void;
setTools: (serverName: string, tools: string[]) => void;
setAsking: (serverName: string, tools: string[]) => void;
setOther: (tools: string[]) => void;
@ -156,6 +162,13 @@ export function useGrantChoice(data: ScheduleMCPConsentView | undefined): GrantC
standing &&
((editedWhole?.revision === data?.revision ? editedWhole?.value : undefined) ??
(data?.revision == null ? true : data.everything));
/** Null until the owner changes it, with the grant it was changed against. */
const [editedKeeps, setEditedKeeps] = useState<{
revision: string | null;
value: boolean;
} | null>(null);
const keepsAsking =
(editedKeeps?.revision === data?.revision ? editedKeeps?.value : undefined) ?? true;
/** A grant allows something: an MCP tool, or one of the other tools. */
const chosenCount =
Object.values(choice).reduce((count, tools) => count + tools.length, 0) + other.length;
@ -202,17 +215,23 @@ export function useGrantChoice(data: ScheduleMCPConsentView | undefined): GrantC
count: chosenCount,
standing,
everything,
keepsAsking,
some: everything || chosenCount > 0,
// The whole agent names nothing. Otherwise `ask` and `tools` are always sent: left out,
// the server would keep what the stored grant asks about and the other tools it allows.
request: everything ? { allow: {}, everything: true } : { allow: choice, ask, tools: other },
// The whole agent names nothing, and says nothing about asking unless the owner stops it:
// left out, the server keeps what the stored grant asks about. Otherwise `ask` and `tools`
// are always sent, since left out the server would keep the stored grant's choice of both.
request: everything
? { allow: {}, everything: true, ...(!keepsAsking && { ask: {} }) }
: { allow: choice, ask, tools: other },
setEverything: (value: boolean) => setEditedWhole({ revision: data?.revision ?? null, value }),
setKeepsAsking: (value: boolean) => setEditedKeeps({ revision: data?.revision ?? null, value }),
setTools,
setAsking,
setOther,
allowEverything,
reset: () => {
setEditedWhole(null);
setEditedKeeps(null);
setEdited(null);
setEditedAsking(null);
setEditedOther(null);
@ -239,10 +258,13 @@ export default function GrantTools({
const noteId = useId();
const otherId = useId();
const wholeId = useId();
const keepId = useId();
const {
standing,
everything,
setEverything,
keepsAsking,
setKeepsAsking,
choice,
ask,
asking,
@ -285,11 +307,20 @@ export default function GrantTools({
{localize('com_ui_schedule_consent_everything_note')}
</p>
{everything && kept.length > 0 && (
<p className="text-text-secondary text-xs">
{localize('com_ui_schedule_consent_everything_asking', {
tools: kept.join(', '),
})}
</p>
<div className="flex items-center gap-2">
<Checkbox
id={keepId}
checked={keepsAsking}
disabled={busy}
aria-labelledby={`${keepId}-label`}
onCheckedChange={(checked) => setKeepsAsking(checked === true)}
/>
<Label id={`${keepId}-label`} htmlFor={keepId} className="text-xs break-all">
{localize('com_ui_schedule_consent_everything_asking', {
tools: kept.join(', '),
})}
</Label>
</div>
)}
</div>
</div>

View file

@ -371,13 +371,34 @@ describe('a grant that can be made for the whole agent', () => {
jest.mocked(dataService.confirmScheduleMCPConsent).mockResolvedValue(asked);
display();
expect(await whole()).toBeChecked();
expect(screen.getByText('com_ui_schedule_consent_everything_asking')).toBeVisible();
const keep = screen.getByRole('checkbox', {
name: 'com_ui_schedule_consent_everything_asking',
});
expect(keep).toBeChecked();
await userEvent.click(confirm());
await waitFor(() => expect(dataService.confirmScheduleMCPConsent).toHaveBeenCalled());
// Left out, the server keeps what the stored grant asks about.
expect(jest.mocked(dataService.confirmScheduleMCPConsent).mock.calls[0][1]).not.toHaveProperty(
'ask',
);
// The owner stops it, here, with the whole agent still ticked.
await userEvent.click(keep);
await userEvent.click(confirm());
await waitFor(() => expect(dataService.confirmScheduleMCPConsent).toHaveBeenCalledTimes(2));
expect(jest.mocked(dataService.confirmScheduleMCPConsent).mock.calls[1][1]).toMatchObject({
allow: {},
everything: true,
ask: {},
});
});
it('offers nothing to keep asking about where the grant asks about nothing', async () => {
jest.mocked(dataService.getScheduleMCPConsent).mockResolvedValue(standing);
display();
expect(await whole()).toBeChecked();
expect(
screen.queryByRole('checkbox', { name: 'com_ui_schedule_consent_everything_asking' }),
).not.toBeInTheDocument();
});
it('starts a stored grant from what it is', async () => {

View file

@ -3948,7 +3948,7 @@
"com_ui_schedule_consent_everything": "Run the whole agent",
"com_ui_schedule_consent_everything_note": "Everything this agent can use, including tools, skills and servers added to it later. Untick to choose tool by tool.",
"com_ui_schedule_consent_everything_allowed": "Allowed: the whole agent, including what is added to it later.",
"com_ui_schedule_consent_everything_asking": "You are still asked before each use of: {{tools}}",
"com_ui_schedule_consent_everything_asking": "Ask me before each use of: {{tools}}",
"com_ui_schedule_authorize_title": "What this schedule may use",
"com_ui_schedule_authorize_changed": "What this schedule may use has changed. Review your choices and create it again.",
"com_ui_schedule_authorize_unavailable": "What this schedule may use could not be loaded. You can create it and authorize it afterwards; until then none of its tools will run.",