fix(ux): exit YOLO before Shift+Tab or /mode preset switch

Ghost state bug: pressing Shift+Tab or /mode while YOLO was active left
session.yolo=true and settingsManager bypass ON even though mode changed.

- Shift+Tab handler calls s.toggleYolo() + settingsManager.toggleYOLO()
  before cycling to the next preset when YOLO is active
- handleModeCommand does the same before applying a named preset

This keeps yolo flag, status display ('SF — 🚀 YOLO'), and safe-git bypass
in sync with the actual running mode at all times.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Mikael Hugo 2026-05-09 16:56:14 +02:00
parent f7381781fa
commit 38a654d5e4
2 changed files with 14 additions and 0 deletions

View file

@ -437,6 +437,13 @@ function handleModeCommand(args, ctx) {
const name = parts[0].toLowerCase();
const preset = resolvePreset(name);
if (preset) {
// If YOLO is active, exit it first so status and safe-git bypass are cleared
if (s.isYolo()) {
s.toggleYolo();
if (ctx.settingsManager && ctx.settingsManager.toggleYOLO) {
ctx.settingsManager.toggleYOLO();
}
}
const prev = inferPresetName(s.getMode()) ?? s.getMode().workMode;
s.setMode({
workMode: preset.workMode,

View file

@ -49,6 +49,13 @@ export default function steerableAutonomousExtension(api) {
// Outside autonomous: cycle through Ask → Plan → Build presets
try {
const s = getAutoSession();
// If YOLO is active, exit it first so status and git bypass stay consistent
if (s.isYolo()) {
s.toggleYolo();
if (ctx.settingsManager && ctx.settingsManager.toggleYOLO) {
ctx.settingsManager.toggleYOLO();
}
}
const current = inferPresetName(s.getMode()) ?? SF_MODE_PRESET_NAMES[0];
const idx = SF_MODE_PRESET_NAMES.indexOf(current);
const nextName = SF_MODE_PRESET_NAMES[(idx + 1) % SF_MODE_PRESET_NAMES.length];