{"record":{"id":"9c867da8eac91888","repo":"can1357/oh-my-pi","slug":"command-aborted-9c867d","errorCode":null,"errorMessage":"Command aborted","messagePattern":"Command aborted","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/coding-agent/src/extensibility/legacy-pi-coding-agent-shim.ts","lineNumber":391,"sourceCode":"\t};\n\ttry {\n\t\tconst result = await operations.exec(spawn.command, spawn.cwd, {\n\t\t\tonData,\n\t\t\tsignal,\n\t\t\ttimeout,\n\t\t\tenv: spawn.env,\n\t\t});\n\t\tconst snapshot = legacyBashSnapshot(output);\n\t\tconst text = snapshot.text || \"(no output)\";\n\t\tif (result.exitCode !== 0 && result.exitCode !== null) {\n\t\t\tthrow new Error(appendStatus(text, `Command exited with code ${result.exitCode}`));\n\t\t}\n\t\treturn { content: [{ type: \"text\", text }], details: snapshot.details };\n\t} catch (err) {\n\t\tconst snapshot = legacyBashSnapshot(output);\n\t\tconst text = snapshot.text;\n\t\tif (err instanceof Error && err.message === \"aborted\") {\n\t\t\tthrow new Error(appendStatus(text, \"Command aborted\"));\n\t\t}\n\t\tif (err instanceof Error && err.message.startsWith(\"timeout:\")) {\n\t\t\tthrow new Error(appendStatus(text, `Command timed out after ${err.message.slice(\"timeout:\".length)} seconds`));\n\t\t}\n\t\tthrow err;\n\t}\n}\n\n/**\n * Convert an image attachment to PNG using the legacy package-root contract.\n *\n * Invalid or unsupported image data returns `null`, matching Pi's historical\n * helper instead of surfacing Bun's decoder error to extensions.\n */\nexport async function convertToPng(\n\tbase64Data: string,\n\tmimeType: string,\n): Promise<{ data: string; mimeType: string } | null> {","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/extensibility/legacy-pi-coding-agent-shim.ts#L373-L409","documentation":"The legacy bash command was aborted before completion (AbortSignal fired, typically by the user pressing Esc or the agent loop cancelling). The captured output snapshot is preserved with 'Command aborted' appended.","triggerScenarios":"executeLegacyBashOperations' spawn rejects with err.message === 'aborted' because the AbortSignal passed to the spawn was triggered mid-run.","commonSituations":"User interrupts a long-running command from the TUI; agent framework cancels the tool call due to turn abort or timeout of the surrounding request; session shutdown while a command runs.","solutions":["Re-run the command if the abort was unintentional","For long commands, reduce runtime or run in background so aborts are less likely","Avoid issuing user aborts while critical commands run","Handle 'Command aborted' distinctly from failures in agent retry logic (it is a cancellation, not a command error)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isAbort(e: unknown): boolean { return e instanceof Error && e.message.includes('Command aborted'); }","tryCatchPattern":"try { await bashTool.execute({ command }, { signal }); } catch (err) {\n  if (err instanceof Error && err.message.includes('Command aborted')) {\n    return { status: 'cancelled', partialOutput: err.message };\n  }\n  throw err;\n}","preventionTips":["Register AbortSignal handlers and treat aborts as intentional cancellations","Avoid starting long-running commands right before user-facing interactive steps","Break long work into smaller commands so aborts lose less progress","Distinguish aborted (cancel) from non-zero exit (failure) in retry logic"],"tags":["bash","aborted","cancellation","legacy-shim"],"backgroundTag":"command-aborted","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}