mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-11-01 10:42:23 +01:00
Merge remote-tracking branch 'origin/dev' into fix/editor-followups-20261030
Reconcile branch with current dev (bebf53be).
Resolve conflicts in static/sw.js (bump cache version and preserve panel precache)
and src/ai_interaction.py (preserve upstream quality handling with per-user settings).
Remediate PR #6992 findings:
- A (CI & Playwright): Pin playwright==1.62.0 in requirements-dev and CI workflow; guard browser test imports against pytest runner collection failure.
- B (Per-User Image Model Settings): Support per-user image_model and image_edit_model in editor_image_models() and ai_interaction; enable non-admin preference persistence via /api/prefs fallback.
- C (CodeQL Regex Alert 1212): Replace polynomial-backtracking regex in routes/editor_agent_routes.py with linear token-based intent matcher.
- D (Undo/Redo rembg layer): Clear stale rembgLiveLayer and rembgLiveSnap references in _restoreState() to prevent edge tuner from corrupting detached layers.
This commit is contained in:
@@ -1,21 +1,42 @@
|
||||
import { invalidateSettings } from '../appConfig.js';
|
||||
|
||||
export async function readImagePreferences() {
|
||||
const response = await fetch('/api/auth/settings', { credentials: 'same-origin' });
|
||||
if (!response.ok) throw new Error('Could not load image settings');
|
||||
return response.json();
|
||||
const [prefsRes, settingsRes] = await Promise.all([
|
||||
fetch('/api/prefs', { credentials: 'same-origin' }).catch(() => null),
|
||||
fetch('/api/auth/settings', { credentials: 'same-origin' }).catch(() => null),
|
||||
]);
|
||||
const prefs = (prefsRes && prefsRes.ok) ? await prefsRes.json().catch(() => ({})) : {};
|
||||
const settings = (settingsRes && settingsRes.ok) ? await settingsRes.json().catch(() => ({})) : {};
|
||||
if (!prefsRes?.ok && !settingsRes?.ok) throw new Error('Could not load image settings');
|
||||
return {
|
||||
...settings,
|
||||
image_model: prefs?.image_model || settings?.image_model || '',
|
||||
image_edit_model: prefs?.image_edit_model || settings?.image_edit_model || '',
|
||||
};
|
||||
}
|
||||
|
||||
let saveQueue = Promise.resolve();
|
||||
export function waitForImagePreferences() { return saveQueue; }
|
||||
export function saveImagePreferences(patch) {
|
||||
const save = async () => {
|
||||
const response = await fetch('/api/auth/settings', {
|
||||
let response = await fetch('/api/auth/settings', {
|
||||
method: 'POST', credentials: 'same-origin',
|
||||
headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(patch),
|
||||
});
|
||||
if (!response.ok) throw new Error(response.status === 403
|
||||
? 'Admin access is required to change image settings.' : 'Could not save image settings');
|
||||
if (response.status === 403) {
|
||||
for (const [key, value] of Object.entries(patch)) {
|
||||
const prefRes = await fetch(`/api/prefs/${encodeURIComponent(key)}`, {
|
||||
method: 'PUT', credentials: 'same-origin',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ value }),
|
||||
});
|
||||
if (!prefRes.ok) {
|
||||
throw new Error('Could not save image preferences');
|
||||
}
|
||||
}
|
||||
} else if (!response.ok) {
|
||||
throw new Error('Could not save image settings');
|
||||
}
|
||||
invalidateSettings();
|
||||
window.dispatchEvent(new CustomEvent('image-preferences-changed', { detail: patch }));
|
||||
return response;
|
||||
|
||||
Reference in New Issue
Block a user