feat: show OpenClaw sidebar entry only in developer mode (#892)

This commit is contained in:
paisley
2026-04-22 17:42:27 +08:00
committed by GitHub
parent c29ff4dd33
commit eda34ad9ce
2 changed files with 25 additions and 20 deletions

View File

@@ -116,6 +116,7 @@ function getAgentIdFromSessionKey(sessionKey: string): string {
export function Sidebar() { export function Sidebar() {
const sidebarCollapsed = useSettingsStore((state) => state.sidebarCollapsed); const sidebarCollapsed = useSettingsStore((state) => state.sidebarCollapsed);
const setSidebarCollapsed = useSettingsStore((state) => state.setSidebarCollapsed); const setSidebarCollapsed = useSettingsStore((state) => state.setSidebarCollapsed);
const devModeUnlocked = useSettingsStore((state) => state.devModeUnlocked);
const sessions = useChatStore((s) => s.sessions); const sessions = useChatStore((s) => s.sessions);
const currentSessionKey = useChatStore((s) => s.currentSessionKey); const currentSessionKey = useChatStore((s) => s.currentSessionKey);
@@ -373,26 +374,28 @@ export function Sidebar() {
)} )}
</NavLink> </NavLink>
<Button {devModeUnlocked && (
data-testid="sidebar-open-dev-console" <Button
variant="ghost" data-testid="sidebar-open-dev-console"
className={cn( variant="ghost"
'flex items-center gap-2.5 rounded-lg px-2.5 py-2 h-auto text-[14px] font-medium transition-colors w-full mt-1', className={cn(
'hover:bg-black/5 dark:hover:bg-white/5 text-foreground/80', 'flex items-center gap-2.5 rounded-lg px-2.5 py-2 h-auto text-[14px] font-medium transition-colors w-full mt-1',
sidebarCollapsed ? 'justify-center px-0' : 'justify-start' 'hover:bg-black/5 dark:hover:bg-white/5 text-foreground/80',
)} sidebarCollapsed ? 'justify-center px-0' : 'justify-start'
onClick={openDevConsole} )}
> onClick={openDevConsole}
<div className="flex shrink-0 items-center justify-center text-muted-foreground"> >
<Terminal className="h-[18px] w-[18px]" strokeWidth={2} /> <div className="flex shrink-0 items-center justify-center text-muted-foreground">
</div> <Terminal className="h-[18px] w-[18px]" strokeWidth={2} />
{!sidebarCollapsed && ( </div>
<> {!sidebarCollapsed && (
<span className="flex-1 text-left overflow-hidden text-ellipsis whitespace-nowrap">{t('common:sidebar.openClawPage')}</span> <>
<ExternalLink className="h-3 w-3 shrink-0 ml-auto opacity-50 text-muted-foreground" /> <span className="flex-1 text-left overflow-hidden text-ellipsis whitespace-nowrap">{t('common:sidebar.openClawPage')}</span>
</> <ExternalLink className="h-3 w-3 shrink-0 ml-auto opacity-50 text-muted-foreground" />
)} </>
</Button> )}
</Button>
)}
</div> </div>
<ConfirmDialog <ConfirmDialog

View File

@@ -8,6 +8,7 @@ test.describe('ClawX developer-mode gated UI', () => {
await expect(page.getByTestId('settings-page')).toBeVisible(); await expect(page.getByTestId('settings-page')).toBeVisible();
await expect(page.getByTestId('settings-developer-section')).toHaveCount(0); await expect(page.getByTestId('settings-developer-section')).toHaveCount(0);
await expect(page.getByTestId('settings-dev-mode-switch')).toHaveAttribute('data-state', 'unchecked'); await expect(page.getByTestId('settings-dev-mode-switch')).toHaveAttribute('data-state', 'unchecked');
await expect(page.getByTestId('sidebar-open-dev-console')).toHaveCount(0);
await page.getByTestId('sidebar-nav-models').click(); await page.getByTestId('sidebar-nav-models').click();
await page.getByTestId('providers-add-button').click(); await page.getByTestId('providers-add-button').click();
@@ -22,6 +23,7 @@ test.describe('ClawX developer-mode gated UI', () => {
await expect(page.getByTestId('settings-dev-mode-switch')).toHaveAttribute('data-state', 'checked'); await expect(page.getByTestId('settings-dev-mode-switch')).toHaveAttribute('data-state', 'checked');
await expect(page.getByTestId('settings-developer-section')).toBeVisible(); await expect(page.getByTestId('settings-developer-section')).toBeVisible();
await expect(page.getByTestId('settings-developer-gateway-token')).toBeVisible(); await expect(page.getByTestId('settings-developer-gateway-token')).toBeVisible();
await expect(page.getByTestId('sidebar-open-dev-console')).toBeVisible();
await page.getByTestId('sidebar-nav-models').click(); await page.getByTestId('sidebar-nav-models').click();
await page.getByTestId('providers-add-button').click(); await page.getByTestId('providers-add-button').click();