Repository navigation
ADFA-7147 AI-Core: let "Always Allow" cover a contributed tool declared read-only - #167
davidschachterADFA wants to merge 18 commits into
Conversation
…ed read-only Step 1 of ADFA-7147. Every contributed tool asked for approval on every call, with no "Always Allow": ContributedToolHandler set allowsSessionApproval to false for all of them. A tool its provider declares read-only (ToolSpec.isReadOnly) may now be allowed for the session. Consent stays explicit: one approval per tool per session, and the dialog still names the source plugin. A tool that may change something is still confirmed on every call. requiresApproval stays true for every contributed tool, so a provider still cannot skip the dialog. For the SQLite debugger's eight read-only tools that means at most eight taps a session instead of one per call. AI-Agent-MCP declares read-only only the debugger entry's readOnlyHint tools (addons#166); every other MCP server's tools stay not read-only, so they keep asking every time. Two guards, because the declaration is the provider's own claim: - A contributed tool's grant is keyed by provider and the tool's own name (ToolHandler.sessionApprovalKey), not by the registered name. That name is first come, first served, so after the sources change it can pass to another plugin's tool, which would have inherited the grant. - A grant is checked against the handler when used, not only when made, so a tool re-registered as not read-only asks again. Built-in tools keep their name-keyed grants unchanged. Limitation: providerId is what the registering plugin declares, so a plugin that registers under another's id can still take over its grants, as it can take over its registration today. Closing that needs the host to vouch for the source, which is step 2 of ADFA-7147. Tests: four new ToolApprovalManagerTest cases run real ContributedToolHandlers through ensureApproved, and two ContributedToolHandlerTest cases cover the declaration and the key. Each guard was reverted on its own and its tests failed; the full AI-Core suite (1347 tests) passes with the change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA
left a comment
There was a problem hiding this comment.
CRITICAL
- none
IMPORTANT
- ContributedToolHandler.kt:72 - Always Allow now depends on an unshown, host-unverified read-only claim by the provider; owner decision
MINOR
- ContributedToolHandler.kt:79 - grant key omits description/schema, so a redefined tool inherits it
- ToolApprovalManager.kt:164 - grants are never cleared across chat sessions; tooltip says they are
NITPICK - none
Review of fb59c32 (base main, not stacked, no existing approvals or review threads, so nothing to re-check from earlier rounds). Rules applied: the repo CLAUDE.md, plugins/README.md, plugins/AI-Core/README.md and the plugin-review skill for plugin criteria only (rubric not scored). None of them states an approve/request-changes rule, so the pr-review default applied. By that default one IMPORTANT would be REQUEST_CHANGES, but this PR is authored by the account posting this review and GitHub refuses that, so it is submitted as COMMENT. The verdict was computed but not submitted. I read the code around the change (ToolSourceRegistryImpl, ApprovalDialogFragment, ChatViewModel, ToolSpec use) and AI-Agent-MCP#166 was not needed.
What checked out: the two guards in the description hold as written (key is per provider and tool; grant is rechecked against the handler on use), requiresApproval stays true, and the new tests exercise ensureApproved with real handlers. Static review only; no Gradle run and no device.
Leads considered and not posted: a revived grant when read-only flips back (the user approved the read-only state, so no new power); a read-only change between dialog and answer (the handler's tool is an immutable value, so unreachable); : delimiter collisions (a provider can already claim any id, so no capability is added); test-coverage gaps.
…and schema Review F12 (addons#167). A contributed tool's "Always Allow" was recorded under contributed:<providerId>:<name>. A provider (or an MCP server behind it, through notifyToolsChanged) could republish the tool under the same name with another description and input schema, still declared read-only, and the new tool ran with no dialog on the grant given to the old one. ContributedToolHandler.sessionApprovalKey now ends in a SHA-256 of the tool's description and parameters schema. The schema is written out with map keys sorted, so a provider that rebuilds its maps in another order on each listing keeps the grant. The description hashed is the provider's own, before it is flattened and capped for the dialog, so a change past the cap counts too. The key is computed lazily, once per handler. Tests: ContributedToolHandlerTest checks that a new description, a new schema, and a change past the dialog's cap each give a new key, and that the same schema in another map order gives the same one. ToolApprovalManagerTest checks through ensureApproved that a republished tool asks again and an unchanged one listed again does not. With the digest removed from the key, three fail: the description/schema and past-the-cap key tests (AssertionError "a new description must ask again") and the republished-tool test (no dialog appears; the grant covered it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
Review F11 (addons#167). The approval dialog offered "Always Allow" for a
contributed tool because its plugin declared the tool read-only, but
nothing on the dialog said so, or that Code on the Go cannot check that
claim. Whether a contributed tool should be session-approvable at all
stays with AI-Core's owner; this commit only fixes the wording.
- ToolHandler.readOnlyOnProvidersWord (false by default) is true for a
ContributedToolHandler its provider declared read-only.
- ToolApprovalManager copies it onto ApprovalRequest when the request
offers "Always Allow".
- ApprovalDialogFragment then adds one line to the provenance block, under
"From <source>": "The plugin that supplied this tool says it only reads.
Code on the Go cannot check that." It is shown even when the source label
is blank, which the source line is not.
- The Always Allow tooltip gains: "For a tool from another plugin, the
button appears only when that plugin says the tool only reads. Code on
the Go cannot check that, and after one tap the agent can call the tool
with any arguments."
No layout changes; the dialog's text for every other tool is unchanged.
Tests: ToolApprovalManagerTest checks that a read-only contributed tool's
request carries the flag, and that a built-in and a contributed tool not
declared read-only do not; ContributedToolHandlerTest checks the handler.
With the ContributedToolHandler override removed, both fail ("the dialog
must say the read-only claim is the plugin's"). The fragment itself has no
unit test: rendering it needs a device or Robolectric, which this module
does not use.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
Review F13 (addons#167). ToolApprovalManager.clearSessionApprovals() had
no caller (on main too), and ChatViewModel's manager lives as long as the
plugin (ChatViewModelStore), across every chat in every project. So an
"Always Allow" outlived the chat it was given in, while the button's
tooltip says the grant "is forgotten when the session ends". This PR
extended that to read-only contributed tools.
A session in AI-Core is a chat (ChatSession). ChatViewModel now clears the
grants in adoptSession, the one place the current chat changes: New chat,
opening another chat, importing one, deleting the open chat (its successor
is adopted), and a project switch (initializeStorage restores that
project's chat through the same path). Re-attaching the tab or reselecting
the open chat does not go through it, so the grant holds there. Clear
Chat also clears the grants, since it resets the chat to a new one.
This changes built-in tools too: a built-in allowed with "Always Allow"
(for example add_dependency) is now asked again in the next chat, where
before the grant lasted until the plugin unloaded.
The tooltip now says when the grant ends: summary "Stop asking about this
tool for the rest of this chat."; detail "Approves this tool for the rest
of this chat ... It is forgotten when you start a new chat, open another
one or clear this one, and when the IDE closes." README says the same.
approvalManager is internal so the test can hold a grant.
Tests: ChatViewModelApprovalGrantTest grants Always Allow on a real
ChatViewModel's manager, then checks the tool asks again after New chat,
opening another chat, deleting the open chat, importing a chat and Clear
Chat, and still runs with no dialog after reselecting and renaming the
open chat (the control). With both clearSessionApprovals() calls removed,
the five change tests fail ("a new chat must not inherit the grant") and
the control passes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
Found in review (F14). Three pieces of user-facing text still described the rule on main: - The Agent guide (assets/docs/index.html) said contributed tools "ask every time", that the dialog "does not offer Always Allow", and that "a plugin cannot waive this for its own tools". It now says the dialog names the source and a plugin cannot skip it; that Always Allow is offered only for a tool its plugin says only reads, with the dialog saying Code on the Go cannot check that; that the grant lasts until a new chat, another chat or Clear Chat; that a changed description or input schema asks again; and that every other contributed tool asks on every call. - The Always Allow tooltip said the grant is "by tool name only". It now says the grant does not depend on the arguments, and for a tool from another plugin, that a changed description or inputs asks again and a tool that may change something asks every time. - The gallery page (ai-core.html) said "a contributed tool can never be blanket-approved for the session: it asks every time". It now names the read-only exception and the dialog's notice. The README was corrected in the F11, F12 and F13 commits. Text only, so no test; addons check passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA
left a comment
There was a problem hiding this comment.
Round 2 at 97a63d3 (round 1 head fb59c32), reviewed at effort medium. Not stacked (base main). Rules read: CLAUDE.md, plugins/README.md; the plugin-review skill was read for criteria only and not scored. This repo has no written approve/request-changes rule, so the skill's default applied; the PR is self-authored, so the event is COMMENT.
MINOR
- ContributedToolHandler.kt:84 - the grant's "provider" is the source's own claimed id, not an authenticated plugin identity
Re-check of round 1 (judged on the code at head, not the replies):
- ContributedToolHandler.kt (read-only claim never shown): fixed. ApprovalDialogFragment adds approval_read_only_claim above the buttons only when Always Allow is offered for a contributed tool, and the tooltip says it covers any arguments.
- ContributedToolHandler.kt (key covers only provider and name): fixed. The key now ends in a SHA-256 over the provider's full description and input schema with map keys sorted; read-only is re-read on every use, so a tool that stops declaring it asks again. Tests pin description, schema, key order and a change past the display cap.
- ToolApprovalManager.kt (grant outlives the chat): fixed. Every path that sets the current chat id goes through adoptSession, which clears the grants, and clearMessages clears too; endRunBeforeSessionChange cancels a pending dialog first, so no grant lands after the clear. Built-in tools are covered.
Earlier findings still open: none.
…cale On a Galaxy Note20 at font_scale 1.3 the approval dialog for a contributed tool call that carries arguments (the SQLite debugger's get_schema and query) lost its button bar: "Always Allow" was unreachable, "Decline" half visible, and nothing scrolled. list_databases (no arguments) was fine. The read-only line and the third button added on this branch made it worse. The dialog now builds its own body instead of the stock AlertDialog title/message/buttons: the title and the full text (header, source, description, argument preview, unchanged and untruncated) scroll inside a bounded area, and the buttons sit below it, always on screen. They stay in one row (same order and texts) when their natural widths fit, and stack one per line, full width, when they do not. The scroll area gets the window height the buttons leave, never below 96dp. main's version of the dialog uses the same stock AlertDialog layout, with a message that includes the argument text and an "Always Allow" button for built-in tools such as add_dependency, so the same clipping is expected there; this fix covers both. Not reproduced on main. Only the sizing decisions are unit-tested (ApprovalDialogLayoutMathTest); AI-Core has no Robolectric, so the view measuring is verified on a device. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA
left a comment
There was a problem hiding this comment.
MINOR
- ApprovalDialogFragment.kt:211 - stacked buttons put "Always Allow" on top, where the old dialog put "Run now"
- ApprovalDialogFragment.kt:151 - the title is no longer the window's title or a heading for TalkBack (plausible, not seen on a device)
- ApprovalDialogFragment.kt:144 - the PR description still says "no layout change"
CRITICAL, IMPORTANT, NITPICK - none
Merge-blocking: none of the new findings block merging (no CRITICAL or IMPORTANT). The stacked order (first MINOR) is a one-line change and worth doing before merge. The new dialog layout has not run on a device, and repo CLAUDE.md (Verification) says a green build is not verification, so it still needs a device check before merge: font_scale 1.0, 1.3 and the largest, portrait and landscape, light and dark, with TalkBack, for a contributed-tool call with arguments, an edit (Correct), and a shell command.
Round 3 at 0bd787f (round 2 head 97a63d3), effort medium, focused on 0bd787f. Not stacked (base main). Rules read at head: CLAUDE.md, plugins/README.md, plugins/AI-Core/README.md; the plugin-review skill was read for criteria only, not scored. This repo has no written approve/request-changes rule, so the pr-review default applied. The computed verdict is COMMENT (MINOR only), which is also the only event allowed on a self-authored PR.
Re-check of earlier threads (judged on the code at head, not the replies):
- ContributedToolHandler.kt:73 (read-only claim never shown): fixed. ApprovalDialogFragment.kt:125-127 still adds
approval_read_only_claimto the scrolled text whenever Always Allow is offered on the provider's word. - ContributedToolHandler.kt:79 (key is provider and name only): fixed. The key ends in a SHA-256 of description and schema (lines 84-85), unchanged by 0bd787f.
- ToolApprovalManager.kt:166 (grant outlives the chat): fixed.
ChatViewModel.adoptSession(2189) andclearMessages(2107) clear the grants, unchanged by 0bd787f. - ContributedToolHandler.kt:84 (provider id is self-declared): not fixed, still open, MINOR, non-blocking. The PR lists it as the owner's decision (step 2 of ADFA-7147); not re-posted.
What checked out in 0bd787f:
- Measuring. AlertDialogLayout gives the custom panel AT_MOST of the window height (the stock title and button panels are GONE).
ApprovalDialogLayoutmeasures the bar first and caps the scroll area at the rest. FrameLayoutcustomthen re-measures with EXACTLY at that height, which gives the same numbers.BoundedScrollViewturns UNSPECIFIED into AT_MOST, so short text keeps its own height. Row or stack is decided again on every measure, and both measure calls see the same width. The 96dp floor can push the bar past the window only when the window is under about 96dp plus the stacked bar, and stacking happens only on narrow windows, where there is the height. - Behaviour. The row order matches the stock bar (neutral, spacer, negative, positive). Each button's result, Correct not dismissing, the tooltips (same tags, now wired when the dialog is built),
setCancelable(false)and recreation from arguments are unchanged. Edit and shell previews take the same path with the same text. - Colours. The text attributes and
borderlessButtonStyleresolve through the host's material and appcompatRclasses. The plugin's DexClassLoader asks its parent first, AGP 9 R ids are not final, and the host's proguard keeps both packages. They resolve against the host's Material3 activity theme, the same context the oldMaterialAlertDialogBuilder(requireContext())used, so dark mode follows the IDE.
Leads considered and not posted: requestLayout from ApprovalButtonBar.onMeasure (its ancestors are already marked for layout, so it does not spread or loop); views built with the activity context, not the dialog overlay's (text colours come from the same theme, and the only difference is the dialog button sub-style); sessionApprovalKey cached over a provider-owned schema map (the provider runs whatever it likes on invoke anyway); digest of Sets or objects with identity toString (MCP schemas are parsed JSON); : in the key (already weighed in round 1); grants not keyed by chat id (round 2 checked every path that changes the chat); approvalManager made internal (module-only, no defect).
Not verified: no build and no device in this round, so the 48dp touch targets, TalkBack order and the stacked layout's look are unmeasured.
…mary first When the approval buttons do not fit side by side, ApprovalButtonBar stacked them Always Allow, Decline, Run now: the reverse of the stock Material dialog it replaced (Run now, Decline, Always Allow). Always Allow sat where users tap Run now, and an accidental tap approves every later call of that tool in the chat. Stacked, the bar now shows the primary action first, then Decline, then Always Allow (or Correct). The order is decided by the pure ApprovalDialogLayoutMath.stackedOrder and pinned by a unit test. The children are re-ordered with the layout, so focus and accessibility traversal follow the visual order. Side by side is unchanged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…t their natural width When the buttons do not fit side by side, the custom button bar made each one full width with its text centered. The stock Material dialog it replaced stacks them at their natural width against the end edge (seen on a Galaxy Note20 at font scale 1.3). Stacked buttons now keep their natural width and sit at the end, so the stacked dialog looks as before: the same position as well as the same order (primary on top, Always Allow at the bottom). A button wider than the dialog still gets the available width and wraps its text. Layout only; ApprovalDialogLayoutMathTest and ToolApprovalManagerTest pass. Not verified on a device yet; the next phone check covers it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA
left a comment
There was a problem hiding this comment.
Review of 0bd787f -> 083078c (a1a2671 stacked order, 083078c natural-width buttons), round 4, effort medium. Nothing here blocks the merge. Repo rules read at the head: CLAUDE.md, plugins/README.md, plugins/AI-Core/README.md. None has a written approve/request-changes rule, so the skill's default applied; this is my own PR, so the review is a COMMENT. Not stacked (base main).
MINOR
- ApprovalDialogLayout.kt:83 - (plausible) a re-arrange during measure drops keyboard and TalkBack focus and cancels a touch
NITPICK - 1 inline, not listed
Blocks merging: none. Still needed before merge, as in the last round: a device check of the new dialog (CLAUDE.md, Verification: a green build is not verification), now including the stacked order and the natural-width buttons at font_scale 1.3 and the largest, portrait and landscape, with TalkBack and a keyboard.
Previous rounds, re-checked against the code at 083078c (a reply is not evidence, I read the code)
- ApprovalDialogFragment.kt:211 (stacked order put Always Allow on top): fixed.
stackedOrderreverses the row order, giving Run now (or Accept), Decline, Always Allow (or Correct), the order of AppCompat's stacked bar; the test pins all three shapes. a1a2671 keeps the row order unchanged. - ApprovalDialogFragment.kt:151 (title is not the window title or a heading): NOT fixed, MINOR, non-blocking. The fragment still has no
window?.setTitleand no heading marking; the title is a plain TextView. Plausible, never seen on a device. Not re-posted. - ApprovalDialogFragment.kt:144 (PR description says "no layout change"): NOT fixed, MINOR, non-blocking. The description still says "Screens and text: no layout change" and "The dialog fragment itself has no unit test", and does not mention the new layout, ApprovalDialogLayoutMathTest or the stacked order. Not re-posted.
- ContributedToolHandler.kt:84 (provider id is self-declared): not fixed, MINOR, non-blocking; the owner's decision (step 2 of ADFA-7147). Not re-posted.
- The other threads (read-only claim shown, key includes a digest, grants end with the chat): fixed, and untouched by this range (it changes three files, all in the dialog).
What I checked in the two commits
- Re-ordering inside onMeasure cannot loop:
arrangeis idempotent per decision, the decision depends only on the incoming width and the buttons' natural widths, never on the arranged state, andrequestLayoutclears the bar's measure cache, so a later pass with an earlier spec is not served a stale result. ApprovalDialogLayout's two measure passes see the same width, and the MATCH_PARENT bar is re-measured at a width no smaller than its first pass, so the decision does not flip between them. At worst one extra traversal follows a flip. - Stacked buttons at natural width with end gravity: each is measured AT_MOST the bar's width, so a label wider than the dialog wraps; it is not cut. AppCompat's button style keeps the 48dp minimum height and the same natural-width stacking as the stock dialog. Not posted.
Not verified: no build and no device in this round, so TalkBack order, focus behaviour and the look of the stacked layout are unmeasured.
… edge, at their natural width" The custom approval dialog layout is replaced by the stock dialog with a bounded message. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…der, primary first" The custom approval dialog layout is replaced by the stock dialog with a bounded message. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…y font scale" The custom approval dialog layout is replaced by the stock dialog with a bounded message. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…e message's height The longer approval message (provenance block, read-only claim) plus long arguments pushed the stacked stock buttons off screen at a large font scale. Keep the stock dialog, title and buttons, but show the message in a scroll view capped at half the window height, styled with the dialog theme's materialAlertDialogBodyTextStyle and dialogPreferredPadding, so the button panel keeps its full height. The cap is a pure function, unit-tested; the layout effect is not testable without a device. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
… their full height AlertDialogLayout measures the button panel at its minimum, then offers the middle panel everything left, and only then returns leftover height to the buttons. A long message therefore left three stacked buttons (large font scale) about 478 px of the 549 they need, hiding "Always Allow". BoundedScrollView now reads the already-measured buttonPanel and caps the message at offered - (full - min), no taller than half the window and no shorter than 96 dp. Without a button panel it keeps the half-window cap. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA
left a comment
There was a problem hiding this comment.
Round 5 review, limited to commits 6acce32, 2e1f398, a27863d, e71f36e and 72971fd (083078c -> 72971fd). Earlier code was reviewed in earlier rounds.
IMPORTANT
- ApprovalDialogFragment.kt:248 - a second measure takes the buttons' extra height off the message twice, so medium-length messages are clipped
MINOR
- ApprovalDialogFragment.kt:234 - the custom panel gets no stock scroll indicators, so nothing shows that the approval text scrolls
- ApprovalDialogFragment.kt:244 - an UNSPECIFIED height spec would measure the message at 0 (no current caller reaches it)
NITPICK - 1 inline, not listed
The reverts. At a27863d the whole tree matches 97a63d3 (git diff 97a63d34 a27863de is empty), so the custom dialog (ApprovalDialogLayout.kt and its test) is fully gone. The only net change after the reverts is e71f36e plus 72971fd.
Checked and correct. On the first measure, messageMaxHeightPx matches AppCompat 1.6.1 AlertDialogLayout.tryOnMeasure, checked against the bytecode: the top panel, then the buttons measured UNSPECIFIED and counted at resolveMinimumHeight, then the middle panel at AT_MOST, then the leftover height to the buttons. minimumHeightOf mirrors resolveMinimumHeight. With setView and no message, contentPanel is GONE, so customPanel is the middle panel and tryOnMeasure does not bail out. The button panel is always measured before the middle panel, so the measuredHeight > 0 fallback is reached only when the panel is missing. In landscape and short windows the floor and minOf(cap, offered) behave as the KDoc says: the buttons scroll only when even the floor leaves no room. setView keeps the window title (setTitle is still the stock path) and FLAG_ALT_FOCUSABLE_IM (the custom view has no text input). The plugin's androidx.appcompat.R.id.buttonPanel and Material attribute lookups were checked too. AGP 9.3.1 leaves R fields non-final (android.nonFinalResIds defaults to true), so they are read at run time through the parent-first DexClassLoader from the IDE's own R classes. That matches the layout the IDE's AppCompat inflates, and agrees with the font 2.0 phone check in the PR description.
Two more differences from setMessage, not posted as findings. The stock scroll view is made non-focusable (setFocusable(false), nested scrolling off). BoundedScrollView keeps NestedScrollView's focusable default, so keyboard and D-pad focus stops on the message. TalkBack therefore probably reads it as one scrollable item rather than as the stock message text. Neither was checked on a device.
Earlier threads these commits address (each checked by reading the code at 72971fd):
- "Screens and text: no layout change" (description): fixed. The description now describes the capped message area.
- Title no longer reaching the window or TalkBack: fixed. The stock
setTitleis back (ApprovalDialogFragment.kt:148), andAlertController.setTitlesets the window title. - Stacked button order reversed: fixed. The custom button bar is reverted, so AppCompat's own
ButtonBarLayoutstacking applies. removeAllViewsInLayout()insideonMeasure: fixed.ApprovalDialogLayout.ktis deleted.- No-op
layoutParams.width = WRAP_CONTENT: fixed. The file is deleted.
Verdict. The repository has no written approve or request-changes rule. I read CLAUDE.md, plugins/README.md and plugins/AI-Core/README.md, so the default rule applies. The computed verdict is REQUEST_CHANGES because of the IMPORTANT finding. It was not submitted, because this PR is self-authored and the run was non-interactive without --verdict. Not verified: anything on a device, including the medium-message clipping, which comes from the bytecode and the arithmetic above.
…ure of the approval message AlertDialogLayout measures the message, hands the buttons their full height, then measures the message again with the height left over. The cap subtracted the buttons' extra height on that second measure too, cutting a 978-1344 px message to 978 px. Remember the first offer; a later offer at or below first - (full - min) has the buttons counted, so nothing more is reserved. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
setView bypasses AppCompat's content panel, which is what shows the top and bottom indicators. Set them on the scroll view (API 23+; the plugin's minSdk is 33). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…re the title gap An UNSPECIFIED height spec has size 0, which made the cap AT_MOST 0; it now means no offered limit, so the window-based cap applies. The stock 8 dp gap between the title and the message (titleDividerNoCustom) is lost with setView; restore it as top padding on the scroll view. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA
left a comment
There was a problem hiding this comment.
Round over 72971fd..3cc8757 (9bc42f2, 3502af1, 3cc8757). Not stacked (base main). Verified against 3cc8757. Rules read: CLAUDE.md, plugins/README.md, plugins/AI-Core/README.md; none sets an approve/request-changes rule, so the default applied. Self-authored PR, so COMMENT.
MINOR
- ApprovalDialogFragment.kt:270 - a stale firstOffered survives a repeated measure sequence with no layout between (non-blocking)
Re-check of earlier threads (judged on the code at head, not on the replies):
- F130 (second-measure over-reserve): fixed. I replayed AppCompat 1.6.1 AlertDialogLayout.tryOnMeasure from the classes.jar bytecode: the middle panel is measured at AT_MOST(H - title - buttonMin); the buttons then get min(remaining, full - min); a second middle measure follows with offer = first - give, which is first - (full - min) whenever one happens. That is exactly the
offered <= first - extratest, so nothing more is reserved. forceUniformWidth's third measure passes the panel's own measured height, which is never above that. The AlertController custom FrameLayout has one child, so it adds no re-measure of its own. onLayout and onDetachedFromWindow clear the state. - F132 (scroll indicators): fixed. TOP|BOTTOM set on the scroll view; minSdk is 33.
- F133 (UNSPECIFIED): fixed. Int.MAX_VALUE offer, window cap applies, no overflow in
first - extra; tested. - F134 (8 dp gap): fixed. abc_dialog_title_divider_material as top padding.
| floorPx = (MESSAGE_FLOOR_DP * metrics.density).toInt(), | ||
| firstOfferedPx = firstOffered, | ||
| ) | ||
| if (firstOffered == null) firstOffered = offered |
There was a problem hiding this comment.
MINOR (PLAUSIBLE): firstOffered is cleared only by onLayout and onDetachedFromWindow, so a second measure sequence that starts before any layout is treated as a continuation of the first.
ViewRootImpl.measureHierarchy can measure a wrap-content-width dialog window two or three times at growing widths before it lays out. If pass 2 starts with a larger first offer than pass 1 (a shorter title or smaller minimum buttons at the wider width), pass 2's second measure offers offered1' - extra', which is above stale first - extra', so the buttons are reserved a second time and the message is cut short by that amount (about 366 px at font 2.0 on the phone), while the buttons still show whole. I could not reproduce it without a device, and the phone check at font 2.0 did not hit it. It is safe to merge: the message still scrolls and the buttons are never clipped.
Inside one sequence the later offers never exceed the first, so an offer above firstOffered marks a new sequence. Re-baselining there makes the state self-correcting, e.g. if (firstOffered != null && offered > firstOffered!!) firstOffered = null before computing the cap.
There was a problem hiding this comment.
Fixed in aa9fafd: an offer larger than the stored first offer now starts a new measure sequence (ApprovalPresentation.sequenceFirstOfferPx), so a second pass before layout reserves the buttons' extra height only once. ApprovalPresentationTest replays two passes with no layout between them and checks the result matches a fresh pass.
…sage is offered more firstOffered was cleared only by onLayout, but measureHierarchy can measure the dialog again at a greater width before any layout. If that pass first offers more (a title a line shorter), its second measure fell above the stale first - (full - min) and reserved the buttons' extra height again, cutting the message short while the buttons still showed whole. Inside one tryOnMeasure the later offers never exceed the first, so a larger offer now starts a new sequence (ApprovalPresentation.sequenceFirstOfferPx). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
… that start on The plugin tooltip still said every tool stays off until the user turns it on. Since 96b49e3 the automatic SQLite debugger entry turns four tools on by default (ReadOnlyTrust.CORE_TOOLS), as the README and the gallery page say. The tooltip, the in-IDE help page and the gallery card (addon.json) now say so too, and that the entry is not on the MCP servers screen in this version. "Asks for your approval every time" stays: AI-Core still asks on every call of a contributed tool until #167 lands. The merge note on #166 lists these lines for whichever of the two lands second. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…e, under a short title
At font scale 2.0 the approval dialog's title, "Confirm: <tool>", cut a long
registered name short ("db_devchec_list_..."). The stock title cannot hold
one: Material's title style is singleLine with ellipsize=end, and AppCompat's
DialogTitle, once ellipsized, allows two lines at most (setMaxLines(2) in its
onMeasure), so a style override cannot make it wrap further, and a wrapped
title would not scroll in any case.
The title is now a short question, "Allow this tool?", and the message,
which scrolls inside the capped BoundedScrollView, opens with "Tool: <name>"
in full. The name and its provenance lines (source, the source's own name,
the read-only claim) form one block, then the description, then the
arguments. The "Tool Approval Required" header went: the title asks it.
The message is composed in ApprovalPresentation.message, a pure function
of the dialog's arguments, so a JVM test can check it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
ADFA-7147
Step 1 of ADFA-7147. Decided by AI-Core's owner (David, 2026-11-18): this lands. It reverses AI-Core's current rule that every contributed tool is confirmed on every call, which the ticket records was chosen so that a plugin cannot opt out by asking. The risks below are accepted for this step.
What it does
ToolSpec.isReadOnly) now offers the dialog's existing "Always Allow" choice (ContributedToolHandler.allowsSessionApproval = readOnly, wasfalse). When it does, the dialog adds one line: "The plugin that supplied this tool says it only reads. Code on the Go cannot check that." The dialog still names the source plugin.requiresApprovalstaystruefor every contributed tool, so a provider still cannot skip the dialog.clearSessionApprovals()had no caller onmain, so a grant lasted until the plugin unloaded, while the tooltip said it was forgotten "when the session ends". Grants are now cleared inChatViewModel.adoptSession(new chat, opening another, import, deleting the open chat, project switch) and inclearMessages. Reselecting the open chat keeps them.Guards, because "read-only" is the provider's own claim
ToolHandler.sessionApprovalKey), not by the registered name. Registered names are first come, first served, so a name can pass to another plugin's tool; and a tool republished with a new description or schema asks again.Risks, accepted by the owner for this step
providerIdis what the registering plugin declares (ToolSourceRegistryImpl), so a plugin that registers under another plugin's id can take over its grants, as it can take over its registration today. Closing that needs the host to vouch for the source: step 2 of ADFA-7147.Owner's decision (David, AI-Core owner, 2026-11-18): option A. The risks above are accepted for this step. The self-declared
providerIdgap is closed in ADFA-7147 step 2, where the host vouches for the source.Effect on the SQLite debugger: none until #166 lands (and the Code on the Go release it needs). #166 switches on only four of the automatic SQLite debugger entry's read-only tools (
list_databases,get_schema,query,get_events), so the SQLite debugger would then ask at most four times a chat per app instead of once per call; each app's tools are separate grants, because their descriptions name the app. Every other MCP server's tools stay not read-only and keep asking on every call. This PR does not depend on #166 and builds againstmain.Merge note: whichever of this PR and #166 lands second must update AI-Agent-MCP's text that says its tools ask on every call and never get "always allow":
plugins/AI-Agent-MCP/README.md(lines 47-49 and 83-85 on #166's head 7122208),ai-agent-mcp.html(73-74, 140, 160-162), and the comments indebugger/ReadOnlyTrust.kt(9-11) andtools/McpToolSource.kt(293-295).Acceptance criteria: this step does not meet AC1 of ADFA-7147 (the SQLite debugger still asks once per tool per chat). AC2 holds. AC3 is covered by the tests below, which go through
ToolApprovalManager.ensureApproved.Tests:
ToolApprovalManagerTest,ContributedToolHandlerTestand a newChatViewModelApprovalGrantTestcover: read-only grant remembered; not-read-only asks again; another provider's tool with the same name asks again; a grant lapses when read-only is dropped; a new description or schema asks again (schema key order does not matter); the dialog request carries the read-only line; grants cleared on each chat change and kept on reselecting the open chat. Each fix was reverted on its own and its tests failed.ApprovalPresentationTestcovers the message cap, partly by replaying AppCompat'sAlertDialogLayoutmeasure passes: the buttons keep their full height at font scale 2.0 and at a modest scale; a message that fits is shown whole; a later measure reserves nothing more; a new measure pass that offers more before any layout reserves only once; an unspecified height gets the window cap; the floor and the half-window fallback.../../gradlew testDebugUnitTest assemblePlugininplugins/AI-Corepasses at aa9fafd (1,371 tests), andaddons checkpasses. The dialog fragment itself has no unit test (the module has no Robolectric).Device check: on a Galaxy Note 20 (Android 13) at font scale 2.0, first on 72971fd with a long
create_filepreview, then on 3cc8757. Both times all three buttons were fully visible without scrolling and the message scrolled on its own; on 3cc8757 the 8 dp gap under the title and the scroll indicators were there too. Not verified on a device: aa9fafd, and a medium message shown whole when it fits; both are unit-tested.Screens and text: the approval dialog is the stock
MaterialAlertDialog: stock title, stock buttons, stock message style. Two changes. When "Always Allow" is offered for a plugin's tool, the message adds the line above. The message now sits in a scroll area whose height is capped, at most half the window, so the stock button panel keeps its full height (72971fd7). Before, with a long argument preview at a large font size, the stock layout gave the message its space first and squeezed the stacked buttons, so "Always Allow" could not be reached. The cap reserves the buttons' extra height only on the first measure of a layout pass (9bc42f2f), a new measure pass that offers more height starts over (aa9fafdb), and an unspecified height counts as no limit, so only the half-window cap applies (3cc8757f). The scroll area puts back what the stock message panel had: the top and bottom scroll indicators (3502af18) and the 8 dp gap under the title (3cc8757f). (An intermediate custom dialog, 0bd787f, a1a2671 and 083078c, was reverted in 6acce32, 2e1f398 and a27863d in favour of this.) Changed text: the Always Allow tooltip ("for the rest of this chat"; forgotten on a new, other or cleared chat and when the IDE closes; not tied to arguments; the plugin's claim), the Agent guide's "Tools from other plugins" section, and the gallery pageai-core.html.🤖 Generated with Claude Code
https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn