Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions ui/desktop/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4261,13 +4261,11 @@
"properties": {
"totalSessions": {
"type": "integer",
"description": "Total number of sessions",
"minimum": 0
},
"totalTokens": {
"type": "integer",
"format": "int64",
"description": "Total tokens used across all sessions"
"format": "int64"
}
}
},
Expand Down
6 changes: 0 additions & 6 deletions ui/desktop/src/api/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -729,13 +729,7 @@ export type SessionDisplayInfo = {
};

export type SessionInsights = {
/**
* Total number of sessions
*/
totalSessions: number;
/**
* Total tokens used across all sessions
*/
totalTokens: number;
};

Expand Down
30 changes: 13 additions & 17 deletions ui/desktop/src/components/BaseChat2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function BaseChatContent({
useChatStream({
sessionId,
onStreamFinish,
initialMessage,
});

const handleFormSubmit = (e: React.FormEvent) => {
Expand All @@ -87,12 +88,6 @@ function BaseChatContent({
session,
});

useEffect(() => {
if (initialMessage && session && messages.length == 0) {
handleSubmit(initialMessage);
}
}, [initialMessage, session, messages, handleSubmit]);

const recipe = session?.recipe;

useEffect(() => {
Expand Down Expand Up @@ -171,7 +166,8 @@ function BaseChatContent({
</>
);

const showPopularTopics = messages.length === 0;
const showPopularTopics =
messages.length === 0 && !initialMessage && chatState === ChatState.Idle;
// TODO(Douwe): get this from the backend
const isCompacting = false;

Expand All @@ -184,6 +180,15 @@ function BaseChatContent({
};

const initialPrompt = messages.length == 0 && recipe?.prompt ? recipe.prompt : '';

// Map chatState to LoadingGoose message
const getLoadingMessage = (): string | undefined => {
if (isCompacting) return 'goose is compacting the conversation...';
if (messages.length === 0 && chatState === ChatState.Thinking) {
return 'loading conversation...';
}
return undefined;
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I meant to say, but we can maybe do this in some other PR that we should move to a world where the useChatStream determines the chatState and BaseChat does not contain any logic. So isCompacting should just be a chatState, as should loading be. I checked and we are already doing this in the LoadingGoose component, so let's move the messaging we generate to one point

return (
<div className="h-full flex flex-col min-h-0">
<h2>Warning: BaseChat2!</h2>
Expand Down Expand Up @@ -255,16 +260,7 @@ function BaseChatContent({

{(chatState !== ChatState.Idle || isCompacting) && !sessionLoadError && (
<div className="absolute bottom-1 left-4 z-20 pointer-events-none">
<LoadingGoose
message={
messages.length === 0
? 'loading conversation...'
: isCompacting
? 'goose is compacting the conversation...'
: undefined
}
chatState={chatState}
/>
<LoadingGoose message={getLoadingMessage()} chatState={chatState} />
</div>
)}
</div>
Expand Down
Loading