The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): give Button a loading prop that swaps label for spinner without layout shift
brooklyn!913867211621
diff --git a/apps/desktop/src/components/assistant-ui/tool/approval.tsx b/apps/desktop/src/components/assistant-ui/tool/approval.tsxindex 66731664ef1..0dbdfcda6df 100644--- a/apps/desktop/src/components/assistant-ui/tool/approval.tsx+++ b/apps/desktop/src/components/assistant-ui/tool/approval.tsx@@ -16,7 +16,7 @@ import {import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu'import { useI18n } from '@/i18n'import { triggerHaptic } from '@/lib/haptics'-import { AlertCircle, ChevronDown, Loader2 } from '@/lib/icons'+import { AlertCircle, ChevronDown } from '@/lib/icons'import { cn } from '@/lib/utils'import { $gateway } from '@/store/gateway'import { notifyError } from '@/store/notifications'@@ -204,12 +204,13 @@ const ApprovalBar: FC<{ request: ApprovalRequest; surface: 'floating' | 'inline'<ButtonclassName="h-full gap-1 rounded-none px-2 text-xs font-medium text-primary hover:bg-primary/15 hover:text-primary"disabled={busy}+ loading={submitting === 'once'}onClick={() => void respond('once')}size="xs"variant="ghost">- {submitting === 'once' ? <Loader2 className="size-3 animate-spin" /> : copy.run}- {submitting !== 'once' && <span className="text-[0.625rem] text-primary/60">{isMac ? '⌘⏎' : 'Ctrl⏎'}</span>}+ {copy.run}+ <span className="text-[0.625rem] text-primary/60">{isMac ? '⌘⏎' : 'Ctrl⏎'}</span></Button>{hasMoreOptions && <span aria-hidden className="w-px self-stretch bg-primary/20" />}{hasMoreOptions && (@@ -252,12 +253,13 @@ const ApprovalBar: FC<{ request: ApprovalRequest; surface: 'floating' | 'inline'<ButtonclassName="h-6 gap-1.5 rounded-md px-1.5 text-xs font-normal text-(--ui-text-tertiary) hover:text-foreground"disabled={busy}+ loading={submitting === 'deny'}onClick={() => void respond('deny')}size="xs"variant="ghost">- {submitting === 'deny' ? <Loader2 className="size-3 animate-spin" /> : copy.reject}- {submitting !== 'deny' && <span className="text-[0.625rem] opacity-55">Esc</span>}+ {copy.reject}+ <span className="text-[0.625rem] opacity-55">Esc</span></Button>{hasCommand && (diff --git a/apps/desktop/src/components/ui/button.tsx b/apps/desktop/src/components/ui/button.tsxindex 4af37b2fccf..444ea564c3b 100644--- a/apps/desktop/src/components/ui/button.tsx+++ b/apps/desktop/src/components/ui/button.tsx@@ -2,6 +2,7 @@ import { cva, type VariantProps } from 'class-variance-authority'import { Slot } from 'radix-ui'import * as React from 'react'+import { Loader2 } from '@/lib/icons'import { cn } from '@/lib/utils'// Text+icon actions underline the label on hover, not the glyph.@@ -73,21 +74,47 @@ function Button({variant = 'default',size = 'default',asChild = false,+ loading = false,+ children,+ disabled,...props}: React.ComponentProps<'button'> &VariantProps<typeof buttonVariants> & {asChild?: boolean+ /** Working. The label stays in flow but goes invisible and a spinner+ * sits over it, so the button keeps its exact width and height — a+ * label swapped for a glyph reflows every sibling on the row. */+ loading?: boolean}) {const Comp = asChild ? Slot.Root : 'button'return (<Comp- className={cn(buttonVariants({ variant, size }), className)}+ aria-busy={loading || undefined}+ className={cn(buttonVariants({ variant, size }), loading && 'relative', className)}data-size={size}data-slot="button"data-variant={variant}+ disabled={disabled || loading}{...props}- />+ >+ {loading ? (+ <>+ {/* Same flex + gap as the button itself, so the ghost label measures+ exactly what the live one did. The spinner sits in a wrapper so+ it is never a direct-child svg — the size variants' `has-[>svg]`+ would otherwise switch to icon padding and shave the width. */}+ <span aria-hidden className="invisible inline-flex items-center gap-[inherit]">+ {children}+ </span>+ <span aria-hidden className="absolute inset-0 grid place-items-center">+ <Loader2 className="animate-spin" />+ </span>+ </>+ ) : (+ children+ )}+ </Comp>)}