cleanup v2

This commit is contained in:
Chad Curtis committed 2025-09-05 23:30:45 +00:00
1 parent fcfcacb855
commit aeee32ea25
4 files changed
+24 -12

No files matched your search

+6 -5
View File
@@ -1,7 +1,8 @@
import { test, expect } from 'vitest';
import { render } from '@testing-library/react';
import { test } from 'vitest';
import App from './App';
test('App', () => {
// Simple test that just checks the App component can be imported
// The actual routing and functionality are tested in individual component tests
expect(true).toBe(true);
});
render(<App />);
})
+2 -2
View File
@@ -8,7 +8,7 @@ import { useAISettings } from '@/hooks/useAISettings';
import { useFS } from '@/hooks/useFS';
import { useKeepAlive } from '@/hooks/useKeepAlive';
import { useAIChatSession } from '@/hooks/useAIChatSession';
import { useAIChat } from '@/hooks/useAIChat';
import type { AIMessage } from '@/lib/SessionManager';
import { ModelSelector } from '@/components/ModelSelector';
@@ -127,7 +127,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
startGeneration,
stopGeneration,
startNewSession: internalStartNewSession,
} = useAIChatSession({
} = useAIChat({
projectId,
projectName,
tools,
@@ -26,7 +26,7 @@ interface StreamingMessage {
* Hook that provides AI chat functionality using the global session manager.
* Sessions persist and can run in the background when switching between projects.
*/
export function useAIChatSession({
export function useAIChat({
projectId,
projectName,
tools = {},
+15 -4
View File
@@ -1,4 +1,4 @@
import { useEffect } from 'react';
import { useEffect, useRef } from 'react';
import { useSessionManager } from './useSessionManager';
import type { SessionManagerEvents } from '@/lib/SessionManager';
@@ -12,11 +12,22 @@ export function useSessionSubscription<K extends keyof SessionManagerEvents>(
): void {
const sessionManager = useSessionManager();
// Use a ref to track the current handler and deps
const handlerRef = useRef(handler);
const depsRef = useRef(deps);
// Update refs when handler or deps change
useEffect(() => {
sessionManager.on(event, handler);
handlerRef.current = handler;
depsRef.current = deps;
}, [handler, deps]);
useEffect(() => {
const currentHandler = handlerRef.current;
sessionManager.on(event, currentHandler);
return () => {
sessionManager.off(event, handler);
sessionManager.off(event, currentHandler);
};
}, [sessionManager, event, handler, ...deps]); // eslint-disable-line react-hooks/exhaustive-deps
}, [sessionManager, event]);
}