Skip to content

Modularize chatStore.ts to improve readability and maintainability of the source code. #93

@jsgrrchg

Description

@jsgrrchg

Description

apps/desktop/src/features/ai/store/chatStore.ts has grown into a very large store with several distinct responsibilities mixed into one file. It currently contains runtime setup, session lifecycle, persisted history, transcript handling, queued message flow, composer state, attachments, streaming deltas, and tracked file review/change-control logic.

This makes the store harder to reason about, increases the risk of regressions when touching AI chat behavior, and makes the inline review / accept-reject flow especially fragile.

chatStore.ts need a refactor into smaller, focused modules while preserving the existing public Zustand API and behavior.

Suggested Scope

Extract cohesive helpers/modules for:

  • AI preferences and runtime catalog persistence.
  • Runtime setup, connection state, and setup status handling.
  • Session creation, hydration, merging, ordering, and persisted history.
  • Transcript/message construction and streaming delta buffering.
  • Queued message lifecycle, interruption, retry, cancel, and drain behavior.
  • Composer parts, attachments, and per-session draft state.
  • Tracked files, action log reconciliation, review hunk resolution, accept/reject, undo reject, and external editor reload handling.

chatStore.ts should become a thinner orchestration layer that wires these modules into the Zustand store instead of owning all implementation details directly.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions