Add Khanegi reset-to-default for full ui-config appearance.

Seeds an immutable app+pages snapshot on first open and restores theme, nav, and header from it.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-03 21:13:46 +03:30
co-authored by Cursor
parent d5f0bf84ef
commit f41424ef0d
2 changed files with 133 additions and 18 deletions
+27 -1
View File
@@ -116,4 +116,30 @@ export function createDefaultKhanegiUiConfig() {
}
}
export type UiConfig = ReturnType<typeof createDefaultKhanegiUiConfig>
export type UiConfigBase = ReturnType<typeof createDefaultKhanegiUiConfig>
export type UiConfig = UiConfigBase & {
/** Immutable factory look — set once; never overwrite on normal save */
defaultSnapshot?: {
app: UiConfigBase['app']
pages: Record<string, unknown>
}
}
export function cloneKhanegiAppSnapshot(config: {
app: UiConfigBase['app']
pages?: Record<string, unknown>
}) {
return {
app: JSON.parse(JSON.stringify(config.app)) as UiConfigBase['app'],
pages: JSON.parse(JSON.stringify(config.pages || {})) as Record<string, unknown>,
}
}
/** Strip SuperAdmin-only meta before sending to product apps via /get_user */
export function stripKhanegiSaMeta<T extends Record<string, unknown> | null | undefined>(ui: T): T {
if (!ui || typeof ui !== 'object') return ui
const { defaultSnapshot: _snap, _backfill, ...rest } = ui as Record<string, unknown>
return rest as T
}