(re)Standardize Session Name Attribute (#5279)

This commit is contained in:
Will Pfleger
2025-10-24 13:34:08 -04:00
committed by GitHub
parent b22abfc623
commit 044b227fdb
29 changed files with 1196 additions and 235 deletions
+1 -1
View File
@@ -174,7 +174,7 @@ function BaseChatContent({
messages,
recipe,
sessionId,
title: session?.description || 'No Session',
name: session?.name || 'No Session',
};
const initialPrompt = messages.length == 0 && recipe?.prompt ? recipe.prompt : '';
@@ -116,16 +116,16 @@ const AppSidebar: React.FC<SidebarProps> = ({ currentPath }) => {
if (
currentPath === '/pair' &&
chatContext?.chat?.title &&
chatContext.chat.title !== DEFAULT_CHAT_TITLE
chatContext?.chat?.name &&
chatContext.chat.name !== DEFAULT_CHAT_TITLE
) {
titleBits.push(chatContext.chat.title);
titleBits.push(chatContext.chat.name);
} else if (currentPath !== '/' && currentItem) {
titleBits.push(currentItem.label);
}
document.title = titleBits.join(' - ');
}, [currentPath, chatContext?.chat?.title]);
}, [currentPath, chatContext?.chat?.name]);
const isActivePath = (path: string) => {
return currentPath === path;
@@ -182,7 +182,7 @@ const SessionHistoryView: React.FC<SessionHistoryViewProps> = ({
config.baseUrl,
session.working_dir,
messages,
session.description || 'Shared Session',
session.name || 'Shared Session',
session.total_tokens || 0
);
@@ -267,7 +267,7 @@ const SessionHistoryView: React.FC<SessionHistoryViewProps> = ({
<div className="flex-1 flex flex-col min-h-0 px-8">
<SessionHeader
onBack={onBack}
title={session.description || 'Session Details'}
title={session.name}
actionButtons={!isLoading ? actionButtons : null}
>
<div className="flex flex-col">
@@ -12,7 +12,7 @@ const SessionItem: React.FC<SessionItemProps> = ({ session, extraActions }) => {
return (
<Card className="p-4 mb-2 hover:bg-accent/50 cursor-pointer flex justify-between items-center">
<div>
<div className="font-medium">{session.description || `Session ${session.id}`}</div>
<div className="font-medium">{session.name}</div>
<div className="text-sm text-muted-foreground">
{formatDate(session.updated_at)} {session.message_count} messages
</div>
@@ -27,7 +27,7 @@ import {
importSession,
listSessions,
Session,
updateSessionDescription,
updateSessionName,
} from '../../api';
interface EditSessionModalProps {
@@ -45,7 +45,7 @@ const EditSessionModal = React.memo<EditSessionModalProps>(
useEffect(() => {
if (session && isOpen) {
setDescription(session.description || session.id);
setDescription(session.name);
} else if (!isOpen) {
// Reset state when modal closes
setDescription('');
@@ -57,16 +57,16 @@ const EditSessionModal = React.memo<EditSessionModalProps>(
if (!session || disabled) return;
const trimmedDescription = description.trim();
if (trimmedDescription === session.description) {
if (trimmedDescription === session.name) {
onClose();
return;
}
setIsUpdating(true);
try {
await updateSessionDescription({
await updateSessionName({
path: { session_id: session.id },
body: { description: trimmedDescription },
body: { name: trimmedDescription },
throwOnError: true,
});
await onSave(session.id, trimmedDescription);
@@ -80,7 +80,7 @@ const EditSessionModal = React.memo<EditSessionModalProps>(
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
console.error('Failed to update session description:', errorMessage);
toast.error(`Failed to update session description: ${errorMessage}`);
setDescription(session.description || session.id);
setDescription(session.name);
} finally {
setIsUpdating(false);
}
@@ -333,7 +333,7 @@ const SessionListView: React.FC<SessionListViewProps> = React.memo(
startTransition(() => {
const searchTerm = caseSensitive ? debouncedSearchTerm : debouncedSearchTerm.toLowerCase();
const filtered = sessions.filter((session) => {
const description = session.description || session.id;
const description = session.name;
const workingDir = session.working_dir;
const sessionId = session.id;
@@ -397,7 +397,7 @@ const SessionListView: React.FC<SessionListViewProps> = React.memo(
const handleModalSave = useCallback(async (sessionId: string, newDescription: string) => {
// Update state immediately for optimistic UI
setSessions((prevSessions) =>
prevSessions.map((s) => (s.id === sessionId ? { ...s, description: newDescription } : s))
prevSessions.map((s) => (s.id === sessionId ? { ...s, name: newDescription } : s))
);
}, []);
@@ -416,7 +416,7 @@ const SessionListView: React.FC<SessionListViewProps> = React.memo(
setShowDeleteConfirmation(false);
const sessionToDeleteId = sessionToDelete.id;
const sessionName = sessionToDelete.description || sessionToDelete.id;
const sessionName = sessionToDelete.name;
setSessionToDelete(null);
try {
@@ -451,7 +451,7 @@ const SessionListView: React.FC<SessionListViewProps> = React.memo(
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `${session.description || session.id}.json`;
a.download = `${session.name}.json`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
@@ -557,9 +557,7 @@ const SessionListView: React.FC<SessionListViewProps> = React.memo(
</div>
<div className="flex-1">
<h3 className="text-base mb-1 pr-16 break-words">
{session.description || session.id}
</h3>
<h3 className="text-base mb-1 pr-16 break-words">{session.name}</h3>
<div className="flex items-center text-text-muted text-xs mb-1">
<Calendar className="w-3 h-3 mr-1 flex-shrink-0" />
@@ -806,7 +804,7 @@ const SessionListView: React.FC<SessionListViewProps> = React.memo(
<ConfirmationModal
isOpen={showDeleteConfirmation}
title="Delete Session"
message={`Are you sure you want to delete the session "${sessionToDelete?.description || sessionToDelete?.id}"? This action cannot be undone.`}
message={`Are you sure you want to delete the session "${sessionToDelete?.name}"? This action cannot be undone.`}
confirmLabel="Delete Session"
cancelLabel="Cancel"
confirmVariant="destructive"
@@ -334,9 +334,7 @@ export function SessionInsights() {
>
<div className="flex items-center space-x-2">
<ChatSmart className="h-4 w-4 text-text-muted" />
<span className="truncate max-w-[300px]">
{session.description || session.id}
</span>
<span className="truncate max-w-[300px]">{session.name}</span>
</div>
<span className="text-text-muted font-mono font-light">
{formatDateOnly(session.updated_at)}
@@ -82,13 +82,14 @@ const SessionsView: React.FC = () => {
selectedSession || {
id: initialSessionId || '',
conversation: [],
description: 'Loading...',
name: 'Loading...',
working_dir: '',
message_count: 0,
total_tokens: 0,
created_at: '',
updated_at: '',
extension_data: {},
user_set_name: false,
}
}
isLoading={isLoadingSession}