Skip to content

Commit bf9f269

Browse files
committed
add rename thread ability
1 parent dbd901c commit bf9f269

File tree

1 file changed

+39
-1
lines changed
  • client/packages/lowcoder/src/comps/comps/chatComp/components/assistant-ui

1 file changed

+39
-1
lines changed

client/packages/lowcoder/src/comps/comps/chatComp/components/assistant-ui/thread-list.tsx

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import {
33
ThreadListItemPrimitive,
44
ThreadListPrimitive,
55
} from "@assistant-ui/react";
6-
import { PlusIcon, Trash2Icon } from "lucide-react";
6+
import { PencilIcon, PlusIcon, Trash2Icon } from "lucide-react";
77

88
import { Button } from "../ui/button";
99
import { TooltipIconButton } from "./tooltip-icon-button";
10+
import { useThreadListItemRuntime } from "@assistant-ui/react";
1011

1112
export const ThreadList: FC = () => {
1213
return (
@@ -38,6 +39,7 @@ const ThreadListItem: FC = () => {
3839
<ThreadListItemPrimitive.Trigger className="aui-thread-list-item-trigger">
3940
<ThreadListItemTitle />
4041
</ThreadListItemPrimitive.Trigger>
42+
<ThreadListItemRename />
4143
<ThreadListItemDelete />
4244
</ThreadListItemPrimitive.Root>
4345
);
@@ -63,4 +65,40 @@ const ThreadListItemDelete: FC = () => {
6365
</TooltipIconButton>
6466
</ThreadListItemPrimitive.Delete>
6567
);
68+
};
69+
70+
71+
const ThreadListItemRename: FC = () => {
72+
const runtime = useThreadListItemRuntime();
73+
74+
const handleClick = async () => {
75+
// runtime doesn't expose a direct `title` prop; read it from its state
76+
let current = "";
77+
try {
78+
// getState is part of the public runtime surface
79+
current = (runtime.getState?.() as any)?.title ?? "";
80+
} catch {
81+
// fallback – generate a title if the runtime provides a helper
82+
if (typeof (runtime as any).generateTitle === "function") {
83+
// generateTitle(threadId) in older builds, generateTitle() in newer ones
84+
current = (runtime as any).generateTitle((runtime as any).threadId ?? undefined);
85+
}
86+
}
87+
88+
const next = prompt("Rename thread", current)?.trim();
89+
if (next && next !== current) {
90+
await runtime.rename(next);
91+
}
92+
};
93+
94+
return (
95+
<TooltipIconButton
96+
tooltip="Rename thread"
97+
variant="ghost"
98+
onClick={handleClick}
99+
className="aui-thread-list-item-rename"
100+
>
101+
<PencilIcon />
102+
</TooltipIconButton>
103+
);
66104
};

0 commit comments

Comments
 (0)