Skip to content
Prev Previous commit
Distinguish in-place progress updates from new phase messages
reportProgress passes an update flag through the callback chain so the
UI updates the existing line in place. reportStart/reportSuccess/emitProgress
create new lines, matching the terminal spinner behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
  • Loading branch information
youknowriad and claude committed Apr 13, 2026
commit 09cf1c15fff32d2c5c1e3dfd7b2fd9fc3cb77a05
4 changes: 2 additions & 2 deletions apps/cli/ai/tests/tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ describe( 'Studio AI MCP tools', () => {

await getTool( 'preview_create' ).handler( { nameOrPath: 'My Site' } as never, null );

expect( previousCallback ).toHaveBeenCalledWith( 'Creating preview…' );
expect( previousCallback ).toHaveBeenCalledWith( 'Almost done…' );
expect( previousCallback ).toHaveBeenCalledWith( 'Creating preview…', undefined );
expect( previousCallback ).toHaveBeenCalledWith( 'Almost done…', undefined );
} );

it( 'rejects shell syntax in wp_cli post content before dispatching to WP-CLI', async () => {
Expand Down
4 changes: 2 additions & 2 deletions apps/cli/ai/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ export async function captureCommandOutput( fn: () => Promise< void > ): Promise
consoleOutput += args.map( String ).join( ' ' ) + '\n';
};
process.exitCode = undefined;
setProgressCallback( ( message ) => {
setProgressCallback( ( message, update ) => {
progressMessages.push( message );
previousCallback?.( message );
previousCallback?.( message, update );
} );

try {
Expand Down
4 changes: 2 additions & 2 deletions apps/cli/ai/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1323,12 +1323,12 @@ export class AiChatUI {

private lastProgressText: Text | null = null;

setLoaderMessage( message: string ): void {
setLoaderMessage( message: string, update?: boolean ): void {
if ( ! message ) {
return;
}
const formatted = ' ' + chalk.dim( '⎿ ' ) + chalk.dim( message );
if ( this.lastProgressText ) {
if ( update && this.lastProgressText ) {
this.lastProgressText.setText( formatted );
} else {
this.lastProgressText = new Text( formatted, 0, 0 );
Expand Down
4 changes: 2 additions & 2 deletions apps/cli/commands/ai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ export async function runCommand(
);
}

setProgressCallback( ( message ) => {
setProgressCallback( ( message, update ) => {
const timestamp = new Date().toISOString();
ui.setLoaderMessage( message );
ui.setLoaderMessage( message, update );
void persist( ( recorder ) => recorder.recordToolProgress( message, timestamp ) );
} );

Expand Down
4 changes: 2 additions & 2 deletions apps/cli/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ora, { Ora } from 'ora';

const isIpcMode = Boolean( process.send );

type ProgressCallback = ( message: string ) => void;
type ProgressCallback = ( message: string, update?: boolean ) => void;
let progressCallback: ProgressCallback | null = null;

export function setProgressCallback( callback: ProgressCallback | null ): void {
Expand Down Expand Up @@ -73,7 +73,7 @@ export class Logger< T extends string > {
}

if ( progressCallback ) {
progressCallback!( message );
progressCallback!( message, true );
return;
}

Expand Down
Loading