@@ -8,10 +8,12 @@ import { prewarmCodeBlocks } from '../CodeBlock';
88
99const mockState = vi . hoisted ( ( ) => ( {
1010 handler : undefined as ( ( value : string ) => void ) | undefined ,
11+ history : [ ] as string [ ] ,
1112 testInput : '' ,
1213 shouldReset : false ,
1314 clear ( ) {
1415 this . handler = undefined ;
16+ this . history = [ ] ;
1517 this . testInput = '' ;
1618 this . shouldReset = true ;
1719 } ,
@@ -92,8 +94,9 @@ vi.mock('../../utils', async () => ({
9294 } ,
9395} ) ) ;
9496
95- vi . mock ( './Input' , ( ) => ( {
96- Input : ( props : {
97+ vi . mock ( './ChatInput' , ( ) => ( {
98+ ChatInput : ( props : {
99+ history ?: string [ ] ;
97100 onSubmit ?: ( value : string ) => void ;
98101 onInterrupt ?: ( ) => void ;
99102 isDisabled ?: boolean ;
@@ -102,6 +105,8 @@ vi.mock('./Input', () => ({
102105 mockState . handler = props . onSubmit ;
103106 }
104107
108+ mockState . history = props . history ?? [ ] ;
109+
105110 if ( props . onInterrupt ) {
106111 interruptState . handler = props . onInterrupt ;
107112 }
@@ -216,6 +221,28 @@ describe('Chat', () => {
216221 expect ( frame ) . toContain ( 'hello' ) ;
217222 } , 10_000 ) ;
218223
224+ it ( 'derives prompt history from user messages and excludes slash commands' , async ( ) => {
225+ render (
226+ < Chat
227+ initialMessages = { [
228+ { role : 'user' , content : 'first prompt' } ,
229+ { role : 'assistant' , content : 'response' } ,
230+ { role : 'user' , content : '/model' } ,
231+ { role : 'user' , content : 'second prompt' } ,
232+ ] }
233+ model = "gemma4"
234+ onCommand = { vi . fn ( ) }
235+ mode = { MODE . SAFE }
236+ onModeChange = { onModeChange }
237+ sessionId = "0"
238+ /> ,
239+ ) ;
240+
241+ await time . tick ( ) ;
242+
243+ expect ( mockState . history ) . toEqual ( [ 'first prompt' , 'second prompt' ] ) ;
244+ } ) ;
245+
219246 it ( 'does not add blank messages' , async ( ) => {
220247 const chat = (
221248 < Chat
0 commit comments