fix last code rabbit comments

This commit is contained in:
Alan Trebugeais
2026-05-09 00:42:35 +02:00
parent 774fd6a17f
commit 4aeb2b6ee2
2 changed files with 32 additions and 3 deletions
+14 -3
View File
@@ -262,6 +262,11 @@ function ExtensionSettingsSection({
}
if (field.type === "slider") {
const step = field.step ?? 0.01;
const stepText = String(step);
const precision = stepText.includes(".")
? stepText.split(".")[1]?.length ?? 0
: 0;
return (
<div key={field.id} className="mt-1">
<SliderControl
@@ -270,12 +275,12 @@ function ExtensionSettingsSection({
defaultValue={field.defaultValue as number}
min={field.min ?? 0}
max={field.max ?? 1}
step={field.step ?? 0.01}
step={step}
onChange={(v) => {
extensionHost.setExtensionSetting(extensionId, field.id, v);
forceUpdate((n) => n + 1);
}}
formatValue={(v) => v.toFixed(1)}
formatValue={(v) => v.toFixed(precision)}
parseInput={(text) => parseFloat(text)}
/>
</div>
@@ -1552,11 +1557,17 @@ export function SettingsPanel({
};
const resetFrameSection = () => {
const preferredFrame = initialEditorPreferences.frame;
const resolvedFrame = preferredFrame
? availableFrames.some((candidate) => candidate.id === preferredFrame)
? preferredFrame
: null
: null;
onShadowChange?.(initialEditorPreferences.shadowIntensity);
onBorderRadiusChange?.(initialEditorPreferences.borderRadius);
onAspectRatioChange?.(initialEditorPreferences.aspectRatio);
onPaddingChange?.({ ...initialEditorPreferences.padding });
onFrameChange?.(initialEditorPreferences.frame);
onFrameChange?.(resolvedFrame);
removeBackgroundStateRef.current = null;
};
+18
View File
@@ -185,6 +185,14 @@ export class ExtensionHost {
isPlaying: boolean;
} | null = null;
constructor() {
if (typeof window !== "undefined") {
window.addEventListener("beforeunload", () => {
this.flushPersistedSettings();
});
}
}
/**
* Activate an extension given its info and resolved module URL.
*/
@@ -274,6 +282,7 @@ export class ExtensionHost {
}
this.activeExtensions.delete(extensionId);
this.flushPersistedSettings();
this.notifyListeners();
console.log(`[extensions] Deactivated: ${extensionId}`);
}
@@ -286,6 +295,7 @@ export class ExtensionHost {
for (const id of ids) {
await this.deactivateExtension(id);
}
this.flushPersistedSettings();
}
// ---------------------------------------------------------------------------
@@ -619,6 +629,14 @@ export class ExtensionHost {
}, 500);
}
private flushPersistedSettings(): void {
if (this.persistTimeout) {
clearTimeout(this.persistTimeout);
this.persistTimeout = null;
}
this.writePersistedSettingsStore(this.getFullSettingsStore());
}
/**
* Create the permission-gated API object for an extension.
*/