mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-03-06 16:31:12 +08:00
feat: upgrade to v7.0.0 with major new features including Team Architecture v2 and Queue Scheduler
- Updated version in README and package.json to v7.0.0 - Added new features in WORKFLOW_GUIDE and WORKFLOW_GUIDE_CN - Introduced session lifecycle commands for managing workflow sessions - Enhanced NativeSessionPanel to support loading sessions by path or execution ID - Created useNativeSessionByPath hook for fetching session content by file path - Improved session metadata structure in API definitions - Increased stale and garbage collection times for session hooks - Refactored HistoryPage to utilize new session handling logic
This commit is contained in:
87
ccw/frontend/src/hooks/useNativeSessionByPath.ts
Normal file
87
ccw/frontend/src/hooks/useNativeSessionByPath.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
// ========================================
|
||||
// useNativeSessionByPath Hook
|
||||
// ========================================
|
||||
// TanStack Query hook for native CLI session content by file path
|
||||
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import {
|
||||
fetchNativeSessionWithOptions,
|
||||
type NativeSession,
|
||||
} from '../lib/api';
|
||||
|
||||
// ========== Query Keys ==========
|
||||
|
||||
export const nativeSessionPathKeys = {
|
||||
all: ['nativeSessionPath'] as const,
|
||||
details: () => [...nativeSessionPathKeys.all, 'detail'] as const,
|
||||
detail: (filePath: string | null) => [...nativeSessionPathKeys.details(), filePath] as const,
|
||||
};
|
||||
|
||||
// ========== Constants ==========
|
||||
|
||||
const STALE_TIME = 5 * 60 * 1000; // 5 minutes
|
||||
const GC_TIME = 30 * 60 * 1000; // 30 minutes
|
||||
|
||||
// ========== Types ==========
|
||||
|
||||
export interface UseNativeSessionByPathOptions {
|
||||
staleTime?: number;
|
||||
gcTime?: number;
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
export interface UseNativeSessionByPathReturn {
|
||||
data: NativeSession | undefined;
|
||||
isLoading: boolean;
|
||||
isFetching: boolean;
|
||||
error: Error | null;
|
||||
refetch: () => Promise<void>;
|
||||
}
|
||||
|
||||
// ========== Hook ==========
|
||||
|
||||
/**
|
||||
* Hook for fetching native CLI session content by file path
|
||||
*
|
||||
* @param filePath - The file path to the session file
|
||||
* @param tool - The tool type (gemini, qwen, codex, claude, opencode)
|
||||
* @param options - Query options
|
||||
*/
|
||||
export function useNativeSessionByPath(
|
||||
filePath: string | null,
|
||||
tool?: string,
|
||||
options: UseNativeSessionByPathOptions = {}
|
||||
): UseNativeSessionByPathReturn {
|
||||
const { staleTime = STALE_TIME, gcTime = GC_TIME, enabled = true } = options;
|
||||
|
||||
const query = useQuery<NativeSession>({
|
||||
queryKey: nativeSessionPathKeys.detail(filePath),
|
||||
queryFn: () => {
|
||||
if (!filePath) throw new Error('filePath is required');
|
||||
return fetchNativeSessionWithOptions({
|
||||
filePath,
|
||||
tool: tool as 'gemini' | 'qwen' | 'codex' | 'claude' | 'opencode' | undefined,
|
||||
}) as Promise<NativeSession>;
|
||||
},
|
||||
enabled: !!filePath && enabled,
|
||||
staleTime,
|
||||
gcTime,
|
||||
refetchOnWindowFocus: false,
|
||||
refetchOnMount: false,
|
||||
refetchOnReconnect: false,
|
||||
retry: 2,
|
||||
retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 10000),
|
||||
});
|
||||
|
||||
const refetch = async () => {
|
||||
await query.refetch();
|
||||
};
|
||||
|
||||
return {
|
||||
data: query.data,
|
||||
isLoading: query.isLoading,
|
||||
isFetching: query.isFetching,
|
||||
error: query.error,
|
||||
refetch,
|
||||
};
|
||||
}
|
||||
@@ -15,8 +15,8 @@ import { workspaceQueryKeys } from '@/lib/queryKeys';
|
||||
|
||||
// ========== Constants ==========
|
||||
|
||||
const STALE_TIME = 30 * 1000;
|
||||
const GC_TIME = 5 * 60 * 1000;
|
||||
const STALE_TIME = 2 * 60 * 1000; // 2 minutes (increased from 30s)
|
||||
const GC_TIME = 10 * 60 * 1000; // 10 minutes (increased from 5min)
|
||||
|
||||
// ========== Types ==========
|
||||
|
||||
|
||||
Reference in New Issue
Block a user