Skip to content

feat(vscode): add calculated permissions display and subagent visibility to agent details#8505

Merged
markijbema merged 7 commits into
mainfrom
feat/agent-permissions-display
Apr 8, 2026
Merged

feat(vscode): add calculated permissions display and subagent visibility to agent details#8505
markijbema merged 7 commits into
mainfrom
feat/agent-permissions-display

Conversation

@markijbema
Copy link
Copy Markdown
Contributor

@markijbema markijbema commented Apr 7, 2026

Summary

  • Add a collapsible "Calculated Permissions" section to the agent detail view in the Agent Behaviour settings tab
  • Show all agents including subagents in the agent list (with a "subagent" badge)
  • Display the CLI-calculated permission ruleset for each agent — the same data used at runtime for permission checks, with no duplicated logic
  • Scope the default-agent picker to only visible primary agents (the CLI rejects subagents as default_agent values)

What it looks like

When you click an agent in the Agent Behaviour tab, a new "Calculated Permissions" section appears (collapsed by default). Expanding it shows:

  1. Effective summary — color-coded badges showing the resolved action (allow/ask/deny) for each tool at the wildcard level
  2. Full ruleset table — all rules in evaluation order (last match wins), with Tool, Pattern, and Action columns

Why

This helps debug permission-related issues by making it easy to inspect what the CLI backend actually computes for a given agent's permissions, without having to use the kilo debug agent CLI command.

Ref: #8331

Key design decisions

  • No duplicated logic — the frontend displays the permission ruleset exactly as the CLI backend computes it, rather than re-implementing resolution logic
  • Graceful fallbacksetAllAgents(message.allAgents ?? message.agents) handles older CLI versions that don't send allAgents
  • Minimal memory overhead — the allAgents signal stores a few extra agent objects (subagents + hidden modes) beyond what agents already holds; the data was already being transmitted over postMessage, just not retained
  • Default-agent picker scoped correctlydefaultAgentOptions only includes visible primary agents since the CLI rejects subagents/hidden modes as default_agent values

Changed files

