Skip to content

fix(settings): clarify sandbox modes and improve blocked-command hint (#270)#274

Open
whitelonng wants to merge 1 commit into
KunAgent:developfrom
whitelonng:fix/sandbox-mode-ux
Open

fix(settings): clarify sandbox modes and improve blocked-command hint (#270)#274
whitelonng wants to merge 1 commit into
KunAgent:developfrom
whitelonng:fix/sandbox-mode-ux

Conversation

@whitelonng

Copy link
Copy Markdown
Contributor

Summary

Closes #270 (UX). When a shell command is blocked by the workspace-write sandbox, the raw backend error string (tool bash is blocked because workspace-write cannot sandbox host shell commands) is shown verbatim with no localization and no guidance on how to resolve it. Users in the issue comments were also confused about the differences between the four file-access modes.

This PR is a frontend-only UX fix (no kun runtime changes):

1. Per-mode descriptions in Settings

Previously each sandbox option in Settings showed only a 4–5 word label (Can edit workspace, Can only read files, …) with a single generic description that didn't explain what each mode actually allows or blocks — in particular, that shell commands are blocked under workspace-write.

Added four sandboxXxxDesc strings (en/zh) and made the SettingRow description update live to match the currently selected mode, so users see the concrete constraints (e.g. "Read and write files inside the workspace. Shell commands are blocked.") right under the dropdown.

2. Localized hint when a tool is blocked by the sandbox

In message-timeline-process.tsx, when a tool error message looks like a sandbox block (matched via the stable is blocked substring shared by all three backend sandbox error messages in sandbox-policy.ts), a localized one-line hint is shown above the raw error text, pointing the user to Settings → File access range → Can access all files. The original English error is preserved below for debugging.

Why frontend-only / string matching

ToolBlock carries the error as a plain text string in detail — there's no structured error code field on the block (the sandbox_command_blocked code exists in the backend but isn't surfaced to the frontend tool block). Changing the kun runtime to propagate a structured code is out of scope for this UX fix and would couple the change across both layers. is blocked is a stable public substring present in all three sandbox error messages (sandbox_read_only, sandbox_write_blocked, sandbox_command_blocked), so matching risk is low.

Verification

  • npm run typecheck passes
  • npm run lint — 0 errors (9 pre-existing warnings unchanged)
  • npx vitest run src/renderer/src/components — 257/257 passed

…KunAgent#270)

Users were confused by the file-access modes because each option only
showed a 4-5 word label with no explanation of what it allows or
blocks (notably that shell commands are blocked under workspace-write).
When bash was actually blocked the raw backend error string was shown
verbatim with no localization or guidance.

- Add per-mode descriptions (en/zh) to settings.json and surface the
  one matching the currently selected mode in the sandbox SettingRow,
  so the constraints update live as the user switches modes.
- Add a localized hint above the raw error in the tool error card when
  the message looks like a sandbox block (matched via the stable
  'is blocked' substring), pointing users to Settings to raise the
  access level. The original error text is preserved below for
  debugging.

Frontend-only; no kun runtime changes.
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.

1 participant