apps/desktop/src/lib/LIB_PLAN.md
src/lib/ Refactoring — CompletedReorganized
src/lib/to eliminate import cycles between directories. Result: 30 → 2 cycles (remaining 2 are test-only:ai <-> testing,forge <-> testing).
utils/branch.ts → branches/branchUtils.tsutils/commitMessage.ts → commits/commitMessage.tsutils/fileStatus.ts → files/fileStatus.tsutils/codegenTools.ts → codegen/codegenTools.tsutils/theme.ts → config/theme.tsconflictEntryPresence.ts → files/conflictEntryPresence.tsrxjs.ts → utils/rxjs.tstabs.ts → utils/tabs.tsdragging/dropHandlers/All feature-module drop handlers moved into dragging/dropHandlers/:
branches/dropHandler.ts → dragging/dropHandlers/branchDropHandler.tscommits/dropHandler.ts → dragging/dropHandlers/commitDropHandler.tshunks/dropHandler.ts → dragging/dropHandlers/hunkDropHandler.tsstacks/dropHandler.ts → dragging/dropHandlers/stackDropHandler.tscodegen/dropzone.ts → dragging/dropHandlers/codegenDropzone.tsEliminated 10 cycles involving dragging ↔ branches/commits/hunks/stacks/codegen.
state/ hubreduxError.ts: Moved from state/ to error/ (it's an error type, not state infrastructure).messageQueueSlice.ts: Moved from codegen/ to state/ (it's a Redux slice consumed by clientState).uiState.svelte.ts: Inlined shared type definitions (ThinkingLevel, ModelType, PermissionMode, GeneralSettingsPageId, ProjectSettingsPageId, RejectionReason) that were previously imported from feature modules. Feature modules now re-export from state.replaceBranchInExclusiveAction, replaceBranchInStackSelection, updateStaleStackState, updateStaleProjectState from state/uiState.svelte.ts to stacks/staleStateUpdaters.ts (only caller is stackService).clientState.svelte.ts: Replaced concrete forge client type imports (GitHubClient, GitLabClient) with opaque structural types to break state <-> forge cycle.Eliminated 6 cycles involving state ↔ codegen/stacks/settings/forge/error/backend.
stores/tokenMemoryService.ts → user/tokenMemoryService.ts (eliminated stores/ directory)dependencies/ merged into hunks/ (eliminated dependencies/ directory)stack/stackController.svelte.ts → stacks/stackController.svelte.ts (eliminated stack/ directory)editMode/editPatchUtils.ts → mode/editPatchUtils.ts (eliminated editMode/ directory)codegen <-> soup: Moved codegenAnalytics.ts from soup/ to codegen/.error <-> notifications: Extracted showError from notifications/toasts.ts into error/showError.ts. Updated all 18 importers.backend <-> error: Made logErrorToFile injectable via setLogErrorToFile() in error/logError.ts, wired in hooks.client.ts.analytics <-> user: Replaced User type import in analytics/sentry.ts with structural type.branches <-> forge: Changed forge/prContents.ts to import Workspace.Commit from @gitbutler/core/api directly.forge <-> stacks: Changed forge/shared/prFooter.ts to import Workspace.BranchDetails from @gitbutler/core/api directly.forge <-> project: Inlined ForgeName type in project/project.ts.hunks <-> worktree: Used structural type for WorktreeService in hunks/dependencyService.svelte.ts.selection <-> stacks: Used structural StackServiceLike interface in selection/fileSelectionManager.svelte.ts.backend <-> utils: Moved utils/url.ts (URLService) to backend/url.ts.svelte-check)ai <-> testingforge <-> testingDirectories removed: stores/, dependencies/, stack/, editMode/
New subdirectory: dragging/dropHandlers/
New file: error/showError.ts, stacks/staleStateUpdaters.ts
Current count: 46 directories, 279 files