From 1b4ae14fd76298b05d87289f66970ee9a500357b Mon Sep 17 00:00:00 2001 From: Gagancreates Date: Mon, 25 May 2026 01:22:07 +0530 Subject: [PATCH] style: refine code-mode permission and command block UX - Render permission block before the command block - Collapse permission details after a response; click header to expand - Drop status icons/badge; use minimal green / bold red blocks - Auto-collapse the running command block once it completes --- apps/x/apps/renderer/src/App.tsx | 4 +- .../ai-elements/permission-request.tsx | 55 +++++++------------ .../renderer/src/components/chat-sidebar.tsx | 2 +- 3 files changed, 24 insertions(+), 37 deletions(-) diff --git a/apps/x/apps/renderer/src/App.tsx b/apps/x/apps/renderer/src/App.tsx index f61cc01d..563d3cb2 100644 --- a/apps/x/apps/renderer/src/App.tsx +++ b/apps/x/apps/renderer/src/App.tsx @@ -2263,7 +2263,7 @@ function App() { return next }) - if (event.toolCallId && event.toolName !== 'executeCommand') { + if (event.toolCallId) { setToolOpenForTab(activeChatTabIdRef.current, event.toolCallId, false) } @@ -5730,7 +5730,6 @@ function App() { const response = tabState.permissionResponses.get(item.id) || null return ( - {rendered} + {rendered} ) } diff --git a/apps/x/apps/renderer/src/components/ai-elements/permission-request.tsx b/apps/x/apps/renderer/src/components/ai-elements/permission-request.tsx index ba003254..d99d2e8b 100644 --- a/apps/x/apps/renderer/src/components/ai-elements/permission-request.tsx +++ b/apps/x/apps/renderer/src/components/ai-elements/permission-request.tsx @@ -9,8 +9,8 @@ import { DropdownMenuItem, } from "@/components/ui/dropdown-menu"; import { cn } from "@/lib/utils"; -import { AlertTriangleIcon, CheckCircleIcon, CheckIcon, ChevronDownIcon, RefreshCwIcon, Terminal, XCircleIcon, XIcon } from "lucide-react"; -import type { ComponentProps } from "react"; +import { AlertTriangleIcon, CheckIcon, ChevronDownIcon, RefreshCwIcon, Terminal, XIcon } from "lucide-react"; +import { useState, type ComponentProps } from "react"; import { ToolCallPart } from "@x/shared/dist/message.js"; import { ToolPermissionMetadata } from "@x/shared/dist/runs.js"; import z from "zod"; @@ -70,14 +70,19 @@ export const PermissionRequest = ({ const isResponded = response !== null; const isApproved = response === 'approve'; + // Once a response is chosen, collapse the details to just the header. + // Users can click the header to expand them again. + const [expanded, setExpanded] = useState(false); + const showDetails = !isResponded || expanded; + return (
- {isResponded ? ( - isApproved ? ( - - ) : ( - - ) - ) : ( + {!isResponded && ( )}
-
+
setExpanded((v) => !v) : undefined} + >

{isResponded ? (isApproved ? "Permission Granted" : "Permission Denied") : "Permission Required"} @@ -114,30 +116,15 @@ export const PermissionRequest = ({

{isResponded && ( - - {isApproved ? ( - <> - - Approved - - ) : ( - <> - - Denied - - )} - + /> )}
- {command && ( + {showDetails && command && (

Command @@ -147,7 +134,7 @@ export const PermissionRequest = ({

)} - {filePermission && ( + {showDetails && filePermission && (

@@ -175,7 +162,7 @@ export const PermissionRequest = ({

)} - {!command && !filePermission && toolCall.arguments && ( + {showDetails && !command && !filePermission && toolCall.arguments && (

Arguments diff --git a/apps/x/apps/renderer/src/components/chat-sidebar.tsx b/apps/x/apps/renderer/src/components/chat-sidebar.tsx index 0ff286e3..ff7c6921 100644 --- a/apps/x/apps/renderer/src/components/chat-sidebar.tsx +++ b/apps/x/apps/renderer/src/components/chat-sidebar.tsx @@ -608,7 +608,6 @@ export function ChatSidebar({ const response = tabState.permissionResponses.get(item.id) || null return ( - {rendered} onPermissionResponse(permRequest.toolCall.toolCallId, permRequest.subflow, 'approve')} @@ -618,6 +617,7 @@ export function ChatSidebar({ isProcessing={isActive && isProcessing} response={response} /> + {rendered} ) }