MCPcopy Create free account
hub / github.com/wavetermdev/waveterm / replaceBlock

Function replaceBlock

frontend/app/store/global.ts:426–445  ·  view source on GitHub ↗
(blockId: string, blockDef: BlockDef, focus: boolean)

Source from the content-addressed store, hash-verified

424}
425
426async function replaceBlock(blockId: string, blockDef: BlockDef, focus: boolean): Promise<string> {
427 const layoutModel = getLayoutModelForStaticTab();
428 const rtOpts: RuntimeOpts = { termsize: { rows: 25, cols: 80 } };
429 const newBlockId = await ObjectService.CreateBlock(blockDef, rtOpts);
430 setTimeout(() => {
431 fireAndForget(() => ObjectService.DeleteBlock(blockId));
432 }, 300);
433 const targetNodeId = layoutModel.getNodeByBlockId(blockId)?.id;
434 if (targetNodeId == null) {
435 throw new Error(`targetNodeId not found for blockId: ${blockId}`);
436 }
437 const replaceNodeAction: LayoutTreeReplaceNodeAction = {
438 type: LayoutTreeActionType.ReplaceNode,
439 targetNodeId: targetNodeId,
440 newNode: newLayoutNode(undefined, undefined, undefined, { blockId: newBlockId }),
441 focused: focus,
442 };
443 layoutModel.treeReducer(replaceNodeAction);
444 return newBlockId;
445}
446
447// when file is not found, returns {data: null, fileInfo: null}
448async function fetchWaveFile(

Callers 4

uxCloseBlockFunction · 0.90
genericCloseFunction · 0.90
registerGlobalKeysFunction · 0.90
handleWidgetSelectMethod · 0.90

Calls 7

fireAndForgetFunction · 0.90
newLayoutNodeFunction · 0.85
getNodeByBlockIdMethod · 0.80
treeReducerMethod · 0.80
CreateBlockMethod · 0.45
DeleteBlockMethod · 0.45

Tested by

no test coverage detected