Files
goodbuddy/src/shared/application-settings-contracts.ts
T
mesalogo bf1d34e897 feat: configure canvas pages sent for note analysis
Canvas analysis previously sent every page. Add a Magic Notes setting for
1-8 canvas pages, defaulting to 1 for new and historical settings. Select
the first N pages in current canvas order before capture and use the same
text/image range for saved entries, drafts and canvas-source todos.

Keep full 50-page saving/export, expose the same setting through config
tools, and use the shared settings select with an inline help icon.
Include pagination, persistence, production IPC and isolated Electron
regressions, including text-only input and scaled page boundaries.

Validation: focused feature tests and isolated Electron regressions passed;
the final compact UI passed 14 tests. Typecheck and lint were reported
passing by the coordinating agent. No full-suite pass is claimed because
the completed full test command exposed no summary. No live model calls
were made for this commit preparation.

Release note: 魔法笔记新增“发送画布页数”设置,可选 1~8 页,默认 1 页,按当前画布顺序发送前 N 页的文字和图片;标题旁问号可查看说明,保存和导出完整画布不受影响。
2026-09-20 00:07:07 +08:00

115 lines
4.2 KiB
TypeScript

import { z } from 'zod'
import { magicNoteCommentFormatSchema } from './magic-notes-contracts'
import { localToolEnvironmentSettingsSchema } from './local-tool-environment-contracts'
import { modelDownloadSourceSchema } from './model-download-contracts'
import { settingsWarningsSchema } from './settings-warning-contracts'
export {
artifactDownloadSourceSchema,
defaultLocalToolEnvironmentSettings,
localToolEnvironmentSettingsSchema,
localToolExecutablePathSchema,
localToolRuntimeSelectionSchema,
type ArtifactDownloadSource,
type LocalToolEnvironmentSettings,
type LocalToolRuntimeSelection
} from './local-tool-environment-contracts'
export {
modelDownloadSourceSchema,
type ModelDownloadSource
} from './model-download-contracts'
export const magicNoteCommentModeSchema = z.enum([
'immediate',
'after-save-auto',
'after-save-manual'
])
export type MagicNoteCommentMode = z.infer<typeof magicNoteCommentModeSchema>
export const magicNoteCanvasPageCountSchema = z.number().int().min(1).max(8)
export const updateSourceSchema = z.enum(['github', 'mirror'])
export type UpdateSource = z.infer<typeof updateSourceSchema>
export const builtInApplicationIds = ['magic-notes', 'knowledge', 'heartbeat', 'local-inference'] as const
export type BuiltInApplicationId = typeof builtInApplicationIds[number]
export const editableApplicationIds = ['magic-notes', 'local-inference'] as const
export type EditableApplicationId = typeof editableApplicationIds[number]
export const defaultApplicationNavigation = {
order: ['knowledge', 'heartbeat', 'magic-notes', 'local-inference'] as BuiltInApplicationId[],
pinned: { 'magic-notes': true, 'local-inference': false }
}
export const applicationNavigationSchema = z.object({
order: z.array(z.enum(builtInApplicationIds)).length(builtInApplicationIds.length)
.refine(ids => new Set(ids).size === builtInApplicationIds.length, 'Each application must occur exactly once'),
pinned: z.object({
'magic-notes': z.boolean(), 'local-inference': z.boolean()
}).strict()
}).strict()
const applicationPreferencesSchema = z
.object({
checkUpdatesOnStartup: z.boolean(),
updateSource: updateSourceSchema,
modelDownloadSource: modelDownloadSourceSchema,
localToolEnvironment: localToolEnvironmentSettingsSchema,
conversationHtmlRenderingEnabled: z.boolean(),
remoteProjectsEnabled: z.boolean(),
applicationNavigation: applicationNavigationSchema.default(defaultApplicationNavigation),
localInferenceEnabled: z.boolean().default(true),
magicNotesEnabled: z.boolean().default(true),
magicNotesShowIncompleteTodoCount: z.boolean().default(true),
magicNoteCommentMode: magicNoteCommentModeSchema.default('immediate'),
magicNoteCommentFormat: magicNoteCommentFormatSchema.default('combined'),
magicNoteCanvasPageCount: magicNoteCanvasPageCountSchema.default(1)
})
.strict()
export const applicationSettingsSchema = applicationPreferencesSchema
.extend({
warnings: settingsWarningsSchema.optional()
})
.strict()
export const applicationSettingsUpdateSchema = applicationPreferencesSchema
.partial()
.extend({
applicationNavigation: applicationNavigationSchema.optional(),
localInferenceEnabled: z.boolean().optional(),
magicNotesEnabled: z.boolean().optional(),
magicNotesShowIncompleteTodoCount: z.boolean().optional(),
magicNoteCommentMode: magicNoteCommentModeSchema.optional(),
magicNoteCommentFormat: magicNoteCommentFormatSchema.optional(),
magicNoteCanvasPageCount: magicNoteCanvasPageCountSchema.optional()
})
.refine((input) => Object.keys(input).length > 0, {
message: 'At least one application setting is required'
})
export type ApplicationSettings = z.infer<typeof applicationSettingsSchema>
export type ApplicationSettingsUpdate = z.infer<
typeof applicationSettingsUpdateSchema
>
export type VersionCheckFile = {
name: string
size: number
sha256: string
}
export type VersionCheckTarget = {
platform: 'windows' | 'macos' | 'linux'
arch: 'x64' | 'arm64'
formats: string[]
files: VersionCheckFile[]
}
export type VersionCheckResult = {
updateAvailable: boolean
currentVersion: string
latestVersion: string
releaseUrl: string
target: VersionCheckTarget
}