mirror of
https://github.com/jlengrand/Maestro.git
synced 2026-03-10 08:31:19 +00:00
fix: Improve History panel performance and fix type duplications
- Remove duplicate GlobalStats interface from types (was causing conflicts) - Only track scroll position when on Files tab (prevent unnecessary updates) - Memoize activeSession to reduce re-render cascades - Wrap HistoryPanel in React.memo to prevent unnecessary re-renders
This commit is contained in:
@@ -782,7 +782,10 @@ export default function MaestroConsole() {
|
||||
|
||||
// Keyboard navigation state
|
||||
const [selectedSidebarIndex, setSelectedSidebarIndex] = useState(0);
|
||||
const activeSession = sessions.find(s => s.id === activeSessionId) || sessions[0] || null;
|
||||
const activeSession = useMemo(() =>
|
||||
sessions.find(s => s.id === activeSessionId) || sessions[0] || null,
|
||||
[sessions, activeSessionId]
|
||||
);
|
||||
const theme = THEMES[activeThemeId];
|
||||
const anyTunnelActive = sessions.some(s => s.tunnelActive);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ export interface HistoryPanelHandle {
|
||||
focus: () => void;
|
||||
}
|
||||
|
||||
export const HistoryPanel = forwardRef<HistoryPanelHandle, HistoryPanelProps>(function HistoryPanel({ session, theme, onJumpToClaudeSession }, ref) {
|
||||
export const HistoryPanel = React.memo(forwardRef<HistoryPanelHandle, HistoryPanelProps>(function HistoryPanel({ session, theme, onJumpToClaudeSession }, ref) {
|
||||
const [historyEntries, setHistoryEntries] = useState<HistoryEntry[]>([]);
|
||||
const [activeFilters, setActiveFilters] = useState<Set<HistoryEntryType>>(new Set(['AUTO', 'USER']));
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
@@ -392,4 +392,4 @@ export const HistoryPanel = forwardRef<HistoryPanelHandle, HistoryPanelProps>(fu
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -164,10 +164,13 @@ export function RightPanel(props: RightPanelProps) {
|
||||
}
|
||||
}}
|
||||
onScroll={(e) => {
|
||||
const scrollTop = e.currentTarget.scrollTop;
|
||||
setSessions(prev => prev.map(s =>
|
||||
s.id === session.id ? { ...s, fileExplorerScrollPos: scrollTop } : s
|
||||
));
|
||||
// Only track scroll position for file explorer tab
|
||||
if (activeRightTab === 'files') {
|
||||
const scrollTop = e.currentTarget.scrollTop;
|
||||
setSessions(prev => prev.map(s =>
|
||||
s.id === session.id ? { ...s, fileExplorerScrollPos: scrollTop } : s
|
||||
));
|
||||
}
|
||||
}}
|
||||
>
|
||||
{activeRightTab === 'files' && (
|
||||
|
||||
@@ -216,15 +216,3 @@ export interface CustomAICommand {
|
||||
isBuiltIn?: boolean; // If true, cannot be deleted (only edited)
|
||||
}
|
||||
|
||||
// Persistent global stats that survive app restarts
|
||||
export interface GlobalStats {
|
||||
totalSessions: number;
|
||||
totalMessages: number;
|
||||
totalInputTokens: number;
|
||||
totalOutputTokens: number;
|
||||
totalCacheReadTokens: number;
|
||||
totalCacheCreationTokens: number;
|
||||
totalCostUsd: number;
|
||||
totalActiveTimeMs: number;
|
||||
lastUpdated: number; // Timestamp for tracking when stats were last updated
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user