Skip to content

refactor hooks#86

Merged
Kitenite merged 1 commit intomainfrom
arc-sidebar-baby-4bv4
Nov 15, 2025
Merged

refactor hooks#86
Kitenite merged 1 commit intomainfrom
arc-sidebar-baby-4bv4

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Nov 15, 2025

Summary by CodeRabbit

  • Refactor
    • Modernized state management by transitioning from prop-based data flow to React Context, centralizing workspace, tab, sidebar, worktree operations, and task management. This improves code organization and maintainability while preserving all existing functionality.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 15, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Introduces a centralized context provider architecture for the desktop renderer. Creates new context modules for workspace, tab, sidebar, task, and worktree operations state, nests them in AppProviders, and refactors multiple UI components to consume contexts instead of receiving props, significantly reducing component surface areas.

Changes

Cohort / File(s) Summary
New Context Infrastructure
apps/desktop/src/renderer/contexts/AppProviders.tsx, WorkspaceContext.tsx, TabContext.tsx, SidebarContext.tsx, TaskContext.tsx, WorktreeOperationsContext.tsx
Introduces six new context modules establishing centralized state management for workspace, tab, sidebar, task, and worktree operations. AppProviders nests these providers; each context exposes typed hooks and provider components for access throughout the renderer.
Context Barrel Export
apps/desktop/src/renderer/contexts/index.ts
Centralizes re-exports of all providers and hooks (AppProviders, WorkspaceProvider, TabProvider, SidebarProvider, WorktreeOperationsProvider, TaskProvider, WorktreeProvider) and their corresponding context hooks.
Renderer Entry Point
apps/desktop/src/renderer/index.tsx
Wraps AppRoutes with AppProviders to initialize context providers at the root of the application.
Main Screen & Content Area Refactoring
apps/desktop/src/renderer/screens/main/MainScreen.tsx, MainContentArea.tsx
Migrates from prop-driven to context-driven data flow; consumes useWorkspaceContext, useTabContext, useSidebarContext, useWorktreeOperationsContext, and useTaskContext. Dramatically reduces prop passing and simplifies component signatures.
Tab Rendering
apps/desktop/src/renderer/screens/main/components/MainContent/TabGroup.tsx, TabContent.tsx
Replaces prop-based workingDirectory, workspaceId, worktreeId, and callback data with context-derived values. TabGroup signature simplified to only receive groupTab.
Sidebar Components
apps/desktop/src/renderer/screens/main/components/Sidebar/Sidebar.tsx, SidebarOverlay.tsx
Removes workspace, worktree, and tab-related props; now consumes useWorkspaceContext, useTabContext, useWorktreeOperationsContext, and useSidebarContext for state and handlers.
Feature Views
apps/desktop/src/renderer/screens/main/components/PlanView/PlanView.tsx
Removes public props (currentWorkspace, selectedWorktreeId, onTabSelect, onTabCreated); derives state and handlers from useWorkspaceContext and useTabContext. PlanViewProps becomes empty interface.

Sequence Diagram

sequenceDiagram
    participant Root as React App
    participant AP as AppProviders
    participant WCP as WorkspaceProvider
    participant TCP as TabProvider
    participant SCP as SidebarProvider
    participant WOP as WorktreeOpsProvider
    participant TP as TaskProvider
    participant Component as UI Component

    Root->>AP: Render with children
    AP->>WCP: Wrap with state (workspace)
    WCP->>TCP: Wrap with state (tab/worktree)
    TCP->>SCP: Wrap with state (sidebar)
    SCP->>WOP: Wrap with state (worktree ops)
    WOP->>TP: Wrap with state (task)
    TP->>Component: Render children

    rect rgb(200, 240, 255)
    Note over Component: Before: Props from parent<br/>MainScreen → MainContentArea → TabGroup → TabContent
    end

    rect rgb(240, 200, 255)
    Note over Component: After: Context consumption<br/>TabContent calls useTabContext()<br/>TabContent calls useWorkspaceContext()
    Component->>TCP: useTabContext()
    Component->>WCP: useWorkspaceContext()
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Areas requiring extra attention:

  • MainContentArea.tsx: Significant logic refactoring with large prop surface reduction and addition of context dependencies; verify all state transitions and rendering paths remain correct
  • Sidebar.tsx and SidebarOverlay.tsx: Verify that all workspace/worktree/tab operations still function correctly through context-based handlers
  • Context initialization order: Ensure AppProviders nesting order is correct and that dependent contexts (e.g., TabProvider using WorkspaceProvider) are properly layered
  • Tab and workspace state synchronization: Verify that selectedWorktreeId, selectedTabId, and currentWorkspace remain synchronized across TabContent, TabGroup, and MainContentArea after prop elimination
  • PlanView empty interface change: Confirm that all call sites have been updated to rely on context rather than passing props

Possibly related PRs

  • refactor 1 #69: Also refactors MainScreen.tsx state management architecture, likely involving workspace/tab state restructuring.
  • start tasks and top bar #81: Modifies TaskContext/TaskProvider and related task utilities (useTasks, task transformations), which this PR introduces as a new context layer.
  • workspace #71: Changes workspace/tab/worktree state management in MainScreen and MainContentArea via different approach, creating code-level overlap.

Poem

🐰 Contexts nested like burrows deep,
State lifted high for all to reap,
Props discarded, clarity freed,
Providers cascading—all we need! 🌿

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch arc-sidebar-baby-4bv4

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between faeb587 and f5b9482.

📒 Files selected for processing (15)
  • apps/desktop/src/renderer/contexts/AppProviders.tsx (1 hunks)
  • apps/desktop/src/renderer/contexts/SidebarContext.tsx (1 hunks)
  • apps/desktop/src/renderer/contexts/TabContext.tsx (1 hunks)
  • apps/desktop/src/renderer/contexts/TaskContext.tsx (1 hunks)
  • apps/desktop/src/renderer/contexts/WorkspaceContext.tsx (1 hunks)
  • apps/desktop/src/renderer/contexts/WorktreeOperationsContext.tsx (1 hunks)
  • apps/desktop/src/renderer/contexts/index.ts (1 hunks)
  • apps/desktop/src/renderer/index.tsx (1 hunks)
  • apps/desktop/src/renderer/screens/main/MainScreen.tsx (4 hunks)
  • apps/desktop/src/renderer/screens/main/components/MainContent/TabContent.tsx (2 hunks)
  • apps/desktop/src/renderer/screens/main/components/MainContent/TabGroup.tsx (2 hunks)
  • apps/desktop/src/renderer/screens/main/components/MainContentArea/MainContentArea.tsx (5 hunks)
  • apps/desktop/src/renderer/screens/main/components/PlanView/PlanView.tsx (3 hunks)
  • apps/desktop/src/renderer/screens/main/components/Sidebar/Sidebar.tsx (4 hunks)
  • apps/desktop/src/renderer/screens/main/components/SidebarOverlay/SidebarOverlay.tsx (2 hunks)

Comment @coderabbitai help to get the list of available commands and usage tips.

@Kitenite Kitenite merged commit 97c98c6 into main Nov 15, 2025
1 of 5 checks passed
@Kitenite Kitenite deleted the arc-sidebar-baby-4bv4 branch November 15, 2025 01:49
@coderabbitai coderabbitai Bot mentioned this pull request Jan 13, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant