Skip to content

Commit

Permalink
Show all agents, smart sorted, in carousel on home screen of web app (#…
Browse files Browse the repository at this point in the history
…943)

## Overview
Allow quickly selecting, switching agents from agents pane on home page of web app

## Details
- Show all agents in carousel on home screen agent pane of web app
- Smart Sort
  1. Pin default agent as first for ease of access
  2. Show used agents by MRU for ease of access
  3. Shuffle unused agents for discoverability
- Select most recently used agent to chat with by default
- Push smart sort logic down to API
  - Common logic can be reused across clients
  - Agent sort was previously done in web app
- Focus on chat input on agent select
- Double click agent on home page to open edit agent card on agents page
  • Loading branch information
debanjum authored Oct 23, 2024
2 parents 3be505d + 750fbce commit c81e708
Show file tree
Hide file tree
Showing 10 changed files with 1,545 additions and 1,379 deletions.
1,293 changes: 12 additions & 1,281 deletions src/interface/web/app/agents/page.tsx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/interface/web/app/chat/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import "katex/dist/katex.min.css";

import { Context, OnlineContext, StreamMessage } from "../components/chatMessage/chatMessage";
import { useIPLocationData, useIsMobileWidth, welcomeConsole } from "../common/utils";
import ChatInputArea, { ChatOptions } from "../components/chatInputArea/chatInputArea";
import { ChatInputArea, ChatOptions } from "../components/chatInputArea/chatInputArea";
import { useAuthenticatedData } from "../common/auth";
import { AgentData } from "../agents/page";

Expand Down
12 changes: 12 additions & 0 deletions src/interface/web/app/common/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,15 @@ export function useUserConfig(detailed: boolean = false) {

return { userConfig, isLoadingUserConfig };
}

export function isUserSubscribed(userConfig: UserConfig | null): boolean {
return (
(userConfig?.subscription_state &&
[
SubscriptionStates.SUBSCRIBED.valueOf(),
SubscriptionStates.TRIAL.valueOf(),
SubscriptionStates.UNSUBSCRIBED.valueOf(),
].includes(userConfig.subscription_state)) ||
false
);
}
16 changes: 16 additions & 0 deletions src/interface/web/app/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,19 @@ export function useIsMobileWidth() {

return isMobileWidth;
}

export function useDebounce<T>(value: T, delay: number): T {
const [debouncedValue, setDebouncedValue] = useState<T>(value);

useEffect(() => {
const handler = setTimeout(() => {
setDebouncedValue(value);
}, delay);

return () => {
clearTimeout(handler);
};
}, [value, delay]);

return debouncedValue;
}
20 changes: 20 additions & 0 deletions src/interface/web/app/components/agentCard/agentCard.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.agentPersonality p {
white-space: inherit;
overflow: hidden;
height: 77px;
line-height: 1.5;
}

div.agentPersonality {
text-align: left;
grid-column: span 3;
overflow: hidden;
}

button.infoButton {
border: none;
background-color: transparent !important;
text-align: left;
font-family: inherit;
font-size: medium;
}
Loading

0 comments on commit c81e708

Please sign in to comment.