Open History to see the last commit
1import {
2 DEFAULT_GIT_TEXT_GENERATION_MODEL,
3 type NativeApi,
4 type ThreadId,
5} from "@t3tools/contracts";
6
7import { newCommandId } from "./lib/utils";
8
9export async function generateAndRenameThreadTitle(input: {
10 api: NativeApi;
11 threadId: ThreadId;
12 model?: string | null;
13}): Promise<string> {
14 const generated = await input.api.server.generateThreadTitle({
15 threadId: input.threadId,
16 model: input.model ?? DEFAULT_GIT_TEXT_GENERATION_MODEL,
17 });
18
19 await input.api.orchestration.dispatchCommand({
20 type: "thread.meta.update",
21 commandId: newCommandId(),
22 threadId: input.threadId,
23 title: generated.title,
24 titleSummaryState: "generated",
25 });
26
27 return generated.title;
28}