fix: align headless interactive tool behavior with bidirectional parity (#894)

This commit is contained in:
Charles Packer
2026-02-10 15:20:37 -08:00
committed by GitHub
parent bfd9a1ec56
commit b0783ef195
8 changed files with 178 additions and 37 deletions

View File

@@ -3,7 +3,17 @@
* Exits plan mode - the plan is read from the plan file by the UI
*/
import { permissionMode } from "../../permissions/mode";
export async function exit_plan_mode(): Promise<{ message: string }> {
// In interactive mode, the UI restores mode before calling this tool.
// In headless/bidirectional mode, there is no UI layer to do that, so
// restore here as a fallback to avoid getting stuck in plan mode.
if (permissionMode.getMode() === "plan") {
const restoredMode = permissionMode.getModeBeforePlan() ?? "default";
permissionMode.setMode(restoredMode);
}
// Return confirmation message that plan was approved
// Note: The plan is read from the plan file by the UI before this return is shown
// The UI layer checks if the plan file exists and auto-rejects if not