Skip to content

Commit 270e53c

Browse files
committed
[TOOL-4280] Nebula: Send automatic msg after sent transaction is settled (#6843)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR primarily focuses on enhancing the chat and transaction components by adding a `sendMessage` prop and handling transaction settlement events. It improves the interaction between components and provides better logging for transaction settlements. ### Detailed summary - Added `sendMessage` prop to `FloatingChatContent` and `ChatPageContent`. - Introduced `onTxSettled` callback in `ExecuteTransactionCard` and `ExecuteTransactionCardLayout`. - Enhanced `Chats` component to utilize `sendMessage` for transaction confirmations. - Implemented logging for transaction settlements in `ExecuteTransactionCard`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 7809c62 commit 270e53c

File tree

6 files changed

+35
-2
lines changed

6 files changed

+35
-2
lines changed

apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ export function ChatPageContent(props: {
370370
client={client}
371371
enableAutoScroll={enableAutoScroll}
372372
setEnableAutoScroll={setEnableAutoScroll}
373+
sendMessage={handleSendMessage}
373374
/>
374375

375376
<div className="container max-w-[800px]">

apps/dashboard/src/app/nebula-app/(app)/components/Chats.stories.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ function Story() {
192192

193193
<BadgeContainer label="Assistant response With request_id, Without request_id">
194194
<Chats
195+
sendMessage={() => {}}
195196
enableAutoScroll={false}
196197
setEnableAutoScroll={() => {}}
197198
client={storybookThirdwebClient}
@@ -215,6 +216,7 @@ function Story() {
215216

216217
<BadgeContainer label="Assistant markdown">
217218
<Chats
219+
sendMessage={() => {}}
218220
enableAutoScroll={false}
219221
setEnableAutoScroll={() => {}}
220222
client={storybookThirdwebClient}
@@ -249,6 +251,7 @@ function Variant(props: {
249251
enableAutoScroll={false}
250252
setEnableAutoScroll={() => {}}
251253
client={storybookThirdwebClient}
254+
sendMessage={() => {}}
252255
authToken="xxxxx"
253256
isChatStreaming={false}
254257
sessionId="xxxxx"

apps/dashboard/src/app/nebula-app/(app)/components/Chats.tsx

+14-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export function Chats(props: {
5252
setEnableAutoScroll: (enable: boolean) => void;
5353
enableAutoScroll: boolean;
5454
useSmallText?: boolean;
55+
sendMessage: (message: string) => void;
5556
}) {
5657
const { messages, setEnableAutoScroll, enableAutoScroll } = props;
5758
const scrollAnchorRef = useRef<HTMLDivElement>(null);
@@ -169,6 +170,11 @@ export function Chats(props: {
169170
<ExecuteTransactionCardWithFallback
170171
txData={message.data}
171172
client={props.client}
173+
onTxSettled={(txHash) => {
174+
props.sendMessage(
175+
`I've sent the transaction with hash: ${txHash}.`,
176+
);
177+
}}
172178
/>
173179
) : (
174180
<span className="leading-loose">
@@ -206,6 +212,7 @@ export function Chats(props: {
206212
function ExecuteTransactionCardWithFallback(props: {
207213
txData: NebulaTxData | null;
208214
client: ThirdwebClient;
215+
onTxSettled: (txHash: string) => void;
209216
}) {
210217
if (!props.txData) {
211218
return (
@@ -216,7 +223,13 @@ function ExecuteTransactionCardWithFallback(props: {
216223
);
217224
}
218225

219-
return <ExecuteTransactionCard txData={props.txData} client={props.client} />;
226+
return (
227+
<ExecuteTransactionCard
228+
txData={props.txData}
229+
client={props.client}
230+
onTxSettled={props.onTxSettled}
231+
/>
232+
);
220233
}
221234

222235
function MessageActions(props: {

apps/dashboard/src/app/nebula-app/(app)/components/ExecuteTransactionCard.stories.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import type { Meta, StoryObj } from "@storybook/react";
22
import { useState } from "react";
3-
import { BadgeContainer, storybookThirdwebClient } from "stories/utils";
3+
import {
4+
BadgeContainer,
5+
storybookLog,
6+
storybookThirdwebClient,
7+
} from "stories/utils";
48
import { ConnectButton, ThirdwebProvider } from "thirdweb/react";
59
import {
610
ExecuteTransactionCardLayout,
@@ -61,6 +65,9 @@ function Variant(props: {
6165
return (
6266
<BadgeContainer label={props.label}>
6367
<ExecuteTransactionCardLayout
68+
onTxSettled={(txHash) => {
69+
storybookLog(`onTxSettled called with ${txHash}`);
70+
}}
6471
setStatus={setStatus}
6572
status={status}
6673
client={storybookThirdwebClient}

apps/dashboard/src/app/nebula-app/(app)/components/ExecuteTransactionCard.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export type TxStatus =
4949
export function ExecuteTransactionCard(props: {
5050
txData: NebulaTxData;
5151
client: ThirdwebClient;
52+
onTxSettled: (txHash: string) => void;
5253
}) {
5354
const [status, setStatus] = useState<TxStatus>({ type: "idle" });
5455
return (
@@ -57,6 +58,7 @@ export function ExecuteTransactionCard(props: {
5758
client={props.client}
5859
status={status}
5960
setStatus={setStatus}
61+
onTxSettled={props.onTxSettled}
6062
/>
6163
);
6264
}
@@ -66,6 +68,7 @@ export function ExecuteTransactionCardLayout(props: {
6668
client: ThirdwebClient;
6769
status: TxStatus;
6870
setStatus: (status: TxStatus) => void;
71+
onTxSettled: (txHash: string) => void;
6972
}) {
7073
const { theme } = useTheme();
7174
const { txData } = props;
@@ -275,13 +278,18 @@ export function ExecuteTransactionCardLayout(props: {
275278
txHash: confirmReceipt.transactionHash,
276279
});
277280

281+
props.onTxSettled(txHash);
282+
278283
trackEvent({
279284
category: "nebula",
280285
action: "execute_transaction",
281286
label: "confirmed",
282287
chainId: txData.chainId,
283288
});
284289
} catch {
290+
if (txHash) {
291+
props.onTxSettled(txHash);
292+
}
285293
props.setStatus({
286294
type: "failed",
287295
txHash: txHash,

apps/dashboard/src/app/nebula-app/(app)/components/FloatingChat/FloatingChatContent.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ function FloatingChatContentLoggedIn(props: {
189189
enableAutoScroll={enableAutoScroll}
190190
setEnableAutoScroll={setEnableAutoScroll}
191191
useSmallText
192+
sendMessage={handleSendMessage}
192193
/>
193194
)}
194195
<ChatBar

0 commit comments

Comments
 (0)