mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
Show first user message in resume picker
This commit is contained in:
@@ -152,6 +152,7 @@ export const ResumeSessionPicker: React.FC<ResumeSessionPickerProps> = ({
|
||||
const width = Math.max(40, terminalWidth - 4)
|
||||
const shownStart = filteredSessions.length === 0 ? 0 : scrollOffset + 1
|
||||
const shownEnd = Math.min(filteredSessions.length, scrollOffset + visibleSessions.length)
|
||||
const selectedTitle = selectedSession?.name ?? selectedSession?.summary ?? selectedSession?.sessionId
|
||||
|
||||
return (
|
||||
<Box flexDirection="column" width={terminalWidth}>
|
||||
@@ -181,6 +182,11 @@ export const ResumeSessionPicker: React.FC<ResumeSessionPickerProps> = ({
|
||||
})}
|
||||
</Box>
|
||||
<Box marginTop={1}>
|
||||
<Text color="gray">
|
||||
Title: {selectedTitle ? truncateText(selectedTitle, Math.max(10, terminalWidth - 11)) : '-'}
|
||||
</Text>
|
||||
</Box>
|
||||
<Box>
|
||||
<Text color="gray">
|
||||
Directory: {selectedSession ? truncateText(selectedSession.directory, Math.max(10, terminalWidth - 15)) : '-'}
|
||||
</Text>
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { ResumableSession } from '@hapi/protocol'
|
||||
import {
|
||||
filterResumeSessions,
|
||||
formatResumeSessionRelativeTime,
|
||||
getResumeSessionName,
|
||||
reducePickerState,
|
||||
type PickerState
|
||||
} from './resumeSessionPickerState'
|
||||
@@ -23,6 +24,15 @@ function session(overrides: Partial<ResumableSession>): ResumableSession {
|
||||
}
|
||||
|
||||
describe('resumeSessionPickerState', () => {
|
||||
it('uses the first user message as the list label before title or summary', () => {
|
||||
expect(getResumeSessionName(session({
|
||||
sessionId: 'session-title',
|
||||
name: 'Generated title',
|
||||
summary: 'Generated summary',
|
||||
firstUserMessage: 'First prompt'
|
||||
}))).toBe('First prompt')
|
||||
})
|
||||
|
||||
it('formats updatedAt as relative time', () => {
|
||||
const now = 1_700_000_000_000
|
||||
|
||||
@@ -39,6 +49,7 @@ describe('resumeSessionPickerState', () => {
|
||||
session({
|
||||
sessionId: 'alpha',
|
||||
name: 'Payment Refactor',
|
||||
firstUserMessage: 'Implement billing flow',
|
||||
directory: '/repo/api',
|
||||
agentSessionId: 'thread-a'
|
||||
}),
|
||||
@@ -58,7 +69,7 @@ describe('resumeSessionPickerState', () => {
|
||||
})
|
||||
]
|
||||
|
||||
expect(filterResumeSessions(sessions, 'payment').map((item) => item.sessionId)).toEqual(['alpha'])
|
||||
expect(filterResumeSessions(sessions, 'billing').map((item) => item.sessionId)).toEqual(['alpha'])
|
||||
expect(filterResumeSessions(sessions, 'MOBILE').map((item) => item.sessionId)).toEqual(['beta'])
|
||||
expect(filterResumeSessions(sessions, 'thread-c').map((item) => item.sessionId)).toEqual(['gamma'])
|
||||
expect(filterResumeSessions(sessions, 'remote').map((item) => item.sessionId)).toEqual(['gamma'])
|
||||
|
||||
@@ -17,7 +17,7 @@ export type PickerKey =
|
||||
| 'escape'
|
||||
|
||||
export function getResumeSessionName(session: ResumableSession): string {
|
||||
return session.name ?? session.summary ?? session.sessionId
|
||||
return session.firstUserMessage ?? session.summary ?? session.sessionId
|
||||
}
|
||||
|
||||
export function getResumeSessionState(session: ResumableSession): string {
|
||||
@@ -55,6 +55,7 @@ export function filterResumeSessions(
|
||||
const fields = [
|
||||
session.name,
|
||||
session.summary,
|
||||
session.firstUserMessage,
|
||||
session.sessionId,
|
||||
session.agentSessionId,
|
||||
session.directory,
|
||||
|
||||
Reference in New Issue
Block a user