Skip to content

Commit 90bf572

Browse files
committed
Add @opentui-ui/toast dependency and integrate toast notifications: include the toast library for user feedback on clipboard actions, replacing previous UI elements for improved user experience.
1 parent 506a1f7 commit 90bf572

File tree

3 files changed

+11
-27
lines changed

3 files changed

+11
-27
lines changed

bun.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@ai-sdk/google": "^3.0.1",
1717
"@ai-sdk/openai": "^3.0.1",
1818
"@ai-sdk/react": "^3.0.3",
19+
"@opentui-ui/toast": "^0.0.3",
1920
"@opentui/core": "^0.1.54",
2021
"@opentui/react": "^0.1.54",
2122
"@types/react": "^19.2.7",

src/index.tsx

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import {
2727
type SubAgentSession,
2828
} from "../tools/index";
2929
import clipboardy from "clipboardy";
30+
import { toast, TOAST_DURATION } from "@opentui-ui/toast";
31+
import { Toaster } from "@opentui-ui/toast/react";
3032

3133
dotenv.config();
3234

@@ -163,9 +165,6 @@ Bun.serve({
163165
onAbort: ({ steps }) => {
164166
console.log("Stream aborted after", steps.length, "steps");
165167
},
166-
onChunk: (chunk) => {
167-
console.log("Chunk:", chunk);
168-
},
169168
providerOptions: {
170169
google: {
171170
thinkingConfig: {
@@ -353,28 +352,24 @@ function SubAgentCard({
353352
function App() {
354353
const inputRef = useRef<any>(null);
355354
const renderer = useRenderer();
356-
const [showCopied, setShowCopied] = useState(false);
357-
const copiedTimeoutRef = useRef<any>(null);
358355

359356
useEffect(() => {
360357
if (!renderer) return;
361358

362359
const handleSelection = async (selection: any) => {
363360
const text = selection.getSelectedText();
361+
console.log("text", text);
364362
if (text) {
365363
await copyToClipboard(text);
366-
setShowCopied(true);
367-
if (copiedTimeoutRef.current) clearTimeout(copiedTimeoutRef.current);
368-
copiedTimeoutRef.current = setTimeout(() => {
369-
setShowCopied(false);
370-
}, 2000);
364+
toast.info("Copied to clipboard!", {
365+
duration: TOAST_DURATION.SHORT,
366+
});
371367
}
372368
};
373369

374370
renderer.on("selection", handleSelection);
375371
return () => {
376372
renderer.off("selection", handleSelection);
377-
if (copiedTimeoutRef.current) clearTimeout(copiedTimeoutRef.current);
378373
};
379374
}, [renderer]);
380375

@@ -556,22 +551,7 @@ function App() {
556551
height="100%"
557552
backgroundColor="#0d0d0d"
558553
>
559-
{showCopied && (
560-
<box
561-
position="absolute"
562-
top={2}
563-
right={3}
564-
width={24}
565-
height={3}
566-
backgroundColor="#1a1a1a"
567-
zIndex={1000}
568-
flexDirection="row"
569-
alignItems="center"
570-
justifyContent="center"
571-
>
572-
<text fg="#9ca3af">Copied to clipboard</text>
573-
</box>
574-
)}
554+
<Toaster position="top-right" />
575555
{/* Output panel - scrollable message area */}
576556
<scrollbox
577557
flexGrow={1}

0 commit comments

Comments
 (0)