-
Notifications
You must be signed in to change notification settings - Fork 283
fix(ui): show current chat title in conversation header #372
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@truefoundry/trueforge-ui': patch | ||
| --- | ||
|
|
||
| Show the current chat title persistently above conversations in every layout. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| 'use client'; | ||
|
|
||
| import { useAuiState } from '../assistant-ui.js'; | ||
| import { cn } from './lib/cn.js'; | ||
|
|
||
| const UNTITLED_CHAT_LABEL = 'New Chat'; | ||
|
|
||
| /** Current chat title shown persistently above the conversation. */ | ||
| export function ChatTitleHeaderLabel({ className }: { className?: string }) { | ||
| const title = useAuiState(state => { | ||
| const { mainThreadId, threadItems } = state.threads; | ||
| return threadItems.find(item => item.id === mainThreadId)?.title; | ||
| }); | ||
| const displayTitle = title?.trim() || UNTITLED_CHAT_LABEL; | ||
|
cursor[bot] marked this conversation as resolved.
|
||
|
|
||
| return ( | ||
| <h1 | ||
| data-slot="aui_chat-title" | ||
| className={cn('min-w-0 flex-1 truncate px-1 text-sm font-medium text-text-primary', className)} | ||
| title={displayTitle} | ||
| > | ||
| {displayTitle} | ||
| </h1> | ||
| ); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Title shown while shell idleMedium Severity
Additional Locations (2)Reviewed by Cursor Bugbot for commit b7ba101. Configure here. |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // @vitest-environment jsdom | ||
| import { render, screen } from '@testing-library/react'; | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| const useAuiState = vi.fn(); | ||
|
|
||
| vi.mock('@/assistant-ui.js', () => ({ | ||
| useAuiState: (selector: (state: unknown) => unknown) => useAuiState(selector), | ||
| })); | ||
|
|
||
| import { ChatTitleHeaderLabel } from '@/atoms/ChatTitleHeaderLabel.js'; | ||
|
|
||
| describe('ChatTitleHeaderLabel', () => { | ||
| beforeEach(() => { | ||
| useAuiState.mockImplementation((selector: (state: unknown) => unknown) => | ||
| selector({ threads: { mainThreadId: 'main', threadItems: [{ id: 'main', title: undefined }] } }), | ||
| ); | ||
| }); | ||
|
|
||
| it('shows a placeholder for an untitled chat', () => { | ||
| render(<ChatTitleHeaderLabel />); | ||
|
|
||
| expect(screen.getByRole('heading', { name: 'New Chat' })).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('shows the current title with truncation and a full-title tooltip', () => { | ||
| const title = 'A very long conversation title that should stay on one line'; | ||
| useAuiState.mockImplementation((selector: (state: unknown) => unknown) => | ||
| selector({ | ||
| threads: { | ||
| mainThreadId: 'active-thread', | ||
| threadItems: [ | ||
| { id: 'other-thread', title: 'Another conversation' }, | ||
| { id: 'active-thread', title }, | ||
| ], | ||
| }, | ||
| }), | ||
| ); | ||
|
|
||
| render(<ChatTitleHeaderLabel />); | ||
|
|
||
| expect(screen.getByRole('heading', { name: title })).toHaveClass('min-w-0', 'flex-1', 'truncate'); | ||
| expect(screen.getByRole('heading', { name: title })).toHaveAttribute('title', title); | ||
| }); | ||
| }); |


Uh oh!
There was an error while loading. Please reload this page.