fix(builder): update_props no longer wipes style on style: null
style: null fell through the shallow-merge branch's `value && typeof value === 'object'` guard and hit the `p[key] = value` fallback, setting p.style = null and losing every existing style key. Treat style: null (or any other non-object style value) as "ignore this key" instead. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -181,9 +181,16 @@ function applyPatch(
|
||||
// AI usually only means to change one or two style keys, and a
|
||||
// blind Object.assign would clobber every other style the user
|
||||
// (or a previous AI turn) had already set.
|
||||
if (key === 'style' && value && typeof value === 'object' && !Array.isArray(value)) {
|
||||
const existingStyle = p.style && typeof p.style === 'object' ? p.style : {};
|
||||
p.style = { ...existingStyle, ...(value as Record<string, unknown>) };
|
||||
if (key === 'style') {
|
||||
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
||||
const existingStyle = p.style && typeof p.style === 'object' ? p.style : {};
|
||||
p.style = { ...existingStyle, ...(value as Record<string, unknown>) };
|
||||
} else {
|
||||
// `style: null` (or any other non-object) is not a valid
|
||||
// style patch — ignore it rather than clobbering the whole
|
||||
// style object with null/undefined/a stray primitive.
|
||||
console.warn('sitesmith patch: update_props ignoring non-object "style" value', value);
|
||||
}
|
||||
} else {
|
||||
p[key] = value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user