Skip to content

Commit dbdfc27

Browse files
proxikalclaude
andcommitted
refactor: address code review findings from Gemini Code Assist
- Extract SCROLL_THRESHOLD (300px) constant so auto-scroll hook and scroll-button visibility logic stay in sync - Extract CONTEXT_PANEL_WIDTH_PX (320px) constant to avoid layout drift if the context panel width is ever adjusted - Gate drag spacer on isElectronMode() && isLeftmostPane to match the TabBar drag region logic and prevent unintended drag regions in split-pane layouts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 890d2d8 commit dbdfc27

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/renderer/components/chat/ChatHistory.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ import { ChevronsDown } from 'lucide-react';
1010
import { useShallow } from 'zustand/react/shallow';
1111

1212
import { SessionContextPanel } from './SessionContextPanel/index';
13+
14+
/** Pixels from bottom considered "near bottom" for scroll-button visibility and auto-scroll. */
15+
const SCROLL_THRESHOLD = 300;
16+
/** Must match the `w-80` (320px) context panel width used in the layout below. */
17+
const CONTEXT_PANEL_WIDTH_PX = 320;
18+
1319
import { ChatHistoryEmptyState } from './ChatHistoryEmptyState';
1420
import { ChatHistoryItem } from './ChatHistoryItem';
1521
import { ChatHistoryLoadingState } from './ChatHistoryLoadingState';
@@ -351,14 +357,14 @@ export const ChatHistory = ({ tabId }: ChatHistoryProps): JSX.Element => {
351357
const container = scrollContainerRef.current;
352358
if (!container) return;
353359
const { scrollTop, scrollHeight, clientHeight } = container;
354-
setShowScrollButton(!isNearBottom(scrollTop, scrollHeight, clientHeight, 300));
360+
setShowScrollButton(!isNearBottom(scrollTop, scrollHeight, clientHeight, SCROLL_THRESHOLD));
355361
}, []);
356362

357363
// Auto-follow when conversation updates, but only if the user was already near bottom.
358364
// This preserves manual reading position when the user scrolls up.
359365
// Disabled during navigation to prevent conflicts with deep-link/search scrolling.
360366
const { scrollToBottom } = useAutoScrollBottom([conversation], {
361-
threshold: 300,
367+
threshold: SCROLL_THRESHOLD,
362368
smoothDuration: 300,
363369
autoBehavior: 'auto',
364370
disabled: shouldDisableAutoScroll,
@@ -841,7 +847,7 @@ export const ChatHistory = ({ tabId }: ChatHistoryProps): JSX.Element => {
841847
style={{
842848
right:
843849
isContextPanelVisible && allContextInjections.length > 0
844-
? 'calc(320px + 1rem)'
850+
? `calc(${CONTEXT_PANEL_WIDTH_PX}px + 1rem)`
845851
: '1rem',
846852
backgroundColor: 'var(--context-btn-bg)',
847853
color: 'var(--color-text-secondary)',

src/renderer/components/layout/TabBar.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,15 @@ export const TabBar = ({ paneId }: TabBarProps): React.JSX.Element => {
348348
</div>
349349

350350
{/* Drag spacer — fills empty space between tab list and action buttons.
351-
Gives users a reliable window-drag target regardless of how many tabs are open. */}
351+
Gives users a reliable window-drag target regardless of how many tabs are open.
352+
Only applied on the leftmost pane in Electron to match the TabBar drag region logic. */}
352353
<div
353354
className="flex-1 self-stretch"
354-
style={{ WebkitAppRegion: 'drag' } as React.CSSProperties}
355+
style={
356+
{
357+
WebkitAppRegion: isElectronMode() && isLeftmostPane ? 'drag' : undefined,
358+
} as React.CSSProperties
359+
}
355360
/>
356361

357362
{/* Right side actions */}

0 commit comments

Comments
 (0)