Skip to content

Commit ab06897

Browse files
committed
fix(cli): keep agent list working-on column to one line
1 parent 1a52983 commit ab06897

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

packages/cli/src/__tests__/commands/agent.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,27 @@ describe('agent command', () => {
125125
expect(ui.warning).toHaveBeenCalledWith('1 agent(s) waiting for input.');
126126
});
127127

128+
it('truncates working-on text to first line', async () => {
129+
jest.spyOn(Date, 'now').mockReturnValue(new Date('2026-02-26T10:00:00.000Z').getTime());
130+
mockManager.listAgents.mockResolvedValue([
131+
{
132+
name: 'repo-a',
133+
status: AgentStatus.RUNNING,
134+
summary: `Investigating parser bug
135+
Waiting on user input`,
136+
lastActive: new Date('2026-02-26T09:58:00.000Z'),
137+
pid: 100,
138+
},
139+
]);
140+
141+
const program = new Command();
142+
registerAgentCommand(program);
143+
await program.parseAsync(['node', 'test', 'agent', 'list']);
144+
145+
const tableArg: any = (ui.table as any).mock.calls[0][0];
146+
expect(tableArg.rows[0][2]).toBe('Investigating parser bug');
147+
});
148+
128149
it('shows available agents when open target is not found', async () => {
129150
mockManager.listAgents.mockResolvedValue([
130151
{ name: 'repo-a', status: AgentStatus.RUNNING, summary: 'A', lastActive: new Date(), pid: 1 },

packages/cli/src/commands/agent.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ function formatRelativeTime(timestamp: Date): string {
3737
return `${diffDays}d ago`;
3838
}
3939

40+
function formatWorkOn(summary?: string): string {
41+
const firstLine = (summary ?? '').split(/\r?\n/, 1)[0] || '';
42+
return firstLine || 'No active task';
43+
}
44+
4045
export function registerAgentCommand(program: Command): void {
4146
const agentCommand = program
4247
.command('agent')
@@ -72,7 +77,7 @@ export function registerAgentCommand(program: Command): void {
7277
const rows = agents.map(agent => [
7378
agent.name,
7479
formatStatus(agent.status),
75-
agent.summary || 'No active task',
80+
formatWorkOn(agent.summary),
7681
formatRelativeTime(agent.lastActive)
7782
]);
7883

0 commit comments

Comments
 (0)