Skip to content

Refactor/code quality#58

Merged
lee-sihun merged 33 commits intomasterfrom
refactor/code-quality
Mar 7, 2026
Merged

Refactor/code quality#58
lee-sihun merged 33 commits intomasterfrom
refactor/code-quality

Conversation

@lee-sihun
Copy link
Member

No description provided.

lee-sihun and others added 30 commits March 5, 2026 15:44
zOrder, keys, canvasItems, groups 순수 함수를 editor/model로 추출.
Store/React 의존 없는 상태 변환 함수로 도메인 로직의 단일 진입점 마련.

- zOrder.ts: moveToFront/Back/Forward/Backward 계산
- keys.ts: 키 CRUD, 스타일, 노트, 카운터 상태 계산
- canvasItems.ts: 가시성 토글, zIndex 재정렬
- groups.ts: layerGroupUtils 재export

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
히스토리 스냅샷 캡처/복원, 플러그인 요소 복원, 백엔드 동기화를
editor/runtime으로 격리.

- editorSnapshot.ts: pushHistory, restorePluginElements, applyToStores, persist
- persistState.ts: positions/mappings 백엔드 동기화 유틸리티

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1,531줄 → 879줄로 축소. 핵심 변경:
- 키 CRUD (add/remove/duplicate) → editor/model/keys.ts
- z-order 이동 (front/back/forward/backward) → editor/model/zOrder.ts
- 히스토리 push → editor/runtime/editorSnapshot.ts
- undo/redo 복원 → editor/runtime (applyRestoredStateToStores, applyRestoredPluginElements, persistRestoredState)
- 백엔드 동기화 → editor/runtime/persistState.ts
- 외부 반환 인터페이스 변경 없음

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- useGridCanvasActions 훅 생성: stat/graph CRUD, z-order, persist 로직
- Grid.tsx에서 ~370줄 인라인 함수 제거, 훅 위임으로 교체
- DuplicateState 타입을 훅에서 export하여 Grid.tsx와 공유
- Grid.tsx: 3,054 → 2,684 lines

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- useGridCanvasActions에 moveStatForward/Backward, moveGraphForward/Backward 추가
- addStatAtPosition, addGraphAtPosition을 훅으로 이동
- Grid.tsx handleSelectedMoveForward/Backward: ~180줄 → ~20줄로 단순화
- Grid.tsx: 2,684 → 2,440 lines (총 3,054에서 -614줄)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- useGridZoomPan: 매 렌더 이벤트 재등록 → ref 패턴으로 안정화
  - 핸들러를 ref에 저장, useEffect로 최신 값 동기화
  - 이벤트 리스너는 마운트 시 1회만 등록 ([] deps)
- editor/model, editor/runtime, Key.tsx 등 포맷팅 일괄 적용

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- GridKeySettingModal.tsx: UnifiedKeySetting 모달 래퍼 분리 (preview/rollback 로직)
- groupActions.ts: 그룹/언그룹 공용 액션 추출 (Grid.tsx + useGridKeyboard.ts 중복 제거)
- selectElementWithGroup/pushDragHistory/openElementContextMenu 공통 헬퍼
- Grid.tsx 2,440줄 → 2,020줄 (-17%), useGridKeyboard.ts 크게 축소
- REFACTORING_PLAN.md 진행 상황 및 새 계획 업데이트

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- layerPanelModel.ts: buildLayerItems/buildDisplayItems 순수 함수 추출
- LayerIcons.tsx: FolderIcon/ChevronIcon/KeyIcon/StatIcon/GraphIcon/PluginIcon 분리
- types.ts: LayerItem/DisplayItem/GroupHeaderItem 타입 추가
- LayerTabContent.tsx 2,971줄 → 2,693줄 (-9%)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- useLayerActions: 가시성 토글, 이름 변경, 컨텍스트 메뉴, 삭제, 그룹 연산 추출
- useLayerDnD: 드래그 앤 드롭 로직 전체 추출 (드롭 타깃 계산, 다중/그룹 드롭)
- React Compiler lint 호환: ref 접근자 패턴(getDidDrag/resetDidDrag), useEffect ref 갱신

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PropertiesPanel 21개 파일을 도메인별 하위 폴더로 분류:
- layer/: LayerTabContent, LayerPanel, LayerIcons, useLayerActions, useLayerDnD 등 (7파일)
- single/: SingleSelectionPanel, StyleTabContent, NoteTabContent, CounterTabContent (4파일)
- batch/: BatchSelectionPanel, BatchStyleTabContent, BatchNoteTabContent, useBatchHandlers 등 (5파일)
- 루트: index.ts, types.ts, PropertyInputs.tsx, usePanelScroll.ts 등 공용 파일 유지

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1. useGridZoomPan: containerRef가 마운트 시 null이면 이벤트 리스너가
   등록되지 않던 문제 수정 (useState로 DOM 요소 추적)

