• Will Chen's avatar
    Refactor React Query keys to use centralized factory pattern (#2268) · 8a38dc75
    Will Chen 提交于
    Introduce a type-safe, centralized query key system following TanStack
    Query best practices:
    
    - Add src/lib/queryKeys.ts with hierarchical factory functions
    - Use `as const` assertions for full type inference
    - Group keys by feature (apps, chats, versions, etc.)
    - Support prefix-based invalidation via parent keys
    
    Update all 30+ hooks and components to use the new queryKeys:
    - Replace inline string arrays with factory calls
    - Replace scattered exports (CHATS_QUERY_KEY, TOKEN_COUNT_QUERY_KEY,
    etc.)
    - Consistent pattern: queryKeys.<feature>.<operation>(params)
    
    Benefits:
    - Single source of truth for all query keys
    - Full autocomplete/IntelliSense support
    - Type-safe invalidation (catches typos at compile time)
    - Easier refactoring and key discovery
    
    <!-- This is an auto-generated description by cubic. -->
    ---
    ## Summary by cubic
    Centralized React Query keys behind a typed queryKeys factory and
    updated 30+ hooks/components to use it. This improves type-safety,
    enables autocomplete, and makes invalidation and refactors simpler.
    
    - **Refactors**
    - Added src/lib/queryKeys.ts with hierarchical factory functions (as
    const) grouped by feature.
    - Replaced inline arrays and scattered constants (e.g., CHATS_QUERY_KEY,
    TOKEN_COUNT_QUERY_KEY, APP_THEME_QUERY_KEY, SUPABASE_QUERY_KEYS).
    - Standardized invalidate/remove calls to use parent keys (e.g.,
    queryKeys.chats.all, queryKeys.versions.list({ appId })).
    - Structured MCP keys (mcp.toolsByServer.all and
    mcp.toolsByServer.list({ serverIds })) and updated Supabase branches to
    include organizationSlug.
    - No behavior changes; safer invalidation and consistent keys across the
    app.
    
    - **Migration**
    - Use queryKeys.<feature>.<operation>(params object) for all queryKey
    definitions.
    - Invalidate broadly via parent keys when needed (e.g.,
    queryKeys.chats.all).
    - Update Supabase branches calls to pass organizationSlug:
    queryKeys.supabase.branches({ projectId, organizationSlug }).
      - Do not add or export per-hook key constants; rely on queryKeys.
    
    <sup>Written for commit 2b80e408f077b8ea3141369ca21f62e514852cfd.
    Summary will update on new commits.</sup>
    
    <!-- End of auto-generated description by cubic. -->
    
    <!-- CURSOR_SUMMARY -->
    ---
    
    > [!NOTE]
    > Introduces a centralized, typed React Query key factory and applies it
    across the app for consistency and safer invalidation.
    > 
    > - Adds `src/lib/queryKeys.ts` with hierarchical, `as const` key
    factories (e.g., `queryKeys.apps.detail`, `queryKeys.versions.list`)
    > - Refactors 30+ hooks/components to use factory keys in
    `useQuery`/`useMutation` and `invalidateQueries`/`removeQueries`
    > - Replaces scattered constants (e.g., `CHATS_QUERY_KEY`,
    `TOKEN_COUNT_QUERY_KEY`, `APP_THEME_QUERY_KEY`, Supabase/MCP keys) with
    `queryKeys`
    > - Updates IPC-driven UI pieces (`AppUpgrades`, `CapacitorControls`,
    `ModelPicker`, `ChatInput`, preview panels, Neon, MCP, Supabase, Vercel,
    etc.) to the new keys
    > - Documentation: `AGENTS.md` adds an Architecture section with usage
    guidelines and changes format script to `npm run fmt`
    > 
    > <sup>Written by [Cursor
    Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
    2b80e408f077b8ea3141369ca21f62e514852cfd. This will update automatically
    on new commits. Configure
    [here](https://cursor.com/dashboard?tab=bugbot).</sup>
    <!-- /CURSOR_SUMMARY -->
    
    ---------
    Co-authored-by: 's avatarClaude <noreply@anthropic.com>
    8a38dc75
名称
最后提交
最后更新
..
ActionHeader.tsx 正在载入提交数据...
AnnotatorOnlyForPro.tsx 正在载入提交数据...
AnnotatorToolbar.tsx 正在载入提交数据...
CodeView.tsx 正在载入提交数据...
ConfigurePanel.tsx 正在载入提交数据...
Console.tsx 正在载入提交数据...
ConsoleEntry.tsx 正在载入提交数据...
ConsoleFilters.tsx 正在载入提交数据...
DraggableTextInput.tsx 正在载入提交数据...
FileEditor.tsx 正在载入提交数据...
FileTree.tsx 正在载入提交数据...
NeonConfigure.tsx 正在载入提交数据...
PreviewIframe.tsx 正在载入提交数据...
PreviewPanel.tsx 正在载入提交数据...
Problems.tsx 正在载入提交数据...
PublishPanel.tsx 正在载入提交数据...
SecurityPanel.tsx 正在载入提交数据...
StylePopover.tsx 正在载入提交数据...
ToolbarColorPicker.tsx 正在载入提交数据...
VisualEditingChangesDialog.tsx 正在载入提交数据...
VisualEditingToolbar.tsx 正在载入提交数据...