feat: ship v0.9.0 with pomodoro, achievements, and injection history
Add pomodoro timer with goal notifications, writing streak milestones, and knowledge injection logging with UI previews across AI writing flows. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,8 +6,9 @@ import schemaV4 from './schema-v4.sql?raw'
|
||||
import schemaV5 from './schema-v5.sql?raw'
|
||||
import schemaV6 from './schema-v6.sql?raw'
|
||||
import schemaV7 from './schema-v7.sql?raw'
|
||||
import schemaV8 from './schema-v8.sql?raw'
|
||||
|
||||
const CURRENT_VERSION = 7
|
||||
const CURRENT_VERSION = 8
|
||||
|
||||
function tryAlter(db: SqliteDb, sql: string): void {
|
||||
try {
|
||||
@@ -81,5 +82,11 @@ export function migrate(db: SqliteDb): void {
|
||||
tryAlter(db, 'ALTER TABLE knowledge_entries ADD COLUMN merge_target_id TEXT')
|
||||
tryAlter(db, 'ALTER TABLE knowledge_entries ADD COLUMN extraction_batch_id TEXT')
|
||||
db.prepare('INSERT INTO schema_version (version, description) VALUES (?, ?)').run(7, 'P5.2 writing logs extraction')
|
||||
current = 7
|
||||
}
|
||||
|
||||
if (current < 8) {
|
||||
db.exec(schemaV8)
|
||||
db.prepare('INSERT INTO schema_version (version, description) VALUES (?, ?)').run(8, 'P5.3 P6.1 goals injection')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import { randomUUID } from 'crypto'
|
||||
import type { InjectionFlowMode, KnowledgeInjectionLog } from '../../../shared/types'
|
||||
import type { SqliteDb } from '../types'
|
||||
|
||||
function mapRow(row: Record<string, unknown>): KnowledgeInjectionLog {
|
||||
return {
|
||||
id: row.id as string,
|
||||
knowledgeEntryId: row.knowledge_entry_id as string,
|
||||
flowMode: row.flow_mode as InjectionFlowMode,
|
||||
flowId: row.flow_id as string,
|
||||
chapterId: (row.chapter_id as string) || undefined,
|
||||
injectedAt: row.injected_at as string
|
||||
}
|
||||
}
|
||||
|
||||
export class KnowledgeInjectionRepository {
|
||||
constructor(private db: SqliteDb) {}
|
||||
|
||||
insertBatch(
|
||||
rows: Array<{
|
||||
knowledgeEntryId: string
|
||||
flowMode: InjectionFlowMode
|
||||
flowId: string
|
||||
chapterId?: string
|
||||
}>
|
||||
): void {
|
||||
const stmt = this.db.prepare(
|
||||
`INSERT INTO knowledge_injection_logs
|
||||
(id, knowledge_entry_id, flow_mode, flow_id, chapter_id)
|
||||
VALUES (?, ?, ?, ?, ?)`
|
||||
)
|
||||
for (const row of rows) {
|
||||
stmt.run(
|
||||
randomUUID(),
|
||||
row.knowledgeEntryId,
|
||||
row.flowMode,
|
||||
row.flowId,
|
||||
row.chapterId ?? null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
listForEntry(entryId: string, limit = 50): KnowledgeInjectionLog[] {
|
||||
const rows = this.db
|
||||
.prepare(
|
||||
`SELECT * FROM knowledge_injection_logs
|
||||
WHERE knowledge_entry_id = ?
|
||||
ORDER BY injected_at DESC LIMIT ?`
|
||||
)
|
||||
.all(entryId, limit) as Record<string, unknown>[]
|
||||
return rows.map(mapRow)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import type { DatabaseSync } from 'node:sqlite'
|
||||
import { localDateString } from '../../services/writing-date.util'
|
||||
|
||||
export class PomodoroDailyRepository {
|
||||
constructor(private db: DatabaseSync) {}
|
||||
|
||||
recordComplete(bookId: string, wordDelta: number, date = localDateString()): void {
|
||||
this.db
|
||||
.prepare(
|
||||
`INSERT INTO pomodoro_daily (date, book_id, completed_count, total_words)
|
||||
VALUES (?, ?, 1, ?)
|
||||
ON CONFLICT(date, book_id) DO UPDATE SET
|
||||
completed_count = completed_count + 1,
|
||||
total_words = total_words + excluded.total_words`
|
||||
)
|
||||
.run(date, bookId, wordDelta)
|
||||
}
|
||||
|
||||
getTodayCount(bookId: string, date = localDateString()): number {
|
||||
const row = this.db
|
||||
.prepare('SELECT completed_count FROM pomodoro_daily WHERE date = ? AND book_id = ?')
|
||||
.get(date, bookId) as { completed_count: number } | undefined
|
||||
return row?.completed_count ?? 0
|
||||
}
|
||||
}
|
||||
@@ -20,10 +20,27 @@ export class WritingLogRepository {
|
||||
book_id TEXT NOT NULL,
|
||||
word_count INTEGER NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (date, book_id)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS writing_milestones (
|
||||
book_id TEXT NOT NULL,
|
||||
milestone TEXT NOT NULL,
|
||||
unlocked_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
PRIMARY KEY (book_id, milestone)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS pomodoro_daily (
|
||||
date TEXT NOT NULL,
|
||||
book_id TEXT NOT NULL,
|
||||
completed_count INTEGER NOT NULL DEFAULT 0,
|
||||
total_words INTEGER NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (date, book_id)
|
||||
)
|
||||
`)
|
||||
}
|
||||
|
||||
getDb(): DatabaseSync {
|
||||
return this.db
|
||||
}
|
||||
|
||||
addToday(bookId: string, delta: number, date = localDateString()): number {
|
||||
const row = this.db
|
||||
.prepare('SELECT word_count FROM writing_logs WHERE date = ? AND book_id = ?')
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import type { DatabaseSync } from 'node:sqlite'
|
||||
import type { WritingAchievement, WritingMilestone } from '../../../shared/types'
|
||||
|
||||
const ORDER: WritingMilestone[] = ['streak_7', 'streak_30', 'streak_100']
|
||||
|
||||
export class WritingMilestoneRepository {
|
||||
constructor(private db: DatabaseSync) {}
|
||||
|
||||
list(bookId: string): WritingAchievement[] {
|
||||
const rows = this.db
|
||||
.prepare('SELECT milestone, unlocked_at FROM writing_milestones WHERE book_id = ?')
|
||||
.all(bookId) as Array<{ milestone: string; unlocked_at: string }>
|
||||
return rows
|
||||
.map((r) => ({ milestone: r.milestone as WritingMilestone, unlockedAt: r.unlocked_at }))
|
||||
.sort((a, b) => ORDER.indexOf(a.milestone) - ORDER.indexOf(b.milestone))
|
||||
}
|
||||
|
||||
has(bookId: string, milestone: WritingMilestone): boolean {
|
||||
const row = this.db
|
||||
.prepare('SELECT 1 FROM writing_milestones WHERE book_id = ? AND milestone = ?')
|
||||
.get(bookId, milestone)
|
||||
return row != null
|
||||
}
|
||||
|
||||
unlock(bookId: string, milestone: WritingMilestone): WritingAchievement | null {
|
||||
if (this.has(bookId, milestone)) return null
|
||||
this.db
|
||||
.prepare(
|
||||
`INSERT INTO writing_milestones (book_id, milestone) VALUES (?, ?)`
|
||||
)
|
||||
.run(bookId, milestone)
|
||||
const row = this.db
|
||||
.prepare('SELECT unlocked_at FROM writing_milestones WHERE book_id = ? AND milestone = ?')
|
||||
.get(bookId, milestone) as { unlocked_at: string }
|
||||
return { milestone, unlockedAt: row.unlocked_at }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
CREATE TABLE IF NOT EXISTS knowledge_injection_logs (
|
||||
id TEXT PRIMARY KEY,
|
||||
knowledge_entry_id TEXT NOT NULL,
|
||||
flow_mode TEXT NOT NULL,
|
||||
flow_id TEXT NOT NULL,
|
||||
chapter_id TEXT,
|
||||
injected_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
FOREIGN KEY (knowledge_entry_id) REFERENCES knowledge_entries(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_injection_entry_time
|
||||
ON knowledge_injection_logs (knowledge_entry_id, injected_at DESC);
|
||||
@@ -0,0 +1,10 @@
|
||||
import { ipcMain } from 'electron'
|
||||
import { IPC } from '../../../shared/ipc-channels'
|
||||
import type { AchievementService } from '../../services/achievement.service'
|
||||
import { wrap } from '../result'
|
||||
|
||||
export function registerAchievementHandlers(achievement: AchievementService): void {
|
||||
ipcMain.handle(IPC.ACHIEVEMENT_LIST, (_e, { bookId }: { bookId: string }) =>
|
||||
wrap(() => achievement.listAchievements(bookId))
|
||||
)
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import { checkInteractiveGate } from '../../services/interactive-gate.service'
|
||||
import { AutoWritingService } from '../../services/auto-writing.service'
|
||||
import { scheduleChapterExtraction } from '../../services/knowledge-extraction-runner'
|
||||
import { trackerFor } from '../../services/chapter-writing-tracker.service'
|
||||
import { recordKnowledgeInjection } from '../../services/knowledge-injection-runner'
|
||||
import type { WritingLogService } from '../../services/writing-log.service'
|
||||
import { InteractiveRepository } from '../../db/repositories/interactive.repo'
|
||||
import { wrap } from '../result'
|
||||
@@ -89,6 +90,12 @@ export function registerAutoHandlers(
|
||||
bookId,
|
||||
settings.get().penName
|
||||
)
|
||||
recordKnowledgeInjection(registry, bookId, {
|
||||
knowledgeIds: binding.knowledgeIds,
|
||||
flowMode: 'auto',
|
||||
flowId,
|
||||
chapterId: registry.getMeta(bookId)?.lastChapterId ?? undefined
|
||||
})
|
||||
return svc.enrichFlow(svc.confirmContext(flowId, payload))
|
||||
})
|
||||
)
|
||||
|
||||
@@ -3,19 +3,29 @@ import { IPC } from '../../../shared/ipc-channels'
|
||||
import { BookRegistryService } from '../../services/book-registry'
|
||||
import { CockpitService } from '../../services/cockpit.service'
|
||||
import type { GlobalSettingsService } from '../../services/global-settings'
|
||||
import type { AchievementService } from '../../services/achievement.service'
|
||||
import type { PomodoroDailyRepository } from '../../db/repositories/pomodoro-daily.repo'
|
||||
import type { WritingLogService } from '../../services/writing-log.service'
|
||||
import { wrap } from '../result'
|
||||
|
||||
export function registerCockpitHandlers(
|
||||
registry: BookRegistryService,
|
||||
settings: GlobalSettingsService,
|
||||
writingLogs: WritingLogService
|
||||
writingLogs: WritingLogService,
|
||||
achievementService: AchievementService,
|
||||
pomodoroDaily: PomodoroDailyRepository
|
||||
): void {
|
||||
ipcMain.handle(
|
||||
IPC.COCKPIT_SUMMARY,
|
||||
(_e, { bookId, volumeId }: { bookId: string; volumeId?: string }) =>
|
||||
wrap(() =>
|
||||
new CockpitService(registry.getDb(bookId), settings, writingLogs).getSummary(volumeId, bookId)
|
||||
new CockpitService(
|
||||
registry.getDb(bookId),
|
||||
settings,
|
||||
writingLogs,
|
||||
achievementService,
|
||||
pomodoroDaily
|
||||
).getSummary(volumeId, bookId)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import { checkInteractiveGate } from '../../services/interactive-gate.service'
|
||||
import { InteractiveWritingService } from '../../services/interactive-writing.service'
|
||||
import { scheduleChapterExtraction } from '../../services/knowledge-extraction-runner'
|
||||
import { trackerFor } from '../../services/chapter-writing-tracker.service'
|
||||
import { recordKnowledgeInjection } from '../../services/knowledge-injection-runner'
|
||||
import type { WritingLogService } from '../../services/writing-log.service'
|
||||
import { wrap } from '../result'
|
||||
|
||||
@@ -66,6 +67,12 @@ export function registerInteractiveHandlers(
|
||||
bookId,
|
||||
settings.get().penName
|
||||
)
|
||||
recordKnowledgeInjection(registry, bookId, {
|
||||
knowledgeIds: binding.knowledgeIds,
|
||||
flowMode: 'interactive',
|
||||
flowId,
|
||||
chapterId: registry.getMeta(bookId)?.lastChapterId ?? undefined
|
||||
})
|
||||
const flow = serviceFor(registry, bookId, aiClient).confirmContext(flowId, payload)
|
||||
return serviceFor(registry, bookId, aiClient).enrichFlow(flow)
|
||||
})
|
||||
|
||||
@@ -11,6 +11,7 @@ import type { AiClientService } from '../../services/ai-client.service'
|
||||
import type { GlobalSettingsService } from '../../services/global-settings'
|
||||
import { KnowledgeRepository } from '../../db/repositories/knowledge.repo'
|
||||
import { KnowledgeExtractionService } from '../../services/knowledge-extraction.service'
|
||||
import { KnowledgeInjectionService } from '../../services/knowledge-injection.service'
|
||||
import { KnowledgeRetrievalService } from '../../services/knowledge-retrieval.service'
|
||||
import { KnowledgeService } from '../../services/knowledge.service'
|
||||
import { wrap } from '../result'
|
||||
@@ -120,4 +121,15 @@ export function registerKnowledgeHandlers(
|
||||
return new KnowledgeService(registry.getDb(bookId)).batchApproveHighConfidence(t)
|
||||
})
|
||||
)
|
||||
|
||||
ipcMain.handle(
|
||||
IPC.KNOWLEDGE_LIST_INJECTIONS,
|
||||
(
|
||||
_e,
|
||||
{ bookId, entryId, limit }: { bookId: string; entryId: string; limit?: number }
|
||||
) =>
|
||||
wrap(() =>
|
||||
new KnowledgeInjectionService(registry.getDb(bookId)).listForEntry(entryId, limit ?? 50)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { ipcMain } from 'electron'
|
||||
import { IPC } from '../../../shared/ipc-channels'
|
||||
import type { PomodoroService } from '../../services/pomodoro.service'
|
||||
import { wrap } from '../result'
|
||||
|
||||
export function registerPomodoroHandlers(pomodoro: PomodoroService): void {
|
||||
ipcMain.handle(IPC.POMODORO_START, (_e, { bookId }: { bookId: string }) =>
|
||||
wrap(() => pomodoro.start(bookId))
|
||||
)
|
||||
ipcMain.handle(IPC.POMODORO_PAUSE, () => wrap(() => pomodoro.pause()))
|
||||
ipcMain.handle(IPC.POMODORO_RESUME, () => wrap(() => pomodoro.resume()))
|
||||
ipcMain.handle(IPC.POMODORO_CANCEL, () => wrap(() => pomodoro.cancel()))
|
||||
ipcMain.handle(IPC.POMODORO_GET_STATE, () => wrap(() => pomodoro.getState()))
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import { GlobalSettingsService } from '../../services/global-settings'
|
||||
import { AiClientService } from '../../services/ai-client.service'
|
||||
import { buildFlowContextPayload, readFlowSystemPrompt } from '../../services/flow-context.util'
|
||||
import { WizardWritingService } from '../../services/wizard-writing.service'
|
||||
import { recordKnowledgeInjection } from '../../services/knowledge-injection-runner'
|
||||
import { InteractiveRepository } from '../../db/repositories/interactive.repo'
|
||||
import { wrap } from '../result'
|
||||
|
||||
@@ -99,6 +100,12 @@ export function registerWizardHandlers(
|
||||
bookId,
|
||||
settings.get().penName
|
||||
)
|
||||
recordKnowledgeInjection(registry, bookId, {
|
||||
knowledgeIds: binding.knowledgeIds,
|
||||
flowMode: 'wizard',
|
||||
flowId,
|
||||
chapterId: registry.getMeta(bookId)?.lastChapterId ?? undefined
|
||||
})
|
||||
const svc = serviceFor(registry, bookId, aiClient)
|
||||
return svc.enrichFlow(svc.confirmContext(flowId, payload))
|
||||
})
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import { join } from 'path'
|
||||
import { app } from 'electron'
|
||||
import { GlobalSettingsService } from '../services/global-settings'
|
||||
import { BookRegistryService } from '../services/book-registry'
|
||||
import { SnapshotService } from '../services/snapshot.service'
|
||||
import { ShortcutManager } from '../shortcuts/manager'
|
||||
import { WritingLogRepository } from '../db/repositories/writing-log.repo'
|
||||
import { WritingMilestoneRepository } from '../db/repositories/writing-milestone.repo'
|
||||
import { PomodoroDailyRepository } from '../db/repositories/pomodoro-daily.repo'
|
||||
import { WritingLogService } from '../services/writing-log.service'
|
||||
import { GoalNotificationService } from '../services/goal-notification.service'
|
||||
import { AchievementService } from '../services/achievement.service'
|
||||
import { PomodoroService } from '../services/pomodoro.service'
|
||||
import { registerSettingsHandlers } from './handlers/settings.handler'
|
||||
import { registerBookHandlers } from './handlers/book.handler'
|
||||
import { registerChapterHandlers } from './handlers/chapter.handler'
|
||||
@@ -23,6 +27,8 @@ import { registerWizardHandlers } from './handlers/wizard.handler'
|
||||
import { registerKnowledgeHandlers } from './handlers/knowledge.handler'
|
||||
import { registerCockpitHandlers } from './handlers/cockpit.handler'
|
||||
import { registerWritingHandlers } from './handlers/writing.handler'
|
||||
import { registerPomodoroHandlers } from './handlers/pomodoro.handler'
|
||||
import { registerAchievementHandlers } from './handlers/achievement.handler'
|
||||
import { registerBridgeHandlers } from './handlers/bridge.handler'
|
||||
import { AiClientService } from '../services/ai-client.service'
|
||||
import { NetworkMonitorService } from '../services/network-monitor.service'
|
||||
@@ -36,7 +42,20 @@ export function registerIpc(): { settings: GlobalSettingsService; books: BookReg
|
||||
|
||||
const settings = new GlobalSettingsService(userData)
|
||||
const books = new BookRegistryService(userData)
|
||||
const writingLogs = new WritingLogService(new WritingLogRepository(userData), settings)
|
||||
const writingLogRepo = new WritingLogRepository(userData)
|
||||
const writingLogs = new WritingLogService(writingLogRepo, settings)
|
||||
const milestoneRepo = new WritingMilestoneRepository(writingLogRepo.getDb())
|
||||
const pomodoroDailyRepo = new PomodoroDailyRepository(writingLogRepo.getDb())
|
||||
const goalNotify = new GoalNotificationService(settings)
|
||||
const achievementService = new AchievementService(
|
||||
milestoneRepo,
|
||||
writingLogs,
|
||||
settings,
|
||||
goalNotify
|
||||
)
|
||||
writingLogs.setGoalHooks(achievementService, goalNotify)
|
||||
const pomodoro = new PomodoroService(writingLogs, pomodoroDailyRepo, settings, goalNotify)
|
||||
|
||||
shortcutManager = new ShortcutManager(settings)
|
||||
snapshotService = new SnapshotService(() => settings.get())
|
||||
networkMonitor = new NetworkMonitorService()
|
||||
@@ -57,8 +76,10 @@ export function registerIpc(): { settings: GlobalSettingsService; books: BookReg
|
||||
registerAutoHandlers(books, settings, aiClient, writingLogs)
|
||||
registerWizardHandlers(books, settings, aiClient)
|
||||
registerKnowledgeHandlers(books, settings, aiClient)
|
||||
registerCockpitHandlers(books, settings, writingLogs)
|
||||
registerCockpitHandlers(books, settings, writingLogs, achievementService, pomodoroDailyRepo)
|
||||
registerWritingHandlers(writingLogs)
|
||||
registerPomodoroHandlers(pomodoro)
|
||||
registerAchievementHandlers(achievementService)
|
||||
registerBridgeHandlers(books, aiClient)
|
||||
|
||||
return { settings, books, shortcuts: shortcutManager }
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import type { WritingAchievement, WritingMilestone } from '../../shared/types'
|
||||
import { WritingMilestoneRepository } from '../db/repositories/writing-milestone.repo'
|
||||
import type { GoalNotificationService } from './goal-notification.service'
|
||||
import type { GlobalSettingsService } from './global-settings'
|
||||
import type { WritingLogService } from './writing-log.service'
|
||||
|
||||
const THRESHOLDS: Array<{ days: number; milestone: WritingMilestone }> = [
|
||||
{ days: 7, milestone: 'streak_7' },
|
||||
{ days: 30, milestone: 'streak_30' },
|
||||
{ days: 100, milestone: 'streak_100' }
|
||||
]
|
||||
|
||||
export class AchievementService {
|
||||
constructor(
|
||||
private milestoneRepo: WritingMilestoneRepository,
|
||||
private writingLogs: WritingLogService,
|
||||
private settings: GlobalSettingsService,
|
||||
private notify: GoalNotificationService
|
||||
) {}
|
||||
|
||||
listAchievements(bookId: string): WritingAchievement[] {
|
||||
return this.milestoneRepo.list(bookId)
|
||||
}
|
||||
|
||||
checkMilestones(bookId: string): WritingAchievement[] {
|
||||
const { dailyWordGoal } = this.settings.get()
|
||||
if (dailyWordGoal <= 0) return []
|
||||
const streak = this.writingLogs.getStats(bookId).streakDays
|
||||
const unlocked: WritingAchievement[] = []
|
||||
for (const { days, milestone } of THRESHOLDS) {
|
||||
if (streak >= days) {
|
||||
const a = this.milestoneRepo.unlock(bookId, milestone)
|
||||
if (a) {
|
||||
this.notify.notifyMilestone(milestone)
|
||||
unlocked.push(a)
|
||||
}
|
||||
}
|
||||
}
|
||||
return unlocked
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import { BookPrefsRepository } from '../db/repositories/book-prefs.repo'
|
||||
import { ChapterRepository } from '../db/repositories/chapter.repo'
|
||||
import type { GlobalSettingsService } from './global-settings'
|
||||
import { KnowledgeService } from './knowledge.service'
|
||||
import type { AchievementService } from './achievement.service'
|
||||
import type { PomodoroDailyRepository } from '../db/repositories/pomodoro-daily.repo'
|
||||
import type { WritingLogService } from './writing-log.service'
|
||||
import { stripHtml } from './word-count'
|
||||
|
||||
@@ -11,7 +13,9 @@ export class CockpitService {
|
||||
constructor(
|
||||
private db: SqliteDb,
|
||||
private settings: GlobalSettingsService,
|
||||
private writingLogs?: WritingLogService
|
||||
private writingLogs?: WritingLogService,
|
||||
private achievementService?: AchievementService,
|
||||
private pomodoroDaily?: PomodoroDailyRepository
|
||||
) {}
|
||||
|
||||
getSummary(activeVolumeId?: string, bookId?: string): CockpitSummary {
|
||||
@@ -27,6 +31,12 @@ export class CockpitService {
|
||||
const { stockBufferThreshold } = this.settings.get()
|
||||
const writingStats =
|
||||
bookId && this.writingLogs ? this.writingLogs.getStats(bookId) : undefined
|
||||
const achievements =
|
||||
bookId && this.achievementService
|
||||
? this.achievementService.listAchievements(bookId)
|
||||
: undefined
|
||||
const pomodoroTodayCount =
|
||||
bookId && this.pomodoroDaily ? this.pomodoroDaily.getTodayCount(bookId) : undefined
|
||||
return {
|
||||
totalWords,
|
||||
volumeWords,
|
||||
@@ -35,7 +45,9 @@ export class CockpitService {
|
||||
foreshadowBuried: stats.buried,
|
||||
foreshadowResolved: stats.resolved,
|
||||
foreshadowForgotten: stats.forgotten,
|
||||
writingStats
|
||||
writingStats,
|
||||
achievements,
|
||||
pomodoroTodayCount
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,10 @@ function defaults(): GlobalSettings {
|
||||
knowledgeAutoSuggest: true,
|
||||
knowledgeSuggestTopN: 8,
|
||||
knowledgeAutoExtract: true,
|
||||
knowledgeExtractConfidenceThreshold: 0.8
|
||||
knowledgeExtractConfidenceThreshold: 0.8,
|
||||
pomodoroDurationMinutes: 25,
|
||||
enableSystemNotifications: false,
|
||||
enableGoalNotifications: true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +60,10 @@ export class GlobalSettingsService {
|
||||
knowledgeSuggestTopN: raw.knowledgeSuggestTopN ?? 8,
|
||||
knowledgeAutoExtract: raw.knowledgeAutoExtract ?? true,
|
||||
knowledgeExtractConfidenceThreshold: raw.knowledgeExtractConfidenceThreshold ?? 0.8,
|
||||
pomodoroDurationMinutes: raw.pomodoroDurationMinutes ?? 25,
|
||||
enableSystemNotifications: raw.enableSystemNotifications ?? false,
|
||||
enableGoalNotifications: raw.enableGoalNotifications ?? true,
|
||||
dailyGoalNotifiedDate: raw.dailyGoalNotifiedDate,
|
||||
shortcuts: { ...DEFAULT_SHORTCUTS, ...raw.shortcuts },
|
||||
aiConfig: { ...DEFAULT_AI_CONFIG, ...raw.aiConfig }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import { BrowserWindow, Notification } from 'electron'
|
||||
import { IPC } from '../../shared/ipc-channels'
|
||||
import type { GoalNotificationPayload, WritingMilestone } from '../../shared/types'
|
||||
import type { GlobalSettingsService } from './global-settings'
|
||||
|
||||
const MILESTONE_LABEL: Record<WritingMilestone, string> = {
|
||||
streak_7: 'achievement.streak7',
|
||||
streak_30: 'achievement.streak30',
|
||||
streak_100: 'achievement.streak100'
|
||||
}
|
||||
|
||||
export class GoalNotificationService {
|
||||
constructor(private settings: GlobalSettingsService) {}
|
||||
|
||||
private getWindow(): BrowserWindow | null {
|
||||
const wins = BrowserWindow.getAllWindows()
|
||||
return wins.length > 0 ? wins[0] : null
|
||||
}
|
||||
|
||||
pushToast(payload: GoalNotificationPayload): void {
|
||||
this.getWindow()?.webContents.send(IPC.GOAL_NOTIFICATION, payload)
|
||||
}
|
||||
|
||||
maybeSystemNotify(title: string, body: string): void {
|
||||
if (!this.settings.get().enableSystemNotifications) return
|
||||
if (!Notification.isSupported()) return
|
||||
try {
|
||||
new Notification({ title, body }).show()
|
||||
} catch {
|
||||
/* permission denied */
|
||||
}
|
||||
}
|
||||
|
||||
notifyPomodoroComplete(words: number): void {
|
||||
const payload: GoalNotificationPayload = {
|
||||
kind: 'pomodoro_complete',
|
||||
messageKey: 'pomodoro.complete',
|
||||
messageParams: { words }
|
||||
}
|
||||
this.pushToast(payload)
|
||||
this.maybeSystemNotify('笔临', `番茄钟完成,本次写作 ${words} 字`)
|
||||
}
|
||||
|
||||
notifyPomodoroBookSwitch(): void {
|
||||
this.pushToast({
|
||||
kind: 'pomodoro_cancelled_book_switch',
|
||||
messageKey: 'pomodoro.switchedBook'
|
||||
})
|
||||
}
|
||||
|
||||
maybeNotifyDailyMet(current: number, goal: number): void {
|
||||
if (!this.settings.get().enableGoalNotifications) return
|
||||
const today = new Date().toLocaleDateString('sv-SE')
|
||||
if (this.settings.get().dailyGoalNotifiedDate === today) return
|
||||
if (current < goal) return
|
||||
this.settings.update({ dailyGoalNotifiedDate: today })
|
||||
this.pushToast({
|
||||
kind: 'daily_met',
|
||||
messageKey: 'goal.dailyMet',
|
||||
messageParams: { current, goal }
|
||||
})
|
||||
this.maybeSystemNotify('笔临', `今日目标已达成 ${current} / ${goal} 字`)
|
||||
}
|
||||
|
||||
notifyMilestone(milestone: WritingMilestone): void {
|
||||
this.pushToast({
|
||||
kind: 'milestone',
|
||||
messageKey: MILESTONE_LABEL[milestone]
|
||||
})
|
||||
this.maybeSystemNotify('笔临', '解锁写作成就')
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import type { BookRegistryService } from './book-registry'
|
||||
import type { InjectionFlowMode } from '../../shared/types'
|
||||
import { KnowledgeInjectionService } from './knowledge-injection.service'
|
||||
|
||||
export function recordKnowledgeInjection(
|
||||
registry: BookRegistryService,
|
||||
bookId: string,
|
||||
input: {
|
||||
knowledgeIds: string[]
|
||||
flowMode: InjectionFlowMode
|
||||
flowId: string
|
||||
chapterId?: string
|
||||
}
|
||||
): void {
|
||||
try {
|
||||
new KnowledgeInjectionService(registry.getDb(bookId)).record(input)
|
||||
} catch (err) {
|
||||
console.error('[knowledge-injection]', err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import type { InjectionFlowMode, KnowledgeInjectionLog } from '../../shared/types'
|
||||
import type { SqliteDb } from '../db/types'
|
||||
import { KnowledgeRepository } from '../db/repositories/knowledge.repo'
|
||||
import { KnowledgeInjectionRepository } from '../db/repositories/knowledge-injection.repo'
|
||||
|
||||
export class KnowledgeInjectionService {
|
||||
private injectionRepo: KnowledgeInjectionRepository
|
||||
private knowledgeRepo: KnowledgeRepository
|
||||
|
||||
constructor(db: SqliteDb) {
|
||||
this.injectionRepo = new KnowledgeInjectionRepository(db)
|
||||
this.knowledgeRepo = new KnowledgeRepository(db)
|
||||
}
|
||||
|
||||
record(input: {
|
||||
knowledgeIds: string[]
|
||||
flowMode: InjectionFlowMode
|
||||
flowId: string
|
||||
chapterId?: string
|
||||
}): void {
|
||||
if (input.knowledgeIds.length === 0) return
|
||||
const rows = input.knowledgeIds
|
||||
.filter((id) => {
|
||||
const entry = this.knowledgeRepo.get(id)
|
||||
return entry?.status === 'approved'
|
||||
})
|
||||
.map((id) => ({
|
||||
knowledgeEntryId: id,
|
||||
flowMode: input.flowMode,
|
||||
flowId: input.flowId,
|
||||
chapterId: input.chapterId
|
||||
}))
|
||||
if (rows.length > 0) this.injectionRepo.insertBatch(rows)
|
||||
}
|
||||
|
||||
listForEntry(entryId: string, limit = 50): KnowledgeInjectionLog[] {
|
||||
return this.injectionRepo.listForEntry(entryId, limit)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import type { PomodoroState } from '../../shared/types'
|
||||
import { PomodoroDailyRepository } from '../db/repositories/pomodoro-daily.repo'
|
||||
import type { GoalNotificationService } from './goal-notification.service'
|
||||
import type { GlobalSettingsService } from './global-settings'
|
||||
import type { WritingLogService } from './writing-log.service'
|
||||
import { IPC } from '../../shared/ipc-channels'
|
||||
import { BrowserWindow } from 'electron'
|
||||
|
||||
export class PomodoroService {
|
||||
private state: PomodoroState = { running: false, paused: false, remainingSec: 0, bookId: null }
|
||||
private wordSnapshot = 0
|
||||
private timer: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
constructor(
|
||||
private writingLogs: WritingLogService,
|
||||
private pomodoroDaily: PomodoroDailyRepository,
|
||||
private settings: GlobalSettingsService,
|
||||
private notify: GoalNotificationService
|
||||
) {}
|
||||
|
||||
getState(): PomodoroState {
|
||||
return { ...this.state }
|
||||
}
|
||||
|
||||
start(bookId: string): PomodoroState {
|
||||
if (this.state.running && this.state.bookId !== bookId) {
|
||||
this.notify.notifyPomodoroBookSwitch()
|
||||
this.cancelInternal()
|
||||
}
|
||||
const duration = this.resolveDurationSec()
|
||||
this.wordSnapshot = this.writingLogs.getStats(bookId).todayWords
|
||||
this.state = { running: true, paused: false, remainingSec: duration, bookId }
|
||||
this.startTimer()
|
||||
this.pushTick()
|
||||
return this.getState()
|
||||
}
|
||||
|
||||
pause(): PomodoroState {
|
||||
if (!this.state.running || this.state.paused) return this.getState()
|
||||
this.state = { ...this.state, paused: true }
|
||||
this.stopTimer()
|
||||
return this.getState()
|
||||
}
|
||||
|
||||
resume(): PomodoroState {
|
||||
if (!this.state.running || !this.state.paused) return this.getState()
|
||||
this.state = { ...this.state, paused: false }
|
||||
this.startTimer()
|
||||
return this.getState()
|
||||
}
|
||||
|
||||
cancel(): PomodoroState {
|
||||
this.cancelInternal()
|
||||
return this.getState()
|
||||
}
|
||||
|
||||
private cancelInternal(): void {
|
||||
this.stopTimer()
|
||||
this.state = { running: false, paused: false, remainingSec: 0, bookId: null }
|
||||
this.wordSnapshot = 0
|
||||
this.pushTick()
|
||||
}
|
||||
|
||||
private complete(): void {
|
||||
const bookId = this.state.bookId!
|
||||
const delta = Math.max(
|
||||
0,
|
||||
this.writingLogs.getStats(bookId).todayWords - this.wordSnapshot
|
||||
)
|
||||
this.pomodoroDaily.recordComplete(bookId, delta)
|
||||
this.notify.notifyPomodoroComplete(delta)
|
||||
this.cancelInternal()
|
||||
}
|
||||
|
||||
private tick(): void {
|
||||
if (!this.state.running || this.state.paused) return
|
||||
if (this.state.remainingSec <= 1) {
|
||||
this.complete()
|
||||
return
|
||||
}
|
||||
this.state = { ...this.state, remainingSec: this.state.remainingSec - 1 }
|
||||
this.pushTick()
|
||||
}
|
||||
|
||||
private startTimer(): void {
|
||||
this.stopTimer()
|
||||
this.timer = setInterval(() => this.tick(), 1000)
|
||||
}
|
||||
|
||||
private stopTimer(): void {
|
||||
if (this.timer) {
|
||||
clearInterval(this.timer)
|
||||
this.timer = null
|
||||
}
|
||||
}
|
||||
|
||||
private pushTick(): void {
|
||||
const wins = BrowserWindow.getAllWindows()
|
||||
for (const win of wins) {
|
||||
win.webContents.send(IPC.POMODORO_TICK, this.getState())
|
||||
}
|
||||
}
|
||||
|
||||
private resolveDurationSec(): number {
|
||||
if (process.env.BILIN_E2E === '1' && process.env.POMODORO_TEST_SEC) {
|
||||
return Number(process.env.POMODORO_TEST_SEC) || 3
|
||||
}
|
||||
const mins = this.settings.get().pomodoroDurationMinutes ?? 25
|
||||
return mins * 60
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,36 @@
|
||||
import type { WritingStats } from '../../shared/types'
|
||||
import { WritingLogRepository } from '../db/repositories/writing-log.repo'
|
||||
import type { AchievementService } from './achievement.service'
|
||||
import type { GlobalSettingsService } from './global-settings'
|
||||
import type { GoalNotificationService } from './goal-notification.service'
|
||||
import { addDays, localDateString } from './writing-date.util'
|
||||
|
||||
export class WritingLogService {
|
||||
private achievementService: AchievementService | null = null
|
||||
private goalNotify: GoalNotificationService | null = null
|
||||
|
||||
constructor(
|
||||
private repo: WritingLogRepository,
|
||||
private settings: GlobalSettingsService
|
||||
) {}
|
||||
|
||||
setGoalHooks(achievement: AchievementService, notify: GoalNotificationService): void {
|
||||
this.achievementService = achievement
|
||||
this.goalNotify = notify
|
||||
}
|
||||
|
||||
addToday(bookId: string, delta: number): number {
|
||||
return this.repo.addToday(bookId, delta)
|
||||
const result = this.repo.addToday(bookId, delta)
|
||||
if (delta !== 0) this.afterWordsChanged(bookId)
|
||||
return result
|
||||
}
|
||||
|
||||
private afterWordsChanged(bookId: string): void {
|
||||
const stats = this.getStats(bookId)
|
||||
if (stats.dailyGoal > 0 && stats.todayWords >= stats.dailyGoal) {
|
||||
this.goalNotify?.maybeNotifyDailyMet(stats.todayWords, stats.dailyGoal)
|
||||
}
|
||||
this.achievementService?.checkMilestones(bookId)
|
||||
}
|
||||
|
||||
getStats(bookId: string): WritingStats {
|
||||
|
||||
+38
-2
@@ -46,7 +46,11 @@ import type {
|
||||
ChapterBridgeResult,
|
||||
PublishStatus,
|
||||
WritingStats,
|
||||
KnowledgeExtractionResult
|
||||
KnowledgeExtractionResult,
|
||||
PomodoroState,
|
||||
GoalNotificationPayload,
|
||||
KnowledgeInjectionLog,
|
||||
WritingAchievement
|
||||
} from '../shared/types'
|
||||
|
||||
const electronAPI = {
|
||||
@@ -477,12 +481,30 @@ const electronAPI = {
|
||||
bookId: string,
|
||||
threshold?: number
|
||||
): Promise<IpcResult<number>> =>
|
||||
ipcRenderer.invoke(IPC.KNOWLEDGE_BATCH_APPROVE_HIGH_CONFIDENCE, { bookId, threshold })
|
||||
ipcRenderer.invoke(IPC.KNOWLEDGE_BATCH_APPROVE_HIGH_CONFIDENCE, { bookId, threshold }),
|
||||
listInjections: (
|
||||
bookId: string,
|
||||
entryId: string,
|
||||
limit?: number
|
||||
): Promise<IpcResult<KnowledgeInjectionLog[]>> =>
|
||||
ipcRenderer.invoke(IPC.KNOWLEDGE_LIST_INJECTIONS, { bookId, entryId, limit })
|
||||
},
|
||||
writing: {
|
||||
getStats: (bookId: string): Promise<IpcResult<WritingStats>> =>
|
||||
ipcRenderer.invoke(IPC.WRITING_GET_STATS, { bookId })
|
||||
},
|
||||
pomodoro: {
|
||||
start: (bookId: string): Promise<IpcResult<PomodoroState>> =>
|
||||
ipcRenderer.invoke(IPC.POMODORO_START, { bookId }),
|
||||
pause: (): Promise<IpcResult<PomodoroState>> => ipcRenderer.invoke(IPC.POMODORO_PAUSE),
|
||||
resume: (): Promise<IpcResult<PomodoroState>> => ipcRenderer.invoke(IPC.POMODORO_RESUME),
|
||||
cancel: (): Promise<IpcResult<PomodoroState>> => ipcRenderer.invoke(IPC.POMODORO_CANCEL),
|
||||
getState: (): Promise<IpcResult<PomodoroState>> => ipcRenderer.invoke(IPC.POMODORO_GET_STATE)
|
||||
},
|
||||
achievement: {
|
||||
list: (bookId: string): Promise<IpcResult<WritingAchievement[]>> =>
|
||||
ipcRenderer.invoke(IPC.ACHIEVEMENT_LIST, { bookId })
|
||||
},
|
||||
cockpit: {
|
||||
getSummary: (bookId: string, volumeId?: string): Promise<IpcResult<CockpitSummary>> =>
|
||||
ipcRenderer.invoke(IPC.COCKPIT_SUMMARY, { bookId, volumeId }),
|
||||
@@ -543,6 +565,20 @@ const electronAPI = {
|
||||
}
|
||||
ipcRenderer.on(IPC.INTERACTIVE_STREAM_CHUNK, handler)
|
||||
return () => ipcRenderer.removeListener(IPC.INTERACTIVE_STREAM_CHUNK, handler)
|
||||
},
|
||||
onPomodoroTick: (callback: (state: PomodoroState) => void): (() => void) => {
|
||||
const handler = (_event: IpcRendererEvent, state: PomodoroState) => {
|
||||
callback(state)
|
||||
}
|
||||
ipcRenderer.on(IPC.POMODORO_TICK, handler)
|
||||
return () => ipcRenderer.removeListener(IPC.POMODORO_TICK, handler)
|
||||
},
|
||||
onGoalNotification: (callback: (payload: GoalNotificationPayload) => void): (() => void) => {
|
||||
const handler = (_event: IpcRendererEvent, payload: GoalNotificationPayload) => {
|
||||
callback(payload)
|
||||
}
|
||||
ipcRenderer.on(IPC.GOAL_NOTIFICATION, handler)
|
||||
return () => ipcRenderer.removeListener(IPC.GOAL_NOTIFICATION, handler)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,12 @@ function AppInner(): React.JSX.Element {
|
||||
if (loaded && !onboardingCompleted) setShowOnboarding(true)
|
||||
}, [loaded, onboardingCompleted])
|
||||
|
||||
useEffect(() => {
|
||||
return window.electronAPI.onGoalNotification((payload) => {
|
||||
showToast(t(payload.messageKey, payload.messageParams))
|
||||
})
|
||||
}, [showToast, t])
|
||||
|
||||
useEffect(() => {
|
||||
const openSearch = (): void => useSearchStore.getState().setOpen(true)
|
||||
const openLandmarks = (): void => useAppStore.getState().setLandmarksModalOpen(true)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useEffect } from 'react'
|
||||
import type { WritingMilestone } from '@shared/types'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useBookStore } from '@renderer/stores/useBookStore'
|
||||
import { useEditStore } from '@renderer/stores/useEditStore'
|
||||
@@ -10,6 +11,14 @@ interface CockpitModalProps {
|
||||
onOpenBridge: (chapterId: string) => void
|
||||
}
|
||||
|
||||
const ALL_MILESTONES: WritingMilestone[] = ['streak_7', 'streak_30', 'streak_100']
|
||||
|
||||
const MILESTONE_I18N: Record<WritingMilestone, string> = {
|
||||
streak_7: 'achievement.streak7',
|
||||
streak_30: 'achievement.streak30',
|
||||
streak_100: 'achievement.streak100'
|
||||
}
|
||||
|
||||
export function CockpitModal({ onOpenBridge }: CockpitModalProps): React.JSX.Element | null {
|
||||
const { t } = useTranslation()
|
||||
const bookId = useBookStore((s) => s.currentBookId)
|
||||
@@ -105,6 +114,26 @@ export function CockpitModal({ onOpenBridge }: CockpitModalProps): React.JSX.Ele
|
||||
<WritingHeatmap heatmap={summary.writingStats.heatmap} />
|
||||
</div>
|
||||
)}
|
||||
<div className="cockpit-pomodoro-today" data-testid="cockpit-pomodoro-today">
|
||||
{t('cockpit.pomodoroToday', { count: summary.pomodoroTodayCount ?? 0 })}
|
||||
</div>
|
||||
<div className="cockpit-achievements-section">
|
||||
<div className="cockpit-heatmap-label">{t('cockpit.achievements')}</div>
|
||||
<div className="cockpit-achievements" data-testid="cockpit-achievements">
|
||||
{ALL_MILESTONES.map((milestone) => {
|
||||
const unlocked = summary.achievements?.some((a) => a.milestone === milestone)
|
||||
return (
|
||||
<span
|
||||
key={milestone}
|
||||
className={`cockpit-achievement-badge ${unlocked ? 'unlocked' : 'locked'}`}
|
||||
title={t(MILESTONE_I18N[milestone])}
|
||||
>
|
||||
{milestone === 'streak_7' ? '7🔥' : milestone === 'streak_30' ? '30🔥' : '100🔥'}
|
||||
</span>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -4,9 +4,11 @@ import type {
|
||||
CreateKnowledgeInput,
|
||||
ForeshadowStatus,
|
||||
KnowledgeEntry,
|
||||
KnowledgeInjectionLog,
|
||||
KnowledgeType
|
||||
} from '@shared/types'
|
||||
import { useBookStore } from '@renderer/stores/useBookStore'
|
||||
import { useEditStore } from '@renderer/stores/useEditStore'
|
||||
import { useKnowledgeStore } from '@renderer/stores/useKnowledgeStore'
|
||||
import { ipcCall } from '@renderer/lib/ipc-client'
|
||||
|
||||
@@ -26,6 +28,7 @@ export function KnowledgeEditorDialog({
|
||||
const { t } = useTranslation()
|
||||
const bookId = useBookStore((s) => s.currentBookId)
|
||||
const chapters = useBookStore((s) => s.chapters)
|
||||
const switchTarget = useEditStore((s) => s.switchTarget)
|
||||
const entries = useKnowledgeStore((s) => s.entries)
|
||||
const create = useKnowledgeStore((s) => s.create)
|
||||
const update = useKnowledgeStore((s) => s.update)
|
||||
@@ -45,6 +48,17 @@ export function KnowledgeEditorDialog({
|
||||
const [foreshadowStatus, setForeshadowStatus] = useState<ForeshadowStatus>('buried')
|
||||
const [sourceChapterId, setSourceChapterId] = useState('')
|
||||
const [approveNow, setApproveNow] = useState(false)
|
||||
const [injections, setInjections] = useState<KnowledgeInjectionLog[]>([])
|
||||
|
||||
useEffect(() => {
|
||||
if (!open || !bookId || !entryId) {
|
||||
setInjections([])
|
||||
return
|
||||
}
|
||||
void ipcCall(() => window.electronAPI.knowledge.listInjections(bookId, entryId)).then(
|
||||
setInjections
|
||||
)
|
||||
}, [open, bookId, entryId])
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return
|
||||
@@ -183,6 +197,39 @@ export function KnowledgeEditorDialog({
|
||||
{t('knowledge.approveNow')}
|
||||
</label>
|
||||
)}
|
||||
{existing && injections.length > 0 && (
|
||||
<div className="knowledge-injection-history" data-testid="knowledge-injection-history">
|
||||
<div className="kb-injection-label">{t('knowledge.injectionHistory')}</div>
|
||||
{injections.map((log) => {
|
||||
const chapterTitle =
|
||||
chapters.find((c) => c.id === log.chapterId)?.title ?? t('knowledge.noChapter')
|
||||
return (
|
||||
<div key={log.id} className="kb-injection-row">
|
||||
<span className="kb-injection-date">
|
||||
{new Date(log.injectedAt).toLocaleString()}
|
||||
</span>
|
||||
<span className="kb-injection-mode">
|
||||
{t(`knowledge.injectionMode.${log.flowMode}`)}
|
||||
</span>
|
||||
{log.chapterId ? (
|
||||
<button
|
||||
type="button"
|
||||
className="kb-injection-chapter-link"
|
||||
onClick={() => {
|
||||
void switchTarget({ kind: 'chapter', id: log.chapterId! })
|
||||
onClose()
|
||||
}}
|
||||
>
|
||||
{chapterTitle}
|
||||
</button>
|
||||
) : (
|
||||
<span>{chapterTitle}</span>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="modal-footer">
|
||||
{isMergeMode && bookId && existing && (
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
export function KnowledgePanel(): React.JSX.Element {
|
||||
const { t } = useTranslation()
|
||||
const bookId = useBookStore((s) => s.currentBookId)
|
||||
const chapters = useBookStore((s) => s.chapters)
|
||||
const selectedChapterId = useBookStore((s) => s.selectedChapterId)
|
||||
const extractThreshold = useSettingsStore((s) => s.knowledgeExtractConfidenceThreshold)
|
||||
const {
|
||||
@@ -32,6 +33,8 @@ export function KnowledgePanel(): React.JSX.Element {
|
||||
extractChapter,
|
||||
batchApproveHighConfidence
|
||||
} = useKnowledgeStore()
|
||||
const injectionPreviews = useKnowledgeStore((s) => s.injectionPreviews)
|
||||
const loadInjectionPreviews = useKnowledgeStore((s) => s.loadInjectionPreviews)
|
||||
const [extracting, setExtracting] = useState(false)
|
||||
const [namingOpen, setNamingOpen] = useState(false)
|
||||
const [selected, setSelected] = useState<Set<string>>(new Set())
|
||||
@@ -51,6 +54,14 @@ export function KnowledgePanel(): React.JSX.Element {
|
||||
)
|
||||
}, [bookId, entries])
|
||||
|
||||
useEffect(() => {
|
||||
if (!bookId || entries.length === 0) return
|
||||
void loadInjectionPreviews(
|
||||
bookId,
|
||||
entries.map((e) => e.id)
|
||||
)
|
||||
}, [bookId, entries, loadInjectionPreviews])
|
||||
|
||||
const handleBatchApprove = async (): Promise<void> => {
|
||||
if (!bookId || selected.size === 0) return
|
||||
await batchApprove(bookId, [...selected])
|
||||
@@ -188,6 +199,25 @@ export function KnowledgePanel(): React.JSX.Element {
|
||||
</div>
|
||||
)}
|
||||
{entry.content && <div className="kb-item-content">{entry.content}</div>}
|
||||
{(injectionPreviews[entry.id]?.length ?? 0) > 0 && (
|
||||
<div
|
||||
className="kb-injection-preview"
|
||||
data-testid={`knowledge-injection-preview-${entry.id}`}
|
||||
>
|
||||
<div className="kb-injection-label">{t('knowledge.injectionPreview')}</div>
|
||||
{injectionPreviews[entry.id]!.map((log) => (
|
||||
<div key={log.id} className="kb-injection-preview-row">
|
||||
{t('knowledge.injectionEntry', {
|
||||
date: new Date(log.injectedAt).toLocaleDateString(),
|
||||
mode: t(`knowledge.injectionMode.${log.flowMode}`),
|
||||
chapter:
|
||||
chapters.find((c) => c.id === log.chapterId)?.title ??
|
||||
t('knowledge.noChapter')
|
||||
})}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="kb-item-actions">
|
||||
{entry.status === 'pending' && bookId && (
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useReferenceStore } from '@renderer/stores/useReferenceStore'
|
||||
import { useSettingsStore } from '@renderer/stores/useSettingsStore'
|
||||
import { useCockpitStore } from '@renderer/stores/useCockpitStore'
|
||||
import { useWritingStatsStore } from '@renderer/stores/useWritingStatsStore'
|
||||
import { usePomodoroStore, formatPomodoroTime } from '@renderer/stores/usePomodoroStore'
|
||||
import { ipcCall } from '@renderer/lib/ipc-client'
|
||||
import { TipTapEditor, flushEditorSave } from '@renderer/components/editor/TipTapEditor'
|
||||
import { insertLandmarkInEditor } from '@renderer/lib/editor-commands'
|
||||
@@ -94,6 +95,15 @@ export function EditorLayout(): React.JSX.Element {
|
||||
const dailyWordGoal = useSettingsStore((s) => s.dailyWordGoal)
|
||||
const writingStats = useWritingStatsStore((s) => s.stats)
|
||||
const refreshWritingStats = useWritingStatsStore((s) => s.refresh)
|
||||
const pomodoroRunning = usePomodoroStore((s) => s.running)
|
||||
const pomodoroPaused = usePomodoroStore((s) => s.paused)
|
||||
const pomodoroRemaining = usePomodoroStore((s) => s.remainingSec)
|
||||
const pomodoroBookId = usePomodoroStore((s) => s.bookId)
|
||||
const pomodoroInit = usePomodoroStore((s) => s.init)
|
||||
const pomodoroStart = usePomodoroStore((s) => s.start)
|
||||
const pomodoroPause = usePomodoroStore((s) => s.pause)
|
||||
const pomodoroResume = usePomodoroStore((s) => s.resume)
|
||||
const pomodoroCancel = usePomodoroStore((s) => s.cancel)
|
||||
const bridgeChapterId = useCockpitStore((s) => s.bridgeChapterId)
|
||||
const clearBridgeChapter = useCockpitStore((s) => s.clearBridgeChapter)
|
||||
const updateChapterLocal = useBookStore((s) => s.updateChapterLocal)
|
||||
@@ -111,11 +121,21 @@ export function EditorLayout(): React.JSX.Element {
|
||||
const isChapterTarget = target?.kind === 'chapter'
|
||||
const chapterId = target?.kind === 'chapter' ? target.id : selectedChapterId
|
||||
|
||||
useEffect(() => {
|
||||
void pomodoroInit()
|
||||
}, [pomodoroInit])
|
||||
|
||||
useEffect(() => {
|
||||
if (!pomodoroRunning || !pomodoroBookId || !currentBookId) return
|
||||
if (pomodoroBookId === currentBookId) return
|
||||
void pomodoroCancel()
|
||||
}, [currentBookId, pomodoroRunning, pomodoroBookId, pomodoroCancel])
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedChapterId && (!target || target.kind === 'chapter')) {
|
||||
setTarget({ kind: 'chapter', id: selectedChapterId })
|
||||
}
|
||||
}, [selectedChapterId, setTarget])
|
||||
}, [selectedChapterId, setTarget, target])
|
||||
|
||||
useEffect(() => {
|
||||
if (!currentBookId || target?.kind !== 'chapter') return
|
||||
@@ -426,6 +446,39 @@ export function EditorLayout(): React.JSX.Element {
|
||||
bookId={currentBookId}
|
||||
/>
|
||||
<div id="editor-statusbar">
|
||||
<div className="pomodoro-control" data-testid="pomodoro-control">
|
||||
{!pomodoroRunning ? (
|
||||
<button
|
||||
type="button"
|
||||
className="pomodoro-btn"
|
||||
title={t('pomodoro.start')}
|
||||
disabled={!currentBookId}
|
||||
onClick={() => currentBookId && void pomodoroStart(currentBookId)}
|
||||
>
|
||||
▶
|
||||
</button>
|
||||
) : (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
className="pomodoro-btn"
|
||||
title={pomodoroPaused ? t('pomodoro.resume') : t('pomodoro.pause')}
|
||||
onClick={() => void (pomodoroPaused ? pomodoroResume() : pomodoroPause())}
|
||||
>
|
||||
{pomodoroPaused ? '▶' : '⏸'}
|
||||
</button>
|
||||
<span className="pomodoro-time">{formatPomodoroTime(pomodoroRemaining)}</span>
|
||||
<button
|
||||
type="button"
|
||||
className="pomodoro-btn"
|
||||
title={t('pomodoro.cancel')}
|
||||
onClick={() => void pomodoroCancel()}
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<span>{saveStatus}{lastSaved ? ` · ${lastSaved.toLocaleTimeString()}` : ''}</span>
|
||||
{dailyWordGoal > 0 && writingStats && (
|
||||
<span
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import type { ThemeId, Language } from '@shared/types'
|
||||
import type { ThemeId, Language, PomodoroDuration } from '@shared/types'
|
||||
import { useSettingsStore } from '@renderer/stores/useSettingsStore'
|
||||
import { ShortcutEditor } from '@renderer/components/settings/ShortcutEditor'
|
||||
import { AiSettingsPage } from '@renderer/components/settings/AiSettingsPage'
|
||||
@@ -159,6 +159,49 @@ export function SettingsPage(): React.JSX.Element {
|
||||
{t('settings.knowledgeAutoExtract')}
|
||||
</label>
|
||||
</div>
|
||||
<div className="setting-item">
|
||||
<span>{t('settings.pomodoroDuration')}</span>
|
||||
<select
|
||||
data-testid="settings-pomodoro-duration"
|
||||
className="form-control form-control--narrow"
|
||||
value={settings.pomodoroDurationMinutes ?? 25}
|
||||
onChange={(e) =>
|
||||
void settings.update({
|
||||
pomodoroDurationMinutes: Number(e.target.value) as PomodoroDuration
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value={15}>15</option>
|
||||
<option value={25}>25</option>
|
||||
<option value={45}>45</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="setting-item">
|
||||
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
data-testid="settings-system-notifications"
|
||||
checked={settings.enableSystemNotifications === true}
|
||||
onChange={(e) =>
|
||||
void settings.update({ enableSystemNotifications: e.target.checked })
|
||||
}
|
||||
/>
|
||||
{t('settings.systemNotifications')}
|
||||
</label>
|
||||
</div>
|
||||
<div className="setting-item">
|
||||
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
data-testid="settings-goal-notifications"
|
||||
checked={settings.enableGoalNotifications !== false}
|
||||
onChange={(e) =>
|
||||
void settings.update({ enableGoalNotifications: e.target.checked })
|
||||
}
|
||||
/>
|
||||
{t('settings.goalNotifications')}
|
||||
</label>
|
||||
</div>
|
||||
<div className="setting-item">
|
||||
<span>{t('settings.extractThreshold')}</span>
|
||||
<input
|
||||
@@ -185,7 +228,7 @@ export function SettingsPage(): React.JSX.Element {
|
||||
{section === 'shortcuts' && <ShortcutEditor />}
|
||||
{section === 'about' && (
|
||||
<p style={{ color: 'var(--text-secondary)', lineHeight: 1.8 }}>
|
||||
{t('app.name')} v0.8.0
|
||||
{t('app.name')} v0.9.0
|
||||
<br />
|
||||
{t('app.tagline')}
|
||||
</p>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { create } from 'zustand'
|
||||
import type {
|
||||
CreateKnowledgeInput,
|
||||
KnowledgeEntry,
|
||||
KnowledgeInjectionLog,
|
||||
KnowledgeStatus,
|
||||
KnowledgeType
|
||||
} from '@shared/types'
|
||||
@@ -17,7 +18,9 @@ interface KnowledgeState {
|
||||
forgottenOnly: boolean
|
||||
editorOpen: boolean
|
||||
editingId: string | null
|
||||
injectionPreviews: Record<string, KnowledgeInjectionLog[]>
|
||||
load: (bookId: string) => Promise<void>
|
||||
loadInjectionPreviews: (bookId: string, entryIds: string[]) => Promise<void>
|
||||
setTab: (tab: KnowledgeTab) => void
|
||||
openForgottenFilter: () => void
|
||||
openEditor: (id?: string | null) => void
|
||||
@@ -46,6 +49,7 @@ export const useKnowledgeStore = create<KnowledgeState>((set, get) => ({
|
||||
forgottenOnly: false,
|
||||
editorOpen: false,
|
||||
editingId: null,
|
||||
injectionPreviews: {},
|
||||
load: async (bookId) => {
|
||||
const [entries, stats] = await Promise.all([
|
||||
ipcCall(() => window.electronAPI.knowledge.list(bookId)),
|
||||
@@ -53,6 +57,21 @@ export const useKnowledgeStore = create<KnowledgeState>((set, get) => ({
|
||||
])
|
||||
set({ entries, stats })
|
||||
},
|
||||
loadInjectionPreviews: async (bookId, entryIds) => {
|
||||
if (entryIds.length === 0) {
|
||||
set({ injectionPreviews: {} })
|
||||
return
|
||||
}
|
||||
const pairs = await Promise.all(
|
||||
entryIds.map(async (id) => {
|
||||
const logs = await ipcCall(() =>
|
||||
window.electronAPI.knowledge.listInjections(bookId, id, 3)
|
||||
)
|
||||
return [id, logs] as const
|
||||
})
|
||||
)
|
||||
set({ injectionPreviews: Object.fromEntries(pairs) })
|
||||
},
|
||||
setTab: (tab) => set({ tab, forgottenOnly: tab === 'foreshadow' ? get().forgottenOnly : false }),
|
||||
openForgottenFilter: () => {
|
||||
useAppStore.getState().setRightPanel('knowledge')
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import { create } from 'zustand'
|
||||
import type { PomodoroState } from '@shared/types'
|
||||
import { ipcCall } from '@renderer/lib/ipc-client'
|
||||
|
||||
interface PomodoroStore extends PomodoroState {
|
||||
tickUnsub: (() => void) | null
|
||||
init: () => Promise<void>
|
||||
start: (bookId: string) => Promise<void>
|
||||
pause: () => Promise<void>
|
||||
resume: () => Promise<void>
|
||||
cancel: () => Promise<void>
|
||||
applyState: (state: PomodoroState) => void
|
||||
}
|
||||
|
||||
const idle: PomodoroState = { running: false, paused: false, remainingSec: 0, bookId: null }
|
||||
|
||||
export const usePomodoroStore = create<PomodoroStore>((set, get) => ({
|
||||
...idle,
|
||||
tickUnsub: null,
|
||||
init: async () => {
|
||||
const state = await ipcCall(() => window.electronAPI.pomodoro.getState())
|
||||
set(state)
|
||||
if (!get().tickUnsub) {
|
||||
const unsub = window.electronAPI.onPomodoroTick((next) => {
|
||||
set(next)
|
||||
})
|
||||
set({ tickUnsub: unsub })
|
||||
}
|
||||
},
|
||||
applyState: (state) => set(state),
|
||||
start: async (bookId) => {
|
||||
const state = await ipcCall(() => window.electronAPI.pomodoro.start(bookId))
|
||||
set(state)
|
||||
},
|
||||
pause: async () => {
|
||||
const state = await ipcCall(() => window.electronAPI.pomodoro.pause())
|
||||
set(state)
|
||||
},
|
||||
resume: async () => {
|
||||
const state = await ipcCall(() => window.electronAPI.pomodoro.resume())
|
||||
set(state)
|
||||
},
|
||||
cancel: async () => {
|
||||
const state = await ipcCall(() => window.electronAPI.pomodoro.cancel())
|
||||
set(state)
|
||||
}
|
||||
}))
|
||||
|
||||
export function formatPomodoroTime(sec: number): string {
|
||||
const m = Math.floor(sec / 60)
|
||||
const s = sec % 60
|
||||
return `${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`
|
||||
}
|
||||
@@ -26,6 +26,9 @@ export const useSettingsStore = create<SettingsState>((set, get) => ({
|
||||
knowledgeSuggestTopN: 8,
|
||||
knowledgeAutoExtract: true,
|
||||
knowledgeExtractConfidenceThreshold: 0.8,
|
||||
pomodoroDurationMinutes: 25,
|
||||
enableSystemNotifications: false,
|
||||
enableGoalNotifications: true,
|
||||
loaded: false,
|
||||
load: async () => {
|
||||
const data = await ipcCall(() => window.electronAPI.settings.get())
|
||||
|
||||
@@ -909,6 +909,108 @@
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.pomodoro-control {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.pomodoro-btn {
|
||||
background: transparent;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
color: var(--text-secondary);
|
||||
cursor: pointer;
|
||||
font-size: 11px;
|
||||
line-height: 1;
|
||||
padding: 2px 6px;
|
||||
}
|
||||
|
||||
.pomodoro-btn:hover:not(:disabled) {
|
||||
border-color: var(--accent);
|
||||
color: var(--accent-light);
|
||||
}
|
||||
|
||||
.pomodoro-btn:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.pomodoro-time {
|
||||
font-variant-numeric: tabular-nums;
|
||||
min-width: 42px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.cockpit-achievements-section {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.cockpit-achievements {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.cockpit-achievement-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 6px 10px;
|
||||
border-radius: 8px;
|
||||
font-size: 13px;
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.cockpit-achievement-badge.unlocked {
|
||||
background: var(--bg-tertiary);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.cockpit-achievement-badge.locked {
|
||||
opacity: 0.35;
|
||||
filter: grayscale(1);
|
||||
}
|
||||
|
||||
.cockpit-pomodoro-today {
|
||||
margin-top: 12px;
|
||||
font-size: 13px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.kb-injection-preview,
|
||||
.knowledge-injection-history {
|
||||
margin-top: 8px;
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.kb-injection-label {
|
||||
font-weight: 600;
|
||||
margin-bottom: 4px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.kb-injection-preview-row,
|
||||
.kb-injection-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
align-items: center;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.kb-injection-chapter-link {
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--accent-light);
|
||||
cursor: pointer;
|
||||
font-size: inherit;
|
||||
padding: 0;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.kb-confidence-badge {
|
||||
margin-left: 8px;
|
||||
font-size: 11px;
|
||||
|
||||
Vendored
+23
-1
@@ -44,7 +44,12 @@ import type {
|
||||
ChapterBridgeResult,
|
||||
PublishStatus,
|
||||
WritingStats,
|
||||
KnowledgeExtractionResult
|
||||
KnowledgeExtractionResult,
|
||||
PomodoroState,
|
||||
GoalNotificationPayload,
|
||||
KnowledgeInjectionLog,
|
||||
WritingAchievement,
|
||||
PomodoroDuration
|
||||
} from './types'
|
||||
|
||||
export interface ElectronAPI {
|
||||
@@ -358,10 +363,25 @@ export interface ElectronAPI {
|
||||
approveMerge: (bookId: string, pendingId: string) => Promise<IpcResult<KnowledgeEntry>>
|
||||
saveMergeAsNew: (bookId: string, pendingId: string) => Promise<IpcResult<KnowledgeEntry>>
|
||||
batchApproveHighConfidence: (bookId: string, threshold?: number) => Promise<IpcResult<number>>
|
||||
listInjections: (
|
||||
bookId: string,
|
||||
entryId: string,
|
||||
limit?: number
|
||||
) => Promise<IpcResult<KnowledgeInjectionLog[]>>
|
||||
}
|
||||
writing: {
|
||||
getStats: (bookId: string) => Promise<IpcResult<WritingStats>>
|
||||
}
|
||||
pomodoro: {
|
||||
start: (bookId: string) => Promise<IpcResult<PomodoroState>>
|
||||
pause: () => Promise<IpcResult<PomodoroState>>
|
||||
resume: () => Promise<IpcResult<PomodoroState>>
|
||||
cancel: () => Promise<IpcResult<PomodoroState>>
|
||||
getState: () => Promise<IpcResult<PomodoroState>>
|
||||
}
|
||||
achievement: {
|
||||
list: (bookId: string) => Promise<IpcResult<WritingAchievement[]>>
|
||||
}
|
||||
cockpit: {
|
||||
getSummary: (bookId: string, volumeId?: string) => Promise<IpcResult<CockpitSummary>>
|
||||
markSeen: (bookId: string) => Promise<IpcResult<void>>
|
||||
@@ -390,6 +410,8 @@ export interface ElectronAPI {
|
||||
onAiStreamChunk: (callback: (payload: AiStreamChunkEvent) => void) => () => void
|
||||
onAiNetworkStatus: (callback: (payload: AiNetworkStatusEvent) => void) => () => void
|
||||
onInteractiveStreamChunk: (callback: (payload: InteractiveStreamChunkEvent) => void) => () => void
|
||||
onPomodoroTick: (callback: (state: PomodoroState) => void) => () => void
|
||||
onGoalNotification: (callback: (payload: GoalNotificationPayload) => void) => () => void
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -117,6 +117,15 @@ export const IPC = {
|
||||
KNOWLEDGE_SAVE_MERGE_AS_NEW: 'knowledge:saveMergeAsNew',
|
||||
KNOWLEDGE_BATCH_APPROVE_HIGH_CONFIDENCE: 'knowledge:batchApproveHighConfidence',
|
||||
WRITING_GET_STATS: 'writing:getStats',
|
||||
POMODORO_START: 'pomodoro:start',
|
||||
POMODORO_PAUSE: 'pomodoro:pause',
|
||||
POMODORO_RESUME: 'pomodoro:resume',
|
||||
POMODORO_CANCEL: 'pomodoro:cancel',
|
||||
POMODORO_GET_STATE: 'pomodoro:getState',
|
||||
POMODORO_TICK: 'pomodoro:tick',
|
||||
ACHIEVEMENT_LIST: 'achievement:list',
|
||||
KNOWLEDGE_LIST_INJECTIONS: 'knowledge:listInjections',
|
||||
GOAL_NOTIFICATION: 'goal:notification',
|
||||
COCKPIT_SUMMARY: 'cockpit:summary',
|
||||
COCKPIT_MARK_SEEN: 'cockpit:markSeen',
|
||||
COCKPIT_SHOULD_SHOW: 'cockpit:shouldShowOnOpen',
|
||||
|
||||
@@ -94,6 +94,8 @@ export interface CockpitSummary {
|
||||
foreshadowResolved: number
|
||||
foreshadowForgotten: number
|
||||
writingStats?: WritingStats
|
||||
achievements?: WritingAchievement[]
|
||||
pomodoroTodayCount?: number
|
||||
}
|
||||
|
||||
export interface WritingDayLog {
|
||||
@@ -127,6 +129,37 @@ export interface KnowledgeExtractionResult {
|
||||
items: ExtractedKnowledgeItem[]
|
||||
}
|
||||
|
||||
export type PomodoroDuration = 15 | 25 | 45
|
||||
export type WritingMilestone = 'streak_7' | 'streak_30' | 'streak_100'
|
||||
export type InjectionFlowMode = 'interactive' | 'auto' | 'wizard'
|
||||
|
||||
export interface PomodoroState {
|
||||
running: boolean
|
||||
paused: boolean
|
||||
remainingSec: number
|
||||
bookId: string | null
|
||||
}
|
||||
|
||||
export interface WritingAchievement {
|
||||
milestone: WritingMilestone
|
||||
unlockedAt: string
|
||||
}
|
||||
|
||||
export interface KnowledgeInjectionLog {
|
||||
id: string
|
||||
knowledgeEntryId: string
|
||||
flowMode: InjectionFlowMode
|
||||
flowId: string
|
||||
chapterId?: string
|
||||
injectedAt: string
|
||||
}
|
||||
|
||||
export interface GoalNotificationPayload {
|
||||
kind: 'daily_met' | 'milestone' | 'pomodoro_complete' | 'pomodoro_cancelled_book_switch'
|
||||
messageKey: string
|
||||
messageParams?: Record<string, string | number>
|
||||
}
|
||||
|
||||
export interface ChapterBridgeResult {
|
||||
previousChapterId: string | null
|
||||
previousTail: string
|
||||
@@ -171,6 +204,10 @@ export interface GlobalSettings {
|
||||
knowledgeSuggestTopN?: number
|
||||
knowledgeAutoExtract?: boolean
|
||||
knowledgeExtractConfidenceThreshold?: number
|
||||
pomodoroDurationMinutes?: PomodoroDuration
|
||||
enableSystemNotifications?: boolean
|
||||
enableGoalNotifications?: boolean
|
||||
dailyGoalNotifiedDate?: string
|
||||
}
|
||||
|
||||
export interface BookMeta {
|
||||
|
||||
Reference in New Issue
Block a user