fix: saving off work
This commit is contained in:
@ -9,6 +9,7 @@ import {
|
|||||||
TEST_COLORS,
|
TEST_COLORS,
|
||||||
commonPoints,
|
commonPoints,
|
||||||
getUtils,
|
getUtils,
|
||||||
|
enableConsoleLogEverything,
|
||||||
} from '@e2e/playwright/test-utils'
|
} from '@e2e/playwright/test-utils'
|
||||||
import { expect, test } from '@e2e/playwright/zoo-test'
|
import { expect, test } from '@e2e/playwright/zoo-test'
|
||||||
|
|
||||||
@ -178,7 +179,19 @@ test.describe('Basic sketch', () => {
|
|||||||
cmdBar,
|
cmdBar,
|
||||||
scene,
|
scene,
|
||||||
editor,
|
editor,
|
||||||
|
tronApp,
|
||||||
}) => {
|
}) => {
|
||||||
|
// await tronApp.cleanProjectDir({
|
||||||
|
// app: {
|
||||||
|
// appearance: {
|
||||||
|
// theme: 'light',
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
enableConsoleLogEverything({
|
||||||
|
page,
|
||||||
|
tronApp,
|
||||||
|
})
|
||||||
await doBasicSketch(page, ['code'], { cmdBar, scene, homePage, editor })
|
await doBasicSketch(page, ['code'], { cmdBar, scene, homePage, editor })
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -188,6 +201,7 @@ test.describe('Basic sketch', () => {
|
|||||||
cmdBar,
|
cmdBar,
|
||||||
scene,
|
scene,
|
||||||
editor,
|
editor,
|
||||||
|
tronApp,
|
||||||
}) => {
|
}) => {
|
||||||
// Load the app with the code panes
|
// Load the app with the code panes
|
||||||
await page.addInitScript(async (persistModelingContext) => {
|
await page.addInitScript(async (persistModelingContext) => {
|
||||||
|
@ -8,10 +8,14 @@ export const TEST_SETTINGS_KEY = '/settings.toml'
|
|||||||
export const TEST_SETTINGS: DeepPartial<Settings> = {
|
export const TEST_SETTINGS: DeepPartial<Settings> = {
|
||||||
app: {
|
app: {
|
||||||
appearance: {
|
appearance: {
|
||||||
theme: Themes.Dark,
|
theme: Themes.Light,
|
||||||
},
|
},
|
||||||
onboarding_status: 'dismissed',
|
onboarding_status: 'dismissed',
|
||||||
show_debug_panel: true,
|
show_debug_panel: true,
|
||||||
|
// Tests were written before this setting existed.
|
||||||
|
// It's true by default because it's a good user experience, but
|
||||||
|
// these tests require it to be false.
|
||||||
|
fixed_size_grid: false,
|
||||||
},
|
},
|
||||||
modeling: {
|
modeling: {
|
||||||
enable_ssao: false,
|
enable_ssao: false,
|
||||||
|
@ -880,10 +880,6 @@ export async function setup(
|
|||||||
},
|
},
|
||||||
...TEST_SETTINGS.project,
|
...TEST_SETTINGS.project,
|
||||||
onboarding_status: 'dismissed',
|
onboarding_status: 'dismissed',
|
||||||
// Tests were written before this setting existed.
|
|
||||||
// It's true by default because it's a good user experience, but
|
|
||||||
// these tests require it to be false.
|
|
||||||
fixed_size_grid: false,
|
|
||||||
},
|
},
|
||||||
project: {
|
project: {
|
||||||
...TEST_SETTINGS.project,
|
...TEST_SETTINGS.project,
|
||||||
|
@ -67,6 +67,7 @@ pub struct Settings {
|
|||||||
#[derive(Debug, Default, Clone, Deserialize, Serialize, JsonSchema, ts_rs::TS, PartialEq, Validate)]
|
#[derive(Debug, Default, Clone, Deserialize, Serialize, JsonSchema, ts_rs::TS, PartialEq, Validate)]
|
||||||
#[ts(export)]
|
#[ts(export)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct AppSettings {
|
pub struct AppSettings {
|
||||||
/// The settings for the appearance of the app.
|
/// The settings for the appearance of the app.
|
||||||
#[serde(default, skip_serializing_if = "is_default")]
|
#[serde(default, skip_serializing_if = "is_default")]
|
||||||
@ -96,7 +97,6 @@ pub struct AppSettings {
|
|||||||
pub show_debug_panel: bool,
|
pub show_debug_panel: bool,
|
||||||
/// If true, the grid cells will be fixed-size, where the width is the user's default length unit.
|
/// If true, the grid cells will be fixed-size, where the width is the user's default length unit.
|
||||||
/// If false, the grid's size will scale as the user zooms in and out.
|
/// If false, the grid's size will scale as the user zooms in and out.
|
||||||
#[serde(default = "make_it_so", skip_serializing_if = "is_default")]
|
|
||||||
pub fixed_size_grid: bool,
|
pub fixed_size_grid: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,10 @@ export async function executeAst({
|
|||||||
path?: string
|
path?: string
|
||||||
}): Promise<ExecutionResult> {
|
}): Promise<ExecutionResult> {
|
||||||
try {
|
try {
|
||||||
|
console.log('YOLO')
|
||||||
const settings = await jsAppSettings()
|
const settings = await jsAppSettings()
|
||||||
|
|
||||||
|
console.log('LANG HELPERS', JSON.stringify(settings, null, 4))
|
||||||
const execState = await rustContext.execute(ast, settings, path)
|
const execState = await rustContext.execute(ast, settings, path)
|
||||||
|
|
||||||
await rustContext.waitForAllEngineCommands()
|
await rustContext.waitForAllEngineCommands()
|
||||||
|
@ -626,6 +626,7 @@ export const readAppSettingsFile = async () => {
|
|||||||
const configToml = await window.electron.readFile(settingsPath, {
|
const configToml = await window.electron.readFile(settingsPath, {
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
})
|
})
|
||||||
|
console.log('config toml', JSON.stringify(configToml, null, 4))
|
||||||
const parsedAppConfig = parseAppSettings(configToml)
|
const parsedAppConfig = parseAppSettings(configToml)
|
||||||
if (err(parsedAppConfig)) {
|
if (err(parsedAppConfig)) {
|
||||||
return Promise.reject(parsedAppConfig)
|
return Promise.reject(parsedAppConfig)
|
||||||
@ -635,6 +636,7 @@ export const readAppSettingsFile = async () => {
|
|||||||
parsedAppConfig.settings?.project?.directory
|
parsedAppConfig.settings?.project?.directory
|
||||||
|
|
||||||
if (hasProjectDirectorySetting) {
|
if (hasProjectDirectorySetting) {
|
||||||
|
console.log('parsed app config', JSON.stringify(parsedAppConfig, null, 4))
|
||||||
return parsedAppConfig
|
return parsedAppConfig
|
||||||
} else {
|
} else {
|
||||||
// inject the default project directory setting
|
// inject the default project directory setting
|
||||||
@ -671,6 +673,7 @@ export const readAppSettingsFile = async () => {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
console.log('MERGED', JSON.stringify(mergedDefaultConfig, null, 4))
|
||||||
return mergedDefaultConfig
|
return mergedDefaultConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,8 @@ export async function getProjectMetaByRouteId(
|
|||||||
: readLocalStorageAppSettingsFile()
|
: readLocalStorageAppSettingsFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('TEST SETTINGS UTILS', JSON.stringify(configuration, null, 4))
|
||||||
|
|
||||||
if (err(configuration)) return Promise.reject(configuration)
|
if (err(configuration)) return Promise.reject(configuration)
|
||||||
|
|
||||||
// Should not be possible but I guess logically it could be
|
// Should not be possible but I guess logically it could be
|
||||||
|
@ -257,6 +257,18 @@ export function createSettings() {
|
|||||||
description: 'Toggle free camera while in sketch mode',
|
description: 'Toggle free camera while in sketch mode',
|
||||||
validate: (v) => typeof v === 'boolean',
|
validate: (v) => typeof v === 'boolean',
|
||||||
}),
|
}),
|
||||||
|
/**
|
||||||
|
* Fixed size grid
|
||||||
|
*/
|
||||||
|
fixedSizeGrid: new Setting<boolean>({
|
||||||
|
defaultValue: true,
|
||||||
|
hideOnLevel:'project',
|
||||||
|
description: 'If true, grid will be a 10x10 grid where each cell is the size of your default length unit. If false, the grid will get bigger as you zoom out and smaller as you zoom in.',
|
||||||
|
validate: (v) => typeof v === 'boolean',
|
||||||
|
commandConfig: {
|
||||||
|
inputType: 'boolean',
|
||||||
|
},
|
||||||
|
}),
|
||||||
onboardingStatus: new Setting<OnboardingStatus>({
|
onboardingStatus: new Setting<OnboardingStatus>({
|
||||||
defaultValue: '',
|
defaultValue: '',
|
||||||
// TODO: this could be better but we don't have a TS side real enum
|
// TODO: this could be better but we don't have a TS side real enum
|
||||||
|
@ -51,6 +51,7 @@ const toUndefinedIfNull = (a: any): OmitNull<any> =>
|
|||||||
export function configurationToSettingsPayload(
|
export function configurationToSettingsPayload(
|
||||||
configuration: DeepPartial<Configuration>
|
configuration: DeepPartial<Configuration>
|
||||||
): DeepPartial<SaveSettingsPayload> {
|
): DeepPartial<SaveSettingsPayload> {
|
||||||
|
console.log('configuration', configuration)
|
||||||
return {
|
return {
|
||||||
app: {
|
app: {
|
||||||
theme: appThemeToTheme(configuration?.settings?.app?.appearance?.theme),
|
theme: appThemeToTheme(configuration?.settings?.app?.appearance?.theme),
|
||||||
@ -66,6 +67,7 @@ export function configurationToSettingsPayload(
|
|||||||
configuration?.settings?.app?.allow_orbit_in_sketch_mode,
|
configuration?.settings?.app?.allow_orbit_in_sketch_mode,
|
||||||
projectDirectory: configuration?.settings?.project?.directory,
|
projectDirectory: configuration?.settings?.project?.directory,
|
||||||
showDebugPanel: configuration?.settings?.app?.show_debug_panel,
|
showDebugPanel: configuration?.settings?.app?.show_debug_panel,
|
||||||
|
fixedSizeGrid: configuration.settings?.app?.fixed_size_grid
|
||||||
},
|
},
|
||||||
modeling: {
|
modeling: {
|
||||||
defaultUnit: configuration?.settings?.modeling?.base_unit,
|
defaultUnit: configuration?.settings?.modeling?.base_unit,
|
||||||
@ -109,6 +111,7 @@ export function settingsPayloadToConfiguration(
|
|||||||
stream_idle_mode: configuration?.app?.streamIdleMode,
|
stream_idle_mode: configuration?.app?.streamIdleMode,
|
||||||
allow_orbit_in_sketch_mode: configuration?.app?.allowOrbitInSketchMode,
|
allow_orbit_in_sketch_mode: configuration?.app?.allowOrbitInSketchMode,
|
||||||
show_debug_panel: configuration?.app?.showDebugPanel,
|
show_debug_panel: configuration?.app?.showDebugPanel,
|
||||||
|
fixed_size_grid: configuration?.app?.fixedSizeGrid
|
||||||
},
|
},
|
||||||
modeling: {
|
modeling: {
|
||||||
base_unit: configuration?.modeling?.defaultUnit,
|
base_unit: configuration?.modeling?.defaultUnit,
|
||||||
@ -327,11 +330,13 @@ export async function loadAndValidateSettings(
|
|||||||
settingsNext.app.projectDirectory.default = await getInitialDefaultDir()
|
settingsNext.app.projectDirectory.default = await getInitialDefaultDir()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("FUCK", appSettingsPayload)
|
||||||
settingsNext = setSettingsAtLevel(
|
settingsNext = setSettingsAtLevel(
|
||||||
settingsNext,
|
settingsNext,
|
||||||
'user',
|
'user',
|
||||||
configurationToSettingsPayload(appSettingsPayload)
|
configurationToSettingsPayload(appSettingsPayload)
|
||||||
)
|
)
|
||||||
|
console.log("FUCK2", settingsNext)
|
||||||
|
|
||||||
// Load the project settings if they exist
|
// Load the project settings if they exist
|
||||||
if (projectPath) {
|
if (projectPath) {
|
||||||
@ -365,10 +370,14 @@ export async function saveSettings(
|
|||||||
await initPromise
|
await initPromise
|
||||||
const onDesktop = isDesktop()
|
const onDesktop = isDesktop()
|
||||||
|
|
||||||
|
console.log('all settings', allSettings)
|
||||||
// Get the user settings.
|
// Get the user settings.
|
||||||
const jsAppSettings = getChangedSettingsAtLevel(allSettings, 'user')
|
const jsAppSettings = getChangedSettingsAtLevel(allSettings, 'user')
|
||||||
|
const DOG = settingsPayloadToConfiguration(jsAppSettings)
|
||||||
|
console.log('CAT',jsAppSettings)
|
||||||
|
console.log("DOG", DOG)
|
||||||
const appTomlString = serializeConfiguration(
|
const appTomlString = serializeConfiguration(
|
||||||
settingsPayloadToConfiguration(jsAppSettings)
|
DOG
|
||||||
)
|
)
|
||||||
if (err(appTomlString)) return
|
if (err(appTomlString)) return
|
||||||
|
|
||||||
@ -542,15 +551,26 @@ export function getSettingInputType(setting: Setting) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const jsAppSettings = async (): Promise<DeepPartial<Configuration>> => {
|
export const jsAppSettings = async (): Promise<DeepPartial<Configuration>> => {
|
||||||
|
console.log("HERE!!!")
|
||||||
let jsAppSettings = default_app_settings()
|
let jsAppSettings = default_app_settings()
|
||||||
|
console.log('old', JSON.stringify(jsAppSettings, null, 4))
|
||||||
|
console.log("NOT HERE!!!")
|
||||||
if (!TEST) {
|
if (!TEST) {
|
||||||
// TODO: https://github.com/KittyCAD/modeling-app/issues/6445
|
// TODO: https://github.com/KittyCAD/modeling-app/issues/6445
|
||||||
const settings = await import('@src/lib/singletons').then((module) =>
|
const settings = await import('@src/lib/singletons').then((module) =>
|
||||||
module.getSettings()
|
module.getSettings()
|
||||||
)
|
)
|
||||||
|
console.log('here1', settings)
|
||||||
if (settings) {
|
if (settings) {
|
||||||
|
console.log('here2', settings)
|
||||||
jsAppSettings = getAllCurrentSettings(settings)
|
jsAppSettings = getAllCurrentSettings(settings)
|
||||||
|
console.log('here3')
|
||||||
|
|
||||||
|
console.log('JS APP SETTINGS', jsAppSettings)
|
||||||
|
console.log('JS APP SETTINGS', settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
console.log('here4')
|
||||||
return settingsPayloadToConfiguration(jsAppSettings)
|
return settingsPayloadToConfiguration(jsAppSettings)
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,7 @@ export const settingsMachine = setup({
|
|||||||
input.rootContext.codeManager.writeCausedByAppCheckedInFileTreeFileSystemWatcher = true
|
input.rootContext.codeManager.writeCausedByAppCheckedInFileTreeFileSystemWatcher = true
|
||||||
const { currentProject, ...settings } = input.context
|
const { currentProject, ...settings } = input.context
|
||||||
|
|
||||||
|
console.log('huh', settings)
|
||||||
const val = await saveSettings(settings, currentProject?.path)
|
const val = await saveSettings(settings, currentProject?.path)
|
||||||
|
|
||||||
if (input.toastCallback) {
|
if (input.toastCallback) {
|
||||||
|
Reference in New Issue
Block a user