Skip to content

refactor(chat): add more info to show in history tab #7966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 21, 2025
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
12 changes: 12 additions & 0 deletions lib/shared/src/chat/transcript/lightweight-history.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { SerializedChatTranscript } from '.'
import type { ChatMessage } from './messages'

/**
* Enum representing the type of chat history.
Expand Down Expand Up @@ -26,6 +27,12 @@ export interface LightweightChatTranscript {

/** The first human message text (used as fallback title) */
firstHumanMessageText?: string

/** The model used for the chat */
model?: string

/** The mode of the chat */
mode?: ChatMessage['intent']
}

/**
Expand All @@ -46,11 +53,16 @@ export function toLightweightChatTranscript(
const firstHumanMessage = transcript.interactions.find(
i => !!transcript.chatTitle || !!i.humanMessage?.editorState
)?.humanMessage
const lastAssistantMessage = transcript.interactions.findLast(
i => !!i.assistantMessage?.model
)?.assistantMessage

return {
id: transcript.id,
chatTitle: transcript.chatTitle || firstHumanMessage?.text,
lastInteractionTimestamp: transcript.lastInteractionTimestamp,
firstHumanMessageText: firstHumanMessage?.text,
model: lastAssistantMessage?.model,
mode: lastAssistantMessage?.intent ?? 'chat',
}
}
2 changes: 1 addition & 1 deletion vscode/src/chat/chat-view/tools/MCPManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export class MCPManager {
}
// Add the connection
const parsedConfig = result.data
await this.connectionManager.addConnection(name, config, parsedConfig?.disabled)
await this.connectionManager.addConnection(name, parsedConfig, parsedConfig?.disabled)
} catch (error) {
logDebug('MCPManager', `Error adding connection for ${name}`, { verbose: { error } })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export enum IntentEnum {
}

// Mapping between ChatMessage intent and IntentEnum for faster lookups
export const INTENT_MAPPING: Record<string, IntentEnum> = {
export const INTENT_MAPPING: Record<NonNullable<ChatMessage['intent']>, IntentEnum> = {
agentic: IntentEnum.Agentic,
chat: IntentEnum.Chat,
search: IntentEnum.Search,
Expand Down Expand Up @@ -135,7 +135,7 @@ export const ModeSelectorField: React.FunctionComponent<{
return
}

if (INTENT_MAPPING[_intent || IntentEnum.Chat] !== currentSelectedIntent) {
if (INTENT_MAPPING[_intent || 'chat'] !== currentSelectedIntent) {
setCurrentSelectedIntent(INTENT_MAPPING[_intent || 'chat'] || IntentEnum.Chat)
}

Expand Down
12 changes: 10 additions & 2 deletions vscode/webviews/tabs/HistoryTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { DownloadIcon, HistoryIcon, MessageSquarePlusIcon, Trash2Icon, TrashIcon
import type React from 'react'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import type { WebviewType } from '../../src/chat/protocol'
import {
INTENT_MAPPING,
IntentEnum,
} from '../chat/cells/messageCell/human/editor/toolbar/ModeSelectorButton'
import { LoadingDots } from '../chat/components/LoadingDots'
import { downloadChatHistory } from '../chat/downloadChatHistory'
import { Button } from '../components/shadcn/ui/button'
Expand Down Expand Up @@ -325,13 +329,14 @@ export const HistoryTabWithData: React.FC<HistoryTabProps & { chats: Lightweight
<CommandList className="tw-flex-1 tw-overflow-y-auto tw-m-2">
{displayedChats.map((chat: LightweightChatTranscript) => {
const id = chat.lastInteractionTimestamp
const chatTitle = chat.chatTitle
const lastMessage = chat.firstHumanMessageText
const chatTitle = chat.chatTitle || lastMessage
// Show the last interaction timestamp in a human-readable format
const timestamp = new Date(chat.lastInteractionTimestamp)
.toLocaleString()
.replace('T', ', ')
.replace('Z', '')
const mode = INTENT_MAPPING[chat.mode || 'chat']

return (
<CommandItem
Expand All @@ -343,9 +348,12 @@ export const HistoryTabWithData: React.FC<HistoryTabProps & { chats: Lightweight
chatID: id,
})
}
title={chat.model}
>
<div className="tw-truncate tw-w-full tw-flex tw-flex-col tw-gap-2">
<div>{chatTitle || lastMessage}</div>
<div>
{mode !== IntentEnum.Chat ? `[${mode}] ${chatTitle}` : chatTitle}
</div>
<div className="tw-text-left tw-text-muted-foreground">{timestamp}</div>
</div>
<Button
Expand Down
Loading