@@ -1673,7 +1673,11 @@ export function deriveMessagesTimelineRows(input: {
16731673 input . worktreeSetup !== undefined &&
16741674 worktreeSetupAgentStarted ( input . worktreeSetup ) &&
16751675 input . latestRun ?. startedAt != null ;
1676- const setupRunning = ! setupHandedOff && input . worktreeSetup ?. phase === "running" ;
1676+ // A finished setup keeps the slot until the turn is live, so the card does
1677+ // not jump above the working header in the gap before the run starts.
1678+ const setupOwnsWorkingSlot =
1679+ ! setupHandedOff &&
1680+ ( input . worktreeSetup ?. phase === "running" || input . worktreeSetup ?. phase === "done" ) ;
16771681 if ( input . worktreeSetup && ( ! setupHandedOff || input . worktreeSetup . phase !== "running" ) ) {
16781682 const setupRow = {
16791683 kind : "worktree-setup" ,
@@ -1688,15 +1692,17 @@ export function deriveMessagesTimelineRows(input: {
16881692 // While the setup runs, the working header leads the card in the same
16891693 // slot it keeps once the agent's own turn takes over. The main pass may
16901694 // already have placed that header (a bootstrap counts as working).
1691- const workingRowIndex = setupRunning ? nextRows . findIndex ( ( row ) => row . kind === "working" ) : - 1 ;
1695+ const workingRowIndex = setupOwnsWorkingSlot
1696+ ? nextRows . findIndex ( ( row ) => row . kind === "working" )
1697+ : - 1 ;
16921698 if ( workingRowIndex >= 0 ) {
16931699 nextRows . splice ( workingRowIndex + 1 , 0 , setupRow ) ;
16941700 } else {
16951701 const insertAt = firstUserRowIndex >= 0 ? firstUserRowIndex + 1 : nextRows . length ;
16961702 nextRows . splice (
16971703 insertAt ,
16981704 0 ,
1699- ...( setupRunning
1705+ ...( setupOwnsWorkingSlot
17001706 ? [
17011707 {
17021708 kind : "working" ,
@@ -1710,15 +1716,15 @@ export function deriveMessagesTimelineRows(input: {
17101716 }
17111717 }
17121718
1713- // A running setup owns the working slot above its card and shows no
1714- // activity row of its own; every other state gets the usual tail.
1719+ // A setup that owns the working slot sits under it and shows no activity
1720+ // row of its own; every other state gets the usual tail.
17151721 const hasWorkingRow = nextRows . some ( ( row ) => row . kind === "working" ) ;
17161722 if ( input . isWorking && ! hasWorkingRow && activeTurnHeaderIndex === timelineEntries . length ) {
17171723 appendWorkingRow ( ) ;
17181724 }
17191725 if (
17201726 input . isWorking &&
1721- ! setupRunning &&
1727+ ! setupOwnsWorkingSlot &&
17221728 ! hasActiveCompaction &&
17231729 ( ! hasActivityRow || latestToolFailed )
17241730 ) {
0 commit comments