@@ -234,6 +234,83 @@ function makeThread(
234234}
235235
236236describe ( "buildThreadFeed" , ( ) => {
237+ it ( "keeps setup failures visible without routine setup notices before or after a turn" , ( ) => {
238+ const thread = makeThread ( {
239+ id : ThreadId . make ( "thread-worktree-setup" ) ,
240+ projectId : ProjectId . make ( "project-1" ) ,
241+ title : "Worktree setup" ,
242+ activities : [
243+ makeActivity ( {
244+ id : EventId . make ( "setup-requested" ) ,
245+ kind : "setup-script.requested" ,
246+ summary : "Starting setup script" ,
247+ createdAt : "2026-08-30T00:00:00.000Z" ,
248+ } ) ,
249+ makeActivity ( {
250+ id : EventId . make ( "setup-started" ) ,
251+ kind : "setup-script.started" ,
252+ summary : "Setup script started" ,
253+ createdAt : "2026-08-30T00:00:01.000Z" ,
254+ } ) ,
255+ makeActivity ( {
256+ id : EventId . make ( "setup-failed" ) ,
257+ kind : "setup-script.failed" ,
258+ summary : "Setup script failed to start" ,
259+ createdAt : "2026-08-30T00:00:02.000Z" ,
260+ tone : "error" ,
261+ payload : { detail : "Setup command was not found" } ,
262+ } ) ,
263+ ] ,
264+ } ) ;
265+ const latestTurn = {
266+ turnId : TurnId . make ( "turn-after-setup" ) ,
267+ state : "running" as const ,
268+ requestedAt : "2026-08-30T00:00:03.000Z" ,
269+ startedAt : "2026-08-30T00:00:04.000Z" ,
270+ completedAt : null ,
271+ assistantMessageId : null ,
272+ } ;
273+
274+ for ( const currentTurn of [ null , latestTurn ] ) {
275+ const feed = buildThreadFeed ( { ...thread , latestTurn : currentTurn } ) ;
276+ expect ( feed ) . toMatchObject ( [
277+ {
278+ type : "activity-group" ,
279+ activities : [ { id : "setup-failed" , status : "failure" } ] ,
280+ } ,
281+ ] ) ;
282+ const group = feed [ 0 ] ;
283+ if ( group ?. type !== "activity-group" ) throw new Error ( "Expected the setup failure group" ) ;
284+ expect ( group . activities [ 0 ] ?. getCopyText ( ) ) . toContain ( "Setup command was not found" ) ;
285+ }
286+ } ) ;
287+
288+ it . each ( [ "setup-script.requested" , "setup-script.started" ] ) (
289+ "keeps error-toned %s notices visible" ,
290+ ( kind ) => {
291+ const feed = buildThreadFeed (
292+ makeThread ( {
293+ id : ThreadId . make ( "thread-setup-error" ) ,
294+ projectId : ProjectId . make ( "project-1" ) ,
295+ title : "Setup error" ,
296+ activities : [
297+ makeActivity ( {
298+ id : EventId . make ( "setup-error" ) ,
299+ kind,
300+ summary : "Setup failed" ,
301+ createdAt : "2026-08-30T00:00:00.000Z" ,
302+ tone : "error" ,
303+ } ) ,
304+ ] ,
305+ } ) ,
306+ ) ;
307+
308+ expect ( feed ) . toMatchObject ( [
309+ { type : "activity-group" , activities : [ { id : "setup-error" , status : "failure" } ] } ,
310+ ] ) ;
311+ } ,
312+ ) ;
313+
237314 it ( "keeps older local feedback before newer messages returned by the server" , ( ) => {
238315 const submission = {
239316 id : MessageId . make ( "feedback-command-ordering" ) ,
0 commit comments