File Change
packages/kilo-vscode/src/KiloProvider.ts Forward all agents (including subagents) with their permission rulesets via new allAgents field; extract mapAgent helper to module scope
packages/kilo-vscode/webview-ui/src/types/messages.ts Add PermissionRuleItem type and permission field to AgentInfo, add allAgents to AgentsLoadedMessage
packages/kilo-vscode/webview-ui/src/context/session.tsx Add allAgents signal and expose on context
packages/kilo-vscode/webview-ui/src/components/settings/AgentBehaviourTab.tsx Use allAgents() for full agent list (shows subagents with badge), scope defaultAgentOptions to visible primary agents only
packages/kilo-vscode/webview-ui/src/components/settings/ModeEditView.tsx Add collapsible PermissionRuleset component with SolidJS Show callback pattern, distinct "unknown" color for unrecognized actions
packages/kilo-vscode/webview-ui/src/stories/StoryProviders.tsx Add allAgents to mock session value
packages/kilo-vscode/webview-ui/src/stories/settings.stories.tsx Add allAgents to all story session mocks
packages/kilo-vscode/webview-ui/src/i18n/*.ts Add translation keys for permissions section (all 20 locales)
CleanShot 2026-04-08 at 13 26 12@2x

also added a copy button so people can just drop the json in issues:
CleanShot 2026-04-08 at 14 23 32@2x

@markijbema
Copy link
Copy Markdown
Contributor Author

LLM Code Review

Note: This review was performed by an LLM (Claude) at the request of @markijbema. It is not a human review.


Overall Assessment

This is a well-structured feature addition that surfaces CLI-computed permission rulesets in the VS Code extension's Agent Behaviour settings. The approach of forwarding the already-resolved data from the backend (rather than duplicating permission resolution logic in the frontend) is the right call.

Positives

  • No duplicated logic — The frontend simply displays what the CLI backend already computes. This avoids drift between what the UI shows and what actually governs runtime permission checks.
  • Graceful fallbacksetAllAgents(message.allAgents ?? message.agents) in session.tsx handles older CLI versions that don't send allAgents, preventing breakage.
  • Good UX decisions — The permissions section is collapsed by default, which avoids overwhelming users who don't need it. The summary badges give a quick at-a-glance view before diving into the full table.
  • i18n coverage — All 20 locale files have been updated with the new translation keys.
  • Default agent picker scoped correctly — The defaultAgentOptions memo was updated to only use visible primary agents, since the CLI rejects subagents as default_agent values. This is a subtle but important correctness fix.

Issues & Suggestions

  1. Inline styles — The PermissionRuleset component and the subagent badge use extensive inline style objects. This is consistent with the existing codebase patterns in this file, but it does make the component harder to maintain. Not a blocker, but worth noting for future refactoring.

  2. agent()!.permission! non-null assertion (ModeEditView.tsx:237) — The Show when={agent()?.permission} guard makes this safe at runtime, but the double non-null assertion (!) is a code smell. Consider:

    <Show when={agent()?.permission} keyed>
      {(rules) => <PermissionRuleset rules={rules} ... />}
    </Show>

    This eliminates the assertion entirely using SolidJS's Show callback pattern.

  3. ACTION_COLORS fallback — The fallback ACTION_COLORS[action] ?? ACTION_COLORS.ask silently maps unknown actions to the "ask" color. If the CLI introduces a new action type, this would be misleading. Consider either logging unknown actions or using a visually distinct "unknown" style.

  4. Summary computation — The summary memo iterates all rules and keeps only those with pattern === "*". If the CLI ever uses a different convention for the "catch-all" pattern, this would silently produce an empty summary. A comment documenting this assumption would help.

  5. mapAgent closure (KiloProvider.ts) — The mapAgent helper is defined inside the callback, which means it's recreated on every agent load. It's a minor allocation, not a perf concern in practice, but moving it to module scope would be marginally cleaner.

  6. Visual regression snapshots — Three workflow-related snapshots (agent-behaviour-workflows, agent-behaviour-workflows-empty) now have identical SHA and size (53794), which suggests they may be rendering the same state. Worth verifying this is intentional and not a regression in the test setup.

Verdict

The feature is solid, well-scoped, and follows existing patterns. The issues above are minor and none are blockers. The most actionable improvement would be item #2 (eliminating the non-null assertion with SolidJS's Show callback).

@markijbema
Copy link
Copy Markdown
Contributor Author

All items addressed in dfed296:

  1. Non-null assertion — replaced with SolidJS Show callback pattern (keyed + render function)
  2. ACTION_COLORS fallback — added a visually distinct unknown color entry; fallback now uses it instead of ask
  3. Wildcard pattern assumption — added a documenting comment about the "*" convention
  4. mapAgent closure — moved to module scope with an explicit Agent type
  5. Visual regression snapshots — verified; identical snapshots are expected (both stories render the same workflows subtab layout)

Item 1 (inline styles) was noted as not a blocker and consistent with existing patterns, so left as-is.

kilo-code-bot Bot and others added 5 commits April 8, 2026 13:36
Show the resolved permission ruleset for each agent in the Agent
Behaviour settings tab. The section is collapsed by default and
expands to show an effective-action summary plus the full ordered
rule table (last match wins).

Changes:
- Forward all agents (including subagents) with their CLI-calculated
  permission rulesets to the webview via a new allAgents field
- Add collapsible PermissionRuleset component in ModeEditView
- Show subagents in the Agent Behaviour agent list with a badge
- Add PermissionRuleItem type mirroring the backend PermissionNext.Rule

Ref: #8331
- Derive defaultAgentOptions from session.agents() (visible agents
  only) so subagents/hidden agents cannot be selected as default_agent
- Add i18n translations for the new permissions UI to all 18 locale
  files (ar, br, bs, da, de, es, fr, ja, ko, nl, no, pl, ru, th, tr,
  uk, zh, zht)
Forward the hidden flag in the allAgents mapping so the webview can
distinguish internal modes (compaction, title, summary). Filter them
out of the Agent Behaviour settings list to prevent leaking
backend-only modes into the UI.
…display

- Replace non-null assertion with SolidJS Show callback pattern
- Add 'unknown' color fallback for unrecognized permission actions
- Document wildcard pattern assumption in summary computation
- Move mapAgent helper to module scope for better code organization
The AgentBehaviourTab now uses session.allAgents() but the story mocks
only provided agents(), causing 'Cannot read properties of undefined
(reading length)' errors in storybook.
@markijbema markijbema force-pushed the feat/agent-permissions-display branch from c959e1e to 69754b8 Compare April 8, 2026 11:36
@markijbema markijbema changed the title feat(vscode): add calculated permissions display to agent details feat(vscode): add calculated permissions display and subagent visibility to agent details Apr 8, 2026
@markijbema markijbema marked this pull request as ready for review April 8, 2026 12:12
Adds a copy icon button in the Calculated Permissions header that copies
the agent name and full permission ruleset as formatted JSON to the
clipboard, making it easy to share in issues or discussions.
files: ["src/KiloProvider.ts"],
rules: {
"max-lines": ["error", 3200],
"max-lines": ["error", 3300],
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably refactor?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, @imanolmzd-svg indicated he was looking into it, but I don't think this specific pr is a big offender

return
}
setAgents(message.agents)
setAllAgents(message.allAgents ?? message.agents)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the fallback correct here?

@marius-kilocode
Copy link
Copy Markdown
Collaborator

@markijbema would this always be shown to users?

const tools = new Map<string, PermissionRuleItem["action"]>()
for (const rule of props.rules) {
if (rule.pattern === "*") {
tools.set(rule.permission, rule.action)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Wildcard permission rules render a misleading summary

The CLI already emits catch-all rules like { permission: "*", pattern: "*", action: "allow" }. In that case this memo records a single * entry, so the new "Effective summary" shows *: allow instead of the effective action for each tool. That makes the summary disagree with the runtime ruleset for agents whose defaults come from wildcard permissions.

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Apr 8, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
packages/kilo-vscode/webview-ui/src/components/settings/ModeEditView.tsx 284 Wildcard permission rules collapse to a single * badge, so the "Effective summary" can misrepresent the runtime permissions.
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
packages/kilo-vscode/webview-ui/src/context/session.tsx 265 removeMode() updates agents but not allAgents, so optimistically removed modes can remain visible until the backend refresh finishes.
Files Reviewed (27 files)
  • packages/kilo-vscode/eslint.config.mjs
  • packages/kilo-vscode/src/KiloProvider.ts
  • packages/kilo-vscode/webview-ui/src/components/settings/AgentBehaviourTab.tsx
  • packages/kilo-vscode/webview-ui/src/components/settings/ModeEditView.tsx
  • packages/kilo-vscode/webview-ui/src/context/session.tsx
  • packages/kilo-vscode/webview-ui/src/i18n/ar.ts
  • packages/kilo-vscode/webview-ui/src/i18n/br.ts
  • packages/kilo-vscode/webview-ui/src/i18n/bs.ts
  • packages/kilo-vscode/webview-ui/src/i18n/da.ts
  • packages/kilo-vscode/webview-ui/src/i18n/de.ts
  • packages/kilo-vscode/webview-ui/src/i18n/en.ts
  • packages/kilo-vscode/webview-ui/src/i18n/es.ts
  • packages/kilo-vscode/webview-ui/src/i18n/fr.ts
  • packages/kilo-vscode/webview-ui/src/i18n/ja.ts
  • packages/kilo-vscode/webview-ui/src/i18n/ko.ts
  • packages/kilo-vscode/webview-ui/src/i18n/nl.ts
  • packages/kilo-vscode/webview-ui/src/i18n/no.ts
  • packages/kilo-vscode/webview-ui/src/i18n/pl.ts
  • packages/kilo-vscode/webview-ui/src/i18n/ru.ts
  • packages/kilo-vscode/webview-ui/src/i18n/th.ts
  • packages/kilo-vscode/webview-ui/src/i18n/tr.ts
  • packages/kilo-vscode/webview-ui/src/i18n/uk.ts
  • packages/kilo-vscode/webview-ui/src/i18n/zh.ts
  • packages/kilo-vscode/webview-ui/src/i18n/zht.ts
  • packages/kilo-vscode/webview-ui/src/stories/StoryProviders.tsx
  • packages/kilo-vscode/webview-ui/src/stories/settings.stories.tsx
  • packages/kilo-vscode/webview-ui/src/types/messages.ts

Reviewed by gpt-5.4-20260305 · 3,287,890 tokens

@markijbema
Copy link
Copy Markdown
Contributor Author

@markijbema would this always be shown to users?

yes, but it is folded by default

@markijbema markijbema merged commit ee332b4 into main Apr 8, 2026
17 checks passed
@markijbema markijbema deleted the feat/agent-permissions-display branch April 8, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants