Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7418eb9363 | ||
|
|
906e9b6f7d | ||
|
|
2b5ba8a50e | ||
|
|
3c731cc754 | ||
|
|
352457189e | ||
|
|
a68feae20e | ||
|
|
64935d943c | ||
|
|
9cf6cafab2 | ||
|
|
d3bc972783 | ||
|
|
30b14d2b74 | ||
|
|
431b35a72a | ||
|
|
e34f036f20 | ||
|
|
c616555d7d | ||
|
|
218868206b | ||
|
|
b2be29bd33 | ||
|
|
4266376b23 | ||
|
|
bd71bba2da | ||
|
|
713553a038 | ||
|
|
d3cf018f62 | ||
|
|
f676c1638e | ||
|
|
2e69f598bc | ||
|
|
014c06e1f0 | ||
|
|
4216d42d7c |
220
CHANGELOG.md
220
CHANGELOG.md
@@ -3,6 +3,226 @@
|
||||
본 파일은 Inkling 의 버전별 사용자 영향 변경 사항을 기록한다.
|
||||
형식은 [Keep a Changelog](https://keepachangelog.com/) 를 느슨하게 따른다.
|
||||
|
||||
## [0.3.14] — 2026-05-12 (force re-tag: 2026-05-14, 추가 dogfood fixes 7건)
|
||||
|
||||
### 추가 dogfood fixes (2026-05-14 force re-tag)
|
||||
|
||||
force re-tag 로 같은 v0.3.14 안에 묶인 후속 변경. 새 minor 안 늘리고 동일 release notes 확장.
|
||||
|
||||
- **fix(capture): QuickCapture blur-on-hide 제거.** 다른 창 클릭해도 ESC / Cmd+Enter 까지 창 유지. alwaysOnTop + screen-saver level 로 다른 앱 위에 떠 있음.
|
||||
- **chore(ux): macOS 사용자 위해 Cmd 키 hint 안내.** Inbox empty state 와 QuickCapture 하단 hint 가 platform-aware 로 분기 — Mac 에선 `Cmd+Shift+J` / `Cmd+Enter`.
|
||||
- **fix(macos): hidden autostart dock indicator + autostart mismatch false positive.** ① LoginItems `--hidden` spawn 시 NSPanel 만 떠 있어 dock 점 안 보이던 문제 — inboxWindow 를 hidden 으로 미리 create + `showInactive → hide` trick 으로 NSApp register. ② SettingsPage 의 자동실행 mismatch 경고가 macOS 13+ SMAppService 한계로 false positive 떠 있던 문제 — willLaunch 신호는 win32 에서만 mismatch 판정에 사용.
|
||||
- **feat(notes): 원문 편집/이력 복원 시 AI 재처리.** `NoteRepository.markAiPendingForReprocess` 신설 — done/failed/pending 노트를 pending reset + pending_jobs 재투입. disabled 는 사용자 의도 존중 no-op. NoteCard.saveRaw 가 optimistic 으로 `aiStatus='pending'` 표시. updateAiResult 의 user-edit 가드로 사용자가 직접 편집한 필드는 보존.
|
||||
- **feat(expiry): 마감 알림 inbox 제한 + 오늘 당일 포함 + 헤딩/라벨/메모 바로가기.** ① `findExpiredCandidates` 가 `due_date <= today` + `status='active'` 로 변경, 완료/보관 노트는 제외. 정렬도 `due_date DESC` 로 오늘 → 어제 순. ② ExpiryBanner 헤딩 분리 카운트 "오늘 마감 X · 지난 Y", 노트 라벨 [오늘] / [N일 지남]. ③ 노트 제목 클릭 → `note-{id}` smooth scroll.
|
||||
- **fix(sync): manifest.exported_at 제거 — no-op push 회피.** 노트 변경 0건이어도 매 sync 마다 timestamp 1줄 commit + push 가 쌓이던 문제. `composeManifest` 에서 cosmetic 필드 제거. 이제 진짜 변경 있을 때만 commit.
|
||||
- **feat(settings): SectionIntro + SyncHelpModal 풀어쓰기.** 설정 페이지 6 section 상단에 1-2 문장 안내. SyncHelpModal 의 기술 용어 (rebase, fast-forward, NTP) 를 사용자 언어로 풀어쓰기.
|
||||
|
||||
### 게이트 (추가 fix 후)
|
||||
|
||||
- 단위 763 PASS
|
||||
- typecheck 0 errors
|
||||
|
||||
---
|
||||
|
||||
### 원본 release (2026-05-12)
|
||||
|
||||
AI 처리 fail 원인 가시화. 이전엔 ai_error 가 NoteCard tooltip (title attribute) 에만 있어 사용자가 마우스 오버해야 보이는 데다 raw 메시지만 노출 → 무엇이 fail 했는지 불명.
|
||||
|
||||
### 수정
|
||||
|
||||
- **NoteCard failed 노트에 "원인 보기" 접힘 섹션 (P1).** `<details>` summary 클릭하면 `<pre>` 로 `ai_error` 전체 노출. wrap + word-break 적용. 사용자가 직접 메시지를 보고 모델/네트워크/JSON 등 fail 카테고리 진단 가능.
|
||||
- **`ai_error` 에 reason + provider name prefix 추가.** AiWorker 의 markAiFailed 시 `[schema|other] local-ollama/gemma4:26b\n<원본 message>` 형식. 사용자가 어느 카테고리에서, 어느 모델로 실패했는지 즉시 식별. log 의 ai.failed 에도 reason/provider 필드 함께 출력.
|
||||
|
||||
### 게이트
|
||||
|
||||
- 단위 752 PASS (ai_error 포맷 변경은 test 영향 없음 — 기존 test 가 정확한 prefix 매칭 안 함)
|
||||
- typecheck 0 errors
|
||||
- 신규 npm dependency 0
|
||||
|
||||
### 사용자 안내
|
||||
|
||||
이미지 AI 처리가 fail 한다면 NoteCard 의 "정리 보류" 옆 "원인 보기" 클릭 → 표시되는 메시지로:
|
||||
- `[timeout] ...` → vision 모델 cold-start 가 5분 초과. `ollama run gemma4:26b` 으로 한번 warm-up 후 재시도
|
||||
- `[schema] title must contain Korean characters` → vision 모델이 영어 title 반환. prompt 가 한국어 강조했지만 일부 모델은 여전히 영어. `gemma3:27b` 등 다른 vision 모델로 대체 고려
|
||||
- `[schema] unparseable response: ...` → vision 모델 JSON 출력 안 따름. v0.3.12 의 loose parse 가 실패한 경우
|
||||
- `[other] missing response field` → Ollama 가 빈 응답 반환. 모델 자체 문제
|
||||
|
||||
### 업그레이드
|
||||
|
||||
v0.3.13 인스톨러 위에 v0.3.14 인스톨러를 같은 위치에 실행하면 in-place 업그레이드.
|
||||
|
||||
## [0.3.13] — 2026-05-12
|
||||
|
||||
대형 vision 모델 (gemma4:26b 등) 의 cold-start timeout 으로 인한 AI 처리 실패 fix.
|
||||
|
||||
### 수정
|
||||
|
||||
- **Vision generate 의 timeout 확장 120s → 300s (P1).** `gemma4:26b` (25B MoE 가중치 + vision encoder 550M) 같은 대형 vision 모델은 첫 generate 시 모델 load + 이미지 encoding 으로 60-180s 소요. 기본 120s timeout 으로 첫 호출 시 abort → fail 빈번. vision path 에 한해 `Math.max(timeoutMs, 300_000)` 적용 (text-only path 영향 없음).
|
||||
|
||||
확인: gemma4 family 는 [공식 release](https://blog.google/innovation-and-ai/technology/developers-tools/gemma-4/) — 26B variant 가 Text+Image 양 modality 지원 ([ollama library](https://ollama.com/library/gemma4:26b)). 본 코드의 `VisionDetect` 가 'gemma4' family 인식하므로 사용자가 settings → Vision 섹션에서 선택 가능.
|
||||
|
||||
### 사용자 안내
|
||||
|
||||
이미지 AI 처리가 여전히 실패한다면:
|
||||
1. 설정 → AI 제공자 → Vision 섹션에서 `gemma4:26b` (또는 vision-capable 모델) 가 선택돼있는지 확인
|
||||
2. `ollama list` 로 모델 실제 설치 여부 확인 (`ollama pull gemma4:26b` 필요)
|
||||
3. NoteCard 의 failed 노트 텍스트 위에 마우스 오버 → tooltip 의 `ai_error` 확인 (구체 fail mode 진단)
|
||||
|
||||
### 게이트
|
||||
|
||||
- 단위 752 PASS (timeout 상수만 변경 — 회귀 없음)
|
||||
- typecheck 0 errors
|
||||
- 신규 npm dependency 0
|
||||
|
||||
### 업그레이드
|
||||
|
||||
v0.3.12 인스톨러 위에 v0.3.13 인스톨러를 같은 위치에 실행하면 in-place 업그레이드.
|
||||
|
||||
## [0.3.12] — 2026-05-12
|
||||
|
||||
이미지 AI 처리 실패 fix. vision model 의 응답이 strict JSON 이 아닌 경우 (markdown fence / prose 섞임) 가 흔해 schema parse 단계에서 throw → `ai_status='failed'` 도달.
|
||||
|
||||
### 수정
|
||||
|
||||
- **Vision model 응답 JSON loose parse (P1).** `LocalOllamaProvider.generate` 의 `JSON.parse` 가 strict 라 vision-tuned 모델의 markdown 코드 펜스 / 앞뒤 prose 응답에서 throw. `parseJsonLoose` 헬퍼 추가 — 첫 `{` ~ 마지막 `}` substring 추출 fallback. 실패 시 raw response 200자 snippet 포함한 에러 throw (디버깅 가시화).
|
||||
- **Vision prompt 강화 (P1).** `buildVisionPrompt` 가 "title 한국어로 요약" 만 명시 → schema 의 KOREAN_REGEX/KEBAB_REGEX 강제와 불일치. 규칙 4건 명시: title 한국어 60자, summary 3줄, tags 영문 kebab-case 3개, due_date ISO 또는 null. "markdown 코드 펜스 금지" 명시로 JSON-only 출력 강제.
|
||||
|
||||
알려진 한계:
|
||||
- `gemma4:26b` 같이 Ollama 에 실제로 release 안 된 모델명 사용 시 healthCheck 통과해도 generate 가 unknown model 로 throw. 모델 설치 여부는 사용자가 `ollama list` 확인 필요.
|
||||
|
||||
### 게이트
|
||||
|
||||
- 단위 750 → **752 PASS** (+2: markdown fence 추출 + prose 추출)
|
||||
- typecheck 0 errors
|
||||
- 신규 npm dependency 0
|
||||
|
||||
### 업그레이드
|
||||
|
||||
v0.3.11 인스톨러 위에 v0.3.12 인스톨러를 같은 위치에 실행하면 in-place 업그레이드. 데이터/마이그레이션 변경 없음.
|
||||
|
||||
## [0.3.11] — 2026-05-12
|
||||
|
||||
붙여넣은 이미지 / 저장된 이미지가 양쪽 창에서 표시 안 되던 CSP 누락 hotfix.
|
||||
|
||||
### 수정
|
||||
|
||||
- **QuickCapture: paste 이미지 thumbnail 렌더 실패.** `quickcapture/index.html` 의 CSP 가 `img-src` 미지정 → `default-src 'self'` fallback → `URL.createObjectURL` 의 `blob:` URL 차단. `img-src 'self' data: blob:` 추가.
|
||||
- **Inbox: 저장된 노트 이미지 렌더 실패.** `inbox/index.html` 의 CSP `img-src 'self' data: blob: file:` 가 `inkling-media:` 미허용 → `NoteCard` 의 `<img src="inkling-media://media/..." />` 차단 (custom protocol 자체는 main 에서 등록됐지만 renderer CSP 별도). `inkling-media:` 추가.
|
||||
|
||||
v0.3.0 (Cut A 이미지 첨부) 이후 양쪽 창에서 paste/render 가 잠재적으로 깨져있던 회귀. 사용자가 dogfood 중 발견.
|
||||
|
||||
### 게이트
|
||||
|
||||
- 단위 750 PASS (CSP meta tag 만 변경 — 코드 path 영향 없음)
|
||||
- typecheck 0 errors
|
||||
- 신규 npm dependency 0
|
||||
|
||||
### 업그레이드
|
||||
|
||||
v0.3.10 인스톨러 위에 v0.3.11 인스톨러를 같은 위치에 실행하면 in-place 업그레이드. 데이터/마이그레이션 변경 없음.
|
||||
|
||||
## [0.3.10] — 2026-05-12
|
||||
|
||||
macOS fullscreen 환경에서 QuickCapture 핫키 (Cmd+Shift+J) 가 작동하지만 강제로 홈 데스크탑으로 Space 전환 후 표시되던 버그 fix.
|
||||
|
||||
### 수정
|
||||
|
||||
- **macOS fullscreen Space 위에 QuickCapture 표시 (P1).** 기본 BrowserWindow 는 첫 생성된 Space (홈 데스크탑) 에만 표시 → 사용자가 다른 앱 fullscreen 중에 핫키 누르면 macOS 가 강제로 Space 전환 → 사용자 흐름 단절. `quickCaptureWindow.ts` 에 darwin 분기 추가:
|
||||
- `type: 'panel'` — fullscreen Space 위에 floating 가능한 macOS native panel
|
||||
- `setAlwaysOnTop(true, 'screen-saver')` — fullscreen app 위에 띄울 수 있는 가장 높은 level
|
||||
- `setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true })` — 현재 Space (fullscreen 포함) 에 함께 표시, Space 전환 차단
|
||||
|
||||
Windows / Linux 동작은 변경 없음 (darwin 분기만).
|
||||
|
||||
### 게이트
|
||||
|
||||
- 단위 750 PASS (변경 없음 — main window 코드는 단위 테스트 대상 아님)
|
||||
- typecheck 0 errors (src)
|
||||
- 신규 npm dependency 0
|
||||
- macOS 사용자 수동 검증 완료
|
||||
|
||||
### 업그레이드
|
||||
|
||||
v0.3.9 인스톨러 위에 v0.3.10 인스톨러를 같은 위치에 실행하면 in-place 업그레이드. 데이터/마이그레이션 변경 없음.
|
||||
|
||||
## [0.3.9] — 2026-05-11
|
||||
|
||||
v0.3.8 audit 의 미수정 edge case 3건 완료. AI 처리 흐름의 사용자 unblock path + FTS5 query 안전성.
|
||||
|
||||
### 수정
|
||||
|
||||
- **`ai_status='pending'` 노트 cancel UI 부재 (P1).** Ollama 끊김 / 무한 pending 상태에서 사용자가 빠져나오는 path 가 없었음. NoteCard 의 pending 표시 옆에 "건너뛰기" 버튼 추가 → `inboxApi.cancelPending(id)` → `repo.cancelPending`: `ai_status='disabled'` + `pending_jobs` DELETE. raw_text 는 보존. pushNoteUpdated emit 으로 renderer 자동 sync.
|
||||
- **`ai_status='failed'` 노트 per-note 재시도 UI 부재 (P2).** 이전엔 FailedBanner 의 일괄 재시도만 가능. NoteCard 의 failed 표시 옆에 "재시도" 버튼 추가 → `inboxApi.retryOneFailed(id)` → `repo.retryOneFailed`: failed → pending + `pending_jobs` INSERT + worker enqueue. pushNoteUpdated emit.
|
||||
- **FTS5 query escape 불완전 (P2).** `sanitizeFtsQuery` 의 special chars regex 가 `["*():]` 만 처리 → backtick/dash/caret 미escape 로 일부 입력이 FTS5 parser throw 야기. `["*():`^\-]` 로 확장. 한국어 사용자가 의도 없이 입력할 가능성 높은 punctuation 까지 안전 처리.
|
||||
|
||||
### 미수정 (의도)
|
||||
|
||||
- **동시 편집 race (P2).** EditableField 가 이미 `editing=true` 중 value prop 변경을 무시하는 guard 보유. 사용자 입력은 보존됨 (last-write-wins). 추가 코드 불필요.
|
||||
|
||||
### 게이트
|
||||
|
||||
- 단위 745 → **750 PASS** (+5: repo retryOneFailed 2 + cancelPending 2 + FTS sanitize 1)
|
||||
- typecheck 0 errors (src)
|
||||
- 신규 npm dependency 0
|
||||
|
||||
### 업그레이드
|
||||
|
||||
v0.3.8 인스톨러 위에 v0.3.9 인스톨러를 같은 위치에 실행하면 in-place 업그레이드. 데이터/마이그레이션 변경 없음.
|
||||
|
||||
## [0.3.8] — 2026-05-11
|
||||
|
||||
전수 audit 후 발견된 사용자 상호작용 hole 8건 일괄 hotfix. 핵심은 (1) push-based status 동기화 root fix, (2) modal Escape affordance 통일, (3) IPC 실패 resilience.
|
||||
|
||||
### 수정
|
||||
|
||||
- **`inbox:set-status` IPC 가 `pushNoteUpdated` emit 안 함 (root fix).** 이전엔 setStatus 후 counts/list/search 가 모두 stale → 호출처마다 `refreshMeta()` 명시 호출이 필요했음 (v0.3.5 워크어라운드). 이제 IPC 핸들러가 `repo.findById()` 후 `pushNoteUpdated` 호출. renderer 의 `onNoteUpdated` 콜백 1개 path 로 모든 status 전이가 일관 갱신.
|
||||
- **`upsertNote` 가 current view 무시 → 잘못된 status 노트 잔류.** 이전엔 trashed 외 모든 status 를 `notes` 에 누적 → 사용자가 inbox 에서 완료로 옮긴 노트가 list 에 잔류. v0.3.8 부터 `viewStatus` (inbox→active, completed→completed, archived→archived) 와 매칭되는 status 만 유지. `searchResults` 도 동일 패턴.
|
||||
- **`upsertNote` 의 trash 판정을 `deletedAt` → `status='trashed'` 로 전환.** m004 이후 status 가 single source of truth, deletedAt 은 backward-compat mirror. sync conflict 후 두 컬럼 불일치 가능성 대비.
|
||||
- **`restoreNote` 가 status 도 'active' 로 갱신.** 이전엔 `deletedAt: null` 만 clear → upsertNote 가 status='trashed' 그대로 라 여전히 trashNotes 에 잔류.
|
||||
- **OnboardingWizard close path 부재.** IPC 실패 시 무한 wizard 잠금 → `try/catch + setBusy/error state + "지금 건너뛰기" 버튼 + Escape` 추가. 첫 launch 사용자 막힘 회피.
|
||||
- **Modal Escape key dismiss 통일.** `MoveStatusModal` / `RevisionHistoryModal` / `ConflictModal` / `SyncHelpModal` / `OnboardingWizard` 모두 `keydown` listener 추가. MoveStatusModal 은 overlay 클릭 close 도 추가 (다른 modal 들은 이미 외부 클릭 지원).
|
||||
- **`store.ts` async 함수 error-resilient.** `loadInitial` / `loadByView` / `searchNotes` / `loadReview` / `refreshMeta` 가 IPC throw 시 try/catch 로 감싸 무한 loading / stale data 회피. loadInitial 은 catch 시 `loading: false`, loadByView 는 빈 list, searchNotes 는 빈 결과, loadReview 는 빈 aggregate 로 graceful fallback.
|
||||
|
||||
### 갱신
|
||||
|
||||
- **NoteCard 의 명시적 `refreshMeta` 호출 보존** — onNoteUpdated path 가 이미 refreshMeta 호출하므로 redundant 지만 backup 으로 유지 (2번 fetch 만 발생, 무해).
|
||||
|
||||
### 게이트
|
||||
|
||||
- 단위 739 → **745 PASS** (+6: view-aware upsertNote 3 + setStatus push emit 1 + Modal Escape 1 + Modal overlay 클릭 1)
|
||||
- typecheck 0 errors (src)
|
||||
- 신규 npm dependency 0
|
||||
|
||||
### 업그레이드
|
||||
|
||||
v0.3.7 인스톨러 위에 v0.3.8 인스톨러를 같은 위치에 실행하면 in-place 업그레이드. 데이터/마이그레이션 변경 없음.
|
||||
|
||||
### 미수정 (낮은 우선순위 / 별도 작업)
|
||||
|
||||
- ai_status='pending' 노트 cancel UI (P1, 별도 spec 필요)
|
||||
- ai_status='failed' 노트 per-note 재시도 UI (P2)
|
||||
- FTS5 query escape (P2, 확인 필요)
|
||||
- 동시 편집 race condition (P2)
|
||||
|
||||
## [0.3.7] — 2026-05-11
|
||||
|
||||
`MoveStatusModal` 의 button hardcode 로 인해 완료/보관/휴지통 노트가 inbox 로 돌아올 수 없던 버그 fix. v0.2.9 Cut B 부터 존재한 잠재 결함 (dropdown 의 `possibleTargets` 필터가 modal 까지 흐르지 못함).
|
||||
|
||||
### 수정
|
||||
|
||||
- **완료/보관/휴지통 노트의 Inbox 복원 path 부재.** `MoveStatusModal` 이 `완료/보관/휴지통` 3 button hardcode 라 currentStatus 외 3 status 만 동적으로 노출해야 한다는 의도가 누락. `currentStatus: NoteStatus` prop 추가 + 4 status 중 current 제외 동적 render. NoteCard 가 `local.status` 전달.
|
||||
- **status label 일관성** — `statusLabel('active')` 가 '활성' 이었으나 헤더 탭 표기는 'Inbox'. modal button + AI 추천 텍스트 양쪽 모두 'Inbox' 로 통일.
|
||||
|
||||
### 게이트
|
||||
|
||||
- 단위 736 → **739 PASS** (+3: completed/archived/trashed currentStatus button list 검증)
|
||||
- typecheck 0 errors (src)
|
||||
- 신규 npm dependency 0
|
||||
|
||||
### 업그레이드
|
||||
|
||||
v0.3.6 인스톨러 위에 v0.3.7 인스톨러를 같은 위치에 실행하면 in-place 업그레이드. 데이터/마이그레이션 변경 없음.
|
||||
|
||||
## [0.3.6] — 2026-05-11
|
||||
|
||||
v0.3.5 의 이동 dropdown 단순화가 사용자 의도와 어긋난 점 정정. 이동 modal (사유 + AI 자동 분류 + 수동 status 선택) 은 보존해야 하는 핵심 UX 였음.
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "inkling",
|
||||
"version": "0.3.6",
|
||||
"version": "0.3.14",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "inkling",
|
||||
"version": "0.3.6",
|
||||
"version": "0.3.14",
|
||||
"dependencies": {
|
||||
"better-sqlite3": "12.9.0",
|
||||
"electron-log": "5.2.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "inkling",
|
||||
"version": "0.3.6",
|
||||
"version": "0.3.14",
|
||||
"private": true,
|
||||
"description": "Inkling — local-first 한 줄 보관 도구",
|
||||
"author": "altair823 <dlsrks0734@gmail.com>",
|
||||
|
||||
@@ -137,6 +137,23 @@ export class AiWorker {
|
||||
const nowDate = this.now();
|
||||
const todayDate = kstTodayAsDate(nowDate);
|
||||
const todayIso = kstTodayIso(nowDate);
|
||||
|
||||
// v0.3.14 — 본문 빈 + 이미지만 첨부 케이스는 모델이 의미 있는 응답 못 함
|
||||
// (gemma4:26b 등 vision 모델의 한계 확인). AI 호출 skip, 자동 placeholder 적용 후
|
||||
// 즉시 done. 사용자가 후에 NoteCard 의 EditableField 로 제목/요약 편집 가능.
|
||||
const rawEmpty = note.rawText.trim().length === 0;
|
||||
if (rawEmpty && note.media.length > 0) {
|
||||
const n = note.media.length;
|
||||
const title = n === 1 ? '첨부 이미지' : `첨부 이미지 ${n}장`;
|
||||
const summary = `이미지 ${n}장이 첨부된 메모입니다.\n원문 영역에서 이미지 확인할 수 있습니다.\n제목과 요약을 클릭해 직접 편집할 수 있습니다.`;
|
||||
this.repo.updateAiResult(job.noteId, {
|
||||
title, summary, tags: [], provider: 'image-only-skip', dueDate: null
|
||||
});
|
||||
this.logger.info('ai.skip.image-only', { noteId: job.noteId, mediaCount: n });
|
||||
this.emit(job.noteId);
|
||||
return;
|
||||
}
|
||||
|
||||
const candidates = parseAllCandidates(note.rawText, todayDate);
|
||||
const vocab = this.repo.getTopUsedTags(VOCAB_TOP_N);
|
||||
// v0.3.1 Cut F — vision path: visionModel + note.media → base64 images
|
||||
@@ -144,7 +161,17 @@ export class AiWorker {
|
||||
// 5MB cap 초과 시 throw → AiWorker 의 'other' 분기 → markAiFailed 도달.
|
||||
const visionModel = this.settings ? await this.settings.getVisionModel() : null;
|
||||
let images: Array<{ base64: string; mime: string }> | undefined;
|
||||
if (visionModel && note.media.length > 0 && this.mediaStore) {
|
||||
const visionActive = !!(visionModel && note.media.length > 0 && this.mediaStore);
|
||||
// v0.3.14 — vision 활성 여부 진단 로그. 사용자가 vision_model 미설정으로 text-only
|
||||
// path 가 도는지 / 이미지가 모델에 전달되는지 확인 가능 (logs/main.log).
|
||||
this.logger.info('ai.vision.decide', {
|
||||
noteId: job.noteId,
|
||||
visionActive,
|
||||
visionModelConfigured: !!visionModel,
|
||||
mediaCount: note.media.length,
|
||||
mediaStorePresent: !!this.mediaStore
|
||||
});
|
||||
if (visionActive) {
|
||||
const oversize = note.media.find((m) => m.bytes > 5 * 1024 * 1024);
|
||||
if (oversize) {
|
||||
throw new Error(`image ${oversize.relPath} exceeds 5MB cap (${oversize.bytes} bytes)`);
|
||||
@@ -233,8 +260,13 @@ export class AiWorker {
|
||||
const nextRunAt = new Date(Date.now() + (this.backoffsMs[attempt + 1] ?? 0)).toISOString();
|
||||
this.repo.incrementJobAttempt(job.noteId, nextRunAt, msg);
|
||||
if (isLast) {
|
||||
this.repo.markAiFailed(job.noteId, msg);
|
||||
this.logger.error('ai.failed', { noteId: job.noteId, err: msg });
|
||||
// v0.3.14 — ai_error 에 reason + provider name prefix 추가. NoteCard 의 "원인 보기"
|
||||
// 가 사용자에게 보여주는 raw 메시지에 context (timeout/unreachable/schema/other +
|
||||
// 어느 모델이 fail 했는지) 가 포함되어 진단성 향상.
|
||||
const provider = this.holder.get().name;
|
||||
const annotated = `[${reason}] ${provider}\n${msg}`;
|
||||
this.repo.markAiFailed(job.noteId, annotated);
|
||||
this.logger.error('ai.failed', { noteId: job.noteId, err: msg, reason, provider });
|
||||
if (this.telemetry) {
|
||||
await this.telemetry.emit({
|
||||
kind: 'ai_failed',
|
||||
|
||||
@@ -13,6 +13,29 @@ function classifyFetchError(e: unknown): 'network' | 'timeout' | 'dns' | 'other'
|
||||
return 'other';
|
||||
}
|
||||
|
||||
/**
|
||||
* v0.3.11 — vision model 이 'format:json' constraint 를 부분적으로 따라 markdown 코드
|
||||
* 펜스 / prose 가 섞인 응답을 반환할 때 fallback. 첫 '{' ~ 마지막 '}' substring 만
|
||||
* 추출해서 JSON.parse 재시도.
|
||||
*
|
||||
* v0.3.14 — fail 시 throw 대신 `{}` 반환. schema 의 graceful coerce 가 빈 객체를
|
||||
* placeholder title/summary 로 채움 → 사용자 데이터 손실 없이 노트 보관 (raw_text 그대로).
|
||||
* 모델이 repetition loop 로 num_predict cap 도달해 JSON truncate 된 케이스에 robust.
|
||||
* 원본 응답 snippet 은 console.warn 으로 로그 (디버그성).
|
||||
*/
|
||||
function parseJsonLoose(raw: string): unknown {
|
||||
try { return JSON.parse(raw); } catch { /* fallback below */ }
|
||||
const first = raw.indexOf('{');
|
||||
const last = raw.lastIndexOf('}');
|
||||
if (first >= 0 && last > first) {
|
||||
const slice = raw.slice(first, last + 1);
|
||||
try { return JSON.parse(slice); } catch { /* fall through */ }
|
||||
}
|
||||
// 빈 객체 반환 → schema coerce 로 placeholder 적용. 원본 일부는 stderr 에 남김.
|
||||
console.warn(`[LocalOllamaProvider] unparseable response, falling back to {}: ${raw.slice(0, 200).replace(/\s+/g, ' ')}`);
|
||||
return {};
|
||||
}
|
||||
|
||||
export interface LocalOllamaOptions {
|
||||
endpoint?: string;
|
||||
model?: string;
|
||||
@@ -46,15 +69,22 @@ export class LocalOllamaProvider implements InferenceProvider {
|
||||
? buildVisionPrompt(input.text, input.todayKst, input.dueDateCandidates.map((c) => c.iso ?? c.matchedToken ?? ''), input.vocab ?? [])
|
||||
: buildPrompt(input.text, input.todayKst, input.dueDateCandidates, input.vocab ?? []);
|
||||
|
||||
// v0.3.13 — vision model 은 cold-start (모델 load + 이미지 encoding) 가 매우 느려
|
||||
// 120s 기본 timeout 으로 첫 호출 fail 빈번. gemma4:26b (MoE 25B) 같은 대형 vision
|
||||
// 모델은 첫 generate 가 60-180s 소요. 5분 (300s) 으로 확장.
|
||||
const effectiveTimeout = useVision ? Math.max(this.timeoutMs, 300_000) : this.timeoutMs;
|
||||
this.abortController = new AbortController();
|
||||
const timer = setTimeout(() => this.abortController?.abort(), this.timeoutMs);
|
||||
const timer = setTimeout(() => this.abortController?.abort(), effectiveTimeout);
|
||||
try {
|
||||
const body: Record<string, unknown> = {
|
||||
model,
|
||||
prompt,
|
||||
format: 'json',
|
||||
stream: false,
|
||||
options: { temperature: this.temperature, num_predict: this.numPredict }
|
||||
// v0.3.14 — repeat_penalty 추가. vision 모델 (특히 gemma 시리즈) 이 "기기기기..."
|
||||
// 같은 repetition loop 에 빠져 num_predict cap 도달 → JSON truncate → unparseable.
|
||||
// 1.15 는 Ollama 권장 범위 (1.0-1.3) 안쪽 conservative 값.
|
||||
options: { temperature: this.temperature, num_predict: this.numPredict, repeat_penalty: 1.15 }
|
||||
};
|
||||
if (useVision) {
|
||||
body.images = input.images!.map((i) => i.base64);
|
||||
@@ -70,9 +100,8 @@ export class LocalOllamaProvider implements InferenceProvider {
|
||||
}
|
||||
const responseBody = (await res.body.json()) as { response?: string };
|
||||
if (!responseBody.response) throw new Error('missing response field');
|
||||
let parsed: unknown;
|
||||
try { parsed = JSON.parse(responseBody.response); }
|
||||
catch (err) { throw new Error(`invalid json in response: ${String(err)}`); }
|
||||
// v0.3.11 — vision model 응답이 markdown fence / prose 섞인 경우 fallback 추출.
|
||||
const parsed = parseJsonLoose(responseBody.response);
|
||||
return parseAiResponse(parsed);
|
||||
} finally {
|
||||
clearTimeout(timer);
|
||||
|
||||
@@ -39,13 +39,34 @@ function validateDueDate(d: string | null | undefined): string | null {
|
||||
return d;
|
||||
}
|
||||
|
||||
export function parseAiResponse(raw: unknown): AiResponse {
|
||||
const parsed = RawResponseSchema.parse(raw);
|
||||
if (!KOREAN_REGEX.test(parsed.title)) {
|
||||
throw new Error('title must contain Korean characters');
|
||||
/**
|
||||
* vision 모델 (gemma4:26b 등) 이 본문 빈 케이스에 title/summary null 반환하는 케이스
|
||||
* 대응. null → placeholder 한국어 문자열로 coerce 후 schema 통과. 빈 string / empty regex
|
||||
* dueDate 도 null 로 normalize. raw_text 는 호출자가 보존하므로 사용자 데이터 손실 없음.
|
||||
*/
|
||||
function coerceNullable(raw: unknown): unknown {
|
||||
if (typeof raw !== 'object' || raw === null) return raw;
|
||||
const obj = { ...(raw as Record<string, unknown>) };
|
||||
if (obj.title === null || obj.title === undefined || obj.title === '') obj.title = '(첨부 메모)';
|
||||
if (obj.summary === null || obj.summary === undefined || obj.summary === '') obj.summary = '내용을 자동으로 정리하지 못했습니다.';
|
||||
// due_date 의 빈 string / regex mismatch 도 null 로 강제 (schema 가 거부하지 않게).
|
||||
if (obj.due_date === '' || (typeof obj.due_date === 'string' && !ISO_DATE_REGEX.test(obj.due_date))) {
|
||||
obj.due_date = null;
|
||||
}
|
||||
// tags 가 null 이면 빈 배열로.
|
||||
if (obj.tags === null || obj.tags === undefined) obj.tags = [];
|
||||
return obj;
|
||||
}
|
||||
|
||||
export function parseAiResponse(raw: unknown): AiResponse {
|
||||
const coerced = coerceNullable(raw);
|
||||
const parsed = RawResponseSchema.parse(coerced);
|
||||
// title 이 한국어 0 자면 fallback placeholder 적용 (영어 title 도 fail 안 함).
|
||||
// placeholder 는 한국어 포함이라 자기 자신 통과.
|
||||
const titleHasKorean = KOREAN_REGEX.test(parsed.title);
|
||||
const finalTitle = titleHasKorean ? parsed.title : '(첨부 메모)';
|
||||
return {
|
||||
title: parsed.title.slice(0, 60),
|
||||
title: finalTitle.slice(0, 60),
|
||||
summary: normalizeSummary(parsed.summary),
|
||||
tags: parsed.tags.filter((t) => KEBAB_REGEX.test(t)).slice(0, 3),
|
||||
dueDate: validateDueDate(parsed.due_date)
|
||||
|
||||
@@ -4,13 +4,33 @@ export function buildVisionPrompt(
|
||||
dueCandidates: string[],
|
||||
vocab: string[]
|
||||
): string {
|
||||
return `다음 메모와 첨부 이미지를 종합 분석해 한국어로 요약하세요.
|
||||
// v0.3.14 — 본문 빈 케이스에 one-shot 예시 추가. gemma4:26b 등이 본문 없이
|
||||
// 이미지만 받으면 null 반환하는 한계 우회. 예시 입력/출력 구조 따라가도록 유도.
|
||||
const bodySection = text
|
||||
? `메모 본문:\n${text}\n\n첨부 이미지도 함께 분석해 요약에 반영하세요.`
|
||||
: `본문이 없습니다. 첨부 이미지의 내용 (텍스트/사람/장면/문서 등) 만으로 한국어 title 과 summary 를 작성하세요. null 반환 절대 금지.
|
||||
|
||||
메모 본문 (비어 있을 수 있음):
|
||||
${text || '(이미지만 있음)'}
|
||||
예시 (이미지: 갈색 강아지가 잔디 위에 앉은 사진):
|
||||
{"title":"잔디 위 강아지","summary":"갈색 강아지가 잔디 위에 앉아 있다.\\n배경에 나무가 보인다.\\n날씨가 맑다.","tags":["pet"],"due_date":null}
|
||||
|
||||
예시 (이미지: 회의실 화이트보드 사진):
|
||||
{"title":"회의실 화이트보드","summary":"화이트보드에 일정과 안건이 적혀 있다.\\n프로젝트 이름이 보인다.\\n다이어그램이 그려져 있다.","tags":["meeting"],"due_date":null}
|
||||
|
||||
이제 첨부된 실제 이미지를 보고 같은 형식으로 작성하세요.`;
|
||||
|
||||
return `다음 메모를 한국어로 분석해 JSON 으로 정리하세요.
|
||||
|
||||
${bodySection}
|
||||
|
||||
규칙 (위반 시 재시도):
|
||||
- "title": 한국어 문자열 필수, null 금지. 60자 이내. 영어 단독 금지.
|
||||
- "summary": 한국어 문자열 필수, null 금지. 3줄. 이미지 시각 정보 (텍스트/사람/장면) 포함.
|
||||
- "tags": 영문 kebab-case 배열 (예: ["meeting-notes"]), 최대 3개. 한국어 태그 금지. 없으면 [].
|
||||
- "due_date": ISO YYYY-MM-DD 또는 null. 빈 문자열 금지.
|
||||
|
||||
오직 JSON 객체 하나만 출력. markdown 코드 펜스 (\`\`\`) / 설명 prose 금지.
|
||||
출력 형식: {"title":"...","summary":"...","tags":[],"due_date":null}
|
||||
|
||||
이미지 분석 시 주요 시각적 정보 (텍스트, 사람, 장면) 도 포함해 요약하세요.
|
||||
출력 JSON: { "title": "...", "summary": "...", "tags": [...], "due_date": "..." }
|
||||
오늘: ${todayKst}
|
||||
가능한 due 후보: ${dueCandidates.join(', ')}
|
||||
빈출 태그: ${vocab.slice(0, 20).join(', ')}`;
|
||||
|
||||
@@ -193,9 +193,10 @@ app.whenReady().then(async () => {
|
||||
});
|
||||
if (!reg.ok) logger.warn('hotkey.register.failed', { reason: reg.reason });
|
||||
|
||||
if (!startedHidden) {
|
||||
createInboxWindow();
|
||||
}
|
||||
// macOS LoginItems autostart 시 startedHidden=true 로 spawn — 그대로 두면 quickCapture
|
||||
// (NSPanel) 만 떠 있어 dock running indicator 미표출. inboxWindow 를 hidden 상태로
|
||||
// 미리 create 하면 NSApp register → 점 표출 + 사용자가 dock 아이콘 확인으로 앱 살아있음 인지.
|
||||
createInboxWindow({ visible: !startedHidden });
|
||||
createQuickCaptureWindow();
|
||||
await worker.loadFromDb();
|
||||
|
||||
|
||||
@@ -150,6 +150,25 @@ export function registerInboxApi(deps: InboxIpcDeps): void {
|
||||
ipcMain.handle('inbox:retryAllFailed', async () => deps.capture.retryAllFailed());
|
||||
ipcMain.handle('inbox:failedCount', () => deps.repo.countFailed());
|
||||
|
||||
// v0.3.9 — per-note retry/cancel. failed/pending 사용자 막힘 해소 path.
|
||||
// status 변경 후 pushNoteUpdated 로 renderer counts/list 자동 sync.
|
||||
ipcMain.handle('inbox:retry-one-failed', async (_e, id: string) => {
|
||||
const r = await deps.capture.retryOneFailed(id);
|
||||
if (r.ok) {
|
||||
const updated = deps.repo.findById(id);
|
||||
if (updated !== null) pushNoteUpdated(deps.getInboxWindow, updated);
|
||||
}
|
||||
return r;
|
||||
});
|
||||
ipcMain.handle('inbox:cancel-pending', (_e, id: string) => {
|
||||
const r = deps.capture.cancelPending(id);
|
||||
if (r.ok) {
|
||||
const updated = deps.repo.findById(id);
|
||||
if (updated !== null) pushNoteUpdated(deps.getInboxWindow, updated);
|
||||
}
|
||||
return r;
|
||||
});
|
||||
|
||||
ipcMain.handle('inbox:listRecallCandidate', () => deps.capture.listRecallCandidate());
|
||||
ipcMain.handle('inbox:markRecallOpened', (_e, id: string) => deps.capture.markRecallOpened(id));
|
||||
ipcMain.handle('inbox:dismissRecall', (_e, id: string) => deps.capture.dismissRecall(id));
|
||||
@@ -198,6 +217,9 @@ export function registerInboxApi(deps: InboxIpcDeps): void {
|
||||
// v0.2.9 Cut B Task 8 — status 4분기 직접 전이 (사유 포함).
|
||||
// Modal 의 "완료/보관/휴지통" 버튼 path. backward compat 동기화는
|
||||
// NoteRepository.setStatus 내부에서 처리 (deleted_at sync).
|
||||
// v0.3.8 — setStatus 도 pushNoteUpdated emit. 이전엔 emit 안 해서 renderer 의 store
|
||||
// (counts/search/list) 가 stale 되어 NoteCard 호출처마다 명시적 refreshMeta 호출이
|
||||
// 필요했음. push 화 시 onNoteUpdated 콜백 1개 path 로 일관 갱신.
|
||||
ipcMain.handle(
|
||||
'inbox:set-status',
|
||||
async (_e, id: string, status: NoteStatus, reason: string | null) => {
|
||||
@@ -206,6 +228,8 @@ export function registerInboxApi(deps: InboxIpcDeps): void {
|
||||
return { ok: false as const, reason: 'invalid status' as const };
|
||||
}
|
||||
deps.repo.setStatus(id, status, reason);
|
||||
const updated = deps.repo.findById(id);
|
||||
if (updated !== null) pushNoteUpdated(deps.getInboxWindow, updated);
|
||||
return { ok: true as const };
|
||||
}
|
||||
);
|
||||
@@ -279,6 +303,7 @@ export function registerInboxApi(deps: InboxIpcDeps): void {
|
||||
return { ok: false as const, reason: 'empty' as const };
|
||||
}
|
||||
deps.repo.updateRawText(id, newText);
|
||||
await reprocessAi(deps, id);
|
||||
return { ok: true as const };
|
||||
});
|
||||
|
||||
@@ -287,6 +312,7 @@ export function registerInboxApi(deps: InboxIpcDeps): void {
|
||||
ipcMain.handle('inbox:restore-revision', async (_e, id: string, revId: number) => {
|
||||
try {
|
||||
deps.repo.restoreRevision(id, revId);
|
||||
await reprocessAi(deps, id);
|
||||
return { ok: true as const };
|
||||
} catch (e) {
|
||||
return { ok: false as const, reason: (e as Error).message };
|
||||
@@ -320,6 +346,19 @@ export function pushNoteUpdated(getWin: () => BrowserWindow | null, note: Note):
|
||||
w.webContents.send('note:updated', note);
|
||||
}
|
||||
|
||||
/**
|
||||
* 원문 변경 후 AI 재처리 트리거. ai_status='pending' 으로 reset + pending_jobs 재투입 +
|
||||
* worker enqueue + renderer push. disabled 노트는 사용자 명시 비활성화 의도 존중하여 skip.
|
||||
*/
|
||||
async function reprocessAi(deps: InboxIpcDeps, id: string): Promise<void> {
|
||||
const now = new Date().toISOString();
|
||||
const r = deps.repo.markAiPendingForReprocess(id, now);
|
||||
if (!r.ok) return;
|
||||
if (deps.enqueue) await deps.enqueue(id);
|
||||
const updated = deps.repo.findById(id);
|
||||
if (updated !== null) pushNoteUpdated(deps.getInboxWindow, updated);
|
||||
}
|
||||
|
||||
export function pushOllamaStatus(getWin: () => BrowserWindow | null, status: HealthResult): void {
|
||||
const w = getWin();
|
||||
if (!w || w.isDestroyed()) return;
|
||||
|
||||
@@ -248,6 +248,70 @@ export class NoteRepository {
|
||||
return { ids };
|
||||
}
|
||||
|
||||
/**
|
||||
* v0.3.9 — 단일 failed 노트 재시도. retryAllFailed 의 per-row 로직 동일.
|
||||
* NoteCard 의 per-note "재시도" 버튼 path. failed 가 아닌 status 면 no-op.
|
||||
*/
|
||||
retryOneFailed(id: string, now: string): { ok: boolean } {
|
||||
const row = this.db
|
||||
.prepare(`SELECT ai_status FROM notes WHERE id=? AND deleted_at IS NULL`)
|
||||
.get(id) as { ai_status: string } | undefined;
|
||||
if (!row || row.ai_status !== 'failed') return { ok: false };
|
||||
const tx = this.db.transaction(() => {
|
||||
this.db
|
||||
.prepare(`UPDATE notes SET ai_status='pending', ai_error=NULL, updated_at=? WHERE id=?`)
|
||||
.run(now, id);
|
||||
this.db
|
||||
.prepare(`INSERT OR IGNORE INTO pending_jobs (note_id, attempts, next_run_at) VALUES (?, 0, ?)`)
|
||||
.run(id, now);
|
||||
});
|
||||
tx();
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
/**
|
||||
* raw_text 편집/복원 직후 AI 재처리 트리거. done/failed/pending 노트를 pending 으로
|
||||
* reset + pending_jobs row 보장 (attempts=0). disabled 는 사용자의 명시적 비활성화
|
||||
* 의도 존중 — no-op. updateAiResult 의 user-edit 가드 (title_edited_by_user 등) 가
|
||||
* 사용자가 직접 편집한 필드는 새 AI 결과로 덮어쓰지 않음.
|
||||
*/
|
||||
markAiPendingForReprocess(id: string, now: string): { ok: boolean } {
|
||||
const row = this.db
|
||||
.prepare(`SELECT ai_status FROM notes WHERE id=? AND deleted_at IS NULL`)
|
||||
.get(id) as { ai_status: string } | undefined;
|
||||
if (!row || row.ai_status === 'disabled') return { ok: false };
|
||||
const tx = this.db.transaction(() => {
|
||||
this.db
|
||||
.prepare(`UPDATE notes SET ai_status='pending', ai_error=NULL, updated_at=? WHERE id=?`)
|
||||
.run(now, id);
|
||||
this.db
|
||||
.prepare(`INSERT OR REPLACE INTO pending_jobs (note_id, attempts, next_run_at) VALUES (?, 0, ?)`)
|
||||
.run(id, now);
|
||||
});
|
||||
tx();
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
/**
|
||||
* v0.3.9 — pending 노트의 AI 처리 cancel. ai_status='disabled' 로 전환 + pending_jobs 삭제.
|
||||
* raw_text 는 보존. 사용자가 무한 pending (Ollama 끊김 등) 에서 빠져나오는 path.
|
||||
* pending 외 status 면 no-op.
|
||||
*/
|
||||
cancelPending(id: string, now: string): { ok: boolean } {
|
||||
const row = this.db
|
||||
.prepare(`SELECT ai_status FROM notes WHERE id=? AND deleted_at IS NULL`)
|
||||
.get(id) as { ai_status: string } | undefined;
|
||||
if (!row || row.ai_status !== 'pending') return { ok: false };
|
||||
const tx = this.db.transaction(() => {
|
||||
this.db
|
||||
.prepare(`UPDATE notes SET ai_status='disabled', ai_error=NULL, updated_at=? WHERE id=?`)
|
||||
.run(now, id);
|
||||
this.db.prepare(`DELETE FROM pending_jobs WHERE note_id=?`).run(id);
|
||||
});
|
||||
tx();
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
/**
|
||||
* v0.2.9 Cut B Task 16 — 모든 ai_status='disabled' 노트를 'pending' 으로 reset 하고
|
||||
* pending_jobs 재투입. 사용자가 settings.ai_enabled OFF→ON 전환 후 "지금 모두 처리"
|
||||
@@ -1057,9 +1121,12 @@ export class NoteRepository {
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes whose due_date is strictly before today (KST calendar) and that are
|
||||
* still active (not trashed) and AI-processed. Includes both AI-extracted and
|
||||
* user-edited due_date (v0.2.3 #5 spec §1 Q1=B).
|
||||
* Notes whose due_date is today (KST calendar) or already past, that are still
|
||||
* active (inbox only — completed/archived/trashed 제외), and AI-processed.
|
||||
* Includes both AI-extracted and user-edited due_date.
|
||||
*
|
||||
* 정렬: due_date DESC → 오늘 당일 먼저, 그 다음 어제, 그 전... 같은 due_date 내에선
|
||||
* created_at DESC, id DESC tiebreak.
|
||||
*
|
||||
* Caller may inject `now` for testability; defaults to `new Date()`.
|
||||
*/
|
||||
@@ -1069,10 +1136,11 @@ export class NoteRepository {
|
||||
.prepare(
|
||||
`SELECT * FROM notes
|
||||
WHERE due_date IS NOT NULL
|
||||
AND due_date < ?
|
||||
AND due_date <= ?
|
||||
AND deleted_at IS NULL
|
||||
AND status = 'active'
|
||||
AND ai_status = 'done'
|
||||
ORDER BY created_at DESC, id DESC`
|
||||
ORDER BY due_date DESC, created_at DESC, id DESC`
|
||||
)
|
||||
.all(today) as Record<string, unknown>[];
|
||||
return rows.map((r) => this.hydrate(r));
|
||||
|
||||
@@ -4,11 +4,14 @@
|
||||
|
||||
import { KST_OFFSET_MS } from '../../shared/util/kstDate.js';
|
||||
|
||||
const FTS5_SPECIAL_CHARS_RE = /["*():]/g;
|
||||
// FTS5 special chars: " * ( ) : 외에도 - (NOT 연산자), ^ (column prefix), ` (escape),
|
||||
// AND/OR/NOT keyword 도 query parser 가 special 처리. v0.3.9 — backtick/dash/caret 추가.
|
||||
// 한국어 사용자가 의도 없이 입력할 가능성 가장 높은 punctuation 까지 sanitize.
|
||||
const FTS5_SPECIAL_CHARS_RE = /["*():`^\-]/g;
|
||||
const WS_COLLAPSE_RE = /\s+/g;
|
||||
|
||||
/**
|
||||
* FTS5 MATCH 쿼리에 안전한 형태로 변환. " * ( ) : 제거 + 공백 정리.
|
||||
* FTS5 MATCH 쿼리에 안전한 형태로 변환. special chars 공백 치환 + 공백 정리.
|
||||
* 다중 토큰은 그대로 두어 FTS5 implicit AND 활용.
|
||||
*/
|
||||
export function sanitizeFtsQuery(input: string): string {
|
||||
|
||||
@@ -13,6 +13,12 @@ export interface AutostartState {
|
||||
withArgs: { openAtLogin: boolean; executableWillLaunchAtLogin: boolean };
|
||||
noArgs: { openAtLogin: boolean; executableWillLaunchAtLogin: boolean };
|
||||
execPath: string;
|
||||
/**
|
||||
* 플랫폼 분기용. macOS 13+ 의 SMAppService API 는 args 옵션 무시 + unsigned/Electron
|
||||
* 앱에 대해 executableWillLaunchAtLogin 이 false 를 반환할 수 있어, mismatch 판정에서
|
||||
* 해당 신호를 제외해야 false positive 방지 가능.
|
||||
*/
|
||||
platform: NodeJS.Platform;
|
||||
registryPath?: string;
|
||||
registryValue?: string | null;
|
||||
}
|
||||
@@ -26,7 +32,8 @@ export async function collectAutostartState(): Promise<AutostartState> {
|
||||
const state: AutostartState = {
|
||||
withArgs: { openAtLogin: w.openAtLogin, executableWillLaunchAtLogin: w.executableWillLaunchAtLogin },
|
||||
noArgs: { openAtLogin: n.openAtLogin, executableWillLaunchAtLogin: n.executableWillLaunchAtLogin },
|
||||
execPath: process.execPath
|
||||
execPath: process.execPath,
|
||||
platform: process.platform
|
||||
};
|
||||
if (process.platform === 'win32') {
|
||||
state.registryPath = `${WIN_REGISTRY_PATH}\\${WIN_REGISTRY_KEY}`;
|
||||
|
||||
@@ -146,9 +146,9 @@ export class CaptureService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 만료 후보 (due_date < today KST, active, ai_status=done) 조회.
|
||||
* 마감 임박 후보 (due_date ≤ today KST, status=active inbox, ai_status=done) 조회.
|
||||
* 오늘 당일 마감 메모도 포함하여 사용자에게 미리 인지시킨다 (정렬은 due_date DESC).
|
||||
* candidates 가 비지 않고 signature 가 직전과 다르면 expired_banner_shown 자동 emit.
|
||||
* v0.2.3 #5 spec §6.2 — dedup 위치 main 통합.
|
||||
*/
|
||||
async listExpired(now: Date = new Date()): Promise<Note[]> {
|
||||
const candidates = this.repo.findExpiredCandidates(now);
|
||||
@@ -207,6 +207,24 @@ export class CaptureService {
|
||||
return { count: ids.length };
|
||||
}
|
||||
|
||||
/**
|
||||
* v0.3.9 — 단일 failed 노트 재시도. NoteCard 의 per-note "재시도" 버튼 path.
|
||||
* repo.retryOneFailed 후 worker.enqueue 재투입.
|
||||
*/
|
||||
async retryOneFailed(id: string): Promise<{ ok: boolean }> {
|
||||
const r = this.repo.retryOneFailed(id, new Date().toISOString());
|
||||
if (r.ok) await this.deps.enqueue(id);
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* v0.3.9 — pending 노트 cancel. ai_status='disabled' + pending_jobs 삭제.
|
||||
* 사용자가 무한 pending (Ollama 끊김 등) 에서 빠져나오는 path.
|
||||
*/
|
||||
cancelPending(id: string): { ok: boolean } {
|
||||
return this.repo.cancelPending(id, new Date().toISOString());
|
||||
}
|
||||
|
||||
/** v0.2.3 #6 — 회상 후보 1건 fetch. */
|
||||
async listRecallCandidate(): Promise<Note | null> {
|
||||
return this.repo.findRecallCandidate();
|
||||
|
||||
@@ -136,7 +136,6 @@ export class ExportService {
|
||||
totalBytes += Buffer.byteLength(indexJsonl, 'utf8');
|
||||
|
||||
const manifest = composeManifest({
|
||||
exportedAt: this.now().toISOString(),
|
||||
noteCount: notes.length,
|
||||
mediaCount
|
||||
});
|
||||
|
||||
@@ -253,14 +253,15 @@ export function composeIndexJsonl(
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export function composeManifest(input: {
|
||||
exportedAt: string;
|
||||
noteCount: number;
|
||||
mediaCount: number;
|
||||
}): string {
|
||||
// exported_at 필드 의도적 제외 — note 변경 없이도 git sync 가 매 호출마다
|
||||
// timestamp 갱신 1줄 commit 을 만들어 history 노이즈와 불필요한 push 유발.
|
||||
// import path 는 inkling_export_version 만 read 하므로 안전.
|
||||
return JSON.stringify(
|
||||
{
|
||||
inkling_export_version: 1,
|
||||
exported_at: input.exportedAt,
|
||||
note_count: input.noteCount,
|
||||
media_count: input.mediaCount
|
||||
},
|
||||
|
||||
@@ -11,10 +11,13 @@ export function getInboxWindow(): BrowserWindowType | null {
|
||||
return inboxWindow;
|
||||
}
|
||||
|
||||
export function createInboxWindow(): BrowserWindowType {
|
||||
export function createInboxWindow(opts: { visible?: boolean } = {}): BrowserWindowType {
|
||||
const visible = opts.visible ?? true;
|
||||
if (inboxWindow && !inboxWindow.isDestroyed()) {
|
||||
inboxWindow.show();
|
||||
inboxWindow.focus();
|
||||
if (visible) {
|
||||
inboxWindow.show();
|
||||
inboxWindow.focus();
|
||||
}
|
||||
return inboxWindow;
|
||||
}
|
||||
|
||||
@@ -43,6 +46,19 @@ export function createInboxWindow(): BrowserWindowType {
|
||||
}
|
||||
});
|
||||
|
||||
inboxWindow.once('ready-to-show', () => inboxWindow?.show());
|
||||
inboxWindow.once('ready-to-show', () => {
|
||||
if (visible) {
|
||||
inboxWindow?.show();
|
||||
return;
|
||||
}
|
||||
// macOS hidden autostart: regular NSWindow 를 NSApp 에 register 해야 dock running
|
||||
// indicator (점) 가 표출된다. panel type 의 quickCapture 만 있으면 NSPanel 미인지 →
|
||||
// dock 점이 안 보여 "앱이 안 떠 있는 것처럼" 보이는 버그. showInactive 로 focus 점유
|
||||
// 없이 짧게 표출 후 즉시 hide — 사용자 화면 깜빡임 최소화.
|
||||
if (process.platform === 'darwin') {
|
||||
inboxWindow?.showInactive();
|
||||
inboxWindow?.hide();
|
||||
}
|
||||
});
|
||||
return inboxWindow;
|
||||
}
|
||||
|
||||
@@ -16,23 +16,35 @@ export function createQuickCaptureWindow(): BrowserWindowType {
|
||||
const x = Math.round((primary.workArea.width - W) / 2 + primary.workArea.x);
|
||||
const y = Math.round((primary.workArea.height - H) / 3 + primary.workArea.y);
|
||||
|
||||
// v0.3.10 — macOS fullscreen Space 위에 quick capture 띄우기.
|
||||
// 기본 BrowserWindow 는 첫 생성된 Space (홈 데스크탑) 에만 표시되므로
|
||||
// 사용자가 다른 앱 fullscreen 중일 때 macOS 가 강제 Space 전환 → 사용자 경험 깨짐.
|
||||
// 'panel' 타입 + 'screen-saver' level + visibleOnFullScreen 조합으로 현재 Space 위에 overlay.
|
||||
const isMac = process.platform === 'darwin';
|
||||
win = new BrowserWindow({
|
||||
width: W, height: H, x, y,
|
||||
frame: false, show: false, alwaysOnTop: true,
|
||||
skipTaskbar: true, resizable: false,
|
||||
...(isMac ? { type: 'panel' as const } : {}),
|
||||
webPreferences: {
|
||||
preload: join(__dirname, '../preload/index.js'),
|
||||
contextIsolation: true, nodeIntegration: false, sandbox: false
|
||||
}
|
||||
});
|
||||
|
||||
if (isMac) {
|
||||
// 'screen-saver' level — fullscreen app 위에 띄울 수 있는 가장 높은 level.
|
||||
// visibleOnFullScreen: true — 현재 fullscreen Space 에 함께 표시 (Space 전환 안 함).
|
||||
win.setAlwaysOnTop(true, 'screen-saver');
|
||||
win.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
|
||||
}
|
||||
|
||||
if (process.env.ELECTRON_RENDERER_URL) {
|
||||
win.loadURL(`${process.env.ELECTRON_RENDERER_URL}/quickcapture/index.html`);
|
||||
} else {
|
||||
win.loadFile(join(__dirname, '../renderer/quickcapture/index.html'));
|
||||
}
|
||||
|
||||
win.on('blur', () => { if (win?.isVisible()) win.hide(); });
|
||||
return win;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,8 @@ const api: InklingApi = {
|
||||
},
|
||||
retryAllFailed: () => ipcRenderer.invoke('inbox:retryAllFailed'),
|
||||
getFailedCount: () => ipcRenderer.invoke('inbox:failedCount'),
|
||||
retryOneFailed: (id: string) => ipcRenderer.invoke('inbox:retry-one-failed', id),
|
||||
cancelPending: (id: string) => ipcRenderer.invoke('inbox:cancel-pending', id),
|
||||
listRecallCandidate: () => ipcRenderer.invoke('inbox:listRecallCandidate'),
|
||||
markRecallOpened: (id: string) => ipcRenderer.invoke('inbox:markRecallOpened', id),
|
||||
dismissRecall: (id: string) => ipcRenderer.invoke('inbox:dismissRecall', id),
|
||||
|
||||
@@ -18,6 +18,9 @@ import { SearchBox } from './components/SearchBox.js';
|
||||
import { ReviewView } from './components/ReviewView.js';
|
||||
import type { InboxView } from './store.js';
|
||||
|
||||
// QuickCapture 단축키 modifier — macOS 는 Cmd, 그 외는 Ctrl.
|
||||
const MOD_KEY = /Mac/i.test(navigator.platform) ? 'Cmd' : 'Ctrl';
|
||||
|
||||
export function App(): React.ReactElement {
|
||||
const {
|
||||
notes, trashNotes, trashCount, showTrash,
|
||||
@@ -190,7 +193,7 @@ export function App(): React.ReactElement {
|
||||
) : searchResults !== null && displayed.length === 0 ? (
|
||||
<div className="empty">검색 결과가 없습니다.</div>
|
||||
) : notes.length === 0 ? (
|
||||
<div className="empty">머릿속에 떠다니는 한 줄을 적어보세요. <code>Ctrl+Shift+J</code></div>
|
||||
<div className="empty">머릿속에 떠다니는 한 줄을 적어보세요. <code>{MOD_KEY}+Shift+J</code></div>
|
||||
) : displayed.length === 0 ? (
|
||||
<div className="empty">이 태그의 노트가 없습니다.</div>
|
||||
) : (
|
||||
|
||||
@@ -38,6 +38,15 @@ export function ConflictModal({ onClose, onResolved, onOpenHelp }: Props): React
|
||||
return () => { cancelled = true; };
|
||||
}, []);
|
||||
|
||||
// Escape key 로 닫기.
|
||||
useEffect(() => {
|
||||
function onKey(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape') onClose();
|
||||
}
|
||||
document.addEventListener('keydown', onKey);
|
||||
return () => document.removeEventListener('keydown', onKey);
|
||||
}, [onClose]);
|
||||
|
||||
async function onChoose(path: string, choice: 'local' | 'remote') {
|
||||
setBusy(path);
|
||||
setError(null);
|
||||
|
||||
@@ -2,6 +2,35 @@ import React, { useEffect, useState } from 'react';
|
||||
import type { Note } from '@shared/types';
|
||||
import { useInbox } from '../store.js';
|
||||
import { Banner } from './Banner.js';
|
||||
import { DAY_MS, kstTodayIso } from '@shared/util/kstDate.js';
|
||||
|
||||
/**
|
||||
* due_date 대비 오늘 (KST) 의 상대 라벨. 오늘 = "오늘", 지난 = "N일 지남".
|
||||
* findExpiredCandidates 가 미래 due 는 반환하지 않으므로 음수 케이스 미고려.
|
||||
*/
|
||||
function dueRelativeLabel(due: string, todayKst: string): string {
|
||||
if (due === todayKst) return '오늘';
|
||||
const dueUtc = Date.UTC(
|
||||
Number(due.slice(0, 4)), Number(due.slice(5, 7)) - 1, Number(due.slice(8, 10))
|
||||
);
|
||||
const todayUtc = Date.UTC(
|
||||
Number(todayKst.slice(0, 4)), Number(todayKst.slice(5, 7)) - 1, Number(todayKst.slice(8, 10))
|
||||
);
|
||||
const days = Math.round((todayUtc - dueUtc) / DAY_MS);
|
||||
return `${days}일 지남`;
|
||||
}
|
||||
|
||||
function headingText(todayCount: number, overdueCount: number): string {
|
||||
if (todayCount > 0 && overdueCount > 0) return `오늘 마감 ${todayCount} · 지난 ${overdueCount}`;
|
||||
if (todayCount > 0) return `오늘 마감 ${todayCount}개`;
|
||||
return `지난 ${overdueCount}개`;
|
||||
}
|
||||
|
||||
/** RecallBanner 와 동일 패턴 — NoteCard 의 `note-{id}` element 로 smooth scroll. */
|
||||
function scrollToNote(id: string): void {
|
||||
const el = document.getElementById(`note-${id}`);
|
||||
if (el) el.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
|
||||
export function ExpiryBanner(): React.ReactElement | null {
|
||||
const candidates = useInbox((s) => s.expiredCandidates);
|
||||
@@ -58,6 +87,10 @@ function ExpiryBannerInner({ candidates, onTrash, onSnooze }: InnerProps): React
|
||||
const allSelected = candidates.length > 0 && candidates.every((c) => selected.has(c.id));
|
||||
const someSelected = selected.size > 0 && !allSelected;
|
||||
|
||||
const todayKst = kstTodayIso();
|
||||
const todayCount = candidates.filter((c) => c.dueDate === todayKst).length;
|
||||
const overdueCount = candidates.length - todayCount;
|
||||
|
||||
function toggleAll() {
|
||||
if (allSelected) setSelected(new Set());
|
||||
else setSelected(new Set(candidates.map((c) => c.id)));
|
||||
@@ -75,7 +108,7 @@ function ExpiryBannerInner({ candidates, onTrash, onSnooze }: InnerProps): React
|
||||
return (
|
||||
<Banner severity="warning">
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<span>⏰ <b>오늘 기준 만료 {candidates.length}개</b></span>
|
||||
<span>⏰ <b>{headingText(todayCount, overdueCount)}</b></span>
|
||||
<button
|
||||
onClick={() => setExpanded((e) => !e)}
|
||||
style={{ background: 'none', border: 'none', cursor: 'pointer', color: '#946100' }}
|
||||
@@ -107,33 +140,51 @@ function ExpiryBannerInner({ candidates, onTrash, onSnooze }: InnerProps): React
|
||||
<span style={{ color: '#666' }}>전체 선택 ({selected.size}/{candidates.length})</span>
|
||||
</label>
|
||||
<div>
|
||||
{candidates.map((n) => (
|
||||
<label
|
||||
key={n.id}
|
||||
style={{
|
||||
display: 'flex', alignItems: 'center', gap: 8,
|
||||
padding: '4px 0', cursor: 'pointer'
|
||||
}}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={selected.has(n.id)}
|
||||
onChange={() => toggle(n.id)}
|
||||
/>
|
||||
<span style={{ flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{n.aiTitle ?? n.rawText.slice(0, 60)}
|
||||
</span>
|
||||
<span style={{ color: '#946100', fontSize: 12 }}>due {n.dueDate}</span>
|
||||
{n.tags[0] && (
|
||||
<span style={{
|
||||
background: '#fce8b2', color: '#946100', padding: '0 6px',
|
||||
borderRadius: 10, fontSize: 11
|
||||
}}>
|
||||
#{n.tags[0].name}
|
||||
{candidates.map((n) => {
|
||||
const title = n.aiTitle ?? n.rawText.slice(0, 60);
|
||||
return (
|
||||
<div
|
||||
key={n.id}
|
||||
style={{
|
||||
display: 'flex', alignItems: 'center', gap: 8,
|
||||
padding: '4px 0'
|
||||
}}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={selected.has(n.id)}
|
||||
onChange={() => toggle(n.id)}
|
||||
aria-label={`${title} 선택`}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => scrollToNote(n.id)}
|
||||
title="해당 메모로 이동"
|
||||
style={{
|
||||
flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
|
||||
background: 'none', border: 'none', padding: 0,
|
||||
cursor: 'pointer', color: 'inherit', font: 'inherit', textAlign: 'left'
|
||||
}}
|
||||
>
|
||||
{title}
|
||||
</button>
|
||||
<span
|
||||
style={{ color: '#946100', fontSize: 12 }}
|
||||
title={`due ${n.dueDate}`}
|
||||
>
|
||||
{dueRelativeLabel(n.dueDate ?? todayKst, todayKst)}
|
||||
</span>
|
||||
)}
|
||||
</label>
|
||||
))}
|
||||
{n.tags[0] && (
|
||||
<span style={{
|
||||
background: '#fce8b2', color: '#946100', padding: '0 6px',
|
||||
borderRadius: 10, fontSize: 11
|
||||
}}>
|
||||
#{n.tags[0].name}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<button
|
||||
onClick={() => onTrash(Array.from(selected))}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useState } from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { inboxApi } from '../api.js';
|
||||
import type { NoteStatus } from '@shared/types';
|
||||
|
||||
@@ -6,17 +6,24 @@ interface Props {
|
||||
noteId: string;
|
||||
rawText: string;
|
||||
summary: string;
|
||||
/** 현재 노트 status. 이 값을 제외한 나머지 status 가 이동 버튼으로 노출. */
|
||||
currentStatus: NoteStatus;
|
||||
onClose: () => void;
|
||||
onMoved: (status: NoteStatus, reason: string | null) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* v0.2.9 Cut B Task 7 — 메모 이동 Modal.
|
||||
* 메모 이동 Modal.
|
||||
*
|
||||
* 사유 입력 + 3 status 버튼 (완료/보관/휴지통) + AI 자동 분류.
|
||||
* 사유 입력 + AI 자동 분류 + 수동 status 선택. 버튼은 currentStatus 를 제외한
|
||||
* 나머지 status 만 노출 (v0.3.6 까지는 완료/보관/휴지통 hardcode 라 완료/보관 노트가
|
||||
* inbox 로 못 돌아오던 버그를 v0.3.7 에서 정정).
|
||||
*/
|
||||
const ALL_STATUSES: readonly NoteStatus[] = ['active', 'completed', 'archived', 'trashed'];
|
||||
|
||||
export function MoveStatusModal({
|
||||
noteId,
|
||||
currentStatus,
|
||||
onClose,
|
||||
onMoved
|
||||
}: Props): React.ReactElement {
|
||||
@@ -27,6 +34,15 @@ export function MoveStatusModal({
|
||||
} | null>(null);
|
||||
const [classifying, setClassifying] = useState(false);
|
||||
|
||||
// Escape key 로 modal 닫기. mount 동안만 listener 활성.
|
||||
useEffect(() => {
|
||||
function onKey(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape') onClose();
|
||||
}
|
||||
document.addEventListener('keydown', onKey);
|
||||
return () => document.removeEventListener('keydown', onKey);
|
||||
}, [onClose]);
|
||||
|
||||
async function move(status: NoteStatus): Promise<void> {
|
||||
const trimmedReason = reason.trim() === '' ? null : reason.trim();
|
||||
await inboxApi.setStatus(noteId, status, trimmedReason);
|
||||
@@ -48,6 +64,7 @@ export function MoveStatusModal({
|
||||
<div
|
||||
role="dialog"
|
||||
aria-label="이동"
|
||||
onClick={onClose}
|
||||
style={{
|
||||
position: 'fixed',
|
||||
top: 0,
|
||||
@@ -62,6 +79,7 @@ export function MoveStatusModal({
|
||||
}}
|
||||
>
|
||||
<div
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
style={{
|
||||
background: '#fff',
|
||||
padding: 16,
|
||||
@@ -90,9 +108,11 @@ export function MoveStatusModal({
|
||||
<button onClick={() => void classify()} disabled={classifying}>
|
||||
{classifying ? '분류 중...' : 'AI 자동 분류'}
|
||||
</button>
|
||||
<button onClick={() => void move('completed')}>완료</button>
|
||||
<button onClick={() => void move('archived')}>보관</button>
|
||||
<button onClick={() => void move('trashed')}>휴지통</button>
|
||||
{ALL_STATUSES.filter((s) => s !== currentStatus).map((s) => (
|
||||
<button key={s} onClick={() => void move(s)}>
|
||||
{statusLabel(s)}
|
||||
</button>
|
||||
))}
|
||||
<button onClick={onClose} style={{ marginLeft: 'auto' }}>
|
||||
취소
|
||||
</button>
|
||||
@@ -126,7 +146,8 @@ export function MoveStatusModal({
|
||||
export function statusLabel(s: NoteStatus): string {
|
||||
switch (s) {
|
||||
case 'active':
|
||||
return '활성';
|
||||
// 헤더 탭 표기 ('Inbox') 와 일치. UI 전반에서 active = Inbox 동의어.
|
||||
return 'Inbox';
|
||||
case 'completed':
|
||||
return '완료';
|
||||
case 'archived':
|
||||
|
||||
@@ -154,7 +154,15 @@ export function NoteCard({ note, onDeleted, onUpdated, mode = 'inbox', onRestore
|
||||
if (next.trim().length === 0) return;
|
||||
const r = await inboxApi.updateRawText(note.id, next);
|
||||
if (!r.ok) return;
|
||||
const updated = { ...local, rawText: next, updatedAt: new Date().toISOString() };
|
||||
// disabled 노트는 AI 재처리 안 됨 (서버에서 skip) — aiStatus 유지.
|
||||
// 그 외는 optimistic 으로 pending 표시 → AiWorker 완료 시 push 로 자동 sync.
|
||||
const willReprocess = local.aiStatus !== 'disabled';
|
||||
const updated = {
|
||||
...local,
|
||||
rawText: next,
|
||||
updatedAt: new Date().toISOString(),
|
||||
...(willReprocess ? { aiStatus: 'pending' as const, aiError: null } : {})
|
||||
};
|
||||
setLocal(updated);
|
||||
onUpdated(updated);
|
||||
setEditingRaw(false);
|
||||
@@ -215,13 +223,61 @@ export function NoteCard({ note, onDeleted, onUpdated, mode = 'inbox', onRestore
|
||||
)}
|
||||
|
||||
{local.aiStatus === 'pending' && (
|
||||
<div style={{ fontSize: 16, fontWeight: 600, color: '#666', marginTop: 4 }}>
|
||||
Inkling이 정리하는 중…
|
||||
<div style={{ marginTop: 4, display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<div style={{ fontSize: 16, fontWeight: 600, color: '#666' }}>
|
||||
Inkling이 정리하는 중…
|
||||
</div>
|
||||
{/* v0.3.9 — pending cancel UI. Ollama 끊김 / 무한 pending 시 사용자 unblock path. */}
|
||||
<button
|
||||
onClick={async () => {
|
||||
await inboxApi.cancelPending(local.id);
|
||||
// push 기반 — onNoteUpdated 가 store 자동 갱신.
|
||||
}}
|
||||
style={{
|
||||
background: 'none', border: '1px solid #ccc', color: '#666',
|
||||
cursor: 'pointer', fontSize: 11, padding: '2px 8px', borderRadius: 4
|
||||
}}
|
||||
title="AI 자동 처리를 건너뛰고 원문만 보관"
|
||||
>
|
||||
건너뛰기
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
{local.aiStatus === 'failed' && (
|
||||
<div title={local.aiError ?? ''} style={{ fontSize: 16, fontWeight: 600, color: '#a55', marginTop: 4 }}>
|
||||
정리 보류 — 원문은 안전합니다
|
||||
<div style={{ marginTop: 4 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<div style={{ fontSize: 16, fontWeight: 600, color: '#a55' }}>
|
||||
정리 보류 — 원문은 안전합니다
|
||||
</div>
|
||||
{/* v0.3.9 — per-note 재시도 UI. FailedBanner 의 일괄 재시도와 별개. */}
|
||||
<button
|
||||
onClick={async () => {
|
||||
await inboxApi.retryOneFailed(local.id);
|
||||
}}
|
||||
style={{
|
||||
background: 'none', border: '1px solid #a55', color: '#a55',
|
||||
cursor: 'pointer', fontSize: 11, padding: '2px 8px', borderRadius: 4
|
||||
}}
|
||||
title="이 노트만 AI 처리 재시도"
|
||||
>
|
||||
재시도
|
||||
</button>
|
||||
</div>
|
||||
{/* v0.3.14 — fail 원인 inline 표시. ai_error 의 raw message 가 그대로 사용자에게
|
||||
보여서 디버깅 + 모델/네트워크 이슈 진단 가능. 너무 길면 <details> 로 접힘. */}
|
||||
{local.aiError !== null && local.aiError.length > 0 && (
|
||||
<details style={{ marginTop: 4 }}>
|
||||
<summary style={{ fontSize: 12, color: '#a55', cursor: 'pointer' }}>
|
||||
원인 보기
|
||||
</summary>
|
||||
<pre style={{
|
||||
fontSize: 11, color: '#666', background: '#fff0f0', padding: 6,
|
||||
borderRadius: 4, marginTop: 4, whiteSpace: 'pre-wrap', wordBreak: 'break-word'
|
||||
}}>
|
||||
{local.aiError}
|
||||
</pre>
|
||||
</details>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{/* v0.2.9 Cut B Task 13 — ai_status='disabled': raw_text 첫 줄 fallback title.
|
||||
@@ -468,6 +524,7 @@ export function NoteCard({ note, onDeleted, onUpdated, mode = 'inbox', onRestore
|
||||
noteId={local.id}
|
||||
rawText={local.rawText}
|
||||
summary={local.aiSummary ?? ''}
|
||||
currentStatus={local.status}
|
||||
onClose={() => setMoveOpen(false)}
|
||||
onMoved={(newStatus, reason) => {
|
||||
const updated = { ...local, status: newStatus, moveReason: reason };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { inboxApi } from '../api.js';
|
||||
|
||||
/**
|
||||
@@ -10,12 +10,42 @@ import { inboxApi } from '../api.js';
|
||||
* 가 SettingsPage 에서 추후 선택 가능.
|
||||
*/
|
||||
export function OnboardingWizard({ onClose }: { onClose: () => void }): React.ReactElement {
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
async function choose(aiEnabled: boolean | null): Promise<void> {
|
||||
if (aiEnabled !== null) await inboxApi.setAiEnabled(aiEnabled);
|
||||
await inboxApi.setOnboardingCompleted(true);
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
if (aiEnabled !== null) await inboxApi.setAiEnabled(aiEnabled);
|
||||
await inboxApi.setOnboardingCompleted(true);
|
||||
onClose();
|
||||
} catch (e) {
|
||||
// IPC 실패 (예: settings 저장 throw) 시 modal stuck 방지. 사용자에게 메시지 표시 +
|
||||
// "지금 건너뛰기" 로 fallback 길 제공. choose() 가 throw 하지 않고 무한 wizard 잠금
|
||||
// 회피.
|
||||
setError((e as Error).message);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
function skip(): void {
|
||||
// IPC 자체가 실패하는 상태 → ai_enabled 변경/onboarding flag 저장 모두 포기하고 wizard 만 닫기.
|
||||
// 다음 launch 에 다시 wizard 가 뜸 (onboarding_completed=false 상태). 그래도 사용자가
|
||||
// 진입 자체는 가능.
|
||||
onClose();
|
||||
}
|
||||
|
||||
// Escape key 로 wizard 종료 (skip 동일 — onboarding flag 미저장).
|
||||
useEffect(() => {
|
||||
function onKey(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape') skip();
|
||||
}
|
||||
document.addEventListener('keydown', onKey);
|
||||
return () => document.removeEventListener('keydown', onKey);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div role="dialog" aria-label="시작 안내" style={{
|
||||
position: 'fixed', top: 0, left: 0, right: 0, bottom: 0,
|
||||
@@ -32,10 +62,16 @@ export function OnboardingWizard({ onClose }: { onClose: () => void }): React.Re
|
||||
<a href="https://ollama.com/download" target="_blank" rel="noopener noreferrer">ollama.com/download</a>
|
||||
</p>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
<button onClick={() => choose(true)}>AI 자동 처리 사용 (Ollama 필요)</button>
|
||||
<button onClick={() => choose(false)}>원문만 저장 (AI 처리 안 함)</button>
|
||||
<button onClick={() => choose(null)} style={{ marginTop: 4 }}>나중에 설정</button>
|
||||
<button onClick={() => choose(true)} disabled={busy}>AI 자동 처리 사용 (Ollama 필요)</button>
|
||||
<button onClick={() => choose(false)} disabled={busy}>원문만 저장 (AI 처리 안 함)</button>
|
||||
<button onClick={() => choose(null)} disabled={busy} style={{ marginTop: 4 }}>나중에 설정</button>
|
||||
</div>
|
||||
{error !== null && (
|
||||
<div style={{ marginTop: 12, padding: 8, background: '#fdecea', color: '#a3261c', fontSize: 12, borderRadius: 4 }}>
|
||||
<div>설정 저장 실패: {error}</div>
|
||||
<button onClick={skip} style={{ marginTop: 8 }}>지금 건너뛰기</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -37,6 +37,15 @@ export function RevisionHistoryModal({ noteId, onClose, onRestored }: Props): Re
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
// Escape key 로 닫기.
|
||||
useEffect(() => {
|
||||
function onKey(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape') onClose();
|
||||
}
|
||||
document.addEventListener('keydown', onKey);
|
||||
return () => document.removeEventListener('keydown', onKey);
|
||||
}, [onClose]);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
void (async () => {
|
||||
|
||||
@@ -36,6 +36,15 @@ export function SyncHelpModal({ onClose, initialAnchor }: Props): React.ReactEle
|
||||
if (el) el.scrollIntoView({ behavior: 'auto', block: 'start' });
|
||||
}, [initialAnchor]);
|
||||
|
||||
// Escape key 로 닫기.
|
||||
useEffect(() => {
|
||||
function onKey(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape') onClose();
|
||||
}
|
||||
document.addEventListener('keydown', onKey);
|
||||
return () => document.removeEventListener('keydown', onKey);
|
||||
}, [onClose]);
|
||||
|
||||
return (
|
||||
<div style={overlayStyle} onClick={onClose}>
|
||||
<div ref={bodyRef} style={modalStyle} onClick={(e) => e.stopPropagation()}>
|
||||
@@ -45,8 +54,8 @@ export function SyncHelpModal({ onClose, initialAnchor }: Props): React.ReactEle
|
||||
</div>
|
||||
|
||||
<section id="main-conflict" style={sectionStyle}>
|
||||
<h4 style={h4Style}>1. 충돌 해결 (메인 시나리오)</h4>
|
||||
<p style={pStyle}>같은 노트를 두 기기에서 동시에 수정하면 충돌이 발생한다. "충돌 해결…" 버튼이 활성화되면 ConflictModal 이 열려 path 별 결정 (내 것 사용 / 원격 사용) 을 받는다.</p>
|
||||
<h4 style={h4Style}>1. 충돌 해결 (직접 결정해야 하는 일)</h4>
|
||||
<p style={pStyle}>같은 노트를 두 기기에서 동시에 수정하면 어느 쪽을 남길지 Inkling 이 자동으로 결정할 수 없습니다. 이때 "충돌 해결…" 버튼이 활성화되고, 노트별로 "내 것 사용" 또는 "원격 사용" 을 골라주시면 됩니다.</p>
|
||||
|
||||
<p style={{ ...pStyle, marginTop: 10, fontWeight: 600 }}>편집/편집 — 가장 흔한 경우</p>
|
||||
<ul style={{ paddingLeft: 18, margin: '4px 0' }}>
|
||||
@@ -70,21 +79,23 @@ export function SyncHelpModal({ onClose, initialAnchor }: Props): React.ReactEle
|
||||
</section>
|
||||
|
||||
<section id="auto" style={sectionStyle}>
|
||||
<h4 style={h4Style}>2. 자동 처리 (내가 안 해도 되는 일)</h4>
|
||||
<h4 style={h4Style}>2. 자동으로 처리되는 일</h4>
|
||||
<p style={pStyle}>아래 동작은 Inkling 이 알아서 처리합니다. 충돌이 없으면 사용자가 신경 쓸 일은 없습니다.</p>
|
||||
<ul style={{ paddingLeft: 18, margin: '4px 0' }}>
|
||||
<li style={liStyle}><b>fetch + rebase</b>: sync 시작 시 원격 변경을 가져와 내 변경 위에 다시 쌓음 (linear history). conflict 없으면 자동 진행</li>
|
||||
<li style={liStyle}><b>첫 sync 순서</b>: 빈 원격에는 어느 기기든 먼저 push 가능. 두 번째 기기는 fetch 후 자동 rebase</li>
|
||||
<li style={liStyle}><b>push 거부 (non-fast-forward)</b>: 다른 기기가 먼저 push 했어도 자동 fetch + rebase + 재시도. 사용자 개입은 rebase conflict 발생 시에만</li>
|
||||
<li style={liStyle}><b>자동 sync 주기</b>: 기본 30분 (설정에서 변경). 앱 종료 시 자동 1회 추가</li>
|
||||
<li style={liStyle}><b>원격 변경 먼저 받아오기</b>: 동기화를 시작하면 다른 기기가 올린 변경을 먼저 받아와 내 변경 위에 차곡차곡 올려놓습니다. 양쪽이 같은 줄을 건드리지 않으면 자동으로 진행됩니다.</li>
|
||||
<li style={liStyle}><b>첫 동기화 순서</b>: 비어있는 원격 저장소에는 어느 기기든 먼저 올릴 수 있습니다. 두 번째 기기는 받아온 뒤 자동으로 합쳐집니다.</li>
|
||||
<li style={liStyle}><b>업로드 거부 시 자동 재시도</b>: 다른 기기가 이미 변경을 올려둔 상태라 내 업로드가 막혀도, 받아오기 + 합치기 + 재시도가 자동으로 진행됩니다. 사용자가 개입할 일은 같은 위치를 양쪽이 동시에 수정한 경우에만 생깁니다.</li>
|
||||
<li style={liStyle}><b>자동 동기화 주기</b>: 기본 30분 (설정에서 변경). 앱 종료 시에도 한 번 추가로 실행됩니다.</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section id="silent" style={sectionStyle}>
|
||||
<h4 style={h4Style}>3. 조용히 잘못될 수 있는 케이스 (silent risk)</h4>
|
||||
<h4 style={h4Style}>3. 모르고 넘어가기 쉬운 함정</h4>
|
||||
<p style={pStyle}>아래 상황은 에러처럼 보이지 않지만 결과가 잘못 나올 수 있으니 미리 알아두는 것이 좋습니다.</p>
|
||||
<ul style={{ paddingLeft: 18, margin: '4px 0' }}>
|
||||
<li style={liStyle}><b>시계 어긋남 (NTP)</b>: 양 기기 시계가 다르면 timestamp 기반 merge 가 잘못된 결과를 낼 수 있음. macOS / Windows 모두 기본 NTP 동기화 켜져 있음 — 수동으로 끄지 말 것</li>
|
||||
<li style={liStyle}><b>두 기기 동시 수정 회피</b>: 같은 노트를 동시에 수정하면 conflict 가 더 자주 발생. 한 기기에서 작업 중이면 다른 기기에서 같은 노트 수정 자제</li>
|
||||
<li style={liStyle}><b>자동 sync 실패 silent</b>: 주기적 sync 실패 시 토스트 안 뜸. 마지막 sync 시각 / 결과는 설정 페이지에서 확인 — 주 1회 점검 권장</li>
|
||||
<li style={liStyle}><b>두 기기의 시각 어긋남</b>: 시계가 어긋나면 변경 순서가 뒤바뀌어 한쪽 수정이 묻힐 수 있습니다. macOS / Windows 모두 기본적으로 시각이 자동 동기화되니, 일부러 끄지 마세요.</li>
|
||||
<li style={liStyle}><b>같은 노트를 두 기기에서 동시에 수정</b>: 충돌이 더 자주 발생합니다. 한 기기에서 작업 중이라면 다른 기기에서 같은 노트는 만지지 않는 편이 안전합니다.</li>
|
||||
<li style={liStyle}><b>자동 동기화 실패는 조용히 지나갑니다</b>: 주기적 동기화가 실패해도 알림 토스트는 뜨지 않습니다. 마지막 동기화 시각과 결과는 설정 페이지에서 확인할 수 있으니, 주 1회 정도 점검을 권장합니다.</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react';
|
||||
import { z } from 'zod';
|
||||
import { inboxApi } from '../../api.js';
|
||||
import { VisionSection } from './VisionSection.js';
|
||||
import { SectionIntro } from './SectionIntro.js';
|
||||
|
||||
const endpointSchema = z.string().url();
|
||||
|
||||
@@ -78,6 +79,10 @@ export function AiProviderSection(): React.ReactElement {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<SectionIntro>
|
||||
메모를 자동으로 정리하는 AI 제공자입니다. Inkling 은 기본적으로 로컬 Ollama 를 사용해
|
||||
데이터가 기기 밖으로 나가지 않게 합니다. 사용할 모델과 접속 주소를 여기서 지정합니다.
|
||||
</SectionIntro>
|
||||
{/* v0.2.9 Cut B Task 15 — AI 자동 처리 토글 (가장 위, 스위치 의미가 가장 큰 결정) */}
|
||||
{aiEnabled !== null && (
|
||||
<label style={{ display: 'flex', gap: 8, alignItems: 'center', marginBottom: 12, fontSize: 13 }}>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import type { AutostartResponse } from '@shared/types';
|
||||
import { inboxApi } from '../../api.js';
|
||||
import { SectionIntro } from './SectionIntro.js';
|
||||
|
||||
export function AutostartSection(): React.ReactElement {
|
||||
const [data, setData] = useState<AutostartResponse | null>(null);
|
||||
@@ -31,14 +32,19 @@ export function AutostartSection(): React.ReactElement {
|
||||
}
|
||||
|
||||
const d = data.diagnostic;
|
||||
// v0.2.7 F12 deeper fix — withArgs vs noArgs 의 openAtLogin 불일치, 또는
|
||||
// executableWillLaunchAtLogin = false 면 mismatch 로 간주 (등록은 됐지만 실제론
|
||||
// 로그인 시 실행되지 않을 수 있는 상태).
|
||||
const mismatch = d.withArgs.openAtLogin !== d.noArgs.openAtLogin
|
||||
|| (data.openAtLogin && !d.withArgs.executableWillLaunchAtLogin);
|
||||
// withArgs vs noArgs 의 openAtLogin 불일치는 양 플랫폼에서 진짜 mismatch 시그널.
|
||||
// executableWillLaunchAtLogin 은 Win 에서만 신뢰 — macOS 13+ SMAppService API 는
|
||||
// LoginItems 에 등록되어 있어도 unsigned/Electron 앱에 대해 false 를 자주 반환해
|
||||
// false positive 가 발생함. macOS 는 이 신호를 mismatch 판정에서 제외.
|
||||
const willLaunchSignal = d.platform === 'win32' && data.openAtLogin && !d.withArgs.executableWillLaunchAtLogin;
|
||||
const mismatch = d.withArgs.openAtLogin !== d.noArgs.openAtLogin || willLaunchSignal;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<SectionIntro>
|
||||
시스템에 로그인하면 Inkling 이 백그라운드로 함께 시작합니다. 메인 창은 뜨지 않고,
|
||||
Cmd+Shift+J (macOS) / Ctrl+Shift+J (Windows) 로 필요할 때 불러와 쓰시면 됩니다.
|
||||
</SectionIntro>
|
||||
<label style={{ display: 'flex', gap: 8, alignItems: 'center', fontSize: 13 }}>
|
||||
<input type="checkbox" checked={data.openAtLogin} onChange={onToggle} />
|
||||
앱 시작 시 자동으로 실행
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React, { useState } from 'react';
|
||||
import { inboxApi } from '../../api.js';
|
||||
import { SectionIntro } from './SectionIntro.js';
|
||||
|
||||
export function BackupSection(): React.ReactElement {
|
||||
const [status, setStatus] = useState<string | null>(null);
|
||||
@@ -14,6 +15,10 @@ export function BackupSection(): React.ReactElement {
|
||||
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
<SectionIntro>
|
||||
메모와 첨부 이미지를 안전하게 백업하거나 다른 기기로 옮길 때 사용합니다. 자동 백업은 매일
|
||||
앱 종료 시 1회 실행되고, 여기서는 필요할 때 수동으로 실행할 수 있습니다.
|
||||
</SectionIntro>
|
||||
<button onClick={() => run('지금 백업', () => inboxApi.runBackup())}>지금 백업</button>
|
||||
<button onClick={() => run('내보내기', () => inboxApi.runExport())}>내보내기...</button>
|
||||
<button onClick={() => run('백업에서 복원', () => inboxApi.runImport())}>백업에서 복원...</button>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { inboxApi } from '../../api.js';
|
||||
import { SectionIntro } from './SectionIntro.js';
|
||||
|
||||
interface AppInfo {
|
||||
version: string;
|
||||
@@ -20,6 +21,9 @@ export function InfoSection(): React.ReactElement {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<SectionIntro>
|
||||
문제 보고나 호환성 확인이 필요할 때 참고하실 정보입니다.
|
||||
</SectionIntro>
|
||||
<dl style={{ fontSize: 12, lineHeight: 1.6 }}>
|
||||
<dt style={{ fontWeight: 600 }}>버전</dt>
|
||||
<dd>{info.version}</dd>
|
||||
|
||||
12
src/renderer/inbox/components/settings/SectionIntro.tsx
Normal file
12
src/renderer/inbox/components/settings/SectionIntro.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
import React from 'react';
|
||||
|
||||
interface Props { children: React.ReactNode; }
|
||||
|
||||
/** Settings page 각 section 상단에 표시되는 간단한 설명 paragraph. */
|
||||
export function SectionIntro({ children }: Props): React.ReactElement {
|
||||
return (
|
||||
<p style={{ fontSize: 12, color: '#666', lineHeight: 1.6, margin: '0 0 12px 0' }}>
|
||||
{children}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { inboxApi } from '../../api.js';
|
||||
import type { SyncStatusSnapshot } from '@shared/types';
|
||||
import { ConflictModal } from '../ConflictModal.js';
|
||||
import { SyncHelpModal, type SyncHelpAnchor } from '../SyncHelpModal.js';
|
||||
import { SectionIntro } from './SectionIntro.js';
|
||||
|
||||
export function SyncSection(): React.ReactElement {
|
||||
const [url, setUrl] = useState('');
|
||||
@@ -64,6 +65,10 @@ export function SyncSection(): React.ReactElement {
|
||||
return (
|
||||
<section style={{ marginTop: 24 }}>
|
||||
<h3 style={{ fontSize: 14, marginBottom: 8 }}>동기화 저장소</h3>
|
||||
<SectionIntro>
|
||||
Git 저장소를 통해 여러 기기 간 메모를 동기화합니다. 단일 기기에서만 사용하시면 URL 을
|
||||
비워두셔도 됩니다. 자동 동기화 주기와 충돌 처리는 아래에서 설정합니다.
|
||||
</SectionIntro>
|
||||
|
||||
<div style={{ display: 'flex', gap: 6, marginBottom: 8 }}>
|
||||
<input
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { inboxApi } from '../../api.js';
|
||||
import { SectionIntro } from './SectionIntro.js';
|
||||
|
||||
export function VisionSection(): React.ReactElement {
|
||||
const [models, setModels] = useState<string[]>([]);
|
||||
@@ -44,6 +45,10 @@ export function VisionSection(): React.ReactElement {
|
||||
return (
|
||||
<section style={{ marginTop: 16 }}>
|
||||
<h4 style={{ fontSize: 13, marginBottom: 6 }}>이미지 분석 모델 (선택사항)</h4>
|
||||
<SectionIntro>
|
||||
첨부 이미지를 함께 분석할 vision 지원 모델입니다. 텍스트용 모델과 별도로 지정할 수 있고,
|
||||
미지정 시 이미지 첨부 메모는 텍스트만 정리됩니다.
|
||||
</SectionIntro>
|
||||
<div style={{ display: 'flex', gap: 6, alignItems: 'center', marginBottom: 6 }}>
|
||||
<select
|
||||
aria-label="이미지 분석 모델"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: file:" />
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: file: inkling-media:" />
|
||||
<title>Inkling</title>
|
||||
<style>
|
||||
body { margin: 0; font-family: system-ui, sans-serif; background: #f5f5f7; color: #111; }
|
||||
|
||||
@@ -102,68 +102,117 @@ export const useInbox = create<InboxState>((set, get) => ({
|
||||
searchResults: null,
|
||||
reviewData: null,
|
||||
async loadInitial() {
|
||||
// v0.3.8 — IPC 실패 시 loading=true 영구 stuck 방지. catch 로 reset.
|
||||
set({ loading: true });
|
||||
const [notes, continuity, pendingCount, ollamaStatus, todayCount, trashCount, expiredCandidates, failedCount, recallCandidate, counts, settings] = await Promise.all([
|
||||
// inbox 탭은 status='active' 만 표시 — loadByView('inbox') 와 동일 path 로 일관성 확보.
|
||||
// listNotes 는 deleted_at IS NULL 만 필터 (= active+completed+archived 혼재) 이라 부정확.
|
||||
inboxApi.listByStatus('active', { limit: 50 }),
|
||||
inboxApi.getContinuity(),
|
||||
inboxApi.getPendingCount(),
|
||||
inboxApi.getOllamaStatus(),
|
||||
inboxApi.getTodayCount(),
|
||||
inboxApi.getTrashCount(),
|
||||
inboxApi.listExpired(),
|
||||
inboxApi.getFailedCount(),
|
||||
inboxApi.listRecallCandidate(),
|
||||
inboxApi.countsByStatus(),
|
||||
inboxApi.getSettings()
|
||||
]);
|
||||
set({ notes, continuity, pendingCount, ollamaStatus, todayCount, trashCount, expiredCandidates, failedCount, recallCandidate, counts, ai_enabled: settings.ai_enabled ?? true, loading: false });
|
||||
try {
|
||||
const [notes, continuity, pendingCount, ollamaStatus, todayCount, trashCount, expiredCandidates, failedCount, recallCandidate, counts, settings] = await Promise.all([
|
||||
// inbox 탭은 status='active' 만 표시 — loadByView('inbox') 와 동일 path 로 일관성 확보.
|
||||
// listNotes 는 deleted_at IS NULL 만 필터 (= active+completed+archived 혼재) 이라 부정확.
|
||||
inboxApi.listByStatus('active', { limit: 50 }),
|
||||
inboxApi.getContinuity(),
|
||||
inboxApi.getPendingCount(),
|
||||
inboxApi.getOllamaStatus(),
|
||||
inboxApi.getTodayCount(),
|
||||
inboxApi.getTrashCount(),
|
||||
inboxApi.listExpired(),
|
||||
inboxApi.getFailedCount(),
|
||||
inboxApi.listRecallCandidate(),
|
||||
inboxApi.countsByStatus(),
|
||||
inboxApi.getSettings()
|
||||
]);
|
||||
set({ notes, continuity, pendingCount, ollamaStatus, todayCount, trashCount, expiredCandidates, failedCount, recallCandidate, counts, ai_enabled: settings.ai_enabled ?? true, loading: false });
|
||||
} catch (e) {
|
||||
// 첫 launch 의 IPC 실패 (DB migration 실패 / main process 비정상) 시 무한 loading 회피.
|
||||
// 빈 데이터로 진입하면 사용자가 캡처 시도 → 실제 fail 이 표면화 → 재시도 가능.
|
||||
console.error('[inbox] loadInitial failed', e);
|
||||
set({ loading: false });
|
||||
}
|
||||
},
|
||||
async refreshMeta() {
|
||||
const [continuity, pendingCount, ollamaStatus, todayCount, trashCount, expiredCandidates, failedCount, recallCandidate, counts, settings] = await Promise.all([
|
||||
inboxApi.getContinuity(),
|
||||
inboxApi.getPendingCount(),
|
||||
inboxApi.getOllamaStatus(),
|
||||
inboxApi.getTodayCount(),
|
||||
inboxApi.getTrashCount(),
|
||||
inboxApi.listExpired(),
|
||||
inboxApi.getFailedCount(),
|
||||
inboxApi.listRecallCandidate(),
|
||||
inboxApi.countsByStatus(),
|
||||
inboxApi.getSettings()
|
||||
]);
|
||||
set({ continuity, pendingCount, ollamaStatus, todayCount, trashCount, expiredCandidates, failedCount, recallCandidate, counts, ai_enabled: settings.ai_enabled ?? true });
|
||||
try {
|
||||
const [continuity, pendingCount, ollamaStatus, todayCount, trashCount, expiredCandidates, failedCount, recallCandidate, counts, settings] = await Promise.all([
|
||||
inboxApi.getContinuity(),
|
||||
inboxApi.getPendingCount(),
|
||||
inboxApi.getOllamaStatus(),
|
||||
inboxApi.getTodayCount(),
|
||||
inboxApi.getTrashCount(),
|
||||
inboxApi.listExpired(),
|
||||
inboxApi.getFailedCount(),
|
||||
inboxApi.listRecallCandidate(),
|
||||
inboxApi.countsByStatus(),
|
||||
inboxApi.getSettings()
|
||||
]);
|
||||
set({ continuity, pendingCount, ollamaStatus, todayCount, trashCount, expiredCandidates, failedCount, recallCandidate, counts, ai_enabled: settings.ai_enabled ?? true });
|
||||
} catch (e) {
|
||||
// refreshMeta 는 background poll/event 에서 자주 호출 → fail 무시 (다음 호출에 회복).
|
||||
console.error('[inbox] refreshMeta failed', e);
|
||||
}
|
||||
},
|
||||
upsertNote(note) {
|
||||
// trashCount 는 server-authoritative. trashNotes 가 cache-loaded (showTrash=true) 일
|
||||
// 때만 trashCount 를 local recompute. 그 외엔 server 값 (refreshMeta) 보존.
|
||||
const showTrash = get().showTrash;
|
||||
if (note.deletedAt !== null) {
|
||||
// trash 노트: notes 에서 제거 + trashNotes 에 upsert
|
||||
const cleanNotes = get().notes.filter((n) => n.id !== note.id);
|
||||
const ti = get().trashNotes.findIndex((n) => n.id === note.id);
|
||||
const nextTrash = get().trashNotes.slice();
|
||||
if (ti >= 0) nextTrash[ti] = note;
|
||||
// v0.3.8 — status 가 current view 와 매칭될 때만 notes 에 유지. 그 외엔 제거.
|
||||
// 이전 구현은 trashed 외 모든 status 를 notes 에 누적 → 사용자가 inbox view 에서
|
||||
// 완료/보관 으로 옮긴 노트가 list 에 잔류하는 버그. push-based (setStatus 도 emit) 로
|
||||
// 모든 status 전이가 upsertNote 를 거치므로 view-aware filter 가 필수.
|
||||
//
|
||||
// trashCount/trashNotes 는 server-authoritative. trashNotes 가 cache-loaded
|
||||
// (view='trash') 일 때만 trashCount 를 local recompute. 그 외엔 server 값
|
||||
// (refreshMeta) 보존. searchResults 도 별도로 갱신 (status 변경 시 list 에서 제거).
|
||||
const state = get();
|
||||
const view = state.view;
|
||||
const showTrash = state.showTrash;
|
||||
const viewStatus: 'active' | 'completed' | 'archived' | 'trashed' | null =
|
||||
view === 'inbox' ? 'active' :
|
||||
view === 'completed' ? 'completed' :
|
||||
view === 'archived' ? 'archived' :
|
||||
view === 'trash' ? 'trashed' : null;
|
||||
|
||||
// trashNotes — note.status='trashed' 면 upsert, 아니면 제거.
|
||||
const cleanTrash = state.trashNotes.filter((n) => n.id !== note.id);
|
||||
let nextTrash = cleanTrash;
|
||||
if (note.status === 'trashed') {
|
||||
const ti = state.trashNotes.findIndex((n) => n.id === note.id);
|
||||
nextTrash = cleanTrash.slice();
|
||||
if (ti >= 0) nextTrash.splice(ti, 0, note);
|
||||
else nextTrash.unshift(note);
|
||||
set({
|
||||
notes: cleanNotes,
|
||||
trashNotes: nextTrash,
|
||||
...(showTrash ? { trashCount: nextTrash.length } : {})
|
||||
});
|
||||
} else {
|
||||
// active 노트: trashNotes 에서 제거 + notes 에 upsert (restore 케이스 포함)
|
||||
const cleanTrash = get().trashNotes.filter((n) => n.id !== note.id);
|
||||
const i = get().notes.findIndex((n) => n.id === note.id);
|
||||
const nextNotes = get().notes.slice();
|
||||
if (i >= 0) nextNotes[i] = note;
|
||||
else nextNotes.unshift(note);
|
||||
set({
|
||||
notes: nextNotes,
|
||||
trashNotes: cleanTrash,
|
||||
...(showTrash ? { trashCount: cleanTrash.length } : {})
|
||||
});
|
||||
}
|
||||
|
||||
// notes — current view 의 status 와 매칭되는 경우만 유지/upsert.
|
||||
// viewStatus=null (review/settings/검색) 이면 notes 직접 렌더 안 함 → 갱신 skip.
|
||||
const cleanNotes = state.notes.filter((n) => n.id !== note.id);
|
||||
let nextNotes = state.notes;
|
||||
if (viewStatus !== null) {
|
||||
if (note.status === viewStatus) {
|
||||
const i = state.notes.findIndex((n) => n.id === note.id);
|
||||
nextNotes = cleanNotes.slice();
|
||||
if (i >= 0) nextNotes.splice(i, 0, note);
|
||||
else nextNotes.unshift(note);
|
||||
} else {
|
||||
nextNotes = cleanNotes;
|
||||
}
|
||||
}
|
||||
|
||||
// searchResults — null 아니면 동일 패턴으로 갱신 (status 가 current search status 와
|
||||
// 안 맞으면 제거, 맞으면 upsert).
|
||||
let nextSearch = state.searchResults;
|
||||
if (state.searchResults !== null) {
|
||||
const cleanSearch = state.searchResults.filter((n) => n.id !== note.id);
|
||||
if (viewStatus === null || note.status === viewStatus) {
|
||||
// search 가 active 한 view 가 review/settings 면 status filter 없음 → 모두 keep.
|
||||
const i = state.searchResults.findIndex((n) => n.id === note.id);
|
||||
nextSearch = cleanSearch.slice();
|
||||
if (i >= 0) nextSearch.splice(i, 0, note);
|
||||
else nextSearch.unshift(note);
|
||||
} else {
|
||||
nextSearch = cleanSearch;
|
||||
}
|
||||
}
|
||||
|
||||
set({
|
||||
notes: nextNotes,
|
||||
trashNotes: nextTrash,
|
||||
searchResults: nextSearch,
|
||||
...(showTrash ? { trashCount: nextTrash.length } : {})
|
||||
});
|
||||
},
|
||||
removeNote(id) {
|
||||
const cleanNotes = get().notes.filter((n) => n.id !== id);
|
||||
@@ -204,13 +253,21 @@ export const useInbox = create<InboxState>((set, get) => ({
|
||||
if (view === 'review-monthly') void get().loadReview('monthly');
|
||||
},
|
||||
async loadByView(view) {
|
||||
// v0.3.8 — IPC 실패 시 stale 한 이전 view 의 notes 가 계속 노출되는 사고 방지.
|
||||
// fail 시 빈 배열로 reset 해서 사용자에게 "비어있음" 으로 표시 (혼동 < stale).
|
||||
const status =
|
||||
view === 'trash' ? 'trashed' : view === 'inbox' ? 'active' : view;
|
||||
const notes = await inboxApi.listByStatus(status, { limit: 200 });
|
||||
if (view === 'trash') {
|
||||
set({ trashNotes: notes, trashCount: notes.length });
|
||||
} else {
|
||||
set({ notes });
|
||||
try {
|
||||
const notes = await inboxApi.listByStatus(status, { limit: 200 });
|
||||
if (view === 'trash') {
|
||||
set({ trashNotes: notes, trashCount: notes.length });
|
||||
} else {
|
||||
set({ notes });
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[inbox] loadByView failed', view, e);
|
||||
if (view === 'trash') set({ trashNotes: [] });
|
||||
else set({ notes: [] });
|
||||
}
|
||||
},
|
||||
async toggleShowTrash() {
|
||||
@@ -225,11 +282,12 @@ export const useInbox = create<InboxState>((set, get) => ({
|
||||
async restoreNote(id) {
|
||||
await inboxApi.restoreNote(id);
|
||||
// 낙관적 갱신: main 은 trash/restore 시 pushNoteUpdated 를 보내지 않음
|
||||
// (현재 AiWorker.onUpdate 만 push). 자가 반영이 primary 메커니즘.
|
||||
// (현재 AiWorker.onUpdate + setStatus 만 push). 자가 반영이 primary 메커니즘.
|
||||
// 전제: 호출 시점에 trashNotes 에 노트가 존재 (T14 trash view 한정 호출).
|
||||
// v0.3.8 — status 도 'active' 로 함께 갱신. upsertNote 가 status='trashed' 만 trash 로 라우팅.
|
||||
const note = get().trashNotes.find((n) => n.id === id);
|
||||
if (note) {
|
||||
get().upsertNote({ ...note, deletedAt: null });
|
||||
get().upsertNote({ ...note, deletedAt: null, status: 'active' });
|
||||
}
|
||||
},
|
||||
async permanentDeleteNote(id) {
|
||||
@@ -306,14 +364,27 @@ export const useInbox = create<InboxState>((set, get) => ({
|
||||
const status = view === 'completed' || view === 'archived' || view === 'trash'
|
||||
? (view === 'trash' ? 'trashed' : view)
|
||||
: view === 'inbox' ? 'active' : undefined;
|
||||
const r = await inboxApi.search(q, status ? { status } : {});
|
||||
set({ searchResults: r });
|
||||
try {
|
||||
const r = await inboxApi.search(q, status ? { status } : {});
|
||||
set({ searchResults: r });
|
||||
} catch (e) {
|
||||
// FTS5 query parse error (special char 미escape) / IPC fail → 빈 결과로.
|
||||
console.error('[inbox] searchNotes failed', e);
|
||||
set({ searchResults: [] });
|
||||
}
|
||||
},
|
||||
clearSearch() {
|
||||
set({ searchQuery: '', searchResults: null });
|
||||
},
|
||||
async loadReview(period) {
|
||||
const data = await inboxApi.reviewAggregate(period);
|
||||
set({ reviewData: data });
|
||||
try {
|
||||
const data = await inboxApi.reviewAggregate(period);
|
||||
set({ reviewData: data });
|
||||
} catch (e) {
|
||||
// review IPC fail 시 reviewData=null → ReviewView 의 "불러오는 중…" 영구 표시 회피.
|
||||
// 빈 aggregate 로 set 해서 사용자에게 "0건" 표기.
|
||||
console.error('[inbox] loadReview failed', period, e);
|
||||
set({ reviewData: { totalCount: 0, tagCounts: [], dueProgress: { total: 0, passed: 0, pending: 0 }, recentNotes: [] } });
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -3,6 +3,9 @@ import { captureApi } from './api.js';
|
||||
|
||||
interface PastedImage { url: string; buffer: ArrayBuffer; }
|
||||
|
||||
// 저장 단축키 modifier — macOS 는 Cmd, 그 외는 Ctrl.
|
||||
const MOD_KEY = /Mac/i.test(navigator.platform) ? 'Cmd' : 'Ctrl';
|
||||
|
||||
export function App(): React.ReactElement {
|
||||
const [text, setText] = useState('');
|
||||
const [images, setImages] = useState<PastedImage[]>([]);
|
||||
@@ -65,7 +68,7 @@ export function App(): React.ReactElement {
|
||||
{images.map((i, idx) => (<img key={idx} src={i.url} alt="" />))}
|
||||
</div>
|
||||
)}
|
||||
<div className="hint">Ctrl+Enter 저장 · Esc 취소 · 이미지 붙여넣기</div>
|
||||
<div className="hint">{MOD_KEY}+Enter 저장 · Esc 취소 · 이미지 붙여넣기</div>
|
||||
{err && <div className="err">{err}</div>}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'" />
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:" />
|
||||
<title>Inkling Capture</title>
|
||||
<style>
|
||||
html, body, #root { margin: 0; height: 100%; background: transparent; font-family: system-ui, sans-serif; overflow: hidden; }
|
||||
|
||||
@@ -113,6 +113,8 @@ export interface AutostartDiagnostic {
|
||||
withArgs: { openAtLogin: boolean; executableWillLaunchAtLogin: boolean };
|
||||
noArgs: { openAtLogin: boolean; executableWillLaunchAtLogin: boolean };
|
||||
execPath: string;
|
||||
/** mismatch 판정 플랫폼 분기용 (macOS 의 SMAppService API 한계 우회). */
|
||||
platform: NodeJS.Platform;
|
||||
registryPath?: string;
|
||||
registryValue?: string | null;
|
||||
}
|
||||
@@ -149,6 +151,9 @@ export interface InboxApi {
|
||||
onOllamaStatus(cb: (status: { ok: boolean; reason?: string }) => void): () => void;
|
||||
retryAllFailed(): Promise<{ count: number }>;
|
||||
getFailedCount(): Promise<number>;
|
||||
// v0.3.9 — per-note retry/cancel. failed/pending 노트의 사용자 unblock path.
|
||||
retryOneFailed(id: string): Promise<{ ok: boolean }>;
|
||||
cancelPending(id: string): Promise<{ ok: boolean }>;
|
||||
listRecallCandidate(): Promise<Note | null>;
|
||||
markRecallOpened(id: string): Promise<{ note: Note }>;
|
||||
dismissRecall(id: string): Promise<{ note: Note }>;
|
||||
|
||||
@@ -98,6 +98,53 @@ describe('AiWorker — vision path (v0.3.1 Cut F)', () => {
|
||||
expect(calls[0]![0].images).toBeUndefined();
|
||||
});
|
||||
|
||||
it('v0.3.14 — 본문 빈 + 이미지만 첨부 → generate 호출 skip + 자동 placeholder', async () => {
|
||||
const { id } = repo.create({ rawText: '' }); // 빈 본문
|
||||
await mkdir(join(workDir, 'media', id), { recursive: true });
|
||||
await writeFile(join(workDir, 'media', id, '1.png'), Buffer.from([0x89, 0x50, 0x4e, 0x47]));
|
||||
repo.insertMedia([{ noteId: id, kind: 'image', relPath: `media/${id}/1.png`, mime: 'image/png', bytes: 4 }]);
|
||||
|
||||
const calls: Array<Parameters<InferenceProvider['generate']>> = [];
|
||||
const generate = vi.fn(async (
|
||||
input: Parameters<InferenceProvider['generate']>[0],
|
||||
opts?: Parameters<InferenceProvider['generate']>[1]
|
||||
): Promise<AiResponse> => {
|
||||
calls.push([input, opts]);
|
||||
return { title: 't', summary: 'a\nb\nc', tags: [], dueDate: null };
|
||||
});
|
||||
const getVisionModel = vi.fn(async (): Promise<string | null> => 'gemma4:26b');
|
||||
const worker = makeWorker(generate, getVisionModel);
|
||||
await worker.enqueue(id);
|
||||
await worker.drain();
|
||||
|
||||
// vision 호출 자체 skip
|
||||
expect(calls.length).toBe(0);
|
||||
// 노트가 자동 placeholder 로 done
|
||||
const note = repo.findById(id);
|
||||
expect(note?.aiStatus).toBe('done');
|
||||
expect(note?.aiTitle).toContain('첨부 이미지');
|
||||
expect(note?.aiSummary).toContain('이미지');
|
||||
expect(note?.aiProvider).toBe('image-only-skip');
|
||||
});
|
||||
|
||||
it('v0.3.14 — 이미지 다수 첨부 시 placeholder 가 개수 포함', async () => {
|
||||
const { id } = repo.create({ rawText: '' });
|
||||
await mkdir(join(workDir, 'media', id), { recursive: true });
|
||||
await writeFile(join(workDir, 'media', id, '1.png'), Buffer.from([0x89]));
|
||||
await writeFile(join(workDir, 'media', id, '2.png'), Buffer.from([0x89]));
|
||||
repo.insertMedia([
|
||||
{ noteId: id, kind: 'image', relPath: `media/${id}/1.png`, mime: 'image/png', bytes: 1 },
|
||||
{ noteId: id, kind: 'image', relPath: `media/${id}/2.png`, mime: 'image/png', bytes: 1 }
|
||||
]);
|
||||
const generate = vi.fn(async (): Promise<AiResponse> => ({ title: 't', summary: 'a\nb\nc', tags: [], dueDate: null }));
|
||||
const getVisionModel = vi.fn(async (): Promise<string | null> => 'gemma4:26b');
|
||||
const worker = makeWorker(generate, getVisionModel);
|
||||
await worker.enqueue(id);
|
||||
await worker.drain();
|
||||
const note = repo.findById(id);
|
||||
expect(note?.aiTitle).toContain('2장');
|
||||
});
|
||||
|
||||
it('5MB 초과 이미지 → throw → AiWorker 의 fail 분기 (generate 미호출)', async () => {
|
||||
const { id } = repo.create({ rawText: 'big image' });
|
||||
await mkdir(join(workDir, 'media', id), { recursive: true });
|
||||
|
||||
@@ -42,6 +42,7 @@ describe('AutostartDiagnostic — collectAutostartState', () => {
|
||||
expect(state.withArgs).toEqual({ openAtLogin: true, executableWillLaunchAtLogin: true });
|
||||
expect(state.noArgs).toEqual({ openAtLogin: false, executableWillLaunchAtLogin: true });
|
||||
expect(state.execPath).toBe(process.execPath);
|
||||
expect(state.platform).toBe('darwin');
|
||||
});
|
||||
|
||||
it('passes args=["--hidden"] for the first call, no args for the second', async () => {
|
||||
|
||||
@@ -3,15 +3,17 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import '@testing-library/jest-dom/vitest';
|
||||
import { render, screen, fireEvent, waitFor, cleanup } from '@testing-library/react';
|
||||
|
||||
function makeDiag(open: boolean): {
|
||||
function makeDiag(open: boolean, platform: NodeJS.Platform = 'win32'): {
|
||||
withArgs: { openAtLogin: boolean; executableWillLaunchAtLogin: boolean };
|
||||
noArgs: { openAtLogin: boolean; executableWillLaunchAtLogin: boolean };
|
||||
execPath: string;
|
||||
platform: NodeJS.Platform;
|
||||
} {
|
||||
return {
|
||||
withArgs: { openAtLogin: open, executableWillLaunchAtLogin: open },
|
||||
noArgs: { openAtLogin: open, executableWillLaunchAtLogin: open },
|
||||
execPath: '/path/to/exe'
|
||||
execPath: '/path/to/exe',
|
||||
platform
|
||||
};
|
||||
}
|
||||
|
||||
@@ -51,7 +53,8 @@ describe('AutostartSection', () => {
|
||||
diagnostic: {
|
||||
withArgs: { openAtLogin: true, executableWillLaunchAtLogin: true },
|
||||
noArgs: { openAtLogin: false, executableWillLaunchAtLogin: true },
|
||||
execPath: '/path/to/Inkling.exe'
|
||||
execPath: '/path/to/Inkling.exe',
|
||||
platform: 'win32'
|
||||
}
|
||||
});
|
||||
render(<AutostartSection />);
|
||||
@@ -71,6 +74,7 @@ describe('AutostartSection', () => {
|
||||
withArgs: { openAtLogin: true, executableWillLaunchAtLogin: true },
|
||||
noArgs: { openAtLogin: true, executableWillLaunchAtLogin: true },
|
||||
execPath: 'C:\\app.exe',
|
||||
platform: 'win32',
|
||||
registryPath: 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\Inkling',
|
||||
registryValue: '"C:\\app.exe" --hidden'
|
||||
}
|
||||
@@ -89,7 +93,8 @@ describe('AutostartSection', () => {
|
||||
diagnostic: {
|
||||
withArgs: { openAtLogin: true, executableWillLaunchAtLogin: true },
|
||||
noArgs: { openAtLogin: true, executableWillLaunchAtLogin: true },
|
||||
execPath: '/p'
|
||||
execPath: '/p',
|
||||
platform: 'win32'
|
||||
}
|
||||
});
|
||||
render(<AutostartSection />);
|
||||
@@ -97,6 +102,38 @@ describe('AutostartSection', () => {
|
||||
expect(screen.queryByText(/⚠️/)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('macOS: no false-positive mismatch when willLaunch=false (SMAppService 한계)', async () => {
|
||||
const { inboxApi } = await import('../../src/renderer/inbox/api.js');
|
||||
vi.mocked(inboxApi.getAutostart).mockResolvedValueOnce({
|
||||
openAtLogin: true,
|
||||
diagnostic: {
|
||||
withArgs: { openAtLogin: true, executableWillLaunchAtLogin: false },
|
||||
noArgs: { openAtLogin: true, executableWillLaunchAtLogin: false },
|
||||
execPath: '/Applications/Inkling.app',
|
||||
platform: 'darwin'
|
||||
}
|
||||
});
|
||||
render(<AutostartSection />);
|
||||
await screen.findByRole('checkbox');
|
||||
expect(screen.queryByText(/⚠️/)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('Win: mismatch warning when openAtLogin=true but willLaunch=false', async () => {
|
||||
const { inboxApi } = await import('../../src/renderer/inbox/api.js');
|
||||
vi.mocked(inboxApi.getAutostart).mockResolvedValueOnce({
|
||||
openAtLogin: true,
|
||||
diagnostic: {
|
||||
withArgs: { openAtLogin: true, executableWillLaunchAtLogin: false },
|
||||
noArgs: { openAtLogin: true, executableWillLaunchAtLogin: false },
|
||||
execPath: 'C:\\app.exe',
|
||||
platform: 'win32'
|
||||
}
|
||||
});
|
||||
render(<AutostartSection />);
|
||||
await screen.findByRole('checkbox');
|
||||
expect(await screen.findByText(/⚠️/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('"재등록" button calls setAutostart with current openAtLogin value', async () => {
|
||||
const { inboxApi } = await import('../../src/renderer/inbox/api.js');
|
||||
vi.mocked(inboxApi.getAutostart).mockResolvedValueOnce({
|
||||
@@ -104,7 +141,8 @@ describe('AutostartSection', () => {
|
||||
diagnostic: {
|
||||
withArgs: { openAtLogin: true, executableWillLaunchAtLogin: true },
|
||||
noArgs: { openAtLogin: true, executableWillLaunchAtLogin: true },
|
||||
execPath: '/p'
|
||||
execPath: '/p',
|
||||
platform: 'win32'
|
||||
}
|
||||
});
|
||||
render(<AutostartSection />);
|
||||
|
||||
@@ -45,13 +45,47 @@ describe('LocalOllamaProvider', () => {
|
||||
expect(parsed.prompt).toContain('Prefer reusing');
|
||||
});
|
||||
|
||||
it('generate throws on non-JSON', async () => {
|
||||
it('v0.3.14 — generate falls back to placeholder when JSON unparseable', async () => {
|
||||
// 이전엔 throw 했지만 schema graceful coerce 추가 후 placeholder 채워서 통과.
|
||||
// truncated / repetition-loop 응답에서 사용자 데이터 (raw_text) 무손실 보존.
|
||||
mock.get('http://localhost:11434').intercept({ path: '/api/generate', method: 'POST' }).reply(200, {
|
||||
response: 'not json'
|
||||
});
|
||||
await expect(
|
||||
new LocalOllamaProvider().generate({ text: 'x', todayKst: '2026-04-26', dueDateCandidates: [] })
|
||||
).rejects.toThrow(/json/i);
|
||||
const r = await new LocalOllamaProvider().generate({ text: 'x', todayKst: '2026-04-26', dueDateCandidates: [] });
|
||||
expect(r.title).toBe('(첨부 메모)');
|
||||
expect(r.summary.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('v0.3.14 — body 에 repeat_penalty 포함 (repetition loop 방지)', async () => {
|
||||
let capturedBody: string = '';
|
||||
mock.get('http://localhost:11434').intercept({
|
||||
path: '/api/generate', method: 'POST'
|
||||
}).reply((opts) => {
|
||||
capturedBody = opts.body as string;
|
||||
return { statusCode: 200, data: JSON.stringify({
|
||||
response: JSON.stringify({ title: '회의', summary: 'a\nb\nc', tags: [] })
|
||||
}) };
|
||||
});
|
||||
await new LocalOllamaProvider().generate({ text: 'x', todayKst: '2026-04-26', dueDateCandidates: [] });
|
||||
const parsed = JSON.parse(capturedBody) as { options: { repeat_penalty: number } };
|
||||
expect(parsed.options.repeat_penalty).toBe(1.15);
|
||||
});
|
||||
|
||||
it('v0.3.11 — generate extracts JSON from markdown fence', async () => {
|
||||
// vision model 이 ```json ... ``` 형태로 응답하는 경우 fallback 으로 추출.
|
||||
mock.get('http://localhost:11434').intercept({ path: '/api/generate', method: 'POST' }).reply(200, {
|
||||
response: '```json\n{"title":"회의","summary":"a\\nb\\nc","tags":["meet"]}\n```'
|
||||
});
|
||||
const r = await new LocalOllamaProvider().generate({ text: 'x', todayKst: '2026-04-26', dueDateCandidates: [] });
|
||||
expect(r.title).toBe('회의');
|
||||
});
|
||||
|
||||
it('v0.3.11 — generate extracts JSON when prose 가 앞뒤로 섞임', async () => {
|
||||
mock.get('http://localhost:11434').intercept({ path: '/api/generate', method: 'POST' }).reply(200, {
|
||||
response: 'Here is the response:\n{"title":"회의","summary":"a\\nb\\nc","tags":[]}\nDone.'
|
||||
});
|
||||
const r = await new LocalOllamaProvider().generate({ text: 'x', todayKst: '2026-04-26', dueDateCandidates: [] });
|
||||
expect(r.title).toBe('회의');
|
||||
});
|
||||
|
||||
it('generate aborts on timeout', async () => {
|
||||
|
||||
@@ -32,6 +32,7 @@ describe('MoveStatusModal', () => {
|
||||
noteId="n1"
|
||||
rawText="t"
|
||||
summary=""
|
||||
currentStatus="active"
|
||||
onClose={vi.fn()}
|
||||
onMoved={vi.fn()}
|
||||
/>
|
||||
@@ -50,6 +51,7 @@ describe('MoveStatusModal', () => {
|
||||
noteId="n1"
|
||||
rawText="t"
|
||||
summary=""
|
||||
currentStatus="active"
|
||||
onClose={vi.fn()}
|
||||
onMoved={onMoved}
|
||||
/>
|
||||
@@ -69,6 +71,7 @@ describe('MoveStatusModal', () => {
|
||||
noteId="n1"
|
||||
rawText="t"
|
||||
summary=""
|
||||
currentStatus="active"
|
||||
onClose={vi.fn()}
|
||||
onMoved={onMoved}
|
||||
/>
|
||||
@@ -81,6 +84,95 @@ describe('MoveStatusModal', () => {
|
||||
await waitFor(() => expect(onMoved).toHaveBeenCalledWith('completed', '결재 끝'));
|
||||
});
|
||||
|
||||
it('currentStatus=completed → Inbox/보관/휴지통 노출, 완료 미노출', () => {
|
||||
render(
|
||||
<MoveStatusModal
|
||||
noteId="n1"
|
||||
rawText="t"
|
||||
summary=""
|
||||
currentStatus="completed"
|
||||
onClose={vi.fn()}
|
||||
onMoved={vi.fn()}
|
||||
/>
|
||||
);
|
||||
expect(screen.getByRole('button', { name: 'Inbox' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: '보관' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: '휴지통' })).toBeInTheDocument();
|
||||
expect(screen.queryByRole('button', { name: '완료' })).toBeNull();
|
||||
});
|
||||
|
||||
it('currentStatus=archived → Inbox 버튼 클릭 시 setStatus("active") 호출', async () => {
|
||||
const onMoved = vi.fn();
|
||||
render(
|
||||
<MoveStatusModal
|
||||
noteId="n1"
|
||||
rawText="t"
|
||||
summary=""
|
||||
currentStatus="archived"
|
||||
onClose={vi.fn()}
|
||||
onMoved={onMoved}
|
||||
/>
|
||||
);
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Inbox' }));
|
||||
await waitFor(() => {
|
||||
expect(mockSetStatus).toHaveBeenCalledWith('n1', 'active', null);
|
||||
expect(onMoved).toHaveBeenCalledWith('active', null);
|
||||
});
|
||||
});
|
||||
|
||||
it('currentStatus=trashed → Inbox/완료/보관 노출, 휴지통 미노출', () => {
|
||||
render(
|
||||
<MoveStatusModal
|
||||
noteId="n1"
|
||||
rawText="t"
|
||||
summary=""
|
||||
currentStatus="trashed"
|
||||
onClose={vi.fn()}
|
||||
onMoved={vi.fn()}
|
||||
/>
|
||||
);
|
||||
expect(screen.getByRole('button', { name: 'Inbox' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: '완료' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: '보관' })).toBeInTheDocument();
|
||||
expect(screen.queryByRole('button', { name: '휴지통' })).toBeNull();
|
||||
});
|
||||
|
||||
it('Escape key → onClose 호출', () => {
|
||||
const onClose = vi.fn();
|
||||
render(
|
||||
<MoveStatusModal
|
||||
noteId="n1"
|
||||
rawText="t"
|
||||
summary=""
|
||||
currentStatus="active"
|
||||
onClose={onClose}
|
||||
onMoved={vi.fn()}
|
||||
/>
|
||||
);
|
||||
fireEvent.keyDown(document, { key: 'Escape' });
|
||||
expect(onClose).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('overlay 클릭 → onClose, modal body 클릭 → 무반응', () => {
|
||||
const onClose = vi.fn();
|
||||
render(
|
||||
<MoveStatusModal
|
||||
noteId="n1"
|
||||
rawText="t"
|
||||
summary=""
|
||||
currentStatus="active"
|
||||
onClose={onClose}
|
||||
onMoved={vi.fn()}
|
||||
/>
|
||||
);
|
||||
// body 클릭 (textarea) → onClose 호출 안 됨
|
||||
fireEvent.click(screen.getByRole('textbox'));
|
||||
expect(onClose).not.toHaveBeenCalled();
|
||||
// overlay (dialog) 클릭 → onClose
|
||||
fireEvent.click(screen.getByRole('dialog', { name: '이동' }));
|
||||
expect(onClose).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('빈 사유 → null reason 전달', async () => {
|
||||
const onMoved = vi.fn();
|
||||
render(
|
||||
@@ -88,6 +180,7 @@ describe('MoveStatusModal', () => {
|
||||
noteId="n1"
|
||||
rawText="t"
|
||||
summary=""
|
||||
currentStatus="active"
|
||||
onClose={vi.fn()}
|
||||
onMoved={onMoved}
|
||||
/>
|
||||
|
||||
@@ -592,6 +592,7 @@ describe('NoteRepository.findExpiredCandidates', () => {
|
||||
edited?: boolean;
|
||||
deletedAt?: string | null;
|
||||
aiStatus?: 'pending' | 'done' | 'failed';
|
||||
status?: 'active' | 'completed' | 'archived' | 'trashed';
|
||||
}): string {
|
||||
const { id } = repo.create({ rawText: opts.rawText });
|
||||
db.prepare(
|
||||
@@ -599,19 +600,21 @@ describe('NoteRepository.findExpiredCandidates', () => {
|
||||
SET due_date = ?,
|
||||
due_date_edited_by_user = ?,
|
||||
ai_status = ?,
|
||||
deleted_at = ?
|
||||
deleted_at = ?,
|
||||
status = ?
|
||||
WHERE id = ?`
|
||||
).run(
|
||||
opts.dueDate,
|
||||
opts.edited ? 1 : 0,
|
||||
opts.aiStatus ?? 'done',
|
||||
opts.deletedAt ?? null,
|
||||
opts.status ?? 'active',
|
||||
id
|
||||
);
|
||||
return id;
|
||||
}
|
||||
|
||||
it('returns notes with due_date < today (KST), ORDER BY created_at DESC', () => {
|
||||
it('returns notes with due_date <= today (KST), ORDER BY due_date DESC then created_at DESC', () => {
|
||||
const a = makeDone({ rawText: 'a', dueDate: '2026-04-20' });
|
||||
db.prepare(`UPDATE notes SET created_at = ? WHERE id = ?`).run('2026-04-30T10:00:00Z', a);
|
||||
const b = makeDone({ rawText: 'b', dueDate: '2026-04-25' });
|
||||
@@ -620,6 +623,14 @@ describe('NoteRepository.findExpiredCandidates', () => {
|
||||
expect(r.map((n) => n.id)).toEqual([b, a]);
|
||||
});
|
||||
|
||||
it('includes notes with due_date == today (오늘 당일 우선 표시)', () => {
|
||||
const past = makeDone({ rawText: 'a', dueDate: '2026-04-30' });
|
||||
const todayNote = makeDone({ rawText: 'b', dueDate: '2026-05-01' });
|
||||
const r = repo.findExpiredCandidates(new Date('2026-05-01T12:00:00Z'));
|
||||
// 오늘 당일이 먼저, 그 다음 지난 메모.
|
||||
expect(r.map((n) => n.id)).toEqual([todayNote, past]);
|
||||
});
|
||||
|
||||
it('includes both AI-extracted and user-edited due_date (Q1=B 회귀 가드)', () => {
|
||||
const ai = makeDone({ rawText: 'a', dueDate: '2026-04-20', edited: false });
|
||||
const manual = makeDone({ rawText: 'b', dueDate: '2026-04-22', edited: true });
|
||||
@@ -629,7 +640,7 @@ describe('NoteRepository.findExpiredCandidates', () => {
|
||||
|
||||
it('excludes trashed notes (deleted_at IS NOT NULL)', () => {
|
||||
const a = makeDone({ rawText: 'a', dueDate: '2026-04-20' });
|
||||
makeDone({ rawText: 'b', dueDate: '2026-04-21', deletedAt: '2026-04-30T00:00:00Z' });
|
||||
makeDone({ rawText: 'b', dueDate: '2026-04-21', deletedAt: '2026-04-30T00:00:00Z', status: 'trashed' });
|
||||
const r = repo.findExpiredCandidates(new Date('2026-05-01T12:00:00Z'));
|
||||
expect(r.map((n) => n.id)).toEqual([a]);
|
||||
});
|
||||
@@ -649,11 +660,12 @@ describe('NoteRepository.findExpiredCandidates', () => {
|
||||
expect(r.map((n) => n.id)).toEqual([dated]);
|
||||
});
|
||||
|
||||
it('excludes notes with due_date == today (boundary, not expired)', () => {
|
||||
const past = makeDone({ rawText: 'a', dueDate: '2026-04-30' });
|
||||
makeDone({ rawText: 'b', dueDate: '2026-05-01' });
|
||||
it('excludes completed / archived notes (inbox 만 — 사용자 의도: 완료/보관은 알림 제외)', () => {
|
||||
const active = makeDone({ rawText: 'a', dueDate: '2026-04-20' });
|
||||
makeDone({ rawText: 'b', dueDate: '2026-04-20', status: 'completed' });
|
||||
makeDone({ rawText: 'c', dueDate: '2026-04-20', status: 'archived' });
|
||||
const r = repo.findExpiredCandidates(new Date('2026-05-01T12:00:00Z'));
|
||||
expect(r.map((n) => n.id)).toEqual([past]);
|
||||
expect(r.map((n) => n.id)).toEqual([active]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -770,6 +782,41 @@ describe('NoteRepository — failed retry helpers', () => {
|
||||
expect(jobs[0]!.nextRunAt).toBe('2026-04-30T00:00:00.000Z');
|
||||
});
|
||||
|
||||
it('v0.3.9 — retryOneFailed: failed → pending + pending_jobs INSERT', () => {
|
||||
const a = makeFailed('a');
|
||||
const b = makeFailed('b');
|
||||
const r = repo.retryOneFailed(a, '2026-05-01T12:00:00.000Z');
|
||||
expect(r).toEqual({ ok: true });
|
||||
expect(repo.findById(a)!.aiStatus).toBe('pending');
|
||||
expect(repo.findById(a)!.aiError).toBeNull();
|
||||
expect(repo.findById(b)!.aiStatus).toBe('failed'); // 다른 노트 영향 없음
|
||||
const jobs = repo.getAllPendingJobs();
|
||||
expect(jobs.find((j) => j.noteId === a)).toBeDefined();
|
||||
});
|
||||
|
||||
it('v0.3.9 — retryOneFailed: non-failed status 면 no-op', () => {
|
||||
const { id } = repo.create({ rawText: 'pending note' });
|
||||
const r = repo.retryOneFailed(id, '2026-05-01T12:00:00.000Z');
|
||||
expect(r).toEqual({ ok: false });
|
||||
});
|
||||
|
||||
it('v0.3.9 — cancelPending: pending → disabled + pending_jobs DELETE', () => {
|
||||
const { id } = repo.create({ rawText: 'x' }); // ai_status=pending
|
||||
expect(repo.findById(id)!.aiStatus).toBe('pending');
|
||||
const r = repo.cancelPending(id, '2026-05-01T12:00:00.000Z');
|
||||
expect(r).toEqual({ ok: true });
|
||||
expect(repo.findById(id)!.aiStatus).toBe('disabled');
|
||||
const jobs = repo.getAllPendingJobs().filter((j) => j.noteId === id);
|
||||
expect(jobs).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('v0.3.9 — cancelPending: non-pending status 면 no-op', () => {
|
||||
const id = makeFailed('a');
|
||||
const r = repo.cancelPending(id, '2026-05-01T12:00:00.000Z');
|
||||
expect(r).toEqual({ ok: false });
|
||||
expect(repo.findById(id)!.aiStatus).toBe('failed'); // 변경 없음
|
||||
});
|
||||
|
||||
it('setNextRunAt — attempts 변경 없이 next_run_at + last_error 갱신', () => {
|
||||
const { id } = repo.create({ rawText: 'x' });
|
||||
repo.incrementJobAttempt(id, '2026-05-01T11:00:00.000Z', 'first error');
|
||||
|
||||
@@ -13,8 +13,8 @@ describe('SyncHelpModal', () => {
|
||||
it('4 섹션 헤더 렌더링', () => {
|
||||
render(<SyncHelpModal onClose={() => {}} />);
|
||||
expect(screen.getByRole('heading', { name: /충돌 해결/ })).toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: /자동 처리/ })).toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: /조용히 잘못될 수 있는/ })).toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: /자동으로 처리되는 일/ })).toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: /모르고 넘어가기 쉬운 함정/ })).toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: /Setup/ })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
@@ -13,10 +13,21 @@ describe('parseAiResponse', () => {
|
||||
expect(r.tags).toEqual(['api-timeout', 'meeting']);
|
||||
});
|
||||
|
||||
it('rejects title without Korean', () => {
|
||||
expect(() =>
|
||||
parseAiResponse({ title: 'English only', summary: 'a\nb\nc', tags: [] })
|
||||
).toThrow(/korean/i);
|
||||
it('영어 title → (첨부 메모) placeholder fallback (vision graceful 처리)', () => {
|
||||
const r = parseAiResponse({ title: 'English only', summary: 'a\nb\nc', tags: [] });
|
||||
expect(r.title).toBe('(첨부 메모)');
|
||||
});
|
||||
|
||||
it('null title/summary → placeholder coerce (vision 본문 빈 케이스)', () => {
|
||||
const r = parseAiResponse({ title: null, summary: null, tags: [], due_date: null });
|
||||
expect(r.title).toBe('(첨부 메모)');
|
||||
expect(r.summary.startsWith('내용을 자동으로 정리하지 못했습니다')).toBe(true);
|
||||
});
|
||||
|
||||
it('empty string title/summary → placeholder coerce', () => {
|
||||
const r = parseAiResponse({ title: '', summary: '', tags: [] });
|
||||
expect(r.title).toBe('(첨부 메모)');
|
||||
expect(r.summary.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('pads short summary to 3 lines', () => {
|
||||
@@ -82,10 +93,14 @@ describe('parseAiResponse', () => {
|
||||
expect(r.dueDate).toBeNull();
|
||||
});
|
||||
|
||||
it('rejects malformed due_date string', () => {
|
||||
expect(() =>
|
||||
parseAiResponse({ title: '내일', summary: 'a\nb\nc', tags: [], due_date: 'tomorrow' })
|
||||
).toThrow();
|
||||
it('malformed due_date string → null coerce (vision graceful 처리)', () => {
|
||||
const r = parseAiResponse({ title: '내일', summary: 'a\nb\nc', tags: [], due_date: 'tomorrow' });
|
||||
expect(r.dueDate).toBeNull();
|
||||
});
|
||||
|
||||
it('empty string due_date → null coerce', () => {
|
||||
const r = parseAiResponse({ title: '내일', summary: 'a\nb\nc', tags: [], due_date: '' });
|
||||
expect(r.dueDate).toBeNull();
|
||||
});
|
||||
|
||||
it('coerces invalid date that passes regex (e.g. 2026-13-99) to null', () => {
|
||||
|
||||
@@ -230,16 +230,22 @@ describe('composeIndexJsonl', () => {
|
||||
});
|
||||
|
||||
describe('composeManifest', () => {
|
||||
it('emits pretty JSON with required fields', () => {
|
||||
it('emits pretty JSON with required fields (timestamp-free)', () => {
|
||||
const m = composeManifest({
|
||||
exportedAt: '2026-04-26T00:00:00.000Z',
|
||||
noteCount: 42,
|
||||
mediaCount: 17
|
||||
});
|
||||
const obj = JSON.parse(m);
|
||||
expect(obj.inkling_export_version).toBe(1);
|
||||
expect(obj.exported_at).toBe('2026-04-26T00:00:00.000Z');
|
||||
expect(obj.note_count).toBe(42);
|
||||
expect(obj.media_count).toBe(17);
|
||||
// exported_at 필드 제거 — sync git history noise 방지.
|
||||
expect(obj.exported_at).toBeUndefined();
|
||||
});
|
||||
|
||||
it('두 번 호출 결과 stable (sync no-op invariant — 같은 input 이면 git diff 0)', () => {
|
||||
const a = composeManifest({ noteCount: 5, mediaCount: 2 });
|
||||
const b = composeManifest({ noteCount: 5, mediaCount: 2 });
|
||||
expect(a).toBe(b);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -15,6 +15,12 @@ describe('sanitizeFtsQuery', () => {
|
||||
it('returns empty string for whitespace-only', () => {
|
||||
expect(sanitizeFtsQuery(' ')).toBe('');
|
||||
});
|
||||
it('v0.3.9 — dash/caret/backtick 추가 sanitize', () => {
|
||||
expect(sanitizeFtsQuery('key-value')).toBe('key value');
|
||||
expect(sanitizeFtsQuery('^prefix')).toBe('prefix');
|
||||
expect(sanitizeFtsQuery('back`tick')).toBe('back tick');
|
||||
expect(sanitizeFtsQuery('-NOT')).toBe('NOT');
|
||||
});
|
||||
});
|
||||
|
||||
describe('computeCutoff', () => {
|
||||
|
||||
@@ -22,6 +22,7 @@ function makeDeps(overrides: Partial<InboxIpcDeps> = {}): InboxIpcDeps {
|
||||
updateRawText: vi.fn(),
|
||||
listRevisions: vi.fn(() => []),
|
||||
restoreRevision: vi.fn(),
|
||||
markAiPendingForReprocess: vi.fn(() => ({ ok: false })),
|
||||
findById: vi.fn(),
|
||||
list: vi.fn(),
|
||||
listByStatus: vi.fn(),
|
||||
|
||||
@@ -83,6 +83,20 @@ describe('inbox:set-status IPC', () => {
|
||||
expect(r.reason).toBe('invalid status');
|
||||
expect(mockSetStatus).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('emits note:updated to renderer after setStatus (v0.3.8 push-based)', async () => {
|
||||
const send = vi.fn();
|
||||
const win = { webContents: { send }, isDestroyed: () => false } as never;
|
||||
const deps = makeDeps();
|
||||
deps.getInboxWindow = () => win;
|
||||
const updatedNote = { id: 'n1', status: 'completed' };
|
||||
mockFindById.mockReturnValue(updatedNote);
|
||||
registerInboxApi(deps);
|
||||
const handler = handlers['inbox:set-status'];
|
||||
if (handler === undefined) throw new Error('handler not registered');
|
||||
await handler(null, 'n1', 'completed', null);
|
||||
expect(send).toHaveBeenCalledWith('note:updated', updatedNote);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ai:classify-status IPC', () => {
|
||||
|
||||
@@ -95,6 +95,37 @@ describe('useInbox — trash state (v0.2.3 #4)', () => {
|
||||
expect(useInbox.getState().notes).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('view-aware upsertNote — inbox view 에서 status=completed 노트 push → notes 에서 제거', async () => {
|
||||
const { useInbox } = await import('../../src/renderer/inbox/store.js');
|
||||
// view='inbox' (default), active 노트 upsert
|
||||
useInbox.getState().upsertNote(noteStub('a'));
|
||||
expect(useInbox.getState().notes).toHaveLength(1);
|
||||
// 같은 노트가 completed 로 status 변경 → 현재 view 와 안 맞으므로 notes 에서 제거
|
||||
const completed: Note = { ...noteStub('a'), status: 'completed' };
|
||||
useInbox.getState().upsertNote(completed);
|
||||
expect(useInbox.getState().notes).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('view-aware upsertNote — completed view 에서 active 노트 push → notes 에 추가 안 됨', async () => {
|
||||
const { useInbox } = await import('../../src/renderer/inbox/store.js');
|
||||
useInbox.setState({ view: 'completed' });
|
||||
useInbox.getState().upsertNote(noteStub('a')); // status='active'
|
||||
expect(useInbox.getState().notes).toHaveLength(0);
|
||||
// completed status 면 추가
|
||||
const completed: Note = { ...noteStub('a'), status: 'completed' };
|
||||
useInbox.getState().upsertNote(completed);
|
||||
expect(useInbox.getState().notes).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('view-aware upsertNote — searchResults 가 있을 때 status mismatch → searchResults 에서 제거', async () => {
|
||||
const { useInbox } = await import('../../src/renderer/inbox/store.js');
|
||||
// 이전 test 가 view='completed' 로 설정한 채 끝났을 수 있어 명시적 초기화.
|
||||
useInbox.setState({ view: 'inbox', searchResults: [noteStub('a')] });
|
||||
const completed: Note = { ...noteStub('a'), status: 'completed' };
|
||||
useInbox.getState().upsertNote(completed);
|
||||
expect(useInbox.getState().searchResults).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('emptyTrash with cancelled confirm leaves trashNotes intact', async () => {
|
||||
mockApi.emptyTrash.mockResolvedValueOnce({ confirmed: false, count: 0 });
|
||||
const { useInbox } = await import('../../src/renderer/inbox/store.js');
|
||||
|
||||
@@ -15,9 +15,18 @@ describe('buildVisionPrompt', () => {
|
||||
expect(result).toContain('work, meeting, project, todo');
|
||||
});
|
||||
|
||||
it('uses (이미지만 있음) placeholder when text is empty', () => {
|
||||
it('본문 빈 경우 이미지 묘사 + null 금지 명시 + one-shot 예시 (v0.3.14+)', () => {
|
||||
const result = buildVisionPrompt('', '2026-05-09', [], []);
|
||||
expect(result).toContain('(이미지만 있음)');
|
||||
expect(result).not.toContain('\n\n\n'); // no double-blank from empty text
|
||||
expect(result).toContain('본문이 없습니다');
|
||||
expect(result).toContain('null 반환 절대 금지');
|
||||
expect(result).toContain('예시'); // one-shot 예시 포함
|
||||
expect(result).toContain('잔디 위 강아지'); // 예시 1
|
||||
expect(result).not.toContain('메모 본문:\n');
|
||||
});
|
||||
|
||||
it('본문 있는 경우 본문 우선 + 이미지 함께 분석 명시', () => {
|
||||
const result = buildVisionPrompt('회의 메모', '2026-05-09', [], []);
|
||||
expect(result).toContain('메모 본문:\n회의 메모');
|
||||
expect(result).toContain('첨부 이미지도 함께 분석');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user