fix: consolidate auth error handling and fix start.bat credential check

This commit addresses issues found during review of PRs #12 and #28:

## PR #12 (Auth Error Handling) Fixes

- Create shared auth.py module with centralized AUTH_ERROR_PATTERNS,
  is_auth_error(), and print_auth_error_help() functions
- Fix start.bat to use directory check instead of outdated
  .credentials.json file check (matching start.sh behavior)
- Update process_manager.py to import from shared auth module
- Update start.py to import from shared auth module
- Update documentation comments in autonomous_agent_demo.py and
  client.py to remove references to deprecated .credentials.json

## PR #28 (Feature Management) Improvements

- Add _priority_lock threading lock to feature_mcp.py to prevent
  race conditions when multiple features are created simultaneously
- Apply lock to feature_create, feature_create_bulk, and feature_skip
- Add checkAndSendTimeoutRef cleanup in useAssistantChat.ts to
  prevent memory leaks on component unmount
- Clear currentAssistantMessageRef on response_done

## Code Quality

- All Python files pass ruff linting
- All security tests pass (91/91)
- UI passes ESLint and TypeScript compilation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Auto
2026-01-10 12:19:32 +02:00
parent cd82a4cf46
commit a0f7e72361
10 changed files with 430 additions and 170 deletions

View File

@@ -43,6 +43,7 @@ export function useAssistantChat({
const maxReconnectAttempts = 3;
const pingIntervalRef = useRef<number | null>(null);
const reconnectTimeoutRef = useRef<number | null>(null);
const checkAndSendTimeoutRef = useRef<number | null>(null);
// Clean up on unmount
useEffect(() => {
@@ -53,9 +54,13 @@ export function useAssistantChat({
if (reconnectTimeoutRef.current) {
clearTimeout(reconnectTimeoutRef.current);
}
if (checkAndSendTimeoutRef.current) {
clearTimeout(checkAndSendTimeoutRef.current);
}
if (wsRef.current) {
wsRef.current.close();
}
currentAssistantMessageRef.current = null;
};
}, []);
@@ -203,6 +208,7 @@ export function useAssistantChat({
case "response_done": {
setIsLoading(false);
currentAssistantMessageRef.current = null;
// Mark current message as done streaming
setMessages((prev) => {
@@ -251,11 +257,18 @@ export function useAssistantChat({
const start = useCallback(
(existingConversationId?: number | null) => {
// Clear any pending check timeout from previous call
if (checkAndSendTimeoutRef.current) {
clearTimeout(checkAndSendTimeoutRef.current);
checkAndSendTimeoutRef.current = null;
}
connect();
// Wait for connection then send start message
const checkAndSend = () => {
if (wsRef.current?.readyState === WebSocket.OPEN) {
checkAndSendTimeoutRef.current = null;
setIsLoading(true);
const payload: { type: string; conversation_id?: number } = {
type: "start",
@@ -266,11 +279,13 @@ export function useAssistantChat({
}
wsRef.current.send(JSON.stringify(payload));
} else if (wsRef.current?.readyState === WebSocket.CONNECTING) {
setTimeout(checkAndSend, 100);
checkAndSendTimeoutRef.current = window.setTimeout(checkAndSend, 100);
} else {
checkAndSendTimeoutRef.current = null;
}
};
setTimeout(checkAndSend, 100);
checkAndSendTimeoutRef.current = window.setTimeout(checkAndSend, 100);
},
[connect],
);