2. useKeyManager: preview가 store를 직접 변경하므로 commit 시점에
   pushCurrentStateToHistory()가 이미 변경된 상태를 저장하던 문제 수정
   - preview 시작 시 한 번만 히스토리 저장 (previewHistorySavedRef)
   - commit 시 preview가 이미 저장했으면 skip

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- build.rs에 generate_permissions() 추가: #[tauri::command] 스캔 후
  permissions/dmnote-allow-all.json 자동 생성
- 모든 커맨드에서 permission = "dmnote-allow-all" 속성 제거 → bare
  #[tauri::command]로 통일
- plugin_storage.rs, bridge.rs에서 불필요한 async 제거 (await 미사용)
- CLAUDE.md에 Tauri 커맨드 규칙 및 백엔드 구조 추가
- RUST_REFACTORING_PLAN.md 리팩토링 계획서 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 2: 루트 파일 모듈 재편
- keyboard.rs, keyboard_daemon.rs, keyboard_labels.rs → keyboard/ 모듈
- key_sound.rs → audio/engine.rs 모듈
- app_state.rs, store.rs → state/ 모듈
- models.rs → models/ 모듈
- 모든 import 경로 업데이트 (commands, services 포함)

Phase 3: commands/ 하위 분류
- 19개 커맨드 파일을 7개 도메인별 하위 폴더로 분류
  (app/, editor/, keys/, layout/, media/, preset/, plugin/)
- build.rs: 재귀 디렉토리 스캔으로 변경
- main.rs: generate_handler![] 경로 전체 업데이트

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
preset.rs (1,541줄)를 3개 파일로 분리:
- mod.rs: 공유 타입 + 유틸리티 (PresetFile, EmbeddedLocal* 등)
- save.rs: preset_save, preset_save_tab + 직렬화 헬퍼
- load.rs: preset_load, preset_load_tab + 역직렬화/복원 헬퍼

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…B + 5)

- errors.rs: CommandError enum + CmdResult<T> 타입 별칭 추가
- 20개 커맨드 파일의 Result<T, String> → CmdResult<T> 전환
- .map_err(|e| e.to_string()) 패턴 제거, ? 연산자로 대체
- 도메인 코드 문자열은 CommandError::msg() 사용

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- migration.rs: load_store_from_path, repair_legacy_state, migrate_*, normalize_state 등 이동
- store.rs: AppStore 본체, persist, cleanup, settings 추출만 유지

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
lee-sihun and others added 3 commits March 6, 2026 22:34
- mod.rs: 공유 코드 (run dispatcher, write_message/command, load_hotkeys)
- windows.rs: HotkeyState, ParsedHotkey, vk_from_key_code, run_raw_input
- macos.rs: MacHotkeyState, labels_from_*, run_macos, accessibility 권한

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lee-sihun lee-sihun merged commit 43df437 into master Mar 7, 2026
1 check passed
@lee-sihun lee-sihun deleted the refactor/code-quality branch March 7, 2026 00:32
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