Skip to content

Commit 6cd66f7

Browse files
dlab-antonmrubens
authored andcommitted
Feat: Vertical settings tabs (RooCodeInc#2914)
Co-authored-by: Matt Rubens <[email protected]>
1 parent 6c1e216 commit 6cd66f7

File tree

21 files changed

+656
-365
lines changed

21 files changed

+656
-365
lines changed

src/activate/registerCommands.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
116116
telemetryService.captureTitleButtonClicked("settings")
117117

118118
visibleProvider.postMessageToWebview({ type: "action", action: "settingsButtonClicked" })
119+
// Also explicitly post the visibility message to trigger scroll reliably
120+
visibleProvider.postMessageToWebview({ type: "action", action: "didBecomeVisible" })
119121
},
120122
"roo-cline.historyButtonClicked": () => {
121123
const visibleProvider = getVisibleProviderOrLog(outputChannel)
@@ -212,10 +214,26 @@ export const openClineInNewTab = async ({ context, outputChannel }: Omit<Registe
212214

213215
await tabProvider.resolveWebviewView(newPanel)
214216

217+
// Add listener for visibility changes to notify webview
218+
newPanel.onDidChangeViewState(
219+
(e) => {
220+
const panel = e.webviewPanel
221+
if (panel.visible) {
222+
panel.webview.postMessage({ type: "action", action: "didBecomeVisible" }) // Use the same message type as in SettingsView.tsx
223+
}
224+
},
225+
null, // First null is for `thisArgs`
226+
context.subscriptions, // Register listener for disposal
227+
)
228+
215229
// Handle panel closing events.
216-
newPanel.onDidDispose(() => {
217-
setPanel(undefined, "tab")
218-
})
230+
newPanel.onDidDispose(
231+
() => {
232+
setPanel(undefined, "tab")
233+
},
234+
null,
235+
context.subscriptions, // Also register dispose listener
236+
)
219237

220238
// Lock the editor group so clicking on files doesn't open them over the panel.
221239
await delay(100)

webview-ui/src/components/common/Tab.tsx

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { HTMLAttributes, useCallback } from "react"
1+
import React, { HTMLAttributes, useCallback, forwardRef } from "react"
22

33
import { useExtensionState } from "@/context/ExtensionStateContext"
44
import { cn } from "@/lib/utils"
55

66
type TabProps = HTMLAttributes<HTMLDivElement>
77

88
export const Tab = ({ className, children, ...props }: TabProps) => (
9-
<div className={cn("fixed inset-0 flex flex-col overflow-hidden", className)} {...props}>
9+
<div className={cn("fixed inset-0 flex flex-col", className)} {...props}>
1010
{children}
1111
</div>
1212
)
@@ -45,3 +45,47 @@ export const TabContent = ({ className, children, ...props }: TabProps) => {
4545
</div>
4646
)
4747
}
48+
49+
export const TabList = forwardRef<
50+
HTMLDivElement,
51+
HTMLAttributes<HTMLDivElement> & {
52+
value: string
53+
onValueChange: (value: string) => void
54+
}
55+
>(({ children, className, value, onValueChange, ...props }, ref) => {
56+
return (
57+
<div ref={ref} role="tablist" className={cn("flex", className)} {...props}>
58+
{React.Children.map(children, (child) => {
59+
if (React.isValidElement(child)) {
60+
return React.cloneElement(child as React.ReactElement<any>, {
61+
isSelected: child.props.value === value,
62+
onSelect: () => onValueChange(child.props.value),
63+
})
64+
}
65+
return child
66+
})}
67+
</div>
68+
)
69+
})
70+
71+
export const TabTrigger = forwardRef<
72+
HTMLButtonElement,
73+
React.ButtonHTMLAttributes<HTMLButtonElement> & {
74+
value: string
75+
isSelected?: boolean
76+
onSelect?: () => void
77+
}
78+
>(({ children, className, value: _value, isSelected, onSelect, ...props }, ref) => {
79+
return (
80+
<button
81+
ref={ref}
82+
role="tab"
83+
aria-selected={isSelected}
84+
tabIndex={isSelected ? 0 : -1}
85+
className={cn("focus:outline-none focus:ring-2 focus:ring-vscode-focusBorder", className)}
86+
onClick={onSelect}
87+
{...props}>
88+
{children}
89+
</button>
90+
)
91+
})

0 commit comments

Comments
 (0)