(blockId: string)
| 20 | } |
| 21 | |
| 22 | async captureBlockScreenshot(blockId: string): Promise<string> { |
| 23 | const layoutModel = getLayoutModelForStaticTab(); |
| 24 | if (!layoutModel) { |
| 25 | throw new Error("Layout model not found"); |
| 26 | } |
| 27 | |
| 28 | const node = layoutModel.getNodeByBlockId(blockId); |
| 29 | if (!node) { |
| 30 | throw new Error(`Block not found: ${blockId}`); |
| 31 | } |
| 32 | |
| 33 | const displayContainer = layoutModel.displayContainerRef.current; |
| 34 | if (!displayContainer) { |
| 35 | throw new Error("Display container not found"); |
| 36 | } |
| 37 | |
| 38 | const containerRect = displayContainer.getBoundingClientRect(); |
| 39 | const additionalProps = layoutModel.getNodeAdditionalProperties(node); |
| 40 | |
| 41 | let electronRect: Electron.Rectangle; |
| 42 | |
| 43 | if (!additionalProps?.rect) { |
| 44 | // Bug: rect is not set when there is only one block in the layout |
| 45 | // In this case, use the full container rect |
| 46 | electronRect = { |
| 47 | x: Math.round(containerRect.x), |
| 48 | y: Math.round(containerRect.y), |
| 49 | width: Math.round(containerRect.width), |
| 50 | height: Math.round(containerRect.height), |
| 51 | }; |
| 52 | } else { |
| 53 | const blockRect = additionalProps.rect; |
| 54 | electronRect = { |
| 55 | x: Math.round(containerRect.x + blockRect.left), |
| 56 | y: Math.round(containerRect.y + blockRect.top), |
| 57 | width: Math.round(blockRect.width), |
| 58 | height: Math.round(blockRect.height), |
| 59 | }; |
| 60 | } |
| 61 | |
| 62 | return await getApi().captureScreenshot(electronRect); |
| 63 | } |
| 64 | |
| 65 | async handle_waveaiaddcontext(rh: RpcResponseHelper, data: CommandWaveAIAddContextData): Promise<void> { |
| 66 | const workspaceLayoutModel = WorkspaceLayoutModel.getInstance(); |
no test coverage detected