()
| 68 | |
| 69 | useEffect(() => { |
| 70 | async function loadDiffData() { |
| 71 | const chatId = blockData?.meta?.["aifilediff:chatid"]; |
| 72 | const toolCallId = blockData?.meta?.["aifilediff:toolcallid"]; |
| 73 | const fileName = blockData?.meta?.file; |
| 74 | |
| 75 | if (!chatId || !toolCallId) { |
| 76 | globalStore.set(model.errorAtom, "Missing chatId or toolCallId in block metadata"); |
| 77 | globalStore.set(model.loadingAtom, false); |
| 78 | return; |
| 79 | } |
| 80 | |
| 81 | if (!fileName) { |
| 82 | globalStore.set(model.errorAtom, "Missing file name in block metadata"); |
| 83 | globalStore.set(model.loadingAtom, false); |
| 84 | return; |
| 85 | } |
| 86 | |
| 87 | try { |
| 88 | const result = await model.env.rpc.WaveAIGetToolDiffCommand(TabRpcClient, { |
| 89 | chatid: chatId, |
| 90 | toolcallid: toolCallId, |
| 91 | }); |
| 92 | |
| 93 | if (!result) { |
| 94 | globalStore.set(model.errorAtom, "No diff data returned from server"); |
| 95 | globalStore.set(model.loadingAtom, false); |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | const originalContent = base64ToString(result.originalcontents64); |
| 100 | const modifiedContent = base64ToString(result.modifiedcontents64); |
| 101 | |
| 102 | globalStore.set(model.diffDataAtom, { |
| 103 | original: originalContent, |
| 104 | modified: modifiedContent, |
| 105 | fileName: fileName, |
| 106 | }); |
| 107 | globalStore.set(model.loadingAtom, false); |
| 108 | } catch (e) { |
| 109 | console.error("Error loading diff data:", e); |
| 110 | globalStore.set(model.errorAtom, `Error loading diff data: ${e.message}`); |
| 111 | globalStore.set(model.loadingAtom, false); |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | loadDiffData(); |
| 116 | }, [blockData?.meta?.["aifilediff:chatid"], blockData?.meta?.["aifilediff:toolcallid"], blockData?.meta?.file]); |
no test coverage detected