From d8c687702bf1fb751126a567367077a0a0ea820d Mon Sep 17 00:00:00 2001 From: Mikael Hugo Date: Sun, 10 May 2026 08:10:27 +0200 Subject: [PATCH] fix(auto): cache lastCommandCtx from any SF command so Ctrl+Y works immediately Previously required /autonomous first. Now any slash command (/next, /chat, /clear etc.) caches the ExtensionCommandContext, so Ctrl+Y YOLO shortcut works on first press after any command interaction. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/resources/extensions/sf/commands/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/resources/extensions/sf/commands/index.js b/src/resources/extensions/sf/commands/index.js index 283f1ccf4..9b4a0fb39 100644 --- a/src/resources/extensions/sf/commands/index.js +++ b/src/resources/extensions/sf/commands/index.js @@ -33,6 +33,17 @@ export function registerSFCommands(pi) { getArgumentCompletions: (prefix) => getSfTopLevelCommandCompletions(command.cmd, prefix), handler: async (args, ctx) => { + // Cache this command ctx so shortcut handlers (Ctrl+Y) can fall back + // to a valid ExtensionCommandContext that has newSession(). + // Import lazily to avoid a circular dep at module load time. + importExtensionModule(import.meta.url, "../auto/session.js").then( + ({ getAutoSession }) => { + const s = getAutoSession(); + if (typeof ctx.newSession === "function") { + s.lastCommandCtx = ctx; + } + }, + ).catch(() => {}); await dispatchDirectSFCommand(command.cmd, args, ctx, pi); }, });