Skip to content

Commit b939738

Browse files
byapparovclaude
andcommitted
fix(run): scope the headless-run mark to the local execution (#155 review 2)
Enable HeadlessRun just before the in-process bootstrap and disable it when the invocation finishes, so the mark never outlives the run and attach-mode clients (which build no tools) are not marked. Attached servers are tracked in #170. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 1878879 commit b939738

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • packages/cli/src/cli/cmd

‎packages/cli/src/cli/cmd/run.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,6 @@ export const RunCommand = cmd({
393393
})
394394
},
395395
handler: async (args) => {
396-
HeadlessRun.enable()
397396
const invocation = createRunInvocation(args.format === "json")
398397

399398
async function fail(message: string, code: string, exit = 1): Promise<never> {
@@ -1100,6 +1099,8 @@ export const RunCommand = cmd({
11001099
return await invocation.run(() => execute(createAictrlClient({ baseUrl: args.attach, directory })))
11011100
}
11021101

1102+
// Sessions this process serves belong to the headless run until it finishes.
1103+
HeadlessRun.enable()
11031104
const execution = bootstrap(process.cwd(), async () => {
11041105
const sdk = {
11051106
session: {
@@ -1192,6 +1193,6 @@ export const RunCommand = cmd({
11921193
}
11931194
await execute(sdk)
11941195
})
1195-
await invocation.run(execution)
1196+
await invocation.run(execution).finally(() => HeadlessRun.disable())
11961197
},
11971198
})

0 commit comments

Comments
 (0)