콘텐츠로 이동

설정 서브프로세스

이 페이지는 CLAUDE.md의 구현 노트를 미러합니다. 서브시스템 변경 시 양쪽 다 업데이트하세요.

설정 창은 platform.launch_settings()로 launch되는 별도 서브프로세스입니다. customtkinter 사용; 디스크에 atomic 작성. 부모 프로세스는 서브프로세스 종료를 관찰하여 BrowserAuth 캐시 reload + launch 전 스냅샷에 대해 streaming.enabled reconcile.

서브프로세스인 이유

  • 메뉴바 앱의 런 루프 (rumps on macOS, pystray on Windows)는 UI에 단일 스레드. 같은 루프의 long-running customtkinter 윈도우가 메뉴/트레이를 deadlock시킴.
  • 크래시 격리 — 설정 widget이 Tk 버그 hit해도 메뉴바 앱은 계속 실행.
  • IPC 단순성 — 없음. 서브프로세스가 config.json + browser_auth.json atomic 작성; 부모가 서브프로세스 종료 시 읽음. 파이프 없음, 소켓 없음, shared-memory 없음.
sequenceDiagram
    participant Tray as 메뉴바 / 트레이
    participant Sub as settings_window 서브프로세스
    participant Disk as config.json + browser_auth.json

    Tray->>Sub: spawn (또는 기존 윈도우 focus)
    Sub->>Disk: launch 시 스냅샷 read
    Sub->>Sub: 사용자가 in-memory 드래프트 편집
    Sub->>Disk: Apply 시 atomic 작성
    Tray->>Tray: 서브프로세스 종료 → BrowserAuth reload, streaming reconcile

Apply / Revert 흐름

드래프트 편집은 사용자가 Apply 클릭할 때까지 in-memory에 유지. 푸터 Apply/Revert 버튼은 diff(draft, snapshot)이 비어있지 않고 그리고 모든 보이는 필드가 검증을 통과할 때만 활성. 검증 로직은 settings_model 참고.

파괴적 액션 — Clear Data, Reset Privacy Permissions, 브라우저별 "Ask now" — 드래프트 우회하고 즉시 commit. 이 클릭들은 설정 편집이 아니라 의도된 액션이기 때문.

멀티 인스턴스 가드

서브프로세스가 <config root>/.cue.settings.lock에 파일 락 획득 (POSIX는 fcntl, Windows는 msvcrt). 두 번째 launch는 lock contention 시 silent 종료. 부모 프로세스도 라이브 서브프로세스 PID 추적, 새 spawn 대신 기존 윈도우를 앞으로 가져오는 플랫폼별 focus_subprocess() helper 호출.

모듈 분리

모듈 용도
cue.settings_model 순수 로직 레이어: load_draft() / validate_regex() / validate_api_key() / diff() / commit() / supported_browsers(). stdlib-only, unit-testable. customtkinter / Tk import 없음.
cue.settings_window UI 셸. customtkinter widget, 레이아웃, 4개 탭 (General / Privacy / Data / About). 모델 레이어 import.

분리는 검증 규칙과 diff 로직이 Tk root 윈도우 spinning up 없이 테스트 cover되도록 존재.

탭 인벤토리

4개 탭과 그 안에 있는 것은 설정 (사용자 facing) 에서 walk through. 그 widget들의 내부는 cue.settings_window에 있음.

메뉴 통합 규칙

탑 레벨 트레이 항목은 양 플랫폼에서 짧게 유지: Open Cue / Privacy paused / Enable Streaming / Preferences… / Quit Cue. 새 stateful 설정은 새 트레이 메뉴 항목이 아닌 설정 탭으로.

더 보기