@@ -1372,6 +1372,109 @@ describe("AgentServer HTTP Mode", () => {
13721372 } ) ;
13731373 } ) ;
13741374
1375+ describe ( "resume prompt display" , ( ) => {
1376+ it ( "hides synthetic resume context while keeping the pending user message visible" , async ( ) => {
1377+ const s = createServer ( ) as unknown as {
1378+ resumeState : ResumeState | null ;
1379+ session : {
1380+ payload : JwtPayload ;
1381+ acpSessionId : string ;
1382+ clientConnection : {
1383+ prompt : ReturnType < typeof vi . fn > ;
1384+ } ;
1385+ logWriter : {
1386+ resetTurnMessages : ReturnType < typeof vi . fn > ;
1387+ appendRawLine : ReturnType < typeof vi . fn > ;
1388+ flushAll : ReturnType < typeof vi . fn > ;
1389+ } ;
1390+ sseController : null ;
1391+ deviceInfo : { type : "cloud" ; name : string } ;
1392+ permissionMode : PermissionMode ;
1393+ hasDesktopConnected : boolean ;
1394+ } ;
1395+ sendResumeMessage (
1396+ payload : JwtPayload ,
1397+ taskRun : TaskRun | null ,
1398+ ) : Promise < void > ;
1399+ } ;
1400+ const payload : JwtPayload = {
1401+ run_id : "test-run-id" ,
1402+ task_id : "test-task-id" ,
1403+ team_id : 1 ,
1404+ user_id : 1 ,
1405+ distinct_id : "test-distinct-id" ,
1406+ mode : "interactive" ,
1407+ } ;
1408+ const prompt = vi . fn ( async ( ) => ( { stopReason : "cancelled" } ) ) ;
1409+ s . session = {
1410+ payload,
1411+ acpSessionId : "acp-session" ,
1412+ clientConnection : { prompt } ,
1413+ logWriter : {
1414+ resetTurnMessages : vi . fn ( ) ,
1415+ appendRawLine : vi . fn ( ) ,
1416+ flushAll : vi . fn ( ) ,
1417+ } ,
1418+ sseController : null ,
1419+ deviceInfo : { type : "cloud" , name : "test-sandbox" } ,
1420+ permissionMode : "bypassPermissions" ,
1421+ hasDesktopConnected : false ,
1422+ } ;
1423+ s . resumeState = {
1424+ conversation : [
1425+ { role : "user" , content : [ { type : "text" , text : "old request" } ] } ,
1426+ {
1427+ role : "assistant" ,
1428+ content : [ { type : "text" , text : "old answer" } ] ,
1429+ } ,
1430+ ] ,
1431+ latestGitCheckpoint : null ,
1432+ interrupted : false ,
1433+ logEntryCount : 2 ,
1434+ sessionId : "prior-session" ,
1435+ } ;
1436+
1437+ await s . sendResumeMessage (
1438+ payload ,
1439+ createTaskRun ( {
1440+ id : "test-run-id" ,
1441+ task : "test-task-id" ,
1442+ state : {
1443+ pending_user_message : "visible follow-up" ,
1444+ pending_user_message_ts : "123.456" ,
1445+ } ,
1446+ } ) ,
1447+ ) ;
1448+
1449+ const [ { prompt : promptBlocks } ] = prompt . mock . calls [ 0 ] as unknown as [
1450+ { prompt : ContentBlock [ ] } ,
1451+ ] ;
1452+ const visibleText = promptBlocks
1453+ . filter (
1454+ ( block ) =>
1455+ block . type === "text" &&
1456+ ! (
1457+ ( block as { _meta ?: { ui ?: { hidden ?: boolean } } } ) . _meta ?. ui
1458+ ?. hidden === true
1459+ ) ,
1460+ )
1461+ . map ( ( block ) => ( block as { text : string } ) . text ) ;
1462+
1463+ expect ( promptBlocks [ 0 ] ) . toMatchObject ( {
1464+ type : "text" ,
1465+ _meta : { ui : { hidden : true } } ,
1466+ } ) ;
1467+ expect ( ( promptBlocks [ 0 ] as { text : string } ) . text ) . toContain (
1468+ "You are resuming a previous conversation" ,
1469+ ) ;
1470+ expect ( visibleText ) . toEqual ( [ "visible follow-up" ] ) ;
1471+ expect ( promptBlocks . at ( - 1 ) ) . toMatchObject ( {
1472+ type : "text" ,
1473+ _meta : { ui : { hidden : true } } ,
1474+ } ) ;
1475+ } ) ;
1476+ } ) ;
1477+
13751478 describe ( "runtime adapter selection" , ( ) => {
13761479 it ( "defaults to claude when no runtime adapter is configured" , ( ) => {
13771480 const s = createServer ( ) ;
0 commit comments