fix(coding-agent): resolve shell config from session settings

Stop shell resolution from consulting ambient process.cwd() during bash execution and use the active session's shellPath setting instead.

closes #3452
This commit is contained in:
Mario Zechner
2026-04-20 22:32:11 +02:00
parent 5a4e22ea44
commit c40efa9bab
5 changed files with 48 additions and 34 deletions

View File

@@ -72,11 +72,11 @@ export interface BashOperations {
* This is useful for extensions that intercept user_bash and still want pi's
* standard local shell behavior while wrapping or rewriting commands.
*/
export function createLocalBashOperations(): BashOperations {
export function createLocalBashOperations(options?: { shellPath?: string }): BashOperations {
return {
exec: (command, cwd, { onData, signal, timeout, env }) => {
return new Promise((resolve, reject) => {
const { shell, args } = getShellConfig();
const { shell, args } = getShellConfig(options?.shellPath);
if (!existsSync(cwd)) {
reject(new Error(`Working directory does not exist: ${cwd}\nCannot execute bash commands.`));
return;
@@ -154,6 +154,8 @@ export interface BashToolOptions {
operations?: BashOperations;
/** Command prefix prepended to every command (for example shell setup commands) */
commandPrefix?: string;
/** Optional explicit shell path from settings */
shellPath?: string;
/** Hook to adjust command, cwd, or env before execution */
spawnHook?: BashSpawnHook;
}
@@ -272,7 +274,7 @@ export function createBashToolDefinition(
cwd: string,
options?: BashToolOptions,
): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, BashRenderState> {
const ops = options?.operations ?? createLocalBashOperations();
const ops = options?.operations ?? createLocalBashOperations({ shellPath: options?.shellPath });
const commandPrefix = options?.commandPrefix;
const spawnHook = options?.spawnHook;
return {