fix: resolve scroll flickering on message send and improve thinking state animation (#1333)

This commit is contained in:
josh 2025-11-29 13:02:24 +00:00 committed by GitHub
parent d0b6f37aee
commit a3802348fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 225 additions and 174 deletions

View file

@ -117,4 +117,4 @@ export const titlePrompt = `\n
- you will generate a short title based on the first message a user begins a conversation with
- ensure it is not more than 80 characters long
- the title should be a summary of the user's message
- do not use quotes or colons`
- do not use quotes or colons`;

View file

@ -1,20 +1,24 @@
import { tool } from "ai";
import { z } from "zod";
async function geocodeCity(city: string): Promise<{ latitude: number; longitude: number } | null> {
async function geocodeCity(
city: string
): Promise<{ latitude: number; longitude: number } | null> {
try {
const response = await fetch(
`https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(city)}&count=1&language=en&format=json`
);
if (!response.ok) return null;
if (!response.ok) {
return null;
}
const data = await response.json();
if (!data.results || data.results.length === 0) {
return null;
}
const result = data.results[0];
return {
latitude: result.latitude,
@ -26,11 +30,15 @@ async function geocodeCity(city: string): Promise<{ latitude: number; longitude:
}
export const getWeather = tool({
description: "Get the current weather at a location. You can provide either coordinates or a city name.",
description:
"Get the current weather at a location. You can provide either coordinates or a city name.",
inputSchema: z.object({
latitude: z.number().optional(),
longitude: z.number().optional(),
city: z.string().describe("City name (e.g., 'San Francisco', 'New York', 'London')").optional(),
city: z
.string()
.describe("City name (e.g., 'San Francisco', 'New York', 'London')")
.optional(),
}),
execute: async (input) => {
let latitude: number;
@ -50,7 +58,8 @@ export const getWeather = tool({
longitude = input.longitude;
} else {
return {
error: "Please provide either a city name or both latitude and longitude coordinates.",
error:
"Please provide either a city name or both latitude and longitude coordinates.",
};
}
@ -59,11 +68,11 @@ export const getWeather = tool({
);
const weatherData = await response.json();
if ("city" in input) {
weatherData.cityName = input.city;
}
return weatherData;
},
});