feat(webui): add developer settings tools

Expose onboarding replay and page crash testing from a dedicated settings page.\n\nKeep replay actions isolated from persisted consent and password state.
This commit is contained in:
DrSmoothl committed 2026-08-01 00:40:44 +08:00
1 parent 8080104311
commit 958d17ecc0
11 files changed
+365 -29

No files matched your search

@@ -0,0 +1,31 @@
export interface OnboardingActionResult {
success: boolean;
message?: string;
}
export interface OnboardingActions {
acceptAgreements: () => Promise<OnboardingActionResult>;
changePassword: (
oldPassword: string,
newPassword: string,
) => Promise<OnboardingActionResult>;
}
export interface OnboardingExecution {
passwordMode: 'change' | 'rehearsal';
actions: OnboardingActions;
}
const REHEARSAL_ACTIONS: OnboardingActions = {
acceptAgreements: async () => ({ success: true }),
changePassword: async () => ({ success: true }),
};
export function onboardingExecution(
replaying: boolean,
liveActions: OnboardingActions,
): OnboardingExecution {
return replaying
? { passwordMode: 'rehearsal', actions: REHEARSAL_ACTIONS }
: { passwordMode: 'change', actions: liveActions };
}
@@ -0,0 +1,27 @@
export const DEVELOPER_ONBOARDING_URL = '/onboarding?mode=developer';
export const DEVELOPER_SETTINGS_URL = '/settings?tab=developer';
export const DEVELOPER_ONBOARDING_RETURN_KEY = 'snowlumaOnboardingReturnTo';
interface LocationLike {
pathname: string;
search: string;
hash?: string;
}
export function isDeveloperOnboardingLocation(location: LocationLike): boolean {
if (location.pathname !== '/onboarding') return false;
return new URLSearchParams(location.search).get('mode') === 'developer';
}
export function browserPath(location: LocationLike): string {
return `${location.pathname}${location.search}${location.hash ?? ''}`;
}
export function developerOnboardingReturnPath(state: unknown): string | null {
if (typeof state !== 'object' || state === null) return null;
const candidate = (state as Record<string, unknown>)[DEVELOPER_ONBOARDING_RETURN_KEY];
if (typeof candidate !== 'string') return null;
if (!candidate.startsWith('/') || candidate.startsWith('//')) return null;
if (candidate.startsWith('/onboarding')) return null;
return candidate;
}