Skip to content

Commit b199448

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
improvement(ui): share browser toolbar actions
1 parent ea31ca7 commit b199448

3 files changed

Lines changed: 40 additions & 32 deletions

File tree

‎apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/browser-session/browser-downloads.tsx‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import { useEffect, useMemo, useRef, useState } from 'react'
44
import type { BrowserDownloadInfo } from '@sim/desktop-bridge'
55
import {
6-
Button,
76
cn,
87
DropdownMenu,
98
DropdownMenuContent,
@@ -18,6 +17,7 @@ import {
1817
showBrowserDownloadInFolder,
1918
showBrowserDownloadsMenu,
2019
} from '@/lib/browser-agent/transport'
20+
import { BrowserToolbarButton } from '@/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/browser-session/browser-toolbar-button'
2121

2222
/** Aggregate byte progress for the toolbar rail; unknown-size downloads are ignored. */
2323
export function aggregateDownloadPercent(downloads: BrowserDownloadInfo[]): number | null {
@@ -127,14 +127,11 @@ export function BrowserDownloads({ scopeId, open, requestOpen, onClose }: Browse
127127
}}
128128
>
129129
<DropdownMenuTrigger asChild>
130-
<Button
130+
<BrowserToolbarButton
131131
ref={buttonRef}
132-
type='button'
133-
variant='ghost-secondary'
134-
size='sm'
135132
aria-label={label}
136133
title={label}
137-
className='relative size-[30px] shrink-0 overflow-hidden p-0'
134+
className='relative overflow-hidden'
138135
onClick={() => setHasUnviewedCompletion(false)}
139136
>
140137
{hasActiveDownloads ? (
@@ -160,7 +157,7 @@ export function BrowserDownloads({ scopeId, open, requestOpen, onClose }: Browse
160157
/>
161158
</span>
162159
)}
163-
</Button>
160+
</BrowserToolbarButton>
164161
</DropdownMenuTrigger>
165162
<DropdownMenuContent align='end' sideOffset={5} className='w-[320px]'>
166163
<DropdownMenuLabel>Downloads</DropdownMenuLabel>

‎apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/browser-session/browser-session.tsx‎

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import type {
1616
DesktopAppearanceTheme,
1717
} from '@sim/desktop-bridge'
1818
import {
19-
Button,
2019
ChipConfirmModal,
2120
ChipInput,
2221
chipVariants,
@@ -82,6 +81,7 @@ import {
8281
useBrowserPanelOcclusion,
8382
} from '@/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/browser-session/browser-panel-occlusion'
8483
import { BrowserThemeNotice } from '@/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/browser-session/browser-theme-notice'
84+
import { BrowserToolbarButton } from '@/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/browser-session/browser-toolbar-button'
8585
import {
8686
buildOmniboxSuggestions,
8787
googleSearchUrl,
@@ -1034,38 +1034,26 @@ export function BrowserSession({
10341034
<div ref={panelRef} className='flex h-full flex-col overflow-hidden'>
10351035
<div className='relative shrink-0 border-[var(--border)] border-b bg-[var(--bg)]'>
10361036
<div className='flex items-center gap-1 px-2.5 py-1.5'>
1037-
<Button
1038-
type='button'
1039-
variant='ghost-secondary'
1040-
size='sm'
1037+
<BrowserToolbarButton
10411038
aria-label='Back'
10421039
disabled={!pageState?.canGoBack}
1043-
className='size-[30px] shrink-0 p-0'
10441040
onClick={() => sendBrowserPanelAction('back', {}, scopeId)}
10451041
>
10461042
<ArrowLeft className='size-[14px]' />
1047-
</Button>
1048-
<Button
1049-
type='button'
1050-
variant='ghost-secondary'
1051-
size='sm'
1043+
</BrowserToolbarButton>
1044+
<BrowserToolbarButton
10521045
aria-label='Forward'
10531046
disabled={!pageState?.canGoForward}
1054-
className='size-[30px] shrink-0 p-0'
10551047
onClick={() => sendBrowserPanelAction('forward', {}, scopeId)}
10561048
>
10571049
<ArrowRight className='size-[14px]' />
1058-
</Button>
1059-
<Button
1060-
type='button'
1061-
variant='ghost-secondary'
1062-
size='sm'
1050+
</BrowserToolbarButton>
1051+
<BrowserToolbarButton
10631052
aria-label='Reload page'
1064-
className='size-[30px] shrink-0 p-0'
10651053
onClick={() => sendBrowserPanelAction('reload', {}, scopeId)}
10661054
>
10671055
<RefreshCw className='size-[14px]' />
1068-
</Button>
1056+
</BrowserToolbarButton>
10691057
{/* URL bar: Enter navigates the agent browser. */}
10701058
<Popover
10711059
open={suggestionsOpen}
@@ -1266,17 +1254,13 @@ export function BrowserSession({
12661254
}}
12671255
>
12681256
<DropdownMenuTrigger asChild>
1269-
<Button
1257+
<BrowserToolbarButton
12701258
ref={fillButtonRef}
1271-
type='button'
1272-
variant='ghost-secondary'
1273-
size='sm'
12741259
aria-label='Fill a saved password'
12751260
title='Fill a saved password'
1276-
className='size-[30px] shrink-0 p-0'
12771261
>
12781262
<Key className='size-[14px]' />
1279-
</Button>
1263+
</BrowserToolbarButton>
12801264
</DropdownMenuTrigger>
12811265
<DropdownMenuContent align='end' sideOffset={5} className='w-[240px]'>
12821266
{fillOptions.map((credential) => (
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use client'
2+
3+
import { type ComponentProps, forwardRef } from 'react'
4+
import { Button, cn } from '@sim/emcn'
5+
6+
type BrowserToolbarButtonProps = Omit<
7+
ComponentProps<typeof Button>,
8+
'variant' | 'size' | 'iconSize' | 'iconPadding'
9+
> & {
10+
'aria-label': string
11+
}
12+
13+
/** Browser navigation and utility action; forwards menu-anchor refs and native events. */
14+
export const BrowserToolbarButton = forwardRef<HTMLButtonElement, BrowserToolbarButtonProps>(
15+
({ className, ...props }, ref) => (
16+
<Button
17+
{...props}
18+
ref={ref}
19+
type='button'
20+
variant='ghost-secondary'
21+
size='sm'
22+
className={cn('size-[30px] shrink-0 p-0', className)}
23+
/>
24+
)
25+
)
26+
27+
BrowserToolbarButton.displayName = 'BrowserToolbarButton'

0 commit comments

Comments
 (0)