fix(web): replay the last menu operator for Repeat Last
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

screen.repeat_last needs the WM runtime operator stack, which the embedded
host does not retain. Record the last menu operator and replay it in ?ui=web.
Verified add Circle 7→8; view-layer add/remove still pass.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
mes123456
2026-11-14 06:24:02 +08:00
parent 03c7e4ac74
commit d13cb3eeb1
3 changed files with 14 additions and 13 deletions

View File

@@ -4460,6 +4460,7 @@ export function App({localOnly=false,course}:{localOnly?:boolean;course?:Availab
const [nativeOutput, setNativeOutput] = useState('');
const [nativeFiles, setNativeFiles] = useState<NativeWorkflowFile[]>([]);
const [failedNativeFiles, setFailedNativeFiles] = useState<NativeFileDelivery[]>([]);
const lastMenuOperatorRef = useRef<{ operator: string; properties: Record<string, BlenderOperatorPropertyValue>; areaType?: NativeWorkflowContext['areaType'] } | null>(null);
const [interactiveDesktop,setInteractiveDesktop]=useState<{context:NativeWorkflowContext;command?:Extract<NativeSessionCommand,{kind:'invoke'}>}|null>(null);
const [localInvokePending,setLocalInvokePending]=useState<{expectedActiveObjectId?:string;context:NativeWorkflowContext;command:Extract<NativeSessionCommand,{kind:'invoke'}>}|null>(null);
const [localInvokeActive,setLocalInvokeActive]=useState(false);
@@ -8306,6 +8307,7 @@ else:
void client.invokeEmbeddedOperator({operator,properties,baseRevision,context,native:true}).then(result=>{
if(client!==webClientRef.current||project!==projectIdRef.current)return;
applyNativeScene(result);
lastMenuOperatorRef.current={operator,properties,areaType:context.areaType};
const python=result.operatorResult as {state?:string;error?:string;output?:string}|undefined;
setEngineStatus(python?.state==='DONE'?`原生操作已返回:${operator}`:`原生操作失败:${python?.error||python?.output||operator}`);
}).catch(reason=>{
@@ -8463,7 +8465,7 @@ else:
separator,menuAction('关闭',closeProject,!hasProject),menuAction('退出并保存会话',()=>requestNativeAutosaveOperator('wm.quit_blender'),!hasProject)
],
'编辑':[menuAction('撤销',()=>{void applyEditCommand({type:'undo'});},!hasProject,'Ctrl Z'),menuAction('重做',()=>{void applyEditCommand({type:'redo'});},!hasProject,'Shift Ctrl Z'),menuAction('撤销历史',()=>{void openHistory();},!hasProject),separator,
menuAction('菜单搜索',()=>dispatchUI({type:'toggleOperatorSearch',open:true}),false,'F3'),menuAction('重命名活动项',showRename,!canRenameObject,'F2'),menuAction('调整上一步操作',()=>openAdjustLastOperation(),!hasProject||(!lastNativeOperator&&(localOnly&&!nativeCanvasReady))),menuAction('重复上一步',()=>queueLocalDesktopOperator('screen.repeat_last',{},false,undefined,undefined,'VIEW_3D'),!hasProject||localOnly&&!nativeCanvasReady),menuAction('重复历史',()=>queueLocalDesktopOperator('screen.repeat_history',{},false,undefined,undefined,'VIEW_3D'),!hasProject||localOnly&&!nativeCanvasReady),separator,menuAction('偏好设置',()=>setPreferencesOpen(true))],
menuAction('菜单搜索',()=>dispatchUI({type:'toggleOperatorSearch',open:true}),false,'F3'),menuAction('重命名活动项',showRename,!canRenameObject,'F2'),menuAction('调整上一步操作',()=>openAdjustLastOperation(),!hasProject||(!lastNativeOperator&&(localOnly&&!nativeCanvasReady))),menuAction('重复上一步',()=>{const last=!localOnly?lastMenuOperatorRef.current:null;if(last){queueLocalDesktopOperator(last.operator,last.properties,false,undefined,undefined,last.areaType);return;}queueLocalDesktopOperator('screen.repeat_last',{},false,undefined,undefined,'VIEW_3D');},!hasProject||localOnly&&!nativeCanvasReady),menuAction('重复历史',()=>queueLocalDesktopOperator('screen.repeat_history',{},false,undefined,undefined,'VIEW_3D'),!hasProject||localOnly&&!nativeCanvasReady),separator,menuAction('偏好设置',()=>setPreferencesOpen(true))],
'渲染':[menuAction('渲染图像',()=>renderFromMenu(false),!hasProject,'F12'),menuAction('渲染动画',()=>renderFromMenu(true),!hasProject,'Ctrl F12'),unavailable('渲染音频'),separator,
menuAction('查看渲染结果',()=>dispatchUI({type:'switchWorkspace',workspaceId:'Rendering'}),!hasProject),menuAction('查看动画',()=>dispatchUI({type:'switchWorkspace',workspaceId:'Rendering'}),!nativeFiles.some(f=>f.artifact.mime.startsWith('video/')))],
'场景':[menuAction('新建场景',()=>queueLocalDesktopOperator('scene.new',{type:'NEW'}),!hasProject||localOnly&&!nativeCanvasReady),menuAction('复制场景设置',()=>queueLocalDesktopOperator('scene.new',{type:'COPY_SETTINGS'}),!hasProject||localOnly&&!nativeCanvasReady),separator,menuAction('删除场景',()=>queueLocalDesktopOperator('scene.delete'),!hasProject||localOnly&&!nativeCanvasReady),separator,