Skip to content

Commit 7955c64

Browse files
Jiajun0413mhenke
authored andcommitted
style: biome format unify-PR files
1 parent cec668e commit 7955c64

7 files changed

Lines changed: 81 additions & 34 deletions

src/hooks/task-session-manager/board-injection.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ import {
2626
parseTaskStateFromOutput,
2727
parseTaskStatusOutput,
2828
renderRunningTaskPlaceholder,
29-
renderTaskTerminalFromBoard,
3029
renderTaskCompletedWithText,
30+
renderTaskTerminalFromBoard,
3131
} from '../../utils';
32-
import { extractSessionResult } from '../../utils/session';
3332
import { isRecord } from '../../utils/guards';
3433
import { log } from '../../utils/logger';
34+
import { extractSessionResult } from '../../utils/session';
3535
import {
3636
appendTaggedSyntheticPart,
3737
appendTrailingVolatileMessage,
@@ -676,7 +676,7 @@ export async function reconcileFalseCompleteFallback(
676676
if (typeof partState.output !== 'string') continue;
677677

678678
const status = parseTaskStatusOutput(partState.output);
679-
if (!status || status.state !== 'completed') continue;
679+
if (status?.state !== 'completed') continue;
680680
// Only reconcile empty results — real completions are intact.
681681
if (status.result && status.result.trim().length > 0) continue;
682682

src/hooks/task-session-manager/fallback-false-cancel.test.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ const PARENT = 'parent-1';
66
const CHILD = 'child-1';
77

88
function createHook(board: BackgroundJobBoard) {
9-
return createTaskSessionManagerHook(
10-
{ client: { session: {} } } as never,
11-
{
12-
maxSessionsPerAgent: 2,
13-
maxRetainedSnapshots: 2,
14-
backgroundJobBoard: board,
15-
shouldManageSession: () => true,
16-
},
17-
);
9+
return createTaskSessionManagerHook({ client: { session: {} } } as never, {
10+
maxSessionsPerAgent: 2,
11+
maxRetainedSnapshots: 2,
12+
backgroundJobBoard: board,
13+
shouldManageSession: () => true,
14+
});
1815
}
1916

2017
/**
@@ -62,15 +59,22 @@ function userMessage(id: string, text: string) {
6259
function findTaskPart(messages: unknown[], callID: string) {
6360
for (const message of messages as { parts?: any[] }[]) {
6461
for (const part of message?.parts ?? []) {
65-
if (part?.type === 'tool' && part?.tool === 'task' && part?.callID === callID) {
62+
if (
63+
part?.type === 'tool' &&
64+
part?.tool === 'task' &&
65+
part?.callID === callID
66+
) {
6667
return part;
6768
}
6869
}
6970
}
7071
return undefined;
7172
}
7273

73-
async function transform(hook: ReturnType<typeof createTaskSessionManagerHook>, history: unknown[]) {
74+
async function transform(
75+
hook: ReturnType<typeof createTaskSessionManagerHook>,
76+
history: unknown[],
77+
) {
7478
const request = { messages: structuredClone(history) };
7579
await hook['experimental.chat.messages.transform']({}, request as never);
7680
return request.messages;
@@ -237,7 +241,12 @@ describe('reconcileFallbackFalseCancel', () => {
237241
const history = [
238242
userMessage('u1', 'fix the bug'),
239243
{
240-
info: { role: 'assistant', agent: 'orchestrator', sessionID: PARENT, id: 'call-2' },
244+
info: {
245+
role: 'assistant',
246+
agent: 'orchestrator',
247+
sessionID: PARENT,
248+
id: 'call-2',
249+
},
241250
parts: [
242251
{ type: 'text', text: ' ' },
243252
{

src/hooks/task-session-manager/false-complete-fallback.test.ts

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, test, mock } from 'bun:test';
1+
import { describe, expect, mock, test } from 'bun:test';
22
import { BackgroundJobBoard } from '../../utils';
33
import { createTaskSessionManagerHook } from './index';
44

@@ -50,7 +50,11 @@ function userMessage(id: string, text: string) {
5050
function findTaskPart(messages: unknown[], callID: string) {
5151
for (const message of messages as { parts?: any[] }[]) {
5252
for (const part of message?.parts ?? []) {
53-
if (part?.type === 'tool' && part?.tool === 'task' && part?.callID === callID) {
53+
if (
54+
part?.type === 'tool' &&
55+
part?.tool === 'task' &&
56+
part?.callID === callID
57+
) {
5458
return part;
5559
}
5660
}
@@ -67,7 +71,10 @@ async function transform(
6771
return request.messages;
6872
}
6973

70-
function setupCompletedBoard(board: BackgroundJobBoard, description = 'test task') {
74+
function setupCompletedBoard(
75+
board: BackgroundJobBoard,
76+
description = 'test task',
77+
) {
7178
board.registerLaunch({
7279
taskID: CHILD,
7380
parentSessionID: PARENT,
@@ -85,7 +92,10 @@ function setupCompletedBoard(board: BackgroundJobBoard, description = 'test task
8592

8693
function mockClient(
8794
childMessages:
88-
| Array<{ info?: { role: string }; parts?: Array<{ type: string; text?: string }> }>
95+
| Array<{
96+
info?: { role: string };
97+
parts?: Array<{ type: string; text?: string }>;
98+
}>
8999
| (() => Promise<unknown>),
90100
) {
91101
const messages =
@@ -132,7 +142,9 @@ describe('reconcileFalseCompleteFallback', () => {
132142

133143
expect(part.state.status).toBe('completed');
134144
expect(part.state.output).toContain('state="completed"');
135-
expect(part.state.output).toContain('Background task completed: audit DATA.md');
145+
expect(part.state.output).toContain(
146+
'Background task completed: audit DATA.md',
147+
);
136148
expect(part.state.output).toContain('# Audit Report');
137149
expect(part.state.output).toContain('All claims verified.');
138150
});
@@ -141,7 +153,10 @@ describe('reconcileFalseCompleteFallback', () => {
141153
const board = new BackgroundJobBoard();
142154
setupCompletedBoard(board, 'test task');
143155
const childMessages = [
144-
{ info: { role: 'assistant' }, parts: [{ type: 'text', text: 'real output' }] },
156+
{
157+
info: { role: 'assistant' },
158+
parts: [{ type: 'text', text: 'real output' }],
159+
},
145160
];
146161
const hook = createTaskSessionManagerHook(
147162
{ client: mockClient(childMessages), directory: '/tmp' } as never,
@@ -204,7 +219,10 @@ describe('reconcileFalseCompleteFallback', () => {
204219
const board = new BackgroundJobBoard();
205220
setupCompletedBoard(board, 'test task');
206221
const childMessages = [
207-
{ info: { role: 'assistant' }, parts: [{ type: 'text', text: 'real output' }] },
222+
{
223+
info: { role: 'assistant' },
224+
parts: [{ type: 'text', text: 'real output' }],
225+
},
208226
];
209227
const hook = createTaskSessionManagerHook(
210228
{ client: mockClient(childMessages), directory: '/tmp' } as never,
@@ -249,7 +267,12 @@ describe('reconcileFalseCompleteFallback', () => {
249267
const history = [
250268
userMessage('u1', 'run task'),
251269
{
252-
info: { role: 'assistant', agent: 'orchestrator', sessionID: PARENT, id: 'call-2' },
270+
info: {
271+
role: 'assistant',
272+
agent: 'orchestrator',
273+
sessionID: PARENT,
274+
id: 'call-2',
275+
},
253276
parts: [
254277
{ type: 'text', text: ' ' },
255278
{
@@ -258,7 +281,8 @@ describe('reconcileFalseCompleteFallback', () => {
258281
callID: 'call-2',
259282
state: {
260283
status: 'completed',
261-
output: '<task id="child-1" state="completed"><task_result></task_result></task>',
284+
output:
285+
'<task id="child-1" state="completed"><task_result></task_result></task>',
262286
metadata: { sessionId: CHILD },
263287
},
264288
},
@@ -282,7 +306,10 @@ describe('reconcileFalseCompleteFallback', () => {
282306
description: 'still running',
283307
});
284308
const childMessages = [
285-
{ info: { role: 'assistant' }, parts: [{ type: 'text', text: 'partial draft' }] },
309+
{
310+
info: { role: 'assistant' },
311+
parts: [{ type: 'text', text: 'partial draft' }],
312+
},
286313
];
287314
const hook = createTaskSessionManagerHook(
288315
{ client: mockClient(childMessages), directory: '/tmp' } as never,

src/hooks/task-session-manager/idle-reconciliation.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,13 @@ describe('idle reconciliation stop confirmation', () => {
7171
});
7272

7373
test('repeated idle beyond confirmation grace becomes stopped exactly once', async () => {
74-
const { board, reconciler, terminalListener, contextFilesForPrompt, prune } =
75-
createHarness();
74+
const {
75+
board,
76+
reconciler,
77+
terminalListener,
78+
contextFilesForPrompt,
79+
prune,
80+
} = createHarness();
7681
const generation = board.get('child-1')?.generation ?? 1;
7782

7883
await observeIdle(reconciler, 10, generation);

src/hooks/task-session-manager/runtime-status-reconciliation.test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,12 @@ describe('runtime status reconciliation', () => {
287287
});
288288

289289
test('repeated idle beyond confirmation grace becomes stopped exactly once', async () => {
290-
const { board, reconciler, contextFilesForPrompt, prune } = createReconciler(
291-
async () => ({ data: { 'child-1': { type: 'idle' } } }),
292-
undefined,
293-
0,
294-
);
290+
const { board, reconciler, contextFilesForPrompt, prune } =
291+
createReconciler(
292+
async () => ({ data: { 'child-1': { type: 'idle' } } }),
293+
undefined,
294+
0,
295+
);
295296
const listener = mock(() => {});
296297
board.addTerminalStateListener(listener);
297298

src/hooks/task-session-manager/runtime-status-reconciliation.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ export function createRuntimeStatusReconciler(options: {
9797
);
9898
continue;
9999
}
100-
if (status === undefined && snapshot.malformedSessionIDs.has(job.taskID)) {
100+
if (
101+
status === undefined &&
102+
snapshot.malformedSessionIDs.has(job.taskID)
103+
) {
101104
options.backgroundJobBoard.markStatusUncertain(
102105
job.taskID,
103106
'Runtime status response did not contain a recognized session state.',

src/utils/task.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ export function renderTaskTerminalFromBoard(input: {
5959
state === 'completed'
6060
? `Background task completed: ${description}`
6161
: `Background task failed: ${description}`;
62-
const body = resultSummary ?? (state === 'completed' ? 'Task completed.' : 'Task failed.');
62+
const body =
63+
resultSummary ??
64+
(state === 'completed' ? 'Task completed.' : 'Task failed.');
6365
return [
6466
`<task id="${taskID}" state="${state}">`,
6567
`<summary>${summary}</summary>`,

0 commit comments

Comments
 (0)