Major UI refresh: sidebar redesign, theme expansion, and chat performance optimizations (#706)
## Summary Complete sidebar redesign and comprehensive UI polish pass with performance optimizations, theme system refinements, and desktop integration improvements. ## Key Changes **Sidebar & Navigation Redesign** - Redesigned sessions sidebar layout with unified button primitives - Added activity sections with project grouping and improved session organization - Refined sidebar corners, spacing, and visual hierarchy - Removed NavRail component in favor of streamlined sidebar - Stabilized sessions bar toggle position in fullscreen mode **Performance Optimizations** - Reduced chat streaming CPU usage and storage churn - Optimized task tool polling and live timers with debouncing - Prevented chat state races and reduced background request load - Debounced draft writes and coalesced session reloads - Optimized message store updates and turn tracking **Theme & Visual System** - Added theme-aware window corners (desktop) and border radius tokens - Introduced glassmorphism effects on desktop sidebar - Added backdrop blur to UI elements **Chat Experience** - Added session-based permission auto-accept toggle in chat input - Polished permission shield UX with improved icon sizing and spacing - Fixed chat scroll-to-bottom behavior and timeline tracking - Enhanced tool output display with better path label detection - Removed duplicate draft context details in chat header - Added text selection menu to chat messages **Git Improvements** - Refreshed git history visual design with cleaner dividers - Added remote removal action in sync selector - Stabilized git polling to prevent excessive requests - Improved tool output rendering for git operations **Settings & Panels** - Fixed mobile scrolling on settings pages - Made outside-click settings close instantly - Reduced settings load churn and CPU spikes - Improved services dropdown layout and spacing - Softened panel resize handles **Desktop Integration** - Synced macOS window theme with app theme - Restored window dragging in sidebar header zones - Fixed system window corners on macOS - Improved header session metadata and action controls **Button & Component Standardization** - Unified button primitives across all components - Standardized destructive action patterns - Removed unused button variants (button-large, button-small) - Aligned context tab close hit areas --------- Co-authored-by: Iuliia Ivashko <yulia.ivashko@gmail.com>
This commit is contained in:
committed by
GitHub
co-authored by
Iuliia Ivashko
parent
359879153a
commit
321cc7252a
@@ -9,10 +9,21 @@ import { useSessionStore } from '@/stores/useSessionStore';
|
||||
* Must be used inside RuntimeAPIProvider.
|
||||
*/
|
||||
export function useGitPolling() {
|
||||
const FORCE_DIFF_REFRESH_TOOLS = React.useMemo(() => new Set([
|
||||
'edit',
|
||||
'multiedit',
|
||||
'apply_patch',
|
||||
'write',
|
||||
'file_write',
|
||||
'create',
|
||||
]), []);
|
||||
|
||||
const { git } = useRuntimeAPIs();
|
||||
const fallbackDirectory = useDirectoryStore((state) => state.currentDirectory);
|
||||
const { currentSessionId, sessions, worktreeMetadata: worktreeMap } = useSessionStore();
|
||||
const { setActiveDirectory, startPolling, stopPolling, fetchAll } = useGitStore();
|
||||
const { currentSessionId, sessions, worktreeMetadata: worktreeMap, sessionStatus } = useSessionStore();
|
||||
const { setActiveDirectory, startPolling, setPollingMode, stopPolling, fetchAll, fetchStatus, clearDiffCache } = useGitStore();
|
||||
const immediateRefreshTimerRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
const lastImmediateRefreshAtRef = React.useRef<number>(0);
|
||||
|
||||
const effectiveDirectory = React.useMemo(() => {
|
||||
const worktreeMetadata = currentSessionId
|
||||
@@ -25,6 +36,62 @@ export function useGitPolling() {
|
||||
return worktreeMetadata?.path ?? sessionDirectory ?? fallbackDirectory ?? null;
|
||||
}, [currentSessionId, sessions, worktreeMap, fallbackDirectory]);
|
||||
|
||||
const activeSessionStatus = React.useMemo<'idle' | 'busy' | 'retry'>(() => {
|
||||
if (!currentSessionId) {
|
||||
return 'idle';
|
||||
}
|
||||
const activeStatus = sessionStatus?.get(currentSessionId)?.type;
|
||||
if (activeStatus === 'busy' || activeStatus === 'retry') {
|
||||
return activeStatus;
|
||||
}
|
||||
return 'idle';
|
||||
}, [currentSessionId, sessionStatus]);
|
||||
|
||||
const pollingMode = activeSessionStatus === 'busy' || activeSessionStatus === 'retry' ? 'busy' : 'normal';
|
||||
|
||||
React.useEffect(() => {
|
||||
setPollingMode(pollingMode);
|
||||
}, [pollingMode, setPollingMode]);
|
||||
|
||||
const queueImmediateStatusRefresh = React.useCallback((
|
||||
delayMs: number = 300,
|
||||
options?: { directory?: string | null; forceDiffRefresh?: boolean }
|
||||
) => {
|
||||
if (!git) {
|
||||
return;
|
||||
}
|
||||
|
||||
const hintedDirectory = typeof options?.directory === 'string' && options.directory.trim().length > 0 && options.directory !== 'global'
|
||||
? options.directory.trim()
|
||||
: null;
|
||||
const targetDirectory = hintedDirectory ?? effectiveDirectory;
|
||||
if (!targetDirectory) {
|
||||
return;
|
||||
}
|
||||
|
||||
const shouldForceDiffRefresh = options?.forceDiffRefresh === true;
|
||||
|
||||
const now = Date.now();
|
||||
if (now - lastImmediateRefreshAtRef.current < 800) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (immediateRefreshTimerRef.current) {
|
||||
clearTimeout(immediateRefreshTimerRef.current);
|
||||
}
|
||||
|
||||
immediateRefreshTimerRef.current = setTimeout(() => {
|
||||
immediateRefreshTimerRef.current = null;
|
||||
lastImmediateRefreshAtRef.current = Date.now();
|
||||
void (async () => {
|
||||
const statusChanged = await fetchStatus(targetDirectory, git, { silent: true });
|
||||
if (shouldForceDiffRefresh && !statusChanged) {
|
||||
clearDiffCache(targetDirectory);
|
||||
}
|
||||
})();
|
||||
}, delayMs);
|
||||
}, [clearDiffCache, effectiveDirectory, fetchStatus, git]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!effectiveDirectory || !git) {
|
||||
stopPolling();
|
||||
@@ -34,11 +101,41 @@ export function useGitPolling() {
|
||||
setActiveDirectory(effectiveDirectory);
|
||||
|
||||
void fetchAll(effectiveDirectory, git, { silentIfCached: true });
|
||||
|
||||
startPolling(git);
|
||||
|
||||
return () => {
|
||||
stopPolling();
|
||||
};
|
||||
}, [effectiveDirectory, git, setActiveDirectory, startPolling, stopPolling, fetchAll]);
|
||||
}, [activeSessionStatus, effectiveDirectory, fetchAll, git, setActiveDirectory, startPolling, stopPolling]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (typeof window === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
const handleGitRefreshHint = (event: Event) => {
|
||||
const customEvent = event as CustomEvent<{ directory?: string | null; toolName?: string | null }>;
|
||||
const toolName = typeof customEvent.detail?.toolName === 'string'
|
||||
? customEvent.detail.toolName.toLowerCase()
|
||||
: null;
|
||||
queueImmediateStatusRefresh(200, {
|
||||
directory: customEvent.detail?.directory ?? null,
|
||||
forceDiffRefresh: Boolean(toolName && FORCE_DIFF_REFRESH_TOOLS.has(toolName)),
|
||||
});
|
||||
};
|
||||
|
||||
window.addEventListener('openchamber:git-refresh-hint', handleGitRefreshHint as EventListener);
|
||||
return () => {
|
||||
window.removeEventListener('openchamber:git-refresh-hint', handleGitRefreshHint as EventListener);
|
||||
};
|
||||
}, [FORCE_DIFF_REFRESH_TOOLS, queueImmediateStatusRefresh]);
|
||||
|
||||
React.useEffect(() => {
|
||||
return () => {
|
||||
if (immediateRefreshTimerRef.current) {
|
||||
clearTimeout(immediateRefreshTimerRef.current);
|
||||
immediateRefreshTimerRef.current = null;
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user